lakelib 0.1.0 → 0.1.1
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/README.md +1 -1
- package/dist/lake.min.js +2 -2
- package/dist/lake.min.js.map +1 -1
- package/lib/lake.js +27 -12
- package/lib/lake.js.map +1 -1
- package/lib/types/editor.d.ts +14 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
Lake is a rich text editor for the web. It has a good user experience and provides easy-to-use programming interface to allow further extension.
|
|
10
10
|
|
|
11
|
-
[Examples](https://lakejs.org/examples/) · [Getting started](https://lakejs.org/guide/getting-started
|
|
11
|
+
[Examples](https://lakejs.org/examples/) · [Getting started](https://lakejs.org/guide/getting-started) · [Reference](https://lakejs.org/reference/)
|
|
12
12
|
|
|
13
13
|
## Development
|
|
14
14
|
|
package/dist/lake.min.js
CHANGED
|
@@ -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">${i.text}</div>
|
|
17
17
|
</li>
|
|
18
|
-
`);if(t.append(o),"color"===e.menuType&&(o.attr("title",i.text),o.find(".lake-dropdown-menu-text").css("background-color",i.value)),i.icon){const t=I('<div class="lake-dropdown-menu-icon"></div>');t.append(i.icon),o.prepend(t)}const a=n.get("check");if(a){const t=I('<div class="lake-dropdown-menu-check"></div>');t.append(a),o.prepend(t)}}}showMenu(){const t=this.config,e=this.node,i=e.find(".lake-dropdown-menu");if(e.attr("disabled"))return;const n=_e.getValue(e);i.find(".lake-dropdown-menu-check").css("visibility","hidden"),i.find("li").each((t=>{const e=I(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");e.get(0).getBoundingClientRect().x+i.width()+50>window.innerWidth?(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=I(s.target).closest("li"),a=o.attr("value");_e.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),n.attr("title",e.tooltip);const s=n.find(".lake-dropdown-text"),o=n.find(".lake-dropdown-icon");e.icon&&o.append(e.icon),e.accentIcon&&o.append(e.accentIcon);const r=n.find(".lake-dropdown-down-icon");e.downIcon&&r.append(e.downIcon);const a=I('<ul class="lake-dropdown-menu" />');if(a.addClass(`lake-${e.menuType}-dropdown-menu`),_e.setValue(i,[e.defaultValue]),s.length>0){const i=_e.getMenuMap(e.menuItems);s.text(null!==(t=i.get(e.defaultValue))&&void 0!==t?t:e.defaultValue)}"color"===e.menuType&&this.updateColorAccent(n,e.defaultValue),this.apppendMenuItems(a),i.append(n),i.append(a),this.root.append(i),this.bindEvents()}unmount(){this.node.remove(),document.removeEventListener("click",this.documentClickListener)}}var Se=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},Ae="object"==typeof Rt&&Rt&&Rt.Object===Object&&Rt,Ce=Ae,Be="object"==typeof self&&self&&self.Object===Object&&self,Ee=Ce||Be||Function("return this")(),Te=Ee,Ie=function(){return Te.Date.now()},Le=/\s/;var Me=function(t){for(var e=t.length;e--&&Le.test(t.charAt(e)););return e},Pe=Me,Oe=/^\s+/;var ze=function(t){return t?t.slice(0,Pe(t)+1).replace(Oe,""):t},Ze=Ee.Symbol,Ne=Ze,He=Object.prototype,De=He.hasOwnProperty,$e=He.toString,Ve=Ne?Ne.toStringTag:void 0;var Fe=function(t){var e=De.call(t,Ve),i=t[Ve];try{t[Ve]=void 0;var n=!0}catch(t){}var s=$e.call(t);return n&&(e?t[Ve]=i:delete t[Ve]),s},je=Object.prototype.toString;var Re=Fe,We=function(t){return je.call(t)},Ue=Ze?Ze.toStringTag:void 0;var qe=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Ue&&Ue in Object(t)?Re(t):We(t)};var Ke=function(t){return null!=t&&"object"==typeof t},Ge=qe,Xe=Ke;var Je=ze,Qe=Se,Ye=function(t){return"symbol"==typeof t||Xe(t)&&"[object Symbol]"==Ge(t)},ti=/^[-+]0x[0-9a-f]+$/i,ei=/^0b[01]+$/i,ii=/^0o[0-7]+$/i,ni=parseInt;var si=Se,oi=Ie,ri=function(t){if("number"==typeof t)return t;if(Ye(t))return NaN;if(Qe(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Qe(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Je(t);var i=ei.test(t);return i||ii.test(t)?ni(t.slice(2),i?2:8):ti.test(t)?NaN:+t},ai=Math.max,li=Math.min;var ci=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=oi();if(m(t))return g(t);a=setTimeout(f,function(t){var i=e-(t-l);return d?li(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=oi(),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=ri(e)||0,si(i)&&(h=!!i.leading,o=(d="maxWait"in i)?ai(ri(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(oi())},v},hi=Wt(ci);var di=function(){this.__data__=[],this.size=0};var pi=function(t,e){return t===e||t!=t&&e!=e},ui=pi;var mi=function(t,e){for(var i=t.length;i--;)if(ui(t[i][0],e))return i;return-1},fi=mi,gi=Array.prototype.splice;var vi=function(t){var e=this.__data__,i=fi(e,t);return!(i<0)&&(i==e.length-1?e.pop():gi.call(e,i,1),--this.size,!0)},wi=mi;var yi=function(t){var e=this.__data__,i=wi(e,t);return i<0?void 0:e[i][1]},xi=mi;var bi=mi;var ki=function(t,e){var i=this.__data__,n=bi(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this},_i=di,Si=vi,Ai=yi,Ci=function(t){return xi(this.__data__,t)>-1},Bi=ki;function Ei(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])}}Ei.prototype.clear=_i,Ei.prototype.delete=Si,Ei.prototype.get=Ai,Ei.prototype.has=Ci,Ei.prototype.set=Bi;var Ti=Ei,Ii=Ti;var Li=function(){this.__data__=new Ii,this.size=0};var Mi=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i};var Pi=function(t){return this.__data__.get(t)};var Oi=function(t){return this.__data__.has(t)},zi=qe,Zi=Se;var Ni,Hi=function(t){if(!Zi(t))return!1;var e=zi(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},Di=Ee["__core-js_shared__"],$i=(Ni=/[^.]+$/.exec(Di&&Di.keys&&Di.keys.IE_PROTO||""))?"Symbol(src)_1."+Ni:"";var Vi=function(t){return!!$i&&$i in t},Fi=Function.prototype.toString;var ji=function(t){if(null!=t){try{return Fi.call(t)}catch(t){}try{return t+""}catch(t){}}return""},Ri=Hi,Wi=Vi,Ui=Se,qi=ji,Ki=/^\[object .+?Constructor\]$/,Gi=Function.prototype,Xi=Object.prototype,Ji=Gi.toString,Qi=Xi.hasOwnProperty,Yi=RegExp("^"+Ji.call(Qi).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var tn=function(t){return!(!Ui(t)||Wi(t))&&(Ri(t)?Yi:Ki).test(qi(t))},en=function(t,e){return null==t?void 0:t[e]};var nn=function(t,e){var i=en(t,e);return tn(i)?i:void 0},sn=nn(Ee,"Map"),on=nn(Object,"create"),rn=on;var an=function(){this.__data__=rn?rn(null):{},this.size=0};var ln=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},cn=on,hn=Object.prototype.hasOwnProperty;var dn=function(t){var e=this.__data__;if(cn){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return hn.call(e,t)?e[t]:void 0},pn=on,un=Object.prototype.hasOwnProperty;var mn=on;var fn=an,gn=ln,vn=dn,wn=function(t){var e=this.__data__;return pn?void 0!==e[t]:un.call(e,t)},yn=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=mn&&void 0===e?"__lodash_hash_undefined__":e,this};function xn(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])}}xn.prototype.clear=fn,xn.prototype.delete=gn,xn.prototype.get=vn,xn.prototype.has=wn,xn.prototype.set=yn;var bn=xn,kn=Ti,_n=sn;var Sn=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var An=function(t,e){var i=t.__data__;return Sn(e)?i["string"==typeof e?"string":"hash"]:i.map},Cn=An;var Bn=An;var En=An;var Tn=An;var In=function(){this.size=0,this.__data__={hash:new bn,map:new(_n||kn),string:new bn}},Ln=function(t){var e=Cn(this,t).delete(t);return this.size-=e?1:0,e},Mn=function(t){return Bn(this,t).get(t)},Pn=function(t){return En(this,t).has(t)},On=function(t,e){var i=Tn(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this};function zn(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])}}zn.prototype.clear=In,zn.prototype.delete=Ln,zn.prototype.get=Mn,zn.prototype.has=Pn,zn.prototype.set=On;var Zn=zn,Nn=Ti,Hn=sn,Dn=Zn;var $n=Ti,Vn=Li,Fn=Mi,jn=Pi,Rn=Oi,Wn=function(t,e){var i=this.__data__;if(i instanceof Nn){var n=i.__data__;if(!Hn||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new Dn(n)}return i.set(t,e),this.size=i.size,this};function Un(t){var e=this.__data__=new $n(t);this.size=e.size}Un.prototype.clear=Vn,Un.prototype.delete=Fn,Un.prototype.get=jn,Un.prototype.has=Rn,Un.prototype.set=Wn;var qn=Un;var Kn=Zn,Gn=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Xn=function(t){return this.__data__.has(t)};function Jn(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new Kn;++e<i;)this.add(t[e])}Jn.prototype.add=Jn.prototype.push=Gn,Jn.prototype.has=Xn;var Qn=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 Yn=Jn,ts=Qn,es=function(t,e){return t.has(e)};var is=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 Yn: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(!ts(e,(function(t,e){if(!es(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 ns=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t,n){i[++e]=[n,t]})),i};var ss=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i},os=Ee.Uint8Array,rs=pi,as=is,ls=ns,cs=ss,hs=Ze?Ze.prototype:void 0,ds=hs?hs.valueOf:void 0;var ps=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 os(t),new os(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return rs(+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=ls;case"[object Set]":var l=1&n;if(a||(a=cs),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=as(a(t),a(e),n,s,o,r);return r.delete(t),h;case"[object Symbol]":if(ds)return ds.call(t)==ds.call(e)}return!1};var us=function(t,e){for(var i=-1,n=e.length,s=t.length;++i<n;)t[s+i]=e[i];return t},ms=Array.isArray,fs=us,gs=ms;var vs=function(t,e,i){var n=e(t);return gs(t)?n:fs(n,i(t))};var ws=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 ys=ws,xs=function(){return[]},bs=Object.prototype.propertyIsEnumerable,ks=Object.getOwnPropertySymbols,_s=ks?function(t){return null==t?[]:(t=Object(t),ys(ks(t),(function(e){return bs.call(t,e)})))}:xs;var Ss=function(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n},As=qe,Cs=Ke;var Bs=function(t){return Cs(t)&&"[object Arguments]"==As(t)},Es=Ke,Ts=Object.prototype,Is=Ts.hasOwnProperty,Ls=Ts.propertyIsEnumerable,Ms=Bs(function(){return arguments}())?Bs:function(t){return Es(t)&&Is.call(t,"callee")&&!Ls.call(t,"callee")},Ps=Ms,Os={exports:{}};var zs=function(){return!1};!function(t,e){var i=Ee,n=zs,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}(Os,Os.exports);var Zs=Os.exports,Ns=/^(?:0|[1-9]\d*)$/;var Hs=function(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&Ns.test(t))&&t>-1&&t%1==0&&t<e};var Ds=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},$s=qe,Vs=Ds,Fs=Ke,js={};js["[object Float32Array]"]=js["[object Float64Array]"]=js["[object Int8Array]"]=js["[object Int16Array]"]=js["[object Int32Array]"]=js["[object Uint8Array]"]=js["[object Uint8ClampedArray]"]=js["[object Uint16Array]"]=js["[object Uint32Array]"]=!0,js["[object Arguments]"]=js["[object Array]"]=js["[object ArrayBuffer]"]=js["[object Boolean]"]=js["[object DataView]"]=js["[object Date]"]=js["[object Error]"]=js["[object Function]"]=js["[object Map]"]=js["[object Number]"]=js["[object Object]"]=js["[object RegExp]"]=js["[object Set]"]=js["[object String]"]=js["[object WeakMap]"]=!1;var Rs=function(t){return Fs(t)&&Vs(t.length)&&!!js[$s(t)]};var Ws=function(t){return function(e){return t(e)}},Us={exports:{}};!function(t,e){var i=Ae,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}(Us,Us.exports);var qs=Us.exports,Ks=Rs,Gs=Ws,Xs=qs&&qs.isTypedArray,Js=Xs?Gs(Xs):Ks,Qs=Ss,Ys=Ps,to=ms,eo=Zs,io=Hs,no=Js,so=Object.prototype.hasOwnProperty;var oo=function(t,e){var i=to(t),n=!i&&Ys(t),s=!i&&!n&&eo(t),o=!i&&!n&&!s&&no(t),r=i||n||s||o,a=r?Qs(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)||io(c,l))||a.push(c);return a},ro=Object.prototype;var ao=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ro)};var lo=function(t,e){return function(i){return t(e(i))}}(Object.keys,Object),co=ao,ho=lo,po=Object.prototype.hasOwnProperty;var uo=Hi,mo=Ds;var fo=oo,go=function(t){if(!co(t))return ho(t);var e=[];for(var i in Object(t))po.call(t,i)&&"constructor"!=i&&e.push(i);return e},vo=function(t){return null!=t&&mo(t.length)&&!uo(t)};var wo=vs,yo=_s,xo=function(t){return vo(t)?fo(t):go(t)};var bo=function(t){return wo(t,xo,yo)},ko=Object.prototype.hasOwnProperty;var _o=function(t,e,i,n,s,o){var r=1&i,a=bo(t),l=a.length;if(l!=bo(e).length&&!r)return!1;for(var c=l;c--;){var h=a[c];if(!(r?h in e:ko.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 w=t.constructor,y=e.constructor;w==y||!("constructor"in t)||!("constructor"in e)||"function"==typeof w&&w instanceof w&&"function"==typeof y&&y instanceof y||(u=!1)}return o.delete(t),o.delete(e),u},So=nn(Ee,"DataView"),Ao=sn,Co=nn(Ee,"Promise"),Bo=nn(Ee,"Set"),Eo=nn(Ee,"WeakMap"),To=qe,Io=ji,Lo="[object Map]",Mo="[object Promise]",Po="[object Set]",Oo="[object WeakMap]",zo="[object DataView]",Zo=Io(So),No=Io(Ao),Ho=Io(Co),Do=Io(Bo),$o=Io(Eo),Vo=To;(So&&Vo(new So(new ArrayBuffer(1)))!=zo||Ao&&Vo(new Ao)!=Lo||Co&&Vo(Co.resolve())!=Mo||Bo&&Vo(new Bo)!=Po||Eo&&Vo(new Eo)!=Oo)&&(Vo=function(t){var e=To(t),i="[object Object]"==e?t.constructor:void 0,n=i?Io(i):"";if(n)switch(n){case Zo:return zo;case No:return Lo;case Ho:return Mo;case Do:return Po;case $o:return Oo}return e});var Fo=qn,jo=is,Ro=ps,Wo=_o,Uo=Vo,qo=ms,Ko=Zs,Go=Js,Xo="[object Arguments]",Jo="[object Array]",Qo="[object Object]",Yo=Object.prototype.hasOwnProperty;var tr=function(t,e,i,n,s,o){var r=qo(t),a=qo(e),l=r?Jo:Uo(t),c=a?Jo:Uo(e),h=(l=l==Xo?Qo:l)==Qo,d=(c=c==Xo?Qo:c)==Qo,p=l==c;if(p&&Ko(t)){if(!Ko(e))return!1;r=!0,h=!1}if(p&&!h)return o||(o=new Fo),r||Go(t)?jo(t,e,i,n,s,o):Ro(t,e,l,i,n,s,o);if(!(1&i)){var u=h&&Yo.call(t,"__wrapped__"),m=d&&Yo.call(e,"__wrapped__");if(u||m){var f=u?t.value():t,g=m?e.value():e;return o||(o=new Fo),s(f,g,i,n,o)}}return!!p&&(o||(o=new Fo),Wo(t,e,i,n,s,o))},er=Ke;var ir=function t(e,i,n,s,o){return e===i||(null==e||null==i||!er(e)&&!er(i)?e!=e&&i!=i:tr(e,i,n,s,t,o))},nr=ir;var sr=Wt((function(t,e){return nr(t,e)}));function or(t){const e=t.get(0),i={};if(e.hasAttributes())for(const t of e.attributes)i[t.name]=t.value;return i}class rr{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 L(t)}return new L}addRangeToNativeSelection(){this.selection.removeAllRanges(),this.selection.addRange(this.range.get())}syncByRange(){const t=this.getRangeFromNativeSelection();this.range.get()!==t.get()&&(this.range=t)}synByBookmark(){const t=this.range,e=this.container,i=e.find("lake-box[focus]");if(i.length>0)return ae(t,{anchor:new T,focus:i}),void this.addRangeToNativeSelection();ae(t,{anchor:e.find('lake-bookmark[type="anchor"]'),focus:e.find('lake-bookmark[type="focus"]')}),this.addRangeToNativeSelection()}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:or(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:or(e),styles:p(e.attr("style"))}),e=e.first()}}(t,this.range),t}insertBookmark(){return oe(this.range)}toBookmark(t){return ae(this.range,t)}insertNode(t){return se(this.range,t)}insertFragment(t){return he(this.range,t)}insertContents(t){return de(this.range,t)}deleteContents(){return ce(this.range)}setBlocks(t){return pe(this.range,t)}splitBlock(){return ue(this.range)}splitMarks(t){return ge(this.range,t)}addMark(t){return we(this.range,t)}removeMark(t){return xe(this.range,t)}fixList(){return le(this.range)}insertLink(t){return be(this.range,t)}}class ar{constructor(t){this.commandMap=new Map,this.event=new qt,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),C(`Command '${t}' executed`)}}var lr,cr={exports:{}};lr=cr,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))}lr.exports?lr.exports=m:t.md5=m}(Rt);var hr=Wt(cr.exports);const dr=new Map;class pr{constructor(t){this.list=[],this.index=0,this.canSave=!0,this.limit=100,this.event=new qt,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 ie(t).getHTML()}addIdToBoxes(t){t.find("lake-box").each((t=>{const e=new T(t),i=hr(`${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=dr.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=>{new 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),oe(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.synByBookmark(),C(`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.synByBookmark(),C(`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)),C(`History saved, the last index is ${this.index}`))}}var ur=["Shift","Meta","Alt","Control"],mr="object"==typeof navigator?navigator.platform:"",fr=/Mac|iPod|iPhone|iPad/.test(mr),gr=fr?"Meta":"Control",vr="Win32"===mr?["Control","Alt"]:fr?["Alt"]:[];function wr(t,e){return"function"==typeof t.getModifierState&&(t.getModifierState(e)||vr.includes(e)&&t.getModifierState("AltGraph"))}function yr(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?gr:t})),i]}))}function xr(t,e){var i;void 0===e&&(e={});var n=null!=(i=e.timeout)?i:1e3,s=Object.keys(t).map((function(e){return[yr(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!wr(t,e)}))||ur.find((function(i){return!e[0].includes(i)&&e[1]!==i&&wr(t,i)})))}(t,s[0])?wr(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 br=new Map([["#","shift+#"]]);class kr{constructor(t){this.keydownEventList=[],this.keyupEventList=[],this.container=t}normalizeType(t){var e;return t=(t=null!==(e=br.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=xr({[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=xr({[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 _r={value:"<p><br /><focus /></p>",readonly:!1,spellcheck:!1,tabIndex:0,indentWithTab:!0,minChangeSize:5,imageRequestMethod:"POST",imageRequestAction:"/upload",imageRequestTypes:["image/gif","image/jpeg","image/png","image/svg+xml"]};class Sr{constructor(t){if(this.unsavedInputData="",this.stateData={appliedItems:[],disabledNameMap:new Map,selectedNameMap:new Map,selectedValuesMap:new Map},this.isComposing=!1,this.event=new qt,this.box=Sr.box,this.beforeunloadListener=()=>{this.history.save()},this.selectionchangeListener=()=>{this.selection.syncByRange(),this.updateBoxSelectionStyle(),this.emitStateChangeEvent()},this.clickListener=t=>{const e=new T(t.target);e.closest(".lake-popup").length>0||this.event.emit("click",e)},this.resizeListener=()=>{this.event.emit("resize")},this.updateBoxSelectionStyle=hi((()=>{if(0===this.root.first().length)return;const t=this.selection.range,e=t.clone();e.adaptBox(),this.box.findAll(this).each((i=>{const n=new 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"),void s.addClass("lake-box-activated");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")):(s.removeClass("lake-box-focused"),s.addClass("lake-box-selected")));s.removeClass("lake-box-activated"),s.removeClass("lake-box-focused"),s.removeClass("lake-box-selected")}})),this.event.emit("boxselectionstylechange")}),50,{leading:!1,trailing:!0,maxWait:50}),this.emitStateChangeEvent=hi((()=>{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};sr(o,this.stateData)||(this.toolbar&&this.toolbar.updateState(o),this.event.emit("statechange",o),this.stateData=o)}),100,{leading:!1,trailing:!0,maxWait:100}),this.emitChangeEvent=t=>{this.rectifyContent(),this.emitStateChangeEvent(),this.event.emit("change",t)},!t.root)throw new Error("The root of the config must be specified.");this.root=I(t.root),this.toolbar=t.toolbar,this.config=Object.assign(Object.assign({},_r),t),this.containerWrapper=I('<div class="lake-container-wrapper" />'),this.container=I('<div class="lake-container" />'),this.overlayContainer=I('<div class="lake-overlay" />'),this.popupContainer=I('<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.selection=new rr(this.container),this.command=new ar(this.selection),this.history=new pr(this.selection),this.keystroke=new kr(this.container),Gt.set(this.container.id,this)}inputInBoxStrip(){const t=this.selection,e=t.range,i=e.startNode.closest(".lake-box-strip"),n=i.closest("lake-box");if("inline"===new Yt(n).type)e.isBoxStart?(e.setStartBefore(n),e.collapseToStart()):(e.setStartAfter(n),e.collapseToStart());else{const t=I("<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),this.emitChangeEvent(t)})),this.history.event.on("redo",(t=>{this.box.renderAll(this),this.emitChangeEvent(t)})),this.history.event.on("save",(t=>{this.box.rectifyInstances(this),this.emitChangeEvent(t)}))}bindFocusEvents(){this.container.on("focus",(()=>{this.root.addClass("lake-root-focused")})),this.container.on("blur",(()=>{this.root.removeClass("lake-root-focused")}))}rectifyContent(){let t=this.container.children();for(const e of t)(e.isBlock||e.isMark)&&""===e.html()&&(e.remove(),C("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 C("Rectifying content: default paragraph was added");if(1===t.length){const e=t[0];if(e.isVoid){const t=I("<p />");e.before(t),t.append(e),this.selection.range.shrinkAfter(t),C("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()}focus(){this.container.focus()}blur(){this.container.blur()}setValue(t){t=u(t);const e=new ie(t).getFragment();this.container.empty(),this.container.append(e),Sr.box.renderAll(this),this.selection.synByBookmark()}getValue(){const t=this.selection.insertBookmark();let e=new ie(this.container).getHTML();return e=m(e),this.selection.toBookmark(t),e}insertBox(t,e){const i=function(t,e,i){if(t.commonAncestor.isOutside)return null;const n=new Yt(e);i&&(n.value=i);const s=document.createDocumentFragment();if(s.appendChild(n.node.get(0)),"inline"===n.type)return he(t,s),n.render(),t.selectBoxEnd(n.node),n;const o=ue(t);return o.start&&(t.setEndAfter(o.start),t.collapseToEnd()),o.end&&o.end.isEmpty&&o.end.remove(),he(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).set(i.node.id,i),i}removeBox(){const t=function(t){if(t.commonAncestor.isOutside)return null;const e=t.commonAncestor.closest("lake-box");if(0===e.length)return null;const i=new Yt(e);if("block"===i.type){const n=I("<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,I("<br />")),t.shrinkAfter(n)),i}(this.selection.range);if(t){this.box.getInstances(this).delete(t.node.id)}return t}render(){const t=u(this.config.value),e=new ie(t).getFragment();this.root.empty(),this.root.append(this.containerWrapper),this.containerWrapper.append(this.container),this.containerWrapper.append(this.overlayContainer),I(document.body).append(this.popupContainer),this.container.append(e),this.readonly||(this.bindFocusEvents(),this.selection.synByBookmark(),this.history.save(),Sr.plugin.loadAll(this)),Sr.box.renderAll(this),this.toolbar&&this.toolbar.render(this),this.readonly||(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.root.empty(),this.popupContainer.remove(),this.readonly||(window.removeEventListener("beforeunload",this.beforeunloadListener),document.removeEventListener("selectionchange",this.selectionchangeListener),document.removeEventListener("click",this.clickListener),window.removeEventListener("resize",this.resizeListener))}}Sr.version="0.1.0",Sr.box=new class{add(t){Kt.set(t.name,t)}remove(t){Kt.delete(t)}getNames(){return Array.from(Kt.keys())}getInstances(t){let e=dr.get(t.container.id);return e||(e=new Map,dr.set(t.container.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))}findAll(t){return t.container.find("lake-box")}renderAll(t){this.rectifyInstances(t);const e=this.getInstances(t);this.findAll(t).each((t=>{const i=new T(t);if(e.get(i.id))return;const n=new Yt(i);n.render(),e.set(n.node.id,n)}))}},Sr.plugin=new class{constructor(){this.pluginList=[]}add(t){this.pluginList.push(t)}loadAll(t){this.pluginList.forEach((e=>{e(t)}))}};const Ar=/^\{.*\}$/,Cr=/(\{(?:[^{}]+|\{(?:[^{}]+)*\})*\})/g,Br=t=>t.substring(1,t.length-1),Er=(t,e=!0,i="",n="")=>t.split(Cr).map((t=>{if(!t.match(Cr))return t;const e=Br(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}})(Br(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})),Tr=(t,e,i)=>e.reduce(((e,i)=>{var n,s,o;return null!==(s=i.match(Ar)?(t=>{var i;return null!==(i=t[e])&&void 0!==i?i:t["*"]})((o=i,Object.fromEntries(Br(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),Ir=/\?\?/g,Lr=(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(Ir,r);const a=o.length?Tr(i,o,r):r;return(""+(null!=a?a:"")).trim()})).join(""))(t,e,i,1===n.length&&o?s:n)},Mr=(t,e)=>{const i={},n=new Intl.PluralRules(t);return(t,...s)=>Lr(((t,e)=>t[e]||(t[e]=Er(e)))(i,t),n,e,s)};const Pr=(t={},e)=>"string"==typeof t?e.bind(null,t):Object.assign(Object.defineProperty((()=>""),"name",{writable:!0}),t),Or=(t,e)=>new Proxy(Pr(t,e),{get:(t,i)=>i===Symbol.iterator?[][Symbol.iterator].bind(Object.values(t).map((t=>Pr(t,e)))):Or(t[i],e)});const zr={"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",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"},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:"图片",removeColor:"默认"},link:{newLink:"新链接",url:"链接 URL",title:"链接文本",copy:"复制到剪贴板",open:"打开链接",save:"确定",unlink:"取消链接"},image:{view:"查看大图",remove:"删除",previous:"上一张",next:"下一张",close:"关闭 (Esc)",loadingError:"图片加载失败",zoomOut:"缩小",zoomIn:"放大"},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:"画像",removeColor:"デフォルト"},link:{newLink:"新しいリンク",url:"リンク URL",title:"リンク文字",copy:"クリップボードにコピー",open:"リンクを開く",save:"確認",unlink:"リンクを削除"},image:{view:"大きな画像を見る",remove:"削除",previous:"前の画像",next:"次の画像",close:"閉じる (Esc)",loadingError:"画像を読み込めません",zoomOut:"縮小",zoomIn:"拡大"},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:"이미지",removeColor:"기본색"},link:{newLink:"새 링크",url:"링크 URL",title:"링크 텍스트",copy:"클립보드에 복사",open:"링크 열기",save:"확인",unlink:"링크 제거"},image:{view:"큰 이미지 보기",remove:"삭제",previous:"이전 이미지",next:"다음 이미지",close:"닫기 (Esc)",loadingError:"이미지를 로드할 수 없습니다",zoomOut:"축소",zoomIn:"확대"},codeBlock:{langType:"코드언어 선택"}}},Zr=Object.keys(zr),Nr={},Hr={},Dr=t=>{Nr[t]||(Nr[t]=zr[t],(t=>{Hr[t]={}})(t))};Zr.forEach(Dr);const $r=(t=>function(t,e,i={}){return Or(e,Mr(t,i))}(t,Nr[t],Hr[t]))(Zr.indexOf(window.LAKE_LANGUAGE)>=0?window.LAKE_LANGUAGE:"en-US"),Vr=[{value:"h1",text:`<span style="font-weight: bold; font-size: 26px;">${$r.toolbar.heading1()}</span>`},{value:"h2",text:`<span style="font-weight: bold; font-size: 24px;">${$r.toolbar.heading2()}</span>`},{value:"h3",text:`<span style="font-weight: bold; font-size: 22px;">${$r.toolbar.heading3()}</span>`},{value:"h4",text:`<span style="font-weight: bold; font-size: 20px;">${$r.toolbar.heading4()}</span>`},{value:"h5",text:`<span style="font-weight: bold; font-size: 18px;">${$r.toolbar.heading5()}</span>`},{value:"h6",text:`<span style="font-weight: bold; font-size: 16px;">${$r.toolbar.heading6()}</span>`},{value:"p",text:$r.toolbar.paragraph()}],Fr=[{icon:n.get("numberedList"),value:"numbered",text:$r.toolbar.numberedList()},{icon:n.get("bulletedList"),value:"bulleted",text:$r.toolbar.bulletedList()},{icon:n.get("checklist"),value:"checklist",text:$r.toolbar.checklist()}],jr=[{icon:n.get("alignLeft"),value:"left",text:$r.toolbar.alignLeft()},{icon:n.get("alignCenter"),value:"center",text:$r.toolbar.alignCenter()},{icon:n.get("alignRight"),value:"right",text:$r.toolbar.alignRight()},{icon:n.get("alignJustify"),value:"justify",text:$r.toolbar.alignJustify()}],Rr=[{icon:n.get("increaseIndent"),value:"increase",text:$r.toolbar.increaseIndent()},{icon:n.get("decreaseIndent"),value:"decrease",text:$r.toolbar.decreaseIndent()}],Wr=[{icon:n.get("italic"),value:"italic",text:$r.toolbar.italic()},{icon:n.get("underline"),value:"underline",text:$r.toolbar.underline()},{icon:n.get("strikethrough"),value:"strikethrough",text:$r.toolbar.strikethrough()},{icon:n.get("superscript"),value:"superscript",text:$r.toolbar.superscript()},{icon:n.get("subscript"),value:"subscript",text:$r.toolbar.subscript()},{icon:n.get("code"),value:"code",text:$r.toolbar.code()}],Ur=["#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"],qr=[{icon:n.get("removeFormat"),value:"",text:$r.toolbar.removeColor()}];for(const t of Ur)qr.push({value:t.toLowerCase(),text:t.toUpperCase()});const Kr=new Map([["strong","bold"],["em","italic"],["i","italic"],["u","underline"],["s","strikethrough"],["sup","superscript"],["sub","subscript"],["code","code"]]),Gr=[{name:"undo",type:"button",icon:n.get("undo"),tooltip:$r.toolbar.undo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"redo",type:"button",icon:n.get("redo"),tooltip:$r.toolbar.redo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"selectAll",type:"button",icon:n.get("selectAll"),tooltip:$r.toolbar.selectAll(),onClick:(t,e)=>{t.command.execute(e)}},{name:"paragraph",type:"button",icon:n.get("paragraph"),tooltip:$r.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:$r.toolbar.blockQuote(),onClick:(t,e)=>{t.command.execute(e)}},{name:"numberedList",type:"button",icon:n.get("numberedList"),tooltip:$r.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:$r.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:$r.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:$r.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:$r.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:$r.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:$r.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:$r.toolbar.increaseIndent(),onClick:t=>{t.command.execute("indent","increase")}},{name:"decreaseIndent",type:"button",icon:n.get("decreaseIndent"),tooltip:$r.toolbar.decreaseIndent(),onClick:t=>{t.command.execute("indent","decrease")}},{name:"bold",type:"button",icon:n.get("bold"),tooltip:$r.toolbar.bold(),onClick:(t,e)=>{t.command.execute(e)}},{name:"italic",type:"button",icon:n.get("italic"),tooltip:$r.toolbar.italic(),onClick:(t,e)=>{t.command.execute(e)}},{name:"underline",type:"button",icon:n.get("underline"),tooltip:$r.toolbar.underline(),onClick:(t,e)=>{t.command.execute(e)}},{name:"strikethrough",type:"button",icon:n.get("strikethrough"),tooltip:$r.toolbar.strikethrough(),onClick:(t,e)=>{t.command.execute(e)}},{name:"superscript",type:"button",icon:n.get("superscript"),tooltip:$r.toolbar.superscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"subscript",type:"button",icon:n.get("subscript"),tooltip:$r.toolbar.subscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"code",type:"button",icon:n.get("code"),tooltip:$r.toolbar.code(),onClick:(t,e)=>{t.command.execute(e)}},{name:"removeFormat",type:"button",icon:n.get("removeFormat"),tooltip:$r.toolbar.removeFormat(),onClick:(t,e)=>{t.command.execute(e)}},{name:"formatPainter",type:"button",icon:n.get("formatPainter"),tooltip:$r.toolbar.formatPainter(),onClick:(t,e)=>{t.command.execute(e)}},{name:"link",type:"button",icon:n.get("link"),tooltip:$r.toolbar.link(),onClick:(t,e)=>{t.command.execute(e)}},{name:"hr",type:"button",icon:n.get("hr"),tooltip:$r.toolbar.hr(),onClick:(t,e)=>{t.command.execute(e)}},{name:"codeBlock",type:"button",icon:n.get("codeBlock"),tooltip:$r.toolbar.codeBlock(),onClick:(t,e)=>{t.command.execute(e)}},{name:"heading",type:"dropdown",downIcon:n.get("down"),defaultValue:"p",tooltip:$r.toolbar.heading(),width:"100px",menuType:"list",menuItems:Vr,onSelect:(t,e)=>{t.command.execute("heading",e)}},{name:"list",type:"dropdown",downIcon:n.get("down"),icon:n.get("list"),defaultValue:"",tooltip:$r.toolbar.list(),width:"auto",menuType:"list",menuItems:Fr,onSelect:(t,e)=>{t.command.execute("list",e)}},{name:"align",type:"dropdown",downIcon:n.get("down"),icon:n.get("alignLeft"),defaultValue:"",tooltip:$r.toolbar.align(),width:"auto",menuType:"list",menuItems:jr,onSelect:(t,e)=>{t.command.execute("align",e)}},{name:"indent",type:"dropdown",downIcon:n.get("down"),icon:n.get("increaseIndent"),defaultValue:"",tooltip:$r.toolbar.indent(),width:"auto",menuType:"list",menuItems:Rr,onSelect:(t,e)=>{t.command.execute("indent",e)}},{name:"fontFamily",type:"dropdown",downIcon:n.get("down"),defaultValue:"Segoe UI",tooltip:$r.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:$r.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:$r.toolbar.moreStyle(),width:"auto",menuType:"list",menuItems:Wr,selectedValues:t=>{var e;const i=[];for(const n of t)if(n.node.isMark){const t=null!==(e=Kr.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:$r.toolbar.fontColor(),width:"auto",menuType:"color",menuItems:qr,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:$r.toolbar.highlight(),width:"auto",menuType:"color",menuItems:qr,onSelect:(t,e)=>{t.command.execute("highlight",e)}},{name:"image",type:"upload",icon:n.get("image"),tooltip:$r.toolbar.image(),accept:"image/*",multiple:!0}];function Xr(t){const{editor:e,file:i,onError:n,onSuccess:s}=t,{imageRequestMethod:o,imageRequestAction:r,imageRequestTypes:a}=e.config;if(a.indexOf(i.type)<0)throw new Error(`Cannot upload file because its type '${i.type}' is not found in ['${a.join("', '")}'].`);const l=e.insertBox("image",{url:URL.createObjectURL(i),status:"uploading",name:i.name,size:i.size,type:i.type,lastModified:i.lastModified}),c=pt({onProgress:t=>{const e=l.node.find(".lake-percent"),i=Math.round(t.percent);e.text(`${i<100?i:99} %`)},onError:(t,e)=>{C(t.toString(),e),l.updateValue("status","error"),l.render(),n&&n()},onSuccess:t=>{if(!t.url)return l.updateValue("status","error"),l.render(),void(n&&n());l.updateValue({status:"done",url:t.url}),l.render(),e.history.save(),s&&s()},file:i,action:r,method:o});return l.setData("xhr",c),l}const Jr=["undo","redo","|","heading","|","formatPainter","removeFormat","bold","moreStyle","|","fontColor","highlight","|","align","list","indent","link","blockQuote","hr"],Qr=new Map;Gr.forEach((t=>{Qr.set(t.name,t)}));function Yr(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(o),"color"===e.menuType&&(o.attr("title",i.text),o.find(".lake-dropdown-menu-text").css("background-color",i.value)),i.icon){const t=I('<div class="lake-dropdown-menu-icon"></div>');t.append(i.icon),o.prepend(t)}const a=n.get("check");if(a){const t=I('<div class="lake-dropdown-menu-check"></div>');t.append(a),o.prepend(t)}}}showMenu(){const t=this.config,e=this.node,i=e.find(".lake-dropdown-menu");if(e.attr("disabled"))return;const n=_e.getValue(e);i.find(".lake-dropdown-menu-check").css("visibility","hidden"),i.find("li").each((t=>{const e=I(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");e.get(0).getBoundingClientRect().x+i.width()+50>window.innerWidth?(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=I(s.target).closest("li"),a=o.attr("value");_e.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),n.attr("title",e.tooltip);const s=n.find(".lake-dropdown-text"),o=n.find(".lake-dropdown-icon");e.icon&&o.append(e.icon),e.accentIcon&&o.append(e.accentIcon);const r=n.find(".lake-dropdown-down-icon");e.downIcon&&r.append(e.downIcon);const a=I('<ul class="lake-dropdown-menu" />');if(a.addClass(`lake-${e.menuType}-dropdown-menu`),_e.setValue(i,[e.defaultValue]),s.length>0){const i=_e.getMenuMap(e.menuItems);s.text(null!==(t=i.get(e.defaultValue))&&void 0!==t?t:e.defaultValue)}"color"===e.menuType&&this.updateColorAccent(n,e.defaultValue),this.apppendMenuItems(a),i.append(n),i.append(a),this.root.append(i),this.bindEvents()}unmount(){this.node.remove(),document.removeEventListener("click",this.documentClickListener)}}var Se=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},Ae="object"==typeof Rt&&Rt&&Rt.Object===Object&&Rt,Ce=Ae,Be="object"==typeof self&&self&&self.Object===Object&&self,Ee=Ce||Be||Function("return this")(),Te=Ee,Ie=function(){return Te.Date.now()},Le=/\s/;var Me=function(t){for(var e=t.length;e--&&Le.test(t.charAt(e)););return e},Pe=Me,Oe=/^\s+/;var ze=function(t){return t?t.slice(0,Pe(t)+1).replace(Oe,""):t},Ze=Ee.Symbol,Ne=Ze,He=Object.prototype,De=He.hasOwnProperty,$e=He.toString,Ve=Ne?Ne.toStringTag:void 0;var Fe=function(t){var e=De.call(t,Ve),i=t[Ve];try{t[Ve]=void 0;var n=!0}catch(t){}var s=$e.call(t);return n&&(e?t[Ve]=i:delete t[Ve]),s},je=Object.prototype.toString;var Re=Fe,We=function(t){return je.call(t)},Ue=Ze?Ze.toStringTag:void 0;var qe=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Ue&&Ue in Object(t)?Re(t):We(t)};var Ke=function(t){return null!=t&&"object"==typeof t},Ge=qe,Xe=Ke;var Je=ze,Qe=Se,Ye=function(t){return"symbol"==typeof t||Xe(t)&&"[object Symbol]"==Ge(t)},ti=/^[-+]0x[0-9a-f]+$/i,ei=/^0b[01]+$/i,ii=/^0o[0-7]+$/i,ni=parseInt;var si=Se,oi=Ie,ri=function(t){if("number"==typeof t)return t;if(Ye(t))return NaN;if(Qe(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Qe(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Je(t);var i=ei.test(t);return i||ii.test(t)?ni(t.slice(2),i?2:8):ti.test(t)?NaN:+t},ai=Math.max,li=Math.min;var ci=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=oi();if(m(t))return g(t);a=setTimeout(f,function(t){var i=e-(t-l);return d?li(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=oi(),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=ri(e)||0,si(i)&&(h=!!i.leading,o=(d="maxWait"in i)?ai(ri(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(oi())},v},hi=Wt(ci);var di=function(){this.__data__=[],this.size=0};var pi=function(t,e){return t===e||t!=t&&e!=e},ui=pi;var mi=function(t,e){for(var i=t.length;i--;)if(ui(t[i][0],e))return i;return-1},fi=mi,gi=Array.prototype.splice;var vi=function(t){var e=this.__data__,i=fi(e,t);return!(i<0)&&(i==e.length-1?e.pop():gi.call(e,i,1),--this.size,!0)},wi=mi;var yi=function(t){var e=this.__data__,i=wi(e,t);return i<0?void 0:e[i][1]},xi=mi;var bi=mi;var ki=function(t,e){var i=this.__data__,n=bi(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this},_i=di,Si=vi,Ai=yi,Ci=function(t){return xi(this.__data__,t)>-1},Bi=ki;function Ei(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])}}Ei.prototype.clear=_i,Ei.prototype.delete=Si,Ei.prototype.get=Ai,Ei.prototype.has=Ci,Ei.prototype.set=Bi;var Ti=Ei,Ii=Ti;var Li=function(){this.__data__=new Ii,this.size=0};var Mi=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i};var Pi=function(t){return this.__data__.get(t)};var Oi=function(t){return this.__data__.has(t)},zi=qe,Zi=Se;var Ni,Hi=function(t){if(!Zi(t))return!1;var e=zi(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},Di=Ee["__core-js_shared__"],$i=(Ni=/[^.]+$/.exec(Di&&Di.keys&&Di.keys.IE_PROTO||""))?"Symbol(src)_1."+Ni:"";var Vi=function(t){return!!$i&&$i in t},Fi=Function.prototype.toString;var ji=function(t){if(null!=t){try{return Fi.call(t)}catch(t){}try{return t+""}catch(t){}}return""},Ri=Hi,Wi=Vi,Ui=Se,qi=ji,Ki=/^\[object .+?Constructor\]$/,Gi=Function.prototype,Xi=Object.prototype,Ji=Gi.toString,Qi=Xi.hasOwnProperty,Yi=RegExp("^"+Ji.call(Qi).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var tn=function(t){return!(!Ui(t)||Wi(t))&&(Ri(t)?Yi:Ki).test(qi(t))},en=function(t,e){return null==t?void 0:t[e]};var nn=function(t,e){var i=en(t,e);return tn(i)?i:void 0},sn=nn(Ee,"Map"),on=nn(Object,"create"),rn=on;var an=function(){this.__data__=rn?rn(null):{},this.size=0};var ln=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},cn=on,hn=Object.prototype.hasOwnProperty;var dn=function(t){var e=this.__data__;if(cn){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return hn.call(e,t)?e[t]:void 0},pn=on,un=Object.prototype.hasOwnProperty;var mn=on;var fn=an,gn=ln,vn=dn,wn=function(t){var e=this.__data__;return pn?void 0!==e[t]:un.call(e,t)},yn=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=mn&&void 0===e?"__lodash_hash_undefined__":e,this};function xn(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])}}xn.prototype.clear=fn,xn.prototype.delete=gn,xn.prototype.get=vn,xn.prototype.has=wn,xn.prototype.set=yn;var bn=xn,kn=Ti,_n=sn;var Sn=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var An=function(t,e){var i=t.__data__;return Sn(e)?i["string"==typeof e?"string":"hash"]:i.map},Cn=An;var Bn=An;var En=An;var Tn=An;var In=function(){this.size=0,this.__data__={hash:new bn,map:new(_n||kn),string:new bn}},Ln=function(t){var e=Cn(this,t).delete(t);return this.size-=e?1:0,e},Mn=function(t){return Bn(this,t).get(t)},Pn=function(t){return En(this,t).has(t)},On=function(t,e){var i=Tn(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this};function zn(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])}}zn.prototype.clear=In,zn.prototype.delete=Ln,zn.prototype.get=Mn,zn.prototype.has=Pn,zn.prototype.set=On;var Zn=zn,Nn=Ti,Hn=sn,Dn=Zn;var $n=Ti,Vn=Li,Fn=Mi,jn=Pi,Rn=Oi,Wn=function(t,e){var i=this.__data__;if(i instanceof Nn){var n=i.__data__;if(!Hn||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new Dn(n)}return i.set(t,e),this.size=i.size,this};function Un(t){var e=this.__data__=new $n(t);this.size=e.size}Un.prototype.clear=Vn,Un.prototype.delete=Fn,Un.prototype.get=jn,Un.prototype.has=Rn,Un.prototype.set=Wn;var qn=Un;var Kn=Zn,Gn=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Xn=function(t){return this.__data__.has(t)};function Jn(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new Kn;++e<i;)this.add(t[e])}Jn.prototype.add=Jn.prototype.push=Gn,Jn.prototype.has=Xn;var Qn=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 Yn=Jn,ts=Qn,es=function(t,e){return t.has(e)};var is=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 Yn: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(!ts(e,(function(t,e){if(!es(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 ns=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t,n){i[++e]=[n,t]})),i};var ss=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i},os=Ee.Uint8Array,rs=pi,as=is,ls=ns,cs=ss,hs=Ze?Ze.prototype:void 0,ds=hs?hs.valueOf:void 0;var ps=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 os(t),new os(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return rs(+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=ls;case"[object Set]":var l=1&n;if(a||(a=cs),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=as(a(t),a(e),n,s,o,r);return r.delete(t),h;case"[object Symbol]":if(ds)return ds.call(t)==ds.call(e)}return!1};var us=function(t,e){for(var i=-1,n=e.length,s=t.length;++i<n;)t[s+i]=e[i];return t},ms=Array.isArray,fs=us,gs=ms;var vs=function(t,e,i){var n=e(t);return gs(t)?n:fs(n,i(t))};var ws=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 ys=ws,xs=function(){return[]},bs=Object.prototype.propertyIsEnumerable,ks=Object.getOwnPropertySymbols,_s=ks?function(t){return null==t?[]:(t=Object(t),ys(ks(t),(function(e){return bs.call(t,e)})))}:xs;var Ss=function(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n},As=qe,Cs=Ke;var Bs=function(t){return Cs(t)&&"[object Arguments]"==As(t)},Es=Ke,Ts=Object.prototype,Is=Ts.hasOwnProperty,Ls=Ts.propertyIsEnumerable,Ms=Bs(function(){return arguments}())?Bs:function(t){return Es(t)&&Is.call(t,"callee")&&!Ls.call(t,"callee")},Ps=Ms,Os={exports:{}};var zs=function(){return!1};!function(t,e){var i=Ee,n=zs,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}(Os,Os.exports);var Zs=Os.exports,Ns=/^(?:0|[1-9]\d*)$/;var Hs=function(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&Ns.test(t))&&t>-1&&t%1==0&&t<e};var Ds=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},$s=qe,Vs=Ds,Fs=Ke,js={};js["[object Float32Array]"]=js["[object Float64Array]"]=js["[object Int8Array]"]=js["[object Int16Array]"]=js["[object Int32Array]"]=js["[object Uint8Array]"]=js["[object Uint8ClampedArray]"]=js["[object Uint16Array]"]=js["[object Uint32Array]"]=!0,js["[object Arguments]"]=js["[object Array]"]=js["[object ArrayBuffer]"]=js["[object Boolean]"]=js["[object DataView]"]=js["[object Date]"]=js["[object Error]"]=js["[object Function]"]=js["[object Map]"]=js["[object Number]"]=js["[object Object]"]=js["[object RegExp]"]=js["[object Set]"]=js["[object String]"]=js["[object WeakMap]"]=!1;var Rs=function(t){return Fs(t)&&Vs(t.length)&&!!js[$s(t)]};var Ws=function(t){return function(e){return t(e)}},Us={exports:{}};!function(t,e){var i=Ae,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}(Us,Us.exports);var qs=Us.exports,Ks=Rs,Gs=Ws,Xs=qs&&qs.isTypedArray,Js=Xs?Gs(Xs):Ks,Qs=Ss,Ys=Ps,to=ms,eo=Zs,io=Hs,no=Js,so=Object.prototype.hasOwnProperty;var oo=function(t,e){var i=to(t),n=!i&&Ys(t),s=!i&&!n&&eo(t),o=!i&&!n&&!s&&no(t),r=i||n||s||o,a=r?Qs(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)||io(c,l))||a.push(c);return a},ro=Object.prototype;var ao=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ro)};var lo=function(t,e){return function(i){return t(e(i))}}(Object.keys,Object),co=ao,ho=lo,po=Object.prototype.hasOwnProperty;var uo=Hi,mo=Ds;var fo=oo,go=function(t){if(!co(t))return ho(t);var e=[];for(var i in Object(t))po.call(t,i)&&"constructor"!=i&&e.push(i);return e},vo=function(t){return null!=t&&mo(t.length)&&!uo(t)};var wo=vs,yo=_s,xo=function(t){return vo(t)?fo(t):go(t)};var bo=function(t){return wo(t,xo,yo)},ko=Object.prototype.hasOwnProperty;var _o=function(t,e,i,n,s,o){var r=1&i,a=bo(t),l=a.length;if(l!=bo(e).length&&!r)return!1;for(var c=l;c--;){var h=a[c];if(!(r?h in e:ko.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 w=t.constructor,y=e.constructor;w==y||!("constructor"in t)||!("constructor"in e)||"function"==typeof w&&w instanceof w&&"function"==typeof y&&y instanceof y||(u=!1)}return o.delete(t),o.delete(e),u},So=nn(Ee,"DataView"),Ao=sn,Co=nn(Ee,"Promise"),Bo=nn(Ee,"Set"),Eo=nn(Ee,"WeakMap"),To=qe,Io=ji,Lo="[object Map]",Mo="[object Promise]",Po="[object Set]",Oo="[object WeakMap]",zo="[object DataView]",Zo=Io(So),No=Io(Ao),Ho=Io(Co),Do=Io(Bo),$o=Io(Eo),Vo=To;(So&&Vo(new So(new ArrayBuffer(1)))!=zo||Ao&&Vo(new Ao)!=Lo||Co&&Vo(Co.resolve())!=Mo||Bo&&Vo(new Bo)!=Po||Eo&&Vo(new Eo)!=Oo)&&(Vo=function(t){var e=To(t),i="[object Object]"==e?t.constructor:void 0,n=i?Io(i):"";if(n)switch(n){case Zo:return zo;case No:return Lo;case Ho:return Mo;case Do:return Po;case $o:return Oo}return e});var Fo=qn,jo=is,Ro=ps,Wo=_o,Uo=Vo,qo=ms,Ko=Zs,Go=Js,Xo="[object Arguments]",Jo="[object Array]",Qo="[object Object]",Yo=Object.prototype.hasOwnProperty;var tr=function(t,e,i,n,s,o){var r=qo(t),a=qo(e),l=r?Jo:Uo(t),c=a?Jo:Uo(e),h=(l=l==Xo?Qo:l)==Qo,d=(c=c==Xo?Qo:c)==Qo,p=l==c;if(p&&Ko(t)){if(!Ko(e))return!1;r=!0,h=!1}if(p&&!h)return o||(o=new Fo),r||Go(t)?jo(t,e,i,n,s,o):Ro(t,e,l,i,n,s,o);if(!(1&i)){var u=h&&Yo.call(t,"__wrapped__"),m=d&&Yo.call(e,"__wrapped__");if(u||m){var f=u?t.value():t,g=m?e.value():e;return o||(o=new Fo),s(f,g,i,n,o)}}return!!p&&(o||(o=new Fo),Wo(t,e,i,n,s,o))},er=Ke;var ir=function t(e,i,n,s,o){return e===i||(null==e||null==i||!er(e)&&!er(i)?e!=e&&i!=i:tr(e,i,n,s,t,o))},nr=ir;var sr=Wt((function(t,e){return nr(t,e)}));function or(t){const e=t.get(0),i={};if(e.hasAttributes())for(const t of e.attributes)i[t.name]=t.value;return i}class rr{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 L(t)}return new L}addRangeToNativeSelection(){this.selection.removeAllRanges(),this.selection.addRange(this.range.get())}syncByRange(){const t=this.getRangeFromNativeSelection();this.range.get()!==t.get()&&(this.range=t)}synByBookmark(){const t=this.range,e=this.container,i=e.find("lake-box[focus]");if(i.length>0)return ae(t,{anchor:new T,focus:i}),void this.addRangeToNativeSelection();ae(t,{anchor:e.find('lake-bookmark[type="anchor"]'),focus:e.find('lake-bookmark[type="focus"]')}),this.addRangeToNativeSelection()}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:or(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:or(e),styles:p(e.attr("style"))}),e=e.first()}}(t,this.range),t}insertBookmark(){return oe(this.range)}toBookmark(t){return ae(this.range,t)}insertNode(t){return se(this.range,t)}insertFragment(t){return he(this.range,t)}insertContents(t){return de(this.range,t)}deleteContents(){return ce(this.range)}setBlocks(t){return pe(this.range,t)}splitBlock(){return ue(this.range)}splitMarks(t){return ge(this.range,t)}addMark(t){return we(this.range,t)}removeMark(t){return xe(this.range,t)}fixList(){return le(this.range)}insertLink(t){return be(this.range,t)}}class ar{constructor(t){this.commandMap=new Map,this.event=new qt,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),C(`Command '${t}' executed`)}}var lr,cr={exports:{}};lr=cr,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))}lr.exports?lr.exports=m:t.md5=m}(Rt);var hr=Wt(cr.exports);const dr=new Map;class pr{constructor(t){this.list=[],this.index=0,this.canSave=!0,this.limit=100,this.event=new qt,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 ie(t).getHTML()}addIdToBoxes(t){t.find("lake-box").each((t=>{const e=new T(t),i=hr(`${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=dr.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=>{new 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),oe(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.synByBookmark(),C(`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.synByBookmark(),C(`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)),C(`History saved, the last index is ${this.index}`))}}var ur=["Shift","Meta","Alt","Control"],mr="object"==typeof navigator?navigator.platform:"",fr=/Mac|iPod|iPhone|iPad/.test(mr),gr=fr?"Meta":"Control",vr="Win32"===mr?["Control","Alt"]:fr?["Alt"]:[];function wr(t,e){return"function"==typeof t.getModifierState&&(t.getModifierState(e)||vr.includes(e)&&t.getModifierState("AltGraph"))}function yr(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?gr:t})),i]}))}function xr(t,e){var i;void 0===e&&(e={});var n=null!=(i=e.timeout)?i:1e3,s=Object.keys(t).map((function(e){return[yr(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!wr(t,e)}))||ur.find((function(i){return!e[0].includes(i)&&e[1]!==i&&wr(t,i)})))}(t,s[0])?wr(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 br=new Map([["#","shift+#"]]);class kr{constructor(t){this.keydownEventList=[],this.keyupEventList=[],this.container=t}normalizeType(t){var e;return t=(t=null!==(e=br.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=xr({[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=xr({[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 _r={value:"<p><br /><focus /></p>",readonly:!1,spellcheck:!1,tabIndex:0,indentWithTab:!0,minChangeSize:5};class Sr{constructor(t){if(this.unsavedInputData="",this.stateData={appliedItems:[],disabledNameMap:new Map,selectedNameMap:new Map,selectedValuesMap:new Map},this.isComposing=!1,this.event=new qt,this.box=Sr.box,this.beforeunloadListener=()=>{this.history.save()},this.selectionchangeListener=()=>{this.selection.syncByRange(),this.updateBoxSelectionStyle(),this.emitStateChangeEvent()},this.clickListener=t=>{const e=new T(t.target);e.closest(".lake-popup").length>0||this.event.emit("click",e)},this.resizeListener=()=>{this.event.emit("resize")},this.updateBoxSelectionStyle=hi((()=>{if(0===this.root.first().length)return;const t=this.selection.range,e=t.clone();e.adaptBox(),this.box.findAll(this).each((i=>{const n=new 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"),void s.addClass("lake-box-activated");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")):(s.removeClass("lake-box-focused"),s.addClass("lake-box-selected")));s.removeClass("lake-box-activated"),s.removeClass("lake-box-focused"),s.removeClass("lake-box-selected")}})),this.event.emit("boxselectionstylechange")}),50,{leading:!1,trailing:!0,maxWait:50}),this.emitStateChangeEvent=hi((()=>{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};sr(o,this.stateData)||(this.toolbar&&this.toolbar.updateState(o),this.event.emit("statechange",o),this.stateData=o)}),100,{leading:!1,trailing:!0,maxWait:100}),this.emitChangeEvent=t=>{this.rectifyContent(),this.emitStateChangeEvent(),this.event.emit("change",t)},!t.root)throw new Error("The root of the config must be specified.");this.root=I(t.root),this.toolbar=t.toolbar,this.config=Object.assign({},_r);for(const e of Object.keys(t))this.config[e]=t[e];this.containerWrapper=I('<div class="lake-container-wrapper" />'),this.container=I('<div class="lake-container" />'),this.overlayContainer=I('<div class="lake-overlay" />'),this.popupContainer=I('<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.selection=new rr(this.container),this.command=new ar(this.selection),this.history=new pr(this.selection),this.keystroke=new kr(this.container),Gt.set(this.container.id,this)}inputInBoxStrip(){const t=this.selection,e=t.range,i=e.startNode.closest(".lake-box-strip"),n=i.closest("lake-box");if("inline"===new Yt(n).type)e.isBoxStart?(e.setStartBefore(n),e.collapseToStart()):(e.setStartAfter(n),e.collapseToStart());else{const t=I("<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),this.emitChangeEvent(t)})),this.history.event.on("redo",(t=>{this.box.renderAll(this),this.emitChangeEvent(t)})),this.history.event.on("save",(t=>{this.box.rectifyInstances(this),this.emitChangeEvent(t)}))}bindFocusEvents(){this.container.on("focus",(()=>{this.root.addClass("lake-root-focused")})),this.container.on("blur",(()=>{this.root.removeClass("lake-root-focused")}))}rectifyContent(){let t=this.container.children();for(const e of t)(e.isBlock||e.isMark)&&""===e.html()&&(e.remove(),C("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 C("Rectifying content: default paragraph was added");if(1===t.length){const e=t[0];if(e.isVoid){const t=I("<p />");e.before(t),t.append(e),this.selection.range.shrinkAfter(t),C("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()}setValue(t){t=u(t);const e=new ie(t).getFragment();this.container.empty(),this.container.append(e),Sr.box.renderAll(this),this.selection.synByBookmark()}getValue(){const t=this.selection.insertBookmark();let e=new ie(this.container).getHTML();return e=m(e),this.selection.toBookmark(t),e}insertBox(t,e){const i=function(t,e,i){if(t.commonAncestor.isOutside)return null;const n=new Yt(e);i&&(n.value=i);const s=document.createDocumentFragment();if(s.appendChild(n.node.get(0)),"inline"===n.type)return he(t,s),n.render(),t.selectBoxEnd(n.node),n;const o=ue(t);return o.start&&(t.setEndAfter(o.start),t.collapseToEnd()),o.end&&o.end.isEmpty&&o.end.remove(),he(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).set(i.node.id,i),i}removeBox(){const t=function(t){if(t.commonAncestor.isOutside)return null;const e=t.commonAncestor.closest("lake-box");if(0===e.length)return null;const i=new Yt(e);if("block"===i.type){const n=I("<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,I("<br />")),t.shrinkAfter(n)),i}(this.selection.range);if(t){this.box.getInstances(this).delete(t.node.id)}return t}render(){const t=u(this.config.value),e=new ie(t).getFragment();this.root.empty(),this.root.append(this.containerWrapper),this.containerWrapper.append(this.container),this.containerWrapper.append(this.overlayContainer),I(document.body).append(this.popupContainer),this.container.append(e),this.readonly||(this.bindFocusEvents(),this.selection.synByBookmark(),this.history.save(),Sr.plugin.loadAll(this)),Sr.box.renderAll(this),this.toolbar&&this.toolbar.render(this),this.readonly||(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.root.empty(),this.popupContainer.remove(),this.readonly||(window.removeEventListener("beforeunload",this.beforeunloadListener),document.removeEventListener("selectionchange",this.selectionchangeListener),document.removeEventListener("click",this.clickListener),window.removeEventListener("resize",this.resizeListener))}}Sr.version="0.1.1",Sr.box=new class{add(t){Kt.set(t.name,t)}remove(t){Kt.delete(t)}getNames(){return Array.from(Kt.keys())}getInstances(t){let e=dr.get(t.container.id);return e||(e=new Map,dr.set(t.container.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))}findAll(t){return t.container.find("lake-box")}renderAll(t){this.rectifyInstances(t);const e=this.getInstances(t);this.findAll(t).each((t=>{const i=new T(t);if(e.get(i.id))return;const n=new Yt(i);n.render(),e.set(n.node.id,n)}))}},Sr.plugin=new class{constructor(){this.pluginList=[]}add(t){this.pluginList.push(t)}loadAll(t){this.pluginList.forEach((e=>{e(t)}))}};const Ar=/^\{.*\}$/,Cr=/(\{(?:[^{}]+|\{(?:[^{}]+)*\})*\})/g,Br=t=>t.substring(1,t.length-1),Er=(t,e=!0,i="",n="")=>t.split(Cr).map((t=>{if(!t.match(Cr))return t;const e=Br(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}})(Br(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})),Tr=(t,e,i)=>e.reduce(((e,i)=>{var n,s,o;return null!==(s=i.match(Ar)?(t=>{var i;return null!==(i=t[e])&&void 0!==i?i:t["*"]})((o=i,Object.fromEntries(Br(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),Ir=/\?\?/g,Lr=(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(Ir,r);const a=o.length?Tr(i,o,r):r;return(""+(null!=a?a:"")).trim()})).join(""))(t,e,i,1===n.length&&o?s:n)},Mr=(t,e)=>{const i={},n=new Intl.PluralRules(t);return(t,...s)=>Lr(((t,e)=>t[e]||(t[e]=Er(e)))(i,t),n,e,s)};const Pr=(t={},e)=>"string"==typeof t?e.bind(null,t):Object.assign(Object.defineProperty((()=>""),"name",{writable:!0}),t),Or=(t,e)=>new Proxy(Pr(t,e),{get:(t,i)=>i===Symbol.iterator?[][Symbol.iterator].bind(Object.values(t).map((t=>Pr(t,e)))):Or(t[i],e)});const zr={"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",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"},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:"图片",removeColor:"默认"},link:{newLink:"新链接",url:"链接 URL",title:"链接文本",copy:"复制到剪贴板",open:"打开链接",save:"确定",unlink:"取消链接"},image:{view:"查看大图",remove:"删除",previous:"上一张",next:"下一张",close:"关闭 (Esc)",loadingError:"图片加载失败",zoomOut:"缩小",zoomIn:"放大"},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:"画像",removeColor:"デフォルト"},link:{newLink:"新しいリンク",url:"リンク URL",title:"リンク文字",copy:"クリップボードにコピー",open:"リンクを開く",save:"確認",unlink:"リンクを削除"},image:{view:"大きな画像を見る",remove:"削除",previous:"前の画像",next:"次の画像",close:"閉じる (Esc)",loadingError:"画像を読み込めません",zoomOut:"縮小",zoomIn:"拡大"},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:"이미지",removeColor:"기본색"},link:{newLink:"새 링크",url:"링크 URL",title:"링크 텍스트",copy:"클립보드에 복사",open:"링크 열기",save:"확인",unlink:"링크 제거"},image:{view:"큰 이미지 보기",remove:"삭제",previous:"이전 이미지",next:"다음 이미지",close:"닫기 (Esc)",loadingError:"이미지를 로드할 수 없습니다",zoomOut:"축소",zoomIn:"확대"},codeBlock:{langType:"코드언어 선택"}}},Zr=Object.keys(zr),Nr={},Hr={},Dr=t=>{Nr[t]||(Nr[t]=zr[t],(t=>{Hr[t]={}})(t))};Zr.forEach(Dr);const $r=(t=>function(t,e,i={}){return Or(e,Mr(t,i))}(t,Nr[t],Hr[t]))(Zr.indexOf(window.LAKE_LANGUAGE)>=0?window.LAKE_LANGUAGE:"en-US"),Vr=[{value:"h1",text:`<span style="font-weight: bold; font-size: 26px;">${$r.toolbar.heading1()}</span>`},{value:"h2",text:`<span style="font-weight: bold; font-size: 24px;">${$r.toolbar.heading2()}</span>`},{value:"h3",text:`<span style="font-weight: bold; font-size: 22px;">${$r.toolbar.heading3()}</span>`},{value:"h4",text:`<span style="font-weight: bold; font-size: 20px;">${$r.toolbar.heading4()}</span>`},{value:"h5",text:`<span style="font-weight: bold; font-size: 18px;">${$r.toolbar.heading5()}</span>`},{value:"h6",text:`<span style="font-weight: bold; font-size: 16px;">${$r.toolbar.heading6()}</span>`},{value:"p",text:$r.toolbar.paragraph()}],Fr=[{icon:n.get("numberedList"),value:"numbered",text:$r.toolbar.numberedList()},{icon:n.get("bulletedList"),value:"bulleted",text:$r.toolbar.bulletedList()},{icon:n.get("checklist"),value:"checklist",text:$r.toolbar.checklist()}],jr=[{icon:n.get("alignLeft"),value:"left",text:$r.toolbar.alignLeft()},{icon:n.get("alignCenter"),value:"center",text:$r.toolbar.alignCenter()},{icon:n.get("alignRight"),value:"right",text:$r.toolbar.alignRight()},{icon:n.get("alignJustify"),value:"justify",text:$r.toolbar.alignJustify()}],Rr=[{icon:n.get("increaseIndent"),value:"increase",text:$r.toolbar.increaseIndent()},{icon:n.get("decreaseIndent"),value:"decrease",text:$r.toolbar.decreaseIndent()}],Wr=[{icon:n.get("italic"),value:"italic",text:$r.toolbar.italic()},{icon:n.get("underline"),value:"underline",text:$r.toolbar.underline()},{icon:n.get("strikethrough"),value:"strikethrough",text:$r.toolbar.strikethrough()},{icon:n.get("superscript"),value:"superscript",text:$r.toolbar.superscript()},{icon:n.get("subscript"),value:"subscript",text:$r.toolbar.subscript()},{icon:n.get("code"),value:"code",text:$r.toolbar.code()}],Ur=["#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"],qr=[{icon:n.get("removeFormat"),value:"",text:$r.toolbar.removeColor()}];for(const t of Ur)qr.push({value:t.toLowerCase(),text:t.toUpperCase()});const Kr=new Map([["strong","bold"],["em","italic"],["i","italic"],["u","underline"],["s","strikethrough"],["sup","superscript"],["sub","subscript"],["code","code"]]),Gr=[{name:"undo",type:"button",icon:n.get("undo"),tooltip:$r.toolbar.undo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"redo",type:"button",icon:n.get("redo"),tooltip:$r.toolbar.redo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"selectAll",type:"button",icon:n.get("selectAll"),tooltip:$r.toolbar.selectAll(),onClick:(t,e)=>{t.command.execute(e)}},{name:"paragraph",type:"button",icon:n.get("paragraph"),tooltip:$r.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:$r.toolbar.blockQuote(),onClick:(t,e)=>{t.command.execute(e)}},{name:"numberedList",type:"button",icon:n.get("numberedList"),tooltip:$r.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:$r.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:$r.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:$r.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:$r.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:$r.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:$r.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:$r.toolbar.increaseIndent(),onClick:t=>{t.command.execute("indent","increase")}},{name:"decreaseIndent",type:"button",icon:n.get("decreaseIndent"),tooltip:$r.toolbar.decreaseIndent(),onClick:t=>{t.command.execute("indent","decrease")}},{name:"bold",type:"button",icon:n.get("bold"),tooltip:$r.toolbar.bold(),onClick:(t,e)=>{t.command.execute(e)}},{name:"italic",type:"button",icon:n.get("italic"),tooltip:$r.toolbar.italic(),onClick:(t,e)=>{t.command.execute(e)}},{name:"underline",type:"button",icon:n.get("underline"),tooltip:$r.toolbar.underline(),onClick:(t,e)=>{t.command.execute(e)}},{name:"strikethrough",type:"button",icon:n.get("strikethrough"),tooltip:$r.toolbar.strikethrough(),onClick:(t,e)=>{t.command.execute(e)}},{name:"superscript",type:"button",icon:n.get("superscript"),tooltip:$r.toolbar.superscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"subscript",type:"button",icon:n.get("subscript"),tooltip:$r.toolbar.subscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"code",type:"button",icon:n.get("code"),tooltip:$r.toolbar.code(),onClick:(t,e)=>{t.command.execute(e)}},{name:"removeFormat",type:"button",icon:n.get("removeFormat"),tooltip:$r.toolbar.removeFormat(),onClick:(t,e)=>{t.command.execute(e)}},{name:"formatPainter",type:"button",icon:n.get("formatPainter"),tooltip:$r.toolbar.formatPainter(),onClick:(t,e)=>{t.command.execute(e)}},{name:"link",type:"button",icon:n.get("link"),tooltip:$r.toolbar.link(),onClick:(t,e)=>{t.command.execute(e)}},{name:"hr",type:"button",icon:n.get("hr"),tooltip:$r.toolbar.hr(),onClick:(t,e)=>{t.command.execute(e)}},{name:"codeBlock",type:"button",icon:n.get("codeBlock"),tooltip:$r.toolbar.codeBlock(),onClick:(t,e)=>{t.command.execute(e)}},{name:"heading",type:"dropdown",downIcon:n.get("down"),defaultValue:"p",tooltip:$r.toolbar.heading(),width:"100px",menuType:"list",menuItems:Vr,onSelect:(t,e)=>{t.command.execute("heading",e)}},{name:"list",type:"dropdown",downIcon:n.get("down"),icon:n.get("list"),defaultValue:"",tooltip:$r.toolbar.list(),width:"auto",menuType:"list",menuItems:Fr,onSelect:(t,e)=>{t.command.execute("list",e)}},{name:"align",type:"dropdown",downIcon:n.get("down"),icon:n.get("alignLeft"),defaultValue:"",tooltip:$r.toolbar.align(),width:"auto",menuType:"list",menuItems:jr,onSelect:(t,e)=>{t.command.execute("align",e)}},{name:"indent",type:"dropdown",downIcon:n.get("down"),icon:n.get("increaseIndent"),defaultValue:"",tooltip:$r.toolbar.indent(),width:"auto",menuType:"list",menuItems:Rr,onSelect:(t,e)=>{t.command.execute("indent",e)}},{name:"fontFamily",type:"dropdown",downIcon:n.get("down"),defaultValue:"Segoe UI",tooltip:$r.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:$r.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:$r.toolbar.moreStyle(),width:"auto",menuType:"list",menuItems:Wr,selectedValues:t=>{var e;const i=[];for(const n of t)if(n.node.isMark){const t=null!==(e=Kr.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:$r.toolbar.fontColor(),width:"auto",menuType:"color",menuItems:qr,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:$r.toolbar.highlight(),width:"auto",menuType:"color",menuItems:qr,onSelect:(t,e)=>{t.command.execute("highlight",e)}},{name:"image",type:"upload",icon:n.get("image"),tooltip:$r.toolbar.image(),accept:"image/*",multiple:!0}];function Xr(t){const{editor:e,file:i,onError:n,onSuccess:s}=t,{requestMethod:o,requestAction:r,requestTypes:a}=e.config.image;if(a.indexOf(i.type)<0)throw new Error(`Cannot upload file because its type '${i.type}' is not found in ['${a.join("', '")}'].`);const l=e.insertBox("image",{url:URL.createObjectURL(i),status:"uploading",name:i.name,size:i.size,type:i.type,lastModified:i.lastModified}),c=pt({onProgress:t=>{const e=l.node.find(".lake-percent"),i=Math.round(t.percent);e.text(`${i<100?i:99} %`)},onError:(t,e)=>{C(t.toString(),e),l.updateValue("status","error"),l.render(),n&&n()},onSuccess:t=>{if(!t.url)return l.updateValue("status","error"),l.render(),void(n&&n());l.updateValue({status:"done",url:t.url}),l.render(),e.history.save(),s&&s()},file:i,action:r,method:o});return l.setData("xhr",c),l}const Jr=["undo","redo","|","heading","|","formatPainter","removeFormat","bold","moreStyle","|","fontColor","highlight","|","align","list","indent","link","blockQuote","hr"],Qr=new Map;Gr.forEach((t=>{Qr.set(t.name,t)}));function Yr(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
|
|
@@ -66,7 +66,7 @@ function ta(t,e,i){const n=document.createElement(e);return t&&(n.className=t),i
|
|
|
66
66
|
</div>
|
|
67
67
|
<div class="lake-row lake-button-row"></div>
|
|
68
68
|
</div>
|
|
69
|
-
`)}writeClipboardText(t){return Yr(this,void 0,void 0,(function*(){let e=!1;try{window.LAKE_TEST?e=window.LAKE_ERROR:yield navigator.clipboard.writeText(t)}catch(t){e=!0}return new Promise((t=>{t(e)}))}))}appendCopyButton(){let t=null;const e=new ke({root:this.container.find(".lake-url-row"),name:"copy",icon:n.get("copy"),tooltip:$r.link.copy(),onClick:()=>{if(!this.linkNode)return;const e=this.getInputValue("url");this.writeClipboardText(e).then((e=>{const i=this.container.find('button[name="copy"] svg');if(i.hide(),e)return i.eq(2).show("inline"),void this.event.emit("copy",e);i.eq(1).show("inline"),this.event.emit("copy",e),t&&window.clearTimeout(t),t=window.setTimeout((()=>{i.hide(),i.eq(0).show("inline")}),2e3)}))}});e.render();const i=n.get("checkCircle");i&&e.node.append(i);const s=n.get("warningCircle");s&&e.node.append(s)}appendOpenButton(){new ke({root:this.container.find(".lake-url-row"),name:"open",icon:n.get("open"),tooltip:$r.link.open(),onClick:()=>{if(!this.linkNode)return;const t=this.getInputValue("url");window.open(t)}}).render()}appendSaveButton(){new ke({root:this.container.find(".lake-button-row"),name:"save",icon:n.get("check"),text:$r.link.save(),onClick:()=>{if(!this.linkNode)return;const t=this.linkNode;this.save(),this.hide(),this.event.emit("save",t)}}).render()}appendUnlinkButton(){new ke({root:this.container.find(".lake-button-row"),name:"unlink",icon:n.get("unlink"),text:$r.link.unlink(),onClick:()=>{if(!this.linkNode)return;const t=this.linkNode.last();this.linkNode.remove(!0),this.hide(),this.event.emit("remove",t)}}).render()}getInputValue(t){return this.container.find(`input[name="${t}"]`).get(0).value}setInputValue(t,e){this.container.find(`input[name="${t}"]`).get(0).value=e}save(){if(!this.linkNode)return;const t=this.getInputValue("url");let e=this.getInputValue("title");""!==t||""!==e?(""===e&&(e=t),this.linkNode.attr("href",t),this.linkNode.text(e)):this.linkNode.remove()}updatePosition(){if(!this.linkNode)return;const t=this.linkNode.get(0).getBoundingClientRect(),e=t.x+window.scrollX,i=t.y+window.scrollY;e<0||i<0?this.hide():(t.x+this.container.width()>window.innerWidth?this.container.css("left",`${e-this.container.width()+t.width}px`):this.container.css("left",`${e}px`),t.y+t.height+this.container.height()>window.innerHeight?this.container.css("top",i-this.container.height()+"px"):this.container.css("top",`${i+t.height}px`))}render(){this.appendCopyButton(),this.appendOpenButton(),this.appendSaveButton(),this.appendUnlinkButton(),this.root.append(this.container)}show(t){if(0===this.root.find(".lake-link-popup").length&&this.render(),this.linkNode&&this.linkNode.get(0)===t.get(0))return;this.linkNode=t;const e=t.attr("href"),i=t.text();this.setInputValue("url",e),i!==e&&this.setInputValue("title",i),this.container.css("visibility","hidden"),this.container.show(),this.updatePosition(),this.container.css("visibility",""),this.container.find('input[name="url"]').focus()}hide(){this.linkNode=null,this.container.hide()}}const xc=new Map([["#","h1"],["##","h2"],["###","h3"],["####","h4"],["#####","h5"],["######","h6"]]),bc=[{re:/\*\*(.+?)\*\*$/,getParameters:()=>["bold"]},{re:/__(.+?)__$/,getParameters:()=>["bold"]},{re:/_(.+?)_$/,getParameters:()=>["italic"]},{re:/\*(.+?)\*$/,getParameters:()=>["italic"]},{re:/==(.+?)==$/,getParameters:()=>["highlight","#fff566"]},{re:/~~(.+?)~~$/,getParameters:()=>["strikethrough"]},{re:/`(.+?)`$/,getParameters:()=>["code"]}],kc=[{re:/^#+$/,getParameters:t=>{var e;return["heading",null!==(e=xc.get(t[0]))&&void 0!==e?e:"h6"]}},{re:/^\d+\.$/,getParameters:()=>["list","numbered"]},{re:/^[*\-+]$/,getParameters:()=>["list","bulleted"]},{re:/^\[\s?\]$/,getParameters:()=>["list","checklist",!1]},{re:/^\[x\]$/i,getParameters:()=>["list","checklist",!0]},{re:/^>$/,getParameters:()=>["blockQuote"]}],_c=[{re:/^:{3,}([a-z]*)$/i,getParameters:t=>t[1]?["blockQuote",t[1]]:["blockQuote","info"]},{re:/^-{3,}$/,getParameters:()=>["hr"]},{re:/^`+([a-z]*)$/i,getParameters:t=>t[1]?["codeBlock",{lang:t[1]}]:["codeBlock"]}];function Sc(t){const e=t.clone(!0);e.find("lake-bookmark").remove(),""===e.html()&&t.prepend("<br />")}function Ac(t,e){const i=t.selection.range,n=i.getEndText();if(t.selection.splitBlock(),e=i.getBlocks()[0])return""!==n||!e.isHeading&&"blockquote"!==e.name?void(e.isList&&"checklist"===e.attr("type")&&e.find("li").attr("value","false")):(t.selection.setBlocks("<p />"),void t.history.save());t.history.save()}function Cc(t){const e=t.selection.range,i=e.startNode.closest("lake-box"),n=i.closestBlock();if(n.length>0&&!n.isContainer)return void(e.isBoxStart?(e.setStartBefore(i),e.collapseToStart(),Ac(t,n)):e.isBoxEnd?(e.setStartAfter(i),e.collapseToStart(),Ac(t,n)):t.removeBox());const s=I("<p><br /></p>");e.isBoxStart?i.before(s):e.isBoxEnd?(i.after(s),e.shrinkAfter(s)):t.removeBox()}function Bc(t){const e=t.selection.range,i=e.startNode.closestBlock();if(i.length>0&&!i.isContainer){const i=e.getPrevNode(),n=e.getEndText();if("br"!==i.name&&""===n)return t.selection.insertContents("<br /><br />"),void t.history.save()}t.selection.insertNode(I("<br />"))}function Ec(t){const e=t.selection.range,i=e.startNode.closest("lake-box"),n=i.closestBlock();if(n.length>0&&!n.isContainer)return void(e.isBoxStart?(e.setStartBefore(i),e.collapseToStart(),Bc(t)):e.isBoxEnd?(e.setStartAfter(i),e.collapseToStart(),Bc(t)):t.removeBox());const s=I("<p><br /></p>");e.isBoxStart?i.before(s):e.isBoxEnd?(i.after(s),e.shrinkAfter(s)):t.removeBox()}function Tc(t,e){const i=t.selection.range;let n=e.prev();if(0===n.length)return void("p"!==e.name&&t.selection.setBlocks("<p />"));if(n.isBox)return e.isEmpty&&e.remove(),void i.selectBoxEnd(n);if("br"===n.name)return void n.remove();if(!n.isBlock){const t=new L;t.selectNodeContents(n),pe(t,"<p />"),n=t.startNode.closestBlock()}if(n.isEmpty)return void n.remove();const s=t.selection.insertBookmark();Z(n,e),t.selection.toBookmark(s),t.selection.fixList()}function Ic(t,e){const i=t.selection.range;let n=e.next();if(0===n.length)return void t.history.save();if(n.isBox)return e.isEmpty&&e.remove(),i.selectBoxStart(n),void t.history.save();if(!n.isBlock){const t=new L;t.selectNodeContents(n),pe(t,"<p />"),n=n.closestBlock()}const s=t.selection.insertBookmark();Z(e,n),t.selection.toBookmark(s),t.selection.fixList()}return Sr.box.add({type:"block",name:"hr",render:t=>{const e=t.getEditor();if(e)return t.useEffect((()=>{t.getContainer().find(".lake-hr").on("click",(()=>{e.selection.range.selectBox(t.node)}))})),'<div class="lake-hr"><hr /></div>'},html:()=>"<hr />"}),Sr.box.add(Bl),Sr.box.add(sc),Sr.plugin.add((t=>{t.container.on("copy",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.startNode.closest("lake-box");if(0===n.length)return;if(i.isBoxStart||i.isBoxEnd)return;e.preventDefault();const s=e.clipboardData;if(!s)return;const o=new Yt(n).getHTML();s.setData("text/html",o)}))})),Sr.plugin.add((t=>{t.container.on("cut",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.startNode.closest("lake-box");if(0===n.length)return;if(i.isBoxStart||i.isBoxEnd)return;e.preventDefault();const s=e.clipboardData;if(!s)return;const o=new Yt(n).getHTML();s.setData("text/html",o),t.removeBox(),t.history.save()}))})),Sr.plugin.add((t=>{const{imageRequestTypes:e}=t.config;t.container.on("paste",(i=>{if(t.selection.range.isInsideBox)return;i.preventDefault();const n=i.clipboardData;if(!n)return;if(t.selection.deleteContents(),n.files.length>0){for(const i of n.files)e.indexOf(i.type)>=0&&Xr({editor:t,file:i});return}const s=n.types;if(1===s.length&&"text/plain"===s[0]){const e=n.getData("text/plain"),i=new ne(e).getFragment();return t.event.emit("beforepaste",i),void ac(t,i)}const o=u(n.getData("text/html")),r=function(){const t=ee();return t.div=t.p,g(t,((t,e)=>{delete e.id,delete e.class})),t}(),a=new ie(o,r).getFragment();t.event.emit("beforepaste",a),function(t){let e=new T(t.firstChild);for(;e.length>0;){const t=e.next();e.isBlock&&rc(e),e=t}let i=[];for(e=new T(t.firstChild);e.length>0;){const t=e.next();e.isMark||e.isText||e.isBookmark||e.isInlineBox?i.push(e):(H(i),i=[]),e=t}H(i)}(a),ac(t,a),t.box.renderAll(t)}))})),Sr.plugin.add((t=>{t.command.add("undo",{execute:()=>{t.history.undo()}}),t.keystroke.setKeydown("mod+z",(e=>{t.selection.range.isInsideBox||(e.preventDefault(),t.command.execute("undo"))}))})),Sr.plugin.add((t=>{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)})),Sr.plugin.add((t=>{t.command.add("selectAll",{execute:()=>{const e=t.selection.range;e.selectNodeContents(t.container),e.shrink()}})})),Sr.plugin.add((t=>{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()}})})),Sr.plugin.add((t=>{t.command.add("blockQuote",{isSelected:t=>!!t.find((t=>"blockquote"===t.name)),execute:e=>{e&&lc.indexOf(e)>=0?t.selection.setBlocks(a`<blockquote type="${e}" />`):t.selection.setBlocks("<blockquote />"),t.history.save()}})})),Sr.plugin.add((t=>{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&&cc(t),"bulleted"===e&&dc(t),"checklist"===e&&pc(t,i)):o?("numbered"===e&&hc(t),"bulleted"===e&&cc(t),"checklist"===e&&pc(t,i)):r?("numbered"===e&&hc(t),"bulleted"===e&&dc(t),"checklist"===e&&cc(t)):("numbered"===e&&hc(t),"bulleted"===e&&dc(t),"checklist"===e&&pc(t,i)),t.history.save()}}),t.container.on("click",(e=>{const i=e;if(!i.target)return;const n=I(i.target);"li"===n.name&&""!==n.attr("value")&&i.offsetX<=18&&(n.attr("value",("true"!==n.attr("value")).toString()),t.history.save())}))})),Sr.plugin.add((t=>{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?[uc[e]||e]:[]},execute:e=>{t.selection.setBlocks({"text-align":e}),t.history.save()}})})),Sr.plugin.add((t=>{t.command.add("indent",{execute:e=>{const i=t.selection.range.getBlocks();for(const t of i)F(t,e);t.history.save()}})})),Sr.plugin.add((t=>{t.command.add("bold",{isDisabled:t=>!!t.find((t=>t.node.isHeading)),isSelected:t=>!!t.find((t=>t.name===mc)),execute:()=>{t.command.isSelected("bold")?t.selection.removeMark(`<${mc} />`):t.selection.addMark(`<${mc} />`),t.history.save()}}),t.keystroke.setKeydown("mod+b",(e=>{e.preventDefault(),t.command.execute("bold")}))})),Sr.plugin.add((t=>{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")}))})),Sr.plugin.add((t=>{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")}))})),Sr.plugin.add((t=>{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")}))})),Sr.plugin.add((t=>{t.command.add("subscript",{isSelected:t=>!!t.find((t=>t.name===fc)),execute:()=>{t.command.isSelected("subscript")?t.selection.removeMark(`<${fc} />`):t.selection.addMark(`<${fc} />`),t.history.save()}})})),Sr.plugin.add((t=>{t.command.add("superscript",{isSelected:t=>!!t.find((t=>t.name===gc)),execute:()=>{t.command.isSelected("superscript")?t.selection.removeMark(`<${gc} />`):t.selection.addMark(`<${gc} />`),t.history.save()}})})),Sr.plugin.add((t=>{t.command.add("code",{isSelected:t=>!!t.find((t=>t.name===vc)),execute:()=>{t.command.isSelected("code")?t.selection.removeMark(`<${vc} />`):t.selection.addMark(`<${vc} />`),t.history.save()}})})),Sr.plugin.add((t=>{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()}})})),Sr.plugin.add((t=>{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()}})})),Sr.plugin.add((t=>{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()}})})),Sr.plugin.add((t=>{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()}})})),Sr.plugin.add((t=>{t.command.add("removeFormat",{execute:()=>{t.selection.removeMark(),t.history.save()}})})),Sr.plugin.add((t=>{let e=[];t.command.add("formatPainter",{execute:()=>{t.container.addClass(wc);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(wc),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(wc),e=[])}))})),Sr.plugin.add((t=>{const e=new yc(t.popupContainer);e.event.on("save",(e=>{const i=t.selection.range;i.setStartAfter(e),i.collapseToStart(),t.selection.addRangeToNativeSelection(),t.history.save()})),e.event.on("remove",(e=>{const i=t.selection.range;i.setStartAfter(e),i.collapseToStart(),t.selection.addRangeToNativeSelection(),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="">${$r.link.newLink()}</a>`);i&&(t.history.save(),e.show(i))}})})),Sr.plugin.add((t=>{t.event.on("beforepaste",(t=>{new mt(t).find("hr").each((t=>{const e=I(t),i=new Yt("hr");e.replaceWith(i.node)}))})),t.command.add("hr",{execute:()=>{t.insertBox("hr"),t.history.save()}})})),Sr.plugin.add((t=>{t.event.on("beforepaste",(t=>{new mt(t).find("img").each((t=>{const e=I(t),i=new 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()}})})),Sr.plugin.add((t=>{window.CodeMirror&&t.command.add("codeBlock",{execute:e=>{const i=t.insertBox("codeBlock",e);t.history.save();i.getData("codeEditor").focus()}})})),Sr.plugin.add((t=>{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 bc){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 kc){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 Sc(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 _c){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(),Sc(e),i.range.shrinkAfter(e),t.command.execute(r,...n),t.commitOperation(),!0)}}return!1}(t,n)?(e.preventDefault(),e.stopImmediatePropagation(),!1):void 0}))})),Sr.plugin.add((t=>{t.keystroke.setKeydown("enter",(e=>{const i=t.selection.range;if(i.isInsideBox)return;if(e.preventDefault(),t.rectifyContent(),i.isBox)return Cc(t),void t.history.save();if(i.adapt(),i.isInoperative)return;if(i.isBox)return Cc(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();Ac(t,n),t.history.save()}))})),Sr.plugin.add((t=>{t.keystroke.setKeydown("shift+enter",(e=>{const i=t.selection.range;if(!i.isInsideBox){if(t.rectifyContent(),e.preventDefault(),i.isBox)return Ec(t),void t.history.save();if(i.adapt(),!i.isInoperative){if(i.isBox)return Ec(t),void t.history.save();Bc(t),t.history.save()}}}))})),Sr.plugin.add((t=>{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(),Tc(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(),i.selectBox(n),t.removeBox(),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();Tc(t,n),t.history.save()}}))})),Sr.plugin.add((t=>{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(),Ic(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(),i.selectBox(n),t.removeBox(),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]),Ic(t,n),t.history.save()}}))})),Sr.plugin.add((t=>{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()}))})),Sr.plugin.add((t=>{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()}}))})),Sr.plugin.add((t=>{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.addRangeToNativeSelection()}t.root.hasClass("lake-root-focused")&&(e.preventDefault(),t.blur())}))})),t.Box=Yt,t.Button=ke,t.Dropdown=_e,t.Editor=Sr,t.Fragment=mt,t.HTMLParser=ie,t.Nodes=T,t.Range=L,t.TextParser=ne,t.Toolbar=class{constructor(t){this.allMenuMap=new Map,this.buttonItemList=[],this.dropdownItemList=[],this.items=t.items||Jr,this.root=I(t.root),this.container=I('<div class="lake-toolbar" />'),this.root.addClass("lake-custom-properties")}appendDivider(){this.container.append('<div class="lake-toolbar-divider" />')}appendButton(t,e){new ke({root:this.container,name:e.name,icon:e.icon,tooltip:e.tooltip,tabIndex:-1,onClick:()=>{t.focus(),e.onClick(t,e.name)}}).render()}appendDropdown(t,e){new _e({root:this.container,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,onSelect:i=>{t.focus(),e.onSelect(t,i)}}).render()}appendUpload(t,e){const i=I(a`
|
|
69
|
+
`)}writeClipboardText(t){return Yr(this,void 0,void 0,(function*(){let e=!1;try{window.LAKE_TEST?e=window.LAKE_ERROR:yield navigator.clipboard.writeText(t)}catch(t){e=!0}return new Promise((t=>{t(e)}))}))}appendCopyButton(){let t=null;const e=new ke({root:this.container.find(".lake-url-row"),name:"copy",icon:n.get("copy"),tooltip:$r.link.copy(),onClick:()=>{if(!this.linkNode)return;const e=this.getInputValue("url");this.writeClipboardText(e).then((e=>{const i=this.container.find('button[name="copy"] svg');if(i.hide(),e)return i.eq(2).show("inline"),void this.event.emit("copy",e);i.eq(1).show("inline"),this.event.emit("copy",e),t&&window.clearTimeout(t),t=window.setTimeout((()=>{i.hide(),i.eq(0).show("inline")}),2e3)}))}});e.render();const i=n.get("checkCircle");i&&e.node.append(i);const s=n.get("warningCircle");s&&e.node.append(s)}appendOpenButton(){new ke({root:this.container.find(".lake-url-row"),name:"open",icon:n.get("open"),tooltip:$r.link.open(),onClick:()=>{if(!this.linkNode)return;const t=this.getInputValue("url");window.open(t)}}).render()}appendSaveButton(){new ke({root:this.container.find(".lake-button-row"),name:"save",icon:n.get("check"),text:$r.link.save(),onClick:()=>{if(!this.linkNode)return;const t=this.linkNode;this.save(),this.hide(),this.event.emit("save",t)}}).render()}appendUnlinkButton(){new ke({root:this.container.find(".lake-button-row"),name:"unlink",icon:n.get("unlink"),text:$r.link.unlink(),onClick:()=>{if(!this.linkNode)return;const t=this.linkNode.last();this.linkNode.remove(!0),this.hide(),this.event.emit("remove",t)}}).render()}getInputValue(t){return this.container.find(`input[name="${t}"]`).get(0).value}setInputValue(t,e){this.container.find(`input[name="${t}"]`).get(0).value=e}save(){if(!this.linkNode)return;const t=this.getInputValue("url");let e=this.getInputValue("title");""!==t||""!==e?(""===e&&(e=t),this.linkNode.attr("href",t),this.linkNode.text(e)):this.linkNode.remove()}updatePosition(){if(!this.linkNode)return;const t=this.linkNode.get(0).getBoundingClientRect(),e=t.x+window.scrollX,i=t.y+window.scrollY;e<0||i<0?this.hide():(t.x+this.container.width()>window.innerWidth?this.container.css("left",`${e-this.container.width()+t.width}px`):this.container.css("left",`${e}px`),t.y+t.height+this.container.height()>window.innerHeight?this.container.css("top",i-this.container.height()+"px"):this.container.css("top",`${i+t.height}px`))}render(){this.appendCopyButton(),this.appendOpenButton(),this.appendSaveButton(),this.appendUnlinkButton(),this.root.append(this.container)}show(t){if(0===this.root.find(".lake-link-popup").length&&this.render(),this.linkNode&&this.linkNode.get(0)===t.get(0))return;this.linkNode=t;const e=t.attr("href"),i=t.text();this.setInputValue("url",e),i!==e&&this.setInputValue("title",i),this.container.css("visibility","hidden"),this.container.show(),this.updatePosition(),this.container.css("visibility",""),this.container.find('input[name="url"]').focus()}hide(){this.linkNode=null,this.container.hide()}}const xc=new Map([["#","h1"],["##","h2"],["###","h3"],["####","h4"],["#####","h5"],["######","h6"]]),bc=[{re:/\*\*(.+?)\*\*$/,getParameters:()=>["bold"]},{re:/__(.+?)__$/,getParameters:()=>["bold"]},{re:/_(.+?)_$/,getParameters:()=>["italic"]},{re:/\*(.+?)\*$/,getParameters:()=>["italic"]},{re:/==(.+?)==$/,getParameters:()=>["highlight","#fff566"]},{re:/~~(.+?)~~$/,getParameters:()=>["strikethrough"]},{re:/`(.+?)`$/,getParameters:()=>["code"]}],kc=[{re:/^#+$/,getParameters:t=>{var e;return["heading",null!==(e=xc.get(t[0]))&&void 0!==e?e:"h6"]}},{re:/^\d+\.$/,getParameters:()=>["list","numbered"]},{re:/^[*\-+]$/,getParameters:()=>["list","bulleted"]},{re:/^\[\s?\]$/,getParameters:()=>["list","checklist",!1]},{re:/^\[x\]$/i,getParameters:()=>["list","checklist",!0]},{re:/^>$/,getParameters:()=>["blockQuote"]}],_c=[{re:/^:{3,}([a-z]*)$/i,getParameters:t=>t[1]?["blockQuote",t[1]]:["blockQuote","info"]},{re:/^-{3,}$/,getParameters:()=>["hr"]},{re:/^`+([a-z]*)$/i,getParameters:t=>t[1]?["codeBlock",{lang:t[1]}]:["codeBlock"]}];function Sc(t){const e=t.clone(!0);e.find("lake-bookmark").remove(),""===e.html()&&t.prepend("<br />")}function Ac(t,e){const i=t.selection.range,n=i.getEndText();if(t.selection.splitBlock(),e=i.getBlocks()[0])return""!==n||!e.isHeading&&"blockquote"!==e.name?void(e.isList&&"checklist"===e.attr("type")&&e.find("li").attr("value","false")):(t.selection.setBlocks("<p />"),void t.history.save());t.history.save()}function Cc(t){const e=t.selection.range,i=e.startNode.closest("lake-box"),n=i.closestBlock();if(n.length>0&&!n.isContainer)return void(e.isBoxStart?(e.setStartBefore(i),e.collapseToStart(),Ac(t,n)):e.isBoxEnd?(e.setStartAfter(i),e.collapseToStart(),Ac(t,n)):t.removeBox());const s=I("<p><br /></p>");e.isBoxStart?i.before(s):e.isBoxEnd?(i.after(s),e.shrinkAfter(s)):t.removeBox()}function Bc(t){const e=t.selection.range,i=e.startNode.closestBlock();if(i.length>0&&!i.isContainer){const i=e.getPrevNode(),n=e.getEndText();if("br"!==i.name&&""===n)return t.selection.insertContents("<br /><br />"),void t.history.save()}t.selection.insertNode(I("<br />"))}function Ec(t){const e=t.selection.range,i=e.startNode.closest("lake-box"),n=i.closestBlock();if(n.length>0&&!n.isContainer)return void(e.isBoxStart?(e.setStartBefore(i),e.collapseToStart(),Bc(t)):e.isBoxEnd?(e.setStartAfter(i),e.collapseToStart(),Bc(t)):t.removeBox());const s=I("<p><br /></p>");e.isBoxStart?i.before(s):e.isBoxEnd?(i.after(s),e.shrinkAfter(s)):t.removeBox()}function Tc(t,e){const i=t.selection.range;let n=e.prev();if(0===n.length)return void("p"!==e.name&&t.selection.setBlocks("<p />"));if(n.isBox)return e.isEmpty&&e.remove(),void i.selectBoxEnd(n);if("br"===n.name)return void n.remove();if(!n.isBlock){const t=new L;t.selectNodeContents(n),pe(t,"<p />"),n=t.startNode.closestBlock()}if(n.isEmpty)return void n.remove();const s=t.selection.insertBookmark();Z(n,e),t.selection.toBookmark(s),t.selection.fixList()}function Ic(t,e){const i=t.selection.range;let n=e.next();if(0===n.length)return void t.history.save();if(n.isBox)return e.isEmpty&&e.remove(),i.selectBoxStart(n),void t.history.save();if(!n.isBlock){const t=new L;t.selectNodeContents(n),pe(t,"<p />"),n=n.closestBlock()}const s=t.selection.insertBookmark();Z(e,n),t.selection.toBookmark(s),t.selection.fixList()}return Sr.box.add({type:"block",name:"hr",render:t=>{const e=t.getEditor();if(e)return t.useEffect((()=>{t.getContainer().find(".lake-hr").on("click",(()=>{e.selection.range.selectBox(t.node)}))})),'<div class="lake-hr"><hr /></div>'},html:()=>"<hr />"}),Sr.box.add(Bl),Sr.box.add(sc),Sr.plugin.add((t=>{t.container.on("copy",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.startNode.closest("lake-box");if(0===n.length)return;if(i.isBoxStart||i.isBoxEnd)return;e.preventDefault();const s=e.clipboardData;if(!s)return;const o=new Yt(n).getHTML();s.setData("text/html",o)}))})),Sr.plugin.add((t=>{t.container.on("cut",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.startNode.closest("lake-box");if(0===n.length)return;if(i.isBoxStart||i.isBoxEnd)return;e.preventDefault();const s=e.clipboardData;if(!s)return;const o=new Yt(n).getHTML();s.setData("text/html",o),t.removeBox(),t.history.save()}))})),Sr.plugin.add((t=>{t.container.on("paste",(e=>{const{requestTypes:i}=t.config.image;if(t.selection.range.isInsideBox)return;e.preventDefault();const n=e.clipboardData;if(!n)return;if(t.selection.deleteContents(),n.files.length>0){for(const e of n.files)i.indexOf(e.type)>=0&&Xr({editor:t,file:e});return}const s=n.types;if(1===s.length&&"text/plain"===s[0]){const e=n.getData("text/plain"),i=new ne(e).getFragment();return t.event.emit("beforepaste",i),void ac(t,i)}const o=u(n.getData("text/html")),r=function(){const t=ee();return t.div=t.p,g(t,((t,e)=>{delete e.id,delete e.class})),t}(),a=new ie(o,r).getFragment();t.event.emit("beforepaste",a),function(t){let e=new T(t.firstChild);for(;e.length>0;){const t=e.next();e.isBlock&&rc(e),e=t}let i=[];for(e=new T(t.firstChild);e.length>0;){const t=e.next();e.isMark||e.isText||e.isBookmark||e.isInlineBox?i.push(e):(H(i),i=[]),e=t}H(i)}(a),ac(t,a),t.box.renderAll(t)}))})),Sr.plugin.add((t=>{t.command.add("undo",{execute:()=>{t.history.undo()}}),t.keystroke.setKeydown("mod+z",(e=>{t.selection.range.isInsideBox||(e.preventDefault(),t.command.execute("undo"))}))})),Sr.plugin.add((t=>{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)})),Sr.plugin.add((t=>{t.command.add("selectAll",{execute:()=>{const e=t.selection.range;e.selectNodeContents(t.container),e.shrink()}})})),Sr.plugin.add((t=>{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()}})})),Sr.plugin.add((t=>{t.command.add("blockQuote",{isSelected:t=>!!t.find((t=>"blockquote"===t.name)),execute:e=>{e&&lc.indexOf(e)>=0?t.selection.setBlocks(a`<blockquote type="${e}" />`):t.selection.setBlocks("<blockquote />"),t.history.save()}})})),Sr.plugin.add((t=>{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&&cc(t),"bulleted"===e&&dc(t),"checklist"===e&&pc(t,i)):o?("numbered"===e&&hc(t),"bulleted"===e&&cc(t),"checklist"===e&&pc(t,i)):r?("numbered"===e&&hc(t),"bulleted"===e&&dc(t),"checklist"===e&&cc(t)):("numbered"===e&&hc(t),"bulleted"===e&&dc(t),"checklist"===e&&pc(t,i)),t.history.save()}}),t.container.on("click",(e=>{const i=e;if(!i.target)return;const n=I(i.target);"li"===n.name&&""!==n.attr("value")&&i.offsetX<=18&&(n.attr("value",("true"!==n.attr("value")).toString()),t.history.save())}))})),Sr.plugin.add((t=>{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?[uc[e]||e]:[]},execute:e=>{t.selection.setBlocks({"text-align":e}),t.history.save()}})})),Sr.plugin.add((t=>{t.command.add("indent",{execute:e=>{const i=t.selection.range.getBlocks();for(const t of i)F(t,e);t.history.save()}})})),Sr.plugin.add((t=>{t.command.add("bold",{isDisabled:t=>!!t.find((t=>t.node.isHeading)),isSelected:t=>!!t.find((t=>t.name===mc)),execute:()=>{t.command.isSelected("bold")?t.selection.removeMark(`<${mc} />`):t.selection.addMark(`<${mc} />`),t.history.save()}}),t.keystroke.setKeydown("mod+b",(e=>{e.preventDefault(),t.command.execute("bold")}))})),Sr.plugin.add((t=>{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")}))})),Sr.plugin.add((t=>{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")}))})),Sr.plugin.add((t=>{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")}))})),Sr.plugin.add((t=>{t.command.add("subscript",{isSelected:t=>!!t.find((t=>t.name===fc)),execute:()=>{t.command.isSelected("subscript")?t.selection.removeMark(`<${fc} />`):t.selection.addMark(`<${fc} />`),t.history.save()}})})),Sr.plugin.add((t=>{t.command.add("superscript",{isSelected:t=>!!t.find((t=>t.name===gc)),execute:()=>{t.command.isSelected("superscript")?t.selection.removeMark(`<${gc} />`):t.selection.addMark(`<${gc} />`),t.history.save()}})})),Sr.plugin.add((t=>{t.command.add("code",{isSelected:t=>!!t.find((t=>t.name===vc)),execute:()=>{t.command.isSelected("code")?t.selection.removeMark(`<${vc} />`):t.selection.addMark(`<${vc} />`),t.history.save()}})})),Sr.plugin.add((t=>{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()}})})),Sr.plugin.add((t=>{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()}})})),Sr.plugin.add((t=>{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()}})})),Sr.plugin.add((t=>{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()}})})),Sr.plugin.add((t=>{t.command.add("removeFormat",{execute:()=>{t.selection.removeMark(),t.history.save()}})})),Sr.plugin.add((t=>{let e=[];t.command.add("formatPainter",{execute:()=>{t.container.addClass(wc);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(wc),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(wc),e=[])}))})),Sr.plugin.add((t=>{const e=new yc(t.popupContainer);e.event.on("save",(e=>{const i=t.selection.range;i.setStartAfter(e),i.collapseToStart(),t.selection.addRangeToNativeSelection(),t.history.save()})),e.event.on("remove",(e=>{const i=t.selection.range;i.setStartAfter(e),i.collapseToStart(),t.selection.addRangeToNativeSelection(),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="">${$r.link.newLink()}</a>`);i&&(t.history.save(),e.show(i))}})})),Sr.plugin.add((t=>{t.event.on("beforepaste",(t=>{new mt(t).find("hr").each((t=>{const e=I(t),i=new Yt("hr");e.replaceWith(i.node)}))})),t.command.add("hr",{execute:()=>{t.insertBox("hr"),t.history.save()}})})),Sr.plugin.add((t=>{t.setPluginConfig("image",{requestMethod:"POST",requestTypes:["image/gif","image/jpeg","image/png","image/svg+xml"]}),t.event.on("beforepaste",(t=>{new mt(t).find("img").each((t=>{const e=I(t),i=new 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()}})})),Sr.plugin.add((t=>{window.CodeMirror&&t.command.add("codeBlock",{execute:e=>{const i=t.insertBox("codeBlock",e);t.history.save();i.getData("codeEditor").focus()}})})),Sr.plugin.add((t=>{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 bc){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 kc){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 Sc(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 _c){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(),Sc(e),i.range.shrinkAfter(e),t.command.execute(r,...n),t.commitOperation(),!0)}}return!1}(t,n)?(e.preventDefault(),e.stopImmediatePropagation(),!1):void 0}))})),Sr.plugin.add((t=>{t.keystroke.setKeydown("enter",(e=>{const i=t.selection.range;if(i.isInsideBox)return;if(e.preventDefault(),t.rectifyContent(),i.isBox)return Cc(t),void t.history.save();if(i.adapt(),i.isInoperative)return;if(i.isBox)return Cc(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();Ac(t,n),t.history.save()}))})),Sr.plugin.add((t=>{t.keystroke.setKeydown("shift+enter",(e=>{const i=t.selection.range;if(!i.isInsideBox){if(t.rectifyContent(),e.preventDefault(),i.isBox)return Ec(t),void t.history.save();if(i.adapt(),!i.isInoperative){if(i.isBox)return Ec(t),void t.history.save();Bc(t),t.history.save()}}}))})),Sr.plugin.add((t=>{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(),Tc(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(),i.selectBox(n),t.removeBox(),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();Tc(t,n),t.history.save()}}))})),Sr.plugin.add((t=>{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(),Ic(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(),i.selectBox(n),t.removeBox(),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]),Ic(t,n),t.history.save()}}))})),Sr.plugin.add((t=>{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()}))})),Sr.plugin.add((t=>{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()}}))})),Sr.plugin.add((t=>{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.addRangeToNativeSelection()}t.root.hasClass("lake-root-focused")&&(e.preventDefault(),t.blur())}))})),t.Box=Yt,t.Button=ke,t.Dropdown=_e,t.Editor=Sr,t.Fragment=mt,t.HTMLParser=ie,t.Nodes=T,t.Range=L,t.TextParser=ne,t.Toolbar=class{constructor(t){this.allMenuMap=new Map,this.buttonItemList=[],this.dropdownItemList=[],this.items=t.items||Jr,this.root=I(t.root),this.container=I('<div class="lake-toolbar" />'),this.root.addClass("lake-custom-properties")}appendDivider(){this.container.append('<div class="lake-toolbar-divider" />')}appendButton(t,e){new ke({root:this.container,name:e.name,icon:e.icon,tooltip:e.tooltip,tabIndex:-1,onClick:()=>{t.focus(),e.onClick(t,e.name)}}).render()}appendDropdown(t,e){new _e({root:this.container,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,onSelect:i=>{t.focus(),e.onSelect(t,i)}}).render()}appendUpload(t,e){const i=I(a`
|
|
70
70
|
<div class="lake-upload" name="${e.name}">
|
|
71
71
|
<input type="file" />
|
|
72
72
|
</div>
|