@editora/plugins 1.0.10 → 1.0.12
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/_commonjsHelpers-BH3jXuIh.js +1 -0
- package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
- package/dist/a11y-checker.cjs.js +12 -12
- package/dist/a11y-checker.esm.js +80 -98
- package/dist/anchor.cjs.js +12 -12
- package/dist/anchor.esm.js +115 -128
- package/dist/anchoredPopover-BzqGPOAE.js +1 -0
- package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
- package/dist/approval-workflow.cjs.js +40 -40
- package/dist/approval-workflow.esm.js +208 -249
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +55 -68
- package/dist/blockquote.esm.js +1 -2
- package/dist/blocks-library.cjs.js +45 -45
- package/dist/blocks-library.esm.js +178 -245
- package/dist/capitalization.esm.js +1 -2
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +58 -82
- package/dist/citations.cjs.js +37 -37
- package/dist/citations.esm.js +439 -512
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +27 -33
- package/dist/code-sample.cjs.js +14 -14
- package/dist/code-sample.esm.js +82 -93
- package/dist/code.cjs.js +119 -42
- package/dist/code.esm.js +2560 -760
- package/dist/comments.cjs.js +6 -6
- package/dist/comments.esm.js +116 -158
- package/dist/conditional-content.cjs.js +90 -90
- package/dist/conditional-content.esm.js +371 -432
- package/dist/content-rules.cjs.js +7 -7
- package/dist/content-rules.esm.js +105 -159
- package/dist/data-binding.cjs.js +46 -46
- package/dist/data-binding.esm.js +328 -368
- package/dist/direction.esm.js +9 -18
- package/dist/doc-schema.cjs.js +29 -29
- package/dist/doc-schema.esm.js +240 -308
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +4 -5
- package/dist/documentManager-CTqRftU8.mjs +8369 -0
- package/dist/documentManager-Jf0RbSks.js +17 -0
- package/dist/{editorContainerHelpers-69585c07.mjs → editorContainerHelpers-C7kdWnS0.mjs} +1 -2
- package/dist/embed-iframe.cjs.js +4 -4
- package/dist/embed-iframe.esm.js +73 -81
- package/dist/emojis.cjs.js +8 -8
- package/dist/emojis.esm.js +65 -77
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +54 -56
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +39 -47
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +37 -53
- package/dist/footnote.cjs.js +2 -2
- package/dist/footnote.esm.js +76 -117
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +70 -92
- package/dist/html2canvas.esm-B5qzocYs.js +5 -0
- package/dist/{html2canvas.esm-1a1724a1.mjs → html2canvas.esm-BWVIUcAF.mjs} +141 -225
- package/dist/indent.cjs.js +1 -1
- package/dist/indent.esm.js +12 -24
- package/dist/{index-f04538f2.mjs → index-BFsKNTTj.mjs} +70 -71
- package/dist/index-CvJk4DKa.js +221 -0
- package/dist/index-D3CycEFU.mjs +16543 -0
- package/dist/index-tqLTHcO6.js +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es-CE_A4QSm.js +5 -0
- package/dist/index.es-DQ78mYYo.mjs +6665 -0
- package/dist/index.esm.js +125 -128
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +8 -9
- package/dist/jspdf.es.min-BoS80556.js +77 -0
- package/dist/{jspdf.es.min-c36a4fd8.mjs → jspdf.es.min-DQCoX5yh.mjs} +3658 -4682
- package/dist/line-height.cjs.js +1 -1
- package/dist/line-height.esm.js +11 -24
- package/dist/link.cjs.js +5 -5
- package/dist/link.esm.js +24 -30
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +20 -25
- package/dist/lite.cjs.js +1 -1
- package/dist/lite.esm.js +59 -61
- package/dist/math.cjs.js +21 -21
- package/dist/math.esm.js +139 -146
- package/dist/media-manager.cjs.js +31 -31
- package/dist/media-manager.esm.js +285 -300
- package/dist/mentions.cjs.js +9 -9
- package/dist/mentions.esm.js +238 -286
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +177 -216
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +33 -49
- package/dist/pii-redaction.cjs.js +19 -19
- package/dist/pii-redaction.esm.js +393 -463
- package/dist/plugins.css +1 -0
- package/dist/preview.esm.js +5 -10
- package/dist/print.cjs.js +4 -4
- package/dist/print.esm.js +17 -20
- package/dist/{purify.es-35a15df8.mjs → purify.es-DHhaBdbu.mjs} +9 -19
- package/dist/{purify.es-a8d731c6.js → purify.es-T2a3nLiC.js} +1 -1
- package/dist/slash-commands.cjs.js +2 -2
- package/dist/slash-commands.esm.js +39 -75
- package/dist/smart-paste.cjs.js +27 -27
- package/dist/smart-paste.esm.js +280 -336
- package/dist/special-characters.cjs.js +7 -7
- package/dist/special-characters.esm.js +61 -69
- package/dist/spell-check.cjs.js +5 -5
- package/dist/spell-check.esm.js +97 -123
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +14 -19
- package/dist/table.cjs.js +4 -4
- package/dist/table.esm.js +191 -225
- package/dist/template.cjs.js +21 -20
- package/dist/template.esm.js +715 -196
- package/dist/text-alignment.cjs.js +1 -1
- package/dist/text-alignment.esm.js +21 -27
- package/dist/text-color.cjs.js +3 -3
- package/dist/text-color.esm.js +70 -87
- package/dist/track-changes.cjs.js +2 -2
- package/dist/track-changes.esm.js +100 -162
- package/dist/translation-workflow.cjs.js +74 -74
- package/dist/translation-workflow.esm.js +602 -678
- package/dist/version-diff.cjs.js +14 -14
- package/dist/version-diff.esm.js +128 -157
- package/package.json +1 -1
- package/dist/_commonjsHelpers-6763f629.js +0 -1
- package/dist/_commonjsHelpers-c5d32002.mjs +0 -30
- package/dist/anchoredPopover-33f1358d.mjs +0 -109
- package/dist/anchoredPopover-8151d535.js +0 -1
- package/dist/documentManager-25b6203c.mjs +0 -9122
- package/dist/documentManager-b69e7054.js +0 -17
- package/dist/html2canvas.esm-09133e29.js +0 -22
- package/dist/index-656d224b.js +0 -231
- package/dist/index-6a8c48bb.js +0 -1
- package/dist/index-d027b7e2.mjs +0 -16859
- package/dist/index.es-730f2d98.mjs +0 -5775
- package/dist/index.es-dd40173b.js +0 -18
- package/dist/jspdf.es.min-90db2c97.js +0 -243
- package/dist/style.css +0 -1
- /package/dist/{editorContainerHelpers-36b8ddf3.js → editorContainerHelpers-CFbfiOJI.js} +0 -0
package/dist/anchor.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("./editorContainerHelpers-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("./editorContainerHelpers-CFbfiOJI.js"),b=new Set,x='[data-theme="dark"], .dark, .editora-theme-dark';function $(t,c){if(c===t.innerHTML)return;const i=window.execEditorCommand||window.executeEditorCommand;if(typeof i=="function")try{i("recordDomTransaction",t,c,t.innerHTML)}catch{}}function z(){if(typeof window>"u"||window.__anchorObserverInitialized)return;window.__anchorObserverInitialized=!0,new MutationObserver(c=>{c.forEach(i=>{i.removedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const d=r;if(d.classList?.contains("rte-anchor")){const n=d.id;n&&b.delete(n)}d.querySelectorAll?.(".rte-anchor")?.forEach(n=>{const u=n.id;u&&b.delete(u)})}})})}).observe(document.body,{childList:!0,subtree:!0})}function S(t){return!t||t.trim().length===0?{valid:!1,error:"Anchor ID cannot be empty"}:t.length>256?{valid:!1,error:"Anchor ID must be less than 256 characters"}:/^[a-z_]/.test(t)?/^[a-z0-9\-_]+$/.test(t)?{valid:!0,error:""}:{valid:!1,error:"Anchor ID can only contain letters, numbers, hyphens, and underscores"}:{valid:!1,error:"Anchor ID must start with a letter or underscore"}}function M(){const t=w.findEditorContainerFromSelection();if(!t)return;const c=w.getContentElement(t);if(!c)return;const i=c.querySelectorAll(".rte-anchor"),r=new Set;i.forEach(d=>{const e=d.id;e&&r.add(e)}),b.clear(),r.forEach(d=>b.add(d))}function R(t){if(t){const r=t.startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(x))return!0}const c=window.getSelection();if(c&&c.rangeCount>0){const r=c.getRangeAt(0).startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(x))return!0}return document.activeElement?.closest(x)?!0:document.body.matches(x)||document.documentElement.matches(x)}function H(t,c,i,r){M();const d=R(r),e=d?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",panelBg:"#222d3a",border:"#3b4657",text:"#e2e8f0",muted:"#94a3b8",closeHoverBg:"#334155",fieldBg:"#111827",fieldFocusBg:"#111827",fieldBorder:"#4b5563",fieldText:"#e2e8f0",fieldErrorBg:"#3f2124",fieldErrorBorder:"#ef4444",cancelBg:"#334155",cancelHover:"#475569",cancelText:"#e2e8f0",saveBg:"#3b82f6",saveHover:"#2563eb",saveDisabledBg:"#374151",saveDisabledText:"#7f8ca1",help:"#9fb0c6",focusRing:"rgba(88, 166, 255, 0.25)",errorRing:"rgba(239, 68, 68, 0.25)"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",panelBg:"#f9f9f9",border:"#e0e0e0",text:"#333333",muted:"#999999",closeHoverBg:"#e0e0e0",fieldBg:"#ffffff",fieldFocusBg:"#f9f9ff",fieldBorder:"#d0d0d0",fieldText:"#333333",fieldErrorBg:"#ffebee",fieldErrorBorder:"#d32f2f",cancelBg:"#f0f0f0",cancelHover:"#e0e0e0",cancelText:"#333333",saveBg:"#0066cc",saveHover:"#0052a3",saveDisabledBg:"#d0d0d0",saveDisabledText:"#999999",help:"#999999",focusRing:"rgba(0, 102, 204, 0.1)",errorRing:"rgba(211, 47, 47, 0.1)"},n=document.createElement("div");n.className="rte-anchor-dialog-overlay",n.style.cssText=`
|
|
2
2
|
position: fixed;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
max-width: 450px;
|
|
20
20
|
overflow: hidden;
|
|
21
21
|
animation: rte-anchor-dialog-appear 0.2s ease;
|
|
22
|
-
`,!document.getElementById("rte-anchor-dialog-styles")){const
|
|
22
|
+
`,!document.getElementById("rte-anchor-dialog-styles")){const s=document.createElement("style");s.id="rte-anchor-dialog-styles",s.textContent=`
|
|
23
23
|
@keyframes rte-anchor-dialog-appear {
|
|
24
24
|
from { opacity: 0; transform: scale(0.95); }
|
|
25
25
|
to { opacity: 1; transform: scale(1); }
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
.rte-anchor-dialog input:focus {
|
|
28
28
|
outline: none !important;
|
|
29
29
|
}
|
|
30
|
-
`,document.head.appendChild(
|
|
30
|
+
`,document.head.appendChild(s)}let l="";const h=document.createElement("div");h.style.cssText=`
|
|
31
31
|
display: flex;
|
|
32
32
|
align-items: center;
|
|
33
33
|
justify-content: space-between;
|
|
34
34
|
padding: 16px 20px;
|
|
35
35
|
border-bottom: 1px solid ${e.border};
|
|
36
36
|
background: ${e.panelBg};
|
|
37
|
-
`;const C=document.createElement("h3");C.style.cssText=`margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`,C.textContent=
|
|
37
|
+
`;const C=document.createElement("h3");C.style.cssText=`margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`,C.textContent="Add Anchor";const f=document.createElement("button");f.textContent="✕",f.style.cssText=`
|
|
38
38
|
background: none;
|
|
39
39
|
border: none;
|
|
40
40
|
font-size: 24px;
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
justify-content: center;
|
|
49
49
|
border-radius: 4px;
|
|
50
50
|
transition: all 0.2s ease;
|
|
51
|
-
`,
|
|
51
|
+
`,f.onmouseover=()=>{f.style.background=e.closeHoverBg,f.style.color="#f8fafc"},f.onmouseout=()=>{f.style.background="none",f.style.color=e.muted},h.appendChild(C),h.appendChild(f);const B=document.createElement("div");B.style.cssText="padding: 20px;";const m=document.createElement("div");m.style.cssText="margin-bottom: 0;";const y=document.createElement("label");y.textContent="Anchor ID",y.style.cssText=`display: block; font-size: 14px; font-weight: 500; color: ${e.text}; margin-bottom: 8px;`,y.setAttribute("for","anchor-id-input");const o=document.createElement("input");o.id="anchor-id-input",o.type="text",o.placeholder="e.g., section-introduction",o.value="",o.style.cssText=`
|
|
52
52
|
width: 100%;
|
|
53
53
|
padding: 10px 12px;
|
|
54
54
|
font-size: 14px;
|
|
@@ -59,19 +59,19 @@
|
|
|
59
59
|
background: ${e.fieldBg};
|
|
60
60
|
transition: all 0.2s ease;
|
|
61
61
|
box-sizing: border-box;
|
|
62
|
-
`,o.style.setProperty("caret-color",e.fieldText);const
|
|
62
|
+
`,o.style.setProperty("caret-color",e.fieldText);const p=document.createElement("div");p.style.cssText=`
|
|
63
63
|
color: #d32f2f;
|
|
64
64
|
font-size: 12px;
|
|
65
65
|
margin-top: 6px;
|
|
66
66
|
display: none;
|
|
67
|
-
`;const k=document.createElement("div");k.textContent="URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.",k.style.cssText=`color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`,
|
|
67
|
+
`;const k=document.createElement("div");k.textContent="URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.",k.style.cssText=`color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`,m.appendChild(y),m.appendChild(o),m.appendChild(p),m.appendChild(k),B.appendChild(m);const v=document.createElement("div");v.style.cssText=`
|
|
68
68
|
display: flex;
|
|
69
69
|
gap: 12px;
|
|
70
70
|
padding: 16px 20px;
|
|
71
71
|
border-top: 1px solid ${e.border};
|
|
72
72
|
background: ${e.panelBg};
|
|
73
73
|
justify-content: flex-end;
|
|
74
|
-
`;const
|
|
74
|
+
`;const g=document.createElement("button");g.textContent="Cancel",g.style.cssText=`
|
|
75
75
|
padding: 8px 16px;
|
|
76
76
|
font-size: 14px;
|
|
77
77
|
font-weight: 500;
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
transition: all 0.2s ease;
|
|
82
82
|
background: ${e.cancelBg};
|
|
83
83
|
color: ${e.cancelText};
|
|
84
|
-
`,
|
|
84
|
+
`,g.onmouseover=()=>g.style.background=e.cancelHover,g.onmouseout=()=>g.style.background=e.cancelBg;const a=document.createElement("button");a.textContent="Add Anchor",a.style.cssText=`
|
|
85
85
|
padding: 8px 16px;
|
|
86
86
|
font-size: 14px;
|
|
87
87
|
font-weight: 500;
|
|
@@ -91,11 +91,11 @@
|
|
|
91
91
|
transition: all 0.2s ease;
|
|
92
92
|
background: ${e.saveBg};
|
|
93
93
|
color: white;
|
|
94
|
-
`,
|
|
94
|
+
`,a.disabled=!o.value.trim();const N=()=>{o.value.trim()?(a.disabled=!1,a.style.background=e.saveBg,a.style.color="white",a.style.cursor="pointer"):(a.disabled=!0,a.style.background=e.saveDisabledBg,a.style.color=e.saveDisabledText,a.style.cursor="not-allowed")};a.onmouseover=()=>{a.disabled||(a.style.background=e.saveHover,a.style.boxShadow=d?"0 2px 8px rgba(59, 130, 246, 0.35)":"0 2px 8px rgba(0, 102, 204, 0.3)")},a.onmouseout=()=>{a.disabled||(a.style.background=e.saveBg,a.style.boxShadow="none")},v.appendChild(g),v.appendChild(a),o.oninput=()=>{const s=o.value;if(N(),s.trim()){const T=S(s);T.valid?b.has(s)?(l=`Anchor ID already exists: ${s}`,p.textContent="⚠ "+l,p.style.display="block",o.style.borderColor=e.fieldErrorBorder,o.style.background=e.fieldErrorBg):(l="",p.style.display="none",o.style.borderColor=e.fieldBorder,o.style.background=e.fieldBg):(l=T.error,p.textContent="⚠ "+l,p.style.display="block",o.style.borderColor=e.fieldErrorBorder,o.style.background=e.fieldErrorBg)}else p.style.display="none",o.style.borderColor=e.fieldBorder,o.style.background=e.fieldBg},o.onfocus=()=>{o.style.borderColor=l?e.fieldErrorBorder:e.saveBg,o.style.boxShadow=l?`0 0 0 3px ${e.errorRing}`:`0 0 0 3px ${e.focusRing}`,o.style.background=l?e.fieldErrorBg:e.fieldFocusBg},o.onblur=()=>{o.style.boxShadow="none",l||(o.style.background=e.fieldBg)};const A=()=>{const s=o.value.trim();!s||!S(s).valid||b.has(s)||(i&&i(s),n.remove())},E=()=>{n.remove()};a.onclick=A,g.onclick=E,f.onclick=E,o.onkeydown=s=>{s.key==="Enter"?(s.preventDefault(),A()):s.key==="Escape"&&(s.preventDefault(),E())},n.onclick=s=>{s.target===n&&E()},u.appendChild(h),u.appendChild(B),u.appendChild(v),n.appendChild(u),document.body.appendChild(n),setTimeout(()=>o.focus(),100)}function _(t,c){let i;if(c)i=c;else{const l=window.getSelection();if(!l||l.rangeCount===0)return;i=l.getRangeAt(0)}let r=null,d=i.startContainer;for(;d&&d!==document.body;){if(d.nodeType===Node.ELEMENT_NODE){const l=d;if(l.getAttribute("contenteditable")==="true"){r=l;break}}d=d.parentNode}const e=r?.innerHTML??"",n=document.createElement("span");n.id=t,n.className="rte-anchor",n.setAttribute("data-type","anchor"),n.setAttribute("data-anchor-id",t),n.setAttribute("title",`Anchor: ${t}`),n.style.cssText=`
|
|
95
95
|
display: inline;
|
|
96
96
|
position: relative;
|
|
97
97
|
cursor: pointer;
|
|
98
|
-
`,
|
|
98
|
+
`,i.insertNode(n),b.add(t),i.setStart(n.nextSibling||n.parentNode,0),i.collapse(!0);const u=window.getSelection();if(u&&(u.removeAllRanges(),u.addRange(i)),r)$(r,e),r.dispatchEvent(new Event("input",{bubbles:!0}));else{const l=w.findEditorContainerFromSelection();if(l){const h=w.getContentElement(l);h&&h.dispatchEvent(new Event("input",{bubbles:!0}))}}D()}function D(){if(document.getElementById("rte-anchor-styles"))return;const t=document.createElement("style");t.id="rte-anchor-styles",t.textContent=`
|
|
99
99
|
.rte-anchor {
|
|
100
100
|
display: inline;
|
|
101
101
|
position: relative;
|
|
@@ -173,4 +173,4 @@
|
|
|
173
173
|
outline: 2px solid #0066cc;
|
|
174
174
|
outline-offset: 2px;
|
|
175
175
|
}
|
|
176
|
-
`,document.head.appendChild(t)}const I=()=>(typeof window<"u"&&(z(),D()),{name:"anchor",toolbar:[{label:"Anchor",command:"insertAnchor",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M12 8.4C13.4912 8.4 14.7 7.19117 14.7 5.7C14.7 4.20883 13.4912 3 12 3C10.5088 3 9.3 4.20883 9.3 5.7C9.3 7.19117 10.5088 8.4 12 8.4ZM12 8.4V20.9999M12 20.9999C9.61305 20.9999 7.32387 20.0518 5.63604 18.364C3.94821 16.6761 3 14.3869 3 12H5M12 20.9999C14.3869 20.9999 16.6761 20.0518 18.364 18.364C20.0518 16.6761 21 14.3869 21 12H19" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-k"}],commands:{insertAnchor:()=>{try{const t=window.getSelection();if(!t||t.rangeCount===0)return alert("Please place your cursor where you want to insert the anchor."),!1;const
|
|
176
|
+
`,document.head.appendChild(t)}const I=()=>(typeof window<"u"&&(z(),D()),{name:"anchor",toolbar:[{label:"Anchor",command:"insertAnchor",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M12 8.4C13.4912 8.4 14.7 7.19117 14.7 5.7C14.7 4.20883 13.4912 3 12 3C10.5088 3 9.3 4.20883 9.3 5.7C9.3 7.19117 10.5088 8.4 12 8.4ZM12 8.4V20.9999M12 20.9999C9.61305 20.9999 7.32387 20.0518 5.63604 18.364C3.94821 16.6761 3 14.3869 3 12H5M12 20.9999C14.3869 20.9999 16.6761 20.0518 18.364 18.364C20.0518 16.6761 21 14.3869 21 12H19" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-k"}],commands:{insertAnchor:()=>{try{const t=window.getSelection();if(!t||t.rangeCount===0)return alert("Please place your cursor where you want to insert the anchor."),!1;const c=t.getRangeAt(0).cloneRange();return H("add","",i=>{_(i,c)},c),!0}catch(t){return console.error("Failed to insert anchor:",t),!1}}},keymap:{"Mod-Shift-k":"insertAnchor"}});exports.AnchorPlugin=I;
|
package/dist/anchor.esm.js
CHANGED
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
import { f as D, g as S } from "./editorContainerHelpers-
|
|
2
|
-
const
|
|
3
|
-
function z(t,
|
|
4
|
-
if (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (typeof s == "function")
|
|
1
|
+
import { f as D, g as S } from "./editorContainerHelpers-C7kdWnS0.mjs";
|
|
2
|
+
const b = /* @__PURE__ */ new Set(), x = '[data-theme="dark"], .dark, .editora-theme-dark';
|
|
3
|
+
function z(t, c) {
|
|
4
|
+
if (c === t.innerHTML) return;
|
|
5
|
+
const i = window.execEditorCommand || window.executeEditorCommand;
|
|
6
|
+
if (typeof i == "function")
|
|
8
7
|
try {
|
|
9
|
-
|
|
8
|
+
i("recordDomTransaction", t, c, t.innerHTML);
|
|
10
9
|
} catch {
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
12
|
function R() {
|
|
14
|
-
if (typeof window > "u" || window.__anchorObserverInitialized)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const r = i.id;
|
|
24
|
-
r && h.delete(r);
|
|
13
|
+
if (typeof window > "u" || window.__anchorObserverInitialized) return;
|
|
14
|
+
window.__anchorObserverInitialized = !0, new MutationObserver((c) => {
|
|
15
|
+
c.forEach((i) => {
|
|
16
|
+
i.removedNodes.forEach((n) => {
|
|
17
|
+
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
18
|
+
const d = n;
|
|
19
|
+
if (d.classList?.contains("rte-anchor")) {
|
|
20
|
+
const r = d.id;
|
|
21
|
+
r && b.delete(r);
|
|
25
22
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
f && h.delete(f);
|
|
23
|
+
d.querySelectorAll?.(".rte-anchor")?.forEach((r) => {
|
|
24
|
+
const u = r.id;
|
|
25
|
+
u && b.delete(u);
|
|
30
26
|
});
|
|
31
27
|
}
|
|
32
28
|
});
|
|
@@ -41,35 +37,30 @@ function A(t) {
|
|
|
41
37
|
}
|
|
42
38
|
function M() {
|
|
43
39
|
const t = D();
|
|
44
|
-
if (!t)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
e && d.add(e);
|
|
53
|
-
}), h.clear(), d.forEach((a) => h.add(a));
|
|
40
|
+
if (!t) return;
|
|
41
|
+
const c = S(t);
|
|
42
|
+
if (!c) return;
|
|
43
|
+
const i = c.querySelectorAll(".rte-anchor"), n = /* @__PURE__ */ new Set();
|
|
44
|
+
i.forEach((d) => {
|
|
45
|
+
const e = d.id;
|
|
46
|
+
e && n.add(e);
|
|
47
|
+
}), b.clear(), n.forEach((d) => b.add(d));
|
|
54
48
|
}
|
|
55
49
|
function H(t) {
|
|
56
50
|
if (t) {
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
return !0;
|
|
51
|
+
const n = t.startContainer;
|
|
52
|
+
if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(x)) return !0;
|
|
60
53
|
}
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
return !0;
|
|
54
|
+
const c = window.getSelection();
|
|
55
|
+
if (c && c.rangeCount > 0) {
|
|
56
|
+
const n = c.getRangeAt(0).startContainer;
|
|
57
|
+
if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(x)) return !0;
|
|
66
58
|
}
|
|
67
|
-
|
|
68
|
-
return s != null && s.closest(y) ? !0 : document.body.matches(y) || document.documentElement.matches(y);
|
|
59
|
+
return document.activeElement?.closest(x) ? !0 : document.body.matches(x) || document.documentElement.matches(x);
|
|
69
60
|
}
|
|
70
|
-
function _(t,
|
|
61
|
+
function _(t, c, i, n) {
|
|
71
62
|
M();
|
|
72
|
-
const
|
|
63
|
+
const d = H(n), e = d ? {
|
|
73
64
|
overlay: "rgba(0, 0, 0, 0.62)",
|
|
74
65
|
dialogBg: "#1f2937",
|
|
75
66
|
panelBg: "#222d3a",
|
|
@@ -81,7 +72,6 @@ function _(t, l, s, d) {
|
|
|
81
72
|
fieldFocusBg: "#111827",
|
|
82
73
|
fieldBorder: "#4b5563",
|
|
83
74
|
fieldText: "#e2e8f0",
|
|
84
|
-
fieldPlaceholder: "#94a3b8",
|
|
85
75
|
fieldErrorBg: "#3f2124",
|
|
86
76
|
fieldErrorBorder: "#ef4444",
|
|
87
77
|
cancelBg: "#334155",
|
|
@@ -106,7 +96,6 @@ function _(t, l, s, d) {
|
|
|
106
96
|
fieldFocusBg: "#f9f9ff",
|
|
107
97
|
fieldBorder: "#d0d0d0",
|
|
108
98
|
fieldText: "#333333",
|
|
109
|
-
fieldPlaceholder: "#9ca3af",
|
|
110
99
|
fieldErrorBg: "#ffebee",
|
|
111
100
|
fieldErrorBorder: "#d32f2f",
|
|
112
101
|
cancelBg: "#f0f0f0",
|
|
@@ -119,8 +108,8 @@ function _(t, l, s, d) {
|
|
|
119
108
|
help: "#999999",
|
|
120
109
|
focusRing: "rgba(0, 102, 204, 0.1)",
|
|
121
110
|
errorRing: "rgba(211, 47, 47, 0.1)"
|
|
122
|
-
},
|
|
123
|
-
|
|
111
|
+
}, r = document.createElement("div");
|
|
112
|
+
r.className = "rte-anchor-dialog-overlay", r.style.cssText = `
|
|
124
113
|
position: fixed;
|
|
125
114
|
top: 0;
|
|
126
115
|
left: 0;
|
|
@@ -144,8 +133,8 @@ function _(t, l, s, d) {
|
|
|
144
133
|
overflow: hidden;
|
|
145
134
|
animation: rte-anchor-dialog-appear 0.2s ease;
|
|
146
135
|
`, !document.getElementById("rte-anchor-dialog-styles")) {
|
|
147
|
-
const
|
|
148
|
-
|
|
136
|
+
const s = document.createElement("style");
|
|
137
|
+
s.id = "rte-anchor-dialog-styles", s.textContent = `
|
|
149
138
|
@keyframes rte-anchor-dialog-appear {
|
|
150
139
|
from { opacity: 0; transform: scale(0.95); }
|
|
151
140
|
to { opacity: 1; transform: scale(1); }
|
|
@@ -153,11 +142,11 @@ function _(t, l, s, d) {
|
|
|
153
142
|
.rte-anchor-dialog input:focus {
|
|
154
143
|
outline: none !important;
|
|
155
144
|
}
|
|
156
|
-
`, document.head.appendChild(
|
|
145
|
+
`, document.head.appendChild(s);
|
|
157
146
|
}
|
|
158
|
-
let
|
|
159
|
-
const
|
|
160
|
-
|
|
147
|
+
let l = "";
|
|
148
|
+
const h = document.createElement("div");
|
|
149
|
+
h.style.cssText = `
|
|
161
150
|
display: flex;
|
|
162
151
|
align-items: center;
|
|
163
152
|
justify-content: space-between;
|
|
@@ -166,9 +155,9 @@ function _(t, l, s, d) {
|
|
|
166
155
|
background: ${e.panelBg};
|
|
167
156
|
`;
|
|
168
157
|
const w = document.createElement("h3");
|
|
169
|
-
w.style.cssText = `margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`, w.textContent =
|
|
170
|
-
const
|
|
171
|
-
|
|
158
|
+
w.style.cssText = `margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`, w.textContent = "Add Anchor";
|
|
159
|
+
const f = document.createElement("button");
|
|
160
|
+
f.textContent = "✕", f.style.cssText = `
|
|
172
161
|
background: none;
|
|
173
162
|
border: none;
|
|
174
163
|
font-size: 24px;
|
|
@@ -182,19 +171,19 @@ function _(t, l, s, d) {
|
|
|
182
171
|
justify-content: center;
|
|
183
172
|
border-radius: 4px;
|
|
184
173
|
transition: all 0.2s ease;
|
|
185
|
-
`,
|
|
186
|
-
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
},
|
|
174
|
+
`, f.onmouseover = () => {
|
|
175
|
+
f.style.background = e.closeHoverBg, f.style.color = "#f8fafc";
|
|
176
|
+
}, f.onmouseout = () => {
|
|
177
|
+
f.style.background = "none", f.style.color = e.muted;
|
|
178
|
+
}, h.appendChild(w), h.appendChild(f);
|
|
190
179
|
const C = document.createElement("div");
|
|
191
180
|
C.style.cssText = "padding: 20px;";
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
|
|
181
|
+
const m = document.createElement("div");
|
|
182
|
+
m.style.cssText = "margin-bottom: 0;";
|
|
183
|
+
const y = document.createElement("label");
|
|
184
|
+
y.textContent = "Anchor ID", y.style.cssText = `display: block; font-size: 14px; font-weight: 500; color: ${e.text}; margin-bottom: 8px;`, y.setAttribute("for", "anchor-id-input");
|
|
196
185
|
const o = document.createElement("input");
|
|
197
|
-
o.id = "anchor-id-input", o.type = "text", o.placeholder = "e.g., section-introduction", o.value =
|
|
186
|
+
o.id = "anchor-id-input", o.type = "text", o.placeholder = "e.g., section-introduction", o.value = "", o.style.cssText = `
|
|
198
187
|
width: 100%;
|
|
199
188
|
padding: 10px 12px;
|
|
200
189
|
font-size: 14px;
|
|
@@ -206,15 +195,15 @@ function _(t, l, s, d) {
|
|
|
206
195
|
transition: all 0.2s ease;
|
|
207
196
|
box-sizing: border-box;
|
|
208
197
|
`, o.style.setProperty("caret-color", e.fieldText);
|
|
209
|
-
const
|
|
210
|
-
|
|
198
|
+
const p = document.createElement("div");
|
|
199
|
+
p.style.cssText = `
|
|
211
200
|
color: #d32f2f;
|
|
212
201
|
font-size: 12px;
|
|
213
202
|
margin-top: 6px;
|
|
214
203
|
display: none;
|
|
215
204
|
`;
|
|
216
205
|
const B = document.createElement("div");
|
|
217
|
-
B.textContent = "URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.", B.style.cssText = `color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`,
|
|
206
|
+
B.textContent = "URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.", B.style.cssText = `color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`, m.appendChild(y), m.appendChild(o), m.appendChild(p), m.appendChild(B), C.appendChild(m);
|
|
218
207
|
const v = document.createElement("div");
|
|
219
208
|
v.style.cssText = `
|
|
220
209
|
display: flex;
|
|
@@ -224,8 +213,8 @@ function _(t, l, s, d) {
|
|
|
224
213
|
background: ${e.panelBg};
|
|
225
214
|
justify-content: flex-end;
|
|
226
215
|
`;
|
|
227
|
-
const
|
|
228
|
-
|
|
216
|
+
const g = document.createElement("button");
|
|
217
|
+
g.textContent = "Cancel", g.style.cssText = `
|
|
229
218
|
padding: 8px 16px;
|
|
230
219
|
font-size: 14px;
|
|
231
220
|
font-weight: 500;
|
|
@@ -235,9 +224,9 @@ function _(t, l, s, d) {
|
|
|
235
224
|
transition: all 0.2s ease;
|
|
236
225
|
background: ${e.cancelBg};
|
|
237
226
|
color: ${e.cancelText};
|
|
238
|
-
`,
|
|
239
|
-
const
|
|
240
|
-
|
|
227
|
+
`, g.onmouseover = () => g.style.background = e.cancelHover, g.onmouseout = () => g.style.background = e.cancelBg;
|
|
228
|
+
const a = document.createElement("button");
|
|
229
|
+
a.textContent = "Add Anchor", a.style.cssText = `
|
|
241
230
|
padding: 8px 16px;
|
|
242
231
|
font-size: 14px;
|
|
243
232
|
font-weight: 500;
|
|
@@ -247,80 +236,78 @@ function _(t, l, s, d) {
|
|
|
247
236
|
transition: all 0.2s ease;
|
|
248
237
|
background: ${e.saveBg};
|
|
249
238
|
color: white;
|
|
250
|
-
`,
|
|
239
|
+
`, a.disabled = !o.value.trim();
|
|
251
240
|
const $ = () => {
|
|
252
|
-
o.value.trim() ? (
|
|
241
|
+
o.value.trim() ? (a.disabled = !1, a.style.background = e.saveBg, a.style.color = "white", a.style.cursor = "pointer") : (a.disabled = !0, a.style.background = e.saveDisabledBg, a.style.color = e.saveDisabledText, a.style.cursor = "not-allowed");
|
|
253
242
|
};
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
},
|
|
257
|
-
|
|
258
|
-
}, v.appendChild(
|
|
259
|
-
const
|
|
260
|
-
if ($(),
|
|
261
|
-
const k = A(
|
|
262
|
-
k.valid ?
|
|
243
|
+
a.onmouseover = () => {
|
|
244
|
+
a.disabled || (a.style.background = e.saveHover, a.style.boxShadow = d ? "0 2px 8px rgba(59, 130, 246, 0.35)" : "0 2px 8px rgba(0, 102, 204, 0.3)");
|
|
245
|
+
}, a.onmouseout = () => {
|
|
246
|
+
a.disabled || (a.style.background = e.saveBg, a.style.boxShadow = "none");
|
|
247
|
+
}, v.appendChild(g), v.appendChild(a), o.oninput = () => {
|
|
248
|
+
const s = o.value;
|
|
249
|
+
if ($(), s.trim()) {
|
|
250
|
+
const k = A(s);
|
|
251
|
+
k.valid ? b.has(s) ? (l = `Anchor ID already exists: ${s}`, p.textContent = "⚠ " + l, p.style.display = "block", o.style.borderColor = e.fieldErrorBorder, o.style.background = e.fieldErrorBg) : (l = "", p.style.display = "none", o.style.borderColor = e.fieldBorder, o.style.background = e.fieldBg) : (l = k.error, p.textContent = "⚠ " + l, p.style.display = "block", o.style.borderColor = e.fieldErrorBorder, o.style.background = e.fieldErrorBg);
|
|
263
252
|
} else
|
|
264
|
-
|
|
253
|
+
p.style.display = "none", o.style.borderColor = e.fieldBorder, o.style.background = e.fieldBg;
|
|
265
254
|
}, o.onfocus = () => {
|
|
266
|
-
o.style.borderColor =
|
|
255
|
+
o.style.borderColor = l ? e.fieldErrorBorder : e.saveBg, o.style.boxShadow = l ? `0 0 0 3px ${e.errorRing}` : `0 0 0 3px ${e.focusRing}`, o.style.background = l ? e.fieldErrorBg : e.fieldFocusBg;
|
|
267
256
|
}, o.onblur = () => {
|
|
268
|
-
o.style.boxShadow = "none",
|
|
257
|
+
o.style.boxShadow = "none", l || (o.style.background = e.fieldBg);
|
|
269
258
|
};
|
|
270
259
|
const T = () => {
|
|
271
|
-
const
|
|
272
|
-
!
|
|
260
|
+
const s = o.value.trim();
|
|
261
|
+
!s || !A(s).valid || b.has(s) || (i && i(s), r.remove());
|
|
273
262
|
}, E = () => {
|
|
274
|
-
|
|
263
|
+
r.remove();
|
|
275
264
|
};
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
},
|
|
279
|
-
|
|
280
|
-
}, u.appendChild(
|
|
265
|
+
a.onclick = T, g.onclick = E, f.onclick = E, o.onkeydown = (s) => {
|
|
266
|
+
s.key === "Enter" ? (s.preventDefault(), T()) : s.key === "Escape" && (s.preventDefault(), E());
|
|
267
|
+
}, r.onclick = (s) => {
|
|
268
|
+
s.target === r && E();
|
|
269
|
+
}, u.appendChild(h), u.appendChild(C), u.appendChild(v), r.appendChild(u), document.body.appendChild(r), setTimeout(() => o.focus(), 100);
|
|
281
270
|
}
|
|
282
|
-
function I(t,
|
|
283
|
-
let
|
|
284
|
-
if (
|
|
285
|
-
|
|
271
|
+
function I(t, c) {
|
|
272
|
+
let i;
|
|
273
|
+
if (c)
|
|
274
|
+
i = c;
|
|
286
275
|
else {
|
|
287
|
-
const
|
|
288
|
-
if (!
|
|
289
|
-
|
|
290
|
-
s = r.getRangeAt(0);
|
|
276
|
+
const l = window.getSelection();
|
|
277
|
+
if (!l || l.rangeCount === 0) return;
|
|
278
|
+
i = l.getRangeAt(0);
|
|
291
279
|
}
|
|
292
|
-
let
|
|
293
|
-
for (;
|
|
294
|
-
if (
|
|
295
|
-
const
|
|
296
|
-
if (
|
|
297
|
-
|
|
280
|
+
let n = null, d = i.startContainer;
|
|
281
|
+
for (; d && d !== document.body; ) {
|
|
282
|
+
if (d.nodeType === Node.ELEMENT_NODE) {
|
|
283
|
+
const l = d;
|
|
284
|
+
if (l.getAttribute("contenteditable") === "true") {
|
|
285
|
+
n = l;
|
|
298
286
|
break;
|
|
299
287
|
}
|
|
300
288
|
}
|
|
301
|
-
|
|
289
|
+
d = d.parentNode;
|
|
302
290
|
}
|
|
303
|
-
const e =
|
|
304
|
-
|
|
291
|
+
const e = n?.innerHTML ?? "", r = document.createElement("span");
|
|
292
|
+
r.id = t, r.className = "rte-anchor", r.setAttribute("data-type", "anchor"), r.setAttribute("data-anchor-id", t), r.setAttribute("title", `Anchor: ${t}`), r.style.cssText = `
|
|
305
293
|
display: inline;
|
|
306
294
|
position: relative;
|
|
307
295
|
cursor: pointer;
|
|
308
|
-
`,
|
|
296
|
+
`, i.insertNode(r), b.add(t), i.setStart(r.nextSibling || r.parentNode, 0), i.collapse(!0);
|
|
309
297
|
const u = window.getSelection();
|
|
310
|
-
if (u && (u.removeAllRanges(), u.addRange(
|
|
311
|
-
z(
|
|
298
|
+
if (u && (u.removeAllRanges(), u.addRange(i)), n)
|
|
299
|
+
z(n, e), n.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
312
300
|
else {
|
|
313
|
-
const
|
|
314
|
-
if (
|
|
315
|
-
const
|
|
316
|
-
|
|
301
|
+
const l = D();
|
|
302
|
+
if (l) {
|
|
303
|
+
const h = S(l);
|
|
304
|
+
h && h.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
317
305
|
}
|
|
318
306
|
}
|
|
319
307
|
N();
|
|
320
308
|
}
|
|
321
309
|
function N() {
|
|
322
|
-
if (document.getElementById("rte-anchor-styles"))
|
|
323
|
-
return;
|
|
310
|
+
if (document.getElementById("rte-anchor-styles")) return;
|
|
324
311
|
const t = document.createElement("style");
|
|
325
312
|
t.id = "rte-anchor-styles", t.textContent = `
|
|
326
313
|
.rte-anchor {
|
|
@@ -418,10 +405,10 @@ const O = () => (typeof window < "u" && (R(), N()), {
|
|
|
418
405
|
const t = window.getSelection();
|
|
419
406
|
if (!t || t.rangeCount === 0)
|
|
420
407
|
return alert("Please place your cursor where you want to insert the anchor."), !1;
|
|
421
|
-
const
|
|
422
|
-
return _("add", "", (
|
|
423
|
-
I(
|
|
424
|
-
},
|
|
408
|
+
const c = t.getRangeAt(0).cloneRange();
|
|
409
|
+
return _("add", "", (i) => {
|
|
410
|
+
I(i, c);
|
|
411
|
+
}, c), !0;
|
|
425
412
|
} catch (t) {
|
|
426
413
|
return console.error("Failed to insert anchor:", t), !1;
|
|
427
414
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const b="p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";function p(e){return!!e.cloneContents().querySelector(b)}function v(e,t){return(e?.nodeType===Node.ELEMENT_NODE?e:e?.parentElement??null)?.closest('[contenteditable="true"]')||t()?.querySelector('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]')}function C(e,t){const n=v(e,t);n&&n.dispatchEvent(new Event("input",{bubbles:!0}))}function A(e,t){let r=e.startContainer.nodeType===Node.TEXT_NODE?e.startContainer.parentElement:e.startContainer;for(;r&&r!==document.body;){if(r.classList.contains(t)){const c=document.createRange();if(c.selectNodeContents(r),c.compareBoundaryPoints(Range.START_TO_START,e)<=0&&c.compareBoundaryPoints(Range.END_TO_END,e)>=0)return r}r=r.parentElement}return null}function S(e){try{if(e.savedRange){const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(e.savedRange.cloneRange()))}const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return!1;const n=t.getRangeAt(0);if(n.collapsed)return!1;const r=A(n,e.className);if(r)return e.styleProperty==="backgroundColor"?r.style.backgroundColor=e.color:r.style.color=e.color,C(r,e.getActiveEditorRoot),!0;v(n.commonAncestorContainer,e.getActiveEditorRoot)?.focus({preventScroll:!0});try{document.execCommand("styleWithCSS",!1,"true")}catch{}let l=!1;if(e.commands.forEach(o=>{l||(l=document.execCommand(o,!1,e.color))}),!l&&!p(n)){const o=document.createElement("span");e.styleProperty==="backgroundColor"?o.style.backgroundColor=e.color:o.style.color=e.color,o.className=e.className;const a=n.extractContents();o.appendChild(a),n.insertNode(o),n.setStartAfter(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n),l=!0}return l?(C(n.commonAncestorContainer,e.getActiveEditorRoot),!0):(e.warnMessage&&console.warn(e.warnMessage),!1)}catch(t){return e.warnMessage?console.error(e.warnMessage,t):console.error("[ColorApply] Failed to apply color",t),!1}}function T({popover:e,anchor:t,onClose:n,gap:r=6,margin:c=8,zIndex:l=1e4}){e.style.position="fixed",e.style.zIndex=`${l}`,e.style.visibility="hidden";const o=()=>{if(!e.isConnected||!t.isConnected){n();return}const s=t.getBoundingClientRect();if(s.width===0&&s.height===0){n();return}const i=e.getBoundingClientRect(),y=i.width||e.offsetWidth||220,f=i.height||e.offsetHeight||260,w=window.innerWidth,E=window.innerHeight;let u=s.left,d=s.bottom+r;if(u+y>w-c&&(u=w-y-c),u=Math.max(c,u),d+f>E-c){const g=s.top-f-r;g>=c?d=g:d=Math.max(c,E-f-c)}d<c&&(d=c),e.style.left=`${Math.round(u)}px`,e.style.top=`${Math.round(d)}px`,e.style.visibility="visible"},a=()=>{o()},m=s=>{const i=s.target;i&&(e.contains(i)||t.contains(i)||n())},h=s=>{s.key==="Escape"&&n()};window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),document.addEventListener("keydown",h);const R=window.requestAnimationFrame(()=>{document.addEventListener("mousedown",m,!0)});return o(),{reposition:o,destroy:()=>{window.cancelAnimationFrame(R),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0),document.removeEventListener("keydown",h),document.removeEventListener("mousedown",m,!0)}}}exports.applyColorToSelection=S;exports.attachAnchoredPopover=T;
|