lakelib 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lake.css +7 -2
- package/dist/lake.min.js +3 -3
- package/dist/lake.min.js.map +1 -1
- package/lib/lake.css +7 -2
- package/lib/lake.js +23 -2
- package/lib/lake.js.map +1 -1
- package/package.json +1 -1
package/dist/lake.css
CHANGED
|
@@ -872,6 +872,8 @@ lake-box[name="image"] .lake-box-selected .lake-image-error {
|
|
|
872
872
|
box-sizing: content-box;
|
|
873
873
|
border: 1px solid transparent;
|
|
874
874
|
border-radius: 4px;
|
|
875
|
+
cursor: default;
|
|
876
|
+
user-select: none;
|
|
875
877
|
}
|
|
876
878
|
.lake-file .lake-file-info {
|
|
877
879
|
display: flex;
|
|
@@ -888,10 +890,13 @@ lake-box[name="image"] .lake-box-selected .lake-image-error {
|
|
|
888
890
|
color: var(--link-color);
|
|
889
891
|
}
|
|
890
892
|
lake-box[name="file"] .lake-box-hovered .lake-file {
|
|
891
|
-
|
|
893
|
+
background-color: var(--box-background-color);
|
|
894
|
+
}
|
|
895
|
+
lake-box[name="file"] .lake-box-selected .lake-file {
|
|
896
|
+
background-color: var(--selection-background-color);
|
|
892
897
|
}
|
|
893
898
|
lake-box[name="file"] .lake-box-focused .lake-file {
|
|
894
|
-
|
|
899
|
+
background-color: var(--selection-background-color);
|
|
895
900
|
}
|
|
896
901
|
/* uploading status */
|
|
897
902
|
.lake-file-uploading .lake-progress {
|
package/dist/lake.min.js
CHANGED
|
@@ -2,7 +2,7 @@ var Lake=function(t){"use strict";class e extends HTMLElement{}void 0!==customEl
|
|
|
2
2
|
<span class="lake-box-strip"><br /></span>
|
|
3
3
|
<div class="lake-box-container" contenteditable="false"></div>
|
|
4
4
|
<span class="lake-box-strip"><br /></span>
|
|
5
|
-
`;class Jt{constructor(t){if(this.event=new Wt,"string"==typeof t){const e=Ut.get(t);if(void 0===e)throw new Error(`Box '${t}' has not been defined yet.`);const i=r(e.type),n=r(e.name);this.node=L(a`<lake-box type="${i}" name="${n}"></lake-box>`),e.value&&(this.value=e.value)}else{this.node=L(t);const e=Ut.get(this.name);if(void 0===e)throw new Error(`Box '${this.name}' has not been defined yet.`);e.value&&!this.node.hasAttr("value")&&(this.value=e.value)}Kt[this.node.id]||(Kt[this.node.id]={}),Gt[this.node.id]||(Gt[this.node.id]={setup:[],cleanup:[]})}addFramework(){let t=this.getContainer();0===t.length?(this.node.html(Xt),t=this.getContainer()):(t.off("mouseenter"),t.off("mouseleave"),t.off("click")),t.on("mouseenter",(()=>{t.hasClass("lake-box-selected")||t.hasClass("lake-box-focused")||t.hasClass("lake-box-activated")||t.addClass("lake-box-hovered")})),t.on("mouseleave",(()=>{t.removeClass("lake-box-hovered")})),t.on("click",(()=>{B(`Box '${this.name}' (id = ${this.node.id}) value:`),B(this.value)})),"block"===this.type&&t.attr("draggable","true")}get type(){return this.node.attr("type")}get name(){return this.node.attr("name")}get value(){const t=this.node.attr("value");return""===t?{}:JSON.parse(Vt(t))}set value(t){this.node.attr("value",$t(JSON.stringify(t)))}updateValue(t,e){const i=this.value;if("string"==typeof t)i[t]=e;else for(const e of Object.keys(t))i[e]=t[e];this.value=i}getData(t){return Kt[this.node.id][t]}setData(t,e){Kt[this.node.id][t]=e}getEditor(){const t=this.node.closest("div[contenteditable]");return t.length>0?qt.get(t.id):void 0}getContainer(){return this.node.find(".lake-box-container")}useEffect(t){Gt[this.node.id].setup.push(t)}render(){Gt[this.node.id].setup=[],Gt[this.node.id].cleanup=[];const t=Ut.get(this.name);if(void 0===t)return;this.addFramework();const e=t.render(this);if(void 0!==e){const t=this.getContainer(),i=t.clone(!1);i.append(e),ht(t,i)}for(const t of Gt[this.node.id].setup){const e=t();void 0!==e&&Gt[this.node.id].cleanup.push(e)}B(`Box '${this.name}' (id = ${this.node.id}) rendered`)}unmount(){this.event.emit("blur");for(const t of Gt[this.node.id].cleanup)t();Kt[this.node.id]={},Gt[this.node.id].setup=[],Gt[this.node.id].cleanup=[],this.event.removeAllListeners(),this.node.empty(),B(`Box '${this.name}' (id = ${this.node.id}) unmounted`)}getHTML(){const t=Ut.get(this.name);return void 0===t?"":void 0===t.html?this.node.outerHTML():t.html(this)}}function Yt(t){if("string"==typeof t)return new Jt(t);const e=(t=L(t)).closestContainer();if(0===e.length)return new Jt(t);let i=pt.get(e.id);i||(i=new Map,pt.set(e.id,i));let n=i.get(t.id);return n||(n=new Jt(t),i.set(n.node.id,n),n)}function Qt(t){const e=t.responseText||t.response;if(!e)return e;try{return JSON.parse(e)}catch(t){return e}}function te(t){const e=new XMLHttpRequest;t.onProgress&&e.upload&&(e.upload.onprogress=e=>{e.total>0&&(e.percent=e.loaded/e.total*100),t.onProgress&&t.onProgress(e)});const i=new FormData,n=t.data||{};Object.keys(n).forEach((t=>{const e=n[t];Array.isArray(e)?e.forEach((e=>{i.append(`${t}[]`,e)})):i.append(t,e)}));const s=t.filename||"file";t.file instanceof Blob?i.append(s,t.file,t.file.name):i.append(s,t.file),e.onerror=e=>{t.onError&&t.onError(e)},e.onload=()=>{if(e.status<200||e.status>=300){if(!t.onError)return;return t.onError(function(t,e){const i=`Cannot ${t.method} ${t.action} ${e.status}'`,n=new Error(i);return n.status=e.status,n.method=t.method,n.url=t.action,n}(t,e),Qt(e))}if(t.onSuccess)return t.onSuccess(Qt(e),e)},e.open(t.method,t.action,!0),t.withCredentials&&"withCredentials"in e&&(e.withCredentials=!0);const o=t.headers||{};return null!==o["X-Requested-With"]&&e.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(o).forEach((t=>{null!==o[t]&&e.setRequestHeader(t,o[t])})),e.send(i),e}var ee=Object.freeze({__proto__:null,appendDeepest:P,camelCase:l,changeTagName:$,debug:B,denormalizeValue:m,encode:r,fileSize:g,fixNumberedList:V,getBox:Yt,getCSS:v,getDeepest:N,inString:c,mergeNodes:Z,modifierText:f,morph:ht,nodeAndView:dt,normalizeValue:u,parseStyle:p,query:L,removeBr:O,removeZWS:D,request:te,safeTemplate:a,setBlockIndent:F,splitNodes:M,template:s,toHex:d,toNodeList:y,wrapNodeList:H});class ie{constructor(t){this.fragment=null!=t?t:document.createDocumentFragment()}find(t){const e=[];let i=new T(this.fragment.firstChild);for(;i.length>0;)i.matches(t)?e.push(i.get(0)):i.isElement&&i.find(t).each((t=>{e.push(t)})),i=i.next();return new T(e)}append(t){t.each((t=>{this.fragment.appendChild(t)}))}}const ne={id:/^[\w-]+$/,class:/^[\w-]+$/,style:{"text-align":["left","center","right","justify","start","end"],"margin-left":/^-?\d+px$/i,"text-indent":/^-?\d+em$/i}};function se(){return{h1:Object.assign({},ne),h2:Object.assign({},ne),h3:Object.assign({},ne),h4:Object.assign({},ne),h5:Object.assign({},ne),h6:Object.assign({},ne),p:Object.assign({},ne),blockquote:Object.assign(Object.assign({},ne),{type:["info","tip","success","warning","error","danger"]}),ul:Object.assign(Object.assign({},ne),{type:"checklist",indent:/^\d+$/}),ol:Object.assign(Object.assign({},ne),{start:/^\d+$/,indent:/^\d+$/}),li:{value:["true","false"]},table:{style:{width:/^-?\d+(px|%)$/i,height:/^-?\d+(px|%)$/i,border:/^[^"]+$/,"border-width":/^-?\d+px$/i,"border-style":/^[\w-]+$/,"border-color":/^[^"]+$/,"background-color":/^[^"]+$/}},tr:{style:{height:/^-?\d+(px|%)$/i}},th:"td",td:{colspan:/^\d+$/,rowspan:/^\d+$/,style:{width:/^-?\d+(px|%)$/i,height:/^-?\d+(px|%)$/i,border:/^[^"]+$/,"border-width":/^-?\d+px$/i,"border-style":/^[\w-]+$/,"border-color":/^[^"]+$/,"background-color":/^[^"]+$/,"text-align":["left","center","right","justify"]}},"lake-box":{type:["inline","block"],name:/^[\w-]+$/,value:/^[^"]+$/,focus:["start","center","end"]},br:{},hr:{},img:{src:/^[^"]+$/,width:/^-?\d+px$/i,height:/^-?\d+px$/i,"data-lake-value":/^[^"]+$/,alt:/^[^"]+$/,style:{width:/^-?\d+px$/i,height:/^-?\d+px$/i}},span:{class:/^[\w-]+$/,style:{color:/^[^"]+$/,"background-color":/^[^"]+$/,"font-family":/^[^;]+$/,"font-size":/^[^"]+$/}},b:"strong",strong:{},em:"i",i:{},u:{},s:{},sub:{},sup:{},code:{},a:{class:/^[\w-]+$/,name:/^[\w-]+$/,href:/^[^"]+$/,target:/^[\w-]+$/,rel:/^[^"]+$/,download:/^[^"]+$/},"lake-bookmark":{type:["anchor","focus"]}}}class oe{constructor(t,e=se()){this.rules=e,this.source="string"==typeof t?this.parseHTML(t):t}parseHTML(t){const e=(new DOMParser).parseFromString(t,"text/html");return new T(e.querySelector("body"))}static matchRule(t,e){return"string"==typeof t?t===e:Array.isArray(t)?t.indexOf(e)>=0:t instanceof RegExp&&t.test(e)}static getOpenTagString(t,e){let i=t.name,n=e[i];if(!n)return"";"string"==typeof n&&(i=n,n=e[i]);const s=t.get(0);if(!s.hasAttributes())return i;const o=new Map;for(const t of s.attributes)if(n[t.name]&&("style"!==t.name&&oe.matchRule(n[t.name],t.value)&&o.set(t.name,t.value),"style"===t.name)){const e=n.style,i=new Map,s=p(t.value);for(const t of Object.keys(s)){const n=s[t];e[t]&&oe.matchRule(e[t],n)&&i.set(t,n)}o.set("style",i)}let r=i;for(const[t,e]of o)if("style"===t){let t="";for(const[i,n]of e)t+=`${i}: ${n.replace(/"/g,""")}; `;""!==t&&(r+=` style="${t.trim()}"`)}else r+=` ${t}="${e}"`;return r}static getClosedTagString(t,e){let i=t.name;const n=e[i];return n?("string"==typeof n&&(i=n),i):""}static getTrimmedText(t){const e=t.parent(),i=t.prev(),n=t.next();let s=t.text();return(i.isBlock||i.isBlockBox)&&(n.isBlock||n.isBlockBox)||0===i.length&&0===n.length&&e.isBlock?s=s.replace(/^[\u0020\t\r\n]+|[\u0020\t\r\n]+$/g,""):i.isBlock||i.isBlockBox||0===i.length&&e.isBlock?s=s.replace(/^[\u0020\t\r\n]+/,""):(n.isBlock||n.isBlockBox||0===n.length&&e.isBlock)&&(s=s.replace(/[\u0020\t\r\n]+$/,"")),s}getHTML(){const t=this.rules;let e="";for(const i of function*e(i){let n=i.first();for(;n.length>0;){const i=n.next();if(n.isText)yield r(oe.getTrimmedText(n));else if(n.isVoid){const e=oe.getOpenTagString(n,t);""!==e&&(yield`<${e} />`)}else if(n.isElement){const i=oe.getOpenTagString(n,t),s=oe.getClosedTagString(n,t);""!==i&&(yield`<${i}>`),n.isBox||(yield*e(n)),""!==s&&(yield`</${s}>`)}n=i}}(this.source))e+=i;return e.trim()}getNodeList(){const t=this.getHTML();return this.parseHTML(t).children()}getFragment(){const t=this.getHTML(),e=this.parseHTML(t),i=document.createDocumentFragment();let n=e.first();for(;n.length>0;){const t=n.next();i.appendChild(n.get(0)),n=t}return i}}class re{constructor(t){this.content=t}getHTML(){let t=this.content;return t=t.replace(/ {2}/g," "),t=r(t.trim()),t=`<p>${t}</p>`,t=t.replace(/(\r\n){2,}/g,"</p><p><br /></p><p>"),t=t.replace(/\r\n/g,"</p><p>"),t=t.replace(/[\r\n]{2,}/g,"</p><p><br /></p><p>"),t=t.replace(/[\r\n]/g,"</p><p>"),t}getFragment(){return new oe(this.getHTML()).getFragment()}}function ae(t,e){if(t.commonAncestor.isOutside)return;const i=(e=L(e)).get(0),n=t.get();n.insertNode(i),n.setEndAfter(i),n.collapse(!1)}function le(t){if(t.commonAncestor.isOutside)return{anchor:new T,focus:new T};const e=t.startNode.closest("lake-box");if(e.length>0)return t.isBoxStart?e.attr("focus","start"):t.isBoxEnd?e.attr("focus","end"):e.attr("focus","center"),{anchor:new T,focus:e};if(t.isCollapsed){const e=t.clone();e.collapseToEnd();const i=L('<lake-bookmark type="focus" />');return ae(e,i),{anchor:new T,focus:i}}const i=t.clone();i.collapseToStart();const n=L('<lake-bookmark type="anchor" />');ae(i,n);const s=t.clone();s.collapseToEnd();const o=L('<lake-bookmark type="focus" />');return ae(s,o),{anchor:n,focus:o}}function ce(t,e){const i=t.prev(),n=t.next();if(i.isText&&n.isText){const e=t.parent();D(e),t.remove(),e.get(0).normalize()}else if(0===i.length&&0===n.length){if(t.parent().isMark&&e){const i=new T(document.createTextNode(""));t.before(i),e.setStartAfter(i),e.collapseToStart()}t.remove()}else t.remove()}function he(t,e){const i=e.anchor,n=e.focus;if(i.length>0&&0===n.length)ce(i);else{if(n.length>0&&0===i.length){if(n.isBox){const e=Yt(n);0===e.getContainer().length&&e.render();const i=n.attr("focus");return"start"===i?t.selectBoxStart(n):"center"===i?t.selectBox(n):t.selectBoxEnd(n),void n.removeAttr("focus")}return t.setStartBefore(n),t.collapseToStart(),void ce(n,t)}if(i.length>0&&n.length>0){const e=new I;e.selectNode(i),e.collapseToEnd(),-1===e.compareAfterNode(n)?(t.setStartBefore(n),ce(n),t.setEndBefore(i),ce(i)):(t.setStartBefore(i),ce(i),t.setEndBefore(n),ce(n))}}}function de(t){if(t.commonAncestor.isOutside)return;V(t.getBlocks())}function pe(t){if(t.isCollapsed)return;if(t.adaptBox(),t.adaptTable(),t.isInoperative)return;const e=t.startNode.closestBlock(),i=t.endNode.closestBlock(),n=e.get(0)===i.get(0);if(t.get().deleteContents(),t.adaptBlock(),n){const e=t.getBlocks()[0];return void(e&&e.isEmpty&&(P(e,L("<br />")),t.shrinkAfter(e)))}const s=t.getBlocks()[0];if(!s)return;const o=s.prev();if(0===o.length)return;const r=le(t);Z(o,s),he(t,r),de(t)}function ue(t,e){if(t.commonAncestor.isOutside)return;t.isCollapsed?t.adaptBox():pe(t);O(t.startNode.closestBlock());const i=le(t);i.focus.before(e),he(t,i),t.adaptBlock()}function me(t,e){const i=L(e),n=document.createDocumentFragment();i.each((t=>{n.appendChild(t)})),ue(t,n)}function fe(t,e){if(t.commonAncestor.isOutside)return;if(t.isCollapsed&&t.isBox)return;if("string"!=typeof e){const i=t.getBlocks();for(const t of i)t.css(e);return}const i=L(e),n=i.name,s=i.get(0).attributes,o=t.getBlocks();if(o.length>0){const e=le(t);for(const t of o)if(t.name===n&&0===i.first().length)for(const e of s)t.attr(e.name,e.value);else{const e=i.clone(!0);t.isList&&""!==t.attr("indent")&&e.attr("indent",t.attr("indent"));const n=N(e);let s=t.first();for(;s.length>0;){const t=s.next();n.append(s),n.name!==s.name&&"li"!==s.name||s.remove(!0),s=t}t.replaceWith(e)}return he(t,e),void de(t)}const r=le(t),a=function(t){const e=t.commonAncestor.closest('div[contenteditable="true"],td');let i=[];if(0===e.length)return i;let n=e.first(),s=!0;for(;n.length>0;){if(n.isMark||n.isText||n.isBookmark||n.isInlineBox)i.push(n);else{if(!s)break;i=[]}t.intersectsNode(n)&&(s=!1),n=n.next()}return i}(t),l=H(a,i);he(t,r),de(t),l.isEmpty&&(P(l,L("<br />")),t.shrinkAfter(l))}function ge(t){if(t.commonAncestor.isOutside)return{start:null,end:null};t.isCollapsed?t.adaptBox():pe(t);const e=t.startNode,i=e.closestOperableBlock();if(0===i.length)return{start:null,end:null};let n=i.parent();n.isOutside&&(n=e.closestContainer());const s=M(e,t.startOffset,n);let o=null,r=null;return s&&(o=s.start,r=s.end),!s&&e.isBlock&&(t.startOffset>0&&(o=e.children()[t.startOffset-1]),r=e.children()[t.startOffset],r&&!r.isBlock&&(r=null)),o&&o.isEmpty&&P(o,L("<br />")),r&&(r.isEmpty?(P(r,L("<br />")),t.shrinkAfter(r)):t.shrinkBefore(r)),de(t),{start:o,end:r}}function ve(t){if(t.isMark&&t.isEmpty)t.remove();else for(const e of t.getWalker())e.isMark&&e.isEmpty&&e.remove()}function ye(t,e,i){let n=null,s=null,o=t.closestBlock();0===o.length&&(o=t.closestContainer());const r=M(t,e,o);return r&&(i?(ve(r.start),ve(r.end),r.start.isEmpty||(n=r.start),r.end.isEmpty||(s=r.end)):(n=r.start,s=r.end)),{start:n,end:s}}function we(t,e=!0){if(t.commonAncestor.isOutside)return{start:null,center:null,end:null};if(t.adaptBox(),t.isCollapsed){const i=ye(t.startNode,t.startOffset,e);return i.start?(t.setStartAfter(i.start),t.collapseToStart()):i.end&&(t.setStartBefore(i.end),t.collapseToStart()),{start:i.start,center:null,end:i.end}}const i=ye(t.startNode,t.startOffset,e);i.start?t.setStartAfter(i.start):i.end&&t.setStartBefore(i.end);const n=ye(t.endNode,t.endOffset,e);return n.start?t.setEndAfter(n.start):n.end&&t.setEndBefore(n.end),{start:i.start,center:n.start,end:n.end}}function xe(t,e){const i=t.text();let n=t;for(;n.length>0;){const t=n.parent();if(!t.isMark||i!==t.text()||!n.isText&&n.name===e&&""!==n.attr("style"))break;n=t}return n}function be(t,e){if(t.commonAncestor.isOutside)return;let i=L(e);const n=i.name,s=p(i.attr("style"));if(t.isCollapsed){if(t.isBox){const e=t.startNode.closest("lake-box");if("block"===Yt(e).type){const i=L("<p><br /></p>");t.isBoxStart?e.before(i):e.after(i),t.shrinkAfter(i)}else t.adaptBox()}O(t.startNode.closestBlock());const e=new T(document.createTextNode("")),o=we(t);if(o.start){const t=function(t){if(!t.isMark)return null;let e=t.clone(),i=t.last();for(;i.length>0;){if(i.isMark){const t=i.clone();e.append(t),e=t}i=i.last()}return e}(o.start);t&&(t.name===n?(t.css(s),i=t):(P(t,e),i.append(t)))}return""===i.text()&&i.append(e),ae(t,i),function(t){const e=t.prev();e.length>0&&e.isText&&e.isEmpty&&e.remove();const i=t.next();i.length>0&&i.isText&&i.isEmpty&&i.remove()}(i),void t.shrinkAfter(i)}we(t);const o=t.getMarks(!0),r=le(t);for(const t of o)if(!t.isEmpty&&t.isText){const e=xe(t,n);if(e.isMark&&e.name===n)e.css(s);else{const t=i.clone();e.before(t),t.append(e)}}he(t,r)}function ke(t){if(t.isMark&&t.isEmpty)t.remove();else for(const e of t.getWalker())e.isMark&&e.isEmpty&&e.remove()}function _e(t,e){if(t.commonAncestor.isOutside)return;let i;if(e){i=L(e).name}if(t.isCollapsed){if(t.isBox)return;if(i&&0===t.commonAncestor.closest(i).length)return;const e=we(t,!1);if(!e.start)return;e.end&&ke(e.end);const n=new T(document.createTextNode("")),s=function(t,e){if(!t.isMark||!e)return null;let i=t.clone(),n=t.last();for(;n.length>0;){if(n.isMark&&n.name!==e){const t=n.clone();i.append(t),i=t}n=n.last()}if(i.name===e){if(!(i.first().length>0))return null;i=i.first()}return i}(e.start,i);return s?(P(s,n),e.start.after(s),ke(e.start),void t.shrinkAfter(s)):(e.start.after(n),ke(e.start),n.prev().isText?(t.setStartAfter(n.prev()),t.collapseToStart(),void n.remove()):(t.setStartAfter(n),void t.collapseToStart()))}we(t);const n=t.getMarks(),s=le(t);for(const t of n)if(!i||t.name===i){const e=t.parent();t.remove(!t.isEmpty),e.length>0&&e.get(0).normalize()}D(t.commonAncestor),he(t,s)}function Se(t,e){if(t.commonAncestor.isOutside)return null;const i=L(e);if(t.isCollapsed){let e=t.commonAncestor.closest("a");if(0===e.length){e=i.clone(!0);return O(t.startNode.closestBlock()),ae(t,e),e}return""!==i.attr("href")&&e.attr({href:i.attr("href")}),e}we(t);const n=le(t);for(const e of t.commonAncestor.getWalker())"a"===e.name&&t.intersectsNode(e)&&e.remove(!0);const s=i.clone(!1);n.anchor.after(s);let o=s.next();for(;o.length>0;){const t=o.next();if(!o.isMark&&!o.isText)break;s.append(o),o=t}return 0===s.first().length&&s.remove(),he(t,n),s}class Ce{constructor(t){this.config=t,this.root=t.root,this.node=L(a`
|
|
5
|
+
`;class Jt{constructor(t){if(this.event=new Wt,"string"==typeof t){const e=Ut.get(t);if(void 0===e)throw new Error(`Box '${t}' has not been defined yet.`);const i=r(e.type),n=r(e.name);this.node=L(a`<lake-box type="${i}" name="${n}"></lake-box>`),e.value&&(this.value=e.value)}else{this.node=L(t);const e=Ut.get(this.name);if(void 0===e)throw new Error(`Box '${this.name}' has not been defined yet.`);e.value&&!this.node.hasAttr("value")&&(this.value=e.value)}Kt[this.node.id]||(Kt[this.node.id]={}),Gt[this.node.id]||(Gt[this.node.id]={setup:[],cleanup:[]})}addFramework(){let t=this.getContainer();0===t.length?(this.node.html(Xt),t=this.getContainer()):(t.off("mouseenter"),t.off("mouseleave"),t.off("click")),t.on("mouseenter",(()=>{t.hasClass("lake-box-selected")||t.hasClass("lake-box-focused")||t.hasClass("lake-box-activated")||t.addClass("lake-box-hovered")})),t.on("mouseleave",(()=>{t.removeClass("lake-box-hovered")})),t.on("click",(()=>{B(`Box '${this.name}' (id = ${this.node.id}) value:`),B(this.value)})),"block"===this.type&&t.attr("draggable","true")}get type(){return this.node.attr("type")}get name(){return this.node.attr("name")}get value(){const t=this.node.attr("value");return""===t?{}:JSON.parse(Vt(t))}set value(t){this.node.attr("value",$t(JSON.stringify(t)))}updateValue(t,e){const i=this.value;if("string"==typeof t)i[t]=e;else for(const e of Object.keys(t))i[e]=t[e];this.value=i}getData(t){return Kt[this.node.id][t]}setData(t,e){Kt[this.node.id][t]=e}getEditor(){const t=this.node.closest("div[contenteditable]");return t.length>0?qt.get(t.id):void 0}getContainer(){return this.node.find(".lake-box-container")}useEffect(t){Gt[this.node.id].setup.push(t)}render(){Gt[this.node.id].setup=[],Gt[this.node.id].cleanup=[];const t=Ut.get(this.name);if(void 0===t)return;this.addFramework();const e=t.render(this);if(void 0!==e){const t=this.getContainer(),i=t.clone(!1);i.append(e),ht(t,i)}for(const t of Gt[this.node.id].setup){const e=t();void 0!==e&&Gt[this.node.id].cleanup.push(e)}B(`Box '${this.name}' (id = ${this.node.id}) rendered`)}unmount(){this.event.emit("blur");for(const t of Gt[this.node.id].cleanup)t();Kt[this.node.id]={},Gt[this.node.id].setup=[],Gt[this.node.id].cleanup=[],this.event.removeAllListeners(),this.node.empty(),B(`Box '${this.name}' (id = ${this.node.id}) unmounted`)}getHTML(){const t=Ut.get(this.name);return void 0===t?"":void 0===t.html?this.node.outerHTML():t.html(this)}}function Yt(t){if("string"==typeof t)return new Jt(t);const e=(t=L(t)).closestContainer();if(0===e.length)return new Jt(t);let i=pt.get(e.id);i||(i=new Map,pt.set(e.id,i));let n=i.get(t.id);return n||(n=new Jt(t),i.set(n.node.id,n),n)}function Qt(t){const e=t.responseText||t.response;if(!e)return e;try{return JSON.parse(e)}catch(t){return e}}function te(t){const e=new XMLHttpRequest;t.onProgress&&e.upload&&(e.upload.onprogress=e=>{e.total>0&&(e.percent=e.loaded/e.total*100),t.onProgress&&t.onProgress(e)});const i=new FormData,n=t.data||{};Object.keys(n).forEach((t=>{const e=n[t];Array.isArray(e)?e.forEach((e=>{i.append(`${t}[]`,e)})):i.append(t,e)}));const s=t.filename||"file";t.file instanceof Blob?i.append(s,t.file,t.file.name):i.append(s,t.file),e.onerror=e=>{t.onError&&t.onError(e)},e.onload=()=>{if(e.status<200||e.status>=300){if(!t.onError)return;return t.onError(function(t,e){const i=`Cannot ${t.method} ${t.action} ${e.status}'`,n=new Error(i);return n.status=e.status,n.method=t.method,n.url=t.action,n}(t,e),Qt(e))}if(t.onSuccess)return t.onSuccess(Qt(e),e)},e.open(t.method,t.action,!0),t.withCredentials&&"withCredentials"in e&&(e.withCredentials=!0);const o=t.headers||{};return null!==o["X-Requested-With"]&&e.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(o).forEach((t=>{null!==o[t]&&e.setRequestHeader(t,o[t])})),e.send(i),e}var ee=Object.freeze({__proto__:null,appendDeepest:P,camelCase:l,changeTagName:$,debug:B,denormalizeValue:m,encode:r,fileSize:g,fixNumberedList:V,getBox:Yt,getCSS:v,getDeepest:N,inString:c,mergeNodes:Z,modifierText:f,morph:ht,nodeAndView:dt,normalizeValue:u,parseStyle:p,query:L,removeBr:O,removeZWS:D,request:te,safeTemplate:a,setBlockIndent:F,splitNodes:M,template:s,toHex:d,toNodeList:y,wrapNodeList:H});class ie{constructor(t){this.fragment=null!=t?t:document.createDocumentFragment()}find(t){const e=[];let i=new T(this.fragment.firstChild);for(;i.length>0;)i.matches(t)?e.push(i.get(0)):i.isElement&&i.find(t).each((t=>{e.push(t)})),i=i.next();return new T(e)}append(t){t.each((t=>{this.fragment.appendChild(t)}))}}const ne={id:/^[\w-]+$/,class:/^[\w-]+$/,style:{"text-align":["left","center","right","justify","start","end"],"margin-left":/^-?\d+px$/i,"text-indent":/^-?\d+em$/i}};function se(){return{h1:Object.assign({},ne),h2:Object.assign({},ne),h3:Object.assign({},ne),h4:Object.assign({},ne),h5:Object.assign({},ne),h6:Object.assign({},ne),p:Object.assign({},ne),blockquote:Object.assign(Object.assign({},ne),{type:["info","tip","success","warning","error","danger"]}),ul:Object.assign(Object.assign({},ne),{type:"checklist",indent:/^\d+$/}),ol:Object.assign(Object.assign({},ne),{start:/^\d+$/,indent:/^\d+$/}),li:{value:["true","false"]},table:{style:{width:/^-?\d+(px|%)$/i,height:/^-?\d+(px|%)$/i,border:/^[^"]+$/,"border-width":/^-?\d+px$/i,"border-style":/^[\w-]+$/,"border-color":/^[^"]+$/,"background-color":/^[^"]+$/}},tr:{style:{height:/^-?\d+(px|%)$/i}},th:"td",td:{colspan:/^\d+$/,rowspan:/^\d+$/,style:{width:/^-?\d+(px|%)$/i,height:/^-?\d+(px|%)$/i,border:/^[^"]+$/,"border-width":/^-?\d+px$/i,"border-style":/^[\w-]+$/,"border-color":/^[^"]+$/,"background-color":/^[^"]+$/,"text-align":["left","center","right","justify"]}},"lake-box":{type:["inline","block"],name:/^[\w-]+$/,value:/^[^"]+$/,focus:["start","center","end"]},br:{},hr:{},img:{src:/^[^"]+$/,width:/^-?\d+px$/i,height:/^-?\d+px$/i,"data-lake-value":/^[^"]+$/,alt:/^[^"]+$/,style:{width:/^-?\d+px$/i,height:/^-?\d+px$/i}},span:{class:/^[\w-]+$/,style:{color:/^[^"]+$/,"background-color":/^[^"]+$/,"font-family":/^[^;]+$/,"font-size":/^[^"]+$/}},b:"strong",strong:{},em:"i",i:{},u:{},s:{},sub:{},sup:{},code:{},a:{class:/^[\w-]+$/,name:/^[\w-]+$/,href:/^[^"]+$/,target:/^[\w-]+$/,rel:/^[^"]+$/,download:/^[^"]+$/},"lake-bookmark":{type:["anchor","focus"]}}}class oe{constructor(t,e=se()){this.rules=e,this.source="string"==typeof t?this.parseHTML(t):t}parseHTML(t){const e=(new DOMParser).parseFromString(t,"text/html");return new T(e.querySelector("body"))}static matchRule(t,e){return"string"==typeof t?t===e:Array.isArray(t)?t.indexOf(e)>=0:t instanceof RegExp&&t.test(e)}static getOpenTagString(t,e){let i=t.name,n=e[i];if(!n)return"";"string"==typeof n&&(i=n,n=e[i]);const s=t.get(0);if(!s.hasAttributes())return i;const o=new Map;for(const t of s.attributes)if(n[t.name]&&("style"!==t.name&&oe.matchRule(n[t.name],t.value)&&o.set(t.name,t.value),"style"===t.name)){const e=n.style,i=new Map,s=p(t.value);for(const t of Object.keys(s)){const n=s[t];e[t]&&oe.matchRule(e[t],n)&&i.set(t,n)}o.set("style",i)}let r=i;for(const[t,e]of o)if("style"===t){let t="";for(const[i,n]of e)t+=`${i}: ${n.replace(/"/g,""")}; `;""!==t&&(r+=` style="${t.trim()}"`)}else r+=` ${t}="${e}"`;return r}static getClosedTagString(t,e){let i=t.name;const n=e[i];return n?("string"==typeof n&&(i=n),i):""}static getTrimmedText(t){const e=t.parent(),i=t.prev(),n=t.next();let s=t.text();return(i.isBlock||i.isBlockBox)&&(n.isBlock||n.isBlockBox)||0===i.length&&0===n.length&&e.isBlock?s=s.replace(/^[\u0020\t\r\n]+|[\u0020\t\r\n]+$/g,""):i.isBlock||i.isBlockBox||0===i.length&&e.isBlock?s=s.replace(/^[\u0020\t\r\n]+/,""):(n.isBlock||n.isBlockBox||0===n.length&&e.isBlock)&&(s=s.replace(/[\u0020\t\r\n]+$/,"")),s}getHTML(){const t=this.rules;let e="";for(const i of function*e(i){let n=i.first();for(;n.length>0;){const i=n.next();if(n.isText)yield r(oe.getTrimmedText(n));else if(n.isVoid){const e=oe.getOpenTagString(n,t);""!==e&&(yield`<${e} />`)}else if(n.isElement){const i=oe.getOpenTagString(n,t),s=oe.getClosedTagString(n,t);""!==i&&(yield`<${i}>`),n.isBox||(yield*e(n)),""!==s&&(yield`</${s}>`)}n=i}}(this.source))e+=i;return e.trim()}getNodeList(){const t=this.getHTML();return this.parseHTML(t).children()}getFragment(){const t=this.getHTML(),e=this.parseHTML(t),i=document.createDocumentFragment();let n=e.first();for(;n.length>0;){const t=n.next();i.appendChild(n.get(0)),n=t}return i}}class re{constructor(t){this.content=t}getHTML(){let t=this.content;return t=t.replace(/ {2}/g," "),t=r(t.trim()),t=`<p>${t}</p>`,t=t.replace(/(\r\n){2,}/g,"</p><p><br /></p><p>"),t=t.replace(/\r\n/g,"</p><p>"),t=t.replace(/[\r\n]{2,}/g,"</p><p><br /></p><p>"),t=t.replace(/[\r\n]/g,"</p><p>"),t}getFragment(){return new oe(this.getHTML()).getFragment()}}function ae(t,e){if(t.commonAncestor.isOutside)return;const i=(e=L(e)).get(0),n=t.get();n.insertNode(i),n.setEndAfter(i),n.collapse(!1)}function le(t){if(t.commonAncestor.isOutside)return{anchor:new T,focus:new T};const e=t.startNode.closest("lake-box");if(e.length>0)return t.isBoxStart?e.attr("focus","start"):t.isBoxEnd?e.attr("focus","end"):e.attr("focus","center"),{anchor:new T,focus:e};if(t.isCollapsed){const e=t.clone();e.collapseToEnd();const i=L('<lake-bookmark type="focus" />');return ae(e,i),{anchor:new T,focus:i}}const i=t.clone();i.collapseToStart();const n=L('<lake-bookmark type="anchor" />');ae(i,n);const s=t.clone();s.collapseToEnd();const o=L('<lake-bookmark type="focus" />');return ae(s,o),{anchor:n,focus:o}}function ce(t,e){const i=t.prev(),n=t.next();if(i.isText&&n.isText){const e=t.parent();D(e),t.remove(),e.get(0).normalize()}else if(0===i.length&&0===n.length){if(t.parent().isMark&&e){const i=new T(document.createTextNode(""));t.before(i),e.setStartAfter(i),e.collapseToStart()}t.remove()}else t.remove()}function he(t,e){const i=e.anchor,n=e.focus;if(i.length>0&&0===n.length)ce(i);else{if(n.length>0&&0===i.length){if(n.isBox){const e=Yt(n);0===e.getContainer().length&&e.render();const i=n.attr("focus");return"start"===i?t.selectBoxStart(n):"center"===i?t.selectBox(n):t.selectBoxEnd(n),void n.removeAttr("focus")}return t.setStartBefore(n),t.collapseToStart(),void ce(n,t)}if(i.length>0&&n.length>0){const e=new I;e.selectNode(i),e.collapseToEnd(),-1===e.compareAfterNode(n)?(t.setStartBefore(n),ce(n),t.setEndBefore(i),ce(i)):(t.setStartBefore(i),ce(i),t.setEndBefore(n),ce(n))}}}function de(t){if(t.commonAncestor.isOutside)return;V(t.getBlocks())}function pe(t){if(t.isCollapsed)return;if(t.adaptBox(),t.adaptTable(),t.isInoperative)return;const e=t.startNode.closestBlock(),i=t.endNode.closestBlock(),n=e.get(0)===i.get(0);if(t.get().deleteContents(),t.adaptBlock(),n){const e=t.getBlocks()[0];return void(e&&e.isEmpty&&(P(e,L("<br />")),t.shrinkAfter(e)))}const s=t.getBlocks()[0];if(!s)return;const o=s.prev();if(0===o.length)return;const r=le(t);Z(o,s),he(t,r),de(t)}function ue(t,e){if(t.commonAncestor.isOutside)return;t.isCollapsed?t.adaptBox():pe(t);O(t.startNode.closestBlock());const i=le(t);i.focus.before(e),he(t,i),t.adaptBlock()}function me(t,e){const i=L(e),n=document.createDocumentFragment();i.each((t=>{n.appendChild(t)})),ue(t,n)}function fe(t,e){if(t.commonAncestor.isOutside)return;if(t.isCollapsed){if(t.commonAncestor.closest("lake-box").isBlockBox)return}if("string"!=typeof e){const i=t.getBlocks();for(const t of i)t.css(e);return}const i=L(e),n=i.name,s=i.get(0).attributes,o=t.getBlocks();if(o.length>0){const e=le(t);for(const t of o)if(t.name===n&&0===i.first().length)for(const e of s)t.attr(e.name,e.value);else{const e=i.clone(!0);t.isList&&""!==t.attr("indent")&&e.attr("indent",t.attr("indent"));const n=N(e);let s=t.first();for(;s.length>0;){const t=s.next();n.append(s),n.name!==s.name&&"li"!==s.name||s.remove(!0),s=t}t.replaceWith(e)}return he(t,e),void de(t)}const r=le(t),a=function(t){const e=t.commonAncestor.closest('div[contenteditable="true"],td');let i=[];if(0===e.length)return i;let n=e.first(),s=!0;for(;n.length>0;){if(n.isMark||n.isText||n.isBookmark||n.isInlineBox)i.push(n);else{if(!s)break;i=[]}t.intersectsNode(n)&&(s=!1),n=n.next()}return i}(t),l=H(a,i);he(t,r),de(t),l.isEmpty&&(P(l,L("<br />")),t.shrinkAfter(l))}function ge(t){if(t.commonAncestor.isOutside)return{start:null,end:null};t.isCollapsed?t.adaptBox():pe(t);const e=t.startNode,i=e.closestOperableBlock();if(0===i.length)return{start:null,end:null};let n=i.parent();n.isOutside&&(n=e.closestContainer());const s=M(e,t.startOffset,n);let o=null,r=null;return s&&(o=s.start,r=s.end),!s&&e.isBlock&&(t.startOffset>0&&(o=e.children()[t.startOffset-1]),r=e.children()[t.startOffset],r&&!r.isBlock&&(r=null)),o&&o.isEmpty&&P(o,L("<br />")),r&&(r.isEmpty?(P(r,L("<br />")),t.shrinkAfter(r)):t.shrinkBefore(r)),de(t),{start:o,end:r}}function ve(t){if(t.isMark&&t.isEmpty)t.remove();else for(const e of t.getWalker())e.isMark&&e.isEmpty&&e.remove()}function ye(t,e,i){let n=null,s=null,o=t.closestBlock();0===o.length&&(o=t.closestContainer());const r=M(t,e,o);return r&&(i?(ve(r.start),ve(r.end),r.start.isEmpty||(n=r.start),r.end.isEmpty||(s=r.end)):(n=r.start,s=r.end)),{start:n,end:s}}function we(t,e=!0){if(t.commonAncestor.isOutside)return{start:null,center:null,end:null};if(t.adaptBox(),t.isCollapsed){const i=ye(t.startNode,t.startOffset,e);return i.start?(t.setStartAfter(i.start),t.collapseToStart()):i.end&&(t.setStartBefore(i.end),t.collapseToStart()),{start:i.start,center:null,end:i.end}}const i=ye(t.startNode,t.startOffset,e);i.start?t.setStartAfter(i.start):i.end&&t.setStartBefore(i.end);const n=ye(t.endNode,t.endOffset,e);return n.start?t.setEndAfter(n.start):n.end&&t.setEndBefore(n.end),{start:i.start,center:n.start,end:n.end}}function xe(t,e){const i=t.text();let n=t;for(;n.length>0;){const t=n.parent();if(!t.isMark||i!==t.text()||!n.isText&&n.name===e&&""!==n.attr("style"))break;n=t}return n}function be(t,e){if(t.commonAncestor.isOutside)return;let i=L(e);const n=i.name,s=p(i.attr("style"));if(t.isCollapsed){if(t.isBox){const e=t.startNode.closest("lake-box");if("block"===Yt(e).type){const i=L("<p><br /></p>");t.isBoxStart?e.before(i):e.after(i),t.shrinkAfter(i)}else t.adaptBox()}O(t.startNode.closestBlock());const e=new T(document.createTextNode("")),o=we(t);if(o.start){const t=function(t){if(!t.isMark)return null;let e=t.clone(),i=t.last();for(;i.length>0;){if(i.isMark){const t=i.clone();e.append(t),e=t}i=i.last()}return e}(o.start);t&&(t.name===n?(t.css(s),i=t):(P(t,e),i.append(t)))}return""===i.text()&&i.append(e),ae(t,i),function(t){const e=t.prev();e.length>0&&e.isText&&e.isEmpty&&e.remove();const i=t.next();i.length>0&&i.isText&&i.isEmpty&&i.remove()}(i),void t.shrinkAfter(i)}we(t);const o=t.getMarks(!0),r=le(t);for(const t of o)if(!t.isEmpty&&t.isText){const e=xe(t,n);if(e.isMark&&e.name===n)e.css(s);else{const t=i.clone();e.before(t),t.append(e)}}he(t,r)}function ke(t){if(t.isMark&&t.isEmpty)t.remove();else for(const e of t.getWalker())e.isMark&&e.isEmpty&&e.remove()}function _e(t,e){if(t.commonAncestor.isOutside)return;let i;if(e){i=L(e).name}if(t.isCollapsed){if(t.isBox)return;if(i&&0===t.commonAncestor.closest(i).length)return;const e=we(t,!1);if(!e.start)return;e.end&&ke(e.end);const n=new T(document.createTextNode("")),s=function(t,e){if(!t.isMark||!e)return null;let i=t.clone(),n=t.last();for(;n.length>0;){if(n.isMark&&n.name!==e){const t=n.clone();i.append(t),i=t}n=n.last()}if(i.name===e){if(!(i.first().length>0))return null;i=i.first()}return i}(e.start,i);return s?(P(s,n),e.start.after(s),ke(e.start),void t.shrinkAfter(s)):(e.start.after(n),ke(e.start),n.prev().isText?(t.setStartAfter(n.prev()),t.collapseToStart(),void n.remove()):(t.setStartAfter(n),void t.collapseToStart()))}we(t);const n=t.getMarks(),s=le(t);for(const t of n)if(!i||t.name===i){const e=t.parent();t.remove(!t.isEmpty),e.length>0&&e.get(0).normalize()}D(t.commonAncestor),he(t,s)}function Se(t,e){if(t.commonAncestor.isOutside)return null;const i=L(e);if(t.isCollapsed){let e=t.commonAncestor.closest("a");if(0===e.length){e=i.clone(!0);return O(t.startNode.closestBlock()),ae(t,e),e}return""!==i.attr("href")&&e.attr({href:i.attr("href")}),e}we(t);const n=le(t);for(const e of t.commonAncestor.getWalker())"a"===e.name&&t.intersectsNode(e)&&e.remove(!0);const s=i.clone(!1);n.anchor.after(s);let o=s.next();for(;o.length>0;){const t=o.next();if(!o.isMark&&!o.isText)break;s.append(o),o=t}return 0===s.first().length&&s.remove(),he(t,n),s}class Ce{constructor(t){this.config=t,this.root=t.root,this.node=L(a`
|
|
6
6
|
<button type="button" name="${t.name}" class="lake-button" />
|
|
7
7
|
`),void 0!==t.tabIndex&&this.node.attr("tabindex",t.tabIndex.toString())}render(){const t=this.config,e=this.node;e.addClass(`lake-${t.text?"text":"icon"}-button`),t.tooltip&&e.attr("title",t.tooltip),t.icon&&e.append(t.icon),t.text&&e.append(`<span>${t.text}</span>`),this.root.append(e),e.on("mouseenter",(()=>{e.attr("disabled")||e.hasClass("lake-button-selected")||e.addClass("lake-button-hovered")})),e.on("mouseleave",(()=>{e.attr("disabled")||e.removeClass("lake-button-hovered")})),e.on("click",(e=>{e.preventDefault(),t.onClick()}))}}const Be=/^\{.*\}$/,Ae=/(\{(?:[^{}]+|\{(?:[^{}]+)*\})*\})/g,Ee=t=>t.substring(1,t.length-1),Te=(t,e=!0,i="",n="")=>t.split(Ae).map((t=>{if(!t.match(Ae))return t;const e=Ee(t);if(e.startsWith("{"))return((t,e)=>{let[i,n]=t.split(":");n||(n=i,i=e);const s=n.split("|"),[o,r,a,l,c,h]=s,d=s.filter((t=>void 0!==t)).length;return 1===d?{k:i,r:o}:2===d?{k:i,o:o,r:r}:3===d?{k:i,z:o,o:r,r:a}:{k:i,z:o,o:r,t:a,f:l,m:c,r:h}})(Ee(e),n);const s=(t=>{const[e="",...i]=t.split("|"),[n="",s]=e.split(":"),[o,r]=n.split("?");return{k:o,i:s,n:""===r,f:i}})(e);return n=s.k||n,!i&&(i=n),s})).map((t=>{if("string"==typeof t)return t;t.k||(t.k=i||"0");const n=(t=>Object.fromEntries(Object.keys(t).map((e=>{const i=t[e];return[e,Array.isArray(i)?i.map((t=>null==t?void 0:t.trim())):i===!!i?i:null==i?void 0:i.trim()]}))))(t);return e?(s=n,Object.fromEntries(Object.entries(s).map((([t,e])=>"i"!==t&&e&&"0"!=e&&[t,e])).filter(Boolean))):n;var s})),Le=(t,e,i)=>e.reduce(((e,i)=>{var n,s,o;return null!==(s=i.match(Be)?(t=>{var i;return null!==(i=t[e])&&void 0!==i?i:t["*"]})((o=i,Object.fromEntries(Ee(o).split(",").map((t=>t.split(":"))).reduce(((t,e)=>2===e.length?[...t,e.map((t=>t.trim()))]:(t[t.length-1][1]+=","+e[0],t)),[])))):null===(n=t[i])||void 0===n?void 0:n.call(t,e))&&void 0!==s?s:e}),i),Ie=/\?\?/g,Me=(t,e,i,n)=>{const s=n[0],o=s&&"object"==typeof s&&s.constructor===Object;return((t,e,i,n)=>t.map((t=>{if("string"==typeof t)return t;const{k:s="0",f:o=[]}=t,r=n[s];if((t=>!(!t.o&&!t.r))(t))return(("boolean"==typeof r?r?t.o:t.r:((t,{z:e,o:i,t:n,f:s,m:o,r:r},a)=>{switch(e&&0==a?"zero":t.select(a)){case"zero":return e;case"one":return i;case"two":return n;case"few":return null!=s?s:r;case"many":return null!=o?o:r;default:return r}})(e,t,r))||"").replace(Ie,r);const a=o.length?Le(i,o,r):r;return(""+(null!=a?a:"")).trim()})).join(""))(t,e,i,1===n.length&&o?s:n)},Pe=(t,e)=>{const i={},n=new Intl.PluralRules(t);return(t,...s)=>Me(((t,e)=>t[e]||(t[e]=Te(e)))(i,t),n,e,s)};const Oe=(t={},e)=>"string"==typeof t?e.bind(null,t):Object.assign(Object.defineProperty((()=>""),"name",{writable:!0}),t),ze=(t,e)=>new Proxy(Oe(t,e),{get:(t,i)=>i===Symbol.iterator?[][Symbol.iterator].bind(Object.values(t).map((t=>Oe(t,e)))):ze(t[i],e)});const Ze={"en-US":{toolbar:{undo:`Undo (${f("mod+Z")})`,redo:`Redo (${f("mod+Y")})`,selectAll:`Select all (${f("mod+A")})`,paragraph:"Paragraph",blockQuote:"Block quotation",numberedList:"Numbered list",bulletedList:"Bulleted list",checklist:"Checklist",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignJustify:"Align justify",increaseIndent:"Increase indent",decreaseIndent:"Decrease indent",bold:`Bold (${f("mod+B")})`,italic:`Italic (${f("mod+I")})`,underline:`Underline (${f("mod+U")})`,strikethrough:"Strikethrough",superscript:"Superscript",subscript:"Subscript",code:"Inline code",removeFormat:"Remove format",formatPainter:"Format painter",link:"Link",hr:"Horizontal line",codeBlock:"Code block",heading:"Heading",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",list:"List",align:"Alignment",indent:"Indent",fontFamily:"Font family",fontSize:"Font size",moreStyle:"More style",fontColor:"Font color",highlight:"Highlight",image:"Image",file:"File",removeColor:"Remove color"},link:{newLink:"New link",url:"Link URL",title:"Link title",copy:"Copy link to clipboard",open:"Open link in new tab",save:"Save",unlink:"Remove link"},image:{view:"Full screen",remove:"Delete",previous:"Previous",next:"Next",close:"Close (Esc)",loadingError:"The image cannot be loaded",zoomOut:"Zoom out",zoomIn:"Zoom in"},file:{download:"Download",remove:"Delete"},codeBlock:{langType:"Select language"}},"zh-CN":{toolbar:{undo:`撤消 (${f("mod+Z")})`,redo:`重做 (${f("mod+Y")})`,selectAll:`全选 (${f("mod+A")})`,paragraph:"正文",blockQuote:"引用",numberedList:"编号",bulletedList:"项目符号",checklist:"任务列表",alignLeft:"左对齐",alignCenter:"居中",alignRight:"右对齐",alignJustify:"两端对齐",increaseIndent:"增加缩进",decreaseIndent:"减少缩进",bold:`粗体 (${f("mod+B")})`,italic:`斜体 (${f("mod+I")})`,underline:`下划线 (${f("mod+U")})`,strikethrough:"删除线",superscript:"上标",subscript:"下标",code:"行内代码",removeFormat:"清除格式",formatPainter:"格式刷",link:"链接",hr:"分割线",codeBlock:"代码块",heading:"标题",heading1:"标题 1",heading2:"标题 2",heading3:"标题 3",heading4:"标题 4",heading5:"标题 5",heading6:"标题 6",list:"列表",align:"对齐方式",indent:"缩进",fontFamily:"字体",fontSize:"文字大小",moreStyle:"更多样式",fontColor:"文字颜色",highlight:"文字背景",image:"图片",file:"文件",removeColor:"默认"},link:{newLink:"新链接",url:"链接 URL",title:"链接文本",copy:"复制到剪贴板",open:"打开链接",save:"确定",unlink:"取消链接"},image:{view:"查看大图",remove:"删除",previous:"上一张",next:"下一张",close:"关闭 (Esc)",loadingError:"图片加载失败",zoomOut:"缩小",zoomIn:"放大"},file:{download:"下载",remove:"删除"},codeBlock:{langType:"选择代码语言"}},ja:{toolbar:{undo:`元に戻す (${f("mod+Z")})`,redo:`やり直し (${f("mod+Y")})`,selectAll:`すべて選択 (${f("mod+A")})`,paragraph:"テキスト",blockQuote:"ブロック引用",numberedList:"番号付きリスト",bulletedList:"箇条書きリスト",checklist:"タスクリスト",alignLeft:"左揃え",alignCenter:"中心揃え",alignRight:"右揃え",alignJustify:"左右に並べ替え",increaseIndent:"インデントを増やす",decreaseIndent:"インデントを減らす",bold:`太字 (${f("mod+B")})`,italic:`斜体 (${f("mod+I")})`,underline:`下線 (${f("mod+U")})`,strikethrough:"取り消し線",superscript:"上付き文字",subscript:"下付き文字",code:"インラインコード",removeFormat:"形式を削除",formatPainter:"形式ペインタ",link:"リンク",hr:"区切り線",codeBlock:"コードブロック",heading:"タイトル",heading1:"タイトル 1",heading2:"タイトル 2",heading3:"タイトル 3",heading4:"タイトル 4",heading5:"タイトル 5",heading6:"タイトル 6",list:"リスト",align:"文字揃え",indent:"インデント",fontFamily:"フォント",fontSize:"文字サイズ",moreStyle:"その他のスタイル",fontColor:"文字色",highlight:"文字の背景",image:"画像",file:"ファイル",removeColor:"デフォルト"},link:{newLink:"新しいリンク",url:"リンク URL",title:"リンク文字",copy:"クリップボードにコピー",open:"リンクを開く",save:"確認",unlink:"リンクを削除"},image:{view:"大きな画像を見る",remove:"削除",previous:"前の画像",next:"次の画像",close:"閉じる (Esc)",loadingError:"画像を読み込めません",zoomOut:"縮小",zoomIn:"拡大"},file:{download:"ダウンロード",remove:"削除"},codeBlock:{langType:"コード言語を選択"}},ko:{toolbar:{undo:`작업취소 (${f("mod+Z")})`,redo:`작업재개 (${f("mod+Y")})`,selectAll:`전체 선택 (${f("mod+A")})`,paragraph:"텍스트",blockQuote:"인용문",numberedList:"순서 목록",bulletedList:"비순서 목록",checklist:"체크리스트",alignLeft:"왼쪽 정렬",alignCenter:"가운데 정렬",alignRight:"오른쪽 정렬",alignJustify:"좌우로 정렬",increaseIndent:"들여쓰기 증가",decreaseIndent:"들여쓰기 줄이기",bold:`굵게 (${f("mod+B")})`,italic:`기울임꼴 (${f("mod+I")})`,underline:`밑줄 (${f("mod+U")})`,strikethrough:"취소선",superscript:"위첨자",subscript:"아래 첨자",code:"인라인 코드",removeFormat:"형식 지우기",formatPainter:"형식 페인터",link:"링크",hr:"구분선",codeBlock:"코드 블록",heading:"제목",heading1:"제목 1",heading2:"제목 2",heading3:"제목 3",heading4:"제목 4",heading5:"제목 5",heading6:"제목 6",list:"목록",align:"정렬",indent:"들여쓰기",fontFamily:"글꼴",fontSize:"글자 크기",moreStyle:"더 많은 스타일",fontColor:"글자 색상",highlight:"글자 배경",image:"이미지",file:"파일",removeColor:"기본색"},link:{newLink:"새 링크",url:"링크 URL",title:"링크 텍스트",copy:"클립보드에 복사",open:"링크 열기",save:"확인",unlink:"링크 제거"},image:{view:"큰 이미지 보기",remove:"삭제",previous:"이전 이미지",next:"다음 이미지",close:"닫기 (Esc)",loadingError:"이미지를 로드할 수 없습니다",zoomOut:"축소",zoomIn:"확대"},file:{download:"다운로드",remove:"삭제"},codeBlock:{langType:"코드언어 선택"}}},Ne=Object.keys(Ze),He={},De={},$e=t=>{He[t]||(He[t]=Ze[t],(t=>{De[t]={}})(t))},Ve=t=>function(t,e,i={}){return ze(e,Pe(t,i))}(t,He[t],De[t]);Ne.forEach($e);class Fe{constructor(t){this.documentClickListener=t=>{const e=new T(t.target),i=this.node.find(".lake-dropdown-title"),n=this.node.find(".lake-dropdown-menu");e.closest(".lake-dropdown-title").get(0)!==i.get(0)&&(n.hide(),document.removeEventListener("click",this.documentClickListener))},this.config=t,this.root=t.root,this.locale=t.locale||Ve("en-US");const e=t.placement||"bottom";if(this.node=L(a`
|
|
8
8
|
<div class="lake-dropdown lake-${t.menuType}-dropdown" name="${t.name}" placement="${e}">
|
|
@@ -15,7 +15,7 @@ var Lake=function(t){"use strict";class e extends HTMLElement{}void 0!==customEl
|
|
|
15
15
|
<li value="${r(i.value)}">
|
|
16
16
|
<div class="lake-dropdown-menu-text">${o}</div>
|
|
17
17
|
</li>
|
|
18
|
-
`);if(t.append(a),"color"===e.menuType&&(a.attr("title",o),a.find(".lake-dropdown-menu-text").css("background-color",i.value)),i.icon){const t=L('<div class="lake-dropdown-menu-icon"></div>');t.append(i.icon),a.prepend(t)}const l=n.get("check");if(l){const t=L('<div class="lake-dropdown-menu-check"></div>');t.append(l),a.prepend(t)}}}showMenu(){const t=this.config,e=this.node,i=e.find(".lake-dropdown-menu");if(e.attr("disabled"))return;const n=Fe.getValue(e);i.find(".lake-dropdown-menu-check").css("visibility","hidden"),i.find("li").each((t=>{const e=L(t);e.on("mouseenter",(()=>{e.hasClass("lake-dropdown-item-selected")||e.addClass("lake-dropdown-item-hovered")})),e.on("mouseleave",(()=>{e.removeClass("lake-dropdown-item-hovered")})),n.indexOf(e.attr("value"))>=0&&e.find(".lake-dropdown-menu-check").css("visibility","visible")})),i.css("visibility","hidden"),i.show("color"===t.menuType?"flex":"block");const s=e.get(0).getBoundingClientRect(),o=i.width()-(s.x+s.width),r=s.x+i.width()-window.innerWidth;r+50>0&&(o<0||o<r)?(i.css("left","auto"),i.css("right","0")):(i.css("left",""),i.css("right","")),i.css("visibility",""),document.addEventListener("click",this.documentClickListener)}bindEvents(){const t=this.config,e=this.node,i=e.find(".lake-dropdown-title"),n=i.find(".lake-dropdown-text"),s=i.find(".lake-dropdown-icon"),o=i.find(".lake-dropdown-down-icon"),r=e.find(".lake-dropdown-menu");"color"===t.menuType?(s.on("mouseenter",(()=>{e.attr("disabled")||s.addClass("lake-dropdown-icon-hovered")})),s.on("mouseleave",(()=>{s.removeClass("lake-dropdown-icon-hovered")})),o.on("mouseenter",(()=>{e.attr("disabled")||o.addClass("lake-dropdown-down-icon-hovered")})),o.on("mouseleave",(()=>{o.removeClass("lake-dropdown-down-icon-hovered")}))):(i.on("mouseenter",(()=>{e.attr("disabled")||i.addClass("lake-dropdown-title-hovered")})),i.on("mouseleave",(()=>{i.removeClass("lake-dropdown-title-hovered")}))),"color"===t.menuType&&s.on("click",(i=>{if(i.preventDefault(),e.attr("disabled"))return;const n=e.attr("color")||t.defaultValue;t.onSelect(n)}));("color"===t.menuType&&o?o:i).on("click",(t=>{t.preventDefault(),this.showMenu()})),r.on("click",(s=>{s.preventDefault();const o=L(s.target).closest("li"),a=o.attr("value");Fe.setValue(e,[a]),n.length>0&&n.text(o.text()),"color"===t.menuType&&""!==a&&(e.attr("color",a),this.updateColorAccent(i,a)),t.onSelect(a),r.hide(),document.removeEventListener("click",this.documentClickListener)}))}render(){var t;const e=this.config,i=this.node,n=i.find(".lake-dropdown-title");e.downIcon||n.addClass("lake-dropdown-title-no-down"),n.css("width",e.width);const s="string"==typeof e.tooltip?e.tooltip:e.tooltip(this.locale);n.attr("title",s);const o=n.find(".lake-dropdown-text"),r=n.find(".lake-dropdown-icon");e.icon&&r.append(e.icon),e.accentIcon&&r.append(e.accentIcon);const a=n.find(".lake-dropdown-down-icon");e.downIcon&&a.append(e.downIcon);const l=L('<ul class="lake-dropdown-menu" />');if(l.addClass(`lake-${e.menuType}-dropdown-menu`),Fe.setValue(i,[e.defaultValue]),o.length>0){const i=Fe.getMenuMap(e.menuItems,this.locale);o.text(null!==(t=i.get(e.defaultValue))&&void 0!==t?t:e.defaultValue)}"color"===e.menuType&&this.updateColorAccent(n,e.defaultValue),this.apppendMenuItems(l),i.append(n),i.append(l),this.root.append(i),this.bindEvents()}unmount(){this.node.remove(),document.removeEventListener("click",this.documentClickListener)}}var je=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},Re="object"==typeof Ft&&Ft&&Ft.Object===Object&&Ft,We=Re,Ue="object"==typeof self&&self&&self.Object===Object&&self,qe=We||Ue||Function("return this")(),Ke=qe,Ge=function(){return Ke.Date.now()},Xe=/\s/;var Je=function(t){for(var e=t.length;e--&&Xe.test(t.charAt(e)););return e},Ye=Je,Qe=/^\s+/;var ti=function(t){return t?t.slice(0,Ye(t)+1).replace(Qe,""):t},ei=qe.Symbol,ii=ei,ni=Object.prototype,si=ni.hasOwnProperty,oi=ni.toString,ri=ii?ii.toStringTag:void 0;var ai=function(t){var e=si.call(t,ri),i=t[ri];try{t[ri]=void 0;var n=!0}catch(t){}var s=oi.call(t);return n&&(e?t[ri]=i:delete t[ri]),s},li=Object.prototype.toString;var ci=ai,hi=function(t){return li.call(t)},di=ei?ei.toStringTag:void 0;var pi=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":di&&di in Object(t)?ci(t):hi(t)};var ui=function(t){return null!=t&&"object"==typeof t},mi=pi,fi=ui;var gi=ti,vi=je,yi=function(t){return"symbol"==typeof t||fi(t)&&"[object Symbol]"==mi(t)},wi=/^[-+]0x[0-9a-f]+$/i,xi=/^0b[01]+$/i,bi=/^0o[0-7]+$/i,ki=parseInt;var _i=je,Si=Ge,Ci=function(t){if("number"==typeof t)return t;if(yi(t))return NaN;if(vi(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=vi(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=gi(t);var i=xi.test(t);return i||bi.test(t)?ki(t.slice(2),i?2:8):wi.test(t)?NaN:+t},Bi=Math.max,Ai=Math.min;var Ei=function(t,e,i){var n,s,o,r,a,l,c=0,h=!1,d=!1,p=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function u(e){var i=n,o=s;return n=s=void 0,c=e,r=t.apply(o,i)}function m(t){var i=t-l;return void 0===l||i>=e||i<0||d&&t-c>=o}function f(){var t=Si();if(m(t))return g(t);a=setTimeout(f,function(t){var i=e-(t-l);return d?Ai(i,o-(t-c)):i}(t))}function g(t){return a=void 0,p&&n?u(t):(n=s=void 0,r)}function v(){var t=Si(),i=m(t);if(n=arguments,s=this,l=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(f,e),h?u(t):r}(l);if(d)return clearTimeout(a),a=setTimeout(f,e),u(l)}return void 0===a&&(a=setTimeout(f,e)),r}return e=Ci(e)||0,_i(i)&&(h=!!i.leading,o=(d="maxWait"in i)?Bi(Ci(i.maxWait)||0,e):o,p="trailing"in i?!!i.trailing:p),v.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=s=a=void 0},v.flush=function(){return void 0===a?r:g(Si())},v},Ti=jt(Ei);var Li=function(){this.__data__=[],this.size=0};var Ii=function(t,e){return t===e||t!=t&&e!=e},Mi=Ii;var Pi=function(t,e){for(var i=t.length;i--;)if(Mi(t[i][0],e))return i;return-1},Oi=Pi,zi=Array.prototype.splice;var Zi=function(t){var e=this.__data__,i=Oi(e,t);return!(i<0)&&(i==e.length-1?e.pop():zi.call(e,i,1),--this.size,!0)},Ni=Pi;var Hi=function(t){var e=this.__data__,i=Ni(e,t);return i<0?void 0:e[i][1]},Di=Pi;var $i=Pi;var Vi=function(t,e){var i=this.__data__,n=$i(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this},Fi=Li,ji=Zi,Ri=Hi,Wi=function(t){return Di(this.__data__,t)>-1},Ui=Vi;function qi(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}qi.prototype.clear=Fi,qi.prototype.delete=ji,qi.prototype.get=Ri,qi.prototype.has=Wi,qi.prototype.set=Ui;var Ki=qi,Gi=Ki;var Xi=function(){this.__data__=new Gi,this.size=0};var Ji=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i};var Yi=function(t){return this.__data__.get(t)};var Qi=function(t){return this.__data__.has(t)},tn=pi,en=je;var nn,sn=function(t){if(!en(t))return!1;var e=tn(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},on=qe["__core-js_shared__"],rn=(nn=/[^.]+$/.exec(on&&on.keys&&on.keys.IE_PROTO||""))?"Symbol(src)_1."+nn:"";var an=function(t){return!!rn&&rn in t},ln=Function.prototype.toString;var cn=function(t){if(null!=t){try{return ln.call(t)}catch(t){}try{return t+""}catch(t){}}return""},hn=sn,dn=an,pn=je,un=cn,mn=/^\[object .+?Constructor\]$/,fn=Function.prototype,gn=Object.prototype,vn=fn.toString,yn=gn.hasOwnProperty,wn=RegExp("^"+vn.call(yn).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var xn=function(t){return!(!pn(t)||dn(t))&&(hn(t)?wn:mn).test(un(t))},bn=function(t,e){return null==t?void 0:t[e]};var kn=function(t,e){var i=bn(t,e);return xn(i)?i:void 0},_n=kn(qe,"Map"),Sn=kn(Object,"create"),Cn=Sn;var Bn=function(){this.__data__=Cn?Cn(null):{},this.size=0};var An=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},En=Sn,Tn=Object.prototype.hasOwnProperty;var Ln=function(t){var e=this.__data__;if(En){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return Tn.call(e,t)?e[t]:void 0},In=Sn,Mn=Object.prototype.hasOwnProperty;var Pn=Sn;var On=Bn,zn=An,Zn=Ln,Nn=function(t){var e=this.__data__;return In?void 0!==e[t]:Mn.call(e,t)},Hn=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Pn&&void 0===e?"__lodash_hash_undefined__":e,this};function Dn(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Dn.prototype.clear=On,Dn.prototype.delete=zn,Dn.prototype.get=Zn,Dn.prototype.has=Nn,Dn.prototype.set=Hn;var $n=Dn,Vn=Ki,Fn=_n;var jn=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var Rn=function(t,e){var i=t.__data__;return jn(e)?i["string"==typeof e?"string":"hash"]:i.map},Wn=Rn;var Un=Rn;var qn=Rn;var Kn=Rn;var Gn=function(){this.size=0,this.__data__={hash:new $n,map:new(Fn||Vn),string:new $n}},Xn=function(t){var e=Wn(this,t).delete(t);return this.size-=e?1:0,e},Jn=function(t){return Un(this,t).get(t)},Yn=function(t){return qn(this,t).has(t)},Qn=function(t,e){var i=Kn(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this};function ts(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}ts.prototype.clear=Gn,ts.prototype.delete=Xn,ts.prototype.get=Jn,ts.prototype.has=Yn,ts.prototype.set=Qn;var es=ts,is=Ki,ns=_n,ss=es;var os=Ki,rs=Xi,as=Ji,ls=Yi,cs=Qi,hs=function(t,e){var i=this.__data__;if(i instanceof is){var n=i.__data__;if(!ns||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new ss(n)}return i.set(t,e),this.size=i.size,this};function ds(t){var e=this.__data__=new os(t);this.size=e.size}ds.prototype.clear=rs,ds.prototype.delete=as,ds.prototype.get=ls,ds.prototype.has=cs,ds.prototype.set=hs;var ps=ds;var us=es,ms=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},fs=function(t){return this.__data__.has(t)};function gs(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new us;++e<i;)this.add(t[e])}gs.prototype.add=gs.prototype.push=ms,gs.prototype.has=fs;var vs=function(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(e(t[i],i,t))return!0;return!1};var ys=gs,ws=vs,xs=function(t,e){return t.has(e)};var bs=function(t,e,i,n,s,o){var r=1&i,a=t.length,l=e.length;if(a!=l&&!(r&&l>a))return!1;var c=o.get(t),h=o.get(e);if(c&&h)return c==e&&h==t;var d=-1,p=!0,u=2&i?new ys:void 0;for(o.set(t,e),o.set(e,t);++d<a;){var m=t[d],f=e[d];if(n)var g=r?n(f,m,d,e,t,o):n(m,f,d,t,e,o);if(void 0!==g){if(g)continue;p=!1;break}if(u){if(!ws(e,(function(t,e){if(!xs(u,e)&&(m===t||s(m,t,i,n,o)))return u.push(e)}))){p=!1;break}}else if(m!==f&&!s(m,f,i,n,o)){p=!1;break}}return o.delete(t),o.delete(e),p};var ks=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t,n){i[++e]=[n,t]})),i};var _s=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i},Ss=qe.Uint8Array,Cs=Ii,Bs=bs,As=ks,Es=_s,Ts=ei?ei.prototype:void 0,Ls=Ts?Ts.valueOf:void 0;var Is=function(t,e,i,n,s,o,r){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new Ss(t),new Ss(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Cs(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=As;case"[object Set]":var l=1&n;if(a||(a=Es),t.size!=e.size&&!l)return!1;var c=r.get(t);if(c)return c==e;n|=2,r.set(t,e);var h=Bs(a(t),a(e),n,s,o,r);return r.delete(t),h;case"[object Symbol]":if(Ls)return Ls.call(t)==Ls.call(e)}return!1};var Ms=function(t,e){for(var i=-1,n=e.length,s=t.length;++i<n;)t[s+i]=e[i];return t},Ps=Array.isArray,Os=Ms,zs=Ps;var Zs=function(t,e,i){var n=e(t);return zs(t)?n:Os(n,i(t))};var Ns=function(t,e){for(var i=-1,n=null==t?0:t.length,s=0,o=[];++i<n;){var r=t[i];e(r,i,t)&&(o[s++]=r)}return o};var Hs=Ns,Ds=function(){return[]},$s=Object.prototype.propertyIsEnumerable,Vs=Object.getOwnPropertySymbols,Fs=Vs?function(t){return null==t?[]:(t=Object(t),Hs(Vs(t),(function(e){return $s.call(t,e)})))}:Ds;var js=function(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n},Rs=pi,Ws=ui;var Us=function(t){return Ws(t)&&"[object Arguments]"==Rs(t)},qs=ui,Ks=Object.prototype,Gs=Ks.hasOwnProperty,Xs=Ks.propertyIsEnumerable,Js=Us(function(){return arguments}())?Us:function(t){return qs(t)&&Gs.call(t,"callee")&&!Xs.call(t,"callee")},Ys=Js,Qs={exports:{}};var to=function(){return!1};!function(t,e){var i=qe,n=to,s=e&&!e.nodeType&&e,o=s&&t&&!t.nodeType&&t,r=o&&o.exports===s?i.Buffer:void 0,a=(r?r.isBuffer:void 0)||n;t.exports=a}(Qs,Qs.exports);var eo=Qs.exports,io=/^(?:0|[1-9]\d*)$/;var no=function(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&io.test(t))&&t>-1&&t%1==0&&t<e};var so=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},oo=pi,ro=so,ao=ui,lo={};lo["[object Float32Array]"]=lo["[object Float64Array]"]=lo["[object Int8Array]"]=lo["[object Int16Array]"]=lo["[object Int32Array]"]=lo["[object Uint8Array]"]=lo["[object Uint8ClampedArray]"]=lo["[object Uint16Array]"]=lo["[object Uint32Array]"]=!0,lo["[object Arguments]"]=lo["[object Array]"]=lo["[object ArrayBuffer]"]=lo["[object Boolean]"]=lo["[object DataView]"]=lo["[object Date]"]=lo["[object Error]"]=lo["[object Function]"]=lo["[object Map]"]=lo["[object Number]"]=lo["[object Object]"]=lo["[object RegExp]"]=lo["[object Set]"]=lo["[object String]"]=lo["[object WeakMap]"]=!1;var co=function(t){return ao(t)&&ro(t.length)&&!!lo[oo(t)]};var ho=function(t){return function(e){return t(e)}},po={exports:{}};!function(t,e){var i=Re,n=e&&!e.nodeType&&e,s=n&&t&&!t.nodeType&&t,o=s&&s.exports===n&&i.process,r=function(){try{var t=s&&s.require&&s.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=r}(po,po.exports);var uo=po.exports,mo=co,fo=ho,go=uo&&uo.isTypedArray,vo=go?fo(go):mo,yo=js,wo=Ys,xo=Ps,bo=eo,ko=no,_o=vo,So=Object.prototype.hasOwnProperty;var Co=function(t,e){var i=xo(t),n=!i&&wo(t),s=!i&&!n&&bo(t),o=!i&&!n&&!s&&_o(t),r=i||n||s||o,a=r?yo(t.length,String):[],l=a.length;for(var c in t)!e&&!So.call(t,c)||r&&("length"==c||s&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||ko(c,l))||a.push(c);return a},Bo=Object.prototype;var Ao=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Bo)};var Eo=function(t,e){return function(i){return t(e(i))}}(Object.keys,Object),To=Ao,Lo=Eo,Io=Object.prototype.hasOwnProperty;var Mo=sn,Po=so;var Oo=Co,zo=function(t){if(!To(t))return Lo(t);var e=[];for(var i in Object(t))Io.call(t,i)&&"constructor"!=i&&e.push(i);return e},Zo=function(t){return null!=t&&Po(t.length)&&!Mo(t)};var No=Zs,Ho=Fs,Do=function(t){return Zo(t)?Oo(t):zo(t)};var $o=function(t){return No(t,Do,Ho)},Vo=Object.prototype.hasOwnProperty;var Fo=function(t,e,i,n,s,o){var r=1&i,a=$o(t),l=a.length;if(l!=$o(e).length&&!r)return!1;for(var c=l;c--;){var h=a[c];if(!(r?h in e:Vo.call(e,h)))return!1}var d=o.get(t),p=o.get(e);if(d&&p)return d==e&&p==t;var u=!0;o.set(t,e),o.set(e,t);for(var m=r;++c<l;){var f=t[h=a[c]],g=e[h];if(n)var v=r?n(g,f,h,e,t,o):n(f,g,h,t,e,o);if(!(void 0===v?f===g||s(f,g,i,n,o):v)){u=!1;break}m||(m="constructor"==h)}if(u&&!m){var y=t.constructor,w=e.constructor;y==w||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof w&&w instanceof w||(u=!1)}return o.delete(t),o.delete(e),u},jo=kn(qe,"DataView"),Ro=_n,Wo=kn(qe,"Promise"),Uo=kn(qe,"Set"),qo=kn(qe,"WeakMap"),Ko=pi,Go=cn,Xo="[object Map]",Jo="[object Promise]",Yo="[object Set]",Qo="[object WeakMap]",tr="[object DataView]",er=Go(jo),ir=Go(Ro),nr=Go(Wo),sr=Go(Uo),or=Go(qo),rr=Ko;(jo&&rr(new jo(new ArrayBuffer(1)))!=tr||Ro&&rr(new Ro)!=Xo||Wo&&rr(Wo.resolve())!=Jo||Uo&&rr(new Uo)!=Yo||qo&&rr(new qo)!=Qo)&&(rr=function(t){var e=Ko(t),i="[object Object]"==e?t.constructor:void 0,n=i?Go(i):"";if(n)switch(n){case er:return tr;case ir:return Xo;case nr:return Jo;case sr:return Yo;case or:return Qo}return e});var ar=ps,lr=bs,cr=Is,hr=Fo,dr=rr,pr=Ps,ur=eo,mr=vo,fr="[object Arguments]",gr="[object Array]",vr="[object Object]",yr=Object.prototype.hasOwnProperty;var wr=function(t,e,i,n,s,o){var r=pr(t),a=pr(e),l=r?gr:dr(t),c=a?gr:dr(e),h=(l=l==fr?vr:l)==vr,d=(c=c==fr?vr:c)==vr,p=l==c;if(p&&ur(t)){if(!ur(e))return!1;r=!0,h=!1}if(p&&!h)return o||(o=new ar),r||mr(t)?lr(t,e,i,n,s,o):cr(t,e,l,i,n,s,o);if(!(1&i)){var u=h&&yr.call(t,"__wrapped__"),m=d&&yr.call(e,"__wrapped__");if(u||m){var f=u?t.value():t,g=m?e.value():e;return o||(o=new ar),s(f,g,i,n,o)}}return!!p&&(o||(o=new ar),hr(t,e,i,n,s,o))},xr=ui;var br=function t(e,i,n,s,o){return e===i||(null==e||null==i||!xr(e)&&!xr(i)?e!=e&&i!=i:wr(e,i,n,s,t,o))},kr=br;var _r=jt((function(t,e){return kr(t,e)}));function Sr(t){const e=t.get(0),i={};if(e.hasAttributes())for(const t of e.attributes)i[t.name]=t.value;return i}class Cr{constructor(t){const e=window.getSelection();if(!e)throw new Error("Selection object is null.");this.selection=e,this.container=t,this.range=this.getRangeFromNativeSelection()}getRangeFromNativeSelection(){if(this.selection.rangeCount>0){const t=this.selection.getRangeAt(0);return new I(t)}return new I}sync(){this.selection.removeAllRanges(),this.selection.addRange(this.range.get())}updateByRange(){const t=this.getRangeFromNativeSelection();this.range.get()!==t.get()&&(this.range=t)}updateByBookmark(){const t=this.range,e=this.container,i=e.find("lake-box[focus]");if(i.length>0)return he(t,{anchor:new T,focus:i}),void this.sync();he(t,{anchor:e.find('lake-bookmark[type="anchor"]'),focus:e.find('lake-bookmark[type="focus"]')}),this.sync()}getAppliedItems(){const t=[];return function(t,e){let i=e.startNode;for(i.isText&&(i=i.parent());i.length>0&&i.isInside;)t.push({node:i,name:i.name,attributes:Sr(i),styles:p(i.attr("style"))}),i=i.parent()}(t,this.range),function(t,e){const i=e.startNode;let n;if(i.isText&&i.text().length===e.startOffset){const t=i.next();t.length>0&&t.isElement&&(n=t)}if(i.isElement){const t=i.children();if(t.length>0){const i=t[e.startOffset];i&&i.isElement&&(n=i)}}if(n){let e=n;for(;e.length>0;)e.isElement&&t.push({node:e,name:e.name,attributes:Sr(e),styles:p(e.attr("style"))}),e=e.first()}}(t,this.range),t}insertBookmark(){return le(this.range)}toBookmark(t){return he(this.range,t)}insertNode(t){return ae(this.range,t)}insertFragment(t){return ue(this.range,t)}insertContents(t){return me(this.range,t)}deleteContents(){return pe(this.range)}setBlocks(t){return fe(this.range,t)}splitBlock(){return ge(this.range)}splitMarks(t){return we(this.range,t)}addMark(t){return be(this.range,t)}removeMark(t){return _e(this.range,t)}fixList(){return de(this.range)}insertLink(t){return Se(this.range,t)}}class Br{constructor(t){this.commandMap=new Map,this.event=new Wt,this.selection=t}add(t,e){this.commandMap.set(t,e)}delete(t){this.commandMap.delete(t)}getNames(){return Array.from(this.commandMap.keys())}has(t){return void 0!==this.commandMap.get(t)}getItem(t){const e=this.commandMap.get(t);if(void 0===e)throw new Error(`Command '${t}' does not exist.`);return e}isDisabled(t){const e=this.getItem(t);if(!e.isDisabled)return!1;const i=this.selection.getAppliedItems();return e.isDisabled(i)}isSelected(t){const e=this.getItem(t);if(!e.isSelected)return!1;const i=this.selection.getAppliedItems();return e.isSelected(i)}selectedValues(t){const e=this.getItem(t);if(!e.selectedValues)return[];const i=this.selection.getAppliedItems();return e.selectedValues(i)}execute(t,...e){const i=this.getItem(t);this.event.emit("beforeexecute",t),i.execute.apply(this,e),this.event.emit("execute",t),B(`Command '${t}' executed`)}}var Ar,Er={exports:{}};Ar=Er,function(t){function e(t,e){var i=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(i>>16)<<16|65535&i}function i(t,i,n,s,o,r){return e((a=e(e(i,t),e(s,r)))<<(l=o)|a>>>32-l,n);var a,l}function n(t,e,n,s,o,r,a){return i(e&n|~e&s,t,e,o,r,a)}function s(t,e,n,s,o,r,a){return i(e&s|n&~s,t,e,o,r,a)}function o(t,e,n,s,o,r,a){return i(e^n^s,t,e,o,r,a)}function r(t,e,n,s,o,r,a){return i(n^(e|~s),t,e,o,r,a)}function a(t,i){var a,l,c,h,d;t[i>>5]|=128<<i%32,t[14+(i+64>>>9<<4)]=i;var p=1732584193,u=-271733879,m=-1732584194,f=271733878;for(a=0;a<t.length;a+=16)l=p,c=u,h=m,d=f,p=n(p,u,m,f,t[a],7,-680876936),f=n(f,p,u,m,t[a+1],12,-389564586),m=n(m,f,p,u,t[a+2],17,606105819),u=n(u,m,f,p,t[a+3],22,-1044525330),p=n(p,u,m,f,t[a+4],7,-176418897),f=n(f,p,u,m,t[a+5],12,1200080426),m=n(m,f,p,u,t[a+6],17,-1473231341),u=n(u,m,f,p,t[a+7],22,-45705983),p=n(p,u,m,f,t[a+8],7,1770035416),f=n(f,p,u,m,t[a+9],12,-1958414417),m=n(m,f,p,u,t[a+10],17,-42063),u=n(u,m,f,p,t[a+11],22,-1990404162),p=n(p,u,m,f,t[a+12],7,1804603682),f=n(f,p,u,m,t[a+13],12,-40341101),m=n(m,f,p,u,t[a+14],17,-1502002290),p=s(p,u=n(u,m,f,p,t[a+15],22,1236535329),m,f,t[a+1],5,-165796510),f=s(f,p,u,m,t[a+6],9,-1069501632),m=s(m,f,p,u,t[a+11],14,643717713),u=s(u,m,f,p,t[a],20,-373897302),p=s(p,u,m,f,t[a+5],5,-701558691),f=s(f,p,u,m,t[a+10],9,38016083),m=s(m,f,p,u,t[a+15],14,-660478335),u=s(u,m,f,p,t[a+4],20,-405537848),p=s(p,u,m,f,t[a+9],5,568446438),f=s(f,p,u,m,t[a+14],9,-1019803690),m=s(m,f,p,u,t[a+3],14,-187363961),u=s(u,m,f,p,t[a+8],20,1163531501),p=s(p,u,m,f,t[a+13],5,-1444681467),f=s(f,p,u,m,t[a+2],9,-51403784),m=s(m,f,p,u,t[a+7],14,1735328473),p=o(p,u=s(u,m,f,p,t[a+12],20,-1926607734),m,f,t[a+5],4,-378558),f=o(f,p,u,m,t[a+8],11,-2022574463),m=o(m,f,p,u,t[a+11],16,1839030562),u=o(u,m,f,p,t[a+14],23,-35309556),p=o(p,u,m,f,t[a+1],4,-1530992060),f=o(f,p,u,m,t[a+4],11,1272893353),m=o(m,f,p,u,t[a+7],16,-155497632),u=o(u,m,f,p,t[a+10],23,-1094730640),p=o(p,u,m,f,t[a+13],4,681279174),f=o(f,p,u,m,t[a],11,-358537222),m=o(m,f,p,u,t[a+3],16,-722521979),u=o(u,m,f,p,t[a+6],23,76029189),p=o(p,u,m,f,t[a+9],4,-640364487),f=o(f,p,u,m,t[a+12],11,-421815835),m=o(m,f,p,u,t[a+15],16,530742520),p=r(p,u=o(u,m,f,p,t[a+2],23,-995338651),m,f,t[a],6,-198630844),f=r(f,p,u,m,t[a+7],10,1126891415),m=r(m,f,p,u,t[a+14],15,-1416354905),u=r(u,m,f,p,t[a+5],21,-57434055),p=r(p,u,m,f,t[a+12],6,1700485571),f=r(f,p,u,m,t[a+3],10,-1894986606),m=r(m,f,p,u,t[a+10],15,-1051523),u=r(u,m,f,p,t[a+1],21,-2054922799),p=r(p,u,m,f,t[a+8],6,1873313359),f=r(f,p,u,m,t[a+15],10,-30611744),m=r(m,f,p,u,t[a+6],15,-1560198380),u=r(u,m,f,p,t[a+13],21,1309151649),p=r(p,u,m,f,t[a+4],6,-145523070),f=r(f,p,u,m,t[a+11],10,-1120210379),m=r(m,f,p,u,t[a+2],15,718787259),u=r(u,m,f,p,t[a+9],21,-343485551),p=e(p,l),u=e(u,c),m=e(m,h),f=e(f,d);return[p,u,m,f]}function l(t){var e,i="",n=32*t.length;for(e=0;e<n;e+=8)i+=String.fromCharCode(t[e>>5]>>>e%32&255);return i}function c(t){var e,i=[];for(i[(t.length>>2)-1]=void 0,e=0;e<i.length;e+=1)i[e]=0;var n=8*t.length;for(e=0;e<n;e+=8)i[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return i}function h(t){var e,i,n="0123456789abcdef",s="";for(i=0;i<t.length;i+=1)e=t.charCodeAt(i),s+=n.charAt(e>>>4&15)+n.charAt(15&e);return s}function d(t){return unescape(encodeURIComponent(t))}function p(t){return function(t){return l(a(c(t),8*t.length))}(d(t))}function u(t,e){return function(t,e){var i,n,s=c(t),o=[],r=[];for(o[15]=r[15]=void 0,s.length>16&&(s=a(s,8*t.length)),i=0;i<16;i+=1)o[i]=909522486^s[i],r[i]=1549556828^s[i];return n=a(o.concat(c(e)),512+8*e.length),l(a(r.concat(n),640))}(d(t),d(e))}function m(t,e,i){return e?i?u(e,t):h(u(e,t)):i?p(t):h(p(t))}Ar.exports?Ar.exports=m:t.md5=m}(Ft);var Tr=jt(Er.exports);class Lr{constructor(t){this.list=[],this.index=0,this.canSave=!0,this.limit=100,this.event=new Wt,this.selection=t,this.container=t.container}removeBookmark(t){return t.replace(/(<lake-box[^>]+)\s+focus="\w+"([^>]*>)/gi,"$1$2").replace(/<lake-bookmark\s+type="anchor">\s*<\/lake-bookmark>/gi,"").replace(/<lake-bookmark\s+type="focus">\s*<\/lake-bookmark>/gi,"")}getValue(t){return new oe(t).getHTML()}addIdToBoxes(t){t.find("lake-box").each((t=>{const e=new T(t),i=Tr(`${e.attr("type")}-${e.attr("name")}-${e.attr("value")}`);e.attr("id",i)}))}removeIdfromBoxes(t){t.find("lake-box").each((t=>{new T(t).removeAttr("id")}))}morphContainer(t){const e=this.container,i={beforeChildrenUpdated:t=>{if("lake-box"===new T(t).name)return!1},afterAttributeUpdated:(t,i)=>{const n=new T(i);if("value"===t&&"lake-box"===n.name){const t=pt.get(e.id);if(!t)return;t.delete(n.id)}}},n=t.clone(!0);this.addIdToBoxes(e),this.addIdToBoxes(n),ht(e,n,{callbacks:i}),this.removeIdfromBoxes(e),this.removeIdfromBoxes(n)}cloneContainer(){const t=this.selection.range,e=this.container.clone(!0);if(e.find("lake-box").each((t=>{Yt(t).getContainer().empty()})),t.commonAncestor.isOutside)return e;if(t.isInsideBox)return e;const i=t.startNode.path(),n=t.endNode.path(),s=e.find(i),o=e.find(n),r=t.clone();return r.setStart(s,t.startOffset),r.setEnd(o,t.endOffset),le(r),e}get count(){return this.list.length}get canUndo(){return this.index>1&&!!this.list[this.index-1]}get canRedo(){return!!this.list[this.index]}undo(){if(!this.list[this.index-1])return;this.selection.insertBookmark();const t=this.getValue(this.container);for(;this.index>0;){const e=this.list[this.index-1];if(!e)break;const i=this.getValue(e);if(this.removeBookmark(i)!==this.removeBookmark(t)){this.morphContainer(e),this.event.emit("undo",i);break}if(1===this.index)break;this.index--}this.selection.updateByBookmark(),B(`History undone, the last index is ${this.index}`)}redo(){if(!this.list[this.index])return;this.selection.insertBookmark();const t=this.getValue(this.container);for(;this.index<this.list.length;){const e=this.list[this.index];if(!e)break;this.index++;const i=this.getValue(e);if(this.removeBookmark(i)!==this.removeBookmark(t)){this.morphContainer(e),this.event.emit("redo",i);break}}this.selection.updateByBookmark(),B(`History redone, the last index is ${this.index}`)}continue(){this.canSave=!0}pause(){this.canSave=!1}save(t=!0){if(!this.canSave)return;const e=this.cloneContainer(),i=this.getValue(e);this.list[this.index-1]&&this.removeBookmark(this.getValue(this.list[this.index-1]))===this.removeBookmark(i)||(this.list.splice(this.index,1/0,e),this.index++,this.list.length>this.limit&&(this.list.shift(),this.index=this.list.length),t&&this.event.emit("save",m(i)),B(`History saved, the last index is ${this.index}`))}}var Ir=["Shift","Meta","Alt","Control"],Mr="object"==typeof navigator?navigator.platform:"",Pr=/Mac|iPod|iPhone|iPad/.test(Mr),Or=Pr?"Meta":"Control",zr="Win32"===Mr?["Control","Alt"]:Pr?["Alt"]:[];function Zr(t,e){return"function"==typeof t.getModifierState&&(t.getModifierState(e)||zr.includes(e)&&t.getModifierState("AltGraph"))}function Nr(t){return t.trim().split(" ").map((function(t){var e=t.split(/\b\+/),i=e.pop();return[e=e.map((function(t){return"$mod"===t?Or:t})),i]}))}function Hr(t,e){var i;void 0===e&&(e={});var n=null!=(i=e.timeout)?i:1e3,s=Object.keys(t).map((function(e){return[Nr(e),t[e]]})),o=new Map,r=null;return function(t){t instanceof KeyboardEvent&&(s.forEach((function(e){var i=e[0],n=e[1],s=o.get(i)||i;!function(t,e){return!(e[1].toUpperCase()!==t.key.toUpperCase()&&e[1]!==t.code||e[0].find((function(e){return!Zr(t,e)}))||Ir.find((function(i){return!e[0].includes(i)&&e[1]!==i&&Zr(t,i)})))}(t,s[0])?Zr(t,t.key)||o.delete(i):s.length>1?o.set(i,s.slice(1)):(o.delete(i),n(t))})),r&&clearTimeout(r),r=setTimeout(o.clear.bind(o),n))}}const Dr=new Map([["#","shift+#"]]);class $r{constructor(t){this.keydownEventList=[],this.keyupEventList=[],this.container=t}normalizeType(t){var e;return t=(t=null!==(e=Dr.get(t))&&void 0!==e?e:t).replace(/(^|\+|\s)mod(\+|\s|$)/g,"$1$mod$2").replace(/shift|control|alt|meta|enter|tab|backspace|delete|space|escape|arrow-left|arrow-right|arrow-up|arrow-down/,(t=>t.charAt(0).toUpperCase()+l(t.substring(1)))).replace(/(^|\+|\s)([a-z])(\+|\s|$)/g,((t,e,i,n)=>`${e}Key${i.toUpperCase()}${n}`))}setKeydown(t,e){t=this.normalizeType(t);const i=Hr({[t]:t=>e(t)});this.keydownEventList.push({type:t,listener:e}),this.container.on("keydown",i)}setKeyup(t,e){t=this.normalizeType(t);const i=Hr({[t]:t=>e(t)});this.keyupEventList.push({type:t,listener:e}),this.container.on("keyup",i)}keydown(t){t=this.normalizeType(t);for(const e of this.keydownEventList)if(e.type===t&&!1===e.listener(new Event(t)))break}keyup(t){t=this.normalizeType(t);for(const e of this.keyupEventList)if(e.type===t&&!1===e.listener(new Event(t)))break}}const Vr={value:"<p><br /></p>",readonly:!1,spellcheck:!1,tabIndex:0,placeholder:"",indentWithTab:!0,lang:"en-US",minChangeSize:5,onMessage:(t,e)=>{"success"!==t?"warning"!==t?"error"===t&&console.error(e):console.warn(e):console.log(e)}};class Fr{constructor(t){if(this.unsavedInputData="",this.state={appliedItems:[],disabledNameMap:new Map,selectedNameMap:new Map,selectedValuesMap:new Map},this.isComposing=!1,this.event=new Wt,this.box=Fr.box,this.copyListener=t=>{this.selection.range.commonAncestor.closestContainer().get(0)===this.container.get(0)&&this.event.emit("copy",t)},this.cutListener=t=>{this.selection.range.commonAncestor.closestContainer().get(0)===this.container.get(0)&&this.event.emit("cut",t)},this.pasteListener=t=>{this.selection.range.commonAncestor.closestContainer().get(0)===this.container.get(0)&&this.event.emit("paste",t)},this.beforeunloadListener=()=>{this.history.save()},this.selectionchangeListener=()=>{this.selection.updateByRange(),this.updateBoxSelectionStyle(),this.emitStateChangeEvent()},this.clickListener=t=>{const e=new T(t.target);!e.get(0).isConnected||e.closest(".lake-popup").length>0||this.event.emit("click",e)},this.resizeListener=()=>{this.event.emit("resize")},this.updateBoxSelectionStyle=Ti((()=>{if(0===this.root.first().length)return;const t=this.selection.range,e=t.clone();e.adaptBox(),this.container.find("lake-box").each((i=>{const n=Yt(i),s=n.getContainer();if(0!==s.length){if(t.compareBeforeNode(s)<0&&t.compareAfterNode(s)>0&&(!t.isCollapsed||t.startNode.get(0)!==s.get(0)||0!==t.startOffset))return s.removeClass("lake-box-hovered"),s.removeClass("lake-box-selected"),s.removeClass("lake-box-focused"),s.addClass("lake-box-activated"),void n.event.emit("focus");if(e.intersectsNode(n.node))return s.removeClass("lake-box-activated"),void(t.isCollapsed?(s.removeClass("lake-box-hovered"),s.removeClass("lake-box-selected"),s.addClass("lake-box-focused"),n.event.emit("focus")):(s.removeClass("lake-box-focused"),s.addClass("lake-box-selected"),n.event.emit("blur")));s.removeClass("lake-box-activated"),s.removeClass("lake-box-focused"),s.removeClass("lake-box-selected"),n.event.emit("blur")}})),this.event.emit("boxselectionstylechange")}),50,{leading:!1,trailing:!0,maxWait:50}),this.emitStateChangeEvent=Ti((()=>{const t=this.command.getNames();let e=this.selection.getAppliedItems();e.length>0&&e[0].node.closestContainer().get(0)!==this.container.get(0)&&(e=[]);const i=new Map,n=new Map,s=new Map;if(e.length>0)for(const o of t){const t=this.command.getItem(o);if(t.isDisabled&&t.isDisabled(e)&&i.set(o,!0),t.isSelected&&t.isSelected(e)&&n.set(o,!0),t.selectedValues){const i=t.selectedValues(e);i.length>0&&s.set(o,i)}}const o={appliedItems:e,disabledNameMap:i,selectedNameMap:n,selectedValuesMap:s};_r(o,this.state)||(this.toolbar&&this.toolbar.updateState(o),this.event.emit("statechange",o),this.state=o)}),100,{leading:!1,trailing:!0,maxWait:100}),this.emitChangeEvent=t=>{this.rectifyContent(),this.emitStateChangeEvent(),this.togglePlaceholderClass(t),this.scrollToCaret(),this.event.emit("change",t)},!t.root)throw new Error("The root of the config must be specified.");this.root=L(t.root),this.toolbar=t.toolbar,this.config=Object.assign({},Vr);for(const e of Object.keys(t))this.config[e]=t[e];this.containerWrapper=L('<div class="lake-container-wrapper" />'),this.container=L('<div class="lake-container" />'),this.overlayContainer=L('<div class="lake-overlay" />'),this.popupContainer=L('<div class="lake-popup lake-custom-properties" />'),this.readonly=this.config.readonly,this.root.addClass("lake-custom-properties"),this.container.attr({contenteditable:this.readonly?"false":"true",spellcheck:this.config.spellcheck?"true":"false",tabindex:this.config.tabIndex.toString()}),""!==this.config.placeholder&&this.container.attr("placeholder",this.config.placeholder),this.selection=new Cr(this.container),this.command=new Br(this.selection),this.history=new Lr(this.selection),this.keystroke=new $r(this.container),qt.set(this.container.id,this)}togglePlaceholderClass(t){const e="lake-show-placeholder";"<p><br /></p>"===(t=m(t)).replace("<focus />","")?this.container.addClass(e):this.container.removeClass(e)}inputInBoxStrip(){const t=this.selection,e=t.range,i=e.startNode.closest(".lake-box-strip"),n=i.closest("lake-box");if("inline"===Yt(n).type)e.isBoxStart?(e.setStartBefore(n),e.collapseToStart()):(e.setStartAfter(n),e.collapseToStart());else{const t=L("<p />");e.isBoxStart?n.before(t):n.after(t),e.shrinkAfter(t)}const s=i.text();i.html("<br />"),t.insertNode(document.createTextNode(s))}bindInputEvents(){this.container.on("compositionstart",(()=>{this.isComposing=!0})),this.container.on("compositionend",(()=>{this.isComposing=!1})),this.container.on("beforeinput",(t=>{const e=t,i=this.selection.range;(i.isBoxStart||i.isBoxEnd||"insertText"!==e.inputType&&"insertCompositionText"!==e.inputType)&&this.commitUnsavedInputData()})),this.container.on("input",(t=>{const e=t;window.setTimeout((()=>{var t;const i=this.selection.range;if(!i.isInsideBox)if(this.isComposing)this.event.emit("input",e);else{if(i.isBoxStart||i.isBoxEnd)return this.inputInBoxStrip(),this.history.save(),void this.event.emit("input",e);if(("insertText"===e.inputType||"insertCompositionText"===e.inputType)&&(this.unsavedInputData+=null!==(t=e.data)&&void 0!==t?t:"",this.unsavedInputData.length<this.config.minChangeSize))return this.event.emit("input",e),void this.emitChangeEvent(this.getValue());this.history.save(),this.event.emit("input",e)}}),0)})),this.command.event.on("beforeexecute",(()=>this.commitUnsavedInputData()))}bindHistoryEvents(){this.history.event.on("undo",(t=>{this.box.renderAll(this.container),this.emitChangeEvent(t)})),this.history.event.on("redo",(t=>{this.box.renderAll(this.container),this.emitChangeEvent(t)})),this.history.event.on("save",(t=>{this.box.rectifyInstances(this.container),this.emitChangeEvent(t)}))}get hasFocus(){const t=document.activeElement;return!!t&&L(t).closest(".lake-container").get(0)===this.container.get(0)}get locale(){return Ve(this.config.lang)}rectifyContent(){let t=this.container.children();for(const e of t)(e.isBlock||e.isMark)&&""===e.html()&&(e.remove(),B("Rectifying content: empty tag was removed"));if(t=this.container.children(),0===t.length)return this.container.html("<p><br /></p>"),this.selection.range.shrinkAfter(this.container),void B("Rectifying content: default paragraph was added");if(1===t.length){const e=t[0];if(e.isVoid){const t=L("<p />");e.before(t),t.append(e),this.selection.range.shrinkAfter(t),B("Rectifying content: void element was wrapped in paragraph")}}}commitUnsavedInputData(){this.unsavedInputData.length>0&&(this.history.save(!1),this.unsavedInputData="")}prepareOperation(){this.commitUnsavedInputData(),this.history.pause()}commitOperation(){this.history.continue(),this.history.save()}setPluginConfig(t,e){this.config[t]||(this.config[t]={});for(const i of Object.keys(e))void 0===this.config[t][i]&&(this.config[t][i]=e[i])}focus(){this.container.focus()}blur(){this.container.blur()}scrollToCaret(){const t=this.selection.range.getRect(),e=this.container.get(0).getBoundingClientRect(),i=L('<div class="lake-artificial-caret" />'),n=t.x-e.x,s=t.y-e.y;let o,r,a,l;i.css({position:"absolute",top:`${s}px`,left:`${n}px`,width:`${t.width}px`,height:`${t.height}px`,"z-index":"-1"}),this.overlayContainer.find(".lake-artificial-caret").remove(),this.overlayContainer.append(i);const c=this.container.closestScroller();if(c.length>0){const t=c.get(0),e=t.getBoundingClientRect();o=t.scrollLeft,r=t.scrollTop,a=e.width,l=e.height}else{const t=this.containerWrapper.get(0);o=window.scrollX,r=window.scrollY,a=window.innerWidth-t.offsetLeft,l=window.innerHeight-t.offsetTop}let h=!1,d=!0;(n<o||n>o+a)&&(h=!0),s<r?(h=!0,d=!0):s>r+l&&(h=!0,d=!1),h&&i.get(0).scrollIntoView(d),i.remove()}setValue(t){t=u(t);const e=new oe(t),i=e.getFragment();this.container.empty(),this.togglePlaceholderClass(e.getHTML()),this.container.append(i),Fr.box.renderAll(this.container),this.selection.updateByBookmark()}getValue(){const t=this.selection.insertBookmark();let e=new oe(this.container).getHTML();return e=m(e),this.selection.toBookmark(t),e}selectBox(t){let e=t;e=t instanceof Jt?t.node:t,this.selection.range.selectBox(e)}insertBox(t,e){const i=function(t,e,i){if(t.commonAncestor.isOutside)return null;const n=Yt(e);i&&(n.value=i);const s=document.createDocumentFragment();if(s.appendChild(n.node.get(0)),"inline"===n.type)return ue(t,s),n.render(),t.selectBoxEnd(n.node),n;const o=ge(t);return o.start&&(t.setEndAfter(o.start),t.collapseToEnd()),o.end&&o.end.isEmpty&&o.end.remove(),ue(t,s),n.render(),t.selectBoxEnd(n.node),o.start&&o.start.isEmpty&&o.start.remove(),n}(this.selection.range,t,e);if(!i)throw new Error(`Box '${t}' cannot be inserted outside the editor.`);return this.box.getInstances(this.container).set(i.node.id,i),i}removeBox(t=null){if(t&&this.selectBox(t),t=function(t){if(t.commonAncestor.isOutside)return null;const e=t.commonAncestor.closest("lake-box");if(0===e.length)return null;const i=Yt(e);if("block"===i.type){const n=L("<p><br /></p>");return e.before(n),t.shrinkAfter(n),i.unmount(),e.remove(),i}t.setStartBefore(e),t.collapseToStart();const n=e.parent();return i.unmount(),e.remove(),n.isEmpty&&(P(n,L("<br />")),t.shrinkAfter(n)),i}(this.selection.range),t){this.box.getInstances(this.container).delete(t.node.id)}return t}render(){const t=u(this.config.value),e=new oe(t),i=e.getFragment();this.root.empty(),this.root.append(this.containerWrapper),this.containerWrapper.append(this.container),this.containerWrapper.append(this.overlayContainer),L(document.body).append(this.popupContainer),this.togglePlaceholderClass(e.getHTML()),this.container.append(i),Fr.plugin.loadAll(this),this.readonly||(this.selection.updateByBookmark(),this.history.save()),Fr.box.renderAll(this.container),this.toolbar&&this.toolbar.render(this),document.addEventListener("copy",this.copyListener),this.readonly||(document.addEventListener("cut",this.cutListener),document.addEventListener("paste",this.pasteListener),window.addEventListener("beforeunload",this.beforeunloadListener),document.addEventListener("selectionchange",this.selectionchangeListener),document.addEventListener("click",this.clickListener),window.addEventListener("resize",this.resizeListener),this.bindInputEvents(),this.bindHistoryEvents())}unmount(){this.event.removeAllListeners(),this.command.event.removeAllListeners(),this.history.event.removeAllListeners(),this.root.empty(),this.popupContainer.remove(),document.removeEventListener("copy",this.copyListener),this.readonly||(document.removeEventListener("cut",this.cutListener),document.removeEventListener("paste",this.pasteListener),window.removeEventListener("beforeunload",this.beforeunloadListener),document.removeEventListener("selectionchange",this.selectionchangeListener),document.removeEventListener("click",this.clickListener),window.removeEventListener("resize",this.resizeListener))}}Fr.version="0.1.10",Fr.box=new class{add(t){Ut.set(t.name,t)}remove(t){Ut.delete(t)}getNames(){return Array.from(Ut.keys())}getInstances(t){let e=pt.get(t.id);return e||(e=new Map,pt.set(t.id,e),e)}rectifyInstances(t){const e=this.getInstances(t);for(const t of e.values())t.node.get(0).isConnected||(t.unmount(),e.delete(t.node.id))}renderAll(t){this.rectifyInstances(t);const e=this.getInstances(t);t.find("lake-box").each((t=>{const i=L(t);if(e.get(i.id))return;Yt(i).render()}))}},Fr.plugin=new class{constructor(){this.pluginList=[]}add(t){this.pluginList.push(t)}loadAll(t){this.pluginList.forEach((e=>{e(t)}))}};const jr=[{icon:n.get("numberedList"),value:"numbered",text:t=>t.toolbar.numberedList()},{icon:n.get("bulletedList"),value:"bulleted",text:t=>t.toolbar.bulletedList()},{icon:n.get("checklist"),value:"checklist",text:t=>t.toolbar.checklist()}],Rr=[{icon:n.get("alignLeft"),value:"left",text:t=>t.toolbar.alignLeft()},{icon:n.get("alignCenter"),value:"center",text:t=>t.toolbar.alignCenter()},{icon:n.get("alignRight"),value:"right",text:t=>t.toolbar.alignRight()},{icon:n.get("alignJustify"),value:"justify",text:t=>t.toolbar.alignJustify()}],Wr=[{icon:n.get("increaseIndent"),value:"increase",text:t=>t.toolbar.increaseIndent()},{icon:n.get("decreaseIndent"),value:"decrease",text:t=>t.toolbar.decreaseIndent()}],Ur=[{icon:n.get("italic"),value:"italic",text:t=>t.toolbar.italic()},{icon:n.get("underline"),value:"underline",text:t=>t.toolbar.underline()},{icon:n.get("strikethrough"),value:"strikethrough",text:t=>t.toolbar.strikethrough()},{icon:n.get("superscript"),value:"superscript",text:t=>t.toolbar.superscript()},{icon:n.get("subscript"),value:"subscript",text:t=>t.toolbar.subscript()},{icon:n.get("code"),value:"code",text:t=>t.toolbar.code()}],qr=["#f5222d","#fa541c","#fa8c16","#faad14","#fadb14","#a0d911","#52c41a","#13c2c2","#1677ff","#2f54eb","#722ed1","#eb2f96","#fff1f0","#fff2e8","#fff7e6","#fffbe6","#feffe6","#fcffe6","#f6ffed","#e6fffb","#e6f4ff","#f0f5ff","#f9f0ff","#fff0f6","#ffccc7","#ffd8bf","#ffe7ba","#fff1b8","#ffffb8","#f4ffb8","#d9f7be","#b5f5ec","#bae0ff","#d6e4ff","#efdbff","#ffd6e7","#ffa39e","#ffbb96","#ffd591","#ffe58f","#fffb8f","#eaff8f","#b7eb8f","#87e8de","#91caff","#adc6ff","#d3adf7","#ffadd2","#ff7875","#ff9c6e","#ffc069","#ffd666","#fff566","#d3f261","#95de64","#5cdbd3","#69b1ff","#85a5ff","#b37feb","#ff85c0","#ff4d4f","#ff7a45","#ffa940","#ffc53d","#ffec3d","#bae637","#73d13d","#36cfc9","#4096ff","#597ef7","#9254de","#f759ab","#cf1322","#d4380d","#d46b08","#d48806","#d4b106","#7cb305","#389e0d","#08979c","#0958d9","#1d39c4","#531dab","#c41d7f","#a8071a","#ad2102","#ad4e00","#ad6800","#ad8b00","#5b8c00","#237804","#006d75","#003eb3","#10239e","#391085","#9e1068","#820014","#871400","#873800","#874d00","#876800","#3f6600","#135200","#00474f","#002c8c","#061178","#22075e","#780650","#5c0011","#610b00","#612500","#613400","#614700","#254000","#092b00","#002329","#001d66","#030852","#120338","#520339","#000000","#1f1f1f","#262626","#434343","#595959","#8c8c8c","#bfbfbf","#d9d9d9","#f0f0f0","#f5f5f5","#fafafa","#ffffff"],Kr=[{icon:n.get("removeFormat"),value:"",text:t=>t.toolbar.removeColor()}];for(const t of qr)Kr.push({value:t.toLowerCase(),text:t.toUpperCase()});const Gr=new Map([["strong","bold"],["em","italic"],["i","italic"],["u","underline"],["s","strikethrough"],["sup","superscript"],["sub","subscript"],["code","code"]]),Xr=[{name:"undo",type:"button",icon:n.get("undo"),tooltip:t=>t.toolbar.undo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"redo",type:"button",icon:n.get("redo"),tooltip:t=>t.toolbar.redo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"selectAll",type:"button",icon:n.get("selectAll"),tooltip:t=>t.toolbar.selectAll(),onClick:(t,e)=>{t.command.execute(e)}},{name:"paragraph",type:"button",icon:n.get("paragraph"),tooltip:t=>t.toolbar.paragraph(),isSelected:t=>!!t.find((t=>"p"===t.name)),onClick:t=>{t.command.execute("heading","p")}},{name:"blockQuote",type:"button",icon:n.get("blockQuote"),tooltip:t=>t.toolbar.blockQuote(),onClick:(t,e)=>{t.command.execute(e)}},{name:"numberedList",type:"button",icon:n.get("numberedList"),tooltip:t=>t.toolbar.numberedList(),isSelected:t=>!!t.find((t=>"ol"===t.name)),onClick:t=>{t.command.execute("list","numbered")}},{name:"bulletedList",type:"button",icon:n.get("bulletedList"),tooltip:t=>t.toolbar.bulletedList(),isSelected:t=>!!t.find((t=>"ul"===t.name&&!t.node.hasAttr("type"))),onClick:t=>{t.command.execute("list","bulleted")}},{name:"checklist",type:"button",icon:n.get("checklist"),tooltip:t=>t.toolbar.checklist(),isSelected:t=>!!t.find((t=>"ul"===t.name&&"checklist"===t.node.attr("type"))),onClick:t=>{t.command.execute("list","checklist")}},{name:"alignLeft",type:"button",icon:n.get("alignLeft"),tooltip:t=>t.toolbar.alignLeft(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"left"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","left")}},{name:"alignCenter",type:"button",icon:n.get("alignCenter"),tooltip:t=>t.toolbar.alignCenter(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"center"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","center")}},{name:"alignRight",type:"button",icon:n.get("alignRight"),tooltip:t=>t.toolbar.alignRight(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"right"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","right")}},{name:"alignJustify",type:"button",icon:n.get("alignJustify"),tooltip:t=>t.toolbar.alignJustify(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"justify"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","justify")}},{name:"increaseIndent",type:"button",icon:n.get("increaseIndent"),tooltip:t=>t.toolbar.increaseIndent(),onClick:t=>{t.command.execute("indent","increase")}},{name:"decreaseIndent",type:"button",icon:n.get("decreaseIndent"),tooltip:t=>t.toolbar.decreaseIndent(),onClick:t=>{t.command.execute("indent","decrease")}},{name:"bold",type:"button",icon:n.get("bold"),tooltip:t=>t.toolbar.bold(),onClick:(t,e)=>{t.command.execute(e)}},{name:"italic",type:"button",icon:n.get("italic"),tooltip:t=>t.toolbar.italic(),onClick:(t,e)=>{t.command.execute(e)}},{name:"underline",type:"button",icon:n.get("underline"),tooltip:t=>t.toolbar.underline(),onClick:(t,e)=>{t.command.execute(e)}},{name:"strikethrough",type:"button",icon:n.get("strikethrough"),tooltip:t=>t.toolbar.strikethrough(),onClick:(t,e)=>{t.command.execute(e)}},{name:"superscript",type:"button",icon:n.get("superscript"),tooltip:t=>t.toolbar.superscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"subscript",type:"button",icon:n.get("subscript"),tooltip:t=>t.toolbar.subscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"code",type:"button",icon:n.get("code"),tooltip:t=>t.toolbar.code(),onClick:(t,e)=>{t.command.execute(e)}},{name:"removeFormat",type:"button",icon:n.get("removeFormat"),tooltip:t=>t.toolbar.removeFormat(),onClick:(t,e)=>{t.command.execute(e)}},{name:"formatPainter",type:"button",icon:n.get("formatPainter"),tooltip:t=>t.toolbar.formatPainter(),onClick:(t,e)=>{t.command.execute(e)}},{name:"link",type:"button",icon:n.get("link"),tooltip:t=>t.toolbar.link(),onClick:(t,e)=>{t.command.execute(e)}},{name:"hr",type:"button",icon:n.get("hr"),tooltip:t=>t.toolbar.hr(),onClick:(t,e)=>{t.command.execute(e)}},{name:"codeBlock",type:"button",icon:n.get("codeBlock"),tooltip:t=>t.toolbar.codeBlock(),onClick:(t,e)=>{t.command.execute(e)}},{name:"heading",type:"dropdown",downIcon:n.get("down"),defaultValue:"p",tooltip:t=>t.toolbar.heading(),width:"100px",menuType:"list",menuItems:[{value:"h1",text:t=>`<span style="font-weight: bold; font-size: 26px;">${t.toolbar.heading1()}</span>`},{value:"h2",text:t=>`<span style="font-weight: bold; font-size: 24px;">${t.toolbar.heading2()}</span>`},{value:"h3",text:t=>`<span style="font-weight: bold; font-size: 22px;">${t.toolbar.heading3()}</span>`},{value:"h4",text:t=>`<span style="font-weight: bold; font-size: 20px;">${t.toolbar.heading4()}</span>`},{value:"h5",text:t=>`<span style="font-weight: bold; font-size: 18px;">${t.toolbar.heading5()}</span>`},{value:"h6",text:t=>`<span style="font-weight: bold; font-size: 16px;">${t.toolbar.heading6()}</span>`},{value:"p",text:t=>t.toolbar.paragraph()}],onSelect:(t,e)=>{t.command.execute("heading",e)}},{name:"list",type:"dropdown",downIcon:n.get("down"),icon:n.get("list"),defaultValue:"",tooltip:t=>t.toolbar.list(),width:"auto",menuType:"list",menuItems:jr,onSelect:(t,e)=>{t.command.execute("list",e)}},{name:"align",type:"dropdown",downIcon:n.get("down"),icon:n.get("alignLeft"),defaultValue:"",tooltip:t=>t.toolbar.align(),width:"auto",menuType:"list",menuItems:Rr,onSelect:(t,e)=>{t.command.execute("align",e)}},{name:"indent",type:"dropdown",downIcon:n.get("down"),icon:n.get("increaseIndent"),defaultValue:"",tooltip:t=>t.toolbar.indent(),width:"auto",menuType:"list",menuItems:Wr,onSelect:(t,e)=>{t.command.execute("indent",e)}},{name:"fontFamily",type:"dropdown",downIcon:n.get("down"),defaultValue:"Segoe UI",tooltip:t=>t.toolbar.fontFamily(),width:"100px",menuType:"list",menuItems:[{value:"Arial",text:'<span style="font-family: Arial;">Arial</span>'},{value:"Arial Black",text:"<span style=\"font-family: 'Arial Black';\">Arial Black</span>"},{value:"Comic Sans MS",text:"<span style=\"font-family: 'Comic Sans MS';\">Comic Sans MS</span>"},{value:"Courier New",text:"<span style=\"font-family: 'Courier New';\">Courier New</span>"},{value:"Georgia",text:'<span style="font-family: Georgia;">Georgia</span>'},{value:"Helvetica",text:'<span style="font-family: Helvetica;">Helvetica</span>'},{value:"Impact",text:'<span style="font-family: Impact;">Impact</span>'},{value:"Segoe UI",text:"<span style=\"font-family: 'Segoe UI';\">Segoe UI</span>"},{value:"Tahoma",text:'<span style="font-family: Tahoma;">Tahoma</span>'},{value:"Times New Roman",text:"<span style=\"font-family: 'Times New Roman';\">Times New Roman</span>"},{value:"Trebuchet MS",text:"<span style=\"font-family: 'Trebuchet MS';\">Trebuchet MS</span>"},{value:"Verdana",text:'<span style="font-family: Verdana;">Verdana</span>'}],onSelect:(t,e)=>{t.command.execute("fontFamily",e)}},{name:"fontSize",type:"dropdown",downIcon:n.get("down"),defaultValue:"16px",tooltip:t=>t.toolbar.fontSize(),width:"65px",menuType:"list",menuItems:[{value:"12px",text:"12px"},{value:"14px",text:"14px"},{value:"16px",text:"16px"},{value:"18px",text:"18px"},{value:"22px",text:"22px"},{value:"24px",text:"24px"},{value:"32px",text:"32px"}],onSelect:(t,e)=>{t.command.execute("fontSize",e)}},{name:"moreStyle",type:"dropdown",icon:n.get("more"),defaultValue:"",tooltip:t=>t.toolbar.moreStyle(),width:"auto",menuType:"list",menuItems:Ur,selectedValues:t=>{var e;const i=[];for(const n of t)if(n.node.isMark){const t=null!==(e=Gr.get(n.name))&&void 0!==e?e:n.name;i.push(t)}return i},onSelect:(t,e)=>{t.command.execute(e)}},{name:"fontColor",type:"dropdown",downIcon:n.get("down"),icon:n.get("fontColor"),accentIcon:n.get("fontColorAccent"),defaultValue:"#f5222d",tooltip:t=>t.toolbar.fontColor(),width:"auto",menuType:"color",menuItems:Kr,onSelect:(t,e)=>{t.command.execute("fontColor",e)}},{name:"highlight",type:"dropdown",downIcon:n.get("down"),icon:n.get("highlight"),accentIcon:n.get("highlightAccent"),defaultValue:"#fadb14",tooltip:t=>t.toolbar.highlight(),width:"auto",menuType:"color",menuItems:Kr,onSelect:(t,e)=>{t.command.execute("highlight",e)}},{name:"image",type:"upload",icon:n.get("image"),tooltip:t=>t.toolbar.image(),accept:"image/*",multiple:!0},{name:"file",type:"upload",icon:n.get("attachment"),tooltip:t=>t.toolbar.file(),accept:"*",multiple:!0}];function Jr(t){const{editor:e,name:i,file:n,onError:s,onSuccess:o}=t,{requestMethod:r,requestAction:a,requestTypes:l}=e.config[i];if(l.indexOf(n.type)<0)throw s&&s(`File '${n.name}' is not allowed for uploading.`),new Error(`Cannot upload file '${n.name}' because its type '${n.type}' is not found in ['${l.join("', '")}'].`);const c=e.insertBox(i,{url:URL.createObjectURL(n),status:"uploading",name:n.name,size:n.size,type:n.type,lastModified:n.lastModified}),h=te({onProgress:t=>{const e=c.node.find(".lake-percent"),i=Math.round(t.percent);e.text(`${i<100?i:99} %`)},onError:(t,e)=>{B(t.toString(),e),c.updateValue("status","error"),c.render(),s&&s(t.toString())},onSuccess:t=>{if(!t.url)return c.updateValue("status","error"),c.render(),void(s&&s("Cannot find the url field."));c.updateValue({status:"done",url:t.url}),c.render(),e.history.save(),o&&o()},file:n,action:a,method:r});return c.setData("xhr",h),c}const Yr=["undo","redo","|","heading","|","formatPainter","removeFormat","bold","moreStyle","|","fontColor","highlight","|","align","list","indent","link","blockQuote","hr"],Qr=new Map;Xr.forEach((t=>{Qr.set(t.name,t)}));function ta(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{l(n.next(t))}catch(t){o(t)}}function a(t){try{l(n.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}l((n=n.apply(t,e||[])).next())}))}
|
|
18
|
+
`);if(t.append(a),"color"===e.menuType&&(a.attr("title",o),a.find(".lake-dropdown-menu-text").css("background-color",i.value)),i.icon){const t=L('<div class="lake-dropdown-menu-icon"></div>');t.append(i.icon),a.prepend(t)}const l=n.get("check");if(l){const t=L('<div class="lake-dropdown-menu-check"></div>');t.append(l),a.prepend(t)}}}showMenu(){const t=this.config,e=this.node,i=e.find(".lake-dropdown-menu");if(e.attr("disabled"))return;const n=Fe.getValue(e);i.find(".lake-dropdown-menu-check").css("visibility","hidden"),i.find("li").each((t=>{const e=L(t);e.on("mouseenter",(()=>{e.hasClass("lake-dropdown-item-selected")||e.addClass("lake-dropdown-item-hovered")})),e.on("mouseleave",(()=>{e.removeClass("lake-dropdown-item-hovered")})),n.indexOf(e.attr("value"))>=0&&e.find(".lake-dropdown-menu-check").css("visibility","visible")})),i.css("visibility","hidden"),i.show("color"===t.menuType?"flex":"block");const s=e.get(0).getBoundingClientRect(),o=i.width()-(s.x+s.width),r=s.x+i.width()-window.innerWidth;r+50>0&&(o<0||o<r)?(i.css("left","auto"),i.css("right","0")):(i.css("left",""),i.css("right","")),i.css("visibility",""),document.addEventListener("click",this.documentClickListener)}bindEvents(){const t=this.config,e=this.node,i=e.find(".lake-dropdown-title"),n=i.find(".lake-dropdown-text"),s=i.find(".lake-dropdown-icon"),o=i.find(".lake-dropdown-down-icon"),r=e.find(".lake-dropdown-menu");"color"===t.menuType?(s.on("mouseenter",(()=>{e.attr("disabled")||s.addClass("lake-dropdown-icon-hovered")})),s.on("mouseleave",(()=>{s.removeClass("lake-dropdown-icon-hovered")})),o.on("mouseenter",(()=>{e.attr("disabled")||o.addClass("lake-dropdown-down-icon-hovered")})),o.on("mouseleave",(()=>{o.removeClass("lake-dropdown-down-icon-hovered")}))):(i.on("mouseenter",(()=>{e.attr("disabled")||i.addClass("lake-dropdown-title-hovered")})),i.on("mouseleave",(()=>{i.removeClass("lake-dropdown-title-hovered")}))),"color"===t.menuType&&s.on("click",(i=>{if(i.preventDefault(),e.attr("disabled"))return;const n=e.attr("color")||t.defaultValue;t.onSelect(n)}));("color"===t.menuType&&o?o:i).on("click",(t=>{t.preventDefault(),this.showMenu()})),r.on("click",(s=>{s.preventDefault();const o=L(s.target).closest("li"),a=o.attr("value");Fe.setValue(e,[a]),n.length>0&&n.text(o.text()),"color"===t.menuType&&""!==a&&(e.attr("color",a),this.updateColorAccent(i,a)),t.onSelect(a),r.hide(),document.removeEventListener("click",this.documentClickListener)}))}render(){var t;const e=this.config,i=this.node,n=i.find(".lake-dropdown-title");e.downIcon||n.addClass("lake-dropdown-title-no-down"),n.css("width",e.width);const s="string"==typeof e.tooltip?e.tooltip:e.tooltip(this.locale);n.attr("title",s);const o=n.find(".lake-dropdown-text"),r=n.find(".lake-dropdown-icon");e.icon&&r.append(e.icon),e.accentIcon&&r.append(e.accentIcon);const a=n.find(".lake-dropdown-down-icon");e.downIcon&&a.append(e.downIcon);const l=L('<ul class="lake-dropdown-menu" />');if(l.addClass(`lake-${e.menuType}-dropdown-menu`),Fe.setValue(i,[e.defaultValue]),o.length>0){const i=Fe.getMenuMap(e.menuItems,this.locale);o.text(null!==(t=i.get(e.defaultValue))&&void 0!==t?t:e.defaultValue)}"color"===e.menuType&&this.updateColorAccent(n,e.defaultValue),this.apppendMenuItems(l),i.append(n),i.append(l),this.root.append(i),this.bindEvents()}unmount(){this.node.remove(),document.removeEventListener("click",this.documentClickListener)}}var je=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},Re="object"==typeof Ft&&Ft&&Ft.Object===Object&&Ft,We=Re,Ue="object"==typeof self&&self&&self.Object===Object&&self,qe=We||Ue||Function("return this")(),Ke=qe,Ge=function(){return Ke.Date.now()},Xe=/\s/;var Je=function(t){for(var e=t.length;e--&&Xe.test(t.charAt(e)););return e},Ye=Je,Qe=/^\s+/;var ti=function(t){return t?t.slice(0,Ye(t)+1).replace(Qe,""):t},ei=qe.Symbol,ii=ei,ni=Object.prototype,si=ni.hasOwnProperty,oi=ni.toString,ri=ii?ii.toStringTag:void 0;var ai=function(t){var e=si.call(t,ri),i=t[ri];try{t[ri]=void 0;var n=!0}catch(t){}var s=oi.call(t);return n&&(e?t[ri]=i:delete t[ri]),s},li=Object.prototype.toString;var ci=ai,hi=function(t){return li.call(t)},di=ei?ei.toStringTag:void 0;var pi=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":di&&di in Object(t)?ci(t):hi(t)};var ui=function(t){return null!=t&&"object"==typeof t},mi=pi,fi=ui;var gi=ti,vi=je,yi=function(t){return"symbol"==typeof t||fi(t)&&"[object Symbol]"==mi(t)},wi=/^[-+]0x[0-9a-f]+$/i,xi=/^0b[01]+$/i,bi=/^0o[0-7]+$/i,ki=parseInt;var _i=je,Si=Ge,Ci=function(t){if("number"==typeof t)return t;if(yi(t))return NaN;if(vi(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=vi(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=gi(t);var i=xi.test(t);return i||bi.test(t)?ki(t.slice(2),i?2:8):wi.test(t)?NaN:+t},Bi=Math.max,Ai=Math.min;var Ei=function(t,e,i){var n,s,o,r,a,l,c=0,h=!1,d=!1,p=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function u(e){var i=n,o=s;return n=s=void 0,c=e,r=t.apply(o,i)}function m(t){var i=t-l;return void 0===l||i>=e||i<0||d&&t-c>=o}function f(){var t=Si();if(m(t))return g(t);a=setTimeout(f,function(t){var i=e-(t-l);return d?Ai(i,o-(t-c)):i}(t))}function g(t){return a=void 0,p&&n?u(t):(n=s=void 0,r)}function v(){var t=Si(),i=m(t);if(n=arguments,s=this,l=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(f,e),h?u(t):r}(l);if(d)return clearTimeout(a),a=setTimeout(f,e),u(l)}return void 0===a&&(a=setTimeout(f,e)),r}return e=Ci(e)||0,_i(i)&&(h=!!i.leading,o=(d="maxWait"in i)?Bi(Ci(i.maxWait)||0,e):o,p="trailing"in i?!!i.trailing:p),v.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=s=a=void 0},v.flush=function(){return void 0===a?r:g(Si())},v},Ti=jt(Ei);var Li=function(){this.__data__=[],this.size=0};var Ii=function(t,e){return t===e||t!=t&&e!=e},Mi=Ii;var Pi=function(t,e){for(var i=t.length;i--;)if(Mi(t[i][0],e))return i;return-1},Oi=Pi,zi=Array.prototype.splice;var Zi=function(t){var e=this.__data__,i=Oi(e,t);return!(i<0)&&(i==e.length-1?e.pop():zi.call(e,i,1),--this.size,!0)},Ni=Pi;var Hi=function(t){var e=this.__data__,i=Ni(e,t);return i<0?void 0:e[i][1]},Di=Pi;var $i=Pi;var Vi=function(t,e){var i=this.__data__,n=$i(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this},Fi=Li,ji=Zi,Ri=Hi,Wi=function(t){return Di(this.__data__,t)>-1},Ui=Vi;function qi(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}qi.prototype.clear=Fi,qi.prototype.delete=ji,qi.prototype.get=Ri,qi.prototype.has=Wi,qi.prototype.set=Ui;var Ki=qi,Gi=Ki;var Xi=function(){this.__data__=new Gi,this.size=0};var Ji=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i};var Yi=function(t){return this.__data__.get(t)};var Qi=function(t){return this.__data__.has(t)},tn=pi,en=je;var nn,sn=function(t){if(!en(t))return!1;var e=tn(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},on=qe["__core-js_shared__"],rn=(nn=/[^.]+$/.exec(on&&on.keys&&on.keys.IE_PROTO||""))?"Symbol(src)_1."+nn:"";var an=function(t){return!!rn&&rn in t},ln=Function.prototype.toString;var cn=function(t){if(null!=t){try{return ln.call(t)}catch(t){}try{return t+""}catch(t){}}return""},hn=sn,dn=an,pn=je,un=cn,mn=/^\[object .+?Constructor\]$/,fn=Function.prototype,gn=Object.prototype,vn=fn.toString,yn=gn.hasOwnProperty,wn=RegExp("^"+vn.call(yn).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var xn=function(t){return!(!pn(t)||dn(t))&&(hn(t)?wn:mn).test(un(t))},bn=function(t,e){return null==t?void 0:t[e]};var kn=function(t,e){var i=bn(t,e);return xn(i)?i:void 0},_n=kn(qe,"Map"),Sn=kn(Object,"create"),Cn=Sn;var Bn=function(){this.__data__=Cn?Cn(null):{},this.size=0};var An=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},En=Sn,Tn=Object.prototype.hasOwnProperty;var Ln=function(t){var e=this.__data__;if(En){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return Tn.call(e,t)?e[t]:void 0},In=Sn,Mn=Object.prototype.hasOwnProperty;var Pn=Sn;var On=Bn,zn=An,Zn=Ln,Nn=function(t){var e=this.__data__;return In?void 0!==e[t]:Mn.call(e,t)},Hn=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Pn&&void 0===e?"__lodash_hash_undefined__":e,this};function Dn(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Dn.prototype.clear=On,Dn.prototype.delete=zn,Dn.prototype.get=Zn,Dn.prototype.has=Nn,Dn.prototype.set=Hn;var $n=Dn,Vn=Ki,Fn=_n;var jn=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var Rn=function(t,e){var i=t.__data__;return jn(e)?i["string"==typeof e?"string":"hash"]:i.map},Wn=Rn;var Un=Rn;var qn=Rn;var Kn=Rn;var Gn=function(){this.size=0,this.__data__={hash:new $n,map:new(Fn||Vn),string:new $n}},Xn=function(t){var e=Wn(this,t).delete(t);return this.size-=e?1:0,e},Jn=function(t){return Un(this,t).get(t)},Yn=function(t){return qn(this,t).has(t)},Qn=function(t,e){var i=Kn(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this};function ts(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}ts.prototype.clear=Gn,ts.prototype.delete=Xn,ts.prototype.get=Jn,ts.prototype.has=Yn,ts.prototype.set=Qn;var es=ts,is=Ki,ns=_n,ss=es;var os=Ki,rs=Xi,as=Ji,ls=Yi,cs=Qi,hs=function(t,e){var i=this.__data__;if(i instanceof is){var n=i.__data__;if(!ns||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new ss(n)}return i.set(t,e),this.size=i.size,this};function ds(t){var e=this.__data__=new os(t);this.size=e.size}ds.prototype.clear=rs,ds.prototype.delete=as,ds.prototype.get=ls,ds.prototype.has=cs,ds.prototype.set=hs;var ps=ds;var us=es,ms=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},fs=function(t){return this.__data__.has(t)};function gs(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new us;++e<i;)this.add(t[e])}gs.prototype.add=gs.prototype.push=ms,gs.prototype.has=fs;var vs=function(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(e(t[i],i,t))return!0;return!1};var ys=gs,ws=vs,xs=function(t,e){return t.has(e)};var bs=function(t,e,i,n,s,o){var r=1&i,a=t.length,l=e.length;if(a!=l&&!(r&&l>a))return!1;var c=o.get(t),h=o.get(e);if(c&&h)return c==e&&h==t;var d=-1,p=!0,u=2&i?new ys:void 0;for(o.set(t,e),o.set(e,t);++d<a;){var m=t[d],f=e[d];if(n)var g=r?n(f,m,d,e,t,o):n(m,f,d,t,e,o);if(void 0!==g){if(g)continue;p=!1;break}if(u){if(!ws(e,(function(t,e){if(!xs(u,e)&&(m===t||s(m,t,i,n,o)))return u.push(e)}))){p=!1;break}}else if(m!==f&&!s(m,f,i,n,o)){p=!1;break}}return o.delete(t),o.delete(e),p};var ks=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t,n){i[++e]=[n,t]})),i};var _s=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i},Ss=qe.Uint8Array,Cs=Ii,Bs=bs,As=ks,Es=_s,Ts=ei?ei.prototype:void 0,Ls=Ts?Ts.valueOf:void 0;var Is=function(t,e,i,n,s,o,r){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new Ss(t),new Ss(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Cs(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=As;case"[object Set]":var l=1&n;if(a||(a=Es),t.size!=e.size&&!l)return!1;var c=r.get(t);if(c)return c==e;n|=2,r.set(t,e);var h=Bs(a(t),a(e),n,s,o,r);return r.delete(t),h;case"[object Symbol]":if(Ls)return Ls.call(t)==Ls.call(e)}return!1};var Ms=function(t,e){for(var i=-1,n=e.length,s=t.length;++i<n;)t[s+i]=e[i];return t},Ps=Array.isArray,Os=Ms,zs=Ps;var Zs=function(t,e,i){var n=e(t);return zs(t)?n:Os(n,i(t))};var Ns=function(t,e){for(var i=-1,n=null==t?0:t.length,s=0,o=[];++i<n;){var r=t[i];e(r,i,t)&&(o[s++]=r)}return o};var Hs=Ns,Ds=function(){return[]},$s=Object.prototype.propertyIsEnumerable,Vs=Object.getOwnPropertySymbols,Fs=Vs?function(t){return null==t?[]:(t=Object(t),Hs(Vs(t),(function(e){return $s.call(t,e)})))}:Ds;var js=function(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n},Rs=pi,Ws=ui;var Us=function(t){return Ws(t)&&"[object Arguments]"==Rs(t)},qs=ui,Ks=Object.prototype,Gs=Ks.hasOwnProperty,Xs=Ks.propertyIsEnumerable,Js=Us(function(){return arguments}())?Us:function(t){return qs(t)&&Gs.call(t,"callee")&&!Xs.call(t,"callee")},Ys=Js,Qs={exports:{}};var to=function(){return!1};!function(t,e){var i=qe,n=to,s=e&&!e.nodeType&&e,o=s&&t&&!t.nodeType&&t,r=o&&o.exports===s?i.Buffer:void 0,a=(r?r.isBuffer:void 0)||n;t.exports=a}(Qs,Qs.exports);var eo=Qs.exports,io=/^(?:0|[1-9]\d*)$/;var no=function(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&io.test(t))&&t>-1&&t%1==0&&t<e};var so=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},oo=pi,ro=so,ao=ui,lo={};lo["[object Float32Array]"]=lo["[object Float64Array]"]=lo["[object Int8Array]"]=lo["[object Int16Array]"]=lo["[object Int32Array]"]=lo["[object Uint8Array]"]=lo["[object Uint8ClampedArray]"]=lo["[object Uint16Array]"]=lo["[object Uint32Array]"]=!0,lo["[object Arguments]"]=lo["[object Array]"]=lo["[object ArrayBuffer]"]=lo["[object Boolean]"]=lo["[object DataView]"]=lo["[object Date]"]=lo["[object Error]"]=lo["[object Function]"]=lo["[object Map]"]=lo["[object Number]"]=lo["[object Object]"]=lo["[object RegExp]"]=lo["[object Set]"]=lo["[object String]"]=lo["[object WeakMap]"]=!1;var co=function(t){return ao(t)&&ro(t.length)&&!!lo[oo(t)]};var ho=function(t){return function(e){return t(e)}},po={exports:{}};!function(t,e){var i=Re,n=e&&!e.nodeType&&e,s=n&&t&&!t.nodeType&&t,o=s&&s.exports===n&&i.process,r=function(){try{var t=s&&s.require&&s.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=r}(po,po.exports);var uo=po.exports,mo=co,fo=ho,go=uo&&uo.isTypedArray,vo=go?fo(go):mo,yo=js,wo=Ys,xo=Ps,bo=eo,ko=no,_o=vo,So=Object.prototype.hasOwnProperty;var Co=function(t,e){var i=xo(t),n=!i&&wo(t),s=!i&&!n&&bo(t),o=!i&&!n&&!s&&_o(t),r=i||n||s||o,a=r?yo(t.length,String):[],l=a.length;for(var c in t)!e&&!So.call(t,c)||r&&("length"==c||s&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||ko(c,l))||a.push(c);return a},Bo=Object.prototype;var Ao=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Bo)};var Eo=function(t,e){return function(i){return t(e(i))}}(Object.keys,Object),To=Ao,Lo=Eo,Io=Object.prototype.hasOwnProperty;var Mo=sn,Po=so;var Oo=Co,zo=function(t){if(!To(t))return Lo(t);var e=[];for(var i in Object(t))Io.call(t,i)&&"constructor"!=i&&e.push(i);return e},Zo=function(t){return null!=t&&Po(t.length)&&!Mo(t)};var No=Zs,Ho=Fs,Do=function(t){return Zo(t)?Oo(t):zo(t)};var $o=function(t){return No(t,Do,Ho)},Vo=Object.prototype.hasOwnProperty;var Fo=function(t,e,i,n,s,o){var r=1&i,a=$o(t),l=a.length;if(l!=$o(e).length&&!r)return!1;for(var c=l;c--;){var h=a[c];if(!(r?h in e:Vo.call(e,h)))return!1}var d=o.get(t),p=o.get(e);if(d&&p)return d==e&&p==t;var u=!0;o.set(t,e),o.set(e,t);for(var m=r;++c<l;){var f=t[h=a[c]],g=e[h];if(n)var v=r?n(g,f,h,e,t,o):n(f,g,h,t,e,o);if(!(void 0===v?f===g||s(f,g,i,n,o):v)){u=!1;break}m||(m="constructor"==h)}if(u&&!m){var y=t.constructor,w=e.constructor;y==w||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof w&&w instanceof w||(u=!1)}return o.delete(t),o.delete(e),u},jo=kn(qe,"DataView"),Ro=_n,Wo=kn(qe,"Promise"),Uo=kn(qe,"Set"),qo=kn(qe,"WeakMap"),Ko=pi,Go=cn,Xo="[object Map]",Jo="[object Promise]",Yo="[object Set]",Qo="[object WeakMap]",tr="[object DataView]",er=Go(jo),ir=Go(Ro),nr=Go(Wo),sr=Go(Uo),or=Go(qo),rr=Ko;(jo&&rr(new jo(new ArrayBuffer(1)))!=tr||Ro&&rr(new Ro)!=Xo||Wo&&rr(Wo.resolve())!=Jo||Uo&&rr(new Uo)!=Yo||qo&&rr(new qo)!=Qo)&&(rr=function(t){var e=Ko(t),i="[object Object]"==e?t.constructor:void 0,n=i?Go(i):"";if(n)switch(n){case er:return tr;case ir:return Xo;case nr:return Jo;case sr:return Yo;case or:return Qo}return e});var ar=ps,lr=bs,cr=Is,hr=Fo,dr=rr,pr=Ps,ur=eo,mr=vo,fr="[object Arguments]",gr="[object Array]",vr="[object Object]",yr=Object.prototype.hasOwnProperty;var wr=function(t,e,i,n,s,o){var r=pr(t),a=pr(e),l=r?gr:dr(t),c=a?gr:dr(e),h=(l=l==fr?vr:l)==vr,d=(c=c==fr?vr:c)==vr,p=l==c;if(p&&ur(t)){if(!ur(e))return!1;r=!0,h=!1}if(p&&!h)return o||(o=new ar),r||mr(t)?lr(t,e,i,n,s,o):cr(t,e,l,i,n,s,o);if(!(1&i)){var u=h&&yr.call(t,"__wrapped__"),m=d&&yr.call(e,"__wrapped__");if(u||m){var f=u?t.value():t,g=m?e.value():e;return o||(o=new ar),s(f,g,i,n,o)}}return!!p&&(o||(o=new ar),hr(t,e,i,n,s,o))},xr=ui;var br=function t(e,i,n,s,o){return e===i||(null==e||null==i||!xr(e)&&!xr(i)?e!=e&&i!=i:wr(e,i,n,s,t,o))},kr=br;var _r=jt((function(t,e){return kr(t,e)}));function Sr(t){const e=t.get(0),i={};if(e.hasAttributes())for(const t of e.attributes)i[t.name]=t.value;return i}class Cr{constructor(t){const e=window.getSelection();if(!e)throw new Error("Selection object is null.");this.selection=e,this.container=t,this.range=this.getRangeFromNativeSelection()}getRangeFromNativeSelection(){if(this.selection.rangeCount>0){const t=this.selection.getRangeAt(0);return new I(t)}return new I}sync(){this.selection.removeAllRanges(),this.selection.addRange(this.range.get())}updateByRange(){const t=this.getRangeFromNativeSelection();this.range.get()!==t.get()&&(this.range=t)}updateByBookmark(){const t=this.range,e=this.container,i=e.find("lake-box[focus]");if(i.length>0)return he(t,{anchor:new T,focus:i}),void this.sync();he(t,{anchor:e.find('lake-bookmark[type="anchor"]'),focus:e.find('lake-bookmark[type="focus"]')}),this.sync()}getAppliedItems(){const t=[];return function(t,e){let i=e.startNode;for(i.isText&&(i=i.parent());i.length>0&&i.isInside;)t.push({node:i,name:i.name,attributes:Sr(i),styles:p(i.attr("style"))}),i=i.parent()}(t,this.range),function(t,e){const i=e.startNode;let n;if(i.isText&&i.text().length===e.startOffset){const t=i.next();t.length>0&&t.isElement&&(n=t)}if(i.isElement){const t=i.children();if(t.length>0){const i=t[e.startOffset];i&&i.isElement&&(n=i)}}if(n){let e=n;for(;e.length>0;)e.isElement&&t.push({node:e,name:e.name,attributes:Sr(e),styles:p(e.attr("style"))}),e=e.first()}}(t,this.range),t}insertBookmark(){return le(this.range)}toBookmark(t){return he(this.range,t)}insertNode(t){return ae(this.range,t)}insertFragment(t){return ue(this.range,t)}insertContents(t){return me(this.range,t)}deleteContents(){return pe(this.range)}setBlocks(t){return fe(this.range,t)}splitBlock(){return ge(this.range)}splitMarks(t){return we(this.range,t)}addMark(t){return be(this.range,t)}removeMark(t){return _e(this.range,t)}fixList(){return de(this.range)}insertLink(t){return Se(this.range,t)}}class Br{constructor(t){this.commandMap=new Map,this.event=new Wt,this.selection=t}add(t,e){this.commandMap.set(t,e)}delete(t){this.commandMap.delete(t)}getNames(){return Array.from(this.commandMap.keys())}has(t){return void 0!==this.commandMap.get(t)}getItem(t){const e=this.commandMap.get(t);if(void 0===e)throw new Error(`Command '${t}' does not exist.`);return e}isDisabled(t){const e=this.getItem(t);if(!e.isDisabled)return!1;const i=this.selection.getAppliedItems();return e.isDisabled(i)}isSelected(t){const e=this.getItem(t);if(!e.isSelected)return!1;const i=this.selection.getAppliedItems();return e.isSelected(i)}selectedValues(t){const e=this.getItem(t);if(!e.selectedValues)return[];const i=this.selection.getAppliedItems();return e.selectedValues(i)}execute(t,...e){const i=this.getItem(t);this.event.emit("beforeexecute",t),i.execute.apply(this,e),this.event.emit("execute",t),B(`Command '${t}' executed`)}}var Ar,Er={exports:{}};Ar=Er,function(t){function e(t,e){var i=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(i>>16)<<16|65535&i}function i(t,i,n,s,o,r){return e((a=e(e(i,t),e(s,r)))<<(l=o)|a>>>32-l,n);var a,l}function n(t,e,n,s,o,r,a){return i(e&n|~e&s,t,e,o,r,a)}function s(t,e,n,s,o,r,a){return i(e&s|n&~s,t,e,o,r,a)}function o(t,e,n,s,o,r,a){return i(e^n^s,t,e,o,r,a)}function r(t,e,n,s,o,r,a){return i(n^(e|~s),t,e,o,r,a)}function a(t,i){var a,l,c,h,d;t[i>>5]|=128<<i%32,t[14+(i+64>>>9<<4)]=i;var p=1732584193,u=-271733879,m=-1732584194,f=271733878;for(a=0;a<t.length;a+=16)l=p,c=u,h=m,d=f,p=n(p,u,m,f,t[a],7,-680876936),f=n(f,p,u,m,t[a+1],12,-389564586),m=n(m,f,p,u,t[a+2],17,606105819),u=n(u,m,f,p,t[a+3],22,-1044525330),p=n(p,u,m,f,t[a+4],7,-176418897),f=n(f,p,u,m,t[a+5],12,1200080426),m=n(m,f,p,u,t[a+6],17,-1473231341),u=n(u,m,f,p,t[a+7],22,-45705983),p=n(p,u,m,f,t[a+8],7,1770035416),f=n(f,p,u,m,t[a+9],12,-1958414417),m=n(m,f,p,u,t[a+10],17,-42063),u=n(u,m,f,p,t[a+11],22,-1990404162),p=n(p,u,m,f,t[a+12],7,1804603682),f=n(f,p,u,m,t[a+13],12,-40341101),m=n(m,f,p,u,t[a+14],17,-1502002290),p=s(p,u=n(u,m,f,p,t[a+15],22,1236535329),m,f,t[a+1],5,-165796510),f=s(f,p,u,m,t[a+6],9,-1069501632),m=s(m,f,p,u,t[a+11],14,643717713),u=s(u,m,f,p,t[a],20,-373897302),p=s(p,u,m,f,t[a+5],5,-701558691),f=s(f,p,u,m,t[a+10],9,38016083),m=s(m,f,p,u,t[a+15],14,-660478335),u=s(u,m,f,p,t[a+4],20,-405537848),p=s(p,u,m,f,t[a+9],5,568446438),f=s(f,p,u,m,t[a+14],9,-1019803690),m=s(m,f,p,u,t[a+3],14,-187363961),u=s(u,m,f,p,t[a+8],20,1163531501),p=s(p,u,m,f,t[a+13],5,-1444681467),f=s(f,p,u,m,t[a+2],9,-51403784),m=s(m,f,p,u,t[a+7],14,1735328473),p=o(p,u=s(u,m,f,p,t[a+12],20,-1926607734),m,f,t[a+5],4,-378558),f=o(f,p,u,m,t[a+8],11,-2022574463),m=o(m,f,p,u,t[a+11],16,1839030562),u=o(u,m,f,p,t[a+14],23,-35309556),p=o(p,u,m,f,t[a+1],4,-1530992060),f=o(f,p,u,m,t[a+4],11,1272893353),m=o(m,f,p,u,t[a+7],16,-155497632),u=o(u,m,f,p,t[a+10],23,-1094730640),p=o(p,u,m,f,t[a+13],4,681279174),f=o(f,p,u,m,t[a],11,-358537222),m=o(m,f,p,u,t[a+3],16,-722521979),u=o(u,m,f,p,t[a+6],23,76029189),p=o(p,u,m,f,t[a+9],4,-640364487),f=o(f,p,u,m,t[a+12],11,-421815835),m=o(m,f,p,u,t[a+15],16,530742520),p=r(p,u=o(u,m,f,p,t[a+2],23,-995338651),m,f,t[a],6,-198630844),f=r(f,p,u,m,t[a+7],10,1126891415),m=r(m,f,p,u,t[a+14],15,-1416354905),u=r(u,m,f,p,t[a+5],21,-57434055),p=r(p,u,m,f,t[a+12],6,1700485571),f=r(f,p,u,m,t[a+3],10,-1894986606),m=r(m,f,p,u,t[a+10],15,-1051523),u=r(u,m,f,p,t[a+1],21,-2054922799),p=r(p,u,m,f,t[a+8],6,1873313359),f=r(f,p,u,m,t[a+15],10,-30611744),m=r(m,f,p,u,t[a+6],15,-1560198380),u=r(u,m,f,p,t[a+13],21,1309151649),p=r(p,u,m,f,t[a+4],6,-145523070),f=r(f,p,u,m,t[a+11],10,-1120210379),m=r(m,f,p,u,t[a+2],15,718787259),u=r(u,m,f,p,t[a+9],21,-343485551),p=e(p,l),u=e(u,c),m=e(m,h),f=e(f,d);return[p,u,m,f]}function l(t){var e,i="",n=32*t.length;for(e=0;e<n;e+=8)i+=String.fromCharCode(t[e>>5]>>>e%32&255);return i}function c(t){var e,i=[];for(i[(t.length>>2)-1]=void 0,e=0;e<i.length;e+=1)i[e]=0;var n=8*t.length;for(e=0;e<n;e+=8)i[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return i}function h(t){var e,i,n="0123456789abcdef",s="";for(i=0;i<t.length;i+=1)e=t.charCodeAt(i),s+=n.charAt(e>>>4&15)+n.charAt(15&e);return s}function d(t){return unescape(encodeURIComponent(t))}function p(t){return function(t){return l(a(c(t),8*t.length))}(d(t))}function u(t,e){return function(t,e){var i,n,s=c(t),o=[],r=[];for(o[15]=r[15]=void 0,s.length>16&&(s=a(s,8*t.length)),i=0;i<16;i+=1)o[i]=909522486^s[i],r[i]=1549556828^s[i];return n=a(o.concat(c(e)),512+8*e.length),l(a(r.concat(n),640))}(d(t),d(e))}function m(t,e,i){return e?i?u(e,t):h(u(e,t)):i?p(t):h(p(t))}Ar.exports?Ar.exports=m:t.md5=m}(Ft);var Tr=jt(Er.exports);class Lr{constructor(t){this.list=[],this.index=0,this.canSave=!0,this.limit=100,this.event=new Wt,this.selection=t,this.container=t.container}removeBookmark(t){return t.replace(/(<lake-box[^>]+)\s+focus="\w+"([^>]*>)/gi,"$1$2").replace(/<lake-bookmark\s+type="anchor">\s*<\/lake-bookmark>/gi,"").replace(/<lake-bookmark\s+type="focus">\s*<\/lake-bookmark>/gi,"")}getValue(t){return new oe(t).getHTML()}addIdToBoxes(t){t.find("lake-box").each((t=>{const e=new T(t),i=Tr(`${e.attr("type")}-${e.attr("name")}-${e.attr("value")}`);e.attr("id",i)}))}removeIdfromBoxes(t){t.find("lake-box").each((t=>{new T(t).removeAttr("id")}))}morphContainer(t){const e=this.container,i={beforeChildrenUpdated:t=>{if("lake-box"===new T(t).name)return!1},afterAttributeUpdated:(t,i)=>{const n=new T(i);if("value"===t&&"lake-box"===n.name){const t=pt.get(e.id);if(!t)return;t.delete(n.id)}}},n=t.clone(!0);this.addIdToBoxes(e),this.addIdToBoxes(n),ht(e,n,{callbacks:i}),this.removeIdfromBoxes(e),this.removeIdfromBoxes(n)}cloneContainer(){const t=this.selection.range,e=this.container.clone(!0);if(e.find("lake-box").each((t=>{Yt(t).getContainer().empty()})),t.commonAncestor.isOutside)return e;if(t.isInsideBox)return e;const i=t.startNode.path(),n=t.endNode.path(),s=e.find(i),o=e.find(n),r=t.clone();return r.setStart(s,t.startOffset),r.setEnd(o,t.endOffset),le(r),e}get count(){return this.list.length}get canUndo(){return this.index>1&&!!this.list[this.index-1]}get canRedo(){return!!this.list[this.index]}undo(){if(!this.list[this.index-1])return;this.selection.insertBookmark();const t=this.getValue(this.container);for(;this.index>0;){const e=this.list[this.index-1];if(!e)break;const i=this.getValue(e);if(this.removeBookmark(i)!==this.removeBookmark(t)){this.morphContainer(e),this.event.emit("undo",i);break}if(1===this.index)break;this.index--}this.selection.updateByBookmark(),B(`History undone, the last index is ${this.index}`)}redo(){if(!this.list[this.index])return;this.selection.insertBookmark();const t=this.getValue(this.container);for(;this.index<this.list.length;){const e=this.list[this.index];if(!e)break;this.index++;const i=this.getValue(e);if(this.removeBookmark(i)!==this.removeBookmark(t)){this.morphContainer(e),this.event.emit("redo",i);break}}this.selection.updateByBookmark(),B(`History redone, the last index is ${this.index}`)}continue(){this.canSave=!0}pause(){this.canSave=!1}save(t=!0){if(!this.canSave)return;const e=this.cloneContainer(),i=this.getValue(e);this.list[this.index-1]&&this.removeBookmark(this.getValue(this.list[this.index-1]))===this.removeBookmark(i)||(this.list.splice(this.index,1/0,e),this.index++,this.list.length>this.limit&&(this.list.shift(),this.index=this.list.length),t&&this.event.emit("save",m(i)),B(`History saved, the last index is ${this.index}`))}}var Ir=["Shift","Meta","Alt","Control"],Mr="object"==typeof navigator?navigator.platform:"",Pr=/Mac|iPod|iPhone|iPad/.test(Mr),Or=Pr?"Meta":"Control",zr="Win32"===Mr?["Control","Alt"]:Pr?["Alt"]:[];function Zr(t,e){return"function"==typeof t.getModifierState&&(t.getModifierState(e)||zr.includes(e)&&t.getModifierState("AltGraph"))}function Nr(t){return t.trim().split(" ").map((function(t){var e=t.split(/\b\+/),i=e.pop();return[e=e.map((function(t){return"$mod"===t?Or:t})),i]}))}function Hr(t,e){var i;void 0===e&&(e={});var n=null!=(i=e.timeout)?i:1e3,s=Object.keys(t).map((function(e){return[Nr(e),t[e]]})),o=new Map,r=null;return function(t){t instanceof KeyboardEvent&&(s.forEach((function(e){var i=e[0],n=e[1],s=o.get(i)||i;!function(t,e){return!(e[1].toUpperCase()!==t.key.toUpperCase()&&e[1]!==t.code||e[0].find((function(e){return!Zr(t,e)}))||Ir.find((function(i){return!e[0].includes(i)&&e[1]!==i&&Zr(t,i)})))}(t,s[0])?Zr(t,t.key)||o.delete(i):s.length>1?o.set(i,s.slice(1)):(o.delete(i),n(t))})),r&&clearTimeout(r),r=setTimeout(o.clear.bind(o),n))}}const Dr=new Map([["#","shift+#"]]);class $r{constructor(t){this.keydownEventList=[],this.keyupEventList=[],this.container=t}normalizeType(t){var e;return t=(t=null!==(e=Dr.get(t))&&void 0!==e?e:t).replace(/(^|\+|\s)mod(\+|\s|$)/g,"$1$mod$2").replace(/shift|control|alt|meta|enter|tab|backspace|delete|space|escape|arrow-left|arrow-right|arrow-up|arrow-down/,(t=>t.charAt(0).toUpperCase()+l(t.substring(1)))).replace(/(^|\+|\s)([a-z])(\+|\s|$)/g,((t,e,i,n)=>`${e}Key${i.toUpperCase()}${n}`))}setKeydown(t,e){t=this.normalizeType(t);const i=Hr({[t]:t=>e(t)});this.keydownEventList.push({type:t,listener:e}),this.container.on("keydown",i)}setKeyup(t,e){t=this.normalizeType(t);const i=Hr({[t]:t=>e(t)});this.keyupEventList.push({type:t,listener:e}),this.container.on("keyup",i)}keydown(t){t=this.normalizeType(t);for(const e of this.keydownEventList)if(e.type===t&&!1===e.listener(new Event(t)))break}keyup(t){t=this.normalizeType(t);for(const e of this.keyupEventList)if(e.type===t&&!1===e.listener(new Event(t)))break}}const Vr={value:"<p><br /></p>",readonly:!1,spellcheck:!1,tabIndex:0,placeholder:"",indentWithTab:!0,lang:"en-US",minChangeSize:5,onMessage:(t,e)=>{"success"!==t?"warning"!==t?"error"===t&&console.error(e):console.warn(e):console.log(e)}};class Fr{constructor(t){if(this.unsavedInputData="",this.state={appliedItems:[],disabledNameMap:new Map,selectedNameMap:new Map,selectedValuesMap:new Map},this.isComposing=!1,this.event=new Wt,this.box=Fr.box,this.copyListener=t=>{this.selection.range.commonAncestor.closestContainer().get(0)===this.container.get(0)&&this.event.emit("copy",t)},this.cutListener=t=>{this.selection.range.commonAncestor.closestContainer().get(0)===this.container.get(0)&&this.event.emit("cut",t)},this.pasteListener=t=>{this.selection.range.commonAncestor.closestContainer().get(0)===this.container.get(0)&&this.event.emit("paste",t)},this.beforeunloadListener=()=>{this.history.save()},this.selectionchangeListener=()=>{this.selection.updateByRange(),this.updateBoxSelectionStyle(),this.emitStateChangeEvent()},this.clickListener=t=>{const e=new T(t.target);!e.get(0).isConnected||e.closest(".lake-popup").length>0||this.event.emit("click",e)},this.resizeListener=()=>{this.event.emit("resize")},this.updateBoxSelectionStyle=Ti((()=>{if(0===this.root.first().length)return;const t=this.selection.range,e=t.clone();e.adaptBox(),this.container.find("lake-box").each((i=>{const n=Yt(i),s=n.getContainer();if(0!==s.length){if(t.compareBeforeNode(s)<0&&t.compareAfterNode(s)>0&&(!t.isCollapsed||t.startNode.get(0)!==s.get(0)||0!==t.startOffset))return s.removeClass("lake-box-hovered"),s.removeClass("lake-box-selected"),s.removeClass("lake-box-focused"),s.addClass("lake-box-activated"),void n.event.emit("focus");if(e.intersectsNode(n.node))return s.removeClass("lake-box-activated"),void(t.isCollapsed?(s.removeClass("lake-box-hovered"),s.removeClass("lake-box-selected"),s.addClass("lake-box-focused"),n.event.emit("focus")):(s.removeClass("lake-box-focused"),s.addClass("lake-box-selected"),n.event.emit("blur")));s.removeClass("lake-box-activated"),s.removeClass("lake-box-focused"),s.removeClass("lake-box-selected"),n.event.emit("blur")}})),this.event.emit("boxselectionstylechange")}),50,{leading:!1,trailing:!0,maxWait:50}),this.emitStateChangeEvent=Ti((()=>{const t=this.command.getNames();let e=this.selection.getAppliedItems();e.length>0&&e[0].node.closestContainer().get(0)!==this.container.get(0)&&(e=[]);const i=new Map,n=new Map,s=new Map;if(e.length>0)for(const o of t){const t=this.command.getItem(o);if(t.isDisabled&&t.isDisabled(e)&&i.set(o,!0),t.isSelected&&t.isSelected(e)&&n.set(o,!0),t.selectedValues){const i=t.selectedValues(e);i.length>0&&s.set(o,i)}}const o={appliedItems:e,disabledNameMap:i,selectedNameMap:n,selectedValuesMap:s};_r(o,this.state)||(this.toolbar&&this.toolbar.updateState(o),this.event.emit("statechange",o),this.state=o)}),100,{leading:!1,trailing:!0,maxWait:100}),this.emitChangeEvent=t=>{this.rectifyContent(),this.emitStateChangeEvent(),this.togglePlaceholderClass(t),this.scrollToCaret(),this.event.emit("change",t)},!t.root)throw new Error("The root of the config must be specified.");this.root=L(t.root),this.toolbar=t.toolbar,this.config=Object.assign({},Vr);for(const e of Object.keys(t))this.config[e]=t[e];this.containerWrapper=L('<div class="lake-container-wrapper" />'),this.container=L('<div class="lake-container" />'),this.overlayContainer=L('<div class="lake-overlay" />'),this.popupContainer=L('<div class="lake-popup lake-custom-properties" />'),this.readonly=this.config.readonly,this.root.addClass("lake-custom-properties"),this.container.attr({contenteditable:this.readonly?"false":"true",spellcheck:this.config.spellcheck?"true":"false",tabindex:this.config.tabIndex.toString()}),""!==this.config.placeholder&&this.container.attr("placeholder",this.config.placeholder),this.selection=new Cr(this.container),this.command=new Br(this.selection),this.history=new Lr(this.selection),this.keystroke=new $r(this.container),qt.set(this.container.id,this)}togglePlaceholderClass(t){const e="lake-show-placeholder";"<p><br /></p>"===(t=m(t)).replace("<focus />","")?this.container.addClass(e):this.container.removeClass(e)}inputInBoxStrip(){const t=this.selection,e=t.range,i=e.startNode.closest(".lake-box-strip"),n=i.closest("lake-box");if("inline"===Yt(n).type)e.isBoxStart?(e.setStartBefore(n),e.collapseToStart()):(e.setStartAfter(n),e.collapseToStart());else{const t=L("<p />");e.isBoxStart?n.before(t):n.after(t),e.shrinkAfter(t)}const s=i.text();i.html("<br />"),t.insertNode(document.createTextNode(s))}bindInputEvents(){this.container.on("compositionstart",(()=>{this.isComposing=!0})),this.container.on("compositionend",(()=>{this.isComposing=!1})),this.container.on("beforeinput",(t=>{const e=t,i=this.selection.range;(i.isBoxStart||i.isBoxEnd||"insertText"!==e.inputType&&"insertCompositionText"!==e.inputType)&&this.commitUnsavedInputData()})),this.container.on("input",(t=>{const e=t;window.setTimeout((()=>{var t;const i=this.selection.range;if(!i.isInsideBox)if(this.isComposing)this.event.emit("input",e);else{if(i.isBoxStart||i.isBoxEnd)return this.inputInBoxStrip(),this.history.save(),void this.event.emit("input",e);if(("insertText"===e.inputType||"insertCompositionText"===e.inputType)&&(this.unsavedInputData+=null!==(t=e.data)&&void 0!==t?t:"",this.unsavedInputData.length<this.config.minChangeSize))return this.event.emit("input",e),void this.emitChangeEvent(this.getValue());this.history.save(),this.event.emit("input",e)}}),0)})),this.command.event.on("beforeexecute",(()=>this.commitUnsavedInputData()))}bindHistoryEvents(){this.history.event.on("undo",(t=>{this.box.renderAll(this.container),this.emitChangeEvent(t)})),this.history.event.on("redo",(t=>{this.box.renderAll(this.container),this.emitChangeEvent(t)})),this.history.event.on("save",(t=>{this.box.rectifyInstances(this.container),this.emitChangeEvent(t)}))}get hasFocus(){const t=document.activeElement;return!!t&&L(t).closest(".lake-container").get(0)===this.container.get(0)}get locale(){return Ve(this.config.lang)}rectifyContent(){let t=this.container.children();for(const e of t)(e.isBlock||e.isMark)&&""===e.html()&&(e.remove(),B("Rectifying content: empty tag was removed"));if(t=this.container.children(),0===t.length)return this.container.html("<p><br /></p>"),this.selection.range.shrinkAfter(this.container),void B("Rectifying content: default paragraph was added");if(1===t.length){const e=t[0];if(e.isVoid){const t=L("<p />");e.before(t),t.append(e),this.selection.range.shrinkAfter(t),B("Rectifying content: void element was wrapped in paragraph")}}}commitUnsavedInputData(){this.unsavedInputData.length>0&&(this.history.save(!1),this.unsavedInputData="")}prepareOperation(){this.commitUnsavedInputData(),this.history.pause()}commitOperation(){this.history.continue(),this.history.save()}setPluginConfig(t,e){this.config[t]||(this.config[t]={});for(const i of Object.keys(e))void 0===this.config[t][i]&&(this.config[t][i]=e[i])}focus(){this.container.focus()}blur(){this.container.blur()}scrollToCaret(){const t=this.selection.range.getRect(),e=this.container.get(0).getBoundingClientRect(),i=L('<div class="lake-artificial-caret" />'),n=t.x-e.x,s=t.y-e.y;let o,r,a,l;i.css({position:"absolute",top:`${s}px`,left:`${n}px`,width:`${t.width}px`,height:`${t.height}px`,"z-index":"-1"}),this.overlayContainer.find(".lake-artificial-caret").remove(),this.overlayContainer.append(i);const c=this.container.closestScroller();if(c.length>0){const t=c.get(0),e=t.getBoundingClientRect();o=t.scrollLeft,r=t.scrollTop,a=e.width,l=e.height}else{const t=this.containerWrapper.get(0);o=window.scrollX,r=window.scrollY,a=window.innerWidth-t.offsetLeft,l=window.innerHeight-t.offsetTop}let h=!1,d=!0;(n<o||n>o+a)&&(h=!0),s<r?(h=!0,d=!0):s>r+l&&(h=!0,d=!1),h&&i.get(0).scrollIntoView(d),i.remove()}setValue(t){t=u(t);const e=new oe(t),i=e.getFragment();this.container.empty(),this.togglePlaceholderClass(e.getHTML()),this.container.append(i),Fr.box.renderAll(this.container),this.selection.updateByBookmark()}getValue(){const t=this.selection.insertBookmark();let e=new oe(this.container).getHTML();return e=m(e),this.selection.toBookmark(t),e}selectBox(t){let e=t;e=t instanceof Jt?t.node:t,this.selection.range.selectBox(e)}insertBox(t,e){const i=function(t,e,i){if(t.commonAncestor.isOutside)return null;const n=Yt(e);i&&(n.value=i);const s=document.createDocumentFragment();if(s.appendChild(n.node.get(0)),"inline"===n.type)return ue(t,s),n.render(),t.selectBoxEnd(n.node),n;const o=ge(t);return o.start&&(t.setEndAfter(o.start),t.collapseToEnd()),o.end&&o.end.isEmpty&&o.end.remove(),ue(t,s),n.render(),t.selectBoxEnd(n.node),o.start&&o.start.isEmpty&&o.start.remove(),n}(this.selection.range,t,e);if(!i)throw new Error(`Box '${t}' cannot be inserted outside the editor.`);return this.box.getInstances(this.container).set(i.node.id,i),i}removeBox(t=null){if(t&&this.selectBox(t),t=function(t){if(t.commonAncestor.isOutside)return null;const e=t.commonAncestor.closest("lake-box");if(0===e.length)return null;const i=Yt(e);if("block"===i.type){const n=L("<p><br /></p>");return e.before(n),t.shrinkAfter(n),i.unmount(),e.remove(),i}t.setStartBefore(e),t.collapseToStart();const n=e.parent();return i.unmount(),e.remove(),n.isEmpty&&(P(n,L("<br />")),t.shrinkAfter(n)),i}(this.selection.range),t){this.box.getInstances(this.container).delete(t.node.id)}return t}render(){const t=u(this.config.value),e=new oe(t),i=e.getFragment();this.root.empty(),this.root.append(this.containerWrapper),this.containerWrapper.append(this.container),this.containerWrapper.append(this.overlayContainer),L(document.body).append(this.popupContainer),this.togglePlaceholderClass(e.getHTML()),this.container.append(i),Fr.plugin.loadAll(this),this.readonly||(this.selection.updateByBookmark(),this.history.save()),Fr.box.renderAll(this.container),this.toolbar&&this.toolbar.render(this),document.addEventListener("copy",this.copyListener),this.readonly||(document.addEventListener("cut",this.cutListener),document.addEventListener("paste",this.pasteListener),window.addEventListener("beforeunload",this.beforeunloadListener),document.addEventListener("selectionchange",this.selectionchangeListener),document.addEventListener("click",this.clickListener),window.addEventListener("resize",this.resizeListener),this.bindInputEvents(),this.bindHistoryEvents())}unmount(){this.event.removeAllListeners(),this.command.event.removeAllListeners(),this.history.event.removeAllListeners(),this.root.empty(),this.popupContainer.remove(),document.removeEventListener("copy",this.copyListener),this.readonly||(document.removeEventListener("cut",this.cutListener),document.removeEventListener("paste",this.pasteListener),window.removeEventListener("beforeunload",this.beforeunloadListener),document.removeEventListener("selectionchange",this.selectionchangeListener),document.removeEventListener("click",this.clickListener),window.removeEventListener("resize",this.resizeListener))}}Fr.version="0.1.11",Fr.box=new class{add(t){Ut.set(t.name,t)}remove(t){Ut.delete(t)}getNames(){return Array.from(Ut.keys())}getInstances(t){let e=pt.get(t.id);return e||(e=new Map,pt.set(t.id,e),e)}rectifyInstances(t){const e=this.getInstances(t);for(const t of e.values())t.node.get(0).isConnected||(t.unmount(),e.delete(t.node.id))}renderAll(t){this.rectifyInstances(t);const e=this.getInstances(t);t.find("lake-box").each((t=>{const i=L(t);if(e.get(i.id))return;Yt(i).render()}))}},Fr.plugin=new class{constructor(){this.pluginList=[]}add(t){this.pluginList.push(t)}loadAll(t){this.pluginList.forEach((e=>{e(t)}))}};const jr=[{icon:n.get("numberedList"),value:"numbered",text:t=>t.toolbar.numberedList()},{icon:n.get("bulletedList"),value:"bulleted",text:t=>t.toolbar.bulletedList()},{icon:n.get("checklist"),value:"checklist",text:t=>t.toolbar.checklist()}],Rr=[{icon:n.get("alignLeft"),value:"left",text:t=>t.toolbar.alignLeft()},{icon:n.get("alignCenter"),value:"center",text:t=>t.toolbar.alignCenter()},{icon:n.get("alignRight"),value:"right",text:t=>t.toolbar.alignRight()},{icon:n.get("alignJustify"),value:"justify",text:t=>t.toolbar.alignJustify()}],Wr=[{icon:n.get("increaseIndent"),value:"increase",text:t=>t.toolbar.increaseIndent()},{icon:n.get("decreaseIndent"),value:"decrease",text:t=>t.toolbar.decreaseIndent()}],Ur=[{icon:n.get("italic"),value:"italic",text:t=>t.toolbar.italic()},{icon:n.get("underline"),value:"underline",text:t=>t.toolbar.underline()},{icon:n.get("strikethrough"),value:"strikethrough",text:t=>t.toolbar.strikethrough()},{icon:n.get("superscript"),value:"superscript",text:t=>t.toolbar.superscript()},{icon:n.get("subscript"),value:"subscript",text:t=>t.toolbar.subscript()},{icon:n.get("code"),value:"code",text:t=>t.toolbar.code()}],qr=["#f5222d","#fa541c","#fa8c16","#faad14","#fadb14","#a0d911","#52c41a","#13c2c2","#1677ff","#2f54eb","#722ed1","#eb2f96","#fff1f0","#fff2e8","#fff7e6","#fffbe6","#feffe6","#fcffe6","#f6ffed","#e6fffb","#e6f4ff","#f0f5ff","#f9f0ff","#fff0f6","#ffccc7","#ffd8bf","#ffe7ba","#fff1b8","#ffffb8","#f4ffb8","#d9f7be","#b5f5ec","#bae0ff","#d6e4ff","#efdbff","#ffd6e7","#ffa39e","#ffbb96","#ffd591","#ffe58f","#fffb8f","#eaff8f","#b7eb8f","#87e8de","#91caff","#adc6ff","#d3adf7","#ffadd2","#ff7875","#ff9c6e","#ffc069","#ffd666","#fff566","#d3f261","#95de64","#5cdbd3","#69b1ff","#85a5ff","#b37feb","#ff85c0","#ff4d4f","#ff7a45","#ffa940","#ffc53d","#ffec3d","#bae637","#73d13d","#36cfc9","#4096ff","#597ef7","#9254de","#f759ab","#cf1322","#d4380d","#d46b08","#d48806","#d4b106","#7cb305","#389e0d","#08979c","#0958d9","#1d39c4","#531dab","#c41d7f","#a8071a","#ad2102","#ad4e00","#ad6800","#ad8b00","#5b8c00","#237804","#006d75","#003eb3","#10239e","#391085","#9e1068","#820014","#871400","#873800","#874d00","#876800","#3f6600","#135200","#00474f","#002c8c","#061178","#22075e","#780650","#5c0011","#610b00","#612500","#613400","#614700","#254000","#092b00","#002329","#001d66","#030852","#120338","#520339","#000000","#1f1f1f","#262626","#434343","#595959","#8c8c8c","#bfbfbf","#d9d9d9","#f0f0f0","#f5f5f5","#fafafa","#ffffff"],Kr=[{icon:n.get("removeFormat"),value:"",text:t=>t.toolbar.removeColor()}];for(const t of qr)Kr.push({value:t.toLowerCase(),text:t.toUpperCase()});const Gr=new Map([["strong","bold"],["em","italic"],["i","italic"],["u","underline"],["s","strikethrough"],["sup","superscript"],["sub","subscript"],["code","code"]]),Xr=[{name:"undo",type:"button",icon:n.get("undo"),tooltip:t=>t.toolbar.undo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"redo",type:"button",icon:n.get("redo"),tooltip:t=>t.toolbar.redo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"selectAll",type:"button",icon:n.get("selectAll"),tooltip:t=>t.toolbar.selectAll(),onClick:(t,e)=>{t.command.execute(e)}},{name:"paragraph",type:"button",icon:n.get("paragraph"),tooltip:t=>t.toolbar.paragraph(),isSelected:t=>!!t.find((t=>"p"===t.name)),onClick:t=>{t.command.execute("heading","p")}},{name:"blockQuote",type:"button",icon:n.get("blockQuote"),tooltip:t=>t.toolbar.blockQuote(),onClick:(t,e)=>{t.command.execute(e)}},{name:"numberedList",type:"button",icon:n.get("numberedList"),tooltip:t=>t.toolbar.numberedList(),isSelected:t=>!!t.find((t=>"ol"===t.name)),onClick:t=>{t.command.execute("list","numbered")}},{name:"bulletedList",type:"button",icon:n.get("bulletedList"),tooltip:t=>t.toolbar.bulletedList(),isSelected:t=>!!t.find((t=>"ul"===t.name&&!t.node.hasAttr("type"))),onClick:t=>{t.command.execute("list","bulleted")}},{name:"checklist",type:"button",icon:n.get("checklist"),tooltip:t=>t.toolbar.checklist(),isSelected:t=>!!t.find((t=>"ul"===t.name&&"checklist"===t.node.attr("type"))),onClick:t=>{t.command.execute("list","checklist")}},{name:"alignLeft",type:"button",icon:n.get("alignLeft"),tooltip:t=>t.toolbar.alignLeft(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"left"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","left")}},{name:"alignCenter",type:"button",icon:n.get("alignCenter"),tooltip:t=>t.toolbar.alignCenter(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"center"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","center")}},{name:"alignRight",type:"button",icon:n.get("alignRight"),tooltip:t=>t.toolbar.alignRight(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"right"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","right")}},{name:"alignJustify",type:"button",icon:n.get("alignJustify"),tooltip:t=>t.toolbar.alignJustify(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"justify"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","justify")}},{name:"increaseIndent",type:"button",icon:n.get("increaseIndent"),tooltip:t=>t.toolbar.increaseIndent(),onClick:t=>{t.command.execute("indent","increase")}},{name:"decreaseIndent",type:"button",icon:n.get("decreaseIndent"),tooltip:t=>t.toolbar.decreaseIndent(),onClick:t=>{t.command.execute("indent","decrease")}},{name:"bold",type:"button",icon:n.get("bold"),tooltip:t=>t.toolbar.bold(),onClick:(t,e)=>{t.command.execute(e)}},{name:"italic",type:"button",icon:n.get("italic"),tooltip:t=>t.toolbar.italic(),onClick:(t,e)=>{t.command.execute(e)}},{name:"underline",type:"button",icon:n.get("underline"),tooltip:t=>t.toolbar.underline(),onClick:(t,e)=>{t.command.execute(e)}},{name:"strikethrough",type:"button",icon:n.get("strikethrough"),tooltip:t=>t.toolbar.strikethrough(),onClick:(t,e)=>{t.command.execute(e)}},{name:"superscript",type:"button",icon:n.get("superscript"),tooltip:t=>t.toolbar.superscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"subscript",type:"button",icon:n.get("subscript"),tooltip:t=>t.toolbar.subscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"code",type:"button",icon:n.get("code"),tooltip:t=>t.toolbar.code(),onClick:(t,e)=>{t.command.execute(e)}},{name:"removeFormat",type:"button",icon:n.get("removeFormat"),tooltip:t=>t.toolbar.removeFormat(),onClick:(t,e)=>{t.command.execute(e)}},{name:"formatPainter",type:"button",icon:n.get("formatPainter"),tooltip:t=>t.toolbar.formatPainter(),onClick:(t,e)=>{t.command.execute(e)}},{name:"link",type:"button",icon:n.get("link"),tooltip:t=>t.toolbar.link(),onClick:(t,e)=>{t.command.execute(e)}},{name:"hr",type:"button",icon:n.get("hr"),tooltip:t=>t.toolbar.hr(),onClick:(t,e)=>{t.command.execute(e)}},{name:"codeBlock",type:"button",icon:n.get("codeBlock"),tooltip:t=>t.toolbar.codeBlock(),onClick:(t,e)=>{t.command.execute(e)}},{name:"heading",type:"dropdown",downIcon:n.get("down"),defaultValue:"p",tooltip:t=>t.toolbar.heading(),width:"100px",menuType:"list",menuItems:[{value:"h1",text:t=>`<span style="font-weight: bold; font-size: 26px;">${t.toolbar.heading1()}</span>`},{value:"h2",text:t=>`<span style="font-weight: bold; font-size: 24px;">${t.toolbar.heading2()}</span>`},{value:"h3",text:t=>`<span style="font-weight: bold; font-size: 22px;">${t.toolbar.heading3()}</span>`},{value:"h4",text:t=>`<span style="font-weight: bold; font-size: 20px;">${t.toolbar.heading4()}</span>`},{value:"h5",text:t=>`<span style="font-weight: bold; font-size: 18px;">${t.toolbar.heading5()}</span>`},{value:"h6",text:t=>`<span style="font-weight: bold; font-size: 16px;">${t.toolbar.heading6()}</span>`},{value:"p",text:t=>t.toolbar.paragraph()}],onSelect:(t,e)=>{t.command.execute("heading",e)}},{name:"list",type:"dropdown",downIcon:n.get("down"),icon:n.get("list"),defaultValue:"",tooltip:t=>t.toolbar.list(),width:"auto",menuType:"list",menuItems:jr,onSelect:(t,e)=>{t.command.execute("list",e)}},{name:"align",type:"dropdown",downIcon:n.get("down"),icon:n.get("alignLeft"),defaultValue:"",tooltip:t=>t.toolbar.align(),width:"auto",menuType:"list",menuItems:Rr,onSelect:(t,e)=>{t.command.execute("align",e)}},{name:"indent",type:"dropdown",downIcon:n.get("down"),icon:n.get("increaseIndent"),defaultValue:"",tooltip:t=>t.toolbar.indent(),width:"auto",menuType:"list",menuItems:Wr,onSelect:(t,e)=>{t.command.execute("indent",e)}},{name:"fontFamily",type:"dropdown",downIcon:n.get("down"),defaultValue:"Segoe UI",tooltip:t=>t.toolbar.fontFamily(),width:"100px",menuType:"list",menuItems:[{value:"Arial",text:'<span style="font-family: Arial;">Arial</span>'},{value:"Arial Black",text:"<span style=\"font-family: 'Arial Black';\">Arial Black</span>"},{value:"Comic Sans MS",text:"<span style=\"font-family: 'Comic Sans MS';\">Comic Sans MS</span>"},{value:"Courier New",text:"<span style=\"font-family: 'Courier New';\">Courier New</span>"},{value:"Georgia",text:'<span style="font-family: Georgia;">Georgia</span>'},{value:"Helvetica",text:'<span style="font-family: Helvetica;">Helvetica</span>'},{value:"Impact",text:'<span style="font-family: Impact;">Impact</span>'},{value:"Segoe UI",text:"<span style=\"font-family: 'Segoe UI';\">Segoe UI</span>"},{value:"Tahoma",text:'<span style="font-family: Tahoma;">Tahoma</span>'},{value:"Times New Roman",text:"<span style=\"font-family: 'Times New Roman';\">Times New Roman</span>"},{value:"Trebuchet MS",text:"<span style=\"font-family: 'Trebuchet MS';\">Trebuchet MS</span>"},{value:"Verdana",text:'<span style="font-family: Verdana;">Verdana</span>'}],onSelect:(t,e)=>{t.command.execute("fontFamily",e)}},{name:"fontSize",type:"dropdown",downIcon:n.get("down"),defaultValue:"16px",tooltip:t=>t.toolbar.fontSize(),width:"65px",menuType:"list",menuItems:[{value:"12px",text:"12px"},{value:"14px",text:"14px"},{value:"16px",text:"16px"},{value:"18px",text:"18px"},{value:"22px",text:"22px"},{value:"24px",text:"24px"},{value:"32px",text:"32px"}],onSelect:(t,e)=>{t.command.execute("fontSize",e)}},{name:"moreStyle",type:"dropdown",icon:n.get("more"),defaultValue:"",tooltip:t=>t.toolbar.moreStyle(),width:"auto",menuType:"list",menuItems:Ur,selectedValues:t=>{var e;const i=[];for(const n of t)if(n.node.isMark){const t=null!==(e=Gr.get(n.name))&&void 0!==e?e:n.name;i.push(t)}return i},onSelect:(t,e)=>{t.command.execute(e)}},{name:"fontColor",type:"dropdown",downIcon:n.get("down"),icon:n.get("fontColor"),accentIcon:n.get("fontColorAccent"),defaultValue:"#f5222d",tooltip:t=>t.toolbar.fontColor(),width:"auto",menuType:"color",menuItems:Kr,onSelect:(t,e)=>{t.command.execute("fontColor",e)}},{name:"highlight",type:"dropdown",downIcon:n.get("down"),icon:n.get("highlight"),accentIcon:n.get("highlightAccent"),defaultValue:"#fadb14",tooltip:t=>t.toolbar.highlight(),width:"auto",menuType:"color",menuItems:Kr,onSelect:(t,e)=>{t.command.execute("highlight",e)}},{name:"image",type:"upload",icon:n.get("image"),tooltip:t=>t.toolbar.image(),accept:"image/*",multiple:!0},{name:"file",type:"upload",icon:n.get("attachment"),tooltip:t=>t.toolbar.file(),accept:"*",multiple:!0}];function Jr(t){const{editor:e,name:i,file:n,onError:s,onSuccess:o}=t,{requestMethod:r,requestAction:a,requestTypes:l}=e.config[i];if(l.indexOf(n.type)<0)throw s&&s(`File '${n.name}' is not allowed for uploading.`),new Error(`Cannot upload file '${n.name}' because its type '${n.type}' is not found in ['${l.join("', '")}'].`);const c=e.insertBox(i,{url:URL.createObjectURL(n),status:"uploading",name:n.name,size:n.size,type:n.type,lastModified:n.lastModified}),h=te({onProgress:t=>{const e=c.node.find(".lake-percent"),i=Math.round(t.percent);e.text(`${i<100?i:99} %`)},onError:(t,e)=>{B(t.toString(),e),c.updateValue("status","error"),c.render(),s&&s(t.toString())},onSuccess:t=>{if(!t.url)return c.updateValue("status","error"),c.render(),void(s&&s("Cannot find the url field."));c.updateValue({status:"done",url:t.url}),c.render(),e.history.save(),o&&o()},file:n,action:a,method:r});return c.setData("xhr",h),c}const Yr=["undo","redo","|","heading","|","formatPainter","removeFormat","bold","moreStyle","|","fontColor","highlight","|","align","list","indent","link","blockQuote","hr"],Qr=new Map;Xr.forEach((t=>{Qr.set(t.name,t)}));function ta(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{l(n.next(t))}catch(t){o(t)}}function a(t){try{l(n.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}l((n=n.apply(t,e||[])).next())}))}
|
|
19
19
|
/*!
|
|
20
20
|
* PhotoSwipe Lightbox 5.4.3 - https://photoswipe.com
|
|
21
21
|
* (c) 2023 Dmytro Semenov
|
|
@@ -81,7 +81,7 @@ function ea(t,e,i){const n=document.createElement(e);return t&&(n.className=t),i
|
|
|
81
81
|
<path d="M181.66,133.66l-80,80A8,8,0,0,1,88,208V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,181.66,133.66Z"></path>
|
|
82
82
|
</svg>
|
|
83
83
|
</div>
|
|
84
|
-
`),t.overlayContainer.append(i)):s.preventDefault()})),t.container.on("dragover",(e=>{const o=e;o.preventDefault();const r=o.dataTransfer;if(!r)return;if(r.dropEffect="move",!i)return;const a=L(o.target);if(a.isContainer)return;const l=a.closest("lake-box");n=l.length>0?l.isBlockBox?l:l.closestBlock():a.closestBlock();const c=t.container.get(0).getBoundingClientRect();let h=n.get(0).getBoundingClientRect();s="bottom";let d=h.x-c.x,p=h.y+h.height-c.y+parseInt(n.computedCSS("margin-bottom"),10)/2;if(o.clientY<h.y+h.height/2){const e=n.prev();e.length>0&&e.isBlock||e.isBlockBox?(n=e,h=n.get(0).getBoundingClientRect(),d=h.x-c.x,p=h.y+h.height-c.y+parseInt(n.computedCSS("margin-bottom"),10)/2):(s="top",p=h.y-c.y-parseInt(t.container.computedCSS("padding-top"),10)/2)}i.css({top:`${p}px`,left:`${d}px`,width:`${h.width}px`,display:"block"})})),t.container.on("dragend",(()=>{i&&(i.remove(),i=null)})),t.container.on("drop",(o=>{const r=o;if(r.dataTransfer&&i&&(i.remove(),i=null,e&&n&&e.isBox)){if(e.get(0)===n.get(0))return;if("bottom"===s&&e.get(0)===n.next().get(0))return;r.preventDefault();const i=Yt(e),o=t.selection.range;n.isBox?"top"===s?o.selectBoxStart(n):o.selectBoxEnd(n):(o.selectNodeContents(n),"top"===s?o.collapseToStart():o.collapseToEnd()),t.insertBox(i.name,i.value),e.remove(),t.history.save()}}))})),Fr.plugin.add((t=>{t.readonly||(t.command.add("undo",{execute:()=>{t.history.undo()}}),t.keystroke.setKeydown("mod+z",(e=>{t.selection.range.isInsideBox||(e.preventDefault(),t.command.execute("undo"))})))})),Fr.plugin.add((t=>{if(t.readonly)return;t.command.add("redo",{execute:()=>{t.history.redo()}});const e=e=>{t.selection.range.isInsideBox||(e.preventDefault(),t.command.execute("redo"))};t.keystroke.setKeydown("mod+y",e),t.keystroke.setKeydown("mod+shift+z",e)})),Fr.plugin.add((t=>{t.readonly||t.command.add("selectAll",{execute:()=>{const e=t.selection.range;e.selectNodeContents(t.container),e.shrink()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("heading",{selectedValues:t=>{const e=t.find((t=>t.node.isHeading||"p"===t.name));return e?[e.name]:[]},execute:e=>{t.selection.setBlocks(`<${e} />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("blockQuote",{isSelected:t=>!!t.find((t=>"blockquote"===t.name)),execute:e=>{e&&pc.indexOf(e)>=0?t.selection.setBlocks(a`<blockquote type="${e}" />`):t.selection.setBlocks("<blockquote />"),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||(t.command.add("list",{selectedValues:t=>{let e;for(const i of t){if("ol"===i.name){e="numbered";break}if("ul"===i.name&&!i.node.hasAttr("type")){e="bulleted";break}if("ul"===i.name&&"checklist"===i.node.attr("type")){e="checklist";break}}return e?[e]:[]},execute:(e,i=!1)=>{const n=t.selection.range.getBlocks();let s=!1,o=!1,r=!1;for(const t of n)s||"ol"!==t.name||(s=!0),o||"ul"!==t.name||t.hasAttr("type")||(o=!0),r||"ul"!==t.name||"checklist"!==t.attr("type")||(r=!0);s?("numbered"===e&&uc(t),"bulleted"===e&&fc(t),"checklist"===e&&gc(t,i)):o?("numbered"===e&&mc(t),"bulleted"===e&&uc(t),"checklist"===e&&gc(t,i)):r?("numbered"===e&&mc(t),"bulleted"===e&&fc(t),"checklist"===e&&uc(t)):("numbered"===e&&mc(t),"bulleted"===e&&fc(t),"checklist"===e&&gc(t,i)),t.history.save()}}),t.container.on("click",(e=>{const i=e;if(!i.target)return;const n=L(i.target);"li"===n.name&&""!==n.attr("value")&&i.offsetX<=18&&(n.attr("value",("true"!==n.attr("value")).toString()),t.history.save())})))})),Fr.plugin.add((t=>{t.readonly||t.command.add("align",{selectedValues:t=>{let e;for(const i of t)if(i.node.isBlock){e=i.node.computedCSS("text-align");break}return e?[vc[e]||e]:[]},execute:e=>{t.selection.setBlocks({"text-align":e}),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("indent",{execute:e=>{const i=t.selection.range.getBlocks();for(const t of i)F(t,e);t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||(t.command.add("bold",{isDisabled:t=>!!t.find((t=>t.node.isHeading)),isSelected:t=>!!t.find((t=>t.name===yc)),execute:()=>{t.command.isSelected("bold")?t.selection.removeMark(`<${yc} />`):t.selection.addMark(`<${yc} />`),t.history.save()}}),t.keystroke.setKeydown("mod+b",(e=>{e.preventDefault(),t.command.execute("bold")})))})),Fr.plugin.add((t=>{t.readonly||(t.command.add("italic",{isSelected:t=>!!t.find((t=>"i"===t.name)),execute:()=>{t.command.isSelected("italic")?t.selection.removeMark("<i />"):t.selection.addMark("<i />"),t.history.save()}}),t.keystroke.setKeydown("mod+i",(e=>{e.preventDefault(),t.command.execute("italic")})))})),Fr.plugin.add((t=>{t.readonly||(t.command.add("underline",{isSelected:t=>!!t.find((t=>"u"===t.name)),execute:()=>{t.command.isSelected("underline")?t.selection.removeMark("<u />"):t.selection.addMark("<u />"),t.history.save()}}),t.keystroke.setKeydown("mod+u",(e=>{e.preventDefault(),t.command.execute("underline")})))})),Fr.plugin.add((t=>{t.readonly||(t.command.add("strikethrough",{isSelected:t=>!!t.find((t=>"s"===t.name)),execute:()=>{t.command.isSelected("strikethrough")?t.selection.removeMark("<s />"):t.selection.addMark("<s />"),t.history.save()}}),t.keystroke.setKeydown("mod+shift+x",(e=>{e.preventDefault(),t.command.execute("strikethrough")})))})),Fr.plugin.add((t=>{t.readonly||t.command.add("subscript",{isSelected:t=>!!t.find((t=>t.name===wc)),execute:()=>{t.command.isSelected("subscript")?t.selection.removeMark(`<${wc} />`):t.selection.addMark(`<${wc} />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("superscript",{isSelected:t=>!!t.find((t=>t.name===xc)),execute:()=>{t.command.isSelected("superscript")?t.selection.removeMark(`<${xc} />`):t.selection.addMark(`<${xc} />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("code",{isSelected:t=>!!t.find((t=>t.name===bc)),execute:()=>{t.command.isSelected("code")?t.selection.removeMark(`<${bc} />`):t.selection.addMark(`<${bc} />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("fontFamily",{selectedValues:t=>{for(const e of t)if("span"===e.name){return[e.node.css("font-family").replace(/['"]/g,"")]}return[]},execute:e=>{t.selection.addMark(`<span style="font-family: ${e};" />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("fontSize",{isDisabled:t=>!!t.find((t=>t.node.isHeading)),selectedValues:t=>{for(const e of t)if("span"===e.name){return[e.node.css("font-size").replace(/\.\d+/,"")]}return[]},execute:e=>{t.selection.addMark(`<span style="font-size: ${e};" />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("fontColor",{selectedValues:t=>{for(const e of t)if("span"===e.name){return[d(e.node.computedCSS("color"))]}return[]},execute:e=>{t.selection.addMark(`<span style="color: ${e};" />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("highlight",{selectedValues:t=>{for(const e of t)if("span"===e.name){return[d(e.node.computedCSS("background-color"))]}return[]},execute:e=>{t.selection.addMark(`<span style="background-color: ${e};" />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("removeFormat",{execute:()=>{t.selection.removeMark(),t.history.save()}})})),Fr.plugin.add((t=>{if(t.readonly)return;let e=[];t.command.add("formatPainter",{execute:()=>{t.container.addClass(kc);const i=t.selection.getAppliedItems();for(const t of i){const i=t.node.clone();i.isMark&&"a"!==i.name&&e.push(i)}}}),t.container.on("click",(()=>{if(t.container.removeClass(kc),0!==e.length){for(const i of e)t.selection.addMark(i);e=[],t.history.save()}})),t.event.on("click",(i=>{if(i.isInside&&i.closestContainer().get(0)===t.container.get(0))return;i.closest('button[name="formatPainter"]').length>0||(t.container.removeClass(kc),e=[])}))})),Fr.plugin.add((t=>{if(t.readonly)return;const e=new _c({root:t.popupContainer,locale:t.locale,onSave:e=>{const i=t.selection.range;i.setStartAfter(e),i.collapseToStart(),t.selection.sync(),t.history.save()},onRemove:e=>{const i=t.selection.range;i.setStartAfter(e),i.collapseToStart(),t.selection.sync(),t.history.save()}});t.root.on("scroll",(()=>{e.updatePosition()})),t.event.on("resize",(()=>{e.updatePosition()})),t.event.on("click",(i=>{if(i.closest('button[name="link"]').length>0)return;const n=i.closest("a");0!==n.length?n.isOutside||n.closestContainer().get(0)!==t.container.get(0)||n.closest("lake-box").length>0?e.hide():e.show(n):e.hide()})),t.command.add("link",{execute:()=>{const i=t.selection.insertLink(`<a href="">${t.locale.link.newLink()}</a>`);i&&(t.history.save(),e.show(i))}})})),Fr.plugin.add((t=>{t.readonly||(t.event.on("beforepaste",(t=>{new ie(t).find("hr").each((t=>{const e=L(t),i=Yt("hr");e.replaceWith(i.node)}))})),t.command.add("hr",{execute:()=>{t.insertBox("hr"),t.history.save()}}))})),Fr.plugin.add((t=>{t.setPluginConfig("image",{requestMethod:"POST",requestTypes:["image/gif","image/jpeg","image/png","image/svg+xml"]}),t.readonly||(t.event.on("beforepaste",(t=>{new ie(t).find("img").each((t=>{const e=L(t),i=Yt("image"),n=e.attr("data-lake-value");""===n?i.value={url:e.attr("src"),status:"done"}:i.node.attr("value",n),e.replaceWith(i.node)}))})),t.command.add("image",{execute:e=>{t.insertBox("image",e),t.history.save()}}))})),Fr.plugin.add((t=>{t.setPluginConfig("file",{requestMethod:"POST",requestTypes:["application/zip","application/x-zip-compressed","application/vnd.rar","image/gif","image/jpeg","image/png","image/svg+xml","text/plain","text/html","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"]}),t.readonly||t.command.add("file",{execute:e=>{t.insertBox("file",e),t.history.save()}})})),Fr.plugin.add((t=>{window.LakeCodeMirror&&(t.setPluginConfig("codeBlock",{langList:Sc,defaultLang:"text"}),t.readonly||t.command.add("codeBlock",{execute:e=>{const i=t.insertBox("codeBlock",e);t.history.save();i.getData("codeEditor").focus()}}))})),Fr.plugin.add((t=>{t.readonly||(t.keystroke.setKeydown("space",(e=>{const i=t.selection.range;if(i.isBox)return;const n=function(t){const e=t.selection.range;let i=e.startNode,n=e.startOffset;if(0!==n){if(i.isElement){const t=i.children()[n-1];if(!t||!t.isText)return;i=t,n=i.text().length}if(!(n<1))return{node:i,offset:n}}}(t);if(!n)return;if(function(t,e){const i=t.selection,n=i.range,s=e.offset,o=e.node.text().slice(0,s);for(const e of Ac){const r=e.re.exec(o);if(null!==r){const o=e.getParameters(),a=o.shift();if(!t.command.has(a))return!1;t.prepareOperation();const l=i.insertBookmark(),c=l.focus.prev(),h=c.text(),d=`${h.replace(e.re,"$1")}`;return c.get(0).nodeValue=d,n.setStart(c,s-r[0].length),n.setEnd(c,s-(h.length-d.length)-1),t.command.execute(a,...o),i.toBookmark(l),t.commitOperation(),!0}}return!1}(t,n))return void e.preventDefault();const s=i.getBlocks()[0];s&&(s.isHeading||"p"===s.name)&&function(t,e){const i=t.selection,n=e.offset;let s=e.node.text().slice(0,n);s=s.replace(/[\u200B\u2060]/g,"");for(const e of Ec){const n=e.re.exec(s);if(null!==n){const s=e.getParameters(n),o=s.shift();if(!t.command.has(o))return!1;t.prepareOperation();const r=i.insertBookmark();r.focus.prev().remove();const a=r.focus.closestBlock();return Lc(a),i.range.shrinkAfter(a),t.command.execute(o,...s),i.toBookmark(r),t.commitOperation(),!0}}return!1}(t,n)&&e.preventDefault()})),t.keystroke.setKeydown("enter",(e=>{const i=t.selection.range;if(i.isBox)return;const n=i.getBlocks()[0];return!n||!n.isHeading&&"p"!==n.name||n.find("lake-box").length>0||""!==i.getEndText()?void 0:function(t,e){const i=t.selection;let n=e.text();n=n.replace(/[\u200B\u2060]/g,"");for(const s of Tc){const o=s.re.exec(n);if(null!==o){const n=s.getParameters(o),r=n.shift();return!!t.command.has(r)&&(t.prepareOperation(),e.empty(),Lc(e),i.range.shrinkAfter(e),t.command.execute(r,...n),t.commitOperation(),!0)}}return!1}(t,n)?(e.preventDefault(),e.stopImmediatePropagation(),!1):void 0})))})),Fr.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("enter",(e=>{const i=t.selection.range;if(i.isInsideBox)return;if(e.preventDefault(),t.rectifyContent(),i.isBox)return Mc(t),void t.history.save();if(i.adapt(),i.isInoperative)return;if(i.isBox)return Mc(t),void t.history.save();let n=i.getBlocks()[0];if(n||(t.selection.setBlocks("<p />"),n=i.getBlocks()[0]),n.isEmpty&&"p"!==n.name)return t.selection.setBlocks("<p />"),void t.history.save();Ic(t,n),t.history.save()}))})),Fr.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("shift+enter",(e=>{const i=t.selection.range;if(!i.isInsideBox){if(t.rectifyContent(),e.preventDefault(),i.isBox)return Oc(t),void t.history.save();if(i.adapt(),!i.isInoperative){if(i.isBox)return Oc(t),void t.history.save();Pc(t),t.history.save()}}}))})),Fr.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("backspace",(e=>{const i=t.selection.range;if(i.isInsideBox)return;if(t.rectifyContent(),i.isBoxStart){const n=i.startNode.closest("lake-box"),s=n.prev();if(0===s.length){const i=n.closestBlock();return void(i.length>0&&!i.isContainer&&(e.preventDefault(),zc(t,i),t.history.save()))}if(s.isBlock)return s.isEmpty?(e.preventDefault(),s.remove(),t.selection.fixList(),void t.history.save()):(e.preventDefault(),void i.shrinkAfter(s));i.adaptBox()}if(i.isBox)return e.preventDefault(),t.removeBox(),void t.history.save();if(!i.isCollapsed)return e.preventDefault(),t.selection.deleteContents(),""===t.container.html().trim()&&t.setValue("<p><br /><focus /></p>"),void t.history.save();i.adapt();const n=i.getPrevNode();if(n.isBox)return e.preventDefault(),t.removeBox(n),void t.history.save();if("br"===n.name&&n.prev().length>0)return e.preventDefault(),i.setStartBefore(n),i.collapseToStart(),n.remove(),void t.history.save();if(""===i.getStartText()){e.preventDefault();let n=i.getBlocks()[0];if(n||(t.selection.setBlocks("<p />"),n=i.getBlocks()[0]),""!==n.css("margin-left")||""!==n.css("text-indent")||""!==n.attr("indent"))return F(n,"decrease"),void t.history.save();if(n.isList||"blockquote"===n.name)return t.selection.setBlocks("<p />"),void t.history.save();zc(t,n),t.history.save()}}))})),Fr.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("delete",(e=>{const i=t.selection.range;if(i.isInsideBox)return;if(t.rectifyContent(),i.isBoxEnd){const n=i.startNode.closest("lake-box"),s=n.next();if(0===s.length){const i=n.closestBlock();return void(i.length>0&&!i.isContainer&&(e.preventDefault(),Zc(t,i),t.history.save()))}if(s.isBlock)return s.isEmpty?(e.preventDefault(),s.remove(),t.selection.fixList(),void t.history.save()):(e.preventDefault(),void i.shrinkBefore(s));i.adaptBox()}if(i.isBox)return e.preventDefault(),t.removeBox(),void t.history.save();if(!i.isCollapsed)return e.preventDefault(),t.selection.deleteContents(),""===t.container.html().trim()&&t.setValue("<p><br /><focus /></p>"),void t.history.save();i.adapt();const n=i.getNextNode();if(n.isBox)return e.preventDefault(),t.removeBox(n),void t.history.save();"br"===n.name&&n.next().length>0&&(e.preventDefault(),i.setStartBefore(n),i.collapseToStart(),n.remove(),t.history.save());if(""===i.getEndText()){e.preventDefault();let n=i.getBlocks()[0];n||(t.selection.setBlocks("<p />"),n=i.getBlocks()[0]),Zc(t,n),t.history.save()}}))})),Fr.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("tab",(e=>{if(!1===t.config.indentWithTab)return;e.preventDefault();t.selection.range.getBlocks().forEach((t=>{"p"===t.name&&"2em"!==t.css("text-indent")?t.css("text-indent","2em"):F(t,"increase")})),t.history.save()}))})),Fr.plugin.add((t=>{t.readonly||(t.keystroke.setKeydown("arrow-left",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(i.isBoxStart){const t=n.prev();return t.isBlock||t.isBox?(e.preventDefault(),t.isInlineBox?void i.selectBox(t):void i.shrinkAfter(t)):(i.setStartBefore(n),void i.collapseToStart())}return i.isBoxEnd?(e.preventDefault(),void i.selectBox(n)):(e.preventDefault(),void i.selectBoxStart(n))}if(!i.isCollapsed)return;const s=i.getPrevNode();s.isBox&&(e.preventDefault(),i.selectBox(s))})),t.keystroke.setKeydown("arrow-right",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(i.isBoxStart)return e.preventDefault(),void i.selectBox(n);if(i.isBoxEnd){const t=n.next();return t.isBlock||t.isBox?(e.preventDefault(),t.isInlineBox?void i.selectBox(t):void i.shrinkBefore(t)):(i.setStartAfter(n),void i.collapseToStart())}return e.preventDefault(),void i.selectBoxEnd(n)}if(!i.isCollapsed)return;const s=i.getNextNode();s.isBox&&(e.preventDefault(),i.selectBox(s))})),t.keystroke.setKeydown("arrow-up",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(n.isBlockBox){const t=n.prev();if(t.isBlock||t.isBox)return e.preventDefault(),void i.shrinkAfter(t)}i.setStartBefore(n),i.collapseToStart()}})),t.keystroke.setKeydown("arrow-down",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(n.isBlockBox){const t=n.next();if(t.isBlock||t.isBox)return e.preventDefault(),void i.shrinkBefore(t)}i.setStartAfter(n),i.collapseToStart()}})))})),Fr.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("escape",(e=>{const i=t.selection,n=i.range;if(n.isBoxCenter||n.isInsideBox){e.preventDefault();const t=n.commonAncestor.closest("lake-box");return n.selectBoxEnd(t),void i.sync()}t.hasFocus&&(e.preventDefault(),t.blur())}))})),t.Box=Jt,t.Button=Ce,t.Dropdown=Fe,t.Editor=Fr,t.Fragment=ie,t.HTMLParser=oe,t.Nodes=T,t.Range=I,t.TextParser=re,t.Toolbar=class{constructor(t){this.placement="top",this.allMenuMap=new Map,this.buttonItemList=[],this.dropdownItemList=[],this.root=L(t.root),this.items=t.items||Yr,t.placement&&(this.placement=t.placement),this.container=L('<div class="lake-toolbar" />'),this.root.addClass("lake-custom-properties")}appendDivider(){this.container.append('<div class="lake-toolbar-divider" />')}appendButton(t,e){new Ce({root:this.container,name:e.name,icon:e.icon,tooltip:"string"==typeof e.tooltip?e.tooltip:e.tooltip(t.locale),tabIndex:-1,onClick:()=>{t.focus(),e.onClick(t,e.name)}}).render()}appendDropdown(t,e){new Fe({root:this.container,locale:t.locale,name:e.name,icon:e.icon,accentIcon:e.accentIcon,downIcon:e.downIcon,defaultValue:e.defaultValue,tooltip:e.tooltip,width:e.width,menuType:e.menuType,menuItems:e.menuItems,tabIndex:-1,placement:"top"===this.placement?"bottom":"top",onSelect:i=>{t.focus(),e.onSelect(t,i)}}).render()}appendUpload(t,e){const i=L(a`
|
|
84
|
+
`),t.overlayContainer.append(i)):s.preventDefault()})),t.container.on("dragover",(e=>{const o=e;o.preventDefault();const r=o.dataTransfer;if(!r)return;if(r.dropEffect="move",!i)return;const a=L(o.target);if(a.isContainer)return;const l=a.closest("lake-box");n=l.length>0?l.isBlockBox?l:l.closestBlock():a.closestBlock();const c=t.container.get(0).getBoundingClientRect();let h=n.get(0).getBoundingClientRect();s="bottom";let d=h.x-c.x,p=h.y+h.height-c.y+parseInt(n.computedCSS("margin-bottom"),10)/2;if(o.clientY<h.y+h.height/2){const e=n.prev();e.length>0&&e.isBlock||e.isBlockBox?(n=e,h=n.get(0).getBoundingClientRect(),d=h.x-c.x,p=h.y+h.height-c.y+parseInt(n.computedCSS("margin-bottom"),10)/2):(s="top",p=h.y-c.y-parseInt(t.container.computedCSS("padding-top"),10)/2)}i.css({top:`${p}px`,left:`${d}px`,width:`${h.width}px`,display:"block"})})),t.container.on("dragend",(()=>{i&&(i.remove(),i=null)})),t.container.on("drop",(o=>{const r=o;if(r.dataTransfer&&i&&(i.remove(),i=null,e&&n&&e.isBox)){if(e.get(0)===n.get(0))return;if("bottom"===s&&e.get(0)===n.next().get(0))return;r.preventDefault();const i=Yt(e),o=t.selection.range;n.isBox?"top"===s?o.selectBoxStart(n):o.selectBoxEnd(n):(o.selectNodeContents(n),"top"===s?o.collapseToStart():o.collapseToEnd()),t.insertBox(i.name,i.value),e.remove(),t.history.save()}}))})),Fr.plugin.add((t=>{t.readonly||(t.command.add("undo",{execute:()=>{t.history.undo()}}),t.keystroke.setKeydown("mod+z",(e=>{t.selection.range.isInsideBox||(e.preventDefault(),t.command.execute("undo"))})))})),Fr.plugin.add((t=>{if(t.readonly)return;t.command.add("redo",{execute:()=>{t.history.redo()}});const e=e=>{t.selection.range.isInsideBox||(e.preventDefault(),t.command.execute("redo"))};t.keystroke.setKeydown("mod+y",e),t.keystroke.setKeydown("mod+shift+z",e)})),Fr.plugin.add((t=>{t.readonly||t.command.add("selectAll",{execute:()=>{const e=t.selection.range;e.selectNodeContents(t.container),e.shrink()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("heading",{selectedValues:t=>{const e=t.find((t=>t.node.isHeading||"p"===t.name));return e?[e.name]:[]},execute:e=>{t.selection.setBlocks(`<${e} />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("blockQuote",{isSelected:t=>!!t.find((t=>"blockquote"===t.name)),execute:e=>{e&&pc.indexOf(e)>=0?t.selection.setBlocks(a`<blockquote type="${e}" />`):t.selection.setBlocks("<blockquote />"),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||(t.command.add("list",{selectedValues:t=>{let e;for(const i of t){if("ol"===i.name){e="numbered";break}if("ul"===i.name&&!i.node.hasAttr("type")){e="bulleted";break}if("ul"===i.name&&"checklist"===i.node.attr("type")){e="checklist";break}}return e?[e]:[]},execute:(e,i=!1)=>{const n=t.selection.range.getBlocks();let s=!1,o=!1,r=!1;for(const t of n)s||"ol"!==t.name||(s=!0),o||"ul"!==t.name||t.hasAttr("type")||(o=!0),r||"ul"!==t.name||"checklist"!==t.attr("type")||(r=!0);s?("numbered"===e&&uc(t),"bulleted"===e&&fc(t),"checklist"===e&&gc(t,i)):o?("numbered"===e&&mc(t),"bulleted"===e&&uc(t),"checklist"===e&&gc(t,i)):r?("numbered"===e&&mc(t),"bulleted"===e&&fc(t),"checklist"===e&&uc(t)):("numbered"===e&&mc(t),"bulleted"===e&&fc(t),"checklist"===e&&gc(t,i)),t.history.save(),t.selection.sync()}}),t.container.on("click",(e=>{const i=e;if(!i.target)return;const n=L(i.target);"li"===n.name&&""!==n.attr("value")&&i.offsetX<=18&&(n.attr("value",("true"!==n.attr("value")).toString()),t.history.save())})))})),Fr.plugin.add((t=>{t.readonly||t.command.add("align",{selectedValues:t=>{let e;for(const i of t)if(i.node.isBlock){e=i.node.computedCSS("text-align");break}return e?[vc[e]||e]:[]},execute:e=>{t.selection.setBlocks({"text-align":e}),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("indent",{execute:e=>{const i=t.selection.range.getBlocks();for(const t of i)F(t,e);t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||(t.command.add("bold",{isDisabled:t=>!!t.find((t=>t.node.isHeading)),isSelected:t=>!!t.find((t=>t.name===yc)),execute:()=>{t.command.isSelected("bold")?t.selection.removeMark(`<${yc} />`):t.selection.addMark(`<${yc} />`),t.history.save()}}),t.keystroke.setKeydown("mod+b",(e=>{e.preventDefault(),t.command.execute("bold")})))})),Fr.plugin.add((t=>{t.readonly||(t.command.add("italic",{isSelected:t=>!!t.find((t=>"i"===t.name)),execute:()=>{t.command.isSelected("italic")?t.selection.removeMark("<i />"):t.selection.addMark("<i />"),t.history.save()}}),t.keystroke.setKeydown("mod+i",(e=>{e.preventDefault(),t.command.execute("italic")})))})),Fr.plugin.add((t=>{t.readonly||(t.command.add("underline",{isSelected:t=>!!t.find((t=>"u"===t.name)),execute:()=>{t.command.isSelected("underline")?t.selection.removeMark("<u />"):t.selection.addMark("<u />"),t.history.save()}}),t.keystroke.setKeydown("mod+u",(e=>{e.preventDefault(),t.command.execute("underline")})))})),Fr.plugin.add((t=>{t.readonly||(t.command.add("strikethrough",{isSelected:t=>!!t.find((t=>"s"===t.name)),execute:()=>{t.command.isSelected("strikethrough")?t.selection.removeMark("<s />"):t.selection.addMark("<s />"),t.history.save()}}),t.keystroke.setKeydown("mod+shift+x",(e=>{e.preventDefault(),t.command.execute("strikethrough")})))})),Fr.plugin.add((t=>{t.readonly||t.command.add("subscript",{isSelected:t=>!!t.find((t=>t.name===wc)),execute:()=>{t.command.isSelected("subscript")?t.selection.removeMark(`<${wc} />`):t.selection.addMark(`<${wc} />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("superscript",{isSelected:t=>!!t.find((t=>t.name===xc)),execute:()=>{t.command.isSelected("superscript")?t.selection.removeMark(`<${xc} />`):t.selection.addMark(`<${xc} />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("code",{isSelected:t=>!!t.find((t=>t.name===bc)),execute:()=>{t.command.isSelected("code")?t.selection.removeMark(`<${bc} />`):t.selection.addMark(`<${bc} />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("fontFamily",{selectedValues:t=>{for(const e of t)if("span"===e.name){return[e.node.css("font-family").replace(/['"]/g,"")]}return[]},execute:e=>{t.selection.addMark(`<span style="font-family: ${e};" />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("fontSize",{isDisabled:t=>!!t.find((t=>t.node.isHeading)),selectedValues:t=>{for(const e of t)if("span"===e.name){return[e.node.css("font-size").replace(/\.\d+/,"")]}return[]},execute:e=>{t.selection.addMark(`<span style="font-size: ${e};" />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("fontColor",{selectedValues:t=>{for(const e of t)if("span"===e.name){return[d(e.node.computedCSS("color"))]}return[]},execute:e=>{t.selection.addMark(`<span style="color: ${e};" />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("highlight",{selectedValues:t=>{for(const e of t)if("span"===e.name){return[d(e.node.computedCSS("background-color"))]}return[]},execute:e=>{t.selection.addMark(`<span style="background-color: ${e};" />`),t.history.save()}})})),Fr.plugin.add((t=>{t.readonly||t.command.add("removeFormat",{execute:()=>{t.selection.removeMark(),t.history.save()}})})),Fr.plugin.add((t=>{if(t.readonly)return;let e=[];t.command.add("formatPainter",{execute:()=>{t.container.addClass(kc);const i=t.selection.getAppliedItems();for(const t of i){const i=t.node.clone();i.isMark&&"a"!==i.name&&e.push(i)}}}),t.container.on("click",(()=>{if(t.container.removeClass(kc),0!==e.length){for(const i of e)t.selection.addMark(i);e=[],t.history.save()}})),t.event.on("click",(i=>{if(i.isInside&&i.closestContainer().get(0)===t.container.get(0))return;i.closest('button[name="formatPainter"]').length>0||(t.container.removeClass(kc),e=[])}))})),Fr.plugin.add((t=>{if(t.readonly)return;const e=new _c({root:t.popupContainer,locale:t.locale,onSave:e=>{const i=t.selection.range;i.setStartAfter(e),i.collapseToStart(),t.selection.sync(),t.history.save()},onRemove:e=>{const i=t.selection.range;i.setStartAfter(e),i.collapseToStart(),t.selection.sync(),t.history.save()}});t.root.on("scroll",(()=>{e.updatePosition()})),t.event.on("resize",(()=>{e.updatePosition()})),t.event.on("click",(i=>{if(i.closest('button[name="link"]').length>0)return;const n=i.closest("a");0!==n.length?n.isOutside||n.closestContainer().get(0)!==t.container.get(0)||n.closest("lake-box").length>0?e.hide():e.show(n):e.hide()})),t.command.add("link",{execute:()=>{const i=t.selection.insertLink(`<a href="">${t.locale.link.newLink()}</a>`);i&&(t.history.save(),e.show(i))}})})),Fr.plugin.add((t=>{t.readonly||(t.event.on("beforepaste",(t=>{new ie(t).find("hr").each((t=>{const e=L(t),i=Yt("hr");e.replaceWith(i.node)}))})),t.command.add("hr",{execute:()=>{t.insertBox("hr"),t.history.save()}}))})),Fr.plugin.add((t=>{t.setPluginConfig("image",{requestMethod:"POST",requestTypes:["image/gif","image/jpeg","image/png","image/svg+xml"]}),t.readonly||(t.event.on("beforepaste",(t=>{new ie(t).find("img").each((t=>{const e=L(t),i=Yt("image"),n=e.attr("data-lake-value");""===n?i.value={url:e.attr("src"),status:"done"}:i.node.attr("value",n),e.replaceWith(i.node)}))})),t.command.add("image",{execute:e=>{t.insertBox("image",e),t.history.save()}}))})),Fr.plugin.add((t=>{t.setPluginConfig("file",{requestMethod:"POST",requestTypes:["application/zip","application/x-zip-compressed","application/vnd.rar","image/gif","image/jpeg","image/png","image/svg+xml","text/plain","text/html","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"]}),t.readonly||t.command.add("file",{execute:e=>{t.insertBox("file",e),t.history.save()}})})),Fr.plugin.add((t=>{window.LakeCodeMirror&&(t.setPluginConfig("codeBlock",{langList:Sc,defaultLang:"text"}),t.readonly||t.command.add("codeBlock",{execute:e=>{const i=t.insertBox("codeBlock",e);t.history.save();i.getData("codeEditor").focus()}}))})),Fr.plugin.add((t=>{t.readonly||(t.keystroke.setKeydown("space",(e=>{const i=t.selection.range;if(i.isBox)return;const n=function(t){const e=t.selection.range;let i=e.startNode,n=e.startOffset;if(0!==n){if(i.isElement){const t=i.children()[n-1];if(!t||!t.isText)return;i=t,n=i.text().length}if(!(n<1))return{node:i,offset:n}}}(t);if(!n)return;if(function(t,e){const i=t.selection,n=i.range,s=e.offset,o=e.node.text().slice(0,s);for(const e of Ac){const r=e.re.exec(o);if(null!==r){const o=e.getParameters(),a=o.shift();if(!t.command.has(a))return!1;t.prepareOperation();const l=i.insertBookmark(),c=l.focus.prev(),h=c.text(),d=`${h.replace(e.re,"$1")}`;return c.get(0).nodeValue=d,n.setStart(c,s-r[0].length),n.setEnd(c,s-(h.length-d.length)-1),t.command.execute(a,...o),i.toBookmark(l),t.commitOperation(),!0}}return!1}(t,n))return void e.preventDefault();const s=i.getBlocks()[0];s&&(s.isHeading||"p"===s.name)&&function(t,e){const i=t.selection,n=e.offset;let s=e.node.text().slice(0,n);s=s.replace(/[\u200B\u2060]/g,"");for(const e of Ec){const n=e.re.exec(s);if(null!==n){const s=e.getParameters(n),o=s.shift();if(!t.command.has(o))return!1;t.prepareOperation();const r=i.insertBookmark();r.focus.prev().remove();const a=r.focus.closestBlock();return Lc(a),i.range.shrinkAfter(a),t.command.execute(o,...s),i.toBookmark(r),t.commitOperation(),!0}}return!1}(t,n)&&e.preventDefault()})),t.keystroke.setKeydown("enter",(e=>{const i=t.selection.range;if(i.isBox)return;const n=i.getBlocks()[0];return!n||!n.isHeading&&"p"!==n.name||n.find("lake-box").length>0||""!==i.getEndText()?void 0:function(t,e){const i=t.selection;let n=e.text();n=n.replace(/[\u200B\u2060]/g,"");for(const s of Tc){const o=s.re.exec(n);if(null!==o){const n=s.getParameters(o),r=n.shift();return!!t.command.has(r)&&(t.prepareOperation(),e.empty(),Lc(e),i.range.shrinkAfter(e),t.command.execute(r,...n),t.commitOperation(),!0)}}return!1}(t,n)?(e.preventDefault(),e.stopImmediatePropagation(),!1):void 0})))})),Fr.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("enter",(e=>{const i=t.selection.range;if(i.isInsideBox)return;if(e.preventDefault(),t.rectifyContent(),i.isBox)return Mc(t),void t.history.save();if(i.adapt(),i.isInoperative)return;if(i.isBox)return Mc(t),void t.history.save();let n=i.getBlocks()[0];if(n||(t.selection.setBlocks("<p />"),n=i.getBlocks()[0]),n.isEmpty&&"p"!==n.name)return t.selection.setBlocks("<p />"),void t.history.save();Ic(t,n),t.history.save()}))})),Fr.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("shift+enter",(e=>{const i=t.selection.range;if(!i.isInsideBox){if(t.rectifyContent(),e.preventDefault(),i.isBox)return Oc(t),void t.history.save();if(i.adapt(),!i.isInoperative){if(i.isBox)return Oc(t),void t.history.save();Pc(t),t.history.save()}}}))})),Fr.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("backspace",(e=>{const i=t.selection.range;if(i.isInsideBox)return;if(t.rectifyContent(),i.isBoxStart){const n=i.startNode.closest("lake-box"),s=n.prev();if(0===s.length){const i=n.closestBlock();return void(i.length>0&&!i.isContainer&&(e.preventDefault(),zc(t,i),t.history.save()))}if(s.isBlock)return s.isEmpty?(e.preventDefault(),s.remove(),t.selection.fixList(),void t.history.save()):(e.preventDefault(),void i.shrinkAfter(s));if(s.isText&&1===s.text().length)return e.preventDefault(),s.remove(),void t.history.save();i.adaptBox()}if(i.isBox)return e.preventDefault(),t.removeBox(),void t.history.save();if(!i.isCollapsed)return e.preventDefault(),t.selection.deleteContents(),""===t.container.html().trim()&&t.setValue("<p><br /><focus /></p>"),void t.history.save();i.adapt();const n=i.getPrevNode();if(n.isBox)return e.preventDefault(),t.removeBox(n),void t.history.save();if(n.isText&&1===n.text().length){e.preventDefault();const s=n.closestBlock();return i.setStartBefore(n),i.collapseToStart(),n.remove(),s.isEmpty&&(P(s,L("<br />")),i.shrinkAfter(s)),void t.history.save()}if("br"===n.name&&n.prev().length>0)return e.preventDefault(),i.setStartBefore(n),i.collapseToStart(),n.remove(),void t.history.save();if(""===i.getStartText()){e.preventDefault();let n=i.getBlocks()[0];if(n||(t.selection.setBlocks("<p />"),n=i.getBlocks()[0]),""!==n.css("margin-left")||""!==n.css("text-indent")||""!==n.attr("indent"))return F(n,"decrease"),void t.history.save();if(n.isList||"blockquote"===n.name)return t.selection.setBlocks("<p />"),void t.history.save();zc(t,n),t.history.save()}}))})),Fr.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("delete",(e=>{const i=t.selection.range;if(i.isInsideBox)return;if(t.rectifyContent(),i.isBoxEnd){const n=i.startNode.closest("lake-box"),s=n.next();if(0===s.length){const i=n.closestBlock();return void(i.length>0&&!i.isContainer&&(e.preventDefault(),Zc(t,i),t.history.save()))}if(s.isBlock)return s.isEmpty?(e.preventDefault(),s.remove(),t.selection.fixList(),void t.history.save()):(e.preventDefault(),void i.shrinkBefore(s));i.adaptBox()}if(i.isBox)return e.preventDefault(),t.removeBox(),void t.history.save();if(!i.isCollapsed)return e.preventDefault(),t.selection.deleteContents(),""===t.container.html().trim()&&t.setValue("<p><br /><focus /></p>"),void t.history.save();i.adapt();const n=i.getNextNode();if(n.isBox)return e.preventDefault(),t.removeBox(n),void t.history.save();"br"===n.name&&n.next().length>0&&(e.preventDefault(),i.setStartBefore(n),i.collapseToStart(),n.remove(),t.history.save());if(""===i.getEndText()){e.preventDefault();let n=i.getBlocks()[0];n||(t.selection.setBlocks("<p />"),n=i.getBlocks()[0]),Zc(t,n),t.history.save()}}))})),Fr.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("tab",(e=>{if(!1===t.config.indentWithTab)return;e.preventDefault();t.selection.range.getBlocks().forEach((t=>{"p"===t.name&&"2em"!==t.css("text-indent")?t.css("text-indent","2em"):F(t,"increase")})),t.history.save()}))})),Fr.plugin.add((t=>{t.readonly||(t.keystroke.setKeydown("arrow-left",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(i.isBoxStart){const t=n.prev();return t.isBlock||t.isBox?(e.preventDefault(),t.isInlineBox?void i.selectBox(t):void i.shrinkAfter(t)):(i.setStartBefore(n),void i.collapseToStart())}return i.isBoxEnd?(e.preventDefault(),void i.selectBox(n)):(e.preventDefault(),void i.selectBoxStart(n))}if(!i.isCollapsed)return;const s=i.getPrevNode();s.isBox&&(e.preventDefault(),i.selectBox(s))})),t.keystroke.setKeydown("arrow-right",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(i.isBoxStart)return e.preventDefault(),void i.selectBox(n);if(i.isBoxEnd){const t=n.next();return t.isBlock||t.isBox?(e.preventDefault(),t.isInlineBox?void i.selectBox(t):void i.shrinkBefore(t)):(i.setStartAfter(n),void i.collapseToStart())}return e.preventDefault(),void i.selectBoxEnd(n)}if(!i.isCollapsed)return;const s=i.getNextNode();s.isBox&&(e.preventDefault(),i.selectBox(s))})),t.keystroke.setKeydown("arrow-up",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(n.isBlockBox){const t=n.prev();if(t.isBlock||t.isBox)return e.preventDefault(),void i.shrinkAfter(t)}i.setStartBefore(n),i.collapseToStart()}})),t.keystroke.setKeydown("arrow-down",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(n.isBlockBox){const t=n.next();if(t.isBlock||t.isBox)return e.preventDefault(),void i.shrinkBefore(t)}i.setStartAfter(n),i.collapseToStart()}})))})),Fr.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("escape",(e=>{const i=t.selection,n=i.range;if(n.isBoxCenter||n.isInsideBox){e.preventDefault();const t=n.commonAncestor.closest("lake-box");return n.selectBoxEnd(t),void i.sync()}t.hasFocus&&(e.preventDefault(),t.blur())}))})),t.Box=Jt,t.Button=Ce,t.Dropdown=Fe,t.Editor=Fr,t.Fragment=ie,t.HTMLParser=oe,t.Nodes=T,t.Range=I,t.TextParser=re,t.Toolbar=class{constructor(t){this.placement="top",this.allMenuMap=new Map,this.buttonItemList=[],this.dropdownItemList=[],this.root=L(t.root),this.items=t.items||Yr,t.placement&&(this.placement=t.placement),this.container=L('<div class="lake-toolbar" />'),this.root.addClass("lake-custom-properties")}appendDivider(){this.container.append('<div class="lake-toolbar-divider" />')}appendButton(t,e){new Ce({root:this.container,name:e.name,icon:e.icon,tooltip:"string"==typeof e.tooltip?e.tooltip:e.tooltip(t.locale),tabIndex:-1,onClick:()=>{t.focus(),e.onClick(t,e.name)}}).render()}appendDropdown(t,e){new Fe({root:this.container,locale:t.locale,name:e.name,icon:e.icon,accentIcon:e.accentIcon,downIcon:e.downIcon,defaultValue:e.defaultValue,tooltip:e.tooltip,width:e.width,menuType:e.menuType,menuItems:e.menuItems,tabIndex:-1,placement:"top"===this.placement?"bottom":"top",onSelect:i=>{t.focus(),e.onSelect(t,i)}}).render()}appendUpload(t,e){const i=L(a`
|
|
85
85
|
<div class="lake-upload" name="${e.name}">
|
|
86
86
|
<input type="file" />
|
|
87
87
|
</div>
|