@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.
- package/README.md +1 -1
- package/dist/approval-workflow.cjs.js +14 -14
- package/dist/approval-workflow.esm.js +265 -262
- package/dist/blockquote.cjs.js +1 -1
- package/dist/blockquote.esm.js +177 -15
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +95 -92
- package/dist/bold.cjs.js +1 -1
- package/dist/bold.esm.js +10 -6
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +124 -44
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +251 -191
- package/dist/citations.cjs.js +4 -4
- package/dist/citations.esm.js +131 -128
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +68 -36
- package/dist/code.cjs.js +121 -44
- package/dist/code.esm.js +2694 -889
- package/dist/content-rules.cjs.js +5 -5
- package/dist/content-rules.esm.js +104 -101
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +51 -48
- package/dist/direction.cjs.js +1 -1
- package/dist/direction.esm.js +97 -74
- package/dist/doc-schema.cjs.js +4 -4
- package/dist/doc-schema.esm.js +104 -101
- package/dist/embed-iframe.cjs.js +21 -4
- package/dist/embed-iframe.esm.js +279 -116
- package/dist/heading.cjs.js +1 -1
- package/dist/heading.esm.js +239 -56
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +74 -89
- package/dist/inlineFormatting-DOYOJdnD.js +1 -0
- package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +12 -8
- package/dist/math.cjs.js +27 -21
- package/dist/math.esm.js +218 -146
- package/dist/merge-tag.cjs.js +8 -2
- package/dist/merge-tag.esm.js +130 -111
- package/dist/pii-redaction.cjs.js +6 -6
- package/dist/pii-redaction.esm.js +169 -166
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +120 -117
- package/dist/special-characters.cjs.js +6 -10
- package/dist/special-characters.esm.js +97 -75
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +11 -25
- package/dist/translation-workflow.cjs.js +7 -7
- package/dist/translation-workflow.esm.js +103 -100
- package/dist/underline.cjs.js +1 -1
- package/dist/underline.esm.js +7 -3
- package/package.json +3 -3
package/dist/embed-iframe.cjs.js
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
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=[{label:"Inline Value",value:"inline"},{label:"Responsive - 21x9",value:"21x9"},{label:"Responsive - 16x9",value:"16x9"},{label:"Responsive - 4x3",value:"4x3"},{label:"Responsive - 1x1",value:"1x1"}],u='[data-theme="dark"], .dark, .editora-theme-dark';let l=null;const v=new WeakMap,s=e=>(v.has(e)||v.set(e,{dialogElement:null,escapeHandler:null,savedRange:null,activeTab:"general",formData:{src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0}}),v.get(e));function C(e){return e?.matches(u)||e?.closest(u)||document.activeElement?.closest(u)?!0:document.body.matches(u)||document.documentElement.matches(u)}function x(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function R(e){const t=e?.editorElement;if(t instanceof HTMLElement)return t;const r=e?.contentElement;if(r instanceof HTMLElement){const i=r.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");return i instanceof HTMLElement?i:r}const o=window.__editoraCommandEditorRoot;if(o instanceof HTMLElement)return o;const a=window.getSelection();if(a&&a.rangeCount>0){const c=x(a.getRangeAt(0).startContainer)?.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");if(c instanceof HTMLElement)return c}const n=document.activeElement;if(n instanceof HTMLElement){const i=n.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");if(i instanceof HTMLElement)return i}return document.querySelector("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")}function w(e){return e.getAttribute("contenteditable")==="true"?e:e.querySelector('.rte-content, .editora-content, [contenteditable="true"]')}function h(e){return x(e)?.closest('.rte-content, .editora-content, [contenteditable="true"]')}function L(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return!e.contains(r.startContainer)||!e.contains(r.endContainer)?null:r.cloneRange()}function k(e,t,r){if(t!==r){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",e,t,r);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:e,beforeHTML:t,afterHTML:r})}catch{}}}function I(e,t){let r=t;for(;r&&r.parentNode&&r.parentNode!==e;)r=r.parentNode;return r&&r.parentNode===e?r:null}function y(e,t){return e.tagName!=="P"?!1:Array.from(e.childNodes).every(r=>r===t?!0:r.nodeType===Node.ELEMENT_NODE?r.tagName==="BR":r.nodeType===Node.TEXT_NODE&&!r.textContent?.trim())}function T(e){if(!(e instanceof Element))return null;const t=e.closest("iframe");if(t instanceof HTMLIFrameElement){const n=h(t);if(!n)return null;const i=t.parentElement;return i&&i.parentElement===n&&y(i,t)?i:t}const r=e.closest("p");if(!(r instanceof HTMLElement))return null;const o=h(r);if(!o||r.parentElement!==o)return null;const a=Array.from(r.children).find(n=>n instanceof HTMLIFrameElement);return a&&y(r,a)?r:null}function f(){l&&(l.classList.remove("rte-selected-embed-object"),l.querySelector("iframe")?.removeAttribute("data-rte-selected-object"),l instanceof HTMLIFrameElement&&l.removeAttribute("data-rte-selected-object"),l=null)}function H(e){if(l===e)return;f(),l=e,e.classList.add("rte-selected-embed-object"),(e instanceof HTMLIFrameElement?e:e.querySelector("iframe"))?.setAttribute("data-rte-selected-object","true");const r=window.getSelection();if(!r)return;const o=document.createRange();o.selectNode(e),r.removeAllRanges(),r.addRange(o)}function N(e,t){const r=window.getSelection();if(!r)return;const o=document.createRange();t&&t.parentNode===e?o.setStartBefore(t):(o.selectNodeContents(e),o.collapse(!1)),o.collapse(!0),r.removeAllRanges(),r.addRange(o)}function q(e){if(e.childNodes.length>0)return;const t=document.createElement("p");t.appendChild(document.createElement("br")),e.appendChild(t)}function A(){if(!l||!l.isConnected)return f(),!1;const e=l,t=h(e);if(!t)return f(),!1;const r=t.innerHTML,o=e.nextSibling;e.remove(),q(t),f(),N(t,o);const a=t.innerHTML;return k(t,r,a),t.dispatchEvent(new window.Event("input",{bubbles:!0})),r!==a}function E(){if(document.getElementById("embed-iframe-object-selection-styles"))return;const e=document.createElement("style");e.id="embed-iframe-object-selection-styles",e.textContent=`
|
|
2
|
+
.rte-selected-embed-object {
|
|
3
|
+
outline: 2px solid #2563eb;
|
|
4
|
+
outline-offset: 3px;
|
|
5
|
+
border-radius: 4px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.rte-content iframe,
|
|
9
|
+
.editora-content iframe,
|
|
10
|
+
[contenteditable="true"] iframe {
|
|
11
|
+
pointer-events: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.rte-selected-embed-object iframe,
|
|
15
|
+
iframe.rte-selected-embed-object {
|
|
16
|
+
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.28);
|
|
17
|
+
}
|
|
18
|
+
`,document.head.appendChild(e)}function M(){typeof window>"u"||window.__embedIframeObjectSelectionInitialized||(window.__embedIframeObjectSelectionInitialized=!0,E(),document.addEventListener("pointerdown",e=>{const t=T(e.target);if(!t){e.target?.closest?.(".rte-embed-iframe-overlay")||f();return}e.preventDefault(),h(t)?.focus(),H(t)},!0),document.addEventListener("keydown",e=>{if(l){if(e.key==="Escape"){f();return}e.key!=="Backspace"&&e.key!=="Delete"||(e.preventDefault(),e.stopPropagation(),A())}},!0))}function z(e){try{const t=new URL(e),r=t.hostname.replace(/^www\./,"");if(r==="youtu.be"){const o=t.pathname.split("/").filter(Boolean)[0];if(o)return`https://www.youtube.com/embed/${encodeURIComponent(o)}`}if(r==="youtube.com"||r==="m.youtube.com"){const o=t.searchParams.get("v");if(o)return`https://www.youtube.com/embed/${encodeURIComponent(o)}`;const a=t.pathname.match(/^\/embed\/([^/]+)/);if(a?.[1])return`https://www.youtube.com/embed/${encodeURIComponent(a[1])}`}if(r==="vimeo.com"){const o=t.pathname.split("/").filter(Boolean)[0];if(o&&/^\d+$/.test(o))return`https://player.vimeo.com/video/${o}`}return e}catch{return e}}const j=()=>({name:"embedIframe",init:M,toolbar:[{label:"Embed Content",command:"openEmbedIframeDialog",icon:'<svg width="24" height="24" focusable="false"><path d="M19 6V5H5v14h2A13 13 0 0 1 19 6Zm0 1.4c-.8.8-1.6 2.4-2.2 4.6H19V7.4Zm0 5.6h-2.4c-.4 1.8-.6 3.8-.6 6h3v-6Zm-4 6c0-2.2.2-4.2.6-6H13c-.7 1.8-1.1 3.8-1.1 6h3Zm-4 0c0-2.2.4-4.2 1-6H9.6A12 12 0 0 0 8 19h3ZM4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm11.8 9c.4-1.9 1-3.4 1.8-4.5a9.2 9.2 0 0 0-4 4.5h2.2Zm-3.4 0a12 12 0 0 1 2.8-4 12 12 0 0 0-5 4h2.2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-Shift-e",type:"button"}],commands:{openEmbedIframeDialog:(e,t)=>(P(R(t)||void 0),!0)},keymap:{"Mod-Shift-e":"openEmbedIframeDialog"}});function P(e){if(!e){const n=document.activeElement;n&&n.closest("[data-editora-editor]")&&(e=n.closest("[data-editora-editor]"))}if(e||(e=document.querySelector("[data-editora-editor]")),!e){console.warn("Editor element not found");return}const t=s(e),r=w(e);t.savedRange=r?L(r):null,t.formData={src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0},t.activeTab="general";const o=document.createElement("div");o.className="rte-dialog-overlay rte-embed-iframe-overlay",C(e)&&o.classList.add("rte-theme-dark"),o.onclick=()=>b(e);const a=document.createElement("div");a.className="rte-dialog-content embed-iframe-dialog",a.onclick=n=>n.stopPropagation(),a.innerHTML=`
|
|
2
19
|
<div class="rte-dialog-header">
|
|
3
20
|
<h3>Embed Iframe</h3>
|
|
4
21
|
<button class="rte-dialog-close">×</button>
|
|
@@ -18,7 +35,7 @@
|
|
|
18
35
|
<div class="rte-form-group">
|
|
19
36
|
<label class="rte-form-label">Size</label>
|
|
20
37
|
<select class="rte-form-select" id="iframe-size">
|
|
21
|
-
${
|
|
38
|
+
${D.map(n=>`<option value="${n.value}">${n.label}</option>`).join("")}
|
|
22
39
|
</select>
|
|
23
40
|
</div>
|
|
24
41
|
<div class="rte-form-row" id="dimensions-row">
|
|
@@ -72,7 +89,7 @@
|
|
|
72
89
|
<button type="button" class="rte-btn rte-btn-secondary" id="cancel-btn">Cancel</button>
|
|
73
90
|
<button type="submit" class="rte-btn rte-btn-primary" id="save-btn">Save</button>
|
|
74
91
|
</div>
|
|
75
|
-
`,
|
|
92
|
+
`,o.appendChild(a),document.body.appendChild(o),t.dialogElement=o,t.escapeHandler=n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),b(e))},document.addEventListener("keydown",t.escapeHandler,!0),O(a,e),W(),setTimeout(()=>{a.querySelector("#iframe-src")?.focus()},100)}function O(e,t){s(t),e.querySelector(".rte-dialog-close")?.addEventListener("click",()=>b(t)),e.querySelectorAll(".rte-tab-button").forEach(n=>{n.addEventListener("click",i=>{const c=i.target.getAttribute("data-tab");c&&_(e,c,t)})}),e.querySelector("#iframe-size")?.addEventListener("change",n=>B(e,n.target.value,t));const o=e.querySelector("#iframe-width"),a=e.querySelector("#iframe-height");o?.addEventListener("input",n=>U(e,n.target.value,t)),a?.addEventListener("input",n=>$(e,n.target.value,t)),e.querySelector("#constrain-btn")?.addEventListener("click",()=>F(e,t)),e.querySelector("#cancel-btn")?.addEventListener("click",()=>b(t)),e.querySelector("#save-btn")?.addEventListener("click",()=>Z(e,t))}function _(e,t,r){const o=s(r);o.activeTab=t,e.querySelectorAll(".rte-tab-button").forEach(a=>{a.classList.toggle("active",a.getAttribute("data-tab")===t)}),e.querySelectorAll(".rte-tab-panel").forEach(a=>{a.style.display=a.getAttribute("data-panel")===t?"block":"none"})}function B(e,t,r){const o=s(r);o.formData.selectedSize=t;const a=e.querySelector("#dimensions-row"),n=e.querySelector("#iframe-width"),i=e.querySelector("#iframe-height");t==="inline"?(a.style.display="flex",n.value="100%",i.value="400px",o.formData.width="100%",o.formData.height="400px"):(a.style.display="none",o.formData.width="100%",o.formData.height="auto")}function U(e,t,r){const o=s(r);if(o.formData.width=t,o.formData.constrainProportions&&o.formData.selectedSize==="inline"){const a=parseFloat(t);if(!isNaN(a)){const n=a*9/16;o.formData.height=`${n}px`;const i=e.querySelector("#iframe-height");i&&(i.value=o.formData.height)}}}function $(e,t,r){const o=s(r);if(o.formData.height=t,o.formData.constrainProportions&&o.formData.selectedSize==="inline"){const a=parseFloat(t);if(!isNaN(a)){const n=a*16/9;o.formData.width=`${n}px`;const i=e.querySelector("#iframe-width");i&&(i.value=o.formData.width)}}}function F(e,t){const r=s(t);r.formData.constrainProportions=!r.formData.constrainProportions;const o=e.querySelector("#constrain-btn");o&&(o.textContent=r.formData.constrainProportions?"🔒":"🔓",o.className=`rte-constrain-btn ${r.formData.constrainProportions?"locked":"unlocked"}`,o.title=r.formData.constrainProportions?"Unlock proportions":"Lock proportions")}function Z(e,t){const r=s(t),o=e.querySelector("#iframe-src")?.value.trim();if(!o){alert("Please enter a source URL");return}if(!o.startsWith("https://")&&!o.startsWith("http://")){alert("Please enter a valid URL starting with https:// or http://");return}const a=e.querySelector("#iframe-name")?.value.trim(),n=e.querySelector("#iframe-title")?.value.trim(),i=e.querySelector("#iframe-longdesc")?.value.trim(),c=e.querySelector("#iframe-desc-url")?.value.trim(),p=e.querySelector("#iframe-border")?.checked??!0,g=e.querySelector("#iframe-scrollbar")?.checked??!0;let d=r.formData.width,m=r.formData.height;r.formData.selectedSize!=="inline"&&(d="100%",m="auto"),V(t,{src:o,width:d,height:m,aspectRatio:r.formData.selectedSize,name:a||void 0,title:n||void 0,longDescription:i||void 0,descriptionUrl:c||void 0,showBorder:p,enableScrollbar:g}),b(t)}function V(e,t){const r=s(e),o=w(e);if(!o)return;const a=o.innerHTML,n=document.createElement("iframe");n.src=z(t.src),n.width=t.width,n.height=t.height,n.allowFullscreen=!0,n.setAttribute("frameborder",t.showBorder?"1":"0"),n.setAttribute("scrolling",t.enableScrollbar?"auto":"no"),n.setAttribute("data-aspect-ratio",t.aspectRatio),t.aspectRatio!=="inline"&&n.classList.add(`rte-iframe-${t.aspectRatio}`),t.name&&(n.name=t.name),t.title&&(n.title=t.title),t.longDescription&&n.setAttribute("data-long-description",t.longDescription),t.descriptionUrl&&n.setAttribute("longdesc",t.descriptionUrl);const i=document.createElement("p");i.appendChild(n),i.appendChild(document.createElement("br"));const c=r.savedRange&&o.contains(r.savedRange.commonAncestorContainer)?r.savedRange:document.createRange();(!r.savedRange||!o.contains(r.savedRange.commonAncestorContainer))&&(c.selectNodeContents(o),c.collapse(!1));const p=I(o,c.startContainer),g=p?p.nextSibling:null;o.insertBefore(i,g);const d=document.createRange();d.setStartAfter(i),d.collapse(!0);const m=window.getSelection();m&&(m.removeAllRanges(),m.addRange(d)),r.savedRange=null;const S=o.innerHTML;k(o,a,S),o.dispatchEvent(new window.Event("input",{bubbles:!0}))}function b(e){const t=s(e);t.savedRange=null,t.escapeHandler&&(document.removeEventListener("keydown",t.escapeHandler,!0),t.escapeHandler=null),t.dialogElement&&(t.dialogElement.remove(),t.dialogElement=null)}function W(){if(E(),document.getElementById("embed-iframe-dialog-styles"))return;const e=document.createElement("style");e.id="embed-iframe-dialog-styles",e.textContent=`
|
|
76
93
|
/* Embed Iframe Dialog Styles */
|
|
77
94
|
.embed-iframe-dialog {
|
|
78
95
|
max-width: 600px;
|
|
@@ -358,4 +375,4 @@
|
|
|
358
375
|
width: 100%;
|
|
359
376
|
height: 100%;
|
|
360
377
|
}
|
|
361
|
-
`,document.head.appendChild(e)}exports.EmbedIframePlugin=
|
|
378
|
+
`,document.head.appendChild(e)}exports.EmbedIframePlugin=j;
|
package/dist/embed-iframe.esm.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
const
|
|
1
|
+
const D = [
|
|
2
2
|
{ label: "Inline Value", value: "inline" },
|
|
3
3
|
{ label: "Responsive - 21x9", value: "21x9" },
|
|
4
4
|
{ label: "Responsive - 16x9", value: "16x9" },
|
|
5
5
|
{ label: "Responsive - 4x3", value: "4x3" },
|
|
6
6
|
{ label: "Responsive - 1x1", value: "1x1" }
|
|
7
|
-
],
|
|
7
|
+
], u = '[data-theme="dark"], .dark, .editora-theme-dark';
|
|
8
|
+
let c = null;
|
|
9
|
+
const v = /* @__PURE__ */ new WeakMap(), s = (e) => (v.has(e) || v.set(e, {
|
|
8
10
|
dialogElement: null,
|
|
9
11
|
escapeHandler: null,
|
|
12
|
+
savedRange: null,
|
|
10
13
|
activeTab: "general",
|
|
11
14
|
formData: {
|
|
12
15
|
src: "",
|
|
@@ -21,12 +24,185 @@ const g = [
|
|
|
21
24
|
showBorder: !0,
|
|
22
25
|
enableScrollbar: !0
|
|
23
26
|
}
|
|
24
|
-
}),
|
|
25
|
-
function
|
|
26
|
-
return e?.matches(
|
|
27
|
+
}), v.get(e));
|
|
28
|
+
function C(e) {
|
|
29
|
+
return e?.matches(u) || e?.closest(u) || document.activeElement?.closest(u) ? !0 : document.body.matches(u) || document.documentElement.matches(u);
|
|
27
30
|
}
|
|
28
|
-
|
|
31
|
+
function x(e) {
|
|
32
|
+
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
|
|
33
|
+
}
|
|
34
|
+
function R(e) {
|
|
35
|
+
const t = e?.editorElement;
|
|
36
|
+
if (t instanceof HTMLElement) return t;
|
|
37
|
+
const r = e?.contentElement;
|
|
38
|
+
if (r instanceof HTMLElement) {
|
|
39
|
+
const i = r.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
|
|
40
|
+
return i instanceof HTMLElement ? i : r;
|
|
41
|
+
}
|
|
42
|
+
const o = window.__editoraCommandEditorRoot;
|
|
43
|
+
if (o instanceof HTMLElement) return o;
|
|
44
|
+
const a = window.getSelection();
|
|
45
|
+
if (a && a.rangeCount > 0) {
|
|
46
|
+
const l = x(a.getRangeAt(0).startContainer)?.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
|
|
47
|
+
if (l instanceof HTMLElement) return l;
|
|
48
|
+
}
|
|
49
|
+
const n = document.activeElement;
|
|
50
|
+
if (n instanceof HTMLElement) {
|
|
51
|
+
const i = n.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
|
|
52
|
+
if (i instanceof HTMLElement) return i;
|
|
53
|
+
}
|
|
54
|
+
return document.querySelector("[data-editora-editor], .rte-editor, .editora-editor, editora-editor");
|
|
55
|
+
}
|
|
56
|
+
function w(e) {
|
|
57
|
+
return e.getAttribute("contenteditable") === "true" ? e : e.querySelector('.rte-content, .editora-content, [contenteditable="true"]');
|
|
58
|
+
}
|
|
59
|
+
function h(e) {
|
|
60
|
+
return x(e)?.closest('.rte-content, .editora-content, [contenteditable="true"]');
|
|
61
|
+
}
|
|
62
|
+
function L(e) {
|
|
63
|
+
const t = window.getSelection();
|
|
64
|
+
if (!t || t.rangeCount === 0) return null;
|
|
65
|
+
const r = t.getRangeAt(0);
|
|
66
|
+
return !e.contains(r.startContainer) || !e.contains(r.endContainer) ? null : r.cloneRange();
|
|
67
|
+
}
|
|
68
|
+
function k(e, t, r) {
|
|
69
|
+
if (t !== r) {
|
|
70
|
+
if (typeof window.execEditorCommand == "function") {
|
|
71
|
+
window.execEditorCommand("recordDomTransaction", e, t, r);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (typeof window.executeEditorCommand == "function")
|
|
75
|
+
try {
|
|
76
|
+
window.executeEditorCommand("recordDomTransaction", { editor: e, beforeHTML: t, afterHTML: r });
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function I(e, t) {
|
|
82
|
+
let r = t;
|
|
83
|
+
for (; r && r.parentNode && r.parentNode !== e; )
|
|
84
|
+
r = r.parentNode;
|
|
85
|
+
return r && r.parentNode === e ? r : null;
|
|
86
|
+
}
|
|
87
|
+
function y(e, t) {
|
|
88
|
+
return e.tagName !== "P" ? !1 : Array.from(e.childNodes).every((r) => r === t ? !0 : r.nodeType === Node.ELEMENT_NODE ? r.tagName === "BR" : r.nodeType === Node.TEXT_NODE && !r.textContent?.trim());
|
|
89
|
+
}
|
|
90
|
+
function T(e) {
|
|
91
|
+
if (!(e instanceof Element)) return null;
|
|
92
|
+
const t = e.closest("iframe");
|
|
93
|
+
if (t instanceof HTMLIFrameElement) {
|
|
94
|
+
const n = h(t);
|
|
95
|
+
if (!n) return null;
|
|
96
|
+
const i = t.parentElement;
|
|
97
|
+
return i && i.parentElement === n && y(i, t) ? i : t;
|
|
98
|
+
}
|
|
99
|
+
const r = e.closest("p");
|
|
100
|
+
if (!(r instanceof HTMLElement)) return null;
|
|
101
|
+
const o = h(r);
|
|
102
|
+
if (!o || r.parentElement !== o) return null;
|
|
103
|
+
const a = Array.from(r.children).find(
|
|
104
|
+
(n) => n instanceof HTMLIFrameElement
|
|
105
|
+
);
|
|
106
|
+
return a && y(r, a) ? r : null;
|
|
107
|
+
}
|
|
108
|
+
function f() {
|
|
109
|
+
c && (c.classList.remove("rte-selected-embed-object"), c.querySelector("iframe")?.removeAttribute("data-rte-selected-object"), c instanceof HTMLIFrameElement && c.removeAttribute("data-rte-selected-object"), c = null);
|
|
110
|
+
}
|
|
111
|
+
function H(e) {
|
|
112
|
+
if (c === e) return;
|
|
113
|
+
f(), c = e, e.classList.add("rte-selected-embed-object"), (e instanceof HTMLIFrameElement ? e : e.querySelector("iframe"))?.setAttribute("data-rte-selected-object", "true");
|
|
114
|
+
const r = window.getSelection();
|
|
115
|
+
if (!r) return;
|
|
116
|
+
const o = document.createRange();
|
|
117
|
+
o.selectNode(e), r.removeAllRanges(), r.addRange(o);
|
|
118
|
+
}
|
|
119
|
+
function N(e, t) {
|
|
120
|
+
const r = window.getSelection();
|
|
121
|
+
if (!r) return;
|
|
122
|
+
const o = document.createRange();
|
|
123
|
+
t && t.parentNode === e ? o.setStartBefore(t) : (o.selectNodeContents(e), o.collapse(!1)), o.collapse(!0), r.removeAllRanges(), r.addRange(o);
|
|
124
|
+
}
|
|
125
|
+
function q(e) {
|
|
126
|
+
if (e.childNodes.length > 0) return;
|
|
127
|
+
const t = document.createElement("p");
|
|
128
|
+
t.appendChild(document.createElement("br")), e.appendChild(t);
|
|
129
|
+
}
|
|
130
|
+
function A() {
|
|
131
|
+
if (!c || !c.isConnected)
|
|
132
|
+
return f(), !1;
|
|
133
|
+
const e = c, t = h(e);
|
|
134
|
+
if (!t)
|
|
135
|
+
return f(), !1;
|
|
136
|
+
const r = t.innerHTML, o = e.nextSibling;
|
|
137
|
+
e.remove(), q(t), f(), N(t, o);
|
|
138
|
+
const a = t.innerHTML;
|
|
139
|
+
return k(t, r, a), t.dispatchEvent(new window.Event("input", { bubbles: !0 })), r !== a;
|
|
140
|
+
}
|
|
141
|
+
function E() {
|
|
142
|
+
if (document.getElementById("embed-iframe-object-selection-styles")) return;
|
|
143
|
+
const e = document.createElement("style");
|
|
144
|
+
e.id = "embed-iframe-object-selection-styles", e.textContent = `
|
|
145
|
+
.rte-selected-embed-object {
|
|
146
|
+
outline: 2px solid #2563eb;
|
|
147
|
+
outline-offset: 3px;
|
|
148
|
+
border-radius: 4px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.rte-content iframe,
|
|
152
|
+
.editora-content iframe,
|
|
153
|
+
[contenteditable="true"] iframe {
|
|
154
|
+
pointer-events: none;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.rte-selected-embed-object iframe,
|
|
158
|
+
iframe.rte-selected-embed-object {
|
|
159
|
+
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.28);
|
|
160
|
+
}
|
|
161
|
+
`, document.head.appendChild(e);
|
|
162
|
+
}
|
|
163
|
+
function M() {
|
|
164
|
+
typeof window > "u" || window.__embedIframeObjectSelectionInitialized || (window.__embedIframeObjectSelectionInitialized = !0, E(), document.addEventListener("pointerdown", (e) => {
|
|
165
|
+
const t = T(e.target);
|
|
166
|
+
if (!t) {
|
|
167
|
+
e.target?.closest?.(".rte-embed-iframe-overlay") || f();
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
e.preventDefault(), h(t)?.focus(), H(t);
|
|
171
|
+
}, !0), document.addEventListener("keydown", (e) => {
|
|
172
|
+
if (c) {
|
|
173
|
+
if (e.key === "Escape") {
|
|
174
|
+
f();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
e.key !== "Backspace" && e.key !== "Delete" || (e.preventDefault(), e.stopPropagation(), A());
|
|
178
|
+
}
|
|
179
|
+
}, !0));
|
|
180
|
+
}
|
|
181
|
+
function z(e) {
|
|
182
|
+
try {
|
|
183
|
+
const t = new URL(e), r = t.hostname.replace(/^www\./, "");
|
|
184
|
+
if (r === "youtu.be") {
|
|
185
|
+
const o = t.pathname.split("/").filter(Boolean)[0];
|
|
186
|
+
if (o) return `https://www.youtube.com/embed/${encodeURIComponent(o)}`;
|
|
187
|
+
}
|
|
188
|
+
if (r === "youtube.com" || r === "m.youtube.com") {
|
|
189
|
+
const o = t.searchParams.get("v");
|
|
190
|
+
if (o) return `https://www.youtube.com/embed/${encodeURIComponent(o)}`;
|
|
191
|
+
const a = t.pathname.match(/^\/embed\/([^/]+)/);
|
|
192
|
+
if (a?.[1]) return `https://www.youtube.com/embed/${encodeURIComponent(a[1])}`;
|
|
193
|
+
}
|
|
194
|
+
if (r === "vimeo.com") {
|
|
195
|
+
const o = t.pathname.split("/").filter(Boolean)[0];
|
|
196
|
+
if (o && /^\d+$/.test(o)) return `https://player.vimeo.com/video/${o}`;
|
|
197
|
+
}
|
|
198
|
+
return e;
|
|
199
|
+
} catch {
|
|
200
|
+
return e;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const W = () => ({
|
|
29
204
|
name: "embedIframe",
|
|
205
|
+
init: M,
|
|
30
206
|
toolbar: [
|
|
31
207
|
{
|
|
32
208
|
label: "Embed Content",
|
|
@@ -37,23 +213,23 @@ const I = () => ({
|
|
|
37
213
|
}
|
|
38
214
|
],
|
|
39
215
|
commands: {
|
|
40
|
-
openEmbedIframeDialog: (e) => (
|
|
216
|
+
openEmbedIframeDialog: (e, t) => (j(R(t) || void 0), !0)
|
|
41
217
|
},
|
|
42
218
|
keymap: {
|
|
43
219
|
"Mod-Shift-e": "openEmbedIframeDialog"
|
|
44
220
|
}
|
|
45
221
|
});
|
|
46
|
-
function
|
|
222
|
+
function j(e) {
|
|
47
223
|
if (!e) {
|
|
48
|
-
const
|
|
49
|
-
|
|
224
|
+
const n = document.activeElement;
|
|
225
|
+
n && n.closest("[data-editora-editor]") && (e = n.closest("[data-editora-editor]"));
|
|
50
226
|
}
|
|
51
227
|
if (e || (e = document.querySelector("[data-editora-editor]")), !e) {
|
|
52
228
|
console.warn("Editor element not found");
|
|
53
229
|
return;
|
|
54
230
|
}
|
|
55
|
-
const t =
|
|
56
|
-
t.formData = {
|
|
231
|
+
const t = s(e), r = w(e);
|
|
232
|
+
t.savedRange = r ? L(r) : null, t.formData = {
|
|
57
233
|
src: "",
|
|
58
234
|
selectedSize: "inline",
|
|
59
235
|
width: "100%",
|
|
@@ -66,10 +242,10 @@ function x(e) {
|
|
|
66
242
|
showBorder: !0,
|
|
67
243
|
enableScrollbar: !0
|
|
68
244
|
}, t.activeTab = "general";
|
|
245
|
+
const o = document.createElement("div");
|
|
246
|
+
o.className = "rte-dialog-overlay rte-embed-iframe-overlay", C(e) && o.classList.add("rte-theme-dark"), o.onclick = () => b(e);
|
|
69
247
|
const a = document.createElement("div");
|
|
70
|
-
a.className = "rte-dialog-
|
|
71
|
-
const r = document.createElement("div");
|
|
72
|
-
r.className = "rte-dialog-content embed-iframe-dialog", r.onclick = (o) => o.stopPropagation(), r.innerHTML = `
|
|
248
|
+
a.className = "rte-dialog-content embed-iframe-dialog", a.onclick = (n) => n.stopPropagation(), a.innerHTML = `
|
|
73
249
|
<div class="rte-dialog-header">
|
|
74
250
|
<h3>Embed Iframe</h3>
|
|
75
251
|
<button class="rte-dialog-close">×</button>
|
|
@@ -89,7 +265,7 @@ function x(e) {
|
|
|
89
265
|
<div class="rte-form-group">
|
|
90
266
|
<label class="rte-form-label">Size</label>
|
|
91
267
|
<select class="rte-form-select" id="iframe-size">
|
|
92
|
-
${
|
|
268
|
+
${D.map((n) => `<option value="${n.value}">${n.label}</option>`).join("")}
|
|
93
269
|
</select>
|
|
94
270
|
</div>
|
|
95
271
|
<div class="rte-form-row" id="dimensions-row">
|
|
@@ -143,128 +319,115 @@ function x(e) {
|
|
|
143
319
|
<button type="button" class="rte-btn rte-btn-secondary" id="cancel-btn">Cancel</button>
|
|
144
320
|
<button type="submit" class="rte-btn rte-btn-primary" id="save-btn">Save</button>
|
|
145
321
|
</div>
|
|
146
|
-
`,
|
|
147
|
-
|
|
148
|
-
}, document.addEventListener("keydown", t.escapeHandler, !0),
|
|
149
|
-
|
|
322
|
+
`, o.appendChild(a), document.body.appendChild(o), t.dialogElement = o, t.escapeHandler = (n) => {
|
|
323
|
+
n.key === "Escape" && (n.preventDefault(), n.stopPropagation(), b(e));
|
|
324
|
+
}, document.addEventListener("keydown", t.escapeHandler, !0), P(a, e), V(), setTimeout(() => {
|
|
325
|
+
a.querySelector("#iframe-src")?.focus();
|
|
150
326
|
}, 100);
|
|
151
327
|
}
|
|
152
|
-
function
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
328
|
+
function P(e, t) {
|
|
329
|
+
s(t), e.querySelector(".rte-dialog-close")?.addEventListener("click", () => b(t)), e.querySelectorAll(".rte-tab-button").forEach((n) => {
|
|
330
|
+
n.addEventListener("click", (i) => {
|
|
331
|
+
const l = i.target.getAttribute("data-tab");
|
|
332
|
+
l && O(e, l, t);
|
|
157
333
|
});
|
|
158
|
-
}), e.querySelector("#iframe-size")?.addEventListener("change", (
|
|
159
|
-
const
|
|
160
|
-
|
|
334
|
+
}), e.querySelector("#iframe-size")?.addEventListener("change", (n) => B(e, n.target.value, t));
|
|
335
|
+
const o = e.querySelector("#iframe-width"), a = e.querySelector("#iframe-height");
|
|
336
|
+
o?.addEventListener("input", (n) => U(e, n.target.value, t)), a?.addEventListener("input", (n) => _(e, n.target.value, t)), e.querySelector("#constrain-btn")?.addEventListener("click", () => $(e, t)), e.querySelector("#cancel-btn")?.addEventListener("click", () => b(t)), e.querySelector("#save-btn")?.addEventListener("click", () => F(e, t));
|
|
161
337
|
}
|
|
162
|
-
function
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}), e.querySelectorAll(".rte-tab-panel").forEach((
|
|
167
|
-
|
|
338
|
+
function O(e, t, r) {
|
|
339
|
+
const o = s(r);
|
|
340
|
+
o.activeTab = t, e.querySelectorAll(".rte-tab-button").forEach((a) => {
|
|
341
|
+
a.classList.toggle("active", a.getAttribute("data-tab") === t);
|
|
342
|
+
}), e.querySelectorAll(".rte-tab-panel").forEach((a) => {
|
|
343
|
+
a.style.display = a.getAttribute("data-panel") === t ? "block" : "none";
|
|
168
344
|
});
|
|
169
345
|
}
|
|
170
|
-
function
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
t === "inline" ? (
|
|
346
|
+
function B(e, t, r) {
|
|
347
|
+
const o = s(r);
|
|
348
|
+
o.formData.selectedSize = t;
|
|
349
|
+
const a = e.querySelector("#dimensions-row"), n = e.querySelector("#iframe-width"), i = e.querySelector("#iframe-height");
|
|
350
|
+
t === "inline" ? (a.style.display = "flex", n.value = "100%", i.value = "400px", o.formData.width = "100%", o.formData.height = "400px") : (a.style.display = "none", o.formData.width = "100%", o.formData.height = "auto");
|
|
175
351
|
}
|
|
176
|
-
function
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
const
|
|
180
|
-
if (!isNaN(
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
352
|
+
function U(e, t, r) {
|
|
353
|
+
const o = s(r);
|
|
354
|
+
if (o.formData.width = t, o.formData.constrainProportions && o.formData.selectedSize === "inline") {
|
|
355
|
+
const a = parseFloat(t);
|
|
356
|
+
if (!isNaN(a)) {
|
|
357
|
+
const n = a * 9 / 16;
|
|
358
|
+
o.formData.height = `${n}px`;
|
|
359
|
+
const i = e.querySelector("#iframe-height");
|
|
360
|
+
i && (i.value = o.formData.height);
|
|
185
361
|
}
|
|
186
362
|
}
|
|
187
363
|
}
|
|
188
|
-
function
|
|
189
|
-
const
|
|
190
|
-
if (
|
|
191
|
-
const
|
|
192
|
-
if (!isNaN(
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
364
|
+
function _(e, t, r) {
|
|
365
|
+
const o = s(r);
|
|
366
|
+
if (o.formData.height = t, o.formData.constrainProportions && o.formData.selectedSize === "inline") {
|
|
367
|
+
const a = parseFloat(t);
|
|
368
|
+
if (!isNaN(a)) {
|
|
369
|
+
const n = a * 16 / 9;
|
|
370
|
+
o.formData.width = `${n}px`;
|
|
371
|
+
const i = e.querySelector("#iframe-width");
|
|
372
|
+
i && (i.value = o.formData.width);
|
|
197
373
|
}
|
|
198
374
|
}
|
|
199
375
|
}
|
|
200
|
-
function
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
|
|
376
|
+
function $(e, t) {
|
|
377
|
+
const r = s(t);
|
|
378
|
+
r.formData.constrainProportions = !r.formData.constrainProportions;
|
|
379
|
+
const o = e.querySelector("#constrain-btn");
|
|
380
|
+
o && (o.textContent = r.formData.constrainProportions ? "🔒" : "🔓", o.className = `rte-constrain-btn ${r.formData.constrainProportions ? "locked" : "unlocked"}`, o.title = r.formData.constrainProportions ? "Unlock proportions" : "Lock proportions");
|
|
205
381
|
}
|
|
206
|
-
function
|
|
207
|
-
const
|
|
208
|
-
if (!
|
|
382
|
+
function F(e, t) {
|
|
383
|
+
const r = s(t), o = e.querySelector("#iframe-src")?.value.trim();
|
|
384
|
+
if (!o) {
|
|
209
385
|
alert("Please enter a source URL");
|
|
210
386
|
return;
|
|
211
387
|
}
|
|
212
|
-
if (!
|
|
388
|
+
if (!o.startsWith("https://") && !o.startsWith("http://")) {
|
|
213
389
|
alert("Please enter a valid URL starting with https:// or http://");
|
|
214
390
|
return;
|
|
215
391
|
}
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}), f(t);
|
|
392
|
+
const a = e.querySelector("#iframe-name")?.value.trim(), n = e.querySelector("#iframe-title")?.value.trim(), i = e.querySelector("#iframe-longdesc")?.value.trim(), l = e.querySelector("#iframe-desc-url")?.value.trim(), p = e.querySelector("#iframe-border")?.checked ?? !0, g = e.querySelector("#iframe-scrollbar")?.checked ?? !0;
|
|
393
|
+
let d = r.formData.width, m = r.formData.height;
|
|
394
|
+
r.formData.selectedSize !== "inline" && (d = "100%", m = "auto"), Z(t, {
|
|
395
|
+
src: o,
|
|
396
|
+
width: d,
|
|
397
|
+
height: m,
|
|
398
|
+
aspectRatio: r.formData.selectedSize,
|
|
399
|
+
name: a || void 0,
|
|
400
|
+
title: n || void 0,
|
|
401
|
+
longDescription: i || void 0,
|
|
402
|
+
descriptionUrl: l || void 0,
|
|
403
|
+
showBorder: p,
|
|
404
|
+
enableScrollbar: g
|
|
405
|
+
}), b(t);
|
|
231
406
|
}
|
|
232
|
-
function
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
if (s && s.rangeCount > 0) {
|
|
250
|
-
const d = s.getRangeAt(0);
|
|
251
|
-
d.deleteContents();
|
|
252
|
-
const b = document.createElement("div");
|
|
253
|
-
b.innerHTML = c;
|
|
254
|
-
const h = document.createDocumentFragment();
|
|
255
|
-
for (; b.firstChild; )
|
|
256
|
-
h.appendChild(b.firstChild);
|
|
257
|
-
d.insertNode(h);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}, 10));
|
|
407
|
+
function Z(e, t) {
|
|
408
|
+
const r = s(e), o = w(e);
|
|
409
|
+
if (!o) return;
|
|
410
|
+
const a = o.innerHTML, n = document.createElement("iframe");
|
|
411
|
+
n.src = z(t.src), n.width = t.width, n.height = t.height, n.allowFullscreen = !0, n.setAttribute("frameborder", t.showBorder ? "1" : "0"), n.setAttribute("scrolling", t.enableScrollbar ? "auto" : "no"), n.setAttribute("data-aspect-ratio", t.aspectRatio), t.aspectRatio !== "inline" && n.classList.add(`rte-iframe-${t.aspectRatio}`), t.name && (n.name = t.name), t.title && (n.title = t.title), t.longDescription && n.setAttribute("data-long-description", t.longDescription), t.descriptionUrl && n.setAttribute("longdesc", t.descriptionUrl);
|
|
412
|
+
const i = document.createElement("p");
|
|
413
|
+
i.appendChild(n), i.appendChild(document.createElement("br"));
|
|
414
|
+
const l = r.savedRange && o.contains(r.savedRange.commonAncestorContainer) ? r.savedRange : document.createRange();
|
|
415
|
+
(!r.savedRange || !o.contains(r.savedRange.commonAncestorContainer)) && (l.selectNodeContents(o), l.collapse(!1));
|
|
416
|
+
const p = I(o, l.startContainer), g = p ? p.nextSibling : null;
|
|
417
|
+
o.insertBefore(i, g);
|
|
418
|
+
const d = document.createRange();
|
|
419
|
+
d.setStartAfter(i), d.collapse(!0);
|
|
420
|
+
const m = window.getSelection();
|
|
421
|
+
m && (m.removeAllRanges(), m.addRange(d)), r.savedRange = null;
|
|
422
|
+
const S = o.innerHTML;
|
|
423
|
+
k(o, a, S), o.dispatchEvent(new window.Event("input", { bubbles: !0 }));
|
|
261
424
|
}
|
|
262
|
-
function
|
|
263
|
-
const t =
|
|
264
|
-
t.escapeHandler && (document.removeEventListener("keydown", t.escapeHandler, !0), t.escapeHandler = null), t.dialogElement && (t.dialogElement.remove(), t.dialogElement = null);
|
|
425
|
+
function b(e) {
|
|
426
|
+
const t = s(e);
|
|
427
|
+
t.savedRange = null, t.escapeHandler && (document.removeEventListener("keydown", t.escapeHandler, !0), t.escapeHandler = null), t.dialogElement && (t.dialogElement.remove(), t.dialogElement = null);
|
|
265
428
|
}
|
|
266
|
-
function
|
|
267
|
-
if (document.getElementById("embed-iframe-dialog-styles")) return;
|
|
429
|
+
function V() {
|
|
430
|
+
if (E(), document.getElementById("embed-iframe-dialog-styles")) return;
|
|
268
431
|
const e = document.createElement("style");
|
|
269
432
|
e.id = "embed-iframe-dialog-styles", e.textContent = `
|
|
270
433
|
/* Embed Iframe Dialog Styles */
|
|
@@ -555,5 +718,5 @@ function z() {
|
|
|
555
718
|
`, document.head.appendChild(e);
|
|
556
719
|
}
|
|
557
720
|
export {
|
|
558
|
-
|
|
721
|
+
W as EmbedIframePlugin
|
|
559
722
|
};
|
package/dist/heading.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=()
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f='.rte-content, .editora-content, [contenteditable="true"]',y="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",g=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE"]),E="p,div,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,table",B=new Set(["p","h1","h2","h3","h4","h5","h6"]);function H(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function S(e){const n=e?.contentElement;if(n instanceof HTMLElement)return n;const t=e?.editorElement;if(t instanceof HTMLElement){const a=t.querySelector(f);if(a instanceof HTMLElement)return a;if(t.getAttribute("contenteditable")==="true")return t}const r=window.getSelection();if(r&&r.rangeCount>0){const a=H(r.getRangeAt(0).startContainer),i=a?.closest(f);if(i instanceof HTMLElement)return i;const u=a?.closest(y)?.querySelector(f);if(u instanceof HTMLElement)return u}const o=document.activeElement?.closest(f);return o instanceof HTMLElement?o:document.querySelector(f)}function N(e){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const t=n.getRangeAt(0);return!e.contains(t.startContainer)||!e.contains(t.endContainer)?null:t}function T(e,n){let t=H(n);if(!t||t===e||!e.contains(t))return null;for(;t.parentElement&&t.parentElement!==e;)t=t.parentElement;if(t.parentElement!==e)return null;if(t.matches(E))return t;const r=t.closest(E);return r instanceof HTMLElement&&r.parentElement===e?r:t}function v(e,n){if(typeof e.intersectsNode=="function")try{return e.intersectsNode(n)}catch{return!1}const t=document.createRange();return t.selectNode(n),e.compareBoundaryPoints(Range.END_TO_START,t)<0&&e.compareBoundaryPoints(Range.START_TO_END,t)>0}function w(e,n){const t=T(e,n.startContainer),r=T(e,n.endContainer);if(!t)return[];if(!r||t===r)return[t];const o=Array.from(e.children).filter(a=>a instanceof HTMLElement).filter(a=>v(n,a));return o.length>0?o:[t]}function A(e,n){Array.from(e.attributes).forEach(t=>{n.setAttribute(t.name,t.value)})}function p(e,n){for(;e.firstChild;)n.appendChild(e.firstChild)}function R(e){return e.tagName!=="P"||e.attributes.length>0||(e.textContent||"").trim()!==""?!1:!e.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function d(e,n){const t=document.createElement(e);return n&&A(n,t),t}function C(e,n){const t=d(n,e);return p(e,t),t.innerHTML.trim()||(t.innerHTML="<br>"),t}function _(e){const n=e.cloneNode(!1);return n instanceof HTMLElement?n:document.createElement(e.tagName.toLowerCase())}function L(e,n,t){const r=e.parentNode;if(!r)return[];const s=document.createDocumentFragment(),o=[];let a=null;const i=()=>{a&&a.children.length>0&&s.appendChild(a),a=null};return Array.from(e.children).forEach(c=>{if(c instanceof HTMLLIElement){if(n.has(c)){i();const u=C(c,t);s.appendChild(u),o.push(u);return}a||(a=_(e)),a.appendChild(c)}}),i(),r.insertBefore(s,e),r.removeChild(e),o}function I(e,n){if(e.tagName.toLowerCase()===n)return[e];const t=d(n,e);return p(e,t),t.innerHTML.trim()||(t.innerHTML="<br>"),e.parentNode?.replaceChild(t,e),[t]}function O(e,n){const t=e.parentNode;if(!t)return[];const r=document.createDocumentFragment(),s=[];return Array.from(e.childNodes).forEach(o=>{if(o instanceof HTMLElement&&R(o)){o.remove();return}if(o instanceof HTMLUListElement||o instanceof HTMLOListElement){Array.from(o.children).forEach(i=>{if(!(i instanceof HTMLLIElement))return;const c=C(i,n);r.appendChild(c),s.push(c)}),o.remove();return}if(o instanceof HTMLElement&&g.has(o.tagName)){const i=d(n,o);p(o,i),r.appendChild(i),s.push(i);return}if(o.nodeType===Node.TEXT_NODE&&(o.textContent||"").trim()===""){o.remove();return}const a=d(n,e);a.appendChild(o),r.appendChild(a),s.push(a)}),t.insertBefore(r,e),t.removeChild(e),s}function b(e){const n=window.getSelection();if(!n)return;const t=document.createRange(),r=e instanceof HTMLElement&&e.querySelector("p,li,h1,h2,h3,h4,h5,h6")||e;t.selectNodeContents(r),t.collapse(!0),n.removeAllRanges(),n.addRange(t)}function k(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function P(e,n,t){const r=window.execEditorCommand;if(typeof r=="function"){r("recordDomTransaction",e,n,t);return}const s=window.executeEditorCommand;typeof s=="function"&&s("recordDomTransaction",{editor:e,beforeHTML:n,afterHTML:t})}function x(e,n){const t=new Map;return Array.from(e.querySelectorAll("li")).filter(s=>s instanceof HTMLLIElement&&v(n,s)).forEach(s=>{const o=s.parentElement;(o instanceof HTMLUListElement||o instanceof HTMLOListElement)&&o.parentElement===e&&(t.has(o)||t.set(o,new Set),t.get(o)?.add(s))}),t}function m(e,n){const t=e.toLowerCase();if(!B.has(t))return!1;const r=S(n);if(!r)return!1;const s=N(r);if(!s)return!1;const o=r.innerHTML,a=[],i=x(r,s);i.size>0?i.forEach((u,l)=>{a.push(...L(l,u,t))}):w(r,s).forEach(l=>{if(l instanceof HTMLUListElement||l instanceof HTMLOListElement){const h=new Set(Array.from(l.children).filter(M=>M instanceof HTMLLIElement));a.push(...L(l,h,t));return}if(g.has(l.tagName)){const h=l.querySelector(":scope > ul, :scope > ol, :scope > blockquote, :scope > table");a.push(...h?O(l,t):I(l,t))}});const c=r.innerHTML;return o===c||a.length===0?!1:(P(r,o,c),k(r),b(a[0]),!0)}const D=()=>({name:"heading",toolbar:[{label:"P",command:"setBlockType",type:"dropdown",options:[{value:"p",label:"P"},{value:"h1",label:"H1"},{value:"h2",label:"H2"},{value:"h3",label:"H3"},{value:"h4",label:"H4"},{value:"h5",label:"H5"},{value:"h6",label:"H6"}],icon:'<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'}],commands:{setBlockType:(e,n)=>e?m(e,n):!1,setHeading1:(e,n)=>m("h1",n),setHeading2:(e,n)=>m("h2",n),setHeading3:(e,n)=>m("h3",n),setParagraph:(e,n)=>m("p",n)},keymap:{"Mod-Alt-1":"setHeading1","Mod-Alt-2":"setHeading2","Mod-Alt-3":"setHeading3","Mod-Alt-0":"setParagraph"}});exports.HeadingPlugin=D;
|