@editora/plugins 1.0.8 → 1.0.9
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/LICENSE +21 -0
- package/README.md +22 -0
- package/dist/approval-workflow.cjs.js +447 -0
- package/dist/approval-workflow.esm.js +1070 -0
- package/dist/blocks-library.cjs.js +442 -0
- package/dist/blocks-library.esm.js +1317 -0
- package/dist/citations.cjs.js +548 -0
- package/dist/citations.esm.js +1457 -0
- package/dist/conditional-content.cjs.js +626 -0
- package/dist/conditional-content.esm.js +1360 -0
- package/dist/content-rules.cjs.js +408 -0
- package/dist/content-rules.esm.js +1093 -0
- package/dist/data-binding.cjs.js +321 -0
- package/dist/data-binding.esm.js +913 -0
- package/dist/doc-schema.cjs.js +398 -0
- package/dist/doc-schema.esm.js +1310 -0
- package/dist/enterprise.cjs.js +1 -0
- package/dist/enterprise.esm.js +56 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +109 -81
- package/dist/mentions.cjs.js +105 -0
- package/dist/mentions.esm.js +726 -0
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +32 -32
- package/dist/pii-redaction.cjs.js +436 -0
- package/dist/pii-redaction.esm.js +1377 -0
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +29 -29
- package/dist/slash-commands.cjs.js +90 -0
- package/dist/slash-commands.esm.js +752 -0
- package/dist/smart-paste.cjs.js +398 -0
- package/dist/smart-paste.esm.js +1388 -0
- package/dist/track-changes.cjs.js +77 -0
- package/dist/track-changes.esm.js +755 -0
- package/dist/translation-workflow.cjs.js +626 -0
- package/dist/translation-workflow.esm.js +1718 -0
- package/dist/version-diff.cjs.js +362 -0
- package/dist/version-diff.esm.js +768 -0
- package/index.d.ts +798 -0
- package/package.json +104 -5
package/dist/preview.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let p=!1;const g=()=>{if(typeof document>"u")return;const i="rte-preview-plugin-styles";if(document.getElementById(i))return;const t=document.createElement("style");t.id=i,t.textContent=`
|
|
2
2
|
/* Preview Editor Dialog Styles */
|
|
3
3
|
.rte-preview-editor-overlay {
|
|
4
4
|
position: fixed !important;
|
|
@@ -217,7 +217,7 @@
|
|
|
217
217
|
font-size: 14px;
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
`,document.head.appendChild(t)},v=()=>{const
|
|
220
|
+
`,document.head.appendChild(t)},v=()=>{const i=window.getSelection();if(i&&i.rangeCount>0){let e=i.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const n=e;if(n.getAttribute("contenteditable")==="true")return n}e=e.parentNode}}const t=document.activeElement;if(t){if(t.getAttribute("contenteditable")==="true")return t;const e=t.closest('[contenteditable="true"]');if(e)return e}return document.querySelector('[contenteditable="true"]')},h=()=>{const i=v();if(!i)return"";const t=i.cloneNode(!0);return[".rte-floating-toolbar",".rte-selection-marker",".rte-toolbar",".rte-resize-handle","[data-rte-internal]"].forEach(n=>{t.querySelectorAll(n).forEach(r=>r.remove())}),t.innerHTML},u=i=>{const t=document.createElement("div");return t.innerHTML=i,t.querySelectorAll('script, iframe[src^="javascript:"], object, embed, form[action^="javascript:"]').forEach(r=>r.remove()),t.querySelectorAll("*").forEach(r=>{Array.from(r.attributes).forEach(o=>{o.name.startsWith("on")&&r.removeAttribute(o.name),(o.name==="href"||o.name==="src")&&o.value.startsWith("javascript:")&&r.removeAttribute(o.name),o.name.toLowerCase()==="contenteditable"&&r.removeAttribute(o.name)}),r.setAttribute("contenteditable","false")}),t.innerHTML},w=()=>{if(typeof window>"u"||p)return;p=!0,g();const i=h(),t=u(i),e=document.createElement("div");e.className="rte-preview-editor-overlay",e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e.setAttribute("aria-labelledby","preview-editor-title");const n=document.createElement("div");n.className="rte-preview-editor-modal";const r=document.createElement("div");r.className="rte-preview-editor-header",r.innerHTML=`
|
|
221
221
|
<h2 id="preview-editor-title">Preview Editor</h2>
|
|
222
222
|
<div class="rte-preview-editor-header-actions">
|
|
223
223
|
<button class="rte-preview-editor-close-btn" aria-label="Close preview editor">
|
|
@@ -227,4 +227,4 @@
|
|
|
227
227
|
</svg>
|
|
228
228
|
</button>
|
|
229
229
|
</div>
|
|
230
|
-
`;const
|
|
230
|
+
`;const o=document.createElement("div");o.className="rte-preview-editor-body";const a=document.createElement("div");a.className="rte-preview-editor-content";const l=document.createElement("div");l.className="rte-preview-editor-light-editor",l.innerHTML=t,a.appendChild(l),o.appendChild(a),n.appendChild(r),n.appendChild(o),e.appendChild(n);const c=()=>{e.parentNode&&e.parentNode.removeChild(e),p=!1,document.removeEventListener("keydown",s)},s=d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),c())},m=r.querySelector(".rte-preview-editor-close-btn");m&&m.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),c()}),e.addEventListener("click",d=>{d.target===e&&c()}),document.addEventListener("keydown",s),document.body.appendChild(e)},f=()=>({name:"preview",toolbar:[{label:"Preview",command:"togglePreview",icon:'<svg fill="#000000" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 92 92" enable-background="new 0 0 92 92" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path id="XMLID_1239_" d="M91.3,43.8C90.6,42.8,74.4,19,46,19C17.6,19,1.4,42.8,0.7,43.8c-0.9,1.3-0.9,3.1,0,4.5 C1.4,49.2,17.6,73,46,73c28.4,0,44.6-23.8,45.3-24.8C92.2,46.9,92.2,45.1,91.3,43.8z M46,65C26.7,65,13.5,51.4,9,46 c4.5-5.5,17.6-19,37-19c19.3,0,32.5,13.6,37,19C78.4,51.5,65.3,65,46,65z M48.3,29.6c-4.4-0.6-8.7,0.5-12.3,3.2c0,0,0,0,0,0 c-7.3,5.5-8.8,15.9-3.3,23.2c2.7,3.6,6.5,5.8,10.9,6.5c0.8,0.1,1.6,0.2,2.3,0.2c3.6,0,7-1.2,9.9-3.3c7.3-5.5,8.8-15.9,3.3-23.2 C56.6,32.5,52.7,30.2,48.3,29.6z M52.3,54.5c-2.2,1.7-5,2.4-7.8,2c-2.8-0.4-5.3-1.9-7-4.1C34.1,47.7,35,41,39.7,37.5 c2.2-1.7,5-2.4,7.8-2c2.8,0.4,5.3,1.9,7,4.1C57.9,44.3,57,51,52.3,54.5z M51.9,40c0.8,0.7,1.2,1.8,1.2,2.8c0,1-0.4,2.1-1.2,2.8 c-0.7,0.7-1.8,1.2-2.8,1.2c-1.1,0-2.1-0.4-2.8-1.2c-0.8-0.8-1.2-1.8-1.2-2.8c0-1.1,0.4-2.1,1.2-2.8c0.7-0.8,1.8-1.2,2.8-1.2 C50.2,38.9,51.2,39.3,51.9,40z"></path> </g></svg>'}],commands:{togglePreview:()=>(w(),!0)},keymap:{}});exports.PreviewPlugin=f;
|
package/dist/preview.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
let c = !1;
|
|
2
2
|
const g = () => {
|
|
3
3
|
if (typeof document > "u") return;
|
|
4
|
-
const
|
|
5
|
-
if (document.getElementById(
|
|
4
|
+
const i = "rte-preview-plugin-styles";
|
|
5
|
+
if (document.getElementById(i)) return;
|
|
6
6
|
const t = document.createElement("style");
|
|
7
|
-
t.id =
|
|
7
|
+
t.id = i, t.textContent = `
|
|
8
8
|
/* Preview Editor Dialog Styles */
|
|
9
9
|
.rte-preview-editor-overlay {
|
|
10
10
|
position: fixed !important;
|
|
@@ -225,14 +225,14 @@ const g = () => {
|
|
|
225
225
|
}
|
|
226
226
|
`, document.head.appendChild(t);
|
|
227
227
|
}, v = () => {
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
230
|
-
let e =
|
|
228
|
+
const i = window.getSelection();
|
|
229
|
+
if (i && i.rangeCount > 0) {
|
|
230
|
+
let e = i.getRangeAt(0).startContainer;
|
|
231
231
|
for (; e && e !== document.body; ) {
|
|
232
232
|
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
233
|
-
const
|
|
234
|
-
if (
|
|
235
|
-
return
|
|
233
|
+
const n = e;
|
|
234
|
+
if (n.getAttribute("contenteditable") === "true")
|
|
235
|
+
return n;
|
|
236
236
|
}
|
|
237
237
|
e = e.parentNode;
|
|
238
238
|
}
|
|
@@ -246,36 +246,36 @@ const g = () => {
|
|
|
246
246
|
}
|
|
247
247
|
return document.querySelector('[contenteditable="true"]');
|
|
248
248
|
}, h = () => {
|
|
249
|
-
const
|
|
250
|
-
if (!
|
|
251
|
-
const t =
|
|
249
|
+
const i = v();
|
|
250
|
+
if (!i) return "";
|
|
251
|
+
const t = i.cloneNode(!0);
|
|
252
252
|
return [
|
|
253
253
|
".rte-floating-toolbar",
|
|
254
254
|
".rte-selection-marker",
|
|
255
255
|
".rte-toolbar",
|
|
256
256
|
".rte-resize-handle",
|
|
257
257
|
"[data-rte-internal]"
|
|
258
|
-
].forEach((
|
|
259
|
-
t.querySelectorAll(
|
|
258
|
+
].forEach((n) => {
|
|
259
|
+
t.querySelectorAll(n).forEach((r) => r.remove());
|
|
260
260
|
}), t.innerHTML;
|
|
261
|
-
}, w = (
|
|
261
|
+
}, w = (i) => {
|
|
262
262
|
const t = document.createElement("div");
|
|
263
|
-
return t.innerHTML =
|
|
263
|
+
return t.innerHTML = i, t.querySelectorAll(
|
|
264
264
|
'script, iframe[src^="javascript:"], object, embed, form[action^="javascript:"]'
|
|
265
|
-
).forEach((
|
|
266
|
-
Array.from(
|
|
267
|
-
|
|
268
|
-
});
|
|
265
|
+
).forEach((r) => r.remove()), t.querySelectorAll("*").forEach((r) => {
|
|
266
|
+
Array.from(r.attributes).forEach((o) => {
|
|
267
|
+
o.name.startsWith("on") && r.removeAttribute(o.name), (o.name === "href" || o.name === "src") && o.value.startsWith("javascript:") && r.removeAttribute(o.name), o.name.toLowerCase() === "contenteditable" && r.removeAttribute(o.name);
|
|
268
|
+
}), r.setAttribute("contenteditable", "false");
|
|
269
269
|
}), t.innerHTML;
|
|
270
270
|
}, u = () => {
|
|
271
271
|
if (typeof window > "u" || c) return;
|
|
272
272
|
c = !0, g();
|
|
273
|
-
const
|
|
273
|
+
const i = h(), t = w(i), e = document.createElement("div");
|
|
274
274
|
e.className = "rte-preview-editor-overlay", e.setAttribute("role", "dialog"), e.setAttribute("aria-modal", "true"), e.setAttribute("aria-labelledby", "preview-editor-title");
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
|
|
275
|
+
const n = document.createElement("div");
|
|
276
|
+
n.className = "rte-preview-editor-modal";
|
|
277
|
+
const r = document.createElement("div");
|
|
278
|
+
r.className = "rte-preview-editor-header", r.innerHTML = `
|
|
279
279
|
<h2 id="preview-editor-title">Preview Editor</h2>
|
|
280
280
|
<div class="rte-preview-editor-header-actions">
|
|
281
281
|
<button class="rte-preview-editor-close-btn" aria-label="Close preview editor">
|
|
@@ -286,17 +286,17 @@ const g = () => {
|
|
|
286
286
|
</button>
|
|
287
287
|
</div>
|
|
288
288
|
`;
|
|
289
|
-
const
|
|
290
|
-
|
|
289
|
+
const o = document.createElement("div");
|
|
290
|
+
o.className = "rte-preview-editor-body";
|
|
291
291
|
const a = document.createElement("div");
|
|
292
292
|
a.className = "rte-preview-editor-content";
|
|
293
293
|
const l = document.createElement("div");
|
|
294
|
-
l.className = "rte-preview-editor-light-editor", l.innerHTML = t, a.appendChild(l),
|
|
294
|
+
l.className = "rte-preview-editor-light-editor", l.innerHTML = t, a.appendChild(l), o.appendChild(a), n.appendChild(r), n.appendChild(o), e.appendChild(n);
|
|
295
295
|
const p = () => {
|
|
296
296
|
e.parentNode && e.parentNode.removeChild(e), c = !1, document.removeEventListener("keydown", s);
|
|
297
297
|
}, s = (d) => {
|
|
298
298
|
d.key === "Escape" && (d.preventDefault(), d.stopPropagation(), p());
|
|
299
|
-
}, m =
|
|
299
|
+
}, m = r.querySelector(".rte-preview-editor-close-btn");
|
|
300
300
|
m && m.addEventListener("click", (d) => {
|
|
301
301
|
d.preventDefault(), d.stopPropagation(), p();
|
|
302
302
|
}), e.addEventListener("click", (d) => {
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function H(e,t){const r=Array.from({length:t}).map(()=>"<th><p><br></p></th>").join(""),n=Array.from({length:e}).map(()=>`<tr>${Array.from({length:t}).map(()=>"<td><p><br></p></td>").join("")}</tr>`).join("");return`<table class="rte-table"><thead><tr>${r}</tr></thead><tbody>${n}</tbody></table><p><br></p>`}function q(){return[{id:"paragraph",label:"Paragraph",description:"Switch to paragraph text",command:"paragraph",keywords:["text","normal","p"]},{id:"h1",label:"Heading 1",description:"Large section heading",command:"heading1",keywords:["title","header","h1"]},{id:"h2",label:"Heading 2",description:"Medium section heading",command:"heading2",keywords:["subtitle","header","h2"]},{id:"h3",label:"Heading 3",description:"Small section heading",command:"heading3",keywords:["header","h3"]},{id:"bulleted-list",label:"Bulleted List",description:"Create a bullet list",command:"toggleBulletList",keywords:["list","ul","bullet"]},{id:"numbered-list",label:"Numbered List",description:"Create a numbered list",command:"toggleOrderedList",keywords:["list","ol","numbered"]},{id:"blockquote",label:"Blockquote",description:"Insert a quote block",command:"toggleBlockquote",keywords:["quote","citation"]},{id:"table-3x3",label:"Table 3x3",description:"Insert a 3 x 3 table",action:({insertHTML:e})=>e(H(3,3)),keywords:["table","grid","rows","columns"]},{id:"horizontal-rule",label:"Divider",description:"Insert a horizontal rule",command:"insertHorizontalRule",keywords:["hr","separator","line"]},{id:"bold",label:"Bold",description:"Toggle bold formatting",command:"toggleBold",keywords:["strong","b"]},{id:"italic",label:"Italic",description:"Toggle italic formatting",command:"toggleItalic",keywords:["emphasis","i"]},{id:"underline",label:"Underline",description:"Toggle underline formatting",command:"toggleUnderline",keywords:["u"]},{id:"strikethrough",label:"Strikethrough",description:"Toggle strikethrough formatting",command:"toggleStrikethrough",keywords:["strike","s"]},{id:"clear-formatting",label:"Clear Formatting",description:"Remove text formatting",command:"clearFormatting",keywords:["reset","plain"]}]}function $(e){const t=[],r=new Set;return e.forEach(n=>{const o=String(n.id||"").trim(),i=String(n.label||"").trim();!o||!i||r.has(o)||(r.add(o),t.push({...n,id:o,label:i,description:n.description?String(n.description):void 0,keywords:Array.isArray(n.keywords)?n.keywords.map(a=>String(a)).filter(Boolean):void 0}))}),t}function D(e){const t=(e.triggerChar||"/")[0]||"/",r=e.includeDefaultItems!==!1,n=r?[...e.items||[],...q()]:e.items||[];return{triggerChar:t,minChars:Math.max(0,e.minChars??0),maxQueryLength:Math.max(1,e.maxQueryLength??48),maxSuggestions:Math.max(1,e.maxSuggestions??10),requireBoundary:e.requireBoundary!==!1,includeDefaultItems:r,items:$(n),itemRenderer:e.itemRenderer,emptyStateText:e.emptyStateText||"No commands found",panelLabel:e.panelLabel||"Slash commands"}}const u='[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark';let E=!1;function B(){if(E||typeof document>"u")return;E=!0;const e=document.createElement("style");e.id="rte-slash-commands-styles",e.textContent=`
|
|
2
|
+
.rte-slash-panel {
|
|
3
|
+
width: min(225px, calc(100vw - 16px));
|
|
4
|
+
max-height: min(360px, calc(100vh - 24px));
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
border: 1px solid #d9dfeb;
|
|
7
|
+
border-radius: 0px;
|
|
8
|
+
background: #ffffff;
|
|
9
|
+
box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2);
|
|
10
|
+
z-index: 2147483646;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.rte-slash-list {
|
|
14
|
+
max-height: min(340px, calc(100vh - 32px));
|
|
15
|
+
overflow: auto;
|
|
16
|
+
padding: 0px;
|
|
17
|
+
display: grid;
|
|
18
|
+
gap: 1px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.rte-slash-item {
|
|
22
|
+
width: 100%;
|
|
23
|
+
border: none;
|
|
24
|
+
background: transparent;
|
|
25
|
+
color: #0f172a;
|
|
26
|
+
border-radius: 0px;
|
|
27
|
+
padding: 6px 9px;
|
|
28
|
+
text-align: left;
|
|
29
|
+
display: grid;
|
|
30
|
+
gap: 0px;
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
font: inherit;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.rte-slash-item:hover,
|
|
36
|
+
.rte-slash-item.active {
|
|
37
|
+
background: #eff6ff;
|
|
38
|
+
color: #1d4ed8;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.rte-slash-item-title {
|
|
42
|
+
font-size: 13px;
|
|
43
|
+
font-weight: 600;
|
|
44
|
+
line-height: 1.35;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.rte-slash-item-description {
|
|
48
|
+
font-size: 12px;
|
|
49
|
+
color: #64748b;
|
|
50
|
+
line-height: 1.35;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.rte-slash-item mark {
|
|
54
|
+
background: rgba(59, 130, 246, 0.16);
|
|
55
|
+
color: inherit;
|
|
56
|
+
padding: 0 2px;
|
|
57
|
+
border-radius: 3px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.rte-slash-empty {
|
|
61
|
+
font-size: 13px;
|
|
62
|
+
color: #64748b;
|
|
63
|
+
text-align: center;
|
|
64
|
+
padding: 12px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
${u} .rte-slash-panel {
|
|
68
|
+
border-color: #364152;
|
|
69
|
+
background: #1f2937;
|
|
70
|
+
box-shadow: 0 22px 44px rgba(0, 0, 0, 0.48);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
${u} .rte-slash-item {
|
|
74
|
+
color: #e5e7eb;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
${u} .rte-slash-item:hover,
|
|
78
|
+
${u} .rte-slash-item.active {
|
|
79
|
+
background: #334155;
|
|
80
|
+
color: #bfdbfe;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
${u} .rte-slash-item-description,
|
|
84
|
+
${u} .rte-slash-empty {
|
|
85
|
+
color: #9ca3af;
|
|
86
|
+
}
|
|
87
|
+
`,document.head.appendChild(e)}const s=".rte-content, .editora-content",g=new WeakMap,p=new WeakMap;let b=!1,f=null,h=0,z=0;function P(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function I(e){return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||e}function _(e){if(e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const n=e.editorElement;if(n.matches(s))return n;const o=n.querySelector(s);if(o instanceof HTMLElement)return o}const t=window.getSelection();if(t&&t.rangeCount>0){const n=t.getRangeAt(0).startContainer,i=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(s);if(i)return i}const r=document.activeElement;if(r){if(r.matches(s))return r;const n=r.closest(s);if(n)return n}return document.querySelector(s)}function m(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function F(e){return e?/\s|[([{"'`]/.test(e):!0}function v(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return e.contains(r.commonAncestorContainer)?r.cloneRange():null}function y(e,t){const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(t),e.focus({preventScroll:!0}))}function j(e){if(!e.collapsed)return null;const t=e.startContainer,r=e.startOffset;if(t.nodeType===Node.TEXT_NODE){const n=t;return{node:n,textBefore:n.data.slice(0,r),caretOffset:r}}if(t.nodeType===Node.ELEMENT_NODE){const n=t;if(r>0){const o=n.childNodes[r-1];if(o&&o.nodeType===Node.TEXT_NODE){const i=o;return{node:i,textBefore:i.data,caretOffset:i.length}}}}return null}function K(e,t,r,n){const o=e.lastIndexOf(t);if(o<0||n&&!F(e[o-1]))return null;const i=e.slice(o+1);return/\s/.test(i)||i.length>r?null:{trigger:t,query:i,startOffset:o}}function Q(e,t){const r=t.cloneRange();r.collapse(!1);const n=r.getClientRects();if(n.length>0)return n[n.length-1];const o=document.createElement("span");o.textContent="",r.insertNode(o);const i=o.getBoundingClientRect();return o.remove(),e.normalize(),i}function A(e,t){if(!e.panel)return;const r=Q(e.editor,t),n=e.panel;n.style.display="block",n.classList.add("show"),n.style.left="0px",n.style.top="0px";const o=n.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight;let l=Math.max(8,Math.min(r.left,i-o.width-8)),d=r.bottom+8;d+o.height>a-8&&(d=Math.max(8,r.top-o.height-8)),n.style.position="fixed",n.style.left=`${l}px`,n.style.top=`${d}px`}function k(e,t){if(!t)return m(e);const r=e.toLowerCase(),n=t.toLowerCase(),o=r.indexOf(n);if(o<0)return m(e);const i=m(e.slice(0,o)),a=m(e.slice(o,o+t.length)),l=m(e.slice(o+t.length));return`${i}<mark>${a}</mark>${l}`}function U(e,t){if(e.panel&&e.list)return;const r=document.createElement("div");r.className="rte-slash-panel",r.style.display="none",r.setAttribute("role","dialog"),r.setAttribute("aria-modal","false");const n=document.createElement("div");n.className="rte-slash-list",n.setAttribute("role","listbox"),n.setAttribute("aria-label",t.panelLabel),r.appendChild(n),document.body.appendChild(r),e.panel=r,e.list=n,r.addEventListener("mousedown",o=>{o.preventDefault()}),r.addEventListener("click",o=>{const i=o.target;if(!i)return;const a=i.closest(".rte-slash-item");if(!a)return;const l=Number(a.getAttribute("data-index"));Number.isFinite(l)&&M(e,l)})}function c(e){e.panel&&(e.panel.style.display="none",e.panel.classList.remove("show"),e.isOpen=!1,e.filteredItems=[],e.activeIndex=0,e.query="",e.replaceRange=null,e.anchorRange=null)}function W(e,t,r){if(!t)return e.slice(0,r);const n=t.toLowerCase();return e.filter(i=>[i.id,i.label,i.description||"",i.command||"",...i.keywords||[]].join(" ").toLowerCase().includes(n)).slice(0,r)}function Z(e,t){if(!e.list)return;const r=e.list;if(r.innerHTML="",e.filteredItems.length===0){const n=document.createElement("div");n.className="rte-slash-empty",n.textContent=t.emptyStateText,r.appendChild(n),r.removeAttribute("aria-activedescendant");return}e.filteredItems.forEach((n,o)=>{const i=document.createElement("button");i.type="button",i.className="rte-slash-item",i.setAttribute("role","option"),i.setAttribute("data-index",String(o)),i.setAttribute("id",`rte-slash-item-${e.instanceId}-${o}`),i.setAttribute("aria-selected",o===e.activeIndex?"true":"false"),i.setAttribute("aria-label",n.description?`${n.label} - ${n.description}`:n.label),o===e.activeIndex&&i.classList.add("active"),t.itemRenderer?i.innerHTML=t.itemRenderer(n,e.query):i.innerHTML=`
|
|
88
|
+
<span class="rte-slash-item-title">${k(n.label,e.query)}</span>
|
|
89
|
+
${n.description?`<span class="rte-slash-item-description">${k(n.description,e.query)}</span>`:""}
|
|
90
|
+
`,r.appendChild(i)}),e.filteredItems.length>0&&r.setAttribute("aria-activedescendant",`rte-slash-item-${e.instanceId}-${e.activeIndex}`)}function G(e,t){if(t===e.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",e,t,e.innerHTML)}catch{}}function V(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function L(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertHTML",!1,t))return!0}catch{}const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const n=r.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return!1;n.deleteContents();const o=document.createElement("template");o.innerHTML=t;const i=o.content,a=i.lastChild;if(n.insertNode(i),a){const l=document.createRange();l.setStartAfter(a),l.collapse(!0),y(e,l)}return!0}function X(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertText",!1,t))return!0}catch{}const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const n=r.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return!1;n.deleteContents();const o=document.createTextNode(t);n.insertNode(o);const i=document.createRange();return i.setStart(o,o.length),i.collapse(!0),y(e,i),!0}function J(e,t){switch(e.toLowerCase()){case"paragraph":case"p":return document.execCommand("formatBlock",!1,"<p>");case"heading1":case"h1":return document.execCommand("formatBlock",!1,"<h1>");case"heading2":case"h2":return document.execCommand("formatBlock",!1,"<h2>");case"heading3":case"h3":return document.execCommand("formatBlock",!1,"<h3>");case"blockquote":case"toggleblockquote":return document.execCommand("formatBlock",!1,"<blockquote>");case"bulletlist":case"togglebulletlist":case"insertunorderedlist":return document.execCommand("insertUnorderedList");case"numberedlist":case"toggleorderedlist":case"insertorderedlist":return document.execCommand("insertOrderedList");case"horizontalrule":case"divider":case"inserthorizontalrule":return document.execCommand("insertHorizontalRule");case"bold":case"togglebold":return document.execCommand("bold");case"italic":case"toggleitalic":return document.execCommand("italic");case"underline":case"toggleunderline":return document.execCommand("underline");case"strikethrough":case"togglestrikethrough":return document.execCommand("strikeThrough");case"clearformatting":case"removeformat":return document.execCommand("removeFormat");default:try{return document.execCommand(e,!1,t)}catch{return!1}}}function S(e,t,r){const n=I(e);if(n&&typeof n.execCommand=="function")try{if(n.execCommand(t,r)!==!1)return!0}catch{}const o=window.execEditorCommand||window.executeEditorCommand;if(typeof o=="function")try{if(o(t,r,{editorElement:n,contentElement:e})!==!1)return!0}catch{}return J(t,r)}async function Y(e,t){const r=e.editor,n=I(r),o={editor:r,editorRoot:n,query:e.query,trigger:e.trigger,executeCommand:(i,a)=>S(r,i,a),insertHTML:i=>L(r,i)};return t.action?await Promise.resolve(t.action(o))!==!1:t.insertHTML?L(r,t.insertHTML):t.command?S(r,t.command,t.commandValue):!1}async function M(e,t){if(t<0||t>=e.filteredItems.length||!e.replaceRange)return;const r=e.filteredItems[t],n=e.editor,o=n.innerHTML,i=`${e.trigger}${e.query}`;if(!window.getSelection())return;const l=e.replaceRange.cloneRange();if(!n.contains(l.commonAncestorContainer))return;l.deleteContents();const d=l.cloneRange();d.collapse(!0),y(n,d);let x=!1;try{x=await Y(e,r)}catch{x=!1}c(e),x?(V(n),G(n,o)):i&&X(n,i),n.focus({preventScroll:!0})}function R(e,t){if(e.filteredItems.length===0)return;const r=e.filteredItems.length;if(e.activeIndex=((e.activeIndex+t)%r+r)%r,!e.list)return;const n=Array.from(e.list.querySelectorAll(".rte-slash-item"));n.forEach((i,a)=>{const l=a===e.activeIndex;i.classList.toggle("active",l),i.setAttribute("aria-selected",l?"true":"false")});const o=n[e.activeIndex];o&&(e.list.setAttribute("aria-activedescendant",o.id),o.scrollIntoView({block:"nearest"}))}function T(e){if(!(!e.isOpen||!e.panel||!e.anchorRange)){if(!e.editor.isConnected){c(e);return}A(e,e.anchorRange)}}function N(e,t,r,n,o,i){U(e,t),e.query=n,e.trigger=o,e.replaceRange=i.cloneRange(),e.anchorRange=r.cloneRange(),e.filteredItems=W(e.items,n,t.maxSuggestions),e.activeIndex=0,e.isOpen=!0,e.panel&&(Z(e,t),A(e,r))}function ee(e,t){const r=e.editor;if(r.getAttribute("contenteditable")==="false"){c(e);return}const n=v(r);if(!n||!n.collapsed){c(e);return}const o=j(n);if(!o){c(e);return}const i=K(o.textBefore,t.triggerChar,t.maxQueryLength,t.requireBoundary);if(!i){c(e);return}if(i.query.length<t.minChars){c(e);return}const a=n.cloneRange();a.setStart(o.node,i.startOffset),a.setEnd(o.node,o.caretOffset),N(e,t,n,i.query,i.trigger,a)}function O(e,t){const r=e.editor;if(r.getAttribute("contenteditable")==="false")return!1;let n=v(r);n||(n=document.createRange(),n.selectNodeContents(r),n.collapse(!1),y(r,n));const o=n.cloneRange();return o.collapse(!0),N(e,t,n,"",t.triggerChar,o),!0}function te(e){return!(e.metaKey||e.ctrlKey)||e.altKey?!1:e.key==="/"||e.code==="Slash"}function ne(e,t){return{editor:e,panel:null,list:null,replaceRange:null,items:t.items,filteredItems:[],activeIndex:0,query:"",trigger:t.triggerChar,isOpen:!1,instanceId:++z,anchorRange:null}}function w(e,t){const r=g.get(e);if(r)return r.items=t.items,r;const n=ne(e,t);return g.set(e,n),n}function re(e){const t=g.get(e);t&&(t.panel?.parentNode&&t.panel.parentNode.removeChild(t.panel),g.delete(e))}function C(e,t,r){if(p.has(e))return;const n={input:()=>{ee(t,r)},keydown:o=>{if(t.editor.getAttribute("contenteditable")==="false"){c(t);return}if(!t.isOpen&&te(o)){o.preventDefault(),O(t,r);return}if(t.isOpen){if(o.key==="ArrowDown"){o.preventDefault(),R(t,1);return}if(o.key==="ArrowUp"){o.preventDefault(),R(t,-1);return}if(o.key==="Enter"||o.key==="Tab"){if(t.filteredItems.length===0){o.key==="Tab"&&o.preventDefault(),c(t);return}o.preventDefault(),M(t,t.activeIndex);return}if(o.key==="Escape"){o.preventDefault(),c(t);return}}},blur:()=>{window.setTimeout(()=>{const o=document.activeElement;t.panel&&o&&t.panel.contains(o)||c(t)},0)},mousedown:o=>{if(!t.isOpen||!t.panel)return;const i=o.target;i&&!t.panel.contains(i)&&!e.contains(i)&&c(t)},selectionchange:()=>{if(!t.isOpen)return;const o=v(e);if(!o||!o.collapsed){c(t);return}t.anchorRange=o.cloneRange(),T(t)},reposition:()=>{T(t)}};e.addEventListener("input",n.input),e.addEventListener("keydown",n.keydown),e.addEventListener("blur",n.blur),document.addEventListener("mousedown",n.mousedown,!0),document.addEventListener("selectionchange",n.selectionchange),window.addEventListener("resize",n.reposition,{passive:!0}),window.addEventListener("scroll",n.reposition,!0),p.set(e,n)}function oe(e){const t=p.get(e);t&&(e.removeEventListener("input",t.input),e.removeEventListener("keydown",t.keydown),e.removeEventListener("blur",t.blur),document.removeEventListener("mousedown",t.mousedown,!0),document.removeEventListener("selectionchange",t.selectionchange),window.removeEventListener("resize",t.reposition),window.removeEventListener("scroll",t.reposition,!0),p.delete(e))}function ie(e){b||(b=!0,f=t=>{const r=t.target;if(!(r instanceof Node))return;const o=P(r)?.closest(s)||null;if(!o)return;const i=w(o,e);C(o,i,e)},document.addEventListener("focusin",f,!0))}function ae(){!b||!f||(document.removeEventListener("focusin",f,!0),b=!1,f=null)}const le=(e={})=>{B();const t=D(e);return{name:"slashCommands",toolbar:[{id:"slashCommands",label:"Slash Commands",command:"openSlashCommands",icon:'<svg width="24" height="24" focusable="false" aria-hidden="true"><path d="M8.7 20a1 1 0 0 1-.7-.3c-.4-.4-.4-1 0-1.4L15.6 5a1 1 0 0 1 1.4 1.4L9.4 19.7a1 1 0 0 1-.7.3Zm7.8 0c-.3 0-.5 0-.7-.3l-1.8-1.8a1 1 0 1 1 1.4-1.4l1.8 1.8a1 1 0 0 1-.7 1.7Zm-9-12a1 1 0 0 1-.7-1.7L8.6 4.5A1 1 0 1 1 10 6L8.2 7.8a1 1 0 0 1-.7.3Z"></path></svg>'}],commands:{openSlashCommands:(r,n)=>{const o=_(n);if(!o)return!1;const i=w(o,t);return C(o,i,t),O(i,t)}},keymap:{"Mod-/":"openSlashCommands","Mod-Shift-7":"openSlashCommands"},init:()=>{h+=1,ie(t),Array.from(document.querySelectorAll(s)).forEach(n=>{const o=w(n,t);C(n,o,t)})},destroy:()=>{h=Math.max(0,h-1),Array.from(document.querySelectorAll(s)).forEach(n=>{const o=g.get(n);o&&(c(o),oe(n),re(n))}),h===0&&ae()}}};exports.SlashCommandsPlugin=le;
|