@ones-editor/editor 1.0.2-beta.11 → 1.0.2-beta.12

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
@@ -913,7 +913,7 @@ ${s}
913
913
  <add as="fillColor" value="#ffffff"/>
914
914
  </add>
915
915
  </mxStylesheet>
916
- `,x4=0,cQ=30*1e3,b4="editor-empty-drawio",v4="show-full-screen-iframe",je=I("embed-block-drawio");function rc(n){return n.options.componentsOptions.drawIO||{}}function uQ(n){const e=rc(n).lang;return e?rQ[e]:""}function fQ(n){var i;const e=((i=(rc(n)||{}).cdn)==null?void 0:i.drawioIframe)||iQ,r=uQ(n);return vg(e,{spin:1,proto:"json",configure:1,lang:r})}function dQ(n){const t=()=>{p(je,n,"el does not exist");const r=document.body.clientWidth||document.documentElement.clientWidth,i=document.body.clientHeight||document.documentElement.clientHeight;n.setAttribute("width",`${r-2*x4}`),n.setAttribute("height",`${i-2*x4}`)},e=()=>{window.removeEventListener("resize",t)};return t(),window.addEventListener("resize",t),{disconnect:e}}async function hQ(n){const e=(rc(n)||{}).callbacks||{},{onCreateDrawIoFrame:r,onCloseDrawIoFrame:i}=e;let o=null,s;if(r)o=await r(n),p(je,o,"iframe create failed"),s=()=>{p(je,o,"iframe does not exist"),p(je,i,"missing parameters: onCloseDrawIoFrame"),i(n,o)};else{const l=B("div",["editor-drawio-iframe-container","loading"],document.body);l.setAttribute("data-placeholder",D.t("drawio.loading")),o=B("iframe",["drawio-iframe-element"],l),o.setAttribute("frameborder","0"),z(l,v4);const{disconnect:c}=dQ(o);s=()=>{p(je,o,"iframe does not exist"),c(),document.body.removeChild(l),ot(l,v4)}}return{drawioIframe:o,exit:s}}async function mQ(n,t,e,r){var i,o;try{r&&je.debug("auto saving drawio data");const s=new Blob([e]),l=new File([s],"drawio.svg",{type:"image/svg+xml"});try{const c=n.findBlockById(st(t));if(c){const d=await n.doc.uploadResource(l),{resourceId:h}=d,E=n.getBlockData(c).embedData,x={src:h,height:E==null?void 0:E.height};n.updateEmbedData(c,x)}else je.error("block has been deleted")}catch(c){const d=`failed to upload drawio data: ${c.message}`;je.error(d)}}catch(s){const l=`failed to save drawio data: ${s.message}`,c=rc(n);if((i=c.callbacks)!=null&&i.onError){const d=new Error(l);d.code="SaveDrawIo",(o=c.callbacks)==null||o.onError(n,d)}}}function gQ(n,t,e,r,i,o,s){const l=()=>{window.removeEventListener("message",c),o()},c=async d=>{var h,C;if(p(je,r.contentWindow,"iframe.contentWindow does not exist"),d.data.length>0){const E=JSON.parse(d.data),x=e.xmlSvg||e.xml,v=document.querySelectorAll(".editor-drawio-iframe-container");switch(E.event){case"configure":r.contentWindow.postMessage(JSON.stringify({action:"configure",config:{defaultFonts:["Humor Sans","Helvetica","Times New Roman"]}}),"*");break;case"init":x!=null&&r.contentWindow.postMessage(JSON.stringify({action:"load",saveAndExit:1,noSaveBtn:1,noExitBtn:0,xml:x}),"*"),i(),v.forEach(L=>{ot(L,"loading")});break;case"export":const R=Kc(E.data.substring(E.data.indexOf(",")+1));mQ(n,t,R,!!((h=E.message)!=null&&h.autoSave)),(C=E.message)!=null&&C.autoSave||l();break;case"save":r.contentWindow.postMessage(JSON.stringify({action:"export",format:"xmlsvg",spin:"Saving graph"}),"*");break;case"exit":l();break}}};window.addEventListener("message",c)}async function B4(n,t,e,r){if(r)return;r=!0;const i=rc(n)||{},{callbacks:o}=i;let s;o&&(o==null?void 0:o.onBeginInitDrawIo)&&o.onBeginInitDrawIo(n,t);const{drawioIframe:l,exit:c}=await hQ(n);if(rE(n,t),e.src){const E=await A4(n,n.doc.buildResourceUrl(e.src));E&&(e.xmlSvg=E)}gQ(n,t,e,l,()=>{s=setInterval(()=>{!l||!l.contentWindow||l.contentWindow.postMessage(JSON.stringify({action:"export",format:"xmlsvg",spin:"Saving graph",autoSave:!0}),"*")},cQ)},()=>{c(),s&&clearInterval(s);const E=n.findBlockById(st(t));E&&iE(n,E)});const C=fQ(n);l.setAttribute("src",C)}async function pQ(n){var i,o;const t=rc(n),e=((i=t.cdn)==null?void 0:i.drawio)||oQ,r=((o=t.cdn)==null?void 0:o.pako)||sQ;await _s(r,"editor-pako"),await _s(e,"editor-drawio"),await new Promise(s=>{setTimeout(s,100)})}function CQ(n){ot(n,b4)}function zE(n){z(n,b4);const t=B("div",["drawio-empty-content"],n);t.innerHTML=lQ,B("span",["drawio-empty-title"],t,D.t("drawio.empty"))}function EQ(n,t,e){const r=nt(t);if(!r)return;const i=Ot(r);t.innerHTML="",t.style.height="100%",z(r,"drawio-load-error");const o=B("div",["drawio-error-content"],t),s=B("div",["drawio-error-brand-icon"],o);s.innerHTML=zh,B("div",["drawio-error-title"],o,D.t("drawio.errorTips"));const l=B("div",["drawio-error-sub-title"],o);B("span",[],l,D.t("drawio.errorSubTips"));const c=B("span",["drawio-error-retry-button"],l,D.t("drawio.retry"));c.onclick=()=>{t.innerHTML="",ot(r,"drawio-load-error"),e.src?T4(e.src,t,n):e.xml?y4(e.xml,t,n):e.xmlSvg&&k4(e.xmlSvg,t),e.height&&(i.style.height=`${e.height}px`,t.style.height=`${e.height-20}px`)}}function GE(n,t){if(p(je,t,"Required data is missing in setGraph"),"src"in t){n.setAttribute("data-src",t.src);return}if("xmlSvg"in t){n.setAttribute("data-xmlsvg",t.xmlSvg);return}if("graph"in t){const{xml:e,graph:r}=t;n.graph=r,n.setAttribute("data-mxfile",e)}}function AQ(n){return{src:n.getAttribute("data-src")||"",xmlSvg:n.getAttribute("data-xmlsvg")||"",xml:n.getAttribute("data-mxfile")||""}}function T4(n,t,e){p(je,n,"params error: src"),p(je,e,"params error: editor");const r=t,i=e.doc.buildResourceUrl(n),o=document.createElement("img");r.innerHTML="",r.appendChild(o),o.src=i,o.draggable=!1,GE(r,{src:n}),o.onload=s=>{const l=r.querySelector("img");s.target!==l||!l||(tQ(l)?zE(t):(l.style.width="100%",l.style.height="100%",CQ(t)))},o.onerror=s=>{const l=r.querySelector("img");s.target===l&&EQ(e,t,{src:n})}}function y4(n,t,e){p(je,e,"parameter missing"),pQ(e).then(()=>{const{mxUtils:r,mxGraph:i,mxCodec:o}=window;p(je,r,"External resource loading exception: mxUtils"),p(je,i,"External resource loading exception: MxGraph"),p(je,o,"External resource loading exception: MxCodec");const s=r.parseXml(n);t.innerHTML="";const l=s.documentElement;p(je,l,"Resource parsing exception"),p(je,l.nodeName==="mxfile","Resource parsing exception");const c=l.getElementsByTagName("diagram");p(je,c.length>0,"Resource parsing exception");let d;const h=c[0];if(h.text||h.textContent){const R=nQ(h),L=atob(R),M=window.pako;p(je,M,"External resource loading exception: pako");const U=M.inflateRaw(Uint8Array.from(L,G=>G.charCodeAt(0)),{to:"string"}),F=decodeURIComponent(U);d=r.parseXml(F)}else{const R=new XMLSerializer().serializeToString(h.firstChild);d=r.parseXml(R)}const C=new i(t);C.resetViewOnRootChange=!1,C.foldingEnabled=!1,C.setTooltips(!1),C.setEnabled(!1),C.setHtmlLabels(!0);const E=r.parseXml(aQ);new o(E).decode(E.documentElement,C.getStylesheet());const v=new o(d);v.decode(v.document.documentElement,C.getModel()),C.maxFitScale=1,C.fit(),C.center(!0,!1),GE(t,{graph:C,xml:n})})}function k4(n,t){t.innerHTML=n,GE(t,{xmlSvg:n});const e=t.querySelectorAll("svg");for(let r=0;r<e.length;r++){const i=e[r];if(!eQ(i))return}zE(t)}function xQ(n,t){const e=IE(n,t,{handleExecuteCommand:(o,s,l)=>{if(l.id==="edit"){const c=o.getBlockData(s).embedData;return B4(o,s,c,!1),!0}return!1}}),r=(o,s)=>{const l=o.getBlockData(s);if(l.embedData&&l.embedData.src){const c=document.createElement("a");return c.href=o.doc.buildResourceUrl(l.embedData.src),c.download=l.embedData.src,c.click(),!0}return!1},i={blockCommands:{"context-menu":{group:"drawio",commands:[{id:"image-save-as",name:D.t("contextMenu.imageSaveAs")}],executeCommand:(o,s,l)=>{const{id:c}=l;switch(c){case"image-save-as":return r(o,s),!0;default:return!1}}}}};return{...e,...i,abstract:D.t("drawio.abstract")}}const bQ={"en-US":{drawio:{title:"Flowchart/UML",empty:"Empty graph",loading:"Loading",abstract:"Flowchart/UML",errorTips:"Flowchart/UML loading failed",errorSubTips:"The network service is abnormal, you can",retry:"Try again"}},"zh-CN":{drawio:{title:"\u6D41\u7A0B\u56FE/UML",empty:"\u7A7A\u56FE\u8868",loading:"\u52A0\u8F7D\u4E2D",abstract:"\u6D41\u7A0B\u56FE/UML",errorTips:"\u6D41\u7A0B\u56FE/UML\u52A0\u8F7D\u5931\u8D25",errorSubTips:"\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5",retry:"\u91CD\u8BD5"}},"ja-JP":{drawio:{title:"\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8/UML",empty:"\u30B0\u30E9\u30D5\u30C7\u30FC\u30BF\u306A\u3057",loading:"\u8AAD\u8FBC\u4E2D",abstract:"\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8/UML",errorTips:"\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8/UML \u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F",errorSubTips:"\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 ",retry:"\u518D\u8A66\u884C"}}};D.mergeLang(bQ);const J0=I("embed-block-drawio"),vQ=!1;function BQ(n,t,e,r){p(J0,e,`parameter missing: ${e}`),p(J0,n,`parameter missing: ${n}`),B4(n,t,r,vQ)}function R4(n,t,e){const{src:r,xml:i,xmlSvg:o}=e;r?T4(r,t,n):i?y4(i,t,n):o?k4(o,t):zE(t)}function TQ(n,t,e){const r=B("div",["editor-drawio-content","editor-embed"],null);t.appendChild(r),R4(n,r,e),e.height&&(t.style.height=`${e.height}px`,r.style.height=`${e.height-20}px`)}function yQ(n,t,e){const{src:r,xml:i,xmlSvg:o}=e,s=AQ(t);if(r!==s.src||(i||"")!==s.xml||(o||"")!==s.xmlSvg){R4(n,t,e);return}const l=t.parentElement,c=nt(l);e.height&&e.height!==Number.parseInt(l.style.height,10)&&(l.style.height=`${e.height}px`,c&&!c.classList.contains("drawio-load-error")?t.style.height=`${e.height-20}px`:t.style.height="100%")}function kQ(n,t,e,r,i,o){const s=e.embedData;TQ(n,t,s),gf.register(n,o)}function RQ(n,t,e){const r=e.embedData,o=Ot(t).querySelector(":scope > .editor-drawio-content");return p(J0,o,"embed should not be null"),yQ(n,o,r),!0}function wQ(){return{name:"UML",insertEmbedCommandItems:[{id:"insert-drawio",name:D.t("drawio.title"),icon:eT,group:"common",order:600,subText:Bn("insert-drawio")}],handleInsertEmptyEmbed:async(n,t)=>{const e={src:"",xml:"",xmlSvg:""},r=n.insertEmbed(t.containerId,t.blockIndex,"drawio",e);return setTimeout(()=>{const o=Ot(r).querySelector(":scope > .editor-drawio-content");p(J0,o,"embed should not be null");const s=n.getBlockData(r);BQ(n,r,o,s.embedData)},100),r}}}function SQ(n,t,e,r){const{embedData:i}=t,o=i;return r==="html"?o.src?`<img src="${n.doc.buildResourceUrl(o.src,{withToken:!0})}" />`:o.xmlSvg?o.xmlSvg:"<p>[drawio]</p>":r==="markdown"?o.src?`![drawio](${n.doc.buildResourceUrl(o.src,{withToken:!0})})`:o.xmlSvg?o.xmlSvg:"[drawio]":""}const w4={embedType:"drawio",getOptions:wQ,createEmbedContent:kQ,handleUpdateBlock:RQ,getBlockProperties:xQ,convertTo:SQ},Clt="",Elt="",LQ=500,IQ=300,WE=I("code-editor");function DQ(n){const t=n.closest(".embed-code-editor-container");return p(WE,t,"code-editor-container non-existent"),t}function _Q(n,t,e){const r=n.target;p(WE,r,"Parameter error: textarea must be an element");const i=r.value;DQ(r).remove(),ot(t,"editing"),e(i),Ot(t).style.removeProperty("margin-top")}function MQ(n,t){p(WE,n,"Parameter Error: handleCodeUpdate[event]");const e=n.target.value;t(e)}const UQ=Ke.default(MQ,LQ);function OQ(n,t,e,r,i){n.domEvents.addEventListener(t,"blur",(o,s)=>{_Q(s,e,i)}),n.domEvents.addEventListener(t,"keyup",(o,s)=>{const l=s.target;s.key==="Escape"&&l.blur()}),n.domEvents.addEventListener(t,"input",(o,s)=>{UQ(s,r)})}function NQ(n,t,e){const{height:r,codeValue:i,onChange:o,onEnd:s}=e,l=r||IQ,c=Ot(t),d=ne(t),h=B("div",["embed-code-editor-container"],d),C=B("textarea",["embed-code-editor-textarea"],h);C.value=i||"",C.setAttribute("spellcheck","false"),h.style.height=`${l}px`,OQ(n,C,t,o,s),c.style.marginTop=`${l}px`,z(t,"editing"),setTimeout(()=>{C.setSelectionRange(0,0),C.focus(),C.scrollTop=0})}var qE={exports:{}};/**
916
+ `,x4=0,cQ=30*1e3,b4="editor-empty-drawio",v4="show-full-screen-iframe",je=I("embed-block-drawio");function rc(n){return n.options.componentsOptions.drawIO||{}}function uQ(n){const e=rc(n).lang;return e?rQ[e]:""}function fQ(n){var i;const e=((i=(rc(n)||{}).cdn)==null?void 0:i.drawioIframe)||iQ,r=uQ(n);return vg(e,{spin:1,proto:"json",configure:1,lang:r})}function dQ(n){const t=()=>{p(je,n,"el does not exist");const r=document.body.clientWidth||document.documentElement.clientWidth,i=document.body.clientHeight||document.documentElement.clientHeight;n.setAttribute("width",`${r-2*x4}`),n.setAttribute("height",`${i-2*x4}`)},e=()=>{window.removeEventListener("resize",t)};return t(),window.addEventListener("resize",t),{disconnect:e}}async function hQ(n){const e=(rc(n)||{}).callbacks||{},{onCreateDrawIoFrame:r,onCloseDrawIoFrame:i}=e;let o=null,s;if(r)o=await r(n),p(je,o,"iframe create failed"),s=()=>{p(je,o,"iframe does not exist"),p(je,i,"missing parameters: onCloseDrawIoFrame"),i(n,o)};else{const l=B("div",["editor-drawio-iframe-container","loading"],document.body);l.setAttribute("data-placeholder",D.t("drawio.loading")),o=B("iframe",["drawio-iframe-element"],l),o.setAttribute("frameborder","0"),z(l,v4);const{disconnect:c}=dQ(o);s=()=>{p(je,o,"iframe does not exist"),c(),document.body.removeChild(l),ot(l,v4)}}return{drawioIframe:o,exit:s}}async function mQ(n,t,e,r){var i,o;try{r&&je.debug("auto saving drawio data");const s=new Blob([e]),l=new File([s],"drawio.svg",{type:"image/svg+xml"});try{const c=n.findBlockById(st(t));if(c){const d=await n.doc.uploadResource(l),{resourceId:h}=d,E=n.getBlockData(c).embedData,x={src:h,height:E==null?void 0:E.height};n.updateEmbedData(c,x)}else je.error("block has been deleted")}catch(c){const d=`failed to upload drawio data: ${c.message}`;je.error(d)}}catch(s){const l=`failed to save drawio data: ${s.message}`,c=rc(n);if((i=c.callbacks)!=null&&i.onError){const d=new Error(l);d.code="SaveDrawIo",(o=c.callbacks)==null||o.onError(n,d)}}}function gQ(n,t,e,r,i,o,s){const l=()=>{window.removeEventListener("message",c),o()},c=async d=>{var h,C;if(p(je,r.contentWindow,"iframe.contentWindow does not exist"),d.data.length>0){const E=JSON.parse(d.data),x=e.xmlSvg||e.xml,v=document.querySelectorAll(".editor-drawio-iframe-container");switch(E.event){case"configure":r.contentWindow.postMessage(JSON.stringify({action:"configure",config:{defaultFonts:["Humor Sans","Helvetica","Times New Roman"]}}),"*");break;case"init":x!=null&&r.contentWindow.postMessage(JSON.stringify({action:"load",saveAndExit:1,noSaveBtn:1,noExitBtn:0,xml:x}),"*"),i(),v.forEach(L=>{ot(L,"loading")});break;case"export":const R=Kc(E.data.substring(E.data.indexOf(",")+1));mQ(n,t,R,!!((h=E.message)!=null&&h.autoSave)),(C=E.message)!=null&&C.autoSave||l();break;case"save":r.contentWindow.postMessage(JSON.stringify({action:"export",format:"xmlsvg",spin:"Saving graph"}),"*");break;case"exit":l();break}}};window.addEventListener("message",c)}async function B4(n,t,e,r){if(r)return;r=!0;const i=rc(n)||{},{callbacks:o}=i;let s;o&&(o==null?void 0:o.onBeginInitDrawIo)&&o.onBeginInitDrawIo(n,t);const{drawioIframe:l,exit:c}=await hQ(n);if(rE(n,t),e.src){const E=await A4(n,n.doc.buildResourceUrl(e.src));E&&(e.xmlSvg=E)}gQ(n,t,e,l,()=>{s=setInterval(()=>{!l||!l.contentWindow||l.contentWindow.postMessage(JSON.stringify({action:"export",format:"xmlsvg",spin:"Saving graph",autoSave:!0}),"*")},cQ)},()=>{c(),s&&clearInterval(s);const E=n.findBlockById(st(t));E&&iE(n,E)});const C=fQ(n);l.setAttribute("src",C)}async function pQ(n){var i,o;const t=rc(n),e=((i=t.cdn)==null?void 0:i.drawio)||oQ,r=((o=t.cdn)==null?void 0:o.pako)||sQ;await _s(r,"editor-pako"),await _s(e,"editor-drawio"),await new Promise(s=>{setTimeout(s,100)})}function CQ(n){ot(n,b4)}function zE(n){z(n,b4);const t=B("div",["drawio-empty-content"],n);t.innerHTML=lQ,B("span",["drawio-empty-title"],t,D.t("drawio.empty"))}function EQ(n,t,e){const r=nt(t);if(!r)return;const i=Ot(r);t.innerHTML="",t.style.height="100%",z(r,"drawio-load-error");const o=B("div",["drawio-error-content"],t),s=B("div",["drawio-error-brand-icon"],o);s.innerHTML=zh,B("div",["drawio-error-title"],o,D.t("drawio.errorTips"));const l=B("div",["drawio-error-sub-title"],o);B("span",[],l,D.t("drawio.errorSubTips"));const c=B("span",["drawio-error-retry-button"],l,D.t("drawio.retry"));c.onclick=()=>{t.innerHTML="",ot(r,"drawio-load-error"),e.src?T4(e.src,t,n):e.xml?y4(e.xml,t,n):e.xmlSvg&&k4(e.xmlSvg,t),e.height&&(i.style.height=`${e.height}px`,t.style.height=`${e.height-20}px`)}}function GE(n,t){if(p(je,t,"Required data is missing in setGraph"),"src"in t){n.setAttribute("data-src",t.src);return}if("xmlSvg"in t){n.setAttribute("data-xmlsvg",t.xmlSvg);return}if("graph"in t){const{xml:e,graph:r}=t;n.graph=r,n.setAttribute("data-mxfile",e)}}function AQ(n){return{src:n.getAttribute("data-src")||"",xmlSvg:n.getAttribute("data-xmlsvg")||"",xml:n.getAttribute("data-mxfile")||""}}function T4(n,t,e){p(je,n,"params error: src"),p(je,e,"params error: editor");const r=t,i=e.doc.buildResourceUrl(n),o=document.createElement("img");r.innerHTML="",r.appendChild(o),o.src=i,o.draggable=!1,GE(r,{src:n}),o.onload=()=>{tQ(o)?zE(t):(o.style.width="100%",o.style.height="100%",CQ(t))},o.onerror=()=>{EQ(e,t,{src:n})}}function y4(n,t,e){p(je,e,"parameter missing"),pQ(e).then(()=>{const{mxUtils:r,mxGraph:i,mxCodec:o}=window;p(je,r,"External resource loading exception: mxUtils"),p(je,i,"External resource loading exception: MxGraph"),p(je,o,"External resource loading exception: MxCodec");const s=r.parseXml(n);t.innerHTML="";const l=s.documentElement;p(je,l,"Resource parsing exception"),p(je,l.nodeName==="mxfile","Resource parsing exception");const c=l.getElementsByTagName("diagram");p(je,c.length>0,"Resource parsing exception");let d;const h=c[0];if(h.text||h.textContent){const R=nQ(h),L=atob(R),M=window.pako;p(je,M,"External resource loading exception: pako");const U=M.inflateRaw(Uint8Array.from(L,G=>G.charCodeAt(0)),{to:"string"}),F=decodeURIComponent(U);d=r.parseXml(F)}else{const R=new XMLSerializer().serializeToString(h.firstChild);d=r.parseXml(R)}const C=new i(t);C.resetViewOnRootChange=!1,C.foldingEnabled=!1,C.setTooltips(!1),C.setEnabled(!1),C.setHtmlLabels(!0);const E=r.parseXml(aQ);new o(E).decode(E.documentElement,C.getStylesheet());const v=new o(d);v.decode(v.document.documentElement,C.getModel()),C.maxFitScale=1,C.fit(),C.center(!0,!1),GE(t,{graph:C,xml:n})})}function k4(n,t){t.innerHTML=n,GE(t,{xmlSvg:n});const e=t.querySelectorAll("svg");for(let r=0;r<e.length;r++){const i=e[r];if(!eQ(i))return}zE(t)}function xQ(n,t){const e=IE(n,t,{handleExecuteCommand:(o,s,l)=>{if(l.id==="edit"){const c=o.getBlockData(s).embedData;return B4(o,s,c,!1),!0}return!1}}),r=(o,s)=>{const l=o.getBlockData(s);if(l.embedData&&l.embedData.src){const c=document.createElement("a");return c.href=o.doc.buildResourceUrl(l.embedData.src),c.download=l.embedData.src,c.click(),!0}return!1},i={blockCommands:{"context-menu":{group:"drawio",commands:[{id:"image-save-as",name:D.t("contextMenu.imageSaveAs")}],executeCommand:(o,s,l)=>{const{id:c}=l;switch(c){case"image-save-as":return r(o,s),!0;default:return!1}}}}};return{...e,...i,abstract:D.t("drawio.abstract")}}const bQ={"en-US":{drawio:{title:"Flowchart/UML",empty:"Empty graph",loading:"Loading",abstract:"Flowchart/UML",errorTips:"Flowchart/UML loading failed",errorSubTips:"The network service is abnormal, you can",retry:"Try again"}},"zh-CN":{drawio:{title:"\u6D41\u7A0B\u56FE/UML",empty:"\u7A7A\u56FE\u8868",loading:"\u52A0\u8F7D\u4E2D",abstract:"\u6D41\u7A0B\u56FE/UML",errorTips:"\u6D41\u7A0B\u56FE/UML\u52A0\u8F7D\u5931\u8D25",errorSubTips:"\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5",retry:"\u91CD\u8BD5"}},"ja-JP":{drawio:{title:"\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8/UML",empty:"\u30B0\u30E9\u30D5\u30C7\u30FC\u30BF\u306A\u3057",loading:"\u8AAD\u8FBC\u4E2D",abstract:"\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8/UML",errorTips:"\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8/UML \u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F",errorSubTips:"\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 ",retry:"\u518D\u8A66\u884C"}}};D.mergeLang(bQ);const J0=I("embed-block-drawio"),vQ=!1;function BQ(n,t,e,r){p(J0,e,`parameter missing: ${e}`),p(J0,n,`parameter missing: ${n}`),B4(n,t,r,vQ)}function R4(n,t,e){const{src:r,xml:i,xmlSvg:o}=e;r?T4(r,t,n):i?y4(i,t,n):o?k4(o,t):zE(t)}function TQ(n,t,e){const r=B("div",["editor-drawio-content","editor-embed"],null);t.appendChild(r),R4(n,r,e),e.height&&(t.style.height=`${e.height}px`,r.style.height=`${e.height-20}px`)}function yQ(n,t,e){const{src:r,xml:i,xmlSvg:o}=e,s=AQ(t);if(r!==s.src||(i||"")!==s.xml||(o||"")!==s.xmlSvg){R4(n,t,e);return}const l=t.parentElement,c=nt(l);e.height&&e.height!==Number.parseInt(l.style.height,10)&&(l.style.height=`${e.height}px`,c&&!c.classList.contains("drawio-load-error")?t.style.height=`${e.height-20}px`:t.style.height="100%")}function kQ(n,t,e,r,i,o){const s=e.embedData;TQ(n,t,s),gf.register(n,o)}function RQ(n,t,e){const r=e.embedData,o=Ot(t).querySelector(":scope > .editor-drawio-content");return p(J0,o,"embed should not be null"),yQ(n,o,r),!0}function wQ(){return{name:"UML",insertEmbedCommandItems:[{id:"insert-drawio",name:D.t("drawio.title"),icon:eT,group:"common",order:600,subText:Bn("insert-drawio")}],handleInsertEmptyEmbed:async(n,t)=>{const e={src:"",xml:"",xmlSvg:""},r=n.insertEmbed(t.containerId,t.blockIndex,"drawio",e);return setTimeout(()=>{const o=Ot(r).querySelector(":scope > .editor-drawio-content");p(J0,o,"embed should not be null");const s=n.getBlockData(r);BQ(n,r,o,s.embedData)},100),r}}}function SQ(n,t,e,r){const{embedData:i}=t,o=i;return r==="html"?o.src?`<img src="${n.doc.buildResourceUrl(o.src,{withToken:!0})}" />`:o.xmlSvg?o.xmlSvg:"<p>[drawio]</p>":r==="markdown"?o.src?`![drawio](${n.doc.buildResourceUrl(o.src,{withToken:!0})})`:o.xmlSvg?o.xmlSvg:"[drawio]":""}const w4={embedType:"drawio",getOptions:wQ,createEmbedContent:kQ,handleUpdateBlock:RQ,getBlockProperties:xQ,convertTo:SQ},Clt="",Elt="",LQ=500,IQ=300,WE=I("code-editor");function DQ(n){const t=n.closest(".embed-code-editor-container");return p(WE,t,"code-editor-container non-existent"),t}function _Q(n,t,e){const r=n.target;p(WE,r,"Parameter error: textarea must be an element");const i=r.value;DQ(r).remove(),ot(t,"editing"),e(i),Ot(t).style.removeProperty("margin-top")}function MQ(n,t){p(WE,n,"Parameter Error: handleCodeUpdate[event]");const e=n.target.value;t(e)}const UQ=Ke.default(MQ,LQ);function OQ(n,t,e,r,i){n.domEvents.addEventListener(t,"blur",(o,s)=>{_Q(s,e,i)}),n.domEvents.addEventListener(t,"keyup",(o,s)=>{const l=s.target;s.key==="Escape"&&l.blur()}),n.domEvents.addEventListener(t,"input",(o,s)=>{UQ(s,r)})}function NQ(n,t,e){const{height:r,codeValue:i,onChange:o,onEnd:s}=e,l=r||IQ,c=Ot(t),d=ne(t),h=B("div",["embed-code-editor-container"],d),C=B("textarea",["embed-code-editor-textarea"],h);C.value=i||"",C.setAttribute("spellcheck","false"),h.style.height=`${l}px`,OQ(n,C,t,o,s),c.style.marginTop=`${l}px`,z(t,"editing"),setTimeout(()=>{C.setSelectionRange(0,0),C.focus(),C.scrollTop=0})}var qE={exports:{}};/**
917
917
  * @license
918
918
  * Lodash <https://lodash.com/>
919
919
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "1.0.2-beta.11",
3
+ "version": "1.0.2-beta.12",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",