@ones-editor/editor 0.0.3-beta.66 → 0.0.3-beta.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -377,7 +377,7 @@ $$${r.mathjaxText}$$
|
|
|
377
377
|
<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"/>
|
|
378
378
|
<animateTransform attributeType="xml" attributeName="transform" type="rotate" values="0 12 12.5;360 12 12.5" dur="2s" repeatCount="indefinite" />
|
|
379
379
|
</g>
|
|
380
|
-
</svg>`,S1=w("webpage");class nS{constructor(t,e){h(this,"currentSrc","");h(this,"loading",null);h(this,"handleMaskMouseMove",(t,e)=>{if(!window.isDragging){if(e.target&&e.target instanceof Element){const o=e.target.closest("webpage-mask");o&&(o.style.display="none")}t.domEvents.addEventListener(document,"mousemove",this.handleDocumentMouseMove)}});h(this,"handleDocumentMouseMove",(t,e)=>{if(!e.target||!(e.target instanceof Element))return;const o=this.editor.findBlockById(this.blockData.id);if(o){const r=this.getExistsMask(o);if(r){if(It(o,e.target)){r.style.display="none";return}r.style.display=""}}});this.editor=t,this.blockData=e}create(t,e,o,r){const i=e.src,s=b("div",["editor-embed"],null),l=b("iframe",["editor-preview-iframe"],s);this.loading=this.createLoading(s);const c=()=>{u(S1,this.loading,"not created"),this.loading.hide(),this.currentSrc=i};t.domEvents.addEventListener(l,"load",c),l.src=i,this.loading.show(),o.append(s),this.createMask(t,r)}update(t,e,o){if(u(S1,this.loading,"not created"),this.currentSrc===o.src)return;const r=e.querySelector(".editor-preview-iframe");u(S1,r,"no exists iframe"),this.loading.show(),r.src=o.src,this.createMask(t,e)}createLoading(t){const e=b("div",["editor-preview-iframe-loading"],null),o=b("span",[],e);return o.innerHTML=eS,{show(){t.append(e)},hide(){const r=t.querySelector(":scope > .editor-preview-iframe-loading");!r||r.remove()}}}getExistsMask(t){return Rt(t).querySelector(".webpage-mask")}createMask(t,e){const o=Rt(e);let r=this.getExistsMask(e);if(r){r.style.display="";return}r=b("div",["webpage-mask"],o),t.domEvents.addEventListener(r,"mousemove",this.handleMaskMouseMove)}destroy(){const t=this.editor.findBlockById(this.blockData.id);if(t){const e=this.getExistsMask(t);e&&(this.editor.domEvents.removeEventListener(e,"mousemove",this.handleMaskMouseMove),this.editor.domEvents.removeEventListener(document,"mousemove",this.handleDocumentMouseMove))}}}function oS(n,t){b("div",["resize-gripper",t],n).setAttribute("data-resize-type",t)}function D1(n){return Rt(n).querySelector(".block-resizer")}function rS(n){const t=D1(n);t&&j(t,"active")}function r6(n,t,e){const o=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,c=r.height;e.style.top=`${i}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}function iS(n,t,e,o){const r=D1(n);if(r)return M(r,"active"),r6(n,t,r),r;const i=Rt(n),s=b("div",["block-resizer"],i);return r6(n,t,s),e.resize.forEach(l=>{oS(s,l)}),s.addEventListener("mousedown",o),M(s,"active"),s}function i6(n,t){const e=D1(n);if(!e)return;const o=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,c=r.height;e.style.top=`${i}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}const hV="",sS=w("block-resizer");class ia extends Yt.TypedEmitter{constructor(e,o){super();h(this,"resizableElement");h(this,"block",null);h(this,"startRect",null);h(this,"startPos",null);h(this,"resizeType",null);h(this,"enabled",!1);h(this,"handleMouseDown",e=>{e.preventDefault(),e.stopPropagation();const o=this.getResizableElement();if(!o||e.button!==0)return;const r=e.target;if(!r||!(r instanceof HTMLElement))return;const i=r.getAttribute("data-resize-type");!i||(this.bindEvents(),this.startRect=o.getBoundingClientRect(),this.startPos=e,this.resizeType=i,Hi(window.getComputedStyle(r).cursor),this.block&&this.editor.selection.selectBlock(this.block,0))});h(this,"handleMouseMove",e=>{if(!this.startPos||!this.startRect||!this.resizeType)return;const o=this.getResizableElement();if(!o||!this.block)return;const r=e.x-this.startPos.x,i=e.y-this.startPos.y,s=this.startRect;let{top:l,left:c,right:a,bottom:d}=s;(this.resizeType==="bottom"||this.resizeType==="bottom-left"||this.resizeType==="bottom-right")&&(d+=i),(this.resizeType==="top"||this.resizeType==="top-left"||this.resizeType==="top-right")&&(l+=i),(this.resizeType==="left"||this.resizeType==="top-left"||this.resizeType==="bottom-left")&&(c+=r),(this.resizeType==="right"||this.resizeType==="top-right"||this.resizeType==="bottom-right")&&(a+=r);const f=a>c?a-c:0,m=d>l?d-l:0,p=new DOMRect(c,l,f,m);this.emit("resizing",this,p),i6(this.block,o)});h(this,"handleMouseUp",e=>{if(e.button!==0)return;Hi(""),this.unbindEvents(),this.emit("resized",this);const o=this.getResizableElement();!o||!this.block||i6(this.block,o)});this.editor=e,this.options=o}enableResize(e,o){this.block=e,this.resizableElement=o,this.createResizer(),this.enabled=!0}disableResize(){!this.block||(rS(this.block),this.enabled=!1)}update(e,o){this.block=e,this.resizableElement=o,this.getResizableElement()&&this.enabled&&this.createResizer()}getBlock(){return this.block}destroy(){}getResizableElement(){return this.resizableElement?this.resizableElement:this.block?st(this.block):null}createResizer(){const e=this.getResizableElement();!e||!this.block||(u(sS,It(this.block,e),"not a block child element"),iS(this.block,e,this.options,this.handleMouseDown))}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}function s6(n){return n&&Te(n)&&Ne(n)==="webpage"}const lS=1e3,cS=100;class aS{constructor(t){h(this,"currentBlockElement",null);h(this,"resizing",!1);h(this,"handleHoveringBlockChange",(t,e)=>{this.resizing||!this.editor.isWritable()||(e&&s6(e)&&this.disableBlockResize(e),t&&s6(t)&&this.enableBlockResize(t))});h(this,"handleResizing",(t,e)=>{this.resizing=!0;const o=t.getBlock();if(!o)return;const r=Math.max(Math.min(e.height,lS),cS);o.style.height=`${r}px`,M(o,"resizing")});h(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!e)return;j(e,"resizing");const o=this.editor.getBlockData(e),r=e.getBoundingClientRect().height;this.editor.updateBlockData(e,{...o,height:r})});this.editor=t,$t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentBlockElement=null,$t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}disableBlockResize(t){const e=this.editor.findCustom(`${z(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t){const e=this.editor.addCustom(`${z(t)}-resizer`,()=>new ia(this.editor,{resize:["bottom"]}));e.enableResize(t),e.removeListener("resizing",this.handleResizing),e.removeListener("resized",this.handleResized),e.addListener("resizing",this.handleResizing),e.addListener("resized",this.handleResized),this.currentBlockElement=t}}const fV="",uS=w("editor-dialog");function dS(n,t){const e=b("div",["editor-dialog-container"],null),o=b("div",["dialog-header"],e);b("span",["dialog-header-title"],o,t.title);const r=b("span",["close-icon"],o);r.innerHTML=f5,b("div",["dialog-content"],e).appendChild(n);const s=b("div",["dialog-footer"],e);return b("button",["cancel-button"],s,"Cancel"),b("button",["submit-button"],s,"Ok"),e}class hS extends Ss{constructor(e,o){super(dS(e,o),o);h(this,"_options");h(this,"getReferenceClientRect",()=>{const e=document.documentElement.clientHeight/2,o=document.documentElement.clientWidth/2,r=this.getCommandBarRoot();u(uS,r,"no command bar root");const{width:i,height:s}=r.getBoundingClientRect();return new DOMRect(Math.max(o-i/2,0),Math.max(e-s/2,0),0,0)});h(this,"handleOk",async()=>{var e,o;try{await((o=(e=this._options).onOk)==null?void 0:o.call(e)),this.destroy()}catch{}});h(this,"handleClose",()=>{var e,o;(o=(e=this._options).onClose)==null||o.call(e),this.destroy()});const r=this.content.querySelector(".submit-button"),i=this.content.querySelector(".cancel-button"),s=this.content.querySelector(".close-icon");r==null||r.addEventListener("click",this.handleOk),s==null||s.addEventListener("click",this.handleClose),i==null||i.addEventListener("click",this.handleClose),this._options=o}show(){super.show(document.documentElement,{getReferenceClientRect:this.getReferenceClientRect})}destroy(){const e=this.content.querySelector(".submit-button"),o=this.content.querySelector(".cancel-button"),r=this.content.querySelector(".close-icon");e==null||e.removeEventListener("click",this.handleOk),o==null||o.removeEventListener("click",this.handleClose),r==null||r.removeEventListener("click",this.handleClose),super.destroy()}}const l6=()=>[{name:x.t("webpage.bilibili"),id:"insert-bilibili",icon:Nw,group:"thirdParty",subText:Ce("insert-bilibili")},{name:x.t("webpage.youku"),id:"insert-youku",icon:Pw,group:"thirdParty",subText:Ce("insert-youku")},{name:x.t("webpage.figma"),id:"insert-figma",icon:$w,group:"thirdParty",subText:Ce("insert-figma")},{name:x.t("webpage.modao"),id:"insert-modao",icon:_w,group:"thirdParty",subText:Ce("insert-modao")},{name:x.t("webpage.tencent"),id:"insert-tencent",icon:Fw,group:"thirdParty",subText:Ce("insert-tencent")},{id:"insert-webPage",name:x.t("webpage.title"),icon:Hw,group:"common",order:1e3,subText:Ce("insert-webPage")}];function L1(n){return n==="insert-webPage"}async function fS(n,t){return n.doc.externalDoc.recognizeLink?n.doc.externalDoc.recognizeLink(t):null}function mS(n){return n&&!n.startsWith("http://")&&!n.startsWith("https://")&&!n.startsWith("//")?`//${n}`:n}async function gS(n){if(!n)throw new Error(x.t("webpage.dialog.errorEnterUrl"));let t=n;t.startsWith("//")&&(t=`${window.location.protocol}${t}`);try{new URL(t)}catch{throw new Error(x.t("webpage.dialog.unsupportedUrl"))}}async function pS(n,t){const e=t.item.id,o=l6().find(a=>a.id===e),r=b("div",["webpage-content"],null);if(L1(e)){const a=b("div",["help-container"],r),d=b("div",["help-content"],a),f=b("span",["help-icon"],d);f.innerHTML=C5,b("span",[],d,x.t("webpage.dialog.helpContent"))}const{getInputValue:i,setFieldError:s,focus:l,getField:c}=Eh(r,{required:!0,label:x.t("webpage.dialog.label"),placeholder:x.t("webpage.dialog.placeholder")});if(!L1(e)){const a=b("div",["help-link-container"],r),d=b("a",["help-link-content"],a);b("span",[],d,x.t("webpage.dialog.helpLink"));const f=b("span",["help-link-icon"],d);f.innerHTML=b5;const m=n.getComponentOptions("webpage");d.href=(m==null?void 0:m.helpLink)||"",d.target="_blank"}try{const a=await new Promise((m,p)=>{const A=new hS(r,{title:x.t("webpage.dialog.title",{name:(o==null?void 0:o.name)||""}),async onOk(){var T;const y=mS(i());try{await gS(y);const E=await fS(n,y);m((E==null?void 0:E.url)||"")}catch(E){if(((T=E==null?void 0:E.responseData)==null?void 0:T.statusCode)===415)if(L1(e))m(y);else throw s(x.t("webpage.dialog.unsupportedUrl")),E;else throw s(E.message||""),E}},onClose(){n.focus(),p()}});A.addListener("show",l),A.show(),c().addEventListener("keydown",async y=>{if(!y.isComposing){if(y.key==="Enter"){await A.handleOk(),y.preventDefault();return}y.key==="Escape"&&A.handleClose()}})}),d={id:P(),type:"embed",embedType:"webpage",embedData:{src:a}},f=n.insertBlock(t.containerId,t.blockIndex,d);return n.focus(),f}catch{return null}}const c6=w("embed-block-properties");function sa(n,t){var e;for(const o of n.blockHooks){const r=(e=o.commands)==null?void 0:e.call(o,n,t);if(!!r&&r.group==="block-comment-actions")return r.executeCommand(n,t,r.commands[0]),!0}return!1}class M1{constructor(t,e,o){h(this,"group","hovering-toolbar");h(this,"_commands",[{id:"edit",name:"Edit",icon:wh},{id:"add-comment",name:"Add Comment",icon:xs}]);this.editor=t,this.block=e,this.properties=o}get commands(){var o,r,i;if(this.editor.readonly)return[];const t=this._commands;t.forEach(s=>{(s.id==="add-comment"||s.id==="edit")&&(s.states=this.editor.isBlockWritable(this.block)?[]:["disabled"])});const e=(o=this.properties)!=null&&o.presetIds?t.filter(s=>{var l,c;return(c=(l=this.properties)==null?void 0:l.presetIds)==null?void 0:c.includes(s.id)}):[...t];return(i=(r=this.properties)==null?void 0:r.extCommands)!=null&&i.length&&(e.push({id:P(),type:"separator",name:""}),e.push(...this.properties.extCommands)),e}executeCommand(t,e,o){var r,i;if(!((i=(r=this.properties)==null?void 0:r.handleExecuteCommand)!=null&&i.call(r,t,e,o))){if(o.id==="add-comment"){sa(t,e)||c6.error("failed to add comment to block");return}c6.error(`unknown command: ${JSON.stringify(o)}`)}}}function R1(n,t,e){return{blockCommands:{"hovering-toolbar":new M1(n,t,e)}}}function CS(n){const t=n.querySelector(".editor-preview-iframe"),e=t.src;t.src="about:blank";const o=setTimeout(()=>{t.src=e,clearTimeout(o)},300);return!0}function AS(n,t){const e=n.getBlockData(t),{embedData:o}=e,r=o.src;return window.open(r,"_blank"),!0}function bS(n,t){const e=R1(n,t,{presetIds:["add-comment"],extCommands:[{id:"refresh",name:"Refresh page",icon:Mw},{id:"open-page",name:"Open the original page",icon:b5}],handleExecuteCommand:(r,i,s)=>{switch(s.id){case"refresh":return CS(i);case"open-page":return AS(r,i)}return!1}}),o=`[${x.t("webpage.abstract")}]`;return{...e,abstract:o}}const vS=w("webpage-embed");function yS(n,t,e,o,r,i){const{embedData:s,id:l}=e,{src:c}=s,a=n.addCustom(`webpage-${l}`,()=>new nS(n,e));u(vS,c,"The src from blockData is invalid "),a.create(n,s,t,i),n.addCustom("webpage-resizer",()=>new aS(n)),e.height&&(i.style.height=`${e.height}px`)}function kS(n,t,e){const{embedData:o,id:r}=e;return n.getCustom(`webpage-${r}`).update(n,t,o),e.height&&(t.style.height=`${e.height}px`),!0}function wS(){return{name:"WebPage",insertEmbedCommandItems:l6(),handleInsertEmptyEmbed:pS}}function BS(n,t,e,o){const i=t.embedData.src;return o==="html"?`<iframe src="${i}" ></iframe>`:o==="markdown"?`[${i}](${i})`:i}const O1={embedType:"webpage",createEmbedContent:yS,getBlockProperties:bS,getOptions:wS,handleUpdateBlock:kS,convertTo:BS},ES={webpage:{title:"\u7F51\u9875",youku:"\u4F18\u9177\u89C6\u9891",modao:"\u58A8\u5200",tencent:"\u817E\u8BAF\u89C6\u9891",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"\u56E0\u76EE\u6807\u7F51\u9875\u7684\u9650\u5236\uFF0C\u90E8\u5206\u7F51\u9875\u53EF\u80FD\u65E0\u6CD5\u6210\u529F\u9884\u89C8\u3002",helpLink:"\u5982\u4F55\u83B7\u53D6\u94FE\u63A5",label:"\u7F51\u9875\u5730\u5740",placeholder:"\u8BF7\u8F93\u5165",title:"\u63D2\u5165{name}",errorEnterUrl:"\u8BF7\u8F93\u5165\u7F51\u9875\u5730\u5740",unsupportedUrl:"\u6682\u4E0D\u652F\u6301\u63D2\u5165\u8BE5\u94FE\u63A5\u5185\u5BB9"},abstract:"\u7F51\u9875"}},IS={webpage:{title:"Webpage",youku:"Youku",modao:"Modao",tencent:"Tencent Video",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"Due to the limitation of the landing page, some pages may not be previewed successfully.",helpLink:"How to get the URL link",label:"Please enter webpage address",placeholder:"Please enter url",title:"Insert {name}",errorEnterUrl:"Please enter the webpage address",unsupportedUrl:"Unsupported url"},abstract:"Webpage"}};x.mergeLang({"zh-CN":ES,"en-US":IS});const mV="";function xS(n,t,e,o){var f;const r=n.getBlockByIndex(t,e);if(G(n,r)!==o)return!1;const i=bt(n.getBlockText(r));if(![...i].every(m=>m==="|")||i.length<3||!n.editorBlocks.hasBlock("table"))return!1;const s=n.editorBlocks.getBlockClass("table");if(!s.convertFrom)return!1;const l=s.convertFrom(n,r,{offset:o});if(!l)return!1;const{blockData:c,focusBlockId:a}=l;if(!c)return!1;const d=n.insertBlock(t,e,c,Ot(n,a!=null?a:c.id,0));return n.deleteBlock(r),(f=l.onConverted)==null||f.call(l,n,d),!0}const TS={mermaid:{blockType:"embed",reg:/^```mermaid$/,data:{embedType:"mermaid"}},flowchart:{blockType:"embed",reg:/^```flowchart$/,data:{embedType:"flowchart"}},plantuml:{blockType:"embed",reg:/^```plantuml$/,data:{embedType:"plantuml"}},code:{blockType:"code",reg:/^```\S+$/},code2:{blockType:"code",reg:/^```$/},table:{blockType:"table",reg:/^\|.+\|.+\|$/},math:{blockType:"embed",reg:/^\$\$.+\$\$$/},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}},dividing:{blockType:"embed",reg:/^-{3,}$/,data:{embedType:"dividing-line"}},toc:{blockType:"embed",reg:/^\[toc\]/,data:{embedType:"toc"}}},SS={orderedList:{reg:/^(\d)+(\.|。)$/,blockType:"list",data:{listType:"ordered"}},unorderedList1:{reg:/^\*$/,blockType:"list",data:{listType:"unordered"}},unorderedList2:{reg:/^-$/,blockType:"list",data:{listType:"unordered"}},checkList1:{reg:/^\[\s?\]$/,blockType:"list",data:{listType:"unchecked"}},checkList2:{reg:/^\[X\]$/i,blockType:"list",data:{listType:"checked"}},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}}};function a6(n,t,e,o,r){if(r==="enter"&&xS(n,t,e,o))return!0;const i=n.getBlockByIndex(t,e),s=bt(ve(n.getBlockText(i),o).left).trim(),l=r==="enter"?TS:SS;for(const[,c]of Object.entries(l)){if(!s.match(c.reg))continue;return!!n.undoManager.runInGroup(()=>{var A;const d=Fl(n,i,c.blockType,{offset:o,data:c.data});if(!d)return null;const{blockData:f,focusBlockId:m}=d;if(!f)return null;const p=n.insertBlock(t,e,f,Ot(n,m!=null?m:f.id,0));return n.deleteBlock(i),(A=d.onConverted)==null||A.call(d,n,p),{newBlock:p,focusBlockId:m}})}return!1}function DS(n,t,e,o){const r=n.getBlockByIndex(t,e);return n.getBlockString(r,{boxReplacement:" "}).substring(0,o)!==">"?!1:(n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{quoted:!0},Ot(n,r,0))}),!0)}const LS={"#":1,"##":2,"###":3,"####":4,"#####":5,"######":6,"#######":7,"########":8};function MS(n,t,e,o){const r=n.getBlockByIndex(t,e),i=n.getBlockString(r,{boxReplacement:" "}).substring(0,o);let s=LS[i];if(!s)return!1;const l=n.getBlockData(r).heading;return l&&l==s&&(s=null),n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{heading:s},Ot(n,r,0))}),!0}function RS(n,t,e,o){return!!(MS(n,t,e,o)||DS(n,t,e,o))}const OS=w("match-text-style");function NS(n){let t="";for(let e=n.length-1;e>=0;e--){const o=n[e];if(!o.attributes||Object.keys(o.attributes).length===0){t+=o.insert;continue}break}return t}function PS(n,t){if(n.length<t.length*2+1||!n.endsWith(t)||n.substring(0,n.length-1).endsWith(t))return-1;const e=n.substring(0,n.length-t.length),o=e.lastIndexOf(t);return o===-1?-1:o===0?0:e.substring(o-1).startsWith(t)?-1:o}const $S={"*":{type:"style",styles:["style-italic"],boxType:""},"**":{type:"style",styles:["style-bold"],boxType:""},"***":{type:"style",styles:["style-bold","style-italic"],boxType:""},"~~":{type:"style",styles:["style-strikethrough"],boxType:""},"`":{type:"style",styles:["style-code"],boxType:""},$$:{type:"box",styles:[],boxType:"math"}};function _S(n,t,e,o){var d,f;const r=n.getBlockByIndex(t,e),i=n.getBlockText(r),{left:s}=ve(i,o),l=NS(s),c=me(s)-l.length,a=Object.entries($S);for(const[m,p]of a){const A=PS(l,m);if(A===-1)continue;const k=c+A,y=o,T=m.length,E=bt(Gt(i,k+T,y-k-T*2).middle);if(p.type==="style"){const L={};p.styles.forEach(_=>{L[_]=!0});const R=tr(E,L);n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,k,y-k),n.insertTextToBlock(r,k,R)})}else if(p.type==="box")try{const L=(f=(d=n.editorBoxes.getBoxClass(p.boxType)).convertFrom)==null?void 0:f.call(d,n,E);if(!L)continue;n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,k,y-k),n.insertBoxToBlock(r,k,L)})}catch(L){OS.warn(`failed to convert to box, ${L.message}`);continue}return!0}return!1}class la{handleAfterInsertText(t,e,o,r,i){return!!(i===" "&&(RS(t,e,o,r)||_S(t,e,o,r)))}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=t.getTextPosition();if($(t,t.getBlockByIndex(r,i))){if(Hn(e,"Enter")){if(a6(t,r,i,s,"enter"))return!0}else if(Hn(e,"Space")&&a6(t,r,i,s,"space"))return!0}return!1}}const FS={"en-US":{placeholder:{default:"Type \u2018/\u2019 for commands",heading:"Heading {heading}",list:"List",mention:"Quickly assign tasks @mention yourself or others",quote:"Quote",title:"Enter document title"}},"zh-CN":{placeholder:{default:"\u8F93\u5165\u300C/\u300D\u5FEB\u901F\u63D2\u5165",heading:"\u6807\u9898{heading}",list:"\u5217\u8868",mention:"\u5FEB\u901F\u5206\u914D\u4EFB\u52A1\uFF0C@\u63D0\u53CA\u81EA\u5DF1\u6216\u4ED6\u4EBA",quote:"\u5F15\u7528",title:"\u8BF7\u8F93\u5165\u6587\u6863\u6807\u9898"}}};x.mergeLang(FS);function Vs(n,t){const e=Ao(n,t);return!!(e.text&&me(e.text)===0&&!t.querySelector(".inputting-insertion"))}function u6(n,t){var o;st(t).removeAttribute("data-content-placeholder"),(o=t.querySelector("[data-type=block-tools] .block-placeholder-container"))==null||o.remove()}function ca(n,t,e){var r;if(!Vs(n,t)){u6(n,t);return}const o=st(t);if(typeof e=="string")o.setAttribute("data-content-placeholder",e);else{const i=Rt(t),s=(r=i.querySelector(".block-placeholder-container"))!=null?r:b("div",["block-placeholder-container"],i);s.innerHTML="",s.appendChild(e)}}function HS(n){const t=n.getAttribute("data-style-heading");return t?x.t("placeholder.heading",{heading:t}):n.getAttribute("data-style-quoted")?x.t("placeholder.quote"):null}function jS(n){const t=n.getAttribute("data-list-type");return t?t==="ordered"||t==="unordered"?x.t("placeholder.list"):x.t("placeholder.mention"):null}function d6(n){switch(rt(n)){case"text":return HS(n);case"list":return jS(n);default:return null}}function zS(n){if(Wn(n))return!1;const t=U(H(n));return t?rt(t)==="code":!1}function US(n){if(Wn(n))return!1;const t=U(H(n));return t?rt(t)==="table":!1}function VS(n,t){var d,f;const e=n.selection.focusedBlock,o=rt(e),r=t.contentPlaceholder||x.t("placeholder.default");let i=r;if(o&&Vi(n,o)&&e){if(zS(e))return;US(e)?i=x.t("placeholder.common.contentInTable"):i=(d=d6(e))!=null?d:i}const s=n.getFirstBlock(),l=dt(s);if(!l)return;const c=dt(l);if(c&&!t.addPlaceholderToAllCurrentEmptyBlock)return;if(!c){Vs(n,l)&&ca(n,l,(f=d6(l))!=null?f:r);return}const a=n.getFocusedBlock();!Vs(n,a)||a!==s&&ca(n,a,i)}function qS(n,t){var r,i;const e=n.getFirstBlock(),o=st(e);Vs(n,e)?(o.setAttribute("data-title-placeholder",(r=t.titlePlaceholder)!=null?r:x.t("placeholder.title")),o.setAttribute("data-title-placeholder-readonly",(i=t.readonlyTitlePlaceholder)!=null?i:"")):(o.removeAttribute("data-title-placeholder"),o.removeAttribute("data-title-placeholder-readonly"))}function WS(n){n.rootContainer.querySelectorAll("[data-content-placeholder").forEach(t=>{t.removeAttribute("data-content-placeholder")}),n.rootContainer.querySelectorAll("[data-type=block-tools] .block-placeholder-container").forEach(t=>{t.remove()})}function GS(n,t){WS(n),n.selection.range.isCollapsed()&&(qS(n,t),VS(n,t))}const CV="",ZS=w("enforce-title");class qs{constructor(t,e={headingLevel:1}){h(this,"handleSelectionChange",t=>{setTimeout(()=>{this.applyPlaceholder(t)})});this.options=e,this.handleChanged(t),this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange)}destroy(t){t.removeListener("selectionChanged",this.handleSelectionChange)}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=t.getTextPosition();if(!qs.isDocumentTitleBlock(r,i)||!Hn(e,"Enter"))return!1;let l=!1,c=null;Ze(t.rootContainer)===2&&(c=xr(t.rootContainer,1),G(t,c)===0&&(l=!0));const a=t.getFirstBlock();return t.undoManager.runInGroup(()=>{t.breakTextBlock(a,s,{forceInsertAfter:!0}),l&&c&&t.deleteBlock(c)}),!0}handleChanged(t){var e;try{const o=t.doc.getContainerBlocks(V(t.rootContainer));u(ZS,o.length>0,"root container is empty");const r=o[0];if(r.type!=="text"||r.heading!==this.options.headingLevel){const i=Vn("",{heading:(e=this.options.headingLevel)!=null?e:1});t.insertBlock(V(t.rootContainer),0,i);return}if(o.length>1)return;t.insertTextBlock("",V(t.rootContainer),1,{newRange:t.selection.range.toDocRange()})}finally{this.applyPlaceholder(t)}}handleRemoteChanged(t){setTimeout(()=>{this.applyPlaceholder(t)})}handleUpdateCompositionText(t){this.applyPlaceholder(t)}applyPlaceholder(t){var e,o;!((e=this.options)!=null&&e.titlePlaceholder)&&!((o=this.options)!=null&&o.contentPlaceholder)||GS(t,this.options)}static isDocumentTitleBlock(t,e){return t==="root"&&e===0}}const h6=w("code-dom");function Do(n){return rt(n)==="code"}function f6(n,t,e){e.language?t.setAttribute("data-language",e.language):t.removeAttribute("data-language"),e.nowrap?j(t,"wrap"):M(t,"wrap")}function N1(n){const t=n.closest("div[data-type=editor-block][data-block-type=code]");return u(h6,t,"no parent code block"),u(h6,Do(t),"not a code block"),t}const aa={plain:{name:"Plain Text",aliases:["txt","text"]},abap:{name:"ABAP",aliases:["abap"]},arduino:{name:"Arduino",aliases:["ino"]},bash:{name:"Bash",aliases:["sh","shell"]},basic:{name:"BASIC",aliases:["bas"]},c:{name:"C",aliases:["c"]},clojure:{name:"Clojure",aliases:["clj"]},cofeescript:{name:"CoffeeScript",aliases:["coffee"]},cpp:{name:"C++",aliases:["cpp","cxx"]},csharp:{name:"C#",aliases:["cs"]},css:{name:"CSS",aliases:["css"]},dart:{name:"Dart",aliases:["dart"]},diff:{name:"Diff",aliases:["diff","patch"]},docker:{name:"Docker",aliases:["dockerfile"]},elixir:{name:"Elixir",aliases:["ex","exs"]},elm:{name:"Elm",aliases:["elm"]},erlang:{name:"Erlang",aliases:["erl"]},flow:{name:"Flow",aliases:["flow"]},fortran:{name:"Fortran",aliases:["f","for","f77","f90"]},fsharp:{name:"F#",aliases:["fsharp"]},gherkin:{name:"Gherkin",aliases:["feature"]},glsl:{name:"GLSL",aliases:["glsl"]},go:{name:"Go",aliases:["go"]},graphql:{name:"GraphQL",aliases:["graphql"]},groovy:{name:"Groovy",aliases:["groovy"]},haskell:{name:"Haskell",aliases:["hs"]},java:{name:"Java",aliases:["java"]},js:{name:"JavaScript",aliases:["js","jsx"]},json:{name:"JSON",aliases:["json"]},julia:{name:"Julia",aliases:["jl"]},kotlin:{name:"Kotlin",aliases:["kt","ktm","kts"]},latex:{name:"LaTeX",aliases:["tex"]},less:{name:"LESS",aliases:["less"]},lisp:{name:"Lisp",aliases:["lisp"]},livescript:{name:"LiveScript",aliases:["ls"]},lua:{name:"Lua",aliases:["lua"]},makefile:{name:"Makefile",aliases:["mk","mak"]},markdown:{name:"Markdown",aliases:["md","mkdown","mkd"]},markup:{name:"HTML / XML",aliases:["html","htm","xml","xsd","xsl","xslt","wsdl"]},matlab:{name:"MATLAB",aliases:["matlab"]},mermaid:{name:"Mermaid",aliases:["mermaid"]},nix:{name:"Nix",aliases:["nix"]},objectivec:{name:"Objective-C",aliases:["m","mm"]},ocaml:{name:"OCaml",aliases:["ml"]},pascal:{name:"Pascal",aliases:["pas"]},perl:{name:"Perl",aliases:["pl","pm"]},php:{name:"PHP",aliases:["php"]},powershell:{name:"PowerShell",aliases:["ps","ps1"]},prolog:{name:"Prolog",aliases:["plg"]},protobuf:{name:"Protocol Buffers",aliases:["proto"]},python:{name:"Python",aliases:["py"]},r:{name:"R",aliases:["r"]},reason:{name:"Reason",aliases:["re","rei"]},ruby:{name:"Ruby",aliases:["rb"]},rust:{name:"Rust",aliases:["rs"]},sass:{name:"Sass",aliases:["sass"]},scala:{name:"Scala",aliases:["scala"]},scheme:{name:"Scheme",aliases:["scm","sm"]},scss:{name:"SCSS",aliases:["scss"]},solidity:{name:"Solidity",aliases:["sol"]},sql:{name:"SQL",aliases:["sql"]},swift:{name:"Swift",aliases:["swift"]},typescript:{name:"TypeScript",aliases:["ts","tsx"]},vbnet:{name:"VB.Net",aliases:["vbnet"]},verilog:{name:"Verilog",aliases:["v"]},vhdl:{name:"VHDL",aliases:["vhdl"]},"visual-basic":{name:"Visual Basic",aliases:["vb","vba"]},wasm:{name:"WebAssembly",aliases:["wasm"]},yaml:{name:"YAML",aliases:["yaml"]}};function QS(n){const t=n.toLocaleLowerCase();let e="";return Object.entries(aa).forEach(([o,r])=>{(o===t||r.aliases.includes(t)||r.name.toLocaleLowerCase()===t)&&(e=o)}),e}function m6(n){const t=n.settingsProvider.getItem("editor-code-lang");return t!=null?t:"plain"}function YS(n,t){return n.settingsProvider.setItem("editor-code-lang",t)}const JS=w("convert-to-code");function KS(n,t){if(!$(n,t))return null;const e={id:P(),type:"text",text:[]},o=P();n.doc.localInsertChildContainer(o,[e]);const r=n.getBlockData(t).text;u(JS,r,"no text");let i=bt(r);i.startsWith("```")&&(i=i.substring(3));const s=QS(i)||m6(n)||"plain";return{blockData:{id:P(),type:"code",language:s,children:[o]},focusBlockId:e.id}}const AV="",P1=w("code-block-child-container");function ai(n){u(P1,Do(n),"not a code block");const e=st(n).querySelector(":scope > div.editor-code-root > div.code-text-root [data-type=editor-container].child");return u(P1,e,"no code text container"),e}function ui(n){u(P1,Do(n),"not a code block");const e=st(n).querySelector(":scope > div.editor-code-root > div.code-caption-root [data-type=editor-container].child");return e||null}function ua(n){const t=[ai(n)],e=ui(n);return e&&t.push(e),t}function di(n,t){if(!$(n,t))return!1;const e=H(t),o=U(e);return o?Do(o)?e===ai(o):rt(t)==="code":!1}const $1=w("code-caption");function XS(n,t){if(n.readonly)return;const e=ui(t);if(e){const c=Ft(e);n.selection.selectBlock(c,0);return}const o=wn(n.doc),r=n.getBlockData(t);u($1,r.children.length===1,"code block should have only one child");const i={...r,children:[r.children[0],o]};n.updateBlockData(t,i);const s=n.getContainerById(o),l=Ft(s);n.selection.selectBlock(l,0)}function g6(n,t){const e=H(t);if(Ct(e))return!1;const o=U(e);if(u($1,o,"no parent block"),!Do(o))return!1;const i=ui(o);return e===i}function tD(n,t){if(n.readonly||!ui(t))return;const o=ai(t),r=Jt(o);n.selection.selectBlock(r,G(n,r));const i=n.getBlockData(t);u($1,i.children.length===2,"code block should have only one child");const s=i.children[1],l={...i,children:[i.children[0]]};n.updateBlockData(t,l),n.deleteChildContainers([s])}const eD=w("paste-in-table-block");class nD{constructor(t){this.editor=t,setTimeout(()=>{t.input.addHandler(this)})}destroy(){}async handleBeforePaste(t,e,o){if(!t.selection.range.isSimple())return!1;const r=t.selection.range.start,i=t.getBlockById(r.blockId),s=H(i);if(Ct(s))return!1;const l=U(s);if(u(eD,l,"no parent block"),!Do(l)||g6(t,i))return!1;const c=o["text/plain"];return c&&t.undoManager.runInGroup(()=>{t.clearSelectedContents(),t.insertDoc(i,r.offset,c)}),!0}}function oD(n){n.addCustom("code-block-paste-event",t=>new nD(t))}class rD{constructor(t){h(this,"id","CodeBlockCommandProvider");setTimeout(()=>{t.editorCommandProviders.registerCommandProvider(this)})}destroy(){}getAvailableCommands(){return[]}executeCommand(){return!1}filterCommands(t,e,o,r){if(di(t,e))return[]}beforeExecuteCommand(t,e,o,r,i){return!!di(t,e)}}function iD(n){n.addCustom("code-block-command-provider",t=>new rD(t))}const sD=w("code-caption-input-handler");function _1(n){if(!n.selection.range.isSimple())return null;const t=n.selection.range.start;if(!t.isSimple())return null;const e=n.getBlockById(t.blockId);return g6(n,e)?e:null}function lD(n){const t=_1(n);if(!t)return!1;const e=N1(t),o=dt(e);return o?(n.selection.selectBlock(o,0),!0):(n.insertTextBlock("",V(H(e)),K(e)+1),!0)}function cD(n){const t=_1(n);if(!t)return!1;if(Tt(n,t)){const e=N1(t);return tD(n,e),!0}return!1}class F1{constructor(t){setTimeout(()=>{t.input.addHandler(this)})}destroy(){}handleBeforeKeyDown(t,e){return e.key==="Enter"?lD(t):e.key==="Backspace"?cD(t):!1}async handleBeforePaste(t,e,o){const r=_1(t);if(!r)return!1;const i=o["text/plain"];if(!i)return!0;const s=sc(t,i);return s&&t.undoManager.runInGroup(()=>{t.clearSelectedContents();const l=t.selection.range.start;u(sD,l.isSimple(),"not simple position"),t.insertTextToBlock(r,l.offset,s)}),!0}static init(t){t.addCustom("code-block-caption-input-handler",e=>new F1(e))}}const aD=`
|
|
380
|
+
</svg>`,S1=w("webpage");class nS{constructor(t,e){h(this,"currentSrc","");h(this,"loading",null);h(this,"handleMaskMouseMove",(t,e)=>{if(!window.isDragging){if(e.target&&e.target instanceof Element){const o=e.target.closest("webpage-mask");o&&(o.style.display="none")}t.domEvents.addEventListener(document,"mousemove",this.handleDocumentMouseMove)}});h(this,"handleDocumentMouseMove",(t,e)=>{if(!e.target||!(e.target instanceof Element))return;const o=this.editor.findBlockById(this.blockData.id);if(o){const r=this.getExistsMask(o);if(r){if(It(o,e.target)){r.style.display="none";return}r.style.display=""}}});this.editor=t,this.blockData=e}create(t,e,o,r){const i=e.src,s=b("div",["editor-embed"],null),l=b("iframe",["editor-preview-iframe"],s);this.loading=this.createLoading(s);const c=()=>{u(S1,this.loading,"not created"),this.loading.hide(),this.currentSrc=i};t.domEvents.addEventListener(l,"load",c),l.src=i,this.loading.show(),o.append(s),this.createMask(t,r)}update(t,e,o){if(u(S1,this.loading,"not created"),this.currentSrc===o.src)return;const r=e.querySelector(".editor-preview-iframe");u(S1,r,"no exists iframe"),this.loading.show(),r.src=o.src,this.createMask(t,e)}createLoading(t){const e=b("div",["editor-preview-iframe-loading"],null),o=b("span",[],e);return o.innerHTML=eS,{show(){t.append(e)},hide(){const r=t.querySelector(":scope > .editor-preview-iframe-loading");!r||r.remove()}}}getExistsMask(t){return Rt(t).querySelector(".webpage-mask")}createMask(t,e){const o=Rt(e);let r=this.getExistsMask(e);if(r){r.style.display="";return}r=b("div",["webpage-mask"],o),t.domEvents.addEventListener(r,"mousemove",this.handleMaskMouseMove)}destroy(){const t=this.editor.findBlockById(this.blockData.id);if(t){const e=this.getExistsMask(t);e&&(this.editor.domEvents.removeEventListener(e,"mousemove",this.handleMaskMouseMove),this.editor.domEvents.removeEventListener(document,"mousemove",this.handleDocumentMouseMove))}}}function oS(n,t){b("div",["resize-gripper",t],n).setAttribute("data-resize-type",t)}function D1(n){return Rt(n).querySelector(".block-resizer")}function rS(n){const t=D1(n);t&&j(t,"active")}function r6(n,t,e){const o=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,c=r.height;e.style.top=`${i}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}function iS(n,t,e,o){const r=D1(n);if(r)return M(r,"active"),r6(n,t,r),r;const i=Rt(n),s=b("div",["block-resizer"],i);return r6(n,t,s),e.resize.forEach(l=>{oS(s,l)}),s.addEventListener("mousedown",o),M(s,"active"),s}function i6(n,t){const e=D1(n);if(!e)return;const o=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,c=r.height;e.style.top=`${i}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}const hV="",sS=w("block-resizer");class ia extends Yt.TypedEmitter{constructor(e,o){super();h(this,"resizableElement");h(this,"block",null);h(this,"startRect",null);h(this,"startPos",null);h(this,"resizeType",null);h(this,"enabled",!1);h(this,"handleMouseDown",e=>{e.preventDefault(),e.stopPropagation();const o=this.getResizableElement();if(!o||e.button!==0)return;const r=e.target;if(!r||!(r instanceof HTMLElement))return;const i=r.getAttribute("data-resize-type");!i||(this.bindEvents(),this.startRect=o.getBoundingClientRect(),this.startPos=e,this.resizeType=i,Hi(window.getComputedStyle(r).cursor),this.block&&this.editor.selection.selectBlock(this.block,0))});h(this,"handleMouseMove",e=>{if(!this.startPos||!this.startRect||!this.resizeType)return;const o=this.getResizableElement();if(!o||!this.block)return;const r=e.x-this.startPos.x,i=e.y-this.startPos.y,s=this.startRect;let{top:l,left:c,right:a,bottom:d}=s;(this.resizeType==="bottom"||this.resizeType==="bottom-left"||this.resizeType==="bottom-right")&&(d+=i),(this.resizeType==="top"||this.resizeType==="top-left"||this.resizeType==="top-right")&&(l+=i),(this.resizeType==="left"||this.resizeType==="top-left"||this.resizeType==="bottom-left")&&(c+=r),(this.resizeType==="right"||this.resizeType==="top-right"||this.resizeType==="bottom-right")&&(a+=r);const f=a>c?a-c:0,m=d>l?d-l:0,p=new DOMRect(c,l,f,m);this.emit("resizing",this,p),i6(this.block,o)});h(this,"handleMouseUp",e=>{if(e.button!==0)return;Hi(""),this.unbindEvents(),this.emit("resized",this);const o=this.getResizableElement();!o||!this.block||i6(this.block,o)});this.editor=e,this.options=o}enableResize(e,o){this.block=e,this.resizableElement=o,this.createResizer(),this.enabled=!0}disableResize(){!this.block||(rS(this.block),this.enabled=!1)}update(e,o){this.block=e,this.resizableElement=o,this.getResizableElement()&&this.enabled&&this.createResizer()}getBlock(){return this.block}destroy(){}getResizableElement(){return this.resizableElement?this.resizableElement:this.block?st(this.block):null}createResizer(){const e=this.getResizableElement();!e||!this.block||(u(sS,It(this.block,e),"not a block child element"),iS(this.block,e,this.options,this.handleMouseDown))}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}function s6(n){return n&&Te(n)&&Ne(n)==="webpage"}const lS=1e3,cS=100;class aS{constructor(t){h(this,"currentBlockElement",null);h(this,"resizing",!1);h(this,"handleHoveringBlockChange",(t,e)=>{this.resizing||!this.editor.isWritable()||(e&&s6(e)&&this.disableBlockResize(e),t&&s6(t)&&this.enableBlockResize(t))});h(this,"handleResizing",(t,e)=>{this.resizing=!0;const o=t.getBlock();if(!o)return;const r=Math.max(Math.min(e.height,lS),cS);o.style.height=`${r}px`,M(o,"resizing")});h(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!e)return;j(e,"resizing");const o=this.editor.getBlockData(e),r=e.getBoundingClientRect().height;this.editor.updateBlockData(e,{...o,height:r})});this.editor=t,$t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentBlockElement=null,$t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}disableBlockResize(t){const e=this.editor.findCustom(`${z(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t){const e=this.editor.addCustom(`${z(t)}-resizer`,()=>new ia(this.editor,{resize:["bottom"]}));e.enableResize(t),e.removeListener("resizing",this.handleResizing),e.removeListener("resized",this.handleResized),e.addListener("resizing",this.handleResizing),e.addListener("resized",this.handleResized),this.currentBlockElement=t}}const fV="",uS=w("editor-dialog");function dS(n,t){const e=b("div",["editor-dialog-container"],null),o=b("div",["dialog-header"],e);b("span",["dialog-header-title"],o,t.title);const r=b("span",["close-icon"],o);r.innerHTML=f5,b("div",["dialog-content"],e).appendChild(n);const s=b("div",["dialog-footer"],e);return b("button",["cancel-button"],s,"Cancel"),b("button",["submit-button"],s,"Ok"),e}class hS extends Ss{constructor(e,o){super(dS(e,o),o);h(this,"_options");h(this,"getReferenceClientRect",()=>{const e=document.documentElement.clientHeight/2,o=document.documentElement.clientWidth/2,r=this.getCommandBarRoot();u(uS,r,"no command bar root");const{width:i,height:s}=r.getBoundingClientRect();return new DOMRect(Math.max(o-i/2,0),Math.max(e-s/2,0),0,0)});h(this,"handleOk",async()=>{var e,o;try{await((o=(e=this._options).onOk)==null?void 0:o.call(e)),this.destroy()}catch{}});h(this,"handleClose",()=>{var e,o;(o=(e=this._options).onClose)==null||o.call(e),this.destroy()});const r=this.content.querySelector(".submit-button"),i=this.content.querySelector(".cancel-button"),s=this.content.querySelector(".close-icon");r==null||r.addEventListener("click",this.handleOk),s==null||s.addEventListener("click",this.handleClose),i==null||i.addEventListener("click",this.handleClose),this._options=o}show(){super.show(document.documentElement,{getReferenceClientRect:this.getReferenceClientRect})}destroy(){const e=this.content.querySelector(".submit-button"),o=this.content.querySelector(".cancel-button"),r=this.content.querySelector(".close-icon");e==null||e.removeEventListener("click",this.handleOk),o==null||o.removeEventListener("click",this.handleClose),r==null||r.removeEventListener("click",this.handleClose),super.destroy()}}const l6=()=>[{name:x.t("webpage.bilibili"),id:"insert-bilibili",icon:Nw,group:"thirdParty",subText:Ce("insert-bilibili")},{name:x.t("webpage.youku"),id:"insert-youku",icon:Pw,group:"thirdParty",subText:Ce("insert-youku")},{name:x.t("webpage.figma"),id:"insert-figma",icon:$w,group:"thirdParty",subText:Ce("insert-figma")},{name:x.t("webpage.modao"),id:"insert-modao",icon:_w,group:"thirdParty",subText:Ce("insert-modao")},{name:x.t("webpage.tencent"),id:"insert-tencent",icon:Fw,group:"thirdParty",subText:Ce("insert-tencent")},{id:"insert-webPage",name:x.t("webpage.title"),icon:Hw,group:"common",order:1e3,subText:Ce("insert-webPage")}];function L1(n){return n==="insert-webPage"}async function fS(n,t){return n.doc.externalDoc.recognizeLink?n.doc.externalDoc.recognizeLink(t):null}function mS(n){return n&&!n.startsWith("http://")&&!n.startsWith("https://")&&!n.startsWith("//")?`${window.location.protocol}//${n}`:n}async function gS(n){if(!n)throw new Error(x.t("webpage.dialog.errorEnterUrl"));const t=n;try{new URL(t)}catch{throw new Error(x.t("webpage.dialog.unsupportedUrl"))}}async function pS(n,t){const e=t.item.id,o=l6().find(a=>a.id===e),r=b("div",["webpage-content"],null);if(L1(e)){const a=b("div",["help-container"],r),d=b("div",["help-content"],a),f=b("span",["help-icon"],d);f.innerHTML=C5,b("span",[],d,x.t("webpage.dialog.helpContent"))}const{getInputValue:i,setFieldError:s,focus:l,getField:c}=Eh(r,{required:!0,label:x.t("webpage.dialog.label"),placeholder:x.t("webpage.dialog.placeholder")});if(!L1(e)){const a=b("div",["help-link-container"],r),d=b("a",["help-link-content"],a);b("span",[],d,x.t("webpage.dialog.helpLink"));const f=b("span",["help-link-icon"],d);f.innerHTML=b5;const m=n.getComponentOptions("webpage");d.href=(m==null?void 0:m.helpLink)||"",d.target="_blank"}try{const a=await new Promise((m,p)=>{const A=new hS(r,{title:x.t("webpage.dialog.title",{name:(o==null?void 0:o.name)||""}),async onOk(){var T;const y=mS(i());try{await gS(y);const E=await fS(n,y);m((E==null?void 0:E.url)||"")}catch(E){if(((T=E==null?void 0:E.responseData)==null?void 0:T.statusCode)===415)if(L1(e))m(y);else throw s(x.t("webpage.dialog.unsupportedUrl")),E;else throw s(E.message||""),E}},onClose(){n.focus(),p()}});A.addListener("show",l),A.show(),c().addEventListener("keydown",async y=>{if(!y.isComposing){if(y.key==="Enter"){await A.handleOk(),y.preventDefault();return}y.key==="Escape"&&A.handleClose()}})}),d={id:P(),type:"embed",embedType:"webpage",embedData:{src:a}},f=n.insertBlock(t.containerId,t.blockIndex,d);return n.focus(),f}catch{return null}}const c6=w("embed-block-properties");function sa(n,t){var e;for(const o of n.blockHooks){const r=(e=o.commands)==null?void 0:e.call(o,n,t);if(!!r&&r.group==="block-comment-actions")return r.executeCommand(n,t,r.commands[0]),!0}return!1}class M1{constructor(t,e,o){h(this,"group","hovering-toolbar");h(this,"_commands",[{id:"edit",name:"Edit",icon:wh},{id:"add-comment",name:"Add Comment",icon:xs}]);this.editor=t,this.block=e,this.properties=o}get commands(){var o,r,i;if(this.editor.readonly)return[];const t=this._commands;t.forEach(s=>{(s.id==="add-comment"||s.id==="edit")&&(s.states=this.editor.isBlockWritable(this.block)?[]:["disabled"])});const e=(o=this.properties)!=null&&o.presetIds?t.filter(s=>{var l,c;return(c=(l=this.properties)==null?void 0:l.presetIds)==null?void 0:c.includes(s.id)}):[...t];return(i=(r=this.properties)==null?void 0:r.extCommands)!=null&&i.length&&(e.push({id:P(),type:"separator",name:""}),e.push(...this.properties.extCommands)),e}executeCommand(t,e,o){var r,i;if(!((i=(r=this.properties)==null?void 0:r.handleExecuteCommand)!=null&&i.call(r,t,e,o))){if(o.id==="add-comment"){sa(t,e)||c6.error("failed to add comment to block");return}c6.error(`unknown command: ${JSON.stringify(o)}`)}}}function R1(n,t,e){return{blockCommands:{"hovering-toolbar":new M1(n,t,e)}}}function CS(n){const t=n.querySelector(".editor-preview-iframe"),e=t.src;t.src="about:blank";const o=setTimeout(()=>{t.src=e,clearTimeout(o)},300);return!0}function AS(n,t){const e=n.getBlockData(t),{embedData:o}=e,r=o.src;return window.open(r,"_blank"),!0}function bS(n,t){const e=R1(n,t,{presetIds:["add-comment"],extCommands:[{id:"refresh",name:"Refresh page",icon:Mw},{id:"open-page",name:"Open the original page",icon:b5}],handleExecuteCommand:(r,i,s)=>{switch(s.id){case"refresh":return CS(i);case"open-page":return AS(r,i)}return!1}}),o=`[${x.t("webpage.abstract")}]`;return{...e,abstract:o}}const vS=w("webpage-embed");function yS(n,t,e,o,r,i){const{embedData:s,id:l}=e,{src:c}=s,a=n.addCustom(`webpage-${l}`,()=>new nS(n,e));u(vS,c,"The src from blockData is invalid "),a.create(n,s,t,i),n.addCustom("webpage-resizer",()=>new aS(n)),e.height&&(i.style.height=`${e.height}px`)}function kS(n,t,e){const{embedData:o,id:r}=e;return n.getCustom(`webpage-${r}`).update(n,t,o),e.height&&(t.style.height=`${e.height}px`),!0}function wS(){return{name:"WebPage",insertEmbedCommandItems:l6(),handleInsertEmptyEmbed:pS}}function BS(n,t,e,o){const i=t.embedData.src;return o==="html"?`<iframe src="${i}" ></iframe>`:o==="markdown"?`[${i}](${i})`:i}const O1={embedType:"webpage",createEmbedContent:yS,getBlockProperties:bS,getOptions:wS,handleUpdateBlock:kS,convertTo:BS},ES={webpage:{title:"\u7F51\u9875",youku:"\u4F18\u9177\u89C6\u9891",modao:"\u58A8\u5200",tencent:"\u817E\u8BAF\u89C6\u9891",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"\u56E0\u76EE\u6807\u7F51\u9875\u7684\u9650\u5236\uFF0C\u90E8\u5206\u7F51\u9875\u53EF\u80FD\u65E0\u6CD5\u6210\u529F\u9884\u89C8\u3002",helpLink:"\u5982\u4F55\u83B7\u53D6\u94FE\u63A5",label:"\u7F51\u9875\u5730\u5740",placeholder:"\u8BF7\u8F93\u5165",title:"\u63D2\u5165{name}",errorEnterUrl:"\u8BF7\u8F93\u5165\u7F51\u9875\u5730\u5740",unsupportedUrl:"\u6682\u4E0D\u652F\u6301\u63D2\u5165\u8BE5\u94FE\u63A5\u5185\u5BB9"},abstract:"\u7F51\u9875"}},IS={webpage:{title:"Webpage",youku:"Youku",modao:"Modao",tencent:"Tencent Video",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"Due to the limitation of the landing page, some pages may not be previewed successfully.",helpLink:"How to get the URL link",label:"Please enter webpage address",placeholder:"Please enter url",title:"Insert {name}",errorEnterUrl:"Please enter the webpage address",unsupportedUrl:"Unsupported url"},abstract:"Webpage"}};x.mergeLang({"zh-CN":ES,"en-US":IS});const mV="";function xS(n,t,e,o){var f;const r=n.getBlockByIndex(t,e);if(G(n,r)!==o)return!1;const i=bt(n.getBlockText(r));if(![...i].every(m=>m==="|")||i.length<3||!n.editorBlocks.hasBlock("table"))return!1;const s=n.editorBlocks.getBlockClass("table");if(!s.convertFrom)return!1;const l=s.convertFrom(n,r,{offset:o});if(!l)return!1;const{blockData:c,focusBlockId:a}=l;if(!c)return!1;const d=n.insertBlock(t,e,c,Ot(n,a!=null?a:c.id,0));return n.deleteBlock(r),(f=l.onConverted)==null||f.call(l,n,d),!0}const TS={mermaid:{blockType:"embed",reg:/^```mermaid$/,data:{embedType:"mermaid"}},flowchart:{blockType:"embed",reg:/^```flowchart$/,data:{embedType:"flowchart"}},plantuml:{blockType:"embed",reg:/^```plantuml$/,data:{embedType:"plantuml"}},code:{blockType:"code",reg:/^```\S+$/},code2:{blockType:"code",reg:/^```$/},table:{blockType:"table",reg:/^\|.+\|.+\|$/},math:{blockType:"embed",reg:/^\$\$.+\$\$$/},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}},dividing:{blockType:"embed",reg:/^-{3,}$/,data:{embedType:"dividing-line"}},toc:{blockType:"embed",reg:/^\[toc\]/,data:{embedType:"toc"}}},SS={orderedList:{reg:/^(\d)+(\.|。)$/,blockType:"list",data:{listType:"ordered"}},unorderedList1:{reg:/^\*$/,blockType:"list",data:{listType:"unordered"}},unorderedList2:{reg:/^-$/,blockType:"list",data:{listType:"unordered"}},checkList1:{reg:/^\[\s?\]$/,blockType:"list",data:{listType:"unchecked"}},checkList2:{reg:/^\[X\]$/i,blockType:"list",data:{listType:"checked"}},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}}};function a6(n,t,e,o,r){if(r==="enter"&&xS(n,t,e,o))return!0;const i=n.getBlockByIndex(t,e),s=bt(ve(n.getBlockText(i),o).left).trim(),l=r==="enter"?TS:SS;for(const[,c]of Object.entries(l)){if(!s.match(c.reg))continue;return!!n.undoManager.runInGroup(()=>{var A;const d=Fl(n,i,c.blockType,{offset:o,data:c.data});if(!d)return null;const{blockData:f,focusBlockId:m}=d;if(!f)return null;const p=n.insertBlock(t,e,f,Ot(n,m!=null?m:f.id,0));return n.deleteBlock(i),(A=d.onConverted)==null||A.call(d,n,p),{newBlock:p,focusBlockId:m}})}return!1}function DS(n,t,e,o){const r=n.getBlockByIndex(t,e);return n.getBlockString(r,{boxReplacement:" "}).substring(0,o)!==">"?!1:(n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{quoted:!0},Ot(n,r,0))}),!0)}const LS={"#":1,"##":2,"###":3,"####":4,"#####":5,"######":6,"#######":7,"########":8};function MS(n,t,e,o){const r=n.getBlockByIndex(t,e),i=n.getBlockString(r,{boxReplacement:" "}).substring(0,o);let s=LS[i];if(!s)return!1;const l=n.getBlockData(r).heading;return l&&l==s&&(s=null),n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{heading:s},Ot(n,r,0))}),!0}function RS(n,t,e,o){return!!(MS(n,t,e,o)||DS(n,t,e,o))}const OS=w("match-text-style");function NS(n){let t="";for(let e=n.length-1;e>=0;e--){const o=n[e];if(!o.attributes||Object.keys(o.attributes).length===0){t+=o.insert;continue}break}return t}function PS(n,t){if(n.length<t.length*2+1||!n.endsWith(t)||n.substring(0,n.length-1).endsWith(t))return-1;const e=n.substring(0,n.length-t.length),o=e.lastIndexOf(t);return o===-1?-1:o===0?0:e.substring(o-1).startsWith(t)?-1:o}const $S={"*":{type:"style",styles:["style-italic"],boxType:""},"**":{type:"style",styles:["style-bold"],boxType:""},"***":{type:"style",styles:["style-bold","style-italic"],boxType:""},"~~":{type:"style",styles:["style-strikethrough"],boxType:""},"`":{type:"style",styles:["style-code"],boxType:""},$$:{type:"box",styles:[],boxType:"math"}};function _S(n,t,e,o){var d,f;const r=n.getBlockByIndex(t,e),i=n.getBlockText(r),{left:s}=ve(i,o),l=NS(s),c=me(s)-l.length,a=Object.entries($S);for(const[m,p]of a){const A=PS(l,m);if(A===-1)continue;const k=c+A,y=o,T=m.length,E=bt(Gt(i,k+T,y-k-T*2).middle);if(p.type==="style"){const L={};p.styles.forEach(_=>{L[_]=!0});const R=tr(E,L);n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,k,y-k),n.insertTextToBlock(r,k,R)})}else if(p.type==="box")try{const L=(f=(d=n.editorBoxes.getBoxClass(p.boxType)).convertFrom)==null?void 0:f.call(d,n,E);if(!L)continue;n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,k,y-k),n.insertBoxToBlock(r,k,L)})}catch(L){OS.warn(`failed to convert to box, ${L.message}`);continue}return!0}return!1}class la{handleAfterInsertText(t,e,o,r,i){return!!(i===" "&&(RS(t,e,o,r)||_S(t,e,o,r)))}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=t.getTextPosition();if($(t,t.getBlockByIndex(r,i))){if(Hn(e,"Enter")){if(a6(t,r,i,s,"enter"))return!0}else if(Hn(e,"Space")&&a6(t,r,i,s,"space"))return!0}return!1}}const FS={"en-US":{placeholder:{default:"Type \u2018/\u2019 for commands",heading:"Heading {heading}",list:"List",mention:"Quickly assign tasks @mention yourself or others",quote:"Quote",title:"Enter document title"}},"zh-CN":{placeholder:{default:"\u8F93\u5165\u300C/\u300D\u5FEB\u901F\u63D2\u5165",heading:"\u6807\u9898{heading}",list:"\u5217\u8868",mention:"\u5FEB\u901F\u5206\u914D\u4EFB\u52A1\uFF0C@\u63D0\u53CA\u81EA\u5DF1\u6216\u4ED6\u4EBA",quote:"\u5F15\u7528",title:"\u8BF7\u8F93\u5165\u6587\u6863\u6807\u9898"}}};x.mergeLang(FS);function Vs(n,t){const e=Ao(n,t);return!!(e.text&&me(e.text)===0&&!t.querySelector(".inputting-insertion"))}function u6(n,t){var o;st(t).removeAttribute("data-content-placeholder"),(o=t.querySelector("[data-type=block-tools] .block-placeholder-container"))==null||o.remove()}function ca(n,t,e){var r;if(!Vs(n,t)){u6(n,t);return}const o=st(t);if(typeof e=="string")o.setAttribute("data-content-placeholder",e);else{const i=Rt(t),s=(r=i.querySelector(".block-placeholder-container"))!=null?r:b("div",["block-placeholder-container"],i);s.innerHTML="",s.appendChild(e)}}function HS(n){const t=n.getAttribute("data-style-heading");return t?x.t("placeholder.heading",{heading:t}):n.getAttribute("data-style-quoted")?x.t("placeholder.quote"):null}function jS(n){const t=n.getAttribute("data-list-type");return t?t==="ordered"||t==="unordered"?x.t("placeholder.list"):x.t("placeholder.mention"):null}function d6(n){switch(rt(n)){case"text":return HS(n);case"list":return jS(n);default:return null}}function zS(n){if(Wn(n))return!1;const t=U(H(n));return t?rt(t)==="code":!1}function US(n){if(Wn(n))return!1;const t=U(H(n));return t?rt(t)==="table":!1}function VS(n,t){var d,f;const e=n.selection.focusedBlock,o=rt(e),r=t.contentPlaceholder||x.t("placeholder.default");let i=r;if(o&&Vi(n,o)&&e){if(zS(e))return;US(e)?i=x.t("placeholder.common.contentInTable"):i=(d=d6(e))!=null?d:i}const s=n.getFirstBlock(),l=dt(s);if(!l)return;const c=dt(l);if(c&&!t.addPlaceholderToAllCurrentEmptyBlock)return;if(!c){Vs(n,l)&&ca(n,l,(f=d6(l))!=null?f:r);return}const a=n.getFocusedBlock();!Vs(n,a)||a!==s&&ca(n,a,i)}function qS(n,t){var r,i;const e=n.getFirstBlock(),o=st(e);Vs(n,e)?(o.setAttribute("data-title-placeholder",(r=t.titlePlaceholder)!=null?r:x.t("placeholder.title")),o.setAttribute("data-title-placeholder-readonly",(i=t.readonlyTitlePlaceholder)!=null?i:"")):(o.removeAttribute("data-title-placeholder"),o.removeAttribute("data-title-placeholder-readonly"))}function WS(n){n.rootContainer.querySelectorAll("[data-content-placeholder").forEach(t=>{t.removeAttribute("data-content-placeholder")}),n.rootContainer.querySelectorAll("[data-type=block-tools] .block-placeholder-container").forEach(t=>{t.remove()})}function GS(n,t){WS(n),n.selection.range.isCollapsed()&&(qS(n,t),VS(n,t))}const CV="",ZS=w("enforce-title");class qs{constructor(t,e={headingLevel:1}){h(this,"handleSelectionChange",t=>{setTimeout(()=>{this.applyPlaceholder(t)})});this.options=e,this.handleChanged(t),this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange)}destroy(t){t.removeListener("selectionChanged",this.handleSelectionChange)}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=t.getTextPosition();if(!qs.isDocumentTitleBlock(r,i)||!Hn(e,"Enter"))return!1;let l=!1,c=null;Ze(t.rootContainer)===2&&(c=xr(t.rootContainer,1),G(t,c)===0&&(l=!0));const a=t.getFirstBlock();return t.undoManager.runInGroup(()=>{t.breakTextBlock(a,s,{forceInsertAfter:!0}),l&&c&&t.deleteBlock(c)}),!0}handleChanged(t){var e;try{const o=t.doc.getContainerBlocks(V(t.rootContainer));u(ZS,o.length>0,"root container is empty");const r=o[0];if(r.type!=="text"||r.heading!==this.options.headingLevel){const i=Vn("",{heading:(e=this.options.headingLevel)!=null?e:1});t.insertBlock(V(t.rootContainer),0,i);return}if(o.length>1)return;t.insertTextBlock("",V(t.rootContainer),1,{newRange:t.selection.range.toDocRange()})}finally{this.applyPlaceholder(t)}}handleRemoteChanged(t){setTimeout(()=>{this.applyPlaceholder(t)})}handleUpdateCompositionText(t){this.applyPlaceholder(t)}applyPlaceholder(t){var e,o;!((e=this.options)!=null&&e.titlePlaceholder)&&!((o=this.options)!=null&&o.contentPlaceholder)||GS(t,this.options)}static isDocumentTitleBlock(t,e){return t==="root"&&e===0}}const h6=w("code-dom");function Do(n){return rt(n)==="code"}function f6(n,t,e){e.language?t.setAttribute("data-language",e.language):t.removeAttribute("data-language"),e.nowrap?j(t,"wrap"):M(t,"wrap")}function N1(n){const t=n.closest("div[data-type=editor-block][data-block-type=code]");return u(h6,t,"no parent code block"),u(h6,Do(t),"not a code block"),t}const aa={plain:{name:"Plain Text",aliases:["txt","text"]},abap:{name:"ABAP",aliases:["abap"]},arduino:{name:"Arduino",aliases:["ino"]},bash:{name:"Bash",aliases:["sh","shell"]},basic:{name:"BASIC",aliases:["bas"]},c:{name:"C",aliases:["c"]},clojure:{name:"Clojure",aliases:["clj"]},cofeescript:{name:"CoffeeScript",aliases:["coffee"]},cpp:{name:"C++",aliases:["cpp","cxx"]},csharp:{name:"C#",aliases:["cs"]},css:{name:"CSS",aliases:["css"]},dart:{name:"Dart",aliases:["dart"]},diff:{name:"Diff",aliases:["diff","patch"]},docker:{name:"Docker",aliases:["dockerfile"]},elixir:{name:"Elixir",aliases:["ex","exs"]},elm:{name:"Elm",aliases:["elm"]},erlang:{name:"Erlang",aliases:["erl"]},flow:{name:"Flow",aliases:["flow"]},fortran:{name:"Fortran",aliases:["f","for","f77","f90"]},fsharp:{name:"F#",aliases:["fsharp"]},gherkin:{name:"Gherkin",aliases:["feature"]},glsl:{name:"GLSL",aliases:["glsl"]},go:{name:"Go",aliases:["go"]},graphql:{name:"GraphQL",aliases:["graphql"]},groovy:{name:"Groovy",aliases:["groovy"]},haskell:{name:"Haskell",aliases:["hs"]},java:{name:"Java",aliases:["java"]},js:{name:"JavaScript",aliases:["js","jsx"]},json:{name:"JSON",aliases:["json"]},julia:{name:"Julia",aliases:["jl"]},kotlin:{name:"Kotlin",aliases:["kt","ktm","kts"]},latex:{name:"LaTeX",aliases:["tex"]},less:{name:"LESS",aliases:["less"]},lisp:{name:"Lisp",aliases:["lisp"]},livescript:{name:"LiveScript",aliases:["ls"]},lua:{name:"Lua",aliases:["lua"]},makefile:{name:"Makefile",aliases:["mk","mak"]},markdown:{name:"Markdown",aliases:["md","mkdown","mkd"]},markup:{name:"HTML / XML",aliases:["html","htm","xml","xsd","xsl","xslt","wsdl"]},matlab:{name:"MATLAB",aliases:["matlab"]},mermaid:{name:"Mermaid",aliases:["mermaid"]},nix:{name:"Nix",aliases:["nix"]},objectivec:{name:"Objective-C",aliases:["m","mm"]},ocaml:{name:"OCaml",aliases:["ml"]},pascal:{name:"Pascal",aliases:["pas"]},perl:{name:"Perl",aliases:["pl","pm"]},php:{name:"PHP",aliases:["php"]},powershell:{name:"PowerShell",aliases:["ps","ps1"]},prolog:{name:"Prolog",aliases:["plg"]},protobuf:{name:"Protocol Buffers",aliases:["proto"]},python:{name:"Python",aliases:["py"]},r:{name:"R",aliases:["r"]},reason:{name:"Reason",aliases:["re","rei"]},ruby:{name:"Ruby",aliases:["rb"]},rust:{name:"Rust",aliases:["rs"]},sass:{name:"Sass",aliases:["sass"]},scala:{name:"Scala",aliases:["scala"]},scheme:{name:"Scheme",aliases:["scm","sm"]},scss:{name:"SCSS",aliases:["scss"]},solidity:{name:"Solidity",aliases:["sol"]},sql:{name:"SQL",aliases:["sql"]},swift:{name:"Swift",aliases:["swift"]},typescript:{name:"TypeScript",aliases:["ts","tsx"]},vbnet:{name:"VB.Net",aliases:["vbnet"]},verilog:{name:"Verilog",aliases:["v"]},vhdl:{name:"VHDL",aliases:["vhdl"]},"visual-basic":{name:"Visual Basic",aliases:["vb","vba"]},wasm:{name:"WebAssembly",aliases:["wasm"]},yaml:{name:"YAML",aliases:["yaml"]}};function QS(n){const t=n.toLocaleLowerCase();let e="";return Object.entries(aa).forEach(([o,r])=>{(o===t||r.aliases.includes(t)||r.name.toLocaleLowerCase()===t)&&(e=o)}),e}function m6(n){const t=n.settingsProvider.getItem("editor-code-lang");return t!=null?t:"plain"}function YS(n,t){return n.settingsProvider.setItem("editor-code-lang",t)}const JS=w("convert-to-code");function KS(n,t){if(!$(n,t))return null;const e={id:P(),type:"text",text:[]},o=P();n.doc.localInsertChildContainer(o,[e]);const r=n.getBlockData(t).text;u(JS,r,"no text");let i=bt(r);i.startsWith("```")&&(i=i.substring(3));const s=QS(i)||m6(n)||"plain";return{blockData:{id:P(),type:"code",language:s,children:[o]},focusBlockId:e.id}}const AV="",P1=w("code-block-child-container");function ai(n){u(P1,Do(n),"not a code block");const e=st(n).querySelector(":scope > div.editor-code-root > div.code-text-root [data-type=editor-container].child");return u(P1,e,"no code text container"),e}function ui(n){u(P1,Do(n),"not a code block");const e=st(n).querySelector(":scope > div.editor-code-root > div.code-caption-root [data-type=editor-container].child");return e||null}function ua(n){const t=[ai(n)],e=ui(n);return e&&t.push(e),t}function di(n,t){if(!$(n,t))return!1;const e=H(t),o=U(e);return o?Do(o)?e===ai(o):rt(t)==="code":!1}const $1=w("code-caption");function XS(n,t){if(n.readonly)return;const e=ui(t);if(e){const c=Ft(e);n.selection.selectBlock(c,0);return}const o=wn(n.doc),r=n.getBlockData(t);u($1,r.children.length===1,"code block should have only one child");const i={...r,children:[r.children[0],o]};n.updateBlockData(t,i);const s=n.getContainerById(o),l=Ft(s);n.selection.selectBlock(l,0)}function g6(n,t){const e=H(t);if(Ct(e))return!1;const o=U(e);if(u($1,o,"no parent block"),!Do(o))return!1;const i=ui(o);return e===i}function tD(n,t){if(n.readonly||!ui(t))return;const o=ai(t),r=Jt(o);n.selection.selectBlock(r,G(n,r));const i=n.getBlockData(t);u($1,i.children.length===2,"code block should have only one child");const s=i.children[1],l={...i,children:[i.children[0]]};n.updateBlockData(t,l),n.deleteChildContainers([s])}const eD=w("paste-in-table-block");class nD{constructor(t){this.editor=t,setTimeout(()=>{t.input.addHandler(this)})}destroy(){}async handleBeforePaste(t,e,o){if(!t.selection.range.isSimple())return!1;const r=t.selection.range.start,i=t.getBlockById(r.blockId),s=H(i);if(Ct(s))return!1;const l=U(s);if(u(eD,l,"no parent block"),!Do(l)||g6(t,i))return!1;const c=o["text/plain"];return c&&t.undoManager.runInGroup(()=>{t.clearSelectedContents(),t.insertDoc(i,r.offset,c)}),!0}}function oD(n){n.addCustom("code-block-paste-event",t=>new nD(t))}class rD{constructor(t){h(this,"id","CodeBlockCommandProvider");setTimeout(()=>{t.editorCommandProviders.registerCommandProvider(this)})}destroy(){}getAvailableCommands(){return[]}executeCommand(){return!1}filterCommands(t,e,o,r){if(di(t,e))return[]}beforeExecuteCommand(t,e,o,r,i){return!!di(t,e)}}function iD(n){n.addCustom("code-block-command-provider",t=>new rD(t))}const sD=w("code-caption-input-handler");function _1(n){if(!n.selection.range.isSimple())return null;const t=n.selection.range.start;if(!t.isSimple())return null;const e=n.getBlockById(t.blockId);return g6(n,e)?e:null}function lD(n){const t=_1(n);if(!t)return!1;const e=N1(t),o=dt(e);return o?(n.selection.selectBlock(o,0),!0):(n.insertTextBlock("",V(H(e)),K(e)+1),!0)}function cD(n){const t=_1(n);if(!t)return!1;if(Tt(n,t)){const e=N1(t);return tD(n,e),!0}return!1}class F1{constructor(t){setTimeout(()=>{t.input.addHandler(this)})}destroy(){}handleBeforeKeyDown(t,e){return e.key==="Enter"?lD(t):e.key==="Backspace"?cD(t):!1}async handleBeforePaste(t,e,o){const r=_1(t);if(!r)return!1;const i=o["text/plain"];if(!i)return!0;const s=sc(t,i);return s&&t.undoManager.runInGroup(()=>{t.clearSelectedContents();const l=t.selection.range.start;u(sD,l.isSimple(),"not simple position"),t.insertTextToBlock(r,l.offset,s)}),!0}static init(t){t.addCustom("code-block-caption-input-handler",e=>new F1(e))}}const aD=`
|
|
381
381
|
<svg fill="currentColor" focusable="false" viewBox="0 0 24 24" aria-hidden="true" tabindex="-1">
|
|
382
382
|
<path d="M8.12 9.29 12 13.17l3.88-3.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0L6.7 10.7a.9959.9959 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0z"></path>
|
|
383
383
|
</svg>`,uD=`
|