@editora/anchor
Advanced tools
| "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function S(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const i=t.getRangeAt(0).startContainer,r=i.nodeType===Node.TEXT_NODE?i.parentElement:i;return R(r)}function R(t){if(!t)return null;if(t.hasAttribute("data-editora-editor"))return t;let n=t.parentElement;for(;n;){if(n.hasAttribute("data-editora-editor"))return n;n=n.parentElement}return null}function D(t){return t?t.querySelector(".rte-content"):(console.warn("[Editora] Editor container not found"),null)}const h=new Set,m='[data-theme="dark"], .dark, .editora-theme-dark';function z(){if(typeof window>"u"||window.__anchorObserverInitialized)return;window.__anchorObserverInitialized=!0,new MutationObserver(n=>{n.forEach(i=>{i.removedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const d=r;if(d.classList?.contains("rte-anchor")){const s=d.id;s&&h.delete(s)}d.querySelectorAll?.(".rte-anchor")?.forEach(s=>{const u=s.id;u&&h.delete(u)})}})})}).observe(document.body,{childList:!0,subtree:!0})}function A(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 _(){const t=S();if(!t)return;const n=D(t);if(!n)return;const i=n.querySelectorAll(".rte-anchor"),r=new Set;i.forEach(d=>{const e=d.id;e&&r.add(e)}),h.clear(),r.forEach(d=>h.add(d))}function M(t){if(t){const r=t.startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(m))return!0}const n=window.getSelection();if(n&&n.rangeCount>0){const r=n.getRangeAt(0).startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(m))return!0}return document.activeElement?.closest(m)?!0:document.body.matches(m)||document.documentElement.matches(m)}function H(t,n,i,r){_();const d=M(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)"},s=document.createElement("div");s.className="rte-anchor-dialog-overlay",s.style.cssText=` | ||
| position: fixed; | ||
| top: 0; | ||
| left: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| background: ${e.overlay}; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| z-index: 10000; | ||
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; | ||
| `;const u=document.createElement("div");if(u.className="rte-anchor-dialog",u.style.cssText=` | ||
| background: ${e.dialogBg}; | ||
| border: 1px solid ${e.border}; | ||
| border-radius: 8px; | ||
| box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2); | ||
| width: 90%; | ||
| max-width: 450px; | ||
| overflow: hidden; | ||
| animation: rte-anchor-dialog-appear 0.2s ease; | ||
| `,!document.getElementById("rte-anchor-dialog-styles")){const l=document.createElement("style");l.id="rte-anchor-dialog-styles",l.textContent=` | ||
| @keyframes rte-anchor-dialog-appear { | ||
| from { opacity: 0; transform: scale(0.95); } | ||
| to { opacity: 1; transform: scale(1); } | ||
| } | ||
| .rte-anchor-dialog input:focus { | ||
| outline: none !important; | ||
| } | ||
| `,document.head.appendChild(l)}let f="";const x=document.createElement("div");x.style.cssText=` | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| padding: 16px 20px; | ||
| border-bottom: 1px solid ${e.border}; | ||
| background: ${e.panelBg}; | ||
| `;const w=document.createElement("h3");w.style.cssText=`margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`,w.textContent="Add Anchor";const c=document.createElement("button");c.textContent="✕",c.style.cssText=` | ||
| background: none; | ||
| border: none; | ||
| font-size: 24px; | ||
| color: ${e.muted}; | ||
| cursor: pointer; | ||
| padding: 0; | ||
| width: 32px; | ||
| height: 32px; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| border-radius: 4px; | ||
| transition: all 0.2s ease; | ||
| `,c.onmouseover=()=>{c.style.background=e.closeHoverBg,c.style.color="#f8fafc"},c.onmouseout=()=>{c.style.background="none",c.style.color=e.muted},x.appendChild(w),x.appendChild(c);const C=document.createElement("div");C.style.cssText="padding: 20px;";const b=document.createElement("div");b.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=` | ||
| width: 100%; | ||
| padding: 10px 12px; | ||
| font-size: 14px; | ||
| border: 1px solid ${e.fieldBorder}; | ||
| border-radius: 4px; | ||
| font-family: 'Courier New', monospace; | ||
| color: ${e.fieldText}; | ||
| background: ${e.fieldBg}; | ||
| transition: all 0.2s ease; | ||
| box-sizing: border-box; | ||
| `,o.style.setProperty("caret-color",e.fieldText);const p=document.createElement("div");p.style.cssText=` | ||
| color: #d32f2f; | ||
| font-size: 12px; | ||
| margin-top: 6px; | ||
| display: none; | ||
| `;const B=document.createElement("div");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;`,b.appendChild(y),b.appendChild(o),b.appendChild(p),b.appendChild(B),C.appendChild(b);const v=document.createElement("div");v.style.cssText=` | ||
| display: flex; | ||
| gap: 12px; | ||
| padding: 16px 20px; | ||
| border-top: 1px solid ${e.border}; | ||
| background: ${e.panelBg}; | ||
| justify-content: flex-end; | ||
| `;const g=document.createElement("button");g.textContent="Cancel",g.style.cssText=` | ||
| padding: 8px 16px; | ||
| font-size: 14px; | ||
| font-weight: 500; | ||
| border: none; | ||
| border-radius: 4px; | ||
| cursor: pointer; | ||
| transition: all 0.2s ease; | ||
| background: ${e.cancelBg}; | ||
| color: ${e.cancelText}; | ||
| `,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=` | ||
| padding: 8px 16px; | ||
| font-size: 14px; | ||
| font-weight: 500; | ||
| border: none; | ||
| border-radius: 4px; | ||
| cursor: pointer; | ||
| transition: all 0.2s ease; | ||
| background: ${e.saveBg}; | ||
| color: white; | ||
| `,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 l=o.value;if(N(),l.trim()){const k=A(l);k.valid?h.has(l)?(f=`Anchor ID already exists: ${l}`,p.textContent="⚠ "+f,p.style.display="block",o.style.borderColor=e.fieldErrorBorder,o.style.background=e.fieldErrorBg):(f="",p.style.display="none",o.style.borderColor=e.fieldBorder,o.style.background=e.fieldBg):(f=k.error,p.textContent="⚠ "+f,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=f?e.fieldErrorBorder:e.saveBg,o.style.boxShadow=f?`0 0 0 3px ${e.errorRing}`:`0 0 0 3px ${e.focusRing}`,o.style.background=f?e.fieldErrorBg:e.fieldFocusBg},o.onblur=()=>{o.style.boxShadow="none",f||(o.style.background=e.fieldBg)};const T=()=>{const l=o.value.trim();!l||!A(l).valid||h.has(l)||(i&&i(l),s.remove())},E=()=>{s.remove()};a.onclick=T,g.onclick=E,c.onclick=E,o.onkeydown=l=>{l.key==="Enter"?(l.preventDefault(),T()):l.key==="Escape"&&(l.preventDefault(),E())},s.onclick=l=>{l.target===s&&E()},u.appendChild(x),u.appendChild(C),u.appendChild(v),s.appendChild(u),document.body.appendChild(s),setTimeout(()=>o.focus(),100)}function I(t,n){let i;if(n)i=n;else{const s=window.getSelection();if(!s||s.rangeCount===0)return;i=s.getRangeAt(0)}const r=document.createElement("span");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=` | ||
| display: inline; | ||
| position: relative; | ||
| cursor: pointer; | ||
| `,i.insertNode(r),h.add(t),i.setStart(r.nextSibling||r.parentNode,0),i.collapse(!0);const d=window.getSelection();d&&(d.removeAllRanges(),d.addRange(i));const e=S();if(e){const s=D(e);s&&s.dispatchEvent(new Event("input",{bubbles:!0}))}$()}function $(){if(document.getElementById("rte-anchor-styles"))return;const t=document.createElement("style");t.id="rte-anchor-styles",t.textContent=` | ||
| .rte-anchor { | ||
| display: inline; | ||
| position: relative; | ||
| cursor: pointer; | ||
| transition: all 0.2s ease; | ||
| } | ||
| .rte-anchor:hover::before { | ||
| content: '⚓'; | ||
| position: absolute; | ||
| top: -1.2em; | ||
| left: 0; | ||
| background: #333; | ||
| color: #fff; | ||
| padding: 2px 6px; | ||
| border-radius: 3px; | ||
| font-size: 0.8em; | ||
| white-space: nowrap; | ||
| z-index: 100; | ||
| box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); | ||
| } | ||
| .rte-anchor:hover::after { | ||
| content: attr(data-anchor-id); | ||
| position: absolute; | ||
| top: -1.2em; | ||
| left: 1.4em; | ||
| background: #333; | ||
| color: #fff; | ||
| padding: 2px 6px; | ||
| border-radius: 3px; | ||
| font-size: 0.75em; | ||
| font-family: 'Courier New', monospace; | ||
| white-space: nowrap; | ||
| z-index: 100; | ||
| box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); | ||
| } | ||
| [contenteditable='true'] .rte-anchor::before { | ||
| content: ''; | ||
| position: absolute; | ||
| width: 8px; | ||
| height: 8px; | ||
| background: #0066cc; | ||
| border-radius: 50%; | ||
| top: -3px; | ||
| left: 0; | ||
| opacity: 0.5; | ||
| transition: opacity 0.2s ease; | ||
| } | ||
| [contenteditable='true'] .rte-anchor:hover::before { | ||
| opacity: 1; | ||
| width: auto; | ||
| height: auto; | ||
| background: #333; | ||
| border-radius: 3px; | ||
| top: -1.2em; | ||
| padding: 2px 6px; | ||
| font-size: 0.8em; | ||
| content: '⚓'; | ||
| } | ||
| @media print { | ||
| .rte-anchor::before, | ||
| .rte-anchor::after { | ||
| display: none; | ||
| } | ||
| .rte-anchor { | ||
| cursor: auto; | ||
| } | ||
| } | ||
| .rte-anchor:focus { | ||
| outline: 2px solid #0066cc; | ||
| outline-offset: 2px; | ||
| } | ||
| `,document.head.appendChild(t)}const O=()=>(typeof window<"u"&&(z(),$()),{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 n=t.getRangeAt(0).cloneRange();return H("add","",i=>{I(i,n)},n),!0}catch(t){return console.error("Failed to insert anchor:",t),!1}}},keymap:{"Mod-Shift-k":"insertAnchor"}});exports.AnchorPlugin=O; |
| function S() { | ||
| const t = window.getSelection(); | ||
| if (!t || !t.rangeCount) | ||
| return null; | ||
| const i = t.getRangeAt(0).startContainer, n = i.nodeType === Node.TEXT_NODE ? i.parentElement : i; | ||
| return R(n); | ||
| } | ||
| function R(t) { | ||
| if (!t) return null; | ||
| if (t.hasAttribute("data-editora-editor")) | ||
| return t; | ||
| let r = t.parentElement; | ||
| for (; r; ) { | ||
| if (r.hasAttribute("data-editora-editor")) | ||
| return r; | ||
| r = r.parentElement; | ||
| } | ||
| return null; | ||
| } | ||
| function D(t) { | ||
| return t ? t.querySelector(".rte-content") : (console.warn("[Editora] Editor container not found"), null); | ||
| } | ||
| const h = /* @__PURE__ */ new Set(), m = '[data-theme="dark"], .dark, .editora-theme-dark'; | ||
| function z() { | ||
| if (typeof window > "u" || window.__anchorObserverInitialized) return; | ||
| window.__anchorObserverInitialized = !0, new MutationObserver((r) => { | ||
| r.forEach((i) => { | ||
| i.removedNodes.forEach((n) => { | ||
| if (n.nodeType === Node.ELEMENT_NODE) { | ||
| const d = n; | ||
| if (d.classList?.contains("rte-anchor")) { | ||
| const s = d.id; | ||
| s && h.delete(s); | ||
| } | ||
| d.querySelectorAll?.(".rte-anchor")?.forEach((s) => { | ||
| const u = s.id; | ||
| u && h.delete(u); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| }).observe(document.body, { | ||
| childList: !0, | ||
| subtree: !0 | ||
| }); | ||
| } | ||
| function A(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 _() { | ||
| const t = S(); | ||
| if (!t) return; | ||
| const r = D(t); | ||
| if (!r) return; | ||
| const i = r.querySelectorAll(".rte-anchor"), n = /* @__PURE__ */ new Set(); | ||
| i.forEach((d) => { | ||
| const e = d.id; | ||
| e && n.add(e); | ||
| }), h.clear(), n.forEach((d) => h.add(d)); | ||
| } | ||
| function M(t) { | ||
| if (t) { | ||
| const n = t.startContainer; | ||
| if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(m)) return !0; | ||
| } | ||
| const r = window.getSelection(); | ||
| if (r && r.rangeCount > 0) { | ||
| const n = r.getRangeAt(0).startContainer; | ||
| if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(m)) return !0; | ||
| } | ||
| return document.activeElement?.closest(m) ? !0 : document.body.matches(m) || document.documentElement.matches(m); | ||
| } | ||
| function H(t, r, i, n) { | ||
| _(); | ||
| const d = M(n), 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)" | ||
| }, s = document.createElement("div"); | ||
| s.className = "rte-anchor-dialog-overlay", s.style.cssText = ` | ||
| position: fixed; | ||
| top: 0; | ||
| left: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| background: ${e.overlay}; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| z-index: 10000; | ||
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; | ||
| `; | ||
| const u = document.createElement("div"); | ||
| if (u.className = "rte-anchor-dialog", u.style.cssText = ` | ||
| background: ${e.dialogBg}; | ||
| border: 1px solid ${e.border}; | ||
| border-radius: 8px; | ||
| box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2); | ||
| width: 90%; | ||
| max-width: 450px; | ||
| overflow: hidden; | ||
| animation: rte-anchor-dialog-appear 0.2s ease; | ||
| `, !document.getElementById("rte-anchor-dialog-styles")) { | ||
| const l = document.createElement("style"); | ||
| l.id = "rte-anchor-dialog-styles", l.textContent = ` | ||
| @keyframes rte-anchor-dialog-appear { | ||
| from { opacity: 0; transform: scale(0.95); } | ||
| to { opacity: 1; transform: scale(1); } | ||
| } | ||
| .rte-anchor-dialog input:focus { | ||
| outline: none !important; | ||
| } | ||
| `, document.head.appendChild(l); | ||
| } | ||
| let f = ""; | ||
| const x = document.createElement("div"); | ||
| x.style.cssText = ` | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| padding: 16px 20px; | ||
| border-bottom: 1px solid ${e.border}; | ||
| background: ${e.panelBg}; | ||
| `; | ||
| const w = document.createElement("h3"); | ||
| w.style.cssText = `margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`, w.textContent = "Add Anchor"; | ||
| const c = document.createElement("button"); | ||
| c.textContent = "✕", c.style.cssText = ` | ||
| background: none; | ||
| border: none; | ||
| font-size: 24px; | ||
| color: ${e.muted}; | ||
| cursor: pointer; | ||
| padding: 0; | ||
| width: 32px; | ||
| height: 32px; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| border-radius: 4px; | ||
| transition: all 0.2s ease; | ||
| `, c.onmouseover = () => { | ||
| c.style.background = e.closeHoverBg, c.style.color = "#f8fafc"; | ||
| }, c.onmouseout = () => { | ||
| c.style.background = "none", c.style.color = e.muted; | ||
| }, x.appendChild(w), x.appendChild(c); | ||
| const C = document.createElement("div"); | ||
| C.style.cssText = "padding: 20px;"; | ||
| const b = document.createElement("div"); | ||
| b.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 = ` | ||
| width: 100%; | ||
| padding: 10px 12px; | ||
| font-size: 14px; | ||
| border: 1px solid ${e.fieldBorder}; | ||
| border-radius: 4px; | ||
| font-family: 'Courier New', monospace; | ||
| color: ${e.fieldText}; | ||
| background: ${e.fieldBg}; | ||
| transition: all 0.2s ease; | ||
| box-sizing: border-box; | ||
| `, o.style.setProperty("caret-color", e.fieldText); | ||
| const p = document.createElement("div"); | ||
| p.style.cssText = ` | ||
| color: #d32f2f; | ||
| font-size: 12px; | ||
| margin-top: 6px; | ||
| display: none; | ||
| `; | ||
| const B = document.createElement("div"); | ||
| 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;`, b.appendChild(y), b.appendChild(o), b.appendChild(p), b.appendChild(B), C.appendChild(b); | ||
| const v = document.createElement("div"); | ||
| v.style.cssText = ` | ||
| display: flex; | ||
| gap: 12px; | ||
| padding: 16px 20px; | ||
| border-top: 1px solid ${e.border}; | ||
| background: ${e.panelBg}; | ||
| justify-content: flex-end; | ||
| `; | ||
| const g = document.createElement("button"); | ||
| g.textContent = "Cancel", g.style.cssText = ` | ||
| padding: 8px 16px; | ||
| font-size: 14px; | ||
| font-weight: 500; | ||
| border: none; | ||
| border-radius: 4px; | ||
| cursor: pointer; | ||
| transition: all 0.2s ease; | ||
| background: ${e.cancelBg}; | ||
| color: ${e.cancelText}; | ||
| `, 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 = ` | ||
| padding: 8px 16px; | ||
| font-size: 14px; | ||
| font-weight: 500; | ||
| border: none; | ||
| border-radius: 4px; | ||
| cursor: pointer; | ||
| transition: all 0.2s ease; | ||
| background: ${e.saveBg}; | ||
| color: white; | ||
| `, 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 l = o.value; | ||
| if (N(), l.trim()) { | ||
| const k = A(l); | ||
| k.valid ? h.has(l) ? (f = `Anchor ID already exists: ${l}`, p.textContent = "⚠ " + f, p.style.display = "block", o.style.borderColor = e.fieldErrorBorder, o.style.background = e.fieldErrorBg) : (f = "", p.style.display = "none", o.style.borderColor = e.fieldBorder, o.style.background = e.fieldBg) : (f = k.error, p.textContent = "⚠ " + f, 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 = f ? e.fieldErrorBorder : e.saveBg, o.style.boxShadow = f ? `0 0 0 3px ${e.errorRing}` : `0 0 0 3px ${e.focusRing}`, o.style.background = f ? e.fieldErrorBg : e.fieldFocusBg; | ||
| }, o.onblur = () => { | ||
| o.style.boxShadow = "none", f || (o.style.background = e.fieldBg); | ||
| }; | ||
| const T = () => { | ||
| const l = o.value.trim(); | ||
| !l || !A(l).valid || h.has(l) || (i && i(l), s.remove()); | ||
| }, E = () => { | ||
| s.remove(); | ||
| }; | ||
| a.onclick = T, g.onclick = E, c.onclick = E, o.onkeydown = (l) => { | ||
| l.key === "Enter" ? (l.preventDefault(), T()) : l.key === "Escape" && (l.preventDefault(), E()); | ||
| }, s.onclick = (l) => { | ||
| l.target === s && E(); | ||
| }, u.appendChild(x), u.appendChild(C), u.appendChild(v), s.appendChild(u), document.body.appendChild(s), setTimeout(() => o.focus(), 100); | ||
| } | ||
| function I(t, r) { | ||
| let i; | ||
| if (r) | ||
| i = r; | ||
| else { | ||
| const s = window.getSelection(); | ||
| if (!s || s.rangeCount === 0) return; | ||
| i = s.getRangeAt(0); | ||
| } | ||
| const 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 = ` | ||
| display: inline; | ||
| position: relative; | ||
| cursor: pointer; | ||
| `, i.insertNode(n), h.add(t), i.setStart(n.nextSibling || n.parentNode, 0), i.collapse(!0); | ||
| const d = window.getSelection(); | ||
| d && (d.removeAllRanges(), d.addRange(i)); | ||
| const e = S(); | ||
| if (e) { | ||
| const s = D(e); | ||
| s && s.dispatchEvent(new Event("input", { bubbles: !0 })); | ||
| } | ||
| $(); | ||
| } | ||
| function $() { | ||
| if (document.getElementById("rte-anchor-styles")) return; | ||
| const t = document.createElement("style"); | ||
| t.id = "rte-anchor-styles", t.textContent = ` | ||
| .rte-anchor { | ||
| display: inline; | ||
| position: relative; | ||
| cursor: pointer; | ||
| transition: all 0.2s ease; | ||
| } | ||
| .rte-anchor:hover::before { | ||
| content: '⚓'; | ||
| position: absolute; | ||
| top: -1.2em; | ||
| left: 0; | ||
| background: #333; | ||
| color: #fff; | ||
| padding: 2px 6px; | ||
| border-radius: 3px; | ||
| font-size: 0.8em; | ||
| white-space: nowrap; | ||
| z-index: 100; | ||
| box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); | ||
| } | ||
| .rte-anchor:hover::after { | ||
| content: attr(data-anchor-id); | ||
| position: absolute; | ||
| top: -1.2em; | ||
| left: 1.4em; | ||
| background: #333; | ||
| color: #fff; | ||
| padding: 2px 6px; | ||
| border-radius: 3px; | ||
| font-size: 0.75em; | ||
| font-family: 'Courier New', monospace; | ||
| white-space: nowrap; | ||
| z-index: 100; | ||
| box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); | ||
| } | ||
| [contenteditable='true'] .rte-anchor::before { | ||
| content: ''; | ||
| position: absolute; | ||
| width: 8px; | ||
| height: 8px; | ||
| background: #0066cc; | ||
| border-radius: 50%; | ||
| top: -3px; | ||
| left: 0; | ||
| opacity: 0.5; | ||
| transition: opacity 0.2s ease; | ||
| } | ||
| [contenteditable='true'] .rte-anchor:hover::before { | ||
| opacity: 1; | ||
| width: auto; | ||
| height: auto; | ||
| background: #333; | ||
| border-radius: 3px; | ||
| top: -1.2em; | ||
| padding: 2px 6px; | ||
| font-size: 0.8em; | ||
| content: '⚓'; | ||
| } | ||
| @media print { | ||
| .rte-anchor::before, | ||
| .rte-anchor::after { | ||
| display: none; | ||
| } | ||
| .rte-anchor { | ||
| cursor: auto; | ||
| } | ||
| } | ||
| .rte-anchor:focus { | ||
| outline: 2px solid #0066cc; | ||
| outline-offset: 2px; | ||
| } | ||
| `, document.head.appendChild(t); | ||
| } | ||
| const O = () => (typeof window < "u" && (z(), $()), { | ||
| 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 r = t.getRangeAt(0).cloneRange(); | ||
| return H("add", "", (i) => { | ||
| I(i, r); | ||
| }, r), !0; | ||
| } catch (t) { | ||
| return console.error("Failed to insert anchor:", t), !1; | ||
| } | ||
| } | ||
| }, | ||
| keymap: { | ||
| "Mod-Shift-k": "insertAnchor" | ||
| } | ||
| }); | ||
| export { | ||
| O as AnchorPlugin | ||
| }; |
+11
-3
| { | ||
| "name": "@editora/anchor", | ||
| "version": "1.0.2", | ||
| "version": "1.0.3", | ||
| "description": "Anchor plugin for Rich Text Editor - Create named navigation targets", | ||
@@ -33,4 +33,4 @@ "main": "dist/index.cjs.js", | ||
| "dependencies": { | ||
| "@editora/core": "^1.0.5", | ||
| "@editora/toast": "^2.0.2" | ||
| "@editora/core": "^1.0.6", | ||
| "@editora/toast": "^2.0.3" | ||
| }, | ||
@@ -40,3 +40,11 @@ "devDependencies": { | ||
| "react-dom": "^18.2.0" | ||
| }, | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.ts", | ||
| "import": "./dist/index.esm.js", | ||
| "require": "./dist/index.cjs.js", | ||
| "default": "./dist/index.esm.js" | ||
| } | ||
| } | ||
| } |
-421
| function S() { | ||
| const t = window.getSelection(); | ||
| if (!t || !t.rangeCount) | ||
| return null; | ||
| const i = t.getRangeAt(0).startContainer, n = i.nodeType === Node.TEXT_NODE ? i.parentElement : i; | ||
| return R(n); | ||
| } | ||
| function R(t) { | ||
| if (!t) return null; | ||
| if (t.hasAttribute("data-editora-editor")) | ||
| return t; | ||
| let r = t.parentElement; | ||
| for (; r; ) { | ||
| if (r.hasAttribute("data-editora-editor")) | ||
| return r; | ||
| r = r.parentElement; | ||
| } | ||
| return null; | ||
| } | ||
| function D(t) { | ||
| return t ? t.querySelector(".rte-content") : (console.warn("[Editora] Editor container not found"), null); | ||
| } | ||
| const h = /* @__PURE__ */ new Set(), m = '[data-theme="dark"], .dark, .editora-theme-dark'; | ||
| function z() { | ||
| if (typeof window > "u" || window.__anchorObserverInitialized) return; | ||
| window.__anchorObserverInitialized = !0, new MutationObserver((r) => { | ||
| r.forEach((i) => { | ||
| i.removedNodes.forEach((n) => { | ||
| if (n.nodeType === Node.ELEMENT_NODE) { | ||
| const d = n; | ||
| if (d.classList?.contains("rte-anchor")) { | ||
| const s = d.id; | ||
| s && h.delete(s); | ||
| } | ||
| d.querySelectorAll?.(".rte-anchor")?.forEach((s) => { | ||
| const u = s.id; | ||
| u && h.delete(u); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| }).observe(document.body, { | ||
| childList: !0, | ||
| subtree: !0 | ||
| }); | ||
| } | ||
| function A(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 _() { | ||
| const t = S(); | ||
| if (!t) return; | ||
| const r = D(t); | ||
| if (!r) return; | ||
| const i = r.querySelectorAll(".rte-anchor"), n = /* @__PURE__ */ new Set(); | ||
| i.forEach((d) => { | ||
| const e = d.id; | ||
| e && n.add(e); | ||
| }), h.clear(), n.forEach((d) => h.add(d)); | ||
| } | ||
| function M(t) { | ||
| if (t) { | ||
| const n = t.startContainer; | ||
| if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(m)) return !0; | ||
| } | ||
| const r = window.getSelection(); | ||
| if (r && r.rangeCount > 0) { | ||
| const n = r.getRangeAt(0).startContainer; | ||
| if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(m)) return !0; | ||
| } | ||
| return document.activeElement?.closest(m) ? !0 : document.body.matches(m) || document.documentElement.matches(m); | ||
| } | ||
| function H(t, r, i, n) { | ||
| _(); | ||
| const d = M(n), 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)" | ||
| }, s = document.createElement("div"); | ||
| s.className = "rte-anchor-dialog-overlay", s.style.cssText = ` | ||
| position: fixed; | ||
| top: 0; | ||
| left: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| background: ${e.overlay}; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| z-index: 10000; | ||
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; | ||
| `; | ||
| const u = document.createElement("div"); | ||
| if (u.className = "rte-anchor-dialog", u.style.cssText = ` | ||
| background: ${e.dialogBg}; | ||
| border: 1px solid ${e.border}; | ||
| border-radius: 8px; | ||
| box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2); | ||
| width: 90%; | ||
| max-width: 450px; | ||
| overflow: hidden; | ||
| animation: rte-anchor-dialog-appear 0.2s ease; | ||
| `, !document.getElementById("rte-anchor-dialog-styles")) { | ||
| const l = document.createElement("style"); | ||
| l.id = "rte-anchor-dialog-styles", l.textContent = ` | ||
| @keyframes rte-anchor-dialog-appear { | ||
| from { opacity: 0; transform: scale(0.95); } | ||
| to { opacity: 1; transform: scale(1); } | ||
| } | ||
| .rte-anchor-dialog input:focus { | ||
| outline: none !important; | ||
| } | ||
| `, document.head.appendChild(l); | ||
| } | ||
| let f = ""; | ||
| const x = document.createElement("div"); | ||
| x.style.cssText = ` | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| padding: 16px 20px; | ||
| border-bottom: 1px solid ${e.border}; | ||
| background: ${e.panelBg}; | ||
| `; | ||
| const w = document.createElement("h3"); | ||
| w.style.cssText = `margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`, w.textContent = "Add Anchor"; | ||
| const c = document.createElement("button"); | ||
| c.textContent = "✕", c.style.cssText = ` | ||
| background: none; | ||
| border: none; | ||
| font-size: 24px; | ||
| color: ${e.muted}; | ||
| cursor: pointer; | ||
| padding: 0; | ||
| width: 32px; | ||
| height: 32px; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| border-radius: 4px; | ||
| transition: all 0.2s ease; | ||
| `, c.onmouseover = () => { | ||
| c.style.background = e.closeHoverBg, c.style.color = "#f8fafc"; | ||
| }, c.onmouseout = () => { | ||
| c.style.background = "none", c.style.color = e.muted; | ||
| }, x.appendChild(w), x.appendChild(c); | ||
| const C = document.createElement("div"); | ||
| C.style.cssText = "padding: 20px;"; | ||
| const b = document.createElement("div"); | ||
| b.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 = ` | ||
| width: 100%; | ||
| padding: 10px 12px; | ||
| font-size: 14px; | ||
| border: 1px solid ${e.fieldBorder}; | ||
| border-radius: 4px; | ||
| font-family: 'Courier New', monospace; | ||
| color: ${e.fieldText}; | ||
| background: ${e.fieldBg}; | ||
| transition: all 0.2s ease; | ||
| box-sizing: border-box; | ||
| `, o.style.setProperty("caret-color", e.fieldText); | ||
| const p = document.createElement("div"); | ||
| p.style.cssText = ` | ||
| color: #d32f2f; | ||
| font-size: 12px; | ||
| margin-top: 6px; | ||
| display: none; | ||
| `; | ||
| const B = document.createElement("div"); | ||
| 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;`, b.appendChild(y), b.appendChild(o), b.appendChild(p), b.appendChild(B), C.appendChild(b); | ||
| const v = document.createElement("div"); | ||
| v.style.cssText = ` | ||
| display: flex; | ||
| gap: 12px; | ||
| padding: 16px 20px; | ||
| border-top: 1px solid ${e.border}; | ||
| background: ${e.panelBg}; | ||
| justify-content: flex-end; | ||
| `; | ||
| const g = document.createElement("button"); | ||
| g.textContent = "Cancel", g.style.cssText = ` | ||
| padding: 8px 16px; | ||
| font-size: 14px; | ||
| font-weight: 500; | ||
| border: none; | ||
| border-radius: 4px; | ||
| cursor: pointer; | ||
| transition: all 0.2s ease; | ||
| background: ${e.cancelBg}; | ||
| color: ${e.cancelText}; | ||
| `, 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 = ` | ||
| padding: 8px 16px; | ||
| font-size: 14px; | ||
| font-weight: 500; | ||
| border: none; | ||
| border-radius: 4px; | ||
| cursor: pointer; | ||
| transition: all 0.2s ease; | ||
| background: ${e.saveBg}; | ||
| color: white; | ||
| `, 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 l = o.value; | ||
| if (N(), l.trim()) { | ||
| const k = A(l); | ||
| k.valid ? h.has(l) ? (f = `Anchor ID already exists: ${l}`, p.textContent = "⚠ " + f, p.style.display = "block", o.style.borderColor = e.fieldErrorBorder, o.style.background = e.fieldErrorBg) : (f = "", p.style.display = "none", o.style.borderColor = e.fieldBorder, o.style.background = e.fieldBg) : (f = k.error, p.textContent = "⚠ " + f, 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 = f ? e.fieldErrorBorder : e.saveBg, o.style.boxShadow = f ? `0 0 0 3px ${e.errorRing}` : `0 0 0 3px ${e.focusRing}`, o.style.background = f ? e.fieldErrorBg : e.fieldFocusBg; | ||
| }, o.onblur = () => { | ||
| o.style.boxShadow = "none", f || (o.style.background = e.fieldBg); | ||
| }; | ||
| const T = () => { | ||
| const l = o.value.trim(); | ||
| !l || !A(l).valid || h.has(l) || (i && i(l), s.remove()); | ||
| }, E = () => { | ||
| s.remove(); | ||
| }; | ||
| a.onclick = T, g.onclick = E, c.onclick = E, o.onkeydown = (l) => { | ||
| l.key === "Enter" ? (l.preventDefault(), T()) : l.key === "Escape" && (l.preventDefault(), E()); | ||
| }, s.onclick = (l) => { | ||
| l.target === s && E(); | ||
| }, u.appendChild(x), u.appendChild(C), u.appendChild(v), s.appendChild(u), document.body.appendChild(s), setTimeout(() => o.focus(), 100); | ||
| } | ||
| function I(t, r) { | ||
| let i; | ||
| if (r) | ||
| i = r; | ||
| else { | ||
| const s = window.getSelection(); | ||
| if (!s || s.rangeCount === 0) return; | ||
| i = s.getRangeAt(0); | ||
| } | ||
| const 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 = ` | ||
| display: inline; | ||
| position: relative; | ||
| cursor: pointer; | ||
| `, i.insertNode(n), h.add(t), i.setStart(n.nextSibling || n.parentNode, 0), i.collapse(!0); | ||
| const d = window.getSelection(); | ||
| d && (d.removeAllRanges(), d.addRange(i)); | ||
| const e = S(); | ||
| if (e) { | ||
| const s = D(e); | ||
| s && s.dispatchEvent(new Event("input", { bubbles: !0 })); | ||
| } | ||
| $(); | ||
| } | ||
| function $() { | ||
| if (document.getElementById("rte-anchor-styles")) return; | ||
| const t = document.createElement("style"); | ||
| t.id = "rte-anchor-styles", t.textContent = ` | ||
| .rte-anchor { | ||
| display: inline; | ||
| position: relative; | ||
| cursor: pointer; | ||
| transition: all 0.2s ease; | ||
| } | ||
| .rte-anchor:hover::before { | ||
| content: '⚓'; | ||
| position: absolute; | ||
| top: -1.2em; | ||
| left: 0; | ||
| background: #333; | ||
| color: #fff; | ||
| padding: 2px 6px; | ||
| border-radius: 3px; | ||
| font-size: 0.8em; | ||
| white-space: nowrap; | ||
| z-index: 100; | ||
| box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); | ||
| } | ||
| .rte-anchor:hover::after { | ||
| content: attr(data-anchor-id); | ||
| position: absolute; | ||
| top: -1.2em; | ||
| left: 1.4em; | ||
| background: #333; | ||
| color: #fff; | ||
| padding: 2px 6px; | ||
| border-radius: 3px; | ||
| font-size: 0.75em; | ||
| font-family: 'Courier New', monospace; | ||
| white-space: nowrap; | ||
| z-index: 100; | ||
| box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); | ||
| } | ||
| [contenteditable='true'] .rte-anchor::before { | ||
| content: ''; | ||
| position: absolute; | ||
| width: 8px; | ||
| height: 8px; | ||
| background: #0066cc; | ||
| border-radius: 50%; | ||
| top: -3px; | ||
| left: 0; | ||
| opacity: 0.5; | ||
| transition: opacity 0.2s ease; | ||
| } | ||
| [contenteditable='true'] .rte-anchor:hover::before { | ||
| opacity: 1; | ||
| width: auto; | ||
| height: auto; | ||
| background: #333; | ||
| border-radius: 3px; | ||
| top: -1.2em; | ||
| padding: 2px 6px; | ||
| font-size: 0.8em; | ||
| content: '⚓'; | ||
| } | ||
| @media print { | ||
| .rte-anchor::before, | ||
| .rte-anchor::after { | ||
| display: none; | ||
| } | ||
| .rte-anchor { | ||
| cursor: auto; | ||
| } | ||
| } | ||
| .rte-anchor:focus { | ||
| outline: 2px solid #0066cc; | ||
| outline-offset: 2px; | ||
| } | ||
| `, document.head.appendChild(t); | ||
| } | ||
| const O = () => (typeof window < "u" && (z(), $()), { | ||
| 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 r = t.getRangeAt(0).cloneRange(); | ||
| return H("add", "", (i) => { | ||
| I(i, r); | ||
| }, r), !0; | ||
| } catch (t) { | ||
| return console.error("Failed to insert anchor:", t), !1; | ||
| } | ||
| } | ||
| }, | ||
| keymap: { | ||
| "Mod-Shift-k": "insertAnchor" | ||
| } | ||
| }); | ||
| export { | ||
| O as AnchorPlugin | ||
| }; |
| (function(b,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(b=typeof globalThis<"u"?globalThis:b||self,m(b.anchorPlugin={}))})(this,(function(b){"use strict";function m(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const i=t.getRangeAt(0).startContainer,n=i.nodeType===Node.TEXT_NODE?i.parentElement:i;return R(n)}function R(t){if(!t)return null;if(t.hasAttribute("data-editora-editor"))return t;let r=t.parentElement;for(;r;){if(r.hasAttribute("data-editora-editor"))return r;r=r.parentElement}return null}function S(t){return t?t.querySelector(".rte-content"):(console.warn("[Editora] Editor container not found"),null)}const h=new Set,y='[data-theme="dark"], .dark, .editora-theme-dark';function z(){if(typeof window>"u"||window.__anchorObserverInitialized)return;window.__anchorObserverInitialized=!0,new MutationObserver(r=>{r.forEach(i=>{i.removedNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){const l=n;if(l.classList?.contains("rte-anchor")){const s=l.id;s&&h.delete(s)}l.querySelectorAll?.(".rte-anchor")?.forEach(s=>{const u=s.id;u&&h.delete(u)})}})})}).observe(document.body,{childList:!0,subtree:!0})}function D(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=m();if(!t)return;const r=S(t);if(!r)return;const i=r.querySelectorAll(".rte-anchor"),n=new Set;i.forEach(l=>{const e=l.id;e&&n.add(e)}),h.clear(),n.forEach(l=>h.add(l))}function _(t){if(t){const n=t.startContainer;if((n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(y))return!0}const r=window.getSelection();if(r&&r.rangeCount>0){const n=r.getRangeAt(0).startContainer;if((n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(y))return!0}return document.activeElement?.closest(y)?!0:document.body.matches(y)||document.documentElement.matches(y)}function H(t,r,i,n){M();const l=_(n),e=l?{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)"},s=document.createElement("div");s.className="rte-anchor-dialog-overlay",s.style.cssText=` | ||
| position: fixed; | ||
| top: 0; | ||
| left: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| background: ${e.overlay}; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| z-index: 10000; | ||
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; | ||
| `;const u=document.createElement("div");if(u.className="rte-anchor-dialog",u.style.cssText=` | ||
| background: ${e.dialogBg}; | ||
| border: 1px solid ${e.border}; | ||
| border-radius: 8px; | ||
| box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2); | ||
| width: 90%; | ||
| max-width: 450px; | ||
| overflow: hidden; | ||
| animation: rte-anchor-dialog-appear 0.2s ease; | ||
| `,!document.getElementById("rte-anchor-dialog-styles")){const d=document.createElement("style");d.id="rte-anchor-dialog-styles",d.textContent=` | ||
| @keyframes rte-anchor-dialog-appear { | ||
| from { opacity: 0; transform: scale(0.95); } | ||
| to { opacity: 1; transform: scale(1); } | ||
| } | ||
| .rte-anchor-dialog input:focus { | ||
| outline: none !important; | ||
| } | ||
| `,document.head.appendChild(d)}let f="";const v=document.createElement("div");v.style.cssText=` | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| padding: 16px 20px; | ||
| border-bottom: 1px solid ${e.border}; | ||
| background: ${e.panelBg}; | ||
| `;const B=document.createElement("h3");B.style.cssText=`margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`,B.textContent="Add Anchor";const c=document.createElement("button");c.textContent="✕",c.style.cssText=` | ||
| background: none; | ||
| border: none; | ||
| font-size: 24px; | ||
| color: ${e.muted}; | ||
| cursor: pointer; | ||
| padding: 0; | ||
| width: 32px; | ||
| height: 32px; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| border-radius: 4px; | ||
| transition: all 0.2s ease; | ||
| `,c.onmouseover=()=>{c.style.background=e.closeHoverBg,c.style.color="#f8fafc"},c.onmouseout=()=>{c.style.background="none",c.style.color=e.muted},v.appendChild(B),v.appendChild(c);const k=document.createElement("div");k.style.cssText="padding: 20px;";const x=document.createElement("div");x.style.cssText="margin-bottom: 0;";const E=document.createElement("label");E.textContent="Anchor ID",E.style.cssText=`display: block; font-size: 14px; font-weight: 500; color: ${e.text}; margin-bottom: 8px;`,E.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=` | ||
| width: 100%; | ||
| padding: 10px 12px; | ||
| font-size: 14px; | ||
| border: 1px solid ${e.fieldBorder}; | ||
| border-radius: 4px; | ||
| font-family: 'Courier New', monospace; | ||
| color: ${e.fieldText}; | ||
| background: ${e.fieldBg}; | ||
| transition: all 0.2s ease; | ||
| box-sizing: border-box; | ||
| `,o.style.setProperty("caret-color",e.fieldText);const p=document.createElement("div");p.style.cssText=` | ||
| color: #d32f2f; | ||
| font-size: 12px; | ||
| margin-top: 6px; | ||
| display: none; | ||
| `;const T=document.createElement("div");T.textContent="URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.",T.style.cssText=`color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`,x.appendChild(E),x.appendChild(o),x.appendChild(p),x.appendChild(T),k.appendChild(x);const w=document.createElement("div");w.style.cssText=` | ||
| display: flex; | ||
| gap: 12px; | ||
| padding: 16px 20px; | ||
| border-top: 1px solid ${e.border}; | ||
| background: ${e.panelBg}; | ||
| justify-content: flex-end; | ||
| `;const g=document.createElement("button");g.textContent="Cancel",g.style.cssText=` | ||
| padding: 8px 16px; | ||
| font-size: 14px; | ||
| font-weight: 500; | ||
| border: none; | ||
| border-radius: 4px; | ||
| cursor: pointer; | ||
| transition: all 0.2s ease; | ||
| background: ${e.cancelBg}; | ||
| color: ${e.cancelText}; | ||
| `,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=` | ||
| padding: 8px 16px; | ||
| font-size: 14px; | ||
| font-weight: 500; | ||
| border: none; | ||
| border-radius: 4px; | ||
| cursor: pointer; | ||
| transition: all 0.2s ease; | ||
| background: ${e.saveBg}; | ||
| color: white; | ||
| `,a.disabled=!o.value.trim();const j=()=>{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=l?"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")},w.appendChild(g),w.appendChild(a),o.oninput=()=>{const d=o.value;if(j(),d.trim()){const A=D(d);A.valid?h.has(d)?(f=`Anchor ID already exists: ${d}`,p.textContent="⚠ "+f,p.style.display="block",o.style.borderColor=e.fieldErrorBorder,o.style.background=e.fieldErrorBg):(f="",p.style.display="none",o.style.borderColor=e.fieldBorder,o.style.background=e.fieldBg):(f=A.error,p.textContent="⚠ "+f,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=f?e.fieldErrorBorder:e.saveBg,o.style.boxShadow=f?`0 0 0 3px ${e.errorRing}`:`0 0 0 3px ${e.focusRing}`,o.style.background=f?e.fieldErrorBg:e.fieldFocusBg},o.onblur=()=>{o.style.boxShadow="none",f||(o.style.background=e.fieldBg)};const N=()=>{const d=o.value.trim();!d||!D(d).valid||h.has(d)||(i&&i(d),s.remove())},C=()=>{s.remove()};a.onclick=N,g.onclick=C,c.onclick=C,o.onkeydown=d=>{d.key==="Enter"?(d.preventDefault(),N()):d.key==="Escape"&&(d.preventDefault(),C())},s.onclick=d=>{d.target===s&&C()},u.appendChild(v),u.appendChild(k),u.appendChild(w),s.appendChild(u),document.body.appendChild(s),setTimeout(()=>o.focus(),100)}function I(t,r){let i;if(r)i=r;else{const s=window.getSelection();if(!s||s.rangeCount===0)return;i=s.getRangeAt(0)}const 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=` | ||
| display: inline; | ||
| position: relative; | ||
| cursor: pointer; | ||
| `,i.insertNode(n),h.add(t),i.setStart(n.nextSibling||n.parentNode,0),i.collapse(!0);const l=window.getSelection();l&&(l.removeAllRanges(),l.addRange(i));const e=m();if(e){const s=S(e);s&&s.dispatchEvent(new Event("input",{bubbles:!0}))}$()}function $(){if(document.getElementById("rte-anchor-styles"))return;const t=document.createElement("style");t.id="rte-anchor-styles",t.textContent=` | ||
| .rte-anchor { | ||
| display: inline; | ||
| position: relative; | ||
| cursor: pointer; | ||
| transition: all 0.2s ease; | ||
| } | ||
| .rte-anchor:hover::before { | ||
| content: '⚓'; | ||
| position: absolute; | ||
| top: -1.2em; | ||
| left: 0; | ||
| background: #333; | ||
| color: #fff; | ||
| padding: 2px 6px; | ||
| border-radius: 3px; | ||
| font-size: 0.8em; | ||
| white-space: nowrap; | ||
| z-index: 100; | ||
| box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); | ||
| } | ||
| .rte-anchor:hover::after { | ||
| content: attr(data-anchor-id); | ||
| position: absolute; | ||
| top: -1.2em; | ||
| left: 1.4em; | ||
| background: #333; | ||
| color: #fff; | ||
| padding: 2px 6px; | ||
| border-radius: 3px; | ||
| font-size: 0.75em; | ||
| font-family: 'Courier New', monospace; | ||
| white-space: nowrap; | ||
| z-index: 100; | ||
| box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); | ||
| } | ||
| [contenteditable='true'] .rte-anchor::before { | ||
| content: ''; | ||
| position: absolute; | ||
| width: 8px; | ||
| height: 8px; | ||
| background: #0066cc; | ||
| border-radius: 50%; | ||
| top: -3px; | ||
| left: 0; | ||
| opacity: 0.5; | ||
| transition: opacity 0.2s ease; | ||
| } | ||
| [contenteditable='true'] .rte-anchor:hover::before { | ||
| opacity: 1; | ||
| width: auto; | ||
| height: auto; | ||
| background: #333; | ||
| border-radius: 3px; | ||
| top: -1.2em; | ||
| padding: 2px 6px; | ||
| font-size: 0.8em; | ||
| content: '⚓'; | ||
| } | ||
| @media print { | ||
| .rte-anchor::before, | ||
| .rte-anchor::after { | ||
| display: none; | ||
| } | ||
| .rte-anchor { | ||
| cursor: auto; | ||
| } | ||
| } | ||
| .rte-anchor:focus { | ||
| outline: 2px solid #0066cc; | ||
| outline-offset: 2px; | ||
| } | ||
| `,document.head.appendChild(t)}const O=()=>(typeof window<"u"&&(z(),$()),{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 r=t.getRangeAt(0).cloneRange();return H("add","",i=>{I(i,r)},r),!0}catch(t){return console.error("Failed to insert anchor:",t),!1}}},keymap:{"Mod-Shift-k":"insertAnchor"}});b.AnchorPlugin=O,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})})); |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
51984
0.02%Updated
Updated