@ones-editor/editor 0.0.3-beta.32 → 0.0.3-beta.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -739,4 +739,4 @@ width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
739
739
  </defs>
740
740
  </svg>`,q3={dwg:[],rvt:[],skp:[],img:["image/png","image/jpg","image/jpeg","image/bmp","image/ico","image/icon","image/gif"],txt:["text/plain"],zip:["application/zip","application/x-rar-compressed","application/x-7z-compressed","application/x-tar","application/x-bzip2","application/java-archive"],ppt:["application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"],excel:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],pdf:["application/pdf"],word:["application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"]},Xh={dwg:__,rvt:N_,skp:P_,img:$_,txt:H_,zip:V3,rar:V3,ppt:j_,excel:F_,pdf:z_,word:U_};function q_(n,t){const e=Object.keys(q3);for(let r=0;r<e.length;r+=1){const i=e[r];if(q3[i].includes(t))return Xh[i]}const o=bm(n.toLowerCase());return Xh[o]?Xh[o]:V_}function W_(n,t){const e=b("div",["card-root","embed-selected-content"],n),o=b("div",["file-icon"],e);o.innerHTML=q_(t.fileName,t.fileType);const r=b("div",["file-details"],e);b("div",["file-name"],r,t.fileName),b("div",["file-size"],r,Bm(t.fileSize));const i=b("div",["file-actions"],e),s=b("button",["download"],i);return s.innerHTML=Jh,{card:e,downloadButton:s}}const fz="";function W3(n,t){const o=n.getBlockData(t).embedData,r=n.options.componentsOptions.file;if(r!=null&&r.onDownloadFile){r.onDownloadFile(n,o);return}const i=n.doc.buildResourceUrl(o.src,{downloadFileName:o.fileName});al(i,o.fileName)}w("webpage-embed");function G_(n,t,e){const{embedData:o}=e,r=o,{card:i,downloadButton:s}=W_(t,r);n.domEvents.addEventListener(s,"click",(l,c)=>{if(!c.target)return;const a=z(c.target);!a||W3(l,a)}),n.domEvents.addEventListener(i,"click",(l,c)=>{if(!c.target)return;const a=z(c.target);if(!a||Ei(c,"button"))return;const h=l.options.componentsOptions.file;if(h!=null&&h.onClick){h.onClick(l,a,c);return}const m=l.getBlockData(a).embedData,C=l.doc.buildResourceUrl(m.src,{downloadFileName:m.fileName});al(C,m.fileName)})}class Z_{constructor(){u(this,"group","file-card");u(this,"commands",[{id:"download",name:"Download",icon:Jh},{id:"sep",name:"",type:"separator"},{id:"to-link",name:"To link",icon:j3},{id:"to-card",name:"To card",icon:F3,states:["checked"]},{id:"sep",name:"",type:"separator"},{id:"add-comment",name:"Add Comment",icon:Hr}])}executeCommand(t,e,o){if(o.id==="to-link"){const r=H(e),i=U(r),s=K(e),l=t.getBlockData(e),{embedData:c}=l,a=c,h={id:N(),box:!0,type:"file",created:Date.now(),src:a.src,fileName:a.fileName,fileSize:a.fileSize,fileType:a.fileType};t.undoManager.runInGroup(()=>{t.deleteBlock(e);const f=[Mg(h)];t.insertTextBlock(f,i,s)})}else o.id==="download"?W3(t,e):o.id==="add-comment"&&z4(t,e)}}function Y_(n,t){const e=n.getBlockData(t),{embedData:o,id:r}=e,i=o;return{blockCommands:{"hovering-toolbar":new Z_},abstract:i.fileName}}const Q_={embedType:"office",createEmbedContent:G_,getBlockProperties:Y_},mz="",K_={media:{upload:{failed:'<div class="line-1">{name} \u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},load:{failed:'<div class="line-1">{name} \u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},audio:{menuItem:"\u97F3\u9891",abstract:"\u97F3\u9891"},video:{menuItem:"\u89C6\u9891",abstract:"\u89C6\u9891"}}},J_={media:{upload:{failed:'<div class="line-1">{name} upload failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},load:{failed:'<div class="line-1">{name} loading failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},audio:{menuItem:"Audio",abstract:"Audio"},video:{menuItem:"Video",abstract:"Video"}}};S.mergeLang({"zh-CN":K_,"en-US":J_});var dn=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(dn||{}),Ns=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))(Ns||{});const G3=10*1024*1024,X_=["wav","mp3","aac","ogg","webm","flac"],tN=["ogg","mp4","webm"],eN=()=>{};function Z3(n){var h,f,m,C,v,k;const t=(h=n.getComponentOptions("media"))!=null?h:{},{allowedMedias:e,maxSize:o,callbacks:r}=t,i=(f=e==null?void 0:e.audio)!=null?f:X_,s=(m=e==null?void 0:e.video)!=null?m:tN,l=(C=o==null?void 0:o.audio)!=null?C:G3,c=(v=o==null?void 0:o.video)!=null?v:G3,a=(k=r==null?void 0:r.onError)!=null?k:eN;return{allowedMedias:{audio:i,video:s},maxSize:{audio:l,video:c},callbacks:{onError:a}}}const nN=w("file-utils");function oN(n){d(nN,n instanceof File,`The file: ${n} isn't instance of File`);const{name:t}=n;if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1)}function Y3(n,t){const e=i=>i.map(s=>`.${s}`).join(","),{allowedMedias:o}=Z3(n),r=o[t];return r?e(r):"*"}function rN(n,t,e){const{maxSize:o,callbacks:r,allowedMedias:i}=Z3(t),{[e]:s}=o,{[e]:l}=i;if(s&&n.size>s){const a=new Error("media is too large");return a.code=`MaxMediaSize-${e}`,r!=null&&r.onError&&(r==null||r.onError(t,a)),a}const c=oN(n);if(l&&!l.includes(c)){const a=new Error(`media file is not allowed: ${c}`);return a.code="NotAllowedFile",r!=null&&r.onError&&(r==null||r.onError(t,a)),a}return!0}function iN(n){return n===Ns.Empty||n===Ns.Error}const ue=w("media");class sN{constructor(t){u(this,"mediaContainer",null);u(this,"media",null);u(this,"abstract",null);u(this,"handleMediaLoadError",(t,e)=>{if(!e.target||!(e.target instanceof Node)||!(e.target instanceof Element?e.target:e.target.parentElement))return;const r=z(e.target);if(!r||!r.contains(this.mediaContainer))return;const i=this.renderError();this.updateMediaContent(i)});u(this,"handleRetry",async t=>{if(t.readonly)return;d(ue,this.abstract,"no abstract");const{mediaType:e}=this.abstract,o=Y3(t,e),r=await Mo(o);this.handleUploadFile(r)});u(this,"handleUploadFile",async t=>{d(ue,this.abstract,"no abstract"),d(ue,this.mediaContainer,"The media element not exist");const{editor:e}=this.options,{mediaType:o}=this.abstract,r=z(this.mediaContainer);d(ue,r,"The block element not exist");const i=e.getBlockData(r);if(!!rN(t,e,o))try{const{resourceId:s}=await e.doc.uploadResource(t,{onProgress:f=>{this.renderProgress(f,t)}}),{name:l,type:c,size:a}=t,h={...i,embedData:{...i.embedData,src:s,fileName:l,fileSize:a,fileType:c}};e.updateBlockData(r,h)}catch{this.renderRetry()}});u(this,"destroy",()=>{this.mediaContainer=null});this.options=t}bindMediaEvent(){const{editor:t}=this.options;this.media&&t.domEvents.addEventListener(this.media,"error",this.handleMediaLoadError)}unbindMediaEvent(){const{editor:t}=this.options;this.media&&t.domEvents.removeEventListener(this.media,"error",this.handleMediaLoadError)}updateMediaContent(t){d(ue,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(t)}renderError(){d(ue,this.abstract,"no abstract");const{editor:t,createMediaElement:e}=this.options,{mediaIcon:o,mediaName:r}=this.abstract;d(ue,this.mediaContainer,"The media element not exist");const i=z(this.mediaContainer);d(ue,i,"The block element not exist");const s=t.getBlockData(i),l=s.embedData.src,c=b("div",["media-error","embed-selected-content","embed-hover-content"],null),a=b("span",["media-error-icon"],c);a.innerHTML=o;const h=b("div",[],c);h.innerHTML=S.t("media.load.failed",{name:r}),c.appendChild(h);const f=h.querySelector("a");return d(ue,f,"The element not exist"),t.domEvents.addEventListener(f,"click",(m,C)=>{if(C.preventDefault(),C.target instanceof HTMLElement&&C.target.tagName==="A"){const v=b("div",["media-element"],null),k=this.getResourceUrl(l),E=e(m,v,s,k);this.unbindMediaEvent(),this.media=E,this.bindMediaEvent(),this.updateMediaContent(v)}}),c}renderRetry(){d(ue,this.abstract,"no abstract");const{editor:t}=this.options,{mediaIcon:e,mediaName:o}=this.abstract,r=b("div",["media-error","embed-selected-content","embed-hover-content"],null),i=b("span",["media-error-icon"],r);i.innerHTML=e;const s=b("div",[],r);s.innerHTML=S.t("media.upload.failed",{name:o}),r.appendChild(s);const l=s.querySelector("a");d(ue,l,"The element not exist"),t.domEvents.addEventListener(l,"click",this.handleRetry),this.updateMediaContent(r)}renderProgress(t,e){d(ue,this.mediaContainer,"The media element not exist");const o=this.mediaContainer.querySelector(":scope .media-progress"),r=t===-1||t===100?100:t;if(o){const{updateProgressElement:i}=this.options;i(o,r)}else{const{createProgressElement:i}=this.options,s=b("div",["media-progress"],null);i(s,r,e),this.updateMediaContent(s)}}renderMediaElement(t){d(ue,this.mediaContainer,"The media element not exist");const e=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:o,updateMediaElement:r,editor:i}=this.options,s=this.getResourceUrl(t.embedData.src);if(e){const l=r(i,e,t,s);this.unbindMediaEvent(),this.media=l,this.bindMediaEvent()}else{const l=b("div",["media-element"],null),c=o(i,l,t,s);this.unbindMediaEvent(),this.media=c,this.bindMediaEvent(),this.updateMediaContent(l)}}renderEmpty(){d(ue,this.abstract,"no abstract"),d(ue,this.mediaContainer,"The media element not exist");const t=b("div",["media-empty","embed-selected-content","embed-hover-content"],this.mediaContainer);t.innerHTML=this.abstract.mediaIcon,this.updateMediaContent(t)}getResourceUrl(t){const{editor:e}=this.options;return e.doc.buildResourceUrl(t)}render(t,e){const{src:o}=t.embedData;(!this.mediaContainer||!e.contains(this.mediaContainer))&&(this.mediaContainer=b("div",["media"],e)),iN(o)?o===Ns.Empty&&this.renderEmpty():this.renderMediaElement(t)}setAbstract(t){this.abstract=t}}w("media-embed");class Q3{constructor(){u(this,"handleInsertEmptyEmbed",async(t,e)=>{var h;const{containerId:o,blockIndex:r}=e;let i;(h=e.data)!=null&&h.file&&(i=e.data.file);const s=Y3(t,this.embedType);if(i=i!=null?i:await Mo(s,{}),!i)return null;const l={id:N(),type:"embed",embedType:this.embedType,embedData:{src:Ns.Empty}},c=t.insertBlock(o,r,l);return await this.getMedia(t,l.id).handleUploadFile(i),c})}getMedia(t,e){const o=t.addCustom(`media-${e}`,()=>new sN({editor:t,createMediaElement:this.createMediaElement,updateMediaElement:this.updateMediaElement,createProgressElement:this.createProgressElement,updateProgressElement:this.updateProgressElement}));return o.setAbstract({...this.abstract}),o}getOptions(){const{menuItem:t,mediaIcon:e,mediaName:o,order:r,group:i}=this.abstract;return{name:o,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:t,icon:e,order:r,group:i}],handleInsertEmptyEmbed:this.handleInsertEmptyEmbed}}createEmbedContent(t,e,o){const{id:r}=o;this.getMedia(t,r).render(o,e)}handleUpdateBlock(t,e,o){const{id:r}=o,i=this.getMedia(t,r),s=rt(e);return i.render(o,s),!0}handleDeleteBlock(t,e){const o=e.id;this.getMedia(t,o).destroy()}}function K3(n,t){const e=b("div",["uploading-progress-mask"],n),o=b("div",["uploading-progress-bar"],e),r=b("div",["uploading-progress-bar-value"],o);r.style.width=`${t}%`}function J3(n,t){const e=n.querySelector(".uploading-progress-bar-value");e&&(e.style.width=`${t}%`)}const lN=w("media-audio");class cN extends Q3{constructor(){super(...arguments);u(this,"embedType",dn.AUDIO);u(this,"abstract",{mediaIcon:V5,mediaName:S.t(`media.${dn.AUDIO}.menuItem`),menuItem:S.t(`media.${dn.AUDIO}.menuItem`),order:800,mediaType:dn.AUDIO,group:"common"});u(this,"updateProgressElement",J3)}getBlockProperties(){return{abstract:`[${S.t(`media.${dn.AUDIO}.abstract`)}]`}}createMediaElement(e,o,r,i){const s=b("div",["audio-container","embed-hover-content","embed-selected-content"],o),l=b("audio",[],s);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=i,l}updateMediaElement(e,o,r,i){const s=o.querySelector(":scope .audio-container > audio");return d(lN,s,"The media element not exist"),s.src!==i&&(s.src=i),s}createProgressElement(e,o){const r=b("audio",[],e);r.innerHTML="Your browser does not support the <code>audio</code> element.",r.controls=!0,r.src="about:blank",K3(e,o)}}const tf=new cN;w("video-resizer");function X3(n){return n&&De(n)&&Le(n)==="video"}const aN=50;class dN{constructor(t){u(this,"currentResizableElement",null);u(this,"resizing",!1);u(this,"handleHoveringBlockChange",(t,e)=>{if(!this.resizing&&(e&&X3(e)&&this.disableBlockResize(e),t&&X3(t))){const o=this.getVideoElement(t);if(!o)return;this.enableBlockResize(t,o)}});u(this,"handleResizing",(t,e)=>{if(this.resizing=!0,!this.currentResizableElement)return;const o=t.getBlock();if(!o)return;const r=o.getBoundingClientRect().width,i=Math.min(Math.max(e.width,aN),r);this.currentResizableElement.style.width=`${i}px`});u(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!this.currentResizableElement||!e)return;const o=this.editor.getBlockData(e),{width:r}=this.currentResizableElement.getBoundingClientRect();this.editor.updateBlockData(e,{...o,width:r})});this.editor=t,_t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,_t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(t){return rt(t).querySelector(":scope .video-container > video")}disableBlockResize(t){const e=this.editor.findCustom(`${G(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t,e){const o=this.editor.addCustom(`${G(t)}-resizer`,()=>new Fc(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}));o.enableResize(t,e),o.removeListener("resizing",this.handleResizing),o.removeListener("resized",this.handleResized),o.addListener("resizing",this.handleResizing),o.addListener("resized",this.handleResized),this.currentResizableElement=e}}const uN=w("video");class hN extends Q3{constructor(){super(...arguments);u(this,"embedType",dn.VIDEO);u(this,"abstract",{mediaName:S.t(`media.${dn.VIDEO}.menuItem`),mediaIcon:q5,menuItem:S.t(`media.${dn.VIDEO}.menuItem`),order:700,mediaType:dn.VIDEO,group:"common"});u(this,"updateProgressElement",J3);u(this,"createProgressElement",(e,o,r)=>{const i=b("video",["progress-video"],e);i.innerHTML="Your browser does not support the <code>audio</code> element.",i.controls=!0,K3(e,o),rl(r).then(s=>{const l=e.querySelector(".progress-video");l&&h1(e)&&(l.src=s)})})}getBlockProperties(){return{abstract:`[${S.t(`media.${dn.VIDEO}.abstract`)}]`}}createMediaElement(e,o,r,i){const s=b("div",["video-container","embed-selected-content","drag-preview-element"],o),l=b("video",[],s);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=i,e.addCustom("video-resizer",()=>new dN(e)),r.width&&(l.style.width=`${r.width}px`),l}updateMediaElement(e,o,r,i){const s=o.querySelector(":scope .video-container > video");return d(uN,s,"The media element not exist"),s.src!==i&&(s.src=i),s}}const ef=new hN,gz="",fN={version:{latest:"\u5F53\u524D\u7248\u672C",insert:"{name} \u6DFB\u52A0",delete:"{name} \u5220\u9664",goBack:"\u8FD4\u56DE",revertVersion:"\u8FD8\u539F\u5185\u5BB9",play:"\u64AD\u653E\u5386\u53F2\u64CD\u4F5C",versionList:"\u5386\u53F2\u8BB0\u5F55 {count}",unknown:"\u672A\u77E5\u7248\u672C",restoreFrom:"\u56DE\u6EDA\u81EA\u7248\u672C {from}",restoreInfo:"\u56DE\u6EDA\u7684\u7248\u672C\u6682\u4E0D\u652F\u6301\u4E0E\u4E0A\u4E00\u7248\u672C\u5BF9\u6BD4"}},mN={version:{latest:"Latest",insert:"Added by {name}",delete:"Deleted by {name}",goBack:"Back",revertVersion:"Revert",play:"Play",versionList:"Versions ({count})",unknown:"Unknown version",restoreFrom:"Reverted from {from}",restoreInfo:"The rolled back version does not currently support comparison with the previous version."}};S.mergeLang({"zh-CN":fN,"en-US":mN});var t9=(n=>(n.NEW="history-new",n.NEW_CHILD="history-new-child",n.DELETED="history-deleted",n.UPDATED="history-updated",n.HISTORY="history",n))(t9||{});const si="--op-color",li="--op-selected-color",pz="";class gN{constructor(t){u(this,"root");this.content=t;const e=b("div",["dialog-root"],null);e.append(t),this.root=e}show(t=document.body){t.append(this.root)}hide(){this.root.remove()}destroy(){}}const{t:ci}=S,e9=w("version-list");class pN{constructor(t){u(this,"activeVersionElement");u(this,"versionsList");u(this,"versionsListHeader");u(this,"handleClickVersionItem",t=>{const o=t.target.closest(".dialog-version-list-item");if(this.isVersionElement(o)){this.toggleActiveVersionElement(o);const r=this.getVersionFromElement(o),{onSelectVersion:i}=this.options;i(r)}});this.options=t;const{versions:e,defaultSelectedIndex:o=0}=t,r=b("div",["version-dialog-list-header"],null,"count");r.innerText=ci("version.versionList",{count:`${e.length}`});const i=b("div",["version-dialog-list"],null),s=this.convertVersionsToFragment(e);i.append(s);const l=i.children[o];M(l,"active"),this.activeVersionElement=l,this.versionsList=i,this.versionsListHeader=r,i.onclick=this.handleClickVersionItem}get isSelectedFirstVersion(){return!!this.activeVersionElement&&this.versionsList.firstChild===this.activeVersionElement}get isSelectedLastVersion(){return!!this.activeVersionElement&&this.versionsList.lastChild===this.activeVersionElement}get beforeVersion(){return d(e9,this.activeVersionElement,"No active version element"),this.activeVersionElement.nextElementSibling?this.activeVersionElement.nextElementSibling.versionData:null}get beforeMajorVersion(){d(e9,this.activeVersionElement,"No active version element");let t=this.activeVersionElement.nextElementSibling;for(;t;){if(t.versionData.type)return t.versionData;t=t.nextElementSibling}return null}convertVersionsToFragment(t){const e=document.createDocumentFragment(),o=i=>{var l;let s;if(i.version!==-1){const c=new Date((l=i.created)!=null?l:i.version);s=`${c.toLocaleDateString()} ${c.toLocaleTimeString()}`}else s=ci("version.latest");return s},r=(i,s,l,c=!1)=>{var C;const a=b("div",["dialog-version-list-item"],e);a.versionData=i,s&&M(a,"child");const h=b("div",["dialog-version-list-item-title"],a);if(b("div",["dialog-version-list-item-date"],h,o(i)),c&&b("div",["dialog-version-list-item-now-ver"],h,ci("version.latest")),typeof i.source=="object"&&((C=i.source)==null?void 0:C.restore)){const v=i.source.restore,k=l.find(A=>A.version==v),E=k?o(k):ci("version.unknown"),L=ci("version.restoreFrom",{from:E}),x=ci("version.restoreInfo"),O=b("div",["dialog-version-item-from-container"],a);b("div",["dialog-version-item-from-main"],O,L),b("div",["dialog-version-item-from-info"],O,x)}const f=b("ul",["dialog-version-list-item-authors"],a),m=v=>{const k=b("li",["dialog-version-list-item-author"],f),E=b("span",["dialog-version-list-item-mark-author"],k);E.style.background=this.options.getMarkColor(v),b("span",["dialog-version-list-item-author-name"],k,v.displayName)};if(this.options.useCreatedBy)if(i.createdBy){const v=i.createdBy;m(v)}else i.authors&&i.authors.length>0&&i.authors.forEach(v=>{m(v)});else if(i.authors&&i.authors.length>0)i.authors.forEach(v=>{m(v)});else if(i.createdBy){const v=i.createdBy;m(v)}};return t.forEach((i,s)=>{r(i,!1,t,s===0),i.minorVersions&&i.minorVersions.length>0&&i.minorVersions.forEach(l=>{r(l,!0,t,!1)})}),e}isVersionElement(t){return t?lt(t,"dialog-version-list-item"):!1}getVersionFromElement(t){return t.versionData}get activeVersion(){return this.getVersionFromElement(this.activeVersionElement)}toggleActiveVersionElement(t){this.activeVersionElement!==t&&(F(this.activeVersionElement,"active"),M(t,"active"),this.activeVersionElement=t)}selectVersionByVersionNum(t){const e=Array.from(this.versionsList.children).find(o=>o.versionData.version===t);return this.isVersionElement(e)?(this.toggleActiveVersionElement(e),this.getVersionFromElement(e)):null}render(t){t.innerHTML="",t.append(this.versionsListHeader,this.versionsList)}destroy(){this.versionsList.onclick=null}}class CN{constructor(t,e){this.doc=t,this.user=e}onDeleteBlock(t,e){this.doc.onDeleteBlock(t,e,this.user)}onInsertBlock(t,e,o){this.doc.onInsertBlock(t,e,o,this.user)}onUpdateBlockText(t,e,o){this.doc.onUpdateBlockText(t,e,o,this.user)}onUpdateBlockData(t,e,o){this.doc.onUpdateBlockData(t,e,o,this.user)}onCreateContainer(t,e){this.doc.onCreateContainer(t,e,this.user)}onCreateComment(){}onDeleteComment(){}onDeleteContainer(){}onUpdateComment(){}}function bN(n){return new Promise(t=>{setTimeout(t,n)})}async function vN(n,t,e,o){for(const r of e){const i=new CN(n,r.user);t.parseHistoryData(r,i),o.play&&await bN(o.speed||150)}}const yN=`<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
741
741
  <path d="M0 0h24v24H0z" fill="none"/><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/>
742
- </svg>`,{t:nf}=S;class kN{constructor(t){u(this,"goBackButton");u(this,"playButton");u(this,"revertButton");this.options=t;const e=b("button",["dialog-text-button"],null),o=b("span",["dialog-button-icon"],e);o.innerHTML=yN,b("span",["dialog-button-text"],e,nf("version.goBack"));const r=b("button",["dialog-version-button"],null,nf("version.play")),i=b("button",["dialog-version-button"],null,nf("version.revertVersion"));this.goBackButton=e,this.playButton=r,this.revertButton=i,this.bindEvent()}bindEvent(){const{onBack:t,onPlay:e,onRevert:o}=this.options;this.playButton.onclick=e,this.goBackButton.onclick=t,this.revertButton.onclick=o}disabledButton(){}render(t,e=!1){e||t.append(this.goBackButton,this.playButton,this.revertButton)}destroy(){this.playButton.onclick=null,this.goBackButton.onclick=null,this.revertButton.onclick=null}}const he=w("split-text-actions");function n9(n){return n.length>2?!1:n.length===1?n[0].insert!==void 0:(d(he,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].insert!==void 0)}function o9(n){return n.length>2?!1:n.length===1?n[0].delete!==void 0:(d(he,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].delete!==void 0)}function r9(n){return n.length>2?!1:n.length===1?n[0].insert===void 0&&n[0].delete===void 0&&n[0].attributes!==void 0:(d(he,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].attributes!==void 0)}function wN(n){const t=[],e=Y.default(n);if(e.length===0)return[];if(e.length===1)return[n];if(e.length===2&&(o9(n)||n9(n)||r9(n)))return[n];const o=(i,s)=>i>0?[{retain:i},s]:[s];let r=0;for(;e.length>0;){const i=e[0];if(i.retain!==void 0&&i.attributes===void 0){d(he,i.retain>0,`invalid text op: ${JSON.stringify(i)}`),d(he,e.length>1,`invalid text op: ${JSON.stringify(i)}`);const s=e[1];d(he,s.delete||s.insert!==void 0||s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=i.retain,t.push(o(r,s)),s.delete!==void 0?r-=s.delete:s.insert!==void 0?r+=s.insert.length:(d(he,s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),d(he,s.retain!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=s.retain),e.splice(0,2)}else d(he,i.delete||i.insert!==void 0||i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),t.push(o(r,i)),e.shift(),i.retain!==void 0&&(d(he,i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),r+=i.retain),i.insert&&(r+=i.insert.length)}return t}function i9(n){if(d(he,n.length===1||n.length===2,`not a single action op: ${JSON.stringify(n)}`),n.length===1)return 0;const t=n[0].retain;return d(he,typeof t=="number"&&t>0,`invalid retain: ${JSON.stringify(n)}`),t}let s9=0;function BN(n,t,e){const o=s9;s9+=1;const r=kt(n);return{insert:" ",attributes:{box:!0,id:N(),type:"history-deleted-box",user:e,created:Date.now(),text:r,deletedOffset:t,deletedOrder:o}}}function EN(n,t,e){const o=i9(t),r=t.length===1?t[0].delete:t[1].delete;d(he,typeof r=="number",`not a delete op: ${JSON.stringify(t)}`);const{left:i,middle:s,right:l}=Jt(n,o,r),c=BN(s,o,e);return[...i,c,...l]}function IN(n,t,e){const o=i9(t),r=t.length===1?t[0].insert:t[1].insert;d(he,typeof r=="string",`invalid insert op: ${JSON.stringify(t)}`);const i=t.length===1?t[0].attributes:t[1].attributes,l=Bl([{insert:r,attributes:i}],"insertedBy",e);return xr(n,o,l,null)}function xN(n,t,e){const o=wN(t).reverse();let r=n;for(const i of o)o9(i)?r=EN(r,i,e):n9(i)?r=IN(r,i,e):(d(he,r9(i),`unknown op: ${JSON.stringify(i)}`),r=oe.apply(r,i));return r}const SN=w("history-update-block-text");function l9(n){const t=[],e=[];let o=0;return n.forEach(r=>{var i;if((i=r.attributes)!=null&&i.box){const s=r.attributes;if(s.type==="history-deleted-box"){t.push({boxData:s,offset:o});return}}e.push(r),o+=N1(r)}),t.sort((r,i)=>i.offset-r.offset),{deletedBoxes:t,newText:e}}function TN(n,t,e){let o=n;return t.forEach(r=>{const i=oe.transformCursor(r.offset,e,!1);o=xr(o,i,[{insert:" ",attributes:r.boxData}],null)}),o}function DN(n){n.sort((t,e)=>t.boxData.deletedOffset!==e.boxData.deletedOffset?t.boxData.deletedOffset-e.boxData.deletedOffset:t.boxData.deletedOrder-e.boxData.deletedOrder)}function LN(n){if(n.length<=1)return n;const t=n[0].offset;n.forEach(e=>{d(SN,e.offset===t,`invalid boxes group, ${JSON.stringify(n)}`)}),DN(n);for(let e=n.length-1;e>=1;e--){const o=n[e],r=n[e-1];o.boxData.user.userId===r.boxData.user.userId&&(r.boxData.text+=o.boxData.text,n.splice(e,1))}return n}function MN(n){let{newText:t,deletedBoxes:e}=l9(n);const o=new Map;return e.forEach(i=>{let s=o.get(i.offset);s||(s=[],o.set(i.offset,s)),s.push(i),s.sort((l,c)=>l.boxData.deletedOffset-c.boxData.deletedOffset)}),Array.from(o.values()).sort((i,s)=>s[0].offset-i[0].offset).forEach(i=>{const s=i[0].offset;LN(i).reverse().forEach(l=>{t=xr(t,s,[{insert:" ",attributes:l.boxData}],null)})}),t}function RN(n,t,e){let{newText:o,deletedBoxes:r}=l9(n);return o=xN(o,t,e),o=TN(o,r,t),o=MN(o),o}const Tn=w("history-doc");function Dn(n){d(Tn,!1,"no local actions for history doc")}class ON extends ki{constructor(e,o){super();u(this,"doc");u(this,"editor");this.doc=Y.default(e),this.editor=o}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return Y.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,o){const r=this.getContainerBlocks(e);d(Tn,r,`no container data: ${e}`);const i=r[o];return d(Tn,i,`no block data: ${o}`),i}localUpdateBlockText(){Dn()}localUpdateBlockData(){Dn()}localInsertBlock(){Dn()}localDeleteBlock(){Dn()}localInsertChildContainer(){Dn()}localDeleteChildContainers(){Dn()}uploadResource(){Dn()}async addResources(e){Dn()}getServerMeta(){var e,o,r;return(r=(o=(e=this.editor.doc.externalDoc).getServerMeta)==null?void 0:o.call(e))!=null?r:{}}buildResourceUrl(e){return this.editor.doc.externalDoc.buildResourceUrl(e)}request(){Dn()}broadcastMessage(){Dn()}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new Zl}destroy(){this.clearCallbacks()}transformBlockIndex(e,o,r){const i=this.doc.blocks[e];d(Tn,i,`no container blocks: ${e}`);let s=0;for(let l=0;l<i.length;l++)if(!i[l].deletedBy){if(s===o)return l;s++}return r?(d(Tn,!1,`invalid block index: ${o}, blocks: ${JSON.stringify(i)}`),-1):(d(Tn,s===o,`invalid block index: ${o}, blocks: ${JSON.stringify(i)}`),i.length)}onDeleteBlock(e,o,r){const i=this.transformBlockIndex(e,o,!0),l=this.doc.blocks[e][i];d(Tn,!l.deleted,`block has already deleted: ${e}/${o}`),l.deletedBy=r,this.callbacks.forEach(c=>{var a;return(a=c.onUpdateBlockData)==null?void 0:a.call(c,e,i,{insert:{},delete:[]},!0)})}onInsertBlock(e,o,r,i){const s=this.transformBlockIndex(e,o,!1),l=this.doc.blocks[e],c=Y.default(r);c.insertedBy=i,l.splice(s,0,c),this.callbacks.forEach(a=>{var h;return(h=a.onInsertBlock)==null?void 0:h.call(a,e,s,c,!0)})}onUpdateBlockText(e,o,r,i){const s=this.transformBlockIndex(e,o,!0),c=this.doc.blocks[e][s];d(Tn,!c.deleted,`block has already deleted: ${e}/${o}`);const a=c.text;d(Tn,a,`no text for block: ${JSON.stringify(c)}`);const h=RN(a,r,i);c.text=h,this.callbacks.forEach(f=>{var m;return(m=f.onUpdateBlockText)==null?void 0:m.call(f,e,o,r,!0)})}onUpdateBlockData(e,o,r,i){const s=this.transformBlockIndex(e,o,!0),l=this.doc.blocks[e],c=l[s];d(Tn,!c.deleted,`block has already deleted: ${e}/${o}`);const a=Y.default(c);a.updatedBy=i,r.delete.forEach(h=>delete a[h]),Object.entries(r.insert).forEach(([h,f])=>{a[h]=f}),l[s]=a,this.callbacks.forEach(h=>{var f;return(f=h.onUpdateBlockData)==null?void 0:f.call(h,e,s,r,!0)})}onCreateContainer(e,o,r){this.doc.blocks[e]=Y.default(o),this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,e,o,!0)})}}const{t:c9}=S;function ai(n,t){return t==="insert"?c9("version.insert",{name:n.displayName}):c9("version.delete",{name:n.displayName})}function sr(n,t){const{userId:e}=t;return["flag","selection"].reduce((r,i)=>{const s=n.doc.getRemoteUsers().getFixedUserColor(e,i);return r[i]=s,r},{})}class AN{renderText(t,e,o){if(!o.box&&o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=sr(t,o.insertedBy);return{classes:["history-inserted-text"],attributes:{"history-inserted-by":r.displayName,"data-op-description":ai(r,"insert")},styles:{[si]:i,[li]:s}}}return{}}renderBlock(t,e,o){if(o.deletedBy){const r=o.deletedBy,{flag:i,selection:s}=sr(t,r);return{classes:["history-deleted-block"],attributes:{"history-deleted-by":r.displayName,"data-op-description":ai(r,"delete")},styles:{[si]:i,[li]:s}}}if(o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=sr(t,r);return{classes:["history-inserted-block"],attributes:{"history-inserted-by":r.displayName,"data-op-description":ai(r,"insert")},styles:{[si]:i,[li]:s}}}return{}}updateBlock(t,e,o,r){if(r.deletedBy){const i=r.deletedBy,{flag:s,selection:l}=sr(t,i);M(o,"history-deleted-block"),Za(o,{"history-inserted-by":i.displayName,"data-op-description":ai(i,"delete")}),Ya(o,{[si]:s,[li]:l});return}if(r.insertedBy){const i=r.insertedBy,{flag:s,selection:l}=sr(t,i);M(o,"history-inserted-block"),Za(o,{"history-inserted-by":i.displayName,"data-op-description":ai(i,"insert")}),Ya(o,{[si]:s,[li]:l})}}}const a9=w("history-deleted-box");function _N(n,t,e,o){const r=o;d(a9,r.text,`no text for text box data: ${JSON.stringify(o)}`),d(a9,typeof r.text=="string",`invalid text type for text box data: ${JSON.stringify(o)}`);const i=b("span",["history-deleted-box"],e,r.text),s=r.user,{flag:l,selection:c}=sr(n,s);i.setAttribute("history-deleted-by",s.displayName),i.setAttribute("data-op-description",ai(s,"delete")),i.style.setProperty(si,l),i.style.setProperty(li,c)}const NN={boxType:"history-deleted-box",updateBoxContent:_N},ve=w("version-dialog");class PN{constructor(t,e){u(this,"editor");u(this,"dialog",null);u(this,"oldViewer",null);u(this,"versionOptions");u(this,"versionList",null);u(this,"actionButtons",null);u(this,"provider");u(this,"components");u(this,"handleClose",()=>{var t;(t=this.dialog)==null||t.hide()});u(this,"handlePlay",()=>{var e;d(ve,this.versionList,"The versionList did not render");const t=(e=this.versionList)==null?void 0:e.activeVersion;d(ve,t,`The version: ${t} is invalid`),this.viewVersion(t,{play:!0,speed:150})});u(this,"handleRevert",async()=>{var e,o;d(ve,this.versionList,"The versionList did not render");const t=(e=this.versionList)==null?void 0:e.activeVersion;d(ve,t,`The version: ${t} is invalid`),await this.versionHelper.revertVersion(t.version),(o=this.dialog)==null||o.hide()});u(this,"handleSelectVersion",t=>{d(ve,t,`The version: ${t} is invalid`),this.viewVersion(t)});u(this,"viewVersion",async(t,e={play:!1,speed:1e3})=>{var C,v,k;this.oldViewer&&(this.oldViewer.destroy(),this.oldViewer=null),d(ve,this.versionList,"The versionList did not render"),d(ve,this.actionButtons,"The actionButtons did not render");const o=t.type==="minor"?this.versionList.beforeVersion:this.versionList.beforeMajorVersion,r=o?o.version:0,i=this.versionList.isSelectedFirstVersion,s=this.versionList.isSelectedLastVersion;this.actionButtons.revertButton.disabled=i,this.actionButtons.playButton.disabled=i;let l=(C=this.versionOptions)==null?void 0:C.hideOps;if((v=this.versionOptions)!=null&&v.onWillChangeVersion){const E=this.versionOptions.onWillChangeVersion(this.editor,t,i,s);E!=null&&E.hideOps&&(l=!0)}let c,a;if(l)c=await this.versionHelper.getVersion(t.version),a=[];else{const E=await this.versionHelper.getHistoryData(t.version,r);c=E.doc,a=E.historyData}const{editorElement:h}=this.components;h.innerHTML="";const f=new ON(c,this.editor),m=this.provider.createHistoryEditor(h,f);m.editorBlockRenders.registerRender(new AN),m.editorBoxes.registerBoxClass(NN),M(m.rootElement,t9.HISTORY);try{await vN(f,this.versionHelper,a,e)}finally{this.oldViewer=m}(k=this.versionOptions)!=null&&k.onVersionChanged&&this.versionOptions.onVersionChanged(this.editor,m,t,i,s)});u(this,"setShowOps",t=>{var e;if(this.versionOptions){this.versionOptions.hideOps=!t;const o=(e=this.versionList)==null?void 0:e.activeVersion;d(ve,o,`The version: ${o} is invalid`),this.viewVersion(o)}});this.editor=t,this.provider=e;const o=b("div",["version-dialog"],null),r=b("div",["version-dialog-note-viewer"],o),i=b("div",["version-dialog-action-container"],r),s=b("div",["version-dialog-editor"],r),l=b("div",["version-dialog-versions-list"],o);this.components={root:o,editorElement:s,actionContainer:i,versionsListContainer:l}}get versionHelper(){d(ve,this.editor.doc.getVersionHelper,"Can not get getVersionHelper from doc");const t=this.editor.doc.getVersionHelper();return d(ve,t,"current doc does not support version"),t}renderContent(t){var s,l;const{actionContainer:e,versionsListContainer:o}=this.components;e.innerHTML="";const r=new kN({onBack:this.handleClose,onPlay:this.handlePlay,onRevert:this.handleRevert});r.render(e,(s=this.versionOptions)==null?void 0:s.hideActions),this.actionButtons=r,o.innerHTML="";const i=new pN({versions:t,useCreatedBy:(l=this.versionOptions)==null?void 0:l.useCreatedBy,onSelectVersion:this.handleSelectVersion,getMarkColor:c=>{const{flag:a}=sr(this.editor,c);return a}});i.render(o),this.versionList=i}initViewVersion(){var t;if((t=this.versionOptions)!=null&&t.initSelectedVersion){d(ve,this.versionList,"The versionList did not render");const{initSelectedVersion:e}=this.versionOptions,o=this.versionList.selectVersionByVersionNum(e);d(ve,o,`The version: ${o} is invalid`),this.viewVersion(o)}else{d(ve,this.versionList,"The versionList did not render");const e=this.versionList.activeVersion;d(ve,e,`The version: ${e} is invalid`),this.viewVersion(e)}}async show(t){this.versionOptions={...this.versionOptions,...t};const e=await this.versionHelper.getVersions();if(this.versionOptions.hideNonVersionedOps&&e.length&&e[0].version===-1&&e.shift(),this.versionOptions.onVersionsLoaded&&this.versionOptions.onVersionsLoaded(this.editor,e),this.renderContent(e),this.initViewVersion(),!this.dialog){const{root:o}=this.components;this.dialog=new gN(o)}this.dialog.show(t.container)}destroy(){var t,e,o;(t=this.dialog)==null||t.destroy(),(e=this.versionList)==null||e.destroy(),(o=this.actionButtons)==null||o.destroy()}}function $N(n,t,e){const o=n.addCustom("version-dialog",()=>new PN(n,t));return o.show(e),{setShowOps:o.setShowOps}}const Cz="",HN=w("heading-collapse");function of(n){var e;const t=Number.parseInt((e=n.getAttribute("data-style-heading"))!=null?e:"",10);return d(HN,t,"not a heading block"),t}function je(n){return!!n.getAttribute("data-style-heading")}function jN(n){return!lt(n,"heading-collapsed")}function lr(n){return lt(n,"heading-collapsed")}function d9(n){if(gt(n))return!1;const e=H(n);return Ct(e)}const FN=w("heading-collapse");function rf(n){d(FN,je(n),"not a heading block");const t=[],e=of(n);let o=ht(n);for(;o&&!(je(o)&&of(o)<=e);)t.push(o),o=ht(o);return t}function u9(n,t){if(!Vo(t))return;n.selection.selectBlock(t,0),rf(t).forEach(o=>{Tm(o)}),M(t,"heading-collapsed")}function di(n,t){rf(t).forEach(o=>{Dm(o)}),F(t,"heading-collapsed")}function zN(n,t){jN(t)?u9(n,t):di(n,t)}const UN=[Xd,tu,eu,nu,ou,ru,iu,su];function VN(n){const t=b("button",["heading-collapse-button"],null);return t.setAttribute(`data-editor-tooltip-${n.clientId}`,"Collapse / Expand"),t.innerHTML=ic,t}function h9(n){return Qc(n).querySelector("button.heading-collapse-button")}function f9(n,t){h9(t)||d9(t)||!Vo(t)||wh(t,VN(n),-1)}function qN(n){var t;(t=h9(n))==null||t.remove()}function m9(n,t){Qc(t).querySelector("button.heading-collapse-button")||f9(n,t)}function WN(n){const t=of(n),e=b("button",["heading-marker"],null);return e.innerHTML=UN[t-1],e}function g9(n){return Qc(n).querySelector("button.heading-marker")}function sf(n){g9(n)||d9(n)||!Vo(n)||wh(n,WN(n),1)}function p9(n){const t=g9(n);t==null||t.remove()}function C9(n){p9(n),je(n)&&sf(n)}class GN{handleDrop(t,e,o,r){if(cl(e)||!je(e)||!lr(e))return;const i=rf(e);i.unshift(e);const s=i.reverse();let l=null;return t.doc.beginBatchUpdate(),s.forEach((c,a,h)=>{const f=t.getBlockData(c),m=zo(t.editorBlocks,t.doc.toJSON(),f),C=t.insertDocAt(o,r,m)[0];a===h.length-1&&(l=C)}),t.doc.endBatchUpdate(),t.doc.beginBatchUpdate(),s.forEach(c=>{t.deleteBlock(c)}),t.doc.endBatchUpdate(),l&&u9(t,l),!0}}const ZN=w("heading-collapse");class YN{constructor(t){u(this,"handleLoad",()=>{this.showCollapseButtons()});u(this,"handleHoverBlock",(t,e)=>{e&&(F(e,"hovering-heading"),je(e)&&Ct(H(e))&&(sf(e),lr(e)||qN(e))),t&&je(t)&&Ct(H(t))&&(M(t,"hovering-heading"),p9(t),f9(this.editor,t))});u(this,"handleClick",(t,e)=>{const o=Ei(e,"button.heading-collapse-button");if(!o)return;const r=z(o);!r||(d(ZN,je(r),"not a heading block"),zN(this.editor,r),m9(this.editor,r))});this.editor=t,t.addListener("load",this.handleLoad),t.addListener("click",this.handleClick),_t.get(t).addListener("change",this.handleHoverBlock),this.showCollapseButtons(),setTimeout(()=>{Ds.get(t).addHandler(new GN)})}showCollapseButtons(){const t=Ot(this.editor.rootContainer).filter(je);t.length!==0&&(t[0]===Kt(this.editor.rootContainer)&&t.splice(0,1),t.forEach(sf))}destroy(){this.editor.removeListener("load",this.handleLoad),this.editor.removeListener("click",this.handleClick)}}function ma(n){const t=n.selection.range;if(t.isCollapsed()||t.start.blockId===t.end.blockId)return;const e=n.getBlockById(t.start.blockId),o=n.getBlockById(t.end.blockId);lr(e)&&di(n,e),lr(o)&&di(n,o)}function QN(n){ma(n);const t=n.getFocusedBlock();!je(t)||lr(t)&&di(n,t)}function KN(n){ma(n);const t=n.getFocusedBlock();if(!je(t))return;const e=n.selection.range.focus;!e.isSimple()||e.offset===Z(n,t)&&lr(t)&&di(n,t)}function JN(n){ma(n);const t=n.getFocusedBlock();if(!je(t))return;const e=n.selection.range.focus;!e.isSimple()||e.offset===0&&lr(t)&&di(n,t)}class XN{handleBeforeKeyDown(t,e){return Xa(e.key)&&ma(t),e.key==="Enter"?(QN(t),!1):e.key==="Delete"?(KN(t),!1):(e.key==="Backspace"&&JN(t),!1)}}class tP{constructor(t){this.editor=t}onInsertBlock(t,e,o,r){this.updateBlockIfNeeded(o.id)}onUpdateBlockData(t,e,o,r){const i=this.editor.doc.getBlockData(t,e);this.updateBlockIfNeeded(i.id,o)}updateBlockIfNeeded(t,e){setTimeout(()=>{const o=this.editor.findBlockById(t);if(!!o){if(!je(o)){e&&e.delete.includes("heading")&&C9(o);return}lt(o,"hovering-heading")&&m9(this.editor,o),C9(o)}},100)}}function eP(n){return!!n.heading}function b9(n){var e;const t=n.heading;return(e=Number.parseInt(`${t}`,10))!=null?e:1}function v9(n,t){var e;return{parentNode:t,children:[],text:kt((e=n.text)!=null?e:[]),level:b9(n),block:n}}class Ps{constructor(){u(this,"nodes",[])}appendBlock(t){const e=this.findParent(b9(t),this.nodes);e?e.children.push(v9(t,e)):this.nodes.push(v9(t,null))}findParent(t,e){const o=e[e.length-1];if(!o||t<=1)return null;if(o.level===t-1)return o;const r=this.findParent(t,o.children);return r||(o.level<t?o:null)}static buildToc(t){const e=new Ps,o=t.blocks.root;for(let r=0;r<o.length;r++){const i=o[r];eP(i)&&e.appendBlock(i)}return e}}class cr extends Wt.TypedEmitter{constructor(e){super();u(this,"toc",new Ps);u(this,"updateToc",Qt.default(()=>{this.updateTocNow()},500));this.editor=e,e.doc.registerCallback(this),this.updateToc()}destroy(){this.editor.doc.unregisterCallback(this)}isHeadingBlock(e){return!!e.heading}onInsertBlock(e,o,r,i){e==="root"&&this.isHeadingBlock(r)&&this.updateToc()}onDeleteBlock(e,o,r){e==="root"&&this.updateToc()}onUpdateBlockText(e,o,r,i){if(e!=="root")return;const s=this.editor.doc.getBlockData(e,o);this.isHeadingBlock(s)&&this.updateToc()}onUpdateBlockData(e,o,r,i){if(e!=="root")return;const s=this.editor.doc.getBlockData(e,o);this.isHeadingBlock(s)&&this.updateToc()}static register(e){return e.addCustom("editor-toc",()=>new cr(e))}static get(e){return e.getCustom("editor-toc")}updateTocNow(){this.toc=Ps.buildToc(this.editor.doc.toJSON()),this.emit("change",this.editor,this.toc)}}const bz="";function nP(n){return n.nodes.length===0?!0:n.nodes.length>1?!1:n.nodes[0].children.length===0}function lf(n,t){t.forEach(e=>{const o=b("div",["toc-node"],n),r=b("div",["toc-title"],o);if(b("span",["toc-text"],r,e.text).setAttribute("data-block-id",e.block.id),e.children.length>0){const s=b("div",["toc-children"],o);lf(s,e.children)}})}function oP(n,t){const e=Ei(t,".toc-text");if(!e)return;const o=e.getAttribute("data-block-id");if(!o)return;const r=n.findBlockById(o);!r||(t.preventDefault(),t.stopPropagation(),n.selection.selectBlock(r,0))}function y9(n,t,e){if(F(t,"loading"),t.innerHTML="",nP(e)){b("div",["toc-empty-message"],t,"No toc");return}e.nodes.length===1?lf(t,e.nodes[0].children):lf(t,e.nodes),Sd(n,"toc-click-handler",()=>{n.addListener("click",oP)})}class rP{constructor(t){u(this,"handleUpdateToc",(t,e)=>{Array.from(t.rootContainer.querySelectorAll('.embed-block[data-type="editor-block"][data-embed-type="toc"]')).forEach(r=>{const i=r.querySelector(".editor-toc-container");i&&y9(t,i,e)})});this.editor=t,cr.register(t).addListener("change",this.handleUpdateToc)}destroy(){cr.register(this.editor).removeListener("change",this.handleUpdateToc)}get toc(){return cr.register(this.editor).toc}}function iP(n,t){const e=b("div",["editor-toc-container"],t),r=n.addCustom("init-editor-toc",()=>new rP(n)).toc;r.nodes.length===0?M(e,"loading"):y9(n,e,r)}function sP(n,t,e,o){return o==="markdown"?"[toc]":""}function lP(n,t,e){const{data:o}=e;if(!o||o.embedType!=="toc"||!j(n,t))return null;const r={};return{blockData:{id:N(),type:"embed",embedType:"toc",embedData:r}}}const k9={embedType:"toc",createEmbedContent:iP,convertTo:sP,convertFrom:lP};function cP(n){return!!n.getAttribute("data-style-heading")}function cf(n,t){return cP(t)&&Z(n,t)>0}function aP(n){const t=Nn(n.rootElement);let e=0,o=0,r=0;if(t===document.documentElement){const i=n.rootContainer.getBoundingClientRect();e=i.left+i.width/2,o=10,r=t.offsetHeight}else{const i=t.getBoundingClientRect();e=i.left+i.width/2,o=i.top+10,r=i.bottom}for(;o<r;){const i=document.elementsFromPoint(e,o);for(let s=0;s<i.length;s++){const l=z(i[s]);if(l&&n.rootContainer.contains(l))return l}o+=10}return null}function af(n,t){let e=t;for(;e&&!cf(n,e);)e=ht(e);return e}function w9(n){if(gt(n))return!1;const e=H(n);return Ct(e)}function ga(n,t){let e=t;for(;e&&!cf(n,e);)e=gt(e),e&&w9(e)&&(e=null);return e}const dP=.3;class uP extends Wt.TypedEmitter{constructor(e){super();u(this,"scrollContainer");u(this,"scrollEventTarget");u(this,"scrollStatus",{curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null});u(this,"handleScroll",Qt.default(()=>{const e={curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null};let o=aP(this.editor);if(o&&(o=fl(o)),!o||!this.scrollContainer){this.setStatus(e);return}if(w9(o)&&(o=ht(o)),!o){this.setStatus(e);return}if(cf(this.editor,o)){e.curHeadingBlock=o,e.previousHeadingBlock=ga(this.editor,o),e.nextHeadingBlock=af(this.editor,o),this.setStatus(e);return}const r=this.scrollContainer.getBoundingClientRect(),i=af(this.editor,o);if(i){const l=i.getBoundingClientRect();if(l.top>r.top&&l.top<r.top+r.height*dP){e.curHeadingBlock=i,e.previousHeadingBlock=ga(this.editor,i),e.nextHeadingBlock=af(this.editor,i),this.setStatus(e);return}e.nextHeadingBlock=i}const s=ga(this.editor,o);s&&(e.curHeadingBlock=s,e.previousHeadingBlock=ga(this.editor,s)),this.setStatus(e)},200));this.editor=e,setTimeout(()=>{this.start()},50)}setStatus(e){this.scrollStatus.previousHeadingBlock===e.previousHeadingBlock&&this.scrollStatus.nextHeadingBlock===e.nextHeadingBlock&&this.scrollStatus.previousHeadingBlock===e.previousHeadingBlock||(this.scrollStatus=e,this.emit("change",this.editor,e))}start(){this.stop(),this.scrollContainer=Nn(this.editor.rootElement),this.scrollEventTarget=this.scrollContainer===document.documentElement?document:this.scrollContainer,this.scrollEventTarget.addEventListener("scroll",this.handleScroll),this.handleScroll()}stop(){this.scrollEventTarget&&this.scrollEventTarget.removeEventListener("scroll",this.handleScroll)}destroy(){this.stop(),this.scrollEventTarget=void 0}}class hP{constructor(t,e){u(this,"suggest");u(this,"onShow",(t,e,o,r)=>{const i=this.editor.getBlockByIndex(e,o);if(!Vo(i)){const s=z(H(i));if(s&&it(s)==="code")return!1}return!0});u(this,"onClickItem",(t,e,o)=>{const r=e.data,i={id:N(),type:"mention",box:!0,created:Date.now(),iconUrl:r.avatarUrl,text:r.displayName,mentionId:r.userId},s=this.editor.selection.range;if(!s.isCollapsed()||!s.isSimple())return;const l=s.focus,c=this.editor.getBlockById(l.blockId);this.editor.insertBoxToBlock(c,l.offset,i)});u(this,"queryItems",async(t,e)=>(await this.options.queryUsers(this.editor,e)).map(i=>({id:i.userId,name:i.displayName,icon:`<img src="${i.avatarUrl}" class="mention-user-avatar">`,element:i.element,data:i})));this.editor=t,this.options=e,this.suggest=new mu(t,{id:"editor-mention",trigger:["@"],autoDeleteTrigger:!0,showLoading:!0,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}destroy(){}}w("mathjax-box");function fP(n,t,e,o){const r=o,i=b("a",["mention-container"],e);b("span",["mention-name"],i,`@${r.text}`),i.setAttribute("data-mention-id",r.mentionId)}function mP(n,t,e){}const B9={boxType:"mention",updateBoxContent:fP,handleClickBox:mP};function gP(n){return kn("list-block-mention",S.t("list.mention.tooltip"),sp,[],n.clientId)}class pP{constructor(t){u(this,"mentionButton");u(this,"handleHoveringBlock",t=>{var e;!this.editor.isWritable()||(t&&this.shouldBlockShowMention(t)?At(t).appendChild(this.mentionButton):(e=this.mentionButton)==null||e.remove())});u(this,"handleMouseDown",(t,e)=>{e.preventDefault(),e.stopPropagation();const o=z(this.mentionButton);if(!o||!j(t,o))return;const r=t.selection.range.focus;if(!r.isSimple())return;let i;t.selection.focusedBlock!==o?i=Z(t,o):i=r.offset,setTimeout(()=>{const s=t.insertTextToBlock(o,i,"@");i+=1;const l=kt(fe(s,i).left);this.editor.selection.selectBlock(o,i),this.editor.focus(),t.getCustom("mention").suggest.popup(o,i,l,"@")})});u(this,"destroy",()=>{_t.get(this.editor).removeListener("change",this.handleHoveringBlock)});this.editor=t,this.mentionButton=gP(t),_t.get(this.editor).addListener("change",this.handleHoveringBlock),t.domEvents.addEventListener(this.mentionButton,"mousedown",this.handleMouseDown)}shouldBlockShowMention(t){if(!j(this.editor,t)||!at(t))return!1;const e=He(t);return!(e==="ordered"||e==="unordered")}}const vz="",CP={templates:{title:"\u9009\u62E9\u6A21\u677F\uFF0C\u5FEB\u901F\u521B\u5EFA",create:"\u65B0\u5EFA\u6A21\u677F",choose:"\u5168\u90E8\u6A21\u677F",customizedMark:"\u81EA\u5B9A\u4E49"}},bP={templates:{title:"Choose a template",create:"New template",choose:"All templates",customizedMark:"Custom"}};S.mergeLang({"zh-CN":CP,"en-US":bP});const yz="",vP="data:image/svg+xml;base64,Cj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gZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K",E9=w("templates");function df(n){const t=n.rootElement.querySelector(":scope .editor-templates");if(!t)return null;const e=t.querySelector(":scope .editor-templates-cards");return d(E9,e,"no card container"),{root:t,cardContainer:e}}function kP(n){const t=df(n);if(t)return t.cardContainer.innerHTML="",t;const e=b("div",["editor-templates"],n.rootElement);b("div",["editor-templates-title"],e,S.t("templates.title"));const o=b("div",["editor-templates-cards"],e);return{root:e,cardContainer:o}}function I9(n,t,e,o,r){var f;const i=(f=n.options.componentsOptions)==null?void 0:f.templates,s=b("div",["editor-template-card",...o],null),l=b("div",["editor-template-thumb-container"],s),c=b("img",["editor-template-thumb"],l);c.src=t,c.style.display="none",c.onerror=()=>{var C;const m=(C=i==null?void 0:i.placeHolderImageSrc)!=null?C:yP;c.src!==m&&(c.src=m)},c.onload=()=>{c.style.display=""};const a=b("div",["editor-template-name"],s),h=b("span",[],a,e);return i!=null&&i.showTemplateTitleAttr&&h.setAttribute("title",e),s.onclick=()=>r(s),s}function wP(n,t){return t.thumbnailUrl?t.thumbnailUrl:n.doc.buildResourceUrl("thumbnail.png")}function BP(n,t){const e=wP(n,t);return I9(n,e,t.name,[],async()=>{var r,i;const o=(r=n.options.componentsOptions)==null?void 0:r.templates;(i=o==null?void 0:o.onApplyTemplate)==null||i.call(o,n,t)})}function EP(n,t){return I9(n,t,S.t("templates.choose"),["more"],()=>{var o,r;const e=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=e==null?void 0:e.onChooseTemplate)==null||r.call(e,n)})}function IP(n,t){var f,m;const e=(f=n.options.componentsOptions)==null?void 0:f.templates;if(!e)return;const r=Gt(n.rootContainer).getBoundingClientRect().width;let i=1;const s=vP,l=df(n);if(l){if(t!=null&&t.reset){const C=Array.from(l.cardContainer.children),v=l.cardContainer.firstElementChild;if(d(E9,v,"no first card"),lt(v,"new")||lt(v,"more"))return;const k=window.getComputedStyle(v),E=parseFloat(k.marginLeft),L=parseFloat(k.marginRight),x=v.getBoundingClientRect().width+E+L;i=Math.floor(r/x);const A=Math.max(1,i-1-1),P=C.length-2;C.forEach((V,nt)=>{nt>A&&nt<P?V.style.display="none":(nt>=P&&lt(V,"more"),V.style.display="")})}return}const c=e.templates,{cardContainer:a}=kP(n);c.forEach((C,v)=>{const k=BP(n,C);if(v>0&&v>=i&&(k.style.display="none"),a.appendChild(k),v===0){const E=window.getComputedStyle(k),L=parseFloat(E.marginLeft),x=parseFloat(E.marginRight),O=k.getBoundingClientRect().width+L+x;i=Math.floor(r/O)-1}});const h=EP(n,s);a.appendChild(h),(m=e==null?void 0:e.onTemplateChooserStatusChanged)==null||m.call(e,n,a,"visible")}const x9=Qt.default(IP,50);function xP(n){var o,r;const t=df(n);if(!t)return;t.root.remove();const e=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=e==null?void 0:e.onTemplateChooserStatusChanged)==null||r.call(e,n,null,"hide")}function SP(n){const t=n.blocks.root;if(t.length===0)return!0;if(t.length>5)return!1;const e=[...t];e[0].type==="text"&&e[0].heading&&e.splice(0,1);const o=r=>{var i;return r.type!=="text"&&r.type!=="list"?!1:r.text?((i=r.text)==null?void 0:i.length)===0:!0};return e.every(r=>o(r))}function uf(n,t){SP(n.doc.toJSON())?x9(n,t):(x9.cancel(),xP(n))}class $s{constructor(t,e){u(this,"_decrypted",!1);this.editor=t,this.blockData=e}get decrypted(){return this._decrypted||this.blockData.owner===this.editor.doc.getUser().userId}setDecrypted(){this._decrypted=!0}destroy(){}static getState(t,e){return t.addCustom(`encrypted-block-${e.id}`,()=>new $s(t,e))}}const kz="",bo=w("encrypted-block");function TP(n,t,e,o,r){const i=r,s=no(o,"div"),l=$s.getState(n,i);if(l.decrypted)n.createChildContainer(t,s,i.children[0]),M(o,"decrypted");else{M(o,"encrypted");const c=At(o),a=b("div",["password-container"],c),h=b("input",[],a);h.type="text",h.onkeydown=f=>{if(f.key==="Enter"){const m=h.value;if(i.password===vi.default(`${i.owner}-${m}`)){l.setDecrypted(),n.reloadBlock(o);const C=E1(n,n.getBlockById(i.id));C&&(n.selection.selectBlock(C,0),n.focus())}}}}return s}function DP(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t)||!mn(r))return null;const i=r;if(n.getBlockData(t).children[0]!==U(i))return null;const l=bt(t,U(i));return new Qe(n,{anchor:l,focus:l})}function LP(n,t,e,o){if($s.getState(n,n.getBlockData(t)).decrypted)return null;if(o==="ArrowDown"||o==="ArrowRight"){const s=ht(t);return s?$(s,Z(n,s),"end"):$(t,1,"end")}const i=gt(t);return $(i||t,0,"home")}function MP(n,t){return n.getBoundingClientRect()}function RP(n,t,e,o){if(e.isSimple()){d(bo,o.isSimple(),"from is simple position but to is not simple position"),bo.debug("full select table"),M(t,"full-selected");return}d(bo,!o.isSimple(),"from is complex position but end is simple position");const r=e,i=o;d(bo,r.blockId===i.blockId,"only allow update one table selection"),d(bo,r.childContainerId===i.childContainerId,"only one container");const s=n.getBlockData(t),l=n.getContainerById(s.children[0]);M(l,"selected")}function OP(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="encrypted"]').forEach(t=>{F(t,"full-selected"),t.querySelectorAll("selected").forEach(e=>{F(e,"selected")})})}function AP(n,t){const e=n.getBlockData(t);return $s.getState(n,e).decrypted?[n.getContainerById(e.children[0])]:[]}function _P(n,t,e,o,r){return null}function NP(n,t,e,o){d(bo,e.blockId===o.blockId,"only allow select in single block"),d(bo,G(t)===e.blockId,"only allow select in single block");const r=n.getBlockData(t);return d(bo,e.childContainerId===r.children[0],"only one container"),[n.getContainerById(r.children[0])]}function PP(n){return{name:"EncryptedBlock",insertBlockCommandItems:[{id:"insert-encrypted-block",name:"Encrypted Block"}],async handleInsertEmptyBlock(t,e){const o=Cn(t.doc),r={id:N(),type:"encrypted",children:[o],owner:t.doc.getUser().userId,ownerDisplayName:t.doc.getUser().displayName,password:vi.default(`${t.doc.getUser().userId}-1234`)},i=t.doc.getContainerBlocks(o)[0];return t.insertBlock(e.containerId,e.blockIndex,r,Lt(t,i.id,0))}}}const $P={blockType:"encrypted",blockKind:"complex",enableKeyboardSelect:!0,createBlockContent:TP,getBlockTextLength:()=>1,getRangeFromPoint:DP,moveCaret:LP,getCaretRect:MP,updateSelection:RP,clearSelection:OP,getChildContainers:AP,getNextContainer:_P,getSelectedContainers:NP,getOptions:PP};function HP(n,t,e){const o=Ui(n,t,{components:{blocks:[bs,ks,$P],decorators:[new Bs],embeds:[ea,fh,Oh,Ah,_h,th,Nh,ef,tf],boxes:[Oc],options:{...e.componentsOptions}}});return o.readonly=!0,o}class jP{constructor(t){this.createOptions=t}createHistoryEditor(t,e){return HP(t,e,this.createOptions)}}w("create-editor");function S9({root:n,childDoc:t,doc:e}){t.uploadResource=e.uploadResource.bind(e),t.buildResourceUrl=e.buildResourceUrl.bind(e);const o=Ui(n,t,{shortcuts:[Wl],components:{blocks:[bs,ks],decorators:[new Bs],embeds:[E6,ea,fh,Oh,Ah,_h,th,Nh,ef,tf],boxes:[Oc,B9],options:{image:{defaultAlign:"left"}}}});return o.input.addHandler(new zc),o.input.addHandler(new Ph(o)),o.input.addHandler(new u_(o)),o}function FP(n,t){const e=Array.from(n.rootContainer.querySelectorAll(`[comment-${t.toLocaleLowerCase()}="${t}"]`)),o=new Set;e.forEach(r=>{const i=z(r);i&&o.add(i)}),o.forEach(r=>{h_(n,r,t)})}class zP{constructor(t){u(this,"listeners",new Set);u(this,"doc");this.editor=t,this.doc=this.editor.doc.externalDoc,this.doc.registerCallback(this)}getComments(){return this.doc.getComments()}getComment(t){return this.doc.getComment(t)}getCommentDoc(t){return this.doc.getCommentDoc(t)}localCreateComment(t,e){this.doc.localCreateComment(t,e)}localDeleteComment(t){const e=this.getComment(t);this.doc.localDeleteComment(t);const o=e.groupId;this.getComments().filter(i=>i.groupId===o).length===0&&FP(this.editor,o)}localUpdateComment(t,e){this.doc.localUpdateComment(t,e)}onCreateComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onCreateComment(t,e))}onDeleteComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onDeleteComment(t,e))}onUpdateComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onUpdateComment(t,e))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}createCommentEditor(t,e){return S9({root:t,childDoc:e,doc:this.doc})}}class UP{constructor(t,e){u(this,"listeners",new Set);this.editor=t,this.localDoc=e}get doc(){return this.localDoc.toJSON()}getComments(){return Object.values(this.doc.comments)}getComment(t){return this.doc.comments[t]}getCommentDoc(t){const e=this.doc.comments[t];return Ud(e)}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}localCreateComment(t,e){}localDeleteComment(t){}localUpdateComment(t,e){}createCommentEditor(t,e){return S9({root:t,childDoc:e,doc:this.localDoc})}}const VP={placeholder:{common:{title:"\u8BF7\u8F93\u5165\u6807\u9898",readonlyTitle:"\u8BF7\u8F93\u5165\u6807\u9898",content:"\u70B9\u51FB + \uFF0C\u6216\u8F93\u5165 / \u5FEB\u6377\u63D2\u5165\u7EC4\u4EF6"},local:{readonlyTitle:"\u672A\u547D\u540D"}}},qP={placeholder:{common:{title:"Enter a title",readonlyTitle:"Enter a title",content:'Click "+", or enter "/" to insert components quickly'},local:{readonlyTitle:"Untitled"}}};S.mergeLang({"zh-CN":VP,"en-US":qP});const hf=w("create-editor"),T9=[ea,fh,Oh,Ah,_h,th,Nh,ef,tf,E6,k9,Q_];async function WP(n,t){var s,l,c,a,h,f,m,C,v;d(hf,n,"app does not exists"),t.lang&&S.setLang(t.lang);const e=t.onReauth?async()=>{var x;const k=t.user.userId,E=t.docId,L=await((x=t.onReauth)==null?void 0:x.call(t,k,E,t.permission));return{userId:k,docId:E,permission:t.permission,appId:t.appId,token:L,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl}}:void 0,o={auth:{appId:t.appId,docId:t.docId,userId:t.user.userId,permission:t.permission,token:t.token,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl},serverUrl:t.serverUrl,reauthFunc:e,disableLogout:t.disableLogout},r=await ns.load(o),i=Ui(n,r,{id:t.id,components:{blocks:[bs,ks,vh,d4],commandProviders:[new Eu],decorators:[new Bs,new qd],embeds:[...T9,...((s=t.components)==null?void 0:s.embeds)||[]],boxes:[Oc,B9,U3],insertions:[z1],blockHooks:[new p6],textRenders:[new P3,new Cx],options:{...t.componentsOptions}},shortcuts:[ND,CM,ah,g3,bx,oh,Wl],colors:["#338FE5","#24B47E","#F0A100","#E52727","#9678D3","#2CB2AE","#EB6414","#8AAB3F"]});if(i.editorCommandProviders.registerCommandProvider(new Sn(i)),i.input.addHandler(new XN),i.input.addHandler(new zc),i.input.addHandler(new Yx),i.input.addHandler(new dM),i.input.addHandler(new ys(i,{headingLevel:1,titlePlaceholder:S.t("placeholder.common.title"),contentPlaceholder:S.t("placeholder.common.content"),readonlyTitlePlaceholder:S.t("placeholder.common.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),i.input.addHandler(new Ac(i,(l=t.componentsOptions)==null?void 0:l.quickMenu)),i.input.addHandler(new Ph(i)),i.input.addHandler(new s3(i)),i.doc.registerCallback(new tP(i)),i.addCustom("remote-cursor",()=>new a5(i)),i.addCustom("block-menu",k=>new y6(k)),i.addCustom("editor-tooltip",()=>new nh(i)),t!=null&&t.enableComments&&i.addCustom("editor-comments",k=>new N3(k,new zP(k))),i.addCustom("create-options",()=>new jf(i,t)),i.addCustom("drop-target",()=>new Ds(i)),i.addCustom("list-to-mindmap",()=>new Lc(i)),i.addCustom("list-to-mention",()=>new pP(i)),(c=t.componentsOptions)!=null&&c.mention){const k=t.componentsOptions.mention;i.addCustom("mention",()=>new hP(i,k))}if(i.addCustom("heading-collapse",()=>new YN(i)),Zr.register(i),Ds.register(i),cr.register(i),(h=(a=t.componentsOptions)==null?void 0:a.remoteCarets)!=null&&h.onUserChanged){const k=(m=(f=t.componentsOptions)==null?void 0:f.remoteCarets)==null?void 0:m.onUserChanged;i.doc.getRemoteUsers().on("change",E=>{k(i,E)})}return(v=(C=t.componentsOptions)==null?void 0:C.templates)!=null&&v.templates.length&&(i.addListener("docChanged",()=>{uf(i)}),i.addListener("resize",()=>{uf(i,{reset:!0})}),setTimeout(()=>{uf(i)},100)),i.doc.registerCallback({onError:async k=>{if(k.code==="ResetDoc"){hf.error(`reset doc: ${k.message}`);const E=await ns.load(o);i.doc.reset(E)}}}),i}function GP(n){return n.toJSON!==void 0}async function ZP(n,t,e){var i,s;d(hf,n,"app does not exists");const o=GP(t)?t:new xd(t);e.lang&&S.setLang(e.lang);const r=Ui(n,o,{id:e.id,components:{blocks:[bs,ks,vh,d4],commandProviders:[new Eu],decorators:[new Bs,new qd],embeds:[...T9,...((i=e.components)==null?void 0:i.embeds)||[]],boxes:[Oc,U3],insertions:[z1],blockHooks:[new p6],textRenders:[new P3],options:{...e.componentsOptions}},shortcuts:[ah,g3,oh,Wl]});return r.editorCommandProviders.registerCommandProvider(new Sn(r)),r.input.addHandler(new zc),r.input.addHandler(new ys(r,{headingLevel:1,titlePlaceholder:S.t("placeholder.common.title"),contentPlaceholder:S.t("placeholder.common.content"),readonlyTitlePlaceholder:S.t("placeholder.local.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),r.input.addHandler(new Ac(r,(s=e.componentsOptions)==null?void 0:s.quickMenu)),r.input.addHandler(new Ph(r)),r.input.addHandler(new s3(r)),r.addCustom("block-menu",l=>new y6(l)),r.addCustom("editor-tooltip",()=>new nh(r)),e!=null&&e.enableComments&&r.addCustom("editor-comments",l=>new N3(l,new UP(l,o))),Zr.register(r),r}function YP(n,t){var l;const e=n.doc;if(!((l=e.getVersionHelper)==null?void 0:l.call(e)))throw new Error("the editor does not support to show versions");const r=n.getCustom("create-options");if(!r)throw new Error("the editor does not support to show versions");const i=r.getData(),s=new jP(i);return $N(n,s,t)}g.AuthError=nc,g.AuthHeader=es,g.AutoScroll=wm,g.BaseURLHeader=oc,g.BlockResizer=Fc,g.BrBox=Kg,g.CodeBlock=ks,g.CodeLineBlock=vh,g.CodeTextDecorator=Bs,g.DefaultShortcuts=Wl,g.DocIdError=Cw,g.DragDrop=tm,g.DrawioEmbed=ea,g.EditorBlocks=sg,g.EditorBoxes=Xg,g.EditorCommandProviders=E0,g.EditorComplexBlockPosition=Ye,g.EditorComplexSelectionRange=Qe,g.EditorDecorators=o2,g.EditorEmbeds=cg,g.EditorInsertions=n2,g.EditorSimpleBlockPosition=Ut,g.EditorSimpleSelectionRange=se,g.EmbedBlock=dg,g.EnforceWithDocumentTitleHandler=ys,g.EventCallbacks=ki,g.FILL_CHAR=Lb,g.FileExtError=bw,g.HeadingBlockScrollListener=uP,g.InputtingInsertion=t2,g.LocalDoc=xd,g.Logger=hr,g.MIN_DISTANCE_THRESHOLD=Jf,g.MarkdownInputHandler=zc,g.MaxUserError=$d,g.OnesEditorCustomDataWrapper=jf,g.OnesEditorHoveringBlock=_t,g.OnesEditorQuickMenu=Ac,g.OnesEditorToc=Ps,g.OnesEditorTocProvider=cr,g.OnesEditorToolbar=Zr,g.OnesEditorTooltip=nh,g.PermissionError=pw,g.RemoteCarets=a5,g.RemoteCaretsDecorator=qd,g.RemoteCaretsInsertion=z1,g.RemoteUsers=Zl,g.RequestReloadError=ts,g.RichText=oe,g.ShareDBDoc=ns,g.SimpleCache=zf,g.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=$1,g.TEXT_STYLE_COLOR_PREFIX=P1,g.TableBlock=bs,g.TableBlockCommandProvider=Eu,g.TableShortcuts=ah,g.TextBlock=Ni,g.TextBox=Qg,g.TextStyleShortcuts=oh,g.TocEmbed=k9,g.ZERO_WIDTH_SPACE_CHAR=wi,g.addAttribute=Bl,g.addClass=M,g.addDays=sC,g.addMonths=iC,g.animateScrollTo=Ii,g.applyPlaceholderToBlock=Uc,g.assert=d,g.blockToDoc=rd,g.blockToHtml=U1,g.blockToMarkdown=r2,g.blockToText=Rl,g.blocksToDoc=iv,g.clearAllSelection=Qm,g.clientType=St,g.cloneBlock=zo,g.cloneChildContainer=X1,g.cloneDoc=td,g.cloneText=jg,g.commentToShareDbComment=Vd,g.compareElement=el,g.comparePosition=w1,g.complexBlockAdjustSelectionPos=pl,g.complexBlockFindNearestChildBlock=mg,g.complexBlockGeFirstSimpleChild=E1,g.complexBlockGetAllChildContainers=Me,g.complexBlockGetBottomChildContainers=fg,g.complexBlockGetLastSimpleChild=wr,g.complexBlockGetSelectedContainers=kr,g.complexBlockGetTopChildContainers=hg,g.containerToDoc=id,g.continuousScroll=km,g.convertBlockFrom=ml,g.copyBlockAttributes=f2,g.createBlockAnchor=No,g.createBlockContentElement=no,g.createBlockElement=Mm,g.createBlockSimpleDocRange=Ll,g.createBlockSimpleRange=Lt,g.createBoxContentElement=Am,g.createBoxElement=Rm,g.createBoxOp=Mg,g.createChildContainer=Gm,g.createComplexBlockPosition=bt,g.createComplexDocPos=Gg,g.createComplexDocRange=Rb,g.createContainer=Ug,g.createContainerElement=f1,g.createDeleteOps=Sg,g.createEditor=Ui,g.createEditorSelectionRange=Vt,g.createElement=b,g.createEmptyContainer=Cn,g.createEmptyDoc=ro,g.createEmptyTextBlockData=Sl,g.createExpandedRange=Xs,g.createIconButton=fr,g.createImage=Uf,g.createInsertOps=wl,g.createInsertionContentElement=Pm,g.createInsertionElement=_m,g.createLocalEditor=ZP,g.createOnesEditor=WP,g.createRange=Vf,g.createRichText=_i,g.createRootContainer=Wm,g.createSimpleBlockPosition=$,g.createSimpleDocPos=Wg,g.createTextBlockData=jn,g.createTextButton=tr,g.createTextOp=_e,g.createTextWithReplaceSoftReturn=O1,g.daysAfter=r1,g.deleteText=_1,g.diffDays=lC,g.disablePageScroll=mm,g.docToHtml=Wb,g.docToHtmlFragment=i2,g.docToMarkdown=Gb,g.docToText=s2,g.downloadObjectToFile=Th,g.downloadSvgToString=x6,g.editLink=wc,g.editorAddComment=m_,g.editorAddTextAttribute=S2,g.editorAutoInsertBlock=m2,g.editorBreakTextBlock=Lr,g.editorClearCompositionText=h2,g.editorClearSelectedContents=K1,g.editorCopyBlock=dd,g.editorDeleteBlock=Y1,g.editorDeleteBlockText=W1,g.editorDeleteBlockWithoutChildren=Z1,g.editorDeleteChildContainer=tv,g.editorDeleteChildContainers=b2,g.editorFocusToBlock=J1,g.editorFocusToEnd=M2,g.editorGetBlockData=io,g.editorGetBlockText=we,g.editorGetBlockTextEx=Al,g.editorGetBoxData=l2,g.editorHandleKeyboardEvent=i0,g.editorInsertBlock=Dr,g.editorInsertBoxToBlock=d2,g.editorInsertDoc=I2,g.editorInsertDocAt=ed,g.editorInsertText=q1,g.editorInsertTextToBlock=a2,g.editorInsertTextToBlockEx=V1,g.editorMergeTextBlock=v2,g.editorRangeClearColor=D2,g.editorRangeGetColor=nd,g.editorRangeSetColor=T2,g.editorRemoveTextAttribute=ov,g.editorReplaceBlockText=Hl,g.editorReplaceContainer=x2,g.editorRunOnce=Sd,g.editorSelectEnd=L2,g.editorSetTextColor=Mr,g.editorShowFindDialog=vA,g.editorUpdateBlockData=jl,g.editorUpdateCompositionText=u2,g.editorUpdateEmbedData=B2,g.enablePageScroll=gm,g.escapeHtmlText=Yf,g.escapeRegExp=l1,g.escapeSpace=z8,g.executeBlockCommand=ig,g.executeEmbedBlockCommand=rg,g.executeRangeCommand=B0,g.fileToDataUrl=rl,g.findAllText=F1,g.findInsertionById=Nm,g.findPrevSimpleBlockBeforeChildContainer=ug,g.findTarget=Ei,g.format=o1,g.formatBytes=Bm,g.formatDate=xm,g.fragmentToHtml=pm,g.fromBase64=ol,g.fromBase64ToBlob=um,g.fromBase64ToUint8Array=tC,g.fromDocRange=oo,g.fromNowString=s1,g.genId=N,g.getAllChildBlocks=x1,g.getAllQuickMenuItems=eh,g.getAllSelectedBlocks=Ke,g.getAttributesAt=Il,g.getBlockBackground=Lm,g.getBlockByIndex=mr,g.getBlockCaretRect=Ze,g.getBlockClass=yt,g.getBlockClassByType=vr,g.getBlockClientRects=Ao,g.getBlockCommandsWithHook=b1,g.getBlockContent=rt,g.getBlockId=G,g.getBlockIndex=K,g.getBlockKind=Ge,g.getBlockMinWidth=Jm,g.getBlockOptions=CC,g.getBlockPath=Oo,g.getBlockProperties=eg,g.getBlockStyles=gC,g.getBlockTextLength=Z,g.getBlockTools=At,g.getBlockType=it,g.getBoxContent=d1,g.getBoxId=Om,g.getBoxTypeFromElement=Ti,g.getChildBlockCount=Ve,g.getChildBlocks=Ot,g.getChildOffset=Er,g.getColorFromAttributes=j1,g.getComplexBlockClass=ke,g.getContainerBlockPath=Um,g.getContainerBlocks=Fm,g.getContainerBlocksElement=hl,g.getContainerById=br,g.getContainerId=U,g.getContainerMinWidth=p1,g.getContainerToolsElement=dC,g.getContainerWidth=tg,g.getDistanceSquare=fn,g.getElementOffset=Bi,g.getEmbedType=Le,g.getExistsBlockTools=ul,g.getExistsContainerById=Hm,g.getFileExt=bm,g.getFirstChildBlock=Kt,g.getFirstClientRect=tl,g.getHeadingMenuOptions=Rc,g.getHorizontalPadding=Wa,g.getInsertionContent=u1,g.getLastChildBlock=Gt,g.getLastClientRect=xo,g.getLogger=w,g.getNextBlock=ht,g.getNextValidOffset=Ir,g.getNextVisibleBlock=Cr,g.getOpAt=Og,g.getOpLength=N1,g.getParentBlock=z,g.getParentBox=a1,g.getParentContainer=H,g.getPrevBlock=gt,g.getPrevValidOffset=$o,g.getPrevVisibleBlock=pr,g.getRangeCommands=k0,g.getRootBlock=fl,g.getScrollContainer=Nn,g.getSpecialBlockCommands=ng,g.getTextBlockChild=Cl,g.getTextBlockClass=Ym,g.getTextBlockContentChildTextLength=Oe,g.getTextBlockContentChildType=gg,g.getTextBlockContentChildren=Hn,g.getTextLength=ce,g.getTextOpLength=T1,g.getTextWidth=sl,g.getToolbar=kc,g.handleBlockElementUpdated=Xm,g.hasAltOnly=Z8,g.hasClass=lt,g.hasCtrlOrCmd=lm,g.hasCtrlOrCmdOnly=G8,g.hideBlock=Tm,g.htmlToFragment=il,g.i18n=S,g.injectStyle=Kf,g.insertEmptyBlock=vC,g.insertEmptyEmbedBlock=v1,g.insertText=xr,g.intersectionCommands=dk,g.isBackspace=am,g.isBlock=gr,g.isBox=c1,g.isCJK=rm,g.isChildContainer=We,g.isChildNode=vt,g.isCollapsedRange=qg,g.isComplexBlockPosition=k1,g.isComplexKindBlock=ct,g.isContainer=mn,g.isControlEvent=Do,g.isDelete=Q8,g.isDraggingFiles=cl,g.isEmbedBlock=De,g.isEmptyContainer=C1,g.isEmptyDoc=Tl,g.isEmptyTextBlock=Et,g.isEmptyTextBlockWithoutCompositionText=vs,g.isEnterOnly=cm,g.isEscape=t1,g.isFirefox=Ja,g.isFirstChildBlockInComplexBlock=WC,g.isHighSurrogate=N8,g.isInBlock=h1,g.isInBlockTools=Di,g.isLetter=om,g.isLowSurrogate=qa,g.isMatchShortcut=_n,g.isMoveForward=q8,g.isNavigationEvent=V8,g.isNavigationKey=sm,g.isNodeRemoved=Wf,g.isNumber=nm,g.isPrintableKey=Xa,g.isRootBlock=Vo,g.isRootContainer=Ct,g.isSafari=im,g.isSameDay=i1,g.isShiftEnter=Y8,g.isShiftTab=J8,g.isShortcutEvent=W8,g.isSimpleBlock=pC,g.isSimpleBlockPosition=yr,g.isSimplePos=Vg,g.isSimpleRange=Dl,g.isSpace=nl,g.isTab=K8,g.isTextBlockContentBoxChild=Re,g.isTextBlockContentChild=Mi,g.isTextBlockContentInsertionChild=$n,g.isTextBlockContentTextChild=Ri,g.isTextKindBlock=j,g.isTextKindBlockType=Li,g.isToday=Em,g.isValidOffset=me,g.isVisibleBlock=dl,g.isYesterday=Im,g.loadJs=Gf,g.loadJsPromise=So,g.lockers=Ue,g.mergeCommands=yc,g.mergeDocs=Fo,g.mergeOps=A1,g.mergeText=xb,g.multiSplitText=bg,g.parseShortcut=dm,g.patchNode=Si,g.pointInRect=To,g.rangeAddAttribute=El,g.rangeGetTextColor=Hg,g.rangeRemoveAttribute=Sr,g.rangeSetTextColor=Ng,g.rangeTransformText=Ag,g.registerDragDrop=Qa,g.removeAttribute=H1,g.removeClass=F,g.removeLastBr=wb,g.removePlaceholderFromBlock=W4,g.removeStyle=Qf,g.replaceAll=cC,g.replaceAllCaseInsensitive=aC,g.replaceAllText=zg,g.replaceText=xl,g.requestDownload=al,g.scrollable=ym,g.selectFile=Mo,g.selectedBlockToDoc=zl,g.selectionToDoc=Ul,g.setAttributes=Za,g.setClipboardData=ll,g.setClipboardDataByEvent=rC,g.setColorToAttributes=Pg,g.setDataset=Ga,g.setDefaultCursor=xi,g.setStyles=Ya,g.shareDBCommentToDocObject=Ud,g.shareDBDocCommentToComment=l5,g.shortcutToDisplayText=X8,g.showBlock=Dm,g.showDocVersions=YP,g.splitText=fe,g.splitToThree=Jt,g.stringToDataUrl=hm,g.stringToObjectUrl=n1,g.subText=vg,g.textNodeOffsetFromPoint=qf,g.toBase64URL=Lo,g.toPlainText=kt,g.trimChar=Ka,g.unicodeLength=P8,g.unicodeSubstr=$8,g.updateBlockSelection=Km,g.updateOpAttributes=Fg,g.updateTextBlockContent=Pb,g.updateUrl=e1,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
742
+ </svg>`,{t:nf}=S;class kN{constructor(t){u(this,"goBackButton");u(this,"playButton");u(this,"revertButton");this.options=t;const e=b("button",["dialog-text-button"],null),o=b("span",["dialog-button-icon"],e);o.innerHTML=yN,b("span",["dialog-button-text"],e,nf("version.goBack"));const r=b("button",["dialog-version-button"],null,nf("version.play")),i=b("button",["dialog-version-button"],null,nf("version.revertVersion"));this.goBackButton=e,this.playButton=r,this.revertButton=i,this.bindEvent()}bindEvent(){const{onBack:t,onPlay:e,onRevert:o}=this.options;this.playButton.onclick=e,this.goBackButton.onclick=t,this.revertButton.onclick=o}disabledButton(){}render(t,e=!1){e||t.append(this.goBackButton,this.playButton,this.revertButton)}destroy(){this.playButton.onclick=null,this.goBackButton.onclick=null,this.revertButton.onclick=null}}const he=w("split-text-actions");function n9(n){return n.length>2?!1:n.length===1?n[0].insert!==void 0:(d(he,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].insert!==void 0)}function o9(n){return n.length>2?!1:n.length===1?n[0].delete!==void 0:(d(he,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].delete!==void 0)}function r9(n){return n.length>2?!1:n.length===1?n[0].insert===void 0&&n[0].delete===void 0&&n[0].attributes!==void 0:(d(he,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].attributes!==void 0)}function wN(n){const t=[],e=Y.default(n);if(e.length===0)return[];if(e.length===1)return[n];if(e.length===2&&(o9(n)||n9(n)||r9(n)))return[n];const o=(i,s)=>i>0?[{retain:i},s]:[s];let r=0;for(;e.length>0;){const i=e[0];if(i.retain!==void 0&&i.attributes===void 0){d(he,i.retain>0,`invalid text op: ${JSON.stringify(i)}`),d(he,e.length>1,`invalid text op: ${JSON.stringify(i)}`);const s=e[1];d(he,s.delete||s.insert!==void 0||s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=i.retain,t.push(o(r,s)),s.delete!==void 0?r-=s.delete:s.insert!==void 0?r+=s.insert.length:(d(he,s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),d(he,s.retain!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=s.retain),e.splice(0,2)}else d(he,i.delete||i.insert!==void 0||i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),t.push(o(r,i)),e.shift(),i.retain!==void 0&&(d(he,i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),r+=i.retain),i.insert&&(r+=i.insert.length)}return t}function i9(n){if(d(he,n.length===1||n.length===2,`not a single action op: ${JSON.stringify(n)}`),n.length===1)return 0;const t=n[0].retain;return d(he,typeof t=="number"&&t>0,`invalid retain: ${JSON.stringify(n)}`),t}let s9=0;function BN(n,t,e){const o=s9;s9+=1;const r=kt(n);return{insert:" ",attributes:{box:!0,id:N(),type:"history-deleted-box",user:e,created:Date.now(),text:r,deletedOffset:t,deletedOrder:o}}}function EN(n,t,e){const o=i9(t),r=t.length===1?t[0].delete:t[1].delete;d(he,typeof r=="number",`not a delete op: ${JSON.stringify(t)}`);const{left:i,middle:s,right:l}=Jt(n,o,r),c=BN(s,o,e);return[...i,c,...l]}function IN(n,t,e){const o=i9(t),r=t.length===1?t[0].insert:t[1].insert;d(he,typeof r=="string",`invalid insert op: ${JSON.stringify(t)}`);const i=t.length===1?t[0].attributes:t[1].attributes,l=Bl([{insert:r,attributes:i}],"insertedBy",e);return xr(n,o,l,null)}function xN(n,t,e){const o=wN(t).reverse();let r=n;for(const i of o)o9(i)?r=EN(r,i,e):n9(i)?r=IN(r,i,e):(d(he,r9(i),`unknown op: ${JSON.stringify(i)}`),r=oe.apply(r,i));return r}const SN=w("history-update-block-text");function l9(n){const t=[],e=[];let o=0;return n.forEach(r=>{var i;if((i=r.attributes)!=null&&i.box){const s=r.attributes;if(s.type==="history-deleted-box"){t.push({boxData:s,offset:o});return}}e.push(r),o+=N1(r)}),t.sort((r,i)=>i.offset-r.offset),{deletedBoxes:t,newText:e}}function TN(n,t,e){let o=n;return t.forEach(r=>{const i=oe.transformCursor(r.offset,e,!1);o=xr(o,i,[{insert:" ",attributes:r.boxData}],null)}),o}function DN(n){n.sort((t,e)=>t.boxData.deletedOffset!==e.boxData.deletedOffset?t.boxData.deletedOffset-e.boxData.deletedOffset:t.boxData.deletedOrder-e.boxData.deletedOrder)}function LN(n){if(n.length<=1)return n;const t=n[0].offset;n.forEach(e=>{d(SN,e.offset===t,`invalid boxes group, ${JSON.stringify(n)}`)}),DN(n);for(let e=n.length-1;e>=1;e--){const o=n[e],r=n[e-1];o.boxData.user.userId===r.boxData.user.userId&&(r.boxData.text+=o.boxData.text,n.splice(e,1))}return n}function MN(n){let{newText:t,deletedBoxes:e}=l9(n);const o=new Map;return e.forEach(i=>{let s=o.get(i.offset);s||(s=[],o.set(i.offset,s)),s.push(i),s.sort((l,c)=>l.boxData.deletedOffset-c.boxData.deletedOffset)}),Array.from(o.values()).sort((i,s)=>s[0].offset-i[0].offset).forEach(i=>{const s=i[0].offset;LN(i).reverse().forEach(l=>{t=xr(t,s,[{insert:" ",attributes:l.boxData}],null)})}),t}function RN(n,t,e){let{newText:o,deletedBoxes:r}=l9(n);return o=xN(o,t,e),o=TN(o,r,t),o=MN(o),o}const Tn=w("history-doc");function Dn(n){d(Tn,!1,"no local actions for history doc")}class ON extends ki{constructor(e,o){super();u(this,"doc");u(this,"editor");this.doc=Y.default(e),this.editor=o}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return Y.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,o){const r=this.getContainerBlocks(e);d(Tn,r,`no container data: ${e}`);const i=r[o];return d(Tn,i,`no block data: ${o}`),i}localUpdateBlockText(){Dn()}localUpdateBlockData(){Dn()}localInsertBlock(){Dn()}localDeleteBlock(){Dn()}localInsertChildContainer(){Dn()}localDeleteChildContainers(){Dn()}uploadResource(){Dn()}async addResources(e){Dn()}getServerMeta(){var e,o,r;return(r=(o=(e=this.editor.doc.externalDoc).getServerMeta)==null?void 0:o.call(e))!=null?r:{}}buildResourceUrl(e){return this.editor.doc.externalDoc.buildResourceUrl(e)}request(){Dn()}broadcastMessage(){Dn()}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new Zl}destroy(){this.clearCallbacks()}transformBlockIndex(e,o,r){const i=this.doc.blocks[e];d(Tn,i,`no container blocks: ${e}`);let s=0;for(let l=0;l<i.length;l++)if(!i[l].deletedBy){if(s===o)return l;s++}return r?(d(Tn,!1,`invalid block index: ${o}, blocks: ${JSON.stringify(i)}`),-1):(d(Tn,s===o,`invalid block index: ${o}, blocks: ${JSON.stringify(i)}`),i.length)}onDeleteBlock(e,o,r){const i=this.transformBlockIndex(e,o,!0),l=this.doc.blocks[e][i];d(Tn,!l.deleted,`block has already deleted: ${e}/${o}`),l.deletedBy=r,this.callbacks.forEach(c=>{var a;return(a=c.onUpdateBlockData)==null?void 0:a.call(c,e,i,{insert:{},delete:[]},!0)})}onInsertBlock(e,o,r,i){const s=this.transformBlockIndex(e,o,!1),l=this.doc.blocks[e],c=Y.default(r);c.insertedBy=i,l.splice(s,0,c),this.callbacks.forEach(a=>{var h;return(h=a.onInsertBlock)==null?void 0:h.call(a,e,s,c,!0)})}onUpdateBlockText(e,o,r,i){const s=this.transformBlockIndex(e,o,!0),c=this.doc.blocks[e][s];d(Tn,!c.deleted,`block has already deleted: ${e}/${o}`);const a=c.text;d(Tn,a,`no text for block: ${JSON.stringify(c)}`);const h=RN(a,r,i);c.text=h,this.callbacks.forEach(f=>{var m;return(m=f.onUpdateBlockText)==null?void 0:m.call(f,e,o,r,!0)})}onUpdateBlockData(e,o,r,i){const s=this.transformBlockIndex(e,o,!0),l=this.doc.blocks[e],c=l[s];d(Tn,!c.deleted,`block has already deleted: ${e}/${o}`);const a=Y.default(c);a.updatedBy=i,r.delete.forEach(h=>delete a[h]),Object.entries(r.insert).forEach(([h,f])=>{a[h]=f}),l[s]=a,this.callbacks.forEach(h=>{var f;return(f=h.onUpdateBlockData)==null?void 0:f.call(h,e,s,r,!0)})}onCreateContainer(e,o,r){this.doc.blocks[e]=Y.default(o),this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,e,o,!0)})}}const{t:c9}=S;function ai(n,t){return t==="insert"?c9("version.insert",{name:n.displayName}):c9("version.delete",{name:n.displayName})}function sr(n,t){const{userId:e}=t;return["flag","selection"].reduce((r,i)=>{const s=n.doc.getRemoteUsers().getFixedUserColor(e,i);return r[i]=s,r},{})}class AN{renderText(t,e,o){if(!o.box&&o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=sr(t,o.insertedBy);return{classes:["history-inserted-text"],attributes:{"history-inserted-by":r.displayName,"data-op-description":ai(r,"insert")},styles:{[si]:i,[li]:s}}}return{}}renderBlock(t,e,o){if(o.deletedBy){const r=o.deletedBy,{flag:i,selection:s}=sr(t,r);return{classes:["history-deleted-block"],attributes:{"history-deleted-by":r.displayName,"data-op-description":ai(r,"delete")},styles:{[si]:i,[li]:s}}}if(o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=sr(t,r);return{classes:["history-inserted-block"],attributes:{"history-inserted-by":r.displayName,"data-op-description":ai(r,"insert")},styles:{[si]:i,[li]:s}}}return{}}updateBlock(t,e,o,r){if(r.deletedBy){const i=r.deletedBy,{flag:s,selection:l}=sr(t,i);M(o,"history-deleted-block"),Za(o,{"history-inserted-by":i.displayName,"data-op-description":ai(i,"delete")}),Ya(o,{[si]:s,[li]:l});return}if(r.insertedBy){const i=r.insertedBy,{flag:s,selection:l}=sr(t,i);M(o,"history-inserted-block"),Za(o,{"history-inserted-by":i.displayName,"data-op-description":ai(i,"insert")}),Ya(o,{[si]:s,[li]:l})}}}const a9=w("history-deleted-box");function _N(n,t,e,o){const r=o;d(a9,r.text,`no text for text box data: ${JSON.stringify(o)}`),d(a9,typeof r.text=="string",`invalid text type for text box data: ${JSON.stringify(o)}`);const i=b("span",["history-deleted-box"],e,r.text),s=r.user,{flag:l,selection:c}=sr(n,s);i.setAttribute("history-deleted-by",s.displayName),i.setAttribute("data-op-description",ai(s,"delete")),i.style.setProperty(si,l),i.style.setProperty(li,c)}const NN={boxType:"history-deleted-box",updateBoxContent:_N},ve=w("version-dialog");class PN{constructor(t,e){u(this,"editor");u(this,"dialog",null);u(this,"oldViewer",null);u(this,"versionOptions");u(this,"versionList",null);u(this,"actionButtons",null);u(this,"provider");u(this,"components");u(this,"handleClose",()=>{var t;(t=this.dialog)==null||t.hide()});u(this,"handlePlay",()=>{var e;d(ve,this.versionList,"The versionList did not render");const t=(e=this.versionList)==null?void 0:e.activeVersion;d(ve,t,`The version: ${t} is invalid`),this.viewVersion(t,{play:!0,speed:150})});u(this,"handleRevert",async()=>{var e,o;d(ve,this.versionList,"The versionList did not render");const t=(e=this.versionList)==null?void 0:e.activeVersion;d(ve,t,`The version: ${t} is invalid`),await this.versionHelper.revertVersion(t.version),(o=this.dialog)==null||o.hide()});u(this,"handleSelectVersion",t=>{d(ve,t,`The version: ${t} is invalid`),this.viewVersion(t)});u(this,"viewVersion",async(t,e={play:!1,speed:1e3})=>{var C,v,k;this.oldViewer&&(this.oldViewer.destroy(),this.oldViewer=null),d(ve,this.versionList,"The versionList did not render"),d(ve,this.actionButtons,"The actionButtons did not render");const o=t.type==="minor"?this.versionList.beforeVersion:this.versionList.beforeMajorVersion,r=o?o.version:0,i=this.versionList.isSelectedFirstVersion,s=this.versionList.isSelectedLastVersion;this.actionButtons.revertButton.disabled=i,this.actionButtons.playButton.disabled=i;let l=(C=this.versionOptions)==null?void 0:C.hideOps;if((v=this.versionOptions)!=null&&v.onWillChangeVersion){const E=this.versionOptions.onWillChangeVersion(this.editor,t,i,s);E!=null&&E.hideOps&&(l=!0)}let c,a;if(l)c=await this.versionHelper.getVersion(t.version),a=[];else{const E=await this.versionHelper.getHistoryData(t.version,r);c=E.doc,a=E.historyData}const{editorElement:h}=this.components;h.innerHTML="";const f=new ON(c,this.editor),m=this.provider.createHistoryEditor(h,f);m.editorBlockRenders.registerRender(new AN),m.editorBoxes.registerBoxClass(NN),M(m.rootElement,t9.HISTORY);try{await vN(f,this.versionHelper,a,e)}finally{this.oldViewer=m}(k=this.versionOptions)!=null&&k.onVersionChanged&&this.versionOptions.onVersionChanged(this.editor,m,t,i,s)});u(this,"setShowOps",t=>{var e;if(this.versionOptions){this.versionOptions.hideOps=!t;const o=(e=this.versionList)==null?void 0:e.activeVersion;d(ve,o,`The version: ${o} is invalid`),this.viewVersion(o)}});this.editor=t,this.provider=e;const o=b("div",["version-dialog"],null),r=b("div",["version-dialog-note-viewer"],o),i=b("div",["version-dialog-action-container"],r),s=b("div",["version-dialog-editor"],r),l=b("div",["version-dialog-versions-list"],o);this.components={root:o,editorElement:s,actionContainer:i,versionsListContainer:l}}get versionHelper(){d(ve,this.editor.doc.getVersionHelper,"Can not get getVersionHelper from doc");const t=this.editor.doc.getVersionHelper();return d(ve,t,"current doc does not support version"),t}renderContent(t){var s,l;const{actionContainer:e,versionsListContainer:o}=this.components;e.innerHTML="";const r=new kN({onBack:this.handleClose,onPlay:this.handlePlay,onRevert:this.handleRevert});r.render(e,(s=this.versionOptions)==null?void 0:s.hideActions),this.actionButtons=r,o.innerHTML="";const i=new pN({versions:t,useCreatedBy:(l=this.versionOptions)==null?void 0:l.useCreatedBy,onSelectVersion:this.handleSelectVersion,getMarkColor:c=>{const{flag:a}=sr(this.editor,c);return a}});i.render(o),this.versionList=i}initViewVersion(){var t;if((t=this.versionOptions)!=null&&t.initSelectedVersion){d(ve,this.versionList,"The versionList did not render");const{initSelectedVersion:e}=this.versionOptions,o=this.versionList.selectVersionByVersionNum(e);d(ve,o,`The version: ${o} is invalid`),this.viewVersion(o)}else{d(ve,this.versionList,"The versionList did not render");const e=this.versionList.activeVersion;d(ve,e,`The version: ${e} is invalid`),this.viewVersion(e)}}async show(t){this.versionOptions={...this.versionOptions,...t};const e=await this.versionHelper.getVersions();if(this.versionOptions.hideNonVersionedOps&&e.length&&e[0].version===-1&&e.shift(),this.versionOptions.onVersionsLoaded&&this.versionOptions.onVersionsLoaded(this.editor,e),this.renderContent(e),this.initViewVersion(),!this.dialog){const{root:o}=this.components;this.dialog=new gN(o)}this.dialog.show(t.container)}destroy(){var t,e,o;(t=this.dialog)==null||t.destroy(),(e=this.versionList)==null||e.destroy(),(o=this.actionButtons)==null||o.destroy()}}function $N(n,t,e){const o=n.addCustom("version-dialog",()=>new PN(n,t));return o.show(e),{setShowOps:o.setShowOps}}const Cz="",HN=w("heading-collapse");function of(n){var e;const t=Number.parseInt((e=n.getAttribute("data-style-heading"))!=null?e:"",10);return d(HN,t,"not a heading block"),t}function je(n){return!!n.getAttribute("data-style-heading")}function jN(n){return!lt(n,"heading-collapsed")}function lr(n){return lt(n,"heading-collapsed")}function d9(n){if(gt(n))return!1;const e=H(n);return Ct(e)}const FN=w("heading-collapse");function rf(n){d(FN,je(n),"not a heading block");const t=[],e=of(n);let o=ht(n);for(;o&&!(je(o)&&of(o)<=e);)t.push(o),o=ht(o);return t}function u9(n,t){if(!Vo(t))return;n.selection.selectBlock(t,0),rf(t).forEach(o=>{Tm(o)}),M(t,"heading-collapsed")}function di(n,t){rf(t).forEach(o=>{Dm(o)}),F(t,"heading-collapsed")}function zN(n,t){jN(t)?u9(n,t):di(n,t)}const UN=[Xd,tu,eu,nu,ou,ru,iu,su];function VN(n){const t=b("button",["heading-collapse-button"],null);return t.setAttribute(`data-editor-tooltip-${n.clientId}`,"Collapse / Expand"),t.innerHTML=ic,t}function h9(n){return Qc(n).querySelector("button.heading-collapse-button")}function f9(n,t){h9(t)||d9(t)||!Vo(t)||wh(t,VN(n),-1)}function qN(n){var t;(t=h9(n))==null||t.remove()}function m9(n,t){Qc(t).querySelector("button.heading-collapse-button")||f9(n,t)}function WN(n){const t=of(n),e=b("button",["heading-marker"],null);return e.innerHTML=UN[t-1],e}function g9(n){return Qc(n).querySelector("button.heading-marker")}function sf(n){g9(n)||d9(n)||!Vo(n)||wh(n,WN(n),1)}function p9(n){const t=g9(n);t==null||t.remove()}function C9(n){p9(n),je(n)&&sf(n)}class GN{handleDrop(t,e,o,r){if(cl(e)||!je(e)||!lr(e))return;const i=rf(e);i.unshift(e);const s=i.reverse();let l=null;return t.doc.beginBatchUpdate(),s.forEach((c,a,h)=>{const f=t.getBlockData(c),m=zo(t.editorBlocks,t.doc.toJSON(),f),C=t.insertDocAt(o,r,m)[0];a===h.length-1&&(l=C)}),t.doc.endBatchUpdate(),t.doc.beginBatchUpdate(),s.forEach(c=>{t.deleteBlock(c)}),t.doc.endBatchUpdate(),l&&u9(t,l),!0}}const ZN=w("heading-collapse");class YN{constructor(t){u(this,"handleLoad",()=>{this.showCollapseButtons()});u(this,"handleHoverBlock",(t,e)=>{e&&(F(e,"hovering-heading"),je(e)&&Ct(H(e))&&(sf(e),lr(e)||qN(e))),t&&je(t)&&Ct(H(t))&&(M(t,"hovering-heading"),p9(t),f9(this.editor,t))});u(this,"handleClick",(t,e)=>{const o=Ei(e,"button.heading-collapse-button");if(!o)return;const r=z(o);!r||(d(ZN,je(r),"not a heading block"),zN(this.editor,r),m9(this.editor,r))});this.editor=t,t.addListener("load",this.handleLoad),t.addListener("click",this.handleClick),_t.get(t).addListener("change",this.handleHoverBlock),this.showCollapseButtons(),setTimeout(()=>{Ds.get(t).addHandler(new GN)})}showCollapseButtons(){const t=Ot(this.editor.rootContainer).filter(je);t.length!==0&&(t[0]===Kt(this.editor.rootContainer)&&t.splice(0,1),t.forEach(sf))}destroy(){this.editor.removeListener("load",this.handleLoad),this.editor.removeListener("click",this.handleClick)}}function ma(n){const t=n.selection.range;if(t.isCollapsed()||t.start.blockId===t.end.blockId)return;const e=n.getBlockById(t.start.blockId),o=n.getBlockById(t.end.blockId);lr(e)&&di(n,e),lr(o)&&di(n,o)}function QN(n){ma(n);const t=n.getFocusedBlock();!je(t)||lr(t)&&di(n,t)}function KN(n){ma(n);const t=n.getFocusedBlock();if(!je(t))return;const e=n.selection.range.focus;!e.isSimple()||e.offset===Z(n,t)&&lr(t)&&di(n,t)}function JN(n){ma(n);const t=n.getFocusedBlock();if(!je(t))return;const e=n.selection.range.focus;!e.isSimple()||e.offset===0&&lr(t)&&di(n,t)}class XN{handleBeforeKeyDown(t,e){return Xa(e.key)&&ma(t),e.key==="Enter"?(QN(t),!1):e.key==="Delete"?(KN(t),!1):(e.key==="Backspace"&&JN(t),!1)}}class tP{constructor(t){this.editor=t}onInsertBlock(t,e,o,r){this.updateBlockIfNeeded(o.id)}onUpdateBlockData(t,e,o,r){const i=this.editor.doc.getBlockData(t,e);this.updateBlockIfNeeded(i.id,o)}updateBlockIfNeeded(t,e){setTimeout(()=>{const o=this.editor.findBlockById(t);if(!!o){if(!je(o)){e&&e.delete.includes("heading")&&C9(o);return}lt(o,"hovering-heading")&&m9(this.editor,o),C9(o)}},100)}}function eP(n){return!!n.heading}function b9(n){var e;const t=n.heading;return(e=Number.parseInt(`${t}`,10))!=null?e:1}function v9(n,t){var e;return{parentNode:t,children:[],text:kt((e=n.text)!=null?e:[]),level:b9(n),block:n}}class Ps{constructor(){u(this,"nodes",[])}appendBlock(t){const e=this.findParent(b9(t),this.nodes);e?e.children.push(v9(t,e)):this.nodes.push(v9(t,null))}findParent(t,e){const o=e[e.length-1];if(!o||t<=1)return null;if(o.level===t-1)return o;const r=this.findParent(t,o.children);return r||(o.level<t?o:null)}static buildToc(t){const e=new Ps,o=t.blocks.root;for(let r=0;r<o.length;r++){const i=o[r];eP(i)&&e.appendBlock(i)}return e}}class cr extends Wt.TypedEmitter{constructor(e){super();u(this,"toc",new Ps);u(this,"updateToc",Qt.default(()=>{this.updateTocNow()},500));this.editor=e,e.doc.registerCallback(this),this.updateToc()}destroy(){this.editor.doc.unregisterCallback(this)}isHeadingBlock(e){return!!e.heading}onInsertBlock(e,o,r,i){e==="root"&&this.isHeadingBlock(r)&&this.updateToc()}onDeleteBlock(e,o,r){e==="root"&&this.updateToc()}onUpdateBlockText(e,o,r,i){if(e!=="root")return;const s=this.editor.doc.getBlockData(e,o);this.isHeadingBlock(s)&&this.updateToc()}onUpdateBlockData(e,o,r,i){if(e!=="root")return;const s=this.editor.doc.getBlockData(e,o);this.isHeadingBlock(s)&&this.updateToc()}static register(e){return e.addCustom("editor-toc",()=>new cr(e))}static get(e){return e.getCustom("editor-toc")}updateTocNow(){this.toc=Ps.buildToc(this.editor.doc.toJSON()),this.emit("change",this.editor,this.toc)}}const bz="";function nP(n){return n.nodes.length===0?!0:n.nodes.length>1?!1:n.nodes[0].children.length===0}function lf(n,t){t.forEach(e=>{const o=b("div",["toc-node"],n),r=b("div",["toc-title"],o);if(b("span",["toc-text"],r,e.text).setAttribute("data-block-id",e.block.id),e.children.length>0){const s=b("div",["toc-children"],o);lf(s,e.children)}})}function oP(n,t){const e=Ei(t,".toc-text");if(!e)return;const o=e.getAttribute("data-block-id");if(!o)return;const r=n.findBlockById(o);!r||(t.preventDefault(),t.stopPropagation(),n.selection.selectBlock(r,0))}function y9(n,t,e){if(F(t,"loading"),t.innerHTML="",nP(e)){b("div",["toc-empty-message"],t,"No toc");return}e.nodes.length===1?lf(t,e.nodes[0].children):lf(t,e.nodes),Sd(n,"toc-click-handler",()=>{n.addListener("click",oP)})}class rP{constructor(t){u(this,"handleUpdateToc",(t,e)=>{Array.from(t.rootContainer.querySelectorAll('.embed-block[data-type="editor-block"][data-embed-type="toc"]')).forEach(r=>{const i=r.querySelector(".editor-toc-container");i&&y9(t,i,e)})});this.editor=t,cr.register(t).addListener("change",this.handleUpdateToc)}destroy(){cr.register(this.editor).removeListener("change",this.handleUpdateToc)}get toc(){return cr.register(this.editor).toc}}function iP(n,t){const e=b("div",["editor-toc-container"],t),r=n.addCustom("init-editor-toc",()=>new rP(n)).toc;r.nodes.length===0?M(e,"loading"):y9(n,e,r)}function sP(n,t,e,o){return o==="markdown"?"[toc]":""}function lP(n,t,e){const{data:o}=e;if(!o||o.embedType!=="toc"||!j(n,t))return null;const r={};return{blockData:{id:N(),type:"embed",embedType:"toc",embedData:r}}}const k9={embedType:"toc",createEmbedContent:iP,convertTo:sP,convertFrom:lP};function cP(n){return!!n.getAttribute("data-style-heading")}function cf(n,t){return cP(t)&&Z(n,t)>0}function aP(n){const t=Nn(n.rootElement);let e=0,o=0,r=0;if(t===document.documentElement){const i=n.rootContainer.getBoundingClientRect();e=i.left+i.width/2,o=10,r=t.offsetHeight}else{const i=t.getBoundingClientRect();e=i.left+i.width/2,o=i.top+10,r=i.bottom}for(;o<r;){const i=document.elementsFromPoint(e,o);for(let s=0;s<i.length;s++){const l=z(i[s]);if(l&&n.rootContainer.contains(l))return l}o+=10}return null}function af(n,t){let e=t;for(;e&&!cf(n,e);)e=ht(e);return e}function w9(n){if(gt(n))return!1;const e=H(n);return Ct(e)}function ga(n,t){let e=t;for(;e&&!cf(n,e);)e=gt(e),e&&w9(e)&&(e=null);return e}const dP=.3;class uP extends Wt.TypedEmitter{constructor(e){super();u(this,"scrollContainer");u(this,"scrollEventTarget");u(this,"scrollStatus",{curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null});u(this,"handleScroll",Qt.default(()=>{const e={curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null};let o=aP(this.editor);if(o&&(o=fl(o)),!o||!this.scrollContainer){this.setStatus(e);return}if(w9(o)&&(o=ht(o)),!o){this.setStatus(e);return}if(cf(this.editor,o)){e.curHeadingBlock=o,e.previousHeadingBlock=ga(this.editor,o),e.nextHeadingBlock=af(this.editor,o),this.setStatus(e);return}const r=this.scrollContainer.getBoundingClientRect(),i=af(this.editor,o);if(i){const l=i.getBoundingClientRect();if(l.top>r.top&&l.top<r.top+r.height*dP){e.curHeadingBlock=i,e.previousHeadingBlock=ga(this.editor,i),e.nextHeadingBlock=af(this.editor,i),this.setStatus(e);return}e.nextHeadingBlock=i}const s=ga(this.editor,o);s&&(e.curHeadingBlock=s,e.previousHeadingBlock=ga(this.editor,s)),this.setStatus(e)},200));this.editor=e,setTimeout(()=>{this.start()},50)}setStatus(e){this.scrollStatus.previousHeadingBlock===e.previousHeadingBlock&&this.scrollStatus.nextHeadingBlock===e.nextHeadingBlock&&this.scrollStatus.previousHeadingBlock===e.previousHeadingBlock||(this.scrollStatus=e,this.emit("change",this.editor,e))}start(){this.stop(),this.scrollContainer=Nn(this.editor.rootElement),this.scrollEventTarget=this.scrollContainer===document.documentElement?document:this.scrollContainer,this.scrollEventTarget.addEventListener("scroll",this.handleScroll),this.handleScroll()}stop(){this.scrollEventTarget&&this.scrollEventTarget.removeEventListener("scroll",this.handleScroll)}destroy(){this.stop(),this.scrollEventTarget=void 0}}class hP{constructor(t,e){u(this,"suggest");u(this,"onShow",(t,e,o,r)=>{const i=this.editor.getBlockByIndex(e,o);if(!Vo(i)){const s=z(H(i));if(s&&it(s)==="code")return!1}return!0});u(this,"onClickItem",(t,e,o)=>{const r=e.data,i={id:N(),type:"mention",box:!0,created:Date.now(),iconUrl:r.avatarUrl,text:r.displayName,mentionId:r.userId},s=this.editor.selection.range;if(!s.isCollapsed()||!s.isSimple())return;const l=s.focus,c=this.editor.getBlockById(l.blockId);this.editor.insertBoxToBlock(c,l.offset,i)});u(this,"queryItems",async(t,e)=>(await this.options.queryUsers(this.editor,e)).map(i=>({id:i.userId,name:i.displayName,icon:`<img src="${i.avatarUrl}" class="mention-user-avatar">`,element:i.element,data:i})));this.editor=t,this.options=e,this.suggest=new mu(t,{id:"editor-mention",trigger:["@"],autoDeleteTrigger:!0,showLoading:!0,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}destroy(){}}w("mathjax-box");function fP(n,t,e,o){const r=o,i=b("a",["mention-container"],e);b("span",["mention-name"],i,`@${r.text}`),i.setAttribute("data-mention-id",r.mentionId)}function mP(n,t,e){}const B9={boxType:"mention",updateBoxContent:fP,handleClickBox:mP};function gP(n){return kn("list-block-mention",S.t("list.mention.tooltip"),sp,[],n.clientId)}class pP{constructor(t){u(this,"mentionButton");u(this,"handleHoveringBlock",t=>{var e;!this.editor.isWritable()||(t&&this.shouldBlockShowMention(t)?At(t).appendChild(this.mentionButton):(e=this.mentionButton)==null||e.remove())});u(this,"handleMouseDown",(t,e)=>{e.preventDefault(),e.stopPropagation();const o=z(this.mentionButton);if(!o||!j(t,o))return;const r=t.selection.range.focus;if(!r.isSimple())return;let i;t.selection.focusedBlock!==o?i=Z(t,o):i=r.offset,setTimeout(()=>{const s=t.insertTextToBlock(o,i,"@");i+=1;const l=kt(fe(s,i).left);this.editor.selection.selectBlock(o,i),this.editor.focus(),t.getCustom("mention").suggest.popup(o,i,l,"@")})});u(this,"destroy",()=>{_t.get(this.editor).removeListener("change",this.handleHoveringBlock)});this.editor=t,this.mentionButton=gP(t),_t.get(this.editor).addListener("change",this.handleHoveringBlock),t.domEvents.addEventListener(this.mentionButton,"mousedown",this.handleMouseDown)}shouldBlockShowMention(t){if(!j(this.editor,t)||!at(t))return!1;const e=He(t);return!(e==="ordered"||e==="unordered")}}const vz="",CP={templates:{title:"\u9009\u62E9\u6A21\u677F\uFF0C\u5FEB\u901F\u521B\u5EFA",create:"\u65B0\u5EFA\u6A21\u677F",choose:"\u5168\u90E8\u6A21\u677F",customizedMark:"\u81EA\u5B9A\u4E49"}},bP={templates:{title:"Choose a template",create:"New template",choose:"All templates",customizedMark:"Custom"}};S.mergeLang({"zh-CN":CP,"en-US":bP});const yz="",vP="data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIHZpZXdCb3g9IjAgMCAxMjAgMTIwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cmVjdCB3aWR0aD0iMTIwIiBoZWlnaHQ9IjEyMCIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTQ4IDU5QzQ4IDU0LjU4MTcgNTEuNTgxNyA1MSA1NiA1MUg5M0M5OC41MjI4IDUxIDEwMyA1NS40NzcyIDEwMyA2MVY4OEMxMDMgOTEuODY2IDk5Ljg2NiA5NSA5NiA5NUg1NkM1MS41ODE3IDk1IDQ4IDkxLjQxODMgNDggODdWNTlaIiBmaWxsPSIjRDZFOUZBIi8+CjxwYXRoIGQ9Ik0xOCA2NEMxOCA2Mi4zNDMxIDE5LjM0MzEgNjEgMjEgNjFINTZDNjAuNDE4MyA2MSA2NCA2NC41ODE3IDY0IDY5VjgzQzY0IDg1LjIwOTEgNjIuMjA5MSA4NyA2MCA4N0gyNkMyMS41ODE3IDg3IDE4IDgzLjQxODMgMTggNzlWNjRaIiBmaWxsPSIjRUFFNEY2Ii8+CjxyZWN0IHg9IjI0IiB5PSIzMSIgd2lkdGg9IjY1IiBoZWlnaHQ9IjUwIiByeD0iNSIgZmlsbD0iIzk5QzdGMiIvPgo8cmVjdCB4PSIzMy41IiB5PSI0MyIgd2lkdGg9IjQ2IiBoZWlnaHQ9Ij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ljk2ODFDOTcuNjA3MyAyMTkuNjM4IDk4LjkzNjIgMjE4LjMwOSA5OC45MzYyIDIxNi42N0M5OC45MzYyIDIxNS4wMzEgOTcuNjA3MyAyMTMuNzAyIDk1Ljk2ODEgMjEzLjcwMkg5MC4wMzE5WiIgZmlsbD0iIzkxRDlCRSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEyNTZfMzcxNjgiPgo8cmVjdCB3aWR0aD0iMzcyIiBoZWlnaHQ9IjI3OSIgZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K",E9=w("templates");function df(n){const t=n.rootElement.querySelector(":scope .editor-templates");if(!t)return null;const e=t.querySelector(":scope .editor-templates-cards");return d(E9,e,"no card container"),{root:t,cardContainer:e}}function kP(n){const t=df(n);if(t)return t.cardContainer.innerHTML="",t;const e=b("div",["editor-templates"],n.rootElement);b("div",["editor-templates-title"],e,S.t("templates.title"));const o=b("div",["editor-templates-cards"],e);return{root:e,cardContainer:o}}function I9(n,t,e,o,r){var f;const i=(f=n.options.componentsOptions)==null?void 0:f.templates,s=b("div",["editor-template-card",...o],null),l=b("div",["editor-template-thumb-container"],s),c=b("img",["editor-template-thumb"],l);c.src=t,c.style.display="none",c.onerror=()=>{var C;const m=(C=i==null?void 0:i.placeHolderImageSrc)!=null?C:yP;c.src!==m&&(c.src=m)},c.onload=()=>{c.style.display=""};const a=b("div",["editor-template-name"],s),h=b("span",[],a,e);return i!=null&&i.showTemplateTitleAttr&&h.setAttribute("title",e),s.onclick=()=>r(s),s}function wP(n,t){return t.thumbnailUrl?t.thumbnailUrl:n.doc.buildResourceUrl("thumbnail.png")}function BP(n,t){const e=wP(n,t);return I9(n,e,t.name,[],async()=>{var r,i;const o=(r=n.options.componentsOptions)==null?void 0:r.templates;(i=o==null?void 0:o.onApplyTemplate)==null||i.call(o,n,t)})}function EP(n,t){return I9(n,t,S.t("templates.choose"),["more"],()=>{var o,r;const e=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=e==null?void 0:e.onChooseTemplate)==null||r.call(e,n)})}function IP(n,t){var f,m;const e=(f=n.options.componentsOptions)==null?void 0:f.templates;if(!e)return;const r=Gt(n.rootContainer).getBoundingClientRect().width;let i=1;const s=vP,l=df(n);if(l){if(t!=null&&t.reset){const C=Array.from(l.cardContainer.children),v=l.cardContainer.firstElementChild;if(d(E9,v,"no first card"),lt(v,"new")||lt(v,"more"))return;const k=window.getComputedStyle(v),E=parseFloat(k.marginLeft),L=parseFloat(k.marginRight),x=v.getBoundingClientRect().width+E+L;i=Math.floor(r/x);const A=Math.max(1,i-1-1),P=C.length-2;C.forEach((V,nt)=>{nt>A&&nt<P?V.style.display="none":(nt>=P&&lt(V,"more"),V.style.display="")})}return}const c=e.templates,{cardContainer:a}=kP(n);c.forEach((C,v)=>{const k=BP(n,C);if(v>0&&v>=i&&(k.style.display="none"),a.appendChild(k),v===0){const E=window.getComputedStyle(k),L=parseFloat(E.marginLeft),x=parseFloat(E.marginRight),O=k.getBoundingClientRect().width+L+x;i=Math.floor(r/O)-1}});const h=EP(n,s);a.appendChild(h),(m=e==null?void 0:e.onTemplateChooserStatusChanged)==null||m.call(e,n,a,"visible")}const x9=Qt.default(IP,50);function xP(n){var o,r;const t=df(n);if(!t)return;t.root.remove();const e=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=e==null?void 0:e.onTemplateChooserStatusChanged)==null||r.call(e,n,null,"hide")}function SP(n){const t=n.blocks.root;if(t.length===0)return!0;if(t.length>5)return!1;const e=[...t];e[0].type==="text"&&e[0].heading&&e.splice(0,1);const o=r=>{var i;return r.type!=="text"&&r.type!=="list"?!1:r.text?((i=r.text)==null?void 0:i.length)===0:!0};return e.every(r=>o(r))}function uf(n,t){SP(n.doc.toJSON())?x9(n,t):(x9.cancel(),xP(n))}class $s{constructor(t,e){u(this,"_decrypted",!1);this.editor=t,this.blockData=e}get decrypted(){return this._decrypted||this.blockData.owner===this.editor.doc.getUser().userId}setDecrypted(){this._decrypted=!0}destroy(){}static getState(t,e){return t.addCustom(`encrypted-block-${e.id}`,()=>new $s(t,e))}}const kz="",bo=w("encrypted-block");function TP(n,t,e,o,r){const i=r,s=no(o,"div"),l=$s.getState(n,i);if(l.decrypted)n.createChildContainer(t,s,i.children[0]),M(o,"decrypted");else{M(o,"encrypted");const c=At(o),a=b("div",["password-container"],c),h=b("input",[],a);h.type="text",h.onkeydown=f=>{if(f.key==="Enter"){const m=h.value;if(i.password===vi.default(`${i.owner}-${m}`)){l.setDecrypted(),n.reloadBlock(o);const C=E1(n,n.getBlockById(i.id));C&&(n.selection.selectBlock(C,0),n.focus())}}}}return s}function DP(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t)||!mn(r))return null;const i=r;if(n.getBlockData(t).children[0]!==U(i))return null;const l=bt(t,U(i));return new Qe(n,{anchor:l,focus:l})}function LP(n,t,e,o){if($s.getState(n,n.getBlockData(t)).decrypted)return null;if(o==="ArrowDown"||o==="ArrowRight"){const s=ht(t);return s?$(s,Z(n,s),"end"):$(t,1,"end")}const i=gt(t);return $(i||t,0,"home")}function MP(n,t){return n.getBoundingClientRect()}function RP(n,t,e,o){if(e.isSimple()){d(bo,o.isSimple(),"from is simple position but to is not simple position"),bo.debug("full select table"),M(t,"full-selected");return}d(bo,!o.isSimple(),"from is complex position but end is simple position");const r=e,i=o;d(bo,r.blockId===i.blockId,"only allow update one table selection"),d(bo,r.childContainerId===i.childContainerId,"only one container");const s=n.getBlockData(t),l=n.getContainerById(s.children[0]);M(l,"selected")}function OP(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="encrypted"]').forEach(t=>{F(t,"full-selected"),t.querySelectorAll("selected").forEach(e=>{F(e,"selected")})})}function AP(n,t){const e=n.getBlockData(t);return $s.getState(n,e).decrypted?[n.getContainerById(e.children[0])]:[]}function _P(n,t,e,o,r){return null}function NP(n,t,e,o){d(bo,e.blockId===o.blockId,"only allow select in single block"),d(bo,G(t)===e.blockId,"only allow select in single block");const r=n.getBlockData(t);return d(bo,e.childContainerId===r.children[0],"only one container"),[n.getContainerById(r.children[0])]}function PP(n){return{name:"EncryptedBlock",insertBlockCommandItems:[{id:"insert-encrypted-block",name:"Encrypted Block"}],async handleInsertEmptyBlock(t,e){const o=Cn(t.doc),r={id:N(),type:"encrypted",children:[o],owner:t.doc.getUser().userId,ownerDisplayName:t.doc.getUser().displayName,password:vi.default(`${t.doc.getUser().userId}-1234`)},i=t.doc.getContainerBlocks(o)[0];return t.insertBlock(e.containerId,e.blockIndex,r,Lt(t,i.id,0))}}}const $P={blockType:"encrypted",blockKind:"complex",enableKeyboardSelect:!0,createBlockContent:TP,getBlockTextLength:()=>1,getRangeFromPoint:DP,moveCaret:LP,getCaretRect:MP,updateSelection:RP,clearSelection:OP,getChildContainers:AP,getNextContainer:_P,getSelectedContainers:NP,getOptions:PP};function HP(n,t,e){const o=Ui(n,t,{components:{blocks:[bs,ks,$P],decorators:[new Bs],embeds:[ea,fh,Oh,Ah,_h,th,Nh,ef,tf],boxes:[Oc],options:{...e.componentsOptions}}});return o.readonly=!0,o}class jP{constructor(t){this.createOptions=t}createHistoryEditor(t,e){return HP(t,e,this.createOptions)}}w("create-editor");function S9({root:n,childDoc:t,doc:e}){t.uploadResource=e.uploadResource.bind(e),t.buildResourceUrl=e.buildResourceUrl.bind(e);const o=Ui(n,t,{shortcuts:[Wl],components:{blocks:[bs,ks],decorators:[new Bs],embeds:[E6,ea,fh,Oh,Ah,_h,th,Nh,ef,tf],boxes:[Oc,B9],options:{image:{defaultAlign:"left"}}}});return o.input.addHandler(new zc),o.input.addHandler(new Ph(o)),o.input.addHandler(new u_(o)),o}function FP(n,t){const e=Array.from(n.rootContainer.querySelectorAll(`[comment-${t.toLocaleLowerCase()}="${t}"]`)),o=new Set;e.forEach(r=>{const i=z(r);i&&o.add(i)}),o.forEach(r=>{h_(n,r,t)})}class zP{constructor(t){u(this,"listeners",new Set);u(this,"doc");this.editor=t,this.doc=this.editor.doc.externalDoc,this.doc.registerCallback(this)}getComments(){return this.doc.getComments()}getComment(t){return this.doc.getComment(t)}getCommentDoc(t){return this.doc.getCommentDoc(t)}localCreateComment(t,e){this.doc.localCreateComment(t,e)}localDeleteComment(t){const e=this.getComment(t);this.doc.localDeleteComment(t);const o=e.groupId;this.getComments().filter(i=>i.groupId===o).length===0&&FP(this.editor,o)}localUpdateComment(t,e){this.doc.localUpdateComment(t,e)}onCreateComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onCreateComment(t,e))}onDeleteComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onDeleteComment(t,e))}onUpdateComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onUpdateComment(t,e))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}createCommentEditor(t,e){return S9({root:t,childDoc:e,doc:this.doc})}}class UP{constructor(t,e){u(this,"listeners",new Set);this.editor=t,this.localDoc=e}get doc(){return this.localDoc.toJSON()}getComments(){return Object.values(this.doc.comments)}getComment(t){return this.doc.comments[t]}getCommentDoc(t){const e=this.doc.comments[t];return Ud(e)}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}localCreateComment(t,e){}localDeleteComment(t){}localUpdateComment(t,e){}createCommentEditor(t,e){return S9({root:t,childDoc:e,doc:this.localDoc})}}const VP={placeholder:{common:{title:"\u8BF7\u8F93\u5165\u6807\u9898",readonlyTitle:"\u8BF7\u8F93\u5165\u6807\u9898",content:"\u70B9\u51FB + \uFF0C\u6216\u8F93\u5165 / \u5FEB\u6377\u63D2\u5165\u7EC4\u4EF6"},local:{readonlyTitle:"\u672A\u547D\u540D"}}},qP={placeholder:{common:{title:"Enter a title",readonlyTitle:"Enter a title",content:'Click "+", or enter "/" to insert components quickly'},local:{readonlyTitle:"Untitled"}}};S.mergeLang({"zh-CN":VP,"en-US":qP});const hf=w("create-editor"),T9=[ea,fh,Oh,Ah,_h,th,Nh,ef,tf,E6,k9,Q_];async function WP(n,t){var s,l,c,a,h,f,m,C,v;d(hf,n,"app does not exists"),t.lang&&S.setLang(t.lang);const e=t.onReauth?async()=>{var x;const k=t.user.userId,E=t.docId,L=await((x=t.onReauth)==null?void 0:x.call(t,k,E,t.permission));return{userId:k,docId:E,permission:t.permission,appId:t.appId,token:L,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl}}:void 0,o={auth:{appId:t.appId,docId:t.docId,userId:t.user.userId,permission:t.permission,token:t.token,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl},serverUrl:t.serverUrl,reauthFunc:e,disableLogout:t.disableLogout},r=await ns.load(o),i=Ui(n,r,{id:t.id,scrollContainer:t==null?void 0:t.scrollContainer,components:{blocks:[bs,ks,vh,d4],commandProviders:[new Eu],decorators:[new Bs,new qd],embeds:[...T9,...((s=t.components)==null?void 0:s.embeds)||[]],boxes:[Oc,B9,U3],insertions:[z1],blockHooks:[new p6],textRenders:[new P3,new Cx],options:{...t.componentsOptions}},shortcuts:[ND,CM,ah,g3,bx,oh,Wl],colors:["#338FE5","#24B47E","#F0A100","#E52727","#9678D3","#2CB2AE","#EB6414","#8AAB3F"]});if(i.editorCommandProviders.registerCommandProvider(new Sn(i)),i.input.addHandler(new XN),i.input.addHandler(new zc),i.input.addHandler(new Yx),i.input.addHandler(new dM),i.input.addHandler(new ys(i,{headingLevel:1,titlePlaceholder:S.t("placeholder.common.title"),contentPlaceholder:S.t("placeholder.common.content"),readonlyTitlePlaceholder:S.t("placeholder.common.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),i.input.addHandler(new Ac(i,(l=t.componentsOptions)==null?void 0:l.quickMenu)),i.input.addHandler(new Ph(i)),i.input.addHandler(new s3(i)),i.doc.registerCallback(new tP(i)),i.addCustom("remote-cursor",()=>new a5(i)),i.addCustom("block-menu",k=>new y6(k)),i.addCustom("editor-tooltip",()=>new nh(i)),t!=null&&t.enableComments&&i.addCustom("editor-comments",k=>new N3(k,new zP(k))),i.addCustom("create-options",()=>new jf(i,t)),i.addCustom("drop-target",()=>new Ds(i)),i.addCustom("list-to-mindmap",()=>new Lc(i)),i.addCustom("list-to-mention",()=>new pP(i)),(c=t.componentsOptions)!=null&&c.mention){const k=t.componentsOptions.mention;i.addCustom("mention",()=>new hP(i,k))}if(i.addCustom("heading-collapse",()=>new YN(i)),Zr.register(i),Ds.register(i),cr.register(i),(h=(a=t.componentsOptions)==null?void 0:a.remoteCarets)!=null&&h.onUserChanged){const k=(m=(f=t.componentsOptions)==null?void 0:f.remoteCarets)==null?void 0:m.onUserChanged;i.doc.getRemoteUsers().on("change",E=>{k(i,E)})}return(v=(C=t.componentsOptions)==null?void 0:C.templates)!=null&&v.templates.length&&(i.addListener("docChanged",()=>{uf(i)}),i.addListener("resize",()=>{uf(i,{reset:!0})}),setTimeout(()=>{uf(i)},100)),i.doc.registerCallback({onError:async k=>{if(k.code==="ResetDoc"){hf.error(`reset doc: ${k.message}`);const E=await ns.load(o);i.doc.reset(E)}}}),i}function GP(n){return n.toJSON!==void 0}async function ZP(n,t,e){var i,s;d(hf,n,"app does not exists");const o=GP(t)?t:new xd(t);e.lang&&S.setLang(e.lang);const r=Ui(n,o,{id:e.id,scrollContainer:e==null?void 0:e.scrollContainer,components:{blocks:[bs,ks,vh,d4],commandProviders:[new Eu],decorators:[new Bs,new qd],embeds:[...T9,...((i=e.components)==null?void 0:i.embeds)||[]],boxes:[Oc,U3],insertions:[z1],blockHooks:[new p6],textRenders:[new P3],options:{...e.componentsOptions}},shortcuts:[ah,g3,oh,Wl]});return r.editorCommandProviders.registerCommandProvider(new Sn(r)),r.input.addHandler(new zc),r.input.addHandler(new ys(r,{headingLevel:1,titlePlaceholder:S.t("placeholder.common.title"),contentPlaceholder:S.t("placeholder.common.content"),readonlyTitlePlaceholder:S.t("placeholder.local.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),r.input.addHandler(new Ac(r,(s=e.componentsOptions)==null?void 0:s.quickMenu)),r.input.addHandler(new Ph(r)),r.input.addHandler(new s3(r)),r.addCustom("block-menu",l=>new y6(l)),r.addCustom("editor-tooltip",()=>new nh(r)),e!=null&&e.enableComments&&r.addCustom("editor-comments",l=>new N3(l,new UP(l,o))),Zr.register(r),r}function YP(n,t){var l;const e=n.doc;if(!((l=e.getVersionHelper)==null?void 0:l.call(e)))throw new Error("the editor does not support to show versions");const r=n.getCustom("create-options");if(!r)throw new Error("the editor does not support to show versions");const i=r.getData(),s=new jP(i);return $N(n,s,t)}g.AuthError=nc,g.AuthHeader=es,g.AutoScroll=wm,g.BaseURLHeader=oc,g.BlockResizer=Fc,g.BrBox=Kg,g.CodeBlock=ks,g.CodeLineBlock=vh,g.CodeTextDecorator=Bs,g.DefaultShortcuts=Wl,g.DocIdError=Cw,g.DragDrop=tm,g.DrawioEmbed=ea,g.EditorBlocks=sg,g.EditorBoxes=Xg,g.EditorCommandProviders=E0,g.EditorComplexBlockPosition=Ye,g.EditorComplexSelectionRange=Qe,g.EditorDecorators=o2,g.EditorEmbeds=cg,g.EditorInsertions=n2,g.EditorSimpleBlockPosition=Ut,g.EditorSimpleSelectionRange=se,g.EmbedBlock=dg,g.EnforceWithDocumentTitleHandler=ys,g.EventCallbacks=ki,g.FILL_CHAR=Lb,g.FileExtError=bw,g.HeadingBlockScrollListener=uP,g.InputtingInsertion=t2,g.LocalDoc=xd,g.Logger=hr,g.MIN_DISTANCE_THRESHOLD=Jf,g.MarkdownInputHandler=zc,g.MaxUserError=$d,g.OnesEditorCustomDataWrapper=jf,g.OnesEditorHoveringBlock=_t,g.OnesEditorQuickMenu=Ac,g.OnesEditorToc=Ps,g.OnesEditorTocProvider=cr,g.OnesEditorToolbar=Zr,g.OnesEditorTooltip=nh,g.PermissionError=pw,g.RemoteCarets=a5,g.RemoteCaretsDecorator=qd,g.RemoteCaretsInsertion=z1,g.RemoteUsers=Zl,g.RequestReloadError=ts,g.RichText=oe,g.ShareDBDoc=ns,g.SimpleCache=zf,g.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=$1,g.TEXT_STYLE_COLOR_PREFIX=P1,g.TableBlock=bs,g.TableBlockCommandProvider=Eu,g.TableShortcuts=ah,g.TextBlock=Ni,g.TextBox=Qg,g.TextStyleShortcuts=oh,g.TocEmbed=k9,g.ZERO_WIDTH_SPACE_CHAR=wi,g.addAttribute=Bl,g.addClass=M,g.addDays=sC,g.addMonths=iC,g.animateScrollTo=Ii,g.applyPlaceholderToBlock=Uc,g.assert=d,g.blockToDoc=rd,g.blockToHtml=U1,g.blockToMarkdown=r2,g.blockToText=Rl,g.blocksToDoc=iv,g.clearAllSelection=Qm,g.clientType=St,g.cloneBlock=zo,g.cloneChildContainer=X1,g.cloneDoc=td,g.cloneText=jg,g.commentToShareDbComment=Vd,g.compareElement=el,g.comparePosition=w1,g.complexBlockAdjustSelectionPos=pl,g.complexBlockFindNearestChildBlock=mg,g.complexBlockGeFirstSimpleChild=E1,g.complexBlockGetAllChildContainers=Me,g.complexBlockGetBottomChildContainers=fg,g.complexBlockGetLastSimpleChild=wr,g.complexBlockGetSelectedContainers=kr,g.complexBlockGetTopChildContainers=hg,g.containerToDoc=id,g.continuousScroll=km,g.convertBlockFrom=ml,g.copyBlockAttributes=f2,g.createBlockAnchor=No,g.createBlockContentElement=no,g.createBlockElement=Mm,g.createBlockSimpleDocRange=Ll,g.createBlockSimpleRange=Lt,g.createBoxContentElement=Am,g.createBoxElement=Rm,g.createBoxOp=Mg,g.createChildContainer=Gm,g.createComplexBlockPosition=bt,g.createComplexDocPos=Gg,g.createComplexDocRange=Rb,g.createContainer=Ug,g.createContainerElement=f1,g.createDeleteOps=Sg,g.createEditor=Ui,g.createEditorSelectionRange=Vt,g.createElement=b,g.createEmptyContainer=Cn,g.createEmptyDoc=ro,g.createEmptyTextBlockData=Sl,g.createExpandedRange=Xs,g.createIconButton=fr,g.createImage=Uf,g.createInsertOps=wl,g.createInsertionContentElement=Pm,g.createInsertionElement=_m,g.createLocalEditor=ZP,g.createOnesEditor=WP,g.createRange=Vf,g.createRichText=_i,g.createRootContainer=Wm,g.createSimpleBlockPosition=$,g.createSimpleDocPos=Wg,g.createTextBlockData=jn,g.createTextButton=tr,g.createTextOp=_e,g.createTextWithReplaceSoftReturn=O1,g.daysAfter=r1,g.deleteText=_1,g.diffDays=lC,g.disablePageScroll=mm,g.docToHtml=Wb,g.docToHtmlFragment=i2,g.docToMarkdown=Gb,g.docToText=s2,g.downloadObjectToFile=Th,g.downloadSvgToString=x6,g.editLink=wc,g.editorAddComment=m_,g.editorAddTextAttribute=S2,g.editorAutoInsertBlock=m2,g.editorBreakTextBlock=Lr,g.editorClearCompositionText=h2,g.editorClearSelectedContents=K1,g.editorCopyBlock=dd,g.editorDeleteBlock=Y1,g.editorDeleteBlockText=W1,g.editorDeleteBlockWithoutChildren=Z1,g.editorDeleteChildContainer=tv,g.editorDeleteChildContainers=b2,g.editorFocusToBlock=J1,g.editorFocusToEnd=M2,g.editorGetBlockData=io,g.editorGetBlockText=we,g.editorGetBlockTextEx=Al,g.editorGetBoxData=l2,g.editorHandleKeyboardEvent=i0,g.editorInsertBlock=Dr,g.editorInsertBoxToBlock=d2,g.editorInsertDoc=I2,g.editorInsertDocAt=ed,g.editorInsertText=q1,g.editorInsertTextToBlock=a2,g.editorInsertTextToBlockEx=V1,g.editorMergeTextBlock=v2,g.editorRangeClearColor=D2,g.editorRangeGetColor=nd,g.editorRangeSetColor=T2,g.editorRemoveTextAttribute=ov,g.editorReplaceBlockText=Hl,g.editorReplaceContainer=x2,g.editorRunOnce=Sd,g.editorSelectEnd=L2,g.editorSetTextColor=Mr,g.editorShowFindDialog=vA,g.editorUpdateBlockData=jl,g.editorUpdateCompositionText=u2,g.editorUpdateEmbedData=B2,g.enablePageScroll=gm,g.escapeHtmlText=Yf,g.escapeRegExp=l1,g.escapeSpace=z8,g.executeBlockCommand=ig,g.executeEmbedBlockCommand=rg,g.executeRangeCommand=B0,g.fileToDataUrl=rl,g.findAllText=F1,g.findInsertionById=Nm,g.findPrevSimpleBlockBeforeChildContainer=ug,g.findTarget=Ei,g.format=o1,g.formatBytes=Bm,g.formatDate=xm,g.fragmentToHtml=pm,g.fromBase64=ol,g.fromBase64ToBlob=um,g.fromBase64ToUint8Array=tC,g.fromDocRange=oo,g.fromNowString=s1,g.genId=N,g.getAllChildBlocks=x1,g.getAllQuickMenuItems=eh,g.getAllSelectedBlocks=Ke,g.getAttributesAt=Il,g.getBlockBackground=Lm,g.getBlockByIndex=mr,g.getBlockCaretRect=Ze,g.getBlockClass=yt,g.getBlockClassByType=vr,g.getBlockClientRects=Ao,g.getBlockCommandsWithHook=b1,g.getBlockContent=rt,g.getBlockId=G,g.getBlockIndex=K,g.getBlockKind=Ge,g.getBlockMinWidth=Jm,g.getBlockOptions=CC,g.getBlockPath=Oo,g.getBlockProperties=eg,g.getBlockStyles=gC,g.getBlockTextLength=Z,g.getBlockTools=At,g.getBlockType=it,g.getBoxContent=d1,g.getBoxId=Om,g.getBoxTypeFromElement=Ti,g.getChildBlockCount=Ve,g.getChildBlocks=Ot,g.getChildOffset=Er,g.getColorFromAttributes=j1,g.getComplexBlockClass=ke,g.getContainerBlockPath=Um,g.getContainerBlocks=Fm,g.getContainerBlocksElement=hl,g.getContainerById=br,g.getContainerId=U,g.getContainerMinWidth=p1,g.getContainerToolsElement=dC,g.getContainerWidth=tg,g.getDistanceSquare=fn,g.getElementOffset=Bi,g.getEmbedType=Le,g.getExistsBlockTools=ul,g.getExistsContainerById=Hm,g.getFileExt=bm,g.getFirstChildBlock=Kt,g.getFirstClientRect=tl,g.getHeadingMenuOptions=Rc,g.getHorizontalPadding=Wa,g.getInsertionContent=u1,g.getLastChildBlock=Gt,g.getLastClientRect=xo,g.getLogger=w,g.getNextBlock=ht,g.getNextValidOffset=Ir,g.getNextVisibleBlock=Cr,g.getOpAt=Og,g.getOpLength=N1,g.getParentBlock=z,g.getParentBox=a1,g.getParentContainer=H,g.getPrevBlock=gt,g.getPrevValidOffset=$o,g.getPrevVisibleBlock=pr,g.getRangeCommands=k0,g.getRootBlock=fl,g.getScrollContainer=Nn,g.getSpecialBlockCommands=ng,g.getTextBlockChild=Cl,g.getTextBlockClass=Ym,g.getTextBlockContentChildTextLength=Oe,g.getTextBlockContentChildType=gg,g.getTextBlockContentChildren=Hn,g.getTextLength=ce,g.getTextOpLength=T1,g.getTextWidth=sl,g.getToolbar=kc,g.handleBlockElementUpdated=Xm,g.hasAltOnly=Z8,g.hasClass=lt,g.hasCtrlOrCmd=lm,g.hasCtrlOrCmdOnly=G8,g.hideBlock=Tm,g.htmlToFragment=il,g.i18n=S,g.injectStyle=Kf,g.insertEmptyBlock=vC,g.insertEmptyEmbedBlock=v1,g.insertText=xr,g.intersectionCommands=dk,g.isBackspace=am,g.isBlock=gr,g.isBox=c1,g.isCJK=rm,g.isChildContainer=We,g.isChildNode=vt,g.isCollapsedRange=qg,g.isComplexBlockPosition=k1,g.isComplexKindBlock=ct,g.isContainer=mn,g.isControlEvent=Do,g.isDelete=Q8,g.isDraggingFiles=cl,g.isEmbedBlock=De,g.isEmptyContainer=C1,g.isEmptyDoc=Tl,g.isEmptyTextBlock=Et,g.isEmptyTextBlockWithoutCompositionText=vs,g.isEnterOnly=cm,g.isEscape=t1,g.isFirefox=Ja,g.isFirstChildBlockInComplexBlock=WC,g.isHighSurrogate=N8,g.isInBlock=h1,g.isInBlockTools=Di,g.isLetter=om,g.isLowSurrogate=qa,g.isMatchShortcut=_n,g.isMoveForward=q8,g.isNavigationEvent=V8,g.isNavigationKey=sm,g.isNodeRemoved=Wf,g.isNumber=nm,g.isPrintableKey=Xa,g.isRootBlock=Vo,g.isRootContainer=Ct,g.isSafari=im,g.isSameDay=i1,g.isShiftEnter=Y8,g.isShiftTab=J8,g.isShortcutEvent=W8,g.isSimpleBlock=pC,g.isSimpleBlockPosition=yr,g.isSimplePos=Vg,g.isSimpleRange=Dl,g.isSpace=nl,g.isTab=K8,g.isTextBlockContentBoxChild=Re,g.isTextBlockContentChild=Mi,g.isTextBlockContentInsertionChild=$n,g.isTextBlockContentTextChild=Ri,g.isTextKindBlock=j,g.isTextKindBlockType=Li,g.isToday=Em,g.isValidOffset=me,g.isVisibleBlock=dl,g.isYesterday=Im,g.loadJs=Gf,g.loadJsPromise=So,g.lockers=Ue,g.mergeCommands=yc,g.mergeDocs=Fo,g.mergeOps=A1,g.mergeText=xb,g.multiSplitText=bg,g.parseShortcut=dm,g.patchNode=Si,g.pointInRect=To,g.rangeAddAttribute=El,g.rangeGetTextColor=Hg,g.rangeRemoveAttribute=Sr,g.rangeSetTextColor=Ng,g.rangeTransformText=Ag,g.registerDragDrop=Qa,g.removeAttribute=H1,g.removeClass=F,g.removeLastBr=wb,g.removePlaceholderFromBlock=W4,g.removeStyle=Qf,g.replaceAll=cC,g.replaceAllCaseInsensitive=aC,g.replaceAllText=zg,g.replaceText=xl,g.requestDownload=al,g.scrollable=ym,g.selectFile=Mo,g.selectedBlockToDoc=zl,g.selectionToDoc=Ul,g.setAttributes=Za,g.setClipboardData=ll,g.setClipboardDataByEvent=rC,g.setColorToAttributes=Pg,g.setDataset=Ga,g.setDefaultCursor=xi,g.setStyles=Ya,g.shareDBCommentToDocObject=Ud,g.shareDBDocCommentToComment=l5,g.shortcutToDisplayText=X8,g.showBlock=Dm,g.showDocVersions=YP,g.splitText=fe,g.splitToThree=Jt,g.stringToDataUrl=hm,g.stringToObjectUrl=n1,g.subText=vg,g.textNodeOffsetFromPoint=qf,g.toBase64URL=Lo,g.toPlainText=kt,g.trimChar=Ka,g.unicodeLength=P8,g.unicodeSubstr=$8,g.updateBlockSelection=Km,g.updateOpAttributes=Fg,g.updateTextBlockContent=Pb,g.updateUrl=e1,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/dist/types.d.ts CHANGED
@@ -40,6 +40,7 @@ export interface CreateOnesEditorOptions {
40
40
  token: string;
41
41
  disableLogout?: boolean;
42
42
  enableComments?: boolean;
43
+ scrollContainer?: HTMLElement;
43
44
  lang?: i18n.LANGS;
44
45
  onReauth?: (userId: string, docId: string, permission: OnesEditorUserPermission) => Promise<string>;
45
46
  user: {
@@ -56,6 +57,7 @@ export interface CreateOnesEditorOptions {
56
57
  export interface CreateLocalEditorOptions {
57
58
  id?: string;
58
59
  lang?: i18n.LANGS;
60
+ scrollContainer?: HTMLElement;
59
61
  components?: {
60
62
  embeds?: Embed[];
61
63
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "0.0.3-beta.32",
3
+ "version": "0.0.3-beta.34",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",