@ones-editor/editor 0.0.3-beta.155 → 0.0.3-beta.157

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.
@@ -9,5 +9,5 @@ export default class VersionInfoHeader {
9
9
  right: HTMLElement;
10
10
  dropdown: VersionsDropdown;
11
11
  constructor(parent: HTMLElement, options: VersionInfoHeaderOptions);
12
- setVersion(ver: DocVersion, compareWithVersion?: DocVersion): void;
12
+ setVersion(ver: DocVersion, compareWithVersion: DocVersion | undefined, isLatest: boolean): void;
13
13
  }
package/dist/index.js CHANGED
@@ -578,7 +578,7 @@ width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
578
578
  `:i.src?`[${i.fileName}](${n.doc.buildResourceUrl(i.src,{withToken:!0})})`:`[${i.fileName}]`}async function Uz(n,e,t,o){const{onGetFileDownloadUrl:r}=n.getComponentOptions("file")||{},i=e.embedData,s=r?await r(n,i):void 0;return{blocks:{root:[{type:"embed",id:K(),embedType:"webpage",embedData:{src:s||i.src,title:i.fileName}}]},meta:{},comments:{}}}const zz={embedType:"office",createEmbedContent:Nz,getBlockProperties:Hz,convertTo:jz,toStandardDoc:Uz},Vz={file:{abstract:"\u9644\u4EF6"}},Wz={file:{abstract:"Attachment"}},qz={file:{abstract:"\u6DFB\u4ED8\u30D5\u30A1\u30A4\u30EB"}};O.mergeLang({"zh-CN":Vz,"en-US":Wz,"ja-JP":qz});function Gz(n){const e=/(\s|^)(http|https):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?$/;return e.test(n)?n.search(e):-1}function Zz(n){const e=n.selection.range;if(!e.isCollapsed()||!e.isSimple())return;const{start:t}=e,o=n.getBlockById(t.blockId);if(!ee(n,o))return;const r=n.getBlockText(o),s=fg(r).slice(0,t.offset),l=Gz(s);if(l===-1)return;const a=s.slice(l),d=s.length;let h=Ea(l,d-l,r,"link",a);return h=$r(h,d," ",null),n.setBlockText(o,h),n.selection.selectBlock(o,d+1),!0}const Qz={Space:Zz},Rne="",Yz={version:{latest:"\u6700\u65B0\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\u7248\u672C ({count})",unknown:"\u672A\u77E5\u7248\u672C",restoreFrom:"\u56DE\u6EDA\u81EA\u7248\u672C\u300C{from}\u300D",restoreInfo:"\u56DE\u6EDA\u7684\u7248\u672C\u6682\u4E0D\u652F\u6301\u4E0E\u4E0A\u4E00\u7248\u672C\u5BF9\u6BD4",versionInfoLeft:'<span class="text-1">\u5F53\u524D\u7248\u672C: </span><span class="name">{versionName}</span><span class="text-2"> \u4E0E</span>',versionInfoRight:'<span class="text-3">\u5BF9\u6BD4</span>',noSelectedVersion:"\u672A\u9009\u62E9\u7248\u672C",noMemoedVersion:"\u6682\u65E0\u5DF2\u5907\u6CE8\u7684\u5386\u53F2\u7248\u672C",noFilterVersion:"\u6682\u65E0\u5339\u914D\u7ED3\u679C",memo:"\u5907\u6CE8",revert:"\u56DE\u6EDA",filter:{all:"\u5168\u90E8",memoed:"\u5DF2\u5907\u6CE8",allVersions:"\u5168\u90E8\u5386\u53F2\u7248\u672C",memoVersions:"\u5DF2\u5907\u6CE8\u7684\u5386\u53F2\u7248\u672C"},textarea:{placeholder:"\u8BF7\u8F93\u5165\u7248\u672C\u5907\u6CE8"},tooltip:{help:`1. \u56DE\u6EDA\u7248\u672C\u4E0D\u652F\u6301\u4E0E\u56DE\u6EDA\u524D\u7248\u672C\u8FDB\u884C\u5BF9\u6BD4\uFF1B
579
579
  2. \u82E5\u4E24\u4E2A\u7248\u672C\u4E4B\u95F4\u5B58\u5728\u56DE\u6EDA\u7248\u672C\uFF0C\u5219\u4E0D\u652F\u6301\u5BF9\u6BD4\u3002`,user:"\u7248\u672C\u53D1\u5E03\u8005\uFF1A{name}",auth:"\u6682\u65E0\u9875\u9762\u7F16\u8F91\u6743\u9650\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458"},dropdownHeader:"\u4EC5\u5C55\u793A\u53EF\u4E0E\u5F53\u524D\u7248\u672C\u8FDB\u884C\u5BF9\u6BD4\u7684\u5386\u53F2\u7248\u672C",dropdown:{header:"\u6240\u6709\u53EF\u5BF9\u6BD4\u7684\u7248\u672C"},noVersions:"\u6682\u65E0\u53EF\u5BF9\u6BD4\u7684\u7248\u672C",lastVersion:"\u4E0A\u4E00\u7248\u672C",filterMemoed:"\u7B5B\u9009\u5DF2\u5907\u6CE8\u7684\u7248\u672C"}},Jz={version:{latest:"Latest",insert:"Added by {name}",delete:"Deleted by {name}",goBack:"Back",revertVersion:"Revert",play:"Play",versionList:"Historical versions ({count})",unknown:"Unknown version",restoreFrom:"Rolled back from version {from}",restoreInfo:"The rolled back version does not currently support comparison with the previous version.",versionInfoLeft:'<span class="text-1">Current version: </span><span class="name">{versionName}</span><span class="text-2"> Compare with</span>',versionInfoRight:'<span class="text-3"></span>',noSelectedVersion:"Not selected",noMemoedVersion:"No historical commented versions",noFilterVersion:"No result",memo:"Comment",revert:"Roll back",filter:{all:"All",memoed:"Commented",allVersions:"All historical versions",memoVersions:"Historical versions with comments"},textarea:{placeholder:"Enter comment"},tooltip:{help:`1. A rolled back version can't be compared with versions before it.
580
580
  2. Versions can't be compared if there are rolled back versions between them.`,user:"Released by {name}",auth:"No edit permission for this page. Contact the admin."},dropdownHeader:"The list below only contains historical versions that can be compared with the current version",dropdown:{header:"All historical versions that can be compared"},noVersions:"No comparable versions available",lastVersion:"Previous version",filterMemoed:"Filter versions with comments"}},Kz={version:{latest:"\u6700\u65B0",insert:"{name}\u304C\u8FFD\u52A0\u3057\u307E\u3057\u305F",delete:"{name}\u304C\u524A\u9664\u3057\u307E\u3057\u305F",goBack:"\u623B\u308B",revertVersion:"\u5185\u5BB9\u3092\u5FA9\u5143",play:"\u5C65\u6B74\u3092\u518D\u751F",versionList:"\u30D0\u30FC\u30B8\u30E7\u30F3\u5C65\u6B74 {count}",unknown:"\u672A\u77E5\u306E\u30D0\u30FC\u30B8\u30E7\u30F3",restoreFrom:"\u5FA9\u5143\u3055\u308C\u305F\u30D0\u30FC\u30B8\u30E7\u30F3\uFF1A{from}",restoreInfo:"\u5C65\u6B74\u30D0\u30FC\u30B8\u30E7\u30F3\u306F\u4EE5\u524D\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u3068\u6BD4\u8F03\u3067\u304D\u307E\u305B\u3093\u3002",versionInfoLeft:'<span class="text-1">\u73FE\u5728\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\uFF1A</span><span class="name">{versionName}</span><span class="text-2"> \u3068</span>',versionInfoRight:'<span class="text-3">\u3092\u6BD4\u8F03\u3059\u308B</span>',noSelectedVersion:"\u672A\u9078\u629E",noMemoedVersion:"\u5099\u8003\u306E\u3042\u308B\u30D0\u30FC\u30B8\u30E7\u30F3\u306F\u3042\u308A\u307E\u305B\u3093",noFilterVersion:"\u4E00\u81F4\u3057\u305F\u7D50\u679C\u306F\u3042\u308A\u307E\u305B\u3093",memo:"\u5099\u8003",revert:"\u5FA9\u5143",filter:{all:"\u3059\u3079\u3066",memoed:"\u5099\u8003\u3042\u308A",allVersions:"\u3059\u3079\u3066",memoVersions:"\u5099\u8003\u3042\u308A"},textarea:{placeholder:"\u8AAC\u660E\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"},tooltip:{help:`1. \u5FA9\u5143\u3055\u308C\u305F\u30D0\u30FC\u30B8\u30E7\u30F3\u306F\u305D\u308C\u4EE5\u524D\u306E\u53E4\u3044\u30D0\u30FC\u30B8\u30E7\u30F3\u3068\u6BD4\u8F03\u3067\u304D\u307E\u305B\u3093\u3002
581
- 2. \u4E8C\u3064\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u306E\u9593\u306B\u5FA9\u5143\u3055\u308C\u305F\u30D0\u30FC\u30B8\u30E7\u30F3\u304C\u3042\u308B\u5834\u5408\u3001\u3053\u306E\u4E8C\u3064\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u306F\u6BD4\u8F03\u3067\u304D\u306A\u3044\u3053\u3068\u306B\u306A\u308A\u307E\u3059\u3002`,user:"\u30D0\u30FC\u30B8\u30E7\u30F3\u4F5C\u6210\u8005\uFF1A{name}",auth:"\u3053\u306E\u30B9\u30DA\u30FC\u30B9\u3092\u7DE8\u96C6\u3059\u308B\u6A29\u9650\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u7BA1\u7406\u8005\u306B\u3054\u9023\u7D61\u304F\u3060\u3055\u3044\u3002"},dropdownHeader:"\u73FE\u5728\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u3068\u6BD4\u8F03\u3067\u304D\u308B\u30D0\u30FC\u30B8\u30E7\u30F3\u3060\u3051\u8868\u793A\u3055\u308C\u307E\u3059",dropdown:{header:"\u6BD4\u8F03\u53EF\u80FD\u306A\u30D0\u30FC\u30B8\u30E7\u30F3"},noVersions:"\u6BD4\u8F03\u53EF\u80FD\u306A\u30D0\u30FC\u30B8\u30E7\u30F3\u306F\u3042\u308A\u307E\u305B\u3093",lastVersion:"\u524D\u306E\u30D0\u30FC\u30B8\u30E7\u30F3",filterMemoed:"\u5099\u8003\u3042\u308A"}};O.mergeLang({"zh-CN":Yz,"en-US":Jz,"ja-JP":Kz});var my=(n=>(n.NEW="history-new",n.NEW_CHILD="history-new-child",n.DELETED="history-deleted",n.UPDATED="history-updated",n.HISTORY="history",n))(my||{});const Ec="--op-color",xc="--op-selected-color",One="";class Xz{constructor(e){m(this,"root");this.content=e;const t=w("div",["editor-dialog-root"],null);t.append(e),this.root=t}show(e=document.body){e.append(this.root)}hide(){this.root.remove()}destroy(){}}function Js(n){var t;let e;if(n.version!==-1){const o=new Date((t=n.created)!=null?t:n.version);e=Lm(o,"YYYY-MM-DD hh:mm")}else e=O.t("version.latest");return e}function Yf(n){return n.source&&typeof n.source=="object"&&!!n.source.restore}const _ne="";class eV{constructor(e,t){m(this,"textArea");m(this,"warning");m(this,"end",!1);m(this,"root");m(this,"handleBlur",()=>{var e,t;this.end||(t=(e=this.options)==null?void 0:e.onend)==null||t.call(e,this.textArea.value,!1)});m(this,"handleKeyDown",e=>{var t,o,r,i;e.isComposing||(e.key==="Enter"||e.key==="Tab"?(e.preventDefault(),(o=(t=this.options)==null?void 0:t.onend)==null||o.call(t,this.textArea.value,!1),this.end=!0):e.key==="Escape"&&(e.preventDefault(),(i=(r=this.options)==null?void 0:r.onend)==null||i.call(r,this.textArea.value,!0),this.end=!0))});m(this,"handleInput",e=>{const t=e.target,{value:o}=t;o.length>this.maxLength-10?this.warning.innerText=`${o.length}/${this.maxLength}`:this.warning.innerText="",this.autoSize()});var o,r;this.maxLength=e,this.options=t,this.root=w("div",["size-limit-textarea",...(o=t==null?void 0:t.classes)!=null?o:[]],null),this.textArea=w("textarea",["size-limit-textarea-input"],this.root),this.warning=w("div",["size-limit-textarea-warning"],this.root),this.textArea.addEventListener("input",this.handleInput),this.textArea.addEventListener("blur",this.handleBlur),this.textArea.addEventListener("keydown",this.handleKeyDown),this.textArea.maxLength=e,this.textArea.placeholder=(r=t==null?void 0:t.placeholder)!=null?r:""}destroy(){this.textArea.removeEventListener("input",this.handleInput),this.textArea.removeEventListener("blur",this.handleBlur),this.textArea.removeEventListener("keydown",this.handleKeyDown)}setValue(e){this.textArea.value=e,this.autoSize()}autoSize(){const e=Math.max(this.textArea.scrollHeight,60);this.textArea.style.height="auto",this.textArea.style.height=`${e}px`}resetSize(){this.textArea.style.height="auto";const e=Math.max(this.textArea.scrollHeight,60);this.textArea.style.height=`${e}px`}focus(){this.textArea.focus(),this.end=!1}}const Fne="",{t:Qn}=O,gy=S("version-list");class tV{constructor(e){m(this,"versionsList");m(this,"versionsListHeader");m(this,"versionFilterToolbar");m(this,"memoInput",null);m(this,"selectedVersion",0);m(this,"handleClickVersionItem",e=>{const t=e.target,o=t.closest(".version-item");if(!this.isVersionElement(o))return;const r=xe(o,"active");if(r&&t.closest(".version-item-memo")&&this.options.enableEdit){this.editItemMemo(o);return}const i=this.getVersionFromElement(o);if(this.setActiveItem(o),t.closest(".add-memo-button")&&this.options.enableEdit){this.handleAddMemo(i,o);return}if(t.closest(".revert-button")&&this.options.enableEdit){this.handleRevert(i,o);return}if(r)return;const{onSelectVersion:s}=this.options;s(i)});m(this,"handleEndEditItemMemo",(e,t)=>{var r,i;const o=(r=this.memoInput)==null?void 0:r.root.closest(".version-item");if(this.isVersionElement(o)&&(te(o,"editing"),!t)){const s=this.getVersionFromElement(o),l=e.replace(/[\n\r]+/g," ");if(((i=s.extra)==null?void 0:i.memo)!==l){s.extra={memo:l},this.options.versionHelper.updateVersionExtra(s.version,s.tagId,s.extra).then(()=>{var d,h;(h=(d=this.options).onMemoChanged)==null||h.call(d,s)});const a=o.querySelector(".version-item-memo");g(gy,a,"no memo element"),a.textContent=l}}setTimeout(()=>{var s;(s=this.memoInput)==null||s.root.remove()})});m(this,"handleRevert",(e,t)=>{const{onRevert:o}=this.options;o(e)});m(this,"handleFilterClick",(e,t)=>{let o=this.options.versions;t.id==="memoed"&&(o=o.filter(i=>{var s;return!!((s=i.extra)!=null&&s.memo)}));const r=this.createVersionItems(o,t.id);this.versionsList.innerHTML="",this.versionsList.append(r),this.versionFilterToolbar.updateItems(this.getFilterItems(t.id)),this.updateHeaderCount(o.length)});var d,h;this.options=e;const{versions:t}=e,o=w("div",["version-list-header"],null),r=Qn("version.versionList",{count:`${t.length}`});w("span",["version-count"],o,r);const i=w("div",["version-list-filter"],o);this.versionFilterToolbar=new oM(i,this.getFilterItems("all"),{tooltipId:"version-viewer"}),this.versionFilterToolbar.addListener("click",this.handleFilterClick),this.selectedVersion=e.selectedVersion||((d=t[0])==null?void 0:d.version)||-1;const s=w("div",["version-list-content"],null),l=this.createVersionItems(t,"all");s.append(l),this.versionsList=s,this.versionsListHeader=o,s.onclick=this.handleClickVersionItem;const a=this.activeVersion;a&&((h=this.options)==null||h.onSelectVersion(a))}getFilterItems(e){return[{id:"filter",name:Qn(e==="all"?"version.filter.all":"version.filter.memoed"),dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",children:[{id:"all",states:e==="all"?["checked"]:[],name:Qn("version.filter.allVersions")},{id:"memoed",states:e==="memoed"?["checked"]:[],name:Qn("version.filter.memoVersions")}]}]}createVersionItems(e,t){const o=document.createDocumentFragment();if(e.length===0){const i=w("div",["version-list-empty"],o);return i.textContent=Qn("version.noMemoedVersion"),o}const r=(i,s,l,a=!1)=>{var x,_;const d=w("div",["version-item"],o);d.versionData=i,s&&W(d,"child"),i.version===this.selectedVersion&&W(d,"active");const h=w("div",["version-item-title"],d);w("div",["version-item-date"],h,Js(i)),a&&w("div",["version-item-latest"],h,Qn("version.latest")),w("div",["spacer"],h);const p=w("div",["version-actions"],h),A=w("button",["add-memo-button"],p);if(A.textContent=Qn("version.memo"),this.options.enableEdit||(W(A,"disabled"),A.setAttribute("data-editor-tooltip-common",O.t("version.tooltip.auth"))),!a){const M=w("button",["revert-button"],p);M.textContent=Qn("version.revert"),this.options.enableEdit||(W(M,"disabled"),M.setAttribute("data-editor-tooltip-common",O.t("version.tooltip.auth")))}let v="";if(typeof i.source=="object"&&((x=i.source)==null?void 0:x.restore)){const M=i.source.restore,j=l.find(q=>q.version==M),z=j?Js(j):Qn("version.unknown");v=Qn("version.restoreFrom",{from:z})}w("div",["version-item-restore-from"],d,v),w("div",["version-item-memo"],d,((_=i.extra)==null?void 0:_.memo)||"");const B=w("ul",["version-item-authors"],d),D=M=>{const j=w("li",["version-item-author"],B),z=w("span",["version-item-author-mark"],j);z.style.background=this.options.getMarkColor(M),w("span",["version-item-author-name"],j,M.displayName).setAttribute("data-editor-tooltip-common",O.t("version.tooltip.user",{name:M.displayName}))};if(this.options.useCreatedBy)if(i.createdBy){const M=i.createdBy;D(M)}else i.authors&&i.authors.length>0&&i.authors.forEach(M=>{D(M)});else if(i.authors&&i.authors.length>0)i.authors.forEach(M=>{D(M)});else if(i.createdBy){const M=i.createdBy;D(M)}};return e.forEach((i,s)=>{r(i,!1,e,s===0),i.minorVersions&&i.minorVersions.length>0&&i.minorVersions.forEach(l=>{r(l,!0,e,!1)})}),o}isVersionElement(e){return e?xe(e,"version-item"):!1}getVersionFromElement(e){return e.versionData}get activeVersion(){return this.options.versions.find(e=>e.version===this.selectedVersion)}setActiveItem(e){if(xe(e,"active"))return;const t=this.versionsList.querySelector(".version-item.active");t&&te(t,"active"),W(e,"active"),this.selectedVersion=this.getVersionFromElement(e).version}handleAddMemo(e,t){this.editItemMemo(t)}editItemMemo(e){var o;this.memoInput||(this.memoInput=new eV(256,{onend:this.handleEndEditItemMemo,classes:["memo-input"],placeholder:Qn("version.textarea.placeholder")}));const t=e.querySelector(".version-item-restore-from");g(gy,t,"no title element"),t.insertAdjacentElement("afterend",this.memoInput.root),W(e,"editing"),this.memoInput.setValue(((o=e.versionData.extra)==null?void 0:o.memo)||""),this.memoInput.resetSize(),this.memoInput.focus()}updateHeaderCount(e){const t=this.versionsListHeader.querySelector(".version-count");t&&(t.textContent=Qn("version.versionList",{count:`${e.toString()}`}))}getVersionItemByVersionNum(e){const t=Array.from(this.versionsList.children).find(o=>o.versionData.version===e);return this.isVersionElement(t)?t:null}selectVersionByVersionNum(e){const t=this.getVersionItemByVersionNum(e);return t?(this.setActiveItem(t),this.getVersionFromElement(t)):null}render(e){e.innerHTML="",e.append(this.versionsListHeader,this.versionsList)}destroy(){this.versionsList.onclick=null,this.versionFilterToolbar.destroy()}}class nV{constructor(e,t){this.doc=e,this.user=t}onDeleteBlock(e,t){this.doc.onDeleteBlock(e,t,this.user)}onInsertBlock(e,t,o){this.doc.onInsertBlock(e,t,o,this.user)}onUpdateBlockText(e,t,o){this.doc.onUpdateBlockText(e,t,o,this.user)}onUpdateBlockData(e,t,o){this.doc.onUpdateBlockData(e,t,o,this.user)}onCreateContainer(e,t){this.doc.onCreateContainer(e,t,this.user)}onCreateComment(){}onDeleteComment(){}onDeleteContainer(){}onUpdateComment(){}}async function oV(n,e,t){for(const o of t){const r=new nV(n,o.user);e.parseHistoryData(o,r)}}const An=S("split-text-actions");function py(n){return n.length>2?!1:n.length===1?n[0].insert!==void 0:(g(An,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].insert!==void 0)}function Cy(n){return n.length>2?!1:n.length===1?n[0].delete!==void 0:(g(An,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].delete!==void 0)}function Ay(n){return n.length>2?!1:n.length===1?n[0].insert===void 0&&n[0].delete===void 0&&n[0].attributes!==void 0:(g(An,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].attributes!==void 0)}function rV(n){const e=[],t=fe.default(n);if(t.length===0)return[];if(t.length===1)return[n];if(t.length===2&&(Cy(n)||py(n)||Ay(n)))return[n];const o=(i,s)=>i>0?[{retain:i},s]:[s];let r=0;for(;t.length>0;){const i=t[0];if(i.retain!==void 0&&i.attributes===void 0){g(An,i.retain>0,`invalid text op: ${JSON.stringify(i)}`),g(An,t.length>1,`invalid text op: ${JSON.stringify(i)}`);const s=t[1];g(An,s.delete||s.insert!==void 0||s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=i.retain,e.push(o(r,s)),s.delete!==void 0?r-=s.delete:s.insert!==void 0?r+=s.insert.length:(g(An,s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),g(An,s.retain!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=s.retain),t.splice(0,2)}else g(An,i.delete||i.insert!==void 0||i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),e.push(o(r,i)),t.shift(),i.retain!==void 0&&(g(An,i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),r+=i.retain),i.insert&&(r+=i.insert.length)}return e}function by(n){if(g(An,n.length===1||n.length===2,`not a single action op: ${JSON.stringify(n)}`),n.length===1)return 0;const e=n[0].retain;return g(An,typeof e=="number"&&e>0,`invalid retain: ${JSON.stringify(n)}`),e}let vy=0;function iV(n,e,t){const o=vy;vy+=1;const r=rt(n);return{insert:" ",attributes:{box:!0,id:K(),type:"history-deleted-box",user:t,created:Date.now(),text:r,deletedOffset:e,deletedOrder:o}}}function sV(n,e,t){const o=by(e),r=e.length===1?e[0].delete:e[1].delete;g(An,typeof r=="number",`not a delete op: ${JSON.stringify(e)}`);const{left:i,middle:s,right:l}=zt(n,o,r),a=iV(s,o,t);return[...i,a,...l]}function lV(n,e,t){const o=by(e),r=e.length===1?e[0].insert:e[1].insert;g(An,typeof r=="string",`invalid insert op: ${JSON.stringify(e)}`);const i=e.length===1?e[0].attributes:e[1].attributes,l=ch([{insert:r,attributes:i}],"insertedBy",t);return $r(n,o,l,null)}function cV(n,e,t){const o=rV(e);let r=n;for(const i of o)Cy(i)?r=sV(r,i,t):py(i)?r=lV(r,i,t):(g(An,Ay(i),`unknown op: ${JSON.stringify(i)}`),r=ln.apply(r,i));return r}const aV=S("history-update-block-text");function yy(n){const e=[],t=[];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"){e.push({boxData:s,offset:o});return}}t.push(r),o+=cg(r)}),e.sort((r,i)=>i.offset-r.offset),{deletedBoxes:e,newText:t}}function uV(n,e,t){let o=n;return e.forEach(r=>{const i=ln.transformCursor(r.offset,t,!1);o=$r(o,i,[{insert:" ",attributes:r.boxData}],null)}),o}function dV(n){n.sort((e,t)=>e.boxData.deletedOffset!==t.boxData.deletedOffset?e.boxData.deletedOffset-t.boxData.deletedOffset:e.boxData.deletedOrder-t.boxData.deletedOrder)}function hV(n){if(n.length<=1)return n;const e=n[0].offset;n.forEach(t=>{g(aV,t.offset===e,`invalid boxes group, ${JSON.stringify(n)}`)}),dV(n);for(let t=n.length-1;t>=1;t--){const o=n[t],r=n[t-1];o.boxData.user.userId===r.boxData.user.userId&&(r.boxData.text+=o.boxData.text,n.splice(t,1))}return n}function fV(n){let{newText:e,deletedBoxes:t}=yy(n);const o=new Map;return t.forEach(i=>{let s=o.get(i.offset);s||(s=[],o.set(i.offset,s)),s.push(i),s.sort((l,a)=>l.boxData.deletedOffset-a.boxData.deletedOffset)}),Array.from(o.values()).sort((i,s)=>s[0].offset-i[0].offset).forEach(i=>{const s=i[0].offset;hV(i).reverse().forEach(l=>{e=$r(e,s,[{insert:" ",attributes:l.boxData}],null)})}),e}function mV(n,e,t){let{newText:o,deletedBoxes:r}=yy(n);return o=cV(o,e,t),o=uV(o,r,e),o=fV(o),o}const Cr=S("history-doc");function Ar(n){g(Cr,!1,"no local actions for history doc")}class gV extends ua{constructor(e,t){super(),this.externalDoc=e,this.docObject=t}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return fe.default(this.docObject)}getContainerBlocks(e){return this.docObject.blocks[e]}getBlockData(e,t){const o=this.getContainerBlocks(e);g(Cr,o,`no container data: ${e}`);const r=o[t];return g(Cr,r,`no block data: ${t}`),r}localUpdateBlockText(){Ar()}localUpdateBlockData(){Ar()}localInsertBlock(){Ar()}localDeleteBlock(){Ar()}localInsertChildContainer(){Ar()}localDeleteChildContainers(){Ar()}uploadResource(){Ar()}async addResources(e){Ar()}getServerMeta(){var e,t,o;return(o=(t=(e=this.externalDoc).getServerMeta)==null?void 0:t.call(e))!=null?o:{}}buildResourceUrl(e){return this.externalDoc.buildResourceUrl(e)}request(){Ar()}broadcastMessage(){Ar()}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new Oh}destroy(){this.clearCallbacks()}transformBlockIndex(e,t,o){const r=this.docObject.blocks[e];g(Cr,r,`no container blocks: ${e}`);let i=0;for(let s=0;s<r.length;s++)if(!r[s].deletedBy){if(i===t)return s;i++}return o&&g(Cr,!1,`invalid block index: ${t}, blocks: ${JSON.stringify(r)}`),g(Cr,i===t,`invalid block index: ${t}, blocks: ${JSON.stringify(r)}`),r.length}onDeleteBlock(e,t,o){const r=this.transformBlockIndex(e,t,!0),s=this.docObject.blocks[e][r];g(Cr,!s.deleted,`block has already deleted: ${e}/${t}`),s.deletedBy=o,this.callbacks.forEach(l=>{var a;return(a=l.onUpdateBlockData)==null?void 0:a.call(l,e,r,{insert:{},delete:[]},!0)})}onInsertBlock(e,t,o,r){const i=this.transformBlockIndex(e,t,!1),s=this.docObject.blocks[e],l=fe.default(o);l.insertedBy=r,s.splice(i,0,l),this.callbacks.forEach(a=>{var d;return(d=a.onInsertBlock)==null?void 0:d.call(a,e,i,l,!0)})}onUpdateBlockText(e,t,o,r){const i=this.transformBlockIndex(e,t,!0),l=this.docObject.blocks[e][i];g(Cr,!l.deleted,`block has already deleted: ${e}/${t}`);const a=l.text;g(Cr,a,`no text for block: ${JSON.stringify(l)}`);const d=mV(a,o,r);l.text=d,this.callbacks.forEach(h=>{var p;return(p=h.onUpdateBlockText)==null?void 0:p.call(h,e,i,o,!0)})}onUpdateBlockData(e,t,o,r){const i=this.transformBlockIndex(e,t,!0),s=this.docObject.blocks[e],l=s[i];g(Cr,!l.deleted,`block has already deleted: ${e}/${t}`);const a=fe.default(l);a.updatedBy=r,o.delete.forEach(d=>delete a[d]),Object.entries(o.insert).forEach(([d,h])=>{a[d]=h}),s[i]=a,this.callbacks.forEach(d=>{var h;return(h=d.onUpdateBlockData)==null?void 0:h.call(d,e,i,o,!0)})}onCreateContainer(e,t,o){this.docObject.blocks[e]=fe.default(t),this.callbacks.forEach(r=>{var i;return(i=r.onInsertChildContainer)==null?void 0:i.call(r,e,t,!0)})}}const{t:ky}=O;function Ic(n,e){return e==="insert"?ky("version.insert",{name:n.displayName}):ky("version.delete",{name:n.displayName})}function Ks(n,e){const{userId:t}=e;return["flag","selection"].reduce((r,i)=>{const s=n.getRemoteUsers().getFixedUserColor(t,i);return r[i]=s,r},{})}class pV{renderText(e,t,o){if(!o.box&&o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=Ks(e.doc,o.insertedBy);return{classes:["history-inserted-text"],attributes:{"history-inserted-by":r.displayName,"data-op-description":Ic(r,"insert")},styles:{[Ec]:i,[xc]:s}}}return{}}renderBlock(e,t,o){if(o.deletedBy){const r=o.deletedBy,{flag:i,selection:s}=Ks(e.doc,r);return{classes:["history-deleted-block"],attributes:{"history-deleted-by":r.displayName,"data-op-description":Ic(r,"delete")},styles:{[Ec]:i,[xc]:s}}}if(o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=Ks(e.doc,r);return{classes:["history-inserted-block"],attributes:{"history-inserted-by":r.displayName,"data-op-description":Ic(r,"insert")},styles:{[Ec]:i,[xc]:s}}}return{}}updateBlock(e,t,o,r){if(r.deletedBy){const i=r.deletedBy,{flag:s,selection:l}=Ks(e.doc,i);W(o,"history-deleted-block"),gm(o,{"history-inserted-by":i.displayName,"data-op-description":Ic(i,"delete")}),pm(o,{[Ec]:s,[xc]:l});return}if(r.insertedBy){const i=r.insertedBy,{flag:s,selection:l}=Ks(e.doc,i);W(o,"history-inserted-block"),gm(o,{"history-inserted-by":i.displayName,"data-op-description":Ic(i,"insert")}),pm(o,{[Ec]:s,[xc]:l})}}}const wy=S("history-deleted-box");function CV(n,e,t,o){const r=o;g(wy,r.text,`no text for text box data: ${JSON.stringify(o)}`),g(wy,typeof r.text=="string",`invalid text type for text box data: ${JSON.stringify(o)}`);const i=w("span",["history-deleted-box"],t,r.text),s=r.user,{flag:l,selection:a}=Ks(n.doc,s);i.setAttribute("history-deleted-by",s.displayName),i.setAttribute("data-op-description",Ic(s,"delete")),i.style.setProperty(Ec,l),i.style.setProperty(xc,a)}function AV(n,e,t,o){return e.text}const bV={boxType:"history-deleted-box",updateBoxContent:CV,convertTo:AV},Pne="",vV=S("versions-dropdown"),By=(n,e)=>{if(!e)return n;let t="";const o=e.length,r=e.toLocaleLowerCase();let i=0;for(i=0;i<=n.length-o;i){let s=n.substring(i,i+o);if(s.toLocaleLowerCase()===r){i+=o;const l=n.charAt(i);let a=!1;s.endsWith(" ")&&(a=!0,s=s.trimEnd()),t+=`<span class="highlight">${s}${l===" "||a?"&nbsp":""}</span>`}else t+=n.charAt(i),i++}return i<n.length&&(t+=n.substring(i)),t};class yV{constructor(e,t){m(this,"dropdown");m(this,"versions",[]);m(this,"currentVersion",null);m(this,"compareWithVersion",null);m(this,"filterMemoed",!1);m(this,"keywords","");m(this,"createFilterMemoedFilterItem",e=>{const t=w("div",["filter-memoed-version-item"],null);e&&w("div",["filter-item-info"],t,O.t("version.dropdown.header"));const o=w("div",["filter-item-input-container"],t),r=w("input",["filter-item-input"],o);r.id="filter-item-input",r.type="checkbox";const i=w("label",["filter-item-label"],o,O.t("version.filterMemoed"));return i.htmlFor=r.id,r.onchange=this.handleInputChange,r.checked=this.filterMemoed,t});m(this,"filterItems",(e,t)=>{var i,s;if(this.keywords=t,!t)return!0;if(e.id==="section")return!1;const o=t.toLocaleLowerCase();if(e.name.toLocaleLowerCase().indexOf(o)!==-1)return!0;const r=e.data;return!!(r&&((i=r.extra)==null?void 0:i.memo)&&((s=r.extra)==null?void 0:s.memo.toLocaleLowerCase().indexOf(o))!==-1)});m(this,"handleClose",()=>{});m(this,"handleClear",()=>{this.options.onCompareWithVersion(null)});m(this,"handleClickItem",e=>{const t=e.data,o=Js(t);this.dropdown.setText(o),this.options.onCompareWithVersion(t)});m(this,"handleInputChange",e=>{const t=e.target;this.filterMemoed=t.checked,this.resetItems()});this.options=t,this.dropdown=new Dp(e,{placeholder:O.t("version.noSelectedVersion"),emptyPlaceholder:O.t("version.noFilterVersion"),popupId:"versions-dropdown-popup",header:this.createHeader(),filter:this.filterItems,onClose:this.handleClose,onClickItem:this.handleClickItem,onClear:this.handleClear,highlight:!0})}createHeader(){const e=w("div",["versions-dropdown-header"],null),t=w("span",["versions-dropdown-header-info"],e);t.innerHTML=O.t("version.dropdownHeader");const o=w("span",["versions-dropdown-header-icon"],e);return o.setAttribute("data-editor-tooltip-common",O.t("version.tooltip.help")),o.setAttribute("data-editor-tooltip-placement","right"),o.innerHTML=cA,o.onclick=this.options.onHelp,e}setVersions(e){this.versions=e}setCurrentVersion(e,t){this.dropdown.setText(""),this.dropdown.setLabels([]),t&&(this.dropdown.setText(Js(t)),(t.version===-1||t.version===this.versions[0].version)&&this.dropdown.setLabels([O.t("version.latest")])),this.currentVersion=e,this.compareWithVersion=t!=null?t:null,this.resetItems()}resetItems(){var A;if(this.versions.length===0)return;const e=this.currentVersion;if(!e)return;const t=e.version===-1?0:this.versions.findIndex(v=>v.version===e.version);g(vV,t!==-1,"version not found");const o=this.versions[0],r=v=>{var j;const B=v.data,D=w("div",["version-item-container"],null),x=w("div",["version-item-line1"],D),_=v.value==="last-version"?O.t("version.lastVersion"):Js(B),M=w("div",["version-item-name"],x);if(this.keywords?M.innerHTML=By(_,this.keywords):M.innerText=_,B.version===o.version&&w("div",["version-item-latest"],x,O.t("version.latest")),(j=B.extra)!=null&&j.memo){const z=w("div",["version-item-line2"],D),q=w("div",["version-item-memo"],z,B.extra.memo);this.keywords?q.innerHTML=By(B.extra.memo,this.keywords):q.innerText=B.extra.memo,q.setAttribute("data-editor-tooltip-common",B.extra.memo),q.setAttribute("data-editor-tooltip-placement","bottom")}return D.onclick=()=>{this.handleClickItem(v),this.dropdown.close()},D},i=[],s=this.versions[t+1],l=s&&!Yf(e);if(l){const v={id:"section",value:"last-version",name:"Last version",data:s,element:r};i.push(v)}let a=t;for(let v=t-1;v>=0;v-=1){const B=this.versions[v];if(Yf(B))break;a=v}let d=t;if(!Yf(e))for(let v=t+1;v<this.versions.length;v+=1){const B=this.versions[v];if(d=v,Yf(B))break}let h=!1;const p=[];for(let v=a;v<=d;v+=1){const B=this.versions[v];if(B.version!==e.version&&B.version!==(s==null?void 0:s.version)&&(!this.filterMemoed||((A=B.extra)==null?void 0:A.memo))){h=!0;let D=Js(B),x=`${B.version}`;v===t+1&&(D="Previous version",x="prev-version");const _={id:x,name:D,data:B,element:r};p.push(_)}}if((l||h||this.filterMemoed)&&i.push({id:"section",name:"",element:this.createFilterMemoedFilterItem(i.length>0&&l),states:["disabled"]}),i.push(...p),!h){const v={id:"section",name:"No versions",states:["disabled"],element:w("span",["version-item-empty"],null,O.t("version.noVersions"))};i.push(v)}this.dropdown.updateItems(i)}}class kV{constructor(e,t){m(this,"left");m(this,"right");m(this,"dropdown");const o=w("div",["version-info-container"],e);this.left=w("div",["version-info-left"],o),this.dropdown=new yV(o,t),this.right=w("div",["version-info-right"],o)}setVersion(e,t){const o=`${Js(e)}<span class="version-item-latest">${O.t("version.latest")}</span>`;this.left.innerHTML=O.t("version.versionInfoLeft",{versionName:o}),this.right.innerHTML=O.t("version.versionInfoRight",{versionName:o}),this.dropdown.setCurrentVersion(e,t)}}const es=S("version-dialog");class Ey{constructor(e,t){m(this,"dialog",null);m(this,"oldViewer",null);m(this,"versionOptions");m(this,"versionList",null);m(this,"provider");m(this,"versions",[]);m(this,"components");m(this,"handleRevert",async e=>{var o,r,i;g(es,this.versionList,"The versionList did not render");const t=e!=null?e:(o=this.versionList)==null?void 0:o.activeVersion;g(es,t,`The version: ${t} is invalid`),!(((r=this.versionOptions)==null?void 0:r.onBeforeRevert)&&await this.versionOptions.onBeforeRevert(t))&&(await this.versionHelper.revertVersion(t.version),(i=this.dialog)==null||i.hide())});m(this,"handleSelectVersion",e=>{g(es,e,`The version: ${e} is invalid`),this.viewVersion(e)});m(this,"handleCompareWithVersion",e=>{var o;const t=(o=this.versionList)==null?void 0:o.activeVersion;g(es,t,"no active version"),this.viewVersion(t,e!=null?e:void 0)});m(this,"handleHelp",()=>{var e,t;(t=(e=this.versionOptions)==null?void 0:e.onHelp)==null||t.call(e)});m(this,"viewVersion",async(e,t)=>{var d,h;if(this.components.infoHeader.setVersion(e,t),this.oldViewer&&(this.oldViewer.destroy(),this.oldViewer=null),!this.versionList)return;(d=this.versionOptions)!=null&&d.onWillChangeVersion&&this.versionOptions.onWillChangeVersion(this,e);const o=t==null?void 0:t.version;let r,i;if(o){const p=Math.min(e.version,o),A=Math.max(e.version,o),v=await this.versionHelper.getHistoryData(A,p);r=v.doc,i=v.historyData}else r=await this.versionHelper.getVersion(e.version),i=[];const{editorContainer:s}=this.components;s.innerHTML="";const l=new gV(this.doc,r),a=this.provider.createHistoryEditor(s,l);a.editorBlockRenders.registerRender(new pV),a.editorBoxes.registerBoxClass(bV),W(a.rootElement,my.HISTORY);try{await oV(l,this.versionHelper,i)}finally{this.oldViewer=a}(h=this.versionOptions)!=null&&h.onVersionChanged&&this.versionOptions.onVersionChanged(this,a,e)});m(this,"onMemoChanged",e=>{var t,o;(o=(t=this.versionOptions)==null?void 0:t.onMemoChanged)==null||o.call(t,e),this.components.infoHeader.dropdown.resetItems(),this.components.infoHeader.dropdown.setVersions(this.versions)});this.doc=e,this.provider=t;const o=w("div",["version-dialog"],null),r=w("div",["version-viewer"],o),i=new kV(r,{onCompareWithVersion:this.handleCompareWithVersion,onHelp:this.handleHelp}),s=w("div",["version-dialog-editor"],r),l=w("div",["version-list-root"],o);this.components={root:o,editorContainer:s,listContainer:l,infoHeader:i}}get versionHelper(){g(es,this.doc.getVersionHelper,"Can not get getVersionHelper from doc");const e=this.doc.getVersionHelper();return g(es,e,"current doc does not support version"),e}get editor(){return this.oldViewer}renderContent(e){var r,i;const{listContainer:t}=this.components;t.innerHTML="";const o=new tV({enableEdit:((r=this.versionOptions)==null?void 0:r.enableEdit)||!1,versions:e,versionHelper:this.versionHelper,useCreatedBy:(i=this.versionOptions)==null?void 0:i.useCreatedBy,onSelectVersion:this.handleSelectVersion,onRevert:this.handleRevert,onMemoChanged:this.onMemoChanged,getMarkColor:s=>{const{flag:l}=Ks(this.doc,s);return l}});o.render(t),this.versionList=o}initViewVersion(){var e;if(g(es,this.versionList,"no versionList"),(e=this.versionOptions)!=null&&e.initSelectedVersion){const{initSelectedVersion:t}=this.versionOptions,o=this.versionList.selectVersionByVersionNum(t);g(es,o,`version ${t} not found`),this.viewVersion(o)}else{const t=this.versionList.activeVersion;t&&this.viewVersion(t)}}async show(e){if(this.versionOptions={...this.versionOptions,...e},this.versions=await this.versionHelper.getVersions(),this.versionOptions.onVersionsLoaded&&this.versionOptions.onVersionsLoaded(this,this.versions),this.components.infoHeader.dropdown.setVersions(this.versions),this.renderContent(this.versions),this.initViewVersion(),!this.dialog){const{root:t}=this.components;this.dialog=new Xz(t)}this.dialog.show(e.container)}destroy(){var e,t;(e=this.dialog)==null||e.destroy(),(t=this.versionList)==null||t.destroy()}}const Nne="",wV=S("heading-collapse");function I2(n){var t;const e=Number.parseInt((t=n.getAttribute("data-style-heading"))!=null?t:"",10);return g(wV,e,"not a heading block"),e}function fo(n){return!!n.getAttribute("data-style-heading")}function BV(n){return!xe(n,"heading-collapsed")}function Xs(n){return xe(n,"heading-collapsed")}function xy(n){if(lt(n))return!1;const t=ne(n);return Xe(t)}const EV=S("heading-collapse");function T2(n){g(EV,fo(n),"not a heading block");const e=[],t=I2(n);let o=Ze(n);for(;o&&!(fo(o)&&I2(o)<=t);)e.push(o),o=Ze(o);return e}function Iy(n,e){if(!ro(e))return;n.selection.selectBlock(e,0),T2(e).forEach(o=>{NC(o)}),W(e,"heading-collapsed")}function Tc(n,e){T2(e).forEach(o=>{$C(o)}),te(e,"heading-collapsed")}function xV(n,e){BV(e)?Iy(n,e):Tc(n,e)}const IV=[Ap,bp,vp,yp,kp,wp,Bp,Ep];function TV(n){const e=w("button",["heading-collapse-button"],null);return e.setAttribute(`data-editor-tooltip-${n.clientId}`,"Collapse / Expand"),e.innerHTML=qh,e}function Ty(n){return Df(n).querySelector("button.heading-collapse-button")}function Dy(n,e){Ty(e)||xy(e)||!ro(e)||Q0(e,TV(n),-1)}function DV(n){var e;(e=Ty(n))==null||e.remove()}function Sy(n,e){Df(e).querySelector("button.heading-collapse-button")||Dy(n,e)}function SV(n){const e=I2(n),t=w("button",["heading-marker"],null);return t.innerHTML=IV[e-1],t}function Ly(n){return Df(n).querySelector("button.heading-marker")}function D2(n){Ly(n)||xy(n)||!ro(n)||Q0(n,SV(n),1)}function My(n){const e=Ly(n);e==null||e.remove()}function Ry(n){My(n),fo(n)&&D2(n)}class LV{handleDrop(e,t,o,r){if(Wd(t)||!fo(t)||!Xs(t))return;const i=T2(t);i.unshift(t);const s=i.reverse();let l=null;return e.doc.beginBatchUpdate(),s.forEach((a,d,h)=>{const p=e.getBlockData(a),A=Fi(e.editorBlocks,e.doc.toJSON(),p),v=e.insertDocAt(o,r,A)[0];d===h.length-1&&(l=v)}),e.doc.endBatchUpdate(),e.doc.beginBatchUpdate(),s.forEach(a=>{e.deleteBlock(a)}),e.doc.endBatchUpdate(),l&&Iy(e,l),!0}}const MV=S("heading-collapse");class Oy{constructor(e){m(this,"handleLoad",()=>{this.showCollapseButtons()});m(this,"handleHoverBlock",(e,t)=>{t&&(te(t,"hovering-heading"),fo(t)&&Xe(ne(t))&&(D2(t),Xs(t)||DV(t))),e&&fo(e)&&Xe(ne(e))&&(W(e,"hovering-heading"),this.editor.readonly||My(e),Dy(this.editor,e))});m(this,"handleClick",(e,t)=>{const o=$l(t,"button.heading-collapse-button");if(!o)return;const r=oe(o);!r||(g(MV,fo(r),"not a heading block"),xV(this.editor,r),Sy(this.editor,r))});this.editor=e,e.addListener("load",this.handleLoad),e.addListener("click",this.handleClick),gt.get(e).addListener("change",this.handleHoverBlock),this.showCollapseButtons(),setTimeout(()=>{var o;(o=Du.find(e))==null||o.addHandler(new LV)})}showCollapseButtons(){const e=bt(this.editor.rootContainer).filter(fo);e.length!==0&&(e[0]===St(this.editor.rootContainer)&&e.splice(0,1),e.forEach(D2))}destroy(){this.editor.removeListener("load",this.handleLoad),this.editor.removeListener("click",this.handleClick)}}function Jf(n){const e=n.selection.range;if(e.isCollapsed()||e.start.blockId===e.end.blockId)return;const t=n.getBlockById(e.start.blockId),o=n.getBlockById(e.end.blockId);Xs(t)&&Tc(n,t),Xs(o)&&Tc(n,o)}function RV(n){Jf(n);const e=n.getFocusedBlock();!fo(e)||Xs(e)&&Tc(n,e)}function OV(n){Jf(n);const e=n.getFocusedBlock();if(!fo(e))return;const t=n.selection.range.focus;!t.isSimple()||t.offset===ue(n,e)&&Xs(e)&&Tc(n,e)}function _V(n){Jf(n);const e=n.getFocusedBlock();if(!fo(e))return;const t=n.selection.range.focus;!t.isSimple()||t.offset===0&&Xs(e)&&Tc(n,e)}class FV{handleBeforeKeyDown(e,t){return km(t.key)&&Jf(e),t.key==="Enter"?(RV(e),!1):t.key==="Delete"?(OV(e),!1):(t.key==="Backspace"&&_V(e),!1)}}class PV{constructor(e){this.editor=e}onInsertBlock(e,t,o,r){this.updateBlockIfNeeded(o.id)}onUpdateBlockData(e,t,o,r){const i=this.editor.doc.getBlockData(e,t);this.updateBlockIfNeeded(i.id,o)}updateBlockIfNeeded(e,t){setTimeout(()=>{const o=this.editor.findBlockById(e);if(!!o){if(!fo(o)){t&&t.delete.includes("heading")&&Ry(o);return}xe(o,"hovering-heading")&&Sy(this.editor,o),Ry(o)}},100)}}function NV(n){return!!n.heading}function _y(n){var t;const e=n.heading;return(t=Number.parseInt(`${e}`,10))!=null?t:1}function Fy(n,e,t){var i;const o=Ss(n,e.type);let r="";if(o.convertTo){const s=Hr();r=o.convertTo(n,e,s,"text",[{containerId:"root",blockIndex:0}]),r=r.replace(/\n/g,"").trim()}else r=rt((i=e.text)!=null?i:[]);return{parentNode:t,children:[],text:r,level:_y(e),block:e}}class Fu{constructor(e){m(this,"nodes",[]);this.editor=e}appendBlock(e){const t=this.findParent(_y(e),this.nodes);t?t.children.push(Fy(this.editor,e,t)):this.nodes.push(Fy(this.editor,e,null))}findParent(e,t){const o=t[t.length-1];if(!o||e<=1)return null;if(o.level===e-1)return o;const r=this.findParent(e,o.children);return r||(o.level<e?o:null)}static buildToc(e,t){const o=new Fu(e),r=t.blocks.root;for(let i=0;i<r.length;i++){const s=r[i];NV(s)&&o.appendBlock(s)}return o}}class el extends At.TypedEmitter{constructor(t){super();m(this,"toc");m(this,"updateToc",Ht.default(()=>{this.updateTocNow()},500));this.editor=t,t.doc.registerCallback(this),this.updateToc(),this.toc=new Fu(this.editor)}destroy(){this.editor.doc.unregisterCallback(this)}isHeadingBlock(t){return!!t.heading}onInsertBlock(t,o,r,i){t==="root"&&this.isHeadingBlock(r)&&this.updateToc()}onDeleteBlock(t,o,r){t==="root"&&this.updateToc()}onUpdateBlockText(t,o,r,i){if(t!=="root")return;const s=this.editor.doc.getBlockData(t,o);this.isHeadingBlock(s)&&this.updateToc()}onUpdateBlockData(t,o,r,i){if(t!=="root")return;const s=this.editor.doc.getBlockData(t,o);this.isHeadingBlock(s)&&this.updateToc()}static register(t){return t.addCustom("editor-toc",()=>new el(t))}static get(t){return t.getCustom("editor-toc")}updateTocNow(){this.toc=Fu.buildToc(this.editor,this.editor.doc.toJSON()),this.emit("change",this.editor,this.toc)}}const $ne="";function $V(n){return n.nodes.length===0?!0:n.nodes.length>1?!1:n.nodes[0].children.length===0}function Py(n,e){e.forEach(t=>{const o=w("div",["toc-node"],n),r=w("div",["toc-title"],o);if(w("span",["toc-text"],r,t.text).setAttribute("data-block-id",t.block.id),t.children.length>0){const s=w("div",["toc-children"],o);Py(s,t.children)}})}function HV(n,e){const t=$l(e,".toc-text");if(!t)return;const o=t.getAttribute("data-block-id");if(!o)return;const r=n.findBlockById(o);!r||(e.preventDefault(),e.stopPropagation(),n.selection.selectBlock(r,0))}function Ny(n,e,t){if(te(e,"loading"),e.innerHTML="",$V(t)){w("div",["toc-empty-message"],e,O.t("toc.empty"));return}if(t.nodes.length>=1){const[o,...r]=t.nodes,i=[...o.children,...r];Py(e,i)}Xg(n,"toc-click-handler",()=>{n.addListener("click",HV)})}class jV{constructor(e){m(this,"handleUpdateToc",(e,t)=>{Array.from(e.rootContainer.querySelectorAll('.embed-block[data-type="editor-block"][data-embed-type="toc"]')).forEach(r=>{const i=r.querySelector(".editor-toc-container");i&&Ny(e,i,t)})});this.editor=e,el.register(e).addListener("change",this.handleUpdateToc)}destroy(){el.register(this.editor).removeListener("change",this.handleUpdateToc)}get toc(){return el.register(this.editor).toc}}function UV(n,e){const t=w("div",["editor-toc-container"],e),r=n.addCustom("init-editor-toc",()=>new jV(n)).toc;r.nodes.length===0?W(t,"loading"):Ny(n,t,r)}function zV(n,e,t,o){return o==="markdown"?"[toc]":""}function VV(n,e,t){const{data:o}=t;if(!o||o.embedType!=="toc"||!ee(n,e))return null;const r={};return{blockData:{id:K(),type:"embed",embedType:"toc",embedData:r}}}const $y={embedType:"toc",createEmbedContent:UV,convertTo:zV,convertFrom:VV},WV={toc:{empty:"No Toc"}},qV={toc:{empty:"No Toc"}},GV={toc:{empty:"No Toc"}};O.mergeLang({"zh-CN":WV,"en-US":qV,"ja-JP":GV});function ZV(n){return!!n.getAttribute("data-style-heading")}function S2(n,e){return ZV(e)&&ue(n,e)>0}function QV(n){const e=oo(n.rootElement);let t=0,o=0,r=0;if(e===document.documentElement){const i=n.rootContainer.getBoundingClientRect();t=i.left+i.width/2,o=10,r=e.offsetHeight}else{const i=e.getBoundingClientRect();t=i.left+i.width/2,o=i.top+10,r=i.bottom}for(;o<r;){const i=document.elementsFromPoint(t,o);for(let s=0;s<i.length;s++){const l=oe(i[s]);if(l&&n.rootContainer.contains(l))return l}o+=10}return null}function L2(n,e){let t=e;for(;t&&!S2(n,t);)t=Ze(t);return t}function Hy(n){if(lt(n))return!1;const t=ne(n);return Xe(t)}function Kf(n,e){let t=e;for(;t&&!S2(n,t);)t=lt(t),t&&Hy(t)&&(t=null);return t}const YV=.3;class JV extends At.TypedEmitter{constructor(t){super();m(this,"scrollContainer");m(this,"scrollEventTarget");m(this,"scrollStatus",{curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null});m(this,"handleScroll",Ht.default(()=>{const t={curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null};let o=QV(this.editor);if(o&&(o=Hm(o)),!o||!this.scrollContainer){this.setStatus(t);return}if(Hy(o)&&(o=Ze(o)),!o){this.setStatus(t);return}if(S2(this.editor,o)){t.curHeadingBlock=o,t.previousHeadingBlock=Kf(this.editor,o),t.nextHeadingBlock=L2(this.editor,o),this.setStatus(t);return}const r=this.scrollContainer.getBoundingClientRect(),i=L2(this.editor,o);if(i){const l=i.getBoundingClientRect();if(l.top>r.top&&l.top<r.top+r.height*YV){t.curHeadingBlock=i,t.previousHeadingBlock=Kf(this.editor,i),t.nextHeadingBlock=L2(this.editor,i),this.setStatus(t);return}t.nextHeadingBlock=i}const s=Kf(this.editor,o);s&&(t.curHeadingBlock=s,t.previousHeadingBlock=Kf(this.editor,s)),this.setStatus(t)},200));this.editor=t,setTimeout(()=>{this.start()},50)}setStatus(t){this.scrollStatus.previousHeadingBlock===t.previousHeadingBlock&&this.scrollStatus.nextHeadingBlock===t.nextHeadingBlock&&this.scrollStatus.previousHeadingBlock===t.previousHeadingBlock||(this.scrollStatus=t,this.emit("change",this.editor,t))}start(){this.stop(),this.scrollContainer=oo(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 M2{constructor(e,t){m(this,"suggest");m(this,"onClose",()=>{this.editor.focus()});m(this,"onShow",(e,t,o,r)=>{const i=this.editor.getBlockByIndex(t,o);if(!ro(i)){const s=oe(ne(i));if(s&&De(s)==="code")return!1}return!0});m(this,"onClickItem",(e,t,o)=>{const r=t.data,i={id:K(),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,a=this.editor.getBlockById(l.blockId);this.editor.insertBoxToBlock(a,l.offset,i)});m(this,"queryItems",async(e,t)=>(await this.options.queryUsers(this.editor,t)).map(i=>{const s=Qd(i.displayName);return{id:i.userId,name:i.displayName,icon:i.avatarUrl?`<img src="${i.avatarUrl}" class="mention-user-avatar">`:`<span style="background: ${s}" class="mention-user-avatar-string">${Zd(i.displayName,1)}</span>`,element:i.element,data:i,subText:i.email}}));this.editor=e,this.options=t,this.suggest=new Op(e,{id:"editor-mention",trigger:["@"],autoDeleteTrigger:!0,showLoading:!0,enableFirstBlock:t.enableFirstBlock,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems,onClose:this.onClose})}destroy(){}}S("mathjax-box");function KV(n,e,t,o){const r=o,i=w("a",["mention-container"],t);w("span",["mention-name"],i,`@${r.text}`),i.setAttribute("data-mention-id",r.mentionId)}function XV(n,e,t){}function eW(n,e,t,o){return`@${e.text}`}function tW(){return{abstract:O.t("mention.abstract")}}const R2={boxType:"mention",updateBoxContent:KV,handleClickBox:XV,convertTo:eW,getBoxProperties:tW};function nW(n){const e=w("div",["mention-button-wrap"],null),t=ji("mention-button",O.t("list.mention.tooltip"),YL,[],n.clientId);return e.appendChild(t),e}class oW{constructor(e){m(this,"mentionButton");m(this,"handleHoveringBlock",e=>{var t;!this.editor.isWritable()||(e&&this.shouldBlockShowMention(e)?Et(e).appendChild(this.mentionButton):(t=this.mentionButton)==null||t.remove())});m(this,"handleMouseDown",(e,t)=>{t.preventDefault(),t.stopPropagation();const o=oe(this.mentionButton);if(!o||!ee(e,o))return;const r=e.selection.range.focus;if(!r.isSimple())return;let i;e.selection.focusedBlock!==o?i=ue(e,o):i=r.offset,setTimeout(()=>{const s=e.insertTextToBlock(o,i,"@");i+=1;const l=rt(xn(s,i).left);this.editor.selection.selectBlock(o,i),this.editor.focus(),e.getCustom("mention").suggest.popup(o,i,l,"@")})});m(this,"destroy",()=>{gt.get(this.editor).removeListener("change",this.handleHoveringBlock)});this.editor=e,this.mentionButton=nW(e),gt.get(this.editor).addListener("change",this.handleHoveringBlock),e.domEvents.addEventListener(this.mentionButton,"mousedown",this.handleMouseDown)}shouldBlockShowMention(e){if(!ee(this.editor,e)||!He(e))return!1;const t=Zn(e);return!(t==="ordered"||t==="unordered")}}const Hne="",rW={mention:{abstract:"\u6210\u5458"}},iW={mention:{abstract:"Member"}},sW={mention:{abstract:"\u30E1\u30F3\u30D0\u30FC"}};O.mergeLang({"zh-CN":rW,"en-US":iW,"ja-JP":sW});const lW={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"}},cW={templates:{title:"Choose a template",create:"New template",choose:"All templates",customizedMark:"Custom"}},aW={templates:{title:"\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3092\u9078\u629E",create:"\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3092\u65B0\u898F\u4F5C\u6210",choose:"\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u4E00\u89A7",customizedMark:"\u30AB\u30B9\u30BF\u30E0"}};O.mergeLang({"zh-CN":lW,"en-US":cW,"ja-JP":aW});const jne="",uW="data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIHZpZXdCb3g9IjAgMCAxMjAgMTIwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cmVjdCB3aWR0aD0iMTIwIiBoZWlnaHQ9IjEyMCIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTQ4IDU5QzQ4IDU0LjU4MTcgNTEuNTgxNyA1MSA1NiA1MUg5M0M5OC41MjI4IDUxIDEwMyA1NS40NzcyIDEwMyA2MVY4OEMxMDMgOTEuODY2IDk5Ljg2NiA5NSA5NiA5NUg1NkM1MS41ODE3IDk1IDQ4IDkxLjQxODMgNDggODdWNTlaIiBmaWxsPSIjRDZFOUZBIi8+CjxwYXRoIGQ9Ik0xOCA2NEMxOCA2Mi4zNDMxIDE5LjM0MzEgNjEgMjEgNjFINTZDNjAuNDE4MyA2MSA2NCA2NC41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5NS44OTQgOTguOTM2MSAxOTQuNTY1IDk4LjkzNjEgMTkyLjkyNkM5OC45MzYxIDE5MS4yODYgOTcuNjA3MiAxODkuOTU4IDk1Ljk2OCAxODkuOTU4SDkwLjAzMThaTTkwLjAzMTkgMjEzLjcwMkM4OC4zOTI3IDIxMy43MDIgODcuMDYzOCAyMTUuMDMxIDg3LjA2MzggMjE2LjY3Qzg3LjA2MzggMjE4LjMwOSA4OC4zOTI3IDIxOS42MzggOTAuMDMxOSAyMTkuNjM4SDk1Ljk2ODFDOTcuNjA3MyAyMTkuNjM4IDk4LjkzNjIgMjE4LjMwOSA5OC45MzYyIDIxNi42N0M5OC45MzYyIDIxNS4wMzEgOTcuNjA3MyAyMTMuNzAyIDk1Ljk2ODEgMjEzLjcwMkg5MC4wMzE5WiIgZmlsbD0iIzkxRDlCRSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEyNTZfMzcxNjgiPgo8cmVjdCB3aWR0aD0iMzcyIiBoZWlnaHQ9IjI3OSIgZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K",jy=S("templates");function O2(n){const e=n.rootElement.querySelector(":scope .editor-templates");if(!e)return null;const t=e.querySelector(":scope .editor-templates-cards");return g(jy,t,"no card container"),{root:e,cardContainer:t}}function hW(n){const e=O2(n);if(e)return e.cardContainer.innerHTML="",e;const t=w("div",["editor-templates"],n.rootElement);w("div",["editor-templates-title"],t,O.t("templates.title"));const o=w("div",["editor-templates-cards"],t);return{root:t,cardContainer:o}}function Uy(n,e,t,o,r){var p;const i=(p=n.options.componentsOptions)==null?void 0:p.templates,s=w("div",["editor-template-card",...o],null),l=w("div",["editor-template-thumb-container"],s),a=w("img",["editor-template-thumb"],l);a.src=e,a.style.display="none",a.onerror=()=>{var v;const A=(v=i==null?void 0:i.placeHolderImageSrc)!=null?v:dW;a.src!==A&&(a.src=A)},a.onload=()=>{a.style.display=""};const d=w("div",["editor-template-name"],s),h=w("span",[],d,t);return i!=null&&i.showTemplateTitleAttr&&h.setAttribute("title",t),s.onclick=()=>r(s),s}function fW(n,e){return e.thumbnailUrl?e.thumbnailUrl:n.doc.buildResourceUrl("thumbnail.png")}function mW(n,e){const t=fW(n,e);return Uy(n,t,e.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,e)})}function gW(n,e){return Uy(n,e,O.t("templates.choose"),["more"],()=>{var o,r;const t=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=t==null?void 0:t.onChooseTemplate)==null||r.call(t,n)})}function pW(n,e){var p,A;const t=(p=n.options.componentsOptions)==null?void 0:p.templates;if(!t)return;const r=Gt(n.rootContainer).getBoundingClientRect().width;let i=1;const s=uW,l=O2(n);if(l){if(e!=null&&e.reset){const v=Array.from(l.cardContainer.children),B=l.cardContainer.firstElementChild;if(g(jy,B,"no first card"),xe(B,"new")||xe(B,"more"))return;const D=window.getComputedStyle(B),x=parseFloat(D.marginLeft),_=parseFloat(D.marginRight),M=B.getBoundingClientRect().width+x+_;i=Math.floor(r/M);const z=Math.max(1,i-1-1),q=v.length-1;v.forEach((ie,me)=>{me>z&&me<q?ie.style.display="none":(me>=q&&xe(ie,"more"),ie.style.display="")})}return}const a=t.templates,{cardContainer:d}=hW(n);a.forEach((v,B)=>{const D=mW(n,v);if(B>0&&B>=i&&(D.style.display="none"),d.appendChild(D),B===0){const x=window.getComputedStyle(D),_=parseFloat(x.marginLeft),M=parseFloat(x.marginRight),j=D.getBoundingClientRect().width+_+M;i=Math.floor(r/j)-1}});const h=gW(n,s);d.appendChild(h),(A=t==null?void 0:t.onTemplateChooserStatusChanged)==null||A.call(t,n,d,"visible")}const zy=Ht.default(pW,50);function CW(n){var o,r;const e=O2(n);if(!e)return;e.root.remove();const t=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=t==null?void 0:t.onTemplateChooserStatusChanged)==null||r.call(t,n,null,"hide")}function AW(n){const e=n.blocks.root;if(e.length===0)return!0;if(e.length>5)return!1;const t=[...e];t[0].type==="text"&&t[0].heading&&t.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 t.every(r=>o(r))}function Xf(n,e){AW(n.doc.toJSON())?zy(n,e):(zy.cancel(),CW(n))}const bW=800;class vW{constructor(e){m(this,"longPressTimeout",0);m(this,"handleSelectionChange",()=>{});m(this,"handleLongPress",e=>{const t=e.touches[0],o=oh(this.editor,t.clientX,t.clientY);!o||console.log(o)});m(this,"handleTouchStart",e=>{e.touches.length===1&&(this.longPressTimeout=window.setTimeout(()=>{this.handleLongPress(e)},bW))});m(this,"handleTouchEnd",e=>{this.longPressTimeout&&(window.clearTimeout(this.longPressTimeout),this.longPressTimeout=0)});this.editor=e,this.editor.addListener("selectionChanged",this.handleSelectionChange),document.addEventListener("touchstart",this.handleTouchStart),document.addEventListener("touchend",this.handleTouchEnd)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChange),document.removeEventListener("touchstart",this.handleTouchStart),document.removeEventListener("touchend",this.handleTouchEnd)}}const yW=`<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
581
+ 2. \u4E8C\u3064\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u306E\u9593\u306B\u5FA9\u5143\u3055\u308C\u305F\u30D0\u30FC\u30B8\u30E7\u30F3\u304C\u3042\u308B\u5834\u5408\u3001\u3053\u306E\u4E8C\u3064\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u306F\u6BD4\u8F03\u3067\u304D\u306A\u3044\u3053\u3068\u306B\u306A\u308A\u307E\u3059\u3002`,user:"\u30D0\u30FC\u30B8\u30E7\u30F3\u4F5C\u6210\u8005\uFF1A{name}",auth:"\u3053\u306E\u30B9\u30DA\u30FC\u30B9\u3092\u7DE8\u96C6\u3059\u308B\u6A29\u9650\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u7BA1\u7406\u8005\u306B\u3054\u9023\u7D61\u304F\u3060\u3055\u3044\u3002"},dropdownHeader:"\u73FE\u5728\u306E\u30D0\u30FC\u30B8\u30E7\u30F3\u3068\u6BD4\u8F03\u3067\u304D\u308B\u30D0\u30FC\u30B8\u30E7\u30F3\u3060\u3051\u8868\u793A\u3055\u308C\u307E\u3059",dropdown:{header:"\u6BD4\u8F03\u53EF\u80FD\u306A\u30D0\u30FC\u30B8\u30E7\u30F3"},noVersions:"\u6BD4\u8F03\u53EF\u80FD\u306A\u30D0\u30FC\u30B8\u30E7\u30F3\u306F\u3042\u308A\u307E\u305B\u3093",lastVersion:"\u524D\u306E\u30D0\u30FC\u30B8\u30E7\u30F3",filterMemoed:"\u5099\u8003\u3042\u308A"}};O.mergeLang({"zh-CN":Yz,"en-US":Jz,"ja-JP":Kz});var my=(n=>(n.NEW="history-new",n.NEW_CHILD="history-new-child",n.DELETED="history-deleted",n.UPDATED="history-updated",n.HISTORY="history",n))(my||{});const Ec="--op-color",xc="--op-selected-color",One="";class Xz{constructor(e){m(this,"root");this.content=e;const t=w("div",["editor-dialog-root"],null);t.append(e),this.root=t}show(e=document.body){e.append(this.root)}hide(){this.root.remove()}destroy(){}}function Js(n){var t;let e;if(n.version!==-1){const o=new Date((t=n.created)!=null?t:n.version);e=Lm(o,"YYYY-MM-DD hh:mm")}else e=O.t("version.latest");return e}function Yf(n){return n.source&&typeof n.source=="object"&&!!n.source.restore}const _ne="";class eV{constructor(e,t){m(this,"textArea");m(this,"warning");m(this,"end",!1);m(this,"root");m(this,"handleBlur",()=>{var e,t;this.end||(t=(e=this.options)==null?void 0:e.onend)==null||t.call(e,this.textArea.value,!1)});m(this,"handleKeyDown",e=>{var t,o,r,i;e.isComposing||(e.key==="Enter"||e.key==="Tab"?(e.preventDefault(),(o=(t=this.options)==null?void 0:t.onend)==null||o.call(t,this.textArea.value,!1),this.end=!0):e.key==="Escape"&&(e.preventDefault(),(i=(r=this.options)==null?void 0:r.onend)==null||i.call(r,this.textArea.value,!0),this.end=!0))});m(this,"handleInput",e=>{const t=e.target,{value:o}=t;o.length>this.maxLength-10?this.warning.innerText=`${o.length}/${this.maxLength}`:this.warning.innerText="",this.autoSize()});var o,r;this.maxLength=e,this.options=t,this.root=w("div",["size-limit-textarea",...(o=t==null?void 0:t.classes)!=null?o:[]],null),this.textArea=w("textarea",["size-limit-textarea-input"],this.root),this.warning=w("div",["size-limit-textarea-warning"],this.root),this.textArea.addEventListener("input",this.handleInput),this.textArea.addEventListener("blur",this.handleBlur),this.textArea.addEventListener("keydown",this.handleKeyDown),this.textArea.maxLength=e,this.textArea.placeholder=(r=t==null?void 0:t.placeholder)!=null?r:""}destroy(){this.textArea.removeEventListener("input",this.handleInput),this.textArea.removeEventListener("blur",this.handleBlur),this.textArea.removeEventListener("keydown",this.handleKeyDown)}setValue(e){this.textArea.value=e,this.autoSize()}autoSize(){const e=Math.max(this.textArea.scrollHeight,60);this.textArea.style.height="auto",this.textArea.style.height=`${e}px`}resetSize(){this.textArea.style.height="auto";const e=Math.max(this.textArea.scrollHeight,60);this.textArea.style.height=`${e}px`}focus(){this.textArea.focus(),this.end=!1}}const Fne="",{t:Qn}=O,gy=S("version-list");class tV{constructor(e){m(this,"versionsList");m(this,"versionsListHeader");m(this,"versionFilterToolbar");m(this,"memoInput",null);m(this,"selectedVersion",0);m(this,"handleClickVersionItem",e=>{const t=e.target,o=t.closest(".version-item");if(!this.isVersionElement(o))return;const r=xe(o,"active");if(r&&t.closest(".version-item-memo")&&this.options.enableEdit){this.editItemMemo(o);return}const i=this.getVersionFromElement(o);if(this.setActiveItem(o),t.closest(".add-memo-button")&&this.options.enableEdit){this.handleAddMemo(i,o);return}if(t.closest(".revert-button")&&this.options.enableEdit){this.handleRevert(i,o);return}if(r)return;const{onSelectVersion:s}=this.options;s(i)});m(this,"handleEndEditItemMemo",(e,t)=>{var r,i;const o=(r=this.memoInput)==null?void 0:r.root.closest(".version-item");if(this.isVersionElement(o)&&(te(o,"editing"),!t)){const s=this.getVersionFromElement(o),l=e.replace(/[\n\r]+/g," ");if(((i=s.extra)==null?void 0:i.memo)!==l){s.extra={memo:l},this.options.versionHelper.updateVersionExtra(s.version,s.tagId,s.extra).then(()=>{var d,h;(h=(d=this.options).onMemoChanged)==null||h.call(d,s)});const a=o.querySelector(".version-item-memo");g(gy,a,"no memo element"),a.textContent=l}}setTimeout(()=>{var s;(s=this.memoInput)==null||s.root.remove()})});m(this,"handleRevert",(e,t)=>{const{onRevert:o}=this.options;o(e)});m(this,"handleFilterClick",(e,t)=>{let o=this.options.versions;t.id==="memoed"&&(o=o.filter(i=>{var s;return!!((s=i.extra)!=null&&s.memo)}));const r=this.createVersionItems(o,t.id);this.versionsList.innerHTML="",this.versionsList.append(r),this.versionFilterToolbar.updateItems(this.getFilterItems(t.id)),this.updateHeaderCount(o.length)});var d,h;this.options=e;const{versions:t}=e,o=w("div",["version-list-header"],null),r=Qn("version.versionList",{count:`${t.length}`});w("span",["version-count"],o,r);const i=w("div",["version-list-filter"],o);this.versionFilterToolbar=new oM(i,this.getFilterItems("all"),{tooltipId:"version-viewer"}),this.versionFilterToolbar.addListener("click",this.handleFilterClick),this.selectedVersion=e.selectedVersion||((d=t[0])==null?void 0:d.version)||-1;const s=w("div",["version-list-content"],null),l=this.createVersionItems(t,"all");s.append(l),this.versionsList=s,this.versionsListHeader=o,s.onclick=this.handleClickVersionItem;const a=this.activeVersion;a&&((h=this.options)==null||h.onSelectVersion(a))}getFilterItems(e){return[{id:"filter",name:Qn(e==="all"?"version.filter.all":"version.filter.memoed"),dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",children:[{id:"all",states:e==="all"?["checked"]:[],name:Qn("version.filter.allVersions")},{id:"memoed",states:e==="memoed"?["checked"]:[],name:Qn("version.filter.memoVersions")}]}]}createVersionItems(e,t){const o=document.createDocumentFragment();if(e.length===0){const i=w("div",["version-list-empty"],o);return i.textContent=Qn("version.noMemoedVersion"),o}const r=(i,s,l,a=!1)=>{var x,_;const d=w("div",["version-item"],o);d.versionData=i,s&&W(d,"child"),i.version===this.selectedVersion&&W(d,"active");const h=w("div",["version-item-title"],d);w("div",["version-item-date"],h,Js(i)),a&&w("div",["version-item-latest"],h,Qn("version.latest")),w("div",["spacer"],h);const p=w("div",["version-actions"],h),A=w("button",["add-memo-button"],p);if(A.textContent=Qn("version.memo"),this.options.enableEdit||(W(A,"disabled"),A.setAttribute("data-editor-tooltip-common",O.t("version.tooltip.auth"))),!a){const M=w("button",["revert-button"],p);M.textContent=Qn("version.revert"),this.options.enableEdit||(W(M,"disabled"),M.setAttribute("data-editor-tooltip-common",O.t("version.tooltip.auth")))}let v="";if(typeof i.source=="object"&&((x=i.source)==null?void 0:x.restore)){const M=i.source.restore,j=l.find(q=>q.version==M),z=j?Js(j):Qn("version.unknown");v=Qn("version.restoreFrom",{from:z})}w("div",["version-item-restore-from"],d,v),w("div",["version-item-memo"],d,((_=i.extra)==null?void 0:_.memo)||"");const B=w("ul",["version-item-authors"],d),D=M=>{const j=w("li",["version-item-author"],B),z=w("span",["version-item-author-mark"],j);z.style.background=this.options.getMarkColor(M),w("span",["version-item-author-name"],j,M.displayName).setAttribute("data-editor-tooltip-common",O.t("version.tooltip.user",{name:M.displayName}))};if(this.options.useCreatedBy)if(i.createdBy){const M=i.createdBy;D(M)}else i.authors&&i.authors.length>0&&i.authors.forEach(M=>{D(M)});else if(i.authors&&i.authors.length>0)i.authors.forEach(M=>{D(M)});else if(i.createdBy){const M=i.createdBy;D(M)}};return e.forEach((i,s)=>{r(i,!1,e,s===0),i.minorVersions&&i.minorVersions.length>0&&i.minorVersions.forEach(l=>{r(l,!0,e,!1)})}),o}isVersionElement(e){return e?xe(e,"version-item"):!1}getVersionFromElement(e){return e.versionData}get activeVersion(){return this.options.versions.find(e=>e.version===this.selectedVersion)}setActiveItem(e){if(xe(e,"active"))return;const t=this.versionsList.querySelector(".version-item.active");t&&te(t,"active"),W(e,"active"),this.selectedVersion=this.getVersionFromElement(e).version}handleAddMemo(e,t){this.editItemMemo(t)}editItemMemo(e){var o;this.memoInput||(this.memoInput=new eV(256,{onend:this.handleEndEditItemMemo,classes:["memo-input"],placeholder:Qn("version.textarea.placeholder")}));const t=e.querySelector(".version-item-restore-from");g(gy,t,"no title element"),t.insertAdjacentElement("afterend",this.memoInput.root),W(e,"editing"),this.memoInput.setValue(((o=e.versionData.extra)==null?void 0:o.memo)||""),this.memoInput.resetSize(),this.memoInput.focus()}updateHeaderCount(e){const t=this.versionsListHeader.querySelector(".version-count");t&&(t.textContent=Qn("version.versionList",{count:`${e.toString()}`}))}getVersionItemByVersionNum(e){const t=Array.from(this.versionsList.children).find(o=>o.versionData.version===e);return this.isVersionElement(t)?t:null}selectVersionByVersionNum(e){const t=this.getVersionItemByVersionNum(e);return t?(this.setActiveItem(t),this.getVersionFromElement(t)):null}render(e){e.innerHTML="",e.append(this.versionsListHeader,this.versionsList)}destroy(){this.versionsList.onclick=null,this.versionFilterToolbar.destroy()}}class nV{constructor(e,t){this.doc=e,this.user=t}onDeleteBlock(e,t){this.doc.onDeleteBlock(e,t,this.user)}onInsertBlock(e,t,o){this.doc.onInsertBlock(e,t,o,this.user)}onUpdateBlockText(e,t,o){this.doc.onUpdateBlockText(e,t,o,this.user)}onUpdateBlockData(e,t,o){this.doc.onUpdateBlockData(e,t,o,this.user)}onCreateContainer(e,t){this.doc.onCreateContainer(e,t,this.user)}onCreateComment(){}onDeleteComment(){}onDeleteContainer(){}onUpdateComment(){}}async function oV(n,e,t){for(const o of t){const r=new nV(n,o.user);e.parseHistoryData(o,r)}}const An=S("split-text-actions");function py(n){return n.length>2?!1:n.length===1?n[0].insert!==void 0:(g(An,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].insert!==void 0)}function Cy(n){return n.length>2?!1:n.length===1?n[0].delete!==void 0:(g(An,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].delete!==void 0)}function Ay(n){return n.length>2?!1:n.length===1?n[0].insert===void 0&&n[0].delete===void 0&&n[0].attributes!==void 0:(g(An,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].attributes!==void 0)}function rV(n){const e=[],t=fe.default(n);if(t.length===0)return[];if(t.length===1)return[n];if(t.length===2&&(Cy(n)||py(n)||Ay(n)))return[n];const o=(i,s)=>i>0?[{retain:i},s]:[s];let r=0;for(;t.length>0;){const i=t[0];if(i.retain!==void 0&&i.attributes===void 0){g(An,i.retain>0,`invalid text op: ${JSON.stringify(i)}`),g(An,t.length>1,`invalid text op: ${JSON.stringify(i)}`);const s=t[1];g(An,s.delete||s.insert!==void 0||s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=i.retain,e.push(o(r,s)),s.delete!==void 0?r-=s.delete:s.insert!==void 0?r+=s.insert.length:(g(An,s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),g(An,s.retain!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=s.retain),t.splice(0,2)}else g(An,i.delete||i.insert!==void 0||i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),e.push(o(r,i)),t.shift(),i.retain!==void 0&&(g(An,i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),r+=i.retain),i.insert&&(r+=i.insert.length)}return e}function by(n){if(g(An,n.length===1||n.length===2,`not a single action op: ${JSON.stringify(n)}`),n.length===1)return 0;const e=n[0].retain;return g(An,typeof e=="number"&&e>0,`invalid retain: ${JSON.stringify(n)}`),e}let vy=0;function iV(n,e,t){const o=vy;vy+=1;const r=rt(n);return{insert:" ",attributes:{box:!0,id:K(),type:"history-deleted-box",user:t,created:Date.now(),text:r,deletedOffset:e,deletedOrder:o}}}function sV(n,e,t){const o=by(e),r=e.length===1?e[0].delete:e[1].delete;g(An,typeof r=="number",`not a delete op: ${JSON.stringify(e)}`);const{left:i,middle:s,right:l}=zt(n,o,r),a=iV(s,o,t);return[...i,a,...l]}function lV(n,e,t){const o=by(e),r=e.length===1?e[0].insert:e[1].insert;g(An,typeof r=="string",`invalid insert op: ${JSON.stringify(e)}`);const i=e.length===1?e[0].attributes:e[1].attributes,l=ch([{insert:r,attributes:i}],"insertedBy",t);return $r(n,o,l,null)}function cV(n,e,t){const o=rV(e);let r=n;for(const i of o)Cy(i)?r=sV(r,i,t):py(i)?r=lV(r,i,t):(g(An,Ay(i),`unknown op: ${JSON.stringify(i)}`),r=ln.apply(r,i));return r}const aV=S("history-update-block-text");function yy(n){const e=[],t=[];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"){e.push({boxData:s,offset:o});return}}t.push(r),o+=cg(r)}),e.sort((r,i)=>i.offset-r.offset),{deletedBoxes:e,newText:t}}function uV(n,e,t){let o=n;return e.forEach(r=>{const i=ln.transformCursor(r.offset,t,!1);o=$r(o,i,[{insert:" ",attributes:r.boxData}],null)}),o}function dV(n){n.sort((e,t)=>e.boxData.deletedOffset!==t.boxData.deletedOffset?e.boxData.deletedOffset-t.boxData.deletedOffset:e.boxData.deletedOrder-t.boxData.deletedOrder)}function hV(n){if(n.length<=1)return n;const e=n[0].offset;n.forEach(t=>{g(aV,t.offset===e,`invalid boxes group, ${JSON.stringify(n)}`)}),dV(n);for(let t=n.length-1;t>=1;t--){const o=n[t],r=n[t-1];o.boxData.user.userId===r.boxData.user.userId&&(r.boxData.text+=o.boxData.text,n.splice(t,1))}return n}function fV(n){let{newText:e,deletedBoxes:t}=yy(n);const o=new Map;return t.forEach(i=>{let s=o.get(i.offset);s||(s=[],o.set(i.offset,s)),s.push(i),s.sort((l,a)=>l.boxData.deletedOffset-a.boxData.deletedOffset)}),Array.from(o.values()).sort((i,s)=>s[0].offset-i[0].offset).forEach(i=>{const s=i[0].offset;hV(i).reverse().forEach(l=>{e=$r(e,s,[{insert:" ",attributes:l.boxData}],null)})}),e}function mV(n,e,t){let{newText:o,deletedBoxes:r}=yy(n);return o=cV(o,e,t),o=uV(o,r,e),o=fV(o),o}const Cr=S("history-doc");function Ar(n){g(Cr,!1,"no local actions for history doc")}class gV extends ua{constructor(e,t){super(),this.externalDoc=e,this.docObject=t}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return fe.default(this.docObject)}getContainerBlocks(e){return this.docObject.blocks[e]}getBlockData(e,t){const o=this.getContainerBlocks(e);g(Cr,o,`no container data: ${e}`);const r=o[t];return g(Cr,r,`no block data: ${t}`),r}localUpdateBlockText(){Ar()}localUpdateBlockData(){Ar()}localInsertBlock(){Ar()}localDeleteBlock(){Ar()}localInsertChildContainer(){Ar()}localDeleteChildContainers(){Ar()}uploadResource(){Ar()}async addResources(e){Ar()}getServerMeta(){var e,t,o;return(o=(t=(e=this.externalDoc).getServerMeta)==null?void 0:t.call(e))!=null?o:{}}buildResourceUrl(e){return this.externalDoc.buildResourceUrl(e)}request(){Ar()}broadcastMessage(){Ar()}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new Oh}destroy(){this.clearCallbacks()}transformBlockIndex(e,t,o){const r=this.docObject.blocks[e];g(Cr,r,`no container blocks: ${e}`);let i=0;for(let s=0;s<r.length;s++)if(!r[s].deletedBy){if(i===t)return s;i++}return o&&g(Cr,!1,`invalid block index: ${t}, blocks: ${JSON.stringify(r)}`),g(Cr,i===t,`invalid block index: ${t}, blocks: ${JSON.stringify(r)}`),r.length}onDeleteBlock(e,t,o){const r=this.transformBlockIndex(e,t,!0),s=this.docObject.blocks[e][r];g(Cr,!s.deleted,`block has already deleted: ${e}/${t}`),s.deletedBy=o,this.callbacks.forEach(l=>{var a;return(a=l.onUpdateBlockData)==null?void 0:a.call(l,e,r,{insert:{},delete:[]},!0)})}onInsertBlock(e,t,o,r){const i=this.transformBlockIndex(e,t,!1),s=this.docObject.blocks[e],l=fe.default(o);l.insertedBy=r,s.splice(i,0,l),this.callbacks.forEach(a=>{var d;return(d=a.onInsertBlock)==null?void 0:d.call(a,e,i,l,!0)})}onUpdateBlockText(e,t,o,r){const i=this.transformBlockIndex(e,t,!0),l=this.docObject.blocks[e][i];g(Cr,!l.deleted,`block has already deleted: ${e}/${t}`);const a=l.text;g(Cr,a,`no text for block: ${JSON.stringify(l)}`);const d=mV(a,o,r);l.text=d,this.callbacks.forEach(h=>{var p;return(p=h.onUpdateBlockText)==null?void 0:p.call(h,e,i,o,!0)})}onUpdateBlockData(e,t,o,r){const i=this.transformBlockIndex(e,t,!0),s=this.docObject.blocks[e],l=s[i];g(Cr,!l.deleted,`block has already deleted: ${e}/${t}`);const a=fe.default(l);a.updatedBy=r,o.delete.forEach(d=>delete a[d]),Object.entries(o.insert).forEach(([d,h])=>{a[d]=h}),s[i]=a,this.callbacks.forEach(d=>{var h;return(h=d.onUpdateBlockData)==null?void 0:h.call(d,e,i,o,!0)})}onCreateContainer(e,t,o){this.docObject.blocks[e]=fe.default(t),this.callbacks.forEach(r=>{var i;return(i=r.onInsertChildContainer)==null?void 0:i.call(r,e,t,!0)})}}const{t:ky}=O;function Ic(n,e){return e==="insert"?ky("version.insert",{name:n.displayName}):ky("version.delete",{name:n.displayName})}function Ks(n,e){const{userId:t}=e;return["flag","selection"].reduce((r,i)=>{const s=n.getRemoteUsers().getFixedUserColor(t,i);return r[i]=s,r},{})}class pV{renderText(e,t,o){if(!o.box&&o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=Ks(e.doc,o.insertedBy);return{classes:["history-inserted-text"],attributes:{"history-inserted-by":r.displayName,"data-op-description":Ic(r,"insert")},styles:{[Ec]:i,[xc]:s}}}return{}}renderBlock(e,t,o){if(o.deletedBy){const r=o.deletedBy,{flag:i,selection:s}=Ks(e.doc,r);return{classes:["history-deleted-block"],attributes:{"history-deleted-by":r.displayName,"data-op-description":Ic(r,"delete")},styles:{[Ec]:i,[xc]:s}}}if(o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=Ks(e.doc,r);return{classes:["history-inserted-block"],attributes:{"history-inserted-by":r.displayName,"data-op-description":Ic(r,"insert")},styles:{[Ec]:i,[xc]:s}}}return{}}updateBlock(e,t,o,r){if(r.deletedBy){const i=r.deletedBy,{flag:s,selection:l}=Ks(e.doc,i);W(o,"history-deleted-block"),gm(o,{"history-inserted-by":i.displayName,"data-op-description":Ic(i,"delete")}),pm(o,{[Ec]:s,[xc]:l});return}if(r.insertedBy){const i=r.insertedBy,{flag:s,selection:l}=Ks(e.doc,i);W(o,"history-inserted-block"),gm(o,{"history-inserted-by":i.displayName,"data-op-description":Ic(i,"insert")}),pm(o,{[Ec]:s,[xc]:l})}}}const wy=S("history-deleted-box");function CV(n,e,t,o){const r=o;g(wy,r.text,`no text for text box data: ${JSON.stringify(o)}`),g(wy,typeof r.text=="string",`invalid text type for text box data: ${JSON.stringify(o)}`);const i=w("span",["history-deleted-box"],t,r.text),s=r.user,{flag:l,selection:a}=Ks(n.doc,s);i.setAttribute("history-deleted-by",s.displayName),i.setAttribute("data-op-description",Ic(s,"delete")),i.style.setProperty(Ec,l),i.style.setProperty(xc,a)}function AV(n,e,t,o){return e.text}const bV={boxType:"history-deleted-box",updateBoxContent:CV,convertTo:AV},Pne="",vV=S("versions-dropdown"),By=(n,e)=>{if(!e)return n;let t="";const o=e.length,r=e.toLocaleLowerCase();let i=0;for(i=0;i<=n.length-o;i){let s=n.substring(i,i+o);if(s.toLocaleLowerCase()===r){i+=o;const l=n.charAt(i);let a=!1;s.endsWith(" ")&&(a=!0,s=s.trimEnd()),t+=`<span class="highlight">${s}${l===" "||a?"&nbsp":""}</span>`}else t+=n.charAt(i),i++}return i<n.length&&(t+=n.substring(i)),t};class yV{constructor(e,t){m(this,"dropdown");m(this,"versions",[]);m(this,"currentVersion",null);m(this,"compareWithVersion",null);m(this,"filterMemoed",!1);m(this,"keywords","");m(this,"createFilterMemoedFilterItem",e=>{const t=w("div",["filter-memoed-version-item"],null);e&&w("div",["filter-item-info"],t,O.t("version.dropdown.header"));const o=w("div",["filter-item-input-container"],t),r=w("input",["filter-item-input"],o);r.id="filter-item-input",r.type="checkbox";const i=w("label",["filter-item-label"],o,O.t("version.filterMemoed"));return i.htmlFor=r.id,r.onchange=this.handleInputChange,r.checked=this.filterMemoed,t});m(this,"filterItems",(e,t)=>{var i,s;if(this.keywords=t,!t)return!0;if(e.id==="section")return!1;const o=t.toLocaleLowerCase();if(e.name.toLocaleLowerCase().indexOf(o)!==-1)return!0;const r=e.data;return!!(r&&((i=r.extra)==null?void 0:i.memo)&&((s=r.extra)==null?void 0:s.memo.toLocaleLowerCase().indexOf(o))!==-1)});m(this,"handleClose",()=>{});m(this,"handleClear",()=>{this.options.onCompareWithVersion(null)});m(this,"handleClickItem",e=>{const t=e.data,o=Js(t);this.dropdown.setText(o),this.options.onCompareWithVersion(t)});m(this,"handleInputChange",e=>{const t=e.target;this.filterMemoed=t.checked,this.resetItems()});this.options=t,this.dropdown=new Dp(e,{placeholder:O.t("version.noSelectedVersion"),emptyPlaceholder:O.t("version.noFilterVersion"),popupId:"versions-dropdown-popup",header:this.createHeader(),filter:this.filterItems,onClose:this.handleClose,onClickItem:this.handleClickItem,onClear:this.handleClear,highlight:!0})}createHeader(){const e=w("div",["versions-dropdown-header"],null),t=w("span",["versions-dropdown-header-info"],e);t.innerHTML=O.t("version.dropdownHeader");const o=w("span",["versions-dropdown-header-icon"],e);return o.setAttribute("data-editor-tooltip-common",O.t("version.tooltip.help")),o.setAttribute("data-editor-tooltip-placement","right"),o.innerHTML=cA,o.onclick=this.options.onHelp,e}setVersions(e){this.versions=e}setCurrentVersion(e,t){this.dropdown.setText(""),this.dropdown.setLabels([]),t&&(this.dropdown.setText(Js(t)),(t.version===-1||t.version===this.versions[0].version)&&this.dropdown.setLabels([O.t("version.latest")])),this.currentVersion=e,this.compareWithVersion=t!=null?t:null,this.resetItems()}resetItems(){var A;if(this.versions.length===0)return;const e=this.currentVersion;if(!e)return;const t=e.version===-1?0:this.versions.findIndex(v=>v.version===e.version);g(vV,t!==-1,"version not found");const o=this.versions[0],r=v=>{var j;const B=v.data,D=w("div",["version-item-container"],null),x=w("div",["version-item-line1"],D),_=v.value==="last-version"?O.t("version.lastVersion"):Js(B),M=w("div",["version-item-name"],x);if(this.keywords?M.innerHTML=By(_,this.keywords):M.innerText=_,B.version===o.version&&w("div",["version-item-latest"],x,O.t("version.latest")),(j=B.extra)!=null&&j.memo){const z=w("div",["version-item-line2"],D),q=w("div",["version-item-memo"],z,B.extra.memo);this.keywords?q.innerHTML=By(B.extra.memo,this.keywords):q.innerText=B.extra.memo,q.setAttribute("data-editor-tooltip-common",B.extra.memo),q.setAttribute("data-editor-tooltip-placement","bottom")}return D.onclick=()=>{this.handleClickItem(v),this.dropdown.close()},D},i=[],s=this.versions[t+1],l=s&&!Yf(e);if(l){const v={id:"section",value:"last-version",name:"Last version",data:s,element:r};i.push(v)}let a=t;for(let v=t-1;v>=0;v-=1){const B=this.versions[v];if(Yf(B))break;a=v}let d=t;if(!Yf(e))for(let v=t+1;v<this.versions.length;v+=1){const B=this.versions[v];if(d=v,Yf(B))break}let h=!1;const p=[];for(let v=a;v<=d;v+=1){const B=this.versions[v];if(B.version!==e.version&&B.version!==(s==null?void 0:s.version)&&(!this.filterMemoed||((A=B.extra)==null?void 0:A.memo))){h=!0;let D=Js(B),x=`${B.version}`;v===t+1&&(D="Previous version",x="prev-version");const _={id:x,name:D,data:B,element:r};p.push(_)}}if((l||h||this.filterMemoed)&&i.push({id:"section",name:"",element:this.createFilterMemoedFilterItem(i.length>0&&l),states:["disabled"]}),i.push(...p),!h){const v={id:"section",name:"No versions",states:["disabled"],element:w("span",["version-item-empty"],null,O.t("version.noVersions"))};i.push(v)}this.dropdown.updateItems(i)}}class kV{constructor(e,t){m(this,"left");m(this,"right");m(this,"dropdown");const o=w("div",["version-info-container"],e);this.left=w("div",["version-info-left"],o),this.dropdown=new yV(o,t),this.right=w("div",["version-info-right"],o)}setVersion(e,t,o){const r=`<span class="version-item-latest">${O.t("version.latest")}</span>`,i=`${Js(e)}${o?r:""}`;this.left.innerHTML=O.t("version.versionInfoLeft",{versionName:i}),this.right.innerHTML=O.t("version.versionInfoRight",{versionName:i}),this.dropdown.setCurrentVersion(e,t)}}const es=S("version-dialog");class Ey{constructor(e,t){m(this,"dialog",null);m(this,"oldViewer",null);m(this,"versionOptions");m(this,"versionList",null);m(this,"provider");m(this,"versions",[]);m(this,"components");m(this,"handleRevert",async e=>{var o,r,i;g(es,this.versionList,"The versionList did not render");const t=e!=null?e:(o=this.versionList)==null?void 0:o.activeVersion;g(es,t,`The version: ${t} is invalid`),!(((r=this.versionOptions)==null?void 0:r.onBeforeRevert)&&await this.versionOptions.onBeforeRevert(t))&&(await this.versionHelper.revertVersion(t.version),(i=this.dialog)==null||i.hide())});m(this,"handleSelectVersion",e=>{g(es,e,`The version: ${e} is invalid`),this.viewVersion(e)});m(this,"handleCompareWithVersion",e=>{var o;const t=(o=this.versionList)==null?void 0:o.activeVersion;g(es,t,"no active version"),this.viewVersion(t,e!=null?e:void 0)});m(this,"handleHelp",()=>{var e,t;(t=(e=this.versionOptions)==null?void 0:e.onHelp)==null||t.call(e)});m(this,"viewVersion",async(e,t)=>{var h,p;const o=this.versions[0].version===e.version;if(this.components.infoHeader.setVersion(e,t,o),this.oldViewer&&(this.oldViewer.destroy(),this.oldViewer=null),!this.versionList)return;(h=this.versionOptions)!=null&&h.onWillChangeVersion&&this.versionOptions.onWillChangeVersion(this,e);const r=t==null?void 0:t.version;let i,s;if(r){const A=Math.min(e.version,r),v=Math.max(e.version,r),B=await this.versionHelper.getHistoryData(v,A);i=B.doc,s=B.historyData}else i=await this.versionHelper.getVersion(e.version),s=[];const{editorContainer:l}=this.components;l.innerHTML="";const a=new gV(this.doc,i),d=this.provider.createHistoryEditor(l,a);d.editorBlockRenders.registerRender(new pV),d.editorBoxes.registerBoxClass(bV),W(d.rootElement,my.HISTORY);try{await oV(a,this.versionHelper,s)}finally{this.oldViewer=d}(p=this.versionOptions)!=null&&p.onVersionChanged&&this.versionOptions.onVersionChanged(this,d,e)});m(this,"onMemoChanged",e=>{var t,o;(o=(t=this.versionOptions)==null?void 0:t.onMemoChanged)==null||o.call(t,e),this.components.infoHeader.dropdown.resetItems(),this.components.infoHeader.dropdown.setVersions(this.versions)});this.doc=e,this.provider=t;const o=w("div",["version-dialog"],null),r=w("div",["version-viewer"],o),i=new kV(r,{onCompareWithVersion:this.handleCompareWithVersion,onHelp:this.handleHelp}),s=w("div",["version-dialog-editor"],r),l=w("div",["version-list-root"],o);this.components={root:o,editorContainer:s,listContainer:l,infoHeader:i}}get versionHelper(){g(es,this.doc.getVersionHelper,"Can not get getVersionHelper from doc");const e=this.doc.getVersionHelper();return g(es,e,"current doc does not support version"),e}get editor(){return this.oldViewer}renderContent(e){var r,i;const{listContainer:t}=this.components;t.innerHTML="";const o=new tV({enableEdit:((r=this.versionOptions)==null?void 0:r.enableEdit)||!1,versions:e,versionHelper:this.versionHelper,useCreatedBy:(i=this.versionOptions)==null?void 0:i.useCreatedBy,onSelectVersion:this.handleSelectVersion,onRevert:this.handleRevert,onMemoChanged:this.onMemoChanged,getMarkColor:s=>{const{flag:l}=Ks(this.doc,s);return l}});o.render(t),this.versionList=o}initViewVersion(){var e;if(g(es,this.versionList,"no versionList"),(e=this.versionOptions)!=null&&e.initSelectedVersion){const{initSelectedVersion:t}=this.versionOptions,o=this.versionList.selectVersionByVersionNum(t);g(es,o,`version ${t} not found`),this.viewVersion(o)}else{const t=this.versionList.activeVersion;t&&this.viewVersion(t)}}async show(e){if(this.versionOptions={...this.versionOptions,...e},this.versions=await this.versionHelper.getVersions(),this.versionOptions.onVersionsLoaded&&this.versionOptions.onVersionsLoaded(this,this.versions),this.components.infoHeader.dropdown.setVersions(this.versions),this.renderContent(this.versions),this.initViewVersion(),!this.dialog){const{root:t}=this.components;this.dialog=new Xz(t)}this.dialog.show(e.container)}destroy(){var e,t;(e=this.dialog)==null||e.destroy(),(t=this.versionList)==null||t.destroy()}}const Nne="",wV=S("heading-collapse");function I2(n){var t;const e=Number.parseInt((t=n.getAttribute("data-style-heading"))!=null?t:"",10);return g(wV,e,"not a heading block"),e}function fo(n){return!!n.getAttribute("data-style-heading")}function BV(n){return!xe(n,"heading-collapsed")}function Xs(n){return xe(n,"heading-collapsed")}function xy(n){if(lt(n))return!1;const t=ne(n);return Xe(t)}const EV=S("heading-collapse");function T2(n){g(EV,fo(n),"not a heading block");const e=[],t=I2(n);let o=Ze(n);for(;o&&!(fo(o)&&I2(o)<=t);)e.push(o),o=Ze(o);return e}function Iy(n,e){if(!ro(e))return;n.selection.selectBlock(e,0),T2(e).forEach(o=>{NC(o)}),W(e,"heading-collapsed")}function Tc(n,e){T2(e).forEach(o=>{$C(o)}),te(e,"heading-collapsed")}function xV(n,e){BV(e)?Iy(n,e):Tc(n,e)}const IV=[Ap,bp,vp,yp,kp,wp,Bp,Ep];function TV(n){const e=w("button",["heading-collapse-button"],null);return e.setAttribute(`data-editor-tooltip-${n.clientId}`,"Collapse / Expand"),e.innerHTML=qh,e}function Ty(n){return Df(n).querySelector("button.heading-collapse-button")}function Dy(n,e){Ty(e)||xy(e)||!ro(e)||Q0(e,TV(n),-1)}function DV(n){var e;(e=Ty(n))==null||e.remove()}function Sy(n,e){Df(e).querySelector("button.heading-collapse-button")||Dy(n,e)}function SV(n){const e=I2(n),t=w("button",["heading-marker"],null);return t.innerHTML=IV[e-1],t}function Ly(n){return Df(n).querySelector("button.heading-marker")}function D2(n){Ly(n)||xy(n)||!ro(n)||Q0(n,SV(n),1)}function My(n){const e=Ly(n);e==null||e.remove()}function Ry(n){My(n),fo(n)&&D2(n)}class LV{handleDrop(e,t,o,r){if(Wd(t)||!fo(t)||!Xs(t))return;const i=T2(t);i.unshift(t);const s=i.reverse();let l=null;return e.doc.beginBatchUpdate(),s.forEach((a,d,h)=>{const p=e.getBlockData(a),A=Fi(e.editorBlocks,e.doc.toJSON(),p),v=e.insertDocAt(o,r,A)[0];d===h.length-1&&(l=v)}),e.doc.endBatchUpdate(),e.doc.beginBatchUpdate(),s.forEach(a=>{e.deleteBlock(a)}),e.doc.endBatchUpdate(),l&&Iy(e,l),!0}}const MV=S("heading-collapse");class Oy{constructor(e){m(this,"handleLoad",()=>{this.showCollapseButtons()});m(this,"handleHoverBlock",(e,t)=>{t&&(te(t,"hovering-heading"),fo(t)&&Xe(ne(t))&&(D2(t),Xs(t)||DV(t))),e&&fo(e)&&Xe(ne(e))&&(W(e,"hovering-heading"),this.editor.readonly||My(e),Dy(this.editor,e))});m(this,"handleClick",(e,t)=>{const o=$l(t,"button.heading-collapse-button");if(!o)return;const r=oe(o);!r||(g(MV,fo(r),"not a heading block"),xV(this.editor,r),Sy(this.editor,r))});this.editor=e,e.addListener("load",this.handleLoad),e.addListener("click",this.handleClick),gt.get(e).addListener("change",this.handleHoverBlock),this.showCollapseButtons(),setTimeout(()=>{var o;(o=Du.find(e))==null||o.addHandler(new LV)})}showCollapseButtons(){const e=bt(this.editor.rootContainer).filter(fo);e.length!==0&&(e[0]===St(this.editor.rootContainer)&&e.splice(0,1),e.forEach(D2))}destroy(){this.editor.removeListener("load",this.handleLoad),this.editor.removeListener("click",this.handleClick)}}function Jf(n){const e=n.selection.range;if(e.isCollapsed()||e.start.blockId===e.end.blockId)return;const t=n.getBlockById(e.start.blockId),o=n.getBlockById(e.end.blockId);Xs(t)&&Tc(n,t),Xs(o)&&Tc(n,o)}function RV(n){Jf(n);const e=n.getFocusedBlock();!fo(e)||Xs(e)&&Tc(n,e)}function OV(n){Jf(n);const e=n.getFocusedBlock();if(!fo(e))return;const t=n.selection.range.focus;!t.isSimple()||t.offset===ue(n,e)&&Xs(e)&&Tc(n,e)}function _V(n){Jf(n);const e=n.getFocusedBlock();if(!fo(e))return;const t=n.selection.range.focus;!t.isSimple()||t.offset===0&&Xs(e)&&Tc(n,e)}class FV{handleBeforeKeyDown(e,t){return km(t.key)&&Jf(e),t.key==="Enter"?(RV(e),!1):t.key==="Delete"?(OV(e),!1):(t.key==="Backspace"&&_V(e),!1)}}class PV{constructor(e){this.editor=e}onInsertBlock(e,t,o,r){this.updateBlockIfNeeded(o.id)}onUpdateBlockData(e,t,o,r){const i=this.editor.doc.getBlockData(e,t);this.updateBlockIfNeeded(i.id,o)}updateBlockIfNeeded(e,t){setTimeout(()=>{const o=this.editor.findBlockById(e);if(!!o){if(!fo(o)){t&&t.delete.includes("heading")&&Ry(o);return}xe(o,"hovering-heading")&&Sy(this.editor,o),Ry(o)}},100)}}function NV(n){return!!n.heading}function _y(n){var t;const e=n.heading;return(t=Number.parseInt(`${e}`,10))!=null?t:1}function Fy(n,e,t){var i;const o=Ss(n,e.type);let r="";if(o.convertTo){const s=Hr();r=o.convertTo(n,e,s,"text",[{containerId:"root",blockIndex:0}]),r=r.replace(/\n/g,"").trim()}else r=rt((i=e.text)!=null?i:[]);return{parentNode:t,children:[],text:r,level:_y(e),block:e}}class Fu{constructor(e){m(this,"nodes",[]);this.editor=e}appendBlock(e){const t=this.findParent(_y(e),this.nodes);t?t.children.push(Fy(this.editor,e,t)):this.nodes.push(Fy(this.editor,e,null))}findParent(e,t){const o=t[t.length-1];if(!o||e<=1)return null;if(o.level===e-1)return o;const r=this.findParent(e,o.children);return r||(o.level<e?o:null)}static buildToc(e,t){const o=new Fu(e),r=t.blocks.root;for(let i=0;i<r.length;i++){const s=r[i];NV(s)&&o.appendBlock(s)}return o}}class el extends At.TypedEmitter{constructor(t){super();m(this,"toc");m(this,"updateToc",Ht.default(()=>{this.updateTocNow()},500));this.editor=t,t.doc.registerCallback(this),this.updateToc(),this.toc=new Fu(this.editor)}destroy(){this.editor.doc.unregisterCallback(this)}isHeadingBlock(t){return!!t.heading}onInsertBlock(t,o,r,i){t==="root"&&this.isHeadingBlock(r)&&this.updateToc()}onDeleteBlock(t,o,r){t==="root"&&this.updateToc()}onUpdateBlockText(t,o,r,i){if(t!=="root")return;const s=this.editor.doc.getBlockData(t,o);this.isHeadingBlock(s)&&this.updateToc()}onUpdateBlockData(t,o,r,i){if(t!=="root")return;const s=this.editor.doc.getBlockData(t,o);this.isHeadingBlock(s)&&this.updateToc()}static register(t){return t.addCustom("editor-toc",()=>new el(t))}static get(t){return t.getCustom("editor-toc")}updateTocNow(){this.toc=Fu.buildToc(this.editor,this.editor.doc.toJSON()),this.emit("change",this.editor,this.toc)}}const $ne="";function $V(n){return n.nodes.length===0?!0:n.nodes.length>1?!1:n.nodes[0].children.length===0}function Py(n,e){e.forEach(t=>{const o=w("div",["toc-node"],n),r=w("div",["toc-title"],o);if(w("span",["toc-text"],r,t.text).setAttribute("data-block-id",t.block.id),t.children.length>0){const s=w("div",["toc-children"],o);Py(s,t.children)}})}function HV(n,e){const t=$l(e,".toc-text");if(!t)return;const o=t.getAttribute("data-block-id");if(!o)return;const r=n.findBlockById(o);!r||(e.preventDefault(),e.stopPropagation(),n.selection.selectBlock(r,0))}function Ny(n,e,t){if(te(e,"loading"),e.innerHTML="",$V(t)){w("div",["toc-empty-message"],e,O.t("toc.empty"));return}if(t.nodes.length>=1){const[o,...r]=t.nodes,i=[...o.children,...r];Py(e,i)}Xg(n,"toc-click-handler",()=>{n.addListener("click",HV)})}class jV{constructor(e){m(this,"handleUpdateToc",(e,t)=>{Array.from(e.rootContainer.querySelectorAll('.embed-block[data-type="editor-block"][data-embed-type="toc"]')).forEach(r=>{const i=r.querySelector(".editor-toc-container");i&&Ny(e,i,t)})});this.editor=e,el.register(e).addListener("change",this.handleUpdateToc)}destroy(){el.register(this.editor).removeListener("change",this.handleUpdateToc)}get toc(){return el.register(this.editor).toc}}function UV(n,e){const t=w("div",["editor-toc-container"],e),r=n.addCustom("init-editor-toc",()=>new jV(n)).toc;r.nodes.length===0?W(t,"loading"):Ny(n,t,r)}function zV(n,e,t,o){return o==="markdown"?"[toc]":""}function VV(n,e,t){const{data:o}=t;if(!o||o.embedType!=="toc"||!ee(n,e))return null;const r={};return{blockData:{id:K(),type:"embed",embedType:"toc",embedData:r}}}const $y={embedType:"toc",createEmbedContent:UV,convertTo:zV,convertFrom:VV},WV={toc:{empty:"No Toc"}},qV={toc:{empty:"No Toc"}},GV={toc:{empty:"No Toc"}};O.mergeLang({"zh-CN":WV,"en-US":qV,"ja-JP":GV});function ZV(n){return!!n.getAttribute("data-style-heading")}function S2(n,e){return ZV(e)&&ue(n,e)>0}function QV(n){const e=oo(n.rootElement);let t=0,o=0,r=0;if(e===document.documentElement){const i=n.rootContainer.getBoundingClientRect();t=i.left+i.width/2,o=10,r=e.offsetHeight}else{const i=e.getBoundingClientRect();t=i.left+i.width/2,o=i.top+10,r=i.bottom}for(;o<r;){const i=document.elementsFromPoint(t,o);for(let s=0;s<i.length;s++){const l=oe(i[s]);if(l&&n.rootContainer.contains(l))return l}o+=10}return null}function L2(n,e){let t=e;for(;t&&!S2(n,t);)t=Ze(t);return t}function Hy(n){if(lt(n))return!1;const t=ne(n);return Xe(t)}function Kf(n,e){let t=e;for(;t&&!S2(n,t);)t=lt(t),t&&Hy(t)&&(t=null);return t}const YV=.3;class JV extends At.TypedEmitter{constructor(t){super();m(this,"scrollContainer");m(this,"scrollEventTarget");m(this,"scrollStatus",{curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null});m(this,"handleScroll",Ht.default(()=>{const t={curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null};let o=QV(this.editor);if(o&&(o=Hm(o)),!o||!this.scrollContainer){this.setStatus(t);return}if(Hy(o)&&(o=Ze(o)),!o){this.setStatus(t);return}if(S2(this.editor,o)){t.curHeadingBlock=o,t.previousHeadingBlock=Kf(this.editor,o),t.nextHeadingBlock=L2(this.editor,o),this.setStatus(t);return}const r=this.scrollContainer.getBoundingClientRect(),i=L2(this.editor,o);if(i){const l=i.getBoundingClientRect();if(l.top>r.top&&l.top<r.top+r.height*YV){t.curHeadingBlock=i,t.previousHeadingBlock=Kf(this.editor,i),t.nextHeadingBlock=L2(this.editor,i),this.setStatus(t);return}t.nextHeadingBlock=i}const s=Kf(this.editor,o);s&&(t.curHeadingBlock=s,t.previousHeadingBlock=Kf(this.editor,s)),this.setStatus(t)},200));this.editor=t,setTimeout(()=>{this.start()},50)}setStatus(t){this.scrollStatus.previousHeadingBlock===t.previousHeadingBlock&&this.scrollStatus.nextHeadingBlock===t.nextHeadingBlock&&this.scrollStatus.previousHeadingBlock===t.previousHeadingBlock||(this.scrollStatus=t,this.emit("change",this.editor,t))}start(){this.stop(),this.scrollContainer=oo(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 M2{constructor(e,t){m(this,"suggest");m(this,"onClose",()=>{this.editor.focus()});m(this,"onShow",(e,t,o,r)=>{const i=this.editor.getBlockByIndex(t,o);if(!ro(i)){const s=oe(ne(i));if(s&&De(s)==="code")return!1}return!0});m(this,"onClickItem",(e,t,o)=>{const r=t.data,i={id:K(),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,a=this.editor.getBlockById(l.blockId);this.editor.insertBoxToBlock(a,l.offset,i)});m(this,"queryItems",async(e,t)=>(await this.options.queryUsers(this.editor,t)).map(i=>{const s=Qd(i.displayName);return{id:i.userId,name:i.displayName,icon:i.avatarUrl?`<img src="${i.avatarUrl}" class="mention-user-avatar">`:`<span style="background: ${s}" class="mention-user-avatar-string">${Zd(i.displayName,1)}</span>`,element:i.element,data:i,subText:i.email}}));this.editor=e,this.options=t,this.suggest=new Op(e,{id:"editor-mention",trigger:["@"],autoDeleteTrigger:!0,showLoading:!0,enableFirstBlock:t.enableFirstBlock,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems,onClose:this.onClose})}destroy(){}}S("mathjax-box");function KV(n,e,t,o){const r=o,i=w("a",["mention-container"],t);w("span",["mention-name"],i,`@${r.text}`),i.setAttribute("data-mention-id",r.mentionId)}function XV(n,e,t){}function eW(n,e,t,o){return`@${e.text}`}function tW(){return{abstract:O.t("mention.abstract")}}const R2={boxType:"mention",updateBoxContent:KV,handleClickBox:XV,convertTo:eW,getBoxProperties:tW};function nW(n){const e=w("div",["mention-button-wrap"],null),t=ji("mention-button",O.t("list.mention.tooltip"),YL,[],n.clientId);return e.appendChild(t),e}class oW{constructor(e){m(this,"mentionButton");m(this,"handleHoveringBlock",e=>{var t;!this.editor.isWritable()||(e&&this.shouldBlockShowMention(e)?Et(e).appendChild(this.mentionButton):(t=this.mentionButton)==null||t.remove())});m(this,"handleMouseDown",(e,t)=>{t.preventDefault(),t.stopPropagation();const o=oe(this.mentionButton);if(!o||!ee(e,o))return;const r=e.selection.range.focus;if(!r.isSimple())return;let i;e.selection.focusedBlock!==o?i=ue(e,o):i=r.offset,setTimeout(()=>{const s=e.insertTextToBlock(o,i,"@");i+=1;const l=rt(xn(s,i).left);this.editor.selection.selectBlock(o,i),this.editor.focus(),e.getCustom("mention").suggest.popup(o,i,l,"@")})});m(this,"destroy",()=>{gt.get(this.editor).removeListener("change",this.handleHoveringBlock)});this.editor=e,this.mentionButton=nW(e),gt.get(this.editor).addListener("change",this.handleHoveringBlock),e.domEvents.addEventListener(this.mentionButton,"mousedown",this.handleMouseDown)}shouldBlockShowMention(e){if(!ee(this.editor,e)||!He(e))return!1;const t=Zn(e);return!(t==="ordered"||t==="unordered")}}const Hne="",rW={mention:{abstract:"\u6210\u5458"}},iW={mention:{abstract:"Member"}},sW={mention:{abstract:"\u30E1\u30F3\u30D0\u30FC"}};O.mergeLang({"zh-CN":rW,"en-US":iW,"ja-JP":sW});const lW={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"}},cW={templates:{title:"Choose a template",create:"New template",choose:"All templates",customizedMark:"Custom"}},aW={templates:{title:"\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3092\u9078\u629E",create:"\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3092\u65B0\u898F\u4F5C\u6210",choose:"\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u4E00\u89A7",customizedMark:"\u30AB\u30B9\u30BF\u30E0"}};O.mergeLang({"zh-CN":lW,"en-US":cW,"ja-JP":aW});const jne="",uW="data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIHZpZXdCb3g9IjAgMCAxMjAgMTIwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cmVjdCB3aWR0aD0iMTIwIiBoZWlnaHQ9IjEyMCIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTQ4IDU5QzQ4IDU0LjU4MTcgNTEuNTgxNyA1MSA1NiA1MUg5M0M5OC41MjI4IDUxIDEwMyA1NS40NzcyIDEwMyA2MVY4OEMxMDMgOTEuODY2IDk5Ljg2NiA5NSA5NiA5NUg1NkM1MS41ODE3IDk1IDQ4IDkxLjQxODMgNDggODdWNTlaIiBmaWxsPSIjRDZFOUZBIi8+CjxwYXRoIGQ9Ik0xOCA2NEMxOCA2Mi4zNDMxIDE5LjM0MzEgNjEgMjEgNjFINTZDNjAuNDE4MyA2MSA2NCA2NC41ODE3IDY0IDY5VjgzQzY0IDg1LjIwOTEgNjIuMjA5MSA4NyA2MCA4N0gyNkMyMS41ODE3IDg3IDE4IDgzLjQxODMgMTggNzlWNjRaIiBmaWxsPSIjRUFFNEY2Ii8+CjxyZWN0IHg9IjI0IiB5PSIzMSIgd2lkdGg9IjY1IiBoZWlnaHQ9IjUwIiByeD0iNSIgZmlsbD0iIzk5QzdGMiIvPgo8cmVjdCB4PSIzMy41IiB5PSI0MyIgd2lkdGg9IjQ2IiB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kuNjM4SDk1Ljk2ODFDOTcuNjA3MyAyMTkuNjM4IDk4LjkzNjIgMjE4LjMwOSA5OC45MzYyIDIxNi42N0M5OC45MzYyIDIxNS4wMzEgOTcuNjA3MyAyMTMuNzAyIDk1Ljk2ODEgMjEzLjcwMkg5MC4wMzE5WiIgZmlsbD0iIzkxRDlCRSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEyNTZfMzcxNjgiPgo8cmVjdCB3aWR0aD0iMzcyIiBoZWlnaHQ9IjI3OSIgZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K",jy=S("templates");function O2(n){const e=n.rootElement.querySelector(":scope .editor-templates");if(!e)return null;const t=e.querySelector(":scope .editor-templates-cards");return g(jy,t,"no card container"),{root:e,cardContainer:t}}function hW(n){const e=O2(n);if(e)return e.cardContainer.innerHTML="",e;const t=w("div",["editor-templates"],n.rootElement);w("div",["editor-templates-title"],t,O.t("templates.title"));const o=w("div",["editor-templates-cards"],t);return{root:t,cardContainer:o}}function Uy(n,e,t,o,r){var p;const i=(p=n.options.componentsOptions)==null?void 0:p.templates,s=w("div",["editor-template-card",...o],null),l=w("div",["editor-template-thumb-container"],s),a=w("img",["editor-template-thumb"],l);a.src=e,a.style.display="none",a.onerror=()=>{var v;const A=(v=i==null?void 0:i.placeHolderImageSrc)!=null?v:dW;a.src!==A&&(a.src=A)},a.onload=()=>{a.style.display=""};const d=w("div",["editor-template-name"],s),h=w("span",[],d,t);return i!=null&&i.showTemplateTitleAttr&&h.setAttribute("title",t),s.onclick=()=>r(s),s}function fW(n,e){return e.thumbnailUrl?e.thumbnailUrl:n.doc.buildResourceUrl("thumbnail.png")}function mW(n,e){const t=fW(n,e);return Uy(n,t,e.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,e)})}function gW(n,e){return Uy(n,e,O.t("templates.choose"),["more"],()=>{var o,r;const t=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=t==null?void 0:t.onChooseTemplate)==null||r.call(t,n)})}function pW(n,e){var p,A;const t=(p=n.options.componentsOptions)==null?void 0:p.templates;if(!t)return;const r=Gt(n.rootContainer).getBoundingClientRect().width;let i=1;const s=uW,l=O2(n);if(l){if(e!=null&&e.reset){const v=Array.from(l.cardContainer.children),B=l.cardContainer.firstElementChild;if(g(jy,B,"no first card"),xe(B,"new")||xe(B,"more"))return;const D=window.getComputedStyle(B),x=parseFloat(D.marginLeft),_=parseFloat(D.marginRight),M=B.getBoundingClientRect().width+x+_;i=Math.floor(r/M);const z=Math.max(1,i-1-1),q=v.length-1;v.forEach((ie,me)=>{me>z&&me<q?ie.style.display="none":(me>=q&&xe(ie,"more"),ie.style.display="")})}return}const a=t.templates,{cardContainer:d}=hW(n);a.forEach((v,B)=>{const D=mW(n,v);if(B>0&&B>=i&&(D.style.display="none"),d.appendChild(D),B===0){const x=window.getComputedStyle(D),_=parseFloat(x.marginLeft),M=parseFloat(x.marginRight),j=D.getBoundingClientRect().width+_+M;i=Math.floor(r/j)-1}});const h=gW(n,s);d.appendChild(h),(A=t==null?void 0:t.onTemplateChooserStatusChanged)==null||A.call(t,n,d,"visible")}const zy=Ht.default(pW,50);function CW(n){var o,r;const e=O2(n);if(!e)return;e.root.remove();const t=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=t==null?void 0:t.onTemplateChooserStatusChanged)==null||r.call(t,n,null,"hide")}function AW(n){const e=n.blocks.root;if(e.length===0)return!0;if(e.length>5)return!1;const t=[...e];t[0].type==="text"&&t[0].heading&&t.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 t.every(r=>o(r))}function Xf(n,e){AW(n.doc.toJSON())?zy(n,e):(zy.cancel(),CW(n))}const bW=800;class vW{constructor(e){m(this,"longPressTimeout",0);m(this,"handleSelectionChange",()=>{});m(this,"handleLongPress",e=>{const t=e.touches[0],o=oh(this.editor,t.clientX,t.clientY);!o||console.log(o)});m(this,"handleTouchStart",e=>{e.touches.length===1&&(this.longPressTimeout=window.setTimeout(()=>{this.handleLongPress(e)},bW))});m(this,"handleTouchEnd",e=>{this.longPressTimeout&&(window.clearTimeout(this.longPressTimeout),this.longPressTimeout=0)});this.editor=e,this.editor.addListener("selectionChanged",this.handleSelectionChange),document.addEventListener("touchstart",this.handleTouchStart),document.addEventListener("touchend",this.handleTouchEnd)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChange),document.removeEventListener("touchstart",this.handleTouchStart),document.removeEventListener("touchend",this.handleTouchEnd)}}const yW=`<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
582
582
  <g>
583
583
  <path fill-rule="evenodd" clip-rule="evenodd" d="M12 7.61719C11.4477 7.61719 11 7.16947 11 6.61719V3.61719C11 3.0649 11.4477 2.61719 12 2.61719C12.5523 2.61719 13 3.0649 13 3.61719V6.61719C13 7.16947 12.5523 7.61719 12 7.61719ZM4.92893 5.54612C5.31946 5.15559 5.95262 5.1556 6.34315 5.54612L8.46447 7.66744C8.85499 8.05796 8.85499 8.69113 8.46447 9.08165C8.07394 9.47218 7.44078 9.47218 7.05025 9.08165L4.92893 6.96033C4.53841 6.56981 4.53841 5.93664 4.92893 5.54612ZM15.5355 9.08165C15.145 8.69113 15.145 8.05796 15.5355 7.66744L17.6569 5.54612C18.0474 5.1556 18.6805 5.1556 19.0711 5.54612C19.4616 5.93664 19.4616 6.56981 19.0711 6.96033L16.9497 9.08165C16.5592 9.47218 15.9261 9.47218 15.5355 9.08165ZM2 12.6172C2 12.0649 2.44772 11.6172 3 11.6172L6 11.6172C6.55229 11.6172 7 12.0649 7 12.6172C7 13.1695 6.55228 13.6172 6 13.6172L3 13.6172C2.44772 13.6172 2 13.1695 2 12.6172ZM17 12.6172C17 12.0649 17.4477 11.6172 18 11.6172L21 11.6172C21.5523 11.6172 22 12.0649 22 12.6172C22 13.1695 21.5523 13.6172 21 13.6172L18 13.6172C17.4477 13.6172 17 13.1695 17 12.6172ZM15.5355 16.1527C15.9261 15.7622 16.5592 15.7622 16.9497 16.1527L19.0711 18.274C19.4616 18.6646 19.4616 19.2977 19.0711 19.6883C18.6805 20.0788 18.0474 20.0788 17.6569 19.6883L15.5355 17.5669C15.145 17.1764 15.145 16.5432 15.5355 16.1527ZM4.92893 19.6883C4.53841 19.2977 4.53841 18.6646 4.92893 18.274L7.05025 16.1527C7.44078 15.7622 8.07394 15.7622 8.46447 16.1527C8.85499 16.5432 8.85499 17.1764 8.46447 17.5669L6.34315 19.6883C5.95262 20.0788 5.31946 20.0788 4.92893 19.6883ZM12 22.6172C11.4477 22.6172 11 22.1695 11 21.6172V18.6172C11 18.0649 11.4477 17.6172 12 17.6172C12.5523 17.6172 13 18.0649 13 18.6172V21.6172C13 22.1695 12.5523 22.6172 12 22.6172Z" fill="#5587F0"/>
584
584
  <animateTransform attributeType="xml" attributeName="transform" type="rotate" values="0 12 12.5;360 12 12.5" dur="2s" repeatCount="indefinite" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "0.0.3-beta.155",
3
+ "version": "0.0.3-beta.157",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",