@editora/plugins 1.0.9 → 1.0.10

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 (140) hide show
  1. package/README.md +5 -0
  2. package/dist/_commonjsHelpers-6763f629.js +1 -0
  3. package/dist/_commonjsHelpers-c5d32002.mjs +30 -0
  4. package/dist/a11y-checker.cjs.js +12 -12
  5. package/dist/a11y-checker.esm.js +98 -80
  6. package/dist/anchor.cjs.js +12 -12
  7. package/dist/anchor.esm.js +128 -115
  8. package/dist/anchoredPopover-33f1358d.mjs +109 -0
  9. package/dist/anchoredPopover-8151d535.js +1 -0
  10. package/dist/approval-workflow.cjs.js +40 -40
  11. package/dist/approval-workflow.esm.js +249 -208
  12. package/dist/background-color.cjs.js +2 -2
  13. package/dist/background-color.esm.js +68 -55
  14. package/dist/blockquote.esm.js +2 -1
  15. package/dist/blocks-library.cjs.js +45 -45
  16. package/dist/blocks-library.esm.js +245 -178
  17. package/dist/capitalization.esm.js +2 -1
  18. package/dist/checklist.cjs.js +1 -1
  19. package/dist/checklist.esm.js +82 -58
  20. package/dist/citations.cjs.js +37 -37
  21. package/dist/citations.esm.js +512 -439
  22. package/dist/clear-formatting.cjs.js +1 -1
  23. package/dist/clear-formatting.esm.js +33 -27
  24. package/dist/code-sample.cjs.js +14 -14
  25. package/dist/code-sample.esm.js +93 -82
  26. package/dist/code.cjs.js +32 -32
  27. package/dist/code.esm.js +653 -594
  28. package/dist/comments.cjs.js +6 -6
  29. package/dist/comments.esm.js +158 -116
  30. package/dist/conditional-content.cjs.js +90 -90
  31. package/dist/conditional-content.esm.js +432 -371
  32. package/dist/content-rules.cjs.js +7 -7
  33. package/dist/content-rules.esm.js +159 -105
  34. package/dist/data-binding.cjs.js +46 -46
  35. package/dist/data-binding.esm.js +368 -328
  36. package/dist/direction.esm.js +18 -9
  37. package/dist/doc-schema.cjs.js +29 -29
  38. package/dist/doc-schema.esm.js +308 -240
  39. package/dist/document-manager.cjs.js +1 -1
  40. package/dist/document-manager.esm.js +5 -4
  41. package/dist/documentManager-25b6203c.mjs +9122 -0
  42. package/dist/documentManager-b69e7054.js +17 -0
  43. package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +2 -1
  44. package/dist/embed-iframe.cjs.js +4 -4
  45. package/dist/embed-iframe.esm.js +81 -73
  46. package/dist/emojis.cjs.js +8 -8
  47. package/dist/emojis.esm.js +77 -65
  48. package/dist/enterprise.cjs.js +1 -1
  49. package/dist/enterprise.esm.js +56 -54
  50. package/dist/font-family.cjs.js +1 -1
  51. package/dist/font-family.esm.js +47 -39
  52. package/dist/font-size.cjs.js +1 -1
  53. package/dist/font-size.esm.js +53 -37
  54. package/dist/footnote.cjs.js +2 -2
  55. package/dist/footnote.esm.js +117 -76
  56. package/dist/history.cjs.js +1 -1
  57. package/dist/history.esm.js +92 -70
  58. package/dist/html2canvas.esm-09133e29.js +22 -0
  59. package/dist/{html2canvas.esm-BWVIUcAF.mjs → html2canvas.esm-1a1724a1.mjs} +225 -141
  60. package/dist/indent.cjs.js +1 -1
  61. package/dist/indent.esm.js +24 -12
  62. package/dist/index-656d224b.js +231 -0
  63. package/dist/index-6a8c48bb.js +1 -0
  64. package/dist/index-d027b7e2.mjs +16859 -0
  65. package/dist/{index-BFsKNTTj.mjs → index-f04538f2.mjs} +71 -70
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-730f2d98.mjs +5775 -0
  68. package/dist/index.es-dd40173b.js +18 -0
  69. package/dist/index.esm.js +128 -125
  70. package/dist/italic.cjs.js +1 -1
  71. package/dist/italic.esm.js +9 -8
  72. package/dist/jspdf.es.min-90db2c97.js +243 -0
  73. package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-c36a4fd8.mjs} +4682 -3658
  74. package/dist/line-height.cjs.js +1 -1
  75. package/dist/line-height.esm.js +24 -11
  76. package/dist/link.cjs.js +5 -5
  77. package/dist/link.esm.js +30 -24
  78. package/dist/list.cjs.js +1 -1
  79. package/dist/list.esm.js +25 -20
  80. package/dist/lite.cjs.js +1 -1
  81. package/dist/lite.esm.js +61 -59
  82. package/dist/math.cjs.js +21 -21
  83. package/dist/math.esm.js +146 -139
  84. package/dist/media-manager.cjs.js +38 -38
  85. package/dist/media-manager.esm.js +325 -308
  86. package/dist/mentions.cjs.js +9 -9
  87. package/dist/mentions.esm.js +286 -238
  88. package/dist/merge-tag.cjs.js +2 -2
  89. package/dist/merge-tag.esm.js +216 -177
  90. package/dist/page-break.cjs.js +2 -2
  91. package/dist/page-break.esm.js +49 -33
  92. package/dist/pii-redaction.cjs.js +19 -19
  93. package/dist/pii-redaction.esm.js +463 -393
  94. package/dist/preview.esm.js +10 -5
  95. package/dist/print.cjs.js +4 -4
  96. package/dist/print.esm.js +20 -17
  97. package/dist/{purify.es-DHhaBdbu.mjs → purify.es-35a15df8.mjs} +19 -9
  98. package/dist/{purify.es-T2a3nLiC.js → purify.es-a8d731c6.js} +1 -1
  99. package/dist/slash-commands.cjs.js +3 -3
  100. package/dist/slash-commands.esm.js +212 -176
  101. package/dist/smart-paste.cjs.js +27 -27
  102. package/dist/smart-paste.esm.js +336 -280
  103. package/dist/special-characters.cjs.js +7 -7
  104. package/dist/special-characters.esm.js +69 -61
  105. package/dist/spell-check.cjs.js +5 -5
  106. package/dist/spell-check.esm.js +123 -97
  107. package/dist/strikethrough.cjs.js +1 -1
  108. package/dist/strikethrough.esm.js +19 -14
  109. package/dist/style.css +1 -0
  110. package/dist/table.cjs.js +4 -4
  111. package/dist/table.esm.js +225 -191
  112. package/dist/template.cjs.js +11 -11
  113. package/dist/template.esm.js +153 -124
  114. package/dist/text-alignment.cjs.js +1 -1
  115. package/dist/text-alignment.esm.js +27 -21
  116. package/dist/text-color.cjs.js +3 -3
  117. package/dist/text-color.esm.js +87 -70
  118. package/dist/track-changes.cjs.js +2 -2
  119. package/dist/track-changes.esm.js +162 -100
  120. package/dist/translation-workflow.cjs.js +74 -74
  121. package/dist/translation-workflow.esm.js +678 -602
  122. package/dist/version-diff.cjs.js +14 -14
  123. package/dist/version-diff.esm.js +157 -128
  124. package/package.json +13 -7
  125. package/LICENSE +0 -21
  126. package/dist/_commonjsHelpers-BH3jXuIh.js +0 -1
  127. package/dist/_commonjsHelpers-ByX85dGu.mjs +0 -33
  128. package/dist/anchoredPopover-BzqGPOAE.js +0 -1
  129. package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
  130. package/dist/documentManager-CTqRftU8.mjs +0 -8369
  131. package/dist/documentManager-Jf0RbSks.js +0 -17
  132. package/dist/html2canvas.esm-B5qzocYs.js +0 -5
  133. package/dist/index-CvJk4DKa.js +0 -221
  134. package/dist/index-D3CycEFU.mjs +0 -16543
  135. package/dist/index-tqLTHcO6.js +0 -1
  136. package/dist/index.es-CE_A4QSm.js +0 -5
  137. package/dist/index.es-DQ78mYYo.mjs +0 -6665
  138. package/dist/jspdf.es.min-BoS80556.js +0 -77
  139. package/dist/plugins.css +0 -1
  140. /package/dist/{editorContainerHelpers-CFbfiOJI.js → editorContainerHelpers-36b8ddf3.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  const a = ["P", "DIV", "H1", "H2", "H3", "H4", "H5", "H6", "LI", "BLOCKQUOTE", "PRE", "TD", "TH"];
2
- function d(n) {
2
+ function f(n) {
3
3
  let t = n;
4
4
  if (t.nodeType === Node.ELEMENT_NODE) {
5
5
  const e = t;
@@ -18,9 +18,10 @@ function d(n) {
18
18
  }
19
19
  return null;
20
20
  }
21
- function g(n) {
22
- const t = [], e = d(n.startContainer), i = d(n.endContainer);
23
- if (!e && !i) return t;
21
+ function h(n) {
22
+ const t = [], e = f(n.startContainer), i = f(n.endContainer);
23
+ if (!e && !i)
24
+ return t;
24
25
  if (n.collapsed)
25
26
  return e && t.push(e), t;
26
27
  if (e === i)
@@ -37,18 +38,20 @@ function g(n) {
37
38
  }
38
39
  r = r.nextElementSibling;
39
40
  }
40
- if (!r) break;
41
+ if (!r)
42
+ break;
41
43
  }
42
44
  i && !t.includes(i) && t.push(i);
43
45
  }
44
46
  return t;
45
47
  }
46
- function h(n) {
48
+ function E(n) {
47
49
  const t = n.commonAncestorContainer.nodeType === Node.ELEMENT_NODE ? n.commonAncestorContainer : n.commonAncestorContainer.parentElement;
48
50
  return t ? t.closest(".rte-content, .editora-content") || t.closest('[contenteditable="true"]') : null;
49
51
  }
50
- function f(n, t) {
51
- if (!n || t === n.innerHTML) return;
52
+ function m(n, t) {
53
+ if (!n || t === n.innerHTML)
54
+ return;
52
55
  const e = window.execEditorCommand || window.executeEditorCommand;
53
56
  if (typeof e == "function")
54
57
  try {
@@ -56,30 +59,33 @@ function f(n, t) {
56
59
  } catch {
57
60
  }
58
61
  }
59
- const E = (n) => {
60
- if (!n || !["left", "center", "right", "justify"].includes(n)) return !1;
62
+ const p = (n) => {
63
+ var u;
64
+ if (!n || !["left", "center", "right", "justify"].includes(n))
65
+ return !1;
61
66
  const e = window.getSelection();
62
- if (!e || e.rangeCount === 0) return !1;
63
- const i = e.getRangeAt(0).cloneRange(), o = h(i), s = o?.innerHTML || "", r = g(i);
67
+ if (!e || e.rangeCount === 0)
68
+ return !1;
69
+ const i = e.getRangeAt(0).cloneRange(), o = E(i), s = (o == null ? void 0 : o.innerHTML) || "", r = h(i);
64
70
  if (r.length > 0)
65
71
  r.forEach((l) => {
66
72
  l && (l.style.textAlign = n);
67
- }), e.removeAllRanges(), e.addRange(i), f(o, s), o && o.dispatchEvent(new Event("input", { bubbles: !0 }));
73
+ }), e.removeAllRanges(), e.addRange(i), m(o, s), o && o.dispatchEvent(new Event("input", { bubbles: !0 }));
68
74
  else
69
75
  try {
70
76
  const l = document.createElement("div");
71
77
  l.style.textAlign = n;
72
- const m = i.extractContents();
73
- l.appendChild(m), i.insertNode(l);
74
- const u = document.createRange();
75
- u.selectNodeContents(l), e.removeAllRanges(), e.addRange(u);
78
+ const g = i.extractContents();
79
+ l.appendChild(g), i.insertNode(l);
80
+ const d = document.createRange();
81
+ d.selectNodeContents(l), e.removeAllRanges(), e.addRange(d);
76
82
  const c = l.closest(".rte-content, .editora-content") || l.closest('[contenteditable="true"]');
77
- f(c || o, s), (c || o) && (c || o)?.dispatchEvent(new Event("input", { bubbles: !0 }));
83
+ m(c || o, s), (c || o) && ((u = c || o) == null || u.dispatchEvent(new Event("input", { bubbles: !0 })));
78
84
  } catch (l) {
79
85
  return console.error("Failed to wrap content for alignment:", l), !1;
80
86
  }
81
87
  return !0;
82
- }, p = () => ({
88
+ }, b = () => ({
83
89
  name: "textAlignment",
84
90
  toolbar: [
85
91
  {
@@ -96,10 +102,10 @@ const E = (n) => {
96
102
  }
97
103
  ],
98
104
  commands: {
99
- setTextAlignment: E
105
+ setTextAlignment: p
100
106
  },
101
107
  keymap: {}
102
108
  });
103
109
  export {
104
- p as TextAlignmentPlugin
110
+ b as TextAlignmentPlugin
105
111
  };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("./anchoredPopover-BzqGPOAE.js");let n=null,d=null,x=null,i="#000000";const u='[data-theme="dark"], .dark, .editora-theme-dark',w=["#000000","#ffffff","#808080","#ff0000","#00ff00","#0000ff","#ffff00","#ff00ff","#00ffff","#ffa500","#800080","#ffc0cb"];function y(){const e=window.getSelection();if(e&&e.rangeCount>0){const c=e.getRangeAt(0).startContainer,l=c.nodeType===Node.ELEMENT_NODE?c:c.parentElement;if(l){const r=l.closest('[data-editora-editor="true"], .rte-editor, .editora-editor');if(r)return r}}const o=document.activeElement;return o?o.closest('[data-editora-editor="true"], .rte-editor, .editora-editor'):null}function C(e){const o=window.__editoraLastCommand,t=window.__editoraLastCommandButton;if(o===e&&t&&t.isConnected){const a=window.getComputedStyle(t),s=t.getBoundingClientRect();if(a.display!=="none"&&a.visibility!=="hidden"&&a.pointerEvents!=="none"&&!(s.width===0&&s.height===0))return t}const c=a=>{for(const s of a){const b=window.getComputedStyle(s),h=s.getBoundingClientRect();if(!(b.display==="none"||b.visibility==="hidden"||b.pointerEvents==="none")&&!(h.width===0&&h.height===0))return s}return null},l=y();if(l){const a=Array.from(l.querySelectorAll(`[data-command="${e}"]`)),s=c(a);if(s)return s}const r=Array.from(document.querySelectorAll(`[data-command="${e}"]`));return c(r)}function E(e){if(e?.closest(u))return!0;const o=window.getSelection();if(o&&o.rangeCount>0){const c=o.getRangeAt(0).startContainer;if((c.nodeType===Node.ELEMENT_NODE?c:c.parentElement)?.closest(u))return!0}return document.activeElement?.closest(u)?!0:document.body.matches(u)||document.documentElement.matches(u)}function f(e){return k.applyColorToSelection({color:e,className:"rte-text-color",styleProperty:"color",commands:["foreColor"],savedRange:x,getActiveEditorRoot:y,warnMessage:"[TextColor] Could not apply color for current selection"})}function S(){const e=window.getSelection();if(!e||e.rangeCount===0)return"#000000";let t=e.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const c=t,l=c.style.color||window.getComputedStyle(c).color;if(l&&l!=="rgb(0, 0, 0)")return T(l)}t=t.parentNode}return"#000000"}function T(e){if(e.startsWith("#"))return e;const o=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(!o)return"#000000";const t=parseInt(o[1]),c=parseInt(o[2]),l=parseInt(o[3]);return"#"+[t,c,l].map(r=>{const a=r.toString(16);return a.length===1?"0"+a:a}).join("")}function A(e){const o=window.getSelection();o&&o.rangeCount>0&&(x=o.getRangeAt(0).cloneRange()),i=S(),n=document.createElement("div"),n.className="rte-inline-color-picker",E(e)&&n.classList.add("rte-theme-dark"),n.addEventListener("click",t=>t.stopPropagation()),n.innerHTML=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("./anchoredPopover-8151d535.js");let l=null,d=null,x=null,i="#000000";const u='[data-theme="dark"], .dark, .editora-theme-dark',w=["#000000","#ffffff","#808080","#ff0000","#00ff00","#0000ff","#ffff00","#ff00ff","#00ffff","#ffa500","#800080","#ffc0cb"];function v(){const e=window.getSelection();if(e&&e.rangeCount>0){const c=e.getRangeAt(0).startContainer,n=c.nodeType===Node.ELEMENT_NODE?c:c.parentElement;if(n){const r=n.closest('[data-editora-editor="true"], .rte-editor, .editora-editor');if(r)return r}}const o=document.activeElement;return o?o.closest('[data-editora-editor="true"], .rte-editor, .editora-editor'):null}function C(e){const o=window.__editoraLastCommand,t=window.__editoraLastCommandButton;if(o===e&&t&&t.isConnected){const a=window.getComputedStyle(t),s=t.getBoundingClientRect();if(a.display!=="none"&&a.visibility!=="hidden"&&a.pointerEvents!=="none"&&!(s.width===0&&s.height===0))return t}const c=a=>{for(const s of a){const b=window.getComputedStyle(s),h=s.getBoundingClientRect();if(!(b.display==="none"||b.visibility==="hidden"||b.pointerEvents==="none")&&!(h.width===0&&h.height===0))return s}return null},n=v();if(n){const a=Array.from(n.querySelectorAll(`[data-command="${e}"]`)),s=c(a);if(s)return s}const r=Array.from(document.querySelectorAll(`[data-command="${e}"]`));return c(r)}function E(e){if(e!=null&&e.closest(u))return!0;const o=window.getSelection();if(o&&o.rangeCount>0){const c=o.getRangeAt(0).startContainer,n=c.nodeType===Node.ELEMENT_NODE?c:c.parentElement;if(n!=null&&n.closest(u))return!0}const t=document.activeElement;return t!=null&&t.closest(u)?!0:document.body.matches(u)||document.documentElement.matches(u)}function f(e){return y.applyColorToSelection({color:e,className:"rte-text-color",styleProperty:"color",commands:["foreColor"],savedRange:x,getActiveEditorRoot:v,warnMessage:"[TextColor] Could not apply color for current selection"})}function S(){const e=window.getSelection();if(!e||e.rangeCount===0)return"#000000";let t=e.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const c=t,n=c.style.color||window.getComputedStyle(c).color;if(n&&n!=="rgb(0, 0, 0)")return T(n)}t=t.parentNode}return"#000000"}function T(e){if(e.startsWith("#"))return e;const o=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(!o)return"#000000";const t=parseInt(o[1]),c=parseInt(o[2]),n=parseInt(o[3]);return"#"+[t,c,n].map(r=>{const a=r.toString(16);return a.length===1?"0"+a:a}).join("")}function A(e){const o=window.getSelection();o&&o.rangeCount>0&&(x=o.getRangeAt(0).cloneRange()),i=S(),l=document.createElement("div"),l.className="rte-inline-color-picker",E(e)&&l.classList.add("rte-theme-dark"),l.addEventListener("click",t=>t.stopPropagation()),l.innerHTML=`
2
2
  <div class="rte-color-picker-header">
3
3
  <span class="rte-color-picker-title">Text Color</span>
4
4
  <button class="rte-color-picker-close" aria-label="Close">×</button>
@@ -48,7 +48,7 @@
48
48
  </div>
49
49
  </div>
50
50
  </div>
51
- `,document.body.appendChild(n),d&&(d.destroy(),d=null),d=k.attachAnchoredPopover({popover:n,anchor:e,onClose:p,gap:4,margin:8,zIndex:1e4}),L()}function L(){if(!n)return;n.querySelector(".rte-color-picker-close")?.addEventListener("click",()=>p()),n.querySelectorAll(".rte-color-swatch").forEach(l=>{l.addEventListener("click",()=>{const r=l.getAttribute("data-color");r&&(i=r,f(r),p())})});const t=n.querySelector(".rte-color-input-native");t?.addEventListener("change",l=>{const r=l.target.value;i=r,f(r),p()});const c=n.querySelector(".rte-color-input-text");c?.addEventListener("change",l=>{const r=l.target.value;/^#[0-9A-Fa-f]{6}$/.test(r)&&(i=r,f(r),p())}),t?.addEventListener("input",l=>{const r=l.target.value;i=r,m(r),v(r),$(r)}),c?.addEventListener("input",l=>{const r=l.target.value;/^#[0-9A-Fa-f]{6}$/.test(r)&&(i=r,m(r),v(r),P(r))})}function m(e){if(!n)return;const o=n.querySelector(".rte-color-preview-box"),t=n.querySelector(".rte-color-preview-label");o&&(o.style.backgroundColor=e,o.style.border=e==="#ffffff"?"1px solid #ccc":"none"),t&&(t.textContent=e.toUpperCase())}function v(e){if(!n)return;n.querySelectorAll(".rte-color-swatch").forEach(t=>{t.getAttribute("data-color")===e?t.classList.add("selected"):t.classList.remove("selected")})}function P(e){if(!n)return;const o=n.querySelector(".rte-color-input-native");o&&(o.value=e)}function $(e){if(!n)return;const o=n.querySelector(".rte-color-input-text");o&&(o.value=e)}function p(){d&&(d.destroy(),d=null),n&&(n.remove(),n=null),x=null}function _(){if(g(),n)return p(),!0;const e=C("openTextColorPicker");return e?(A(e),!0):!1}function g(){if(!window.__textColorPluginInitialized&&(window.__textColorPluginInitialized=!0,!document.getElementById("text-color-plugin-styles"))){const e=document.createElement("style");e.id="text-color-plugin-styles",e.textContent=`
51
+ `,document.body.appendChild(l),d&&(d.destroy(),d=null),d=y.attachAnchoredPopover({popover:l,anchor:e,onClose:p,gap:4,margin:8,zIndex:1e4}),L()}function L(){if(!l)return;const e=l.querySelector(".rte-color-picker-close");e==null||e.addEventListener("click",()=>p()),l.querySelectorAll(".rte-color-swatch").forEach(n=>{n.addEventListener("click",()=>{const r=n.getAttribute("data-color");r&&(i=r,f(r),p())})});const t=l.querySelector(".rte-color-input-native");t==null||t.addEventListener("change",n=>{const r=n.target.value;i=r,f(r),p()});const c=l.querySelector(".rte-color-input-text");c==null||c.addEventListener("change",n=>{const r=n.target.value;/^#[0-9A-Fa-f]{6}$/.test(r)&&(i=r,f(r),p())}),t==null||t.addEventListener("input",n=>{const r=n.target.value;i=r,m(r),k(r),$(r)}),c==null||c.addEventListener("input",n=>{const r=n.target.value;/^#[0-9A-Fa-f]{6}$/.test(r)&&(i=r,m(r),k(r),P(r))})}function m(e){if(!l)return;const o=l.querySelector(".rte-color-preview-box"),t=l.querySelector(".rte-color-preview-label");o&&(o.style.backgroundColor=e,o.style.border=e==="#ffffff"?"1px solid #ccc":"none"),t&&(t.textContent=e.toUpperCase())}function k(e){if(!l)return;l.querySelectorAll(".rte-color-swatch").forEach(t=>{t.getAttribute("data-color")===e?t.classList.add("selected"):t.classList.remove("selected")})}function P(e){if(!l)return;const o=l.querySelector(".rte-color-input-native");o&&(o.value=e)}function $(e){if(!l)return;const o=l.querySelector(".rte-color-input-text");o&&(o.value=e)}function p(){d&&(d.destroy(),d=null),l&&(l.remove(),l=null),x=null}function _(){if(g(),l)return p(),!0;const e=C("openTextColorPicker");return e?(A(e),!0):!1}function g(){if(!window.__textColorPluginInitialized&&(window.__textColorPluginInitialized=!0,!document.getElementById("text-color-plugin-styles"))){const e=document.createElement("style");e.id="text-color-plugin-styles",e.textContent=`
52
52
  .rte-inline-color-picker {
53
53
  background: white;
54
54
  border-radius: 8px;
@@ -297,4 +297,4 @@
297
297
  .rte-inline-color-picker.rte-theme-dark .rte-color-input-text:focus {
298
298
  border-color: #58a6ff;
299
299
  }
300
- `,document.head.appendChild(e)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",g):setTimeout(g,100);const M=()=>({name:"textColor",marks:{textColor:{attrs:{color:{default:"#000000"}},parseDOM:[{tag:"span[style*=color]",getAttrs:e=>{const t=(e.getAttribute("style")||"").match(/color:\s*([^;]+)/);return t?{color:t[1]}:null}},{tag:"font[color]",getAttrs:e=>{const o=e.getAttribute("color");return o?{color:o}:null}}],toDOM:e=>["span",{style:`color: ${e.attrs?.color||"#000000"}`,class:"rte-text-color"},0]}},toolbar:[{label:"Text Color",command:"openTextColorPicker",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path class="tox-icon-text-color__color" d="M3 18h18v3H3z" fill="currentColor"></path><path d="M8.7 16h-.8a.5.5 0 0 1-.5-.6l2.7-9c.1-.3.3-.4.5-.4h2.8c.2 0 .4.1.5.4l2.7 9a.5.5 0 0 1-.5.6h-.8a.5.5 0 0 1-.4-.4l-.7-2.2c0-.3-.3-.4-.5-.4h-3.4c-.2 0-.4.1-.5.4l-.7 2.2c0 .3-.2.4-.4.4Zm2.6-7.6-.6 2a.5.5 0 0 0 .5.6h1.6a.5.5 0 0 0 .5-.6l-.6-2c0-.3-.3-.4-.5-.4h-.4c-.2 0-.4.1-.5.4Z"></path></g></svg>'}],commands:{openTextColorPicker:()=>_(),setTextColor:e=>e?f(e):!1},keymap:{}});exports.TextColorPlugin=M;
300
+ `,document.head.appendChild(e)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",g):setTimeout(g,100);const M=()=>({name:"textColor",marks:{textColor:{attrs:{color:{default:"#000000"}},parseDOM:[{tag:"span[style*=color]",getAttrs:e=>{const t=(e.getAttribute("style")||"").match(/color:\s*([^;]+)/);return t?{color:t[1]}:null}},{tag:"font[color]",getAttrs:e=>{const o=e.getAttribute("color");return o?{color:o}:null}}],toDOM:e=>{var o;return["span",{style:`color: ${((o=e.attrs)==null?void 0:o.color)||"#000000"}`,class:"rte-text-color"},0]}}},toolbar:[{label:"Text Color",command:"openTextColorPicker",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path class="tox-icon-text-color__color" d="M3 18h18v3H3z" fill="currentColor"></path><path d="M8.7 16h-.8a.5.5 0 0 1-.5-.6l2.7-9c.1-.3.3-.4.5-.4h2.8c.2 0 .4.1.5.4l2.7 9a.5.5 0 0 1-.5.6h-.8a.5.5 0 0 1-.4-.4l-.7-2.2c0-.3-.3-.4-.5-.4h-3.4c-.2 0-.4.1-.5.4l-.7 2.2c0 .3-.2.4-.4.4Zm2.6-7.6-.6 2a.5.5 0 0 0 .5.6h1.6a.5.5 0 0 0 .5-.6l-.6-2c0-.3-.3-.4-.5-.4h-.4c-.2 0-.4.1-.5.4Z"></path></g></svg>'}],commands:{openTextColorPicker:()=>_(),setTextColor:e=>e?f(e):!1},keymap:{}});exports.TextColorPlugin=M;
@@ -1,5 +1,5 @@
1
- import { a as y, b as w } from "./anchoredPopover-Dts0IrgU.mjs";
2
- let n = null, d = null, g = null, i = "#000000";
1
+ import { a as v, b as w } from "./anchoredPopover-33f1358d.mjs";
2
+ let l = null, d = null, x = null, i = "#000000";
3
3
  const u = '[data-theme="dark"], .dark, .editora-theme-dark', C = [
4
4
  "#000000",
5
5
  "#ffffff",
@@ -14,15 +14,16 @@ const u = '[data-theme="dark"], .dark, .editora-theme-dark', C = [
14
14
  "#800080",
15
15
  "#ffc0cb"
16
16
  ];
17
- function v() {
17
+ function y() {
18
18
  const e = window.getSelection();
19
19
  if (e && e.rangeCount > 0) {
20
- const c = e.getRangeAt(0).startContainer, l = c.nodeType === Node.ELEMENT_NODE ? c : c.parentElement;
21
- if (l) {
22
- const r = l.closest(
20
+ const c = e.getRangeAt(0).startContainer, n = c.nodeType === Node.ELEMENT_NODE ? c : c.parentElement;
21
+ if (n) {
22
+ const r = n.closest(
23
23
  '[data-editora-editor="true"], .rte-editor, .editora-editor'
24
24
  );
25
- if (r) return r;
25
+ if (r)
26
+ return r;
26
27
  }
27
28
  }
28
29
  const o = document.activeElement;
@@ -39,17 +40,18 @@ function E(e) {
39
40
  }
40
41
  const c = (a) => {
41
42
  for (const s of a) {
42
- const b = window.getComputedStyle(s), h = s.getBoundingClientRect();
43
- if (!(b.display === "none" || b.visibility === "hidden" || b.pointerEvents === "none") && !(h.width === 0 && h.height === 0))
43
+ const b = window.getComputedStyle(s), m = s.getBoundingClientRect();
44
+ if (!(b.display === "none" || b.visibility === "hidden" || b.pointerEvents === "none") && !(m.width === 0 && m.height === 0))
44
45
  return s;
45
46
  }
46
47
  return null;
47
- }, l = v();
48
- if (l) {
48
+ }, n = y();
49
+ if (n) {
49
50
  const a = Array.from(
50
- l.querySelectorAll(`[data-command="${e}"]`)
51
+ n.querySelectorAll(`[data-command="${e}"]`)
51
52
  ), s = c(a);
52
- if (s) return s;
53
+ if (s)
54
+ return s;
53
55
  }
54
56
  const r = Array.from(
55
57
  document.querySelectorAll(`[data-command="${e}"]`)
@@ -57,52 +59,58 @@ function E(e) {
57
59
  return c(r);
58
60
  }
59
61
  function S(e) {
60
- if (e?.closest(u)) return !0;
62
+ if (e != null && e.closest(u))
63
+ return !0;
61
64
  const o = window.getSelection();
62
65
  if (o && o.rangeCount > 0) {
63
- const c = o.getRangeAt(0).startContainer;
64
- if ((c.nodeType === Node.ELEMENT_NODE ? c : c.parentElement)?.closest(u)) return !0;
66
+ const c = o.getRangeAt(0).startContainer, n = c.nodeType === Node.ELEMENT_NODE ? c : c.parentElement;
67
+ if (n != null && n.closest(u))
68
+ return !0;
65
69
  }
66
- return document.activeElement?.closest(u) ? !0 : document.body.matches(u) || document.documentElement.matches(u);
70
+ const t = document.activeElement;
71
+ return t != null && t.closest(u) ? !0 : document.body.matches(u) || document.documentElement.matches(u);
67
72
  }
68
73
  function f(e) {
69
- return y({
74
+ return v({
70
75
  color: e,
71
76
  className: "rte-text-color",
72
77
  styleProperty: "color",
73
78
  commands: ["foreColor"],
74
- savedRange: g,
75
- getActiveEditorRoot: v,
79
+ savedRange: x,
80
+ getActiveEditorRoot: y,
76
81
  warnMessage: "[TextColor] Could not apply color for current selection"
77
82
  });
78
83
  }
79
84
  function T() {
80
85
  const e = window.getSelection();
81
- if (!e || e.rangeCount === 0) return "#000000";
86
+ if (!e || e.rangeCount === 0)
87
+ return "#000000";
82
88
  let t = e.getRangeAt(0).startContainer;
83
89
  for (; t && t !== document.body; ) {
84
90
  if (t.nodeType === Node.ELEMENT_NODE) {
85
- const c = t, l = c.style.color || window.getComputedStyle(c).color;
86
- if (l && l !== "rgb(0, 0, 0)")
87
- return A(l);
91
+ const c = t, n = c.style.color || window.getComputedStyle(c).color;
92
+ if (n && n !== "rgb(0, 0, 0)")
93
+ return A(n);
88
94
  }
89
95
  t = t.parentNode;
90
96
  }
91
97
  return "#000000";
92
98
  }
93
99
  function A(e) {
94
- if (e.startsWith("#")) return e;
100
+ if (e.startsWith("#"))
101
+ return e;
95
102
  const o = e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
96
- if (!o) return "#000000";
97
- const t = parseInt(o[1]), c = parseInt(o[2]), l = parseInt(o[3]);
98
- return "#" + [t, c, l].map((r) => {
103
+ if (!o)
104
+ return "#000000";
105
+ const t = parseInt(o[1]), c = parseInt(o[2]), n = parseInt(o[3]);
106
+ return "#" + [t, c, n].map((r) => {
99
107
  const a = r.toString(16);
100
108
  return a.length === 1 ? "0" + a : a;
101
109
  }).join("");
102
110
  }
103
111
  function L(e) {
104
112
  const o = window.getSelection();
105
- o && o.rangeCount > 0 && (g = o.getRangeAt(0).cloneRange()), i = T(), n = document.createElement("div"), n.className = "rte-inline-color-picker", S(e) && n.classList.add("rte-theme-dark"), n.addEventListener("click", (t) => t.stopPropagation()), n.innerHTML = `
113
+ o && o.rangeCount > 0 && (x = o.getRangeAt(0).cloneRange()), i = T(), l = document.createElement("div"), l.className = "rte-inline-color-picker", S(e) && l.classList.add("rte-theme-dark"), l.addEventListener("click", (t) => t.stopPropagation()), l.innerHTML = `
106
114
  <div class="rte-color-picker-header">
107
115
  <span class="rte-color-picker-title">Text Color</span>
108
116
  <button class="rte-color-picker-close" aria-label="Close">×</button>
@@ -152,8 +160,8 @@ function L(e) {
152
160
  </div>
153
161
  </div>
154
162
  </div>
155
- `, document.body.appendChild(n), d && (d.destroy(), d = null), d = w({
156
- popover: n,
163
+ `, document.body.appendChild(l), d && (d.destroy(), d = null), d = w({
164
+ popover: l,
157
165
  anchor: e,
158
166
  onClose: p,
159
167
  gap: 4,
@@ -162,61 +170,67 @@ function L(e) {
162
170
  }), P();
163
171
  }
164
172
  function P() {
165
- if (!n) return;
166
- n.querySelector(".rte-color-picker-close")?.addEventListener("click", () => p()), n.querySelectorAll(".rte-color-swatch").forEach((l) => {
167
- l.addEventListener("click", () => {
168
- const r = l.getAttribute("data-color");
173
+ if (!l)
174
+ return;
175
+ const e = l.querySelector(".rte-color-picker-close");
176
+ e == null || e.addEventListener("click", () => p()), l.querySelectorAll(".rte-color-swatch").forEach((n) => {
177
+ n.addEventListener("click", () => {
178
+ const r = n.getAttribute("data-color");
169
179
  r && (i = r, f(r), p());
170
180
  });
171
181
  });
172
- const t = n.querySelector(".rte-color-input-native");
173
- t?.addEventListener("change", (l) => {
174
- const r = l.target.value;
182
+ const t = l.querySelector(".rte-color-input-native");
183
+ t == null || t.addEventListener("change", (n) => {
184
+ const r = n.target.value;
175
185
  i = r, f(r), p();
176
186
  });
177
- const c = n.querySelector(".rte-color-input-text");
178
- c?.addEventListener("change", (l) => {
179
- const r = l.target.value;
187
+ const c = l.querySelector(".rte-color-input-text");
188
+ c == null || c.addEventListener("change", (n) => {
189
+ const r = n.target.value;
180
190
  /^#[0-9A-Fa-f]{6}$/.test(r) && (i = r, f(r), p());
181
- }), t?.addEventListener("input", (l) => {
182
- const r = l.target.value;
183
- i = r, m(r), k(r), _(r);
184
- }), c?.addEventListener("input", (l) => {
185
- const r = l.target.value;
186
- /^#[0-9A-Fa-f]{6}$/.test(r) && (i = r, m(r), k(r), $(r));
191
+ }), t == null || t.addEventListener("input", (n) => {
192
+ const r = n.target.value;
193
+ i = r, h(r), k(r), _(r);
194
+ }), c == null || c.addEventListener("input", (n) => {
195
+ const r = n.target.value;
196
+ /^#[0-9A-Fa-f]{6}$/.test(r) && (i = r, h(r), k(r), $(r));
187
197
  });
188
198
  }
189
- function m(e) {
190
- if (!n) return;
191
- const o = n.querySelector(".rte-color-preview-box"), t = n.querySelector(".rte-color-preview-label");
199
+ function h(e) {
200
+ if (!l)
201
+ return;
202
+ const o = l.querySelector(".rte-color-preview-box"), t = l.querySelector(".rte-color-preview-label");
192
203
  o && (o.style.backgroundColor = e, o.style.border = e === "#ffffff" ? "1px solid #ccc" : "none"), t && (t.textContent = e.toUpperCase());
193
204
  }
194
205
  function k(e) {
195
- if (!n) return;
196
- n.querySelectorAll(".rte-color-swatch").forEach((t) => {
206
+ if (!l)
207
+ return;
208
+ l.querySelectorAll(".rte-color-swatch").forEach((t) => {
197
209
  t.getAttribute("data-color") === e ? t.classList.add("selected") : t.classList.remove("selected");
198
210
  });
199
211
  }
200
212
  function $(e) {
201
- if (!n) return;
202
- const o = n.querySelector(".rte-color-input-native");
213
+ if (!l)
214
+ return;
215
+ const o = l.querySelector(".rte-color-input-native");
203
216
  o && (o.value = e);
204
217
  }
205
218
  function _(e) {
206
- if (!n) return;
207
- const o = n.querySelector(".rte-color-input-text");
219
+ if (!l)
220
+ return;
221
+ const o = l.querySelector(".rte-color-input-text");
208
222
  o && (o.value = e);
209
223
  }
210
224
  function p() {
211
- d && (d.destroy(), d = null), n && (n.remove(), n = null), g = null;
225
+ d && (d.destroy(), d = null), l && (l.remove(), l = null), x = null;
212
226
  }
213
227
  function R() {
214
- if (x(), n)
228
+ if (g(), l)
215
229
  return p(), !0;
216
230
  const e = E("openTextColorPicker");
217
231
  return e ? (L(e), !0) : !1;
218
232
  }
219
- function x() {
233
+ function g() {
220
234
  if (!window.__textColorPluginInitialized && (window.__textColorPluginInitialized = !0, !document.getElementById("text-color-plugin-styles"))) {
221
235
  const e = document.createElement("style");
222
236
  e.id = "text-color-plugin-styles", e.textContent = `
@@ -471,8 +485,8 @@ function x() {
471
485
  `, document.head.appendChild(e);
472
486
  }
473
487
  }
474
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", x) : setTimeout(x, 100);
475
- const N = () => ({
488
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", g) : setTimeout(g, 100);
489
+ const M = () => ({
476
490
  name: "textColor",
477
491
  marks: {
478
492
  textColor: {
@@ -495,14 +509,17 @@ const N = () => ({
495
509
  }
496
510
  }
497
511
  ],
498
- toDOM: (e) => [
499
- "span",
500
- {
501
- style: `color: ${e.attrs?.color || "#000000"}`,
502
- class: "rte-text-color"
503
- },
504
- 0
505
- ]
512
+ toDOM: (e) => {
513
+ var o;
514
+ return [
515
+ "span",
516
+ {
517
+ style: `color: ${((o = e.attrs) == null ? void 0 : o.color) || "#000000"}`,
518
+ class: "rte-text-color"
519
+ },
520
+ 0
521
+ ];
522
+ }
506
523
  }
507
524
  },
508
525
  toolbar: [
@@ -519,5 +536,5 @@ const N = () => ({
519
536
  keymap: {}
520
537
  });
521
538
  export {
522
- N as TextColorPlugin
539
+ M as TextColorPlugin
523
540
  };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=".rte-content, .editora-content",g='.rte-track-insert[data-track-change="insert"]',f='.rte-track-delete[data-track-change="delete"]',x=`${g}, ${f}`,H="__editoraCommandEditorRoot",B=new WeakMap,N=new WeakMap,L=new WeakMap,D=new Set;let q=!1,h=null,j=!1,T={},F=!1;const J=typeof InputEvent<"u"&&typeof InputEvent.prototype=="object"&&"inputType"in InputEvent.prototype,Q=new Set(["IMG","TABLE","VIDEO","AUDIO","SVG","MATH","HR","IFRAME","INPUT","TEXTAREA","SELECT","BUTTON","CANVAS"]);function ee(e){if(!e)return null;const t=e.querySelector('[contenteditable="true"]');return t instanceof HTMLElement?t:null}function te(){if(typeof window>"u")return null;const e=window[H];if(!(e instanceof HTMLElement))return null;window[H]=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 r=ee(t);if(r)return r;if(t.getAttribute("contenteditable")==="true")return t}if(e.getAttribute("contenteditable")==="true")return e;const n=e.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null}function ne(e){if(e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const o=e.editorElement;if(o.getAttribute("contenteditable")==="true")return o;const a=o.querySelector('[contenteditable="true"]');if(a instanceof HTMLElement)return a}const t=te();if(t&&document.contains(t))return t;const n=window.getSelection();if(n&&n.rangeCount>0){const o=n.getRangeAt(0).startContainer,c=(o.nodeType===Node.ELEMENT_NODE?o:o.parentElement)?.closest(p);if(c)return c}const r=document.activeElement;if(r){if(r.matches(p))return r;const o=r.closest(p);if(o)return o}return h?.isConnected?h:document.querySelector(p)}function w(e,t){k(e),_(e);let n=B.get(e);return n||(n={enabled:!!t.enabledByDefault,author:t.author?.trim()||"system",includeTimestamp:t.includeTimestamp!==!1},B.set(e,n),n.enabled&&(M(e,n),y(e,n.enabled))),S(e,"toggleTrackChanges",n.enabled),n}function y(e,t){e.classList.toggle("rte-track-changes-enabled",t),t?e.setAttribute("data-track-changes","true"):e.removeAttribute("data-track-changes")}function re(e){return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||e}function S(e,t,n){const r=re(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(a=>{a.classList.toggle("active",n),a.setAttribute("data-active",n?"true":"false"),a.setAttribute("aria-pressed",n?"true":"false"),a.setAttribute("title",n?"Track Changes (On)":"Track Changes (Off)")})}function ae(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function oe(e,t){if(t===e.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",e,t,e.innerHTML)}catch{}}function m(e,t){ae(e),oe(e,t)}function ce(e,t){return e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset}function G(e){return{author:e.author,timestamp:e.includeTimestamp?new Date().toISOString():""}}function se(e,t){const n=document.createElement("span");n.className="rte-track-insert",n.setAttribute("data-track-change","insert"),n.setAttribute("contenteditable","false");const r=G(t);return n.setAttribute("data-track-author",r.author),r.timestamp&&n.setAttribute("data-track-time",r.timestamp),n.appendChild(document.createTextNode(e)),n}function k(e){Array.from(e.querySelectorAll(g)).forEach(n=>{n.setAttribute("contenteditable","false")})}function E(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function le(e,t){const n=e.startContainer,r=e.startOffset;if(n.nodeType===Node.TEXT_NODE){const o=n,a=o.previousSibling||o.nextSibling;if(a instanceof HTMLElement&&a.matches(g)&&t.contains(a))return a}if(n.nodeType===Node.ELEMENT_NODE){const o=n,a=o.childNodes[r-1];if(a instanceof HTMLElement&&a.matches(g)&&t.contains(a))return a;const c=o.childNodes[r];if(c instanceof HTMLElement&&c.matches(g)&&t.contains(c))return c}return null}function P(e,t,n){const r=t.lastChild;r&&r.nodeType===Node.TEXT_NODE?r.data+=n:t.appendChild(document.createTextNode(n)),C(e,t)}function ie(e,t){const n=document.createElement("span");n.className="rte-track-delete",n.setAttribute("data-track-change","delete"),n.setAttribute("contenteditable","false");const r=G(t);return n.setAttribute("data-track-author",r.author),r.timestamp&&n.setAttribute("data-track-time",r.timestamp),n.appendChild(e),n}function b(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return e.contains(n.commonAncestorContainer)?n:null}function ue(){F||typeof document>"u"||(F=!0,document.addEventListener("selectionchange",()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=e.getRangeAt(0),r=E(t.startContainer)?.closest(p)||null;r&&(L.set(r,t.cloneRange()),h=r)},!0))}function C(e,t){if(!t.parentNode){e.focus({preventScroll:!0});return}const n=window.getSelection();if(!n)return;const r=document.createRange();r.setStartAfter(t),r.collapse(!0),n.removeAllRanges(),n.addRange(r),e.focus({preventScroll:!0})}function O(e,t){if(!t.parentNode){e.focus({preventScroll:!0});return}const n=window.getSelection();if(!n)return;const r=document.createRange();r.setStartBefore(t),r.collapse(!0),n.removeAllRanges(),n.addRange(r),e.focus({preventScroll:!0})}function de(e,t,n){const r=window.getSelection();if(!r)return;const o=document.createRange();o.setStart(t,Math.max(0,n)),o.collapse(!0),r.removeAllRanges(),r.addRange(o),e.focus({preventScroll:!0})}function V(e){let t=b(e);if(!t){const c=L.get(e);c&&e.contains(c.commonAncestorContainer)&&(t=c.cloneRange())}if(!t||!t.collapsed)return;const n=E(t.startContainer);if(!n)return;const r=n.closest(g);if(!r||!e.contains(r)||!r.parentNode)return;const o=window.getSelection();if(!o)return;const a=document.createRange();a.setStartAfter(r),a.collapse(!0),o.removeAllRanges(),o.addRange(a),e.focus({preventScroll:!0})}function K(e,t){const n=e.innerHTML;k(e),V(e),e.focus({preventScroll:!0});const r=t==="insertLineBreak"?"insertLineBreak":"insertParagraph",o=document.execCommand(r,!1);return k(e),m(e,n),o!==!1}function fe(e){const t=b(e);if(t&&t.collapsed)return t;const n=L.get(e);return n&&n.collapsed&&e.contains(n.commonAncestorContainer)?n.cloneRange():null}function ge(e){return e.matches(g)||e.matches(f)?(e.textContent||"").replace(/\u200B/g,"").trim().length>0:Q.has(e.tagName)}function W(e,t){if(t!=="insertParagraph")return!1;const n=fe(e);if(!n)return!1;const r=E(n.startContainer);if(!r)return!1;const o=r.closest("li");return!(o instanceof HTMLElement)||!e.contains(o)||(o.textContent||"").replace(/\u200B/g,"").trim().length>0?!1:!Array.from(o.querySelectorAll("*")).some(s=>ge(s))}function me(e){const t=document.createRange(),n=window.getSelection();if(n&&n.rangeCount>0){const r=n.getRangeAt(0);if(e.contains(r.commonAncestorContainer))return t.setStart(r.endContainer,r.endOffset),t.collapse(!0),t}return t.selectNodeContents(e),t.collapse(!1),t}function he(e){return(e.textContent||"").length>0?!0:Array.from(e.childNodes).some(n=>{if(n.nodeType!==Node.ELEMENT_NODE)return!1;const r=n;return["BR","IMG","TABLE","VIDEO","AUDIO","SVG","MATH"].includes(r.tagName)})}function pe(e){return Array.from(e.childNodes).some(t=>{if(t.nodeType===Node.TEXT_NODE)return(t.textContent||"").length>0;if(t.nodeType!==Node.ELEMENT_NODE)return!1;const n=t;return["BR","IMG","TABLE","VIDEO","AUDIO","SVG","MATH"].includes(n.tagName)})}function Ee(e,t,n){if(!e.collapsed)return null;const r=e.startContainer,o=e.startOffset;let a=null;if(r.nodeType===Node.TEXT_NODE){const c=r;t==="backward"&&o===0?a=c.previousSibling:t==="forward"&&o===c.length&&(a=c.nextSibling)}else if(r.nodeType===Node.ELEMENT_NODE){const c=r;t==="backward"&&o>0?a=c.childNodes[o-1]||null:t==="forward"&&o<c.childNodes.length&&(a=c.childNodes[o]||null)}return!(a instanceof HTMLElement)||!a.matches(g)||!n.contains(a)?null:a}function ke(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=[];let o=n.nextNode();for(;o;){const a=o;a.data.length>0&&r.push(a),o=n.nextNode()}return r.length===0?null:t?r[r.length-1]:r[0]}function Te(e,t,n){const r=Ee(t,n,e);return r?v(e,r,n):!1}function v(e,t,n){const r=t.parentNode;if(!r)return!1;const o=Array.prototype.indexOf.call(r.childNodes,t),a=ke(t,n==="backward");return a?(n==="backward"?a.data=a.data.slice(0,-1):a.data=a.data.slice(1),a.data.length===0&&a.remove(),pe(t)?(n==="backward"?C(e,t):O(e,t),!0):(t.remove(),de(e,r,o),!0)):!1}function Z(e){if(e.startContainer!==e.endContainer||e.startContainer.nodeType!==Node.ELEMENT_NODE)return null;const t=e.startContainer;return e.endOffset-e.startOffset!==1?null:t.childNodes[e.startOffset]||null}function I(e,t){const n=Z(e);return!(n instanceof HTMLElement)||!n.matches(f)||!t.contains(n)?null:n}function be(e,t){const n=Z(e);return!(n instanceof HTMLElement)||!n.matches(g)||!t.contains(n)?null:n}function Ce(e,t){if(t.collapsed){const c=E(t.startContainer)?.closest(f);if(c&&e.contains(c)){const s=document.createRange();return s.setStartAfter(c),s.collapse(!0),s}return t}const n=I(t,e);if(n){const a=document.createRange();return a.setStartAfter(n),a.collapse(!0),a}const r=E(t.startContainer)?.closest(f),o=E(t.endContainer)?.closest(f);if(r&&o&&r===o&&e.contains(r)){const a=document.createRange();return a.setStartAfter(r),a.collapse(!0),a}return t}function Ae(e,t){const r=Array.from(t.querySelectorAll(g)).filter(s=>{try{return e.intersectsNode(s)}catch{return!1}});if(r.length!==1)return null;const o=r[0],a=(e.toString()||"").replace(/\s+/g,""),c=(o.textContent||"").replace(/\s+/g,"");return!c||a!==c?null:o}function U(e,t,n){if(t.collapsed)return null;const r=t.cloneContents();if(!he(r))return null;const o=ie(r,n);return t.deleteContents(),t.insertNode(o),C(e,o),o}function Ne(e,t,n){if(!t.collapsed)return t;const r=t.startContainer,o=t.startOffset;if(r.nodeType===Node.TEXT_NODE){const s=r;if(n==="backward"&&o>0){const l=t.cloneRange();return l.setStart(s,o-1),l}if(n==="forward"&&o<s.length){const l=t.cloneRange();return l.setEnd(s,o+1),l}}if(r.nodeType===Node.ELEMENT_NODE){const s=r;if(n==="backward"&&o>0)for(let l=o-1;l>=0;l-=1){const i=s.childNodes[l];if(!i||i instanceof HTMLElement&&i.matches(f))continue;const u=t.cloneRange();if(i.nodeType===Node.TEXT_NODE){const d=i;if(d.length===0)continue;u.setStart(d,d.length-1),u.setEnd(d,d.length)}else u.setStartBefore(i),u.setEndAfter(i);return u}if(n==="forward"&&o<s.childNodes.length)for(let l=o;l<s.childNodes.length;l+=1){const i=s.childNodes[l];if(!i||i instanceof HTMLElement&&i.matches(f))continue;const u=t.cloneRange();if(i.nodeType===Node.TEXT_NODE){const d=i;if(d.length===0)continue;u.setStart(d,0),u.setEnd(d,1)}else u.setStartBefore(i),u.setEndAfter(i);return u}}const a=window.getSelection();if(!a||typeof a.modify!="function")return null;const c=t.cloneRange();a.removeAllRanges(),a.addRange(c);try{if(a.modify("extend",n,"character"),a.rangeCount===0)return null;const s=a.getRangeAt(0).cloneRange();if(s.collapsed||!e.contains(s.commonAncestorContainer))return null;const l=I(s,e);return l?(n==="backward"?O(e,l):C(e,l),null):s}catch{return null}finally{a.removeAllRanges(),a.addRange(c)}}function z(e,t,n){let r=b(e);if(!r)return!1;const o=Ce(e,r.cloneRange());if(!ce(o,r)){const d=window.getSelection();d&&(d.removeAllRanges(),d.addRange(o)),r=o}const a=e.innerHTML;r.collapsed||U(e,r.cloneRange(),t);const s=E(r.startContainer)?.closest(g);if(r.collapsed&&s&&e.contains(s))return P(e,s,n),m(e,a),!0;const l=r.collapsed?le(r,e):null;if(l)return P(e,l,n),m(e,a),!0;const i=me(e),u=se(n,t);return i.insertNode(u),C(e,u),m(e,a),!0}function $(e,t,n){const r=b(e);if(!r)return!1;const o=n.includes("Backward")?"backward":"forward",a=e.innerHTML;if(r.collapsed&&Te(e,r.cloneRange(),o))return m(e,a),!0;const c=be(r,e);if(c&&v(e,c,o))return m(e,a),!0;if(!r.collapsed){const u=Ae(r,e);if(u&&v(e,u,o))return m(e,a),!0}const s=r.collapsed?Ne(e,r.cloneRange(),o):r.cloneRange();if(!s)return!1;const l=I(s,e);return l?(o==="backward"?O(e,l):C(e,l),!0):U(e,s,t)?(_(e),m(e,a),!0):!1}function R(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function _(e){Array.from(e.querySelectorAll(f)).forEach(r=>{r.setAttribute("contenteditable","false"),Array.from(r.querySelectorAll(f)).forEach(a=>{a!==r&&R(a)})});let n=!0;for(;n;)n=!1,Array.from(e.querySelectorAll(f)).forEach(o=>{if(!o.isConnected)return;let a=o.nextSibling;for(;a&&a.nodeType===Node.TEXT_NODE&&!(a.textContent||"").trim();)a=a.nextSibling;if(a instanceof HTMLElement&&a.matches(f)){for(;a.firstChild;)o.appendChild(a.firstChild);a.remove(),n=!0}o.firstChild||(o.remove(),n=!0)})}function Y(e){return Array.from(e.querySelectorAll(x))}function ye(e){const t=b(e);if(!t)return[];const n=new Set,r=t.startContainer.nodeType===Node.ELEMENT_NODE?t.startContainer:t.startContainer.parentElement,o=t.endContainer.nodeType===Node.ELEMENT_NODE?t.endContainer:t.endContainer.parentElement,a=r?.closest(x);a&&e.contains(a)&&n.add(a);const c=o?.closest(x);return c&&e.contains(c)&&n.add(c),Y(e).filter(l=>{try{return t.intersectsNode(l)}catch{return!1}}).forEach(l=>n.add(l)),Array.from(n)}function A(e,t,n){const r=n==="all"?Y(e):ye(e);if(r.length===0)return!1;const o=e.innerHTML;return r.forEach(a=>{if(!a.isConnected)return;const c=a.matches(g),s=a.matches(f);if(!(!c&&!s)){if(t==="accept"){c?R(a):a.remove();return}c?a.remove():(a.removeAttribute("contenteditable"),R(a))}}),_(e),m(e,o),!0}function Se(e){return e instanceof Node&&(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(p)||null}function Me(){j||typeof document>"u"||(j=!0,document.addEventListener("focusin",e=>{if(!T.enabledByDefault)return;const t=Se(e.target);if(!t)return;h=t;const n=w(t,T);n.enabled?(M(t,n),y(t,!0),S(t,"toggleTrackChanges",!0)):k(t)},!0))}function xe(e,t){return n=>{if(!t.enabled||e.getAttribute("data-track-changes")!=="true")return;h=e;const r=n.inputType||"";if(r==="insertParagraph"||r==="insertLineBreak"){if(W(e,r))return;n.preventDefault(),K(e,r);return}if(r.startsWith("delete")){n.preventDefault(),$(e,t,r);return}if(r==="insertText"||r==="insertCompositionText"){const o=n.data||"";if(!o)return;n.preventDefault(),z(e,t,o)}}}function we(e,t){return n=>{if(!t.enabled||e.getAttribute("data-track-changes")!=="true"||n.key!=="Enter"||J)return;const r=n.shiftKey?"insertLineBreak":"insertParagraph";W(e,r)||(h=e,n.preventDefault(),n.stopPropagation(),K(e,r))}}function ve(e,t){return n=>{if(n.__editoraSmartPasteHandled===!0||n.defaultPrevented||!t.enabled||e.getAttribute("data-track-changes")!=="true")return;const r=n.clipboardData?.getData("text/plain")||"";r&&(n.preventDefault(),h=e,z(e,t,r))}}function Re(e,t){return n=>{if(!t.enabled||e.getAttribute("data-track-changes")!=="true")return;const r=b(e);if(!r||r.collapsed)return;const o=r.toString();n.clipboardData&&(n.clipboardData.setData("text/plain",o),n.preventDefault()),h=e,$(e,t,"deleteByCut")}}function M(e,t){if(N.has(e))return;k(e);const n={beforeInput:xe(e,t),keydown:we(e,t),paste:ve(e,t),cut:Re(e,t)};e.addEventListener("beforeinput",n.beforeInput),e.addEventListener("keydown",n.keydown),e.addEventListener("paste",n.paste),e.addEventListener("cut",n.cut),N.set(e,n),D.add(e)}function X(e){const t=N.get(e);t&&(e.removeEventListener("beforeinput",t.beforeInput),e.removeEventListener("keydown",t.keydown),e.removeEventListener("paste",t.paste),e.removeEventListener("cut",t.cut),N.delete(e),D.delete(e))}function Le(){if(q||typeof document>"u")return;q=!0;const e=document.createElement("style");e.id="rte-track-changes-styles",e.textContent=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=".rte-content, .editora-content",g='.rte-track-insert[data-track-change="insert"]',f='.rte-track-delete[data-track-change="delete"]',w=`${g}, ${f}`,H="__editoraCommandEditorRoot",B=new WeakMap,N=new WeakMap,L=new WeakMap,D=new Set;let q=!1,h=null,j=!1,T={},F=!1;const J=typeof InputEvent<"u"&&typeof InputEvent.prototype=="object"&&"inputType"in InputEvent.prototype,Q=new Set(["IMG","TABLE","VIDEO","AUDIO","SVG","MATH","HR","IFRAME","INPUT","TEXTAREA","SELECT","BUTTON","CANVAS"]);function ee(e){if(!e)return null;const t=e.querySelector('[contenteditable="true"]');return t instanceof HTMLElement?t:null}function te(){if(typeof window>"u")return null;const e=window[H];if(!(e instanceof HTMLElement))return null;window[H]=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 r=ee(t);if(r)return r;if(t.getAttribute("contenteditable")==="true")return t}if(e.getAttribute("contenteditable")==="true")return e;const n=e.closest('[contenteditable="true"]');return n instanceof HTMLElement?n:null}function ne(e){if((e==null?void 0:e.contentElement)instanceof HTMLElement)return e.contentElement;if((e==null?void 0:e.editorElement)instanceof HTMLElement){const o=e.editorElement;if(o.getAttribute("contenteditable")==="true")return o;const a=o.querySelector('[contenteditable="true"]');if(a instanceof HTMLElement)return a}const t=te();if(t&&document.contains(t))return t;const n=window.getSelection();if(n&&n.rangeCount>0){const o=n.getRangeAt(0).startContainer,a=o.nodeType===Node.ELEMENT_NODE?o:o.parentElement,c=a==null?void 0:a.closest(p);if(c)return c}const r=document.activeElement;if(r){if(r.matches(p))return r;const o=r.closest(p);if(o)return o}return h!=null&&h.isConnected?h:document.querySelector(p)}function v(e,t){var r;k(e),_(e);let n=B.get(e);return n||(n={enabled:!!t.enabledByDefault,author:((r=t.author)==null?void 0:r.trim())||"system",includeTimestamp:t.includeTimestamp!==!1},B.set(e,n),n.enabled&&(M(e,n),y(e,n.enabled))),S(e,"toggleTrackChanges",n.enabled),n}function y(e,t){e.classList.toggle("rte-track-changes-enabled",t),t?e.setAttribute("data-track-changes","true"):e.removeAttribute("data-track-changes")}function re(e){return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||e}function S(e,t,n){const r=re(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(a=>{a.classList.toggle("active",n),a.setAttribute("data-active",n?"true":"false"),a.setAttribute("aria-pressed",n?"true":"false"),a.setAttribute("title",n?"Track Changes (On)":"Track Changes (Off)")})}function ae(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function oe(e,t){if(t===e.innerHTML)return;const n=window.execEditorCommand||window.executeEditorCommand;if(typeof n=="function")try{n("recordDomTransaction",e,t,e.innerHTML)}catch{}}function m(e,t){ae(e),oe(e,t)}function ce(e,t){return e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset}function G(e){return{author:e.author,timestamp:e.includeTimestamp?new Date().toISOString():""}}function se(e,t){const n=document.createElement("span");n.className="rte-track-insert",n.setAttribute("data-track-change","insert"),n.setAttribute("contenteditable","false");const r=G(t);return n.setAttribute("data-track-author",r.author),r.timestamp&&n.setAttribute("data-track-time",r.timestamp),n.appendChild(document.createTextNode(e)),n}function k(e){Array.from(e.querySelectorAll(g)).forEach(n=>{n.setAttribute("contenteditable","false")})}function E(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function le(e,t){const n=e.startContainer,r=e.startOffset;if(n.nodeType===Node.TEXT_NODE){const o=n,a=o.previousSibling||o.nextSibling;if(a instanceof HTMLElement&&a.matches(g)&&t.contains(a))return a}if(n.nodeType===Node.ELEMENT_NODE){const o=n,a=o.childNodes[r-1];if(a instanceof HTMLElement&&a.matches(g)&&t.contains(a))return a;const c=o.childNodes[r];if(c instanceof HTMLElement&&c.matches(g)&&t.contains(c))return c}return null}function P(e,t,n){const r=t.lastChild;r&&r.nodeType===Node.TEXT_NODE?r.data+=n:t.appendChild(document.createTextNode(n)),C(e,t)}function ie(e,t){const n=document.createElement("span");n.className="rte-track-delete",n.setAttribute("data-track-change","delete"),n.setAttribute("contenteditable","false");const r=G(t);return n.setAttribute("data-track-author",r.author),r.timestamp&&n.setAttribute("data-track-time",r.timestamp),n.appendChild(e),n}function b(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const n=t.getRangeAt(0);return e.contains(n.commonAncestorContainer)?n:null}function ue(){F||typeof document>"u"||(F=!0,document.addEventListener("selectionchange",()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=e.getRangeAt(0),n=E(t.startContainer),r=(n==null?void 0:n.closest(p))||null;r&&(L.set(r,t.cloneRange()),h=r)},!0))}function C(e,t){if(!t.parentNode){e.focus({preventScroll:!0});return}const n=window.getSelection();if(!n)return;const r=document.createRange();r.setStartAfter(t),r.collapse(!0),n.removeAllRanges(),n.addRange(r),e.focus({preventScroll:!0})}function O(e,t){if(!t.parentNode){e.focus({preventScroll:!0});return}const n=window.getSelection();if(!n)return;const r=document.createRange();r.setStartBefore(t),r.collapse(!0),n.removeAllRanges(),n.addRange(r),e.focus({preventScroll:!0})}function de(e,t,n){const r=window.getSelection();if(!r)return;const o=document.createRange();o.setStart(t,Math.max(0,n)),o.collapse(!0),r.removeAllRanges(),r.addRange(o),e.focus({preventScroll:!0})}function V(e){let t=b(e);if(!t){const c=L.get(e);c&&e.contains(c.commonAncestorContainer)&&(t=c.cloneRange())}if(!t||!t.collapsed)return;const n=E(t.startContainer);if(!n)return;const r=n.closest(g);if(!r||!e.contains(r)||!r.parentNode)return;const o=window.getSelection();if(!o)return;const a=document.createRange();a.setStartAfter(r),a.collapse(!0),o.removeAllRanges(),o.addRange(a),e.focus({preventScroll:!0})}function K(e,t){const n=e.innerHTML;k(e),V(e),e.focus({preventScroll:!0});const r=t==="insertLineBreak"?"insertLineBreak":"insertParagraph",o=document.execCommand(r,!1);return k(e),m(e,n),o!==!1}function fe(e){const t=b(e);if(t&&t.collapsed)return t;const n=L.get(e);return n&&n.collapsed&&e.contains(n.commonAncestorContainer)?n.cloneRange():null}function ge(e){return e.matches(g)||e.matches(f)?(e.textContent||"").replace(/\u200B/g,"").trim().length>0:Q.has(e.tagName)}function W(e,t){if(t!=="insertParagraph")return!1;const n=fe(e);if(!n)return!1;const r=E(n.startContainer);if(!r)return!1;const o=r.closest("li");return!(o instanceof HTMLElement)||!e.contains(o)||(o.textContent||"").replace(/\u200B/g,"").trim().length>0?!1:!Array.from(o.querySelectorAll("*")).some(s=>ge(s))}function he(e){const t=document.createRange(),n=window.getSelection();if(n&&n.rangeCount>0){const r=n.getRangeAt(0);if(e.contains(r.commonAncestorContainer))return t.setStart(r.endContainer,r.endOffset),t.collapse(!0),t}return t.selectNodeContents(e),t.collapse(!1),t}function me(e){return(e.textContent||"").length>0?!0:Array.from(e.childNodes).some(n=>{if(n.nodeType!==Node.ELEMENT_NODE)return!1;const r=n;return["BR","IMG","TABLE","VIDEO","AUDIO","SVG","MATH"].includes(r.tagName)})}function pe(e){return Array.from(e.childNodes).some(t=>{if(t.nodeType===Node.TEXT_NODE)return(t.textContent||"").length>0;if(t.nodeType!==Node.ELEMENT_NODE)return!1;const n=t;return["BR","IMG","TABLE","VIDEO","AUDIO","SVG","MATH"].includes(n.tagName)})}function Ee(e,t,n){if(!e.collapsed)return null;const r=e.startContainer,o=e.startOffset;let a=null;if(r.nodeType===Node.TEXT_NODE){const c=r;t==="backward"&&o===0?a=c.previousSibling:t==="forward"&&o===c.length&&(a=c.nextSibling)}else if(r.nodeType===Node.ELEMENT_NODE){const c=r;t==="backward"&&o>0?a=c.childNodes[o-1]||null:t==="forward"&&o<c.childNodes.length&&(a=c.childNodes[o]||null)}return!(a instanceof HTMLElement)||!a.matches(g)||!n.contains(a)?null:a}function ke(e,t){const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=[];let o=n.nextNode();for(;o;){const a=o;a.data.length>0&&r.push(a),o=n.nextNode()}return r.length===0?null:t?r[r.length-1]:r[0]}function Te(e,t,n){const r=Ee(t,n,e);return r?R(e,r,n):!1}function R(e,t,n){const r=t.parentNode;if(!r)return!1;const o=Array.prototype.indexOf.call(r.childNodes,t),a=ke(t,n==="backward");return a?(n==="backward"?a.data=a.data.slice(0,-1):a.data=a.data.slice(1),a.data.length===0&&a.remove(),pe(t)?(n==="backward"?C(e,t):O(e,t),!0):(t.remove(),de(e,r,o),!0)):!1}function Z(e){if(e.startContainer!==e.endContainer||e.startContainer.nodeType!==Node.ELEMENT_NODE)return null;const t=e.startContainer;return e.endOffset-e.startOffset!==1?null:t.childNodes[e.startOffset]||null}function I(e,t){const n=Z(e);return!(n instanceof HTMLElement)||!n.matches(f)||!t.contains(n)?null:n}function be(e,t){const n=Z(e);return!(n instanceof HTMLElement)||!n.matches(g)||!t.contains(n)?null:n}function Ce(e,t){var a,c;if(t.collapsed){const s=E(t.startContainer),l=s==null?void 0:s.closest(f);if(l&&e.contains(l)){const i=document.createRange();return i.setStartAfter(l),i.collapse(!0),i}return t}const n=I(t,e);if(n){const s=document.createRange();return s.setStartAfter(n),s.collapse(!0),s}const r=(a=E(t.startContainer))==null?void 0:a.closest(f),o=(c=E(t.endContainer))==null?void 0:c.closest(f);if(r&&o&&r===o&&e.contains(r)){const s=document.createRange();return s.setStartAfter(r),s.collapse(!0),s}return t}function Ae(e,t){const r=Array.from(t.querySelectorAll(g)).filter(s=>{try{return e.intersectsNode(s)}catch{return!1}});if(r.length!==1)return null;const o=r[0],a=(e.toString()||"").replace(/\s+/g,""),c=(o.textContent||"").replace(/\s+/g,"");return!c||a!==c?null:o}function U(e,t,n){if(t.collapsed)return null;const r=t.cloneContents();if(!me(r))return null;const o=ie(r,n);return t.deleteContents(),t.insertNode(o),C(e,o),o}function Ne(e,t,n){if(!t.collapsed)return t;const r=t.startContainer,o=t.startOffset;if(r.nodeType===Node.TEXT_NODE){const s=r;if(n==="backward"&&o>0){const l=t.cloneRange();return l.setStart(s,o-1),l}if(n==="forward"&&o<s.length){const l=t.cloneRange();return l.setEnd(s,o+1),l}}if(r.nodeType===Node.ELEMENT_NODE){const s=r;if(n==="backward"&&o>0)for(let l=o-1;l>=0;l-=1){const i=s.childNodes[l];if(!i||i instanceof HTMLElement&&i.matches(f))continue;const u=t.cloneRange();if(i.nodeType===Node.TEXT_NODE){const d=i;if(d.length===0)continue;u.setStart(d,d.length-1),u.setEnd(d,d.length)}else u.setStartBefore(i),u.setEndAfter(i);return u}if(n==="forward"&&o<s.childNodes.length)for(let l=o;l<s.childNodes.length;l+=1){const i=s.childNodes[l];if(!i||i instanceof HTMLElement&&i.matches(f))continue;const u=t.cloneRange();if(i.nodeType===Node.TEXT_NODE){const d=i;if(d.length===0)continue;u.setStart(d,0),u.setEnd(d,1)}else u.setStartBefore(i),u.setEndAfter(i);return u}}const a=window.getSelection();if(!a||typeof a.modify!="function")return null;const c=t.cloneRange();a.removeAllRanges(),a.addRange(c);try{if(a.modify("extend",n,"character"),a.rangeCount===0)return null;const s=a.getRangeAt(0).cloneRange();if(s.collapsed||!e.contains(s.commonAncestorContainer))return null;const l=I(s,e);return l?(n==="backward"?O(e,l):C(e,l),null):s}catch{return null}finally{a.removeAllRanges(),a.addRange(c)}}function z(e,t,n){let r=b(e);if(!r)return!1;const o=Ce(e,r.cloneRange());if(!ce(o,r)){const d=window.getSelection();d&&(d.removeAllRanges(),d.addRange(o)),r=o}const a=e.innerHTML;r.collapsed||U(e,r.cloneRange(),t);const c=E(r.startContainer),s=c==null?void 0:c.closest(g);if(r.collapsed&&s&&e.contains(s))return P(e,s,n),m(e,a),!0;const l=r.collapsed?le(r,e):null;if(l)return P(e,l,n),m(e,a),!0;const i=he(e),u=se(n,t);return i.insertNode(u),C(e,u),m(e,a),!0}function $(e,t,n){const r=b(e);if(!r)return!1;const o=n.includes("Backward")?"backward":"forward",a=e.innerHTML;if(r.collapsed&&Te(e,r.cloneRange(),o))return m(e,a),!0;const c=be(r,e);if(c&&R(e,c,o))return m(e,a),!0;if(!r.collapsed){const u=Ae(r,e);if(u&&R(e,u,o))return m(e,a),!0}const s=r.collapsed?Ne(e,r.cloneRange(),o):r.cloneRange();if(!s)return!1;const l=I(s,e);return l?(o==="backward"?O(e,l):C(e,l),!0):U(e,s,t)?(_(e),m(e,a),!0):!1}function x(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function _(e){Array.from(e.querySelectorAll(f)).forEach(r=>{r.setAttribute("contenteditable","false"),Array.from(r.querySelectorAll(f)).forEach(a=>{a!==r&&x(a)})});let n=!0;for(;n;)n=!1,Array.from(e.querySelectorAll(f)).forEach(o=>{if(!o.isConnected)return;let a=o.nextSibling;for(;a&&a.nodeType===Node.TEXT_NODE&&!(a.textContent||"").trim();)a=a.nextSibling;if(a instanceof HTMLElement&&a.matches(f)){for(;a.firstChild;)o.appendChild(a.firstChild);a.remove(),n=!0}o.firstChild||(o.remove(),n=!0)})}function Y(e){return Array.from(e.querySelectorAll(w))}function ye(e){const t=b(e);if(!t)return[];const n=new Set,r=t.startContainer.nodeType===Node.ELEMENT_NODE?t.startContainer:t.startContainer.parentElement,o=t.endContainer.nodeType===Node.ELEMENT_NODE?t.endContainer:t.endContainer.parentElement,a=r==null?void 0:r.closest(w);a&&e.contains(a)&&n.add(a);const c=o==null?void 0:o.closest(w);return c&&e.contains(c)&&n.add(c),Y(e).filter(l=>{try{return t.intersectsNode(l)}catch{return!1}}).forEach(l=>n.add(l)),Array.from(n)}function A(e,t,n){const r=n==="all"?Y(e):ye(e);if(r.length===0)return!1;const o=e.innerHTML;return r.forEach(a=>{if(!a.isConnected)return;const c=a.matches(g),s=a.matches(f);if(!(!c&&!s)){if(t==="accept"){c?x(a):a.remove();return}c?a.remove():(a.removeAttribute("contenteditable"),x(a))}}),_(e),m(e,o),!0}function Se(e){if(!(e instanceof Node))return null;const t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return(t==null?void 0:t.closest(p))||null}function Me(){j||typeof document>"u"||(j=!0,document.addEventListener("focusin",e=>{if(!T.enabledByDefault)return;const t=Se(e.target);if(!t)return;h=t;const n=v(t,T);n.enabled?(M(t,n),y(t,!0),S(t,"toggleTrackChanges",!0)):k(t)},!0))}function we(e,t){return n=>{if(!t.enabled||e.getAttribute("data-track-changes")!=="true")return;h=e;const r=n.inputType||"";if(r==="insertParagraph"||r==="insertLineBreak"){if(W(e,r))return;n.preventDefault(),K(e,r);return}if(r.startsWith("delete")){n.preventDefault(),$(e,t,r);return}if(r==="insertText"||r==="insertCompositionText"){const o=n.data||"";if(!o)return;n.preventDefault(),z(e,t,o)}}}function ve(e,t){return n=>{if(!t.enabled||e.getAttribute("data-track-changes")!=="true"||n.key!=="Enter"||J)return;const r=n.shiftKey?"insertLineBreak":"insertParagraph";W(e,r)||(h=e,n.preventDefault(),n.stopPropagation(),K(e,r))}}function Re(e,t){return n=>{var o;if(n.__editoraSmartPasteHandled===!0||n.defaultPrevented||!t.enabled||e.getAttribute("data-track-changes")!=="true")return;const r=((o=n.clipboardData)==null?void 0:o.getData("text/plain"))||"";r&&(n.preventDefault(),h=e,z(e,t,r))}}function xe(e,t){return n=>{if(!t.enabled||e.getAttribute("data-track-changes")!=="true")return;const r=b(e);if(!r||r.collapsed)return;const o=r.toString();n.clipboardData&&(n.clipboardData.setData("text/plain",o),n.preventDefault()),h=e,$(e,t,"deleteByCut")}}function M(e,t){if(N.has(e))return;k(e);const n={beforeInput:we(e,t),keydown:ve(e,t),paste:Re(e,t),cut:xe(e,t)};e.addEventListener("beforeinput",n.beforeInput),e.addEventListener("keydown",n.keydown),e.addEventListener("paste",n.paste),e.addEventListener("cut",n.cut),N.set(e,n),D.add(e)}function X(e){const t=N.get(e);t&&(e.removeEventListener("beforeinput",t.beforeInput),e.removeEventListener("keydown",t.keydown),e.removeEventListener("paste",t.paste),e.removeEventListener("cut",t.cut),N.delete(e),D.delete(e))}function Le(){if(q||typeof document>"u")return;q=!0;const e=document.createElement("style");e.id="rte-track-changes-styles",e.textContent=`
2
2
  .rte-track-insert[data-track-change="insert"] {
3
3
  background: rgba(22, 163, 74, 0.2);
4
4
  color: inherit;
@@ -74,4 +74,4 @@
74
74
  .editora-toolbar-button[data-command="toggleTrackChanges"].active {
75
75
  background-color: #ccc;
76
76
  }
77
- `,document.head.appendChild(e)}const De=(e={})=>{Le(),ue(),T={...T,...e},Me(),T.enabledByDefault&&typeof document<"u"&&(typeof requestAnimationFrame=="function"?requestAnimationFrame:o=>window.setTimeout(o,0))(()=>{Array.from(document.querySelectorAll(p)).forEach(a=>{const c=w(a,T);c.enabled?(M(a,c),y(a,!0),S(a,"toggleTrackChanges",!0)):k(a)})});const t=r=>{const o=ne(r);return o?(h=o,o):null},n=r=>{const o=t(r);if(!o)return null;const a=w(o,e);return{editor:o,state:a}};return{name:"trackChanges",toolbar:[{label:"Track Changes",command:"toggleTrackChanges",type:"group",items:[{label:"Track Changes",command:"toggleTrackChanges",icon:'<svg width="24" height="24" focusable="false"><path d="M4 6h10a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm0 5h7a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm0 5h8a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm13.3-3.6 1.3 1.3 2.9-2.9a1 1 0 1 1 1.4 1.4l-3.6 3.6a1 1 0 0 1-1.4 0l-2-2a1 1 0 1 1 1.4-1.4Z"></path></svg>',shortcut:"Mod-Shift-t"},{label:"Accept All Changes",command:"acceptAllTrackChanges",icon:'<svg width="24" height="24" focusable="false"><path d="M9.2 16.2 5.8 12.8a1 1 0 1 1 1.4-1.4l2.1 2.1 7.5-7.5a1 1 0 1 1 1.4 1.4l-8.2 8.2a1 1 0 0 1-1.4 0Z"></path></svg>'},{label:"Reject All Changes",command:"rejectAllTrackChanges",icon:'<svg width="24" height="24" focusable="false"><path d="M7.8 7.8a1 1 0 0 1 1.4 0L12 10.6l2.8-2.8a1 1 0 1 1 1.4 1.4L13.4 12l2.8 2.8a1 1 0 1 1-1.4 1.4L12 13.4l-2.8 2.8a1 1 0 1 1-1.4-1.4l2.8-2.8-2.8-2.8a1 1 0 0 1 0-1.4Z"></path></svg>'}]}],commands:{toggleTrackChanges:(r,o)=>{const a=n(o);if(!a)return!1;const{editor:c,state:s}=a;return s.enabled=!s.enabled,s.enabled?M(c,s):(X(c),k(c),V(c)),y(c,s.enabled),S(c,"toggleTrackChanges",s.enabled),c.dispatchEvent(new CustomEvent("editora:track-changes-toggle",{bubbles:!0,detail:{enabled:s.enabled,author:s.author}})),s.enabled},acceptAllTrackChanges:(r,o)=>{const a=n(o);return a?A(a.editor,"accept","all"):!1},rejectAllTrackChanges:(r,o)=>{const a=n(o);return a?A(a.editor,"reject","all"):!1},acceptSelectedTrackChanges:(r,o)=>{const a=n(o);return a?A(a.editor,"accept","selection"):!1},rejectSelectedTrackChanges:(r,o)=>{const a=n(o);return a?A(a.editor,"reject","selection"):!1}},keymap:{"Mod-Shift-t":"toggleTrackChanges","Mod-Shift-T":"toggleTrackChanges"},destroy:()=>{Array.from(D).forEach(r=>X(r))}}};exports.TrackChangesPlugin=De;
77
+ `,document.head.appendChild(e)}const De=(e={})=>{Le(),ue(),T={...T,...e},Me(),T.enabledByDefault&&typeof document<"u"&&(typeof requestAnimationFrame=="function"?requestAnimationFrame:o=>window.setTimeout(o,0))(()=>{Array.from(document.querySelectorAll(p)).forEach(a=>{const c=v(a,T);c.enabled?(M(a,c),y(a,!0),S(a,"toggleTrackChanges",!0)):k(a)})});const t=r=>{const o=ne(r);return o?(h=o,o):null},n=r=>{const o=t(r);if(!o)return null;const a=v(o,e);return{editor:o,state:a}};return{name:"trackChanges",toolbar:[{label:"Track Changes",command:"toggleTrackChanges",type:"group",items:[{label:"Track Changes",command:"toggleTrackChanges",icon:'<svg width="24" height="24" focusable="false"><path d="M4 6h10a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm0 5h7a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm0 5h8a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2Zm13.3-3.6 1.3 1.3 2.9-2.9a1 1 0 1 1 1.4 1.4l-3.6 3.6a1 1 0 0 1-1.4 0l-2-2a1 1 0 1 1 1.4-1.4Z"></path></svg>',shortcut:"Mod-Shift-t"},{label:"Accept All Changes",command:"acceptAllTrackChanges",icon:'<svg width="24" height="24" focusable="false"><path d="M9.2 16.2 5.8 12.8a1 1 0 1 1 1.4-1.4l2.1 2.1 7.5-7.5a1 1 0 1 1 1.4 1.4l-8.2 8.2a1 1 0 0 1-1.4 0Z"></path></svg>'},{label:"Reject All Changes",command:"rejectAllTrackChanges",icon:'<svg width="24" height="24" focusable="false"><path d="M7.8 7.8a1 1 0 0 1 1.4 0L12 10.6l2.8-2.8a1 1 0 1 1 1.4 1.4L13.4 12l2.8 2.8a1 1 0 1 1-1.4 1.4L12 13.4l-2.8 2.8a1 1 0 1 1-1.4-1.4l2.8-2.8-2.8-2.8a1 1 0 0 1 0-1.4Z"></path></svg>'}]}],commands:{toggleTrackChanges:(r,o)=>{const a=n(o);if(!a)return!1;const{editor:c,state:s}=a;return s.enabled=!s.enabled,s.enabled?M(c,s):(X(c),k(c),V(c)),y(c,s.enabled),S(c,"toggleTrackChanges",s.enabled),c.dispatchEvent(new CustomEvent("editora:track-changes-toggle",{bubbles:!0,detail:{enabled:s.enabled,author:s.author}})),s.enabled},acceptAllTrackChanges:(r,o)=>{const a=n(o);return a?A(a.editor,"accept","all"):!1},rejectAllTrackChanges:(r,o)=>{const a=n(o);return a?A(a.editor,"reject","all"):!1},acceptSelectedTrackChanges:(r,o)=>{const a=n(o);return a?A(a.editor,"accept","selection"):!1},rejectSelectedTrackChanges:(r,o)=>{const a=n(o);return a?A(a.editor,"reject","selection"):!1}},keymap:{"Mod-Shift-t":"toggleTrackChanges","Mod-Shift-T":"toggleTrackChanges"},destroy:()=>{Array.from(D).forEach(r=>X(r))}}};exports.TrackChangesPlugin=De;