6 lines
7.5 KiB
JavaScript
6 lines
7.5 KiB
JavaScript
!function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=4)}([function(t,e,n){var o;
|
|
/*!
|
|
Copyright (c) 2018 Jed Watson.
|
|
Licensed under the MIT License (MIT), see
|
|
http://jedwatson.github.io/classnames
|
|
*/!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var t=[],e=0;e<arguments.length;e++){var o=arguments[e];if(o){var c=typeof o;if("string"===c||"number"===c)t.push(o);else if(Array.isArray(o)){if(o.length){var i=r.apply(null,o);i&&t.push(i)}}else if("object"===c)if(o.toString===Object.prototype.toString)for(var u in o)n.call(o,u)&&o[u]&&t.push(u);else t.push(o.toString())}}return t.join(" ")}t.exports?(r.default=r,t.exports=r):void 0===(o=function(){return r}.apply(e,[]))||(t.exports=o)}()},function(t,e,n){!function(t){"use strict";function e(t,e,n,o){var r,c=!1,i=0;function u(){r&&clearTimeout(r)}function a(){for(var a=arguments.length,l=new Array(a),f=0;f<a;f++)l[f]=arguments[f];var s=this,p=Date.now()-i;function y(){i=Date.now(),n.apply(s,l)}function b(){r=void 0}c||(o&&!r&&y(),u(),void 0===o&&p>t?y():!0!==e&&(r=setTimeout(o?b:y,void 0===o?t-p:t)))}return"boolean"!=typeof e&&(o=n,n=e,e=void 0),a.cancel=function(){u(),c=!0},a}t.debounce=function(t,n,o){return void 0===o?e(t,n,!1):e(t,o,!1!==n)},t.throttle=e,Object.defineProperty(t,"__esModule",{value:!0})}(e)},,,function(t,e,n){t.exports=n(5)},function(t,e,n){"use strict";n.r(e);var o=n(0),r=n.n(o),c=n(1);function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function f(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,o=y(t);if(e){var r=y(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return s(this,n)}}function s(t,e){return!e||"object"!==i(e)&&"function"!=typeof e?p(t):e}function p(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function y(t){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var b=wp.i18n.__,d=wp.apiFetch,h=wp.element,m=h.Component,v=h.Fragment,w=h.RawHTML,g=wp.components,O=g.Disabled,_=g.Placeholder,j=g.Spinner,S=wp.data.withSelect,P=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&l(t,e)}(i,t);var e,n,o,r=f(i);function i(){var t;return u(this,i),(t=r.apply(this,arguments)).state={html:"",data:"",loading:!1},t.maybeFetchToc=Object(c.debounce)(300,t.maybeFetchToc.bind(p(t))),t}return e=i,(n=[{key:"componentDidMount",value:function(){this.maybeFetchToc(this.props)}},{key:"componentDidUpdate",value:function(){this.maybeFetchToc(this.props)}},{key:"maybeFetchToc",value:function(t){var e=this,n=t.attributes,o=t.titlesData,r=t.getEditedPostContent,c=n.title,i=n.depth,u=n.minCount,a=n.minCharacters,l=n.btnHide,f=n.defaultState;if(!this.state.loading){var s="".concat(c," ").concat(i," ").concat(u," ").concat(a," ").concat(l," ").concat(f," ").concat(o);if(this.state.data!==s){this.setState({loading:!0});var p={path:"/powerkit-toc/v1/get",method:"post",data:{content:r(),params:{title:c,depth:i,min_count:u,min_characters:a,btn_hide:l,default_state:f}}};d(p).then((function(t){var n={loading:!1,data:s};"string"==typeof t&&(n.html=t),e.setState(n)}))}}}},{key:"render",value:function(){var t=this.state,e=t.html,n=t.loading;return wp.element.createElement(v,null,n?wp.element.createElement(_,null,wp.element.createElement(j,null)):"",!n&&e?wp.element.createElement(O,null,wp.element.createElement(w,null,e)):"",n||e?"":wp.element.createElement(_,null,b("There is no table of contents for this post.")))}}])&&a(e.prototype,n),o&&a(e,o),i}(m),E=S((function(t,e){var n=t("core/editor"),o=n.getEditedPostContent,r=n.getBlocks,c="";return r().forEach((function(t){"core/heading"===t.name&&(c+=t.attributes.level+t.attributes.content)})),{getEditedPostContent:o,getBlocks:r,titlesData:c}}))(P);function R(t){return(R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function T(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function k(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function x(t,e){return(x=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function C(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,o=B(t);if(e){var r=B(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return F(this,n)}}function F(t,e){return!e||"object"!==R(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function B(t){return(B=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var D=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&x(t,e)}(i,t);var e,n,o,c=C(i);function i(){return T(this,i),c.apply(this,arguments)}return e=i,(n=[{key:"render",value:function(){var t=this.props.className,e=this.props.attributes.canvasClassName;return t=r()("pk-block-toc",e,t),wp.element.createElement("div",{className:t},wp.element.createElement(E,this.props))}}])&&k(e.prototype,n),o&&k(e,o),i}(wp.element.Component);(0,wp.hooks.addFilter)("canvas.customBlock.editRender","canvas/toc/editRender",(function(t,e){return"canvas/toc"===e.name?wp.element.createElement(D,e):t}))}]); |