2 lines
7.1 KiB
JavaScript
2 lines
7.1 KiB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(l){if("default"!==l){var n=Object.getOwnPropertyDescriptor(e,l);Object.defineProperty(t,l,n.get?n:{enumerable:!0,get:function(){return e[l]}})}})),t.default=e,Object.freeze(t)}var r=l(e);function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var l=0;l<t.length;l++){var n=t[l];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e,t){if(t&&("object"===i(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return s(e)}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}function d(e,t,l){return t in e?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function m(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),l.push.apply(l,n)}return l}function b(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?m(Object(l),!0).forEach((function(t){d(e,t,l[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):m(Object(l)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))}))}return e}function y(){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(e){return!1}}var h=function(l){c(v,e.Component);var u,i,s,d,m,h=(u=v,i=y(),function(){var e,t=f(u);if(i){var l=f(this).constructor;e=Reflect.construct(t,arguments,l)}else e=t.apply(this,arguments);return p(this,e)});function v(){return o(this,v),h.apply(this,arguments)}return s=v,(d=[{key:"getQuill",value:function(){return this.quill}},{key:"componentDidMount",value:function(){var e=this;Promise.resolve().then((function(){return n(require("quill"))})).then((function(l){l&&l.default&&t.DomHandler.isExist(e.editorElement)&&(e.quill=new l.default(e.editorElement,{modules:b({toolbar:!!e.props.showHeader&&e.toolbarElement},e.props.modules),placeholder:e.props.placeholder,readOnly:e.props.readOnly,theme:e.props.theme,formats:e.props.formats}),e.props.value&&e.quill.setContents(e.quill.clipboard.convert(e.props.value)),e.quill.on("text-change",(function(t,l){var n=e.editorElement.children[0].innerHTML,r=e.quill.getText();"<p><br></p>"===n&&(n=null),e.props.onTextChange&&e.props.onTextChange({htmlValue:n,textValue:r,delta:t,source:l})})),e.quill.on("selection-change",(function(t,l,n){e.props.onSelectionChange&&e.props.onSelectionChange({range:t,oldRange:l,source:n})})))})).then((function(){e.quill&&e.quill.getModule("toolbar")&&e.props.onLoad&&e.props.onLoad(e.quill)}))}},{key:"componentDidUpdate",value:function(e){this.props.value!==e.value&&this.quill&&!this.quill.hasFocus()&&(this.props.value?this.quill.setContents(this.quill.clipboard.convert(this.props.value)):this.quill.setText(""))}},{key:"render",value:function(){var e=this,l=t.classNames("p-component p-editor-container",this.props.className),n=null;return!1===this.props.showHeader?(n="",this.toolbarElement=void 0):n=this.props.headerTemplate?r.default.createElement("div",{ref:function(t){return e.toolbarElement=t},className:"p-editor-toolbar"},this.props.headerTemplate):r.default.createElement("div",{ref:function(t){return e.toolbarElement=t},className:"p-editor-toolbar"},r.default.createElement("span",{className:"ql-formats"},r.default.createElement("select",{className:"ql-header",defaultValue:"0"},r.default.createElement("option",{value:"1"},"Heading"),r.default.createElement("option",{value:"2"},"Subheading"),r.default.createElement("option",{value:"0"},"Normal")),r.default.createElement("select",{className:"ql-font"},r.default.createElement("option",null),r.default.createElement("option",{value:"serif"}),r.default.createElement("option",{value:"monospace"}))),r.default.createElement("span",{className:"ql-formats"},r.default.createElement("button",{type:"button",className:"ql-bold","aria-label":"Bold"}),r.default.createElement("button",{type:"button",className:"ql-italic","aria-label":"Italic"}),r.default.createElement("button",{type:"button",className:"ql-underline","aria-label":"Underline"})),r.default.createElement("span",{className:"ql-formats"},r.default.createElement("select",{className:"ql-color"}),r.default.createElement("select",{className:"ql-background"})),r.default.createElement("span",{className:"ql-formats"},r.default.createElement("button",{type:"button",className:"ql-list",value:"ordered","aria-label":"Ordered List"}),r.default.createElement("button",{type:"button",className:"ql-list",value:"bullet","aria-label":"Unordered List"}),r.default.createElement("select",{className:"ql-align"},r.default.createElement("option",{defaultValue:!0}),r.default.createElement("option",{value:"center"}),r.default.createElement("option",{value:"right"}),r.default.createElement("option",{value:"justify"}))),r.default.createElement("span",{className:"ql-formats"},r.default.createElement("button",{type:"button",className:"ql-link","aria-label":"Insert Link"}),r.default.createElement("button",{type:"button",className:"ql-image","aria-label":"Insert Image"}),r.default.createElement("button",{type:"button",className:"ql-code-block","aria-label":"Insert Code Block"})),r.default.createElement("span",{className:"ql-formats"},r.default.createElement("button",{type:"button",className:"ql-clean","aria-label":"Remove Styles"}))),r.default.createElement("div",{id:this.props.id,className:l},n,r.default.createElement("div",{ref:function(t){return e.editorElement=t},className:"p-editor-content",style:this.props.style}))}}])&&a(s.prototype,d),m&&a(s,m),Object.defineProperty(s,"prototype",{writable:!1}),v}();d(h,"defaultProps",{id:null,value:null,style:null,className:null,placeholder:null,readOnly:!1,modules:null,formats:null,theme:"snow",showHeader:!0,headerTemplate:null,onTextChange:null,onSelectionChange:null,onLoad:null}),exports.Editor=h;
|