@ones-editor/editor 0.0.3-beta.134 → 0.0.3-beta.135
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
|
@@ -400,7 +400,7 @@ $$${r.mathjaxText}$$
|
|
|
400
400
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
|
|
401
401
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.4388 7.11504H5.55388C5.24779 7.11504 5 6.86726 5 6.55388C5 6.24779 5.24779 6 5.55388 6H18.4388C18.7522 6 19 6.24779 19 6.55388C19 6.86726 18.7449 7.11504 18.4388 7.11504ZM18.4388 10.7225H5.55388C5.24779 10.7225 5 10.4748 5 10.1687C5 9.86257 5.24779 9.61478 5.55388 9.61478H18.4388C18.7522 9.61478 19 9.85528 19 10.1687C19 10.4748 18.7449 10.7225 18.4388 10.7225ZM18.4388 14.3373H5.55388C5.24779 14.3373 5 14.0895 5 13.7834C5 13.4701 5.24779 13.2223 5.55388 13.2223H18.4388C18.7522 13.2223 19 13.4701 19 13.7834C19 14.0895 18.7449 14.3373 18.4388 14.3373ZM12.8855 17.9448H5.55388C5.24779 17.9448 5 17.697 5 17.3909C5 17.0849 5.24779 16.8371 5.55388 16.8371H12.8855C13.1989 16.8371 13.4466 17.0849 13.4466 17.3909C13.4466 17.7043 13.1989 17.9448 12.8855 17.9448ZM21 14.7344V16.3013C21 17.486 20.4268 18.0593 19.2357 18.0593L17.5159 18.0593V18.8555C17.5159 19.2631 17.1019 19.4351 16.7771 19.1803L15.2866 18.0211C14.9045 17.7217 14.9045 17.3459 15.2866 17.0465L16.7771 15.8809C17.1019 15.6262 17.5159 15.8045 17.5159 16.2121V17.0083H19.1847C19.6943 17.0083 19.9554 16.7535 19.9554 16.2121V14.7344C19.9554 14.365 20.1465 14.1548 20.4777 14.1484C20.8153 14.1421 21 14.365 21 14.7344Z"/>
|
|
402
402
|
</svg>
|
|
403
|
-
`;function RF(n,e,t){const r={...n.getBlockData(e),language:t};n.updateBlockData(e,r),En(n,e).forEach(s=>{At(s).forEach(l=>{n.reloadBlock(l)})})}function OF(n,e,t){const r={...n.getBlockData(e),nowrap:t};n.updateBlockData(e,r)}const Zs=S("code-block-header"),_F=Object.entries(Cu).map(([n,e])=>({id:n,name:e.name,language:e}));function ob(n,e,t){m(Zs,Yi(e),"not a code block");const o=St(pc(e));n.selection.selectBlock(o,0),t.focusToEditor&&n.focus()}function PF(n,e){if(e){const t=n,{editor:o,codeBlock:r}=t.custom;RF(o,r,e.id);const i=r.querySelector(".code-block-header .language-select .name-label");i.innerText=e.name,mF(o,e.id),o.focus()}}function FF(n,e,t){n.addCustom("code-header-language-select-dropdown",i=>{const s=new ZS(_F,i.rootElement,{placeholder:O.t("code.search")});return s.onSelected=PF,s});const o=w("div",["language-select"],null);w("span",["name-label"],o,t);const r=w("span",["arrow-icon"],o);return r.innerHTML=SF,n.domEvents.addEventListener(o,"click",(i,s)=>{if(i.readonly)return;const a=s.target.closest(".language-select"),d=re(a);m(Zs,d,"no parent block"),m(Zs,Se(d)==="code","not a code block");const f=i.getBlockData(d),p=i.getCustom("code-header-language-select-dropdown");p.custom={codeBlock:d,editor:i},p.setSelectedId(f.language),p.show(a),ob(i,d,{focusToEditor:!1}),W(e,"editing-language"),p.onHide=()=>{te(e,"editing-language")}}),o}function NF(){return w("div",["code-header-spacer"],null)}function $F(n,e){const t=e.target,o=t.closest(".code-header-button");m(Zs,o,"no button");const r=re(t);m(Zs,r,"no parent block");const i=o.getAttribute("data-id");if(m(Zs,Se(r)==="code","not a code block"),i==="wrap"){const s=n.getBlockData(r);OF(n,r,!s.nowrap);return}if(i==="copy"){ob(n,r,{focusToEditor:!0}),Eh(n,r).then(()=>{const{onCodeCopyComplete:s}=n.getComponentOptions("code")||{};if(s){s();return}const l=o.getBoundingClientRect();QS(O.t("code.copySuccess"),{position:{x:l.x+l.width/2,y:l.bottom+30}})}).catch(s=>{Zs.error(s.message)});return}i==="caption"&&(CF(n,r),setTimeout(()=>{n.focus()}))}function R0(n,e,t,o){const r=w("button",["code-header-button"],null);if(r.setAttribute("data-id",e),o){const i=w("span",["button-icon"],r);i.innerHTML=o,t&&r.setAttribute(`data-editor-tooltip-${n.clientId}`,t)}else if(t){const i=w("span",["button-label"],r);i.innerHTML=t}return n.domEvents.addEventListener(r,"click",$F),r}function HF(n,e,t){const o=Bt(e),r=w("div",["code-block-header"],o),i=Cu[t.language]||Cu[Y8(t.language.toLocaleLowerCase())]||Cu.plain;r.appendChild(FF(n,e,i.name)),r.appendChild(NF()),r.appendChild(R0(n,"wrap",O.t("code.wrap"),MF));const s=r.appendChild(R0(n,"copy",O.t("code.copy"),LF));M0()||(W(s,"disabled"),s.setAttribute("data-editor-tooltip-maxwidth","800"),s.setAttribute(`data-editor-tooltip-${n.clientId}`,O.t("copyCutProperty.unsafeEnvTips",{shortCut:ko("CtrlOrCmd+C"),operation:O.t("copyCutProperty.copy")}))),r.appendChild(R0(n,"caption",O.t("code.caption"),null))}function jF(n,e){!e.target||setTimeout(()=>{n.selection.caret.update()})}function UF(n,e,t,o){S0.init(n);const r=o.children,i=Is(t,"div");i.setAttribute("data-language",o.language||"text"),Q8(n,t,o);const s=w("div",["editor-code-root"],i),l=w("div",["code-text-root"],s),a=n.createChildContainer(e,l,r[0]);if(r.length===2){const d=w("div",["code-caption-root"],s);n.createChildContainer(e,d,r[1])}return n.domEvents.addEventListener(a,"scroll",jF),HF(n,t,o),i}async function zF(n){const e={id:K(),type:"text",text:[]},t=K();n.doc.localInsertChildContainer(t,[e]);const o=await J8(n);return{blockData:{id:K(),type:"code",language:o,children:[t]},focusBlockId:e.id}}const mr=S("code-block");function VF(n,e,t,o,r){yF(n),wF(n),m(mr,r.type==="code","invalid block data type");const i=r;return m(mr,i.children,"invalid block data children"),m(mr,i.children.length===1||i.children.length===2,"invalid block data children length"),UF(n,e,o,i)}function WF(n){return 1}function qF(n,e,t,o){const r=document.elementsFromPoint(t,o)[0];if(!r||!e.contains(r)||!n.contains(e)||!Or(r))return null;const i=Af(e);if(!Or(r))return null;const s=r;if(i.indexOf(s)===-1||Bo(s)>1)return null;const l=ht(e,ae(s));return new or(n,{anchor:l,focus:l})}function GF(n,e,t,o){return null}function ZF(n,e){return n.getBoundingClientRect()}function QF(n,e,t,o){if(t.isSimple()){m(mr,o.isSimple(),"from is simple position but to is not simple position"),mr.debug("full select list"),W(e,"full-selected");return}m(mr,!o.isSimple(),"from is complex position but end is simple position");const r=t,i=o;m(mr,r.blockId===i.blockId,"only allow update one table selection"),Af(e).forEach(l=>{const a=ae(l);(a===r.childContainerId||a===i.childContainerId)&&W(l,"selected")})}function YF(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="code"]').forEach(e=>{te(e,"full-selected"),e.querySelectorAll("div[data-type=editor-container].child.selected").forEach(t=>{te(t,"selected")})})}function JF(n,e){return Af(e)}function KF(n,e,t,o,r){if(o==="ArrowDown"||o==="ArrowRight"){if(t===pc(e))return Cc(e)}else if(t===Cc(e))return pc(e);return null}function XF(n,e,t,o){const r=Af(e),i=r.map(ae),s=i.indexOf(t.childContainerId),l=i.indexOf(o.childContainerId);m(mr,s!==-1,"invalid start pos"),m(mr,l!==-1,"invalid end pos");const a=[r[s]];return s!==l&&a.push(r[l]),a}function eN(n,e,t){m(mr,Yi(e),"invalid block type"),Q8(n,e,t)}async function tN(n,e){const t=await zF(n);if(!t)return null;const{blockData:o,focusBlockId:r}=t;return n.insertBlock(e.containerId,e.blockIndex,o,bt(n,r,0))}function nN(n){return{name:"CodeBlock",insertBlockCommandItems:[{id:"insert-code",name:O.t("code.title"),icon:xL,order:300,group:"common",subText:pn("insert-code")}],handleInsertEmptyBlock:tN}}function oN(){return{abstract:`${O.t("code.abstract")}`}}function rN(n,e,t,o){const r=e,i=a=>{const d=[];return t.blocks[a].forEach(p=>{var A;d.push(rt((A=p.text)!=null?A:[]))}),d.join(`
|
|
403
|
+
`;function RF(n,e,t){const r={...n.getBlockData(e),language:t};n.updateBlockData(e,r),En(n,e).forEach(s=>{At(s).forEach(l=>{n.reloadBlock(l)})})}function OF(n,e,t){const r={...n.getBlockData(e),nowrap:t};n.updateBlockData(e,r)}const Zs=S("code-block-header"),_F=Object.entries(Cu).map(([n,e])=>({id:n,name:e.name,language:e}));function ob(n,e,t){m(Zs,Yi(e),"not a code block");const o=St(pc(e));n.selection.selectBlock(o,0),t.focusToEditor&&n.focus()}function PF(n,e){if(e){const t=n,{editor:o,codeBlock:r}=t.custom;RF(o,r,e.id);const i=r.querySelector(".code-block-header .language-select .name-label");i.innerText=e.name,mF(o,e.id),o.focus()}}function FF(n,e,t){n.addCustom("code-header-language-select-dropdown",i=>{const s=new ZS(_F,i.rootElement,{placeholder:O.t("code.search")});return s.onSelected=PF,s});const o=w("div",["language-select"],null);w("span",["name-label"],o,t);const r=w("span",["arrow-icon"],o);return r.innerHTML=SF,n.domEvents.addEventListener(o,"click",(i,s)=>{if(i.readonly)return;const a=s.target.closest(".language-select"),d=re(a);m(Zs,d,"no parent block"),m(Zs,Se(d)==="code","not a code block");const f=i.getBlockData(d),p=i.getCustom("code-header-language-select-dropdown");p.custom={codeBlock:d,editor:i},p.setSelectedId(f.language),p.show(a),ob(i,d,{focusToEditor:!1}),W(e,"editing-language"),p.onHide=()=>{te(e,"editing-language")}}),o}function NF(){return w("div",["code-header-spacer"],null)}function $F(n,e){const t=e.target,o=t.closest(".code-header-button");m(Zs,o,"no button");const r=re(t);m(Zs,r,"no parent block");const i=o.getAttribute("data-id");if(m(Zs,Se(r)==="code","not a code block"),i==="wrap"){const s=n.getBlockData(r);OF(n,r,!s.nowrap);return}if(i==="copy"){ob(n,r,{focusToEditor:!0}),Eh(n,r).then(()=>{const{onCodeCopyComplete:s}=n.getComponentOptions("code")||{};if(s){s();return}const l=o.getBoundingClientRect();QS(O.t("code.copySuccess"),{position:{x:l.x+l.width/2,y:l.bottom+30}})}).catch(s=>{Zs.error(s.message)});return}i==="caption"&&(CF(n,r),setTimeout(()=>{n.focus()}))}function R0(n,e,t,o){const r=w("button",["code-header-button"],null);if(r.setAttribute("data-id",e),o){const i=w("span",["button-icon"],r);i.innerHTML=o,t&&r.setAttribute(`data-editor-tooltip-${n.clientId}`,t)}else if(t){const i=w("span",["button-label"],r);i.innerHTML=t}return n.domEvents.addEventListener(r,"click",$F),r}function HF(n,e,t){const o=Bt(e),r=w("div",["code-block-header"],o),i=Cu[t.language]||Cu[Y8(t.language.toLocaleLowerCase())]||Cu.plain;r.appendChild(FF(n,e,i.name)),r.appendChild(NF()),r.appendChild(R0(n,"wrap",O.t("code.wrap"),MF));const s=r.appendChild(R0(n,"copy",O.t("code.copy"),LF));M0()||(W(s,"disabled"),s.setAttribute("data-editor-tooltip-maxwidth","800"),s.setAttribute(`data-editor-tooltip-${n.clientId}`,O.t("copyCutProperty.unsafeEnvTips",{shortCut:ko("CtrlOrCmd+C"),operation:O.t("copyCutProperty.copy")}))),r.appendChild(R0(n,"caption",O.t("code.caption"),null))}function jF(n,e){!e.target||setTimeout(()=>{n.selection.caret.update()})}function UF(n,e,t,o){S0.init(n);const r=o.children,i=Is(t,"div");i.setAttribute("data-language",o.language||"text"),Q8(n,t,o);const s=w("div",["editor-code-root"],i),l=w("div",["code-text-root"],s),a=n.createChildContainer(e,l,r[0]);if(r.length===2){const d=w("div",["code-caption-root"],s);n.createChildContainer(e,d,r[1])}return n.domEvents.addEventListener(a,"scroll",jF),HF(n,t,o),i}async function zF(n){const e={id:K(),type:"text",text:[]},t=K();n.doc.localInsertChildContainer(t,[e]);const o=await J8(n);return{blockData:{id:K(),type:"code",language:o,children:[t]},focusBlockId:e.id}}const mr=S("code-block");function VF(n,e,t,o,r){yF(n),wF(n),m(mr,r.type==="code","invalid block data type");const i=r;return m(mr,i.children,"invalid block data children"),m(mr,i.children.length===1||i.children.length===2,"invalid block data children length"),UF(n,e,o,i)}function WF(n){return 1}function qF(n,e,t,o){const r=document.elementsFromPoint(t,o)[0];if(!r||!e.contains(r)||!n.contains(e)||!Or(r))return null;const i=Af(e);if(!Or(r))return null;const s=r;if(i.indexOf(s)===-1||Bo(s)>1)return null;const l=ht(e,ae(s));return new or(n,{anchor:l,focus:l})}function GF(n,e,t,o){return null}function ZF(n,e){return n.getBoundingClientRect()}function QF(n,e,t,o){if(t.isSimple()){m(mr,o.isSimple(),"from is simple position but to is not simple position"),mr.debug("full select list"),W(e,"full-selected");return}m(mr,!o.isSimple(),"from is complex position but end is simple position");const r=t,i=o;m(mr,r.blockId===i.blockId,"only allow update one table selection"),Af(e).forEach(l=>{const a=ae(l);(a===r.childContainerId||a===i.childContainerId)&&W(l,"selected")})}function YF(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="code"]').forEach(e=>{te(e,"full-selected"),e.querySelectorAll("div[data-type=editor-container].child.selected").forEach(t=>{te(t,"selected")})})}function JF(n,e){return Af(e)}function KF(n,e,t,o,r){if(o==="ArrowDown"||o==="ArrowRight"){if(t===pc(e))return Cc(e)}else if(t===Cc(e))return pc(e);return null}function XF(n,e,t,o){const r=Af(e),i=r.map(ae),s=i.indexOf(t.childContainerId),l=i.indexOf(o.childContainerId);m(mr,s!==-1,"invalid start pos"),m(mr,l!==-1,"invalid end pos");const a=[r[s]];return s!==l&&a.push(r[l]),a}function eN(n,e,t){m(mr,Yi(e),"invalid block type"),Q8(n,e,t)}async function tN(n,e){const t=await zF(n);if(!t)return null;const{blockData:o,focusBlockId:r}=t;return n.focus(),n.insertBlock(e.containerId,e.blockIndex,o,bt(n,r,0))}function nN(n){return{name:"CodeBlock",insertBlockCommandItems:[{id:"insert-code",name:O.t("code.title"),icon:xL,order:300,group:"common",subText:pn("insert-code")}],handleInsertEmptyBlock:tN}}function oN(){return{abstract:`${O.t("code.abstract")}`}}function rN(n,e,t,o){const r=e,i=a=>{const d=[];return t.blocks[a].forEach(p=>{var A;d.push(rt((A=p.text)!=null?A:[]))}),d.join(`
|
|
404
404
|
`)},s=i(r.children[0]),l=r.children[1]?i(r.children[1]):"";return o==="text"?`${s}
|
|
405
405
|
${l}`:o==="markdown"?`\`\`\`${r.language}
|
|
406
406
|
${s}
|