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