@editora/plugins 1.0.11 → 1.0.13

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 (54) hide show
  1. package/README.md +1 -1
  2. package/dist/approval-workflow.cjs.js +14 -14
  3. package/dist/approval-workflow.esm.js +265 -262
  4. package/dist/blockquote.cjs.js +1 -1
  5. package/dist/blockquote.esm.js +177 -15
  6. package/dist/blocks-library.cjs.js +6 -6
  7. package/dist/blocks-library.esm.js +95 -92
  8. package/dist/bold.cjs.js +1 -1
  9. package/dist/bold.esm.js +10 -6
  10. package/dist/capitalization.cjs.js +1 -1
  11. package/dist/capitalization.esm.js +124 -44
  12. package/dist/checklist.cjs.js +1 -1
  13. package/dist/checklist.esm.js +251 -191
  14. package/dist/citations.cjs.js +4 -4
  15. package/dist/citations.esm.js +131 -128
  16. package/dist/clear-formatting.cjs.js +1 -1
  17. package/dist/clear-formatting.esm.js +68 -36
  18. package/dist/code.cjs.js +121 -44
  19. package/dist/code.esm.js +2694 -889
  20. package/dist/content-rules.cjs.js +5 -5
  21. package/dist/content-rules.esm.js +104 -101
  22. package/dist/data-binding.cjs.js +3 -3
  23. package/dist/data-binding.esm.js +51 -48
  24. package/dist/direction.cjs.js +1 -1
  25. package/dist/direction.esm.js +97 -74
  26. package/dist/doc-schema.cjs.js +4 -4
  27. package/dist/doc-schema.esm.js +104 -101
  28. package/dist/embed-iframe.cjs.js +21 -4
  29. package/dist/embed-iframe.esm.js +279 -116
  30. package/dist/heading.cjs.js +1 -1
  31. package/dist/heading.esm.js +239 -56
  32. package/dist/history.cjs.js +1 -1
  33. package/dist/history.esm.js +74 -89
  34. package/dist/inlineFormatting-DOYOJdnD.js +1 -0
  35. package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
  36. package/dist/italic.cjs.js +1 -1
  37. package/dist/italic.esm.js +12 -8
  38. package/dist/math.cjs.js +27 -21
  39. package/dist/math.esm.js +218 -146
  40. package/dist/merge-tag.cjs.js +8 -2
  41. package/dist/merge-tag.esm.js +130 -111
  42. package/dist/pii-redaction.cjs.js +6 -6
  43. package/dist/pii-redaction.esm.js +169 -166
  44. package/dist/smart-paste.cjs.js +5 -5
  45. package/dist/smart-paste.esm.js +120 -117
  46. package/dist/special-characters.cjs.js +6 -10
  47. package/dist/special-characters.esm.js +97 -75
  48. package/dist/strikethrough.cjs.js +1 -1
  49. package/dist/strikethrough.esm.js +11 -25
  50. package/dist/translation-workflow.cjs.js +7 -7
  51. package/dist/translation-workflow.esm.js +103 -100
  52. package/dist/underline.cjs.js +1 -1
  53. package/dist/underline.esm.js +7 -3
  54. package/package.json +3 -3
@@ -1,63 +1,246 @@
1
- const t = () => {
2
- const e = (a) => {
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"]);
2
+ function H(e) {
3
+ return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
4
+ }
5
+ function S(e) {
6
+ const n = e?.contentElement;
7
+ if (n instanceof HTMLElement) return n;
8
+ const t = e?.editorElement;
9
+ if (t instanceof HTMLElement) {
10
+ const a = t.querySelector(f);
11
+ if (a instanceof HTMLElement) return a;
12
+ if (t.getAttribute("contenteditable") === "true") return t;
13
+ }
14
+ const r = window.getSelection();
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;
20
+ }
21
+ const o = document.activeElement?.closest(f);
22
+ return o instanceof HTMLElement ? o : document.querySelector(f);
23
+ }
24
+ function N(e) {
25
+ const n = window.getSelection();
26
+ if (!n || n.rangeCount === 0) return null;
27
+ const t = n.getRangeAt(0);
28
+ return !e.contains(t.startContainer) || !e.contains(t.endContainer) ? null : t;
29
+ }
30
+ function T(e, n) {
31
+ let t = H(n);
32
+ if (!t || t === e || !e.contains(t)) return null;
33
+ for (; t.parentElement && t.parentElement !== e; )
34
+ t = t.parentElement;
35
+ if (t.parentElement !== e) return null;
36
+ if (t.matches(E)) return t;
37
+ const r = t.closest(E);
38
+ return r instanceof HTMLElement && r.parentElement === e ? r : t;
39
+ }
40
+ function v(e, n) {
41
+ if (typeof e.intersectsNode == "function")
3
42
  try {
4
- return document.execCommand("formatBlock", !1, a), !0;
5
- } catch (l) {
6
- return console.error(`Failed to set block type to ${a}:`, l), !1;
43
+ return e.intersectsNode(n);
44
+ } catch {
45
+ return !1;
7
46
  }
47
+ const t = document.createRange();
48
+ return t.selectNode(n), e.compareBoundaryPoints(Range.END_TO_START, t) < 0 && e.compareBoundaryPoints(Range.START_TO_END, t) > 0;
49
+ }
50
+ function w(e, n) {
51
+ const t = T(e, n.startContainer), r = T(e, n.endContainer);
52
+ if (!t) return [];
53
+ if (!r || t === r) return [t];
54
+ const o = Array.from(e.children).filter(
55
+ (a) => a instanceof HTMLElement
56
+ ).filter((a) => v(n, a));
57
+ return o.length > 0 ? o : [t];
58
+ }
59
+ function A(e, n) {
60
+ Array.from(e.attributes).forEach((t) => {
61
+ n.setAttribute(t.name, t.value);
62
+ });
63
+ }
64
+ function p(e, n) {
65
+ for (; e.firstChild; )
66
+ n.appendChild(e.firstChild);
67
+ }
68
+ function R(e) {
69
+ return e.tagName !== "P" || e.attributes.length > 0 || (e.textContent || "").trim() !== "" ? !1 : !e.querySelector("img, video, table, iframe, hr, pre, ul, ol");
70
+ }
71
+ function d(e, n) {
72
+ const t = document.createElement(e);
73
+ return n && A(n, t), t;
74
+ }
75
+ function C(e, n) {
76
+ const t = d(n, e);
77
+ return p(e, t), t.innerHTML.trim() || (t.innerHTML = "<br>"), t;
78
+ }
79
+ function I(e) {
80
+ const n = e.cloneNode(!1);
81
+ return n instanceof HTMLElement ? n : document.createElement(e.tagName.toLowerCase());
82
+ }
83
+ function L(e, n, t) {
84
+ const r = e.parentNode;
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;
8
90
  };
9
- return {
10
- name: "heading",
11
- // Toolbar button configuration with dropdown
12
- toolbar: [
13
- {
14
- label: "Heading",
15
- command: "setBlockType",
16
- type: "dropdown",
17
- options: [
18
- { value: "p", label: "Paragraph" },
19
- { value: "h1", label: "Heading 1" },
20
- { value: "h2", label: "Heading 2" },
21
- { value: "h3", label: "Heading 3" },
22
- { value: "h4", label: "Heading 4" },
23
- { value: "h5", label: "Heading 5" },
24
- { value: "h6", label: "Heading 6" }
25
- ],
26
- 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>'
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);
97
+ return;
27
98
  }
28
- ],
29
- // Native command implementations
30
- commands: {
31
- /**
32
- * Set block type to specific heading level or paragraph
33
- */
34
- setBlockType: (a) => a ? e(a) : !1,
35
- /**
36
- * Set heading level 1
37
- */
38
- setHeading1: () => e("h1"),
39
- /**
40
- * Set heading level 2
41
- */
42
- setHeading2: () => e("h2"),
43
- /**
44
- * Set heading level 3
45
- */
46
- setHeading3: () => e("h3"),
47
- /**
48
- * Set to paragraph
49
- */
50
- setParagraph: () => e("p")
51
- },
52
- // Keyboard shortcuts
53
- keymap: {
54
- "Mod-Alt-1": "setHeading1",
55
- "Mod-Alt-2": "setHeading2",
56
- "Mod-Alt-3": "setHeading3",
57
- "Mod-Alt-0": "setParagraph"
99
+ a || (a = I(e)), a.appendChild(i);
58
100
  }
59
- };
60
- };
101
+ }), c(), r.insertBefore(s, e), r.removeChild(e), o;
102
+ }
103
+ function _(e, n) {
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];
107
+ }
108
+ function O(e, n) {
109
+ const t = e.parentNode;
110
+ if (!t) return [];
111
+ const r = document.createDocumentFragment(), s = [];
112
+ return Array.from(e.childNodes).forEach((o) => {
113
+ if (o instanceof HTMLElement && R(o)) {
114
+ o.remove();
115
+ return;
116
+ }
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);
122
+ }), o.remove();
123
+ return;
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);
128
+ return;
129
+ }
130
+ if (o.nodeType === Node.TEXT_NODE && (o.textContent || "").trim() === "") {
131
+ o.remove();
132
+ return;
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;
137
+ }
138
+ function b(e) {
139
+ const n = window.getSelection();
140
+ if (!n) return;
141
+ const t = document.createRange(), r = e instanceof HTMLElement && e.querySelector("p,li,h1,h2,h3,h4,h5,h6") || e;
142
+ t.selectNodeContents(r), t.collapse(!0), n.removeAllRanges(), n.addRange(t);
143
+ }
144
+ function k(e) {
145
+ e.dispatchEvent(new Event("input", { bubbles: !0 }));
146
+ }
147
+ function x(e, n, t) {
148
+ const r = window.execEditorCommand;
149
+ if (typeof r == "function") {
150
+ r("recordDomTransaction", e, n, t);
151
+ return;
152
+ }
153
+ const s = window.executeEditorCommand;
154
+ typeof s == "function" && s("recordDomTransaction", { editor: e, beforeHTML: n, afterHTML: t });
155
+ }
156
+ function D(e, n) {
157
+ const t = /* @__PURE__ */ new Map();
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));
163
+ }), t;
164
+ }
165
+ function m(e, n) {
166
+ const t = e.toLowerCase();
167
+ if (!B.has(t)) return !1;
168
+ const r = S(n);
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) => {
176
+ if (l instanceof HTMLUListElement || l instanceof HTMLOListElement) {
177
+ const h = new Set(Array.from(l.children).filter(
178
+ (M) => M instanceof HTMLLIElement
179
+ ));
180
+ a.push(...L(l, h, t));
181
+ return;
182
+ }
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)
187
+ );
188
+ }
189
+ });
190
+ const i = r.innerHTML;
191
+ return o === i || a.length === 0 ? !1 : (x(r, o, i), k(r), b(a[0]), !0);
192
+ }
193
+ const P = () => ({
194
+ name: "heading",
195
+ // Toolbar button configuration with dropdown
196
+ toolbar: [
197
+ {
198
+ label: "P",
199
+ command: "setBlockType",
200
+ type: "dropdown",
201
+ options: [
202
+ { value: "p", label: "P" },
203
+ { value: "h1", label: "H1" },
204
+ { value: "h2", label: "H2" },
205
+ { value: "h3", label: "H3" },
206
+ { value: "h4", label: "H4" },
207
+ { value: "h5", label: "H5" },
208
+ { value: "h6", label: "H6" }
209
+ ],
210
+ 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>'
211
+ }
212
+ ],
213
+ // Native command implementations
214
+ commands: {
215
+ /**
216
+ * Set block type to specific heading level or paragraph
217
+ */
218
+ setBlockType: (e, n) => e ? m(e, n) : !1,
219
+ /**
220
+ * Set heading level 1
221
+ */
222
+ setHeading1: (e, n) => m("h1", n),
223
+ /**
224
+ * Set heading level 2
225
+ */
226
+ setHeading2: (e, n) => m("h2", n),
227
+ /**
228
+ * Set heading level 3
229
+ */
230
+ setHeading3: (e, n) => m("h3", n),
231
+ /**
232
+ * Set to paragraph
233
+ */
234
+ setParagraph: (e, n) => m("p", n)
235
+ },
236
+ // Keyboard shortcuts
237
+ keymap: {
238
+ "Mod-Alt-1": "setHeading1",
239
+ "Mod-Alt-2": "setHeading2",
240
+ "Mod-Alt-3": "setHeading3",
241
+ "Mod-Alt-0": "setParagraph"
242
+ }
243
+ });
61
244
  export {
62
- t as HeadingPlugin
245
+ P as HeadingPlugin
63
246
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=".rte-content, .editora-content",y=100,M="__editoraCommandEditorRoot",d=new Map,E={};let T=!1,c=null;function I(t){if(!t)return null;const e=t.querySelector('[contenteditable="true"]');return e instanceof HTMLElement?e:null}function z(){if(typeof window>"u")return null;const t=window[M];if(!(t instanceof HTMLElement))return null;window[M]=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=I(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 F(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function a(t){const e=F(t);if(!e)return null;const n=e.closest(v);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 l(){const t=z();if(t&&document.contains(t))return t;const e=window.getSelection();if(e&&e.rangeCount>0){const i=a(e.getRangeAt(0).startContainer);if(i)return i}const n=document.activeElement;if(n){const i=a(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(v);return r||document.querySelector('[contenteditable="true"]')}function A(){for(const t of d.keys())t.isConnected||(d.delete(t),c===t&&(c=null))}function C(t){A();let e=d.get(t);return e||(e={undoStack:[],redoStack:[]},d.set(t,e)),e}function s(t){t&&t.dispatchEvent(new Event("input",{bubbles:!0}))}function h(t){return t?t.innerHTML:""}function m(t,e){if(!t)return;const n=C(t);n.undoStack.push(e),n.redoStack.length=0,n.undoStack.length>y&&n.undoStack.splice(0,n.undoStack.length-y),c=t}function L(t,e="undo"){if(A(),t?.isConnected)return t;const n=l();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 w(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 H(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(E[t]=e,typeof window>"u")return;const n=window.registerEditorCommand;typeof n=="function"?n(t,e):(window.registerEditorCommand=(o,r)=>{E[o]=r},window.registerEditorCommand(t,e))}const S=(t,...e)=>{const n=E[t];return n?n(...e):!1};function p(){T||typeof window>"u"||(T=!0,window.execEditorCommand||(window.execEditorCommand=S),window.executeEditorCommand||(window.executeEditorCommand=S),u("undo",k),u("redo",D),u("setAttribute",O),u("setText",_),u("autoFixA11y",N),u("recordDomTransaction",R),u("undoDom",b),u("redoDom",g))}function x(t,e){const n=e||l(),o=h(n);n?.focus({preventScroll:!0});let r=!1;try{r=!!document.execCommand(t,!1)}catch{r=!1}const i=h(n),f=o!==i;return f&&s(n),{executed:r,changed:f}}const k=()=>{const t=l();return x("undo",t).changed?!0:b(t??void 0)},D=()=>{const t=l();return x("redo",t).changed?!0:g(t??void 0)},O=(t,e,n)=>{if(!(t instanceof HTMLElement))return;const o=a(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)}}),s(o)},_=(t,e)=>{if(!(t instanceof HTMLElement))return;const n=a(t),o=t.textContent??"";t.textContent=e,m(n,{undo:()=>{t.isConnected&&(t.textContent=o)},redo:()=>{t.isConnected&&(t.textContent=e)}}),s(n)},N=t=>{const e=t?.element;if(!(e instanceof HTMLElement))return;const n=a(e),o=window.a11yRuleRegistry?.find(f=>f.id===t.rule);if(!o||typeof o.fix!="function")return;const r=w(e);o.fix(t);const i=w(e);m(n,{undo:()=>{e.isConnected&&H(e,r)},redo:()=>{e.isConnected&&H(e,i)}}),s(n)},R=(t,e,n)=>{if(!(t instanceof HTMLElement))return!1;const o=typeof n=="string"?n:t.innerHTML;return e===o?!1:(m(t,{undo:()=>{t.isConnected&&(t.innerHTML=e)},redo:()=>{t.isConnected&&(t.innerHTML=o)}}),!0)},b=t=>{const e=L(t,"undo");if(!e)return!1;const n=C(e),o=n.undoStack.pop();return o?(o.undo(),n.redoStack.push(o),c=e,s(e),!0):!1},g=t=>{const e=L(t,"redo");if(!e)return!1;const n=C(e),o=n.redoStack.pop();return o?(o.redo(),n.undoStack.push(o),c=e,s(e),!0):!1};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",p,{once:!0}):p());const Z=()=>(p(),{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:k,redo:D,setAttribute:O,setText:_,autoFixA11y:N,recordDomTransaction:R,undoDom:b,redoDom:g},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 H=".rte-content, .editora-content",M=100,T="__editoraCommandEditorRoot",d=new Map,l={};let g=!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 E(){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 b(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 f(t,e){if(!t)return;const n=b(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=E();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 y(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(l[t]=e,typeof window>"u")return;const n=window.registerEditorCommand;typeof n=="function"?n(t,e):(window.registerEditorCommand=(o,r)=>{l[o]=r},window.registerEditorCommand(t,e))}const h=(t,...e)=>{const n=l[t];return n?n(...e):!1};function m(){g||typeof window>"u"||(g=!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",p),u("redoDom",C))}const L=()=>{const t=E();return p(t??void 0)},v=()=>{const t=E();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),f(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,f(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=y(e);o.fix(t);const i=y(e);f(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;return e===o?!1:(f(t,{undo:()=>{t.isConnected&&(t.innerHTML=e)},redo:()=>{t.isConnected&&(t.innerHTML=o)}}),!0)},p=t=>{const e=A(t,"undo");if(!e)return!1;const n=b(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=b(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",m,{once:!0}):m());const z=()=>(m(),{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:p,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,19 +1,19 @@
1
- const S = ".rte-content, .editora-content";
2
- const T = "__editoraCommandEditorRoot", d = /* @__PURE__ */ new Map(), E = {};
3
- let g = !1, c = null;
4
- function I(t) {
1
+ const H = ".rte-content, .editora-content";
2
+ const b = "__editoraCommandEditorRoot", d = /* @__PURE__ */ new Map(), l = {};
3
+ let T = !1, c = null;
4
+ function _(t) {
5
5
  if (!t) return null;
6
6
  const e = t.querySelector('[contenteditable="true"]');
7
7
  return e instanceof HTMLElement ? e : null;
8
8
  }
9
- function N() {
9
+ function R() {
10
10
  if (typeof window > "u") return null;
11
- const t = window[T];
11
+ const t = window[b];
12
12
  if (!(t instanceof HTMLElement)) return null;
13
- window[T] = null;
13
+ window[b] = null;
14
14
  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);
15
15
  if (e) {
16
- const o = I(e);
16
+ const o = _(e);
17
17
  if (o) return o;
18
18
  if (e.getAttribute("contenteditable") === "true") return e;
19
19
  }
@@ -22,13 +22,13 @@ function N() {
22
22
  const n = t.closest('[contenteditable="true"]');
23
23
  return n instanceof HTMLElement ? n : null;
24
24
  }
25
- function z(t) {
25
+ function I(t) {
26
26
  return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
27
27
  }
28
- function a(t) {
29
- const e = z(t);
28
+ function s(t) {
29
+ const e = I(t);
30
30
  if (!e) return null;
31
- const n = e.closest(S);
31
+ const n = e.closest(H);
32
32
  if (n) return n;
33
33
  const o = e.closest('[contenteditable="true"]');
34
34
  if (!o) return null;
@@ -37,50 +37,47 @@ function a(t) {
37
37
  i.getAttribute("contenteditable") === "true" && (r = i), i = i.parentElement;
38
38
  return r;
39
39
  }
40
- function l() {
41
- const t = N();
40
+ function E() {
41
+ const t = R();
42
42
  if (t && document.contains(t))
43
43
  return t;
44
44
  const e = window.getSelection();
45
45
  if (e && e.rangeCount > 0) {
46
- const i = a(e.getRangeAt(0).startContainer);
46
+ const i = s(e.getRangeAt(0).startContainer);
47
47
  if (i) return i;
48
48
  }
49
49
  const n = document.activeElement;
50
50
  if (n) {
51
- const i = a(n);
51
+ const i = s(n);
52
52
  if (i) return i;
53
53
  }
54
54
  if (c?.isConnected) return c;
55
55
  const o = Array.from(d.keys()).find((i) => i.isConnected);
56
56
  if (o) return o;
57
- const r = document.querySelector(S);
57
+ const r = document.querySelector(H);
58
58
  return r || document.querySelector('[contenteditable="true"]');
59
59
  }
60
- function v() {
60
+ function h() {
61
61
  for (const t of d.keys())
62
62
  t.isConnected || (d.delete(t), c === t && (c = null));
63
63
  }
64
- function C(t) {
65
- v();
64
+ function p(t) {
65
+ h();
66
66
  let e = d.get(t);
67
67
  return e || (e = { undoStack: [], redoStack: [] }, d.set(t, e)), e;
68
68
  }
69
- function s(t) {
69
+ function a(t) {
70
70
  t && t.dispatchEvent(new Event("input", { bubbles: !0 }));
71
71
  }
72
- function h(t) {
73
- return t ? t.innerHTML : "";
74
- }
75
- function m(t, e) {
72
+ function f(t, e) {
76
73
  if (!t) return;
77
- const n = C(t);
74
+ const n = p(t);
78
75
  n.undoStack.push(e), n.redoStack.length = 0, n.undoStack.length > 100 && n.undoStack.splice(0, n.undoStack.length - 100), c = t;
79
76
  }
80
- function A(t, e = "undo") {
81
- if (v(), t?.isConnected)
77
+ function S(t, e = "undo") {
78
+ if (h(), t?.isConnected)
82
79
  return t;
83
- const n = l();
80
+ const n = E();
84
81
  if (n?.isConnected)
85
82
  return n;
86
83
  if (c?.isConnected)
@@ -105,86 +102,74 @@ function y(t) {
105
102
  checked: o ? t.checked : null
106
103
  };
107
104
  }
108
- function H(t, e) {
105
+ function g(t, e) {
109
106
  const n = new Set(t.getAttributeNames());
110
107
  Object.keys(e.attributes).forEach((o) => n.delete(o)), n.forEach((o) => t.removeAttribute(o)), Object.entries(e.attributes).forEach(([o, r]) => {
111
108
  t.setAttribute(o, r);
112
109
  }), 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);
113
110
  }
114
111
  function u(t, e) {
115
- if (E[t] = e, typeof window > "u") return;
112
+ if (l[t] = e, typeof window > "u") return;
116
113
  const n = window.registerEditorCommand;
117
114
  typeof n == "function" ? n(t, e) : (window.registerEditorCommand = (o, r) => {
118
- E[o] = r;
115
+ l[o] = r;
119
116
  }, window.registerEditorCommand(t, e));
120
117
  }
121
118
  const w = (t, ...e) => {
122
- const n = E[t];
119
+ const n = l[t];
123
120
  return n ? n(...e) : !1;
124
121
  };
125
- function p() {
126
- g || typeof window > "u" || (g = !0, window.execEditorCommand || (window.execEditorCommand = w), window.executeEditorCommand || (window.executeEditorCommand = w), u("undo", x), u("redo", k), u("setAttribute", O), u("setText", D), u("autoFixA11y", _), u("recordDomTransaction", R), u("undoDom", M), u("redoDom", b));
127
- }
128
- function L(t, e) {
129
- const n = e || l(), o = h(n);
130
- n?.focus({ preventScroll: !0 });
131
- let r = !1;
132
- try {
133
- r = !!document.execCommand(t, !1);
134
- } catch {
135
- r = !1;
136
- }
137
- const i = h(n), f = o !== i;
138
- return f && s(n), { executed: r, changed: f };
139
- }
140
- const x = () => {
141
- const t = l();
142
- return L("undo", t).changed ? !0 : M(t ?? void 0);
143
- }, k = () => {
144
- const t = l();
145
- return L("redo", t).changed ? !0 : b(t ?? void 0);
146
- }, O = (t, e, n) => {
122
+ function m() {
123
+ T || typeof window > "u" || (T = !0, window.execEditorCommand || (window.execEditorCommand = w), window.executeEditorCommand || (window.executeEditorCommand = w), u("undo", A), u("redo", L), u("setAttribute", v), u("setText", x), u("autoFixA11y", k), u("recordDomTransaction", O), u("undoDom", C), u("redoDom", M));
124
+ }
125
+ const A = () => {
126
+ const t = E();
127
+ return C(t ?? void 0);
128
+ }, L = () => {
129
+ const t = E();
130
+ return M(t ?? void 0);
131
+ }, v = (t, e, n) => {
147
132
  if (!(t instanceof HTMLElement)) return;
148
- const o = a(t), r = t.hasAttribute(e), i = t.getAttribute(e);
149
- t.setAttribute(e, n), m(o, {
133
+ const o = s(t), r = t.hasAttribute(e), i = t.getAttribute(e);
134
+ t.setAttribute(e, n), f(o, {
150
135
  undo: () => {
151
136
  t.isConnected && (r && i !== null ? t.setAttribute(e, i) : t.removeAttribute(e));
152
137
  },
153
138
  redo: () => {
154
139
  t.isConnected && t.setAttribute(e, n);
155
140
  }
156
- }), s(o);
157
- }, D = (t, e) => {
141
+ }), a(o);
142
+ }, x = (t, e) => {
158
143
  if (!(t instanceof HTMLElement)) return;
159
- const n = a(t), o = t.textContent ?? "";
160
- t.textContent = e, m(n, {
144
+ const n = s(t), o = t.textContent ?? "";
145
+ t.textContent = e, f(n, {
161
146
  undo: () => {
162
147
  t.isConnected && (t.textContent = o);
163
148
  },
164
149
  redo: () => {
165
150
  t.isConnected && (t.textContent = e);
166
151
  }
167
- }), s(n);
168
- }, _ = (t) => {
152
+ }), a(n);
153
+ }, k = (t) => {
169
154
  const e = t?.element;
170
155
  if (!(e instanceof HTMLElement)) return;
171
- const n = a(e), o = window.a11yRuleRegistry?.find((f) => f.id === t.rule);
156
+ const n = s(e), o = window.a11yRuleRegistry?.find((D) => D.id === t.rule);
172
157
  if (!o || typeof o.fix != "function") return;
173
158
  const r = y(e);
174
159
  o.fix(t);
175
160
  const i = y(e);
176
- m(n, {
161
+ f(n, {
177
162
  undo: () => {
178
- e.isConnected && H(e, r);
163
+ e.isConnected && g(e, r);
179
164
  },
180
165
  redo: () => {
181
- e.isConnected && H(e, i);
166
+ e.isConnected && g(e, i);
182
167
  }
183
- }), s(n);
184
- }, R = (t, e, n) => {
168
+ }), a(n);
169
+ }, O = (t, e, n) => {
185
170
  if (!(t instanceof HTMLElement)) return !1;
186
171
  const o = typeof n == "string" ? n : t.innerHTML;
187
- return e === o ? !1 : (m(t, {
172
+ return e === o ? !1 : (f(t, {
188
173
  undo: () => {
189
174
  t.isConnected && (t.innerHTML = e);
190
175
  },
@@ -192,19 +177,19 @@ const x = () => {
192
177
  t.isConnected && (t.innerHTML = o);
193
178
  }
194
179
  }), !0);
195
- }, M = (t) => {
196
- const e = A(t, "undo");
180
+ }, C = (t) => {
181
+ const e = S(t, "undo");
197
182
  if (!e) return !1;
198
- const n = C(e), o = n.undoStack.pop();
199
- return o ? (o.undo(), n.redoStack.push(o), c = e, s(e), !0) : !1;
200
- }, b = (t) => {
201
- const e = A(t, "redo");
183
+ const n = p(e), o = n.undoStack.pop();
184
+ return o ? (o.undo(), n.redoStack.push(o), c = e, a(e), !0) : !1;
185
+ }, M = (t) => {
186
+ const e = S(t, "redo");
202
187
  if (!e) return !1;
203
- const n = C(e), o = n.redoStack.pop();
204
- return o ? (o.redo(), n.undoStack.push(o), c = e, s(e), !0) : !1;
188
+ const n = p(e), o = n.redoStack.pop();
189
+ return o ? (o.redo(), n.undoStack.push(o), c = e, a(e), !0) : !1;
205
190
  };
206
- typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", p, { once: !0 }) : p());
207
- const F = () => (p(), {
191
+ typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", m, { once: !0 }) : m());
192
+ const N = () => (m(), {
208
193
  name: "history",
209
194
  toolbar: [
210
195
  {
@@ -223,14 +208,14 @@ const F = () => (p(), {
223
208
  }
224
209
  ],
225
210
  commands: {
226
- undo: x,
227
- redo: k,
228
- setAttribute: O,
229
- setText: D,
230
- autoFixA11y: _,
231
- recordDomTransaction: R,
232
- undoDom: M,
233
- redoDom: b
211
+ undo: A,
212
+ redo: L,
213
+ setAttribute: v,
214
+ setText: x,
215
+ autoFixA11y: k,
216
+ recordDomTransaction: O,
217
+ undoDom: C,
218
+ redoDom: M
234
219
  },
235
220
  keymap: {
236
221
  "Mod-z": "undo",
@@ -242,5 +227,5 @@ const F = () => (p(), {
242
227
  }
243
228
  });
244
229
  export {
245
- F as HistoryPlugin
230
+ N as HistoryPlugin
246
231
  };
@@ -0,0 +1 @@
1
+ "use strict";const u="data-editora-selection-marker";function w(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function f(t){return t?t.getAttribute("contenteditable")==="true"?t:t.querySelector('[contenteditable="true"]'):null}function y(t){if(t?.contentElement instanceof HTMLElement)return t.contentElement;const e=f(t?.editorElement??null);if(e)return e;const n=typeof window<"u"?window.__editoraCommandEditorRoot:null,o=n instanceof HTMLElement?f(n):null;if(o)return o;const i=window.getSelection();if(i&&i.rangeCount>0){const l=w(i.getRangeAt(0).startContainer)?.closest('.rte-content, .editora-content, [contenteditable="true"]');if(l instanceof HTMLElement)return l}const r=document.activeElement;if(r instanceof HTMLElement){const c=r.closest('.rte-content, .editora-content, [contenteditable="true"]');if(c instanceof HTMLElement)return c}return document.querySelector('.rte-content, .editora-content, [contenteditable="true"]')}function p(t){const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const n=e.getRangeAt(0);return t.contains(n.startContainer)&&t.contains(n.endContainer)}function E(t){const e=document.createElement("span");return e.setAttribute(u,t),e.style.display="inline-block",e.style.width="0",e.style.height="0",e.style.overflow="hidden",e.style.lineHeight="0",e.appendChild(document.createTextNode("\uFEFF")),e}function R(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);if(!t.contains(n.startContainer)||!t.contains(n.endContainer))return null;const o=n.collapsed,i=E("start"),r=o?null:E("end"),c=n.cloneRange();if(r){const a=c.cloneRange();a.collapse(!1),a.insertNode(r)}const l=c.cloneRange();return l.collapse(!0),l.insertNode(i),()=>{const a=window.getSelection(),s=document.createRange(),d=t.querySelector(`[${u}="start"]`),m=t.querySelector(`[${u}="end"]`);if(!a||!d){t.querySelectorAll(`[${u}]`).forEach(g=>g.remove());return}o||!m?(s.setStartBefore(d),s.collapse(!0)):(s.setStartAfter(d),s.setEndBefore(m)),a.removeAllRanges(),a.addRange(s),d.remove(),m?.remove()}}function S(t,e,n){if(e!==n){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",t,e,n);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})}catch{}}}function b(t){const e=y(t.context);if(!e)return!1;const n=e.innerHTML;p(e)&&e.focus({preventScroll:!0});let o=!1;try{o=document.execCommand(t.command,!1)}catch{o=!1}const i=e.innerHTML;if(t.normalize&&i!==n){const c=R(e);t.normalize(e),c?.()}const r=e.innerHTML;return n!==r&&(S(e,n,r),e.dispatchEvent(new Event("input",{bubbles:!0}))),o!==!1||n!==r}exports.applyInlineFormatting=b;