@editora/plugins 1.0.19 → 1.0.21

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.
Files changed (45) hide show
  1. package/dist/{CodePlugin.native-Bwf25lLX.js → CodePlugin.native-CKJo7IFG.js} +8 -8
  2. package/dist/{CodePlugin.native-Cpp4u3Jl.mjs → CodePlugin.native-D8gGxB8i.mjs} +59 -60
  3. package/dist/a11y-checker.cjs.js +1 -1
  4. package/dist/a11y-checker.esm.js +18 -18
  5. package/dist/anchor.cjs.js +6 -6
  6. package/dist/anchor.esm.js +57 -57
  7. package/dist/blockquote.cjs.js +1 -1
  8. package/dist/blockquote.esm.js +31 -31
  9. package/dist/capitalization.cjs.js +1 -1
  10. package/dist/capitalization.esm.js +25 -25
  11. package/dist/checklist.cjs.js +1 -1
  12. package/dist/checklist.esm.js +30 -30
  13. package/dist/code.cjs.js +1 -1
  14. package/dist/code.esm.js +1 -1
  15. package/dist/collaboration.cjs.js +8 -8
  16. package/dist/collaboration.esm.js +1279 -1169
  17. package/dist/comments.cjs.js +1 -1
  18. package/dist/comments.esm.js +1 -1
  19. package/dist/direction.cjs.js +1 -1
  20. package/dist/direction.esm.js +26 -26
  21. package/dist/document-manager.cjs.js +1 -1
  22. package/dist/document-manager.esm.js +1 -1
  23. package/dist/{documentManager-yjRBab4v.mjs → documentManager-BL98a7YZ.mjs} +402 -404
  24. package/dist/{documentManager-BDz6tovy.js → documentManager-r8t7yZEd.js} +9 -9
  25. package/dist/enterprise.cjs.js +1 -1
  26. package/dist/enterprise.esm.js +1 -1
  27. package/dist/font-family.cjs.js +1 -1
  28. package/dist/font-family.esm.js +26 -26
  29. package/dist/{index-Bm1eqYHh.mjs → index-B-VitI3v.mjs} +23 -22
  30. package/dist/{index-CoflqYuK.js → index-D5xugkYA.js} +2 -2
  31. package/dist/index.cjs.js +1 -1
  32. package/dist/index.esm.js +2 -2
  33. package/dist/preview.cjs.js +3 -3
  34. package/dist/preview.esm.js +48 -51
  35. package/dist/purify.es-B6PsRpEV.js +3 -0
  36. package/dist/purify.es-DmCsrgBd.mjs +1480 -0
  37. package/dist/sanitizeHtml-CDoBlNTk.js +1 -0
  38. package/dist/sanitizeHtml-CtLy8um-.mjs +16 -0
  39. package/dist/spell-check.cjs.js +2 -2
  40. package/dist/spell-check.esm.js +19 -19
  41. package/dist/table.cjs.js +14 -14
  42. package/dist/table.esm.js +158 -150
  43. package/dist/template.cjs.js +20 -21
  44. package/dist/template.esm.js +176 -724
  45. package/package.json +6 -4
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M="__editoraCommandEditorRoot",R=e=>{if(!e)return null;const t=e.querySelector('[contenteditable="true"]');return t instanceof HTMLElement?t:null},H=()=>{if(typeof window>"u")return null;const e=window[M];if(!(e instanceof HTMLElement))return null;window[M]=null;const t=e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?e:null);if(t){const n=R(t);if(n)return n;if(t.getAttribute("contenteditable")==="true")return t}if(e.getAttribute("contenteditable")==="true")return e;const r=e.closest('[contenteditable="true"]');return r instanceof HTMLElement?r:null},_=()=>{const e=H();if(e&&document.contains(e))return e;const t=window.getSelection();if(t&&t.rangeCount>0){let n=t.getRangeAt(0).startContainer;for(;n&&n!==document.body;){if(n.nodeType===Node.ELEMENT_NODE){const o=n;if(o.getAttribute("contenteditable")==="true")return o}n=n.parentNode}}const r=document.activeElement;if(r){if(r.getAttribute("contenteditable")==="true")return r;const n=r.closest('[contenteditable="true"]');if(n)return n}return document.querySelector('[contenteditable="true"]')},A=e=>e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null,O=e=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return e.contains(r.commonAncestorContainer)?r:null},y=e=>{e.dispatchEvent(new Event("input",{bubbles:!0}))},L=(e,t)=>{if(t===e.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",e,t,e.innerHTML)}catch{}},C=(e,t)=>{if(!e.isConnected){t.focus({preventScroll:!0});return}const r=window.getSelection();if(!r)return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),r.removeAllRanges();try{r.addRange(n)}catch{t.focus({preventScroll:!0});return}t.focus({preventScroll:!0})},b=e=>{let t=e.querySelector(":scope > p");if(!t){t=document.createElement("p");const r=[];e.childNodes.forEach(n=>{n.nodeType===Node.ELEMENT_NODE&&["UL","OL"].includes(n.tagName)||r.push(n)}),r.forEach(n=>t.appendChild(n)),e.insertBefore(t,e.firstChild)}return t.innerHTML.trim()||(t.innerHTML="<br>"),t},I=e=>(e.textContent||"").replace(/\u200B/g,"").trim()?!1:!e.querySelector("img, video, table, iframe, hr, pre, ul, ol"),v=()=>{const e=document.createElement("p");return e.innerHTML="<br>",e},S=(e,t)=>{if(!e.isConnected){t.focus({preventScroll:!0});return}const r=window.getSelection();if(!r)return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!0),r.removeAllRanges();try{r.addRange(n)}catch{t.focus({preventScroll:!0});return}t.focus({preventScroll:!0})},P=(e,t)=>{e.appendChild(t),e.innerHTML.trim()||(e.innerHTML="<br>")},D=(e,t,r)=>{const n=v();t.parentNode?.insertBefore(n,t.nextSibling),r.remove(),T(t).length===0&&t.remove(),S(n,e)},x=(e,t,r)=>{const n=b(t),o=r.cloneRange();o.deleteContents();const a=document.createRange();a.setStart(o.startContainer,o.startOffset),a.setEndAfter(n.lastChild||n);const s=document.createDocumentFragment();try{s.appendChild(a.extractContents())}catch{}n.innerHTML.trim()||(n.innerHTML="<br>");const c=document.createElement("li");c.setAttribute("data-type","checklist-item"),c.setAttribute("data-checked","false");const u=document.createElement("p");P(u,s),c.appendChild(u),t.parentNode?.insertBefore(c,t.nextSibling),S(u,e)},k=e=>{const t=document.createElement("li");t.setAttribute("data-type","checklist-item"),t.setAttribute("data-checked","false");const r=document.createElement("p");return r.innerHTML=e.trim()||"<br>",t.appendChild(r),t},T=e=>Array.from(e.children).filter(t=>t instanceof HTMLLIElement),B=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","LI"]),N=e=>B.has(e.tagName)&&e.getAttribute("contenteditable")!=="true",F=(e,t)=>{const r=[],n=new Set,o=i=>{!i||n.has(i)||t.contains(i)&&N(i)&&(i.closest("ul, ol")||(n.add(i),r.push(i)))},a=i=>{let d=i;for(;d&&d!==document.body;){if(d.nodeType===Node.ELEMENT_NODE){const p=d;if(N(p))return p;if(p.getAttribute("contenteditable")==="true")break}d=d.parentNode}return null};if(e.collapsed)return o(a(e.startContainer)),r;const s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const d=i;if(!N(d)||d.closest("ul, ol"))return NodeFilter.FILTER_SKIP;if(typeof e.intersectsNode=="function")return e.intersectsNode(d)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP;const p=document.createRange();return p.selectNodeContents(d),e.compareBoundaryPoints(Range.END_TO_START,p)>0&&e.compareBoundaryPoints(Range.START_TO_END,p)<0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let c=s.nextNode();for(;c;)o(c),c=s.nextNode();if(r.length===0&&o(a(e.commonAncestorContainer)),r.length<=1)return r;const u=r.filter(i=>!r.some(d=>d!==i&&i.contains(d)));return u.length>0?u:r},K=new Set(["P","DIV","UL","OL","LI","BLOCKQUOTE","H1","H2","H3","H4","H5","H6","TABLE","PRE","FIGURE","SECTION","ARTICLE","HEADER","FOOTER","HR"]),z=(e,t)=>{const r=t.startContainer,n=t.startOffset,o=t.endContainer,a=t.endOffset;let s=null,c=!1;if(Array.from(e.childNodes).forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE&&K.has(i.tagName)){s=null;return}i.nodeType===Node.TEXT_NODE&&!(i.textContent||"").trim()||i.nodeType!==Node.TEXT_NODE&&i.nodeType!==Node.ELEMENT_NODE||(s||(s=document.createElement("p"),e.insertBefore(s,i)),s.appendChild(i),c=!0)}),!c)return;try{r===e?t.setStart(e,0):r.isConnected&&t.setStart(r,n),o===e?t.setEnd(e,e.childNodes.length):o.isConnected&&t.setEnd(o,a)}catch{}const u=window.getSelection();u&&(u.removeAllRanges(),u.addRange(t))},q=e=>{const t=[],r=document.createElement("div"),n=()=>{const o=r.innerHTML.trim();if(!o)return;const a=document.createElement("p");a.innerHTML=o,t.push(a),r.innerHTML=""};if(e.childNodes.forEach(o=>{if(o.nodeType===Node.ELEMENT_NODE&&["UL","OL"].includes(o.tagName)){n();return}if(o.nodeType===Node.ELEMENT_NODE&&o.tagName==="P"){n();const a=o.innerHTML.trim(),s=document.createElement("p");s.innerHTML=a||"<br>",t.push(s);return}o.nodeType===Node.TEXT_NODE&&!(o.textContent||"").trim()||r.appendChild(o.cloneNode(!0))}),n(),t.length===0){const o=document.createElement("p");o.innerHTML="<br>",t.push(o)}return t},V=()=>({name:"checklist",init:()=>{if(!(typeof document>"u"||typeof window>"u")){if(!window.__checklistPluginClickInitialized){window.__checklistPluginClickInitialized=!0;const e=t=>{const n=t.target.closest('li[data-type="checklist-item"]');if(!n)return;const o=n.getBoundingClientRect();if(!(t.clientX-o.left<32))return;t.preventDefault(),t.stopPropagation();const c=n.closest("[contenteditable], .rte-content, .editora-content");if(c?.getAttribute("contenteditable")==="false"||!!c?.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]'))return;const i=c?.innerHTML||"",d=n.getAttribute("data-checked")==="true";n.setAttribute("data-checked",(!d).toString()),c&&(L(c,i),y(c))};document.addEventListener("click",e)}if(!window.__checklistPluginKeydownInitialized){window.__checklistPluginKeydownInitialized=!0;const e=t=>{if(t.key!=="Enter"||t.shiftKey||t.altKey||t.ctrlKey||t.metaKey||t.defaultPrevented)return;const r=window.getSelection();if(!r||r.rangeCount===0)return;const n=r.getRangeAt(0),a=A(n.startContainer)?.closest('li[data-type="checklist-item"]');if(!a)return;const s=a.closest('ul[data-type="checklist"]');if(!s)return;const c=a.closest("[contenteditable], .rte-content, .editora-content");if(!c||c.getAttribute("contenteditable")==="false"||!!c.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]'))return;t.preventDefault();const i=c.innerHTML,d=b(a);I(d)?D(c,s,a):x(c,a,n),L(c,i),y(c)};document.addEventListener("keydown",e)}}},nodes:{checklist:{content:"checklistItem+",group:"block",parseDOM:[{tag:'ul[data-type="checklist"]'}],toDOM:()=>["ul",{"data-type":"checklist"},0]},checklistItem:{content:"paragraph",attrs:{checked:{default:!1}},parseDOM:[{tag:'li[data-type="checklist-item"]',getAttrs:e=>({checked:e.getAttribute("data-checked")==="true"})}],toDOM:e=>["li",{"data-type":"checklist-item","data-checked":e?.attrs?.checked?"true":"false"},0]}},toolbar:[{label:"Checklist",command:"toggleChecklist",icon:'<svg width="24px" height="24px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 4.48h-.71L2 3.43l.71-.7.69.68L4.81 2l.71.71-1.77 1.77zM6.99 3h8v1h-8V3zm0 3h8v1h-8V6zm8 3h-8v1h8V9zm-8 3h8v1h-8v-1zM3.04 7.48h.71l1.77-1.77-.71-.7L3.4 6.42l-.69-.69-.71.71 1.04 1.04zm.71 3.01h-.71L2 9.45l.71-.71.69.69 1.41-1.42.71.71-1.77 1.77zm-.71 3.01h.71l1.77-1.77-.71-.71-1.41 1.42-.69-.69-.71.7 1.04 1.05z"></path></g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleChecklist:()=>{try{const e=_();if(!e)return!1;const t=e.innerHTML,r=()=>(L(e,t),y(e),!0),n=O(e);if(!n)return!1;z(e,n);const o=A(n.startContainer);if(!o)return!1;const a=o.closest('ul[data-type="checklist"]');if(a&&e.contains(a)){const l=T(a);if(l.length===0)return!1;const h=document.createDocumentFragment();let f=null;return l.forEach((m,E)=>{const g=q(m);g.forEach(w=>{h.appendChild(w),!f&&(m.contains(n.startContainer)||E===0)&&(f=w)}),!f&&E===0&&g[0]&&(f=g[0])}),a.replaceWith(h),f&&C(f,e),r()}const s=o.closest("ul, ol");if(s&&e.contains(s)){let l;if(s.tagName.toLowerCase()==="ul")l=s;else{for(l=document.createElement("ul");s.firstChild;)l.appendChild(s.firstChild);s.replaceWith(l)}l.setAttribute("data-type","checklist");let h=T(l);h.length===0&&(l.appendChild(k("")),h=T(l));let f=null;h.forEach(E=>{E.setAttribute("data-type","checklist-item"),E.hasAttribute("data-checked")||E.setAttribute("data-checked","false");const g=b(E);E.contains(n.startContainer)&&(f=g)});const m=l.querySelector(':scope > li[data-type="checklist-item"] > p');return C(f||m||l,e),r()}const c=F(n,e);if(c.length>1){const l=document.createElement("ul");l.setAttribute("data-type","checklist"),c.forEach(m=>{l.appendChild(k(m.innerHTML))}),c[0].replaceWith(l),c.slice(1).forEach(m=>{m.isConnected&&m.remove()});const f=l.querySelector(':scope > li[data-type="checklist-item"] > p');return f&&C(f,e),r()}const u=c[0]||o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");if(u&&u!==e){const l=document.createElement("ul");l.setAttribute("data-type","checklist");const h=k(u.innerHTML);l.appendChild(h),u.replaceWith(l);const f=h.querySelector(":scope > p");return f&&C(f,e),r()}const i=document.createElement("ul");i.setAttribute("data-type","checklist");const d=k("");i.appendChild(d),n.deleteContents(),n.insertNode(i);const p=d.querySelector(":scope > p");return p&&C(p,e),r()}catch(e){return console.error("Failed to toggle checklist:",e),!1}}},keymap:{"Mod-Shift-9":"toggleChecklist"}});exports.ChecklistPlugin=V;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M="__editoraCommandEditorRoot",S=e=>{if(!e)return null;const t=e.querySelector('[contenteditable="true"]');return t instanceof HTMLElement?t:null},R=()=>{if(typeof window>"u")return null;const e=window[M];if(!(e instanceof HTMLElement))return null;window[M]=null;const t=e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?e:null);if(t){const n=S(t);if(n)return n;if(t.getAttribute("contenteditable")==="true")return t}if(e.getAttribute("contenteditable")==="true")return e;const r=e.closest('[contenteditable="true"]');return r instanceof HTMLElement?r:null},O=()=>{const e=R();if(e&&document.contains(e))return e;const t=window.getSelection();if(t&&t.rangeCount>0){let n=t.getRangeAt(0).startContainer;for(;n&&n!==document.body;){if(n.nodeType===Node.ELEMENT_NODE){const o=n;if(o.getAttribute("contenteditable")==="true")return o}n=n.parentNode}}const r=document.activeElement;if(r){if(r.getAttribute("contenteditable")==="true")return r;const n=r.closest('[contenteditable="true"]');if(n)return n}return document.querySelector('[contenteditable="true"]')},A=e=>e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null,_=e=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return e.contains(r.commonAncestorContainer)?r:null},y=e=>{e.dispatchEvent(new Event("input",{bubbles:!0}))},L=(e,t)=>{if(t===e.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",e,t,e.innerHTML)}catch{}},C=(e,t)=>{if(!e.isConnected){t.focus({preventScroll:!0});return}const r=window.getSelection();if(!r)return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),r.removeAllRanges();try{r.addRange(n)}catch{t.focus({preventScroll:!0});return}t.focus({preventScroll:!0})},b=e=>{let t=e.querySelector(":scope > p");if(!t){t=document.createElement("p");const r=[];e.childNodes.forEach(n=>{n.nodeType===Node.ELEMENT_NODE&&["UL","OL"].includes(n.tagName)||r.push(n)}),r.forEach(n=>t.appendChild(n)),e.insertBefore(t,e.firstChild)}return t.innerHTML.trim()||(t.innerHTML="<br>"),t},I=e=>(e.textContent||"").replace(/\u200B/g,"").trim()?!1:!e.querySelector("img, video, table, iframe, hr, pre, ul, ol"),v=()=>{const e=document.createElement("p");return e.innerHTML="<br>",e},H=(e,t)=>{if(!e.isConnected){t.focus({preventScroll:!0});return}const r=window.getSelection();if(!r)return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!0),r.removeAllRanges();try{r.addRange(n)}catch{t.focus({preventScroll:!0});return}t.focus({preventScroll:!0})},P=(e,t)=>{e.appendChild(t),e.innerHTML.trim()||(e.innerHTML="<br>")},D=(e,t,r)=>{const n=v();t.parentNode?.insertBefore(n,t.nextSibling),r.remove(),T(t).length===0&&t.remove(),H(n,e)},x=(e,t,r)=>{const n=b(t),o=r.cloneRange();o.deleteContents();const a=document.createRange();a.setStart(o.startContainer,o.startOffset),a.setEndAfter(n.lastChild||n);const s=document.createDocumentFragment();try{s.appendChild(a.extractContents())}catch{}n.innerHTML.trim()||(n.innerHTML="<br>");const c=document.createElement("li");c.setAttribute("data-type","checklist-item"),c.setAttribute("data-checked","false");const u=document.createElement("p");P(u,s),c.appendChild(u),t.parentNode?.insertBefore(c,t.nextSibling),H(u,e)},k=e=>{const t=document.createElement("li");t.setAttribute("data-type","checklist-item"),t.setAttribute("data-checked","false");const r=document.createElement("p");return r.innerHTML=e.trim()||"<br>",t.appendChild(r),t},T=e=>Array.from(e.children).filter(t=>t instanceof HTMLLIElement),B=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","LI"]),N=e=>B.has(e.tagName)&&e.getAttribute("contenteditable")!=="true",F=(e,t)=>{const r=[],n=new Set,o=i=>{!i||n.has(i)||t.contains(i)&&N(i)&&(i.closest("ul, ol")||(n.add(i),r.push(i)))},a=i=>{let d=i;for(;d&&d!==document.body;){if(d.nodeType===Node.ELEMENT_NODE){const h=d;if(N(h))return h;if(h.getAttribute("contenteditable")==="true")break}d=d.parentNode}return null};if(e.collapsed)return o(a(e.startContainer)),r;const s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const d=i;if(!N(d)||d.closest("ul, ol"))return NodeFilter.FILTER_SKIP;if(typeof e.intersectsNode=="function")return e.intersectsNode(d)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP;const h=document.createRange();return h.selectNodeContents(d),e.compareBoundaryPoints(Range.END_TO_START,h)>0&&e.compareBoundaryPoints(Range.START_TO_END,h)<0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let c=s.nextNode();for(;c;)o(c),c=s.nextNode();if(r.length===0&&o(a(e.commonAncestorContainer)),r.length<=1)return r;const u=r.filter(i=>!r.some(d=>d!==i&&i.contains(d)));return u.length>0?u:r},K=new Set(["P","DIV","UL","OL","LI","BLOCKQUOTE","H1","H2","H3","H4","H5","H6","TABLE","PRE","FIGURE","SECTION","ARTICLE","HEADER","FOOTER","HR"]),z=(e,t)=>{const r=t.startContainer,n=t.startOffset,o=t.endContainer,a=t.endOffset;let s=null,c=!1;if(Array.from(e.childNodes).forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE&&K.has(i.tagName)){s=null;return}i.nodeType===Node.TEXT_NODE&&!(i.textContent||"").trim()||i.nodeType!==Node.TEXT_NODE&&i.nodeType!==Node.ELEMENT_NODE||(s||(s=document.createElement("p"),e.insertBefore(s,i)),s.appendChild(i),c=!0)}),!c)return;try{r===e?t.setStart(e,0):r.isConnected&&t.setStart(r,n),o===e?t.setEnd(e,e.childNodes.length):o.isConnected&&t.setEnd(o,a)}catch{}const u=window.getSelection();u&&(u.removeAllRanges(),u.addRange(t))},q=e=>{const t=[],r=document.createElement("div"),n=()=>{const o=r.innerHTML.trim();if(!o)return;const a=document.createElement("p");a.innerHTML=o,t.push(a),r.innerHTML=""};if(e.childNodes.forEach(o=>{if(o.nodeType===Node.ELEMENT_NODE&&["UL","OL"].includes(o.tagName)){n();return}if(o.nodeType===Node.ELEMENT_NODE&&o.tagName==="P"){n();const a=o.innerHTML.trim(),s=document.createElement("p");s.innerHTML=a||"<br>",t.push(s);return}o.nodeType===Node.TEXT_NODE&&!(o.textContent||"").trim()||r.appendChild(o.cloneNode(!0))}),n(),t.length===0){const o=document.createElement("p");o.innerHTML="<br>",t.push(o)}return t},X=()=>({name:"checklist",init:()=>{if(!(typeof document>"u"||typeof window>"u")){if(!window.__checklistPluginClickInitialized){window.__checklistPluginClickInitialized=!0;const e=t=>{const n=t.target.closest('li[data-type="checklist-item"]');if(!n)return;const o=n.getBoundingClientRect();if(!(t.clientX-o.left<32))return;t.preventDefault(),t.stopPropagation();const c=n.closest("[contenteditable], .rte-content, .editora-content");if(c?.getAttribute("contenteditable")==="false"||!!c?.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]'))return;const i=c?.innerHTML||"",d=n.getAttribute("data-checked")==="true";n.setAttribute("data-checked",(!d).toString()),c&&(L(c,i),y(c))};document.addEventListener("click",e)}if(!window.__checklistPluginKeydownInitialized){window.__checklistPluginKeydownInitialized=!0;const e=t=>{if(t.key!=="Enter"||t.shiftKey||t.altKey||t.ctrlKey||t.metaKey||t.defaultPrevented)return;const r=window.getSelection();if(!r||r.rangeCount===0)return;const n=r.getRangeAt(0),a=A(n.startContainer)?.closest('li[data-type="checklist-item"]');if(!a)return;const s=a.closest('ul[data-type="checklist"]');if(!s)return;const c=a.closest("[contenteditable], .rte-content, .editora-content");if(!c||c.getAttribute("contenteditable")==="false"||!!c.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]'))return;t.preventDefault();const i=c.innerHTML,d=b(a);I(d)?D(c,s,a):x(c,a,n),L(c,i),y(c)};document.addEventListener("keydown",e)}}},nodes:{checklist:{content:"checklistItem+",group:"block",parseDOM:[{tag:'ul[data-type="checklist"]'}],toDOM:()=>["ul",{"data-type":"checklist"},0]},checklistItem:{content:"paragraph",attrs:{checked:{default:!1}},parseDOM:[{tag:'li[data-type="checklist-item"]',getAttrs:e=>({checked:e.getAttribute("data-checked")==="true"})}],toDOM:e=>["li",{"data-type":"checklist-item","data-checked":e?.attrs?.checked?"true":"false"},0]}},toolbar:[{label:"Checklist",command:"toggleChecklist",icon:'<svg width="24px" height="24px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 4.48h-.71L2 3.43l.71-.7.69.68L4.81 2l.71.71-1.77 1.77zM6.99 3h8v1h-8V3zm0 3h8v1h-8V6zm8 3h-8v1h8V9zm-8 3h8v1h-8v-1zM3.04 7.48h.71l1.77-1.77-.71-.7L3.4 6.42l-.69-.69-.71.71 1.04 1.04zm.71 3.01h-.71L2 9.45l.71-.71.69.69 1.41-1.42.71.71-1.77 1.77zm-.71 3.01h.71l1.77-1.77-.71-.71-1.41 1.42-.69-.69-.71.7 1.04 1.05z"></path></g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleChecklist:()=>{try{const e=O();if(!e)return!1;const t=e.innerHTML,r=()=>(L(e,t),y(e),!0),n=_(e);if(!n)return!1;z(e,n);const o=A(n.startContainer);if(!o)return!1;const a=o.closest('ul[data-type="checklist"]');if(a&&e.contains(a)){const l=T(a);if(l.length===0)return!1;const p=document.createDocumentFragment();let f=null;return l.forEach((m,E)=>{const g=q(m);g.forEach(w=>{p.appendChild(w),!f&&(m.contains(n.startContainer)||E===0)&&(f=w)}),!f&&E===0&&g[0]&&(f=g[0])}),a.replaceWith(p),f&&C(f,e),r()}const s=o.closest("ul, ol");if(s&&e.contains(s)){let l;if(s.tagName.toLowerCase()==="ul")l=s;else{for(l=document.createElement("ul");s.firstChild;)l.appendChild(s.firstChild);s.replaceWith(l)}l.setAttribute("data-type","checklist");let p=T(l);p.length===0&&(l.appendChild(k("")),p=T(l));let f=null;p.forEach(E=>{E.setAttribute("data-type","checklist-item"),E.hasAttribute("data-checked")||E.setAttribute("data-checked","false");const g=b(E);E.contains(n.startContainer)&&(f=g)});const m=l.querySelector(':scope > li[data-type="checklist-item"] > p');return C(f||m||l,e),r()}const c=F(n,e);if(c.length>1){const l=document.createElement("ul");l.setAttribute("data-type","checklist"),c.forEach(m=>{l.appendChild(k(m.innerHTML))}),c[0].replaceWith(l),c.slice(1).forEach(m=>{m.isConnected&&m.remove()});const f=l.querySelector(':scope > li[data-type="checklist-item"] > p');return f&&C(f,e),r()}const u=c[0]||o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");if(u&&u!==e){const l=document.createElement("ul");l.setAttribute("data-type","checklist");const p=k(u.innerHTML);l.appendChild(p),u.replaceWith(l);const f=p.querySelector(":scope > p");return f&&C(f,e),r()}const i=document.createElement("ul");i.setAttribute("data-type","checklist");const d=k("");i.appendChild(d),n.deleteContents(),n.insertNode(i);const h=d.querySelector(":scope > p");return h&&C(h,e),r()}catch(e){return console.error("Failed to toggle checklist:",e),!1}}},keymap:{"Mod-Shift-9":"toggleChecklist"}});exports.ChecklistPlugin=X;
@@ -1,15 +1,15 @@
1
- const A = "__editoraCommandEditorRoot", S = (e) => {
1
+ const A = "__editoraCommandEditorRoot", R = (e) => {
2
2
  if (!e) return null;
3
3
  const t = e.querySelector('[contenteditable="true"]');
4
4
  return t instanceof HTMLElement ? t : null;
5
- }, H = () => {
5
+ }, S = () => {
6
6
  if (typeof window > "u") return null;
7
7
  const e = window[A];
8
8
  if (!(e instanceof HTMLElement)) return null;
9
9
  window[A] = null;
10
10
  const t = e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? e : null);
11
11
  if (t) {
12
- const n = S(t);
12
+ const n = R(t);
13
13
  if (n) return n;
14
14
  if (t.getAttribute("contenteditable") === "true") return t;
15
15
  }
@@ -17,8 +17,8 @@ const A = "__editoraCommandEditorRoot", S = (e) => {
17
17
  return e;
18
18
  const r = e.closest('[contenteditable="true"]');
19
19
  return r instanceof HTMLElement ? r : null;
20
- }, _ = () => {
21
- const e = H();
20
+ }, O = () => {
21
+ const e = S();
22
22
  if (e && document.contains(e))
23
23
  return e;
24
24
  const t = window.getSelection();
@@ -41,7 +41,7 @@ const A = "__editoraCommandEditorRoot", S = (e) => {
41
41
  if (n) return n;
42
42
  }
43
43
  return document.querySelector('[contenteditable="true"]');
44
- }, M = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, O = (e) => {
44
+ }, M = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, _ = (e) => {
45
45
  const t = window.getSelection();
46
46
  if (!t || t.rangeCount === 0) return null;
47
47
  const r = t.getRangeAt(0);
@@ -85,7 +85,7 @@ const A = "__editoraCommandEditorRoot", S = (e) => {
85
85
  }, I = (e) => (e.textContent || "").replace(/\u200B/g, "").trim() ? !1 : !e.querySelector("img, video, table, iframe, hr, pre, ul, ol"), v = () => {
86
86
  const e = document.createElement("p");
87
87
  return e.innerHTML = "<br>", e;
88
- }, R = (e, t) => {
88
+ }, H = (e, t) => {
89
89
  if (!e.isConnected) {
90
90
  t.focus({ preventScroll: !0 });
91
91
  return;
@@ -105,7 +105,7 @@ const A = "__editoraCommandEditorRoot", S = (e) => {
105
105
  e.appendChild(t), e.innerHTML.trim() || (e.innerHTML = "<br>");
106
106
  }, x = (e, t, r) => {
107
107
  const n = v();
108
- t.parentNode?.insertBefore(n, t.nextSibling), r.remove(), T(t).length === 0 && t.remove(), R(n, e);
108
+ t.parentNode?.insertBefore(n, t.nextSibling), r.remove(), T(t).length === 0 && t.remove(), H(n, e);
109
109
  }, P = (e, t, r) => {
110
110
  const n = b(t), o = r.cloneRange();
111
111
  o.deleteContents();
@@ -120,7 +120,7 @@ const A = "__editoraCommandEditorRoot", S = (e) => {
120
120
  const c = document.createElement("li");
121
121
  c.setAttribute("data-type", "checklist-item"), c.setAttribute("data-checked", "false");
122
122
  const u = document.createElement("p");
123
- D(u, s), c.appendChild(u), t.parentNode?.insertBefore(c, t.nextSibling), R(u, e);
123
+ D(u, s), c.appendChild(u), t.parentNode?.insertBefore(c, t.nextSibling), H(u, e);
124
124
  }, k = (e) => {
125
125
  const t = document.createElement("li");
126
126
  t.setAttribute("data-type", "checklist-item"), t.setAttribute("data-checked", "false");
@@ -147,9 +147,9 @@ const A = "__editoraCommandEditorRoot", S = (e) => {
147
147
  let d = i;
148
148
  for (; d && d !== document.body; ) {
149
149
  if (d.nodeType === Node.ELEMENT_NODE) {
150
- const p = d;
151
- if (N(p)) return p;
152
- if (p.getAttribute("contenteditable") === "true") break;
150
+ const h = d;
151
+ if (N(h)) return h;
152
+ if (h.getAttribute("contenteditable") === "true") break;
153
153
  }
154
154
  d = d.parentNode;
155
155
  }
@@ -166,8 +166,8 @@ const A = "__editoraCommandEditorRoot", S = (e) => {
166
166
  if (!N(d) || d.closest("ul, ol")) return NodeFilter.FILTER_SKIP;
167
167
  if (typeof e.intersectsNode == "function")
168
168
  return e.intersectsNode(d) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
169
- const p = document.createRange();
170
- return p.selectNodeContents(d), e.compareBoundaryPoints(Range.END_TO_START, p) > 0 && e.compareBoundaryPoints(Range.START_TO_END, p) < 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
169
+ const h = document.createRange();
170
+ return h.selectNodeContents(d), e.compareBoundaryPoints(Range.END_TO_START, h) > 0 && e.compareBoundaryPoints(Range.START_TO_END, h) < 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
171
171
  }
172
172
  }
173
173
  );
@@ -239,7 +239,7 @@ const A = "__editoraCommandEditorRoot", S = (e) => {
239
239
  o.innerHTML = "<br>", t.push(o);
240
240
  }
241
241
  return t;
242
- }, V = () => ({
242
+ }, X = () => ({
243
243
  name: "checklist",
244
244
  // Initialize click handler when plugin is loaded
245
245
  init: () => {
@@ -314,16 +314,16 @@ const A = "__editoraCommandEditorRoot", S = (e) => {
314
314
  {
315
315
  label: "Checklist",
316
316
  command: "toggleChecklist",
317
- icon: '<svg width="24px" height="24px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 4.48h-.71L2 3.43l.71-.7.69.68L4.81 2l.71.71-1.77 1.77zM6.99 3h8v1h-8V3zm0 3h8v1h-8V6zm8 3h-8v1h8V9zm-8 3h8v1h-8v-1zM3.04 7.48h.71l1.77-1.77-.71-.7L3.4 6.42l-.69-.69-.71.71 1.04 1.04zm.71 3.01h-.71L2 9.45l.71-.71.69.69 1.41-1.42.71.71-1.77 1.77zm-.71 3.01h.71l1.77-1.77-.71-.71-1.41 1.42-.69-.69-.71.7 1.04 1.05z"></path></g></svg>',
317
+ icon: '<svg width="24px" height="24px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g stroke-width="0"></g><g stroke-linecap="round" stroke-linejoin="round"></g><g><path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 4.48h-.71L2 3.43l.71-.7.69.68L4.81 2l.71.71-1.77 1.77zM6.99 3h8v1h-8V3zm0 3h8v1h-8V6zm8 3h-8v1h8V9zm-8 3h8v1h-8v-1zM3.04 7.48h.71l1.77-1.77-.71-.7L3.4 6.42l-.69-.69-.71.71 1.04 1.04zm.71 3.01h-.71L2 9.45l.71-.71.69.69 1.41-1.42.71.71-1.77 1.77zm-.71 3.01h.71l1.77-1.77-.71-.71-1.41 1.42-.69-.69-.71.7 1.04 1.05z"></path></g></svg>',
318
318
  shortcut: "Mod-Shift-9"
319
319
  }
320
320
  ],
321
321
  commands: {
322
322
  toggleChecklist: () => {
323
323
  try {
324
- const e = _();
324
+ const e = O();
325
325
  if (!e) return !1;
326
- const t = e.innerHTML, r = () => (L(e, t), y(e), !0), n = O(e);
326
+ const t = e.innerHTML, r = () => (L(e, t), y(e), !0), n = _(e);
327
327
  if (!n) return !1;
328
328
  z(e, n);
329
329
  const o = M(n.startContainer);
@@ -332,14 +332,14 @@ const A = "__editoraCommandEditorRoot", S = (e) => {
332
332
  if (a && e.contains(a)) {
333
333
  const l = T(a);
334
334
  if (l.length === 0) return !1;
335
- const h = document.createDocumentFragment();
335
+ const p = document.createDocumentFragment();
336
336
  let f = null;
337
337
  return l.forEach((m, E) => {
338
338
  const g = q(m);
339
339
  g.forEach((w) => {
340
- h.appendChild(w), !f && (m.contains(n.startContainer) || E === 0) && (f = w);
340
+ p.appendChild(w), !f && (m.contains(n.startContainer) || E === 0) && (f = w);
341
341
  }), !f && E === 0 && g[0] && (f = g[0]);
342
- }), a.replaceWith(h), f && C(f, e), r();
342
+ }), a.replaceWith(p), f && C(f, e), r();
343
343
  }
344
344
  const s = o.closest("ul, ol");
345
345
  if (s && e.contains(s)) {
@@ -352,10 +352,10 @@ const A = "__editoraCommandEditorRoot", S = (e) => {
352
352
  s.replaceWith(l);
353
353
  }
354
354
  l.setAttribute("data-type", "checklist");
355
- let h = T(l);
356
- h.length === 0 && (l.appendChild(k("")), h = T(l));
355
+ let p = T(l);
356
+ p.length === 0 && (l.appendChild(k("")), p = T(l));
357
357
  let f = null;
358
- h.forEach((E) => {
358
+ p.forEach((E) => {
359
359
  E.setAttribute("data-type", "checklist-item"), E.hasAttribute("data-checked") || E.setAttribute("data-checked", "false");
360
360
  const g = b(E);
361
361
  E.contains(n.startContainer) && (f = g);
@@ -378,17 +378,17 @@ const A = "__editoraCommandEditorRoot", S = (e) => {
378
378
  if (u && u !== e) {
379
379
  const l = document.createElement("ul");
380
380
  l.setAttribute("data-type", "checklist");
381
- const h = k(u.innerHTML);
382
- l.appendChild(h), u.replaceWith(l);
383
- const f = h.querySelector(":scope > p");
381
+ const p = k(u.innerHTML);
382
+ l.appendChild(p), u.replaceWith(l);
383
+ const f = p.querySelector(":scope > p");
384
384
  return f && C(f, e), r();
385
385
  }
386
386
  const i = document.createElement("ul");
387
387
  i.setAttribute("data-type", "checklist");
388
388
  const d = k("");
389
389
  i.appendChild(d), n.deleteContents(), n.insertNode(i);
390
- const p = d.querySelector(":scope > p");
391
- return p && C(p, e), r();
390
+ const h = d.querySelector(":scope > p");
391
+ return h && C(h, e), r();
392
392
  } catch (e) {
393
393
  return console.error("Failed to toggle checklist:", e), !1;
394
394
  }
@@ -399,5 +399,5 @@ const A = "__editoraCommandEditorRoot", S = (e) => {
399
399
  }
400
400
  });
401
401
  export {
402
- V as ChecklistPlugin
402
+ X as ChecklistPlugin
403
403
  };
package/dist/code.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./CodePlugin.native-Bwf25lLX.js");exports.CodePlugin=e.CodePlugin;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./CodePlugin.native-CKJo7IFG.js");exports.CodePlugin=e.CodePlugin;
package/dist/code.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as r } from "./CodePlugin.native-Cpp4u3Jl.mjs";
1
+ import { C as r } from "./CodePlugin.native-D8gGxB8i.mjs";
2
2
  export {
3
3
  r as CodePlugin
4
4
  };