cl-editor
Version:
Lightweight text editor built with svelte + typescript
2 lines (1 loc) • 30.7 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).clEditor=e()}(this,(function(){"use strict";function t(){}function e(t){return t()}function n(){return Object.create(null)}function o(t){t.forEach(e)}function i(t){return"function"==typeof t}function l(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function r(e,...n){if(null==e)return t;const o=e.subscribe(...n);return o.unsubscribe?()=>o.unsubscribe():o}function s(t){let e;return r(t,(t=>e=t))(),e}function c(t,e,n){t.$$.on_destroy.push(r(e,n))}function a(t,e,n){return t.set(n),e}function d(t,e){t.appendChild(e)}function h(t,e,n){const o=function(t){if(!t)return document;const e=t.getRootNode?t.getRootNode():t.ownerDocument;if(e&&e.host)return e;return t.ownerDocument}(t);if(!o.getElementById(e)){const t=g("style");t.id=e,t.textContent=n,function(t,e){d(t.head||t,e)}(o,t)}}function u(t,e,n){t.insertBefore(e,n||null)}function f(t){t.parentNode.removeChild(t)}function p(t,e){for(let n=0;n<t.length;n+=1)t[n]&&t[n].d(e)}function g(t){return document.createElement(t)}function v(t){return document.createTextNode(t)}function b(){return v(" ")}function m(t,e,n,o){return t.addEventListener(e,n,o),()=>t.removeEventListener(e,n,o)}function x(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function y(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function $(t,e){t.value=null==e?"":e}function w(t,e,n,o){t.style.setProperty(e,n,o?"important":"")}function k(t,e,n){t.classList[n?"add":"remove"](e)}class j{constructor(){this.e=this.n=null}c(t){this.h(t)}m(t,e,n=null){this.e||(this.e=g(e.nodeName),this.t=e,this.c(t)),this.i(n)}h(t){this.e.innerHTML=t,this.n=Array.from(this.e.childNodes)}i(t){for(let e=0;e<this.n.length;e+=1)u(this.t,this.n[e],t)}p(t){this.d(),this.h(t),this.i(this.a)}d(){this.n.forEach(f)}}let z;function H(t){z=t}function M(){if(!z)throw new Error("Function called outside component initialization");return z}function E(){const t=M();return(e,n)=>{const o=t.$$.callbacks[e];if(o){const i=function(t,e,n=!1){const o=document.createEvent("CustomEvent");return o.initCustomEvent(t,n,!1,e),o}(e,n);o.slice().forEach((e=>{e.call(t,i)}))}}}const L=[],C=[],T=[],B=[],F=Promise.resolve();let R=!1;function O(t){T.push(t)}let N=!1;const _=new Set;function A(){if(!N){N=!0;do{for(let t=0;t<L.length;t+=1){const e=L[t];H(e),D(e.$$)}for(H(null),L.length=0;C.length;)C.pop()();for(let t=0;t<T.length;t+=1){const e=T[t];_.has(e)||(_.add(e),e())}T.length=0}while(L.length);for(;B.length;)B.pop()();R=!1,N=!1,_.clear()}}function D(t){if(null!==t.fragment){t.update(),o(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(O)}}const I=new Set;function S(t,e){t&&t.i&&(I.delete(t),t.i(e))}function U(t,e,n,o){if(t&&t.o){if(I.has(t))return;I.add(t),undefined.c.push((()=>{I.delete(t),o&&(n&&t.d(1),o())})),t.o(e)}}function q(t){t&&t.c()}function V(t,n,l,r){const{fragment:s,on_mount:c,on_destroy:a,after_update:d}=t.$$;s&&s.m(n,l),r||O((()=>{const n=c.map(e).filter(i);a?a.push(...n):o(n),t.$$.on_mount=[]})),d.forEach(O)}function P(t,e){const n=t.$$;null!==n.fragment&&(o(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function X(t,e){-1===t.$$.dirty[0]&&(L.push(t),R||(R=!0,F.then(A)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function J(e,i,l,r,s,c,a,d=[-1]){const h=z;H(e);const u=e.$$={fragment:null,ctx:null,props:c,update:t,not_equal:s,bound:n(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(i.context||(h?h.$$.context:[])),callbacks:n(),dirty:d,skip_bound:!1,root:i.target||h.$$.root};a&&a(u.root);let p=!1;if(u.ctx=l?l(e,i.props||{},((t,n,...o)=>{const i=o.length?o[0]:n;return u.ctx&&s(u.ctx[t],u.ctx[t]=i)&&(!u.skip_bound&&u.bound[t]&&u.bound[t](i),p&&X(e,t)),n})):[],u.update(),p=!0,o(u.before_update),u.fragment=!!r&&r(u.ctx),i.target){if(i.hydrate){const t=function(t){return Array.from(t.childNodes)}(i.target);u.fragment&&u.fragment.l(t),t.forEach(f)}else u.fragment&&u.fragment.c();i.intro&&S(e.$$.fragment),V(e,i.target,i.anchor,i.customElement),A()}H(h)}class Q{$destroy(){P(this,1),this.$destroy=t}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}let W={};const K=(t,e=null)=>{document.execCommand(t,!1,e)},G=(t,e)=>{if(e=e||(t&&t.tagName?[t.tagName]:[]),!t||!t.parentNode)return e;const n=(t=t.parentNode).tagName;return t.style&&t.getAttribute&&[t.style.textAlign||t.getAttribute("align"),t.style.color||"FONT"===n&&"forecolor",t.style.backgroundColor&&"backcolor"].filter((t=>t)).forEach((t=>e.push(t))),"DIV"===n?e:(e.push(n),G(t,e).filter((t=>null!=t)))},Y=t=>{const e=document.getSelection();if(W.range=null,e.rangeCount){let n,o=W.range=e.getRangeAt(0),i=document.createRange();i.selectNodeContents(t),i.setEnd(o.startContainer,o.startOffset),n=(i+"").length,W.metaRange={start:n,end:n+(o+"").length}}},Z=t=>{let e,n=W.metaRange,o=W.range,i=document.getSelection();if(o){if(n&&n.start!==n.end){let o,i=0,l=[t],r=!1,s=!1;for(e=document.createRange();!s&&(o=l.pop());)if(3===o.nodeType){let t=i+o.length;!r&&n.start>=i&&n.start<=t&&(e.setStart(o,n.start-i),r=!0),r&&n.end>=i&&n.end<=t&&(e.setEnd(o,n.end-i),s=!0),i=t}else{let t=o.childNodes,e=t.length;for(;e>0;)e-=1,l.push(t[e])}}i.removeAllRanges(),i.addRange(e||o)}},tt=(t,e)=>{Array.from(t).forEach((t=>{e.some((e=>e===t.tagName.toLowerCase()))&&(t.children.length&&tt(t.children,e),(t=>{const e=document.createDocumentFragment();for(;t.firstChild;){const n=t.removeChild(t.firstChild);e.appendChild(n)}t.parentNode.replaceChild(e,t)})(t))}))},et=t=>Object.keys(t).map((e=>t[e])),nt=t=>(["style","script","applet","embed","noframes","noscript"].forEach((e=>{t=t.replace(new RegExp(`<${e}.*?${e}(.*?)>`,"gi"),"")})),t),ot=(t,e)=>t===e||!!t.parentElement&&ot(t.parentElement,e),it=[];function lt(e,n=t){let o;const i=new Set;function r(t){if(l(e,t)&&(e=t,o)){const t=!it.length;for(const t of i)t[1](),it.push(t,e);if(t){for(let t=0;t<it.length;t+=2)it[t][0](it[t+1]);it.length=0}}}return{set:r,update:function(t){r(t(e))},subscribe:function(l,s=t){const c=[l,s];return i.add(c),1===i.size&&(o=n(r)||t),l(e),()=>{i.delete(c),0===i.size&&(o(),o=null)}}}}const rt='<svg viewBox="0 0 72 72" width="17px" height="100%"><path d="M31.1 48.9l-6.7 6.7c-.8.8-1.6.9-2.1.9s-1.4-.1-2.1-.9L15 50.4c-1.1-1.1-1.1-3.1 0-4.2l6.1-6.1.2-.2 6.5-6.5c-1.2-.6-2.5-.9-3.8-.9-2.3 0-4.6.9-6.3 2.6L11 41.8c-3.5 3.5-3.5 9.2 0 12.7l5.2 5.2c1.7 1.7 4 2.6 6.3 2.6s4.6-.9 6.3-2.6l6.7-6.7c2.5-2.6 3.1-6.7 1.5-10l-5.9 5.9zM38.7 22.5l6.7-6.7c.8-.8 1.6-.9 2.1-.9s1.4.1 2.1.9l5.2 5.2c1.1 1.1 1.1 3.1 0 4.2l-6.1 6.1-.2.2L42 38c1.2.6 2.5.9 3.8.9 2.3 0 4.6-.9 6.3-2.6l6.7-6.7c3.5-3.5 3.5-9.2 0-12.7l-5.2-5.2c-1.7-1.7-4-2.6-6.3-2.6s-4.6.9-6.3 2.6l-6.7 6.7c-2.7 2.7-3.3 6.9-1.7 10.2l6.1-6.1c0 .1 0 .1 0 0z"></path><path d="M44.2 30.5c.2-.2.4-.6.4-.9 0-.3-.1-.6-.4-.9l-2.3-2.3c-.3-.2-.6-.4-.9-.4-.3 0-.6.1-.9.4L25.9 40.6c-.2.2-.4.6-.4.9 0 .3.1.6.4.9l2.3 2.3c.2.2.6.4.9.4.3 0 .6-.1.9-.4l14.2-14.2zM49.9 55.4h-8.5v-5h8.5v-8.9h5.2v8.9h8.5v5h-8.5v8.9h-5.2v-8.9z"></path></svg>';var st={viewHtml:{icon:'<svg viewBox="0 0 72 72" width="17px" height="100%"><path fill="none" stroke="currentColor" stroke-width="8" stroke-miterlimit="10" d="M26.9 17.9L9 36.2 26.9 54M45 54l17.9-18.3L45 17.9"></path></svg>',title:"View HTML",result:function(){let t=s(this.references),e=s(this.state).actionObj,n=s(this.helper);n.showEditor=!n.showEditor,t.editor.style.display=n.showEditor?"block":"none",t.raw.style.display=n.showEditor?"none":"block",n.showEditor?t.editor.innerHTML=t.raw.value:t.raw.value=t.editor.innerHTML,setTimeout((()=>{Object.keys(e).forEach((t=>e[t].disabled=!n.showEditor)),e.viewHtml.disabled=!1,e.viewHtml.active=!n.showEditor,this.state.update((t=>(t.actionBtns=et(e),t.actionObj=e,t)))}))}},undo:{icon:'<svg viewBox="0 0 72 72" width="17px" height="100%"><path d="M61.2 51.2c0-5.1-2.1-9.7-5.4-13.1-3.3-3.3-8-5.4-13.1-5.4H26.1v-12L10.8 36l15.3 15.3V39.1h16.7c3.3 0 6.4 1.3 8.5 3.5 2.2 2.2 3.5 5.2 3.5 8.5h6.4z"></path></svg>',title:"Undo",result:()=>K("undo")},redo:{icon:'<svg viewBox="0 0 72 72" width="17px" height="100%"><path d="M10.8 51.2c0-5.1 2.1-9.7 5.4-13.1 3.3-3.3 8-5.4 13.1-5.4H46v-12L61.3 36 45.9 51.3V39.1H29.3c-3.3 0-6.4 1.3-8.5 3.5-2.2 2.2-3.5 5.2-3.5 8.5h-6.5z"></path></svg>',title:"Redo",result:()=>K("redo")},b:{icon:"<b>B</b>",title:"Bold",result:()=>K("bold")},i:{icon:"<i>I</i>",title:"Italic",result:()=>K("italic")},u:{icon:"<u>U</u>",title:"Underline",result:()=>K("underline")},strike:{icon:"<strike>S</strike>",title:"Strike-through",result:()=>K("strikeThrough")},sup:{icon:"A<sup>2</sup>",title:"Superscript",result:()=>K("superscript")},sub:{icon:"A<sub>2</sub>",title:"Subscript",result:()=>K("subscript")},h1:{icon:"<b>H<sub>1</sub></b>",title:"Heading 1",result:()=>K("formatBlock","<H1>")},h2:{icon:"<b>H<sub>2</sub></b>",title:"Heading 2",result:()=>K("formatBlock","<H2>")},p:{icon:"¶",title:"Paragraph",result:()=>K("formatBlock","<P>")},blockquote:{icon:"“ ”",title:"Quote",result:()=>K("formatBlock","<BLOCKQUOTE>")},ol:{icon:'<svg viewBox="0 0 72 72" width="17px" height="100%"><path d="M27 14h36v8H27zM27 50h36v8H27zM27 32h36v8H27zM11.8 15.8V22h1.8v-7.8h-1.5l-2.1 1 .3 1.3zM12.1 38.5l.7-.6c1.1-1 2.1-2.1 2.1-3.4 0-1.4-1-2.4-2.7-2.4-1.1 0-2 .4-2.6.8l.5 1.3c.4-.3 1-.6 1.7-.6.9 0 1.3.5 1.3 1.1 0 .9-.9 1.8-2.6 3.3l-1 .9V40H15v-1.5h-2.9zM13.3 53.9c1-.4 1.4-1 1.4-1.8 0-1.1-.9-1.9-2.6-1.9-1 0-1.9.3-2.4.6l.4 1.3c.3-.2 1-.5 1.6-.5.8 0 1.2.3 1.2.8 0 .7-.8.9-1.4.9h-.7v1.3h.7c.8 0 1.6.3 1.6 1.1 0 .6-.5 1-1.4 1-.7 0-1.5-.3-1.8-.5l-.4 1.4c.5.3 1.3.6 2.3.6 2 0 3.2-1 3.2-2.4 0-1.1-.8-1.8-1.7-1.9z"></path></svg>',title:"Ordered List",result:()=>K("insertOrderedList")},ul:{icon:'<svg viewBox="0 0 72 72" width="17px" height="100%"><path d="M27 14h36v8H27zM27 50h36v8H27zM9 50h9v8H9zM9 32h9v8H9zM9 14h9v8H9zM27 32h36v8H27z"></path></svg>',title:"Unordered List",result:()=>K("insertUnorderedList")},hr:{icon:"―",title:"Horizontal Line",result:()=>K("insertHorizontalRule")},left:{icon:'<svg viewBox="0 0 72 72" width="17px" height="100%"><path d="M9 14h54v8H9zM9 50h54v8H9zM9 32h36v8H9z"></path></svg>',title:"Justify left",result:()=>K("justifyLeft")},right:{icon:'<svg viewBox="0 0 72 72" width="17px" height="100%"><path d="M9 14h54v8H9zM9 50h54v8H9zM27 32h36v8H27z"></path></svg>',title:"Justify right",result:()=>K("justifyRight")},center:{icon:'<svg viewBox="0 0 72 72" width="17px" height="100%"><path d="M9 14h54v8H9zM9 50h54v8H9zM18 32h36v8H18z"></path></svg>',title:"Justify center",result:()=>K("justifyCenter")},justify:{icon:'<svg viewBox="0 0 72 72" width="17px" height="100%"><path d="M9 14h54v8H9zM9 50h54v8H9zM9 32h54v8H9z"></path></svg>',title:"Justify full",result:()=>K("justifyFull")},a:{icon:rt,title:"Insert link",result:function(){const t=s(this.state).actionObj,e=s(this.references);if(t.a.active){const e=window.getSelection(),n=document.createRange();n.selectNodeContents(document.getSelection().focusNode),e.removeAllRanges(),e.addRange(n),K("unlink"),t.a.title="Insert link",t.a.icon=rt,this.state.update((e=>(e.actionBtn=et(t),e.actionObj=t,e)))}else Y(e.editor),e.modal.$set({show:!0,event:"linkUrl",title:"Insert link",label:"Url"}),s(this.helper).link||(this.helper.update((t=>(t.link=!0,t))),e.modal.$on("linkUrl",(n=>{Z(e.editor),K("createLink",n.detail),t.a.title="Unlink",t.a.icon='<svg viewBox="0 0 72 72" width="17px" height="100%"><path d="M30.9 49.1l-6.7 6.7c-.8.8-1.6.9-2.1.9s-1.4-.1-2.1-.9l-5.2-5.2c-1.1-1.1-1.1-3.1 0-4.2l6.1-6.1.2-.2 6.5-6.5c-1.2-.6-2.5-.9-3.8-.9-2.3 0-4.6.9-6.3 2.6L10.8 42c-3.5 3.5-3.5 9.2 0 12.7l5.2 5.2c1.7 1.7 4 2.6 6.3 2.6s4.6-.9 6.3-2.6l6.7-6.7C38 50.5 38.6 46.3 37 43l-6.1 6.1zM38.5 22.7l6.7-6.7c.8-.8 1.6-.9 2.1-.9s1.4.1 2.1.9l5.2 5.2c1.1 1.1 1.1 3.1 0 4.2l-6.1 6.1-.2.2-6.5 6.5c1.2.6 2.5.9 3.8.9 2.3 0 4.6-.9 6.3-2.6l6.7-6.7c3.5-3.5 3.5-9.2 0-12.7l-5.2-5.2c-1.7-1.7-4-2.6-6.3-2.6s-4.6.9-6.3 2.6l-6.7 6.7c-2.7 2.7-3.3 6.9-1.7 10.2l6.1-6.1z"></path><path d="M44.1 30.7c.2-.2.4-.6.4-.9 0-.3-.1-.6-.4-.9l-2.3-2.3c-.2-.2-.6-.4-.9-.4-.3 0-.6.1-.9.4L25.8 40.8c-.2.2-.4.6-.4.9 0 .3.1.6.4.9l2.3 2.3c.2.2.6.4.9.4.3 0 .6-.1.9-.4l14.2-14.2zM41.3 55.8v-5h22.2v5H41.3z"></path></svg>',this.state.update((e=>(e.actionBtn=et(t),e.actionObj=t,e)))})))}},image:{icon:'<svg viewBox="0 0 72 72" width="17px" height="100%"><path d="M64 17v38H8V17h56m8-8H0v54h72V9z"></path><path d="M17.5 22C15 22 13 24 13 26.5s2 4.5 4.5 4.5 4.5-2 4.5-4.5-2-4.5-4.5-4.5zM16 50h27L29.5 32zM36 36.2l8.9-8.5L60.2 50H45.9S35.6 35.9 36 36.2z"></path></svg>',title:"Image",result:function(){const t=s(this.references);Y(t.editor),t.modal.$set({show:!0,event:"imageUrl",title:"Insert image",label:"Url"}),s(this.helper).image||(this.helper.update((t=>(t.image=!0,t))),t.modal.$on("imageUrl",(e=>{Z(t.editor),K("insertImage",e.detail)})))}},forecolor:{icon:'<svg viewBox="0 0 72 72" width="17px" height="100%"><path d="M32 15h7.8L56 57.1h-7.9l-4-11.1H27.4l-4 11.1h-7.6L32 15zm-2.5 25.4h12.9L36 22.3h-.2l-6.3 18.1z"></path></svg>',title:"Text color",colorPicker:!0,result:function(){ct.call(this,"foreColor")}},backcolor:{icon:'<svg viewBox="0 0 72 72" width="17px" height="100%"><path d="M36.5 22.3l-6.3 18.1H43l-6.3-18.1z"></path><path d="M9 8.9v54.2h54.1V8.9H9zm39.9 48.2L45 46H28.2l-3.9 11.1h-7.6L32.8 15h7.8l16.2 42.1h-7.9z"></path></svg>',title:"Background color",colorPicker:!0,result:function(){ct.call(this,"backColor")}},removeFormat:{icon:'<svg viewBox="0 0 72 72" width="17px" height="100%"><path d="M58.2 54.6L52 48.5l3.6-3.6 6.1 6.1 6.4-6.4 3.8 3.8-6.4 6.4 6.1 6.1-3.6 3.6-6.1-6.1-6.4 6.4-3.7-3.8 6.4-6.4zM21.7 52.1H50V57H21.7zM18.8 15.2h34.1v6.4H39.5v24.2h-7.4V21.5H18.8v-6.3z"></path></svg>',title:"Remove format",result:function(){const t=s(this.references),e=window.getSelection();if(!e.toString().length){tt(t.editor.children,this.removeFormatTags);const n=document.createRange();n.selectNodeContents(t.editor),e.removeAllRanges(),e.addRange(n)}K("removeFormat"),e.removeAllRanges()}}};const ct=function(t){const e=s(this.references);Y(e.editor),e.colorPicker.$set({show:!0,event:t}),s(this.helper)[t]||(this.helper.update((e=>(e[t]=!0,e))),e.colorPicker.$on(t,(n=>{let o=n.detail;if(o.modal){e.modal.$set({show:!0,event:`${t}Changed`,title:"Text color",label:"foreColor"===t?"Text color":"Background color"});const n=t;s(this.helper)[`${n}Modal`]||(s(this.helper)[`${n}Modal`]=!0,e.modal.$on(`${n}Changed`,(t=>{let o=t.detail;Z(e.editor),K(n,o)})))}else Z(e.editor),K(t,o.color)})))};function at(t){h(t,"svelte-42yfje",'.cl-editor-modal.svelte-42yfje.svelte-42yfje{position:absolute;top:37px;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);max-width:520px;width:100%;height:140px;backface-visibility:hidden;z-index:11}.cl-editor-overlay.svelte-42yfje.svelte-42yfje{position:absolute;background-color:rgba(255,255,255,.5);height:100%;width:100%;left:0;top:0;z-index:10}.modal-box.svelte-42yfje.svelte-42yfje{position:absolute;top:0;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);max-width:500px;width:calc(100% - 20px);padding-bottom:36px;z-index:1;background-color:#FFF;text-align:center;font-size:14px;box-shadow:rgba(0,0,0,.2) 0 2px 3px;-webkit-backface-visibility:hidden;backface-visibility:hidden}.modal-title.svelte-42yfje.svelte-42yfje{font-size:24px;font-weight:700;margin:0 0 20px;padding:2px 0 4px;display:block;border-bottom:1px solid #EEE;color:#333;background:#fbfcfc}.modal-label.svelte-42yfje.svelte-42yfje{display:block;position:relative;margin:15px 12px;height:29px;line-height:29px;overflow:hidden}.modal-label.svelte-42yfje input.svelte-42yfje{position:absolute;top:0;right:0;height:27px;line-height:25px;border:1px solid #DEDEDE;background:#fff;font-size:14px;max-width:330px;width:70%;padding:0 7px;transition:all 150ms}.modal-label.svelte-42yfje input.svelte-42yfje:focus{outline:none}.input-error.svelte-42yfje input.svelte-42yfje{border:1px solid #e74c3c}.input-info.svelte-42yfje.svelte-42yfje{display:block;text-align:left;height:25px;line-height:25px;transition:all 150ms}.input-info.svelte-42yfje span.svelte-42yfje{display:block;color:#69878f;background-color:#fbfcfc;border:1px solid #DEDEDE;padding:1px 7px;width:150px}.input-error.svelte-42yfje .input-info.svelte-42yfje{margin-top:-29px}.input-error.svelte-42yfje .msg-error.svelte-42yfje{color:#e74c3c}.modal-button.svelte-42yfje.svelte-42yfje{position:absolute;bottom:10px;right:0;text-decoration:none;color:#FFF;display:block;width:100px;height:35px;line-height:33px;margin:0 10px;background-color:#333;border:none;cursor:pointer;font-family:"Lato",Helvetica,Verdana,sans-serif;font-size:16px;transition:all 150ms}.modal-submit.svelte-42yfje.svelte-42yfje{right:110px;background:#2bc06a}.modal-reset.svelte-42yfje.svelte-42yfje{color:#555;background:#e6e6e6}')}function dt(e){let n,l,r,s,c,a,h,p,w,j,z,H,M,E,L,C,T,B,F,R,O,N,_=e[2]&&ht();return{c(){n=g("div"),l=b(),r=g("div"),s=g("div"),c=g("span"),a=v(e[3]),h=b(),p=g("form"),w=g("label"),j=g("input"),H=b(),M=g("span"),E=g("span"),L=v(e[4]),C=b(),_&&_.c(),T=b(),B=g("button"),B.textContent="Confirm",F=b(),R=g("button"),R.textContent="Cancel",x(n,"class","cl-editor-overlay svelte-42yfje"),x(c,"class","modal-title svelte-42yfje"),x(j,"name","text"),x(j,"class","svelte-42yfje"),x(E,"class","svelte-42yfje"),x(M,"class","input-info svelte-42yfje"),x(w,"class","modal-label svelte-42yfje"),k(w,"input-error",e[2]),x(B,"class","modal-button modal-submit svelte-42yfje"),x(B,"type","submit"),x(R,"class","modal-button modal-reset svelte-42yfje"),x(R,"type","reset"),x(s,"class","modal-box svelte-42yfje"),x(r,"class","cl-editor-modal svelte-42yfje")},m(o,f){var g,v;u(o,n,f),u(o,l,f),u(o,r,f),d(r,s),d(s,c),d(c,a),d(s,h),d(s,p),d(p,w),d(w,j),e[11](j),$(j,e[1]),d(w,H),d(w,M),d(M,E),d(E,L),d(M,C),_&&_.m(M,null),d(p,T),d(p,B),d(p,F),d(p,R),O||(N=[m(n,"click",e[8]),m(j,"keyup",e[9]),(v=z=e[6].call(null,j),v&&i(v.destroy)?v.destroy:t),m(j,"input",e[12]),m(R,"click",e[8]),m(p,"submit",(g=e[13],function(t){return t.preventDefault(),g.call(this,t)}))],O=!0)},p(t,e){8&e&&y(a,t[3]),2&e&&j.value!==t[1]&&$(j,t[1]),16&e&&y(L,t[4]),t[2]?_||(_=ht(),_.c(),_.m(M,null)):_&&(_.d(1),_=null),4&e&&k(w,"input-error",t[2])},d(t){t&&f(n),t&&f(l),t&&f(r),e[11](null),_&&_.d(),O=!1,o(N)}}}function ht(t){let e;return{c(){e=g("span"),e.textContent="Required",x(e,"class","msg-error svelte-42yfje")},m(t,n){u(t,e,n)},d(t){t&&f(e)}}}function ut(e){let n,o=e[0]&&dt(e);return{c(){o&&o.c(),n=v("")},m(t,e){o&&o.m(t,e),u(t,n,e)},p(t,[e]){t[0]?o?o.p(t,e):(o=dt(t),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null)},i:t,o:t,d(t){o&&o.d(t),t&&f(n)}}}function ft(t,e,n){let o=new E,{show:i=!1}=e,{text:l=""}=e,{event:r=""}=e,{title:s=""}=e,{label:c=""}=e,{error:a=!1}=e,d={};function h(){l?(o(r,l),u()):(n(2,a=!0),d.text.focus())}function u(){n(0,i=!1),n(1,l=""),n(2,a=!1)}return t.$$set=t=>{"show"in t&&n(0,i=t.show),"text"in t&&n(1,l=t.text),"event"in t&&n(10,r=t.event),"title"in t&&n(3,s=t.title),"label"in t&&n(4,c=t.label),"error"in t&&n(2,a=t.error)},t.$$.update=()=>{33&t.$$.dirty&&i&&setTimeout((()=>{d.text.focus()}))},[i,l,a,s,c,d,t=>{t.type=r.includes("Color")?"color":"text"},h,u,function(){n(2,a=!1)},r,function(t){C[t?"unshift":"push"]((()=>{d.text=t,n(5,d)}))},function(){l=this.value,n(1,l)},t=>h()]}class pt extends Q{constructor(t){super(),J(this,t,ft,ut,l,{show:0,text:1,event:10,title:3,label:4,error:2},at)}get show(){return this.$$.ctx[0]}set show(t){this.$$set({show:t}),A()}get text(){return this.$$.ctx[1]}set text(t){this.$$set({text:t}),A()}get event(){return this.$$.ctx[10]}set event(t){this.$$set({event:t}),A()}get title(){return this.$$.ctx[3]}set title(t){this.$$set({title:t}),A()}get label(){return this.$$.ctx[4]}set label(t){this.$$set({label:t}),A()}get error(){return this.$$.ctx[2]}set error(t){this.$$set({error:t}),A()}}function gt(t){h(t,"svelte-njq4pk",'.color-picker-wrapper.svelte-njq4pk{border:1px solid #ecf0f1;border-top:none;background:#FFF;box-shadow:rgba(0,0,0,.1) 0 2px 3px;width:290px;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%);padding:0;position:absolute;top:37px;z-index:11}.color-picker-overlay.svelte-njq4pk{position:absolute;background-color:rgba(255,255,255,.5);height:100%;width:100%;left:0;top:0;z-index:10}.color-picker-btn.svelte-njq4pk{display:block;position:relative;float:left;height:20px;width:20px;border:1px solid #333;padding:0;margin:2px;line-height:35px;text-decoration:none;background:#FFF;color:#333!important;cursor:pointer;text-align:left;font-size:15px;transition:all 150ms;line-height:20px;padding:0px 5px}.color-picker-btn.svelte-njq4pk:hover::after{content:" ";display:block;position:absolute;top:-5px;left:-5px;height:27px;width:27px;background:inherit;border:1px solid #FFF;box-shadow:#000 0 0 2px;z-index:10}')}function vt(t,e,n){const o=t.slice();return o[8]=e[n],o}function bt(t){let e,n,o,i,l=(t[8].text||"")+"";function r(...e){return t[6](t[8],...e)}return{c(){e=g("button"),n=v(l),x(e,"type","button"),x(e,"class","color-picker-btn svelte-njq4pk"),w(e,"background-color",t[8].color)},m(t,l){u(t,e,l),d(e,n),o||(i=m(e,"click",r),o=!0)},p(o,i){t=o,2&i&&l!==(l=(t[8].text||"")+"")&&y(n,l),2&i&&w(e,"background-color",t[8].color)},d(t){t&&f(e),o=!1,i()}}}function mt(e){let n,o,i,l,r,s,c=e[1],a=[];for(let t=0;t<c.length;t+=1)a[t]=bt(vt(e,c,t));return{c(){n=g("div"),o=g("div"),i=b(),l=g("div");for(let t=0;t<a.length;t+=1)a[t].c();x(o,"class","color-picker-overlay svelte-njq4pk"),x(l,"class","color-picker-wrapper svelte-njq4pk"),w(n,"display",e[0]?"block":"none")},m(t,c){u(t,n,c),d(n,o),d(n,i),d(n,l);for(let t=0;t<a.length;t+=1)a[t].m(l,null);r||(s=m(o,"click",e[2]),r=!0)},p(t,[e]){if(10&e){let n;for(c=t[1],n=0;n<c.length;n+=1){const o=vt(t,c,n);a[n]?a[n].p(o,e):(a[n]=bt(o),a[n].c(),a[n].m(l,null))}for(;n<a.length;n+=1)a[n].d(1);a.length=c.length}1&e&&w(n,"display",t[0]?"block":"none")},i:t,o:t,d(t){t&&f(n),p(a,t),r=!1,s()}}}function xt(t,e,n){const o=new E;let{show:i=!1}=e,{btns:l=[]}=e,{event:r=""}=e,{colors:s=[]}=e;function c(){n(0,i=!1)}function a(t){o(r,t),c()}return t.$$set=t=>{"show"in t&&n(0,i=t.show),"btns"in t&&n(1,l=t.btns),"event"in t&&n(4,r=t.event),"colors"in t&&n(5,s=t.colors)},t.$$.update=()=>{32&t.$$.dirty&&n(1,l=s.map((t=>({color:t}))).concat([{text:"#",modal:!0}]))},[i,l,c,a,r,s,(t,e)=>a(t)]}class yt extends Q{constructor(t){super(),J(this,t,xt,mt,l,{show:0,btns:1,event:4,colors:5},gt)}}const $t=function(t){const{subscribe:e,set:n,update:o}=lt({actionBtns:[],actionObj:{}});return{name:t,set:n,update:o,subscribe:e}};function wt(t){h(t,"svelte-1a534py",".cl.svelte-1a534py .svelte-1a534py{box-sizing:border-box}.cl.svelte-1a534py.svelte-1a534py{box-shadow:0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1);box-sizing:border-box;width:100%;position:relative}.cl-content.svelte-1a534py.svelte-1a534py{height:300px;outline:0;overflow-y:auto;padding:10px;width:100%;background-color:white}.cl-actionbar.svelte-1a534py.svelte-1a534py{background-color:#ecf0f1;border-bottom:1px solid rgba(10, 10, 10, 0.1);width:100%}.cl-button.svelte-1a534py.svelte-1a534py{background-color:transparent;border:none;cursor:pointer;height:35px;outline:0;width:35px;vertical-align:top;position:relative}.cl-button.svelte-1a534py.svelte-1a534py:hover,.cl-button.active.svelte-1a534py.svelte-1a534py{background-color:#fff}.cl-button.svelte-1a534py.svelte-1a534py:disabled{opacity:.5;pointer-events:none}.cl-textarea.svelte-1a534py.svelte-1a534py{display:none;max-width:100%;min-width:100%;border:none;padding:10px}.cl-textarea.svelte-1a534py.svelte-1a534py:focus{outline:none}")}function kt(t,e,n){const o=t.slice();return o[38]=e[n],o}function jt(t){let e,n,o,i,l,r,s,c,a=t[38].icon+"";function h(...e){return t[24](t[38],...e)}return{c(){e=g("button"),n=new j,o=b(),n.a=o,x(e,"type","button"),x(e,"class",i="cl-button "+(t[38].active?"active":"")+" svelte-1a534py"),x(e,"title",l=t[38].title),e.disabled=r=t[38].disabled},m(t,i){u(t,e,i),n.m(a,e),d(e,o),s||(c=m(e,"click",h),s=!0)},p(o,s){t=o,16&s[0]&&a!==(a=t[38].icon+"")&&n.p(a),16&s[0]&&i!==(i="cl-button "+(t[38].active?"active":"")+" svelte-1a534py")&&x(e,"class",i),16&s[0]&&l!==(l=t[38].title)&&x(e,"title",l),16&s[0]&&r!==(r=t[38].disabled)&&(e.disabled=r)},d(t){t&&f(e),s=!1,c()}}}function zt(t){let e,n,i,l,r,s,c,a,h,v,y,$,k,j=t[4].actionBtns,z=[];for(let e=0;e<j.length;e+=1)z[e]=jt(kt(t,j,e));a=new pt({props:{}}),t[31](a);let H={colors:t[2]};return v=new yt({props:H}),t[32](v),{c(){e=g("div"),n=g("div");for(let t=0;t<z.length;t+=1)z[t].c();i=b(),l=g("div"),r=b(),s=g("textarea"),c=b(),q(a.$$.fragment),h=b(),q(v.$$.fragment),x(n,"class","cl-actionbar svelte-1a534py"),x(l,"id",t[1]),x(l,"class","cl-content svelte-1a534py"),w(l,"height",t[0]),x(l,"contenteditable","true"),x(s,"class","cl-textarea svelte-1a534py"),w(s,"max-height",t[0]),w(s,"min-height",t[0]),x(e,"class","cl svelte-1a534py")},m(o,f){u(o,e,f),d(e,n);for(let t=0;t<z.length;t+=1)z[t].m(n,null);d(e,i),d(e,l),t[25](l),d(e,r),d(e,s),t[30](s),d(e,c),V(a,e,null),d(e,h),V(v,e,null),t[33](e),y=!0,$||(k=[m(window,"click",t[23]),m(l,"input",t[26]),m(l,"mouseup",t[27]),m(l,"keyup",t[28]),m(l,"paste",t[29])],$=!0)},p(t,e){if(272&e[0]){let o;for(j=t[4].actionBtns,o=0;o<j.length;o+=1){const i=kt(t,j,o);z[o]?z[o].p(i,e):(z[o]=jt(i),z[o].c(),z[o].m(n,null))}for(;o<z.length;o+=1)z[o].d(1);z.length=j.length}(!y||2&e[0])&&x(l,"id",t[1]),(!y||1&e[0])&&w(l,"height",t[0]),(!y||1&e[0])&&w(s,"max-height",t[0]),(!y||1&e[0])&&w(s,"min-height",t[0]);a.$set({});const o={};4&e[0]&&(o.colors=t[2]),v.$set(o)},i(t){y||(S(a.$$.fragment,t),S(v.$$.fragment,t),y=!0)},o(t){U(a.$$.fragment,t),U(v.$$.fragment,t),y=!1},d(n){n&&f(e),p(z,n),t[25](null),t[30](null),t[31](null),P(a),t[32](null),P(v),t[33](null),$=!1,o(k)}}}const Ht=[];function Mt(t,e,n){let o,i,l,r=new E,{actions:s=[]}=e,{height:d="300px"}=e,{html:h=""}=e,{contentId:u=""}=e,{colors:f=["#ffffff","#000000","#eeece1","#1f497d","#4f81bd","#c0504d","#9bbb59","#8064a2","#4bacc6","#f79646","#ffff00","#f2f2f2","#7f7f7f","#ddd9c3","#c6d9f0","#dbe5f1","#f2dcdb","#ebf1dd","#e5e0ec","#dbeef3","#fdeada","#fff2ca","#d8d8d8","#595959","#c4bd97","#8db3e2","#b8cce4","#e5b9b7","#d7e3bc","#ccc1d9","#b7dde8","#fbd5b5","#ffe694","#bfbfbf","#3f3f3f","#938953","#548dd4","#95b3d7","#d99694","#c3d69b","#b2a2c7","#b7dde8","#fac08f","#f2c314","#a5a5a5","#262626","#494429","#17365d","#366092","#953734","#76923c","#5f497a","#92cddc","#e36c09","#c09100","#7f7f7f","#0c0c0c","#1d1b10","#0f243e","#244061","#632423","#4f6128","#3f3151","#31859b","#974806","#7f6000"]}=e,{removeFormatTags:p=["h1","h2","blockquote"]}=e,g=lt({foreColor:!1,backColor:!1,foreColorModal:!1,backColorModal:!1,image:!1,link:!1,showEditor:!0,blurActive:!1});c(t,g,(t=>n(34,i=t))),Ht.push({});let v="editor_"+Ht.length,b=$t(v);c(t,b,(t=>n(4,l=t)));let m=lt({});c(t,m,(t=>n(3,o=t))),a(b,l.actionObj=((t,e=[])=>{if(e&&e.length){const n={};return e.forEach((e=>{"string"==typeof e?n[e]=Object.assign({},t[e]):t[e.name]?n[e.name]=Object.assign(t[e.name],e):n[e.name]=Object.assign({},e)})),n}return t})(st,s),l);let x={exec:H,getHtml:L,getText:T,setHtml:B,saveRange:F,restoreRange:R,helper:g,references:m,state:b,removeFormatTags:p};var y;function $(t){o.editor.focus(),F(o.editor),R(o.editor),t.result.call(x),w()}function w(t){const e=t?[]:G(document.getSelection().focusNode);Object.keys(l.actionObj).forEach((t=>a(b,l.actionObj[t].active=!1,l))),e.forEach((t=>(l.actionObj[t.toLowerCase()]||{}).active=!0)),a(b,l.actionBtns=et(l.actionObj),l),b.set(l)}function k(t){t.preventDefault(),H("insertHTML",t.clipboardData.getData("text/html")?(t=>{const e=t.match(/<!--StartFragment-->(.*?)<!--EndFragment-->/);let n=e&&e[1]||t;return n=n.replace(/\r?\n|\r/g," ").replace(/<!--(.*?)-->/g,"").replace(new RegExp("<(/)*(meta|link|span|\\?xml:|st1:|o:|font|w:sdt)(.*?)>","gi"),"").replace(/<!\[if !supportLists\]>(.*?)<!\[endif\]>/gi,"").replace(/style="[^"]*"/gi,"").replace(/style='[^']*'/gi,"").replace(/ /gi," ").replace(/>(\s+)</g,"><").replace(/class="[^"]*"/gi,"").replace(/class='[^']*'/gi,"").replace(/<[^/].*?>/g,(t=>t.split(/[ >]/g)[0]+">")).trim(),n=nt(n),n})(t.clipboardData.getData("text/html")):t.clipboardData.getData("text"))}function j(t){r("change",t)}function z(t){!ot(t.target,o.editorWrapper)&&i.blurActive&&r("blur",t),a(g,i.blurActive=!0,i)}function H(t,e){K(t,e)}function L(t){return t?nt(o.editor.innerHTML):o.editor.innerHTML}function T(){return o.editor.innerText}function B(t,e){const n=e?nt(t):t||"";a(m,o.editor.innerHTML=n,o),a(m,o.raw.value=n,o)}function F(){Y(o.editor)}function R(){Z(o.editor)}!function(t,e){M().$$.context.set(t,e)}(v,x),y=()=>{a(b,l.actionBtns=et(l.actionObj),l),B(h)},M().$$.on_mount.push(y);const O=o;return t.$$set=t=>{"actions"in t&&n(13,s=t.actions),"height"in t&&n(0,d=t.height),"html"in t&&n(14,h=t.html),"contentId"in t&&n(1,u=t.contentId),"colors"in t&&n(2,f=t.colors),"removeFormatTags"in t&&n(15,p=t.removeFormatTags)},[d,u,f,o,l,g,b,m,$,w,k,j,z,s,h,p,H,L,T,B,F,R,O,t=>z(t),(t,e)=>$(t),function(t){C[t?"unshift":"push"]((()=>{o.editor=t,m.set(o)}))},t=>j(t.target.innerHTML),()=>w(),()=>w(),t=>k(t),function(t){C[t?"unshift":"push"]((()=>{o.raw=t,m.set(o)}))},function(t){C[t?"unshift":"push"]((()=>{o.modal=t,m.set(o)}))},function(t){C[t?"unshift":"push"]((()=>{o.colorPicker=t,m.set(o)}))},function(t){C[t?"unshift":"push"]((()=>{o.editorWrapper=t,m.set(o)}))}]}return class extends Q{constructor(t){super(),J(this,t,Mt,zt,l,{actions:13,height:0,html:14,contentId:1,colors:2,removeFormatTags:15,exec:16,getHtml:17,getText:18,setHtml:19,saveRange:20,restoreRange:21,refs:22},wt,[-1,-1])}get actions(){return this.$$.ctx[13]}set actions(t){this.$$set({actions:t}),A()}get height(){return this.$$.ctx[0]}set height(t){this.$$set({height:t}),A()}get html(){return this.$$.ctx[14]}set html(t){this.$$set({html:t}),A()}get contentId(){return this.$$.ctx[1]}set contentId(t){this.$$set({contentId:t}),A()}get colors(){return this.$$.ctx[2]}set colors(t){this.$$set({colors:t}),A()}get removeFormatTags(){return this.$$.ctx[15]}set removeFormatTags(t){this.$$set({removeFormatTags:t}),A()}get exec(){return this.$$.ctx[16]}get getHtml(){return this.$$.ctx[17]}get getText(){return this.$$.ctx[18]}get setHtml(){return this.$$.ctx[19]}get saveRange(){return this.$$.ctx[20]}get restoreRange(){return this.$$.ctx[21]}get refs(){return this.$$.ctx[22]}}}));