@editora/plugins 1.0.21 → 1.0.23

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 (100) hide show
  1. package/README.md +259 -645
  2. package/dist/{CodePlugin.native-D8gGxB8i.mjs → CodePlugin.native-DESvGCrJ.mjs} +61 -53
  3. package/dist/{CodePlugin.native-CKJo7IFG.js → CodePlugin.native-DJqwsRPZ.js} +11 -11
  4. package/dist/a11y-checker.cjs.js +3 -3
  5. package/dist/a11y-checker.esm.js +6 -4
  6. package/dist/anchor.cjs.js +4 -4
  7. package/dist/anchor.esm.js +19 -18
  8. package/dist/anchoredPopover-BNJ8e7j-.mjs +128 -0
  9. package/dist/anchoredPopover-Cygmit_o.js +1 -0
  10. package/dist/approval-workflow.cjs.js +7 -7
  11. package/dist/approval-workflow.esm.js +55 -54
  12. package/dist/background-color.cjs.js +2 -2
  13. package/dist/background-color.esm.js +72 -67
  14. package/dist/blocks-library.cjs.js +18 -19
  15. package/dist/blocks-library.esm.js +41 -42
  16. package/dist/citations.cjs.js +4 -4
  17. package/dist/citations.esm.js +50 -50
  18. package/dist/code-sample.cjs.js +10 -10
  19. package/dist/code-sample.esm.js +4 -4
  20. package/dist/code.cjs.js +1 -1
  21. package/dist/code.esm.js +1 -1
  22. package/dist/comments.cjs.js +23 -11
  23. package/dist/comments.esm.js +167 -149
  24. package/dist/conditional-content.cjs.js +2 -2
  25. package/dist/conditional-content.esm.js +2 -2
  26. package/dist/confirmDialog-6BPaNPis.mjs +106 -0
  27. package/dist/confirmDialog-C4UWENes.js +46 -0
  28. package/dist/content-rules.cjs.js +6 -6
  29. package/dist/content-rules.esm.js +51 -51
  30. package/dist/data-binding.cjs.js +2 -2
  31. package/dist/data-binding.esm.js +2 -2
  32. package/dist/dialogHelpers-BbwpIXD9.mjs +183 -0
  33. package/dist/dialogHelpers-BxSQ7A6M.js +12 -0
  34. package/dist/document-manager.cjs.js +1 -1
  35. package/dist/document-manager.esm.js +1 -1
  36. package/dist/{documentManager-BL98a7YZ.mjs → documentManager-BFjGIeI8.mjs} +793 -781
  37. package/dist/{documentManager-r8t7yZEd.js → documentManager-C9d17K5W.js} +10 -10
  38. package/dist/embed-iframe.cjs.js +6 -6
  39. package/dist/embed-iframe.esm.js +6 -6
  40. package/dist/emojis.cjs.js +5 -5
  41. package/dist/emojis.esm.js +3 -3
  42. package/dist/enterprise.cjs.js +1 -1
  43. package/dist/enterprise.esm.js +1 -1
  44. package/dist/format-painter.cjs.js +1 -1
  45. package/dist/format-painter.esm.js +172 -151
  46. package/dist/heading.cjs.js +1 -1
  47. package/dist/heading.esm.js +96 -83
  48. package/dist/history.cjs.js +1 -1
  49. package/dist/history.esm.js +176 -97
  50. package/dist/{index-D5xugkYA.js → index-CtR8olYy.js} +2 -2
  51. package/dist/{index-B-VitI3v.mjs → index-Du_Ljqfz.mjs} +36 -35
  52. package/dist/index.cjs.js +1 -1
  53. package/dist/index.esm.js +2 -2
  54. package/dist/katex-Cc3-mvOY.js +257 -0
  55. package/dist/katex-DoRnZ_sp.mjs +11682 -0
  56. package/dist/katex.min--Ws3c9be.mjs +5 -0
  57. package/dist/katex.min-Dk2VscxB.js +2 -0
  58. package/dist/link.cjs.js +3 -3
  59. package/dist/link.esm.js +3 -3
  60. package/dist/list.cjs.js +1 -1
  61. package/dist/list.esm.js +140 -52
  62. package/dist/math.cjs.js +14 -14
  63. package/dist/math.esm.js +149 -136
  64. package/dist/media-manager.cjs.js +46 -46
  65. package/dist/media-manager.esm.js +320 -264
  66. package/dist/mentions.cjs.js +12 -12
  67. package/dist/mentions.esm.js +149 -143
  68. package/dist/merge-tag.cjs.js +5 -3
  69. package/dist/merge-tag.esm.js +5 -3
  70. package/dist/notify-BkbzMopb.js +32 -0
  71. package/dist/notify-zOp-mUOJ.mjs +59 -0
  72. package/dist/pii-redaction.cjs.js +1 -1
  73. package/dist/pii-redaction.esm.js +1 -1
  74. package/dist/preview.cjs.js +1 -1
  75. package/dist/preview.esm.js +1 -1
  76. package/dist/shared-config.cjs.js +1 -1
  77. package/dist/shared-config.esm.js +14 -14
  78. package/dist/slash-commands.cjs.js +5 -5
  79. package/dist/slash-commands.esm.js +259 -236
  80. package/dist/smart-paste.cjs.js +1 -1
  81. package/dist/smart-paste.esm.js +1 -1
  82. package/dist/special-characters.cjs.js +3 -3
  83. package/dist/special-characters.esm.js +3 -3
  84. package/dist/spell-check.cjs.js +9 -9
  85. package/dist/spell-check.esm.js +288 -251
  86. package/dist/table.cjs.js +14 -14
  87. package/dist/table.esm.js +175 -154
  88. package/dist/template.cjs.js +5 -3
  89. package/dist/template.esm.js +15 -13
  90. package/dist/text-color.cjs.js +4 -4
  91. package/dist/text-color.esm.js +38 -34
  92. package/dist/translation-workflow.cjs.js +9 -9
  93. package/dist/translation-workflow.esm.js +98 -95
  94. package/dist/version-diff.cjs.js +4 -4
  95. package/dist/version-diff.esm.js +36 -36
  96. package/package.json +6 -5
  97. package/dist/anchoredPopover-Bg-ey7Yo.js +0 -1
  98. package/dist/anchoredPopover-D_JbjvdA.mjs +0 -111
  99. package/dist/dialogHelpers-5d5BuOCW.mjs +0 -39
  100. package/dist/dialogHelpers-zU6zpMIA.js +0 -12
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f='.rte-content, .editora-content, [contenteditable="true"]',y="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",g=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE"]),E="p,div,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,table",B=new Set(["p","h1","h2","h3","h4","h5","h6"]);function H(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function S(e){const n=e?.contentElement;if(n instanceof HTMLElement)return n;const t=e?.editorElement;if(t instanceof HTMLElement){const a=t.querySelector(f);if(a instanceof HTMLElement)return a;if(t.getAttribute("contenteditable")==="true")return t}const r=window.getSelection();if(r&&r.rangeCount>0){const a=H(r.getRangeAt(0).startContainer),i=a?.closest(f);if(i instanceof HTMLElement)return i;const u=a?.closest(y)?.querySelector(f);if(u instanceof HTMLElement)return u}const o=document.activeElement?.closest(f);return o instanceof HTMLElement?o:document.querySelector(f)}function N(e){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const t=n.getRangeAt(0);return!e.contains(t.startContainer)||!e.contains(t.endContainer)?null:t}function T(e,n){let t=H(n);if(!t||t===e||!e.contains(t))return null;for(;t.parentElement&&t.parentElement!==e;)t=t.parentElement;if(t.parentElement!==e)return null;if(t.matches(E))return t;const r=t.closest(E);return r instanceof HTMLElement&&r.parentElement===e?r:t}function v(e,n){if(typeof e.intersectsNode=="function")try{return e.intersectsNode(n)}catch{return!1}const t=document.createRange();return t.selectNode(n),e.compareBoundaryPoints(Range.END_TO_START,t)<0&&e.compareBoundaryPoints(Range.START_TO_END,t)>0}function w(e,n){const t=T(e,n.startContainer),r=T(e,n.endContainer);if(!t)return[];if(!r||t===r)return[t];const o=Array.from(e.children).filter(a=>a instanceof HTMLElement).filter(a=>v(n,a));return o.length>0?o:[t]}function A(e,n){Array.from(e.attributes).forEach(t=>{n.setAttribute(t.name,t.value)})}function p(e,n){for(;e.firstChild;)n.appendChild(e.firstChild)}function R(e){return e.tagName!=="P"||e.attributes.length>0||(e.textContent||"").trim()!==""?!1:!e.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function d(e,n){const t=document.createElement(e);return n&&A(n,t),t}function C(e,n){const t=d(n,e);return p(e,t),t.innerHTML.trim()||(t.innerHTML="<br>"),t}function _(e){const n=e.cloneNode(!1);return n instanceof HTMLElement?n:document.createElement(e.tagName.toLowerCase())}function L(e,n,t){const r=e.parentNode;if(!r)return[];const s=document.createDocumentFragment(),o=[];let a=null;const i=()=>{a&&a.children.length>0&&s.appendChild(a),a=null};return Array.from(e.children).forEach(c=>{if(c instanceof HTMLLIElement){if(n.has(c)){i();const u=C(c,t);s.appendChild(u),o.push(u);return}a||(a=_(e)),a.appendChild(c)}}),i(),r.insertBefore(s,e),r.removeChild(e),o}function I(e,n){if(e.tagName.toLowerCase()===n)return[e];const t=d(n,e);return p(e,t),t.innerHTML.trim()||(t.innerHTML="<br>"),e.parentNode?.replaceChild(t,e),[t]}function O(e,n){const t=e.parentNode;if(!t)return[];const r=document.createDocumentFragment(),s=[];return Array.from(e.childNodes).forEach(o=>{if(o instanceof HTMLElement&&R(o)){o.remove();return}if(o instanceof HTMLUListElement||o instanceof HTMLOListElement){Array.from(o.children).forEach(i=>{if(!(i instanceof HTMLLIElement))return;const c=C(i,n);r.appendChild(c),s.push(c)}),o.remove();return}if(o instanceof HTMLElement&&g.has(o.tagName)){const i=d(n,o);p(o,i),r.appendChild(i),s.push(i);return}if(o.nodeType===Node.TEXT_NODE&&(o.textContent||"").trim()===""){o.remove();return}const a=d(n,e);a.appendChild(o),r.appendChild(a),s.push(a)}),t.insertBefore(r,e),t.removeChild(e),s}function b(e){const n=window.getSelection();if(!n)return;const t=document.createRange(),r=e instanceof HTMLElement&&e.querySelector("p,li,h1,h2,h3,h4,h5,h6")||e;t.selectNodeContents(r),t.collapse(!0),n.removeAllRanges(),n.addRange(t)}function k(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function P(e,n,t){const r=window.execEditorCommand;if(typeof r=="function"){r("recordDomTransaction",e,n,t);return}const s=window.executeEditorCommand;typeof s=="function"&&s("recordDomTransaction",{editor:e,beforeHTML:n,afterHTML:t})}function x(e,n){const t=new Map;return Array.from(e.querySelectorAll("li")).filter(s=>s instanceof HTMLLIElement&&v(n,s)).forEach(s=>{const o=s.parentElement;(o instanceof HTMLUListElement||o instanceof HTMLOListElement)&&o.parentElement===e&&(t.has(o)||t.set(o,new Set),t.get(o)?.add(s))}),t}function m(e,n){const t=e.toLowerCase();if(!B.has(t))return!1;const r=S(n);if(!r)return!1;const s=N(r);if(!s)return!1;const o=r.innerHTML,a=[],i=x(r,s);i.size>0?i.forEach((u,l)=>{a.push(...L(l,u,t))}):w(r,s).forEach(l=>{if(l instanceof HTMLUListElement||l instanceof HTMLOListElement){const h=new Set(Array.from(l.children).filter(M=>M instanceof HTMLLIElement));a.push(...L(l,h,t));return}if(g.has(l.tagName)){const h=l.querySelector(":scope > ul, :scope > ol, :scope > blockquote, :scope > table");a.push(...h?O(l,t):I(l,t))}});const c=r.innerHTML;return o===c||a.length===0?!1:(P(r,o,c),k(r),b(a[0]),!0)}const D=()=>({name:"heading",toolbar:[{label:"P",command:"setBlockType",type:"dropdown",options:[{value:"p",label:"P"},{value:"h1",label:"H1"},{value:"h2",label:"H2"},{value:"h3",label:"H3"},{value:"h4",label:"H4"},{value:"h5",label:"H5"},{value:"h6",label:"H6"}],icon:'<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'}],commands:{setBlockType:(e,n)=>e?m(e,n):!1,setHeading1:(e,n)=>m("h1",n),setHeading2:(e,n)=>m("h2",n),setHeading3:(e,n)=>m("h3",n),setParagraph:(e,n)=>m("p",n)},keymap:{"Mod-Alt-1":"setHeading1","Mod-Alt-2":"setHeading2","Mod-Alt-3":"setHeading3","Mod-Alt-0":"setParagraph"}});exports.HeadingPlugin=D;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d='.rte-content, .editora-content, [contenteditable="true"]',B="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",C=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE"]),T="p,div,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,table",S=new Set(["p","h1","h2","h3","h4","h5","h6"]);function v(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function w(e){const n=e?.contentElement;if(n instanceof HTMLElement)return n;const t=e?.editorElement;if(t instanceof HTMLElement){const s=t.querySelector(d);if(s instanceof HTMLElement)return s;if(t.getAttribute("contenteditable")==="true")return t}const r=window.getSelection();if(r&&r.rangeCount>0){const s=v(r.getRangeAt(0).startContainer),i=s?.closest(d);if(i instanceof HTMLElement)return i;const u=s?.closest(B)?.querySelector(d);if(u instanceof HTMLElement)return u}const o=document.activeElement?.closest(d);return o instanceof HTMLElement?o:document.querySelector(d)}function O(e){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const t=n.getRangeAt(0);return!e.contains(t.startContainer)||!e.contains(t.endContainer)?null:t}function g(e,n){let t=v(n);if(!t||t===e||!e.contains(t))return null;for(;t.parentElement&&t.parentElement!==e;)t=t.parentElement;if(t.parentElement!==e)return null;if(t.matches(T))return t;const r=t.closest(T);return r instanceof HTMLElement&&r.parentElement===e?r:t}function H(e,n){if(typeof e.intersectsNode=="function")try{return e.intersectsNode(n)}catch{return!1}const t=document.createRange();return t.selectNode(n),e.compareBoundaryPoints(Range.END_TO_START,t)<0&&e.compareBoundaryPoints(Range.START_TO_END,t)>0}function R(e,n){const t=g(e,n.startContainer),r=g(e,n.endContainer);if(!t)return[];if(!r||t===r)return[t];const o=Array.from(e.children).filter(s=>s instanceof HTMLElement).filter(s=>H(n,s));return o.length>0?o:[t]}function A(e,n){Array.from(e.attributes).forEach(t=>{n.setAttribute(t.name,t.value)})}function E(e,n){for(;e.firstChild;)n.appendChild(e.firstChild)}function N(e){return e.tagName!=="P"||e.attributes.length>0||(e.textContent||"").trim()!==""?!1:!e.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function h(e,n){const t=document.createElement(e);return n&&A(n,t),t}function M(e,n){const t=h(n,e);return E(e,t),t.innerHTML.trim()||(t.innerHTML="<br>"),t}function _(e){const n=e.cloneNode(!1);return n instanceof HTMLElement?n:document.createElement(e.tagName.toLowerCase())}function L(e,n,t){const r=e.parentNode;if(!r)return[];const a=document.createDocumentFragment(),o=[];let s=null;const i=()=>{s&&s.children.length>0&&a.appendChild(s),s=null};return Array.from(e.children).forEach(c=>{if(c instanceof HTMLLIElement){if(n.has(c)){i();const u=M(c,t);a.appendChild(u),o.push(u);return}s||(s=_(e)),s.appendChild(c)}}),i(),r.insertBefore(a,e),r.removeChild(e),o}function I(e,n){if(e.tagName.toLowerCase()===n)return[e];const t=h(n,e);return E(e,t),t.innerHTML.trim()||(t.innerHTML="<br>"),e.parentNode?.replaceChild(t,e),[t]}function b(e,n){const t=e.parentNode;if(!t)return[];const r=document.createDocumentFragment(),a=[];return Array.from(e.childNodes).forEach(o=>{if(o instanceof HTMLElement&&N(o)){o.remove();return}if(o instanceof HTMLUListElement||o instanceof HTMLOListElement){Array.from(o.children).forEach(i=>{if(!(i instanceof HTMLLIElement))return;const c=M(i,n);r.appendChild(c),a.push(c)}),o.remove();return}if(o instanceof HTMLElement&&C.has(o.tagName)){const i=h(n,o);E(o,i),r.appendChild(i),a.push(i);return}if(o.nodeType===Node.TEXT_NODE&&(o.textContent||"").trim()===""){o.remove();return}const s=h(n,e);s.appendChild(o),r.appendChild(s),a.push(s)}),t.insertBefore(r,e),t.removeChild(e),a}function k(e){const n=window.getSelection();if(!n)return;const t=document.createRange(),r=e instanceof HTMLElement&&e.querySelector("p,li,h1,h2,h3,h4,h5,h6")||e;t.selectNodeContents(r),t.collapse(!0),n.removeAllRanges(),n.addRange(t)}function P(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function x(e,n,t){const r=window.execEditorCommand;if(typeof r=="function"){r("recordDomTransaction",e,n,t);return}const a=window.executeEditorCommand;typeof a=="function"&&a("recordDomTransaction",{editor:e,beforeHTML:n,afterHTML:t})}function D(e,n){const t=new Map;return Array.from(e.querySelectorAll("li")).filter(a=>a instanceof HTMLLIElement&&H(n,a)).forEach(a=>{const o=a.parentElement;(o instanceof HTMLUListElement||o instanceof HTMLOListElement)&&o.parentElement===e&&(t.has(o)||t.set(o,new Set),t.get(o)?.add(a))}),t}function m(e,n){const t=e.toLowerCase();if(!S.has(t))return!1;const r=w(n);if(!r)return!1;const a=O(r);if(!a)return!1;const o=r.innerHTML,s=[],i=D(r,a),c={startContainer:a.startContainer,startOffset:a.startOffset,endContainer:a.endContainer,endOffset:a.endOffset};i.size>0?i.forEach((f,l)=>{s.push(...L(l,f,t))}):R(r,a).forEach(l=>{if(l instanceof HTMLUListElement||l instanceof HTMLOListElement){const p=new Set(Array.from(l.children).filter(y=>y instanceof HTMLLIElement));s.push(...L(l,p,t));return}if(C.has(l.tagName)){const p=l.querySelector(":scope > ul, :scope > ol, :scope > blockquote, :scope > table");s.push(...p?b(l,t):I(l,t))}});const u=r.innerHTML;if(o===u||s.length===0)return!1;if(x(r,o,u),P(r),r.contains(c.startContainer)&&r.contains(c.endContainer)){const f=document.createRange();f.setStart(c.startContainer,c.startOffset),f.setEnd(c.endContainer,c.endOffset);const l=window.getSelection();l?.removeAllRanges(),l?.addRange(f)}else k(s[0]);return!0}const q=()=>({name:"heading",toolbar:[{label:"P",command:"setBlockType",type:"dropdown",options:[{value:"p",label:"P"},{value:"h1",label:"H1"},{value:"h2",label:"H2"},{value:"h3",label:"H3"},{value:"h4",label:"H4"},{value:"h5",label:"H5"},{value:"h6",label:"H6"}],icon:'<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'}],commands:{setBlockType:(e,n)=>e?m(e,n):!1,setHeading1:(e,n)=>m("h1",n),setHeading2:(e,n)=>m("h2",n),setHeading3:(e,n)=>m("h3",n),setParagraph:(e,n)=>m("p",n)},keymap:{"Mod-Alt-1":"setHeading1","Mod-Alt-2":"setHeading2","Mod-Alt-3":"setHeading3","Mod-Alt-0":"setParagraph"}});exports.HeadingPlugin=q;
@@ -1,40 +1,40 @@
1
- const f = '.rte-content, .editora-content, [contenteditable="true"]', y = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", g = /* @__PURE__ */ new Set(["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "PRE"]), E = "p,div,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,table", B = /* @__PURE__ */ new Set(["p", "h1", "h2", "h3", "h4", "h5", "h6"]);
1
+ const d = '.rte-content, .editora-content, [contenteditable="true"]', B = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", C = /* @__PURE__ */ new Set(["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "PRE"]), T = "p,div,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,table", S = /* @__PURE__ */ new Set(["p", "h1", "h2", "h3", "h4", "h5", "h6"]);
2
2
  function H(e) {
3
3
  return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
4
4
  }
5
- function S(e) {
5
+ function w(e) {
6
6
  const n = e?.contentElement;
7
7
  if (n instanceof HTMLElement) return n;
8
8
  const t = e?.editorElement;
9
9
  if (t instanceof HTMLElement) {
10
- const a = t.querySelector(f);
11
- if (a instanceof HTMLElement) return a;
10
+ const s = t.querySelector(d);
11
+ if (s instanceof HTMLElement) return s;
12
12
  if (t.getAttribute("contenteditable") === "true") return t;
13
13
  }
14
14
  const r = window.getSelection();
15
15
  if (r && r.rangeCount > 0) {
16
- const a = H(r.getRangeAt(0).startContainer), c = a?.closest(f);
17
- if (c instanceof HTMLElement) return c;
18
- const u = a?.closest(y)?.querySelector(f);
19
- if (u instanceof HTMLElement) return u;
16
+ const s = H(r.getRangeAt(0).startContainer), i = s?.closest(d);
17
+ if (i instanceof HTMLElement) return i;
18
+ const f = s?.closest(B)?.querySelector(d);
19
+ if (f instanceof HTMLElement) return f;
20
20
  }
21
- const o = document.activeElement?.closest(f);
22
- return o instanceof HTMLElement ? o : document.querySelector(f);
21
+ const o = document.activeElement?.closest(d);
22
+ return o instanceof HTMLElement ? o : document.querySelector(d);
23
23
  }
24
- function N(e) {
24
+ function R(e) {
25
25
  const n = window.getSelection();
26
26
  if (!n || n.rangeCount === 0) return null;
27
27
  const t = n.getRangeAt(0);
28
28
  return !e.contains(t.startContainer) || !e.contains(t.endContainer) ? null : t;
29
29
  }
30
- function T(e, n) {
30
+ function L(e, n) {
31
31
  let t = H(n);
32
32
  if (!t || t === e || !e.contains(t)) return null;
33
33
  for (; t.parentElement && t.parentElement !== e; )
34
34
  t = t.parentElement;
35
35
  if (t.parentElement !== e) return null;
36
- if (t.matches(E)) return t;
37
- const r = t.closest(E);
36
+ if (t.matches(T)) return t;
37
+ const r = t.closest(T);
38
38
  return r instanceof HTMLElement && r.parentElement === e ? r : t;
39
39
  }
40
40
  function v(e, n) {
@@ -47,150 +47,163 @@ function v(e, n) {
47
47
  const t = document.createRange();
48
48
  return t.selectNode(n), e.compareBoundaryPoints(Range.END_TO_START, t) < 0 && e.compareBoundaryPoints(Range.START_TO_END, t) > 0;
49
49
  }
50
- function w(e, n) {
51
- const t = T(e, n.startContainer), r = T(e, n.endContainer);
50
+ function A(e, n) {
51
+ const t = L(e, n.startContainer), r = L(e, n.endContainer);
52
52
  if (!t) return [];
53
53
  if (!r || t === r) return [t];
54
54
  const o = Array.from(e.children).filter(
55
- (a) => a instanceof HTMLElement
56
- ).filter((a) => v(n, a));
55
+ (s) => s instanceof HTMLElement
56
+ ).filter((s) => v(n, s));
57
57
  return o.length > 0 ? o : [t];
58
58
  }
59
- function A(e, n) {
59
+ function N(e, n) {
60
60
  Array.from(e.attributes).forEach((t) => {
61
61
  n.setAttribute(t.name, t.value);
62
62
  });
63
63
  }
64
- function p(e, n) {
64
+ function E(e, n) {
65
65
  for (; e.firstChild; )
66
66
  n.appendChild(e.firstChild);
67
67
  }
68
- function R(e) {
68
+ function O(e) {
69
69
  return e.tagName !== "P" || e.attributes.length > 0 || (e.textContent || "").trim() !== "" ? !1 : !e.querySelector("img, video, table, iframe, hr, pre, ul, ol");
70
70
  }
71
- function d(e, n) {
71
+ function h(e, n) {
72
72
  const t = document.createElement(e);
73
- return n && A(n, t), t;
73
+ return n && N(n, t), t;
74
74
  }
75
- function C(e, n) {
76
- const t = d(n, e);
77
- return p(e, t), t.innerHTML.trim() || (t.innerHTML = "<br>"), t;
75
+ function M(e, n) {
76
+ const t = h(n, e);
77
+ return E(e, t), t.innerHTML.trim() || (t.innerHTML = "<br>"), t;
78
78
  }
79
79
  function I(e) {
80
80
  const n = e.cloneNode(!1);
81
81
  return n instanceof HTMLElement ? n : document.createElement(e.tagName.toLowerCase());
82
82
  }
83
- function L(e, n, t) {
83
+ function g(e, n, t) {
84
84
  const r = e.parentNode;
85
85
  if (!r) return [];
86
- const s = document.createDocumentFragment(), o = [];
87
- let a = null;
88
- const c = () => {
89
- a && a.children.length > 0 && s.appendChild(a), a = null;
86
+ const a = document.createDocumentFragment(), o = [];
87
+ let s = null;
88
+ const i = () => {
89
+ s && s.children.length > 0 && a.appendChild(s), s = null;
90
90
  };
91
- return Array.from(e.children).forEach((i) => {
92
- if (i instanceof HTMLLIElement) {
93
- if (n.has(i)) {
94
- c();
95
- const u = C(i, t);
96
- s.appendChild(u), o.push(u);
91
+ return Array.from(e.children).forEach((c) => {
92
+ if (c instanceof HTMLLIElement) {
93
+ if (n.has(c)) {
94
+ i();
95
+ const f = M(c, t);
96
+ a.appendChild(f), o.push(f);
97
97
  return;
98
98
  }
99
- a || (a = I(e)), a.appendChild(i);
99
+ s || (s = I(e)), s.appendChild(c);
100
100
  }
101
- }), c(), r.insertBefore(s, e), r.removeChild(e), o;
101
+ }), i(), r.insertBefore(a, e), r.removeChild(e), o;
102
102
  }
103
103
  function _(e, n) {
104
104
  if (e.tagName.toLowerCase() === n) return [e];
105
- const t = d(n, e);
106
- return p(e, t), t.innerHTML.trim() || (t.innerHTML = "<br>"), e.parentNode?.replaceChild(t, e), [t];
105
+ const t = h(n, e);
106
+ return E(e, t), t.innerHTML.trim() || (t.innerHTML = "<br>"), e.parentNode?.replaceChild(t, e), [t];
107
107
  }
108
- function O(e, n) {
108
+ function b(e, n) {
109
109
  const t = e.parentNode;
110
110
  if (!t) return [];
111
- const r = document.createDocumentFragment(), s = [];
111
+ const r = document.createDocumentFragment(), a = [];
112
112
  return Array.from(e.childNodes).forEach((o) => {
113
- if (o instanceof HTMLElement && R(o)) {
113
+ if (o instanceof HTMLElement && O(o)) {
114
114
  o.remove();
115
115
  return;
116
116
  }
117
117
  if (o instanceof HTMLUListElement || o instanceof HTMLOListElement) {
118
- Array.from(o.children).forEach((c) => {
119
- if (!(c instanceof HTMLLIElement)) return;
120
- const i = C(c, n);
121
- r.appendChild(i), s.push(i);
118
+ Array.from(o.children).forEach((i) => {
119
+ if (!(i instanceof HTMLLIElement)) return;
120
+ const c = M(i, n);
121
+ r.appendChild(c), a.push(c);
122
122
  }), o.remove();
123
123
  return;
124
124
  }
125
- if (o instanceof HTMLElement && g.has(o.tagName)) {
126
- const c = d(n, o);
127
- p(o, c), r.appendChild(c), s.push(c);
125
+ if (o instanceof HTMLElement && C.has(o.tagName)) {
126
+ const i = h(n, o);
127
+ E(o, i), r.appendChild(i), a.push(i);
128
128
  return;
129
129
  }
130
130
  if (o.nodeType === Node.TEXT_NODE && (o.textContent || "").trim() === "") {
131
131
  o.remove();
132
132
  return;
133
133
  }
134
- const a = d(n, e);
135
- a.appendChild(o), r.appendChild(a), s.push(a);
136
- }), t.insertBefore(r, e), t.removeChild(e), s;
134
+ const s = h(n, e);
135
+ s.appendChild(o), r.appendChild(s), a.push(s);
136
+ }), t.insertBefore(r, e), t.removeChild(e), a;
137
137
  }
138
- function b(e) {
138
+ function k(e) {
139
139
  const n = window.getSelection();
140
140
  if (!n) return;
141
141
  const t = document.createRange(), r = e instanceof HTMLElement && e.querySelector("p,li,h1,h2,h3,h4,h5,h6") || e;
142
142
  t.selectNodeContents(r), t.collapse(!0), n.removeAllRanges(), n.addRange(t);
143
143
  }
144
- function k(e) {
144
+ function x(e) {
145
145
  e.dispatchEvent(new Event("input", { bubbles: !0 }));
146
146
  }
147
- function x(e, n, t) {
147
+ function D(e, n, t) {
148
148
  const r = window.execEditorCommand;
149
149
  if (typeof r == "function") {
150
150
  r("recordDomTransaction", e, n, t);
151
151
  return;
152
152
  }
153
- const s = window.executeEditorCommand;
154
- typeof s == "function" && s("recordDomTransaction", { editor: e, beforeHTML: n, afterHTML: t });
153
+ const a = window.executeEditorCommand;
154
+ typeof a == "function" && a("recordDomTransaction", { editor: e, beforeHTML: n, afterHTML: t });
155
155
  }
156
- function D(e, n) {
156
+ function P(e, n) {
157
157
  const t = /* @__PURE__ */ new Map();
158
158
  return Array.from(e.querySelectorAll("li")).filter(
159
- (s) => s instanceof HTMLLIElement && v(n, s)
160
- ).forEach((s) => {
161
- const o = s.parentElement;
162
- (o instanceof HTMLUListElement || o instanceof HTMLOListElement) && o.parentElement === e && (t.has(o) || t.set(o, /* @__PURE__ */ new Set()), t.get(o)?.add(s));
159
+ (a) => a instanceof HTMLLIElement && v(n, a)
160
+ ).forEach((a) => {
161
+ const o = a.parentElement;
162
+ (o instanceof HTMLUListElement || o instanceof HTMLOListElement) && o.parentElement === e && (t.has(o) || t.set(o, /* @__PURE__ */ new Set()), t.get(o)?.add(a));
163
163
  }), t;
164
164
  }
165
165
  function m(e, n) {
166
166
  const t = e.toLowerCase();
167
- if (!B.has(t)) return !1;
168
- const r = S(n);
167
+ if (!S.has(t)) return !1;
168
+ const r = w(n);
169
169
  if (!r) return !1;
170
- const s = N(r);
171
- if (!s) return !1;
172
- const o = r.innerHTML, a = [], c = D(r, s);
173
- c.size > 0 ? c.forEach((u, l) => {
174
- a.push(...L(l, u, t));
175
- }) : w(r, s).forEach((l) => {
170
+ const a = R(r);
171
+ if (!a) return !1;
172
+ const o = r.innerHTML, s = [], i = P(r, a), c = {
173
+ startContainer: a.startContainer,
174
+ startOffset: a.startOffset,
175
+ endContainer: a.endContainer,
176
+ endOffset: a.endOffset
177
+ };
178
+ i.size > 0 ? i.forEach((u, l) => {
179
+ s.push(...g(l, u, t));
180
+ }) : A(r, a).forEach((l) => {
176
181
  if (l instanceof HTMLUListElement || l instanceof HTMLOListElement) {
177
- const h = new Set(Array.from(l.children).filter(
178
- (M) => M instanceof HTMLLIElement
182
+ const p = new Set(Array.from(l.children).filter(
183
+ (y) => y instanceof HTMLLIElement
179
184
  ));
180
- a.push(...L(l, h, t));
185
+ s.push(...g(l, p, t));
181
186
  return;
182
187
  }
183
- if (g.has(l.tagName)) {
184
- const h = l.querySelector(":scope > ul, :scope > ol, :scope > blockquote, :scope > table");
185
- a.push(
186
- ...h ? O(l, t) : _(l, t)
188
+ if (C.has(l.tagName)) {
189
+ const p = l.querySelector(":scope > ul, :scope > ol, :scope > blockquote, :scope > table");
190
+ s.push(
191
+ ...p ? b(l, t) : _(l, t)
187
192
  );
188
193
  }
189
194
  });
190
- const i = r.innerHTML;
191
- return o === i || a.length === 0 ? !1 : (x(r, o, i), k(r), b(a[0]), !0);
195
+ const f = r.innerHTML;
196
+ if (o === f || s.length === 0) return !1;
197
+ if (D(r, o, f), x(r), r.contains(c.startContainer) && r.contains(c.endContainer)) {
198
+ const u = document.createRange();
199
+ u.setStart(c.startContainer, c.startOffset), u.setEnd(c.endContainer, c.endOffset);
200
+ const l = window.getSelection();
201
+ l?.removeAllRanges(), l?.addRange(u);
202
+ } else
203
+ k(s[0]);
204
+ return !0;
192
205
  }
193
- const P = () => ({
206
+ const q = () => ({
194
207
  name: "heading",
195
208
  // Toolbar button configuration with dropdown
196
209
  toolbar: [
@@ -242,5 +255,5 @@ const P = () => ({
242
255
  }
243
256
  });
244
257
  export {
245
- P as HeadingPlugin
258
+ q as HeadingPlugin
246
259
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=".rte-content, .editora-content",M=100,T="__editoraCommandEditorRoot",d=new Map,m={};let y=!1,c=null;function N(t){if(!t)return null;const e=t.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null}function R(){if(typeof window>"u")return null;const t=window[T];if(!(t instanceof HTMLElement))return null;window[T]=null;const e=t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?t:null);if(e){const o=N(e);if(o)return o;if(e.getAttribute("contenteditable")==="true")return e}if(t.getAttribute("contenteditable")==="true")return t;const n=t.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null}function I(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function s(t){const e=I(t);if(!e)return null;const n=e.closest(h);if(n)return n;const o=e.closest('[contenteditable="true"]');if(!o)return null;let r=o,i=r.parentElement;for(;i;)i.getAttribute("contenteditable")==="true"&&(r=i),i=i.parentElement;return r}function p(){const t=R();if(t&&document.contains(t))return t;const e=window.getSelection();if(e&&e.rangeCount>0){const i=s(e.getRangeAt(0).startContainer);if(i)return i}const n=document.activeElement;if(n){const i=s(n);if(i)return i}if(c?.isConnected)return c;const o=Array.from(d.keys()).find(i=>i.isConnected);if(o)return o;const r=document.querySelector(h);return r||document.querySelector('[contenteditable="true"]')}function S(){for(const t of d.keys())t.isConnected||(d.delete(t),c===t&&(c=null))}function f(t){S();let e=d.get(t);return e||(e={undoStack:[],redoStack:[]},d.set(t,e)),e}function a(t){t&&t.dispatchEvent(new Event("input",{bubbles:!0}))}function l(t,e){if(!t)return;const n=f(t);n.undoStack.push(e),n.redoStack.length=0,n.undoStack.length>M&&n.undoStack.splice(0,n.undoStack.length-M),c=t}function A(t,e="undo"){if(S(),t?.isConnected)return t;const n=p();if(n?.isConnected)return n;if(c?.isConnected)return c;const o=r=>e==="undo"?r.undoStack.length>0:r.redoStack.length>0;for(const[r,i]of d.entries())if(r.isConnected&&o(i))return r;return null}function g(t){const e={};for(const r of t.getAttributeNames()){const i=t.getAttribute(r);i!==null&&(e[r]=i)}const n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement,o=t instanceof HTMLInputElement;return{attributes:e,innerHTML:t.innerHTML,value:n?t.value:null,checked:o?t.checked:null}}function w(t,e){const n=new Set(t.getAttributeNames());Object.keys(e.attributes).forEach(o=>n.delete(o)),n.forEach(o=>t.removeAttribute(o)),Object.entries(e.attributes).forEach(([o,r])=>{t.setAttribute(o,r)}),t.innerHTML!==e.innerHTML&&(t.innerHTML=e.innerHTML),e.value!==null&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t.value=e.value),e.checked!==null&&t instanceof HTMLInputElement&&(t.checked=e.checked)}function u(t,e){if(m[t]=e,typeof window>"u")return;const n=window.registerEditorCommand;typeof n=="function"?n(t,e):(window.registerEditorCommand=(o,r)=>{m[o]=r},window.registerEditorCommand(t,e))}const H=(t,...e)=>{const n=m[t];return n?n(...e):!1};function E(){y||typeof window>"u"||(y=!0,window.execEditorCommand||(window.execEditorCommand=H),window.executeEditorCommand||(window.executeEditorCommand=H),u("undo",L),u("redo",v),u("setAttribute",k),u("setText",x),u("autoFixA11y",D),u("recordDomTransaction",O),u("undoDom",b),u("redoDom",C))}const L=()=>{const t=p();return b(t??void 0)},v=()=>{const t=p();return C(t??void 0)},k=(t,e,n)=>{if(!(t instanceof HTMLElement))return;const o=s(t),r=t.hasAttribute(e),i=t.getAttribute(e);t.setAttribute(e,n),l(o,{undo:()=>{t.isConnected&&(r&&i!==null?t.setAttribute(e,i):t.removeAttribute(e))},redo:()=>{t.isConnected&&t.setAttribute(e,n)}}),a(o)},x=(t,e)=>{if(!(t instanceof HTMLElement))return;const n=s(t),o=t.textContent??"";t.textContent=e,l(n,{undo:()=>{t.isConnected&&(t.textContent=o)},redo:()=>{t.isConnected&&(t.textContent=e)}}),a(n)},D=t=>{const e=t?.element;if(!(e instanceof HTMLElement))return;const n=s(e),o=window.a11yRuleRegistry?.find(_=>_.id===t.rule);if(!o||typeof o.fix!="function")return;const r=g(e);o.fix(t);const i=g(e);l(n,{undo:()=>{e.isConnected&&w(e,r)},redo:()=>{e.isConnected&&w(e,i)}}),a(n)},O=(t,e,n)=>{if(!(t instanceof HTMLElement))return!1;const o=typeof n=="string"?n:t.innerHTML;if(e===o)return!1;const r=f(t).undoStack.slice(-1)[0];return r&&r.beforeHTML===e&&r.afterHTML===o?!1:(l(t,{beforeHTML:e,afterHTML:o,undo:()=>{t.isConnected&&(t.innerHTML=e)},redo:()=>{t.isConnected&&(t.innerHTML=o)}}),!0)},b=t=>{const e=A(t,"undo");if(!e)return!1;const n=f(e),o=n.undoStack.pop();return o?(o.undo(),n.redoStack.push(o),c=e,a(e),!0):!1},C=t=>{const e=A(t,"redo");if(!e)return!1;const n=f(e),o=n.redoStack.pop();return o?(o.redo(),n.undoStack.push(o),c=e,a(e),!0):!1};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",E,{once:!0}):E());const z=()=>(E(),{name:"history",toolbar:[{label:"Undo",command:"undo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.4 8H12c3.7 0 6.2 2 6.8 5.1.6 2.7-.4 5.6-2.3 6.8a1 1 0 0 1-1-1.8c1.1-.6 1.8-2.7 1.4-4.6-.5-2.1-2.1-3.5-4.9-3.5H6.4l3.3 3.3a1 1 0 1 1-1.4 1.4l-5-5a1 1 0 0 1 0-1.4l5-5a1 1 0 0 1 1.4 1.4L6.4 8Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-z"},{label:"Redo",command:"redo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M17.6 10H12c-2.8 0-4.4 1.4-4.9 3.5-.4 2 .3 4 1.4 4.6a1 1 0 1 1-1 1.8c-2-1.2-2.9-4.1-2.3-6.8.6-3 3-5.1 6.8-5.1h5.6l-3.3-3.3a1 1 0 1 1 1.4-1.4l5 5a1 1 0 0 1 0 1.4l-5 5a1 1 0 0 1-1.4-1.4l3.3-3.3Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-y"}],commands:{undo:L,redo:v,setAttribute:k,setText:x,autoFixA11y:D,recordDomTransaction:O,undoDom:b,redoDom:C},keymap:{"Mod-z":"undo","Mod-Z":"undo","Mod-y":"redo","Mod-Y":"redo","Mod-Shift-z":"redo","Mod-Shift-Z":"redo"}});exports.HistoryPlugin=z;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const _=".rte-content, .editora-content",y=200,Y=4e7,X=1e3,B=8e3,S="__editoraCommandEditorRoot",f=new Map,p={};let A=!1,u=null;function Z(t){if(!t)return null;const e=t.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null}function j(){if(typeof window>"u")return null;const t=window[S];if(!(t instanceof HTMLElement))return null;window[S]=null;const e=t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?t:null);if(e){const o=Z(e);if(o)return o;if(e.getAttribute("contenteditable")==="true")return e}if(t.getAttribute("contenteditable")==="true")return t;const n=t.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null}function q(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function m(t){const e=q(t);if(!e)return null;const n=e.closest(_);if(n)return n;const o=e.closest('[contenteditable="true"]');if(!o)return null;let r=o,i=r.parentElement;for(;i;)i.getAttribute("contenteditable")==="true"&&(r=i),i=i.parentElement;return r}function H(){const t=j();if(t&&document.contains(t))return t;const e=window.getSelection();if(e&&e.rangeCount>0){const i=m(e.getRangeAt(0).startContainer);if(i)return i}const n=document.activeElement;if(n){const i=m(n);if(i)return i}if(u?.isConnected)return u;const o=Array.from(f.keys()).find(i=>i.isConnected);if(o)return o;const r=document.querySelector(_);return r||document.querySelector('[contenteditable="true"]')}function D(){for(const t of f.keys())t.isConnected||(f.delete(t),u===t&&(u=null))}function h(t){D();let e=f.get(t);return e||(e={undoStack:[],redoStack:[]},f.set(t,e)),e}function E(t){t&&t.dispatchEvent(new Event("input",{bubbles:!0}))}function W(t){return t==="insertText"||t==="insertCompositionText"?"insert":t==="deleteContentBackward"||t==="deleteContentForward"?"delete":null}function T(t){if(!t)return;const e=f.get(t)?.undoStack,n=e&&e[e.length-1];n&&(n.closed=!0)}function L(t){const e=document.createElement("div");return e.innerHTML=t,(e.textContent??"").replace(/\u00a0/g," ")}function V(t,e){const n=L(t),o=L(e),r=Math.min(n.length,o.length);let i=0;for(;i<r&&n.charCodeAt(i)===o.charCodeAt(i);)i++;let c=0;for(;c<r-i&&n.charCodeAt(n.length-1-c)===o.charCodeAt(o.length-1-c);)c++;return{start:i,beforeEnd:n.length-c,afterEnd:o.length-c}}function K(t,e){const n=window.getSelection();if(!n)return;const o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let r=Math.max(0,e),i=null,c=null;for(;i=o.nextNode();){const s=i;if(c=s,r<=s.data.length){const g=document.createRange();g.setStart(s,r),g.collapse(!0),n.removeAllRanges(),n.addRange(g);return}r-=s.data.length}const d=document.createRange();c?d.setStart(c,c.data.length):d.selectNodeContents(t),d.collapse(!0),n.removeAllRanges(),n.addRange(d)}function k(t,e,n,o){const r=document.activeElement,i=t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");if(!(!r||r===document.body||t.contains(r)||!!i?.contains(r)))return;const d=V(e,n);K(t,o==="undo"?d.beforeEnd:d.afterEnd),t.contains(document.activeElement)||t.focus({preventScroll:!0})}let v=!1;function $(){v||typeof document>"u"||(v=!0,document.addEventListener("pointerdown",t=>T(m(t.target)),!0),document.addEventListener("keydown",t=>{/^(Arrow(Left|Right|Up|Down)|Home|End|Page(Up|Down)|Tab)$/.test(t.key)&&T(m(t.target))},!0))}function M(t,e){if(!t)return;const n=h(t);n.undoStack.push(e),n.redoStack.length=0,n.undoStack.length>y&&n.undoStack.splice(0,n.undoStack.length-y);let o=0;n.undoStack.forEach(i=>{o+=(i.beforeHTML?.length??0)+(i.afterHTML?.length??0)});let r=0;for(;o>Y&&n.undoStack.length-r>1;){const i=n.undoStack[r];o-=(i.beforeHTML?.length??0)+(i.afterHTML?.length??0),r+=1}r>0&&n.undoStack.splice(0,r),u=t}function N(t,e="undo"){if(D(),t?.isConnected)return t;const n=H();if(n?.isConnected)return n;if(u?.isConnected)return u;const o=r=>e==="undo"?r.undoStack.length>0:r.redoStack.length>0;for(const[r,i]of f.entries())if(r.isConnected&&o(i))return r;return null}function x(t){const e={};for(const r of t.getAttributeNames()){const i=t.getAttribute(r);i!==null&&(e[r]=i)}const n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement,o=t instanceof HTMLInputElement;return{attributes:e,innerHTML:t.innerHTML,value:n?t.value:null,checked:o?t.checked:null}}function O(t,e){const n=new Set(t.getAttributeNames());Object.keys(e.attributes).forEach(o=>n.delete(o)),n.forEach(o=>t.removeAttribute(o)),Object.entries(e.attributes).forEach(([o,r])=>{t.setAttribute(o,r)}),t.innerHTML!==e.innerHTML&&(t.innerHTML=e.innerHTML),e.value!==null&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&(t.value=e.value),e.checked!==null&&t instanceof HTMLInputElement&&(t.checked=e.checked)}function a(t,e){if(p[t]=e,typeof window>"u")return;const n=window.registerEditorCommand;typeof n=="function"?n(t,e):(window.registerEditorCommand=(o,r)=>{p[o]=r},window.registerEditorCommand(t,e))}const R=(t,...e)=>{const n=p[t];return n?n(...e):!1};function C(){A||typeof window>"u"||(A=!0,$(),window.execEditorCommand||(window.execEditorCommand=R),window.executeEditorCommand||(window.executeEditorCommand=R),a("undo",I),a("redo",F),a("setAttribute",P),a("setText",z),a("autoFixA11y",G),a("recordDomTransaction",U),a("undoDom",w),a("redoDom",b))}const I=()=>{const t=H();return w(t??void 0)},F=()=>{const t=H();return b(t??void 0)},P=(t,e,n)=>{if(!(t instanceof HTMLElement))return;const o=m(t),r=t.hasAttribute(e),i=t.getAttribute(e);t.setAttribute(e,n),M(o,{undo:()=>{t.isConnected&&(r&&i!==null?t.setAttribute(e,i):t.removeAttribute(e))},redo:()=>{t.isConnected&&t.setAttribute(e,n)}}),E(o)},z=(t,e)=>{if(!(t instanceof HTMLElement))return;const n=m(t),o=t.textContent??"";t.textContent=e,M(n,{undo:()=>{t.isConnected&&(t.textContent=o)},redo:()=>{t.isConnected&&(t.textContent=e)}}),E(n)},G=t=>{const e=t?.element;if(!(e instanceof HTMLElement))return;const n=m(e),o=window.a11yRuleRegistry?.find(c=>c.id===t.rule);if(!o||typeof o.fix!="function")return;const r=x(e);o.fix(t);const i=x(e);M(n,{undo:()=>{e.isConnected&&O(e,r)},redo:()=>{e.isConnected&&O(e,i)}}),E(n)},U=(t,e,n,o)=>{if(!(t instanceof HTMLElement))return!1;const r=typeof n=="string"?n:t.innerHTML;if(e===r)return!1;const i=h(t),c=i.undoStack[i.undoStack.length-1];if(c&&c.beforeHTML===e&&c.afterHTML===r)return!1;const d=Date.now(),s=o?.selectionCollapsed===!1?null:W(o?.inputType),g=s==="insert"&&typeof o?.data=="string"&&/\s/.test(o.data);if(s&&c&&c.group===s&&!c.closed&&c.afterHTML===e&&d-(c.updatedAt??0)<=X&&d-(c.startedAt??0)<=B)return c.afterHTML=r,c.updatedAt=d,g&&(c.closed=!0),i.redoStack.length=0,u=t,!0;const l={beforeHTML:c&&c.afterHTML===e?c.afterHTML:e,afterHTML:r,group:s??void 0,startedAt:d,updatedAt:d,closed:g,undo:()=>{t.isConnected&&(t.innerHTML=l.beforeHTML,k(t,l.beforeHTML,l.afterHTML,"undo"))},redo:()=>{t.isConnected&&(t.innerHTML=l.afterHTML,k(t,l.beforeHTML,l.afterHTML,"redo"))}};return M(t,l),!0},w=t=>{const e=N(t,"undo");if(!e)return!1;const n=h(e),o=n.undoStack.pop();return o?(o.undo(),n.redoStack.push(o),T(e),u=e,E(e),!0):!1},b=t=>{const e=N(t,"redo");if(!e)return!1;const n=h(e),o=n.redoStack.pop();return o?(o.redo(),n.undoStack.push(o),T(e),u=e,E(e),!0):!1};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",C,{once:!0}):C());const J=()=>(C(),{name:"history",toolbar:[{label:"Undo",command:"undo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.4 8H12c3.7 0 6.2 2 6.8 5.1.6 2.7-.4 5.6-2.3 6.8a1 1 0 0 1-1-1.8c1.1-.6 1.8-2.7 1.4-4.6-.5-2.1-2.1-3.5-4.9-3.5H6.4l3.3 3.3a1 1 0 1 1-1.4 1.4l-5-5a1 1 0 0 1 0-1.4l5-5a1 1 0 0 1 1.4 1.4L6.4 8Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-z"},{label:"Redo",command:"redo",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M17.6 10H12c-2.8 0-4.4 1.4-4.9 3.5-.4 2 .3 4 1.4 4.6a1 1 0 1 1-1 1.8c-2-1.2-2.9-4.1-2.3-6.8.6-3 3-5.1 6.8-5.1h5.6l-3.3-3.3a1 1 0 1 1 1.4-1.4l5 5a1 1 0 0 1 0 1.4l-5 5a1 1 0 0 1-1.4-1.4l3.3-3.3Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-y"}],commands:{undo:I,redo:F,setAttribute:P,setText:z,autoFixA11y:G,recordDomTransaction:U,undoDom:w,redoDom:b},keymap:{"Mod-z":"undo","Mod-Z":"undo","Mod-y":"redo","Mod-Y":"redo","Mod-Shift-z":"redo","Mod-Shift-Z":"redo"}});exports.HistoryPlugin=J;