Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@editora/plugins

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@editora/plugins - npm Package Compare versions

Comparing version
1.0.7
to
1.0.8
+1
dist/_commonjsHelpers-BH3jXuIh.js
"use strict";var u=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function f(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function l(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var n=e.default;if(typeof n=="function"){var t=function o(){var r=!1;try{r=this instanceof o}catch{}return r?Reflect.construct(n,arguments,this.constructor):n.apply(this,arguments)};t.prototype=n.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(e).forEach(function(o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}),t}exports.commonjsGlobal=u;exports.getAugmentedNamespace=l;exports.getDefaultExportFromCjs=f;
var u = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function a(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function f(e) {
if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
var n = e.default;
if (typeof n == "function") {
var t = function r() {
var o = !1;
try {
o = this instanceof r;
} catch {
}
return o ? Reflect.construct(n, arguments, this.constructor) : n.apply(this, arguments);
};
t.prototype = n.prototype;
} else t = {};
return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(e).forEach(function(r) {
var o = Object.getOwnPropertyDescriptor(e, r);
Object.defineProperty(t, r, o.get ? o : {
enumerable: !0,
get: function() {
return e[r];
}
});
}), t;
}
export {
f as a,
u as c,
a as g
};
"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;
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 N(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(), w = i.width || e.offsetWidth || 220, f = i.height || e.offsetHeight || 260, y = window.innerWidth, E = window.innerHeight;
let u = s.left, d = s.bottom + r;
if (u + w > y - c && (u = y - w - 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);
} };
}
export {
N as a,
T as b
};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

import { getGlobalApiConfig as d, buildApiUrl as s, getGlobalApiHeaders as u } from "./shared-config.esm.js";
const m = () => ({
name: "document-manager",
toolbar: [
{
label: "Import Word",
command: "importWord",
icon: '<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V15h-2V9h-4V5H5c0-1.1.9-2 2-2Z"></path><path d="M9.5 7A1.5 1.5 0 0 1 11 8.4v7.1A1.5 1.5 0 0 1 9.6 17H2.5A1.5 1.5 0 0 1 1 15.6V8.5A1.5 1.5 0 0 1 2.4 7h7.1Zm-1 2.8-1 2.6-1-2.5v-.1a.6.6 0 0 0-1 0l-.1.1-.9 2.5-1-2.5v-.1a.6.6 0 0 0-1 .4v.1l1.5 4v.1a.6.6 0 0 0 1 0v-.1l1-2.5.9 2.5v.1a.6.6 0 0 0 1 0H8l1.6-4v-.2a.6.6 0 0 0-1.1-.4Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M11.4 18.2a1 1 0 0 0 1.2 1.6l1.4-1V22a1 1 0 1 0 2 0v-3.1l1.4 1a1 1 0 0 0 1.2-1.7L15 15.8l-3.6 2.4Z"></path></svg>',
type: "button"
},
{
label: "Export Word",
command: "exportWord",
icon: '<svg width="24" height="24" focusable="false"><path d="M9.5 7A1.5 1.5 0 0 1 11 8.4v7.1A1.5 1.5 0 0 1 9.6 17H2.5A1.5 1.5 0 0 1 1 15.6V8.5A1.5 1.5 0 0 1 2.4 7h7.1Zm-1 2.8-1 2.6-1-2.5v-.1a.6.6 0 0 0-1 0l-.1.1-.9 2.5-1-2.5v-.1a.6.6 0 0 0-1 .4v.1l1.5 4v.1a.6.6 0 0 0 1 0v-.1l1-2.5.9 2.5v.1a.6.6 0 0 0 1 0H8l1.6-4v-.2a.6.6 0 0 0-1.1-.4Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V17h-2V9h-4V5H7v3H5V5c0-1.1.9-2 2-2ZM15 17a1 1 0 1 0-2 0v3.1l-1.4-1a1 1 0 1 0-1.2 1.7l3.6 2.4 3.6-2.4a1 1 0 0 0-1.2-1.6l-1.4 1V17Z"></path></svg>',
type: "button"
},
{
label: "Export PDF",
command: "exportPdf",
icon: '<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V17h-2V9h-4V5H7v3H5V5c0-1.1.9-2 2-2Z"></path><path d="M2.6 15.2v-1.9h1c.6 0 1-.2 1.4-.5.3-.3.5-.7.5-1.2s-.2-.9-.5-1.2a2 2 0 0 0-1.3-.4H1v5.2h1.6Zm.4-3h-.4v-1.1h.5l.6.1.2.5c0 .1 0 .3-.2.4l-.7.1Zm5.7 3 1-.1c.3 0 .5-.2.7-.4l.5-.8c.2-.3.2-.7.2-1.3v-1l-.5-.8c-.2-.3-.4-.5-.7-.6L8.7 10H6.3v5.2h2.4Zm-.4-1.1H8v-3h.4c.5 0 .8.2 1 .4l.2 1.1-.1 1-.3.3-.8.2Zm5.3 1.2V13h2v-1h-2v-1H16V10h-4v5.2h1.6Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M15 17a1 1 0 1 0-2 0v3.1l-1.4-1a1 1 0 1 0-1.2 1.7l3.6 2.4 3.6-2.4a1 1 0 0 0-1.2-1.6l-1.4 1V17Z"></path></svg>',
type: "button"
}
],
commands: {
importWord: () => {
const r = () => {
const o = window.getSelection();
if (o && o.rangeCount > 0) {
let a = o.getRangeAt(0).startContainer;
for (; a && a !== document.body; ) {
if (a.nodeType === Node.ELEMENT_NODE) {
const i = a;
if (i.getAttribute("contenteditable") === "true")
return i;
}
a = a.parentNode;
}
}
const n = document.activeElement;
if (n?.getAttribute("contenteditable") === "true")
return n;
const t = n?.closest('[contenteditable="true"]');
return t || document.querySelector('[contenteditable="true"]');
}, e = document.createElement("input");
return e.type = "file", e.accept = ".docx", e.onchange = async (o) => {
const n = o.target.files?.[0];
if (n)
try {
const t = r();
if (t) {
const { importFromWord: a } = await import("./documentManager-CTqRftU8.mjs"), i = await a(n);
t.innerHTML = i, t.dispatchEvent(new Event("input", { bubbles: !0 }));
}
} catch (t) {
console.error("Import failed:", t), alert("Failed to import Word document. Please check the console for details.");
}
}, e.click(), !0;
},
exportWord: async () => {
const r = () => {
const e = window.getSelection();
if (e && e.rangeCount > 0) {
let t = e.getRangeAt(0).startContainer;
for (; t && t !== document.body; ) {
if (t.nodeType === Node.ELEMENT_NODE && t.getAttribute("contenteditable") === "true")
return t;
t = t.parentNode;
}
}
const o = document.activeElement;
return o?.getAttribute("contenteditable") === "true" ? o : o?.closest('[contenteditable="true"]') || document.querySelector('[contenteditable="true"]');
};
try {
const e = r();
if (e) {
const o = e.innerHTML, { exportToWord: n } = await import("./documentManager-CTqRftU8.mjs");
await n(o, "document.docx");
}
return !0;
} catch (e) {
return console.error("Export failed:", e), alert("Failed to export to Word. Please check the console for details."), !1;
}
},
exportPdf: async () => {
const r = () => {
const e = window.getSelection();
if (e && e.rangeCount > 0) {
let t = e.getRangeAt(0).startContainer;
for (; t && t !== document.body; ) {
if (t.nodeType === Node.ELEMENT_NODE && t.getAttribute("contenteditable") === "true")
return t;
t = t.parentNode;
}
}
const o = document.activeElement;
return o?.getAttribute("contenteditable") === "true" ? o : o?.closest('[contenteditable="true"]') || document.querySelector('[contenteditable="true"]');
};
try {
const e = r();
if (e) {
const o = e.innerHTML, { exportToPdf: n } = await import("./documentManager-CTqRftU8.mjs");
await n(o, "document.pdf", e);
} else
console.error("PDF Export: No editor element found"), alert("No active editor found. Please click in the editor area first.");
return !0;
} catch (e) {
return console.error("PDF Export: Export failed:", e), alert("Failed to export to PDF. Please check the console for details."), !1;
}
}
},
keymap: {}
}), p = {
apiEndpoints: {
exportWord: "/documents/export-word"
},
headers: {
// Add default headers if needed (e.g., API key)
// 'Authorization': 'Bearer YOUR_API_KEY',
// 'X-API-Key': 'YOUR_API_KEY'
},
useClientSideFallback: !0
// Enable fallback by default
};
let l = { ...p };
function f(r) {
l = { ...l, ...r };
}
function c() {
return { ...l };
}
function v(r) {
const e = c(), o = d(), n = e.apiUrl || o.apiUrl;
return s(n, e.apiEndpoints[r]);
}
function g() {
const r = u(), o = c().headers || {};
return { ...r, ...o };
}
export {
m as D,
v as a,
g as b,
c as g,
f as s
};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

"use strict";const a=require("./shared-config.cjs.js"),u=()=>({name:"document-manager",toolbar:[{label:"Import Word",command:"importWord",icon:'<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V15h-2V9h-4V5H5c0-1.1.9-2 2-2Z"></path><path d="M9.5 7A1.5 1.5 0 0 1 11 8.4v7.1A1.5 1.5 0 0 1 9.6 17H2.5A1.5 1.5 0 0 1 1 15.6V8.5A1.5 1.5 0 0 1 2.4 7h7.1Zm-1 2.8-1 2.6-1-2.5v-.1a.6.6 0 0 0-1 0l-.1.1-.9 2.5-1-2.5v-.1a.6.6 0 0 0-1 .4v.1l1.5 4v.1a.6.6 0 0 0 1 0v-.1l1-2.5.9 2.5v.1a.6.6 0 0 0 1 0H8l1.6-4v-.2a.6.6 0 0 0-1.1-.4Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M11.4 18.2a1 1 0 0 0 1.2 1.6l1.4-1V22a1 1 0 1 0 2 0v-3.1l1.4 1a1 1 0 0 0 1.2-1.7L15 15.8l-3.6 2.4Z"></path></svg>',type:"button"},{label:"Export Word",command:"exportWord",icon:'<svg width="24" height="24" focusable="false"><path d="M9.5 7A1.5 1.5 0 0 1 11 8.4v7.1A1.5 1.5 0 0 1 9.6 17H2.5A1.5 1.5 0 0 1 1 15.6V8.5A1.5 1.5 0 0 1 2.4 7h7.1Zm-1 2.8-1 2.6-1-2.5v-.1a.6.6 0 0 0-1 0l-.1.1-.9 2.5-1-2.5v-.1a.6.6 0 0 0-1 .4v.1l1.5 4v.1a.6.6 0 0 0 1 0v-.1l1-2.5.9 2.5v.1a.6.6 0 0 0 1 0H8l1.6-4v-.2a.6.6 0 0 0-1.1-.4Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V17h-2V9h-4V5H7v3H5V5c0-1.1.9-2 2-2ZM15 17a1 1 0 1 0-2 0v3.1l-1.4-1a1 1 0 1 0-1.2 1.7l3.6 2.4 3.6-2.4a1 1 0 0 0-1.2-1.6l-1.4 1V17Z"></path></svg>',type:"button"},{label:"Export PDF",command:"exportPdf",icon:'<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V17h-2V9h-4V5H7v3H5V5c0-1.1.9-2 2-2Z"></path><path d="M2.6 15.2v-1.9h1c.6 0 1-.2 1.4-.5.3-.3.5-.7.5-1.2s-.2-.9-.5-1.2a2 2 0 0 0-1.3-.4H1v5.2h1.6Zm.4-3h-.4v-1.1h.5l.6.1.2.5c0 .1 0 .3-.2.4l-.7.1Zm5.7 3 1-.1c.3 0 .5-.2.7-.4l.5-.8c.2-.3.2-.7.2-1.3v-1l-.5-.8c-.2-.3-.4-.5-.7-.6L8.7 10H6.3v5.2h2.4Zm-.4-1.1H8v-3h.4c.5 0 .8.2 1 .4l.2 1.1-.1 1-.3.3-.8.2Zm5.3 1.2V13h2v-1h-2v-1H16V10h-4v5.2h1.6Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M15 17a1 1 0 1 0-2 0v3.1l-1.4-1a1 1 0 1 0-1.2 1.7l3.6 2.4 3.6-2.4a1 1 0 0 0-1.2-1.6l-1.4 1V17Z"></path></svg>',type:"button"}],commands:{importWord:()=>{const r=()=>{const o=window.getSelection();if(o&&o.rangeCount>0){let i=o.getRangeAt(0).startContainer;for(;i&&i!==document.body;){if(i.nodeType===Node.ELEMENT_NODE){const l=i;if(l.getAttribute("contenteditable")==="true")return l}i=i.parentNode}}const n=document.activeElement;if(n?.getAttribute("contenteditable")==="true")return n;const t=n?.closest('[contenteditable="true"]');return t||document.querySelector('[contenteditable="true"]')},e=document.createElement("input");return e.type="file",e.accept=".docx",e.onchange=async o=>{const n=o.target.files?.[0];if(n)try{const t=r();if(t){const{importFromWord:i}=await Promise.resolve().then(()=>require("./documentManager-Jf0RbSks.js")),l=await i(n);t.innerHTML=l,t.dispatchEvent(new Event("input",{bubbles:!0}))}}catch(t){console.error("Import failed:",t),alert("Failed to import Word document. Please check the console for details.")}},e.click(),!0},exportWord:async()=>{const r=()=>{const e=window.getSelection();if(e&&e.rangeCount>0){let t=e.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE&&t.getAttribute("contenteditable")==="true")return t;t=t.parentNode}}const o=document.activeElement;return o?.getAttribute("contenteditable")==="true"?o:o?.closest('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]')};try{const e=r();if(e){const o=e.innerHTML,{exportToWord:n}=await Promise.resolve().then(()=>require("./documentManager-Jf0RbSks.js"));await n(o,"document.docx")}return!0}catch(e){return console.error("Export failed:",e),alert("Failed to export to Word. Please check the console for details."),!1}},exportPdf:async()=>{const r=()=>{const e=window.getSelection();if(e&&e.rangeCount>0){let t=e.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE&&t.getAttribute("contenteditable")==="true")return t;t=t.parentNode}}const o=document.activeElement;return o?.getAttribute("contenteditable")==="true"?o:o?.closest('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]')};try{const e=r();if(e){const o=e.innerHTML,{exportToPdf:n}=await Promise.resolve().then(()=>require("./documentManager-Jf0RbSks.js"));await n(o,"document.pdf",e)}else console.error("PDF Export: No editor element found"),alert("No active editor found. Please click in the editor area first.");return!0}catch(e){return console.error("PDF Export: Export failed:",e),alert("Failed to export to PDF. Please check the console for details."),!1}}},keymap:{}}),s={apiEndpoints:{exportWord:"/documents/export-word"},headers:{},useClientSideFallback:!0};let c={...s};function p(r){c={...c,...r}}function d(){return{...c}}function h(r){const e=d(),o=a.getGlobalApiConfig(),n=e.apiUrl||o.apiUrl;return a.buildApiUrl(n,e.apiEndpoints[r])}function g(){const r=a.getGlobalApiHeaders(),o=d().headers||{};return{...r,...o}}exports.DocumentManagerPlugin=u;exports.getApiHeaders=g;exports.getApiUrl=h;exports.getDocumentManagerConfig=d;exports.setDocumentManagerConfig=p;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

+11
-11

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("./editorContainerHelpers-CFbfiOJI.js"),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(d=>{d.forEach(s=>{s.removedNodes.forEach(r=>{if(r.nodeType===Node.ELEMENT_NODE){const l=r;if(l.classList?.contains("rte-anchor")){const a=l.id;a&&h.delete(a)}l.querySelectorAll?.(".rte-anchor")?.forEach(a=>{const u=a.id;u&&h.delete(u)})}})})}).observe(document.body,{childList:!0,subtree:!0})}function S(o){return!o||o.trim().length===0?{valid:!1,error:"Anchor ID cannot be empty"}:o.length>256?{valid:!1,error:"Anchor ID must be less than 256 characters"}:/^[a-z_]/.test(o)?/^[a-z0-9\-_]+$/.test(o)?{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 R(){const o=w.findEditorContainerFromSelection();if(!o)return;const d=w.getContentElement(o);if(!d)return;const s=d.querySelectorAll(".rte-anchor"),r=new Set;s.forEach(l=>{const e=l.id;e&&r.add(e)}),h.clear(),r.forEach(l=>h.add(l))}function N(o){if(o){const r=o.startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(m))return!0}const d=window.getSelection();if(d&&d.rangeCount>0){const r=d.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 M(o,d,s,r){R();const l=N(r),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)"},a=document.createElement("div");a.className="rte-anchor-dialog-overlay",a.style.cssText=`
"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=`
position: fixed;

@@ -22,3 +22,3 @@ top: 0;

animation: rte-anchor-dialog-appear 0.2s ease;
`,!document.getElementById("rte-anchor-dialog-styles")){const i=document.createElement("style");i.id="rte-anchor-dialog-styles",i.textContent=`
`,!document.getElementById("rte-anchor-dialog-styles")){const s=document.createElement("style");s.id="rte-anchor-dialog-styles",s.textContent=`
@keyframes rte-anchor-dialog-appear {

@@ -31,3 +31,3 @@ from { opacity: 0; transform: scale(0.95); }

}
`,document.head.appendChild(i)}let p="";const x=document.createElement("div");x.style.cssText=`
`,document.head.appendChild(s)}let l="";const h=document.createElement("div");h.style.cssText=`
display: flex;

@@ -39,3 +39,3 @@ align-items: center;

background: ${e.panelBg};
`;const C=document.createElement("h3");C.style.cssText=`margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`,C.textContent="Add Anchor";const c=document.createElement("button");c.textContent="✕",c.style.cssText=`
`;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=`
background: none;

@@ -54,3 +54,3 @@ border: none;

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(C),x.appendChild(c);const B=document.createElement("div");B.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 t=document.createElement("input");t.id="anchor-id-input",t.type="text",t.placeholder="e.g., section-introduction",t.value="",t.style.cssText=`
`,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=`
width: 100%;

@@ -66,3 +66,3 @@ padding: 10px 12px;

box-sizing: border-box;
`,t.style.setProperty("caret-color",e.fieldText);const f=document.createElement("div");f.style.cssText=`
`,o.style.setProperty("caret-color",e.fieldText);const p=document.createElement("div");p.style.cssText=`
color: #d32f2f;

@@ -72,3 +72,3 @@ font-size: 12px;

display: none;
`;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;`,b.appendChild(y),b.appendChild(t),b.appendChild(f),b.appendChild(k),B.appendChild(b);const v=document.createElement("div");v.style.cssText=`
`;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=`
display: flex;

@@ -90,3 +90,3 @@ gap: 12px;

color: ${e.cancelText};
`,g.onmouseover=()=>g.style.background=e.cancelHover,g.onmouseout=()=>g.style.background=e.cancelBg;const n=document.createElement("button");n.textContent="Add Anchor",n.style.cssText=`
`,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;

@@ -101,7 +101,7 @@ font-size: 14px;

color: white;
`,n.disabled=!t.value.trim();const $=()=>{t.value.trim()?(n.disabled=!1,n.style.background=e.saveBg,n.style.color="white",n.style.cursor="pointer"):(n.disabled=!0,n.style.background=e.saveDisabledBg,n.style.color=e.saveDisabledText,n.style.cursor="not-allowed")};n.onmouseover=()=>{n.disabled||(n.style.background=e.saveHover,n.style.boxShadow=l?"0 2px 8px rgba(59, 130, 246, 0.35)":"0 2px 8px rgba(0, 102, 204, 0.3)")},n.onmouseout=()=>{n.disabled||(n.style.background=e.saveBg,n.style.boxShadow="none")},v.appendChild(g),v.appendChild(n),t.oninput=()=>{const i=t.value;if($(),i.trim()){const T=S(i);T.valid?h.has(i)?(p=`Anchor ID already exists: ${i}`,f.textContent="⚠ "+p,f.style.display="block",t.style.borderColor=e.fieldErrorBorder,t.style.background=e.fieldErrorBg):(p="",f.style.display="none",t.style.borderColor=e.fieldBorder,t.style.background=e.fieldBg):(p=T.error,f.textContent="⚠ "+p,f.style.display="block",t.style.borderColor=e.fieldErrorBorder,t.style.background=e.fieldErrorBg)}else f.style.display="none",t.style.borderColor=e.fieldBorder,t.style.background=e.fieldBg},t.onfocus=()=>{t.style.borderColor=p?e.fieldErrorBorder:e.saveBg,t.style.boxShadow=p?`0 0 0 3px ${e.errorRing}`:`0 0 0 3px ${e.focusRing}`,t.style.background=p?e.fieldErrorBg:e.fieldFocusBg},t.onblur=()=>{t.style.boxShadow="none",p||(t.style.background=e.fieldBg)};const A=()=>{const i=t.value.trim();!i||!S(i).valid||h.has(i)||(s&&s(i),a.remove())},E=()=>{a.remove()};n.onclick=A,g.onclick=E,c.onclick=E,t.onkeydown=i=>{i.key==="Enter"?(i.preventDefault(),A()):i.key==="Escape"&&(i.preventDefault(),E())},a.onclick=i=>{i.target===a&&E()},u.appendChild(x),u.appendChild(B),u.appendChild(v),a.appendChild(u),document.body.appendChild(a),setTimeout(()=>t.focus(),100)}function _(o,d){let s;if(d)s=d;else{const a=window.getSelection();if(!a||a.rangeCount===0)return;s=a.getRangeAt(0)}const r=document.createElement("span");r.id=o,r.className="rte-anchor",r.setAttribute("data-type","anchor"),r.setAttribute("data-anchor-id",o),r.setAttribute("title",`Anchor: ${o}`),r.style.cssText=`
`,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=`
display: inline;
position: relative;
cursor: pointer;
`,s.insertNode(r),h.add(o),s.setStart(r.nextSibling||r.parentNode,0),s.collapse(!0);const l=window.getSelection();l&&(l.removeAllRanges(),l.addRange(s));const e=w.findEditorContainerFromSelection();if(e){const a=w.getContentElement(e);a&&a.dispatchEvent(new Event("input",{bubbles:!0}))}D()}function D(){if(document.getElementById("rte-anchor-styles"))return;const o=document.createElement("style");o.id="rte-anchor-styles",o.textContent=`
`,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=`
.rte-anchor {

@@ -184,2 +184,2 @@ display: inline;

}
`,document.head.appendChild(o)}const H=()=>(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 o=window.getSelection();if(!o||o.rangeCount===0)return alert("Please place your cursor where you want to insert the anchor."),!1;const d=o.getRangeAt(0).cloneRange();return M("add","",s=>{_(s,d)},d),!0}catch(o){return console.error("Failed to insert anchor:",o),!1}}},keymap:{"Mod-Shift-k":"insertAnchor"}});exports.AnchorPlugin=H;
`,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;

@@ -1,17 +0,26 @@

import { f as S, g as D } from "./editorContainerHelpers-C7kdWnS0.mjs";
const h = /* @__PURE__ */ new Set(), m = '[data-theme="dark"], .dark, .editora-theme-dark';
import { f as D, g as S } from "./editorContainerHelpers-C7kdWnS0.mjs";
const b = /* @__PURE__ */ new Set(), x = '[data-theme="dark"], .dark, .editora-theme-dark';
function z(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 R() {
if (typeof window > "u" || window.__anchorObserverInitialized) return;
window.__anchorObserverInitialized = !0, new MutationObserver((l) => {
l.forEach((i) => {
i.removedNodes.forEach((r) => {
if (r.nodeType === Node.ELEMENT_NODE) {
const d = r;
window.__anchorObserverInitialized = !0, new MutationObserver((c) => {
c.forEach((i) => {
i.removedNodes.forEach((n) => {
if (n.nodeType === Node.ELEMENT_NODE) {
const d = n;
if (d.classList?.contains("rte-anchor")) {
const a = d.id;
a && h.delete(a);
const r = d.id;
r && b.delete(r);
}
d.querySelectorAll?.(".rte-anchor")?.forEach((a) => {
const u = a.id;
u && h.delete(u);
d.querySelectorAll?.(".rte-anchor")?.forEach((r) => {
const u = r.id;
u && b.delete(u);
});

@@ -26,31 +35,31 @@ }

}
function A(o) {
return !o || o.trim().length === 0 ? { valid: !1, error: "Anchor ID cannot be empty" } : o.length > 256 ? { valid: !1, error: "Anchor ID must be less than 256 characters" } : /^[a-z_]/.test(o) ? /^[a-z0-9\-_]+$/.test(o) ? { 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 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 N() {
const o = S();
if (!o) return;
const l = D(o);
if (!l) return;
const i = l.querySelectorAll(".rte-anchor"), r = /* @__PURE__ */ new Set();
function M() {
const t = D();
if (!t) return;
const c = S(t);
if (!c) return;
const i = c.querySelectorAll(".rte-anchor"), n = /* @__PURE__ */ new Set();
i.forEach((d) => {
const e = d.id;
e && r.add(e);
}), h.clear(), r.forEach((d) => h.add(d));
e && n.add(e);
}), b.clear(), n.forEach((d) => b.add(d));
}
function M(o) {
if (o) {
const r = o.startContainer;
if ((r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement)?.closest(m)) return !0;
function H(t) {
if (t) {
const n = t.startContainer;
if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(x)) return !0;
}
const l = window.getSelection();
if (l && l.rangeCount > 0) {
const r = l.getRangeAt(0).startContainer;
if ((r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement)?.closest(m)) return !0;
const c = window.getSelection();
if (c && c.rangeCount > 0) {
const n = c.getRangeAt(0).startContainer;
if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(x)) return !0;
}
return document.activeElement?.closest(m) ? !0 : document.body.matches(m) || document.documentElement.matches(m);
return document.activeElement?.closest(x) ? !0 : document.body.matches(x) || document.documentElement.matches(x);
}
function _(o, l, i, r) {
N();
const d = M(r), e = d ? {
function _(t, c, i, n) {
M();
const d = H(n), e = d ? {
overlay: "rgba(0, 0, 0, 0.62)",

@@ -103,4 +112,4 @@ dialogBg: "#1f2937",

errorRing: "rgba(211, 47, 47, 0.1)"
}, a = document.createElement("div");
a.className = "rte-anchor-dialog-overlay", a.style.cssText = `
}, r = document.createElement("div");
r.className = "rte-anchor-dialog-overlay", r.style.cssText = `
position: fixed;

@@ -140,5 +149,5 @@ top: 0;

}
let p = "";
const x = document.createElement("div");
x.style.cssText = `
let l = "";
const h = document.createElement("div");
h.style.cssText = `
display: flex;

@@ -153,4 +162,4 @@ align-items: center;

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 = `
const f = document.createElement("button");
f.textContent = "✕", f.style.cssText = `
background: none;

@@ -169,15 +178,15 @@ border: none;

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);
`, f.onmouseover = () => {
f.style.background = e.closeHoverBg, f.style.color = "#f8fafc";
}, f.onmouseout = () => {
f.style.background = "none", f.style.color = e.muted;
}, h.appendChild(w), h.appendChild(f);
const C = document.createElement("div");
C.style.cssText = "padding: 20px;";
const b = document.createElement("div");
b.style.cssText = "margin-bottom: 0;";
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 t = document.createElement("input");
t.id = "anchor-id-input", t.type = "text", t.placeholder = "e.g., section-introduction", t.value = "", t.style.cssText = `
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%;

@@ -193,5 +202,5 @@ padding: 10px 12px;

box-sizing: border-box;
`, t.style.setProperty("caret-color", e.fieldText);
const f = document.createElement("div");
f.style.cssText = `
`, o.style.setProperty("caret-color", e.fieldText);
const p = document.createElement("div");
p.style.cssText = `
color: #d32f2f;

@@ -203,3 +212,3 @@ font-size: 12px;

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(t), b.appendChild(f), b.appendChild(B), C.appendChild(b);
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);
const v = document.createElement("div");

@@ -226,4 +235,4 @@ v.style.cssText = `

`, g.onmouseover = () => g.style.background = e.cancelHover, g.onmouseout = () => g.style.background = e.cancelBg;
const n = document.createElement("button");
n.textContent = "Add Anchor", n.style.cssText = `
const a = document.createElement("button");
a.textContent = "Add Anchor", a.style.cssText = `
padding: 8px 16px;

@@ -238,62 +247,76 @@ font-size: 14px;

color: white;
`, n.disabled = !t.value.trim();
const z = () => {
t.value.trim() ? (n.disabled = !1, n.style.background = e.saveBg, n.style.color = "white", n.style.cursor = "pointer") : (n.disabled = !0, n.style.background = e.saveDisabledBg, n.style.color = e.saveDisabledText, n.style.cursor = "not-allowed");
`, a.disabled = !o.value.trim();
const $ = () => {
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");
};
n.onmouseover = () => {
n.disabled || (n.style.background = e.saveHover, n.style.boxShadow = d ? "0 2px 8px rgba(59, 130, 246, 0.35)" : "0 2px 8px rgba(0, 102, 204, 0.3)");
}, n.onmouseout = () => {
n.disabled || (n.style.background = e.saveBg, n.style.boxShadow = "none");
}, v.appendChild(g), v.appendChild(n), t.oninput = () => {
const s = t.value;
if (z(), s.trim()) {
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 ($(), s.trim()) {
const k = A(s);
k.valid ? h.has(s) ? (p = `Anchor ID already exists: ${s}`, f.textContent = "⚠ " + p, f.style.display = "block", t.style.borderColor = e.fieldErrorBorder, t.style.background = e.fieldErrorBg) : (p = "", f.style.display = "none", t.style.borderColor = e.fieldBorder, t.style.background = e.fieldBg) : (p = k.error, f.textContent = "⚠ " + p, f.style.display = "block", t.style.borderColor = e.fieldErrorBorder, t.style.background = e.fieldErrorBg);
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);
} else
f.style.display = "none", t.style.borderColor = e.fieldBorder, t.style.background = e.fieldBg;
}, t.onfocus = () => {
t.style.borderColor = p ? e.fieldErrorBorder : e.saveBg, t.style.boxShadow = p ? `0 0 0 3px ${e.errorRing}` : `0 0 0 3px ${e.focusRing}`, t.style.background = p ? e.fieldErrorBg : e.fieldFocusBg;
}, t.onblur = () => {
t.style.boxShadow = "none", p || (t.style.background = e.fieldBg);
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 T = () => {
const s = t.value.trim();
!s || !A(s).valid || h.has(s) || (i && i(s), a.remove());
const s = o.value.trim();
!s || !A(s).valid || b.has(s) || (i && i(s), r.remove());
}, E = () => {
a.remove();
r.remove();
};
n.onclick = T, g.onclick = E, c.onclick = E, t.onkeydown = (s) => {
a.onclick = T, g.onclick = E, f.onclick = E, o.onkeydown = (s) => {
s.key === "Enter" ? (s.preventDefault(), T()) : s.key === "Escape" && (s.preventDefault(), E());
}, a.onclick = (s) => {
s.target === a && E();
}, u.appendChild(x), u.appendChild(C), u.appendChild(v), a.appendChild(u), document.body.appendChild(a), setTimeout(() => t.focus(), 100);
}, r.onclick = (s) => {
s.target === r && E();
}, u.appendChild(h), u.appendChild(C), u.appendChild(v), r.appendChild(u), document.body.appendChild(r), setTimeout(() => o.focus(), 100);
}
function H(o, l) {
function I(t, c) {
let i;
if (l)
i = l;
if (c)
i = c;
else {
const a = window.getSelection();
if (!a || a.rangeCount === 0) return;
i = a.getRangeAt(0);
const l = window.getSelection();
if (!l || l.rangeCount === 0) return;
i = l.getRangeAt(0);
}
const r = document.createElement("span");
r.id = o, r.className = "rte-anchor", r.setAttribute("data-type", "anchor"), r.setAttribute("data-anchor-id", o), r.setAttribute("title", `Anchor: ${o}`), r.style.cssText = `
let n = null, d = i.startContainer;
for (; d && d !== document.body; ) {
if (d.nodeType === Node.ELEMENT_NODE) {
const l = d;
if (l.getAttribute("contenteditable") === "true") {
n = l;
break;
}
}
d = d.parentNode;
}
const e = n?.innerHTML ?? "", 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(o), 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 a = D(e);
a && a.dispatchEvent(new Event("input", { bubbles: !0 }));
`, i.insertNode(r), b.add(t), i.setStart(r.nextSibling || r.parentNode, 0), i.collapse(!0);
const u = window.getSelection();
if (u && (u.removeAllRanges(), u.addRange(i)), n)
z(n, e), n.dispatchEvent(new Event("input", { bubbles: !0 }));
else {
const l = D();
if (l) {
const h = S(l);
h && h.dispatchEvent(new Event("input", { bubbles: !0 }));
}
}
$();
N();
}
function $() {
function N() {
if (document.getElementById("rte-anchor-styles")) return;
const o = document.createElement("style");
o.id = "rte-anchor-styles", o.textContent = `
const t = document.createElement("style");
t.id = "rte-anchor-styles", t.textContent = `
.rte-anchor {

@@ -376,5 +399,5 @@ display: inline;

}
`, document.head.appendChild(o);
`, document.head.appendChild(t);
}
const O = () => (typeof window < "u" && (R(), $()), {
const O = () => (typeof window < "u" && (R(), N()), {
name: "anchor",

@@ -392,11 +415,11 @@ toolbar: [

try {
const o = window.getSelection();
if (!o || o.rangeCount === 0)
const t = window.getSelection();
if (!t || t.rangeCount === 0)
return alert("Please place your cursor where you want to insert the anchor."), !1;
const l = o.getRangeAt(0).cloneRange();
const c = t.getRangeAt(0).cloneRange();
return _("add", "", (i) => {
H(i, l);
}, l), !0;
} catch (o) {
return console.error("Failed to insert anchor:", o), !1;
I(i, c);
}, c), !0;
} catch (t) {
return console.error("Failed to insert anchor:", t), !1;
}

@@ -403,0 +426,0 @@ }

@@ -1,4 +0,4 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("./colorSelectionApply-C0iOfMWb.js");let l=null,k=null,L=null,s="#ffff00";const h='[data-theme="dark"], .dark, .editora-theme-dark',A=["#000000","#ffffff","#808080","#ff0000","#00ff00","#0000ff","#ffff00","#ff00ff","#00ffff","#ffa500","#800080","#ffc0cb"];function M(){const e=window.getSelection();if(e&&e.rangeCount>0){const r=e.getRangeAt(0).startContainer,a=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement;if(a){const n=a.closest('[data-editora-editor="true"], .rte-editor, .editora-editor');if(n)return n}}const t=document.activeElement;return t?t.closest('[data-editora-editor="true"], .rte-editor, .editora-editor'):null}function R(e){const t=M();if(t){const c=t.querySelector(`[data-command="${e}"]`);if(c)return c}return document.querySelector(`[data-command="${e}"]`)}function T(e){if(e?.closest(h))return!0;const t=window.getSelection();if(t&&t.rangeCount>0){const r=t.getRangeAt(0).startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(h))return!0}return document.activeElement?.closest(h)?!0:document.body.matches(h)||document.documentElement.matches(h)}function q(){if(document.getElementById("rte-bg-color-picker-styles"))return;const e=document.createElement("style");e.id="rte-bg-color-picker-styles",e.textContent=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("./anchoredPopover-BzqGPOAE.js");let a=null,N=null,g=null,L=null,i="#ffff00";const k='[data-theme="dark"], .dark, .editora-theme-dark',R=["#000000","#ffffff","#808080","#ff0000","#00ff00","#0000ff","#ffff00","#ff00ff","#00ffff","#ffa500","#800080","#ffc0cb"];function P(){const e=window.getSelection();if(e&&e.rangeCount>0){const r=e.getRangeAt(0).startContainer,n=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement;if(n){const o=n.closest('[data-editora-editor="true"], .rte-editor, .editora-editor');if(o)return o}}const t=document.activeElement;return t?t.closest('[data-editora-editor="true"], .rte-editor, .editora-editor'):null}function M(e){const t=window.__editoraLastCommand,c=window.__editoraLastCommandButton;if(t===e&&c&&c.isConnected){const l=window.getComputedStyle(c),s=c.getBoundingClientRect();if(l.display!=="none"&&l.visibility!=="hidden"&&l.pointerEvents!=="none"&&!(s.width===0&&s.height===0))return c}const r=l=>{for(const s of l){const d=window.getComputedStyle(s),p=s.getBoundingClientRect();if(!(d.display==="none"||d.visibility==="hidden"||d.pointerEvents==="none")&&!(p.width===0&&p.height===0))return s}return null},n=P();if(n){const l=Array.from(n.querySelectorAll(`[data-command="${e}"]`)),s=r(l);if(s)return s}const o=Array.from(document.querySelectorAll(`[data-command="${e}"]`));return r(o)}function T(e){if(e?.closest(k))return!0;const t=window.getSelection();if(t&&t.rangeCount>0){const r=t.getRangeAt(0).startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(k))return!0}return document.activeElement?.closest(k)?!0:document.body.matches(k)||document.documentElement.matches(k)}function _(){if(document.getElementById("rte-bg-color-picker-styles"))return;const e=document.createElement("style");e.id="rte-bg-color-picker-styles",e.textContent=`
.rte-bg-color-picker {
position: absolute;
position: fixed;
background: white;

@@ -218,2 +218,2 @@ border-radius: 8px;

}
`,document.head.appendChild(e)}function H(){const e=document.createElement("div");e.className="rte-bg-color-picker",T(k)&&e.classList.add("rte-theme-dark"),e.addEventListener("click",m=>m.stopPropagation());const t=document.createElement("div");t.className="rte-bg-color-picker-header";const c=document.createElement("span");c.className="rte-bg-color-picker-title",c.textContent="Background Color";const r=document.createElement("button");r.type="button",r.className="rte-bg-color-picker-close",r.id="rte-bg-color-close",r.setAttribute("aria-label","Close"),r.textContent="×",t.appendChild(c),t.appendChild(r);const a=document.createElement("div");a.className="rte-bg-color-picker-body";const n=document.createElement("div");n.className="rte-bg-color-section";const o=document.createElement("div");o.className="rte-bg-color-section-label",o.textContent="Current Color";const i=document.createElement("div");i.className="rte-bg-color-preview";const d=document.createElement("div");d.className="rte-bg-color-preview-swatch",d.id="rte-bg-color-preview-swatch";const u=document.createElement("span");u.className="rte-bg-color-preview-hex",u.id="rte-bg-color-preview-hex",i.appendChild(d),i.appendChild(u),n.appendChild(o),n.appendChild(i);const x=document.createElement("div");x.className="rte-bg-color-section";const E=document.createElement("div");E.className="rte-bg-color-section-label",E.textContent="Colors";const C=document.createElement("div");C.className="rte-bg-color-grid",C.id="rte-bg-color-grid",A.forEach(m=>{const g=document.createElement("button");g.type="button",g.className="rte-bg-color-swatch",g.style.backgroundColor=m,g.dataset.color=m,g.title=m,C.appendChild(g)}),x.appendChild(E),x.appendChild(C);const w=document.createElement("div");w.className="rte-bg-color-section";const S=document.createElement("div");S.className="rte-bg-color-section-label",S.textContent="Custom";const v=document.createElement("div");v.className="rte-bg-color-custom";const f=document.createElement("input");f.type="color",f.className="rte-bg-color-input",f.id="rte-bg-color-input",f.value=s;const p=document.createElement("input");return p.type="text",p.className="rte-bg-color-text-input",p.id="rte-bg-color-text-input",p.placeholder="#FFFF00",p.value=s.toUpperCase(),p.maxLength=7,v.appendChild(f),v.appendChild(p),w.appendChild(S),w.appendChild(v),a.appendChild(n),a.appendChild(x),a.appendChild(w),e.appendChild(t),e.appendChild(a),e}function U(){if(!l)return;l.querySelector("#rte-bg-color-close")?.addEventListener("click",()=>b());const t=l.querySelector("#rte-bg-color-grid");t&&t.addEventListener("click",n=>{const o=n.target;if(o.classList.contains("rte-bg-color-swatch")){const i=o.dataset.color;i&&(s=i,y(i),b())}});const c=l.querySelector("#rte-bg-color-input");c&&(c.addEventListener("change",n=>{const o=n.target.value.toUpperCase();s=o,y(o),b()}),c.addEventListener("input",n=>{s=n.target.value.toUpperCase(),N(),B()}));const r=l.querySelector("#rte-bg-color-text-input");r&&(r.addEventListener("change",n=>{let o=n.target.value.trim();o&&!o.startsWith("#")&&(o="#"+o),/^#[0-9A-F]{6}$/i.test(o)&&(s=o.toUpperCase(),y(s),b())}),r.addEventListener("input",n=>{let o=n.target.value.trim();o&&!o.startsWith("#")&&(o="#"+o,r.value=o),/^#[0-9A-F]{6}$/i.test(o)&&(s=o.toUpperCase(),N(),B())}));const a=n=>{if(l&&k){const o=n.target;!l.contains(o)&&!k.contains(o)&&b()}};setTimeout(()=>{document.addEventListener("click",a)},100),l._clickOutsideHandler=a}function N(){if(!l)return;const e=l.querySelector("#rte-bg-color-preview-swatch"),t=l.querySelector("#rte-bg-color-preview-hex"),c=l.querySelector("#rte-bg-color-input"),r=l.querySelector("#rte-bg-color-text-input");e&&(e.style.backgroundColor=s),t&&(t.textContent=s.toUpperCase()),c&&(c.value=s),r&&(r.value=s.toUpperCase())}function B(){if(!l)return;l.querySelectorAll(".rte-bg-color-swatch").forEach(t=>{t.dataset.color?.toUpperCase()===s.toUpperCase()?t.classList.add("selected"):t.classList.remove("selected")})}function I(){try{const e=window.getSelection();if(!e||e.rangeCount===0)return"#ffff00";const c=e.getRangeAt(0).commonAncestorContainer,r=c.nodeType===1?c:c.parentElement;if(r){const a=r.closest('[style*="background-color"]');if(a){const n=a.style.backgroundColor;if(n)return O(n)}}return"#ffff00"}catch{return"#ffff00"}}function O(e){if(e.startsWith("#"))return e.toUpperCase();const t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(t){const c=parseInt(t[1]),r=parseInt(t[2]),a=parseInt(t[3]);return"#"+[c,r,a].map(n=>{const o=n.toString(16);return o.length===1?"0"+o:o}).join("").toUpperCase()}return"#ffff00"}function y(e){const t=P.applyColorToSelection({color:e,className:"rte-bg-color",styleProperty:"backgroundColor",commands:["hiliteColor","backColor"],savedRange:L,getActiveEditorRoot:M,warnMessage:"[BackgroundColor] Could not apply highlight for current selection"});return t&&console.log("[BackgroundColor] Applied color:",e),t}function b(){if(l){const e=l._clickOutsideHandler;e&&document.removeEventListener("click",e),l.remove(),l=null}k=null,L=null}function _(e,t){const c=e.getBoundingClientRect(),r=t.getBoundingClientRect(),a=r.width||220,n=r.height||320,o=8;let i=c.left;i+a>window.innerWidth-o&&(i=window.innerWidth-a-o),i=Math.max(o,i);let d=c.bottom+o;if(d+n>window.innerHeight-o){const u=c.top-n-o;u>=o?d=u:d=Math.max(o,window.innerHeight-n-o)}t.style.top=`${Math.round(d+window.scrollY)}px`,t.style.left=`${Math.round(i+window.scrollX)}px`}function z(){if(q(),l)return b(),!0;const e=R("openBackgroundColorPicker");if(!e)return!1;const t=window.getSelection();return!t||t.isCollapsed?(alert("Please select text to apply background color"),!1):(t.rangeCount>0&&(L=t.getRangeAt(0).cloneRange()),s=I(),l=H(),document.body.appendChild(l),k=e,_(e,l),N(),B(),U(),!0)}const D=()=>({name:"backgroundColor",marks:{backgroundColor:{attrs:{color:{default:"#ffffff"}},parseDOM:[{tag:'span[style*="background-color"]',getAttrs:e=>{const r=(e.getAttribute("style")||"").match(/background-color:\s*([^;]+)/);return r?{color:r[1]}:null}},{tag:"mark",getAttrs:e=>({color:e.style.backgroundColor||"#ffff00"})}],toDOM:e=>["span",{style:`background-color: ${e.attrs?.color||"#ffffff"}`,class:"rte-bg-color"},0]}},toolbar:[{label:"Background Color",command:"openBackgroundColorPicker",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path class="tox-icon-highlight-bg-color__color" d="M3 18h18v3H3z" fill="#000000"></path><path fill-rule="nonzero" d="M7.7 16.7H3l3.3-3.3-.7-.8L10.2 8l4 4.1-4 4.2c-.2.2-.6.2-.8 0l-.6-.7-1.1 1.1zm5-7.5L11 7.4l3-2.9a2 2 0 0 1 2.6 0L18 6c.7.7.7 2 0 2.7l-2.9 2.9-1.8-1.8-.5-.6"></path></g></svg>',shortcut:"Mod-Shift-h"}],commands:{openBackgroundColorPicker:()=>z(),setBackgroundColor:e=>e?y(e):!1},keymap:{"Mod-Shift-h":"openBackgroundColorPicker"}});exports.BackgroundColorPlugin=D;
`,document.head.appendChild(e)}function q(){const e=document.createElement("div");e.className="rte-bg-color-picker",T(N)&&e.classList.add("rte-theme-dark"),e.addEventListener("click",h=>h.stopPropagation());const t=document.createElement("div");t.className="rte-bg-color-picker-header";const c=document.createElement("span");c.className="rte-bg-color-picker-title",c.textContent="Background Color";const r=document.createElement("button");r.type="button",r.className="rte-bg-color-picker-close",r.id="rte-bg-color-close",r.setAttribute("aria-label","Close"),r.textContent="×",t.appendChild(c),t.appendChild(r);const n=document.createElement("div");n.className="rte-bg-color-picker-body";const o=document.createElement("div");o.className="rte-bg-color-section";const l=document.createElement("div");l.className="rte-bg-color-preview";const s=document.createElement("div");s.className="rte-bg-color-preview-swatch",s.id="rte-bg-color-preview-swatch";const d=document.createElement("span");d.className="rte-bg-color-preview-hex",d.id="rte-bg-color-preview-hex",l.appendChild(s),l.appendChild(d),o.appendChild(l);const p=document.createElement("div");p.className="rte-bg-color-section";const y=document.createElement("div");y.className="rte-bg-color-section-label",y.textContent="Colors";const x=document.createElement("div");x.className="rte-bg-color-grid",x.id="rte-bg-color-grid",R.forEach(h=>{const b=document.createElement("button");b.type="button",b.className="rte-bg-color-swatch",b.style.backgroundColor=h,b.dataset.color=h,b.title=h,x.appendChild(b)}),p.appendChild(y),p.appendChild(x);const C=document.createElement("div");C.className="rte-bg-color-section";const E=document.createElement("div");E.className="rte-bg-color-section-label",E.textContent="Custom";const v=document.createElement("div");v.className="rte-bg-color-custom";const m=document.createElement("input");m.type="color",m.className="rte-bg-color-input",m.id="rte-bg-color-input",m.value=i;const u=document.createElement("input");return u.type="text",u.className="rte-bg-color-text-input",u.id="rte-bg-color-text-input",u.placeholder="#FFFF00",u.value=i.toUpperCase(),u.maxLength=7,v.appendChild(m),v.appendChild(u),C.appendChild(E),C.appendChild(v),n.appendChild(o),n.appendChild(p),n.appendChild(C),e.appendChild(t),e.appendChild(n),e}function I(){if(!a)return;a.querySelector("#rte-bg-color-close")?.addEventListener("click",()=>f());const t=a.querySelector("#rte-bg-color-grid");t&&t.addEventListener("click",n=>{const o=n.target;if(o.classList.contains("rte-bg-color-swatch")){const l=o.dataset.color;l&&(i=l,w(l),f())}});const c=a.querySelector("#rte-bg-color-input");c&&(c.addEventListener("change",n=>{const o=n.target.value.toUpperCase();i=o,w(o),f()}),c.addEventListener("input",n=>{i=n.target.value.toUpperCase(),S(),B()}));const r=a.querySelector("#rte-bg-color-text-input");r&&(r.addEventListener("change",n=>{let o=n.target.value.trim();o&&!o.startsWith("#")&&(o="#"+o),/^#[0-9A-F]{6}$/i.test(o)&&(i=o.toUpperCase(),w(i),f())}),r.addEventListener("input",n=>{let o=n.target.value.trim();o&&!o.startsWith("#")&&(o="#"+o,r.value=o),/^#[0-9A-F]{6}$/i.test(o)&&(i=o.toUpperCase(),S(),B())}))}function S(){if(!a)return;const e=a.querySelector("#rte-bg-color-preview-swatch"),t=a.querySelector("#rte-bg-color-preview-hex"),c=a.querySelector("#rte-bg-color-input"),r=a.querySelector("#rte-bg-color-text-input");e&&(e.style.backgroundColor=i),t&&(t.textContent=i.toUpperCase()),c&&(c.value=i),r&&(r.value=i.toUpperCase())}function B(){if(!a)return;a.querySelectorAll(".rte-bg-color-swatch").forEach(t=>{t.dataset.color?.toUpperCase()===i.toUpperCase()?t.classList.add("selected"):t.classList.remove("selected")})}function U(){try{const e=window.getSelection();if(!e||e.rangeCount===0)return"#ffff00";const c=e.getRangeAt(0).commonAncestorContainer,r=c.nodeType===1?c:c.parentElement;if(r){const n=r.closest('[style*="background-color"]');if(n){const o=n.style.backgroundColor;if(o)return z(o)}}return"#ffff00"}catch{return"#ffff00"}}function z(e){if(e.startsWith("#"))return e.toUpperCase();const t=e.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(t){const c=parseInt(t[1]),r=parseInt(t[2]),n=parseInt(t[3]);return"#"+[c,r,n].map(o=>{const l=o.toString(16);return l.length===1?"0"+l:l}).join("").toUpperCase()}return"#ffff00"}function w(e){const t=A.applyColorToSelection({color:e,className:"rte-bg-color",styleProperty:"backgroundColor",commands:["hiliteColor","backColor"],savedRange:L,getActiveEditorRoot:P,warnMessage:"[BackgroundColor] Could not apply highlight for current selection"});return t&&console.log("[BackgroundColor] Applied color:",e),t}function f(){g&&(g.destroy(),g=null),a&&(a.remove(),a=null),N=null,L=null}function H(){if(_(),a)return f(),!0;const e=M("openBackgroundColorPicker");if(!e)return!1;const t=window.getSelection();return!t||t.isCollapsed?(alert("Please select text to apply background color"),!1):(t.rangeCount>0&&(L=t.getRangeAt(0).cloneRange()),i=U(),a=q(),document.body.appendChild(a),N=e,g&&(g.destroy(),g=null),g=A.attachAnchoredPopover({popover:a,anchor:e,onClose:f,gap:8,margin:8,zIndex:1e4}),S(),B(),I(),!0)}const O=()=>({name:"backgroundColor",marks:{backgroundColor:{attrs:{color:{default:"#ffffff"}},parseDOM:[{tag:'span[style*="background-color"]',getAttrs:e=>{const r=(e.getAttribute("style")||"").match(/background-color:\s*([^;]+)/);return r?{color:r[1]}:null}},{tag:"mark",getAttrs:e=>({color:e.style.backgroundColor||"#ffff00"})}],toDOM:e=>["span",{style:`background-color: ${e.attrs?.color||"#ffffff"}`,class:"rte-bg-color"},0]}},toolbar:[{label:"Background Color",command:"openBackgroundColorPicker",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path class="tox-icon-highlight-bg-color__color" d="M3 18h18v3H3z" fill="#000000"></path><path fill-rule="nonzero" d="M7.7 16.7H3l3.3-3.3-.7-.8L10.2 8l4 4.1-4 4.2c-.2.2-.6.2-.8 0l-.6-.7-1.1 1.1zm5-7.5L11 7.4l3-2.9a2 2 0 0 1 2.6 0L18 6c.7.7.7 2 0 2.7l-2.9 2.9-1.8-1.8-.5-.6"></path></g></svg>',shortcut:"Mod-Shift-h"}],commands:{openBackgroundColorPicker:()=>H(),setBackgroundColor:e=>e?w(e):!1},keymap:{"Mod-Shift-h":"openBackgroundColorPicker"}});exports.BackgroundColorPlugin=O;

@@ -1,4 +0,4 @@

import { a as A } from "./colorSelectionApply-D8r_gV32.mjs";
let l = null, k = null, B = null, s = "#ffff00";
const h = '[data-theme="dark"], .dark, .editora-theme-dark', M = [
import { a as P, b as R } from "./anchoredPopover-Dts0IrgU.mjs";
let a = null, N = null, g = null, L = null, i = "#ffff00";
const k = '[data-theme="dark"], .dark, .editora-theme-dark', I = [
"#000000",

@@ -17,11 +17,11 @@ "#ffffff",

];
function R() {
function A() {
const e = window.getSelection();
if (e && e.rangeCount > 0) {
const r = e.getRangeAt(0).startContainer, a = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement;
if (a) {
const n = a.closest(
const r = e.getRangeAt(0).startContainer, n = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement;
if (n) {
const o = n.closest(
'[data-editora-editor="true"], .rte-editor, .editora-editor'
);
if (n) return n;
if (o) return o;
}

@@ -34,22 +34,38 @@ }

}
function P(e) {
const t = R();
if (t) {
const c = t.querySelector(
`[data-command="${e}"]`
);
if (c) return c;
function M(e) {
const t = window.__editoraLastCommand, c = window.__editoraLastCommandButton;
if (t === e && c && c.isConnected) {
const l = window.getComputedStyle(c), s = c.getBoundingClientRect();
if (l.display !== "none" && l.visibility !== "hidden" && l.pointerEvents !== "none" && !(s.width === 0 && s.height === 0))
return c;
}
return document.querySelector(`[data-command="${e}"]`);
const r = (l) => {
for (const s of l) {
const d = window.getComputedStyle(s), p = s.getBoundingClientRect();
if (!(d.display === "none" || d.visibility === "hidden" || d.pointerEvents === "none") && !(p.width === 0 && p.height === 0))
return s;
}
return null;
}, n = A();
if (n) {
const l = Array.from(
n.querySelectorAll(`[data-command="${e}"]`)
), s = r(l);
if (s) return s;
}
const o = Array.from(
document.querySelectorAll(`[data-command="${e}"]`)
);
return r(o);
}
function T(e) {
if (e?.closest(h)) return !0;
if (e?.closest(k)) return !0;
const t = window.getSelection();
if (t && t.rangeCount > 0) {
const r = t.getRangeAt(0).startContainer;
if ((r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement)?.closest(h)) return !0;
if ((r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement)?.closest(k)) return !0;
}
return document.activeElement?.closest(h) ? !0 : document.body.matches(h) || document.documentElement.matches(h);
return document.activeElement?.closest(k) ? !0 : document.body.matches(k) || document.documentElement.matches(k);
}
function H() {
function U() {
if (document.getElementById("rte-bg-color-picker-styles"))

@@ -60,3 +76,3 @@ return;

.rte-bg-color-picker {
position: absolute;
position: fixed;
background: white;

@@ -278,5 +294,5 @@ border-radius: 8px;

}
function U() {
function q() {
const e = document.createElement("div");
e.className = "rte-bg-color-picker", T(k) && e.classList.add("rte-theme-dark"), e.addEventListener("click", (m) => m.stopPropagation());
e.className = "rte-bg-color-picker", T(N) && e.classList.add("rte-theme-dark"), e.addEventListener("click", (h) => h.stopPropagation());
const t = document.createElement("div");

@@ -288,82 +304,71 @@ t.className = "rte-bg-color-picker-header";

r.type = "button", r.className = "rte-bg-color-picker-close", r.id = "rte-bg-color-close", r.setAttribute("aria-label", "Close"), r.textContent = "×", t.appendChild(c), t.appendChild(r);
const a = document.createElement("div");
a.className = "rte-bg-color-picker-body";
const n = document.createElement("div");
n.className = "rte-bg-color-section";
n.className = "rte-bg-color-picker-body";
const o = document.createElement("div");
o.className = "rte-bg-color-section-label", o.textContent = "Current Color";
const i = document.createElement("div");
i.className = "rte-bg-color-preview";
const d = document.createElement("div");
d.className = "rte-bg-color-preview-swatch", d.id = "rte-bg-color-preview-swatch";
const u = document.createElement("span");
u.className = "rte-bg-color-preview-hex", u.id = "rte-bg-color-preview-hex", i.appendChild(d), i.appendChild(u), n.appendChild(o), n.appendChild(i);
o.className = "rte-bg-color-section";
const l = document.createElement("div");
l.className = "rte-bg-color-preview";
const s = document.createElement("div");
s.className = "rte-bg-color-preview-swatch", s.id = "rte-bg-color-preview-swatch";
const d = document.createElement("span");
d.className = "rte-bg-color-preview-hex", d.id = "rte-bg-color-preview-hex", l.appendChild(s), l.appendChild(d), o.appendChild(l);
const p = document.createElement("div");
p.className = "rte-bg-color-section";
const y = document.createElement("div");
y.className = "rte-bg-color-section-label", y.textContent = "Colors";
const x = document.createElement("div");
x.className = "rte-bg-color-section";
x.className = "rte-bg-color-grid", x.id = "rte-bg-color-grid", I.forEach((h) => {
const b = document.createElement("button");
b.type = "button", b.className = "rte-bg-color-swatch", b.style.backgroundColor = h, b.dataset.color = h, b.title = h, x.appendChild(b);
}), p.appendChild(y), p.appendChild(x);
const C = document.createElement("div");
C.className = "rte-bg-color-section";
const E = document.createElement("div");
E.className = "rte-bg-color-section-label", E.textContent = "Colors";
const C = document.createElement("div");
C.className = "rte-bg-color-grid", C.id = "rte-bg-color-grid", M.forEach((m) => {
const g = document.createElement("button");
g.type = "button", g.className = "rte-bg-color-swatch", g.style.backgroundColor = m, g.dataset.color = m, g.title = m, C.appendChild(g);
}), x.appendChild(E), x.appendChild(C);
E.className = "rte-bg-color-section-label", E.textContent = "Custom";
const w = document.createElement("div");
w.className = "rte-bg-color-section";
const S = document.createElement("div");
S.className = "rte-bg-color-section-label", S.textContent = "Custom";
const v = document.createElement("div");
v.className = "rte-bg-color-custom";
const f = document.createElement("input");
f.type = "color", f.className = "rte-bg-color-input", f.id = "rte-bg-color-input", f.value = s;
const p = document.createElement("input");
return p.type = "text", p.className = "rte-bg-color-text-input", p.id = "rte-bg-color-text-input", p.placeholder = "#FFFF00", p.value = s.toUpperCase(), p.maxLength = 7, v.appendChild(f), v.appendChild(p), w.appendChild(S), w.appendChild(v), a.appendChild(n), a.appendChild(x), a.appendChild(w), e.appendChild(t), e.appendChild(a), e;
w.className = "rte-bg-color-custom";
const m = document.createElement("input");
m.type = "color", m.className = "rte-bg-color-input", m.id = "rte-bg-color-input", m.value = i;
const u = document.createElement("input");
return u.type = "text", u.className = "rte-bg-color-text-input", u.id = "rte-bg-color-text-input", u.placeholder = "#FFFF00", u.value = i.toUpperCase(), u.maxLength = 7, w.appendChild(m), w.appendChild(u), C.appendChild(E), C.appendChild(w), n.appendChild(o), n.appendChild(p), n.appendChild(C), e.appendChild(t), e.appendChild(n), e;
}
function q() {
if (!l) return;
l.querySelector("#rte-bg-color-close")?.addEventListener("click", () => b());
const t = l.querySelector("#rte-bg-color-grid");
function _() {
if (!a) return;
a.querySelector("#rte-bg-color-close")?.addEventListener("click", () => f());
const t = a.querySelector("#rte-bg-color-grid");
t && t.addEventListener("click", (n) => {
const o = n.target;
if (o.classList.contains("rte-bg-color-swatch")) {
const i = o.dataset.color;
i && (s = i, y(i), b());
const l = o.dataset.color;
l && (i = l, v(l), f());
}
});
const c = l.querySelector("#rte-bg-color-input");
const c = a.querySelector("#rte-bg-color-input");
c && (c.addEventListener("change", (n) => {
const o = n.target.value.toUpperCase();
s = o, y(o), b();
i = o, v(o), f();
}), c.addEventListener("input", (n) => {
s = n.target.value.toUpperCase(), N(), L();
i = n.target.value.toUpperCase(), S(), B();
}));
const r = l.querySelector("#rte-bg-color-text-input");
const r = a.querySelector("#rte-bg-color-text-input");
r && (r.addEventListener("change", (n) => {
let o = n.target.value.trim();
o && !o.startsWith("#") && (o = "#" + o), /^#[0-9A-F]{6}$/i.test(o) && (s = o.toUpperCase(), y(s), b());
o && !o.startsWith("#") && (o = "#" + o), /^#[0-9A-F]{6}$/i.test(o) && (i = o.toUpperCase(), v(i), f());
}), r.addEventListener("input", (n) => {
let o = n.target.value.trim();
o && !o.startsWith("#") && (o = "#" + o, r.value = o), /^#[0-9A-F]{6}$/i.test(o) && (s = o.toUpperCase(), N(), L());
o && !o.startsWith("#") && (o = "#" + o, r.value = o), /^#[0-9A-F]{6}$/i.test(o) && (i = o.toUpperCase(), S(), B());
}));
const a = (n) => {
if (l && k) {
const o = n.target;
!l.contains(o) && !k.contains(o) && b();
}
};
setTimeout(() => {
document.addEventListener("click", a);
}, 100), l._clickOutsideHandler = a;
}
function N() {
if (!l) return;
const e = l.querySelector("#rte-bg-color-preview-swatch"), t = l.querySelector("#rte-bg-color-preview-hex"), c = l.querySelector("#rte-bg-color-input"), r = l.querySelector("#rte-bg-color-text-input");
e && (e.style.backgroundColor = s), t && (t.textContent = s.toUpperCase()), c && (c.value = s), r && (r.value = s.toUpperCase());
function S() {
if (!a) return;
const e = a.querySelector("#rte-bg-color-preview-swatch"), t = a.querySelector("#rte-bg-color-preview-hex"), c = a.querySelector("#rte-bg-color-input"), r = a.querySelector("#rte-bg-color-text-input");
e && (e.style.backgroundColor = i), t && (t.textContent = i.toUpperCase()), c && (c.value = i), r && (r.value = i.toUpperCase());
}
function L() {
if (!l) return;
l.querySelectorAll(".rte-bg-color-swatch").forEach((t) => {
t.dataset.color?.toUpperCase() === s.toUpperCase() ? t.classList.add("selected") : t.classList.remove("selected");
function B() {
if (!a) return;
a.querySelectorAll(".rte-bg-color-swatch").forEach((t) => {
t.dataset.color?.toUpperCase() === i.toUpperCase() ? t.classList.add("selected") : t.classList.remove("selected");
});
}
function I() {
function z() {
try {

@@ -375,7 +380,7 @@ const e = window.getSelection();

if (r) {
const a = r.closest('[style*="background-color"]');
if (a) {
const n = a.style.backgroundColor;
if (n)
return O(n);
const n = r.closest('[style*="background-color"]');
if (n) {
const o = n.style.backgroundColor;
if (o)
return H(o);
}

@@ -388,3 +393,3 @@ }

}
function O(e) {
function H(e) {
if (e.startsWith("#"))

@@ -394,6 +399,6 @@ return e.toUpperCase();

if (t) {
const c = parseInt(t[1]), r = parseInt(t[2]), a = parseInt(t[3]);
return "#" + [c, r, a].map((n) => {
const o = n.toString(16);
return o.length === 1 ? "0" + o : o;
const c = parseInt(t[1]), r = parseInt(t[2]), n = parseInt(t[3]);
return "#" + [c, r, n].map((o) => {
const l = o.toString(16);
return l.length === 1 ? "0" + l : l;
}).join("").toUpperCase();

@@ -403,4 +408,4 @@ }

}
function y(e) {
const t = A({
function v(e) {
const t = P({
color: e,

@@ -410,4 +415,4 @@ className: "rte-bg-color",

commands: ["hiliteColor", "backColor"],
savedRange: B,
getActiveEditorRoot: R,
savedRange: L,
getActiveEditorRoot: A,
warnMessage: "[BackgroundColor] Could not apply highlight for current selection"

@@ -417,30 +422,22 @@ });

}
function b() {
if (l) {
const e = l._clickOutsideHandler;
e && document.removeEventListener("click", e), l.remove(), l = null;
}
k = null, B = null;
function f() {
g && (g.destroy(), g = null), a && (a.remove(), a = null), N = null, L = null;
}
function z(e, t) {
const c = e.getBoundingClientRect(), r = t.getBoundingClientRect(), a = r.width || 220, n = r.height || 320, o = 8;
let i = c.left;
i + a > window.innerWidth - o && (i = window.innerWidth - a - o), i = Math.max(o, i);
let d = c.bottom + o;
if (d + n > window.innerHeight - o) {
const u = c.top - n - o;
u >= o ? d = u : d = Math.max(o, window.innerHeight - n - o);
}
t.style.top = `${Math.round(d + window.scrollY)}px`, t.style.left = `${Math.round(i + window.scrollX)}px`;
}
function _() {
if (H(), l)
return b(), !0;
const e = P("openBackgroundColorPicker");
function D() {
if (U(), a)
return f(), !0;
const e = M("openBackgroundColorPicker");
if (!e)
return !1;
const t = window.getSelection();
return !t || t.isCollapsed ? (alert("Please select text to apply background color"), !1) : (t.rangeCount > 0 && (B = t.getRangeAt(0).cloneRange()), s = I(), l = U(), document.body.appendChild(l), k = e, z(e, l), N(), L(), q(), !0);
return !t || t.isCollapsed ? (alert("Please select text to apply background color"), !1) : (t.rangeCount > 0 && (L = t.getRangeAt(0).cloneRange()), i = z(), a = q(), document.body.appendChild(a), N = e, g && (g.destroy(), g = null), g = R({
popover: a,
anchor: e,
onClose: f,
gap: 8,
margin: 8,
zIndex: 1e4
}), S(), B(), _(), !0);
}
const F = () => ({
const O = () => ({
name: "backgroundColor",

@@ -484,4 +481,4 @@ marks: {

commands: {
openBackgroundColorPicker: () => _(),
setBackgroundColor: (e) => e ? y(e) : !1
openBackgroundColorPicker: () => D(),
setBackgroundColor: (e) => e ? v(e) : !1
},

@@ -493,3 +490,3 @@ keymap: {

export {
F as BackgroundColorPlugin
O as BackgroundColorPlugin
};

@@ -1,6 +0,6 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=new WeakMap;let x=null,S=!1,k=0;const E="User";function h(e){return k+=1,`${e}-${Date.now()}-${k}`}function v(e){if(!e)return null;const t=e instanceof Element?e:e.parentElement;return t?t.closest("[data-editora-editor]")||t.closest(".rte-editor")||t.closest(".editora-editor"):null}function w(e,t){return t.contains(e.commonAncestorContainer)}function I(){if(typeof window<"u"){const o=window.__editoraCommandEditorRoot;if(o instanceof HTMLElement){const a=o.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(o.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?o:null);if(a)return x=a,window.__editoraCommandEditorRoot=null,a}}const e=document.activeElement,t=e?v(e):null;if(t)return t;const r=window.getSelection();if(r&&r.rangeCount>0){const o=v(r.getRangeAt(0).commonAncestorContainer);if(o)return o}return x}function B(e){const t=C.get(e);if(t)return t;const r={root:e,comments:new Map,panelVisible:!1,panelElement:null,expandedComments:new Set,replyTexts:{},savedSelection:null,newCommentText:"",selectionChangeListener:null};return C.set(e,r),r}function f(){const e=I();return e?(x=e,B(e)):null}function T(e){const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const r=t.getRangeAt(0);return w(r,e)?r.cloneRange():null}function R(e,t){if(!t.anchorId)return;const r=e.root.querySelector(`#${t.anchorId}`);r&&r.classList.toggle("rte-comment-anchor-resolved",t.resolved)}function b(e,t,r){const o=e.comments.get(t);if(!o||!o.anchorId)return;const a=e.root.querySelector(`#${o.anchorId}`);a&&a.classList.toggle("highlighted",r)}function $(e,t,r){t.onclick=o=>{o.preventDefault(),o.stopPropagation(),x=e.root,e.expandedComments.add(r),y(e,!0),m(e)}}function q(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);e.remove()}}function y(e,t){F(),H(e),e.panelVisible=t,e.root.setAttribute("data-rte-comments-open",t?"true":"false"),e.panelElement&&(e.panelElement.classList.toggle("is-open",t),e.panelElement.setAttribute("aria-hidden",t?"false":"true")),t?N(e):z(e)}function H(e){if(e.panelElement)return;const t=document.createElement("aside");t.className="rte-comments-panel",t.setAttribute("role","complementary"),t.setAttribute("aria-label","Comments"),t.setAttribute("aria-hidden","true"),window.getComputedStyle(e.root).position==="static"&&(e.root.style.position="relative"),e.root.appendChild(t),e.panelElement=t}function N(e){e.selectionChangeListener||(e.selectionChangeListener=()=>{const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return;const r=t.getRangeAt(0);w(r,e.root)&&(e.savedSelection=r.cloneRange(),x=e.root)},document.addEventListener("selectionchange",e.selectionChangeListener))}function z(e){e.selectionChangeListener&&(document.removeEventListener("selectionchange",e.selectionChangeListener),e.selectionChangeListener=null)}function V(e){return Array.from(e.comments.values()).sort((t,r)=>r.createdAt.localeCompare(t.createdAt))}function A(e){return new Date(e).toLocaleString()}function M(e,t){const r=e.expandedComments.has(t.id),o=document.createElement("article");o.className=`rte-comment-item${t.resolved?" resolved":""}`,o.innerHTML=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=new WeakMap;let x=null,S=!1,k=0;const E="User";function v(t){return k+=1,`${t}-${Date.now()}-${k}`}function y(t){if(!t)return null;const e=t instanceof Element?t:t.parentElement;return e?e.closest("[data-editora-editor]")||e.closest(".rte-editor")||e.closest(".editora-editor"):null}function A(t){const e=t?.editorElement||t?.contentElement||null;if(!(e instanceof HTMLElement))return;const r=e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?e:null);r&&(x=r)}function w(t,e){return e.contains(t.commonAncestorContainer)}function B(){if(typeof window<"u"){const o=window.__editoraCommandEditorRoot;if(o instanceof HTMLElement){const a=o.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(o.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?o:null);if(a)return x=a,window.__editoraCommandEditorRoot=null,a}}const t=document.activeElement,e=t?y(t):null;if(e)return e;const r=window.getSelection();if(r&&r.rangeCount>0){const o=y(r.getRangeAt(0).commonAncestorContainer);if(o)return o}return x}function H(t){const e=C.get(t);if(e)return e;const r={root:t,comments:new Map,panelVisible:!1,panelElement:null,expandedComments:new Set,replyTexts:{},savedSelection:null,newCommentText:"",selectionChangeListener:null};return C.set(t,r),r}function u(){const t=B();return t?(x=t,H(t)):null}function R(t){const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return null;const r=e.getRangeAt(0);return w(r,t)?r.cloneRange():null}function I(t,e){if(!e.anchorId)return;const r=t.root.querySelector(`#${e.anchorId}`);r&&r.classList.toggle("rte-comment-anchor-resolved",e.resolved)}function h(t,e,r){const o=t.comments.get(e);if(!o||!o.anchorId)return;const a=t.root.querySelector(`#${o.anchorId}`);a&&a.classList.toggle("highlighted",r)}function $(t,e,r){e.onclick=o=>{o.preventDefault(),o.stopPropagation(),x=t.root,t.expandedComments.add(r),g(t,!0),m(t)}}function q(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);t.remove()}}function g(t,e){if(t.panelVisible=e,e){Z(),N(t),t.root.setAttribute("data-rte-comments-open","true"),t.panelElement&&(t.panelElement.classList.add("is-open"),t.panelElement.setAttribute("aria-hidden","false")),z(t);return}t.root.removeAttribute("data-rte-comments-open"),V(t),t.panelElement&&(t.panelElement.remove(),t.panelElement=null)}function N(t){if(t.panelElement)return;const e=document.createElement("aside");e.className="rte-comments-panel",e.setAttribute("role","complementary"),e.setAttribute("aria-label","Comments"),e.setAttribute("aria-hidden","true"),window.getComputedStyle(t.root).position==="static"&&(t.root.style.position="relative"),t.root.appendChild(e),t.panelElement=e}function z(t){t.selectionChangeListener||(t.selectionChangeListener=()=>{const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return;const r=e.getRangeAt(0);w(r,t.root)&&(t.savedSelection=r.cloneRange(),x=t.root)},document.addEventListener("selectionchange",t.selectionChangeListener))}function V(t){t.selectionChangeListener&&(document.removeEventListener("selectionchange",t.selectionChangeListener),t.selectionChangeListener=null)}function M(t){return Array.from(t.comments.values()).sort((e,r)=>r.createdAt.localeCompare(e.createdAt))}function L(t){return new Date(t).toLocaleString()}function D(t,e){const r=t.expandedComments.has(e.id),o=document.createElement("article");o.className=`rte-comment-item${e.resolved?" resolved":""}`,o.innerHTML=`
<header class="rte-comment-header">
<div class="rte-comment-meta">
<strong class="rte-comment-author">${t.author}</strong>
<time class="rte-comment-date">${A(t.createdAt)}</time>
<strong class="rte-comment-author">${e.author}</strong>
<time class="rte-comment-date">${L(e.createdAt)}</time>
</div>

@@ -12,14 +12,14 @@ <button class="rte-comment-expand" type="button" aria-label="Toggle details">

<div class="rte-comment-text"></div>
${t.selectedText?`<blockquote class="rte-comment-selection">${t.selectedText}</blockquote>`:""}
${e.selectedText?`<blockquote class="rte-comment-selection">${e.selectedText}</blockquote>`:""}
<section class="rte-comment-expanded${r?" show":""}"></section>
`;const a=o.querySelector(".rte-comment-text");a&&(a.textContent=t.text),o.querySelector(".rte-comment-expand")?.addEventListener("click",()=>{e.expandedComments.has(t.id)?e.expandedComments.delete(t.id):e.expandedComments.add(t.id),m(e)});const p=o.querySelector(".rte-comment-expanded");if(p&&r){if(t.replies.length>0){const n=document.createElement("div");n.className="rte-comment-replies",t.replies.forEach(s=>{const l=document.createElement("div");l.className="rte-comment-reply",l.innerHTML=`
`;const a=o.querySelector(".rte-comment-text");a&&(a.textContent=e.text),o.querySelector(".rte-comment-expand")?.addEventListener("click",()=>{t.expandedComments.has(e.id)?t.expandedComments.delete(e.id):t.expandedComments.add(e.id),m(t)});const p=o.querySelector(".rte-comment-expanded");if(p&&r){if(e.replies.length>0){const n=document.createElement("div");n.className="rte-comment-replies",e.replies.forEach(s=>{const l=document.createElement("div");l.className="rte-comment-reply",l.innerHTML=`
<div class="rte-comment-reply-header">
<strong>${s.author}</strong>
<time>${A(s.createdAt)}</time>
<time>${L(s.createdAt)}</time>
</div>
<div class="rte-comment-reply-text"></div>
`;const u=l.querySelector(".rte-comment-reply-text");u&&(u.textContent=s.text),n.appendChild(l)}),p.appendChild(n)}if(!t.resolved){const n=document.createElement("div");n.className="rte-comment-reply-composer",n.innerHTML=`
`;const f=l.querySelector(".rte-comment-reply-text");f&&(f.textContent=s.text),n.appendChild(l)}),p.appendChild(n)}if(!e.resolved){const n=document.createElement("div");n.className="rte-comment-reply-composer",n.innerHTML=`
<textarea class="rte-comment-reply-textarea" rows="2" placeholder="Reply..."></textarea>
<button type="button" class="rte-comment-btn primary">Reply</button>
`;const s=n.querySelector(".rte-comment-reply-textarea"),l=n.querySelector(".rte-comment-btn.primary");if(s&&l){s.value=e.replyTexts[t.id]||"";const u=()=>{const g=!!s.value.trim();l.disabled=!g};u(),s.addEventListener("input",()=>{e.replyTexts[t.id]=s.value,u()}),l.addEventListener("click",()=>{const g=s.value.trim();g&&(_(t.id,E,g),e.replyTexts[t.id]="",m(e))})}p.appendChild(n)}const i=document.createElement("div");if(i.className="rte-comment-actions",t.anchorId){const n=document.createElement("button");n.type="button",n.className="rte-comment-btn ghost",n.textContent="Jump to text",n.onclick=()=>{const s=e.root.querySelector(`#${t.anchorId}`);s&&(s.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),b(e,t.id,!0),window.setTimeout(()=>b(e,t.id,!1),1200))},i.appendChild(n)}if(t.resolved){const n=document.createElement("button");n.type="button",n.className="rte-comment-btn ghost",n.textContent="Reopen",n.onclick=()=>P(t.id),i.appendChild(n)}else{const n=document.createElement("button");n.type="button",n.className="rte-comment-btn success",n.textContent="Resolve",n.onclick=()=>O(t.id,E),i.appendChild(n)}const c=document.createElement("button");c.type="button",c.className="rte-comment-btn danger",c.textContent="Delete",c.onclick=()=>j(t.id),i.appendChild(c),p.appendChild(i)}return o.addEventListener("mouseenter",()=>b(e,t.id,!0)),o.addEventListener("mouseleave",()=>b(e,t.id,!1)),o}function m(e){const t=e||f();if(!t?.panelElement)return;const r=V(t);t.panelElement.innerHTML=`
`;const s=n.querySelector(".rte-comment-reply-textarea"),l=n.querySelector(".rte-comment-btn.primary");if(s&&l){s.value=t.replyTexts[e.id]||"";const f=()=>{const b=!!s.value.trim();l.disabled=!b};f(),s.addEventListener("input",()=>{t.replyTexts[e.id]=s.value,f()}),l.addEventListener("click",()=>{const b=s.value.trim();b&&(F(e.id,E,b),t.replyTexts[e.id]="",m(t))})}p.appendChild(n)}const c=document.createElement("div");if(c.className="rte-comment-actions",e.anchorId){const n=document.createElement("button");n.type="button",n.className="rte-comment-btn ghost",n.textContent="Jump to text",n.onclick=()=>{const s=t.root.querySelector(`#${e.anchorId}`);s&&(s.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),h(t,e.id,!0),window.setTimeout(()=>h(t,e.id,!1),1200))},c.appendChild(n)}if(e.resolved){const n=document.createElement("button");n.type="button",n.className="rte-comment-btn ghost",n.textContent="Reopen",n.onclick=()=>_(e.id),c.appendChild(n)}else{const n=document.createElement("button");n.type="button",n.className="rte-comment-btn success",n.textContent="Resolve",n.onclick=()=>P(e.id,E),c.appendChild(n)}const i=document.createElement("button");i.type="button",i.className="rte-comment-btn danger",i.textContent="Delete",i.onclick=()=>j(e.id),c.appendChild(i),p.appendChild(c)}return o.addEventListener("mouseenter",()=>h(t,e.id,!0)),o.addEventListener("mouseleave",()=>h(t,e.id,!1)),o}function m(t){const e=t||u();if(!e?.panelElement)return;const r=M(e);e.panelElement.innerHTML=`
<div class="rte-comments-header">

@@ -39,3 +39,3 @@ <div>

${r.length===0?'<div class="rte-comments-empty">No comments yet.</div>':'<div class="rte-comments-list"></div>'}
`,t.panelElement.querySelector(".rte-comments-close")?.addEventListener("click",()=>{y(t,!1)});const a=t.panelElement.querySelector(".new-comment-textarea"),d=t.panelElement.querySelector(".add-comment-btn");if(a&&d){a.value=t.newCommentText;const i=()=>{const c=!!a.value.trim();d.disabled=!c};i(),a.addEventListener("input",()=>{t.newCommentText=a.value,i()}),a.addEventListener("keydown",c=>{(c.ctrlKey||c.metaKey)&&c.key==="Enter"&&(c.preventDefault(),d.click())}),d.addEventListener("click",()=>{const c=a.value.trim();if(!c)return;const n=!!t.savedSelection;D(E,c,!n),t.newCommentText="",m(t)})}const p=t.panelElement.querySelector(".rte-comments-list");p&&r.forEach(i=>{p.appendChild(M(t,i))})}function L(){S||(S=!0,document.addEventListener("focusin",e=>{const t=v(e.target);t&&(x=t)}),document.addEventListener("selectionchange",()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return;const t=e.getRangeAt(0),r=v(t.commonAncestorContainer);if(!r)return;x=r;const o=C.get(r);!o||e.isCollapsed||w(t,r)&&(o.savedSelection=t.cloneRange())}))}function D(e,t,r=!1){const o=f();if(!o)return"";const a=t.trim();if(!a)return"";if(r){const l=h("comment");return o.comments.set(l,{id:l,anchorId:"",selectedText:"",author:e,text:a,createdAt:new Date().toISOString(),resolved:!1,replies:[]}),m(o),l}const d=o.savedSelection||T(o.root);if(!d||!w(d,o.root))return"";const p=d.toString().trim();if(!p)return"";const i=h("comment"),c=h("comment-anchor"),n=document.createElement("span");n.id=c,n.className="rte-comment-anchor",n.setAttribute("data-comment-id",i),n.setAttribute("title","Commented text");try{const l=d.cloneRange(),u=l.extractContents();if(!u.textContent?.trim())return"";n.appendChild(u),l.insertNode(n)}catch{return""}return $(o,n,i),o.comments.set(i,{id:i,anchorId:c,selectedText:p,author:e,text:a,createdAt:new Date().toISOString(),resolved:!1,replies:[]}),o.savedSelection=null,window.getSelection()?.removeAllRanges(),m(o),i}function O(e,t){const r=f();if(!r)return;const o=r.comments.get(e);o&&(o.resolved=!0,o.resolvedBy=t,o.resolvedAt=new Date().toISOString(),R(r,o),m(r))}function P(e){const t=f();if(!t)return;const r=t.comments.get(e);r&&(r.resolved=!1,r.resolvedBy=void 0,r.resolvedAt=void 0,R(t,r),m(t))}function j(e){const t=f();if(!t)return;const r=t.comments.get(e);if(r){if(r.anchorId){const o=t.root.querySelector(`#${r.anchorId}`);o&&q(o)}t.comments.delete(e),t.expandedComments.delete(e),delete t.replyTexts[e],m(t)}}function _(e,t,r){const o=f();if(!o)return;const a=o.comments.get(e);if(!a)return;const d=r.trim();d&&(a.replies.push({id:h("reply"),author:t,text:d,createdAt:new Date().toISOString()}),m(o))}function F(){if(document.getElementById("rte-comments-panel-styles"))return;const e=document.createElement("style");e.id="rte-comments-panel-styles",e.textContent=`
`,e.panelElement.querySelector(".rte-comments-close")?.addEventListener("click",()=>{g(e,!1)});const a=e.panelElement.querySelector(".new-comment-textarea"),d=e.panelElement.querySelector(".add-comment-btn");if(a&&d){a.value=e.newCommentText;const c=()=>{const i=!!a.value.trim();d.disabled=!i};c(),a.addEventListener("input",()=>{e.newCommentText=a.value,c()}),a.addEventListener("keydown",i=>{(i.ctrlKey||i.metaKey)&&i.key==="Enter"&&(i.preventDefault(),d.click())}),d.addEventListener("click",()=>{const i=a.value.trim();if(!i)return;const n=!!e.savedSelection;O(E,i,!n),e.newCommentText="",m(e)})}const p=e.panelElement.querySelector(".rte-comments-list");p&&r.forEach(c=>{p.appendChild(D(e,c))})}function T(){S||(S=!0,document.addEventListener("focusin",t=>{const e=y(t.target);e&&(x=e)}),document.addEventListener("selectionchange",()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return;const e=t.getRangeAt(0),r=y(e.commonAncestorContainer);if(!r)return;x=r;const o=C.get(r);!o||t.isCollapsed||w(e,r)&&(o.savedSelection=e.cloneRange())}),document.addEventListener("keydown",t=>{if(t.key!=="Escape")return;const e=u();!e||!e.panelVisible||(t.preventDefault(),t.stopPropagation(),g(e,!1))},!0))}function O(t,e,r=!1){const o=u();if(!o)return"";const a=e.trim();if(!a)return"";if(r){const l=v("comment");return o.comments.set(l,{id:l,anchorId:"",selectedText:"",author:t,text:a,createdAt:new Date().toISOString(),resolved:!1,replies:[]}),m(o),l}const d=o.savedSelection||R(o.root);if(!d||!w(d,o.root))return"";const p=d.toString().trim();if(!p)return"";const c=v("comment"),i=v("comment-anchor"),n=document.createElement("span");n.id=i,n.className="rte-comment-anchor",n.setAttribute("data-comment-id",c),n.setAttribute("title","Commented text");try{const l=d.cloneRange(),f=l.extractContents();if(!f.textContent?.trim())return"";n.appendChild(f),l.insertNode(n)}catch{return""}return $(o,n,c),o.comments.set(c,{id:c,anchorId:i,selectedText:p,author:t,text:a,createdAt:new Date().toISOString(),resolved:!1,replies:[]}),o.savedSelection=null,window.getSelection()?.removeAllRanges(),m(o),c}function P(t,e){const r=u();if(!r)return;const o=r.comments.get(t);o&&(o.resolved=!0,o.resolvedBy=e,o.resolvedAt=new Date().toISOString(),I(r,o),m(r))}function _(t){const e=u();if(!e)return;const r=e.comments.get(t);r&&(r.resolved=!1,r.resolvedBy=void 0,r.resolvedAt=void 0,I(e,r),m(e))}function j(t){const e=u();if(!e)return;const r=e.comments.get(t);if(r){if(r.anchorId){const o=e.root.querySelector(`#${r.anchorId}`);o&&q(o)}e.comments.delete(t),e.expandedComments.delete(t),delete e.replyTexts[t],m(e)}}function F(t,e,r){const o=u();if(!o)return;const a=o.comments.get(t);if(!a)return;const d=r.trim();d&&(a.replies.push({id:v("reply"),author:e,text:d,createdAt:new Date().toISOString()}),m(o))}function Z(){if(document.getElementById("rte-comments-panel-styles"))return;const t=document.createElement("style");t.id="rte-comments-panel-styles",t.textContent=`
.rte-comments-panel {

@@ -356,2 +356,2 @@ --rte-comments-panel-width: min(360px, 42vw);

}
`,document.head.appendChild(e)}const Z=()=>({name:"comments",toolbar:[{label:"Add Comment",command:"addComment",type:"button",icon:'<svg fill="#000000" width="24px" height="24px" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:none;}</style></defs><title>add-comment</title><path d="M17.74,30,16,29l4-7h6a2,2,0,0,0,2-2V8a2,2,0,0,0-2-2H6A2,2,0,0,0,4,8V20a2,2,0,0,0,2,2h9v2H6a4,4,0,0,1-4-4V8A4,4,0,0,1,6,4H26a4,4,0,0,1,4,4V20a4,4,0,0,1-4,4H21.16Z"></path><polygon points="17 9 15 9 15 13 11 13 11 15 15 15 15 19 17 19 17 15 21 15 21 13 17 13 17 9"></polygon><rect class="cls-1" width="32" height="32"></rect></svg>'},{label:"Show / Hide Comments",command:"toggleComments",type:"button",icon:'<svg width="24px" height="24px" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M16 1H4V11H8L10 13L12 11H16V1Z" fill="#000000"></path><path d="M2 5V13H7.17157L8.70711 14.5355L7.29289 15.9497L6.34315 15H0V5H2Z" fill="#000000"></path></svg>'}],commands:{addComment:()=>{L();const e=f();return e?(e.savedSelection=T(e.root),e.savedSelection&&window.getSelection()?.removeAllRanges(),y(e,!0),m(e),e.panelElement?.querySelector(".new-comment-textarea")?.focus({preventScroll:!0}),!0):!1},toggleComments:()=>{L();const e=f();return e?(y(e,!e.panelVisible),e.panelVisible&&m(e),!0):!1}},keymap:{}});exports.CommentsPlugin=Z;
`,document.head.appendChild(t)}const K=()=>({name:"comments",toolbar:[{label:"Add Comment",command:"addComment",type:"button",icon:'<svg fill="#000000" width="24px" height="24px" viewBox="0 0 32 32" id="icon" xmlns="http://www.w3.org/2000/svg"><defs><style>.cls-1{fill:none;}</style></defs><title>add-comment</title><path d="M17.74,30,16,29l4-7h6a2,2,0,0,0,2-2V8a2,2,0,0,0-2-2H6A2,2,0,0,0,4,8V20a2,2,0,0,0,2,2h9v2H6a4,4,0,0,1-4-4V8A4,4,0,0,1,6,4H26a4,4,0,0,1,4,4V20a4,4,0,0,1-4,4H21.16Z"></path><polygon points="17 9 15 9 15 13 11 13 11 15 15 15 15 19 17 19 17 15 21 15 21 13 17 13 17 9"></polygon><rect class="cls-1" width="32" height="32"></rect></svg>'},{label:"Show / Hide Comments",command:"toggleComments",type:"button",icon:'<svg width="24px" height="24px" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M16 1H4V11H8L10 13L12 11H16V1Z" fill="#000000"></path><path d="M2 5V13H7.17157L8.70711 14.5355L7.29289 15.9497L6.34315 15H0V5H2Z" fill="#000000"></path></svg>'}],commands:{addComment:(t,e)=>{A(e),T();const r=u();return r?(r.savedSelection=R(r.root),r.savedSelection&&window.getSelection()?.removeAllRanges(),g(r,!0),m(r),r.panelElement?.querySelector(".new-comment-textarea")?.focus({preventScroll:!0}),!0):!1},toggleComments:(t,e)=>{A(e),T();const r=u();return r?(g(r,!r.panelVisible),r.panelVisible&&m(r),!0):!1}},keymap:{}});exports.CommentsPlugin=K;
const C = /* @__PURE__ */ new WeakMap();
let x = null, S = !1, k = 0;
const E = "User";
function h(e) {
return k += 1, `${e}-${Date.now()}-${k}`;
function v(t) {
return k += 1, `${t}-${Date.now()}-${k}`;
}
function v(e) {
if (!e) return null;
const t = e instanceof Element ? e : e.parentElement;
return t ? t.closest("[data-editora-editor]") || t.closest(".rte-editor") || t.closest(".editora-editor") : null;
function y(t) {
if (!t) return null;
const e = t instanceof Element ? t : t.parentElement;
return e ? e.closest("[data-editora-editor]") || e.closest(".rte-editor") || e.closest(".editora-editor") : null;
}
function w(e, t) {
return t.contains(e.commonAncestorContainer);
function A(t) {
const e = t?.editorElement || t?.contentElement || null;
if (!(e instanceof HTMLElement)) return;
const r = e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? e : null);
r && (x = r);
}
function I() {
function w(t, e) {
return e.contains(t.commonAncestorContainer);
}
function B() {
if (typeof window < "u") {

@@ -24,7 +30,7 @@ const o = window.__editoraCommandEditorRoot;

}
const e = document.activeElement, t = e ? v(e) : null;
if (t) return t;
const t = document.activeElement, e = t ? y(t) : null;
if (e) return e;
const r = window.getSelection();
if (r && r.rangeCount > 0) {
const o = v(
const o = y(
r.getRangeAt(0).commonAncestorContainer

@@ -36,7 +42,7 @@ );

}
function B(e) {
const t = C.get(e);
if (t) return t;
function H(t) {
const e = C.get(t);
if (e) return e;
const r = {
root: e,
root: t,
comments: /* @__PURE__ */ new Map(),

@@ -51,72 +57,76 @@ panelVisible: !1,

};
return C.set(e, r), r;
return C.set(t, r), r;
}
function f() {
const e = I();
return e ? (x = e, B(e)) : null;
function u() {
const t = B();
return t ? (x = t, H(t)) : null;
}
function T(e) {
const t = window.getSelection();
if (!t || t.rangeCount === 0 || t.isCollapsed) return null;
const r = t.getRangeAt(0);
return w(r, e) ? r.cloneRange() : null;
function R(t) {
const e = window.getSelection();
if (!e || e.rangeCount === 0 || e.isCollapsed) return null;
const r = e.getRangeAt(0);
return w(r, t) ? r.cloneRange() : null;
}
function R(e, t) {
if (!t.anchorId) return;
const r = e.root.querySelector(`#${t.anchorId}`);
r && r.classList.toggle("rte-comment-anchor-resolved", t.resolved);
function I(t, e) {
if (!e.anchorId) return;
const r = t.root.querySelector(`#${e.anchorId}`);
r && r.classList.toggle("rte-comment-anchor-resolved", e.resolved);
}
function b(e, t, r) {
const o = e.comments.get(t);
function h(t, e, r) {
const o = t.comments.get(e);
if (!o || !o.anchorId) return;
const a = e.root.querySelector(`#${o.anchorId}`);
const a = t.root.querySelector(`#${o.anchorId}`);
a && a.classList.toggle("highlighted", r);
}
function $(e, t, r) {
t.onclick = (o) => {
o.preventDefault(), o.stopPropagation(), x = e.root, e.expandedComments.add(r), y(e, !0), m(e);
function $(t, e, r) {
e.onclick = (o) => {
o.preventDefault(), o.stopPropagation(), x = t.root, t.expandedComments.add(r), g(t, !0), m(t);
};
}
function q(e) {
const t = e.parentNode;
if (t) {
for (; e.firstChild; )
t.insertBefore(e.firstChild, e);
e.remove();
function q(t) {
const e = t.parentNode;
if (e) {
for (; t.firstChild; )
e.insertBefore(t.firstChild, t);
t.remove();
}
}
function y(e, t) {
F(), H(e), e.panelVisible = t, e.root.setAttribute("data-rte-comments-open", t ? "true" : "false"), e.panelElement && (e.panelElement.classList.toggle("is-open", t), e.panelElement.setAttribute("aria-hidden", t ? "false" : "true")), t ? N(e) : z(e);
function g(t, e) {
if (t.panelVisible = e, e) {
Z(), N(t), t.root.setAttribute("data-rte-comments-open", "true"), t.panelElement && (t.panelElement.classList.add("is-open"), t.panelElement.setAttribute("aria-hidden", "false")), z(t);
return;
}
t.root.removeAttribute("data-rte-comments-open"), V(t), t.panelElement && (t.panelElement.remove(), t.panelElement = null);
}
function H(e) {
if (e.panelElement) return;
const t = document.createElement("aside");
t.className = "rte-comments-panel", t.setAttribute("role", "complementary"), t.setAttribute("aria-label", "Comments"), t.setAttribute("aria-hidden", "true"), window.getComputedStyle(e.root).position === "static" && (e.root.style.position = "relative"), e.root.appendChild(t), e.panelElement = t;
function N(t) {
if (t.panelElement) return;
const e = document.createElement("aside");
e.className = "rte-comments-panel", e.setAttribute("role", "complementary"), e.setAttribute("aria-label", "Comments"), e.setAttribute("aria-hidden", "true"), window.getComputedStyle(t.root).position === "static" && (t.root.style.position = "relative"), t.root.appendChild(e), t.panelElement = e;
}
function N(e) {
e.selectionChangeListener || (e.selectionChangeListener = () => {
const t = window.getSelection();
if (!t || t.rangeCount === 0 || t.isCollapsed) return;
const r = t.getRangeAt(0);
w(r, e.root) && (e.savedSelection = r.cloneRange(), x = e.root);
}, document.addEventListener("selectionchange", e.selectionChangeListener));
function z(t) {
t.selectionChangeListener || (t.selectionChangeListener = () => {
const e = window.getSelection();
if (!e || e.rangeCount === 0 || e.isCollapsed) return;
const r = e.getRangeAt(0);
w(r, t.root) && (t.savedSelection = r.cloneRange(), x = t.root);
}, document.addEventListener("selectionchange", t.selectionChangeListener));
}
function z(e) {
e.selectionChangeListener && (document.removeEventListener("selectionchange", e.selectionChangeListener), e.selectionChangeListener = null);
function V(t) {
t.selectionChangeListener && (document.removeEventListener("selectionchange", t.selectionChangeListener), t.selectionChangeListener = null);
}
function V(e) {
return Array.from(e.comments.values()).sort(
(t, r) => r.createdAt.localeCompare(t.createdAt)
function M(t) {
return Array.from(t.comments.values()).sort(
(e, r) => r.createdAt.localeCompare(e.createdAt)
);
}
function A(e) {
return new Date(e).toLocaleString();
function L(t) {
return new Date(t).toLocaleString();
}
function M(e, t) {
const r = e.expandedComments.has(t.id), o = document.createElement("article");
o.className = `rte-comment-item${t.resolved ? " resolved" : ""}`, o.innerHTML = `
function D(t, e) {
const r = t.expandedComments.has(e.id), o = document.createElement("article");
o.className = `rte-comment-item${e.resolved ? " resolved" : ""}`, o.innerHTML = `
<header class="rte-comment-header">
<div class="rte-comment-meta">
<strong class="rte-comment-author">${t.author}</strong>
<time class="rte-comment-date">${A(t.createdAt)}</time>
<strong class="rte-comment-author">${e.author}</strong>
<time class="rte-comment-date">${L(e.createdAt)}</time>
</div>

@@ -128,14 +138,14 @@ <button class="rte-comment-expand" type="button" aria-label="Toggle details">

<div class="rte-comment-text"></div>
${t.selectedText ? `<blockquote class="rte-comment-selection">${t.selectedText}</blockquote>` : ""}
${e.selectedText ? `<blockquote class="rte-comment-selection">${e.selectedText}</blockquote>` : ""}
<section class="rte-comment-expanded${r ? " show" : ""}"></section>
`;
const a = o.querySelector(".rte-comment-text");
a && (a.textContent = t.text), o.querySelector(".rte-comment-expand")?.addEventListener("click", () => {
e.expandedComments.has(t.id) ? e.expandedComments.delete(t.id) : e.expandedComments.add(t.id), m(e);
a && (a.textContent = e.text), o.querySelector(".rte-comment-expand")?.addEventListener("click", () => {
t.expandedComments.has(e.id) ? t.expandedComments.delete(e.id) : t.expandedComments.add(e.id), m(t);
});
const p = o.querySelector(".rte-comment-expanded");
if (p && r) {
if (t.replies.length > 0) {
if (e.replies.length > 0) {
const n = document.createElement("div");
n.className = "rte-comment-replies", t.replies.forEach((s) => {
n.className = "rte-comment-replies", e.replies.forEach((s) => {
const l = document.createElement("div");

@@ -145,11 +155,11 @@ l.className = "rte-comment-reply", l.innerHTML = `

<strong>${s.author}</strong>
<time>${A(s.createdAt)}</time>
<time>${L(s.createdAt)}</time>
</div>
<div class="rte-comment-reply-text"></div>
`;
const u = l.querySelector(".rte-comment-reply-text");
u && (u.textContent = s.text), n.appendChild(l);
const f = l.querySelector(".rte-comment-reply-text");
f && (f.textContent = s.text), n.appendChild(l);
}), p.appendChild(n);
}
if (!t.resolved) {
if (!e.resolved) {
const n = document.createElement("div");

@@ -166,12 +176,12 @@ n.className = "rte-comment-reply-composer", n.innerHTML = `

if (s && l) {
s.value = e.replyTexts[t.id] || "";
const u = () => {
const g = !!s.value.trim();
l.disabled = !g;
s.value = t.replyTexts[e.id] || "";
const f = () => {
const b = !!s.value.trim();
l.disabled = !b;
};
u(), s.addEventListener("input", () => {
e.replyTexts[t.id] = s.value, u();
f(), s.addEventListener("input", () => {
t.replyTexts[e.id] = s.value, f();
}), l.addEventListener("click", () => {
const g = s.value.trim();
g && (_(t.id, E, g), e.replyTexts[t.id] = "", m(e));
const b = s.value.trim();
b && (F(e.id, E, b), t.replyTexts[e.id] = "", m(t));
});

@@ -181,27 +191,27 @@ }

}
const i = document.createElement("div");
if (i.className = "rte-comment-actions", t.anchorId) {
const c = document.createElement("div");
if (c.className = "rte-comment-actions", e.anchorId) {
const n = document.createElement("button");
n.type = "button", n.className = "rte-comment-btn ghost", n.textContent = "Jump to text", n.onclick = () => {
const s = e.root.querySelector(`#${t.anchorId}`);
s && (s.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), b(e, t.id, !0), window.setTimeout(() => b(e, t.id, !1), 1200));
}, i.appendChild(n);
const s = t.root.querySelector(`#${e.anchorId}`);
s && (s.scrollIntoView({ behavior: "smooth", block: "center", inline: "nearest" }), h(t, e.id, !0), window.setTimeout(() => h(t, e.id, !1), 1200));
}, c.appendChild(n);
}
if (t.resolved) {
if (e.resolved) {
const n = document.createElement("button");
n.type = "button", n.className = "rte-comment-btn ghost", n.textContent = "Reopen", n.onclick = () => j(t.id), i.appendChild(n);
n.type = "button", n.className = "rte-comment-btn ghost", n.textContent = "Reopen", n.onclick = () => _(e.id), c.appendChild(n);
} else {
const n = document.createElement("button");
n.type = "button", n.className = "rte-comment-btn success", n.textContent = "Resolve", n.onclick = () => O(t.id, E), i.appendChild(n);
n.type = "button", n.className = "rte-comment-btn success", n.textContent = "Resolve", n.onclick = () => P(e.id, E), c.appendChild(n);
}
const c = document.createElement("button");
c.type = "button", c.className = "rte-comment-btn danger", c.textContent = "Delete", c.onclick = () => P(t.id), i.appendChild(c), p.appendChild(i);
const i = document.createElement("button");
i.type = "button", i.className = "rte-comment-btn danger", i.textContent = "Delete", i.onclick = () => j(e.id), c.appendChild(i), p.appendChild(c);
}
return o.addEventListener("mouseenter", () => b(e, t.id, !0)), o.addEventListener("mouseleave", () => b(e, t.id, !1)), o;
return o.addEventListener("mouseenter", () => h(t, e.id, !0)), o.addEventListener("mouseleave", () => h(t, e.id, !1)), o;
}
function m(e) {
const t = e || f();
if (!t?.panelElement) return;
const r = V(t);
t.panelElement.innerHTML = `
function m(t) {
const e = t || u();
if (!e?.panelElement) return;
const r = M(e);
e.panelElement.innerHTML = `
<div class="rte-comments-header">

@@ -221,53 +231,61 @@ <div>

${r.length === 0 ? '<div class="rte-comments-empty">No comments yet.</div>' : '<div class="rte-comments-list"></div>'}
`, t.panelElement.querySelector(".rte-comments-close")?.addEventListener("click", () => {
y(t, !1);
`, e.panelElement.querySelector(".rte-comments-close")?.addEventListener("click", () => {
g(e, !1);
});
const a = t.panelElement.querySelector(
const a = e.panelElement.querySelector(
".new-comment-textarea"
), d = t.panelElement.querySelector(
), d = e.panelElement.querySelector(
".add-comment-btn"
);
if (a && d) {
a.value = t.newCommentText;
const i = () => {
const c = !!a.value.trim();
d.disabled = !c;
a.value = e.newCommentText;
const c = () => {
const i = !!a.value.trim();
d.disabled = !i;
};
i(), a.addEventListener("input", () => {
t.newCommentText = a.value, i();
}), a.addEventListener("keydown", (c) => {
(c.ctrlKey || c.metaKey) && c.key === "Enter" && (c.preventDefault(), d.click());
c(), a.addEventListener("input", () => {
e.newCommentText = a.value, c();
}), a.addEventListener("keydown", (i) => {
(i.ctrlKey || i.metaKey) && i.key === "Enter" && (i.preventDefault(), d.click());
}), d.addEventListener("click", () => {
const c = a.value.trim();
if (!c) return;
const n = !!t.savedSelection;
D(E, c, !n), t.newCommentText = "", m(t);
const i = a.value.trim();
if (!i) return;
const n = !!e.savedSelection;
O(E, i, !n), e.newCommentText = "", m(e);
});
}
const p = t.panelElement.querySelector(".rte-comments-list");
p && r.forEach((i) => {
p.appendChild(M(t, i));
const p = e.panelElement.querySelector(".rte-comments-list");
p && r.forEach((c) => {
p.appendChild(D(e, c));
});
}
function L() {
S || (S = !0, document.addEventListener("focusin", (e) => {
const t = v(e.target);
t && (x = t);
function T() {
S || (S = !0, document.addEventListener("focusin", (t) => {
const e = y(t.target);
e && (x = e);
}), document.addEventListener("selectionchange", () => {
const e = window.getSelection();
if (!e || e.rangeCount === 0) return;
const t = e.getRangeAt(0), r = v(t.commonAncestorContainer);
const t = window.getSelection();
if (!t || t.rangeCount === 0) return;
const e = t.getRangeAt(0), r = y(e.commonAncestorContainer);
if (!r) return;
x = r;
const o = C.get(r);
!o || e.isCollapsed || w(t, r) && (o.savedSelection = t.cloneRange());
}));
!o || t.isCollapsed || w(e, r) && (o.savedSelection = e.cloneRange());
}), document.addEventListener(
"keydown",
(t) => {
if (t.key !== "Escape") return;
const e = u();
!e || !e.panelVisible || (t.preventDefault(), t.stopPropagation(), g(e, !1));
},
!0
));
}
function D(e, t, r = !1) {
const o = f();
function O(t, e, r = !1) {
const o = u();
if (!o) return "";
const a = t.trim();
const a = e.trim();
if (!a) return "";
if (r) {
const l = h("comment");
const l = v("comment");
return o.comments.set(l, {

@@ -277,3 +295,3 @@ id: l,

selectedText: "",
author: e,
author: t,
text: a,

@@ -285,20 +303,20 @@ createdAt: (/* @__PURE__ */ new Date()).toISOString(),

}
const d = o.savedSelection || T(o.root);
const d = o.savedSelection || R(o.root);
if (!d || !w(d, o.root)) return "";
const p = d.toString().trim();
if (!p) return "";
const i = h("comment"), c = h("comment-anchor"), n = document.createElement("span");
n.id = c, n.className = "rte-comment-anchor", n.setAttribute("data-comment-id", i), n.setAttribute("title", "Commented text");
const c = v("comment"), i = v("comment-anchor"), n = document.createElement("span");
n.id = i, n.className = "rte-comment-anchor", n.setAttribute("data-comment-id", c), n.setAttribute("title", "Commented text");
try {
const l = d.cloneRange(), u = l.extractContents();
if (!u.textContent?.trim()) return "";
n.appendChild(u), l.insertNode(n);
const l = d.cloneRange(), f = l.extractContents();
if (!f.textContent?.trim()) return "";
n.appendChild(f), l.insertNode(n);
} catch {
return "";
}
return $(o, n, i), o.comments.set(i, {
id: i,
anchorId: c,
return $(o, n, c), o.comments.set(c, {
id: c,
anchorId: i,
selectedText: p,
author: e,
author: t,
text: a,

@@ -308,37 +326,37 @@ createdAt: (/* @__PURE__ */ new Date()).toISOString(),

replies: []
}), o.savedSelection = null, window.getSelection()?.removeAllRanges(), m(o), i;
}), o.savedSelection = null, window.getSelection()?.removeAllRanges(), m(o), c;
}
function O(e, t) {
const r = f();
function P(t, e) {
const r = u();
if (!r) return;
const o = r.comments.get(e);
o && (o.resolved = !0, o.resolvedBy = t, o.resolvedAt = (/* @__PURE__ */ new Date()).toISOString(), R(r, o), m(r));
const o = r.comments.get(t);
o && (o.resolved = !0, o.resolvedBy = e, o.resolvedAt = (/* @__PURE__ */ new Date()).toISOString(), I(r, o), m(r));
}
function j(e) {
const t = f();
if (!t) return;
const r = t.comments.get(e);
r && (r.resolved = !1, r.resolvedBy = void 0, r.resolvedAt = void 0, R(t, r), m(t));
function _(t) {
const e = u();
if (!e) return;
const r = e.comments.get(t);
r && (r.resolved = !1, r.resolvedBy = void 0, r.resolvedAt = void 0, I(e, r), m(e));
}
function P(e) {
const t = f();
if (!t) return;
const r = t.comments.get(e);
function j(t) {
const e = u();
if (!e) return;
const r = e.comments.get(t);
if (r) {
if (r.anchorId) {
const o = t.root.querySelector(`#${r.anchorId}`);
const o = e.root.querySelector(`#${r.anchorId}`);
o && q(o);
}
t.comments.delete(e), t.expandedComments.delete(e), delete t.replyTexts[e], m(t);
e.comments.delete(t), e.expandedComments.delete(t), delete e.replyTexts[t], m(e);
}
}
function _(e, t, r) {
const o = f();
function F(t, e, r) {
const o = u();
if (!o) return;
const a = o.comments.get(e);
const a = o.comments.get(t);
if (!a) return;
const d = r.trim();
d && (a.replies.push({
id: h("reply"),
author: t,
id: v("reply"),
author: e,
text: d,

@@ -348,6 +366,6 @@ createdAt: (/* @__PURE__ */ new Date()).toISOString()

}
function F() {
function Z() {
if (document.getElementById("rte-comments-panel-styles")) return;
const e = document.createElement("style");
e.id = "rte-comments-panel-styles", e.textContent = `
const t = document.createElement("style");
t.id = "rte-comments-panel-styles", t.textContent = `
.rte-comments-panel {

@@ -668,5 +686,5 @@ --rte-comments-panel-width: min(360px, 42vw);

}
`, document.head.appendChild(e);
`, document.head.appendChild(t);
}
const Z = () => ({
const K = () => ({
name: "comments",

@@ -688,13 +706,13 @@ toolbar: [

commands: {
addComment: () => {
L();
const e = f();
return e ? (e.savedSelection = T(e.root), e.savedSelection && window.getSelection()?.removeAllRanges(), y(e, !0), m(e), e.panelElement?.querySelector(
addComment: (t, e) => {
A(e), T();
const r = u();
return r ? (r.savedSelection = R(r.root), r.savedSelection && window.getSelection()?.removeAllRanges(), g(r, !0), m(r), r.panelElement?.querySelector(
".new-comment-textarea"
)?.focus({ preventScroll: !0 }), !0) : !1;
},
toggleComments: () => {
L();
const e = f();
return e ? (y(e, !e.panelVisible), e.panelVisible && m(e), !0) : !1;
toggleComments: (t, e) => {
A(e), T();
const r = u();
return r ? (g(r, !r.panelVisible), r.panelVisible && m(r), !0) : !1;
}

@@ -705,3 +723,3 @@ },

export {
Z as CommentsPlugin
K as CommentsPlugin
};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-D3pJyAsj.js");exports.DocumentManagerPlugin=e.DocumentManagerPlugin;exports.getDocumentManagerConfig=e.getDocumentManagerConfig;exports.setDocumentManagerConfig=e.setDocumentManagerConfig;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-tqLTHcO6.js");exports.DocumentManagerPlugin=e.DocumentManagerPlugin;exports.getDocumentManagerConfig=e.getDocumentManagerConfig;exports.setDocumentManagerConfig=e.setDocumentManagerConfig;

@@ -1,2 +0,2 @@

import { D as n, g, s as o } from "./index-Bskk414V.mjs";
import { D as n, g, s as o } from "./index-BFsKNTTj.mjs";
export {

@@ -3,0 +3,0 @@ n as DocumentManagerPlugin,

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=[{label:"Inline Value",value:"inline"},{label:"Responsive - 21x9",value:"21x9"},{label:"Responsive - 16x9",value:"16x9"},{label:"Responsive - 4x3",value:"4x3"},{label:"Responsive - 1x1",value:"1x1"}],m='[data-theme="dark"], .dark, .editora-theme-dark',u=new WeakMap,l=e=>(u.has(e)||u.set(e,{dialogElement:null,activeTab:"general",formData:{src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0}}),u.get(e));function v(e){return e?.matches(m)||e?.closest(m)||document.activeElement?.closest(m)?!0:document.body.matches(m)||document.documentElement.matches(m)}const x=()=>({name:"embedIframe",toolbar:[{label:"Embed Content",command:"openEmbedIframeDialog",icon:'<svg width="24" height="24" focusable="false"><path d="M19 6V5H5v14h2A13 13 0 0 1 19 6Zm0 1.4c-.8.8-1.6 2.4-2.2 4.6H19V7.4Zm0 5.6h-2.4c-.4 1.8-.6 3.8-.6 6h3v-6Zm-4 6c0-2.2.2-4.2.6-6H13c-.7 1.8-1.1 3.8-1.1 6h3Zm-4 0c0-2.2.4-4.2 1-6H9.6A12 12 0 0 0 8 19h3ZM4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm11.8 9c.4-1.9 1-3.4 1.8-4.5a9.2 9.2 0 0 0-4 4.5h2.2Zm-3.4 0a12 12 0 0 1 2.8-4 12 12 0 0 0-5 4h2.2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-Shift-e",type:"button"}],commands:{openEmbedIframeDialog:e=>(y(e),!0)},keymap:{"Mod-Shift-e":"openEmbedIframeDialog"}});function y(e){if(!e){const o=document.activeElement;o&&o.closest("[data-editora-editor]")&&(e=o.closest("[data-editora-editor]"))}if(e||(e=document.querySelector("[data-editora-editor]")),!e){console.warn("Editor element not found");return}const t=l(e);t.formData={src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0},t.activeTab="general";const a=document.createElement("div");a.className="rte-dialog-overlay rte-embed-iframe-overlay",v(e)&&a.classList.add("rte-theme-dark"),a.onclick=()=>f(e);const r=document.createElement("div");r.className="rte-dialog-content embed-iframe-dialog",r.onclick=o=>o.stopPropagation(),r.innerHTML=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=[{label:"Inline Value",value:"inline"},{label:"Responsive - 21x9",value:"21x9"},{label:"Responsive - 16x9",value:"16x9"},{label:"Responsive - 4x3",value:"4x3"},{label:"Responsive - 1x1",value:"1x1"}],m='[data-theme="dark"], .dark, .editora-theme-dark',u=new WeakMap,l=e=>(u.has(e)||u.set(e,{dialogElement:null,escapeHandler:null,activeTab:"general",formData:{src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0}}),u.get(e));function v(e){return e?.matches(m)||e?.closest(m)||document.activeElement?.closest(m)?!0:document.body.matches(m)||document.documentElement.matches(m)}const x=()=>({name:"embedIframe",toolbar:[{label:"Embed Content",command:"openEmbedIframeDialog",icon:'<svg width="24" height="24" focusable="false"><path d="M19 6V5H5v14h2A13 13 0 0 1 19 6Zm0 1.4c-.8.8-1.6 2.4-2.2 4.6H19V7.4Zm0 5.6h-2.4c-.4 1.8-.6 3.8-.6 6h3v-6Zm-4 6c0-2.2.2-4.2.6-6H13c-.7 1.8-1.1 3.8-1.1 6h3Zm-4 0c0-2.2.4-4.2 1-6H9.6A12 12 0 0 0 8 19h3ZM4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm11.8 9c.4-1.9 1-3.4 1.8-4.5a9.2 9.2 0 0 0-4 4.5h2.2Zm-3.4 0a12 12 0 0 1 2.8-4 12 12 0 0 0-5 4h2.2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-Shift-e",type:"button"}],commands:{openEmbedIframeDialog:e=>(y(e),!0)},keymap:{"Mod-Shift-e":"openEmbedIframeDialog"}});function y(e){if(!e){const o=document.activeElement;o&&o.closest("[data-editora-editor]")&&(e=o.closest("[data-editora-editor]"))}if(e||(e=document.querySelector("[data-editora-editor]")),!e){console.warn("Editor element not found");return}const t=l(e);t.formData={src:"",selectedSize:"inline",width:"100%",height:"400px",constrainProportions:!0,name:"",title:"",longDescription:"",descriptionUrl:"",showBorder:!0,enableScrollbar:!0},t.activeTab="general";const a=document.createElement("div");a.className="rte-dialog-overlay rte-embed-iframe-overlay",v(e)&&a.classList.add("rte-theme-dark"),a.onclick=()=>f(e);const r=document.createElement("div");r.className="rte-dialog-content embed-iframe-dialog",r.onclick=o=>o.stopPropagation(),r.innerHTML=`
<div class="rte-dialog-header">

@@ -75,3 +75,3 @@ <h3>Embed Iframe</h3>

</div>
`,a.appendChild(r),document.body.appendChild(a),t.dialogElement=a,k(r,e),C(),setTimeout(()=>{r.querySelector("#iframe-src")?.focus()},100)}function k(e,t){l(t),e.querySelector(".rte-dialog-close")?.addEventListener("click",()=>f(t)),e.querySelectorAll(".rte-tab-button").forEach(i=>{i.addEventListener("click",n=>{const c=n.target.getAttribute("data-tab");c&&S(e,c,t)})}),e.querySelector("#iframe-size")?.addEventListener("change",i=>w(e,i.target.value,t));const r=e.querySelector("#iframe-width"),o=e.querySelector("#iframe-height");r?.addEventListener("input",i=>D(e,i.target.value,t)),o?.addEventListener("input",i=>q(e,i.target.value,t)),e.querySelector("#constrain-btn")?.addEventListener("click",()=>E(e,t)),e.querySelector("#cancel-btn")?.addEventListener("click",()=>f(t)),e.querySelector("#save-btn")?.addEventListener("click",()=>I(e,t))}function S(e,t,a){const r=l(a);r.activeTab=t,e.querySelectorAll(".rte-tab-button").forEach(o=>{o.classList.toggle("active",o.getAttribute("data-tab")===t)}),e.querySelectorAll(".rte-tab-panel").forEach(o=>{o.style.display=o.getAttribute("data-panel")===t?"block":"none"})}function w(e,t,a){const r=l(a);r.formData.selectedSize=t;const o=e.querySelector("#dimensions-row"),i=e.querySelector("#iframe-width"),n=e.querySelector("#iframe-height");t==="inline"?(o.style.display="flex",i.value="100%",n.value="400px",r.formData.width="100%",r.formData.height="400px"):(o.style.display="none",r.formData.width="100%",r.formData.height="auto")}function D(e,t,a){const r=l(a);if(r.formData.width=t,r.formData.constrainProportions&&r.formData.selectedSize==="inline"){const o=parseFloat(t);if(!isNaN(o)){const i=o*9/16;r.formData.height=`${i}px`;const n=e.querySelector("#iframe-height");n&&(n.value=r.formData.height)}}}function q(e,t,a){const r=l(a);if(r.formData.height=t,r.formData.constrainProportions&&r.formData.selectedSize==="inline"){const o=parseFloat(t);if(!isNaN(o)){const i=o*16/9;r.formData.width=`${i}px`;const n=e.querySelector("#iframe-width");n&&(n.value=r.formData.width)}}}function E(e,t){const a=l(t);a.formData.constrainProportions=!a.formData.constrainProportions;const r=e.querySelector("#constrain-btn");r&&(r.textContent=a.formData.constrainProportions?"🔒":"🔓",r.className=`rte-constrain-btn ${a.formData.constrainProportions?"locked":"unlocked"}`,r.title=a.formData.constrainProportions?"Unlock proportions":"Lock proportions")}function I(e,t){const a=l(t),r=e.querySelector("#iframe-src")?.value.trim();if(!r){alert("Please enter a source URL");return}if(!r.startsWith("https://")&&!r.startsWith("http://")){alert("Please enter a valid URL starting with https:// or http://");return}const o=e.querySelector("#iframe-name")?.value.trim(),i=e.querySelector("#iframe-title")?.value.trim(),n=e.querySelector("#iframe-longdesc")?.value.trim();e.querySelector("#iframe-desc-url")?.value.trim();const c=e.querySelector("#iframe-border")?.checked??!0,p=e.querySelector("#iframe-scrollbar")?.checked??!0;let s=a.formData.width,d=a.formData.height;a.formData.selectedSize!=="inline"&&(s="100%",d="auto"),z(t,{src:r,width:s,height:d,aspectRatio:a.formData.selectedSize,name:o||void 0,title:i||void 0,longDescription:n||void 0,showBorder:c,enableScrollbar:p}),f(t)}function z(e,t){const a=e.querySelector('[contenteditable="true"]');a&&(a.focus(),setTimeout(()=>{const r=[`src="${t.src}"`,`width="${t.width}"`,`height="${t.height}"`,"allowfullscreen",`frameborder="${t.showBorder?"1":"0"}"`,`scrolling="${t.enableScrollbar?"auto":"no"}"`];t.name&&r.push(`name="${t.name}"`),t.title&&r.push(`title="${t.title}"`),t.longDescription&&r.push(`longdesc="${t.longDescription}"`);const o=[];t.aspectRatio!=="inline"&&o.push(`rte-iframe-${t.aspectRatio}`);const i=o.length>0?`class="${o.join(" ")}"`:"",n=`data-aspect-ratio="${t.aspectRatio}"`,c=`<iframe ${r.join(" ")} ${i} ${n}></iframe>`;if(!document.execCommand("insertHTML",!1,c)){const s=window.getSelection();if(s&&s.rangeCount>0){const d=s.getRangeAt(0);d.deleteContents();const b=document.createElement("div");b.innerHTML=c;const h=document.createDocumentFragment();for(;b.firstChild;)h.appendChild(b.firstChild);d.insertNode(h)}}},10))}function f(e){const t=l(e);t.dialogElement&&(document.body.removeChild(t.dialogElement),t.dialogElement=null)}function C(){if(document.getElementById("embed-iframe-dialog-styles"))return;const e=document.createElement("style");e.id="embed-iframe-dialog-styles",e.textContent=`
`,a.appendChild(r),document.body.appendChild(a),t.dialogElement=a,t.escapeHandler=o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),f(e))},document.addEventListener("keydown",t.escapeHandler,!0),k(r,e),z(),setTimeout(()=>{r.querySelector("#iframe-src")?.focus()},100)}function k(e,t){l(t),e.querySelector(".rte-dialog-close")?.addEventListener("click",()=>f(t)),e.querySelectorAll(".rte-tab-button").forEach(i=>{i.addEventListener("click",n=>{const c=n.target.getAttribute("data-tab");c&&w(e,c,t)})}),e.querySelector("#iframe-size")?.addEventListener("change",i=>S(e,i.target.value,t));const r=e.querySelector("#iframe-width"),o=e.querySelector("#iframe-height");r?.addEventListener("input",i=>D(e,i.target.value,t)),o?.addEventListener("input",i=>q(e,i.target.value,t)),e.querySelector("#constrain-btn")?.addEventListener("click",()=>E(e,t)),e.querySelector("#cancel-btn")?.addEventListener("click",()=>f(t)),e.querySelector("#save-btn")?.addEventListener("click",()=>L(e,t))}function w(e,t,a){const r=l(a);r.activeTab=t,e.querySelectorAll(".rte-tab-button").forEach(o=>{o.classList.toggle("active",o.getAttribute("data-tab")===t)}),e.querySelectorAll(".rte-tab-panel").forEach(o=>{o.style.display=o.getAttribute("data-panel")===t?"block":"none"})}function S(e,t,a){const r=l(a);r.formData.selectedSize=t;const o=e.querySelector("#dimensions-row"),i=e.querySelector("#iframe-width"),n=e.querySelector("#iframe-height");t==="inline"?(o.style.display="flex",i.value="100%",n.value="400px",r.formData.width="100%",r.formData.height="400px"):(o.style.display="none",r.formData.width="100%",r.formData.height="auto")}function D(e,t,a){const r=l(a);if(r.formData.width=t,r.formData.constrainProportions&&r.formData.selectedSize==="inline"){const o=parseFloat(t);if(!isNaN(o)){const i=o*9/16;r.formData.height=`${i}px`;const n=e.querySelector("#iframe-height");n&&(n.value=r.formData.height)}}}function q(e,t,a){const r=l(a);if(r.formData.height=t,r.formData.constrainProportions&&r.formData.selectedSize==="inline"){const o=parseFloat(t);if(!isNaN(o)){const i=o*16/9;r.formData.width=`${i}px`;const n=e.querySelector("#iframe-width");n&&(n.value=r.formData.width)}}}function E(e,t){const a=l(t);a.formData.constrainProportions=!a.formData.constrainProportions;const r=e.querySelector("#constrain-btn");r&&(r.textContent=a.formData.constrainProportions?"🔒":"🔓",r.className=`rte-constrain-btn ${a.formData.constrainProportions?"locked":"unlocked"}`,r.title=a.formData.constrainProportions?"Unlock proportions":"Lock proportions")}function L(e,t){const a=l(t),r=e.querySelector("#iframe-src")?.value.trim();if(!r){alert("Please enter a source URL");return}if(!r.startsWith("https://")&&!r.startsWith("http://")){alert("Please enter a valid URL starting with https:// or http://");return}const o=e.querySelector("#iframe-name")?.value.trim(),i=e.querySelector("#iframe-title")?.value.trim(),n=e.querySelector("#iframe-longdesc")?.value.trim();e.querySelector("#iframe-desc-url")?.value.trim();const c=e.querySelector("#iframe-border")?.checked??!0,p=e.querySelector("#iframe-scrollbar")?.checked??!0;let s=a.formData.width,d=a.formData.height;a.formData.selectedSize!=="inline"&&(s="100%",d="auto"),I(t,{src:r,width:s,height:d,aspectRatio:a.formData.selectedSize,name:o||void 0,title:i||void 0,longDescription:n||void 0,showBorder:c,enableScrollbar:p}),f(t)}function I(e,t){const a=e.querySelector('[contenteditable="true"]');a&&(a.focus(),setTimeout(()=>{const r=[`src="${t.src}"`,`width="${t.width}"`,`height="${t.height}"`,"allowfullscreen",`frameborder="${t.showBorder?"1":"0"}"`,`scrolling="${t.enableScrollbar?"auto":"no"}"`];t.name&&r.push(`name="${t.name}"`),t.title&&r.push(`title="${t.title}"`),t.longDescription&&r.push(`longdesc="${t.longDescription}"`);const o=[];t.aspectRatio!=="inline"&&o.push(`rte-iframe-${t.aspectRatio}`);const i=o.length>0?`class="${o.join(" ")}"`:"",n=`data-aspect-ratio="${t.aspectRatio}"`,c=`<iframe ${r.join(" ")} ${i} ${n}></iframe>`;if(!document.execCommand("insertHTML",!1,c)){const s=window.getSelection();if(s&&s.rangeCount>0){const d=s.getRangeAt(0);d.deleteContents();const b=document.createElement("div");b.innerHTML=c;const h=document.createDocumentFragment();for(;b.firstChild;)h.appendChild(b.firstChild);d.insertNode(h)}}},10))}function f(e){const t=l(e);t.escapeHandler&&(document.removeEventListener("keydown",t.escapeHandler,!0),t.escapeHandler=null),t.dialogElement&&(t.dialogElement.remove(),t.dialogElement=null)}function z(){if(document.getElementById("embed-iframe-dialog-styles"))return;const e=document.createElement("style");e.id="embed-iframe-dialog-styles",e.textContent=`
/* Embed Iframe Dialog Styles */

@@ -78,0 +78,0 @@ .embed-iframe-dialog {

@@ -9,2 +9,3 @@ const g = [

dialogElement: null,
escapeHandler: null,
activeTab: "general",

@@ -146,3 +147,5 @@ formData: {

</div>
`, a.appendChild(r), document.body.appendChild(a), t.dialogElement = a, y(r, e), C(), setTimeout(() => {
`, a.appendChild(r), document.body.appendChild(a), t.dialogElement = a, t.escapeHandler = (o) => {
o.key === "Escape" && (o.preventDefault(), o.stopPropagation(), f(e));
}, document.addEventListener("keydown", t.escapeHandler, !0), y(r, e), z(), setTimeout(() => {
r.querySelector("#iframe-src")?.focus();

@@ -219,3 +222,3 @@ }, 100);

let s = a.formData.width, d = a.formData.height;
a.formData.selectedSize !== "inline" && (s = "100%", d = "auto"), z(t, {
a.formData.selectedSize !== "inline" && (s = "100%", d = "auto"), L(t, {
src: r,

@@ -232,3 +235,3 @@ width: s,

}
function z(e, t) {
function L(e, t) {
const a = e.querySelector('[contenteditable="true"]');

@@ -265,5 +268,5 @@ a && (a.focus(), setTimeout(() => {

const t = l(e);
t.dialogElement && (document.body.removeChild(t.dialogElement), t.dialogElement = null);
t.escapeHandler && (document.removeEventListener("keydown", t.escapeHandler, !0), t.escapeHandler = null), t.dialogElement && (t.dialogElement.remove(), t.dialogElement = null);
}
function C() {
function z() {
if (document.getElementById("embed-iframe-dialog-styles")) return;

@@ -270,0 +273,0 @@ const e = document.createElement("style");

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d={all:{name:"All",emojis:["❤️","💔","💙","💚","💛","🖤","🤍","🤎","✔️","❌","☑️","❗","❓","⚠️","💯","➕","➖","✖️","➗","♻️","⚡","🔥","✨","⭐","⭕","🚫","😀","😃","😄","😁","😆","😅","😂","🤣","😊","😇","🙂","🙃","😉","😍","😘","😎","🤓","😐","😑","😬","🙄","😏","😌","🤩","🥳","🤔","😴","😭","😢","😡","🤯","👍","👎","👌","✌️","🤞","🙏","👏","🙌","💪","🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸","🐵","🐔","🐧","🐦","🦆","🦅","🦄","🐝","🦋","🌲","🌳","🌴","🌵","🌸","🌼","🌻","☀️","🌙","⭐","🌈","🌧️","❄️","🌊","🍎","🍌","🍉","🍇","🍓","🍒","🍍","🥭","🍐","🍊","🍋","🍑","🥝","🥑","🍔","🍟","🍕","🌭","🥪","🌮","🌯","🍣","🍜","🍰","🧁","🍩","🍪","🍫","☕","🍵","🥤","🍺","🍷","🍸","🍹","🥂","⚽","🏀","🏈","⚾","🎾","🏐","🏉","🎮","🎯","🎳","🎲","♟️","🏃","🚴","🏊","🏋️","🧘","🎸","🎹","🥁","🎺","🎤","🏆","🥇","🚗","🚕","🚌","🚎","🚓","🚑","🚒","✈️","🚀","🚁","🚤","🛳️","🚢","🏠","🏢","🏬","🏫","🏥","🏰","🗼","🗽","⛩️","🕌","🌍","🌎","🌏","🏖️","🏝️","📱","💻","🖥️","⌨️","🖱️","📷","📸","🎥","📹","📚","📖","📝","📄","📂","🔒","🔑","🗝️","💡","🔦","🕯️","🧰","🛠️","🔧","⚙️","📦","💳","💰","🔋","🔌","🇮🇳","🇺🇸","🇬🇧","🇨🇦","🇦🇺","🇩🇪","🇫🇷","🇪🇸","🇮🇹","🇯🇵","🇰🇷","🇨🇳","🇧🇷","🇲🇽","🇷🇺","🇿🇦","🇳🇿"]},symbols:{name:"Symbols",emojis:["❤️","💔","💙","💚","💛","🖤","🤍","🤎","✔️","❌","☑️","❗","❓","⚠️","💯","➕","➖","✖️","➗","♻️","⚡","🔥","✨","⭐","⭕","🚫","⬆️","⬇️","⬅️","➡️","🔄","🔁","🔀","🔔","🔕","⏰","⌛","⏳"]},people:{name:"People",emojis:["😀","😃","😄","😁","😆","😅","😂","🤣","😊","😇","🙂","🙃","😉","😍","😘","😎","🤓","😐","😑","😬","🙄","😏","😌","🤩","🥳","🤔","😴","😭","😢","😡","🤯","👍","👎","👌","✌️","🤞","🙏","👏","🙌","💪"]},"animals-nature":{name:"Animals & Nature",emojis:["🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸","🐵","🐔","🐧","🐦","🦆","🦅","🦄","🐝","🦋","🌲","🌳","🌴","🌵","🌸","🌼","🌻","☀️","🌙","⭐","🌈","🌧️","❄️","🌊"]},"food-drink":{name:"Food & Drink",emojis:["🍎","🍌","🍉","🍇","🍓","🍒","🍍","🥭","🍐","🍊","🍋","🍑","🥝","🥑","🍔","🍟","🍕","🌭","🥪","🌮","🌯","🍣","🍜","🍰","🧁","🍩","🍪","🍫","☕","🍵","🥤","🍺","🍷","🍸","🍹","🥂"]},activity:{name:"Activity",emojis:["⚽","🏀","🏈","⚾","🎾","🏐","🏉","🎮","🎯","🎳","🎲","♟️","🏃","🚴","🏊","🏋️","🧘","🎸","🎹","🥁","🎺","🎤","🏆","🥇","🥈","🥉"]},"travel-places":{name:"Travel & Places",emojis:["🚗","🚕","🚌","🚎","🚓","🚑","🚒","✈️","🚀","🚁","🚤","🛳️","🚢","🏠","🏢","🏬","🏫","🏥","🏰","🗼","🗽","⛩️","🕌","🌍","🌎","🌏","🏖️","🏝️"]},objects:{name:"Objects",emojis:["📱","💻","🖥️","⌨️","🖱️","📷","📸","🎥","📹","📚","📖","📝","📄","📂","🔒","🔑","🗝️","💡","🔦","🕯️","🧰","🛠️","🔧","⚙️","📦","💳","💰","🔋","🔌"]},flags:{name:"Flags",emojis:["🇮🇳","🇺🇸","🇬🇧","🇨🇦","🇦🇺","🇩🇪","🇫🇷","🇪🇸","🇮🇹","🇯🇵","🇰🇷","🇨🇳","🇧🇷","🇲🇽","🇷🇺","🇿🇦","🇳🇿"]}},p={"💙":"blue heart","💚":"green heart","💛":"yellow heart","🖤":"black heart","🤍":"white heart","🤎":"brown heart","☑️":"check box with check","🔴":"red circle","🟢":"green circle","🟡":"yellow circle","🔵":"blue circle","⬆️":"up arrow","⬇️":"down arrow","⬅️":"left arrow","➡️":"right arrow","🔄":"counterclockwise arrows","🔁":"repeat button","🔀":"shuffle tracks","🔔":"bell","🔕":"muted bell","⏰":"alarm clock","⏳":"hourglass not done","⌛":"hourglass done","♠️":"spade suit","♥️":"heart suit","♦️":"diamond suit","♣️":"club suit","🚫":"prohibited","⭕":"hollow red circle","❎":"cross mark button","😐":"neutral face","😑":"expressionless face","😬":"grimacing face","🙄":"face with rolling eyes","😏":"smirking face","😌":"relieved face","🤩":"star struck","😜":"winking face with tongue","😝":"squinting face with tongue","🤪":"zany face","😢":"crying face","😥":"sad but relieved face","😓":"downcast face with sweat","😱":"face screaming in fear","😨":"fearful face","🤗":"hugging face","🤭":"face with hand over mouth","🤫":"shushing face","🤥":"lying face","👌":"ok hand","✌️":"victory hand","🤞":"crossed fingers","🙌":"raising hands","💪":"flexed biceps","🐔":"chicken","🐧":"penguin","🐦":"bird","🐤":"baby chick","🦆":"duck","🦅":"eagle","🐺":"wolf","🦄":"unicorn","🐝":"honeybee","🐞":"lady beetle","🦋":"butterfly","🐢":"turtle","🐍":"snake","🦖":"t-rex","🌿":"herb","🍀":"four leaf clover","🍁":"maple leaf","🍂":"fallen leaf","🌊":"water wave","❄️":"snowflake","☁️":"cloud","⛈️":"cloud with lightning and rain","🌪️":"tornado","🍐":"pear","🍊":"tangerine","🍋":"lemon","🍑":"peach","🥝":"kiwi fruit","🥑":"avocado","🍆":"eggplant","🌽":"ear of corn","🥕":"carrot","🥔":"potato","🍞":"bread","🥐":"croissant","🥖":"baguette bread","🧀":"cheese wedge","🍖":"meat on bone","🍗":"poultry leg","🥩":"cut of meat","🍦":"soft ice cream","🍨":"ice cream","🍫":"chocolate bar","🍬":"candy","🥛":"glass of milk","🧃":"beverage box","🍹":"tropical drink","🥂":"clinking glasses","🏓":"ping pong","🥊":"boxing glove","🥋":"martial arts uniform","⛳":"flag in hole","🏹":"bow and arrow","🎿":"skis","⛷️":"skier","🏂":"snowboarder","🎤":"microphone","🎬":"clapper board","🎨":"artist palette","🧩":"puzzle piece","🪀":"yo-yo","🚇":"metro","🚉":"station","🚊":"tram","🚝":"monorail","🛻":"pickup truck","🚐":"minibus","🗺️":"world map","🧭":"compass","⛰️":"mountain","🏔️":"snow capped mountain","🌋":"volcano","🏜️":"desert","🏕️":"camping","🏙️":"cityscape","🌆":"city at dusk","🌃":"night with stars","📦":"package","📫":"closed mailbox with raised flag","📬":"open mailbox with raised flag","📭":"open mailbox with lowered flag","🧾":"receipt","💳":"credit card","💰":"money bag","🪙":"coin","🔋":"battery","🔌":"electric plug","🧯":"fire extinguisher","🪜":"ladder","🪞":"mirror","🧹":"broom","🧸":"teddy bear"};let c=null,n="all",l="",s=null;const j='[data-theme="dark"], .dark, .editora-theme-dark',h=()=>({name:"emojis",toolbar:[{label:"Insert Emoji",command:"openEmojiDialog",icon:'<svg width="24" height="24" focusable="false"><path d="M9 11c.6 0 1-.4 1-1s-.4-1-1-1a1 1 0 0 0-1 1c0 .6.4 1 1 1Zm6 0c.6 0 1-.4 1-1s-.4-1-1-1a1 1 0 0 0-1 1c0 .6.4 1 1 1Zm-3 5.5c2.1 0 4-1.5 4.4-3.5H7.6c.5 2 2.3 3.5 4.4 3.5ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm0 14.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-Shift-j",type:"button"}],commands:{openEmojiDialog:(o,t)=>{const e=t?.contentElement||u();return e?(v(e),!0):!1},insertEmoji:(o,t)=>{if(!o)return!1;const e=t?.contentElement||u();if(!e)return!1;try{return f(o,e),!0}catch{return!1}}},keymap:{"Mod-Shift-j":"openEmojiDialog"}});function v(o){n="all",l="";const t=window.getSelection();s=null,t&&t.rangeCount>0&&o.contains(t.anchorNode)&&(s=t.getRangeAt(0).cloneRange());const e=document.createElement("div");e.className="emojis-overlay",y(o)&&e.classList.add("rte-ui-theme-dark"),e.onclick=g;const r=document.createElement("div");r.className="emojis-dialog",r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.onclick=a=>a.stopPropagation();const i=Object.keys(d);r.innerHTML=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p={all:{name:"All",emojis:["❤️","💔","💙","💚","💛","🖤","🤍","🤎","✔️","❌","☑️","❗","❓","⚠️","💯","➕","➖","✖️","➗","♻️","⚡","🔥","✨","⭐","⭕","🚫","😀","😃","😄","😁","😆","😅","😂","🤣","😊","😇","🙂","🙃","😉","😍","😘","😎","🤓","😐","😑","😬","🙄","😏","😌","🤩","🥳","🤔","😴","😭","😢","😡","🤯","👍","👎","👌","✌️","🤞","🙏","👏","🙌","💪","🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸","🐵","🐔","🐧","🐦","🦆","🦅","🦄","🐝","🦋","🌲","🌳","🌴","🌵","🌸","🌼","🌻","☀️","🌙","⭐","🌈","🌧️","❄️","🌊","🍎","🍌","🍉","🍇","🍓","🍒","🍍","🥭","🍐","🍊","🍋","🍑","🥝","🥑","🍔","🍟","🍕","🌭","🥪","🌮","🌯","🍣","🍜","🍰","🧁","🍩","🍪","🍫","☕","🍵","🥤","🍺","🍷","🍸","🍹","🥂","⚽","🏀","🏈","⚾","🎾","🏐","🏉","🎮","🎯","🎳","🎲","♟️","🏃","🚴","🏊","🏋️","🧘","🎸","🎹","🥁","🎺","🎤","🏆","🥇","🚗","🚕","🚌","🚎","🚓","🚑","🚒","✈️","🚀","🚁","🚤","🛳️","🚢","🏠","🏢","🏬","🏫","🏥","🏰","🗼","🗽","⛩️","🕌","🌍","🌎","🌏","🏖️","🏝️","📱","💻","🖥️","⌨️","🖱️","📷","📸","🎥","📹","📚","📖","📝","📄","📂","🔒","🔑","🗝️","💡","🔦","🕯️","🧰","🛠️","🔧","⚙️","📦","💳","💰","🔋","🔌","🇮🇳","🇺🇸","🇬🇧","🇨🇦","🇦🇺","🇩🇪","🇫🇷","🇪🇸","🇮🇹","🇯🇵","🇰🇷","🇨🇳","🇧🇷","🇲🇽","🇷🇺","🇿🇦","🇳🇿"]},symbols:{name:"Symbols",emojis:["❤️","💔","💙","💚","💛","🖤","🤍","🤎","✔️","❌","☑️","❗","❓","⚠️","💯","➕","➖","✖️","➗","♻️","⚡","🔥","✨","⭐","⭕","🚫","⬆️","⬇️","⬅️","➡️","🔄","🔁","🔀","🔔","🔕","⏰","⌛","⏳"]},people:{name:"People",emojis:["😀","😃","😄","😁","😆","😅","😂","🤣","😊","😇","🙂","🙃","😉","😍","😘","😎","🤓","😐","😑","😬","🙄","😏","😌","🤩","🥳","🤔","😴","😭","😢","😡","🤯","👍","👎","👌","✌️","🤞","🙏","👏","🙌","💪"]},"animals-nature":{name:"Animals & Nature",emojis:["🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸","🐵","🐔","🐧","🐦","🦆","🦅","🦄","🐝","🦋","🌲","🌳","🌴","🌵","🌸","🌼","🌻","☀️","🌙","⭐","🌈","🌧️","❄️","🌊"]},"food-drink":{name:"Food & Drink",emojis:["🍎","🍌","🍉","🍇","🍓","🍒","🍍","🥭","🍐","🍊","🍋","🍑","🥝","🥑","🍔","🍟","🍕","🌭","🥪","🌮","🌯","🍣","🍜","🍰","🧁","🍩","🍪","🍫","☕","🍵","🥤","🍺","🍷","🍸","🍹","🥂"]},activity:{name:"Activity",emojis:["⚽","🏀","🏈","⚾","🎾","🏐","🏉","🎮","🎯","🎳","🎲","♟️","🏃","🚴","🏊","🏋️","🧘","🎸","🎹","🥁","🎺","🎤","🏆","🥇","🥈","🥉"]},"travel-places":{name:"Travel & Places",emojis:["🚗","🚕","🚌","🚎","🚓","🚑","🚒","✈️","🚀","🚁","🚤","🛳️","🚢","🏠","🏢","🏬","🏫","🏥","🏰","🗼","🗽","⛩️","🕌","🌍","🌎","🌏","🏖️","🏝️"]},objects:{name:"Objects",emojis:["📱","💻","🖥️","⌨️","🖱️","📷","📸","🎥","📹","📚","📖","📝","📄","📂","🔒","🔑","🗝️","💡","🔦","🕯️","🧰","🛠️","🔧","⚙️","📦","💳","💰","🔋","🔌"]},flags:{name:"Flags",emojis:["🇮🇳","🇺🇸","🇬🇧","🇨🇦","🇦🇺","🇩🇪","🇫🇷","🇪🇸","🇮🇹","🇯🇵","🇰🇷","🇨🇳","🇧🇷","🇲🇽","🇷🇺","🇿🇦","🇳🇿"]}},x={"💙":"blue heart","💚":"green heart","💛":"yellow heart","🖤":"black heart","🤍":"white heart","🤎":"brown heart","☑️":"check box with check","🔴":"red circle","🟢":"green circle","🟡":"yellow circle","🔵":"blue circle","⬆️":"up arrow","⬇️":"down arrow","⬅️":"left arrow","➡️":"right arrow","🔄":"counterclockwise arrows","🔁":"repeat button","🔀":"shuffle tracks","🔔":"bell","🔕":"muted bell","⏰":"alarm clock","⏳":"hourglass not done","⌛":"hourglass done","♠️":"spade suit","♥️":"heart suit","♦️":"diamond suit","♣️":"club suit","🚫":"prohibited","⭕":"hollow red circle","❎":"cross mark button","😐":"neutral face","😑":"expressionless face","😬":"grimacing face","🙄":"face with rolling eyes","😏":"smirking face","😌":"relieved face","🤩":"star struck","😜":"winking face with tongue","😝":"squinting face with tongue","🤪":"zany face","😢":"crying face","😥":"sad but relieved face","😓":"downcast face with sweat","😱":"face screaming in fear","😨":"fearful face","🤗":"hugging face","🤭":"face with hand over mouth","🤫":"shushing face","🤥":"lying face","👌":"ok hand","✌️":"victory hand","🤞":"crossed fingers","🙌":"raising hands","💪":"flexed biceps","🐔":"chicken","🐧":"penguin","🐦":"bird","🐤":"baby chick","🦆":"duck","🦅":"eagle","🐺":"wolf","🦄":"unicorn","🐝":"honeybee","🐞":"lady beetle","🦋":"butterfly","🐢":"turtle","🐍":"snake","🦖":"t-rex","🌿":"herb","🍀":"four leaf clover","🍁":"maple leaf","🍂":"fallen leaf","🌊":"water wave","❄️":"snowflake","☁️":"cloud","⛈️":"cloud with lightning and rain","🌪️":"tornado","🍐":"pear","🍊":"tangerine","🍋":"lemon","🍑":"peach","🥝":"kiwi fruit","🥑":"avocado","🍆":"eggplant","🌽":"ear of corn","🥕":"carrot","🥔":"potato","🍞":"bread","🥐":"croissant","🥖":"baguette bread","🧀":"cheese wedge","🍖":"meat on bone","🍗":"poultry leg","🥩":"cut of meat","🍦":"soft ice cream","🍨":"ice cream","🍫":"chocolate bar","🍬":"candy","🥛":"glass of milk","🧃":"beverage box","🍹":"tropical drink","🥂":"clinking glasses","🏓":"ping pong","🥊":"boxing glove","🥋":"martial arts uniform","⛳":"flag in hole","🏹":"bow and arrow","🎿":"skis","⛷️":"skier","🏂":"snowboarder","🎤":"microphone","🎬":"clapper board","🎨":"artist palette","🧩":"puzzle piece","🪀":"yo-yo","🚇":"metro","🚉":"station","🚊":"tram","🚝":"monorail","🛻":"pickup truck","🚐":"minibus","🗺️":"world map","🧭":"compass","⛰️":"mountain","🏔️":"snow capped mountain","🌋":"volcano","🏜️":"desert","🏕️":"camping","🏙️":"cityscape","🌆":"city at dusk","🌃":"night with stars","📦":"package","📫":"closed mailbox with raised flag","📬":"open mailbox with raised flag","📭":"open mailbox with lowered flag","🧾":"receipt","💳":"credit card","💰":"money bag","🪙":"coin","🔋":"battery","🔌":"electric plug","🧯":"fire extinguisher","🪜":"ladder","🪞":"mirror","🧹":"broom","🧸":"teddy bear"};let g=null,s="all",u="",n=null,l=null,d=null;const k='[data-theme="dark"], .dark, .editora-theme-dark',w=()=>({name:"emojis",toolbar:[{label:"Insert Emoji",command:"openEmojiDialog",icon:'<svg width="24" height="24" focusable="false"><path d="M9 11c.6 0 1-.4 1-1s-.4-1-1-1a1 1 0 0 0-1 1c0 .6.4 1 1 1Zm6 0c.6 0 1-.4 1-1s-.4-1-1-1a1 1 0 0 0-1 1c0 .6.4 1 1 1Zm-3 5.5c2.1 0 4-1.5 4.4-3.5H7.6c.5 2 2.3 3.5 4.4 3.5ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm0 14.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-Shift-j",type:"button"}],commands:{openEmojiDialog:(t,r)=>{const e=r?.contentElement||b();return e?(y(e),!0):!1},insertEmoji:(t,r)=>{if(!t)return!1;const e=r?.contentElement||b();if(!e)return!1;try{return v(t,e),!0}catch{return!1}}},keymap:{"Mod-Shift-j":"openEmojiDialog"}});function y(t){m(),s="all",u="";const r=window.getSelection();l=null,r&&r.rangeCount>0&&t.contains(r.anchorNode)&&(l=r.getRangeAt(0).cloneRange());const e=document.createElement("div");e.className="emojis-overlay",S(t)&&e.classList.add("rte-ui-theme-dark"),e.onclick=m;const o=document.createElement("div");o.className="emojis-dialog",o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.onclick=a=>a.stopPropagation();const i=Object.keys(p);o.innerHTML=`
<div class="rte-dialog-header emojis-header">

@@ -9,4 +9,4 @@ <h3>Insert Emojis</h3>

${i.map(a=>`
<button class="emojis-tab ${a===n?"active":""}" data-category="${a}">
${d[a].name}
<button class="emojis-tab ${a===s?"active":""}" data-category="${a}">
${p[a].name}
</button>

@@ -29,15 +29,15 @@ `).join("")}

<div class="emojis-grid" id="emojis-grid">
${b(n,l)}
${j(s,u)}
</div>
</div>
</div>
`,e.appendChild(r),document.body.appendChild(e),c=e,x(r,o),k(),setTimeout(()=>{r.querySelector("#emoji-search-input")?.focus()},100)}function x(o,t){o.querySelector(".emojis-close")?.addEventListener("click",g),o.querySelectorAll(".emojis-tab").forEach(r=>{r.addEventListener("click",i=>{const a=i.target.getAttribute("data-category");a&&w(o,a,t)})}),o.querySelector("#emoji-search-input")?.addEventListener("input",r=>{l=r.target.value,m(o,t)}),m(o,t)}function w(o,t,e){n=t,o.querySelectorAll(".emojis-tab").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-category")===t)}),m(o,e)}function m(o,t){const e=o.querySelector("#emojis-grid");e&&(e.innerHTML=b(n,l),e.querySelectorAll(".emojis-item").forEach(r=>{r.addEventListener("click",()=>{const i=r.textContent?.trim()||"";i&&(f(i,t),g())})}))}function b(o,t){let e=d[o].emojis;return t.trim()&&(e=e.filter(r=>r.toLowerCase().includes(t.toLowerCase())?!0:(p[r]||"").toLowerCase().includes(t.toLowerCase()))),e.length===0&&t.trim()?`<div class="emojis-no-results">No emojis found for "${t}"</div>`:e.map((r,i)=>`
`,e.appendChild(o),document.body.appendChild(e),g=e,d=a=>{a.key==="Escape"&&(a.preventDefault(),a.stopPropagation(),m())},document.addEventListener("keydown",d,!0),E(o,t),A(),requestAnimationFrame(()=>{o.querySelector("#emoji-search-input")?.focus()})}function E(t,r){t.querySelector(".emojis-close")?.addEventListener("click",m),t.querySelectorAll(".emojis-tab").forEach(i=>{i.addEventListener("click",a=>{const c=a.target.getAttribute("data-category");c&&z(t,c)})}),t.querySelector("#emoji-search-input")?.addEventListener("input",i=>{u=i.target.value,n!==null&&window.clearTimeout(n),n=window.setTimeout(()=>{n=null,h(t)},90)}),t.querySelector("#emojis-grid")?.addEventListener("click",i=>{const c=i.target.closest(".emojis-item");if(!c)return;const f=c.getAttribute("data-emoji")||c.textContent?.trim()||"";f&&(v(f,r),m())})}function z(t,r){s=r,t.querySelectorAll(".emojis-tab").forEach(e=>{e.classList.toggle("active",e.getAttribute("data-category")===r)}),h(t)}function h(t){const r=t.querySelector("#emojis-grid");r&&(r.innerHTML=j(s,u))}function j(t,r){let e=p[t].emojis;return r.trim()&&(e=e.filter(o=>o.toLowerCase().includes(r.toLowerCase())?!0:(x[o]||"").toLowerCase().includes(r.toLowerCase()))),e.length===0&&r.trim()?`<div class="emojis-no-results">No emojis found for "${r}"</div>`:e.map((o,i)=>`
<button
class="emojis-item"
title="Insert ${r}"
data-emoji="${r}"
title="Insert ${o}"
data-emoji="${o}"
>
${r}
${o}
</button>
`).join("")}function g(){c&&(document.body.removeChild(c),c=null)}function f(o,t){t.focus();let e=window.getSelection();if(s&&(e?.removeAllRanges(),e?.addRange(s),s=null),e=window.getSelection(),e&&e.rangeCount>0){const r=e.getRangeAt(0);r.deleteContents();const i=document.createTextNode(o);r.insertNode(i),r.setStartAfter(i),r.setEndAfter(i),e.removeAllRanges(),e.addRange(r)}}function u(){const o=window.getSelection();if(o&&o.rangeCount>0){const e=o.anchorNode,i=(e instanceof HTMLElement?e:e?.parentElement)?.closest(".editora-content, .rte-content");if(i)return i}const t=document.activeElement;return t&&(t.classList.contains("editora-content")||t.classList.contains("rte-content"))?t:document.querySelector(".editora-content, .rte-content")}function y(o){const t=o||u();return t?!!t.closest(j):!1}function k(){if(document.getElementById("emojis-dialog-styles"))return;const o=document.createElement("style");o.id="emojis-dialog-styles",o.textContent=`
`).join("")}function m(){d&&(document.removeEventListener("keydown",d,!0),d=null),n!==null&&(window.clearTimeout(n),n=null),g&&(g.remove(),g=null)}function v(t,r){r.focus();let e=window.getSelection();if(l&&(e?.removeAllRanges(),e?.addRange(l),l=null),e=window.getSelection(),e&&e.rangeCount>0){const o=e.getRangeAt(0);o.deleteContents();const i=document.createTextNode(t);o.insertNode(i),o.setStartAfter(i),o.setEndAfter(i),e.removeAllRanges(),e.addRange(o)}}function b(){const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.anchorNode,i=(e instanceof HTMLElement?e:e?.parentElement)?.closest(".editora-content, .rte-content");if(i)return i}const r=document.activeElement;return r&&(r.classList.contains("editora-content")||r.classList.contains("rte-content"))?r:document.querySelector(".editora-content, .rte-content")}function S(t){const r=t||b();return r?!!r.closest(k):!1}function A(){if(document.getElementById("emojis-dialog-styles"))return;const t=document.createElement("style");t.id="emojis-dialog-styles",t.textContent=`
.emojis-overlay {

@@ -54,2 +54,22 @@ --rte-emoji-overlay-bg: rgba(15, 23, 36, 0.56);

--rte-emoji-ring: rgba(31, 117, 254, 0.18);
--rte-picker-dialog-width: min(640px, 96vw);
--rte-picker-dialog-max-height: min(560px, 86vh);
--rte-picker-dialog-radius: 12px;
--rte-picker-search-wrap-padding: 12px;
--rte-picker-search-height: 38px;
--rte-picker-search-font-size: 13px;
--rte-picker-search-radius: 8px;
--rte-picker-tabs-width: 156px;
--rte-picker-tab-padding-y: 10px;
--rte-picker-tab-padding-x: 12px;
--rte-picker-tab-font-size: 13px;
--rte-picker-grid-padding: 12px;
--rte-picker-grid-gap: 6px;
--rte-picker-cell-size: 34px;
--rte-picker-cell-font-size: 17px;
--rte-picker-cell-radius: 7px;
--rte-picker-mobile-tab-min-width: 82px;
--rte-picker-mobile-cell-size: 32px;
--rte-picker-mobile-grid-gap: 5px;
--rte-picker-mobile-dialog-max-height: 88vh;
position: fixed;

@@ -65,3 +85,3 @@ top: 0;

justify-content: center;
z-index: 1000;
z-index: 10000;
padding: 16px;

@@ -88,7 +108,6 @@ box-sizing: border-box;

border: 1px solid var(--rte-emoji-border);
border-radius: 12px;
border-radius: var(--rte-picker-dialog-radius);
box-shadow: 0 24px 48px rgba(10, 15, 24, 0.28);
max-width: 800px;
width: 90%;
max-height: 80vh;
width: var(--rte-picker-dialog-width);
max-height: var(--rte-picker-dialog-max-height);
display: flex;

@@ -131,6 +150,7 @@ flex-direction: column;

overflow: hidden;
min-width: 0;
}
.emojis-search {
padding: 16px 16px 0 16px;
padding: var(--rte-picker-search-wrap-padding) var(--rte-picker-search-wrap-padding) 0 var(--rte-picker-search-wrap-padding);
position: relative;

@@ -141,4 +161,4 @@ }

position: absolute;
left: 28px;
top: 27px;
left: 24px;
top: 22px;
color: var(--rte-emoji-muted-text);

@@ -150,10 +170,12 @@ pointer-events: none;

.emojis-search-input {
width: calc(100% - 24px);
padding: 10px 12px 10px 40px;
width: 100%;
height: var(--rte-picker-search-height);
padding: 8px 12px 8px 36px;
border: 1px solid var(--rte-emoji-border);
border-radius: 8px;
font-size: 14px;
border-radius: var(--rte-picker-search-radius);
font-size: var(--rte-picker-search-font-size);
color: var(--rte-emoji-dialog-text);
background-color: var(--rte-emoji-subtle-bg);
transition: border-color 0.2s ease, box-shadow 0.2s ease;
box-sizing: border-box;
}

@@ -178,9 +200,10 @@

flex-direction: column;
width: 180px;
width: var(--rte-picker-tabs-width);
border-right: 1px solid var(--rte-emoji-border);
background-color: var(--rte-emoji-subtle-bg);
overflow-y: auto;
}
.emojis-tab {
padding: 12px 16px;
padding: var(--rte-picker-tab-padding-y) var(--rte-picker-tab-padding-x);
border: none;

@@ -190,6 +213,7 @@ background: none;

cursor: pointer;
font-size: 14px;
font-size: var(--rte-picker-tab-font-size);
color: var(--rte-emoji-muted-text);
border-bottom: 1px solid var(--rte-emoji-border);
transition: all 0.2s ease;
line-height: 1.25;
}

@@ -213,12 +237,13 @@

.emojis-grid {
padding: 16px;
padding: var(--rte-picker-grid-padding);
overflow-y: auto;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
gap: 8px;
grid-template-columns: repeat(auto-fill, minmax(var(--rte-picker-cell-size), 1fr));
gap: var(--rte-picker-grid-gap);
contain: content;
}
.emojis-item {
width: 40px;
height: 40px;
width: var(--rte-picker-cell-size);
height: var(--rte-picker-cell-size);
display: flex;

@@ -229,5 +254,5 @@ align-items: center;

background: var(--rte-emoji-subtle-bg);
border-radius: 8px;
border-radius: var(--rte-picker-cell-radius);
cursor: pointer;
font-size: 18px;
font-size: var(--rte-picker-cell-font-size);
transition: all 0.2s ease;

@@ -262,4 +287,4 @@ color: var(--rte-emoji-dialog-text);

.emojis-dialog {
width: 95%;
max-height: 90vh;
width: 96%;
max-height: var(--rte-picker-mobile-dialog-max-height);
}

@@ -283,16 +308,16 @@

white-space: nowrap;
min-width: 80px;
min-width: var(--rte-picker-mobile-tab-min-width);
}
.emojis-grid {
grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
gap: 6px;
grid-template-columns: repeat(auto-fill, minmax(var(--rte-picker-mobile-cell-size), 1fr));
gap: var(--rte-picker-mobile-grid-gap);
}
.emojis-item {
width: 36px;
height: 36px;
width: var(--rte-picker-mobile-cell-size);
height: var(--rte-picker-mobile-cell-size);
font-size: 16px;
}
}
`,document.head.appendChild(o)}exports.EmojisPlugin=h;
`,document.head.appendChild(t)}exports.EmojisPlugin=w;

@@ -1,2 +0,2 @@

const d = {
const p = {
all: {

@@ -543,3 +543,3 @@ name: "All",

}
}, p = {
}, x = {
"💙": "blue heart",

@@ -692,4 +692,4 @@ "💚": "green heart",

};
let c = null, n = "all", l = "", s = null;
const j = '[data-theme="dark"], .dark, .editora-theme-dark', k = () => ({
let g = null, s = "all", u = "", n = null, l = null, d = null;
const k = '[data-theme="dark"], .dark, .editora-theme-dark', A = () => ({
name: "emojis",

@@ -706,12 +706,12 @@ toolbar: [

commands: {
openEmojiDialog: (o, t) => {
const e = t?.contentElement || u();
return e ? (h(e), !0) : !1;
openEmojiDialog: (t, r) => {
const e = r?.contentElement || b();
return e ? (w(e), !0) : !1;
},
insertEmoji: (o, t) => {
if (!o) return !1;
const e = t?.contentElement || u();
insertEmoji: (t, r) => {
if (!t) return !1;
const e = r?.contentElement || b();
if (!e) return !1;
try {
return f(o, e), !0;
return v(t, e), !0;
} catch {

@@ -726,12 +726,12 @@ return !1;

});
function h(o) {
n = "all", l = "";
const t = window.getSelection();
s = null, t && t.rangeCount > 0 && o.contains(t.anchorNode) && (s = t.getRangeAt(0).cloneRange());
function w(t) {
m(), s = "all", u = "";
const r = window.getSelection();
l = null, r && r.rangeCount > 0 && t.contains(r.anchorNode) && (l = r.getRangeAt(0).cloneRange());
const e = document.createElement("div");
e.className = "emojis-overlay", w(o) && e.classList.add("rte-ui-theme-dark"), e.onclick = g;
const r = document.createElement("div");
r.className = "emojis-dialog", r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "true"), r.onclick = (a) => a.stopPropagation();
const i = Object.keys(d);
r.innerHTML = `
e.className = "emojis-overlay", z(t) && e.classList.add("rte-ui-theme-dark"), e.onclick = m;
const o = document.createElement("div");
o.className = "emojis-dialog", o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "true"), o.onclick = (a) => a.stopPropagation();
const i = Object.keys(p);
o.innerHTML = `
<div class="rte-dialog-header emojis-header">

@@ -744,4 +744,4 @@ <h3>Insert Emojis</h3>

${i.map((a) => `
<button class="emojis-tab ${a === n ? "active" : ""}" data-category="${a}">
${d[a].name}
<button class="emojis-tab ${a === s ? "active" : ""}" data-category="${a}">
${p[a].name}
</button>

@@ -764,76 +764,80 @@ `).join("")}

<div class="emojis-grid" id="emojis-grid">
${b(n, l)}
${j(s, u)}
</div>
</div>
</div>
`, e.appendChild(r), document.body.appendChild(e), c = e, x(r, o), y(), setTimeout(() => {
r.querySelector("#emoji-search-input")?.focus();
}, 100);
`, e.appendChild(o), document.body.appendChild(e), g = e, d = (a) => {
a.key === "Escape" && (a.preventDefault(), a.stopPropagation(), m());
}, document.addEventListener("keydown", d, !0), y(o, t), S(), requestAnimationFrame(() => {
o.querySelector("#emoji-search-input")?.focus();
});
}
function x(o, t) {
o.querySelector(".emojis-close")?.addEventListener("click", g), o.querySelectorAll(".emojis-tab").forEach((r) => {
r.addEventListener("click", (i) => {
const a = i.target.getAttribute("data-category");
a && v(o, a, t);
function y(t, r) {
t.querySelector(".emojis-close")?.addEventListener("click", m), t.querySelectorAll(".emojis-tab").forEach((i) => {
i.addEventListener("click", (a) => {
const c = a.target.getAttribute("data-category");
c && E(t, c);
});
}), o.querySelector("#emoji-search-input")?.addEventListener("input", (r) => {
l = r.target.value, m(o, t);
}), m(o, t);
}), t.querySelector("#emoji-search-input")?.addEventListener("input", (i) => {
u = i.target.value, n !== null && window.clearTimeout(n), n = window.setTimeout(() => {
n = null, h(t);
}, 90);
}), t.querySelector("#emojis-grid")?.addEventListener("click", (i) => {
const c = i.target.closest(".emojis-item");
if (!c) return;
const f = c.getAttribute("data-emoji") || c.textContent?.trim() || "";
f && (v(f, r), m());
});
}
function v(o, t, e) {
n = t, o.querySelectorAll(".emojis-tab").forEach((r) => {
r.classList.toggle("active", r.getAttribute("data-category") === t);
}), m(o, e);
function E(t, r) {
s = r, t.querySelectorAll(".emojis-tab").forEach((e) => {
e.classList.toggle("active", e.getAttribute("data-category") === r);
}), h(t);
}
function m(o, t) {
const e = o.querySelector("#emojis-grid");
e && (e.innerHTML = b(n, l), e.querySelectorAll(".emojis-item").forEach((r) => {
r.addEventListener("click", () => {
const i = r.textContent?.trim() || "";
i && (f(i, t), g());
});
}));
function h(t) {
const r = t.querySelector("#emojis-grid");
r && (r.innerHTML = j(s, u));
}
function b(o, t) {
let e = d[o].emojis;
return t.trim() && (e = e.filter((r) => r.toLowerCase().includes(t.toLowerCase()) ? !0 : (p[r] || "").toLowerCase().includes(t.toLowerCase()))), e.length === 0 && t.trim() ? `<div class="emojis-no-results">No emojis found for "${t}"</div>` : e.map((r, i) => `
function j(t, r) {
let e = p[t].emojis;
return r.trim() && (e = e.filter((o) => o.toLowerCase().includes(r.toLowerCase()) ? !0 : (x[o] || "").toLowerCase().includes(r.toLowerCase()))), e.length === 0 && r.trim() ? `<div class="emojis-no-results">No emojis found for "${r}"</div>` : e.map((o, i) => `
<button
class="emojis-item"
title="Insert ${r}"
data-emoji="${r}"
title="Insert ${o}"
data-emoji="${o}"
>
${r}
${o}
</button>
`).join("");
}
function g() {
c && (document.body.removeChild(c), c = null);
function m() {
d && (document.removeEventListener("keydown", d, !0), d = null), n !== null && (window.clearTimeout(n), n = null), g && (g.remove(), g = null);
}
function f(o, t) {
t.focus();
function v(t, r) {
r.focus();
let e = window.getSelection();
if (s && (e?.removeAllRanges(), e?.addRange(s), s = null), e = window.getSelection(), e && e.rangeCount > 0) {
const r = e.getRangeAt(0);
r.deleteContents();
const i = document.createTextNode(o);
r.insertNode(i), r.setStartAfter(i), r.setEndAfter(i), e.removeAllRanges(), e.addRange(r);
if (l && (e?.removeAllRanges(), e?.addRange(l), l = null), e = window.getSelection(), e && e.rangeCount > 0) {
const o = e.getRangeAt(0);
o.deleteContents();
const i = document.createTextNode(t);
o.insertNode(i), o.setStartAfter(i), o.setEndAfter(i), e.removeAllRanges(), e.addRange(o);
}
}
function u() {
const o = window.getSelection();
if (o && o.rangeCount > 0) {
const e = o.anchorNode, i = (e instanceof HTMLElement ? e : e?.parentElement)?.closest(".editora-content, .rte-content");
function b() {
const t = window.getSelection();
if (t && t.rangeCount > 0) {
const e = t.anchorNode, i = (e instanceof HTMLElement ? e : e?.parentElement)?.closest(".editora-content, .rte-content");
if (i) return i;
}
const t = document.activeElement;
return t && (t.classList.contains("editora-content") || t.classList.contains("rte-content")) ? t : document.querySelector(".editora-content, .rte-content");
const r = document.activeElement;
return r && (r.classList.contains("editora-content") || r.classList.contains("rte-content")) ? r : document.querySelector(".editora-content, .rte-content");
}
function w(o) {
const t = o || u();
return t ? !!t.closest(j) : !1;
function z(t) {
const r = t || b();
return r ? !!r.closest(k) : !1;
}
function y() {
function S() {
if (document.getElementById("emojis-dialog-styles")) return;
const o = document.createElement("style");
o.id = "emojis-dialog-styles", o.textContent = `
const t = document.createElement("style");
t.id = "emojis-dialog-styles", t.textContent = `
.emojis-overlay {

@@ -850,2 +854,22 @@ --rte-emoji-overlay-bg: rgba(15, 23, 36, 0.56);

--rte-emoji-ring: rgba(31, 117, 254, 0.18);
--rte-picker-dialog-width: min(640px, 96vw);
--rte-picker-dialog-max-height: min(560px, 86vh);
--rte-picker-dialog-radius: 12px;
--rte-picker-search-wrap-padding: 12px;
--rte-picker-search-height: 38px;
--rte-picker-search-font-size: 13px;
--rte-picker-search-radius: 8px;
--rte-picker-tabs-width: 156px;
--rte-picker-tab-padding-y: 10px;
--rte-picker-tab-padding-x: 12px;
--rte-picker-tab-font-size: 13px;
--rte-picker-grid-padding: 12px;
--rte-picker-grid-gap: 6px;
--rte-picker-cell-size: 34px;
--rte-picker-cell-font-size: 17px;
--rte-picker-cell-radius: 7px;
--rte-picker-mobile-tab-min-width: 82px;
--rte-picker-mobile-cell-size: 32px;
--rte-picker-mobile-grid-gap: 5px;
--rte-picker-mobile-dialog-max-height: 88vh;
position: fixed;

@@ -861,3 +885,3 @@ top: 0;

justify-content: center;
z-index: 1000;
z-index: 10000;
padding: 16px;

@@ -884,7 +908,6 @@ box-sizing: border-box;

border: 1px solid var(--rte-emoji-border);
border-radius: 12px;
border-radius: var(--rte-picker-dialog-radius);
box-shadow: 0 24px 48px rgba(10, 15, 24, 0.28);
max-width: 800px;
width: 90%;
max-height: 80vh;
width: var(--rte-picker-dialog-width);
max-height: var(--rte-picker-dialog-max-height);
display: flex;

@@ -927,6 +950,7 @@ flex-direction: column;

overflow: hidden;
min-width: 0;
}
.emojis-search {
padding: 16px 16px 0 16px;
padding: var(--rte-picker-search-wrap-padding) var(--rte-picker-search-wrap-padding) 0 var(--rte-picker-search-wrap-padding);
position: relative;

@@ -937,4 +961,4 @@ }

position: absolute;
left: 28px;
top: 27px;
left: 24px;
top: 22px;
color: var(--rte-emoji-muted-text);

@@ -946,10 +970,12 @@ pointer-events: none;

.emojis-search-input {
width: calc(100% - 24px);
padding: 10px 12px 10px 40px;
width: 100%;
height: var(--rte-picker-search-height);
padding: 8px 12px 8px 36px;
border: 1px solid var(--rte-emoji-border);
border-radius: 8px;
font-size: 14px;
border-radius: var(--rte-picker-search-radius);
font-size: var(--rte-picker-search-font-size);
color: var(--rte-emoji-dialog-text);
background-color: var(--rte-emoji-subtle-bg);
transition: border-color 0.2s ease, box-shadow 0.2s ease;
box-sizing: border-box;
}

@@ -974,9 +1000,10 @@

flex-direction: column;
width: 180px;
width: var(--rte-picker-tabs-width);
border-right: 1px solid var(--rte-emoji-border);
background-color: var(--rte-emoji-subtle-bg);
overflow-y: auto;
}
.emojis-tab {
padding: 12px 16px;
padding: var(--rte-picker-tab-padding-y) var(--rte-picker-tab-padding-x);
border: none;

@@ -986,6 +1013,7 @@ background: none;

cursor: pointer;
font-size: 14px;
font-size: var(--rte-picker-tab-font-size);
color: var(--rte-emoji-muted-text);
border-bottom: 1px solid var(--rte-emoji-border);
transition: all 0.2s ease;
line-height: 1.25;
}

@@ -1009,12 +1037,13 @@

.emojis-grid {
padding: 16px;
padding: var(--rte-picker-grid-padding);
overflow-y: auto;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
gap: 8px;
grid-template-columns: repeat(auto-fill, minmax(var(--rte-picker-cell-size), 1fr));
gap: var(--rte-picker-grid-gap);
contain: content;
}
.emojis-item {
width: 40px;
height: 40px;
width: var(--rte-picker-cell-size);
height: var(--rte-picker-cell-size);
display: flex;

@@ -1025,5 +1054,5 @@ align-items: center;

background: var(--rte-emoji-subtle-bg);
border-radius: 8px;
border-radius: var(--rte-picker-cell-radius);
cursor: pointer;
font-size: 18px;
font-size: var(--rte-picker-cell-font-size);
transition: all 0.2s ease;

@@ -1058,4 +1087,4 @@ color: var(--rte-emoji-dialog-text);

.emojis-dialog {
width: 95%;
max-height: 90vh;
width: 96%;
max-height: var(--rte-picker-mobile-dialog-max-height);
}

@@ -1079,20 +1108,20 @@

white-space: nowrap;
min-width: 80px;
min-width: var(--rte-picker-mobile-tab-min-width);
}
.emojis-grid {
grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
gap: 6px;
grid-template-columns: repeat(auto-fill, minmax(var(--rte-picker-mobile-cell-size), 1fr));
gap: var(--rte-picker-mobile-grid-gap);
}
.emojis-item {
width: 36px;
height: 36px;
width: var(--rte-picker-mobile-cell-size);
height: var(--rte-picker-mobile-cell-size);
font-size: 16px;
}
}
`, document.head.appendChild(o);
`, document.head.appendChild(t);
}
export {
k as EmojisPlugin
A as EmojisPlugin
};

@@ -1,1 +0,1 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./heading.cjs.js"),l=require("./bold.cjs.js"),t=require("./italic.cjs.js"),u=require("./underline.cjs.js"),g=require("./strikethrough.cjs.js"),o=require("./list.cjs.js"),a=require("./checklist.cjs.js"),c=require("./history.cjs.js"),P=require("./link.cjs.js"),s=require("./blockquote.cjs.js"),q=require("./clear-formatting.cjs.js"),d=require("./code.cjs.js"),m=require("./table.cjs.js"),C=require("./font-size.cjs.js"),h=require("./font-family.cjs.js"),p=require("./text-alignment.cjs.js"),M=require("./text-color.cjs.js"),k=require("./background-color.cjs.js"),f=require("./line-height.cjs.js"),b=require("./indent.cjs.js"),A=require("./direction.cjs.js"),F=require("./capitalization.cjs.js"),S=require("./math.cjs.js"),T=require("./special-characters.cjs.js"),y=require("./emojis.cjs.js"),B=require("./embed-iframe.cjs.js"),H=require("./anchor.cjs.js"),i=require("./media-manager.cjs.js"),n=require("./index-D3pJyAsj.js"),D=require("./preview.cjs.js"),I=require("./fullscreen.cjs.js"),x=require("./print.cjs.js"),z=require("./page-break.cjs.js"),G=require("./footnote.cjs.js"),L=require("./code-sample.cjs.js"),v=require("./merge-tag.cjs.js"),j=require("./template.cjs.js"),E=require("./comments.cjs.js"),U=require("./spell-check.cjs.js"),w=require("./a11y-checker.cjs.js"),e=require("./shared-config.cjs.js");exports.HeadingPlugin=r.HeadingPlugin;exports.BoldPlugin=l.BoldPlugin;exports.ItalicPlugin=t.ItalicPlugin;exports.UnderlinePlugin=u.UnderlinePlugin;exports.StrikethroughPlugin=g.StrikethroughPlugin;exports.ListPlugin=o.ListPlugin;exports.ChecklistPlugin=a.ChecklistPlugin;exports.HistoryPlugin=c.HistoryPlugin;exports.LinkPlugin=P.LinkPlugin;exports.BlockquotePlugin=s.BlockquotePlugin;exports.ClearFormattingPlugin=q.ClearFormattingPlugin;exports.CodePlugin=d.CodePlugin;exports.TablePlugin=m.TablePlugin;exports.FontSizePlugin=C.FontSizePlugin;exports.FontFamilyPlugin=h.FontFamilyPlugin;exports.TextAlignmentPlugin=p.TextAlignmentPlugin;exports.TextColorPlugin=M.TextColorPlugin;exports.BackgroundColorPlugin=k.BackgroundColorPlugin;exports.LineHeightPlugin=f.LineHeightPlugin;exports.IndentPlugin=b.IndentPlugin;exports.DirectionPlugin=A.DirectionPlugin;exports.CapitalizationPlugin=F.CapitalizationPlugin;exports.MathPlugin=S.MathPlugin;exports.SpecialCharactersPlugin=T.SpecialCharactersPlugin;exports.EmojisPlugin=y.EmojisPlugin;exports.EmbedIframePlugin=B.EmbedIframePlugin;exports.AnchorPlugin=H.AnchorPlugin;exports.MediaManagerPlugin=i.MediaManagerPlugin;exports.getMediaManagerConfig=i.getMediaManagerConfig;exports.setMediaManagerConfig=i.setMediaManagerConfig;exports.DocumentManagerPlugin=n.DocumentManagerPlugin;exports.getDocumentManagerConfig=n.getDocumentManagerConfig;exports.setDocumentManagerConfig=n.setDocumentManagerConfig;exports.PreviewPlugin=D.PreviewPlugin;exports.FullscreenPlugin=I.FullscreenPlugin;exports.PrintPlugin=x.PrintPlugin;exports.PageBreakPlugin=z.PageBreakPlugin;exports.FootnotePlugin=G.FootnotePlugin;exports.CodeSamplePlugin=L.CodeSamplePlugin;exports.MergeTagPlugin=v.MergeTagPlugin;exports.TemplatePlugin=j.TemplatePlugin;exports.CommentsPlugin=E.CommentsPlugin;exports.SpellCheckPlugin=U.SpellCheckPlugin;exports.A11yCheckerPlugin=w.A11yCheckerPlugin;exports.buildApiUrl=e.buildApiUrl;exports.getGlobalApiConfig=e.getGlobalApiConfig;exports.getGlobalApiHeaders=e.getGlobalApiHeaders;exports.setGlobalApiConfig=e.setGlobalApiConfig;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("./heading.cjs.js"),r=require("./bold.cjs.js"),g=require("./italic.cjs.js"),u=require("./underline.cjs.js"),o=require("./strikethrough.cjs.js"),a=require("./list.cjs.js"),s=require("./checklist.cjs.js"),c=require("./history.cjs.js"),P=require("./link.cjs.js"),m=require("./blockquote.cjs.js"),d=require("./clear-formatting.cjs.js"),C=require("./code.cjs.js"),q=require("./table.cjs.js"),p=require("./font-size.cjs.js"),h=require("./font-family.cjs.js"),T=require("./text-alignment.cjs.js"),M=require("./text-color.cjs.js"),k=require("./background-color.cjs.js"),f=require("./line-height.cjs.js"),b=require("./indent.cjs.js"),A=require("./direction.cjs.js"),F=require("./capitalization.cjs.js"),S=require("./math.cjs.js"),y=require("./special-characters.cjs.js"),E=require("./emojis.cjs.js"),D=require("./embed-iframe.cjs.js"),B=require("./anchor.cjs.js"),n=require("./media-manager.cjs.js"),l=require("./index-tqLTHcO6.js"),H=require("./preview.cjs.js"),I=require("./fullscreen.cjs.js"),z=require("./print.cjs.js"),L=require("./page-break.cjs.js"),v=require("./footnote.cjs.js"),x=require("./code-sample.cjs.js"),G=require("./merge-tag.cjs.js"),e=require("./template.cjs.js"),j=require("./comments.cjs.js"),U=require("./spell-check.cjs.js"),_=require("./a11y-checker.cjs.js"),i=require("./shared-config.cjs.js");exports.HeadingPlugin=t.HeadingPlugin;exports.BoldPlugin=r.BoldPlugin;exports.ItalicPlugin=g.ItalicPlugin;exports.UnderlinePlugin=u.UnderlinePlugin;exports.StrikethroughPlugin=o.StrikethroughPlugin;exports.ListPlugin=a.ListPlugin;exports.ChecklistPlugin=s.ChecklistPlugin;exports.HistoryPlugin=c.HistoryPlugin;exports.LinkPlugin=P.LinkPlugin;exports.BlockquotePlugin=m.BlockquotePlugin;exports.ClearFormattingPlugin=d.ClearFormattingPlugin;exports.CodePlugin=C.CodePlugin;exports.TablePlugin=q.TablePlugin;exports.FontSizePlugin=p.FontSizePlugin;exports.FontFamilyPlugin=h.FontFamilyPlugin;exports.TextAlignmentPlugin=T.TextAlignmentPlugin;exports.TextColorPlugin=M.TextColorPlugin;exports.BackgroundColorPlugin=k.BackgroundColorPlugin;exports.LineHeightPlugin=f.LineHeightPlugin;exports.IndentPlugin=b.IndentPlugin;exports.DirectionPlugin=A.DirectionPlugin;exports.CapitalizationPlugin=F.CapitalizationPlugin;exports.MathPlugin=S.MathPlugin;exports.SpecialCharactersPlugin=y.SpecialCharactersPlugin;exports.EmojisPlugin=E.EmojisPlugin;exports.EmbedIframePlugin=D.EmbedIframePlugin;exports.AnchorPlugin=B.AnchorPlugin;exports.MediaManagerPlugin=n.MediaManagerPlugin;exports.getMediaManagerConfig=n.getMediaManagerConfig;exports.setMediaManagerConfig=n.setMediaManagerConfig;exports.DocumentManagerPlugin=l.DocumentManagerPlugin;exports.getDocumentManagerConfig=l.getDocumentManagerConfig;exports.setDocumentManagerConfig=l.setDocumentManagerConfig;exports.PreviewPlugin=H.PreviewPlugin;exports.FullscreenPlugin=I.FullscreenPlugin;exports.PrintPlugin=z.PrintPlugin;exports.PageBreakPlugin=L.PageBreakPlugin;exports.FootnotePlugin=v.FootnotePlugin;exports.CodeSamplePlugin=x.CodeSamplePlugin;exports.MergeTagPlugin=G.MergeTagPlugin;exports.PREDEFINED_TEMPLATES=e.PREDEFINED_TEMPLATES;exports.TemplatePlugin=e.TemplatePlugin;exports.addCustomTemplate=e.addCustomTemplate;exports.getAllTemplates=e.getAllTemplates;exports.getTemplateCategories=e.getTemplateCategories;exports.getTemplatesByCategory=e.getTemplatesByCategory;exports.sanitizeTemplate=e.sanitizeTemplate;exports.searchTemplates=e.searchTemplates;exports.validateTemplate=e.validateTemplate;exports.CommentsPlugin=j.CommentsPlugin;exports.SpellCheckPlugin=U.SpellCheckPlugin;exports.A11yCheckerPlugin=_.A11yCheckerPlugin;exports.buildApiUrl=i.buildApiUrl;exports.getGlobalApiConfig=i.getGlobalApiConfig;exports.getGlobalApiHeaders=i.getGlobalApiHeaders;exports.setGlobalApiConfig=i.setGlobalApiConfig;

@@ -1,91 +0,99 @@

import { HeadingPlugin as e } from "./heading.esm.js";
import { BoldPlugin as t } from "./bold.esm.js";
import { ItalicPlugin as l } from "./italic.esm.js";
import { HeadingPlugin as r } from "./heading.esm.js";
import { BoldPlugin as i } from "./bold.esm.js";
import { ItalicPlugin as n } from "./italic.esm.js";
import { UnderlinePlugin as m } from "./underline.esm.js";
import { StrikethroughPlugin as f } from "./strikethrough.esm.js";
import { ListPlugin as x } from "./list.esm.js";
import { ChecklistPlugin as a } from "./checklist.esm.js";
import { HistoryPlugin as s } from "./history.esm.js";
import { LinkPlugin as d } from "./link.esm.js";
import { BlockquotePlugin as h } from "./blockquote.esm.js";
import { StrikethroughPlugin as a } from "./strikethrough.esm.js";
import { ListPlugin as f } from "./list.esm.js";
import { ChecklistPlugin as x } from "./checklist.esm.js";
import { HistoryPlugin as C } from "./history.esm.js";
import { LinkPlugin as c } from "./link.esm.js";
import { BlockquotePlugin as M } from "./blockquote.esm.js";
import { ClearFormattingPlugin as A } from "./clear-formatting.esm.js";
import { CodePlugin as F } from "./code.esm.js";
import { TablePlugin as S } from "./table.esm.js";
import { FontSizePlugin as B } from "./font-size.esm.js";
import { FontFamilyPlugin as y } from "./font-family.esm.js";
import { CodePlugin as D } from "./code.esm.js";
import { TablePlugin as F } from "./table.esm.js";
import { FontSizePlugin as S } from "./font-size.esm.js";
import { FontFamilyPlugin as B } from "./font-family.esm.js";
import { TextAlignmentPlugin as I } from "./text-alignment.esm.js";
import { TextColorPlugin as z } from "./text-color.esm.js";
import { BackgroundColorPlugin as U } from "./background-color.esm.js";
import { LineHeightPlugin as q } from "./line-height.esm.js";
import { BackgroundColorPlugin as v } from "./background-color.esm.js";
import { LineHeightPlugin as j } from "./line-height.esm.js";
import { IndentPlugin as w } from "./indent.esm.js";
import { DirectionPlugin as K } from "./direction.esm.js";
import { CapitalizationPlugin as O } from "./capitalization.esm.js";
import { MathPlugin as R } from "./math.esm.js";
import { SpecialCharactersPlugin as W } from "./special-characters.esm.js";
import { EmojisPlugin as Y } from "./emojis.esm.js";
import { EmbedIframePlugin as _ } from "./embed-iframe.esm.js";
import { AnchorPlugin as oo } from "./anchor.esm.js";
import { MediaManagerPlugin as eo, getMediaManagerConfig as io, setMediaManagerConfig as to } from "./media-manager.esm.js";
import { D as lo, g as go, s as mo } from "./index-Bskk414V.mjs";
import { PreviewPlugin as fo } from "./preview.esm.js";
import { FullscreenPlugin as xo } from "./fullscreen.esm.js";
import { PrintPlugin as ao } from "./print.esm.js";
import { PageBreakPlugin as so } from "./page-break.esm.js";
import { FootnotePlugin as Mo } from "./footnote.esm.js";
import { CodeSamplePlugin as ko } from "./code-sample.esm.js";
import { MergeTagPlugin as bo } from "./merge-tag.esm.js";
import { TemplatePlugin as Do } from "./template.esm.js";
import { CommentsPlugin as To } from "./comments.esm.js";
import { SpellCheckPlugin as Ho } from "./spell-check.esm.js";
import { A11yCheckerPlugin as Go } from "./a11y-checker.esm.js";
import { buildApiUrl as Lo, getGlobalApiConfig as zo, getGlobalApiHeaders as Eo, setGlobalApiConfig as Uo } from "./shared-config.esm.js";
import { DirectionPlugin as R } from "./direction.esm.js";
import { CapitalizationPlugin as J } from "./capitalization.esm.js";
import { MathPlugin as O } from "./math.esm.js";
import { SpecialCharactersPlugin as V } from "./special-characters.esm.js";
import { EmojisPlugin as X } from "./emojis.esm.js";
import { EmbedIframePlugin as Z } from "./embed-iframe.esm.js";
import { AnchorPlugin as ee } from "./anchor.esm.js";
import { MediaManagerPlugin as re, getMediaManagerConfig as te, setMediaManagerConfig as ie } from "./media-manager.esm.js";
import { D as ne, g as ge, s as me } from "./index-BFsKNTTj.mjs";
import { PreviewPlugin as ae } from "./preview.esm.js";
import { FullscreenPlugin as fe } from "./fullscreen.esm.js";
import { PrintPlugin as xe } from "./print.esm.js";
import { PageBreakPlugin as Ce } from "./page-break.esm.js";
import { FootnotePlugin as ce } from "./footnote.esm.js";
import { CodeSamplePlugin as Me } from "./code-sample.esm.js";
import { MergeTagPlugin as Ae } from "./merge-tag.esm.js";
import { PREDEFINED_TEMPLATES as De, TemplatePlugin as Ee, addCustomTemplate as Fe, getAllTemplates as be, getTemplateCategories as Se, getTemplatesByCategory as ye, sanitizeTemplate as Be, searchTemplates as He, validateTemplate as Ie } from "./template.esm.js";
import { CommentsPlugin as ze } from "./comments.esm.js";
import { SpellCheckPlugin as ve } from "./spell-check.esm.js";
import { A11yCheckerPlugin as je } from "./a11y-checker.esm.js";
import { buildApiUrl as we, getGlobalApiConfig as Ne, getGlobalApiHeaders as Re, setGlobalApiConfig as _e } from "./shared-config.esm.js";
export {
Go as A11yCheckerPlugin,
oo as AnchorPlugin,
U as BackgroundColorPlugin,
h as BlockquotePlugin,
t as BoldPlugin,
O as CapitalizationPlugin,
a as ChecklistPlugin,
je as A11yCheckerPlugin,
ee as AnchorPlugin,
v as BackgroundColorPlugin,
M as BlockquotePlugin,
i as BoldPlugin,
J as CapitalizationPlugin,
x as ChecklistPlugin,
A as ClearFormattingPlugin,
F as CodePlugin,
ko as CodeSamplePlugin,
To as CommentsPlugin,
K as DirectionPlugin,
lo as DocumentManagerPlugin,
_ as EmbedIframePlugin,
Y as EmojisPlugin,
y as FontFamilyPlugin,
B as FontSizePlugin,
Mo as FootnotePlugin,
xo as FullscreenPlugin,
e as HeadingPlugin,
s as HistoryPlugin,
D as CodePlugin,
Me as CodeSamplePlugin,
ze as CommentsPlugin,
R as DirectionPlugin,
ne as DocumentManagerPlugin,
Z as EmbedIframePlugin,
X as EmojisPlugin,
B as FontFamilyPlugin,
S as FontSizePlugin,
ce as FootnotePlugin,
fe as FullscreenPlugin,
r as HeadingPlugin,
C as HistoryPlugin,
w as IndentPlugin,
l as ItalicPlugin,
q as LineHeightPlugin,
d as LinkPlugin,
x as ListPlugin,
R as MathPlugin,
eo as MediaManagerPlugin,
bo as MergeTagPlugin,
so as PageBreakPlugin,
fo as PreviewPlugin,
ao as PrintPlugin,
W as SpecialCharactersPlugin,
Ho as SpellCheckPlugin,
f as StrikethroughPlugin,
S as TablePlugin,
Do as TemplatePlugin,
n as ItalicPlugin,
j as LineHeightPlugin,
c as LinkPlugin,
f as ListPlugin,
O as MathPlugin,
re as MediaManagerPlugin,
Ae as MergeTagPlugin,
De as PREDEFINED_TEMPLATES,
Ce as PageBreakPlugin,
ae as PreviewPlugin,
xe as PrintPlugin,
V as SpecialCharactersPlugin,
ve as SpellCheckPlugin,
a as StrikethroughPlugin,
F as TablePlugin,
Ee as TemplatePlugin,
I as TextAlignmentPlugin,
z as TextColorPlugin,
m as UnderlinePlugin,
Lo as buildApiUrl,
go as getDocumentManagerConfig,
zo as getGlobalApiConfig,
Eo as getGlobalApiHeaders,
io as getMediaManagerConfig,
mo as setDocumentManagerConfig,
Uo as setGlobalApiConfig,
to as setMediaManagerConfig
Fe as addCustomTemplate,
we as buildApiUrl,
be as getAllTemplates,
ge as getDocumentManagerConfig,
Ne as getGlobalApiConfig,
Re as getGlobalApiHeaders,
te as getMediaManagerConfig,
Se as getTemplateCategories,
ye as getTemplatesByCategory,
Be as sanitizeTemplate,
He as searchTemplates,
me as setDocumentManagerConfig,
_e as setGlobalApiConfig,
ie as setMediaManagerConfig,
Ie as validateTemplate
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let a=null,u=!1,l=null;const c='[data-theme="dark"], .dark, .editora-theme-dark',L=e=>{if(!e)return null;let t=e;for(;t;){if(t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")==="true"||t.hasAttribute("data-editora-content"))return t;t=t.parentElement}return null},w=e=>{if(e){const n=e.startContainer;if((n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(c))return!0}return document.activeElement?.closest(c)?!0:document.body.matches(c)||document.documentElement.matches(c)},C=()=>{if(document.getElementById("rte-link-dialog-theme-styles"))return;const e=document.createElement("style");e.id="rte-link-dialog-theme-styles",e.textContent=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let a=null,u=!1,l=null;const p='[data-theme="dark"], .dark, .editora-theme-dark',w=e=>{if(!e)return null;let t=e;for(;t;){if(t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")==="true"||t.hasAttribute("data-editora-content"))return t;t=t.parentElement}return null},C=e=>{if(e){const n=e.startContainer;if((n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(p))return!0}return document.activeElement?.closest(p)?!0:document.body.matches(p)||document.documentElement.matches(p)},T=()=>{if(document.getElementById("rte-link-dialog-theme-styles"))return;const e=document.createElement("style");e.id="rte-link-dialog-theme-styles",e.textContent=`
.link-dialog-overlay.rte-theme-dark .link-dialog {

@@ -64,3 +64,3 @@ background: #1f2937 !important;

}
`,document.head.appendChild(e)},T=e=>{if(!a){console.warn("No selection range stored");return}const t=a.startContainer,n=t.nodeType===Node.TEXT_NODE?t.parentElement:t,o=L(n);if(o){if(u&&l){l.href=e.url,l.textContent=e.text,l.target=e.target,e.target==="_blank"?l.setAttribute("rel","noopener noreferrer"):l.removeAttribute("rel"),e.title?l.title=e.title:l.removeAttribute("title");const r=document.createRange();r.selectNodeContents(l);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(r))}else{const r=document.createElement("a");r.href=e.url,r.textContent=e.text,r.target=e.target,e.target==="_blank"&&r.setAttribute("rel","noopener noreferrer"),e.title&&(r.title=e.title),a.deleteContents(),a.insertNode(r),a.setStartAfter(r),a.setEndAfter(r);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(a))}o.focus(),a=null,u=!1,l=null}},b=(e,t)=>{C();const n=document.createElement("div");n.className="link-dialog-overlay",t&&n.classList.add("rte-theme-dark"),n.style.cssText=`
`,document.head.appendChild(e)},A=e=>{if(!a){console.warn("No selection range stored");return}const t=a.startContainer,n=t.nodeType===Node.TEXT_NODE?t.parentElement:t,o=w(n);if(o){if(u&&l){l.href=e.url,l.textContent=e.text,l.target=e.target,e.target==="_blank"?l.setAttribute("rel","noopener noreferrer"):l.removeAttribute("rel"),e.title?l.title=e.title:l.removeAttribute("title");const r=document.createRange();r.selectNodeContents(l);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(r))}else{const r=document.createElement("a");r.href=e.url,r.textContent=e.text,r.target=e.target,e.target==="_blank"&&r.setAttribute("rel","noopener noreferrer"),e.title&&(r.title=e.title),a.deleteContents(),a.insertNode(r),a.setStartAfter(r),a.setEndAfter(r);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(a))}o.focus(),a=null,u=!1,l=null}},k=(e,t)=>{T();const n=document.createElement("div");n.className="link-dialog-overlay",t&&n.classList.add("rte-theme-dark"),n.style.cssText=`
position: fixed;

@@ -96,3 +96,3 @@ top: 0;

placeholder="Enter link text"
style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
/>

@@ -108,3 +108,3 @@ </div>

required
style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
/>

@@ -119,3 +119,3 @@ </div>

placeholder="Link tooltip text"
style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
/>

@@ -142,2 +142,2 @@ </div>

</form>
`,n.appendChild(o),document.body.appendChild(n);const r=o.querySelector("#link-form"),i=o.querySelector("#link-text"),d=o.querySelector("#link-url"),x=o.querySelector("#link-title"),y=o.querySelector("#link-target"),v=o.querySelector(".link-dialog-close"),E=o.querySelector(".btn-cancel"),s=()=>{document.body.removeChild(n)};v.addEventListener("click",s),E.addEventListener("click",s),n.addEventListener("click",p=>{p.target===n&&s()}),r.addEventListener("submit",p=>{p.preventDefault();const m=d.value.trim();m&&(T({text:i.value.trim()||m,url:m,target:y.checked?"_blank":"_self",title:x.value.trim()||void 0}),s())}),setTimeout(()=>i.focus(),100)},f=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0).cloneRange();a=t;const n=w(t),o=e.toString()||"",r=t.startContainer,d=(r.nodeType===Node.TEXT_NODE?r.parentElement:r)?.closest("a");return d?(u=!0,l=d,b({text:d.textContent||"",url:d.href,target:d.target||"_self",title:d.title||"",isEditing:!0},n)):(u=!1,l=null,b({text:o,url:"",target:"_self",isEditing:!1},n)),!0},h=()=>(document.execCommand("unlink",!1),!0),g=(e,t)=>{typeof window<"u"&&window.registerEditorCommand?.(e,t)},k=()=>{g("openLinkDialog",f),g("removeLink",h),g("createLink",e=>{e&&document.execCommand("createLink",!1,e)})};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",k):k());const A=()=>({name:"link",marks:{link:{attrs:{href:{},title:{default:null},target:{default:null}},parseDOM:[{tag:"a[href]",getAttrs:e=>({href:e.getAttribute("href"),title:e.getAttribute("title"),target:e.getAttribute("target")})}],toDOM:e=>["a",{href:e.attrs.href,title:e.attrs.title,target:e.attrs.target,rel:e.attrs.target==="_blank"?"noopener noreferrer":null},0]}},toolbar:[{label:"Link",command:"openLinkDialog",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.2 12.3a1 1 0 0 1 1.4 1.4l-2 2a2 2 0 1 0 2.6 2.8l4.8-4.8a1 1 0 0 0 0-1.4 1 1 0 1 1 1.4-1.3 2.9 2.9 0 0 1 0 4L9.6 20a3.9 3.9 0 0 1-5.5-5.5l2-2Zm11.6-.6a1 1 0 0 1-1.4-1.4l2-2a2 2 0 1 0-2.6-2.8L11 10.3a1 1 0 0 0 0 1.4A1 1 0 1 1 9.6 13a2.9 2.9 0 0 1 0-4L14.4 4a3.9 3.9 0 0 1 5.5 5.5l-2 2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-k"}],commands:{openLinkDialog:f,removeLink:h},keymap:{"Mod-k":"openLinkDialog"}});exports.LinkPlugin=A;
`,n.appendChild(o),document.body.appendChild(n);const r=o.querySelector("#link-form"),i=o.querySelector("#link-text"),d=o.querySelector("#link-url"),y=o.querySelector("#link-title"),v=o.querySelector("#link-target"),E=o.querySelector(".link-dialog-close"),L=o.querySelector(".btn-cancel"),b=s=>{s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),c())},c=()=>{document.removeEventListener("keydown",b,!0),n.remove()};E.addEventListener("click",c),L.addEventListener("click",c),n.addEventListener("click",s=>{s.target===n&&c()}),document.addEventListener("keydown",b,!0),r.addEventListener("submit",s=>{s.preventDefault();const g=d.value.trim();g&&(A({text:i.value.trim()||g,url:g,target:v.checked?"_blank":"_self",title:y.value.trim()||void 0}),c())}),setTimeout(()=>i.focus(),100)},x=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0).cloneRange();a=t;const n=C(t),o=e.toString()||"",r=t.startContainer,d=(r.nodeType===Node.TEXT_NODE?r.parentElement:r)?.closest("a");return d?(u=!0,l=d,k({text:d.textContent||"",url:d.href,target:d.target||"_self",title:d.title||"",isEditing:!0},n)):(u=!1,l=null,k({text:o,url:"",target:"_self",isEditing:!1},n)),!0},h=()=>(document.execCommand("unlink",!1),!0),m=(e,t)=>{typeof window<"u"&&window.registerEditorCommand?.(e,t)},f=()=>{m("openLinkDialog",x),m("removeLink",h),m("createLink",e=>{e&&document.execCommand("createLink",!1,e)})};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",f):f());const S=()=>({name:"link",marks:{link:{attrs:{href:{},title:{default:null},target:{default:null}},parseDOM:[{tag:"a[href]",getAttrs:e=>({href:e.getAttribute("href"),title:e.getAttribute("title"),target:e.getAttribute("target")})}],toDOM:e=>["a",{href:e.attrs.href,title:e.attrs.title,target:e.attrs.target,rel:e.attrs.target==="_blank"?"noopener noreferrer":null},0]}},toolbar:[{label:"Link",command:"openLinkDialog",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.2 12.3a1 1 0 0 1 1.4 1.4l-2 2a2 2 0 1 0 2.6 2.8l4.8-4.8a1 1 0 0 0 0-1.4 1 1 0 1 1 1.4-1.3 2.9 2.9 0 0 1 0 4L9.6 20a3.9 3.9 0 0 1-5.5-5.5l2-2Zm11.6-.6a1 1 0 0 1-1.4-1.4l2-2a2 2 0 1 0-2.6-2.8L11 10.3a1 1 0 0 0 0 1.4A1 1 0 1 1 9.6 13a2.9 2.9 0 0 1 0-4L14.4 4a3.9 3.9 0 0 1 5.5 5.5l-2 2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-k"}],commands:{openLinkDialog:x,removeLink:h},keymap:{"Mod-k":"openLinkDialog"}});exports.LinkPlugin=S;

@@ -1,3 +0,3 @@

let a = null, p = !1, l = null;
const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
let a = null, u = !1, l = null;
const p = '[data-theme="dark"], .dark, .editora-theme-dark', w = (e) => {
if (!e) return null;

@@ -11,9 +11,9 @@ let t = e;

return null;
}, w = (e) => {
}, C = (e) => {
if (e) {
const n = e.startContainer;
if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(c)) return !0;
if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(p)) return !0;
}
return document.activeElement?.closest(c) ? !0 : document.body.matches(c) || document.documentElement.matches(c);
}, C = () => {
return document.activeElement?.closest(p) ? !0 : document.body.matches(p) || document.documentElement.matches(p);
}, T = () => {
if (document.getElementById("rte-link-dialog-theme-styles")) return;

@@ -85,3 +85,3 @@ const e = document.createElement("style");

`, document.head.appendChild(e);
}, T = (e) => {
}, A = (e) => {
if (!a) {

@@ -91,5 +91,5 @@ console.warn("No selection range stored");

}
const t = a.startContainer, n = t.nodeType === Node.TEXT_NODE ? t.parentElement : t, o = L(n);
const t = a.startContainer, n = t.nodeType === Node.TEXT_NODE ? t.parentElement : t, o = w(n);
if (o) {
if (p && l) {
if (u && l) {
l.href = e.url, l.textContent = e.text, l.target = e.target, e.target === "_blank" ? l.setAttribute("rel", "noopener noreferrer") : l.removeAttribute("rel"), e.title ? l.title = e.title : l.removeAttribute("title");

@@ -106,6 +106,6 @@ const r = document.createRange();

}
o.focus(), a = null, p = !1, l = null;
o.focus(), a = null, u = !1, l = null;
}
}, b = (e, t) => {
C();
}, k = (e, t) => {
T();
const n = document.createElement("div");

@@ -145,3 +145,3 @@ n.className = "link-dialog-overlay", t && n.classList.add("rte-theme-dark"), n.style.cssText = `

placeholder="Enter link text"
style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
/>

@@ -157,3 +157,3 @@ </div>

required
style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
/>

@@ -168,3 +168,3 @@ </div>

placeholder="Link tooltip text"
style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
/>

@@ -192,18 +192,20 @@ </div>

`, n.appendChild(o), document.body.appendChild(n);
const r = o.querySelector("#link-form"), i = o.querySelector("#link-text"), d = o.querySelector("#link-url"), x = o.querySelector("#link-title"), y = o.querySelector("#link-target"), v = o.querySelector(".link-dialog-close"), E = o.querySelector(".btn-cancel"), s = () => {
document.body.removeChild(n);
const r = o.querySelector("#link-form"), i = o.querySelector("#link-text"), d = o.querySelector("#link-url"), y = o.querySelector("#link-title"), v = o.querySelector("#link-target"), E = o.querySelector(".link-dialog-close"), L = o.querySelector(".btn-cancel"), b = (s) => {
s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), c());
}, c = () => {
document.removeEventListener("keydown", b, !0), n.remove();
};
v.addEventListener("click", s), E.addEventListener("click", s), n.addEventListener("click", (u) => {
u.target === n && s();
}), r.addEventListener("submit", (u) => {
u.preventDefault();
const m = d.value.trim();
m && (T({
text: i.value.trim() || m,
url: m,
target: y.checked ? "_blank" : "_self",
title: x.value.trim() || void 0
}), s());
E.addEventListener("click", c), L.addEventListener("click", c), n.addEventListener("click", (s) => {
s.target === n && c();
}), document.addEventListener("keydown", b, !0), r.addEventListener("submit", (s) => {
s.preventDefault();
const g = d.value.trim();
g && (A({
text: i.value.trim() || g,
url: g,
target: v.checked ? "_blank" : "_self",
title: y.value.trim() || void 0
}), c());
}), setTimeout(() => i.focus(), 100);
}, f = () => {
}, x = () => {
const e = window.getSelection();

@@ -213,4 +215,4 @@ if (!e || e.rangeCount === 0) return !1;

a = t;
const n = w(t), o = e.toString() || "", r = t.startContainer, d = (r.nodeType === Node.TEXT_NODE ? r.parentElement : r)?.closest("a");
return d ? (p = !0, l = d, b({
const n = C(t), o = e.toString() || "", r = t.startContainer, d = (r.nodeType === Node.TEXT_NODE ? r.parentElement : r)?.closest("a");
return d ? (u = !0, l = d, k({
text: d.textContent || "",

@@ -221,3 +223,3 @@ url: d.href,

isEditing: !0
}, n)) : (p = !1, l = null, b({
}, n)) : (u = !1, l = null, k({
text: o,

@@ -228,11 +230,11 @@ url: "",

}, n)), !0;
}, h = () => (document.execCommand("unlink", !1), !0), g = (e, t) => {
}, h = () => (document.execCommand("unlink", !1), !0), m = (e, t) => {
typeof window < "u" && window.registerEditorCommand?.(e, t);
}, k = () => {
g("openLinkDialog", f), g("removeLink", h), g("createLink", (e) => {
}, f = () => {
m("openLinkDialog", x), m("removeLink", h), m("createLink", (e) => {
e && document.execCommand("createLink", !1, e);
});
};
typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", k) : k());
const A = () => ({
typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", f) : f());
const S = () => ({
name: "link",

@@ -278,3 +280,3 @@ marks: {

commands: {
openLinkDialog: f,
openLinkDialog: x,
removeLink: h

@@ -287,3 +289,3 @@ },

export {
A as LinkPlugin
S as LinkPlugin
};

@@ -1,5 +0,5 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C={latex:[{name:"Fraction",formula:"\\frac{a}{b}",description:"Simple fraction"},{name:"Square Root",formula:"\\sqrt{x}",description:"Square root"},{name:"Power",formula:"x^{2}",description:"Exponent/power"},{name:"Subscript",formula:"x_{sub}",description:"Subscript"},{name:"Integral",formula:"\\int_{a}^{b} f(x) \\, dx",description:"Definite integral"},{name:"Summation",formula:"\\sum_{i=1}^{n} x_{i}",description:"Summation"},{name:"Limit",formula:"\\lim_{x \\to 0} f(x)",description:"Limit"},{name:"Derivative",formula:"\\frac{d}{dx} f(x)",description:"Derivative"},{name:"Matrix 2x2",formula:"\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}",description:"2x2 matrix"},{name:"System",formula:"\\begin{cases} x + y = 1 \\\\ 2x - y = 0 \\end{cases}",description:"System of equations"}],mathml:[{name:"Fraction",formula:"<mfrac><mi>a</mi><mi>b</mi></mfrac>",description:"Simple fraction"},{name:"Square Root",formula:"<msqrt><mi>x</mi></msqrt>",description:"Square root"},{name:"Power",formula:"<msup><mi>x</mi><mn>2</mn></msup>",description:"Exponent/power"},{name:"Subscript",formula:"<msub><mi>x</mi><mi>sub</mi></msub>",description:"Subscript"},{name:"Parentheses",formula:'<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>',description:"Grouped expression"}]};let h=null,w=null,E=!1;const y='[data-theme="dark"], .dark, .editora-theme-dark',q=()=>new Promise((a,s)=>{if(window.katex){a(window.katex);return}if(E){const i=setInterval(()=>{window.katex&&(clearInterval(i),a(window.katex))},100);return}E=!0;const o=document.createElement("link");o.rel="stylesheet",o.href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css",document.head.appendChild(o);const e=document.createElement("script");e.src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js",e.onload=()=>a(window.katex),e.onerror=s,document.head.appendChild(e)}),H=()=>{const a=window.getSelection();if(a&&a.rangeCount>0){const o=a.getRangeAt(0).startContainer;if((o.nodeType===Node.ELEMENT_NODE?o:o.parentElement)?.closest(y))return!0}return document.activeElement?.closest(y)?!0:document.body.matches(y)||document.documentElement.matches(y)},T=async a=>{const s=window.getSelection();s&&s.rangeCount>0&&(h=s.getRangeAt(0).cloneRange()),await q();const o=H(),e=o?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",border:"#3b4657",panelBg:"#222d3a",fieldBg:"#111827",fieldBorder:"#4b5563",text:"#e2e8f0",muted:"#94a3b8",templateBtnBg:"#273244",templateBtnHover:"#334155",templateBtnText:"#dbe7f7",templateSubText:"#9fb0c6",previewBg:"#111827",previewText:"#cbd5e1",cancelBg:"#334155",cancelText:"#e2e8f0",cancelBorder:"#4b5563",insertBg:"#3b82f6",insertHover:"#2563eb",invalid:"#f87171"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",border:"#e1e5e9",panelBg:"#f8f9fa",fieldBg:"#ffffff",fieldBorder:"#ced4da",text:"#1f2937",muted:"#6c757d",templateBtnBg:"#ffffff",templateBtnHover:"#f8f9fa",templateBtnText:"#1f2937",templateSubText:"#6c757d",previewBg:"#f8f9fa",previewText:"#6c757d",cancelBg:"#ffffff",cancelText:"#1f2937",cancelBorder:"#ced4da",insertBg:"#007bff",insertHover:"#0069d9",invalid:"#cc0000"},i=document.createElement("div");i.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: 99999;`;const l=document.createElement("div");l.style.cssText=`background: ${e.dialogBg}; border: 1px solid ${e.border}; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); color: ${e.text};`;let d=a?.format||"latex",u=a?.formula||"",M=a?.inline!==!1;l.innerHTML=`
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${e.border}; background: ${e.panelBg};">
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};">${a?"Edit":"Insert"} Math Formula</h2>
<button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${e.muted}; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const F={latex:[{name:"Fraction",formula:"\\frac{a}{b}",description:"Simple fraction"},{name:"Square Root",formula:"\\sqrt{x}",description:"Square root"},{name:"Power",formula:"x^{2}",description:"Exponent/power"},{name:"Subscript",formula:"x_{sub}",description:"Subscript"},{name:"Integral",formula:"\\int_{a}^{b} f(x) \\, dx",description:"Definite integral"},{name:"Summation",formula:"\\sum_{i=1}^{n} x_{i}",description:"Summation"},{name:"Limit",formula:"\\lim_{x \\to 0} f(x)",description:"Limit"},{name:"Derivative",formula:"\\frac{d}{dx} f(x)",description:"Derivative"},{name:"Matrix 2x2",formula:"\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}",description:"2x2 matrix"},{name:"System",formula:"\\begin{cases} x + y = 1 \\\\ 2x - y = 0 \\end{cases}",description:"System of equations"}],mathml:[{name:"Fraction",formula:"<mfrac><mi>a</mi><mi>b</mi></mfrac>",description:"Simple fraction"},{name:"Square Root",formula:"<msqrt><mi>x</mi></msqrt>",description:"Square root"},{name:"Power",formula:"<msup><mi>x</mi><mn>2</mn></msup>",description:"Exponent/power"},{name:"Subscript",formula:"<msub><mi>x</mi><mi>sub</mi></msub>",description:"Subscript"},{name:"Parentheses",formula:'<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>',description:"Grouped expression"}]};let $=null,B=null,A=!1,b=null;const w='[data-theme="dark"], .dark, .editora-theme-dark',N=()=>new Promise((a,l)=>{if(window.katex){a(window.katex);return}if(A){const i=setInterval(()=>{window.katex&&(clearInterval(i),a(window.katex))},100);return}A=!0;const o=document.createElement("link");o.rel="stylesheet",o.href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css",document.head.appendChild(o);const d=document.createElement("script");d.src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js",d.onload=()=>a(window.katex),d.onerror=l,document.head.appendChild(d)}),H=()=>{const a=window.getSelection();if(!a||a.rangeCount===0)return null;const l=a.getRangeAt(0).startContainer;return(l.nodeType===Node.ELEMENT_NODE?l:l.parentElement)?.closest(".rte-content, .editora-content")||null},j=a=>{if((a||H())?.closest(w))return!0;const o=window.getSelection();if(o&&o.rangeCount>0){const i=o.getRangeAt(0).startContainer;if((i.nodeType===Node.ELEMENT_NODE?i:i.parentElement)?.closest(w))return!0}return document.activeElement?.closest(w)?!0:document.body.matches(w)||document.documentElement.matches(w)},q=async(a,l)=>{const o=l||B?.closest(".rte-content, .editora-content")||H()||b;b=o||null;const d=window.getSelection();if(d&&d.rangeCount>0){const e=d.getRangeAt(0);$=o&&o.contains(e.commonAncestorContainer)?e.cloneRange():null}await N();const i=j(o),t=i?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",border:"#3b4657",panelBg:"#222d3a",fieldBg:"#111827",fieldBorder:"#4b5563",text:"#e2e8f0",muted:"#94a3b8",templateBtnBg:"#273244",templateBtnHover:"#334155",templateBtnText:"#dbe7f7",templateSubText:"#9fb0c6",previewBg:"#111827",previewText:"#cbd5e1",cancelBg:"#334155",cancelText:"#e2e8f0",cancelBorder:"#4b5563",insertBg:"#3b82f6",insertHover:"#2563eb",invalid:"#f87171"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",border:"#e1e5e9",panelBg:"#f8f9fa",fieldBg:"#ffffff",fieldBorder:"#ced4da",text:"#1f2937",muted:"#6c757d",templateBtnBg:"#ffffff",templateBtnHover:"#f8f9fa",templateBtnText:"#1f2937",templateSubText:"#6c757d",previewBg:"#f8f9fa",previewText:"#6c757d",cancelBg:"#ffffff",cancelText:"#1f2937",cancelBorder:"#ced4da",insertBg:"#007bff",insertHover:"#0069d9",invalid:"#cc0000"},c=document.createElement("div");c.style.cssText=`position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: ${t.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;const s=document.createElement("div");s.style.cssText=`background: ${t.dialogBg}; border: 1px solid ${t.border}; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); color: ${t.text};`;let m=a?.format||"latex",T=a?.formula||"",P=a?.inline!==!1,g=null,M="";s.innerHTML=`
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${t.border}; background: ${t.panelBg};">
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${t.text};">${a?"Edit":"Insert"} Math Formula</h2>
<button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${t.muted}; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
</div>

@@ -9,6 +9,6 @@

<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Format:</label>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Format:</label>
<div style="display: flex; gap: 16px;">
<label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="latex" ${d==="latex"?"checked":""} style="margin-right: 6px;"> LaTeX</label>
<label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="mathml" ${d==="mathml"?"checked":""} style="margin-right: 6px;"> MathML</label>
<label style="cursor: pointer; color: ${t.text};"><input type="radio" name="format" value="latex" ${m==="latex"?"checked":""} style="margin-right: 6px;"> LaTeX</label>
<label style="cursor: pointer; color: ${t.text};"><input type="radio" name="format" value="mathml" ${m==="mathml"?"checked":""} style="margin-right: 6px;"> MathML</label>
</div>

@@ -18,3 +18,3 @@ </div>

<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Quick Templates:</label>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Quick Templates:</label>
<div id="templates-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 200px; overflow-y: auto;"></div>

@@ -24,25 +24,25 @@ </div>

<div style="margin-bottom: 20px;">
<label style="cursor: pointer; color: ${e.text};"><input type="checkbox" id="inline-cb" ${M?"checked":""} style="margin-right: 8px;"> Inline math</label>
<label style="cursor: pointer; color: ${t.text};"><input type="checkbox" id="inline-cb" ${P?"checked":""} style="margin-right: 8px;"> Inline math</label>
</div>
<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Formula:</label>
<textarea id="formula-input" rows="4" style="width: 100%; padding: 10px; border: 1px solid ${e.fieldBorder}; border-radius: 4px; font-family: 'Courier New', monospace; font-size: 14px; background: ${e.fieldBg}; color: ${e.text};">${u}</textarea>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Formula:</label>
<textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${t.fieldBorder}; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.45; background: ${t.fieldBg}; color: ${t.text}; box-sizing: border-box; overflow-x: hidden; overflow-y: auto; resize: vertical;">${T}</textarea>
</div>
<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Preview:</label>
<div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${e.fieldBorder}; border-radius: 4px; background: ${e.previewBg}; display: flex; align-items: center; justify-content: center; color: ${e.previewText};"></div>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Preview:</label>
<div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${t.fieldBorder}; border-radius: 4px; background: ${t.previewBg}; display: flex; align-items: center; justify-content: center; color: ${t.previewText};"></div>
</div>
</div>
<div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${e.border}; background: ${e.panelBg};">
<button class="cancel-btn" style="padding: 10px 20px; background: ${e.cancelBg}; color: ${e.cancelText}; border: 1px solid ${e.cancelBorder}; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
<button id="insert-btn" style="padding: 10px 20px; background: ${e.insertBg}; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${a?"Update":"Insert"}</button>
<div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${t.border}; background: ${t.panelBg};">
<button class="cancel-btn" style="padding: 10px 20px; background: ${t.cancelBg}; color: ${t.cancelText}; border: 1px solid ${t.cancelBorder}; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
<button id="insert-btn" style="padding: 10px 20px; background: ${t.insertBg}; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${a?"Update":"Insert"}</button>
</div>
`,i.appendChild(l),document.body.appendChild(i);const c=l.querySelector("#formula-input"),f=l.querySelector("#preview-area"),k=l.querySelector("#templates-grid"),S=l.querySelectorAll('input[name="format"]'),L=l.querySelector("#inline-cb"),m=l.querySelector("#insert-btn"),p=l.querySelector(".close-btn"),x=l.querySelector(".cancel-btn"),$=()=>{const t=C[d];k.innerHTML=t.map(n=>`
<button type="button" data-formula="${n.formula.replace(/"/g,"&quot;")}" title="${n.description}" style="padding: 8px; border: 1px solid ${e.fieldBorder}; border-radius: 4px; background: ${e.templateBtnBg}; cursor: pointer; text-align: left;">
<div style="font-weight: 600; font-size: 12px; color: ${e.templateBtnText};">${n.name}</div>
<div style="font-size: 10px; color: ${e.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${n.formula.substring(0,20)}...</div>
`,c.appendChild(s),document.body.appendChild(c);const u=s.querySelector("#formula-input"),h=s.querySelector("#preview-area"),k=s.querySelector("#templates-grid"),_=s.querySelectorAll('input[name="format"]'),z=s.querySelector("#inline-cb"),p=s.querySelector("#insert-btn"),f=s.querySelector(".close-btn"),v=s.querySelector(".cancel-btn"),I=e=>encodeURIComponent(e),D=e=>{try{return decodeURIComponent(e)}catch{return e}},L=()=>{const e=F[m];k.innerHTML=e.map(r=>`
<button type="button" data-formula="${I(r.formula)}" title="${r.description}" style="padding: 8px; border: 1px solid ${t.fieldBorder}; border-radius: 4px; background: ${t.templateBtnBg}; cursor: pointer; text-align: left; transition: background-color 0.16s ease;">
<div style="font-weight: 600; font-size: 12px; color: ${t.templateBtnText};">${r.name}</div>
<div style="font-size: 10px; color: ${t.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${r.formula.substring(0,20)}...</div>
</button>
`).join(""),k.querySelectorAll("button").forEach(n=>{const r=n;r.onmouseover=()=>{r.style.background=e.templateBtnHover},r.onmouseout=()=>{r.style.background=e.templateBtnBg},n.addEventListener("click",()=>{c.value=n.getAttribute("data-formula")||"",u=c.value,b()})})},b=()=>{const t=c.value.trim();if(!t){f.innerHTML=`<span style="color: ${e.previewText};">Enter a formula to see preview</span>`,m.disabled=!0;return}m.disabled=!1;try{if(d==="latex"){const n=window.katex;f.innerHTML=n.renderToString(t,{displayMode:!1,throwOnError:!1})}else t.trim().startsWith("<math")?f.innerHTML=t:f.innerHTML=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${t}</math>`}catch{f.innerHTML=`<span style="color: ${e.invalid};">Invalid formula</span>`}},g=()=>document.body.removeChild(i);p.onmouseover=()=>{p.style.color="#f8fafc",p.style.background=o?"#334155":"#e5e7eb",p.style.borderRadius="4px"},p.onmouseout=()=>{p.style.color=e.muted,p.style.background="none"},x.onmouseover=()=>{x.style.background=o?"#475569":"#f3f4f6"},x.onmouseout=()=>{x.style.background=e.cancelBg},m.onmouseover=()=>{m.disabled||(m.style.background=e.insertHover)},m.onmouseout=()=>{m.style.background=e.insertBg};const B=()=>{const t=c.value.trim();if(!t)return;const n={formula:t,format:d,inline:L.checked},r=n.inline?document.createElement("span"):document.createElement("div");if(r.className=n.inline?"math-formula":"math-block",r.setAttribute("data-math-formula",t),r.setAttribute("data-math-format",d),r.contentEditable="false",r.style.cssText=n.inline?"background: #f0f8ff; border: 1px solid #b8daff; border-radius: 4px; padding: 2px 6px; margin: 0 2px; color: #004085; display: inline-block; cursor: pointer;":"background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin: 8px 0; text-align: center; display: block; cursor: pointer;",d==="latex"){const v=window.katex;try{r.innerHTML=v.renderToString(t,{displayMode:!n.inline,throwOnError:!1})}catch{r.textContent=n.inline?`$${t}$`:`$$${t}$$`}}else if(t.trim().startsWith("<math"))r.innerHTML=t;else{const v=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="${n.inline?"inline":"block"}">${t}</math>`;r.innerHTML=v}w?w.replaceWith(r):h&&(h.deleteContents(),h.insertNode(r)),g()};p.addEventListener("click",g),x.addEventListener("click",g),m.addEventListener("click",B),i.addEventListener("click",t=>{t.target===i&&g()}),S.forEach(t=>{t.addEventListener("change",n=>{d=n.target.value,$(),b()})}),c.addEventListener("input",()=>{u=c.value,b()}),c.addEventListener("keydown",t=>{(t.ctrlKey||t.metaKey)&&t.key==="Enter"&&(t.preventDefault(),B())}),$(),b(),c.focus()};if(typeof window<"u"&&!window.__mathPluginDoubleClickInitialized){window.__mathPluginDoubleClickInitialized=!0;const a=o=>{const i=o.target.closest(".math-formula, .math-block");if(i){o.preventDefault(),o.stopPropagation(),o.stopImmediatePropagation(),w=i;const l=i.getAttribute("data-math-formula")||"",d=i.getAttribute("data-math-format")||"latex",u=i.classList.contains("math-formula");T({formula:l,format:d,inline:u})}},s=()=>{document.addEventListener("dblclick",a,{capture:!0})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",s):setTimeout(s,100)}const _=()=>({name:"math",toolbar:[{label:"Insert Math",command:"insertMath",icon:'<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M9 4.8c.1-.5.5-.8 1-.8h10a1 1 0 1 1 0 2h-9.2L8.3 19.2a1 1 0 0 1-1.7.4l-3.4-4.2a1 1 0 0 1 1.6-1.2l2 2.5L9 4.8Zm9.7 5.5c.4.4.4 1 0 1.4L17 13.5l1.8 1.8a1 1 0 0 1-1.4 1.4L15.5 15l-1.8 1.8a1 1 0 0 1-1.4-1.4l1.8-1.8-1.8-1.8a1 1 0 0 1 1.4-1.4l1.8 1.8 1.8-1.8a1 1 0 0 1 1.4 0Z"></path></svg>'}],commands:{insertMath:()=>(T(),!0)},keymap:{"Mod-Shift-m":"insertMath"}});exports.MathPlugin=_;
`).join("")},R=()=>{const e=u.value.trim(),r=`${m}:${e}`;if(r!==M){if(M=r,!e){h.innerHTML=`<span style="color: ${t.previewText};">Enter a formula to see preview</span>`,p.disabled=!0;return}p.disabled=!1;try{if(m==="latex"){const n=window.katex;h.innerHTML=n.renderToString(e,{displayMode:!1,throwOnError:!1})}else e.trim().startsWith("<math")?h.innerHTML=e:h.innerHTML=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${e}</math>`}catch{h.innerHTML=`<span style="color: ${t.invalid};">Invalid formula</span>`}}},E=()=>{g!==null&&cancelAnimationFrame(g),g=requestAnimationFrame(()=>{g=null,R()})},S=e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),y())},y=()=>{document.removeEventListener("keydown",S,!0),g!==null&&(cancelAnimationFrame(g),g=null),c.parentNode&&c.parentNode.removeChild(c)};f.onmouseover=()=>{f.style.color="#f8fafc",f.style.background=i?"#334155":"#e5e7eb",f.style.borderRadius="4px"},f.onmouseout=()=>{f.style.color=t.muted,f.style.background="none"},v.onmouseover=()=>{v.style.background=i?"#475569":"#f3f4f6"},v.onmouseout=()=>{v.style.background=t.cancelBg},p.onmouseover=()=>{p.disabled||(p.style.background=t.insertHover)},p.onmouseout=()=>{p.style.background=t.insertBg},k.addEventListener("mouseover",e=>{const n=e.target.closest("button[data-formula]");n&&(n.style.background=t.templateBtnHover)}),k.addEventListener("mouseout",e=>{const n=e.target.closest("button[data-formula]");n&&(n.style.background=t.templateBtnBg)}),k.addEventListener("click",e=>{const n=e.target.closest("button[data-formula]");n&&(u.value=D(n.getAttribute("data-formula")||""),T=u.value,E())});const C=()=>{const e=u.value.trim();if(!e)return;const r={formula:e,format:m,inline:z.checked},n=r.inline?document.createElement("span"):document.createElement("div");if(n.className=r.inline?"math-formula":"math-block",n.setAttribute("data-math-formula",e),n.setAttribute("data-math-format",m),n.contentEditable="false",n.style.cssText=r.inline?"background: #f0f8ff; border: 1px solid #b8daff; border-radius: 4px; padding: 2px 6px; margin: 0 2px; color: #004085; display: inline-block; cursor: pointer;":"background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin: 8px 0; text-align: center; display: block; cursor: pointer;",m==="latex"){const x=window.katex;try{n.innerHTML=x.renderToString(e,{displayMode:!r.inline,throwOnError:!1})}catch{n.textContent=r.inline?`$${e}$`:`$$${e}$$`}}else if(e.trim().startsWith("<math"))n.innerHTML=e;else{const x=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="${r.inline?"inline":"block"}">${e}</math>`;n.innerHTML=x}if(B)B.replaceWith(n);else if($)$.deleteContents(),$.insertNode(n);else if(b&&b.isConnected){const x=document.createRange();x.selectNodeContents(b),x.collapse(!1),x.insertNode(n)}(n.closest(".rte-content, .editora-content")||b)?.dispatchEvent(new Event("input",{bubbles:!0})),y()};f.addEventListener("click",y),v.addEventListener("click",y),p.addEventListener("click",C),c.addEventListener("click",e=>{e.target===c&&y()}),document.addEventListener("keydown",S,!0),_.forEach(e=>{e.addEventListener("change",r=>{m=r.target.value,M="",L(),E()})}),u.addEventListener("input",()=>{T=u.value,E()}),u.addEventListener("keydown",e=>{(e.ctrlKey||e.metaKey)&&e.key==="Enter"&&(e.preventDefault(),C())}),L(),E(),u.focus()};if(typeof window<"u"&&!window.__mathPluginDoubleClickInitialized){window.__mathPluginDoubleClickInitialized=!0;const a=o=>{const i=o.target.closest(".math-formula, .math-block");if(i){o.preventDefault(),o.stopPropagation(),o.stopImmediatePropagation(),B=i;const t=i.getAttribute("data-math-formula")||"",c=i.getAttribute("data-math-format")||"latex",s=i.classList.contains("math-formula");q({formula:t,format:c,inline:s})}},l=()=>{document.addEventListener("dblclick",a,{capture:!0})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",l):setTimeout(l,100)}const O=()=>({name:"math",toolbar:[{label:"Insert Math",command:"insertMath",icon:'<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M9 4.8c.1-.5.5-.8 1-.8h10a1 1 0 1 1 0 2h-9.2L8.3 19.2a1 1 0 0 1-1.7.4l-3.4-4.2a1 1 0 0 1 1.6-1.2l2 2.5L9 4.8Zm9.7 5.5c.4.4.4 1 0 1.4L17 13.5l1.8 1.8a1 1 0 0 1-1.4 1.4L15.5 15l-1.8 1.8a1 1 0 0 1-1.4-1.4l1.8-1.8-1.8-1.8a1 1 0 0 1 1.4-1.4l1.8 1.8 1.8-1.8a1 1 0 0 1 1.4 0Z"></path></svg>'}],commands:{insertMath:(a,l)=>{const o=l?.contentElement instanceof HTMLElement?l.contentElement:null;return q(void 0,o),!0}},keymap:{"Mod-Shift-m":"insertMath"}});exports.MathPlugin=O;

@@ -1,2 +0,2 @@

const C = {
const F = {
latex: [

@@ -22,4 +22,4 @@ { name: "Fraction", formula: "\\frac{a}{b}", description: "Simple fraction" },

};
let h = null, w = null, E = !1;
const y = '[data-theme="dark"], .dark, .editora-theme-dark', q = () => new Promise((a, s) => {
let $ = null, B = null, A = !1, b = null;
const w = '[data-theme="dark"], .dark, .editora-theme-dark', N = () => new Promise((a, l) => {
if (window.katex) {

@@ -29,3 +29,3 @@ a(window.katex);

}
if (E) {
if (A) {
const i = setInterval(() => {

@@ -36,18 +36,30 @@ window.katex && (clearInterval(i), a(window.katex));

}
E = !0;
A = !0;
const o = document.createElement("link");
o.rel = "stylesheet", o.href = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css", document.head.appendChild(o);
const e = document.createElement("script");
e.src = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js", e.onload = () => a(window.katex), e.onerror = s, document.head.appendChild(e);
const d = document.createElement("script");
d.src = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js", d.onload = () => a(window.katex), d.onerror = l, document.head.appendChild(d);
}), H = () => {
const a = window.getSelection();
if (a && a.rangeCount > 0) {
const o = a.getRangeAt(0).startContainer;
if ((o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement)?.closest(y)) return !0;
if (!a || a.rangeCount === 0) return null;
const l = a.getRangeAt(0).startContainer;
return (l.nodeType === Node.ELEMENT_NODE ? l : l.parentElement)?.closest(".rte-content, .editora-content") || null;
}, j = (a) => {
if ((a || H())?.closest(w)) return !0;
const o = window.getSelection();
if (o && o.rangeCount > 0) {
const i = o.getRangeAt(0).startContainer;
if ((i.nodeType === Node.ELEMENT_NODE ? i : i.parentElement)?.closest(w)) return !0;
}
return document.activeElement?.closest(y) ? !0 : document.body.matches(y) || document.documentElement.matches(y);
}, T = async (a) => {
const s = window.getSelection();
s && s.rangeCount > 0 && (h = s.getRangeAt(0).cloneRange()), await q();
const o = H(), e = o ? {
return document.activeElement?.closest(w) ? !0 : document.body.matches(w) || document.documentElement.matches(w);
}, q = async (a, l) => {
const o = l || B?.closest(".rte-content, .editora-content") || H() || b;
b = o || null;
const d = window.getSelection();
if (d && d.rangeCount > 0) {
const e = d.getRangeAt(0);
$ = o && o.contains(e.commonAncestorContainer) ? e.cloneRange() : null;
}
await N();
const i = j(o), t = i ? {
overlay: "rgba(0, 0, 0, 0.62)",

@@ -94,11 +106,11 @@ dialogBg: "#1f2937",

invalid: "#cc0000"
}, i = document.createElement("div");
i.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: 99999;`;
const l = document.createElement("div");
l.style.cssText = `background: ${e.dialogBg}; border: 1px solid ${e.border}; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); color: ${e.text};`;
let d = a?.format || "latex", u = a?.formula || "", M = a?.inline !== !1;
l.innerHTML = `
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${e.border}; background: ${e.panelBg};">
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};">${a ? "Edit" : "Insert"} Math Formula</h2>
<button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${e.muted}; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
}, c = document.createElement("div");
c.style.cssText = `position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: ${t.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;
const s = document.createElement("div");
s.style.cssText = `background: ${t.dialogBg}; border: 1px solid ${t.border}; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); color: ${t.text};`;
let m = a?.format || "latex", T = a?.formula || "", z = a?.inline !== !1, x = null, L = "";
s.innerHTML = `
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${t.border}; background: ${t.panelBg};">
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${t.text};">${a ? "Edit" : "Insert"} Math Formula</h2>
<button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${t.muted}; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
</div>

@@ -108,6 +120,6 @@

<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Format:</label>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Format:</label>
<div style="display: flex; gap: 16px;">
<label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="latex" ${d === "latex" ? "checked" : ""} style="margin-right: 6px;"> LaTeX</label>
<label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="mathml" ${d === "mathml" ? "checked" : ""} style="margin-right: 6px;"> MathML</label>
<label style="cursor: pointer; color: ${t.text};"><input type="radio" name="format" value="latex" ${m === "latex" ? "checked" : ""} style="margin-right: 6px;"> LaTeX</label>
<label style="cursor: pointer; color: ${t.text};"><input type="radio" name="format" value="mathml" ${m === "mathml" ? "checked" : ""} style="margin-right: 6px;"> MathML</label>
</div>

@@ -117,3 +129,3 @@ </div>

<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Quick Templates:</label>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Quick Templates:</label>
<div id="templates-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 200px; overflow-y: auto;"></div>

@@ -123,101 +135,125 @@ </div>

<div style="margin-bottom: 20px;">
<label style="cursor: pointer; color: ${e.text};"><input type="checkbox" id="inline-cb" ${M ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
<label style="cursor: pointer; color: ${t.text};"><input type="checkbox" id="inline-cb" ${z ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
</div>
<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Formula:</label>
<textarea id="formula-input" rows="4" style="width: 100%; padding: 10px; border: 1px solid ${e.fieldBorder}; border-radius: 4px; font-family: 'Courier New', monospace; font-size: 14px; background: ${e.fieldBg}; color: ${e.text};">${u}</textarea>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Formula:</label>
<textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${t.fieldBorder}; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.45; background: ${t.fieldBg}; color: ${t.text}; box-sizing: border-box; overflow-x: hidden; overflow-y: auto; resize: vertical;">${T}</textarea>
</div>
<div style="margin-bottom: 20px;">
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Preview:</label>
<div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${e.fieldBorder}; border-radius: 4px; background: ${e.previewBg}; display: flex; align-items: center; justify-content: center; color: ${e.previewText};"></div>
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Preview:</label>
<div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${t.fieldBorder}; border-radius: 4px; background: ${t.previewBg}; display: flex; align-items: center; justify-content: center; color: ${t.previewText};"></div>
</div>
</div>
<div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${e.border}; background: ${e.panelBg};">
<button class="cancel-btn" style="padding: 10px 20px; background: ${e.cancelBg}; color: ${e.cancelText}; border: 1px solid ${e.cancelBorder}; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
<button id="insert-btn" style="padding: 10px 20px; background: ${e.insertBg}; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${a ? "Update" : "Insert"}</button>
<div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${t.border}; background: ${t.panelBg};">
<button class="cancel-btn" style="padding: 10px 20px; background: ${t.cancelBg}; color: ${t.cancelText}; border: 1px solid ${t.cancelBorder}; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
<button id="insert-btn" style="padding: 10px 20px; background: ${t.insertBg}; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${a ? "Update" : "Insert"}</button>
</div>
`, i.appendChild(l), document.body.appendChild(i);
const c = l.querySelector("#formula-input"), f = l.querySelector("#preview-area"), k = l.querySelector("#templates-grid"), L = l.querySelectorAll('input[name="format"]'), S = l.querySelector("#inline-cb"), m = l.querySelector("#insert-btn"), p = l.querySelector(".close-btn"), x = l.querySelector(".cancel-btn"), $ = () => {
const t = C[d];
k.innerHTML = t.map((n) => `
<button type="button" data-formula="${n.formula.replace(/"/g, "&quot;")}" title="${n.description}" style="padding: 8px; border: 1px solid ${e.fieldBorder}; border-radius: 4px; background: ${e.templateBtnBg}; cursor: pointer; text-align: left;">
<div style="font-weight: 600; font-size: 12px; color: ${e.templateBtnText};">${n.name}</div>
<div style="font-size: 10px; color: ${e.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${n.formula.substring(0, 20)}...</div>
</button>
`).join(""), k.querySelectorAll("button").forEach((n) => {
const r = n;
r.onmouseover = () => {
r.style.background = e.templateBtnHover;
}, r.onmouseout = () => {
r.style.background = e.templateBtnBg;
}, n.addEventListener("click", () => {
c.value = n.getAttribute("data-formula") || "", u = c.value, b();
});
});
}, b = () => {
const t = c.value.trim();
if (!t) {
f.innerHTML = `<span style="color: ${e.previewText};">Enter a formula to see preview</span>`, m.disabled = !0;
return;
}
m.disabled = !1;
`, c.appendChild(s), document.body.appendChild(c);
const u = s.querySelector("#formula-input"), h = s.querySelector("#preview-area"), k = s.querySelector("#templates-grid"), I = s.querySelectorAll('input[name="format"]'), D = s.querySelector("#inline-cb"), p = s.querySelector("#insert-btn"), f = s.querySelector(".close-btn"), v = s.querySelector(".cancel-btn"), P = (e) => encodeURIComponent(e), R = (e) => {
try {
if (d === "latex") {
const n = window.katex;
f.innerHTML = n.renderToString(t, { displayMode: !1, throwOnError: !1 });
} else
t.trim().startsWith("<math") ? f.innerHTML = t : f.innerHTML = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${t}</math>`;
return decodeURIComponent(e);
} catch {
f.innerHTML = `<span style="color: ${e.invalid};">Invalid formula</span>`;
return e;
}
}, g = () => document.body.removeChild(i);
p.onmouseover = () => {
p.style.color = "#f8fafc", p.style.background = o ? "#334155" : "#e5e7eb", p.style.borderRadius = "4px";
}, M = () => {
const e = F[m];
k.innerHTML = e.map((r) => `
<button type="button" data-formula="${P(r.formula)}" title="${r.description}" style="padding: 8px; border: 1px solid ${t.fieldBorder}; border-radius: 4px; background: ${t.templateBtnBg}; cursor: pointer; text-align: left; transition: background-color 0.16s ease;">
<div style="font-weight: 600; font-size: 12px; color: ${t.templateBtnText};">${r.name}</div>
<div style="font-size: 10px; color: ${t.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${r.formula.substring(0, 20)}...</div>
</button>
`).join("");
}, _ = () => {
const e = u.value.trim(), r = `${m}:${e}`;
if (r !== L) {
if (L = r, !e) {
h.innerHTML = `<span style="color: ${t.previewText};">Enter a formula to see preview</span>`, p.disabled = !0;
return;
}
p.disabled = !1;
try {
if (m === "latex") {
const n = window.katex;
h.innerHTML = n.renderToString(e, { displayMode: !1, throwOnError: !1 });
} else
e.trim().startsWith("<math") ? h.innerHTML = e : h.innerHTML = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${e}</math>`;
} catch {
h.innerHTML = `<span style="color: ${t.invalid};">Invalid formula</span>`;
}
}
}, E = () => {
x !== null && cancelAnimationFrame(x), x = requestAnimationFrame(() => {
x = null, _();
});
}, S = (e) => {
e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), y());
}, y = () => {
document.removeEventListener("keydown", S, !0), x !== null && (cancelAnimationFrame(x), x = null), c.parentNode && c.parentNode.removeChild(c);
};
f.onmouseover = () => {
f.style.color = "#f8fafc", f.style.background = i ? "#334155" : "#e5e7eb", f.style.borderRadius = "4px";
}, f.onmouseout = () => {
f.style.color = t.muted, f.style.background = "none";
}, v.onmouseover = () => {
v.style.background = i ? "#475569" : "#f3f4f6";
}, v.onmouseout = () => {
v.style.background = t.cancelBg;
}, p.onmouseover = () => {
p.disabled || (p.style.background = t.insertHover);
}, p.onmouseout = () => {
p.style.color = e.muted, p.style.background = "none";
}, x.onmouseover = () => {
x.style.background = o ? "#475569" : "#f3f4f6";
}, x.onmouseout = () => {
x.style.background = e.cancelBg;
}, m.onmouseover = () => {
m.disabled || (m.style.background = e.insertHover);
}, m.onmouseout = () => {
m.style.background = e.insertBg;
};
const B = () => {
const t = c.value.trim();
if (!t) return;
const n = { formula: t, format: d, inline: S.checked }, r = n.inline ? document.createElement("span") : document.createElement("div");
if (r.className = n.inline ? "math-formula" : "math-block", r.setAttribute("data-math-formula", t), r.setAttribute("data-math-format", d), r.contentEditable = "false", r.style.cssText = n.inline ? "background: #f0f8ff; border: 1px solid #b8daff; border-radius: 4px; padding: 2px 6px; margin: 0 2px; color: #004085; display: inline-block; cursor: pointer;" : "background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin: 8px 0; text-align: center; display: block; cursor: pointer;", d === "latex") {
const v = window.katex;
p.style.background = t.insertBg;
}, k.addEventListener("mouseover", (e) => {
const n = e.target.closest("button[data-formula]");
n && (n.style.background = t.templateBtnHover);
}), k.addEventListener("mouseout", (e) => {
const n = e.target.closest("button[data-formula]");
n && (n.style.background = t.templateBtnBg);
}), k.addEventListener("click", (e) => {
const n = e.target.closest("button[data-formula]");
n && (u.value = R(n.getAttribute("data-formula") || ""), T = u.value, E());
});
const C = () => {
const e = u.value.trim();
if (!e) return;
const r = { formula: e, format: m, inline: D.checked }, n = r.inline ? document.createElement("span") : document.createElement("div");
if (n.className = r.inline ? "math-formula" : "math-block", n.setAttribute("data-math-formula", e), n.setAttribute("data-math-format", m), n.contentEditable = "false", n.style.cssText = r.inline ? "background: #f0f8ff; border: 1px solid #b8daff; border-radius: 4px; padding: 2px 6px; margin: 0 2px; color: #004085; display: inline-block; cursor: pointer;" : "background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin: 8px 0; text-align: center; display: block; cursor: pointer;", m === "latex") {
const g = window.katex;
try {
r.innerHTML = v.renderToString(t, {
displayMode: !n.inline,
n.innerHTML = g.renderToString(e, {
displayMode: !r.inline,
throwOnError: !1
});
} catch {
r.textContent = n.inline ? `$${t}$` : `$$${t}$$`;
n.textContent = r.inline ? `$${e}$` : `$$${e}$$`;
}
} else if (t.trim().startsWith("<math"))
r.innerHTML = t;
} else if (e.trim().startsWith("<math"))
n.innerHTML = e;
else {
const v = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${n.inline ? "inline" : "block"}">${t}</math>`;
r.innerHTML = v;
const g = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${r.inline ? "inline" : "block"}">${e}</math>`;
n.innerHTML = g;
}
w ? w.replaceWith(r) : h && (h.deleteContents(), h.insertNode(r)), g();
if (B)
B.replaceWith(n);
else if ($)
$.deleteContents(), $.insertNode(n);
else if (b && b.isConnected) {
const g = document.createRange();
g.selectNodeContents(b), g.collapse(!1), g.insertNode(n);
}
(n.closest(".rte-content, .editora-content") || b)?.dispatchEvent(new Event("input", { bubbles: !0 })), y();
};
p.addEventListener("click", g), x.addEventListener("click", g), m.addEventListener("click", B), i.addEventListener("click", (t) => {
t.target === i && g();
}), L.forEach((t) => {
t.addEventListener("change", (n) => {
d = n.target.value, $(), b();
f.addEventListener("click", y), v.addEventListener("click", y), p.addEventListener("click", C), c.addEventListener("click", (e) => {
e.target === c && y();
}), document.addEventListener("keydown", S, !0), I.forEach((e) => {
e.addEventListener("change", (r) => {
m = r.target.value, L = "", M(), E();
});
}), c.addEventListener("input", () => {
u = c.value, b();
}), c.addEventListener("keydown", (t) => {
(t.ctrlKey || t.metaKey) && t.key === "Enter" && (t.preventDefault(), B());
}), $(), b(), c.focus();
}), u.addEventListener("input", () => {
T = u.value, E();
}), u.addEventListener("keydown", (e) => {
(e.ctrlKey || e.metaKey) && e.key === "Enter" && (e.preventDefault(), C());
}), M(), E(), u.focus();
};

@@ -229,12 +265,12 @@ if (typeof window < "u" && !window.__mathPluginDoubleClickInitialized) {

if (i) {
o.preventDefault(), o.stopPropagation(), o.stopImmediatePropagation(), w = i;
const l = i.getAttribute("data-math-formula") || "", d = i.getAttribute("data-math-format") || "latex", u = i.classList.contains("math-formula");
T({ formula: l, format: d, inline: u });
o.preventDefault(), o.stopPropagation(), o.stopImmediatePropagation(), B = i;
const t = i.getAttribute("data-math-formula") || "", c = i.getAttribute("data-math-format") || "latex", s = i.classList.contains("math-formula");
q({ formula: t, format: c, inline: s });
}
}, s = () => {
}, l = () => {
document.addEventListener("dblclick", a, { capture: !0 });
};
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", s) : setTimeout(s, 100);
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", l) : setTimeout(l, 100);
}
const z = () => ({
const K = () => ({
name: "math",

@@ -249,3 +285,6 @@ toolbar: [

commands: {
insertMath: () => (T(), !0)
insertMath: (a, l) => {
const o = l?.contentElement instanceof HTMLElement ? l.contentElement : null;
return q(void 0, o), !0;
}
},

@@ -257,3 +296,3 @@ keymap: {

export {
z as MathPlugin
K as MathPlugin
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("./shared-config.cjs.js");let T=null,s=null,d=null,R=[],A=!1,q=null,U=0,P=0,z=0,$=0,_=1,I=null;const j='[data-theme="dark"], .dark, .editora-theme-dark',O=()=>{if(typeof document>"u"||document.getElementById("rte-media-dialog-styles"))return;const e=document.createElement("style");e.id="rte-media-dialog-styles",e.textContent=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("./shared-config.cjs.js");let A=null,s=null,l=null,R=[],D=!1,I=null,V=0,j=0,C=0,$=0,N=1,T=null;const W='[data-theme="dark"], .dark, .editora-theme-dark',B=(e,t)=>{const r=i=>{i.key!=="Escape"||!e.isConnected||(i.preventDefault(),i.stopPropagation(),t())};return document.addEventListener("keydown",r,!0),()=>{document.removeEventListener("keydown",r,!0)}},X=()=>{if(typeof document>"u"||document.getElementById("rte-media-dialog-styles"))return;const e=document.createElement("style");e.id="rte-media-dialog-styles",e.textContent=`
.rte-media-overlay {

@@ -379,3 +379,3 @@ --rte-media-overlay-bg: rgba(15, 23, 36, 0.56);

.media-floating-toolbar.rte-ui-theme-dark,
${j} .media-floating-toolbar {
${W} .media-floating-toolbar {
--rte-media-toolbar-bg: #24303f;

@@ -428,3 +428,3 @@ --rte-media-toolbar-border: #4a5a71;

}
`,document.head.appendChild(e)},G=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;return(t instanceof HTMLElement?t:t?.parentElement)?.closest(".rte-content, .editora-content")||null},X=e=>{if(e)return e;const t=G();if(t)return t;if(I)return I;const r=document.activeElement;return r?r.closest(".rte-content, .editora-content")||r:null},F=e=>{const t=X(e);return t?!!t.closest(j):!1},D=e=>{O();const t=document.createElement("div");return t.className="rte-media-overlay",F(e)&&t.classList.add("rte-ui-theme-dark"),t},B=(e=!1)=>{const t=document.createElement("div");return t.className=e?"rte-media-dialog rte-media-dialog-compact":"rte-media-dialog",t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t},V=(e,t)=>{const r=window.getSelection();r&&r.rangeCount>0&&(T=r.getRangeAt(0).cloneRange());const i=D(t),a=B();let o="upload",n="",c="",m="",b="";const v=()=>{a.innerHTML=`
`,document.head.appendChild(e)},Y=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;return(t instanceof HTMLElement?t:t?.parentElement)?.closest(".rte-content, .editora-content")||null},Z=e=>{if(e)return e;const t=Y();if(t)return t;if(T)return T;const r=document.activeElement;return r?r.closest(".rte-content, .editora-content")||r:null},O=e=>{const t=Z(e);return t?!!t.closest(W):!1},_=e=>{X();const t=document.createElement("div");return t.className="rte-media-overlay",O(e)&&t.classList.add("rte-ui-theme-dark"),t},H=(e=!1)=>{const t=document.createElement("div");return t.className=e?"rte-media-dialog rte-media-dialog-compact":"rte-media-dialog",t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t},F=(e,t)=>{const r=window.getSelection();r&&r.rangeCount>0&&(A=r.getRangeAt(0).cloneRange());const i=_(t),a=H();let o="upload",d="",c="",p="",g="";const v=()=>{a.innerHTML=`
<div class="rte-media-header">

@@ -461,3 +461,3 @@ <h2 class="rte-media-title">Insert ${e==="image"?"Image":"Video"}</h2>

<label class="rte-media-label">URL</label>
<input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/${e}.${e==="image"?"jpg":"mp4"}" value="${n}">
<input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/${e}.${e==="image"?"jpg":"mp4"}" value="${d}">
</div>

@@ -467,3 +467,3 @@ ${e==="image"?`

<label class="rte-media-label">Alt Text (for accessibility)</label>
<input type="text" id="alt-input" class="rte-media-input" placeholder="Describe the image" value="${b}">
<input type="text" id="alt-input" class="rte-media-input" placeholder="Describe the image" value="${g}">
</div>

@@ -478,10 +478,10 @@ `:""}

<label class="rte-media-label">Height (px)</label>
<input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${m}">
<input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${p}">
</div>
</div>
${n?`
${d?`
<div class="rte-media-field">
<label class="rte-media-label">Preview</label>
<div class="rte-media-preview">
${e==="image"?`<img src="${n}" alt="Preview">`:`<video src="${n}" controls></video>`}
${e==="image"?`<img src="${d}" alt="Preview">`:`<video src="${d}" controls></video>`}
</div>

@@ -496,5 +496,5 @@ </div>

<button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
<button id="insert-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!n&&o==="url"?"disabled":""}>Insert</button>
<button id="insert-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!d&&o==="url"?"disabled":""}>Insert</button>
</div>
`};v(),i.appendChild(a),document.body.appendChild(i);const h=()=>{i.parentNode&&i.parentNode.removeChild(i)},E=()=>{if(!n)return;const l=e==="image"?document.createElement("img"):document.createElement("video");l.src=n,l.setAttribute("data-media-type",e),e==="image"&&b&&(l.alt=b),c&&(l.style.width=`${c}px`,l.setAttribute("width",c)),m&&(l.style.height=`${m}px`,l.setAttribute("height",m)),e==="video"&&(l.controls=!0),!c&&!m?l.style.cssText="max-width: 100%; height: auto; display: block; margin: 1em 0; cursor: pointer;":l.style.cssText=`display: block; margin: 1em 0; cursor: pointer; ${c?`width: ${c}px;`:"max-width: 100%;"} ${m?`height: ${m}px;`:"height: auto;"}`,T&&(T.deleteContents(),T.insertNode(l)),h()},y=async l=>{const g=a.querySelector("#upload-progress"),p=a.querySelector("#progress-bar"),x=a.querySelector("#progress-text");if(g&&p&&x){g.style.display="block";let C=0;const f=setInterval(()=>{C+=Math.random()*30,C>90&&(C=90),p.style.width=`${C}%`},200);try{const k=new FileReader;k.onload=()=>{clearInterval(f),p.style.width="100%",x.textContent="Upload complete",setTimeout(()=>{n=k.result,o="url",v(),u()},500)},k.readAsDataURL(l)}catch{clearInterval(f),x.textContent="Upload failed"}}},u=()=>{const l=a.querySelector(".close-btn"),g=a.querySelector(".cancel-btn"),p=a.querySelector("#insert-btn"),x=a.querySelector(".tab-upload"),C=a.querySelector(".tab-url");if(l?.addEventListener("click",h),g?.addEventListener("click",h),p?.addEventListener("click",E),x?.addEventListener("click",()=>{o="upload",v(),u()}),C?.addEventListener("click",()=>{o="url",v(),u()}),o==="upload"){const f=a.querySelector(".dropzone"),k=a.querySelector("#file-input");f?.addEventListener("click",()=>k?.click()),f?.addEventListener("dragover",L=>{L.preventDefault(),f.classList.add("is-dragover")}),f?.addEventListener("dragleave",()=>{f.classList.remove("is-dragover")}),f?.addEventListener("drop",L=>{L.preventDefault(),f.classList.remove("is-dragover");const S=L.dataTransfer?.files[0];S&&y(S)}),k?.addEventListener("change",L=>{const S=L.target.files?.[0];S&&y(S)})}if(o==="url"){const f=a.querySelector("#url-input"),k=a.querySelector("#alt-input"),L=a.querySelector("#width-input"),S=a.querySelector("#height-input");f?.addEventListener("input",()=>{n=f.value,v(),u()}),k?.addEventListener("input",()=>{b=k.value}),L?.addEventListener("input",()=>{c=L.value}),S?.addEventListener("input",()=>{m=S.value})}};u(),i.addEventListener("click",l=>{l.target===i&&h()})},Y=()=>{["nw","ne","sw","se"].forEach(t=>{const r=document.createElement("div");r.className=`media-resize-handle-${t}`,r.style.cssText=`
`};v(),i.appendChild(a),document.body.appendChild(i);let k=()=>{};const h=()=>{k(),i.parentNode&&i.parentNode.removeChild(i)};k=B(i,h);const L=()=>{if(!d)return;const n=e==="image"?document.createElement("img"):document.createElement("video");n.src=d,n.setAttribute("data-media-type",e),e==="image"&&g&&(n.alt=g),c&&(n.style.width=`${c}px`,n.setAttribute("width",c)),p&&(n.style.height=`${p}px`,n.setAttribute("height",p)),e==="video"&&(n.controls=!0),!c&&!p?n.style.cssText="max-width: 100%; height: auto; display: block; margin: 1em 0; cursor: pointer;":n.style.cssText=`display: block; margin: 1em 0; cursor: pointer; ${c?`width: ${c}px;`:"max-width: 100%;"} ${p?`height: ${p}px;`:"height: auto;"}`,A&&(A.deleteContents(),A.insertNode(n)),h()},x=async n=>{const b=a.querySelector("#upload-progress"),u=a.querySelector("#progress-bar"),y=a.querySelector("#progress-text");if(b&&u&&y){b.style.display="block";let q=0;const f=setInterval(()=>{q+=Math.random()*30,q>90&&(q=90),u.style.width=`${q}%`},200);try{const w=new FileReader;w.onload=()=>{clearInterval(f),u.style.width="100%",y.textContent="Upload complete",setTimeout(()=>{d=w.result,o="url",v(),m()},500)},w.readAsDataURL(n)}catch{clearInterval(f),y.textContent="Upload failed"}}},m=()=>{const n=a.querySelector(".close-btn"),b=a.querySelector(".cancel-btn"),u=a.querySelector("#insert-btn"),y=a.querySelector(".tab-upload"),q=a.querySelector(".tab-url");if(n?.addEventListener("click",h),b?.addEventListener("click",h),u?.addEventListener("click",L),y?.addEventListener("click",()=>{o="upload",v(),m()}),q?.addEventListener("click",()=>{o="url",v(),m()}),o==="upload"){const f=a.querySelector(".dropzone"),w=a.querySelector("#file-input");f?.addEventListener("click",()=>w?.click()),f?.addEventListener("dragover",S=>{S.preventDefault(),f.classList.add("is-dragover")}),f?.addEventListener("dragleave",()=>{f.classList.remove("is-dragover")}),f?.addEventListener("drop",S=>{S.preventDefault(),f.classList.remove("is-dragover");const z=S.dataTransfer?.files[0];z&&x(z)}),w?.addEventListener("change",S=>{const z=S.target.files?.[0];z&&x(z)})}if(o==="url"){const f=a.querySelector("#url-input"),w=a.querySelector("#alt-input"),S=a.querySelector("#width-input"),z=a.querySelector("#height-input");f?.addEventListener("input",()=>{d=f.value,v(),m()}),w?.addEventListener("input",()=>{g=w.value}),S?.addEventListener("input",()=>{c=S.value}),z?.addEventListener("input",()=>{p=z.value})}};m(),i.addEventListener("click",n=>{n.target===i&&h()})},K=()=>{["nw","ne","sw","se"].forEach(t=>{const r=document.createElement("div");r.className=`media-resize-handle-${t}`,r.style.cssText=`
position: fixed;

@@ -510,3 +510,3 @@ width: 10px;

box-shadow: 0 1px 3px rgba(0,0,0,0.3);
`,r.setAttribute("data-position",t),document.body.appendChild(r),R.push(r)})},M=()=>{if(!s){R.forEach(r=>r.style.display="none");return}const e=s.getBoundingClientRect(),t={nw:{x:e.left-5,y:e.top-5},ne:{x:e.right-5,y:e.top-5},sw:{x:e.left-5,y:e.bottom-5},se:{x:e.right-5,y:e.bottom-5}};R.forEach(r=>{const i=r.getAttribute("data-position"),a=t[i];r.style.left=`${a.x}px`,r.style.top=`${a.y}px`,r.style.display="block"})},Z=e=>{const t=D(e),r=B(!0);r.innerHTML=`
`,r.setAttribute("data-position",t),document.body.appendChild(r),R.push(r)})},M=()=>{if(!s){R.forEach(r=>r.style.display="none");return}const e=s.getBoundingClientRect(),t={nw:{x:e.left-5,y:e.top-5},ne:{x:e.right-5,y:e.top-5},sw:{x:e.left-5,y:e.bottom-5},se:{x:e.right-5,y:e.bottom-5}};R.forEach(r=>{const i=r.getAttribute("data-position"),a=t[i];r.style.left=`${a.x}px`,r.style.top=`${a.y}px`,r.style.display="block"})},J=e=>{const t=_(e),r=H(!0);r.innerHTML=`
<div class="rte-media-header">

@@ -525,3 +525,3 @@ <h2 class="rte-media-title">Edit Alt Text</h2>

</div>
`,t.appendChild(r),document.body.appendChild(t);const i=r.querySelector("#alt-text-input"),a=r.querySelector(".close-btn"),o=r.querySelector(".cancel-btn"),n=r.querySelector(".save-btn"),c=()=>{t.parentNode&&t.parentNode.removeChild(t)};a.addEventListener("click",c),o.addEventListener("click",c),t.addEventListener("click",m=>{m.target===t&&c()}),n.addEventListener("click",()=>{e.alt=i.value,c()}),i.focus(),i.select()},K=e=>{const t=e.closest("a"),r=t?.getAttribute("href")||"",i=t?.getAttribute("target")||"_self",a=t?.getAttribute("title")||"",o=D(e),n=B(!0);n.innerHTML=`
`,t.appendChild(r),document.body.appendChild(t);const i=r.querySelector("#alt-text-input"),a=r.querySelector(".close-btn"),o=r.querySelector(".cancel-btn"),d=r.querySelector(".save-btn");let c=()=>{};const p=()=>{c(),t.parentNode&&t.parentNode.removeChild(t)};c=B(t,p),a.addEventListener("click",p),o.addEventListener("click",p),t.addEventListener("click",g=>{g.target===t&&p()}),d.addEventListener("click",()=>{e.alt=i.value,p()}),i.focus(),i.select()},Q=e=>{const t=e.closest("a"),r=t?.getAttribute("href")||"",i=t?.getAttribute("target")||"_self",a=t?.getAttribute("title")||"",o=_(e),d=H(!0);d.innerHTML=`
<div class="rte-media-header">

@@ -552,3 +552,3 @@ <h2 class="rte-media-title">${t?"Edit Link":"Add Link"}</h2>

</div>
`,o.appendChild(n),document.body.appendChild(o);const c=n.querySelector("#link-url"),m=n.querySelector("#link-title"),b=n.querySelector("#link-target"),v=n.querySelector(".close-btn"),h=n.querySelector(".cancel-btn"),E=n.querySelector(".save-btn"),y=n.querySelector(".remove-link-btn"),u=()=>{o.parentNode&&o.parentNode.removeChild(o)};v.addEventListener("click",u),h.addEventListener("click",u),o.addEventListener("click",l=>{l.target===o&&u()}),E.addEventListener("click",()=>{const l=c.value.trim();if(l){const g=l.startsWith("http")?l:`https://${l}`;if(t)t.setAttribute("href",g),t.setAttribute("target",b.checked?"_blank":"_self"),b.checked?t.setAttribute("rel","noopener noreferrer"):t.removeAttribute("rel"),m.value.trim()?t.setAttribute("title",m.value.trim()):t.removeAttribute("title");else{const p=document.createElement("a");p.href=g,p.target=b.checked?"_blank":"_self",b.checked&&(p.rel="noopener noreferrer"),m.value.trim()&&(p.title=m.value.trim()),e.replaceWith(p),p.appendChild(e)}u(),d&&s&&H(s)}}),y?.addEventListener("click",()=>{t&&confirm("Remove link from this media?")&&(t.replaceWith(e),u(),d&&s&&H(s))}),c.focus()},J=e=>{const t=D(e),r=B();let i="url",a=e.src;const o=()=>{r.innerHTML=`
`,o.appendChild(d),document.body.appendChild(o);const c=d.querySelector("#link-url"),p=d.querySelector("#link-title"),g=d.querySelector("#link-target"),v=d.querySelector(".close-btn"),k=d.querySelector(".cancel-btn"),h=d.querySelector(".save-btn"),L=d.querySelector(".remove-link-btn");let x=()=>{};const m=()=>{x(),o.parentNode&&o.parentNode.removeChild(o)};x=B(o,m),v.addEventListener("click",m),k.addEventListener("click",m),o.addEventListener("click",n=>{n.target===o&&m()}),h.addEventListener("click",()=>{const n=c.value.trim();if(n){const b=n.startsWith("http")?n:`https://${n}`;if(t)t.setAttribute("href",b),t.setAttribute("target",g.checked?"_blank":"_self"),g.checked?t.setAttribute("rel","noopener noreferrer"):t.removeAttribute("rel"),p.value.trim()?t.setAttribute("title",p.value.trim()):t.removeAttribute("title");else{const u=document.createElement("a");u.href=b,u.target=g.checked?"_blank":"_self",g.checked&&(u.rel="noopener noreferrer"),p.value.trim()&&(u.title=p.value.trim()),e.replaceWith(u),u.appendChild(e)}m(),l&&s&&U(s)}}),L?.addEventListener("click",()=>{t&&confirm("Remove link from this media?")&&(t.replaceWith(e),m(),l&&s&&U(s))}),c.focus()},ee=e=>{const t=_(e),r=H();let i="url",a=e.src;const o=()=>{r.innerHTML=`
<div class="rte-media-header">

@@ -602,3 +602,3 @@ <h2 class="rte-media-title">Replace Image</h2>

</div>
`};o(),t.appendChild(r),document.body.appendChild(t);const n=()=>{t.parentNode&&t.parentNode.removeChild(t)},c=()=>{a&&(e.src=a,n())},m=async v=>{const h=r.querySelector("#upload-progress"),E=r.querySelector("#progress-bar"),y=r.querySelector("#progress-text");if(h&&E&&y){h.style.display="block";let u=0;const l=setInterval(()=>{u+=Math.random()*30,u>90&&(u=90),E.style.width=`${u}%`},200);try{const g=new FileReader;g.onload=()=>{clearInterval(l),E.style.width="100%",y.textContent="Upload complete",setTimeout(()=>{a=g.result,i="url",o(),b()},500)},g.readAsDataURL(v)}catch{clearInterval(l),y.textContent="Upload failed"}}},b=()=>{const v=r.querySelector(".close-btn"),h=r.querySelector(".cancel-btn"),E=r.querySelector("#replace-btn"),y=r.querySelector(".tab-upload"),u=r.querySelector(".tab-url");if(v?.addEventListener("click",n),h?.addEventListener("click",n),E?.addEventListener("click",c),y?.addEventListener("click",()=>{i="upload",o(),b()}),u?.addEventListener("click",()=>{i="url",o(),b()}),i==="upload"){const l=r.querySelector(".dropzone"),g=r.querySelector("#file-input");l?.addEventListener("click",()=>g?.click()),l?.addEventListener("dragover",p=>{p.preventDefault(),l.classList.add("is-dragover")}),l?.addEventListener("dragleave",()=>{l.classList.remove("is-dragover")}),l?.addEventListener("drop",p=>{p.preventDefault(),l.classList.remove("is-dragover");const x=p.dataTransfer?.files[0];x&&m(x)}),g?.addEventListener("change",p=>{const x=p.target.files?.[0];x&&m(x)})}if(i==="url"){const l=r.querySelector("#url-input");l?.addEventListener("input",()=>{a=l.value,o(),b()})}};b(),t.addEventListener("click",v=>{v.target===t&&n()})},w=()=>{if(!d||!s)return;const e=d.offsetHeight||40,t=s.offsetTop,r=s.offsetLeft,i=s.offsetWidth,a=t-e-8,o=r+i/2-(d.offsetWidth||120)/2;d.style.top=`${a}px`,d.style.left=`${o}px`,setTimeout(()=>{d&&(d.style.display="flex")},100)},H=e=>{d&&(d._cleanup&&d._cleanup(),d.remove());const t=e.parentElement;if(t){const n=t.style.position;(!n||n==="static")&&(t.style.position="relative",t._originalPosition=n),d=document.createElement("div"),d.className="media-floating-toolbar",F(e)&&d.classList.add("rte-ui-theme-dark"),t.insertBefore(d,t.firstChild),w()}const r=e.tagName==="IMG",i=e.closest("a");d.innerHTML=`
`};o(),t.appendChild(r),document.body.appendChild(t);let d=()=>{};const c=()=>{d(),t.parentNode&&t.parentNode.removeChild(t)};d=B(t,c);const p=()=>{a&&(e.src=a,c())},g=async k=>{const h=r.querySelector("#upload-progress"),L=r.querySelector("#progress-bar"),x=r.querySelector("#progress-text");if(h&&L&&x){h.style.display="block";let m=0;const n=setInterval(()=>{m+=Math.random()*30,m>90&&(m=90),L.style.width=`${m}%`},200);try{const b=new FileReader;b.onload=()=>{clearInterval(n),L.style.width="100%",x.textContent="Upload complete",setTimeout(()=>{a=b.result,i="url",o(),v()},500)},b.readAsDataURL(k)}catch{clearInterval(n),x.textContent="Upload failed"}}},v=()=>{const k=r.querySelector(".close-btn"),h=r.querySelector(".cancel-btn"),L=r.querySelector("#replace-btn"),x=r.querySelector(".tab-upload"),m=r.querySelector(".tab-url");if(k?.addEventListener("click",c),h?.addEventListener("click",c),L?.addEventListener("click",p),x?.addEventListener("click",()=>{i="upload",o(),v()}),m?.addEventListener("click",()=>{i="url",o(),v()}),i==="upload"){const n=r.querySelector(".dropzone"),b=r.querySelector("#file-input");n?.addEventListener("click",()=>b?.click()),n?.addEventListener("dragover",u=>{u.preventDefault(),n.classList.add("is-dragover")}),n?.addEventListener("dragleave",()=>{n.classList.remove("is-dragover")}),n?.addEventListener("drop",u=>{u.preventDefault(),n.classList.remove("is-dragover");const y=u.dataTransfer?.files[0];y&&g(y)}),b?.addEventListener("change",u=>{const y=u.target.files?.[0];y&&g(y)})}if(i==="url"){const n=r.querySelector("#url-input");n?.addEventListener("input",()=>{a=n.value,o(),v()})}};v(),t.addEventListener("click",k=>{k.target===t&&c()})},E=()=>{if(!l||!s)return;const e=l.offsetHeight||40,t=s.offsetTop,r=s.offsetLeft,i=s.offsetWidth,a=t-e-8,o=r+i/2-(l.offsetWidth||120)/2;l.style.top=`${a}px`,l.style.left=`${o}px`,setTimeout(()=>{l&&(l.style.display="flex")},100)},U=e=>{l&&(l._cleanup&&l._cleanup(),l.remove());const t=e.parentElement;if(t){const d=t.style.position;(!d||d==="static")&&(t.style.position="relative",t._originalPosition=d),l=document.createElement("div"),l.className="media-floating-toolbar",O(e)&&l.classList.add("rte-ui-theme-dark"),t.insertBefore(l,t.firstChild),E()}const r=e.tagName==="IMG",i=e.closest("a");l.innerHTML=`
<button class="media-floating-toolbar-btn btn-align-left" title="Align Left" type="button">

@@ -629,2 +629,2 @@ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="17" y1="10" x2="3" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="17" y1="18" x2="3" y2="18"></line></svg>

</button>
`,setTimeout(()=>{w()},0);const a=()=>w();let o=s.parentElement;for(;o;)o.addEventListener("scroll",a),o=o.parentElement;window.addEventListener("scroll",a),window.addEventListener("resize",a),d._cleanup=()=>{let n=s?.parentElement;for(;n;)n.removeEventListener("scroll",a),n=n.parentElement;window.removeEventListener("scroll",a),window.removeEventListener("resize",a)},d.querySelector(".btn-align-left")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="0",e.style.marginRight="auto",w()}),d.querySelector(".btn-align-center")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="auto",w()}),d.querySelector(".btn-align-right")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="0",w()}),d.querySelector(".btn-alt")?.addEventListener("click",()=>{e.tagName==="IMG"&&Z(e)}),d.querySelector(".btn-link")?.addEventListener("click",()=>{K(e)}),d.querySelector(".btn-replace")?.addEventListener("click",()=>{e.tagName==="IMG"&&J(e)}),d.querySelector(".btn-resize")?.addEventListener("click",()=>{const n=prompt("Enter width in pixels:",String(e.width||e.offsetWidth));if(n&&!isNaN(parseInt(n))){const c=parseInt(n);e.style.width=`${c}px`,e.setAttribute("width",String(c)),M(),w()}}),d.querySelector(".btn-remove")?.addEventListener("click",()=>{confirm("Remove this media?")&&(e.remove(),d&&(d._cleanup&&d._cleanup(),d.remove(),d=null),s=null,M())}),d._cleanup=()=>{window.removeEventListener("scroll",w),window.removeEventListener("resize",w)}},W=e=>{I=e||null,Y(),document.addEventListener("click",t=>{const r=t.target;if(r.tagName==="IMG"||r.tagName==="VIDEO"){const i=r;let a=!1;if(I?a=I.contains(i):a=!!i.closest('[contenteditable="true"]'),a){t.preventDefault(),t.stopPropagation(),s=i,s.style.display="block",H(i),M();return}}if(!r.closest(".btn-link, .btn-resize, .btn-remove")&&d&&!r.closest("button")){if(d._cleanup&&d._cleanup(),d.remove(),d=null,s&&s.parentElement){const i=s.parentElement;i._originalPosition!==void 0&&(i.style.position=i._originalPosition,delete i._originalPosition)}s=null,M()}}),R.forEach(t=>{t.addEventListener("mousedown",r=>{if(!s)return;r.preventDefault(),r.stopPropagation(),A=!0,q=t.getAttribute("data-position"),U=r.clientX,P=r.clientY;const i=s.getBoundingClientRect();z=i.width,$=i.height,_=z/$,document.body.style.userSelect="none",document.body.style.cursor=`${q}-resize`})}),document.addEventListener("mousemove",t=>{if(!A||!s||!q)return;const r=t.clientX-U,i=t.clientY-P;let a=z,o=$;switch(q){case"se":a=z+r,o=$+i;break;case"sw":a=z-r,o=$+i;break;case"ne":a=z+r,o=$-i;break;case"nw":a=z-r,o=$-i;break}Math.abs(r)>Math.abs(i)?o=a/_:a=o*_,a=Math.max(50,a),o=Math.max(50,o),s.style.width=`${a}px`,s.style.height=`${o}px`,s.setAttribute("width",String(Math.round(a))),s.setAttribute("height",String(Math.round(o))),M(),w()}),document.addEventListener("mouseup",()=>{A&&(A=!1,q=null,document.body.style.userSelect="",document.body.style.cursor="")}),window.addEventListener("scroll",M),window.addEventListener("resize",M)};typeof window<"u"&&!window.__mediaManagerInitialized&&(window.__mediaManagerInitialized=!0,W());const Q=()=>({name:"image",initialize:e=>{const t=e?.editorElement;W(t)},toolbar:[{label:"Image",command:"insertImage",icon:'<svg width="24px" height="24px" viewBox="0 0 32 32" enable-background="new 0 0 32 32"><g><rect fill="none" height="22" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2" width="30" x="1" y="5"></rect><polygon fill="none" points="31,27 21,17 11,27" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></polygon><polygon fill="none" points="18,20 9,11 1,19 1,27 11,27" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></polygon><circle cx="19" cy="11" fill="none" r="2" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></circle></g></svg>'},{label:"Video",command:"insertVideo",icon:'<svg width="24" height="24" focusable="false"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5H5Zm4.8 2.6 5.6 4a.5.5 0 0 1 0 .8l-5.6 4A.5.5 0 0 1 9 16V8a.5.5 0 0 1 .8-.4Z" fill-rule="nonzero"></path></svg>'}],commands:{insertImage:(e,t)=>{const r=t?.contentElement instanceof HTMLElement?t.contentElement:void 0;return V("image",r),!0},insertVideo:(e,t)=>{const r=t?.contentElement instanceof HTMLElement?t.contentElement:void 0;return V("video",r),!0}},keymap:{"Mod-Shift-i":"insertImage"}}),ee={apiEndpoints:{upload:"/media/upload",library:"/media/library",delete:"/media/library"},maxFileSize:10*1024*1024,allowedTypes:["image/jpeg","image/png","image/gif","video/mp4","video/webm"],headers:{}};let N={...ee};function te(e){N={...N,...e}}function re(){return{...N}}exports.MediaManagerPlugin=Q;exports.getMediaManagerConfig=re;exports.setMediaManagerConfig=te;
`,setTimeout(()=>{E()},0);const a=()=>E();let o=s.parentElement;for(;o;)o.addEventListener("scroll",a),o=o.parentElement;window.addEventListener("scroll",a),window.addEventListener("resize",a),l._cleanup=()=>{let d=s?.parentElement;for(;d;)d.removeEventListener("scroll",a),d=d.parentElement;window.removeEventListener("scroll",a),window.removeEventListener("resize",a)},l.querySelector(".btn-align-left")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="0",e.style.marginRight="auto",E()}),l.querySelector(".btn-align-center")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="auto",E()}),l.querySelector(".btn-align-right")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="0",E()}),l.querySelector(".btn-alt")?.addEventListener("click",()=>{e.tagName==="IMG"&&J(e)}),l.querySelector(".btn-link")?.addEventListener("click",()=>{Q(e)}),l.querySelector(".btn-replace")?.addEventListener("click",()=>{e.tagName==="IMG"&&ee(e)}),l.querySelector(".btn-resize")?.addEventListener("click",()=>{const d=prompt("Enter width in pixels:",String(e.width||e.offsetWidth));if(d&&!isNaN(parseInt(d))){const c=parseInt(d);e.style.width=`${c}px`,e.setAttribute("width",String(c)),M(),E()}}),l.querySelector(".btn-remove")?.addEventListener("click",()=>{confirm("Remove this media?")&&(e.remove(),l&&(l._cleanup&&l._cleanup(),l.remove(),l=null),s=null,M())}),l._cleanup=()=>{window.removeEventListener("scroll",E),window.removeEventListener("resize",E)}},G=e=>{T=e||null,K(),document.addEventListener("click",t=>{const r=t.target;if(r.tagName==="IMG"||r.tagName==="VIDEO"){const i=r;let a=!1;if(T?a=T.contains(i):a=!!i.closest('[contenteditable="true"]'),a){t.preventDefault(),t.stopPropagation(),s=i,s.style.display="block",U(i),M();return}}if(!r.closest(".btn-link, .btn-resize, .btn-remove")&&l&&!r.closest("button")){if(l._cleanup&&l._cleanup(),l.remove(),l=null,s&&s.parentElement){const i=s.parentElement;i._originalPosition!==void 0&&(i.style.position=i._originalPosition,delete i._originalPosition)}s=null,M()}}),R.forEach(t=>{t.addEventListener("mousedown",r=>{if(!s)return;r.preventDefault(),r.stopPropagation(),D=!0,I=t.getAttribute("data-position"),V=r.clientX,j=r.clientY;const i=s.getBoundingClientRect();C=i.width,$=i.height,N=C/$,document.body.style.userSelect="none",document.body.style.cursor=`${I}-resize`})}),document.addEventListener("mousemove",t=>{if(!D||!s||!I)return;const r=t.clientX-V,i=t.clientY-j;let a=C,o=$;switch(I){case"se":a=C+r,o=$+i;break;case"sw":a=C-r,o=$+i;break;case"ne":a=C+r,o=$-i;break;case"nw":a=C-r,o=$-i;break}Math.abs(r)>Math.abs(i)?o=a/N:a=o*N,a=Math.max(50,a),o=Math.max(50,o),s.style.width=`${a}px`,s.style.height=`${o}px`,s.setAttribute("width",String(Math.round(a))),s.setAttribute("height",String(Math.round(o))),M(),E()}),document.addEventListener("mouseup",()=>{D&&(D=!1,I=null,document.body.style.userSelect="",document.body.style.cursor="")}),window.addEventListener("scroll",M),window.addEventListener("resize",M)};typeof window<"u"&&!window.__mediaManagerInitialized&&(window.__mediaManagerInitialized=!0,G());const te=()=>({name:"image",initialize:e=>{const t=e?.editorElement;G(t)},toolbar:[{label:"Image",command:"insertImage",icon:'<svg width="24px" height="24px" viewBox="0 0 32 32" enable-background="new 0 0 32 32"><g><rect fill="none" height="22" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2" width="30" x="1" y="5"></rect><polygon fill="none" points="31,27 21,17 11,27" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></polygon><polygon fill="none" points="18,20 9,11 1,19 1,27 11,27" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></polygon><circle cx="19" cy="11" fill="none" r="2" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></circle></g></svg>'},{label:"Video",command:"insertVideo",icon:'<svg width="24" height="24" focusable="false"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5H5Zm4.8 2.6 5.6 4a.5.5 0 0 1 0 .8l-5.6 4A.5.5 0 0 1 9 16V8a.5.5 0 0 1 .8-.4Z" fill-rule="nonzero"></path></svg>'}],commands:{insertImage:(e,t)=>{const r=t?.contentElement instanceof HTMLElement?t.contentElement:void 0;return F("image",r),!0},insertVideo:(e,t)=>{const r=t?.contentElement instanceof HTMLElement?t.contentElement:void 0;return F("video",r),!0}},keymap:{"Mod-Shift-i":"insertImage"}}),re={apiEndpoints:{upload:"/media/upload",library:"/media/library",delete:"/media/library"},maxFileSize:10*1024*1024,allowedTypes:["image/jpeg","image/png","image/gif","video/mp4","video/webm"],headers:{}};let P={...re};function ae(e){P={...P,...e}}function ie(){return{...P}}exports.MediaManagerPlugin=te;exports.getMediaManagerConfig=ie;exports.setMediaManagerConfig=ae;
import "./shared-config.esm.js";
let T = null, s = null, d = null, R = [], A = !1, M = null, U = 0, V = 0, z = 0, $ = 0, _ = 1, I = null;
const j = '[data-theme="dark"], .dark, .editora-theme-dark', G = () => {
let A = null, s = null, l = null, R = [], D = !1, I = null, V = 0, j = 0, $ = 0, C = 0, N = 1, T = null;
const W = '[data-theme="dark"], .dark, .editora-theme-dark', B = (e, t) => {
const r = (i) => {
i.key !== "Escape" || !e.isConnected || (i.preventDefault(), i.stopPropagation(), t());
};
return document.addEventListener("keydown", r, !0), () => {
document.removeEventListener("keydown", r, !0);
};
}, X = () => {
if (typeof document > "u" || document.getElementById("rte-media-dialog-styles")) return;

@@ -384,3 +391,3 @@ const e = document.createElement("style");

.media-floating-toolbar.rte-ui-theme-dark,
${j} .media-floating-toolbar {
${W} .media-floating-toolbar {
--rte-media-toolbar-bg: #24303f;

@@ -434,3 +441,3 @@ --rte-media-toolbar-border: #4a5a71;

`, document.head.appendChild(e);
}, O = () => {
}, Y = () => {
const e = window.getSelection();

@@ -440,24 +447,24 @@ if (!e || e.rangeCount === 0) return null;

return (t instanceof HTMLElement ? t : t?.parentElement)?.closest(".rte-content, .editora-content") || null;
}, X = (e) => {
}, Z = (e) => {
if (e) return e;
const t = O();
const t = Y();
if (t) return t;
if (I) return I;
if (T) return T;
const r = document.activeElement;
return r ? r.closest(".rte-content, .editora-content") || r : null;
}, F = (e) => {
const t = X(e);
return t ? !!t.closest(j) : !1;
}, D = (e) => {
G();
}, G = (e) => {
const t = Z(e);
return t ? !!t.closest(W) : !1;
}, _ = (e) => {
X();
const t = document.createElement("div");
return t.className = "rte-media-overlay", F(e) && t.classList.add("rte-ui-theme-dark"), t;
}, B = (e = !1) => {
return t.className = "rte-media-overlay", G(e) && t.classList.add("rte-ui-theme-dark"), t;
}, H = (e = !1) => {
const t = document.createElement("div");
return t.className = e ? "rte-media-dialog rte-media-dialog-compact" : "rte-media-dialog", t.setAttribute("role", "dialog"), t.setAttribute("aria-modal", "true"), t;
}, P = (e, t) => {
}, F = (e, t) => {
const r = window.getSelection();
r && r.rangeCount > 0 && (T = r.getRangeAt(0).cloneRange());
const i = D(t), a = B();
let o = "upload", n = "", c = "", m = "", b = "";
r && r.rangeCount > 0 && (A = r.getRangeAt(0).cloneRange());
const i = _(t), a = H();
let o = "upload", d = "", c = "", p = "", g = "";
const v = () => {

@@ -496,3 +503,3 @@ a.innerHTML = `

<label class="rte-media-label">URL</label>
<input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/${e}.${e === "image" ? "jpg" : "mp4"}" value="${n}">
<input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/${e}.${e === "image" ? "jpg" : "mp4"}" value="${d}">
</div>

@@ -502,3 +509,3 @@ ${e === "image" ? `

<label class="rte-media-label">Alt Text (for accessibility)</label>
<input type="text" id="alt-input" class="rte-media-input" placeholder="Describe the image" value="${b}">
<input type="text" id="alt-input" class="rte-media-input" placeholder="Describe the image" value="${g}">
</div>

@@ -513,10 +520,10 @@ ` : ""}

<label class="rte-media-label">Height (px)</label>
<input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${m}">
<input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${p}">
</div>
</div>
${n ? `
${d ? `
<div class="rte-media-field">
<label class="rte-media-label">Preview</label>
<div class="rte-media-preview">
${e === "image" ? `<img src="${n}" alt="Preview">` : `<video src="${n}" controls></video>`}
${e === "image" ? `<img src="${d}" alt="Preview">` : `<video src="${d}" controls></video>`}
</div>

@@ -531,3 +538,3 @@ </div>

<button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
<button id="insert-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!n && o === "url" ? "disabled" : ""}>Insert</button>
<button id="insert-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!d && o === "url" ? "disabled" : ""}>Insert</button>
</div>

@@ -537,65 +544,69 @@ `;

v(), i.appendChild(a), document.body.appendChild(i);
let k = () => {
};
const h = () => {
i.parentNode && i.parentNode.removeChild(i);
}, E = () => {
if (!n) return;
const l = e === "image" ? document.createElement("img") : document.createElement("video");
l.src = n, l.setAttribute("data-media-type", e), e === "image" && b && (l.alt = b), c && (l.style.width = `${c}px`, l.setAttribute("width", c)), m && (l.style.height = `${m}px`, l.setAttribute("height", m)), e === "video" && (l.controls = !0), !c && !m ? l.style.cssText = "max-width: 100%; height: auto; display: block; margin: 1em 0; cursor: pointer;" : l.style.cssText = `display: block; margin: 1em 0; cursor: pointer; ${c ? `width: ${c}px;` : "max-width: 100%;"} ${m ? `height: ${m}px;` : "height: auto;"}`, T && (T.deleteContents(), T.insertNode(l)), h();
}, y = async (l) => {
const g = a.querySelector("#upload-progress"), p = a.querySelector("#progress-bar"), x = a.querySelector("#progress-text");
if (g && p && x) {
g.style.display = "block";
let q = 0;
k(), i.parentNode && i.parentNode.removeChild(i);
};
k = B(i, h);
const L = () => {
if (!d) return;
const n = e === "image" ? document.createElement("img") : document.createElement("video");
n.src = d, n.setAttribute("data-media-type", e), e === "image" && g && (n.alt = g), c && (n.style.width = `${c}px`, n.setAttribute("width", c)), p && (n.style.height = `${p}px`, n.setAttribute("height", p)), e === "video" && (n.controls = !0), !c && !p ? n.style.cssText = "max-width: 100%; height: auto; display: block; margin: 1em 0; cursor: pointer;" : n.style.cssText = `display: block; margin: 1em 0; cursor: pointer; ${c ? `width: ${c}px;` : "max-width: 100%;"} ${p ? `height: ${p}px;` : "height: auto;"}`, A && (A.deleteContents(), A.insertNode(n)), h();
}, x = async (n) => {
const b = a.querySelector("#upload-progress"), u = a.querySelector("#progress-bar"), y = a.querySelector("#progress-text");
if (b && u && y) {
b.style.display = "block";
let M = 0;
const f = setInterval(() => {
q += Math.random() * 30, q > 90 && (q = 90), p.style.width = `${q}%`;
M += Math.random() * 30, M > 90 && (M = 90), u.style.width = `${M}%`;
}, 200);
try {
const k = new FileReader();
k.onload = () => {
clearInterval(f), p.style.width = "100%", x.textContent = "Upload complete", setTimeout(() => {
n = k.result, o = "url", v(), u();
const w = new FileReader();
w.onload = () => {
clearInterval(f), u.style.width = "100%", y.textContent = "Upload complete", setTimeout(() => {
d = w.result, o = "url", v(), m();
}, 500);
}, k.readAsDataURL(l);
}, w.readAsDataURL(n);
} catch {
clearInterval(f), x.textContent = "Upload failed";
clearInterval(f), y.textContent = "Upload failed";
}
}
}, u = () => {
const l = a.querySelector(".close-btn"), g = a.querySelector(".cancel-btn"), p = a.querySelector("#insert-btn"), x = a.querySelector(".tab-upload"), q = a.querySelector(".tab-url");
if (l?.addEventListener("click", h), g?.addEventListener("click", h), p?.addEventListener("click", E), x?.addEventListener("click", () => {
o = "upload", v(), u();
}), q?.addEventListener("click", () => {
o = "url", v(), u();
}, m = () => {
const n = a.querySelector(".close-btn"), b = a.querySelector(".cancel-btn"), u = a.querySelector("#insert-btn"), y = a.querySelector(".tab-upload"), M = a.querySelector(".tab-url");
if (n?.addEventListener("click", h), b?.addEventListener("click", h), u?.addEventListener("click", L), y?.addEventListener("click", () => {
o = "upload", v(), m();
}), M?.addEventListener("click", () => {
o = "url", v(), m();
}), o === "upload") {
const f = a.querySelector(".dropzone"), k = a.querySelector("#file-input");
f?.addEventListener("click", () => k?.click()), f?.addEventListener("dragover", (L) => {
L.preventDefault(), f.classList.add("is-dragover");
const f = a.querySelector(".dropzone"), w = a.querySelector("#file-input");
f?.addEventListener("click", () => w?.click()), f?.addEventListener("dragover", (S) => {
S.preventDefault(), f.classList.add("is-dragover");
}), f?.addEventListener("dragleave", () => {
f.classList.remove("is-dragover");
}), f?.addEventListener("drop", (L) => {
L.preventDefault(), f.classList.remove("is-dragover");
const S = L.dataTransfer?.files[0];
S && y(S);
}), k?.addEventListener("change", (L) => {
const S = L.target.files?.[0];
S && y(S);
}), f?.addEventListener("drop", (S) => {
S.preventDefault(), f.classList.remove("is-dragover");
const z = S.dataTransfer?.files[0];
z && x(z);
}), w?.addEventListener("change", (S) => {
const z = S.target.files?.[0];
z && x(z);
});
}
if (o === "url") {
const f = a.querySelector("#url-input"), k = a.querySelector("#alt-input"), L = a.querySelector("#width-input"), S = a.querySelector("#height-input");
const f = a.querySelector("#url-input"), w = a.querySelector("#alt-input"), S = a.querySelector("#width-input"), z = a.querySelector("#height-input");
f?.addEventListener("input", () => {
n = f.value, v(), u();
}), k?.addEventListener("input", () => {
b = k.value;
}), L?.addEventListener("input", () => {
c = L.value;
d = f.value, v(), m();
}), w?.addEventListener("input", () => {
g = w.value;
}), S?.addEventListener("input", () => {
m = S.value;
c = S.value;
}), z?.addEventListener("input", () => {
p = z.value;
});
}
};
u(), i.addEventListener("click", (l) => {
l.target === i && h();
m(), i.addEventListener("click", (n) => {
n.target === i && h();
});
}, Y = () => {
}, K = () => {
["nw", "ne", "sw", "se"].forEach((t) => {

@@ -616,3 +627,3 @@ const r = document.createElement("div");

});
}, C = () => {
}, q = () => {
if (!s) {

@@ -632,4 +643,4 @@ R.forEach((r) => r.style.display = "none");

});
}, Z = (e) => {
const t = D(e), r = B(!0);
}, J = (e) => {
const t = _(e), r = H(!0);
r.innerHTML = `

@@ -650,13 +661,16 @@ <div class="rte-media-header">

`, t.appendChild(r), document.body.appendChild(t);
const i = r.querySelector("#alt-text-input"), a = r.querySelector(".close-btn"), o = r.querySelector(".cancel-btn"), n = r.querySelector(".save-btn"), c = () => {
t.parentNode && t.parentNode.removeChild(t);
const i = r.querySelector("#alt-text-input"), a = r.querySelector(".close-btn"), o = r.querySelector(".cancel-btn"), d = r.querySelector(".save-btn");
let c = () => {
};
a.addEventListener("click", c), o.addEventListener("click", c), t.addEventListener("click", (m) => {
m.target === t && c();
}), n.addEventListener("click", () => {
e.alt = i.value, c();
const p = () => {
c(), t.parentNode && t.parentNode.removeChild(t);
};
c = B(t, p), a.addEventListener("click", p), o.addEventListener("click", p), t.addEventListener("click", (g) => {
g.target === t && p();
}), d.addEventListener("click", () => {
e.alt = i.value, p();
}), i.focus(), i.select();
}, K = (e) => {
const t = e.closest("a"), r = t?.getAttribute("href") || "", i = t?.getAttribute("target") || "_self", a = t?.getAttribute("title") || "", o = D(e), n = B(!0);
n.innerHTML = `
}, Q = (e) => {
const t = e.closest("a"), r = t?.getAttribute("href") || "", i = t?.getAttribute("target") || "_self", a = t?.getAttribute("title") || "", o = _(e), d = H(!0);
d.innerHTML = `
<div class="rte-media-header">

@@ -687,25 +701,28 @@ <h2 class="rte-media-title">${t ? "Edit Link" : "Add Link"}</h2>

</div>
`, o.appendChild(n), document.body.appendChild(o);
const c = n.querySelector("#link-url"), m = n.querySelector("#link-title"), b = n.querySelector("#link-target"), v = n.querySelector(".close-btn"), h = n.querySelector(".cancel-btn"), E = n.querySelector(".save-btn"), y = n.querySelector(".remove-link-btn"), u = () => {
o.parentNode && o.parentNode.removeChild(o);
`, o.appendChild(d), document.body.appendChild(o);
const c = d.querySelector("#link-url"), p = d.querySelector("#link-title"), g = d.querySelector("#link-target"), v = d.querySelector(".close-btn"), k = d.querySelector(".cancel-btn"), h = d.querySelector(".save-btn"), L = d.querySelector(".remove-link-btn");
let x = () => {
};
v.addEventListener("click", u), h.addEventListener("click", u), o.addEventListener("click", (l) => {
l.target === o && u();
}), E.addEventListener("click", () => {
const l = c.value.trim();
if (l) {
const g = l.startsWith("http") ? l : `https://${l}`;
const m = () => {
x(), o.parentNode && o.parentNode.removeChild(o);
};
x = B(o, m), v.addEventListener("click", m), k.addEventListener("click", m), o.addEventListener("click", (n) => {
n.target === o && m();
}), h.addEventListener("click", () => {
const n = c.value.trim();
if (n) {
const b = n.startsWith("http") ? n : `https://${n}`;
if (t)
t.setAttribute("href", g), t.setAttribute("target", b.checked ? "_blank" : "_self"), b.checked ? t.setAttribute("rel", "noopener noreferrer") : t.removeAttribute("rel"), m.value.trim() ? t.setAttribute("title", m.value.trim()) : t.removeAttribute("title");
t.setAttribute("href", b), t.setAttribute("target", g.checked ? "_blank" : "_self"), g.checked ? t.setAttribute("rel", "noopener noreferrer") : t.removeAttribute("rel"), p.value.trim() ? t.setAttribute("title", p.value.trim()) : t.removeAttribute("title");
else {
const p = document.createElement("a");
p.href = g, p.target = b.checked ? "_blank" : "_self", b.checked && (p.rel = "noopener noreferrer"), m.value.trim() && (p.title = m.value.trim()), e.replaceWith(p), p.appendChild(e);
const u = document.createElement("a");
u.href = b, u.target = g.checked ? "_blank" : "_self", g.checked && (u.rel = "noopener noreferrer"), p.value.trim() && (u.title = p.value.trim()), e.replaceWith(u), u.appendChild(e);
}
u(), d && s && H(s);
m(), l && s && U(s);
}
}), y?.addEventListener("click", () => {
t && confirm("Remove link from this media?") && (t.replaceWith(e), u(), d && s && H(s));
}), L?.addEventListener("click", () => {
t && confirm("Remove link from this media?") && (t.replaceWith(e), m(), l && s && U(s));
}), c.focus();
}, J = (e) => {
const t = D(e), r = B();
}, ee = (e) => {
const t = _(e), r = H();
let i = "url", a = e.src;

@@ -765,71 +782,75 @@ const o = () => {

o(), t.appendChild(r), document.body.appendChild(t);
const n = () => {
t.parentNode && t.parentNode.removeChild(t);
}, c = () => {
a && (e.src = a, n());
}, m = async (v) => {
const h = r.querySelector("#upload-progress"), E = r.querySelector("#progress-bar"), y = r.querySelector("#progress-text");
if (h && E && y) {
let d = () => {
};
const c = () => {
d(), t.parentNode && t.parentNode.removeChild(t);
};
d = B(t, c);
const p = () => {
a && (e.src = a, c());
}, g = async (k) => {
const h = r.querySelector("#upload-progress"), L = r.querySelector("#progress-bar"), x = r.querySelector("#progress-text");
if (h && L && x) {
h.style.display = "block";
let u = 0;
const l = setInterval(() => {
u += Math.random() * 30, u > 90 && (u = 90), E.style.width = `${u}%`;
let m = 0;
const n = setInterval(() => {
m += Math.random() * 30, m > 90 && (m = 90), L.style.width = `${m}%`;
}, 200);
try {
const g = new FileReader();
g.onload = () => {
clearInterval(l), E.style.width = "100%", y.textContent = "Upload complete", setTimeout(() => {
a = g.result, i = "url", o(), b();
const b = new FileReader();
b.onload = () => {
clearInterval(n), L.style.width = "100%", x.textContent = "Upload complete", setTimeout(() => {
a = b.result, i = "url", o(), v();
}, 500);
}, g.readAsDataURL(v);
}, b.readAsDataURL(k);
} catch {
clearInterval(l), y.textContent = "Upload failed";
clearInterval(n), x.textContent = "Upload failed";
}
}
}, b = () => {
const v = r.querySelector(".close-btn"), h = r.querySelector(".cancel-btn"), E = r.querySelector("#replace-btn"), y = r.querySelector(".tab-upload"), u = r.querySelector(".tab-url");
if (v?.addEventListener("click", n), h?.addEventListener("click", n), E?.addEventListener("click", c), y?.addEventListener("click", () => {
i = "upload", o(), b();
}), u?.addEventListener("click", () => {
i = "url", o(), b();
}, v = () => {
const k = r.querySelector(".close-btn"), h = r.querySelector(".cancel-btn"), L = r.querySelector("#replace-btn"), x = r.querySelector(".tab-upload"), m = r.querySelector(".tab-url");
if (k?.addEventListener("click", c), h?.addEventListener("click", c), L?.addEventListener("click", p), x?.addEventListener("click", () => {
i = "upload", o(), v();
}), m?.addEventListener("click", () => {
i = "url", o(), v();
}), i === "upload") {
const l = r.querySelector(".dropzone"), g = r.querySelector("#file-input");
l?.addEventListener("click", () => g?.click()), l?.addEventListener("dragover", (p) => {
p.preventDefault(), l.classList.add("is-dragover");
}), l?.addEventListener("dragleave", () => {
l.classList.remove("is-dragover");
}), l?.addEventListener("drop", (p) => {
p.preventDefault(), l.classList.remove("is-dragover");
const x = p.dataTransfer?.files[0];
x && m(x);
}), g?.addEventListener("change", (p) => {
const x = p.target.files?.[0];
x && m(x);
const n = r.querySelector(".dropzone"), b = r.querySelector("#file-input");
n?.addEventListener("click", () => b?.click()), n?.addEventListener("dragover", (u) => {
u.preventDefault(), n.classList.add("is-dragover");
}), n?.addEventListener("dragleave", () => {
n.classList.remove("is-dragover");
}), n?.addEventListener("drop", (u) => {
u.preventDefault(), n.classList.remove("is-dragover");
const y = u.dataTransfer?.files[0];
y && g(y);
}), b?.addEventListener("change", (u) => {
const y = u.target.files?.[0];
y && g(y);
});
}
if (i === "url") {
const l = r.querySelector("#url-input");
l?.addEventListener("input", () => {
a = l.value, o(), b();
const n = r.querySelector("#url-input");
n?.addEventListener("input", () => {
a = n.value, o(), v();
});
}
};
b(), t.addEventListener("click", (v) => {
v.target === t && n();
v(), t.addEventListener("click", (k) => {
k.target === t && c();
});
}, w = () => {
if (!d || !s) return;
const e = d.offsetHeight || 40, t = s.offsetTop, r = s.offsetLeft, i = s.offsetWidth, a = t - e - 8, o = r + i / 2 - (d.offsetWidth || 120) / 2;
d.style.top = `${a}px`, d.style.left = `${o}px`, setTimeout(() => {
d && (d.style.display = "flex");
}, E = () => {
if (!l || !s) return;
const e = l.offsetHeight || 40, t = s.offsetTop, r = s.offsetLeft, i = s.offsetWidth, a = t - e - 8, o = r + i / 2 - (l.offsetWidth || 120) / 2;
l.style.top = `${a}px`, l.style.left = `${o}px`, setTimeout(() => {
l && (l.style.display = "flex");
}, 100);
}, H = (e) => {
d && (d._cleanup && d._cleanup(), d.remove());
}, U = (e) => {
l && (l._cleanup && l._cleanup(), l.remove());
const t = e.parentElement;
if (t) {
const n = t.style.position;
(!n || n === "static") && (t.style.position = "relative", t._originalPosition = n), d = document.createElement("div"), d.className = "media-floating-toolbar", F(e) && d.classList.add("rte-ui-theme-dark"), t.insertBefore(d, t.firstChild), w();
const d = t.style.position;
(!d || d === "static") && (t.style.position = "relative", t._originalPosition = d), l = document.createElement("div"), l.className = "media-floating-toolbar", G(e) && l.classList.add("rte-ui-theme-dark"), t.insertBefore(l, t.firstChild), E();
}
const r = e.tagName === "IMG", i = e.closest("a");
d.innerHTML = `
l.innerHTML = `
<button class="media-floating-toolbar-btn btn-align-left" title="Align Left" type="button">

@@ -861,38 +882,38 @@ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="17" y1="10" x2="3" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="17" y1="18" x2="3" y2="18"></line></svg>

`, setTimeout(() => {
w();
E();
}, 0);
const a = () => w();
const a = () => E();
let o = s.parentElement;
for (; o; )
o.addEventListener("scroll", a), o = o.parentElement;
window.addEventListener("scroll", a), window.addEventListener("resize", a), d._cleanup = () => {
let n = s?.parentElement;
for (; n; )
n.removeEventListener("scroll", a), n = n.parentElement;
window.addEventListener("scroll", a), window.addEventListener("resize", a), l._cleanup = () => {
let d = s?.parentElement;
for (; d; )
d.removeEventListener("scroll", a), d = d.parentElement;
window.removeEventListener("scroll", a), window.removeEventListener("resize", a);
}, d.querySelector(".btn-align-left")?.addEventListener("click", () => {
e.style.display = "block", e.style.marginLeft = "0", e.style.marginRight = "auto", w();
}), d.querySelector(".btn-align-center")?.addEventListener("click", () => {
e.style.display = "block", e.style.marginLeft = "auto", e.style.marginRight = "auto", w();
}), d.querySelector(".btn-align-right")?.addEventListener("click", () => {
e.style.display = "block", e.style.marginLeft = "auto", e.style.marginRight = "0", w();
}), d.querySelector(".btn-alt")?.addEventListener("click", () => {
e.tagName === "IMG" && Z(e);
}), d.querySelector(".btn-link")?.addEventListener("click", () => {
K(e);
}), d.querySelector(".btn-replace")?.addEventListener("click", () => {
}, l.querySelector(".btn-align-left")?.addEventListener("click", () => {
e.style.display = "block", e.style.marginLeft = "0", e.style.marginRight = "auto", E();
}), l.querySelector(".btn-align-center")?.addEventListener("click", () => {
e.style.display = "block", e.style.marginLeft = "auto", e.style.marginRight = "auto", E();
}), l.querySelector(".btn-align-right")?.addEventListener("click", () => {
e.style.display = "block", e.style.marginLeft = "auto", e.style.marginRight = "0", E();
}), l.querySelector(".btn-alt")?.addEventListener("click", () => {
e.tagName === "IMG" && J(e);
}), d.querySelector(".btn-resize")?.addEventListener("click", () => {
const n = prompt("Enter width in pixels:", String(e.width || e.offsetWidth));
if (n && !isNaN(parseInt(n))) {
const c = parseInt(n);
e.style.width = `${c}px`, e.setAttribute("width", String(c)), C(), w();
}), l.querySelector(".btn-link")?.addEventListener("click", () => {
Q(e);
}), l.querySelector(".btn-replace")?.addEventListener("click", () => {
e.tagName === "IMG" && ee(e);
}), l.querySelector(".btn-resize")?.addEventListener("click", () => {
const d = prompt("Enter width in pixels:", String(e.width || e.offsetWidth));
if (d && !isNaN(parseInt(d))) {
const c = parseInt(d);
e.style.width = `${c}px`, e.setAttribute("width", String(c)), q(), E();
}
}), d.querySelector(".btn-remove")?.addEventListener("click", () => {
confirm("Remove this media?") && (e.remove(), d && (d._cleanup && d._cleanup(), d.remove(), d = null), s = null, C());
}), d._cleanup = () => {
window.removeEventListener("scroll", w), window.removeEventListener("resize", w);
}), l.querySelector(".btn-remove")?.addEventListener("click", () => {
confirm("Remove this media?") && (e.remove(), l && (l._cleanup && l._cleanup(), l.remove(), l = null), s = null, q());
}), l._cleanup = () => {
window.removeEventListener("scroll", E), window.removeEventListener("resize", E);
};
}, W = (e) => {
I = e || null, Y(), document.addEventListener("click", (t) => {
}, O = (e) => {
T = e || null, K(), document.addEventListener("click", (t) => {
const r = t.target;

@@ -902,13 +923,13 @@ if (r.tagName === "IMG" || r.tagName === "VIDEO") {

let a = !1;
if (I ? a = I.contains(i) : a = !!i.closest('[contenteditable="true"]'), a) {
t.preventDefault(), t.stopPropagation(), s = i, s.style.display = "block", H(i), C();
if (T ? a = T.contains(i) : a = !!i.closest('[contenteditable="true"]'), a) {
t.preventDefault(), t.stopPropagation(), s = i, s.style.display = "block", U(i), q();
return;
}
}
if (!r.closest(".btn-link, .btn-resize, .btn-remove") && d && !r.closest("button")) {
if (d._cleanup && d._cleanup(), d.remove(), d = null, s && s.parentElement) {
if (!r.closest(".btn-link, .btn-resize, .btn-remove") && l && !r.closest("button")) {
if (l._cleanup && l._cleanup(), l.remove(), l = null, s && s.parentElement) {
const i = s.parentElement;
i._originalPosition !== void 0 && (i.style.position = i._originalPosition, delete i._originalPosition);
}
s = null, C();
s = null, q();
}

@@ -918,35 +939,35 @@ }), R.forEach((t) => {

if (!s) return;
r.preventDefault(), r.stopPropagation(), A = !0, M = t.getAttribute("data-position"), U = r.clientX, V = r.clientY;
r.preventDefault(), r.stopPropagation(), D = !0, I = t.getAttribute("data-position"), V = r.clientX, j = r.clientY;
const i = s.getBoundingClientRect();
z = i.width, $ = i.height, _ = z / $, document.body.style.userSelect = "none", document.body.style.cursor = `${M}-resize`;
$ = i.width, C = i.height, N = $ / C, document.body.style.userSelect = "none", document.body.style.cursor = `${I}-resize`;
});
}), document.addEventListener("mousemove", (t) => {
if (!A || !s || !M) return;
const r = t.clientX - U, i = t.clientY - V;
let a = z, o = $;
switch (M) {
if (!D || !s || !I) return;
const r = t.clientX - V, i = t.clientY - j;
let a = $, o = C;
switch (I) {
case "se":
a = z + r, o = $ + i;
a = $ + r, o = C + i;
break;
case "sw":
a = z - r, o = $ + i;
a = $ - r, o = C + i;
break;
case "ne":
a = z + r, o = $ - i;
a = $ + r, o = C - i;
break;
case "nw":
a = z - r, o = $ - i;
a = $ - r, o = C - i;
break;
}
Math.abs(r) > Math.abs(i) ? o = a / _ : a = o * _, a = Math.max(50, a), o = Math.max(50, o), s.style.width = `${a}px`, s.style.height = `${o}px`, s.setAttribute("width", String(Math.round(a))), s.setAttribute("height", String(Math.round(o))), C(), w();
Math.abs(r) > Math.abs(i) ? o = a / N : a = o * N, a = Math.max(50, a), o = Math.max(50, o), s.style.width = `${a}px`, s.style.height = `${o}px`, s.setAttribute("width", String(Math.round(a))), s.setAttribute("height", String(Math.round(o))), q(), E();
}), document.addEventListener("mouseup", () => {
A && (A = !1, M = null, document.body.style.userSelect = "", document.body.style.cursor = "");
}), window.addEventListener("scroll", C), window.addEventListener("resize", C);
D && (D = !1, I = null, document.body.style.userSelect = "", document.body.style.cursor = "");
}), window.addEventListener("scroll", q), window.addEventListener("resize", q);
};
typeof window < "u" && !window.__mediaManagerInitialized && (window.__mediaManagerInitialized = !0, W());
const te = () => ({
typeof window < "u" && !window.__mediaManagerInitialized && (window.__mediaManagerInitialized = !0, O());
const ae = () => ({
name: "image",
initialize: (e) => {
const t = e?.editorElement;
W(t);
O(t);
},

@@ -968,7 +989,7 @@ toolbar: [

const r = t?.contentElement instanceof HTMLElement ? t.contentElement : void 0;
return P("image", r), !0;
return F("image", r), !0;
},
insertVideo: (e, t) => {
const r = t?.contentElement instanceof HTMLElement ? t.contentElement : void 0;
return P("video", r), !0;
return F("video", r), !0;
}

@@ -979,3 +1000,3 @@ },

}
}), Q = {
}), te = {
apiEndpoints: {

@@ -1001,13 +1022,13 @@ upload: "/media/upload",

};
let N = { ...Q };
function re(e) {
N = { ...N, ...e };
let P = { ...te };
function ie(e) {
P = { ...P, ...e };
}
function ae() {
return { ...N };
function oe() {
return { ...P };
}
export {
te as MediaManagerPlugin,
ae as getMediaManagerConfig,
re as setMediaManagerConfig
ae as MediaManagerPlugin,
oe as getMediaManagerConfig,
ie as setMediaManagerConfig
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const R={USER:{name:"User",tags:[{key:"first_name",label:"First Name",category:"User",preview:"John"},{key:"last_name",label:"Last Name",category:"User",preview:"Doe"},{key:"email",label:"Email",category:"User",preview:"john@example.com"},{key:"phone",label:"Phone",category:"User",preview:"+1-555-1234"},{key:"full_name",label:"Full Name",category:"User",preview:"John Doe"},{key:"username",label:"Username",category:"User",preview:"johndoe"}]},COMPANY:{name:"Company",tags:[{key:"company_name",label:"Company Name",category:"Company",preview:"Acme Corp"},{key:"company_address",label:"Company Address",category:"Company",preview:"123 Main St"},{key:"company_phone",label:"Company Phone",category:"Company",preview:"+1-555-0000"},{key:"company_email",label:"Company Email",category:"Company",preview:"info@acme.com"}]},DATE:{name:"Date",tags:[{key:"today",label:"Today",category:"Date",preview:new Date().toLocaleDateString()},{key:"tomorrow",label:"Tomorrow",category:"Date",preview:new Date(Date.now()+864e5).toLocaleDateString()},{key:"next_week",label:"Next Week",category:"Date",preview:new Date(Date.now()+6048e5).toLocaleDateString()}]},CUSTOM:{name:"Custom",tags:[]}},v=".rte-content, .editora-content",X='[data-theme="dark"], .dark, .editora-theme-dark',L=Object.keys(R),Y=L.reduce((t,e)=>(t[e]=R[e].tags.map(r=>({...r,searchIndex:`${r.label} ${r.key} ${r.category} ${"description"in r?r.description??"":""}`.toLowerCase()})),t),{});let B=!1,P=!1,C=null,k=null,y=null,j=!1;function A(){if(B||typeof document>"u")return;B=!0;const t=document.createElement("style");t.id="merge-tag-plugin-styles",t.textContent=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=".rte-content, .editora-content",Q='[data-theme="dark"], .dark, .editora-theme-dark',ee={title:"Insert Merge Tag",searchPlaceholder:"Search merge tags...",emptyStateText:"No merge tags found",cancelText:"Cancel",insertText:"Insert",showPreview:!0};function te(){return[{id:"USER",name:"User",tags:[{key:"first_name",label:"First Name",category:"User",preview:"John"},{key:"last_name",label:"Last Name",category:"User",preview:"Doe"},{key:"email",label:"Email",category:"User",preview:"john@example.com"},{key:"phone",label:"Phone",category:"User",preview:"+1-555-1234"},{key:"full_name",label:"Full Name",category:"User",preview:"John Doe"},{key:"username",label:"Username",category:"User",preview:"johndoe"}]},{id:"COMPANY",name:"Company",tags:[{key:"company_name",label:"Company Name",category:"Company",preview:"Acme Corp"},{key:"company_address",label:"Company Address",category:"Company",preview:"123 Main St"},{key:"company_phone",label:"Company Phone",category:"Company",preview:"+1-555-0000"},{key:"company_email",label:"Company Email",category:"Company",preview:"info@acme.com"}]},{id:"DATE",name:"Date",tags:[{key:"today",label:"Today",category:"Date",preview:new Date().toLocaleDateString()},{key:"tomorrow",label:"Tomorrow",category:"Date",preview:new Date(Date.now()+864e5).toLocaleDateString()},{key:"next_week",label:"Next Week",category:"Date",preview:new Date(Date.now()+6048e5).toLocaleDateString()}]},{id:"CUSTOM",name:"Custom",tags:[]}]}function I(t,r){return t.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`CATEGORY_${r+1}`}function re(t,r){return(t.key||t.value||t.label).trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`tag_${r+1}`}function ne(t){const r=(()=>{if(Array.isArray(t?.categories)&&t.categories.length>0)return t.categories;if(Array.isArray(t?.tags)&&t.tags.length>0){const c=new Map;return t.tags.forEach(d=>{const g=(d.category||"Custom").trim()||"Custom",i=c.get(g);i?i.push(d):c.set(g,[d])}),Array.from(c.entries()).map(([d,g],i)=>({id:I(d,i),name:d,tags:g}))}return te()})(),e={},n=[];if(r.forEach((c,d)=>{const g=I(c.id||c.name,d);n.push(g),e[g]={name:c.name,tags:(Array.isArray(c.tags)?c.tags:[]).map((i,b)=>{const u=re(i,b),f=(i.category||c.name).trim()||c.name;return{...i,key:u,category:f,categoryKey:g,searchIndex:`${i.label} ${u} ${f} ${i.description??""} ${i.value??""}`.toLowerCase()}})}}),n.length===0){const c="CUSTOM";n.push(c),e[c]={name:"Custom",tags:[]}}const a=t?.defaultCategory?I(t.defaultCategory,0):null,l=a&&n.includes(a)?a:n[0];return{categoriesByKey:e,categoryKeys:n,defaultCategory:l}}function ae(t){const r=t?.tokenTemplate;return typeof r=="function"?e=>{const n=r(e);return typeof n=="string"&&n.trim()?n:e.value?.trim()||`{{ ${e.label} }}`}:typeof r=="string"&&r.trim()?e=>r.replace(/\{key\}/gi,e.key).replace(/\{label\}/gi,e.label).replace(/\{category\}/gi,e.category).replace(/\{value\}/gi,e.value??""):e=>e.value?.trim()||`{{ ${e.label} }}`}function oe(t){return{catalog:ne(t),dialog:{...ee,...t?.dialog||{}},formatToken:ae(t)}}let $=!1,K=!1,S=null,N=null,E=null,H=!1;function J(t,r){if(r===t.innerHTML)return;const e=window.execEditorCommand||window.executeEditorCommand;if(typeof e=="function")try{e("recordDomTransaction",t,r,t.innerHTML)}catch{}}function R(){if($||typeof document>"u")return;$=!0;const t=document.createElement("style");t.id="merge-tag-plugin-styles",t.textContent=`
.rte-merge-tag-overlay {

@@ -51,15 +51,50 @@ --rte-mt-overlay-bg: rgba(15, 23, 36, 0.56);

.rte-merge-tag-header { padding: 16px; border-bottom: 1px solid var(--rte-mt-border); display:flex; justify-content:space-between; align-items:center; }
.rte-merge-tag-body { padding: 16px; overflow-y:auto; flex:1; }
.rte-merge-tag-input { width:100%; padding:10px; border:1px solid var(--rte-mt-border); border-radius:4px; background:var(--rte-mt-subtle-bg); color:var(--rte-mt-dialog-text); }
.rte-merge-tag-tabs { display:flex; gap:8px; margin: 12px 0; }
.rte-merge-tag-body {
padding: 16px;
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
}
.rte-merge-tag-input {
width:100%;
padding:11px 12px;
border:1px solid var(--rte-mt-border);
border-radius:6px;
background:var(--rte-mt-subtle-bg);
color:var(--rte-mt-dialog-text);
font-size:14px;
line-height:1.45;
box-sizing:border-box;
}
.rte-merge-tag-tabs { display:flex; flex-wrap: wrap; gap:8px; margin: 12px 0; }
.rte-merge-tag-tab { padding:8px 12px; background:none; border:none; cursor:pointer; color:var(--rte-mt-muted-text); border-bottom:3px solid transparent; }
.rte-merge-tag-tab.active { color:var(--rte-mt-accent); border-bottom-color:var(--rte-mt-accent); }
.rte-merge-tag-list { border:1px solid var(--rte-mt-border); border-radius:4px; max-height:300px; overflow-y:auto; margin-bottom:12px; background:var(--rte-mt-subtle-bg); }
.rte-merge-tag-item { padding:8px 12px; border-bottom:1px solid var(--rte-mt-border); cursor:pointer; transition:background-color 0.16s; color:var(--rte-mt-dialog-text); }
.rte-merge-tag-list {
border:1px solid var(--rte-mt-border);
border-radius:4px;
flex: 1;
min-height: 180px;
max-height: 300px;
overflow-y:auto;
overflow-x:hidden;
margin-bottom:12px;
background:var(--rte-mt-subtle-bg);
}
.rte-merge-tag-item {
padding:8px 12px;
border-bottom:1px solid var(--rte-mt-border);
cursor:pointer;
transition:background-color 0.16s;
color:var(--rte-mt-dialog-text);
overflow-wrap:anywhere;
word-break:break-word;
}
.rte-merge-tag-item:last-child { border-bottom: none; }
.rte-merge-tag-item.selected, .rte-merge-tag-item:hover { background-color:var(--rte-mt-subtle-hover); }
.rte-merge-tag-item-label { font-weight: 600; }
.rte-merge-tag-item-preview { font-size: 12px; color: var(--rte-mt-muted-text); margin-top: 2px; }
.rte-merge-tag-item-preview { font-size: 12px; color: var(--rte-mt-muted-text); margin-top: 2px; overflow-wrap:anywhere; word-break:break-word; }
.rte-merge-tag-empty { padding: 24px; text-align: center; color: var(--rte-mt-muted-text); }
.rte-merge-tag-preview { padding:8px; background:var(--rte-mt-subtle-bg); border-radius:4px; font-family:monospace; font-size:12px; color:var(--rte-mt-dialog-text); }
.rte-merge-tag-preview { padding:8px; background:var(--rte-mt-subtle-bg); border-radius:4px; font-family:monospace; font-size:12px; color:var(--rte-mt-dialog-text); overflow-wrap:anywhere; word-break:break-word; }
.rte-merge-tag-footer { padding:12px 16px; border-top:1px solid var(--rte-mt-border); display:flex; gap:8px; justify-content:flex-end; background:var(--rte-mt-subtle-bg); }

@@ -91,5 +126,2 @@ .rte-merge-tag-btn-primary { padding:8px 16px; border:none; border-radius:4px; background:var(--rte-mt-accent); color:#fff; cursor:pointer; }

}
`,document.head.appendChild(t)}function H(){P||typeof document>"u"||(P=!0,document.addEventListener("focusin",t=>{const r=t.target?.closest(v);r&&(C=r)}),document.addEventListener("selectionchange",()=>{const t=V();t&&(C=t)}))}function V(){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0).startContainer;return(r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(v)||null}function J(){const t=V();if(t)return t;const r=document.activeElement?.closest(v);return r||(C?.isConnected?C:document.querySelector(v))}function Q(t){const e=t.parentNode;if(!e)return;const r=window.getSelection();if(!r)return;const n=document.createRange(),i=Array.from(e.childNodes).indexOf(t);i<0||(n.setStart(e,i),n.setEnd(e,i+1),r.removeAllRanges(),r.addRange(n))}function $(t,e){t instanceof Text&&t.data.length!==0&&(e?(t.data.startsWith(" ")||t.data.startsWith(" "))&&t.deleteData(0,1):(t.data.endsWith(" ")||t.data.endsWith(" "))&&t.deleteData(t.data.length-1,1),t.data.length===0&&t.parentNode?.removeChild(t))}function G(t,e){const r=window.getSelection();if(!r)return;const n=document.createRange(),o=Math.max(0,Math.min(e,t.childNodes.length));n.setStart(t,o),n.collapse(!0),r.removeAllRanges(),r.addRange(n)}function Z(t,e){const r=t.parentNode;if(!r)return!1;const o=Array.from(r.childNodes).indexOf(t);if(o<0)return!1;const i=t.previousSibling,c=t.nextSibling;r.removeChild(t),e==="Backspace"?($(c,!0),G(r,o)):($(i,!1),G(r,o));const d=r instanceof HTMLElement?r.closest(v):r.parentElement?.closest(v)||null;return d&&d.dispatchEvent(new Event("input",{bubbles:!0})),!0}function ee(t){if(t.collapsed||!(t.startContainer instanceof HTMLElement||t.startContainer instanceof Text)||t.startContainer!==t.endContainer||t.endOffset!==t.startOffset+1)return null;const e=t.startContainer;if(!(e instanceof Element||e instanceof DocumentFragment))return null;const r=e.childNodes[t.startOffset];return r instanceof HTMLElement&&r.classList.contains("rte-merge-tag")?r:null}function te(t,e){if(!t.collapsed)return null;const{startContainer:r,startOffset:n}=t,o=i=>i instanceof HTMLElement&&i.classList.contains("rte-merge-tag")?i:null;if(r.nodeType===Node.ELEMENT_NODE){const i=r;return e==="Backspace"&&n>0?o(i.childNodes[n-1]||null):e==="Delete"?o(i.childNodes[n]||null):null}if(r.nodeType===Node.TEXT_NODE){const i=r;return e==="Backspace"?n===0?o(i.previousSibling):n===1&&(i.data[0]===" "||i.data[0]===" ")&&i.previousSibling instanceof HTMLElement&&i.previousSibling.classList.contains("rte-merge-tag")?i.previousSibling:null:n===i.data.length?o(i.nextSibling):null}return null}function q(){j||typeof document>"u"||(j=!0,document.addEventListener("click",t=>{const r=t.target?.closest(".rte-merge-tag");if(!r)return;const n=r.closest(v);n&&(t.preventDefault(),t.stopPropagation(),n.focus({preventScroll:!0}),Q(r))}),document.addEventListener("keydown",t=>{if(t.key!=="Backspace"&&t.key!=="Delete")return;const e=window.getSelection();if(!e||e.rangeCount===0)return;const r=e.getRangeAt(0),n=J();if(!n||!n.contains(r.commonAncestorContainer))return;let o=ee(r);o||(o=te(r,t.key)),o&&(t.preventDefault(),t.stopPropagation(),Z(o,t.key))}))}function re(t){return t?!!t.closest(X):!1}function ne(){y&&(y(),y=null),k=null}function W(t){const e=document.createRange();return e.selectNodeContents(t),e.collapse(!1),e}function ae(t,e){const r=window.getSelection(),n=e?e.cloneRange():W(t),i=n.startContainer.isConnected&&n.endContainer.isConnected&&t.contains(n.commonAncestorContainer)?n:W(t);return r&&(r.removeAllRanges(),r.addRange(i)),i}function oe(t){const e=document.createElement("span");return e.className="rte-merge-tag",e.setAttribute("contenteditable","false"),e.setAttribute("data-key",t.key),e.setAttribute("data-category",t.category),e.setAttribute("data-label",t.label),e.setAttribute("aria-label",`Merge tag: ${t.label}`),e.textContent=`{{ ${t.label} }}`,e}function ie(t,e,r){const n=window.getSelection();if(!n)return!1;t.focus({preventScroll:!0});const o=ae(t,e),c=(o.startContainer.nodeType===Node.ELEMENT_NODE?o.startContainer:o.startContainer.parentElement)?.closest(".rte-merge-tag");c&&t.contains(c)&&(o.setStartAfter(c),o.setEndAfter(c));try{o.deleteContents();const d=oe(r),g=document.createTextNode(" "),u=document.createDocumentFragment();u.appendChild(d),u.appendChild(g),o.insertNode(u);const f=document.createRange();return f.setStartAfter(g),f.collapse(!0),n.removeAllRanges(),n.addRange(f),t.dispatchEvent(new Event("input",{bubbles:!0})),!0}catch(d){return console.error("Failed to insert merge tag:",d),!1}}function le(t,e){const r=Y[t],n=e.trim().toLowerCase();return n?r.filter(o=>o.searchIndex.includes(n)):r}function se(t){ne(),A();const e={category:"USER",searchTerm:"",filteredTags:Y.USER,selectedIndex:0,savedRange:(()=>{const a=window.getSelection();if(!a||a.rangeCount===0)return null;const l=a.getRangeAt(0);return t.contains(l.commonAncestorContainer)?l.cloneRange():null})(),searchRaf:null},r=document.createElement("div");r.className="rte-merge-tag-overlay",r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),re(t)&&r.classList.add("rte-ui-theme-dark");const n=document.createElement("div");n.className="rte-merge-tag-dialog";const o=document.createElement("div");o.className="rte-merge-tag-header",o.innerHTML=`
<h2 style="margin:0; font-size:18px; font-weight:700;">Insert Merge Tag</h2>
<button class="rte-merge-tag-close" aria-label="Close" style="background:none;border:none;color:inherit;cursor:pointer;font-size:20px;">✕</button>
`;const i=document.createElement("div");i.className="rte-merge-tag-body";const c=document.createElement("input");c.type="text",c.className="rte-merge-tag-input",c.placeholder="Search merge tags...",c.setAttribute("aria-label","Search merge tags");const d=document.createElement("div");d.className="rte-merge-tag-tabs",L.forEach(a=>{const l=document.createElement("button");l.type="button",l.className="rte-merge-tag-tab",l.setAttribute("data-category",a),l.textContent=R[a].name,d.appendChild(l)});const g=document.createElement("div");g.className="rte-merge-tag-list";const u=document.createElement("div");u.className="rte-merge-tag-preview",i.appendChild(c),i.appendChild(d),i.appendChild(g),i.appendChild(u);const f=document.createElement("div");f.className="rte-merge-tag-footer";const x=document.createElement("button");x.type="button",x.className="rte-merge-tag-btn-secondary",x.textContent="Cancel";const p=document.createElement("button");p.type="button",p.className="rte-merge-tag-btn-primary",p.textContent="Insert",f.appendChild(x),f.appendChild(p),n.appendChild(o),n.appendChild(i),n.appendChild(f),r.appendChild(n),document.body.appendChild(r),k=r;const D=()=>{d.querySelectorAll(".rte-merge-tag-tab").forEach(l=>{const m=l.dataset.category===e.category;l.classList.toggle("active",m)})},w=()=>{if(e.filteredTags.length===0){e.selectedIndex=-1;return}e.selectedIndex<0&&(e.selectedIndex=0),e.selectedIndex>=e.filteredTags.length&&(e.selectedIndex=e.filteredTags.length-1)},I=()=>{w();const a=e.selectedIndex>=0?e.filteredTags[e.selectedIndex]:null;if(!a){u.style.display="none",p.disabled=!0;return}u.style.display="block",u.innerHTML=`<strong>Preview:</strong> {{ ${a.label} }}`,p.disabled=!1},K=()=>{if(e.selectedIndex<0)return;g.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.scrollIntoView({block:"nearest"})},h=()=>{if(e.filteredTags=le(e.category,e.searchTerm),e.filteredTags.length>0&&e.selectedIndex<0&&(e.selectedIndex=0),w(),g.innerHTML="",e.filteredTags.length===0){const l=document.createElement("div");l.className="rte-merge-tag-empty",l.textContent="No merge tags found",g.appendChild(l),I();return}const a=document.createDocumentFragment();e.filteredTags.forEach((l,m)=>{const s=document.createElement("div");s.className="rte-merge-tag-item",s.setAttribute("data-index",String(m)),s.classList.toggle("selected",m===e.selectedIndex);const N=document.createElement("div");if(N.className="rte-merge-tag-item-label",N.textContent=l.label,s.appendChild(N),l.preview){const S=document.createElement("div");S.className="rte-merge-tag-item-preview",S.textContent=l.preview,s.appendChild(S)}a.appendChild(s)}),g.appendChild(a),I(),K()},M=()=>{e.searchRaf!==null&&cancelAnimationFrame(e.searchRaf),e.searchRaf=requestAnimationFrame(()=>{e.searchRaf=null,e.searchTerm=c.value,e.selectedIndex=0,h()})},b=()=>{e.searchRaf!==null&&(cancelAnimationFrame(e.searchRaf),e.searchRaf=null),r.remove(),k===r&&(k=null,y=null)},E=()=>{if(w(),e.selectedIndex<0)return;const a=e.filteredTags[e.selectedIndex];ie(t,e.savedRange,a)&&b()},O=a=>{const m=a.target.closest(".rte-merge-tag-tab");if(!m)return;const s=m.dataset.category;!s||!L.includes(s)||(e.category=s,e.searchTerm="",c.value="",e.selectedIndex=0,D(),h())},_=a=>{const m=a.target.closest(".rte-merge-tag-item");if(!m)return;const s=Number(m.dataset.index||"-1");Number.isNaN(s)||s<0||s>=e.filteredTags.length||(e.selectedIndex=s,h())},F=a=>{const m=a.target.closest(".rte-merge-tag-item");if(!m)return;const s=Number(m.dataset.index||"-1");Number.isNaN(s)||s<0||s>=e.filteredTags.length||(e.selectedIndex=s,E())},T=a=>{if(a.key==="Escape"){a.preventDefault(),b();return}if(a.key==="ArrowDown"){if(a.preventDefault(),e.filteredTags.length===0)return;e.selectedIndex=Math.min(e.filteredTags.length-1,e.selectedIndex+1),h();return}if(a.key==="ArrowUp"){if(a.preventDefault(),e.filteredTags.length===0)return;e.selectedIndex=Math.max(0,e.selectedIndex-1),h();return}a.key==="Enter"&&(a.preventDefault(),E())},U=a=>{a.target===r&&b()},z=o.querySelector(".rte-merge-tag-close");d.addEventListener("click",O),g.addEventListener("click",_),g.addEventListener("dblclick",F),c.addEventListener("input",M),c.addEventListener("keydown",T),r.addEventListener("click",U),n.addEventListener("keydown",T),z?.addEventListener("click",b),x.addEventListener("click",b),p.addEventListener("click",E),y=()=>{d.removeEventListener("click",O),g.removeEventListener("click",_),g.removeEventListener("dblclick",F),c.removeEventListener("input",M),c.removeEventListener("keydown",T),r.removeEventListener("click",U),n.removeEventListener("keydown",T),z?.removeEventListener("click",b),x.removeEventListener("click",b),p.removeEventListener("click",E),e.searchRaf!==null&&(cancelAnimationFrame(e.searchRaf),e.searchRaf=null),r.remove()},D(),h(),setTimeout(()=>{c.focus()},0)}const ce=()=>({name:"mergeTag",init:()=>{A(),H(),q()},toolbar:[{label:"Merge Tag",command:"insertMergeTag",icon:"{{ }}"}],commands:{insertMergeTag:()=>{A(),H(),q();const t=J();return t?(se(t),!0):!1}}});exports.MergeTagPlugin=ce;
`,document.head.appendChild(t)}function j(){K||typeof document>"u"||(K=!0,document.addEventListener("focusin",t=>{const e=t.target?.closest(h);e&&(S=e)}),document.addEventListener("selectionchange",()=>{const t=Y();t&&(S=t)}))}function Y(){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.getRangeAt(0).startContainer;return(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(h)||null}function X(){const t=Y();if(t)return t;const e=document.activeElement?.closest(h);return e||(S?.isConnected?S:document.querySelector(h))}function le(t){const r=t.parentNode;if(!r)return;const e=window.getSelection();if(!e)return;const n=document.createRange(),l=Array.from(r.childNodes).indexOf(t);l<0||(n.setStart(r,l),n.setEnd(r,l+1),e.removeAllRanges(),e.addRange(n))}function q(t,r){t instanceof Text&&t.data.length!==0&&(r?(t.data.startsWith(" ")||t.data.startsWith(" "))&&t.deleteData(0,1):(t.data.endsWith(" ")||t.data.endsWith(" "))&&t.deleteData(t.data.length-1,1),t.data.length===0&&t.parentNode?.removeChild(t))}function W(t,r){const e=window.getSelection();if(!e)return;const n=document.createRange(),a=Math.max(0,Math.min(r,t.childNodes.length));n.setStart(t,a),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}function ce(t,r){const e=t.closest(h),n=e?.innerHTML??"",a=t.parentNode;if(!a)return!1;const c=Array.from(a.childNodes).indexOf(t);if(c<0)return!1;const d=t.previousSibling,g=t.nextSibling;return a.removeChild(t),r==="Backspace"?(q(g,!0),W(a,c)):(q(d,!1),W(a,c)),e&&(J(e,n),e.dispatchEvent(new Event("input",{bubbles:!0}))),!0}function ie(t){if(t.collapsed||!(t.startContainer instanceof HTMLElement||t.startContainer instanceof Text)||t.startContainer!==t.endContainer||t.endOffset!==t.startOffset+1)return null;const r=t.startContainer;if(!(r instanceof Element||r instanceof DocumentFragment))return null;const e=r.childNodes[t.startOffset];return e instanceof HTMLElement&&e.classList.contains("rte-merge-tag")?e:null}function se(t,r){if(!t.collapsed)return null;const{startContainer:e,startOffset:n}=t,a=l=>l instanceof HTMLElement&&l.classList.contains("rte-merge-tag")?l:null;if(e.nodeType===Node.ELEMENT_NODE){const l=e;return r==="Backspace"&&n>0?a(l.childNodes[n-1]||null):r==="Delete"?a(l.childNodes[n]||null):null}if(e.nodeType===Node.TEXT_NODE){const l=e;return r==="Backspace"?n===0?a(l.previousSibling):n===1&&(l.data[0]===" "||l.data[0]===" ")&&l.previousSibling instanceof HTMLElement&&l.previousSibling.classList.contains("rte-merge-tag")?l.previousSibling:null:n===l.data.length?a(l.nextSibling):null}return null}function V(){H||typeof document>"u"||(H=!0,document.addEventListener("click",t=>{const e=t.target?.closest(".rte-merge-tag");if(!e)return;const n=e.closest(h);n&&(t.preventDefault(),t.stopPropagation(),n.focus({preventScroll:!0}),le(e))}),document.addEventListener("keydown",t=>{if(t.key!=="Backspace"&&t.key!=="Delete")return;const r=window.getSelection();if(!r||r.rangeCount===0)return;const e=r.getRangeAt(0),n=X();if(!n||!n.contains(e.commonAncestorContainer))return;let a=ie(e);a||(a=se(e,t.key)),a&&(t.preventDefault(),t.stopPropagation(),ce(a,t.key))}))}function de(t){return t?!!t.closest(Q):!1}function ge(){E&&(E(),E=null),N=null}function G(t){const r=document.createRange();return r.selectNodeContents(t),r.collapse(!1),r}function me(t,r){const e=window.getSelection(),n=r?r.cloneRange():G(t),l=n.startContainer.isConnected&&n.endContainer.isConnected&&t.contains(n.commonAncestorContainer)?n:G(t);return e&&(e.removeAllRanges(),e.addRange(l)),l}function ue(t,r){const e=document.createElement("span");e.className="rte-merge-tag",e.setAttribute("contenteditable","false"),e.setAttribute("data-key",t.key),e.setAttribute("data-category",t.category),e.setAttribute("data-label",t.label),t.value&&e.setAttribute("data-value",t.value);const n=r(t);return e.setAttribute("data-token",n),e.setAttribute("aria-label",`Merge tag: ${t.label}`),e.textContent=n,e}function fe(t,r,e,n){const a=window.getSelection();if(!a)return!1;const l=t.innerHTML;t.focus({preventScroll:!0});const c=me(t,r),g=(c.startContainer.nodeType===Node.ELEMENT_NODE?c.startContainer:c.startContainer.parentElement)?.closest(".rte-merge-tag");g&&t.contains(g)&&(c.setStartAfter(g),c.setEndAfter(g));try{c.deleteContents();const i=ue(e,n),b=document.createTextNode(" "),u=document.createDocumentFragment();u.appendChild(i),u.appendChild(b),c.insertNode(u);const f=document.createRange();return f.setStartAfter(b),f.collapse(!0),a.removeAllRanges(),a.addRange(f),J(t,l),t.dispatchEvent(new Event("input",{bubbles:!0})),!0}catch(i){return console.error("Failed to insert merge tag:",i),!1}}function pe(t,r,e){const n=t.catalog.categoriesByKey[r]?.tags||[],a=e.trim().toLowerCase();return a?n.filter(l=>l.searchIndex.includes(a)):n}function be(t,r){ge(),R();const e={category:r.catalog.defaultCategory,searchTerm:"",filteredTags:r.catalog.categoriesByKey[r.catalog.defaultCategory]?.tags||[],selectedIndex:0,savedRange:(()=>{const o=window.getSelection();if(!o||o.rangeCount===0)return null;const s=o.getRangeAt(0);return t.contains(s.commonAncestorContainer)?s.cloneRange():null})(),searchRaf:null},n=document.createElement("div");n.className="rte-merge-tag-overlay",n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),de(t)&&n.classList.add("rte-ui-theme-dark");const a=document.createElement("div");a.className="rte-merge-tag-dialog";const l=document.createElement("div");l.className="rte-merge-tag-header";const c=document.createElement("h2");c.style.margin="0",c.style.fontSize="18px",c.style.fontWeight="700",c.textContent=r.dialog.title;const d=document.createElement("button");d.className="rte-merge-tag-close",d.setAttribute("aria-label","Close"),d.style.background="none",d.style.border="none",d.style.color="inherit",d.style.cursor="pointer",d.style.fontSize="20px",d.textContent="✕",l.appendChild(c),l.appendChild(d);const g=document.createElement("div");g.className="rte-merge-tag-body";const i=document.createElement("input");i.type="text",i.className="rte-merge-tag-input",i.placeholder=r.dialog.searchPlaceholder,i.setAttribute("aria-label","Search merge tags");const b=document.createElement("div");b.className="rte-merge-tag-tabs",r.catalog.categoryKeys.forEach(o=>{const s=document.createElement("button");s.type="button",s.className="rte-merge-tag-tab",s.setAttribute("data-category",o),s.textContent=r.catalog.categoriesByKey[o]?.name||o,b.appendChild(s)});const u=document.createElement("div");u.className="rte-merge-tag-list";const f=document.createElement("div");f.className="rte-merge-tag-preview",g.appendChild(i),g.appendChild(b),g.appendChild(u),g.appendChild(f);const w=document.createElement("div");w.className="rte-merge-tag-footer";const x=document.createElement("button");x.type="button",x.className="rte-merge-tag-btn-secondary",x.textContent=r.dialog.cancelText;const y=document.createElement("button");y.type="button",y.className="rte-merge-tag-btn-primary",y.textContent=r.dialog.insertText,w.appendChild(x),w.appendChild(y),a.appendChild(l),a.appendChild(g),a.appendChild(w),n.appendChild(a),document.body.appendChild(n),N=n;const _=()=>{b.querySelectorAll(".rte-merge-tag-tab").forEach(s=>{const p=s.dataset.category===e.category;s.classList.toggle("active",p)})},L=()=>{if(e.filteredTags.length===0){e.selectedIndex=-1;return}e.selectedIndex<0&&(e.selectedIndex=0),e.selectedIndex>=e.filteredTags.length&&(e.selectedIndex=e.filteredTags.length-1)},O=()=>{if(!r.dialog.showPreview){f.style.display="none",y.disabled=e.filteredTags.length===0;return}L();const o=e.selectedIndex>=0?e.filteredTags[e.selectedIndex]:null;if(!o){f.style.display="none",y.disabled=!0;return}f.style.display="block",f.textContent=`Preview: ${r.formatToken(o)}`,y.disabled=!1},Z=()=>{if(e.selectedIndex<0)return;u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.scrollIntoView({block:"nearest"})},k=()=>{u.querySelector(".rte-merge-tag-item.selected")?.classList.remove("selected"),e.selectedIndex>=0&&u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.classList.add("selected"),O(),Z()},A=()=>{if(e.filteredTags=pe(r,e.category,e.searchTerm),e.filteredTags.length>0&&e.selectedIndex<0&&(e.selectedIndex=0),L(),u.innerHTML="",e.filteredTags.length===0){const s=document.createElement("div");s.className="rte-merge-tag-empty",s.textContent=r.dialog.emptyStateText,u.appendChild(s),O();return}const o=document.createDocumentFragment();e.filteredTags.forEach((s,p)=>{const m=document.createElement("div");m.className="rte-merge-tag-item",m.setAttribute("data-index",String(p)),m.classList.toggle("selected",p===e.selectedIndex);const D=document.createElement("div");if(D.className="rte-merge-tag-item-label",D.textContent=s.label,m.appendChild(D),s.preview){const M=document.createElement("div");M.className="rte-merge-tag-item-preview",M.textContent=s.preview,m.appendChild(M)}o.appendChild(m)}),u.appendChild(o),k()},z=()=>{e.searchRaf!==null&&cancelAnimationFrame(e.searchRaf),e.searchRaf=requestAnimationFrame(()=>{e.searchRaf=null,e.searchTerm=i.value,e.selectedIndex=0,A()})},v=()=>{e.searchRaf!==null&&(cancelAnimationFrame(e.searchRaf),e.searchRaf=null),n.remove(),N===n&&(N=null,E=null)},T=()=>{if(L(),e.selectedIndex<0)return;const o=e.filteredTags[e.selectedIndex];fe(t,e.savedRange,o,r.formatToken)&&v()},F=o=>{const p=o.target.closest(".rte-merge-tag-tab");if(!p)return;const m=p.dataset.category;!m||!r.catalog.categoriesByKey[m]||(e.category=m,e.searchTerm="",i.value="",e.selectedIndex=0,_(),A())},P=o=>{const p=o.target.closest(".rte-merge-tag-item");if(!p)return;const m=Number(p.dataset.index||"-1");Number.isNaN(m)||m<0||m>=e.filteredTags.length||(e.selectedIndex=m,k())},B=o=>{const p=o.target.closest(".rte-merge-tag-item");if(!p)return;const m=Number(p.dataset.index||"-1");Number.isNaN(m)||m<0||m>=e.filteredTags.length||(e.selectedIndex=m,T())},C=o=>{if(o.key==="Escape"){o.preventDefault(),v();return}if(o.key==="ArrowDown"){if(o.preventDefault(),e.filteredTags.length===0)return;e.selectedIndex=Math.min(e.filteredTags.length-1,e.selectedIndex+1),k();return}if(o.key==="ArrowUp"){if(o.preventDefault(),e.filteredTags.length===0)return;e.selectedIndex=Math.max(0,e.selectedIndex-1),k();return}o.key==="Enter"&&(o.preventDefault(),T())},U=o=>{o.target===n&&v()};b.addEventListener("click",F),u.addEventListener("click",P),u.addEventListener("dblclick",B),i.addEventListener("input",z),i.addEventListener("keydown",C),n.addEventListener("click",U),a.addEventListener("keydown",C),d?.addEventListener("click",v),x.addEventListener("click",v),y.addEventListener("click",T),E=()=>{b.removeEventListener("click",F),u.removeEventListener("click",P),u.removeEventListener("dblclick",B),i.removeEventListener("input",z),i.removeEventListener("keydown",C),n.removeEventListener("click",U),a.removeEventListener("keydown",C),d?.removeEventListener("click",v),x.removeEventListener("click",v),y.removeEventListener("click",T),e.searchRaf!==null&&(cancelAnimationFrame(e.searchRaf),e.searchRaf=null),n.remove()},_(),A(),setTimeout(()=>{i.focus()},0)}const ye=t=>({name:"mergeTag",config:t,init:()=>{R(),j(),V()},toolbar:[{label:"Merge Tag",command:"insertMergeTag",icon:"{{ }}"}],commands:{insertMergeTag:()=>{R(),j(),V();const r=X();return r?(be(r,oe(t)),!0):!1}}});exports.MergeTagPlugin=ye;

@@ -1,45 +0,128 @@

const R = {
USER: {
name: "User",
tags: [
{ key: "first_name", label: "First Name", category: "User", preview: "John" },
{ key: "last_name", label: "Last Name", category: "User", preview: "Doe" },
{ key: "email", label: "Email", category: "User", preview: "john@example.com" },
{ key: "phone", label: "Phone", category: "User", preview: "+1-555-1234" },
{ key: "full_name", label: "Full Name", category: "User", preview: "John Doe" },
{ key: "username", label: "Username", category: "User", preview: "johndoe" }
]
},
COMPANY: {
name: "Company",
tags: [
{ key: "company_name", label: "Company Name", category: "Company", preview: "Acme Corp" },
{ key: "company_address", label: "Company Address", category: "Company", preview: "123 Main St" },
{ key: "company_phone", label: "Company Phone", category: "Company", preview: "+1-555-0000" },
{ key: "company_email", label: "Company Email", category: "Company", preview: "info@acme.com" }
]
},
DATE: {
name: "Date",
tags: [
{ key: "today", label: "Today", category: "Date", preview: (/* @__PURE__ */ new Date()).toLocaleDateString() },
{ key: "tomorrow", label: "Tomorrow", category: "Date", preview: new Date(Date.now() + 864e5).toLocaleDateString() },
{ key: "next_week", label: "Next Week", category: "Date", preview: new Date(Date.now() + 6048e5).toLocaleDateString() }
]
},
CUSTOM: {
name: "Custom",
tags: []
const h = ".rte-content, .editora-content", Q = '[data-theme="dark"], .dark, .editora-theme-dark', ee = {
title: "Insert Merge Tag",
searchPlaceholder: "Search merge tags...",
emptyStateText: "No merge tags found",
cancelText: "Cancel",
insertText: "Insert",
showPreview: !0
};
function te() {
return [
{
id: "USER",
name: "User",
tags: [
{ key: "first_name", label: "First Name", category: "User", preview: "John" },
{ key: "last_name", label: "Last Name", category: "User", preview: "Doe" },
{ key: "email", label: "Email", category: "User", preview: "john@example.com" },
{ key: "phone", label: "Phone", category: "User", preview: "+1-555-1234" },
{ key: "full_name", label: "Full Name", category: "User", preview: "John Doe" },
{ key: "username", label: "Username", category: "User", preview: "johndoe" }
]
},
{
id: "COMPANY",
name: "Company",
tags: [
{ key: "company_name", label: "Company Name", category: "Company", preview: "Acme Corp" },
{ key: "company_address", label: "Company Address", category: "Company", preview: "123 Main St" },
{ key: "company_phone", label: "Company Phone", category: "Company", preview: "+1-555-0000" },
{ key: "company_email", label: "Company Email", category: "Company", preview: "info@acme.com" }
]
},
{
id: "DATE",
name: "Date",
tags: [
{ key: "today", label: "Today", category: "Date", preview: (/* @__PURE__ */ new Date()).toLocaleDateString() },
{ key: "tomorrow", label: "Tomorrow", category: "Date", preview: new Date(Date.now() + 864e5).toLocaleDateString() },
{ key: "next_week", label: "Next Week", category: "Date", preview: new Date(Date.now() + 6048e5).toLocaleDateString() }
]
},
{
id: "CUSTOM",
name: "Custom",
tags: []
}
];
}
function M(t, r) {
return t.trim().toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "") || `CATEGORY_${r + 1}`;
}
function re(t, r) {
return (t.key || t.value || t.label).trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "") || `tag_${r + 1}`;
}
function ne(t) {
const r = (() => {
if (Array.isArray(t?.categories) && t.categories.length > 0)
return t.categories;
if (Array.isArray(t?.tags) && t.tags.length > 0) {
const c = /* @__PURE__ */ new Map();
return t.tags.forEach((d) => {
const g = (d.category || "Custom").trim() || "Custom", i = c.get(g);
i ? i.push(d) : c.set(g, [d]);
}), Array.from(c.entries()).map(([d, g], i) => ({
id: M(d, i),
name: d,
tags: g
}));
}
return te();
})(), e = {}, n = [];
if (r.forEach((c, d) => {
const g = M(c.id || c.name, d);
n.push(g), e[g] = {
name: c.name,
tags: (Array.isArray(c.tags) ? c.tags : []).map((i, b) => {
const u = re(i, b), f = (i.category || c.name).trim() || c.name;
return {
...i,
key: u,
category: f,
categoryKey: g,
searchIndex: `${i.label} ${u} ${f} ${i.description ?? ""} ${i.value ?? ""}`.toLowerCase()
};
})
};
}), n.length === 0) {
const c = "CUSTOM";
n.push(c), e[c] = { name: "Custom", tags: [] };
}
}, v = ".rte-content, .editora-content", X = '[data-theme="dark"], .dark, .editora-theme-dark', L = Object.keys(R), Y = L.reduce(
(t, e) => (t[e] = R[e].tags.map((r) => ({
...r,
searchIndex: `${r.label} ${r.key} ${r.category} ${"description" in r ? r.description ?? "" : ""}`.toLowerCase()
})), t),
{}
);
let B = !1, j = !1, T = null, C = null, y = null, H = !1;
function A() {
if (B || typeof document > "u") return;
B = !0;
const a = t?.defaultCategory ? M(t.defaultCategory, 0) : null, l = a && n.includes(a) ? a : n[0];
return {
categoriesByKey: e,
categoryKeys: n,
defaultCategory: l
};
}
function ae(t) {
const r = t?.tokenTemplate;
return typeof r == "function" ? (e) => {
const n = r(e);
return typeof n == "string" && n.trim() ? n : e.value?.trim() || `{{ ${e.label} }}`;
} : typeof r == "string" && r.trim() ? (e) => r.replace(/\{key\}/gi, e.key).replace(/\{label\}/gi, e.label).replace(/\{category\}/gi, e.category).replace(/\{value\}/gi, e.value ?? "") : (e) => e.value?.trim() || `{{ ${e.label} }}`;
}
function oe(t) {
return {
catalog: ne(t),
dialog: {
...ee,
...t?.dialog || {}
},
formatToken: ae(t)
};
}
let K = !1, P = !1, S = null, N = null, E = null, H = !1;
function J(t, r) {
if (r === t.innerHTML) return;
const e = window.execEditorCommand || window.executeEditorCommand;
if (typeof e == "function")
try {
e("recordDomTransaction", t, r, t.innerHTML);
} catch {
}
}
function R() {
if (K || typeof document > "u") return;
K = !0;
const t = document.createElement("style");

@@ -96,15 +179,50 @@ t.id = "merge-tag-plugin-styles", t.textContent = `

.rte-merge-tag-header { padding: 16px; border-bottom: 1px solid var(--rte-mt-border); display:flex; justify-content:space-between; align-items:center; }
.rte-merge-tag-body { padding: 16px; overflow-y:auto; flex:1; }
.rte-merge-tag-input { width:100%; padding:10px; border:1px solid var(--rte-mt-border); border-radius:4px; background:var(--rte-mt-subtle-bg); color:var(--rte-mt-dialog-text); }
.rte-merge-tag-tabs { display:flex; gap:8px; margin: 12px 0; }
.rte-merge-tag-body {
padding: 16px;
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
}
.rte-merge-tag-input {
width:100%;
padding:11px 12px;
border:1px solid var(--rte-mt-border);
border-radius:6px;
background:var(--rte-mt-subtle-bg);
color:var(--rte-mt-dialog-text);
font-size:14px;
line-height:1.45;
box-sizing:border-box;
}
.rte-merge-tag-tabs { display:flex; flex-wrap: wrap; gap:8px; margin: 12px 0; }
.rte-merge-tag-tab { padding:8px 12px; background:none; border:none; cursor:pointer; color:var(--rte-mt-muted-text); border-bottom:3px solid transparent; }
.rte-merge-tag-tab.active { color:var(--rte-mt-accent); border-bottom-color:var(--rte-mt-accent); }
.rte-merge-tag-list { border:1px solid var(--rte-mt-border); border-radius:4px; max-height:300px; overflow-y:auto; margin-bottom:12px; background:var(--rte-mt-subtle-bg); }
.rte-merge-tag-item { padding:8px 12px; border-bottom:1px solid var(--rte-mt-border); cursor:pointer; transition:background-color 0.16s; color:var(--rte-mt-dialog-text); }
.rte-merge-tag-list {
border:1px solid var(--rte-mt-border);
border-radius:4px;
flex: 1;
min-height: 180px;
max-height: 300px;
overflow-y:auto;
overflow-x:hidden;
margin-bottom:12px;
background:var(--rte-mt-subtle-bg);
}
.rte-merge-tag-item {
padding:8px 12px;
border-bottom:1px solid var(--rte-mt-border);
cursor:pointer;
transition:background-color 0.16s;
color:var(--rte-mt-dialog-text);
overflow-wrap:anywhere;
word-break:break-word;
}
.rte-merge-tag-item:last-child { border-bottom: none; }
.rte-merge-tag-item.selected, .rte-merge-tag-item:hover { background-color:var(--rte-mt-subtle-hover); }
.rte-merge-tag-item-label { font-weight: 600; }
.rte-merge-tag-item-preview { font-size: 12px; color: var(--rte-mt-muted-text); margin-top: 2px; }
.rte-merge-tag-item-preview { font-size: 12px; color: var(--rte-mt-muted-text); margin-top: 2px; overflow-wrap:anywhere; word-break:break-word; }
.rte-merge-tag-empty { padding: 24px; text-align: center; color: var(--rte-mt-muted-text); }
.rte-merge-tag-preview { padding:8px; background:var(--rte-mt-subtle-bg); border-radius:4px; font-family:monospace; font-size:12px; color:var(--rte-mt-dialog-text); }
.rte-merge-tag-preview { padding:8px; background:var(--rte-mt-subtle-bg); border-radius:4px; font-family:monospace; font-size:12px; color:var(--rte-mt-dialog-text); overflow-wrap:anywhere; word-break:break-word; }
.rte-merge-tag-footer { padding:12px 16px; border-top:1px solid var(--rte-mt-border); display:flex; gap:8px; justify-content:flex-end; background:var(--rte-mt-subtle-bg); }

@@ -138,172 +256,174 @@ .rte-merge-tag-btn-primary { padding:8px 16px; border:none; border-radius:4px; background:var(--rte-mt-accent); color:#fff; cursor:pointer; }

}
function P() {
j || typeof document > "u" || (j = !0, document.addEventListener("focusin", (t) => {
const r = t.target?.closest(v);
r && (T = r);
function j() {
P || typeof document > "u" || (P = !0, document.addEventListener("focusin", (t) => {
const e = t.target?.closest(h);
e && (S = e);
}), document.addEventListener("selectionchange", () => {
const t = V();
t && (T = t);
const t = Y();
t && (S = t);
}));
}
function V() {
function Y() {
const t = window.getSelection();
if (!t || t.rangeCount === 0) return null;
const r = t.getRangeAt(0).startContainer;
return (r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement)?.closest(v) || null;
const e = t.getRangeAt(0).startContainer;
return (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest(h) || null;
}
function J() {
const t = V();
function X() {
const t = Y();
if (t) return t;
const r = document.activeElement?.closest(v);
return r || (T?.isConnected ? T : document.querySelector(v));
const e = document.activeElement?.closest(h);
return e || (S?.isConnected ? S : document.querySelector(h));
}
function Q(t) {
const e = t.parentNode;
function le(t) {
const r = t.parentNode;
if (!r) return;
const e = window.getSelection();
if (!e) return;
const r = window.getSelection();
if (!r) return;
const n = document.createRange(), i = Array.from(e.childNodes).indexOf(t);
i < 0 || (n.setStart(e, i), n.setEnd(e, i + 1), r.removeAllRanges(), r.addRange(n));
const n = document.createRange(), l = Array.from(r.childNodes).indexOf(t);
l < 0 || (n.setStart(r, l), n.setEnd(r, l + 1), e.removeAllRanges(), e.addRange(n));
}
function $(t, e) {
t instanceof Text && t.data.length !== 0 && (e ? (t.data.startsWith(" ") || t.data.startsWith(" ")) && t.deleteData(0, 1) : (t.data.endsWith(" ") || t.data.endsWith(" ")) && t.deleteData(t.data.length - 1, 1), t.data.length === 0 && t.parentNode?.removeChild(t));
function q(t, r) {
t instanceof Text && t.data.length !== 0 && (r ? (t.data.startsWith(" ") || t.data.startsWith(" ")) && t.deleteData(0, 1) : (t.data.endsWith(" ") || t.data.endsWith(" ")) && t.deleteData(t.data.length - 1, 1), t.data.length === 0 && t.parentNode?.removeChild(t));
}
function G(t, e) {
const r = window.getSelection();
if (!r) return;
const n = document.createRange(), o = Math.max(0, Math.min(e, t.childNodes.length));
n.setStart(t, o), n.collapse(!0), r.removeAllRanges(), r.addRange(n);
function W(t, r) {
const e = window.getSelection();
if (!e) return;
const n = document.createRange(), a = Math.max(0, Math.min(r, t.childNodes.length));
n.setStart(t, a), n.collapse(!0), e.removeAllRanges(), e.addRange(n);
}
function Z(t, e) {
const r = t.parentNode;
if (!r) return !1;
const o = Array.from(r.childNodes).indexOf(t);
if (o < 0) return !1;
const i = t.previousSibling, c = t.nextSibling;
r.removeChild(t), e === "Backspace" ? ($(c, !0), G(r, o)) : ($(i, !1), G(r, o));
const d = r instanceof HTMLElement ? r.closest(v) : r.parentElement?.closest(v) || null;
return d && d.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
function ce(t, r) {
const e = t.closest(h), n = e?.innerHTML ?? "", a = t.parentNode;
if (!a) return !1;
const c = Array.from(a.childNodes).indexOf(t);
if (c < 0) return !1;
const d = t.previousSibling, g = t.nextSibling;
return a.removeChild(t), r === "Backspace" ? (q(g, !0), W(a, c)) : (q(d, !1), W(a, c)), e && (J(e, n), e.dispatchEvent(new Event("input", { bubbles: !0 }))), !0;
}
function ee(t) {
function ie(t) {
if (t.collapsed || !(t.startContainer instanceof HTMLElement || t.startContainer instanceof Text) || t.startContainer !== t.endContainer || t.endOffset !== t.startOffset + 1) return null;
const e = t.startContainer;
if (!(e instanceof Element || e instanceof DocumentFragment)) return null;
const r = e.childNodes[t.startOffset];
return r instanceof HTMLElement && r.classList.contains("rte-merge-tag") ? r : null;
const r = t.startContainer;
if (!(r instanceof Element || r instanceof DocumentFragment)) return null;
const e = r.childNodes[t.startOffset];
return e instanceof HTMLElement && e.classList.contains("rte-merge-tag") ? e : null;
}
function te(t, e) {
function se(t, r) {
if (!t.collapsed) return null;
const { startContainer: r, startOffset: n } = t, o = (i) => i instanceof HTMLElement && i.classList.contains("rte-merge-tag") ? i : null;
if (r.nodeType === Node.ELEMENT_NODE) {
const i = r;
return e === "Backspace" && n > 0 ? o(i.childNodes[n - 1] || null) : e === "Delete" ? o(i.childNodes[n] || null) : null;
const { startContainer: e, startOffset: n } = t, a = (l) => l instanceof HTMLElement && l.classList.contains("rte-merge-tag") ? l : null;
if (e.nodeType === Node.ELEMENT_NODE) {
const l = e;
return r === "Backspace" && n > 0 ? a(l.childNodes[n - 1] || null) : r === "Delete" ? a(l.childNodes[n] || null) : null;
}
if (r.nodeType === Node.TEXT_NODE) {
const i = r;
return e === "Backspace" ? n === 0 ? o(i.previousSibling) : n === 1 && (i.data[0] === " " || i.data[0] === " ") && i.previousSibling instanceof HTMLElement && i.previousSibling.classList.contains("rte-merge-tag") ? i.previousSibling : null : n === i.data.length ? o(i.nextSibling) : null;
if (e.nodeType === Node.TEXT_NODE) {
const l = e;
return r === "Backspace" ? n === 0 ? a(l.previousSibling) : n === 1 && (l.data[0] === " " || l.data[0] === " ") && l.previousSibling instanceof HTMLElement && l.previousSibling.classList.contains("rte-merge-tag") ? l.previousSibling : null : n === l.data.length ? a(l.nextSibling) : null;
}
return null;
}
function q() {
function V() {
H || typeof document > "u" || (H = !0, document.addEventListener("click", (t) => {
const r = t.target?.closest(".rte-merge-tag");
if (!r) return;
const n = r.closest(v);
n && (t.preventDefault(), t.stopPropagation(), n.focus({ preventScroll: !0 }), Q(r));
const e = t.target?.closest(".rte-merge-tag");
if (!e) return;
const n = e.closest(h);
n && (t.preventDefault(), t.stopPropagation(), n.focus({ preventScroll: !0 }), le(e));
}), document.addEventListener("keydown", (t) => {
if (t.key !== "Backspace" && t.key !== "Delete") return;
const e = window.getSelection();
if (!e || e.rangeCount === 0) return;
const r = e.getRangeAt(0), n = J();
if (!n || !n.contains(r.commonAncestorContainer)) return;
let o = ee(r);
o || (o = te(r, t.key)), o && (t.preventDefault(), t.stopPropagation(), Z(o, t.key));
const r = window.getSelection();
if (!r || r.rangeCount === 0) return;
const e = r.getRangeAt(0), n = X();
if (!n || !n.contains(e.commonAncestorContainer)) return;
let a = ie(e);
a || (a = se(e, t.key)), a && (t.preventDefault(), t.stopPropagation(), ce(a, t.key));
}));
}
function re(t) {
return t ? !!t.closest(X) : !1;
function de(t) {
return t ? !!t.closest(Q) : !1;
}
function ne() {
y && (y(), y = null), C = null;
function ge() {
E && (E(), E = null), N = null;
}
function W(t) {
const e = document.createRange();
return e.selectNodeContents(t), e.collapse(!1), e;
function G(t) {
const r = document.createRange();
return r.selectNodeContents(t), r.collapse(!1), r;
}
function ae(t, e) {
const r = window.getSelection(), n = e ? e.cloneRange() : W(t), i = n.startContainer.isConnected && n.endContainer.isConnected && t.contains(n.commonAncestorContainer) ? n : W(t);
return r && (r.removeAllRanges(), r.addRange(i)), i;
function me(t, r) {
const e = window.getSelection(), n = r ? r.cloneRange() : G(t), l = n.startContainer.isConnected && n.endContainer.isConnected && t.contains(n.commonAncestorContainer) ? n : G(t);
return e && (e.removeAllRanges(), e.addRange(l)), l;
}
function oe(t) {
function ue(t, r) {
const e = document.createElement("span");
return e.className = "rte-merge-tag", e.setAttribute("contenteditable", "false"), e.setAttribute("data-key", t.key), e.setAttribute("data-category", t.category), e.setAttribute("data-label", t.label), e.setAttribute("aria-label", `Merge tag: ${t.label}`), e.textContent = `{{ ${t.label} }}`, e;
e.className = "rte-merge-tag", e.setAttribute("contenteditable", "false"), e.setAttribute("data-key", t.key), e.setAttribute("data-category", t.category), e.setAttribute("data-label", t.label), t.value && e.setAttribute("data-value", t.value);
const n = r(t);
return e.setAttribute("data-token", n), e.setAttribute("aria-label", `Merge tag: ${t.label}`), e.textContent = n, e;
}
function ie(t, e, r) {
const n = window.getSelection();
if (!n) return !1;
function fe(t, r, e, n) {
const a = window.getSelection();
if (!a) return !1;
const l = t.innerHTML;
t.focus({ preventScroll: !0 });
const o = ae(t, e), c = (o.startContainer.nodeType === Node.ELEMENT_NODE ? o.startContainer : o.startContainer.parentElement)?.closest(".rte-merge-tag");
c && t.contains(c) && (o.setStartAfter(c), o.setEndAfter(c));
const c = me(t, r), g = (c.startContainer.nodeType === Node.ELEMENT_NODE ? c.startContainer : c.startContainer.parentElement)?.closest(".rte-merge-tag");
g && t.contains(g) && (c.setStartAfter(g), c.setEndAfter(g));
try {
o.deleteContents();
const d = oe(r), g = document.createTextNode(" "), u = document.createDocumentFragment();
u.appendChild(d), u.appendChild(g), o.insertNode(u);
c.deleteContents();
const i = ue(e, n), b = document.createTextNode(" "), u = document.createDocumentFragment();
u.appendChild(i), u.appendChild(b), c.insertNode(u);
const f = document.createRange();
return f.setStartAfter(g), f.collapse(!0), n.removeAllRanges(), n.addRange(f), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
} catch (d) {
return console.error("Failed to insert merge tag:", d), !1;
return f.setStartAfter(b), f.collapse(!0), a.removeAllRanges(), a.addRange(f), J(t, l), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
} catch (i) {
return console.error("Failed to insert merge tag:", i), !1;
}
}
function le(t, e) {
const r = Y[t], n = e.trim().toLowerCase();
return n ? r.filter((o) => o.searchIndex.includes(n)) : r;
function pe(t, r, e) {
const n = t.catalog.categoriesByKey[r]?.tags || [], a = e.trim().toLowerCase();
return a ? n.filter((l) => l.searchIndex.includes(a)) : n;
}
function se(t) {
ne(), A();
function be(t, r) {
ge(), R();
const e = {
category: "USER",
category: r.catalog.defaultCategory,
searchTerm: "",
filteredTags: Y.USER,
filteredTags: r.catalog.categoriesByKey[r.catalog.defaultCategory]?.tags || [],
selectedIndex: 0,
savedRange: (() => {
const a = window.getSelection();
if (!a || a.rangeCount === 0) return null;
const l = a.getRangeAt(0);
return t.contains(l.commonAncestorContainer) ? l.cloneRange() : null;
const o = window.getSelection();
if (!o || o.rangeCount === 0) return null;
const s = o.getRangeAt(0);
return t.contains(s.commonAncestorContainer) ? s.cloneRange() : null;
})(),
searchRaf: null
}, r = document.createElement("div");
r.className = "rte-merge-tag-overlay", r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "true"), re(t) && r.classList.add("rte-ui-theme-dark");
const n = document.createElement("div");
n.className = "rte-merge-tag-dialog";
const o = document.createElement("div");
o.className = "rte-merge-tag-header", o.innerHTML = `
<h2 style="margin:0; font-size:18px; font-weight:700;">Insert Merge Tag</h2>
<button class="rte-merge-tag-close" aria-label="Close" style="background:none;border:none;color:inherit;cursor:pointer;font-size:20px;">✕</button>
`;
const i = document.createElement("div");
i.className = "rte-merge-tag-body";
const c = document.createElement("input");
c.type = "text", c.className = "rte-merge-tag-input", c.placeholder = "Search merge tags...", c.setAttribute("aria-label", "Search merge tags");
const d = document.createElement("div");
d.className = "rte-merge-tag-tabs", L.forEach((a) => {
const l = document.createElement("button");
l.type = "button", l.className = "rte-merge-tag-tab", l.setAttribute("data-category", a), l.textContent = R[a].name, d.appendChild(l);
}, n = document.createElement("div");
n.className = "rte-merge-tag-overlay", n.setAttribute("role", "dialog"), n.setAttribute("aria-modal", "true"), de(t) && n.classList.add("rte-ui-theme-dark");
const a = document.createElement("div");
a.className = "rte-merge-tag-dialog";
const l = document.createElement("div");
l.className = "rte-merge-tag-header";
const c = document.createElement("h2");
c.style.margin = "0", c.style.fontSize = "18px", c.style.fontWeight = "700", c.textContent = r.dialog.title;
const d = document.createElement("button");
d.className = "rte-merge-tag-close", d.setAttribute("aria-label", "Close"), d.style.background = "none", d.style.border = "none", d.style.color = "inherit", d.style.cursor = "pointer", d.style.fontSize = "20px", d.textContent = "✕", l.appendChild(c), l.appendChild(d);
const g = document.createElement("div");
g.className = "rte-merge-tag-body";
const i = document.createElement("input");
i.type = "text", i.className = "rte-merge-tag-input", i.placeholder = r.dialog.searchPlaceholder, i.setAttribute("aria-label", "Search merge tags");
const b = document.createElement("div");
b.className = "rte-merge-tag-tabs", r.catalog.categoryKeys.forEach((o) => {
const s = document.createElement("button");
s.type = "button", s.className = "rte-merge-tag-tab", s.setAttribute("data-category", o), s.textContent = r.catalog.categoriesByKey[o]?.name || o, b.appendChild(s);
});
const g = document.createElement("div");
g.className = "rte-merge-tag-list";
const u = document.createElement("div");
u.className = "rte-merge-tag-preview", i.appendChild(c), i.appendChild(d), i.appendChild(g), i.appendChild(u);
u.className = "rte-merge-tag-list";
const f = document.createElement("div");
f.className = "rte-merge-tag-footer";
const x = document.createElement("button");
x.type = "button", x.className = "rte-merge-tag-btn-secondary", x.textContent = "Cancel";
const p = document.createElement("button");
p.type = "button", p.className = "rte-merge-tag-btn-primary", p.textContent = "Insert", f.appendChild(x), f.appendChild(p), n.appendChild(o), n.appendChild(i), n.appendChild(f), r.appendChild(n), document.body.appendChild(r), C = r;
const D = () => {
d.querySelectorAll(".rte-merge-tag-tab").forEach((l) => {
const m = l.dataset.category === e.category;
l.classList.toggle("active", m);
f.className = "rte-merge-tag-preview", g.appendChild(i), g.appendChild(b), g.appendChild(u), g.appendChild(f);
const w = document.createElement("div");
w.className = "rte-merge-tag-footer";
const v = document.createElement("button");
v.type = "button", v.className = "rte-merge-tag-btn-secondary", v.textContent = r.dialog.cancelText;
const y = document.createElement("button");
y.type = "button", y.className = "rte-merge-tag-btn-primary", y.textContent = r.dialog.insertText, w.appendChild(v), w.appendChild(y), a.appendChild(l), a.appendChild(g), a.appendChild(w), n.appendChild(a), document.body.appendChild(n), N = n;
const _ = () => {
b.querySelectorAll(".rte-merge-tag-tab").forEach((s) => {
const p = s.dataset.category === e.category;
s.classList.toggle("active", p);
});
}, w = () => {
}, L = () => {
if (e.filteredTags.length === 0) {

@@ -314,84 +434,91 @@ e.selectedIndex = -1;

e.selectedIndex < 0 && (e.selectedIndex = 0), e.selectedIndex >= e.filteredTags.length && (e.selectedIndex = e.filteredTags.length - 1);
}, I = () => {
w();
const a = e.selectedIndex >= 0 ? e.filteredTags[e.selectedIndex] : null;
if (!a) {
u.style.display = "none", p.disabled = !0;
}, O = () => {
if (!r.dialog.showPreview) {
f.style.display = "none", y.disabled = e.filteredTags.length === 0;
return;
}
u.style.display = "block", u.innerHTML = `<strong>Preview:</strong> {{ ${a.label} }}`, p.disabled = !1;
}, K = () => {
L();
const o = e.selectedIndex >= 0 ? e.filteredTags[e.selectedIndex] : null;
if (!o) {
f.style.display = "none", y.disabled = !0;
return;
}
f.style.display = "block", f.textContent = `Preview: ${r.formatToken(o)}`, y.disabled = !1;
}, Z = () => {
if (e.selectedIndex < 0) return;
g.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.scrollIntoView({ block: "nearest" });
}, h = () => {
if (e.filteredTags = le(e.category, e.searchTerm), e.filteredTags.length > 0 && e.selectedIndex < 0 && (e.selectedIndex = 0), w(), g.innerHTML = "", e.filteredTags.length === 0) {
const l = document.createElement("div");
l.className = "rte-merge-tag-empty", l.textContent = "No merge tags found", g.appendChild(l), I();
u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.scrollIntoView({ block: "nearest" });
}, k = () => {
u.querySelector(".rte-merge-tag-item.selected")?.classList.remove("selected"), e.selectedIndex >= 0 && u.querySelector(`.rte-merge-tag-item[data-index="${e.selectedIndex}"]`)?.classList.add("selected"), O(), Z();
}, A = () => {
if (e.filteredTags = pe(r, e.category, e.searchTerm), e.filteredTags.length > 0 && e.selectedIndex < 0 && (e.selectedIndex = 0), L(), u.innerHTML = "", e.filteredTags.length === 0) {
const s = document.createElement("div");
s.className = "rte-merge-tag-empty", s.textContent = r.dialog.emptyStateText, u.appendChild(s), O();
return;
}
const a = document.createDocumentFragment();
e.filteredTags.forEach((l, m) => {
const s = document.createElement("div");
s.className = "rte-merge-tag-item", s.setAttribute("data-index", String(m)), s.classList.toggle("selected", m === e.selectedIndex);
const N = document.createElement("div");
if (N.className = "rte-merge-tag-item-label", N.textContent = l.label, s.appendChild(N), l.preview) {
const S = document.createElement("div");
S.className = "rte-merge-tag-item-preview", S.textContent = l.preview, s.appendChild(S);
const o = document.createDocumentFragment();
e.filteredTags.forEach((s, p) => {
const m = document.createElement("div");
m.className = "rte-merge-tag-item", m.setAttribute("data-index", String(p)), m.classList.toggle("selected", p === e.selectedIndex);
const D = document.createElement("div");
if (D.className = "rte-merge-tag-item-label", D.textContent = s.label, m.appendChild(D), s.preview) {
const I = document.createElement("div");
I.className = "rte-merge-tag-item-preview", I.textContent = s.preview, m.appendChild(I);
}
a.appendChild(s);
}), g.appendChild(a), I(), K();
}, M = () => {
o.appendChild(m);
}), u.appendChild(o), k();
}, z = () => {
e.searchRaf !== null && cancelAnimationFrame(e.searchRaf), e.searchRaf = requestAnimationFrame(() => {
e.searchRaf = null, e.searchTerm = c.value, e.selectedIndex = 0, h();
e.searchRaf = null, e.searchTerm = i.value, e.selectedIndex = 0, A();
});
}, b = () => {
e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), r.remove(), C === r && (C = null, y = null);
}, E = () => {
if (w(), e.selectedIndex < 0) return;
const a = e.filteredTags[e.selectedIndex];
ie(t, e.savedRange, a) && b();
}, O = (a) => {
const m = a.target.closest(".rte-merge-tag-tab");
if (!m) return;
const s = m.dataset.category;
!s || !L.includes(s) || (e.category = s, e.searchTerm = "", c.value = "", e.selectedIndex = 0, D(), h());
}, _ = (a) => {
const m = a.target.closest(".rte-merge-tag-item");
if (!m) return;
const s = Number(m.dataset.index || "-1");
Number.isNaN(s) || s < 0 || s >= e.filteredTags.length || (e.selectedIndex = s, h());
}, F = (a) => {
const m = a.target.closest(".rte-merge-tag-item");
if (!m) return;
const s = Number(m.dataset.index || "-1");
Number.isNaN(s) || s < 0 || s >= e.filteredTags.length || (e.selectedIndex = s, E());
}, k = (a) => {
if (a.key === "Escape") {
a.preventDefault(), b();
}, x = () => {
e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove(), N === n && (N = null, E = null);
}, T = () => {
if (L(), e.selectedIndex < 0) return;
const o = e.filteredTags[e.selectedIndex];
fe(t, e.savedRange, o, r.formatToken) && x();
}, F = (o) => {
const p = o.target.closest(".rte-merge-tag-tab");
if (!p) return;
const m = p.dataset.category;
!m || !r.catalog.categoriesByKey[m] || (e.category = m, e.searchTerm = "", i.value = "", e.selectedIndex = 0, _(), A());
}, B = (o) => {
const p = o.target.closest(".rte-merge-tag-item");
if (!p) return;
const m = Number(p.dataset.index || "-1");
Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m, k());
}, U = (o) => {
const p = o.target.closest(".rte-merge-tag-item");
if (!p) return;
const m = Number(p.dataset.index || "-1");
Number.isNaN(m) || m < 0 || m >= e.filteredTags.length || (e.selectedIndex = m, T());
}, C = (o) => {
if (o.key === "Escape") {
o.preventDefault(), x();
return;
}
if (a.key === "ArrowDown") {
if (a.preventDefault(), e.filteredTags.length === 0) return;
e.selectedIndex = Math.min(e.filteredTags.length - 1, e.selectedIndex + 1), h();
if (o.key === "ArrowDown") {
if (o.preventDefault(), e.filteredTags.length === 0) return;
e.selectedIndex = Math.min(e.filteredTags.length - 1, e.selectedIndex + 1), k();
return;
}
if (a.key === "ArrowUp") {
if (a.preventDefault(), e.filteredTags.length === 0) return;
e.selectedIndex = Math.max(0, e.selectedIndex - 1), h();
if (o.key === "ArrowUp") {
if (o.preventDefault(), e.filteredTags.length === 0) return;
e.selectedIndex = Math.max(0, e.selectedIndex - 1), k();
return;
}
a.key === "Enter" && (a.preventDefault(), E());
}, U = (a) => {
a.target === r && b();
}, z = o.querySelector(".rte-merge-tag-close");
d.addEventListener("click", O), g.addEventListener("click", _), g.addEventListener("dblclick", F), c.addEventListener("input", M), c.addEventListener("keydown", k), r.addEventListener("click", U), n.addEventListener("keydown", k), z?.addEventListener("click", b), x.addEventListener("click", b), p.addEventListener("click", E), y = () => {
d.removeEventListener("click", O), g.removeEventListener("click", _), g.removeEventListener("dblclick", F), c.removeEventListener("input", M), c.removeEventListener("keydown", k), r.removeEventListener("click", U), n.removeEventListener("keydown", k), z?.removeEventListener("click", b), x.removeEventListener("click", b), p.removeEventListener("click", E), e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), r.remove();
}, D(), h(), setTimeout(() => {
c.focus();
o.key === "Enter" && (o.preventDefault(), T());
}, $ = (o) => {
o.target === n && x();
};
b.addEventListener("click", F), u.addEventListener("click", B), u.addEventListener("dblclick", U), i.addEventListener("input", z), i.addEventListener("keydown", C), n.addEventListener("click", $), a.addEventListener("keydown", C), d?.addEventListener("click", x), v.addEventListener("click", x), y.addEventListener("click", T), E = () => {
b.removeEventListener("click", F), u.removeEventListener("click", B), u.removeEventListener("dblclick", U), i.removeEventListener("input", z), i.removeEventListener("keydown", C), n.removeEventListener("click", $), a.removeEventListener("keydown", C), d?.removeEventListener("click", x), v.removeEventListener("click", x), y.removeEventListener("click", T), e.searchRaf !== null && (cancelAnimationFrame(e.searchRaf), e.searchRaf = null), n.remove();
}, _(), A(), setTimeout(() => {
i.focus();
}, 0);
}
const ce = () => ({
const ye = (t) => ({
name: "mergeTag",
config: t,
init: () => {
A(), P(), q();
R(), j(), V();
},

@@ -407,5 +534,5 @@ toolbar: [

insertMergeTag: () => {
A(), P(), q();
const t = J();
return t ? (se(t), !0) : !1;
R(), j(), V();
const r = X();
return r ? (be(r, oe(t)), !0) : !1;
}

@@ -415,3 +542,3 @@ }

export {
ce as MergeTagPlugin
ye as MergeTagPlugin
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d='.rte-page-break[data-type="page-break"]',g=".rte-content, .editora-content";let p=null,m=!1;const k=new Set(["DIV","P","BLOCKQUOTE","PRE","H1","H2","H3","H4","H5","H6","LI","TD","TH"]),x=()=>{p||typeof document>"u"||(p=document.createElement("style"),p.textContent=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d='.rte-page-break[data-type="page-break"]',g=".rte-content, .editora-content";let p=null,m=!1;const h=(e,n)=>{if(n===e.innerHTML)return;const t=window.execEditorCommand||window.executeEditorCommand;if(typeof t=="function")try{t("recordDomTransaction",e,n,e.innerHTML)}catch{}},x=new Set(["DIV","P","BLOCKQUOTE","PRE","H1","H2","H3","H4","H5","H6","LI","TD","TH"]),w=()=>{p||typeof document>"u"||(p=document.createElement("style"),p.textContent=`
.rte-page-break {

@@ -72,2 +72,2 @@ display: block;

}
`,document.head.appendChild(p))},N=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return(n.startContainer.nodeType===Node.ELEMENT_NODE?n.startContainer:n.startContainer.parentElement)?.closest(g)||null},v=()=>{const e=N();if(e)return e;const t=document.activeElement?.closest(g);return t||document.querySelector(g)},C=(e,n)=>{let t=e;for(;t&&t!==n;){if(t.nodeType===Node.ELEMENT_NODE){const r=t;if(k.has(r.tagName))return r}t=t.parentNode}return null},S=()=>{const e=document.createElement("div");return e.className="rte-page-break",e.setAttribute("data-page-break","true"),e.setAttribute("data-type","page-break"),e.setAttribute("contenteditable","false"),e.setAttribute("tabindex","0"),e.setAttribute("role","separator"),e.setAttribute("aria-label","Page break"),e},w=e=>{let n=e.nextElementSibling;for(;n&&n.matches(d);){const r=n;n=n.nextElementSibling,r.remove()}let t=e.previousElementSibling;for(;t&&t.matches(d);){const r=t;t=t.previousElementSibling,r.remove()}},h=e=>{const n=e.nextElementSibling;if(n&&!n.matches(d))return n;const t=document.createElement("p");return t.innerHTML="<br>",e.parentNode?.insertBefore(t,e.nextSibling),t},u=e=>{const n=window.getSelection();if(!n)return;const t=document.createRange();e.nodeType,Node.TEXT_NODE,t.setStart(e,0),t.collapse(!0),n.removeAllRanges(),n.addRange(t)},b=e=>{const n=window.getSelection();if(!n)return;const t=document.createRange();if(e.nodeType===Node.TEXT_NODE){const r=e;t.setStart(r,r.data.length)}else t.selectNodeContents(e),t.collapse(!1);n.removeAllRanges(),n.addRange(t)},f=(e,n)=>{let t=e;for(;t;){if(!(t instanceof HTMLElement&&t.matches(d)))return t;t=n==="previous"?t.previousSibling:t.nextSibling}return null},A=e=>{const n=window.getSelection();if(!n||!e.parentNode)return;const t=e.parentNode,r=Array.from(t.childNodes).indexOf(e);if(r<0)return;const o=document.createRange();o.setStart(t,r),o.setEnd(t,r+1),n.removeAllRanges(),n.addRange(o),e.focus({preventScroll:!0})},T=e=>{if(e.collapsed||e.startContainer!==e.endContainer||e.endOffset!==e.startOffset+1||!(e.startContainer instanceof Element||e.startContainer instanceof DocumentFragment))return null;const n=e.startContainer.childNodes[e.startOffset];return n instanceof HTMLElement&&n.matches(d)?n:null},L=(e,n,t)=>{if(!e.collapsed)return null;const{startContainer:r,startOffset:o}=e,i=a=>a instanceof HTMLElement&&a.matches(d)?a:null,s=a=>{if(r.nodeType===Node.ELEMENT_NODE){const c=r;if(a==="previous"){if(o>0)return c.childNodes[o-1]||null}else if(o<c.childNodes.length)return c.childNodes[o]||null}if(r.nodeType===Node.TEXT_NODE&&(a==="previous"&&o<r.data.length||a==="next"&&o>0))return null;let l=r;for(;l&&l!==n;){const c=a==="previous"?l.previousSibling:l.nextSibling;if(c)return c;l=l.parentNode}return null};if(r.nodeType===Node.ELEMENT_NODE){const a=r;return t==="Backspace"&&o>0?i(a.childNodes[o-1]||null):t==="Delete"?i(a.childNodes[o]||null):null}if(r.nodeType===Node.TEXT_NODE){const a=r;if(t==="Backspace"&&o===0){const l=i(a.previousSibling);return l||i(s("previous"))}if(t==="Delete"&&o===a.data.length){const l=i(a.nextSibling);return l||i(s("next"))}}return i(s(t==="Backspace"?"previous":"next"))},E=(e,n)=>{const t=e.closest(g),r=e.previousSibling,o=e.nextSibling;e.remove();const i=f(r,"previous"),s=f(o,"next");if(n==="Backspace"){if(i)b(i);else if(s)u(s);else if(t){const a=document.createElement("p");a.innerHTML="<br>",t.appendChild(a),u(a)}}else if(s)u(s);else if(i)b(i);else if(t){const a=document.createElement("p");a.innerHTML="<br>",t.appendChild(a),u(a)}return t&&t.dispatchEvent(new Event("input",{bubbles:!0})),!0},R=()=>{const e=v();if(!e)return!1;const n=window.getSelection();if(!n)return!1;let t;n.rangeCount>0&&e.contains(n.getRangeAt(0).commonAncestorContainer)?t=n.getRangeAt(0):(t=document.createRange(),t.selectNodeContents(e),t.collapse(!1),n.removeAllRanges(),n.addRange(t));const r=C(t.endContainer,e)||C(t.startContainer,e),o=S();r&&r.parentNode?r.parentNode.insertBefore(o,r.nextSibling):e.appendChild(o),w(o);const i=h(o);return u(i),e.dispatchEvent(new Event("input",{bubbles:!0})),!0},B=()=>{m||typeof document>"u"||(m=!0,document.addEventListener("click",e=>{const t=e.target?.closest(d);t&&(e.preventDefault(),e.stopPropagation(),A(t))}),document.addEventListener("keydown",e=>{const n=e.key;if(!["Backspace","Delete","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(n))return;const t=window.getSelection();if(!t||t.rangeCount===0)return;const r=t.getRangeAt(0),o=v();if(!o||!o.contains(r.commonAncestorContainer))return;const i=T(r);if(i){if(n==="Backspace"||n==="Delete"){e.preventDefault(),e.stopPropagation(),E(i,n);return}if(n==="ArrowRight"||n==="ArrowDown"){e.preventDefault();const s=f(i.nextSibling,"next")||h(i);u(s);return}if(n==="ArrowLeft"||n==="ArrowUp"){e.preventDefault();const s=f(i.previousSibling,"previous");s?b(s):u(o);return}}if(n==="Backspace"||n==="Delete"){const s=L(r,o,n);if(!s)return;e.preventDefault(),e.stopPropagation(),E(s,n)}}))},P=()=>(x(),B(),{name:"pageBreak",toolbar:[{label:"Page Break",command:"insertPageBreak",icon:'<svg fill="#000000" width="24px" height="24px" viewBox="0 0 14 14" 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="M1,6 L3,6 C3.55228475,6 4,6.44771525 4,7 C4,7.55228475 3.55228475,8 3,8 L1,8 C0.44771525,8 0,7.55228475 0,7 C0,6.44771525 0.44771525,6 1,6 Z M11,6 L13,6 C13.5522847,6 14,6.44771525 14,7 C14,7.55228475 13.5522847,8 13,8 L11,8 C10.4477153,8 10,7.55228475 10,7 C10,6.44771525 10.4477153,6 11,6 Z M6,6 L8,6 C8.55228475,6 9,6.44771525 9,7 C9,7.55228475 8.55228475,8 8,8 L6,8 C5.44771525,8 5,7.55228475 5,7 C5,6.44771525 5.44771525,6 6,6 Z M0,1 C0,0.44771525 0.44771525,-2.26485497e-13 1,-2.26485497e-13 C1.55228475,-2.26485497e-13 2,0.44771525 2,1 L2,3.0142458 L12,3.0142458 L12,1 C12,0.44771525 12.4477153,-2.26485497e-13 13,-2.26485497e-13 C13.5522847,-2.26485497e-13 14,0.44771525 14,1 L14,3.0142458 C14,4.1188153 13.1045695,5.0142458 12,5.0142458 L2,5.0142458 C0.8954305,5.0142458 0,4.1188153 0,3.0142458 L0,1 Z M0,13.0142458 L0,11 C0,9.8954305 0.8954305,9 2,9 L12,9 C13.1045695,9 14,9.8954305 14,11 L14,13.0142458 C14,13.5665305 13.5522847,14.0142458 13,14.0142458 C12.4477153,14.0142458 12,13.5665305 12,13.0142458 L12,11 L2,11 L2,13.0142458 C2,13.5665305 1.55228475,14.0142458 1,14.0142458 C0.44771525,14.0142458 0,13.5665305 0,13.0142458 Z"></path></g></svg>',shortcut:"Mod-Enter"}],commands:{insertPageBreak:R},keymap:{"Mod-Enter":"insertPageBreak"}});exports.PageBreakPlugin=P;
`,document.head.appendChild(p))},N=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const n=e.getRangeAt(0);return(n.startContainer.nodeType===Node.ELEMENT_NODE?n.startContainer:n.startContainer.parentElement)?.closest(g)||null},v=()=>{const e=N();if(e)return e;const t=document.activeElement?.closest(g);return t||document.querySelector(g)},C=(e,n)=>{let t=e;for(;t&&t!==n;){if(t.nodeType===Node.ELEMENT_NODE){const r=t;if(x.has(r.tagName))return r}t=t.parentNode}return null},S=()=>{const e=document.createElement("div");return e.className="rte-page-break",e.setAttribute("data-page-break","true"),e.setAttribute("data-type","page-break"),e.setAttribute("contenteditable","false"),e.setAttribute("tabindex","0"),e.setAttribute("role","separator"),e.setAttribute("aria-label","Page break"),e},T=e=>{let n=e.nextElementSibling;for(;n&&n.matches(d);){const r=n;n=n.nextElementSibling,r.remove()}let t=e.previousElementSibling;for(;t&&t.matches(d);){const r=t;t=t.previousElementSibling,r.remove()}},k=e=>{const n=e.nextElementSibling;if(n&&!n.matches(d))return n;const t=document.createElement("p");return t.innerHTML="<br>",e.parentNode?.insertBefore(t,e.nextSibling),t},u=e=>{const n=window.getSelection();if(!n)return;const t=document.createRange();e.nodeType,Node.TEXT_NODE,t.setStart(e,0),t.collapse(!0),n.removeAllRanges(),n.addRange(t)},b=e=>{const n=window.getSelection();if(!n)return;const t=document.createRange();if(e.nodeType===Node.TEXT_NODE){const r=e;t.setStart(r,r.data.length)}else t.selectNodeContents(e),t.collapse(!1);n.removeAllRanges(),n.addRange(t)},f=(e,n)=>{let t=e;for(;t;){if(!(t instanceof HTMLElement&&t.matches(d)))return t;t=n==="previous"?t.previousSibling:t.nextSibling}return null},L=e=>{const n=window.getSelection();if(!n||!e.parentNode)return;const t=e.parentNode,r=Array.from(t.childNodes).indexOf(e);if(r<0)return;const o=document.createRange();o.setStart(t,r),o.setEnd(t,r+1),n.removeAllRanges(),n.addRange(o),e.focus({preventScroll:!0})},A=e=>{if(e.collapsed||e.startContainer!==e.endContainer||e.endOffset!==e.startOffset+1||!(e.startContainer instanceof Element||e.startContainer instanceof DocumentFragment))return null;const n=e.startContainer.childNodes[e.startOffset];return n instanceof HTMLElement&&n.matches(d)?n:null},R=(e,n,t)=>{if(!e.collapsed)return null;const{startContainer:r,startOffset:o}=e,a=i=>i instanceof HTMLElement&&i.matches(d)?i:null,c=i=>{if(r.nodeType===Node.ELEMENT_NODE){const l=r;if(i==="previous"){if(o>0)return l.childNodes[o-1]||null}else if(o<l.childNodes.length)return l.childNodes[o]||null}if(r.nodeType===Node.TEXT_NODE&&(i==="previous"&&o<r.data.length||i==="next"&&o>0))return null;let s=r;for(;s&&s!==n;){const l=i==="previous"?s.previousSibling:s.nextSibling;if(l)return l;s=s.parentNode}return null};if(r.nodeType===Node.ELEMENT_NODE){const i=r;return t==="Backspace"&&o>0?a(i.childNodes[o-1]||null):t==="Delete"?a(i.childNodes[o]||null):null}if(r.nodeType===Node.TEXT_NODE){const i=r;if(t==="Backspace"&&o===0){const s=a(i.previousSibling);return s||a(c("previous"))}if(t==="Delete"&&o===i.data.length){const s=a(i.nextSibling);return s||a(c("next"))}}return a(c(t==="Backspace"?"previous":"next"))},E=(e,n)=>{const t=e.closest(g),r=t?.innerHTML??"",o=e.previousSibling,a=e.nextSibling;e.remove();const c=f(o,"previous"),i=f(a,"next");if(n==="Backspace"){if(c)b(c);else if(i)u(i);else if(t){const s=document.createElement("p");s.innerHTML="<br>",t.appendChild(s),u(s)}}else if(i)u(i);else if(c)b(c);else if(t){const s=document.createElement("p");s.innerHTML="<br>",t.appendChild(s),u(s)}return t&&(h(t,r),t.dispatchEvent(new Event("input",{bubbles:!0}))),!0},y=()=>{const e=v();if(!e)return!1;const n=e.innerHTML,t=window.getSelection();if(!t)return!1;let r;t.rangeCount>0&&e.contains(t.getRangeAt(0).commonAncestorContainer)?r=t.getRangeAt(0):(r=document.createRange(),r.selectNodeContents(e),r.collapse(!1),t.removeAllRanges(),t.addRange(r));const o=C(r.endContainer,e)||C(r.startContainer,e),a=S();o&&o.parentNode?o.parentNode.insertBefore(a,o.nextSibling):e.appendChild(a),T(a);const c=k(a);return u(c),h(e,n),e.dispatchEvent(new Event("input",{bubbles:!0})),!0},B=()=>{m||typeof document>"u"||(m=!0,document.addEventListener("click",e=>{const t=e.target?.closest(d);t&&(e.preventDefault(),e.stopPropagation(),L(t))}),document.addEventListener("keydown",e=>{const n=e.key;if(!["Backspace","Delete","ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(n))return;const t=window.getSelection();if(!t||t.rangeCount===0)return;const r=t.getRangeAt(0),o=v();if(!o||!o.contains(r.commonAncestorContainer))return;const a=A(r);if(a){if(n==="Backspace"||n==="Delete"){e.preventDefault(),e.stopPropagation(),E(a,n);return}if(n==="ArrowRight"||n==="ArrowDown"){e.preventDefault();const c=f(a.nextSibling,"next")||k(a);u(c);return}if(n==="ArrowLeft"||n==="ArrowUp"){e.preventDefault();const c=f(a.previousSibling,"previous");c?b(c):u(o);return}}if(n==="Backspace"||n==="Delete"){const c=R(r,o,n);if(!c)return;e.preventDefault(),e.stopPropagation(),E(c,n)}}))},P=()=>(w(),B(),{name:"pageBreak",toolbar:[{label:"Page Break",command:"insertPageBreak",icon:'<svg fill="#000000" width="24px" height="24px" viewBox="0 0 14 14" 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="M1,6 L3,6 C3.55228475,6 4,6.44771525 4,7 C4,7.55228475 3.55228475,8 3,8 L1,8 C0.44771525,8 0,7.55228475 0,7 C0,6.44771525 0.44771525,6 1,6 Z M11,6 L13,6 C13.5522847,6 14,6.44771525 14,7 C14,7.55228475 13.5522847,8 13,8 L11,8 C10.4477153,8 10,7.55228475 10,7 C10,6.44771525 10.4477153,6 11,6 Z M6,6 L8,6 C8.55228475,6 9,6.44771525 9,7 C9,7.55228475 8.55228475,8 8,8 L6,8 C5.44771525,8 5,7.55228475 5,7 C5,6.44771525 5.44771525,6 6,6 Z M0,1 C0,0.44771525 0.44771525,-2.26485497e-13 1,-2.26485497e-13 C1.55228475,-2.26485497e-13 2,0.44771525 2,1 L2,3.0142458 L12,3.0142458 L12,1 C12,0.44771525 12.4477153,-2.26485497e-13 13,-2.26485497e-13 C13.5522847,-2.26485497e-13 14,0.44771525 14,1 L14,3.0142458 C14,4.1188153 13.1045695,5.0142458 12,5.0142458 L2,5.0142458 C0.8954305,5.0142458 0,4.1188153 0,3.0142458 L0,1 Z M0,13.0142458 L0,11 C0,9.8954305 0.8954305,9 2,9 L12,9 C13.1045695,9 14,9.8954305 14,11 L14,13.0142458 C14,13.5665305 13.5522847,14.0142458 13,14.0142458 C12.4477153,14.0142458 12,13.5665305 12,13.0142458 L12,11 L2,11 L2,13.0142458 C2,13.5665305 1.55228475,14.0142458 1,14.0142458 C0.44771525,14.0142458 0,13.5665305 0,13.0142458 Z"></path></g></svg>',shortcut:"Mod-Enter"}],commands:{insertPageBreak:y},keymap:{"Mod-Enter":"insertPageBreak"}});exports.PageBreakPlugin=P;
const u = '.rte-page-break[data-type="page-break"]', g = ".rte-content, .editora-content";
let p = null, m = !1;
const v = /* @__PURE__ */ new Set([
const h = (e, n) => {
if (n === e.innerHTML) return;
const t = window.execEditorCommand || window.executeEditorCommand;
if (typeof t == "function")
try {
t("recordDomTransaction", e, n, e.innerHTML);
} catch {
}
}, x = /* @__PURE__ */ new Set([
"DIV",

@@ -17,3 +25,3 @@ "P",

"TH"
]), x = () => {
]), w = () => {
p || typeof document > "u" || (p = document.createElement("style"), p.textContent = `

@@ -96,3 +104,3 @@ .rte-page-break {

return (n.startContainer.nodeType === Node.ELEMENT_NODE ? n.startContainer : n.startContainer.parentElement)?.closest(g) || null;
}, h = () => {
}, k = () => {
const e = N();

@@ -107,3 +115,3 @@ if (e) return e;

const r = t;
if (v.has(r.tagName))
if (x.has(r.tagName))
return r;

@@ -114,3 +122,3 @@ }

return null;
}, w = () => {
}, T = () => {
const e = document.createElement("div");

@@ -129,3 +137,3 @@ return e.className = "rte-page-break", e.setAttribute("data-page-break", "true"), e.setAttribute("data-type", "page-break"), e.setAttribute("contenteditable", "false"), e.setAttribute("tabindex", "0"), e.setAttribute("role", "separator"), e.setAttribute("aria-label", "Page break"), e;

}
}, k = (e) => {
}, v = (e) => {
const n = e.nextElementSibling;

@@ -159,3 +167,3 @@ if (n && !n.matches(u))

return null;
}, A = (e) => {
}, L = (e) => {
const n = window.getSelection();

@@ -167,24 +175,24 @@ if (!n || !e.parentNode) return;

o.setStart(t, r), o.setEnd(t, r + 1), n.removeAllRanges(), n.addRange(o), e.focus({ preventScroll: !0 });
}, L = (e) => {
}, A = (e) => {
if (e.collapsed || e.startContainer !== e.endContainer || e.endOffset !== e.startOffset + 1 || !(e.startContainer instanceof Element || e.startContainer instanceof DocumentFragment)) return null;
const n = e.startContainer.childNodes[e.startOffset];
return n instanceof HTMLElement && n.matches(u) ? n : null;
}, T = (e, n, t) => {
}, R = (e, n, t) => {
if (!e.collapsed) return null;
const { startContainer: r, startOffset: o } = e, i = (a) => a instanceof HTMLElement && a.matches(u) ? a : null, s = (a) => {
const { startContainer: r, startOffset: o } = e, a = (i) => i instanceof HTMLElement && i.matches(u) ? i : null, c = (i) => {
if (r.nodeType === Node.ELEMENT_NODE) {
const c = r;
if (a === "previous") {
const l = r;
if (i === "previous") {
if (o > 0)
return c.childNodes[o - 1] || null;
} else if (o < c.childNodes.length)
return c.childNodes[o] || null;
return l.childNodes[o - 1] || null;
} else if (o < l.childNodes.length)
return l.childNodes[o] || null;
}
if (r.nodeType === Node.TEXT_NODE && (a === "previous" && o < r.data.length || a === "next" && o > 0))
if (r.nodeType === Node.TEXT_NODE && (i === "previous" && o < r.data.length || i === "next" && o > 0))
return null;
let l = r;
for (; l && l !== n; ) {
const c = a === "previous" ? l.previousSibling : l.nextSibling;
if (c) return c;
l = l.parentNode;
let s = r;
for (; s && s !== n; ) {
const l = i === "previous" ? s.previousSibling : s.nextSibling;
if (l) return l;
s = s.parentNode;
}

@@ -194,54 +202,54 @@ return null;

if (r.nodeType === Node.ELEMENT_NODE) {
const a = r;
return t === "Backspace" && o > 0 ? i(a.childNodes[o - 1] || null) : t === "Delete" ? i(a.childNodes[o] || null) : null;
const i = r;
return t === "Backspace" && o > 0 ? a(i.childNodes[o - 1] || null) : t === "Delete" ? a(i.childNodes[o] || null) : null;
}
if (r.nodeType === Node.TEXT_NODE) {
const a = r;
const i = r;
if (t === "Backspace" && o === 0) {
const l = i(a.previousSibling);
return l || i(s("previous"));
const s = a(i.previousSibling);
return s || a(c("previous"));
}
if (t === "Delete" && o === a.data.length) {
const l = i(a.nextSibling);
return l || i(s("next"));
if (t === "Delete" && o === i.data.length) {
const s = a(i.nextSibling);
return s || a(c("next"));
}
}
return i(s(t === "Backspace" ? "previous" : "next"));
return a(c(t === "Backspace" ? "previous" : "next"));
}, E = (e, n) => {
const t = e.closest(g), r = e.previousSibling, o = e.nextSibling;
const t = e.closest(g), r = t?.innerHTML ?? "", o = e.previousSibling, a = e.nextSibling;
e.remove();
const i = f(r, "previous"), s = f(o, "next");
const c = f(o, "previous"), i = f(a, "next");
if (n === "Backspace") {
if (i)
b(i);
else if (s)
d(s);
if (c)
b(c);
else if (i)
d(i);
else if (t) {
const a = document.createElement("p");
a.innerHTML = "<br>", t.appendChild(a), d(a);
const s = document.createElement("p");
s.innerHTML = "<br>", t.appendChild(s), d(s);
}
} else if (s)
d(s);
else if (i)
b(i);
} else if (i)
d(i);
else if (c)
b(c);
else if (t) {
const a = document.createElement("p");
a.innerHTML = "<br>", t.appendChild(a), d(a);
const s = document.createElement("p");
s.innerHTML = "<br>", t.appendChild(s), d(s);
}
return t && t.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
}, R = () => {
const e = h();
return t && (h(t, r), t.dispatchEvent(new Event("input", { bubbles: !0 }))), !0;
}, y = () => {
const e = k();
if (!e) return !1;
const n = window.getSelection();
if (!n) return !1;
let t;
n.rangeCount > 0 && e.contains(n.getRangeAt(0).commonAncestorContainer) ? t = n.getRangeAt(0) : (t = document.createRange(), t.selectNodeContents(e), t.collapse(!1), n.removeAllRanges(), n.addRange(t));
const r = C(t.endContainer, e) || C(t.startContainer, e), o = w();
r && r.parentNode ? r.parentNode.insertBefore(o, r.nextSibling) : e.appendChild(o), S(o);
const i = k(o);
return d(i), e.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
const n = e.innerHTML, t = window.getSelection();
if (!t) return !1;
let r;
t.rangeCount > 0 && e.contains(t.getRangeAt(0).commonAncestorContainer) ? r = t.getRangeAt(0) : (r = document.createRange(), r.selectNodeContents(e), r.collapse(!1), t.removeAllRanges(), t.addRange(r));
const o = C(r.endContainer, e) || C(r.startContainer, e), a = T();
o && o.parentNode ? o.parentNode.insertBefore(a, o.nextSibling) : e.appendChild(a), S(a);
const c = v(a);
return d(c), h(e, n), e.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
}, B = () => {
m || typeof document > "u" || (m = !0, document.addEventListener("click", (e) => {
const t = e.target?.closest(u);
t && (e.preventDefault(), e.stopPropagation(), A(t));
t && (e.preventDefault(), e.stopPropagation(), L(t));
}), document.addEventListener("keydown", (e) => {

@@ -253,8 +261,8 @@ const n = e.key;

if (!t || t.rangeCount === 0) return;
const r = t.getRangeAt(0), o = h();
const r = t.getRangeAt(0), o = k();
if (!o || !o.contains(r.commonAncestorContainer)) return;
const i = L(r);
if (i) {
const a = A(r);
if (a) {
if (n === "Backspace" || n === "Delete") {
e.preventDefault(), e.stopPropagation(), E(i, n);
e.preventDefault(), e.stopPropagation(), E(a, n);
return;

@@ -264,4 +272,4 @@ }

e.preventDefault();
const s = f(i.nextSibling, "next") || k(i);
d(s);
const c = f(a.nextSibling, "next") || v(a);
d(c);
return;

@@ -271,4 +279,4 @@ }

e.preventDefault();
const s = f(i.previousSibling, "previous");
s ? b(s) : d(o);
const c = f(a.previousSibling, "previous");
c ? b(c) : d(o);
return;

@@ -278,3 +286,3 @@ }

if (n === "Backspace" || n === "Delete") {
const s = T(
const c = R(
r,

@@ -284,7 +292,7 @@ o,

);
if (!s) return;
e.preventDefault(), e.stopPropagation(), E(s, n);
if (!c) return;
e.preventDefault(), e.stopPropagation(), E(c, n);
}
}));
}, D = () => (x(), B(), {
}, D = () => (w(), B(), {
name: "pageBreak",

@@ -300,3 +308,3 @@ toolbar: [

commands: {
insertPageBreak: R
insertPageBreak: y
},

@@ -303,0 +311,0 @@ keymap: {

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p={all:{name:"All",characters:["€","£","¥","¢","₹","₽","₩","₿","₺","₴","₦","₨","₪","₫","₭","₮","₯","₰","₱","₲","₳","₴","₵","₶","₷","₹","₺","₼","₽","₾","₿",'"',"'","«","»","„","‟","‹","›","‚","‛","〝","〞","〟","‟","„","©","®","™","°","§","¶","†","‡","•","‣","⁃","‰","‱","′","″","‴","‵","‶","‷","※","‼","‽","‾","‿","⁀","⁁","⁂","⁃","⁇","⁈","⁉","+","-","×","÷","=","≠","≈","≡","≤","≥","<",">","±","∓","∴","∵","∶","∷","∸","∹","∺","∻","∼","∽","∾","∿","≀","≁","≂","≃","≄","≅","≆","≇","≈","≉","≊","≋","≌","≍","≎","≏","≐","≑","≒","≓","≔","≕","≖","≗","≘","≙","≚","≛","≜","≝","≞","≟","≠","≡","≢","≣","≤","≥","≦","≧","≨","≩","≪","≫","≬","≭","≮","≯","≰","≱","≲","≳","≴","≵","≶","≷","≸","≹","≺","≻","≼","≽","≾","≿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ","¡","¿","‽","‼","⁇","⁈","⁉","※","‾","‿","⁀","⁁","⁂","⁃","←","↑","→","↓","↔","↕","↖","↗","↘","↙","↚","↛","↜","↝","↞","↟","↠","↡","↢","↣","↤","↥","↦","↧","↨","↩","↪","↫","↬","↭","↮","↯","↰","↱","↲","↳","↴","↵","↶","↷","↸","↹","↺","↻","↼","↽","↾","↿","⇀","⇁","⇂","⇃","⇄","⇅","⇆","⇇","⇈","⇉","⇊","⇋","⇌","⇍","⇎","⇏","⇐","⇑","⇒","⇓","⇔","⇕","⇖","⇗","⇘","⇙","⇚","⇛","⇜","⇝","⇞","⇟","⇠","⇡","⇢","⇣","⇤","⇥","⇦","⇧","⇨","⇩","⇪","⇫","⇬","⇭","⇮","⇯","⇰","⇱","⇲","⇳","⇴","⇵","⇶","⇷","⇸","⇹","⇺","⇻","⇼","⇽","⇾","⇿"]},currency:{name:"Currency",characters:["€","£","¥","¢","₹","₽","₩","₿","₺","₴","₦","₨","₪","₫","₭","₮","₯","₰","₱","₲","₳","₵","₶","₷","₼","₾","₿"]},text:{name:"Text",characters:["©","®","™","°","§","¶","†","‡","•","‣","⁃","‰","‱","′","″","‴","‵","‶","‷","※","‼","‽","‾","‿","⁀","⁁","⁂"]},quotation:{name:"Quotation",characters:['"',"'","«","»","„","‟","‹","›","‚","‛","〝","〞","〟"]},mathematical:{name:"Mathematical",characters:["+","-","×","÷","=","≠","≈","≡","≤","≥","<",">","±","∓","∴","∵","∶","∷","∸","∹","∺","∻","∼","∽","∾","∿","≀","≁","≂","≃","≄","≅","≆","≇","≉","≊","≋","≌","≍","≎","≏","≐","≑","≒","≓","≔","≕","≖","≗","≘","≙","≚","≛","≜","≝","≞","≟","≢","≣","≦","≧","≨","≩","≪","≫","≬","≭","≮","≯","≰","≱","≲","≳","≴","≵","≶","≷","≸","≹","≺","≻","≼","≽","≾","≿"]},"extended-latin":{name:"Extended Latin",characters:["À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ"]},symbols:{name:"Symbols",characters:["¡","¿","‽","‼","⁇","⁈","⁉","※","‾","‿","⁀","⁁","⁂","⁃"]},arrows:{name:"Arrows",characters:["←","↑","→","↓","↔","↕","↖","↗","↘","↙","↚","↛","↜","↝","↞","↟","↠","↡","↢","↣","↤","↥","↦","↧","↨","↩","↪","↫","↬","↭","↮","↯","↰","↱","↲","↳","↴","↵","↶","↷","↸","↹","↺","↻","↼","↽","↾","↿","⇀","⇁","⇂","⇃","⇄","⇅","⇆","⇇","⇈","⇉","⇊","⇋","⇌","⇍","⇎","⇏","⇐","⇑","⇒","⇓","⇔","⇕","⇖","⇗","⇘","⇙","⇚","⇛","⇜","⇝","⇞","⇟","⇠","⇡","⇢","⇣","⇤","⇥","⇦","⇧","⇨","⇩","⇪","⇫","⇬","⇭","⇮","⇯","⇰","⇱","⇲","⇳","⇴","⇵","⇶","⇷","⇸","⇹","⇺","⇻","⇼","⇽","⇾","⇿"]}},g={"€":"euro","£":"pound","¥":"yen","¢":"cent","₹":"rupee","₽":"ruble","₩":"won","₿":"bitcoin",'"':"quote","'":"apostrophe","«":"left angle quote","»":"right angle quote","„":"low quote","©":"copyright","®":"registered","™":"trademark","°":"degree","§":"section","¶":"paragraph","†":"dagger","‡":"double dagger","•":"bullet","‰":"per mille","′":"prime","″":"double prime","+":"plus","-":"minus","×":"multiplication","÷":"division","=":"equals","≠":"not equal","≈":"approximately","≡":"identical","≤":"less or equal","≥":"greater or equal","±":"plus minus",À:"a grave",Á:"a acute",Â:"a circumflex",Ã:"a tilde",Ä:"a diaeresis",Ç:"c cedilla","←":"left arrow","↑":"up arrow","→":"right arrow","↓":"down arrow","↔":"left right arrow"};let u=!1;const f='[data-theme="dark"], .dark, .editora-theme-dark',b=()=>{const a=window.getSelection();if(!a||a.rangeCount===0)return null;const e=a.anchorNode;return(e instanceof HTMLElement?e:e?.parentElement)?.closest(".rte-content, .editora-content")||null},m=a=>{const e=a||b();return e?!!e.closest(f):!1},x=()=>{if(typeof document>"u")return;const a="special-characters-plugin-styles";if(document.getElementById(a))return;const e=document.createElement("style");e.id=a,e.textContent=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g={all:{name:"All",characters:["€","£","¥","¢","₹","₽","₩","₿","₺","₴","₦","₨","₪","₫","₭","₮","₯","₰","₱","₲","₳","₴","₵","₶","₷","₹","₺","₼","₽","₾","₿",'"',"'","«","»","„","‟","‹","›","‚","‛","〝","〞","〟","‟","„","©","®","™","°","§","¶","†","‡","•","‣","⁃","‰","‱","′","″","‴","‵","‶","‷","※","‼","‽","‾","‿","⁀","⁁","⁂","⁃","⁇","⁈","⁉","+","-","×","÷","=","≠","≈","≡","≤","≥","<",">","±","∓","∴","∵","∶","∷","∸","∹","∺","∻","∼","∽","∾","∿","≀","≁","≂","≃","≄","≅","≆","≇","≈","≉","≊","≋","≌","≍","≎","≏","≐","≑","≒","≓","≔","≕","≖","≗","≘","≙","≚","≛","≜","≝","≞","≟","≠","≡","≢","≣","≤","≥","≦","≧","≨","≩","≪","≫","≬","≭","≮","≯","≰","≱","≲","≳","≴","≵","≶","≷","≸","≹","≺","≻","≼","≽","≾","≿","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ","¡","¿","‽","‼","⁇","⁈","⁉","※","‾","‿","⁀","⁁","⁂","⁃","←","↑","→","↓","↔","↕","↖","↗","↘","↙","↚","↛","↜","↝","↞","↟","↠","↡","↢","↣","↤","↥","↦","↧","↨","↩","↪","↫","↬","↭","↮","↯","↰","↱","↲","↳","↴","↵","↶","↷","↸","↹","↺","↻","↼","↽","↾","↿","⇀","⇁","⇂","⇃","⇄","⇅","⇆","⇇","⇈","⇉","⇊","⇋","⇌","⇍","⇎","⇏","⇐","⇑","⇒","⇓","⇔","⇕","⇖","⇗","⇘","⇙","⇚","⇛","⇜","⇝","⇞","⇟","⇠","⇡","⇢","⇣","⇤","⇥","⇦","⇧","⇨","⇩","⇪","⇫","⇬","⇭","⇮","⇯","⇰","⇱","⇲","⇳","⇴","⇵","⇶","⇷","⇸","⇹","⇺","⇻","⇼","⇽","⇾","⇿"]},currency:{name:"Currency",characters:["€","£","¥","¢","₹","₽","₩","₿","₺","₴","₦","₨","₪","₫","₭","₮","₯","₰","₱","₲","₳","₵","₶","₷","₼","₾","₿"]},text:{name:"Text",characters:["©","®","™","°","§","¶","†","‡","•","‣","⁃","‰","‱","′","″","‴","‵","‶","‷","※","‼","‽","‾","‿","⁀","⁁","⁂"]},quotation:{name:"Quotation",characters:['"',"'","«","»","„","‟","‹","›","‚","‛","〝","〞","〟"]},mathematical:{name:"Mathematical",characters:["+","-","×","÷","=","≠","≈","≡","≤","≥","<",">","±","∓","∴","∵","∶","∷","∸","∹","∺","∻","∼","∽","∾","∿","≀","≁","≂","≃","≄","≅","≆","≇","≉","≊","≋","≌","≍","≎","≏","≐","≑","≒","≓","≔","≕","≖","≗","≘","≙","≚","≛","≜","≝","≞","≟","≢","≣","≦","≧","≨","≩","≪","≫","≬","≭","≮","≯","≰","≱","≲","≳","≴","≵","≶","≷","≸","≹","≺","≻","≼","≽","≾","≿"]},"extended-latin":{name:"Extended Latin",characters:["À","Á","Â","Ã","Ä","Å","Æ","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Ü","Ý","Þ","ß","à","á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï","ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ","ÿ"]},symbols:{name:"Symbols",characters:["¡","¿","‽","‼","⁇","⁈","⁉","※","‾","‿","⁀","⁁","⁂","⁃"]},arrows:{name:"Arrows",characters:["←","↑","→","↓","↔","↕","↖","↗","↘","↙","↚","↛","↜","↝","↞","↟","↠","↡","↢","↣","↤","↥","↦","↧","↨","↩","↪","↫","↬","↭","↮","↯","↰","↱","↲","↳","↴","↵","↶","↷","↸","↹","↺","↻","↼","↽","↾","↿","⇀","⇁","⇂","⇃","⇄","⇅","⇆","⇇","⇈","⇉","⇊","⇋","⇌","⇍","⇎","⇏","⇐","⇑","⇒","⇓","⇔","⇕","⇖","⇗","⇘","⇙","⇚","⇛","⇜","⇝","⇞","⇟","⇠","⇡","⇢","⇣","⇤","⇥","⇦","⇧","⇨","⇩","⇪","⇫","⇬","⇭","⇮","⇯","⇰","⇱","⇲","⇳","⇴","⇵","⇶","⇷","⇸","⇹","⇺","⇻","⇼","⇽","⇾","⇿"]}},x={"€":"euro","£":"pound","¥":"yen","¢":"cent","₹":"rupee","₽":"ruble","₩":"won","₿":"bitcoin",'"':"quote","'":"apostrophe","«":"left angle quote","»":"right angle quote","„":"low quote","©":"copyright","®":"registered","™":"trademark","°":"degree","§":"section","¶":"paragraph","†":"dagger","‡":"double dagger","•":"bullet","‰":"per mille","′":"prime","″":"double prime","+":"plus","-":"minus","×":"multiplication","÷":"division","=":"equals","≠":"not equal","≈":"approximately","≡":"identical","≤":"less or equal","≥":"greater or equal","±":"plus minus",À:"a grave",Á:"a acute",Â:"a circumflex",Ã:"a tilde",Ä:"a diaeresis",Ç:"c cedilla","←":"left arrow","↑":"up arrow","→":"right arrow","↓":"down arrow","↔":"left right arrow"};let u=!1;const C='[data-theme="dark"], .dark, .editora-theme-dark',k=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.anchorNode;return(e instanceof HTMLElement?e:e?.parentElement)?.closest(".rte-content, .editora-content")||null},E=t=>{const e=t||k();return e?!!e.closest(C):!1},z=()=>{if(typeof document>"u")return;const t="special-characters-plugin-styles";if(document.getElementById(t))return;const e=document.createElement("style");e.id=t,e.textContent=`
.special-characters-overlay {

@@ -13,2 +13,22 @@ --rte-sc-overlay-bg: rgba(15, 23, 36, 0.56);

--rte-sc-ring: rgba(31, 117, 254, 0.18);
--rte-picker-dialog-width: min(640px, 96vw);
--rte-picker-dialog-max-height: min(560px, 86vh);
--rte-picker-dialog-radius: 12px;
--rte-picker-search-wrap-padding: 12px;
--rte-picker-search-height: 38px;
--rte-picker-search-font-size: 13px;
--rte-picker-search-radius: 8px;
--rte-picker-tabs-width: 156px;
--rte-picker-tab-padding-y: 10px;
--rte-picker-tab-padding-x: 12px;
--rte-picker-tab-font-size: 13px;
--rte-picker-grid-padding: 12px;
--rte-picker-grid-gap: 6px;
--rte-picker-cell-size: 34px;
--rte-picker-cell-font-size: 17px;
--rte-picker-cell-radius: 7px;
--rte-picker-mobile-tab-min-width: 82px;
--rte-picker-mobile-cell-size: 32px;
--rte-picker-mobile-grid-gap: 5px;
--rte-picker-mobile-dialog-max-height: 88vh;
position: fixed;

@@ -46,7 +66,6 @@ top: 0;

border: 1px solid var(--rte-sc-border);
border-radius: 12px;
border-radius: var(--rte-picker-dialog-radius);
box-shadow: 0 24px 48px rgba(10, 15, 24, 0.28);
max-width: 800px;
width: 90%;
max-height: 80vh;
width: var(--rte-picker-dialog-width);
max-height: var(--rte-picker-dialog-max-height);
display: flex;

@@ -105,6 +124,7 @@ flex-direction: column;

overflow: hidden;
min-width: 0;
}
.special-characters-search {
padding: 16px 16px 0 16px;
padding: var(--rte-picker-search-wrap-padding) var(--rte-picker-search-wrap-padding) 0 var(--rte-picker-search-wrap-padding);
}

@@ -114,6 +134,7 @@

width: 100%;
padding: 10px 12px;
height: var(--rte-picker-search-height);
padding: 8px 12px;
border: 1px solid var(--rte-sc-border);
border-radius: 8px;
font-size: 14px;
border-radius: var(--rte-picker-search-radius);
font-size: var(--rte-picker-search-font-size);
color: var(--rte-sc-dialog-text);

@@ -138,9 +159,10 @@ background-color: var(--rte-sc-subtle-bg);

flex-direction: column;
width: 180px;
width: var(--rte-picker-tabs-width);
border-right: 1px solid var(--rte-sc-border);
background-color: var(--rte-sc-subtle-bg);
overflow-y: auto;
}
.special-characters-tab {
padding: 12px 16px;
padding: var(--rte-picker-tab-padding-y) var(--rte-picker-tab-padding-x);
border: none;

@@ -150,6 +172,7 @@ background: none;

cursor: pointer;
font-size: 14px;
font-size: var(--rte-picker-tab-font-size);
color: var(--rte-sc-muted-text);
border-bottom: 1px solid var(--rte-sc-border);
transition: all 0.2s ease;
line-height: 1.25;
}

@@ -169,12 +192,13 @@

.special-characters-grid {
padding: 16px;
padding: var(--rte-picker-grid-padding);
overflow-y: auto;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
gap: 8px;
grid-template-columns: repeat(auto-fill, minmax(var(--rte-picker-cell-size), 1fr));
gap: var(--rte-picker-grid-gap);
contain: content;
}
.special-characters-item {
width: 40px;
height: 40px;
width: var(--rte-picker-cell-size);
height: var(--rte-picker-cell-size);
display: flex;

@@ -185,5 +209,5 @@ align-items: center;

background: var(--rte-sc-subtle-bg);
border-radius: 8px;
border-radius: var(--rte-picker-cell-radius);
cursor: pointer;
font-size: 18px;
font-size: var(--rte-picker-cell-font-size);
transition: all 0.2s ease;

@@ -217,4 +241,4 @@ color: var(--rte-sc-dialog-text);

.special-characters-dialog {
width: 95%;
max-height: 90vh;
width: 96%;
max-height: var(--rte-picker-mobile-dialog-max-height);
}

@@ -238,30 +262,44 @@

white-space: nowrap;
min-width: var(--rte-picker-mobile-tab-min-width);
}
.special-characters-grid {
grid-template-columns: repeat(auto-fill, minmax(var(--rte-picker-mobile-cell-size), 1fr));
gap: var(--rte-picker-mobile-grid-gap);
}
.special-characters-item {
width: var(--rte-picker-mobile-cell-size);
height: var(--rte-picker-mobile-cell-size);
font-size: 16px;
}
}
`,document.head.appendChild(e)},v=a=>{const e=window.getSelection();if(e&&e.rangeCount>0){const r=e.getRangeAt(0);r.deleteContents();const c=document.createTextNode(a);r.insertNode(c),r.setStartAfter(c),r.setEndAfter(c),e.removeAllRanges(),e.addRange(r)}},y=a=>{if(typeof window>"u"||u)return;u=!0,x();let e="all",r="";const c=document.createElement("div");c.className="special-characters-overlay",m(a)&&c.classList.add("rte-ui-theme-dark");const o=document.createElement("div");o.className="special-characters-dialog",o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true");const d=()=>{const s=p[e].characters.filter(t=>{if(!r.trim())return!0;const n=r.toLowerCase();return t.toLowerCase().includes(n)||(g[t]||"").toLowerCase().includes(n)});o.innerHTML=`
<div class="special-characters-header">
<h2>Insert Special Characters</h2>
<button class="special-characters-close">×</button>
`,document.head.appendChild(e)},S=t=>{const e=window.getSelection();if(e&&e.rangeCount>0){const a=e.getRangeAt(0);a.deleteContents();const c=document.createTextNode(t);a.insertNode(c),a.setStartAfter(c),a.setEndAfter(c),e.removeAllRanges(),e.addRange(a)}},L=t=>{if(typeof window>"u"||u)return;u=!0,z();let e="all",a="",c=null;const i=document.createElement("div");i.className="special-characters-overlay",E(t)&&i.classList.add("rte-ui-theme-dark");const s=document.createElement("div");s.className="special-characters-dialog",s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.innerHTML=`
<div class="special-characters-header">
<h2>Insert Special Characters</h2>
<button class="special-characters-close">×</button>
</div>
<div class="special-characters-content">
<div class="special-characters-tabs">
${Object.keys(g).map(r=>`
<button class="special-characters-tab ${e===r?"active":""}" data-category="${r}">
${g[r].name}
</button>
`).join("")}
</div>
<div class="special-characters-content">
<div class="special-characters-tabs">
${Object.keys(p).map(t=>`
<button class="special-characters-tab ${e===t?"active":""}" data-category="${t}">
${p[t].name}
</button>
`).join("")}
<div class="special-characters-main-content">
<div class="special-characters-search">
<input
type="text"
placeholder="Search characters..."
class="special-characters-search-input"
>
</div>
<div class="special-characters-main-content">
<div class="special-characters-search">
<input type="text" placeholder="Search characters..." value="${r}" class="special-characters-search-input">
</div>
<div class="special-characters-grid">
${s.length>0?s.map(t=>`
<button class="special-characters-item" data-char="${t}" title="${g[t]||t}">
${t}
</button>
`).join(""):`<div class="special-characters-no-results">No characters found for "${r}"</div>`}
</div>
</div>
<div class="special-characters-grid"></div>
</div>
`,o.querySelector(".special-characters-close")?.addEventListener("click",l),o.querySelectorAll(".special-characters-tab").forEach(t=>{t.addEventListener("click",n=>{const i=n.target.getAttribute("data-category");i&&(e=i,d())})}),o.querySelector(".special-characters-search-input")?.addEventListener("input",t=>{r=t.target.value,d()}),o.querySelectorAll(".special-characters-item").forEach(t=>{t.addEventListener("click",n=>{const i=n.target.getAttribute("data-char");i&&(v(i),l())})})},l=()=>{c.parentNode&&c.parentNode.removeChild(c),u=!1,document.removeEventListener("keydown",h)},h=s=>{s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),l())};c.addEventListener("click",s=>{s.target===c&&l()}),document.addEventListener("keydown",h),d(),c.appendChild(o),document.body.appendChild(c)},w=()=>({name:"specialCharacters",toolbar:[{label:"Special Characters",command:"insertSpecialCharacter",icon:'<svg width="24" height="24" focusable="false"><path d="M15 18h4l1-2v4h-6v-3.3l1.4-1a6 6 0 0 0 1.8-2.9 6.3 6.3 0 0 0-.1-4.1 5.8 5.8 0 0 0-3-3.2c-.6-.3-1.3-.5-2.1-.5a5.1 5.1 0 0 0-3.9 1.8 6.3 6.3 0 0 0-1.3 6 6.2 6.2 0 0 0 1.8 3l1.4.9V20H4v-4l1 2h4v-.5l-2-1L5.4 15A6.5 6.5 0 0 1 4 11c0-1 .2-1.9.6-2.7A7 7 0 0 1 6.3 6C7.1 5.4 8 5 9 4.5c1-.3 2-.5 3.1-.5a8.8 8.8 0 0 1 5.7 2 7 7 0 0 1 1.7 2.3 6 6 0 0 1 .2 4.8c-.2.7-.6 1.3-1 1.9a7.6 7.6 0 0 1-3.6 2.5v.5Z" fill-rule="evenodd"></path></svg>'}],commands:{insertSpecialCharacter:(a,e)=>{const r=e?.contentElement instanceof HTMLElement?e.contentElement:b();return y(r),!0}},keymap:{}});exports.SpecialCharactersPlugin=w;
</div>
`;const b=s.querySelector(".special-characters-tabs"),d=s.querySelector(".special-characters-grid"),m=s.querySelector(".special-characters-search-input"),w=s.querySelector(".special-characters-close"),y=()=>g[e].characters.filter(r=>{if(!a.trim())return!0;const o=a.toLowerCase();return r.toLowerCase().includes(o)||(x[r]||"").toLowerCase().includes(o)}),v=()=>{b?.querySelectorAll(".special-characters-tab").forEach(r=>{r.classList.toggle("active",r.getAttribute("data-category")===e)})},h=()=>{if(!d)return;const r=y();if(r.length===0){d.innerHTML=`<div class="special-characters-no-results">No characters found for "${a}"</div>`;return}d.innerHTML=r.map(o=>`
<button class="special-characters-item" data-char="${o}" title="${x[o]||o}">
${o}
</button>
`).join("")},p=()=>{c!==null&&(window.clearTimeout(c),c=null),i.parentNode&&i.parentNode.removeChild(i),u=!1,document.removeEventListener("keydown",f,!0)},f=r=>{r.key==="Escape"&&(r.preventDefault(),r.stopPropagation(),p())};w?.addEventListener("click",p),b?.addEventListener("click",r=>{const l=r.target.closest(".special-characters-tab");if(!l)return;const n=l.getAttribute("data-category");!n||e===n||(e=n,v(),h())}),m?.addEventListener("input",r=>{a=r.target.value,c!==null&&window.clearTimeout(c),c=window.setTimeout(()=>{c=null,h()},90)}),d?.addEventListener("click",r=>{const l=r.target.closest(".special-characters-item");if(!l)return;const n=l.getAttribute("data-char");n&&(S(n),p())}),i.addEventListener("click",r=>{r.target===i&&p()}),document.addEventListener("keydown",f,!0),v(),h(),i.appendChild(s),document.body.appendChild(i),requestAnimationFrame(()=>m?.focus())},T=()=>({name:"specialCharacters",toolbar:[{label:"Special Characters",command:"insertSpecialCharacter",icon:'<svg width="24" height="24" focusable="false"><path d="M15 18h4l1-2v4h-6v-3.3l1.4-1a6 6 0 0 0 1.8-2.9 6.3 6.3 0 0 0-.1-4.1 5.8 5.8 0 0 0-3-3.2c-.6-.3-1.3-.5-2.1-.5a5.1 5.1 0 0 0-3.9 1.8 6.3 6.3 0 0 0-1.3 6 6.2 6.2 0 0 0 1.8 3l1.4.9V20H4v-4l1 2h4v-.5l-2-1L5.4 15A6.5 6.5 0 0 1 4 11c0-1 .2-1.9.6-2.7A7 7 0 0 1 6.3 6C7.1 5.4 8 5 9 4.5c1-.3 2-.5 3.1-.5a8.8 8.8 0 0 1 5.7 2 7 7 0 0 1 1.7 2.3 6 6 0 0 1 .2 4.8c-.2.7-.6 1.3-1 1.9a7.6 7.6 0 0 1-3.6 2.5v.5Z" fill-rule="evenodd"></path></svg>'}],commands:{insertSpecialCharacter:(t,e)=>{const a=e?.contentElement instanceof HTMLElement?e.contentElement:k();return L(a),!0}},keymap:{}});exports.SpecialCharactersPlugin=T;

@@ -1,2 +0,2 @@

const p = {
const g = {
all: {

@@ -392,3 +392,3 @@ name: "All",

}
}, g = {
}, x = {
"€": "euro",

@@ -442,17 +442,17 @@ "£": "pound",

};
let h = !1;
const f = '[data-theme="dark"], .dark, .editora-theme-dark', b = () => {
const a = window.getSelection();
if (!a || a.rangeCount === 0) return null;
const e = a.anchorNode;
let u = !1;
const C = '[data-theme="dark"], .dark, .editora-theme-dark', k = () => {
const t = window.getSelection();
if (!t || t.rangeCount === 0) return null;
const e = t.anchorNode;
return (e instanceof HTMLElement ? e : e?.parentElement)?.closest(".rte-content, .editora-content") || null;
}, m = (a) => {
const e = a || b();
return e ? !!e.closest(f) : !1;
}, x = () => {
}, E = (t) => {
const e = t || k();
return e ? !!e.closest(C) : !1;
}, z = () => {
if (typeof document > "u") return;
const a = "special-characters-plugin-styles";
if (document.getElementById(a)) return;
const t = "special-characters-plugin-styles";
if (document.getElementById(t)) return;
const e = document.createElement("style");
e.id = a, e.textContent = `
e.id = t, e.textContent = `
.special-characters-overlay {

@@ -469,2 +469,22 @@ --rte-sc-overlay-bg: rgba(15, 23, 36, 0.56);

--rte-sc-ring: rgba(31, 117, 254, 0.18);
--rte-picker-dialog-width: min(640px, 96vw);
--rte-picker-dialog-max-height: min(560px, 86vh);
--rte-picker-dialog-radius: 12px;
--rte-picker-search-wrap-padding: 12px;
--rte-picker-search-height: 38px;
--rte-picker-search-font-size: 13px;
--rte-picker-search-radius: 8px;
--rte-picker-tabs-width: 156px;
--rte-picker-tab-padding-y: 10px;
--rte-picker-tab-padding-x: 12px;
--rte-picker-tab-font-size: 13px;
--rte-picker-grid-padding: 12px;
--rte-picker-grid-gap: 6px;
--rte-picker-cell-size: 34px;
--rte-picker-cell-font-size: 17px;
--rte-picker-cell-radius: 7px;
--rte-picker-mobile-tab-min-width: 82px;
--rte-picker-mobile-cell-size: 32px;
--rte-picker-mobile-grid-gap: 5px;
--rte-picker-mobile-dialog-max-height: 88vh;
position: fixed;

@@ -502,7 +522,6 @@ top: 0;

border: 1px solid var(--rte-sc-border);
border-radius: 12px;
border-radius: var(--rte-picker-dialog-radius);
box-shadow: 0 24px 48px rgba(10, 15, 24, 0.28);
max-width: 800px;
width: 90%;
max-height: 80vh;
width: var(--rte-picker-dialog-width);
max-height: var(--rte-picker-dialog-max-height);
display: flex;

@@ -561,6 +580,7 @@ flex-direction: column;

overflow: hidden;
min-width: 0;
}
.special-characters-search {
padding: 16px 16px 0 16px;
padding: var(--rte-picker-search-wrap-padding) var(--rte-picker-search-wrap-padding) 0 var(--rte-picker-search-wrap-padding);
}

@@ -570,6 +590,7 @@

width: 100%;
padding: 10px 12px;
height: var(--rte-picker-search-height);
padding: 8px 12px;
border: 1px solid var(--rte-sc-border);
border-radius: 8px;
font-size: 14px;
border-radius: var(--rte-picker-search-radius);
font-size: var(--rte-picker-search-font-size);
color: var(--rte-sc-dialog-text);

@@ -594,9 +615,10 @@ background-color: var(--rte-sc-subtle-bg);

flex-direction: column;
width: 180px;
width: var(--rte-picker-tabs-width);
border-right: 1px solid var(--rte-sc-border);
background-color: var(--rte-sc-subtle-bg);
overflow-y: auto;
}
.special-characters-tab {
padding: 12px 16px;
padding: var(--rte-picker-tab-padding-y) var(--rte-picker-tab-padding-x);
border: none;

@@ -606,6 +628,7 @@ background: none;

cursor: pointer;
font-size: 14px;
font-size: var(--rte-picker-tab-font-size);
color: var(--rte-sc-muted-text);
border-bottom: 1px solid var(--rte-sc-border);
transition: all 0.2s ease;
line-height: 1.25;
}

@@ -625,12 +648,13 @@

.special-characters-grid {
padding: 16px;
padding: var(--rte-picker-grid-padding);
overflow-y: auto;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
gap: 8px;
grid-template-columns: repeat(auto-fill, minmax(var(--rte-picker-cell-size), 1fr));
gap: var(--rte-picker-grid-gap);
contain: content;
}
.special-characters-item {
width: 40px;
height: 40px;
width: var(--rte-picker-cell-size);
height: var(--rte-picker-cell-size);
display: flex;

@@ -641,5 +665,5 @@ align-items: center;

background: var(--rte-sc-subtle-bg);
border-radius: 8px;
border-radius: var(--rte-picker-cell-radius);
cursor: pointer;
font-size: 18px;
font-size: var(--rte-picker-cell-font-size);
transition: all 0.2s ease;

@@ -673,4 +697,4 @@ color: var(--rte-sc-dialog-text);

.special-characters-dialog {
width: 95%;
max-height: 90vh;
width: 96%;
max-height: var(--rte-picker-mobile-dialog-max-height);
}

@@ -694,75 +718,100 @@

white-space: nowrap;
min-width: var(--rte-picker-mobile-tab-min-width);
}
.special-characters-grid {
grid-template-columns: repeat(auto-fill, minmax(var(--rte-picker-mobile-cell-size), 1fr));
gap: var(--rte-picker-mobile-grid-gap);
}
.special-characters-item {
width: var(--rte-picker-mobile-cell-size);
height: var(--rte-picker-mobile-cell-size);
font-size: 16px;
}
}
`, document.head.appendChild(e);
}, v = (a) => {
}, L = (t) => {
const e = window.getSelection();
if (e && e.rangeCount > 0) {
const t = e.getRangeAt(0);
t.deleteContents();
const c = document.createTextNode(a);
t.insertNode(c), t.setStartAfter(c), t.setEndAfter(c), e.removeAllRanges(), e.addRange(t);
const a = e.getRangeAt(0);
a.deleteContents();
const c = document.createTextNode(t);
a.insertNode(c), a.setStartAfter(c), a.setEndAfter(c), e.removeAllRanges(), e.addRange(a);
}
}, y = (a) => {
if (typeof window > "u" || h) return;
h = !0, x();
let e = "all", t = "";
const c = document.createElement("div");
c.className = "special-characters-overlay", m(a) && c.classList.add("rte-ui-theme-dark");
const o = document.createElement("div");
o.className = "special-characters-dialog", o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "true");
const d = () => {
const s = p[e].characters.filter((r) => {
if (!t.trim()) return !0;
const n = t.toLowerCase();
return r.toLowerCase().includes(n) || (g[r] || "").toLowerCase().includes(n);
});
o.innerHTML = `
<div class="special-characters-header">
<h2>Insert Special Characters</h2>
<button class="special-characters-close">×</button>
}, S = (t) => {
if (typeof window > "u" || u) return;
u = !0, z();
let e = "all", a = "", c = null;
const i = document.createElement("div");
i.className = "special-characters-overlay", E(t) && i.classList.add("rte-ui-theme-dark");
const s = document.createElement("div");
s.className = "special-characters-dialog", s.setAttribute("role", "dialog"), s.setAttribute("aria-modal", "true"), s.innerHTML = `
<div class="special-characters-header">
<h2>Insert Special Characters</h2>
<button class="special-characters-close">×</button>
</div>
<div class="special-characters-content">
<div class="special-characters-tabs">
${Object.keys(g).map((r) => `
<button class="special-characters-tab ${e === r ? "active" : ""}" data-category="${r}">
${g[r].name}
</button>
`).join("")}
</div>
<div class="special-characters-content">
<div class="special-characters-tabs">
${Object.keys(p).map((r) => `
<button class="special-characters-tab ${e === r ? "active" : ""}" data-category="${r}">
${p[r].name}
</button>
`).join("")}
<div class="special-characters-main-content">
<div class="special-characters-search">
<input
type="text"
placeholder="Search characters..."
class="special-characters-search-input"
>
</div>
<div class="special-characters-main-content">
<div class="special-characters-search">
<input type="text" placeholder="Search characters..." value="${t}" class="special-characters-search-input">
</div>
<div class="special-characters-grid">
${s.length > 0 ? s.map((r) => `
<button class="special-characters-item" data-char="${r}" title="${g[r] || r}">
${r}
</button>
`).join("") : `<div class="special-characters-no-results">No characters found for "${t}"</div>`}
</div>
</div>
<div class="special-characters-grid"></div>
</div>
`, o.querySelector(".special-characters-close")?.addEventListener("click", l), o.querySelectorAll(".special-characters-tab").forEach((r) => {
r.addEventListener("click", (n) => {
const i = n.target.getAttribute("data-category");
i && (e = i, d());
});
}), o.querySelector(".special-characters-search-input")?.addEventListener("input", (r) => {
t = r.target.value, d();
}), o.querySelectorAll(".special-characters-item").forEach((r) => {
r.addEventListener("click", (n) => {
const i = n.target.getAttribute("data-char");
i && (v(i), l());
});
</div>
`;
const b = s.querySelector(".special-characters-tabs"), d = s.querySelector(".special-characters-grid"), m = s.querySelector(".special-characters-search-input"), w = s.querySelector(".special-characters-close"), y = () => g[e].characters.filter((r) => {
if (!a.trim()) return !0;
const o = a.toLowerCase();
return r.toLowerCase().includes(o) || (x[r] || "").toLowerCase().includes(o);
}), v = () => {
b?.querySelectorAll(".special-characters-tab").forEach((r) => {
r.classList.toggle("active", r.getAttribute("data-category") === e);
});
}, l = () => {
c.parentNode && c.parentNode.removeChild(c), h = !1, document.removeEventListener("keydown", u);
}, u = (s) => {
s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), l());
}, h = () => {
if (!d) return;
const r = y();
if (r.length === 0) {
d.innerHTML = `<div class="special-characters-no-results">No characters found for "${a}"</div>`;
return;
}
d.innerHTML = r.map((o) => `
<button class="special-characters-item" data-char="${o}" title="${x[o] || o}">
${o}
</button>
`).join("");
}, p = () => {
c !== null && (window.clearTimeout(c), c = null), i.parentNode && i.parentNode.removeChild(i), u = !1, document.removeEventListener("keydown", f, !0);
}, f = (r) => {
r.key === "Escape" && (r.preventDefault(), r.stopPropagation(), p());
};
c.addEventListener("click", (s) => {
s.target === c && l();
}), document.addEventListener("keydown", u), d(), c.appendChild(o), document.body.appendChild(c);
}, E = () => ({
w?.addEventListener("click", p), b?.addEventListener("click", (r) => {
const l = r.target.closest(".special-characters-tab");
if (!l) return;
const n = l.getAttribute("data-category");
!n || e === n || (e = n, v(), h());
}), m?.addEventListener("input", (r) => {
a = r.target.value, c !== null && window.clearTimeout(c), c = window.setTimeout(() => {
c = null, h();
}, 90);
}), d?.addEventListener("click", (r) => {
const l = r.target.closest(".special-characters-item");
if (!l) return;
const n = l.getAttribute("data-char");
n && (L(n), p());
}), i.addEventListener("click", (r) => {
r.target === i && p();
}), document.addEventListener("keydown", f, !0), v(), h(), i.appendChild(s), document.body.appendChild(i), requestAnimationFrame(() => m?.focus());
}, q = () => ({
name: "specialCharacters",

@@ -775,5 +824,5 @@ toolbar: [{

commands: {
insertSpecialCharacter: (a, e) => {
const t = e?.contentElement instanceof HTMLElement ? e.contentElement : b();
return y(t), !0;
insertSpecialCharacter: (t, e) => {
const a = e?.contentElement instanceof HTMLElement ? e.contentElement : k();
return S(a), !0;
}

@@ -784,3 +833,3 @@ },

export {
E as SpecialCharactersPlugin
q as SpecialCharactersPlugin
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const H=new Set(["the","a","an","and","or","but","in","on","at","to","for","of","with","by","from","is","are","be","was","were","have","has","had","do","does","did","will","would","could","should","may","might","must","can","this","that","these","those","what","which","who","whom","where","when","why","how","all","each","every","both","few","more","most","other","same","such","no","nor","not","only","own","so","than","too","very","just","as","if","because","while","although","though","it","its","their","them","they","you","he","she","we","me","him","her","us","our","i","my","your","his","hers","ours","yours","theirs","editor","document","text","word","paragraph","line","page","content","hello","world","test","example","sample","demo","lorem","ipsum"]),E=new Set,C=new Set;let u=!1,d=null,f=null,a=null,s=null,g=null,v=!1,h=null,O=!1,b=0;const $={characterData:!0,childList:!0,subtree:!0},D="rte-spellcheck-styles",F="__editoraCommandEditorRoot";function q(){if(typeof window>"u")return null;const e=window[F];if(!(e instanceof HTMLElement))return null;window[F]=null;const r=e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?e:null);if(r){const l=j(r);if(l)return l;if(r.getAttribute("contenteditable")==="true")return r}if(e.getAttribute("contenteditable")==="true")return e;const t=e.closest('[contenteditable="true"]');return t instanceof HTMLElement?t:null}function T(){let e=document.getElementById(D);e||(e=document.createElement("style"),e.id=D,document.head.appendChild(e)),e.textContent=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=new Set(["the","a","an","and","or","but","in","on","at","to","for","of","with","by","from","is","are","be","was","were","have","has","had","do","does","did","will","would","could","should","may","might","must","can","this","that","these","those","what","which","who","whom","where","when","why","how","all","each","every","both","few","more","most","other","same","such","no","nor","not","only","own","so","than","too","very","just","as","if","because","while","although","though","it","its","their","them","they","you","he","she","we","me","him","her","us","our","i","my","your","his","hers","ours","yours","theirs","editor","document","text","word","paragraph","line","page","content","hello","world","test","example","sample","demo","lorem","ipsum"]),C=new Set,S=new Set;let u=!1,d=null,f=null,a=null,s=null,x=null,y=!1,h=null,_=!1,b=0,g=null;const B={characterData:!0,childList:!0,subtree:!0},H="rte-spellcheck-styles",R="__editoraCommandEditorRoot";function K(e){const t=e?.contentElement||e?.editorElement||null;if(!(t instanceof HTMLElement))return;const r=t.getAttribute("contenteditable")==="true"?t:t.querySelector?.('[contenteditable="true"]');if(r instanceof HTMLElement){s=r,h=r;return}const l=t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?t:null),o=A(l);o&&(s=o,h=o)}function P(){if(typeof window>"u")return null;const e=window[R];if(!(e instanceof HTMLElement))return null;window[R]=null;const t=e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?e:null);if(t){const l=A(t);if(l)return l;if(t.getAttribute("contenteditable")==="true")return t}if(e.getAttribute("contenteditable")==="true")return e;const r=e.closest('[contenteditable="true"]');return r instanceof HTMLElement?r:null}function T(){let e=document.getElementById(H);e||(e=document.createElement("style"),e.id=H,document.head.appendChild(e)),e.textContent=`
.rte-spell-check-panel {

@@ -469,3 +469,3 @@ position: absolute;

}
`}function k(){if(s&&document.contains(s))return s;const e=B();return e&&(s=e),e}function z(e){if(!e)return;const t=(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest('[contenteditable="true"]');t&&(s=t)}function j(e){if(!e)return null;const r=e.querySelector('[contenteditable="true"]');return r instanceof HTMLElement?r:null}function X(){if(O)return;const e=r=>{const t=r.target;if(!t)return;const l=t.closest('.editora-toolbar-button[data-command="toggleSpellCheck"], .rte-toolbar-button[data-command="toggleSpellCheck"]');if(!l)return;const o=l.closest("[data-editora-editor]"),c=j(o);c&&(h=c,s=c)};document.addEventListener("pointerdown",e,!0),O=!0}function Z(){const e=q();if(e&&document.contains(e))return s=e,h=null,e;if(h&&document.contains(h)){const r=h;return h=null,s=r,r}return B()}function K(){b+=1,b===1&&d&&d.disconnect()}function Q(){if(b===0||(b-=1,b>0)||!d)return;const e=k();e&&d.observe(e,$)}function L(e){K();try{return e()}finally{Q()}}const ee=()=>{try{const e=localStorage.getItem("rte-custom-dictionary");e&&JSON.parse(e).forEach(t=>E.add(t.toLowerCase()))}catch(e){console.warn("Failed to load custom dictionary:",e)}},te=()=>{try{const e=Array.from(E);localStorage.setItem("rte-custom-dictionary",JSON.stringify(e))}catch(e){console.warn("Failed to save custom dictionary:",e)}};function re(e,r){const t=[];for(let l=0;l<=r.length;l++)t[l]=[l];for(let l=0;l<=e.length;l++)t[0][l]=l;for(let l=1;l<=r.length;l++)for(let o=1;o<=e.length;o++)r.charAt(l-1)===e.charAt(o-1)?t[l][o]=t[l-1][o-1]:t[l][o]=Math.min(t[l-1][o-1]+1,t[l][o-1]+1,t[l-1][o]+1);return t[r.length][e.length]}function oe(e){const r=e.toLowerCase();return H.has(r)||E.has(r)||C.has(r)}function le(e,r=5){const t=e.toLowerCase(),o=Array.from(H).map(c=>({word:c,distance:re(t,c)}));return o.sort((c,n)=>c.distance-n.distance),o.filter(c=>c.distance<=3).slice(0,r).map(c=>c.word)}function ce(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;const r=e;return!!(r.closest('code, pre, [contenteditable="false"], .rte-widget, .rte-template, .rte-comment, .rte-merge-tag')||r.hasAttribute("data-comment-id")||r.hasAttribute("data-template")||r.hasAttribute("data-merge-tag"))}function ne(e){const r=[],t=/([\p{L}\p{M}\p{N}\p{Emoji_Presentation}\u200d'-]+|[\uD800-\uDBFF][\uDC00-\uDFFF])/gu;let l;for(;(l=t.exec(e.data))!==null;){const o=l[0],c=l.index,n=c+o.length;/https?:\/\//.test(o)||/@/.test(o)||/\{\{.*\}\}/.test(o)||/^\d+$/.test(o)||oe(o)||/[a-z][A-Z]/.test(o)||/-/.test(o)||o[0]===o[0].toUpperCase()&&o.length>1||r.push({id:`${o}-${c}`,node:e,startOffset:c,endOffset:n,word:o,suggestions:le(o),ignored:!1})}return r}const B=()=>{const e=q();if(e&&document.contains(e))return s=e,e;const r=window.getSelection();if(r&&r.rangeCount>0){let l=r.getRangeAt(0).startContainer;for(;l&&l!==document.body;){if(l.nodeType===Node.ELEMENT_NODE){const o=l;if(o.getAttribute("contenteditable")==="true")return o}l=l.parentNode}}const t=document.activeElement;if(t){if(t.getAttribute("contenteditable")==="true")return t;const l=t.closest('[contenteditable="true"]');if(l)return l;const o=t.closest("[data-editora-editor]");if(o){const c=o.querySelector('[contenteditable="true"]');if(c)return c}}return document.querySelector('[contenteditable="true"]')};function N(){const e=k();if(!e)return[];const r=[],t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:o=>!o.textContent?.trim()||o.parentNode&&ce(o.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT});let l=t.nextNode();for(;l;)r.push(...ne(l)),l=t.nextNode();return r}function m(e){const r=k();r&&(e||(e=N()),L(()=>{r.querySelectorAll(".rte-misspelled").forEach(t=>{const l=t.parentNode;if(l){for(;t.firstChild;)l.insertBefore(t.firstChild,t);l.removeChild(t)}}),e.forEach(t=>{if(C.has(t.word.toLowerCase()))return;const l=t.node.data.length;if(!(t.startOffset<0||t.endOffset>l||t.startOffset>=t.endOffset))try{const o=document.createRange();o.setStart(t.node,t.startOffset),o.setEnd(t.node,t.endOffset);const c=document.createElement("span");c.className="rte-misspelled",c.setAttribute("data-word",t.word),c.setAttribute("data-suggestions",t.suggestions.join(",")),c.setAttribute("title",`Suggestions: ${t.suggestions.join(", ")}`),c.style.borderBottom="2px wavy red",c.style.cursor="pointer",o.surroundContents(c)}catch{}})}),y(e))}function S(){const e=k();e&&L(()=>{e.querySelectorAll(".rte-misspelled").forEach(r=>{const t=r.parentNode;if(t){for(;r.firstChild;)t.insertBefore(r.firstChild,r);t.removeChild(r)}})})}function ae(e,r){L(()=>{const t=document.createRange();t.setStart(e.node,e.startOffset),t.setEnd(e.node,e.endOffset);const l=document.createTextNode(r);t.deleteContents(),t.insertNode(l)})}function P(e){C.add(e.toLowerCase()),S(),m()}function W(e){E.add(e.toLowerCase()),te(),S(),m()}function se(e){const r=k();if(!r)return{total:0,misspelled:0,accuracy:100};e||(e=N());const t=e.filter(n=>!C.has(n.word.toLowerCase())).length,c=((r.textContent||"").match(/[\p{L}\p{M}\p{N}]+/gu)||[]).length;return{total:c,misspelled:t,accuracy:c>0?(c-t)/c*100:100}}function ie(e,r){const t=document.createTextNode(r);e.replaceWith(t)}function de(e){e.classList.remove("rte-misspelled"),e.removeAttribute("data-word"),e.removeAttribute("data-suggestions"),e.removeAttribute("title"),e.style.borderBottom="",e.style.cursor=""}function pe(e,r,t,l,o){z(o),document.querySelectorAll(".rte-spellcheck-menu").forEach(p=>p.remove());const c=document.createElement("div");if(c.className="rte-spellcheck-menu",l.slice(0,5).forEach(p=>{const w=document.createElement("div");w.className="rte-spellcheck-menu-item",w.textContent=p,w.onclick=()=>{ie(o,p),window.setTimeout(()=>{u&&(m(),y())},0),c.remove()},c.appendChild(w)}),l.length>0){const p=document.createElement("div");p.style.cssText="height: 1px; background: #ddd; margin: 4px 0;",c.appendChild(p)}const n=document.createElement("div");n.className="rte-spellcheck-menu-item meta",n.textContent="Ignore Once",n.onclick=()=>{de(o),c.remove()},c.appendChild(n);const i=document.createElement("div");i.className="rte-spellcheck-menu-item meta",i.textContent="Ignore All",i.onclick=()=>{P(t),c.remove()},c.appendChild(i);const x=document.createElement("div");x.className="rte-spellcheck-menu-item positive",x.textContent="Add to Dictionary",x.onclick=()=>{W(t),c.remove()},c.appendChild(x),document.body.appendChild(c);const A=c.getBoundingClientRect(),U=window.innerWidth-A.width-8,Y=window.innerHeight-A.height-8;c.style.left=`${Math.max(8,Math.min(e,U))}px`,c.style.top=`${Math.max(8,Math.min(r,Y))}px`;const M=p=>{c.contains(p.target)||(c.remove(),document.removeEventListener("mousedown",M))};setTimeout(()=>document.addEventListener("mousedown",M),0)}function _(){v||(g=e=>{const r=e.target;if(r&&r.classList.contains("rte-misspelled")){e.preventDefault(),z(r);const t=r.getAttribute("data-word"),l=(r.getAttribute("data-suggestions")||"").split(",").filter(o=>o);pe(e.clientX,e.clientY,t,l,r)}},document.addEventListener("contextmenu",g),v=!0)}function he(){!v||!g||(document.removeEventListener("contextmenu",g),g=null,v=!1)}function ue(e){return e.closest("[data-editora-editor]")||e.parentElement||e}function I(){const e=k();if(!e)throw new Error("Spell check panel requested without active editor");const r=ue(e);T();const t=document.createElement("div");return t.className="rte-spell-check-panel",window.getComputedStyle(r).position==="static"&&(r.style.position="relative"),r.appendChild(t),t}function y(e){if(!a)return;const r=e||N(),t=se(r);a.innerHTML=`
`}function k(){if(s&&document.contains(s))return s;const e=V();return e&&(s=e),e}function W(e){if(!e)return;const r=(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest('[contenteditable="true"]');r&&(s=r)}function A(e){if(!e)return null;const t=e.querySelector('[contenteditable="true"]');return t instanceof HTMLElement?t:null}function Q(){if(_)return;const e=t=>{const r=t.target;if(!r)return;const l=r.closest('.editora-toolbar-button[data-command="toggleSpellCheck"], .rte-toolbar-button[data-command="toggleSpellCheck"]');if(!l)return;const o=l.closest("[data-editora-editor]"),n=A(o);n&&(h=n,s=n)};document.addEventListener("pointerdown",e,!0),_=!0}function ee(){const e=P();if(e&&document.contains(e))return s=e,h=null,e;if(h&&document.contains(h)){const t=h;return h=null,s=t,t}return V()}function te(){b+=1,b===1&&d&&d.disconnect()}function re(){if(b===0||(b-=1,b>0)||!d)return;const e=k();e&&d.observe(e,B)}function N(e){te();try{return e()}finally{re()}}const oe=()=>{try{const e=localStorage.getItem("rte-custom-dictionary");e&&JSON.parse(e).forEach(r=>C.add(r.toLowerCase()))}catch(e){console.warn("Failed to load custom dictionary:",e)}},le=()=>{try{const e=Array.from(C);localStorage.setItem("rte-custom-dictionary",JSON.stringify(e))}catch(e){console.warn("Failed to save custom dictionary:",e)}};function ne(e,t){const r=[];for(let l=0;l<=t.length;l++)r[l]=[l];for(let l=0;l<=e.length;l++)r[0][l]=l;for(let l=1;l<=t.length;l++)for(let o=1;o<=e.length;o++)t.charAt(l-1)===e.charAt(o-1)?r[l][o]=r[l-1][o-1]:r[l][o]=Math.min(r[l-1][o-1]+1,r[l][o-1]+1,r[l-1][o]+1);return r[t.length][e.length]}function ce(e){const t=e.toLowerCase();return j.has(t)||C.has(t)||S.has(t)}function ae(e,t=5){const r=e.toLowerCase(),o=Array.from(j).map(n=>({word:n,distance:ne(r,n)}));return o.sort((n,c)=>n.distance-c.distance),o.filter(n=>n.distance<=3).slice(0,t).map(n=>n.word)}function se(e){if(e.nodeType!==Node.ELEMENT_NODE)return!1;const t=e;return!!(t.closest('code, pre, [contenteditable="false"], .rte-widget, .rte-template, .rte-comment, .rte-merge-tag')||t.hasAttribute("data-comment-id")||t.hasAttribute("data-template")||t.hasAttribute("data-merge-tag"))}function ie(e){const t=[],r=/([\p{L}\p{M}\p{N}\p{Emoji_Presentation}\u200d'-]+|[\uD800-\uDBFF][\uDC00-\uDFFF])/gu;let l;for(;(l=r.exec(e.data))!==null;){const o=l[0],n=l.index,c=n+o.length;/https?:\/\//.test(o)||/@/.test(o)||/\{\{.*\}\}/.test(o)||/^\d+$/.test(o)||ce(o)||/[a-z][A-Z]/.test(o)||/-/.test(o)||o[0]===o[0].toUpperCase()&&o.length>1||t.push({id:`${o}-${n}`,node:e,startOffset:n,endOffset:c,word:o,suggestions:ae(o),ignored:!1})}return t}const V=()=>{const e=P();if(e&&document.contains(e))return s=e,e;const t=window.getSelection();if(t&&t.rangeCount>0){let l=t.getRangeAt(0).startContainer;for(;l&&l!==document.body;){if(l.nodeType===Node.ELEMENT_NODE){const o=l;if(o.getAttribute("contenteditable")==="true")return o}l=l.parentNode}}const r=document.activeElement;if(r){if(r.getAttribute("contenteditable")==="true")return r;const l=r.closest('[contenteditable="true"]');if(l)return l;const o=r.closest("[data-editora-editor]");if(o){const n=o.querySelector('[contenteditable="true"]');if(n)return n}}return document.querySelector('[contenteditable="true"]')};function M(){const e=k();if(!e)return[];const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:o=>!o.textContent?.trim()||o.parentNode&&se(o.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT});let l=r.nextNode();for(;l;)t.push(...ie(l)),l=r.nextNode();return t}function m(e){const t=k();t&&(e||(e=M()),N(()=>{t.querySelectorAll(".rte-misspelled").forEach(r=>{const l=r.parentNode;if(l){for(;r.firstChild;)l.insertBefore(r.firstChild,r);l.removeChild(r)}}),e.forEach(r=>{if(S.has(r.word.toLowerCase()))return;const l=r.node.data.length;if(!(r.startOffset<0||r.endOffset>l||r.startOffset>=r.endOffset))try{const o=document.createRange();o.setStart(r.node,r.startOffset),o.setEnd(r.node,r.endOffset);const n=document.createElement("span");n.className="rte-misspelled",n.setAttribute("data-word",r.word),n.setAttribute("data-suggestions",r.suggestions.join(",")),n.setAttribute("title",`Suggestions: ${r.suggestions.join(", ")}`),n.style.borderBottom="2px wavy red",n.style.cursor="pointer",o.surroundContents(n)}catch{}})}),E(e))}function L(){const e=k();e&&N(()=>{e.querySelectorAll(".rte-misspelled").forEach(t=>{const r=t.parentNode;if(r){for(;t.firstChild;)r.insertBefore(t.firstChild,t);r.removeChild(t)}})})}function de(e,t){N(()=>{const r=document.createRange();r.setStart(e.node,e.startOffset),r.setEnd(e.node,e.endOffset);const l=document.createTextNode(t);r.deleteContents(),r.insertNode(l)})}function G(e){S.add(e.toLowerCase()),L(),m()}function J(e){C.add(e.toLowerCase()),le(),L(),m()}function pe(e){const t=k();if(!t)return{total:0,misspelled:0,accuracy:100};e||(e=M());const r=e.filter(c=>!S.has(c.word.toLowerCase())).length,n=((t.textContent||"").match(/[\p{L}\p{M}\p{N}]+/gu)||[]).length;return{total:n,misspelled:r,accuracy:n>0?(n-r)/n*100:100}}function he(e,t){const r=document.createTextNode(t);e.replaceWith(r)}function ue(e){e.classList.remove("rte-misspelled"),e.removeAttribute("data-word"),e.removeAttribute("data-suggestions"),e.removeAttribute("title"),e.style.borderBottom="",e.style.cursor=""}function me(e,t,r,l,o){W(o),document.querySelectorAll(".rte-spellcheck-menu").forEach(p=>p.remove());const n=document.createElement("div");if(n.className="rte-spellcheck-menu",l.slice(0,5).forEach(p=>{const v=document.createElement("div");v.className="rte-spellcheck-menu-item",v.textContent=p,v.onclick=()=>{he(o,p),window.setTimeout(()=>{u&&(m(),E())},0),n.remove()},n.appendChild(v)}),l.length>0){const p=document.createElement("div");p.style.cssText="height: 1px; background: #ddd; margin: 4px 0;",n.appendChild(p)}const c=document.createElement("div");c.className="rte-spellcheck-menu-item meta",c.textContent="Ignore Once",c.onclick=()=>{ue(o),n.remove()},n.appendChild(c);const i=document.createElement("div");i.className="rte-spellcheck-menu-item meta",i.textContent="Ignore All",i.onclick=()=>{G(r),n.remove()},n.appendChild(i);const w=document.createElement("div");w.className="rte-spellcheck-menu-item positive",w.textContent="Add to Dictionary",w.onclick=()=>{J(r),n.remove()},n.appendChild(w),document.body.appendChild(n);const D=n.getBoundingClientRect(),X=window.innerWidth-D.width-8,Z=window.innerHeight-D.height-8;n.style.left=`${Math.max(8,Math.min(e,X))}px`,n.style.top=`${Math.max(8,Math.min(t,Z))}px`;const F=p=>{n.contains(p.target)||(n.remove(),document.removeEventListener("mousedown",F))};setTimeout(()=>document.addEventListener("mousedown",F),0)}function I(){y||(x=e=>{const t=e.target;if(t&&t.classList.contains("rte-misspelled")){e.preventDefault(),W(t);const r=t.getAttribute("data-word"),l=(t.getAttribute("data-suggestions")||"").split(",").filter(o=>o);me(e.clientX,e.clientY,r,l,t)}},document.addEventListener("contextmenu",x),y=!0)}function ke(){!y||!x||(document.removeEventListener("contextmenu",x),x=null,y=!1)}function fe(e){return e.closest("[data-editora-editor]")||e.parentElement||e}function q(){const e=k();if(!e)throw new Error("Spell check panel requested without active editor");const t=fe(e);T();const r=document.createElement("div");return r.className="rte-spell-check-panel",window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t.appendChild(r),r}function E(e){if(!a)return;const t=e||M(),r=pe(t);a.innerHTML=`
<div class="rte-spellcheck-header">

@@ -482,11 +482,11 @@ <div>

<span class="rte-spellcheck-stat-label">Total</span>
<strong class="rte-spellcheck-stat-value">${t.total}</strong>
<strong class="rte-spellcheck-stat-value">${r.total}</strong>
</div>
<div class="rte-spellcheck-stat">
<span class="rte-spellcheck-stat-label">Misspelled</span>
<strong class="rte-spellcheck-stat-value">${t.misspelled}</strong>
<strong class="rte-spellcheck-stat-value">${r.misspelled}</strong>
</div>
<div class="rte-spellcheck-stat">
<span class="rte-spellcheck-stat-label">Accuracy</span>
<strong class="rte-spellcheck-stat-value">${t.accuracy.toFixed(1)}%</strong>
<strong class="rte-spellcheck-stat-value">${r.accuracy.toFixed(1)}%</strong>
</div>

@@ -496,4 +496,4 @@ </div>

<div class="rte-spellcheck-list">
${r.length===0?'<div class="rte-spellcheck-empty">No spelling errors found in this editor.</div>':r.map((o,c)=>`
<div class="rte-spellcheck-item" data-word="${o.word}" data-index="${c}">
${t.length===0?'<div class="rte-spellcheck-empty">No spelling errors found in this editor.</div>':t.map((o,n)=>`
<div class="rte-spellcheck-item" data-word="${o.word}" data-index="${n}">
<button class="rte-spellcheck-word-header" type="button">

@@ -505,3 +505,3 @@ <span class="rte-spellcheck-word">${o.word}</span>

${o.suggestions.length>0?`<div class="rte-spellcheck-actions">
${o.suggestions.map(n=>`<button class="rte-spellcheck-btn primary suggestion-btn" data-suggestion="${n}" type="button">${n}</button>`).join("")}
${o.suggestions.map(c=>`<button class="rte-spellcheck-btn primary suggestion-btn" data-suggestion="${c}" type="button">${c}</button>`).join("")}
</div>`:'<div class="rte-spellcheck-subtitle">No suggestions available</div>'}

@@ -516,2 +516,2 @@ <div class="rte-spellcheck-actions">

</div>
`,a.querySelector(".rte-spellcheck-close")?.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),J()}),a.querySelectorAll(".rte-spellcheck-word-header").forEach(o=>{o.addEventListener("click",()=>{const n=o.closest(".rte-spellcheck-item")?.querySelector(".rte-spellcheck-suggestions"),i=o.querySelector(".rte-spellcheck-caret");n&&i&&(n.classList.contains("show")?(n.classList.remove("show"),i.textContent="▶"):(n.classList.add("show"),i.textContent="▼"))})}),a.querySelectorAll(".suggestion-btn").forEach(o=>{o.addEventListener("click",()=>{const c=o.getAttribute("data-suggestion"),n=o.closest(".rte-spellcheck-item");n?.getAttribute("data-word");const i=parseInt(n?.getAttribute("data-index")||"0");r[i]&&(ae(r[i],c),m())})}),a.querySelectorAll(".ignore-btn").forEach(o=>{o.addEventListener("click",()=>{const n=o.closest(".rte-spellcheck-item")?.getAttribute("data-word");P(n)})}),a.querySelectorAll(".add-btn").forEach(o=>{o.addEventListener("click",()=>{const n=o.closest(".rte-spellcheck-item")?.getAttribute("data-word");W(n)})})}function R(){const e=k();e&&(d&&d.disconnect(),d=new MutationObserver(r=>{b>0||r.some(t=>t.type==="characterData"||t.type==="childList")&&(f&&clearTimeout(f),f=window.setTimeout(()=>{u&&m()},350))}),d.observe(e,{...$}))}function V(){d&&(d.disconnect(),d=null),f&&(clearTimeout(f),f=null)}function G(){document.querySelectorAll(".rte-spellcheck-menu").forEach(e=>e.remove())}function J(){return u&&(S(),V(),he(),G(),a&&(a.remove(),a=null),s=null,h=null,u=!1),!1}function me(){const e=Z();return e?u&&s&&s!==e?(S(),V(),G(),a&&(a.remove(),a=null),s=e,T(),_(),m(),R(),a=I(),y(),!0):u?J():(s=e,u=!0,T(),_(),m(),R(),a&&(a.remove(),a=null),a=I(),y(),!0):!1}const ke=()=>({name:"spellCheck",init:()=>{ee(),X()},toolbar:[{label:"Spell Check",command:"toggleSpellCheck",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="M3 12.5L3.84375 9.5M3.84375 9.5L5 5.38889C5 5.38889 5.25 4.5 6 4.5C6.75 4.5 7 5.38889 7 5.38889L8.15625 9.5M3.84375 9.5H8.15625M9 12.5L8.15625 9.5M13 16.8333L15.4615 19.5L21 13.5M12 8.5H15C16.1046 8.5 17 7.60457 17 6.5C17 5.39543 16.1046 4.5 15 4.5H12V8.5ZM12 8.5H16C17.1046 8.5 18 9.39543 18 10.5C18 11.6046 17.1046 12.5 16 12.5H12V8.5Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"F7"}],commands:{toggleSpellCheck:()=>(me(),!0)},keymap:{F7:"toggleSpellCheck"}});exports.SpellCheckPlugin=ke;
`,a.querySelector(".rte-spellcheck-close")?.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),O()}),a.querySelectorAll(".rte-spellcheck-word-header").forEach(o=>{o.addEventListener("click",()=>{const c=o.closest(".rte-spellcheck-item")?.querySelector(".rte-spellcheck-suggestions"),i=o.querySelector(".rte-spellcheck-caret");c&&i&&(c.classList.contains("show")?(c.classList.remove("show"),i.textContent="▶"):(c.classList.add("show"),i.textContent="▼"))})}),a.querySelectorAll(".suggestion-btn").forEach(o=>{o.addEventListener("click",()=>{const n=o.getAttribute("data-suggestion"),c=o.closest(".rte-spellcheck-item");c?.getAttribute("data-word");const i=parseInt(c?.getAttribute("data-index")||"0");t[i]&&(de(t[i],n),m())})}),a.querySelectorAll(".ignore-btn").forEach(o=>{o.addEventListener("click",()=>{const c=o.closest(".rte-spellcheck-item")?.getAttribute("data-word");G(c)})}),a.querySelectorAll(".add-btn").forEach(o=>{o.addEventListener("click",()=>{const c=o.closest(".rte-spellcheck-item")?.getAttribute("data-word");J(c)})})}function $(){const e=k();e&&(d&&d.disconnect(),d=new MutationObserver(t=>{b>0||t.some(r=>r.type==="characterData"||r.type==="childList")&&(f&&clearTimeout(f),f=window.setTimeout(()=>{u&&m()},350))}),d.observe(e,{...B}))}function U(){d&&(d.disconnect(),d=null),f&&(clearTimeout(f),f=null)}function Y(){document.querySelectorAll(".rte-spellcheck-menu").forEach(e=>e.remove())}function z(){g||(g=e=>{e.key!=="Escape"||!u||(e.preventDefault(),e.stopPropagation(),O())},document.addEventListener("keydown",g,!0))}function be(){g&&(document.removeEventListener("keydown",g,!0),g=null)}function O(){return u&&(L(),U(),ke(),Y(),a&&(a.remove(),a=null),s=null,h=null,u=!1,be()),!1}function ge(){const e=ee();return e?u&&s&&s!==e?(L(),U(),Y(),a&&(a.remove(),a=null),s=e,T(),I(),z(),m(),$(),a=q(),E(),!0):u?O():(s=e,u=!0,T(),I(),z(),m(),$(),a&&(a.remove(),a=null),a=q(),E(),!0):!1}const xe=()=>({name:"spellCheck",init:()=>{oe(),Q()},toolbar:[{label:"Spell Check",command:"toggleSpellCheck",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="M3 12.5L3.84375 9.5M3.84375 9.5L5 5.38889C5 5.38889 5.25 4.5 6 4.5C6.75 4.5 7 5.38889 7 5.38889L8.15625 9.5M3.84375 9.5H8.15625M9 12.5L8.15625 9.5M13 16.8333L15.4615 19.5L21 13.5M12 8.5H15C16.1046 8.5 17 7.60457 17 6.5C17 5.39543 16.1046 4.5 15 4.5H12V8.5ZM12 8.5H16C17.1046 8.5 18 9.39543 18 10.5C18 11.6046 17.1046 12.5 16 12.5H12V8.5Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"F7"}],commands:{toggleSpellCheck:(e,t)=>(K(t),ge(),!0)},keymap:{F7:"toggleSpellCheck"}});exports.SpellCheckPlugin=xe;

@@ -1,2 +0,2 @@

const H = /* @__PURE__ */ new Set([
const B = /* @__PURE__ */ new Set([
"the",

@@ -112,28 +112,39 @@ "a",

"ipsum"
]), E = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Set();
let u = !1, d = null, f = null, a = null, s = null, g = null, v = !1, h = null, O = !1, b = 0;
const $ = {
]), C = /* @__PURE__ */ new Set(), S = /* @__PURE__ */ new Set();
let u = !1, d = null, f = null, a = null, s = null, x = null, y = !1, h = null, _ = !1, b = 0, g = null;
const j = {
characterData: !0,
childList: !0,
subtree: !0
}, D = "rte-spellcheck-styles", F = "__editoraCommandEditorRoot";
function q() {
}, H = "rte-spellcheck-styles", R = "__editoraCommandEditorRoot";
function K(e) {
const t = e?.contentElement || e?.editorElement || null;
if (!(t instanceof HTMLElement)) return;
const r = t.getAttribute("contenteditable") === "true" ? t : t.querySelector?.('[contenteditable="true"]');
if (r instanceof HTMLElement) {
s = r, h = r;
return;
}
const l = t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (t.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? t : null), o = A(l);
o && (s = o, h = o);
}
function P() {
if (typeof window > "u") return null;
const e = window[F];
const e = window[R];
if (!(e instanceof HTMLElement)) return null;
window[F] = null;
const r = e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? e : null);
if (r) {
const l = B(r);
window[R] = null;
const t = e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? e : null);
if (t) {
const l = A(t);
if (l) return l;
if (r.getAttribute("contenteditable") === "true") return r;
if (t.getAttribute("contenteditable") === "true") return t;
}
if (e.getAttribute("contenteditable") === "true")
return e;
const t = e.closest('[contenteditable="true"]');
return t instanceof HTMLElement ? t : null;
const r = e.closest('[contenteditable="true"]');
return r instanceof HTMLElement ? r : null;
}
function T() {
let e = document.getElementById(D);
e || (e = document.createElement("style"), e.id = D, document.head.appendChild(e)), e.textContent = `
let e = document.getElementById(H);
e || (e = document.createElement("style"), e.id = H, document.head.appendChild(e)), e.textContent = `
.rte-spell-check-panel {

@@ -611,65 +622,65 @@ position: absolute;

return s;
const e = j();
const e = V();
return e && (s = e), e;
}
function z(e) {
function W(e) {
if (!e) return;
const t = (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest('[contenteditable="true"]');
t && (s = t);
const r = (e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement)?.closest('[contenteditable="true"]');
r && (s = r);
}
function B(e) {
function A(e) {
if (!e) return null;
const r = e.querySelector('[contenteditable="true"]');
return r instanceof HTMLElement ? r : null;
const t = e.querySelector('[contenteditable="true"]');
return t instanceof HTMLElement ? t : null;
}
function X() {
if (O) return;
const e = (r) => {
const t = r.target;
if (!t) return;
const l = t.closest(
function Q() {
if (_) return;
const e = (t) => {
const r = t.target;
if (!r) return;
const l = r.closest(
'.editora-toolbar-button[data-command="toggleSpellCheck"], .rte-toolbar-button[data-command="toggleSpellCheck"]'
);
if (!l) return;
const o = l.closest("[data-editora-editor]"), c = B(o);
c && (h = c, s = c);
const o = l.closest("[data-editora-editor]"), n = A(o);
n && (h = n, s = n);
};
document.addEventListener("pointerdown", e, !0), O = !0;
document.addEventListener("pointerdown", e, !0), _ = !0;
}
function Z() {
const e = q();
function ee() {
const e = P();
if (e && document.contains(e))
return s = e, h = null, e;
if (h && document.contains(h)) {
const r = h;
return h = null, s = r, r;
const t = h;
return h = null, s = t, t;
}
return j();
return V();
}
function K() {
function te() {
b += 1, b === 1 && d && d.disconnect();
}
function Q() {
function re() {
if (b === 0 || (b -= 1, b > 0) || !d) return;
const e = k();
e && d.observe(e, $);
e && d.observe(e, j);
}
function L(e) {
K();
function N(e) {
te();
try {
return e();
} finally {
Q();
re();
}
}
const ee = () => {
const oe = () => {
try {
const e = localStorage.getItem("rte-custom-dictionary");
e && JSON.parse(e).forEach((t) => E.add(t.toLowerCase()));
e && JSON.parse(e).forEach((r) => C.add(r.toLowerCase()));
} catch (e) {
console.warn("Failed to load custom dictionary:", e);
}
}, te = () => {
}, le = () => {
try {
const e = Array.from(E);
const e = Array.from(C);
localStorage.setItem("rte-custom-dictionary", JSON.stringify(e));

@@ -680,55 +691,55 @@ } catch (e) {

};
function re(e, r) {
const t = [];
for (let l = 0; l <= r.length; l++) t[l] = [l];
for (let l = 0; l <= e.length; l++) t[0][l] = l;
for (let l = 1; l <= r.length; l++)
function ne(e, t) {
const r = [];
for (let l = 0; l <= t.length; l++) r[l] = [l];
for (let l = 0; l <= e.length; l++) r[0][l] = l;
for (let l = 1; l <= t.length; l++)
for (let o = 1; o <= e.length; o++)
r.charAt(l - 1) === e.charAt(o - 1) ? t[l][o] = t[l - 1][o - 1] : t[l][o] = Math.min(
t[l - 1][o - 1] + 1,
t.charAt(l - 1) === e.charAt(o - 1) ? r[l][o] = r[l - 1][o - 1] : r[l][o] = Math.min(
r[l - 1][o - 1] + 1,
// substitution
t[l][o - 1] + 1,
r[l][o - 1] + 1,
// insertion
t[l - 1][o] + 1
r[l - 1][o] + 1
// deletion
);
return t[r.length][e.length];
return r[t.length][e.length];
}
function oe(e) {
const r = e.toLowerCase();
return H.has(r) || E.has(r) || C.has(r);
function ce(e) {
const t = e.toLowerCase();
return B.has(t) || C.has(t) || S.has(t);
}
function le(e, r = 5) {
const t = e.toLowerCase(), o = Array.from(H).map((c) => ({ word: c, distance: re(t, c) }));
return o.sort((c, n) => c.distance - n.distance), o.filter((c) => c.distance <= 3).slice(0, r).map((c) => c.word);
function ae(e, t = 5) {
const r = e.toLowerCase(), o = Array.from(B).map((n) => ({ word: n, distance: ne(r, n) }));
return o.sort((n, c) => n.distance - c.distance), o.filter((n) => n.distance <= 3).slice(0, t).map((n) => n.word);
}
function ce(e) {
function se(e) {
if (e.nodeType !== Node.ELEMENT_NODE) return !1;
const r = e;
return !!(r.closest('code, pre, [contenteditable="false"], .rte-widget, .rte-template, .rte-comment, .rte-merge-tag') || r.hasAttribute("data-comment-id") || r.hasAttribute("data-template") || r.hasAttribute("data-merge-tag"));
const t = e;
return !!(t.closest('code, pre, [contenteditable="false"], .rte-widget, .rte-template, .rte-comment, .rte-merge-tag') || t.hasAttribute("data-comment-id") || t.hasAttribute("data-template") || t.hasAttribute("data-merge-tag"));
}
function ne(e) {
const r = [], t = /([\p{L}\p{M}\p{N}\p{Emoji_Presentation}\u200d'-]+|[\uD800-\uDBFF][\uDC00-\uDFFF])/gu;
function ie(e) {
const t = [], r = /([\p{L}\p{M}\p{N}\p{Emoji_Presentation}\u200d'-]+|[\uD800-\uDBFF][\uDC00-\uDFFF])/gu;
let l;
for (; (l = t.exec(e.data)) !== null; ) {
const o = l[0], c = l.index, n = c + o.length;
/https?:\/\//.test(o) || /@/.test(o) || /\{\{.*\}\}/.test(o) || /^\d+$/.test(o) || oe(o) || /[a-z][A-Z]/.test(o) || /-/.test(o) || o[0] === o[0].toUpperCase() && o.length > 1 || r.push({
id: `${o}-${c}`,
for (; (l = r.exec(e.data)) !== null; ) {
const o = l[0], n = l.index, c = n + o.length;
/https?:\/\//.test(o) || /@/.test(o) || /\{\{.*\}\}/.test(o) || /^\d+$/.test(o) || ce(o) || /[a-z][A-Z]/.test(o) || /-/.test(o) || o[0] === o[0].toUpperCase() && o.length > 1 || t.push({
id: `${o}-${n}`,
node: e,
startOffset: c,
endOffset: n,
startOffset: n,
endOffset: c,
word: o,
suggestions: le(o),
suggestions: ae(o),
ignored: !1
});
}
return r;
return t;
}
const j = () => {
const e = q();
const V = () => {
const e = P();
if (e && document.contains(e))
return s = e, e;
const r = window.getSelection();
if (r && r.rangeCount > 0) {
let l = r.getRangeAt(0).startContainer;
const t = window.getSelection();
if (t && t.rangeCount > 0) {
let l = t.getRangeAt(0).startContainer;
for (; l && l !== document.body; ) {

@@ -743,12 +754,12 @@ if (l.nodeType === Node.ELEMENT_NODE) {

}
const t = document.activeElement;
if (t) {
if (t.getAttribute("contenteditable") === "true")
return t;
const l = t.closest('[contenteditable="true"]');
const r = document.activeElement;
if (r) {
if (r.getAttribute("contenteditable") === "true")
return r;
const l = r.closest('[contenteditable="true"]');
if (l) return l;
const o = t.closest("[data-editora-editor]");
const o = r.closest("[data-editora-editor]");
if (o) {
const c = o.querySelector('[contenteditable="true"]');
if (c) return c;
const n = o.querySelector('[contenteditable="true"]');
if (n) return n;
}

@@ -758,50 +769,50 @@ }

};
function N() {
function M() {
const e = k();
if (!e) return [];
const r = [], t = document.createTreeWalker(
const t = [], r = document.createTreeWalker(
e,
NodeFilter.SHOW_TEXT,
{
acceptNode: (o) => !o.textContent?.trim() || o.parentNode && ce(o.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
acceptNode: (o) => !o.textContent?.trim() || o.parentNode && se(o.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT
}
);
let l = t.nextNode();
let l = r.nextNode();
for (; l; )
r.push(...ne(l)), l = t.nextNode();
return r;
t.push(...ie(l)), l = r.nextNode();
return t;
}
function m(e) {
const r = k();
r && (e || (e = N()), L(() => {
r.querySelectorAll(".rte-misspelled").forEach((t) => {
const l = t.parentNode;
const t = k();
t && (e || (e = M()), N(() => {
t.querySelectorAll(".rte-misspelled").forEach((r) => {
const l = r.parentNode;
if (l) {
for (; t.firstChild; )
l.insertBefore(t.firstChild, t);
l.removeChild(t);
for (; r.firstChild; )
l.insertBefore(r.firstChild, r);
l.removeChild(r);
}
}), e.forEach((t) => {
if (C.has(t.word.toLowerCase())) return;
const l = t.node.data.length;
if (!(t.startOffset < 0 || t.endOffset > l || t.startOffset >= t.endOffset))
}), e.forEach((r) => {
if (S.has(r.word.toLowerCase())) return;
const l = r.node.data.length;
if (!(r.startOffset < 0 || r.endOffset > l || r.startOffset >= r.endOffset))
try {
const o = document.createRange();
o.setStart(t.node, t.startOffset), o.setEnd(t.node, t.endOffset);
const c = document.createElement("span");
c.className = "rte-misspelled", c.setAttribute("data-word", t.word), c.setAttribute("data-suggestions", t.suggestions.join(",")), c.setAttribute("title", `Suggestions: ${t.suggestions.join(", ")}`), c.style.borderBottom = "2px wavy red", c.style.cursor = "pointer", o.surroundContents(c);
o.setStart(r.node, r.startOffset), o.setEnd(r.node, r.endOffset);
const n = document.createElement("span");
n.className = "rte-misspelled", n.setAttribute("data-word", r.word), n.setAttribute("data-suggestions", r.suggestions.join(",")), n.setAttribute("title", `Suggestions: ${r.suggestions.join(", ")}`), n.style.borderBottom = "2px wavy red", n.style.cursor = "pointer", o.surroundContents(n);
} catch {
}
});
}), y(e));
}), E(e));
}
function S() {
function L() {
const e = k();
e && L(() => {
e.querySelectorAll(".rte-misspelled").forEach((r) => {
const t = r.parentNode;
if (t) {
for (; r.firstChild; )
t.insertBefore(r.firstChild, r);
t.removeChild(r);
e && N(() => {
e.querySelectorAll(".rte-misspelled").forEach((t) => {
const r = t.parentNode;
if (r) {
for (; t.firstChild; )
r.insertBefore(t.firstChild, t);
r.removeChild(t);
}

@@ -811,95 +822,95 @@ });

}
function ae(e, r) {
L(() => {
const t = document.createRange();
t.setStart(e.node, e.startOffset), t.setEnd(e.node, e.endOffset);
const l = document.createTextNode(r);
t.deleteContents(), t.insertNode(l);
function de(e, t) {
N(() => {
const r = document.createRange();
r.setStart(e.node, e.startOffset), r.setEnd(e.node, e.endOffset);
const l = document.createTextNode(t);
r.deleteContents(), r.insertNode(l);
});
}
function P(e) {
C.add(e.toLowerCase()), S(), m();
function G(e) {
S.add(e.toLowerCase()), L(), m();
}
function W(e) {
E.add(e.toLowerCase()), te(), S(), m();
function J(e) {
C.add(e.toLowerCase()), le(), L(), m();
}
function se(e) {
const r = k();
if (!r) return { total: 0, misspelled: 0, accuracy: 100 };
e || (e = N());
const t = e.filter((n) => !C.has(n.word.toLowerCase())).length, c = ((r.textContent || "").match(/[\p{L}\p{M}\p{N}]+/gu) || []).length;
function pe(e) {
const t = k();
if (!t) return { total: 0, misspelled: 0, accuracy: 100 };
e || (e = M());
const r = e.filter((c) => !S.has(c.word.toLowerCase())).length, n = ((t.textContent || "").match(/[\p{L}\p{M}\p{N}]+/gu) || []).length;
return {
total: c,
misspelled: t,
accuracy: c > 0 ? (c - t) / c * 100 : 100
total: n,
misspelled: r,
accuracy: n > 0 ? (n - r) / n * 100 : 100
};
}
function ie(e, r) {
const t = document.createTextNode(r);
e.replaceWith(t);
function he(e, t) {
const r = document.createTextNode(t);
e.replaceWith(r);
}
function de(e) {
function ue(e) {
e.classList.remove("rte-misspelled"), e.removeAttribute("data-word"), e.removeAttribute("data-suggestions"), e.removeAttribute("title"), e.style.borderBottom = "", e.style.cursor = "";
}
function pe(e, r, t, l, o) {
z(o), document.querySelectorAll(".rte-spellcheck-menu").forEach((p) => p.remove());
const c = document.createElement("div");
if (c.className = "rte-spellcheck-menu", l.slice(0, 5).forEach((p) => {
const w = document.createElement("div");
w.className = "rte-spellcheck-menu-item", w.textContent = p, w.onclick = () => {
ie(o, p), window.setTimeout(() => {
u && (m(), y());
}, 0), c.remove();
}, c.appendChild(w);
function me(e, t, r, l, o) {
W(o), document.querySelectorAll(".rte-spellcheck-menu").forEach((p) => p.remove());
const n = document.createElement("div");
if (n.className = "rte-spellcheck-menu", l.slice(0, 5).forEach((p) => {
const v = document.createElement("div");
v.className = "rte-spellcheck-menu-item", v.textContent = p, v.onclick = () => {
he(o, p), window.setTimeout(() => {
u && (m(), E());
}, 0), n.remove();
}, n.appendChild(v);
}), l.length > 0) {
const p = document.createElement("div");
p.style.cssText = "height: 1px; background: #ddd; margin: 4px 0;", c.appendChild(p);
p.style.cssText = "height: 1px; background: #ddd; margin: 4px 0;", n.appendChild(p);
}
const n = document.createElement("div");
n.className = "rte-spellcheck-menu-item meta", n.textContent = "Ignore Once", n.onclick = () => {
de(o), c.remove();
}, c.appendChild(n);
const c = document.createElement("div");
c.className = "rte-spellcheck-menu-item meta", c.textContent = "Ignore Once", c.onclick = () => {
ue(o), n.remove();
}, n.appendChild(c);
const i = document.createElement("div");
i.className = "rte-spellcheck-menu-item meta", i.textContent = "Ignore All", i.onclick = () => {
P(t), c.remove();
}, c.appendChild(i);
const x = document.createElement("div");
x.className = "rte-spellcheck-menu-item positive", x.textContent = "Add to Dictionary", x.onclick = () => {
W(t), c.remove();
}, c.appendChild(x), document.body.appendChild(c);
const A = c.getBoundingClientRect(), U = window.innerWidth - A.width - 8, Y = window.innerHeight - A.height - 8;
c.style.left = `${Math.max(8, Math.min(e, U))}px`, c.style.top = `${Math.max(8, Math.min(r, Y))}px`;
const M = (p) => {
c.contains(p.target) || (c.remove(), document.removeEventListener("mousedown", M));
G(r), n.remove();
}, n.appendChild(i);
const w = document.createElement("div");
w.className = "rte-spellcheck-menu-item positive", w.textContent = "Add to Dictionary", w.onclick = () => {
J(r), n.remove();
}, n.appendChild(w), document.body.appendChild(n);
const D = n.getBoundingClientRect(), X = window.innerWidth - D.width - 8, Z = window.innerHeight - D.height - 8;
n.style.left = `${Math.max(8, Math.min(e, X))}px`, n.style.top = `${Math.max(8, Math.min(t, Z))}px`;
const F = (p) => {
n.contains(p.target) || (n.remove(), document.removeEventListener("mousedown", F));
};
setTimeout(() => document.addEventListener("mousedown", M), 0);
setTimeout(() => document.addEventListener("mousedown", F), 0);
}
function _() {
v || (g = (e) => {
const r = e.target;
if (r && r.classList.contains("rte-misspelled")) {
e.preventDefault(), z(r);
const t = r.getAttribute("data-word"), l = (r.getAttribute("data-suggestions") || "").split(",").filter((o) => o);
pe(e.clientX, e.clientY, t, l, r);
function I() {
y || (x = (e) => {
const t = e.target;
if (t && t.classList.contains("rte-misspelled")) {
e.preventDefault(), W(t);
const r = t.getAttribute("data-word"), l = (t.getAttribute("data-suggestions") || "").split(",").filter((o) => o);
me(e.clientX, e.clientY, r, l, t);
}
}, document.addEventListener("contextmenu", g), v = !0);
}, document.addEventListener("contextmenu", x), y = !0);
}
function he() {
!v || !g || (document.removeEventListener("contextmenu", g), g = null, v = !1);
function ke() {
!y || !x || (document.removeEventListener("contextmenu", x), x = null, y = !1);
}
function ue(e) {
function fe(e) {
return e.closest("[data-editora-editor]") || e.parentElement || e;
}
function I() {
function q() {
const e = k();
if (!e)
throw new Error("Spell check panel requested without active editor");
const r = ue(e);
const t = fe(e);
T();
const t = document.createElement("div");
return t.className = "rte-spell-check-panel", window.getComputedStyle(r).position === "static" && (r.style.position = "relative"), r.appendChild(t), t;
const r = document.createElement("div");
return r.className = "rte-spell-check-panel", window.getComputedStyle(t).position === "static" && (t.style.position = "relative"), t.appendChild(r), r;
}
function y(e) {
function E(e) {
if (!a) return;
const r = e || N(), t = se(r);
const t = e || M(), r = pe(t);
a.innerHTML = `

@@ -917,11 +928,11 @@ <div class="rte-spellcheck-header">

<span class="rte-spellcheck-stat-label">Total</span>
<strong class="rte-spellcheck-stat-value">${t.total}</strong>
<strong class="rte-spellcheck-stat-value">${r.total}</strong>
</div>
<div class="rte-spellcheck-stat">
<span class="rte-spellcheck-stat-label">Misspelled</span>
<strong class="rte-spellcheck-stat-value">${t.misspelled}</strong>
<strong class="rte-spellcheck-stat-value">${r.misspelled}</strong>
</div>
<div class="rte-spellcheck-stat">
<span class="rte-spellcheck-stat-label">Accuracy</span>
<strong class="rte-spellcheck-stat-value">${t.accuracy.toFixed(1)}%</strong>
<strong class="rte-spellcheck-stat-value">${r.accuracy.toFixed(1)}%</strong>
</div>

@@ -931,4 +942,4 @@ </div>

<div class="rte-spellcheck-list">
${r.length === 0 ? '<div class="rte-spellcheck-empty">No spelling errors found in this editor.</div>' : r.map((o, c) => `
<div class="rte-spellcheck-item" data-word="${o.word}" data-index="${c}">
${t.length === 0 ? '<div class="rte-spellcheck-empty">No spelling errors found in this editor.</div>' : t.map((o, n) => `
<div class="rte-spellcheck-item" data-word="${o.word}" data-index="${n}">
<button class="rte-spellcheck-word-header" type="button">

@@ -940,3 +951,3 @@ <span class="rte-spellcheck-word">${o.word}</span>

${o.suggestions.length > 0 ? `<div class="rte-spellcheck-actions">
${o.suggestions.map((n) => `<button class="rte-spellcheck-btn primary suggestion-btn" data-suggestion="${n}" type="button">${n}</button>`).join("")}
${o.suggestions.map((c) => `<button class="rte-spellcheck-btn primary suggestion-btn" data-suggestion="${c}" type="button">${c}</button>`).join("")}
</div>` : '<div class="rte-spellcheck-subtitle">No suggestions available</div>'}

@@ -952,54 +963,62 @@ <div class="rte-spellcheck-actions">

`, a.querySelector(".rte-spellcheck-close")?.addEventListener("click", (o) => {
o.preventDefault(), o.stopPropagation(), J();
o.preventDefault(), o.stopPropagation(), O();
}), a.querySelectorAll(".rte-spellcheck-word-header").forEach((o) => {
o.addEventListener("click", () => {
const n = o.closest(".rte-spellcheck-item")?.querySelector(".rte-spellcheck-suggestions"), i = o.querySelector(".rte-spellcheck-caret");
n && i && (n.classList.contains("show") ? (n.classList.remove("show"), i.textContent = "▶") : (n.classList.add("show"), i.textContent = "▼"));
const c = o.closest(".rte-spellcheck-item")?.querySelector(".rte-spellcheck-suggestions"), i = o.querySelector(".rte-spellcheck-caret");
c && i && (c.classList.contains("show") ? (c.classList.remove("show"), i.textContent = "▶") : (c.classList.add("show"), i.textContent = "▼"));
});
}), a.querySelectorAll(".suggestion-btn").forEach((o) => {
o.addEventListener("click", () => {
const c = o.getAttribute("data-suggestion"), n = o.closest(".rte-spellcheck-item");
n?.getAttribute("data-word");
const i = parseInt(n?.getAttribute("data-index") || "0");
r[i] && (ae(r[i], c), m());
const n = o.getAttribute("data-suggestion"), c = o.closest(".rte-spellcheck-item");
c?.getAttribute("data-word");
const i = parseInt(c?.getAttribute("data-index") || "0");
t[i] && (de(t[i], n), m());
});
}), a.querySelectorAll(".ignore-btn").forEach((o) => {
o.addEventListener("click", () => {
const n = o.closest(".rte-spellcheck-item")?.getAttribute("data-word");
P(n);
const c = o.closest(".rte-spellcheck-item")?.getAttribute("data-word");
G(c);
});
}), a.querySelectorAll(".add-btn").forEach((o) => {
o.addEventListener("click", () => {
const n = o.closest(".rte-spellcheck-item")?.getAttribute("data-word");
W(n);
const c = o.closest(".rte-spellcheck-item")?.getAttribute("data-word");
J(c);
});
});
}
function R() {
function $() {
const e = k();
e && (d && d.disconnect(), d = new MutationObserver((r) => {
b > 0 || r.some((t) => t.type === "characterData" || t.type === "childList") && (f && clearTimeout(f), f = window.setTimeout(() => {
e && (d && d.disconnect(), d = new MutationObserver((t) => {
b > 0 || t.some((r) => r.type === "characterData" || r.type === "childList") && (f && clearTimeout(f), f = window.setTimeout(() => {
u && m();
}, 350));
}), d.observe(e, {
...$
...j
}));
}
function V() {
function U() {
d && (d.disconnect(), d = null), f && (clearTimeout(f), f = null);
}
function G() {
function Y() {
document.querySelectorAll(".rte-spellcheck-menu").forEach((e) => e.remove());
}
function J() {
return u && (S(), V(), he(), G(), a && (a.remove(), a = null), s = null, h = null, u = !1), !1;
function z() {
g || (g = (e) => {
e.key !== "Escape" || !u || (e.preventDefault(), e.stopPropagation(), O());
}, document.addEventListener("keydown", g, !0));
}
function me() {
const e = Z();
return e ? u && s && s !== e ? (S(), V(), G(), a && (a.remove(), a = null), s = e, T(), _(), m(), R(), a = I(), y(), !0) : u ? J() : (s = e, u = !0, T(), _(), m(), R(), a && (a.remove(), a = null), a = I(), y(), !0) : !1;
function be() {
g && (document.removeEventListener("keydown", g, !0), g = null);
}
const ke = () => ({
function O() {
return u && (L(), U(), ke(), Y(), a && (a.remove(), a = null), s = null, h = null, u = !1, be()), !1;
}
function ge() {
const e = ee();
return e ? u && s && s !== e ? (L(), U(), Y(), a && (a.remove(), a = null), s = e, T(), I(), z(), m(), $(), a = q(), E(), !0) : u ? O() : (s = e, u = !0, T(), I(), z(), m(), $(), a && (a.remove(), a = null), a = q(), E(), !0) : !1;
}
const xe = () => ({
name: "spellCheck",
init: () => {
ee(), X();
oe(), Q();
},

@@ -1015,3 +1034,3 @@ toolbar: [

commands: {
toggleSpellCheck: () => (me(), !0)
toggleSpellCheck: (e, t) => (K(t), ge(), !0)
},

@@ -1023,3 +1042,3 @@ keymap: {

export {
ke as SpellCheckPlugin
xe as SpellCheckPlugin
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=require("./purify.es-T2a3nLiC.js");let o=null,d=null,s=null,n=null,p="",m="",g="insert";const M=[{id:"formal-letter",name:"Formal Letter",category:"Letters",description:"Professional business letter template",html:`<p><strong>{{ Company Name }}</strong></p>
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const q=require("./purify.es-T2a3nLiC.js");let n=null,d=null,u=null,o=null,m="",g="",v="insert",x=null,s=null,E=null;function N(t,e){if(e===t.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",t,e,t.innerHTML)}catch{}}function V(t){if(!t)return null;let e=t.startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const r=e;if(r.getAttribute("contenteditable")==="true")return r}e=e.parentNode}return null}const I=[{id:"formal-letter",name:"Formal Letter",category:"Letters",description:"Professional business letter template",html:`<p><strong>{{ Company Name }}</strong></p>
<p>{{ Today }}</p>

@@ -43,3 +43,3 @@ <p>Dear {{ first_name }} {{ last_name }},</p>

<h3>Q: What are the requirements?</h3>
<p>A: [Answer here]</p>`}];let w=[...M];const y=()=>w,k=()=>{const t=new Set(w.map(e=>e.category));return Array.from(t)},R=t=>{const e=t.toLowerCase();return w.filter(r=>r.name.toLowerCase().includes(e)||r.description?.toLowerCase().includes(e)||r.tags?.some(l=>l.toLowerCase().includes(e)))},L=t=>S.default.sanitize(t,{ALLOWED_TAGS:["p","br","strong","em","u","h1","h2","h3","h4","ul","ol","li","blockquote","table","thead","tbody","tr","th","td","a","span"],ALLOWED_ATTR:["href","target","class","data-key","data-category"]});function D(t){d=document.createElement("div"),d.className="rte-dialog-overlay",N(t)&&d.classList.add("rte-ui-theme-dark"),d.addEventListener("click",()=>c()),o=document.createElement("div"),o.className="rte-dialog rte-template-dialog",o.addEventListener("click",r=>r.stopPropagation());const e=k();e.length>0&&!p&&(p=e[0]),b(),d.appendChild(o),document.body.appendChild(d),$()}const H='[data-theme="dark"], .dark, .editora-theme-dark',A=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.anchorNode;return(e instanceof HTMLElement?e:e?.parentElement)?.closest(".rte-content, .editora-content")||null},N=t=>{const e=t||A();return e?!!e.closest(H):!1};function b(){if(!o)return;const t=k(),e=T();o.innerHTML=`
<p>A: [Answer here]</p>`}];let b=[...I];const L=()=>b,z=t=>b.filter(e=>e.category===t),C=()=>{const t=new Set(b.map(e=>e.category));return Array.from(t)},P=t=>{const e=t.toLowerCase();return b.filter(r=>r.name.toLowerCase().includes(e)||r.description?.toLowerCase().includes(e)||r.tags?.some(l=>l.toLowerCase().includes(e)))},A=t=>q.default.sanitize(t,{ALLOWED_TAGS:["p","br","strong","em","u","h1","h2","h3","h4","ul","ol","li","blockquote","table","thead","tbody","tr","th","td","a","span"],ALLOWED_ATTR:["href","target","class","data-key","data-category"]}),B=t=>b.some(e=>e.id===t.id)?(console.warn(`Template with ID ${t.id} already exists`),!1):(b.push(t),!0),F=t=>!!(t.id&&t.name&&t.category&&t.html&&t.html.trim().length>0);function O(t){d=document.createElement("div"),d.className="rte-dialog-overlay",Z(t)&&d.classList.add("rte-ui-theme-dark"),d.addEventListener("click",()=>c()),n=document.createElement("div"),n.className="rte-dialog rte-template-dialog",n.addEventListener("click",r=>r.stopPropagation());const e=C();e.length>0&&!m&&(m=e[0]),y(),d.appendChild(n),document.body.appendChild(d),Q(),X()}function Q(){_(),x=t=>{t.key==="Escape"&&(!d||!n||(t.preventDefault(),t.stopPropagation(),c()))},document.addEventListener("keydown",x,!0)}function _(){x&&(document.removeEventListener("keydown",x,!0),x=null)}const W='[data-theme="dark"], .dark, .editora-theme-dark',R=()=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const e=t.anchorNode;return(e instanceof HTMLElement?e:e?.parentElement)?.closest(".rte-content, .editora-content")||null},Z=t=>{const e=t||R();return e?!!e.closest(W):!1};function S(){const t=V(u);if(t)return t;if(E?.isConnected)return E;const e=R();return e||document.querySelector(".rte-content, .editora-content")}function y(){if(!n)return;const t=C(),e=M();n.innerHTML=`
<div class="rte-dialog-header">

@@ -55,3 +55,3 @@ <h2>Insert Template</h2>

placeholder="Search templates..."
value="${m}"
value="${g}"
class="rte-input rte-template-search"

@@ -64,3 +64,3 @@ aria-label="Search templates"

${t.map(r=>`
<button class="rte-tab ${p===r?"active":""}" data-category="${r}">
<button class="rte-tab ${m===r?"active":""}" data-category="${r}">
${r}

@@ -75,3 +75,3 @@ </button>

<div
class="rte-template-item ${n?.id===r.id?"selected":""}"
class="rte-template-item ${o?.id===r.id?"selected":""}"
data-template-id="${r.id}"

@@ -86,6 +86,6 @@ >

<!-- Preview -->
${n?`
${o?`
<div class="rte-template-preview">
<strong>Preview:</strong>
<div class="template-preview-content">${n.html}</div>
<div class="template-preview-content">${o.html}</div>
</div>

@@ -97,7 +97,7 @@ `:""}

<label>
<input type="radio" name="insertMode" value="insert" ${g==="insert"?"checked":""} />
<input type="radio" name="insertMode" value="insert" ${v==="insert"?"checked":""} />
Insert at cursor
</label>
<label>
<input type="radio" name="insertMode" value="replace" ${g==="replace"?"checked":""} />
<input type="radio" name="insertMode" value="replace" ${v==="replace"?"checked":""} />
Replace document

@@ -110,7 +110,7 @@ </label>

<button class="rte-button-secondary rte-cancel-btn">Cancel</button>
<button class="rte-button-primary rte-insert-btn" ${n?"":"disabled"}>
${g==="insert"?"Insert":"Replace"}
<button class="rte-button-primary rte-insert-btn" ${o?"":"disabled"}>
${v==="insert"?"Insert":"Replace"}
</button>
</div>
`,_()}function I(){if(!o)return;o.innerHTML=`
`,K()}function G(){if(!n)return;n.innerHTML=`
<div class="rte-dialog-header">

@@ -126,3 +126,3 @@ <h2>Replace Document?</h2>

</div>
`;const t=o.querySelector(".rte-cancel-warning-btn"),e=o.querySelector(".rte-confirm-replace-btn");t?.addEventListener("click",()=>b()),e?.addEventListener("click",()=>j())}function T(){const t=y();return m.trim()?R(m):p?t.filter(e=>e.category===p):t}function _(){if(!o)return;o.querySelector(".rte-dialog-close")?.addEventListener("click",()=>c()),o.querySelector(".rte-cancel-btn")?.addEventListener("click",()=>c()),o.querySelector(".rte-insert-btn")?.addEventListener("click",()=>x());const l=o.querySelector(".rte-template-search");l?.addEventListener("input",a=>{m=a.target.value,E()}),l?.addEventListener("keydown",a=>{a.key==="Enter"&&n?x():a.key==="Escape"&&c()}),o.querySelectorAll(".rte-tab").forEach(a=>{a.addEventListener("click",()=>{const i=a.getAttribute("data-category");i&&(p=i,m="",E())})}),o.querySelectorAll(".rte-template-item").forEach(a=>{a.addEventListener("click",()=>{const i=a.getAttribute("data-template-id");if(i){const u=y().find(v=>v.id===i);u&&(n=u,b())}}),a.addEventListener("dblclick",()=>{const i=a.getAttribute("data-template-id");if(i){const u=y().find(v=>v.id===i);u&&(n=u,x())}})}),o.querySelectorAll('input[name="insertMode"]').forEach(a=>{a.addEventListener("change",i=>{g=i.target.value,b()})})}function E(){const t=T();t.length>0?(!n||!t.find(e=>e.id===n.id))&&(n=t[0]):n=null,b()}function x(){if(n)if(g==="replace"){let t=null;if(s){let e=s.startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const r=e;if(r.getAttribute("contenteditable")==="true"){t=r;break}}e=e.parentNode}}if(t||(t=document.querySelector('[contenteditable="true"]')),t?.innerHTML?.trim()){I();return}C(n),c()}else q(n),c()}function j(){n&&(C(n),c())}function q(t){if(s){const f=window.getSelection();f&&(f.removeAllRanges(),f.addRange(s))}const e=window.getSelection();if(!e||e.rangeCount===0)return;const r=e.getRangeAt(0),l=document.createRange().createContextualFragment(L(t.html));r.deleteContents(),r.insertNode(l);const h=document.createRange();h.setStartAfter(r.endContainer),h.collapse(!0),e.removeAllRanges(),e.addRange(h)}function C(t){let e=null;if(s){let r=s.startContainer;for(;r&&r!==document.body;){if(r.nodeType===Node.ELEMENT_NODE){const l=r;if(l.getAttribute("contenteditable")==="true"){e=l;break}}r=r.parentNode}}e||(e=document.querySelector('[contenteditable="true"]')),e&&(e.innerHTML=L(t.html),e.dispatchEvent(new Event("input",{bubbles:!0})))}function c(){d&&(d.remove(),d=null),o=null,s=null,m=""}function V(t){const e=window.getSelection();e&&e.rangeCount>0?s=e.getRangeAt(0).cloneRange():s=null;const r=T();r.length>0&&!n&&(n=r[0]);const l=t?.contentElement instanceof HTMLElement?t.contentElement:A();D(l)}function $(){if(typeof document>"u")return;const t="template-plugin-dialog-styles";if(document.getElementById(t))return;const e=document.createElement("style");e.id=t,e.textContent=`
`;const t=n.querySelector(".rte-cancel-warning-btn"),e=n.querySelector(".rte-confirm-replace-btn");t?.addEventListener("click",()=>y()),e?.addEventListener("click",()=>Y())}function M(){const t=L();return g.trim()?P(g):m?t.filter(e=>e.category===m):t}function K(){if(!n)return;n.querySelector(".rte-dialog-close")?.addEventListener("click",()=>c()),n.querySelector(".rte-cancel-btn")?.addEventListener("click",()=>c()),n.querySelector(".rte-insert-btn")?.addEventListener("click",()=>k());const l=n.querySelector(".rte-template-search");l?.addEventListener("input",a=>{s!==null&&cancelAnimationFrame(s),g=a.target.value,s=requestAnimationFrame(()=>{s=null,H()})}),l?.addEventListener("keydown",a=>{a.key==="Enter"&&o?k():a.key==="Escape"&&c()}),n.querySelector(".rte-tabs")?.addEventListener("click",a=>{const f=a.target.closest(".rte-tab");if(!f)return;const h=f.getAttribute("data-category");h&&(m=h,g="",s!==null&&(cancelAnimationFrame(s),s=null),H())});const T=n.querySelector(".rte-template-list"),p=a=>{const f=a.target.closest(".rte-template-item");if(!f)return null;const h=f.getAttribute("data-template-id");return h&&L().find(j=>j.id===h)||null};T?.addEventListener("click",a=>{const i=p(a);i&&(o=i,y())}),T?.addEventListener("dblclick",a=>{const i=p(a);i&&(o=i,k())}),n.querySelector(".rte-insert-mode")?.addEventListener("change",a=>{const i=a.target;!i||i.name!=="insertMode"||(v=i.value,y())})}function H(){const t=M();t.length>0?(!o||!t.find(e=>e.id===o.id))&&(o=t[0]):o=null,y()}function k(){if(o)if(v==="replace"){if(S()?.innerHTML?.trim()){G();return}$(o),c()}else J(o),c()}function Y(){o&&($(o),c())}function J(t){const e=window.getSelection();if(!e)return;const r=S();if(!r)return;if(u)e.removeAllRanges(),e.addRange(u);else{const w=document.createRange();w.selectNodeContents(r),w.collapse(!1),e.removeAllRanges(),e.addRange(w)}if(e.rangeCount===0)return;const l=e.getRangeAt(0),D=r?.innerHTML??"",T=document.createRange().createContextualFragment(A(t.html));l.deleteContents(),l.insertNode(T);const p=document.createRange();p.setStartAfter(l.endContainer),p.collapse(!0),e.removeAllRanges(),e.addRange(p),r&&(N(r,D),r.dispatchEvent(new Event("input",{bubbles:!0})))}function $(t){const e=S();if(e){const r=e.innerHTML;e.innerHTML=A(t.html),N(e,r),e.dispatchEvent(new Event("input",{bubbles:!0}))}}function c(){_(),s!==null&&(cancelAnimationFrame(s),s=null),d&&(d.remove(),d=null),n=null,u=null,g="",E=null}function U(t){const e=window.getSelection();e&&e.rangeCount>0?u=e.getRangeAt(0).cloneRange():u=null;const r=M();r.length>0&&!o&&(o=r[0]);const l=t?.contentElement instanceof HTMLElement?t.contentElement:R();E=l||null,O(l)}function X(){if(typeof document>"u")return;const t="template-plugin-dialog-styles";if(document.getElementById(t))return;const e=document.createElement("style");e.id=t,e.textContent=`
.rte-dialog-overlay {

@@ -364,2 +364,2 @@ --rte-tmpl-overlay-bg: rgba(15, 23, 36, 0.56);

}
`,document.head.appendChild(e)}const z=()=>({name:"template",toolbar:[{label:"Template",command:"insertTemplate",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 fill-rule="evenodd" clip-rule="evenodd" d="M3 3V9H21V3H3ZM19 5H5V7H19V5Z" fill="#000000"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M3 11V21H11V11H3ZM9 13H5V19H9V13Z" fill="#000000"></path> <path d="M21 11H13V13H21V11Z" fill="#000000"></path> <path d="M13 15H21V17H13V15Z" fill="#000000"></path> <path d="M21 19H13V21H21V19Z" fill="#000000"></path> </g></svg>'}],commands:{insertTemplate:(t,e)=>(V(e),!0)},keymap:{}});exports.TemplatePlugin=z;
`,document.head.appendChild(e)}const ee=()=>({name:"template",toolbar:[{label:"Template",command:"insertTemplate",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 fill-rule="evenodd" clip-rule="evenodd" d="M3 3V9H21V3H3ZM19 5H5V7H19V5Z" fill="#000000"></path> <path fill-rule="evenodd" clip-rule="evenodd" d="M3 11V21H11V11H3ZM9 13H5V19H9V13Z" fill="#000000"></path> <path d="M21 11H13V13H21V11Z" fill="#000000"></path> <path d="M13 15H21V17H13V15Z" fill="#000000"></path> <path d="M21 19H13V21H21V19Z" fill="#000000"></path> </g></svg>'}],commands:{insertTemplate:(t,e)=>(U(e),!0)},keymap:{}});exports.PREDEFINED_TEMPLATES=I;exports.TemplatePlugin=ee;exports.addCustomTemplate=B;exports.getAllTemplates=L;exports.getTemplateCategories=C;exports.getTemplatesByCategory=z;exports.sanitizeTemplate=A;exports.searchTemplates=P;exports.validateTemplate=F;

@@ -1,4 +0,26 @@

import S from "./purify.es-DHhaBdbu.mjs";
let o = null, d = null, s = null, n = null, p = "", m = "", g = "insert";
const M = [
import j from "./purify.es-DHhaBdbu.mjs";
let n = null, d = null, u = null, o = null, m = "", g = "", v = "insert", x = null, s = null, E = null;
function M(t, e) {
if (e === t.innerHTML) return;
const r = window.execEditorCommand || window.executeEditorCommand;
if (typeof r == "function")
try {
r("recordDomTransaction", t, e, t.innerHTML);
} catch {
}
}
function q(t) {
if (!t) return null;
let e = t.startContainer;
for (; e && e !== document.body; ) {
if (e.nodeType === Node.ELEMENT_NODE) {
const r = e;
if (r.getAttribute("contenteditable") === "true")
return r;
}
e = e.parentNode;
}
return null;
}
const z = [
{

@@ -75,21 +97,29 @@ id: "formal-letter",

];
let w = [...M];
const y = () => w, k = () => {
const t = new Set(w.map((e) => e.category));
let b = [...z];
const H = () => b, U = (t) => b.filter((e) => e.category === t), D = () => {
const t = new Set(b.map((e) => e.category));
return Array.from(t);
}, R = (t) => {
}, B = (t) => {
const e = t.toLowerCase();
return w.filter(
return b.filter(
(r) => r.name.toLowerCase().includes(e) || r.description?.toLowerCase().includes(e) || r.tags?.some((l) => l.toLowerCase().includes(e))
);
}, L = (t) => S.sanitize(t, {
}, N = (t) => j.sanitize(t, {
ALLOWED_TAGS: ["p", "br", "strong", "em", "u", "h1", "h2", "h3", "h4", "ul", "ol", "li", "blockquote", "table", "thead", "tbody", "tr", "th", "td", "a", "span"],
ALLOWED_ATTR: ["href", "target", "class", "data-key", "data-category"]
});
function D(t) {
d = document.createElement("div"), d.className = "rte-dialog-overlay", N(t) && d.classList.add("rte-ui-theme-dark"), d.addEventListener("click", () => c()), o = document.createElement("div"), o.className = "rte-dialog rte-template-dialog", o.addEventListener("click", (r) => r.stopPropagation());
const e = k();
e.length > 0 && !p && (p = e[0]), b(), d.appendChild(o), document.body.appendChild(d), z();
}), X = (t) => b.some((e) => e.id === t.id) ? (console.warn(`Template with ID ${t.id} already exists`), !1) : (b.push(t), !0), ee = (t) => !!(t.id && t.name && t.category && t.html && t.html.trim().length > 0);
function F(t) {
d = document.createElement("div"), d.className = "rte-dialog-overlay", Q(t) && d.classList.add("rte-ui-theme-dark"), d.addEventListener("click", () => c()), n = document.createElement("div"), n.className = "rte-dialog rte-template-dialog", n.addEventListener("click", (r) => r.stopPropagation());
const e = D();
e.length > 0 && !m && (m = e[0]), y(), d.appendChild(n), document.body.appendChild(d), P(), Y();
}
const H = '[data-theme="dark"], .dark, .editora-theme-dark', A = () => {
function P() {
$(), x = (t) => {
t.key === "Escape" && (!d || !n || (t.preventDefault(), t.stopPropagation(), c()));
}, document.addEventListener("keydown", x, !0);
}
function $() {
x && (document.removeEventListener("keydown", x, !0), x = null);
}
const _ = '[data-theme="dark"], .dark, .editora-theme-dark', L = () => {
const t = window.getSelection();

@@ -101,10 +131,17 @@ if (!t || t.rangeCount === 0) return null;

) || null;
}, N = (t) => {
const e = t || A();
return e ? !!e.closest(H) : !1;
}, Q = (t) => {
const e = t || L();
return e ? !!e.closest(_) : !1;
};
function b() {
if (!o) return;
const t = k(), e = E();
o.innerHTML = `
function C() {
const t = q(u);
if (t) return t;
if (E?.isConnected) return E;
const e = L();
return e || document.querySelector(".rte-content, .editora-content");
}
function y() {
if (!n) return;
const t = D(), e = A();
n.innerHTML = `
<div class="rte-dialog-header">

@@ -120,3 +157,3 @@ <h2>Insert Template</h2>

placeholder="Search templates..."
value="${m}"
value="${g}"
class="rte-input rte-template-search"

@@ -129,3 +166,3 @@ aria-label="Search templates"

${t.map((r) => `
<button class="rte-tab ${p === r ? "active" : ""}" data-category="${r}">
<button class="rte-tab ${m === r ? "active" : ""}" data-category="${r}">
${r}

@@ -140,3 +177,3 @@ </button>

<div
class="rte-template-item ${n?.id === r.id ? "selected" : ""}"
class="rte-template-item ${o?.id === r.id ? "selected" : ""}"
data-template-id="${r.id}"

@@ -151,6 +188,6 @@ >

<!-- Preview -->
${n ? `
${o ? `
<div class="rte-template-preview">
<strong>Preview:</strong>
<div class="template-preview-content">${n.html}</div>
<div class="template-preview-content">${o.html}</div>
</div>

@@ -162,7 +199,7 @@ ` : ""}

<label>
<input type="radio" name="insertMode" value="insert" ${g === "insert" ? "checked" : ""} />
<input type="radio" name="insertMode" value="insert" ${v === "insert" ? "checked" : ""} />
Insert at cursor
</label>
<label>
<input type="radio" name="insertMode" value="replace" ${g === "replace" ? "checked" : ""} />
<input type="radio" name="insertMode" value="replace" ${v === "replace" ? "checked" : ""} />
Replace document

@@ -175,11 +212,11 @@ </label>

<button class="rte-button-secondary rte-cancel-btn">Cancel</button>
<button class="rte-button-primary rte-insert-btn" ${n ? "" : "disabled"}>
${g === "insert" ? "Insert" : "Replace"}
<button class="rte-button-primary rte-insert-btn" ${o ? "" : "disabled"}>
${v === "insert" ? "Insert" : "Replace"}
</button>
</div>
`, V();
`, W();
}
function I() {
if (!o) return;
o.innerHTML = `
function O() {
if (!n) return;
n.innerHTML = `
<div class="rte-dialog-header">

@@ -196,115 +233,96 @@ <h2>Replace Document?</h2>

`;
const t = o.querySelector(".rte-cancel-warning-btn"), e = o.querySelector(".rte-confirm-replace-btn");
t?.addEventListener("click", () => b()), e?.addEventListener("click", () => $());
const t = n.querySelector(".rte-cancel-warning-btn"), e = n.querySelector(".rte-confirm-replace-btn");
t?.addEventListener("click", () => y()), e?.addEventListener("click", () => Z());
}
function E() {
const t = y();
return m.trim() ? R(m) : p ? t.filter((e) => e.category === p) : t;
function A() {
const t = H();
return g.trim() ? B(g) : m ? t.filter((e) => e.category === m) : t;
}
function V() {
if (!o) return;
o.querySelector(".rte-dialog-close")?.addEventListener("click", () => c()), o.querySelector(".rte-cancel-btn")?.addEventListener("click", () => c()), o.querySelector(".rte-insert-btn")?.addEventListener("click", () => x());
const l = o.querySelector(".rte-template-search");
function W() {
if (!n) return;
n.querySelector(".rte-dialog-close")?.addEventListener("click", () => c()), n.querySelector(".rte-cancel-btn")?.addEventListener("click", () => c()), n.querySelector(".rte-insert-btn")?.addEventListener("click", () => k());
const l = n.querySelector(".rte-template-search");
l?.addEventListener("input", (a) => {
m = a.target.value, T();
s !== null && cancelAnimationFrame(s), g = a.target.value, s = requestAnimationFrame(() => {
s = null, S();
});
}), l?.addEventListener("keydown", (a) => {
a.key === "Enter" && n ? x() : a.key === "Escape" && c();
}), o.querySelectorAll(".rte-tab").forEach((a) => {
a.addEventListener("click", () => {
const i = a.getAttribute("data-category");
i && (p = i, m = "", T());
});
}), o.querySelectorAll(".rte-template-item").forEach((a) => {
a.addEventListener("click", () => {
const i = a.getAttribute("data-template-id");
if (i) {
const u = y().find((v) => v.id === i);
u && (n = u, b());
}
}), a.addEventListener("dblclick", () => {
const i = a.getAttribute("data-template-id");
if (i) {
const u = y().find((v) => v.id === i);
u && (n = u, x());
}
});
}), o.querySelectorAll('input[name="insertMode"]').forEach((a) => {
a.addEventListener("change", (i) => {
g = i.target.value, b();
});
a.key === "Enter" && o ? k() : a.key === "Escape" && c();
}), n.querySelector(".rte-tabs")?.addEventListener("click", (a) => {
const f = a.target.closest(".rte-tab");
if (!f) return;
const h = f.getAttribute("data-category");
h && (m = h, g = "", s !== null && (cancelAnimationFrame(s), s = null), S());
});
const w = n.querySelector(".rte-template-list"), p = (a) => {
const f = a.target.closest(".rte-template-item");
if (!f) return null;
const h = f.getAttribute("data-template-id");
return h && H().find((V) => V.id === h) || null;
};
w?.addEventListener("click", (a) => {
const i = p(a);
i && (o = i, y());
}), w?.addEventListener("dblclick", (a) => {
const i = p(a);
i && (o = i, k());
}), n.querySelector(".rte-insert-mode")?.addEventListener("change", (a) => {
const i = a.target;
!i || i.name !== "insertMode" || (v = i.value, y());
});
}
function T() {
const t = E();
t.length > 0 ? (!n || !t.find((e) => e.id === n.id)) && (n = t[0]) : n = null, b();
function S() {
const t = A();
t.length > 0 ? (!o || !t.find((e) => e.id === o.id)) && (o = t[0]) : o = null, y();
}
function x() {
if (n)
if (g === "replace") {
let t = null;
if (s) {
let e = s.startContainer;
for (; e && e !== document.body; ) {
if (e.nodeType === Node.ELEMENT_NODE) {
const r = e;
if (r.getAttribute("contenteditable") === "true") {
t = r;
break;
}
}
e = e.parentNode;
}
}
if (t || (t = document.querySelector('[contenteditable="true"]')), t?.innerHTML?.trim()) {
I();
function k() {
if (o)
if (v === "replace") {
if (C()?.innerHTML?.trim()) {
O();
return;
}
C(n), c();
I(o), c();
} else
j(n), c();
G(o), c();
}
function $() {
n && (C(n), c());
function Z() {
o && (I(o), c());
}
function j(t) {
if (s) {
const f = window.getSelection();
f && (f.removeAllRanges(), f.addRange(s));
function G(t) {
const e = window.getSelection();
if (!e) return;
const r = C();
if (!r) return;
if (u)
e.removeAllRanges(), e.addRange(u);
else {
const T = document.createRange();
T.selectNodeContents(r), T.collapse(!1), e.removeAllRanges(), e.addRange(T);
}
const e = window.getSelection();
if (!e || e.rangeCount === 0) return;
const r = e.getRangeAt(0), l = document.createRange().createContextualFragment(L(t.html));
r.deleteContents(), r.insertNode(l);
const h = document.createRange();
h.setStartAfter(r.endContainer), h.collapse(!0), e.removeAllRanges(), e.addRange(h);
if (e.rangeCount === 0) return;
const l = e.getRangeAt(0), R = r?.innerHTML ?? "", w = document.createRange().createContextualFragment(N(t.html));
l.deleteContents(), l.insertNode(w);
const p = document.createRange();
p.setStartAfter(l.endContainer), p.collapse(!0), e.removeAllRanges(), e.addRange(p), r && (M(r, R), r.dispatchEvent(new Event("input", { bubbles: !0 })));
}
function C(t) {
let e = null;
if (s) {
let r = s.startContainer;
for (; r && r !== document.body; ) {
if (r.nodeType === Node.ELEMENT_NODE) {
const l = r;
if (l.getAttribute("contenteditable") === "true") {
e = l;
break;
}
}
r = r.parentNode;
}
function I(t) {
const e = C();
if (e) {
const r = e.innerHTML;
e.innerHTML = N(t.html), M(e, r), e.dispatchEvent(new Event("input", { bubbles: !0 }));
}
e || (e = document.querySelector('[contenteditable="true"]')), e && (e.innerHTML = L(t.html), e.dispatchEvent(new Event("input", { bubbles: !0 })));
}
function c() {
d && (d.remove(), d = null), o = null, s = null, m = "";
$(), s !== null && (cancelAnimationFrame(s), s = null), d && (d.remove(), d = null), n = null, u = null, g = "", E = null;
}
function q(t) {
function K(t) {
const e = window.getSelection();
e && e.rangeCount > 0 ? s = e.getRangeAt(0).cloneRange() : s = null;
const r = E();
r.length > 0 && !n && (n = r[0]);
const l = t?.contentElement instanceof HTMLElement ? t.contentElement : A();
D(l);
e && e.rangeCount > 0 ? u = e.getRangeAt(0).cloneRange() : u = null;
const r = A();
r.length > 0 && !o && (o = r[0]);
const l = t?.contentElement instanceof HTMLElement ? t.contentElement : L();
E = l || null, F(l);
}
function z() {
function Y() {
if (typeof document > "u") return;

@@ -553,3 +571,3 @@ const t = "template-plugin-dialog-styles";

}
const P = () => ({
const te = () => ({
name: "template",

@@ -564,3 +582,3 @@ toolbar: [

commands: {
insertTemplate: (t, e) => (q(e), !0)
insertTemplate: (t, e) => (K(e), !0)
},

@@ -570,3 +588,11 @@ keymap: {}

export {
P as TemplatePlugin
z as PREDEFINED_TEMPLATES,
te as TemplatePlugin,
X as addCustomTemplate,
H as getAllTemplates,
D as getTemplateCategories,
U as getTemplatesByCategory,
N as sanitizeTemplate,
B as searchTemplates,
ee as validateTemplate
};

@@ -1,2 +0,2 @@

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("./colorSelectionApply-C0iOfMWb.js");let o=null,p=null,f=null,i="#000000";const s='[data-theme="dark"], .dark, .editora-theme-dark',k=["#000000","#ffffff","#808080","#ff0000","#00ff00","#0000ff","#ffff00","#ff00ff","#00ffff","#ffa500","#800080","#ffc0cb"];function m(){const e=window.getSelection();if(e&&e.rangeCount>0){const l=e.getRangeAt(0).startContainer,c=l.nodeType===Node.ELEMENT_NODE?l:l.parentElement;if(c){const n=c.closest('[data-editora-editor="true"], .rte-editor, .editora-editor');if(n)return n}}const t=document.activeElement;return t?t.closest('[data-editora-editor="true"], .rte-editor, .editora-editor'):null}function v(e){const t=m();if(t){const r=t.querySelector(`[data-command="${e}"]`);if(r)return r}return document.querySelector(`[data-command="${e}"]`)}function y(e){if(e?.closest(s))return!0;const t=window.getSelection();if(t&&t.rangeCount>0){const l=t.getRangeAt(0).startContainer;if((l.nodeType===Node.ELEMENT_NODE?l:l.parentElement)?.closest(s))return!0}return document.activeElement?.closest(s)?!0:document.body.matches(s)||document.documentElement.matches(s)}function d(e){return h.applyColorToSelection({color:e,className:"rte-text-color",styleProperty:"color",commands:["foreColor"],savedRange:f,getActiveEditorRoot:m,warnMessage:"[TextColor] Could not apply color for current selection"})}function w(){const e=window.getSelection();if(!e||e.rangeCount===0)return"#000000";let r=e.getRangeAt(0).startContainer;for(;r&&r!==document.body;){if(r.nodeType===Node.ELEMENT_NODE){const l=r,c=l.style.color||window.getComputedStyle(l).color;if(c&&c!=="rgb(0, 0, 0)")return C(c)}r=r.parentNode}return"#000000"}function C(e){if(e.startsWith("#"))return e;const t=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(!t)return"#000000";const r=parseInt(t[1]),l=parseInt(t[2]),c=parseInt(t[3]);return"#"+[r,l,c].map(n=>{const u=n.toString(16);return u.length===1?"0"+u:u}).join("")}function E(e){const t=window.getSelection();t&&t.rangeCount>0&&(f=t.getRangeAt(0).cloneRange()),i=w(),o=document.createElement("div"),o.className="rte-inline-color-picker",y(e)&&o.classList.add("rte-theme-dark"),o.addEventListener("click",l=>l.stopPropagation()),o.innerHTML=`
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("./anchoredPopover-BzqGPOAE.js");let n=null,d=null,x=null,i="#000000";const u='[data-theme="dark"], .dark, .editora-theme-dark',w=["#000000","#ffffff","#808080","#ff0000","#00ff00","#0000ff","#ffff00","#ff00ff","#00ffff","#ffa500","#800080","#ffc0cb"];function y(){const e=window.getSelection();if(e&&e.rangeCount>0){const c=e.getRangeAt(0).startContainer,l=c.nodeType===Node.ELEMENT_NODE?c:c.parentElement;if(l){const r=l.closest('[data-editora-editor="true"], .rte-editor, .editora-editor');if(r)return r}}const o=document.activeElement;return o?o.closest('[data-editora-editor="true"], .rte-editor, .editora-editor'):null}function C(e){const o=window.__editoraLastCommand,t=window.__editoraLastCommandButton;if(o===e&&t&&t.isConnected){const a=window.getComputedStyle(t),s=t.getBoundingClientRect();if(a.display!=="none"&&a.visibility!=="hidden"&&a.pointerEvents!=="none"&&!(s.width===0&&s.height===0))return t}const c=a=>{for(const s of a){const b=window.getComputedStyle(s),h=s.getBoundingClientRect();if(!(b.display==="none"||b.visibility==="hidden"||b.pointerEvents==="none")&&!(h.width===0&&h.height===0))return s}return null},l=y();if(l){const a=Array.from(l.querySelectorAll(`[data-command="${e}"]`)),s=c(a);if(s)return s}const r=Array.from(document.querySelectorAll(`[data-command="${e}"]`));return c(r)}function E(e){if(e?.closest(u))return!0;const o=window.getSelection();if(o&&o.rangeCount>0){const c=o.getRangeAt(0).startContainer;if((c.nodeType===Node.ELEMENT_NODE?c:c.parentElement)?.closest(u))return!0}return document.activeElement?.closest(u)?!0:document.body.matches(u)||document.documentElement.matches(u)}function f(e){return k.applyColorToSelection({color:e,className:"rte-text-color",styleProperty:"color",commands:["foreColor"],savedRange:x,getActiveEditorRoot:y,warnMessage:"[TextColor] Could not apply color for current selection"})}function S(){const e=window.getSelection();if(!e||e.rangeCount===0)return"#000000";let t=e.getRangeAt(0).startContainer;for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE){const c=t,l=c.style.color||window.getComputedStyle(c).color;if(l&&l!=="rgb(0, 0, 0)")return T(l)}t=t.parentNode}return"#000000"}function T(e){if(e.startsWith("#"))return e;const o=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(!o)return"#000000";const t=parseInt(o[1]),c=parseInt(o[2]),l=parseInt(o[3]);return"#"+[t,c,l].map(r=>{const a=r.toString(16);return a.length===1?"0"+a:a}).join("")}function A(e){const o=window.getSelection();o&&o.rangeCount>0&&(x=o.getRangeAt(0).cloneRange()),i=S(),n=document.createElement("div"),n.className="rte-inline-color-picker",E(e)&&n.classList.add("rte-theme-dark"),n.addEventListener("click",t=>t.stopPropagation()),n.innerHTML=`
<div class="rte-color-picker-header">

@@ -18,9 +18,9 @@ <span class="rte-color-picker-title">Text Color</span>

<div class="rte-color-palette">
${k.map(l=>`
${w.map(t=>`
<button
class="rte-color-swatch ${i===l?"selected":""}"
style="background-color: ${l}; ${l==="#ffffff"?"border: 1px solid #ccc;":""}"
data-color="${l}"
title="${l.toUpperCase()}"
aria-label="${l.toUpperCase()}"
class="rte-color-swatch ${i===t?"selected":""}"
style="background-color: ${t}; ${t==="#ffffff"?"border: 1px solid #ccc;":""}"
data-color="${t}"
title="${t.toUpperCase()}"
aria-label="${t.toUpperCase()}"
></button>

@@ -52,3 +52,3 @@ `).join("")}

</div>
`;const r=e.getBoundingClientRect();o.style.position="absolute",o.style.top=`${r.bottom+window.scrollY+4}px`,o.style.left=`${r.left+window.scrollX}px`,o.style.zIndex="10000",document.body.appendChild(o),p=e,T()}function T(){if(!o)return;o.querySelector(".rte-color-picker-close")?.addEventListener("click",()=>a()),o.querySelectorAll(".rte-color-swatch").forEach(c=>{c.addEventListener("click",()=>{const n=c.getAttribute("data-color");n&&(i=n,d(n),a())})});const r=o.querySelector(".rte-color-input-native");r?.addEventListener("change",c=>{const n=c.target.value;i=n,d(n),a()});const l=o.querySelector(".rte-color-input-text");l?.addEventListener("change",c=>{const n=c.target.value;/^#[0-9A-Fa-f]{6}$/.test(n)&&(i=n,d(n),a())}),r?.addEventListener("input",c=>{const n=c.target.value;i=n,x(n),b(n),L(n)}),l?.addEventListener("input",c=>{const n=c.target.value;/^#[0-9A-Fa-f]{6}$/.test(n)&&(i=n,x(n),b(n),S(n))})}function x(e){if(!o)return;const t=o.querySelector(".rte-color-preview-box"),r=o.querySelector(".rte-color-preview-label");t&&(t.style.backgroundColor=e,t.style.border=e==="#ffffff"?"1px solid #ccc":"none"),r&&(r.textContent=e.toUpperCase())}function b(e){if(!o)return;o.querySelectorAll(".rte-color-swatch").forEach(r=>{r.getAttribute("data-color")===e?r.classList.add("selected"):r.classList.remove("selected")})}function S(e){if(!o)return;const t=o.querySelector(".rte-color-input-native");t&&(t.value=e)}function L(e){if(!o)return;const t=o.querySelector(".rte-color-input-text");t&&(t.value=e)}function a(){o&&(o.remove(),o=null),p=null,f=null}function $(){if(o)return a(),!0;const e=v("openTextColorPicker");return e?(E(e),!0):!1}function g(){if(!window.__textColorPluginInitialized&&(window.__textColorPluginInitialized=!0,document.addEventListener("click",e=>{if(o&&p){const t=e.target;!o.contains(t)&&!p.contains(t)&&a()}}),!document.getElementById("text-color-plugin-styles"))){const e=document.createElement("style");e.id="text-color-plugin-styles",e.textContent=`
`,document.body.appendChild(n),d&&(d.destroy(),d=null),d=k.attachAnchoredPopover({popover:n,anchor:e,onClose:p,gap:4,margin:8,zIndex:1e4}),L()}function L(){if(!n)return;n.querySelector(".rte-color-picker-close")?.addEventListener("click",()=>p()),n.querySelectorAll(".rte-color-swatch").forEach(l=>{l.addEventListener("click",()=>{const r=l.getAttribute("data-color");r&&(i=r,f(r),p())})});const t=n.querySelector(".rte-color-input-native");t?.addEventListener("change",l=>{const r=l.target.value;i=r,f(r),p()});const c=n.querySelector(".rte-color-input-text");c?.addEventListener("change",l=>{const r=l.target.value;/^#[0-9A-Fa-f]{6}$/.test(r)&&(i=r,f(r),p())}),t?.addEventListener("input",l=>{const r=l.target.value;i=r,m(r),v(r),$(r)}),c?.addEventListener("input",l=>{const r=l.target.value;/^#[0-9A-Fa-f]{6}$/.test(r)&&(i=r,m(r),v(r),P(r))})}function m(e){if(!n)return;const o=n.querySelector(".rte-color-preview-box"),t=n.querySelector(".rte-color-preview-label");o&&(o.style.backgroundColor=e,o.style.border=e==="#ffffff"?"1px solid #ccc":"none"),t&&(t.textContent=e.toUpperCase())}function v(e){if(!n)return;n.querySelectorAll(".rte-color-swatch").forEach(t=>{t.getAttribute("data-color")===e?t.classList.add("selected"):t.classList.remove("selected")})}function P(e){if(!n)return;const o=n.querySelector(".rte-color-input-native");o&&(o.value=e)}function $(e){if(!n)return;const o=n.querySelector(".rte-color-input-text");o&&(o.value=e)}function p(){d&&(d.destroy(),d=null),n&&(n.remove(),n=null),x=null}function _(){if(g(),n)return p(),!0;const e=C("openTextColorPicker");return e?(A(e),!0):!1}function g(){if(!window.__textColorPluginInitialized&&(window.__textColorPluginInitialized=!0,!document.getElementById("text-color-plugin-styles"))){const e=document.createElement("style");e.id="text-color-plugin-styles",e.textContent=`
.rte-inline-color-picker {

@@ -302,2 +302,2 @@ background: white;

}
`,document.head.appendChild(e)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",g):setTimeout(g,100);const P=()=>({name:"textColor",marks:{textColor:{attrs:{color:{default:"#000000"}},parseDOM:[{tag:"span[style*=color]",getAttrs:e=>{const r=(e.getAttribute("style")||"").match(/color:\s*([^;]+)/);return r?{color:r[1]}:null}},{tag:"font[color]",getAttrs:e=>{const t=e.getAttribute("color");return t?{color:t}:null}}],toDOM:e=>["span",{style:`color: ${e.attrs?.color||"#000000"}`,class:"rte-text-color"},0]}},toolbar:[{label:"Text Color",command:"openTextColorPicker",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path class="tox-icon-text-color__color" d="M3 18h18v3H3z" fill="currentColor"></path><path d="M8.7 16h-.8a.5.5 0 0 1-.5-.6l2.7-9c.1-.3.3-.4.5-.4h2.8c.2 0 .4.1.5.4l2.7 9a.5.5 0 0 1-.5.6h-.8a.5.5 0 0 1-.4-.4l-.7-2.2c0-.3-.3-.4-.5-.4h-3.4c-.2 0-.4.1-.5.4l-.7 2.2c0 .3-.2.4-.4.4Zm2.6-7.6-.6 2a.5.5 0 0 0 .5.6h1.6a.5.5 0 0 0 .5-.6l-.6-2c0-.3-.3-.4-.5-.4h-.4c-.2 0-.4.1-.5.4Z"></path></g></svg>'}],commands:{openTextColorPicker:()=>$(),setTextColor:e=>e?d(e):!1},keymap:{}});exports.TextColorPlugin=P;
`,document.head.appendChild(e)}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",g):setTimeout(g,100);const M=()=>({name:"textColor",marks:{textColor:{attrs:{color:{default:"#000000"}},parseDOM:[{tag:"span[style*=color]",getAttrs:e=>{const t=(e.getAttribute("style")||"").match(/color:\s*([^;]+)/);return t?{color:t[1]}:null}},{tag:"font[color]",getAttrs:e=>{const o=e.getAttribute("color");return o?{color:o}:null}}],toDOM:e=>["span",{style:`color: ${e.attrs?.color||"#000000"}`,class:"rte-text-color"},0]}},toolbar:[{label:"Text Color",command:"openTextColorPicker",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path class="tox-icon-text-color__color" d="M3 18h18v3H3z" fill="currentColor"></path><path d="M8.7 16h-.8a.5.5 0 0 1-.5-.6l2.7-9c.1-.3.3-.4.5-.4h2.8c.2 0 .4.1.5.4l2.7 9a.5.5 0 0 1-.5.6h-.8a.5.5 0 0 1-.4-.4l-.7-2.2c0-.3-.3-.4-.5-.4h-3.4c-.2 0-.4.1-.5.4l-.7 2.2c0 .3-.2.4-.4.4Zm2.6-7.6-.6 2a.5.5 0 0 0 .5.6h1.6a.5.5 0 0 0 .5-.6l-.6-2c0-.3-.3-.4-.5-.4h-.4c-.2 0-.4.1-.5.4Z"></path></g></svg>'}],commands:{openTextColorPicker:()=>_(),setTextColor:e=>e?f(e):!1},keymap:{}});exports.TextColorPlugin=M;

@@ -1,4 +0,4 @@

import { a as h } from "./colorSelectionApply-D8r_gV32.mjs";
let o = null, p = null, f = null, i = "#000000";
const s = '[data-theme="dark"], .dark, .editora-theme-dark', k = [
import { a as y, b as w } from "./anchoredPopover-Dts0IrgU.mjs";
let n = null, d = null, g = null, i = "#000000";
const u = '[data-theme="dark"], .dark, .editora-theme-dark', C = [
"#000000",

@@ -17,39 +17,55 @@ "#ffffff",

];
function m() {
function v() {
const e = window.getSelection();
if (e && e.rangeCount > 0) {
const l = e.getRangeAt(0).startContainer, c = l.nodeType === Node.ELEMENT_NODE ? l : l.parentElement;
if (c) {
const n = c.closest(
const c = e.getRangeAt(0).startContainer, l = c.nodeType === Node.ELEMENT_NODE ? c : c.parentElement;
if (l) {
const r = l.closest(
'[data-editora-editor="true"], .rte-editor, .editora-editor'
);
if (n) return n;
if (r) return r;
}
}
const t = document.activeElement;
return t ? t.closest(
const o = document.activeElement;
return o ? o.closest(
'[data-editora-editor="true"], .rte-editor, .editora-editor'
) : null;
}
function v(e) {
const t = m();
if (t) {
const r = t.querySelector(
`[data-command="${e}"]`
);
if (r) return r;
function E(e) {
const o = window.__editoraLastCommand, t = window.__editoraLastCommandButton;
if (o === e && t && t.isConnected) {
const a = window.getComputedStyle(t), s = t.getBoundingClientRect();
if (a.display !== "none" && a.visibility !== "hidden" && a.pointerEvents !== "none" && !(s.width === 0 && s.height === 0))
return t;
}
return document.querySelector(`[data-command="${e}"]`);
const c = (a) => {
for (const s of a) {
const b = window.getComputedStyle(s), h = s.getBoundingClientRect();
if (!(b.display === "none" || b.visibility === "hidden" || b.pointerEvents === "none") && !(h.width === 0 && h.height === 0))
return s;
}
return null;
}, l = v();
if (l) {
const a = Array.from(
l.querySelectorAll(`[data-command="${e}"]`)
), s = c(a);
if (s) return s;
}
const r = Array.from(
document.querySelectorAll(`[data-command="${e}"]`)
);
return c(r);
}
function y(e) {
if (e?.closest(s)) return !0;
const t = window.getSelection();
if (t && t.rangeCount > 0) {
const l = t.getRangeAt(0).startContainer;
if ((l.nodeType === Node.ELEMENT_NODE ? l : l.parentElement)?.closest(s)) return !0;
function S(e) {
if (e?.closest(u)) return !0;
const o = window.getSelection();
if (o && o.rangeCount > 0) {
const c = o.getRangeAt(0).startContainer;
if ((c.nodeType === Node.ELEMENT_NODE ? c : c.parentElement)?.closest(u)) return !0;
}
return document.activeElement?.closest(s) ? !0 : document.body.matches(s) || document.documentElement.matches(s);
return document.activeElement?.closest(u) ? !0 : document.body.matches(u) || document.documentElement.matches(u);
}
function d(e) {
return h({
function f(e) {
return y({
color: e,

@@ -59,34 +75,34 @@ className: "rte-text-color",

commands: ["foreColor"],
savedRange: f,
getActiveEditorRoot: m,
savedRange: g,
getActiveEditorRoot: v,
warnMessage: "[TextColor] Could not apply color for current selection"
});
}
function w() {
function T() {
const e = window.getSelection();
if (!e || e.rangeCount === 0) return "#000000";
let r = e.getRangeAt(0).startContainer;
for (; r && r !== document.body; ) {
if (r.nodeType === Node.ELEMENT_NODE) {
const l = r, c = l.style.color || window.getComputedStyle(l).color;
if (c && c !== "rgb(0, 0, 0)")
return C(c);
let t = e.getRangeAt(0).startContainer;
for (; t && t !== document.body; ) {
if (t.nodeType === Node.ELEMENT_NODE) {
const c = t, l = c.style.color || window.getComputedStyle(c).color;
if (l && l !== "rgb(0, 0, 0)")
return A(l);
}
r = r.parentNode;
t = t.parentNode;
}
return "#000000";
}
function C(e) {
function A(e) {
if (e.startsWith("#")) return e;
const t = e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
if (!t) return "#000000";
const r = parseInt(t[1]), l = parseInt(t[2]), c = parseInt(t[3]);
return "#" + [r, l, c].map((n) => {
const u = n.toString(16);
return u.length === 1 ? "0" + u : u;
const o = e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
if (!o) return "#000000";
const t = parseInt(o[1]), c = parseInt(o[2]), l = parseInt(o[3]);
return "#" + [t, c, l].map((r) => {
const a = r.toString(16);
return a.length === 1 ? "0" + a : a;
}).join("");
}
function E(e) {
const t = window.getSelection();
t && t.rangeCount > 0 && (f = t.getRangeAt(0).cloneRange()), i = w(), o = document.createElement("div"), o.className = "rte-inline-color-picker", y(e) && o.classList.add("rte-theme-dark"), o.addEventListener("click", (l) => l.stopPropagation()), o.innerHTML = `
function L(e) {
const o = window.getSelection();
o && o.rangeCount > 0 && (g = o.getRangeAt(0).cloneRange()), i = T(), n = document.createElement("div"), n.className = "rte-inline-color-picker", S(e) && n.classList.add("rte-theme-dark"), n.addEventListener("click", (t) => t.stopPropagation()), n.innerHTML = `
<div class="rte-color-picker-header">

@@ -108,9 +124,9 @@ <span class="rte-color-picker-title">Text Color</span>

<div class="rte-color-palette">
${k.map((l) => `
${C.map((t) => `
<button
class="rte-color-swatch ${i === l ? "selected" : ""}"
style="background-color: ${l}; ${l === "#ffffff" ? "border: 1px solid #ccc;" : ""}"
data-color="${l}"
title="${l.toUpperCase()}"
aria-label="${l.toUpperCase()}"
class="rte-color-swatch ${i === t ? "selected" : ""}"
style="background-color: ${t}; ${t === "#ffffff" ? "border: 1px solid #ccc;" : ""}"
data-color="${t}"
title="${t.toUpperCase()}"
aria-label="${t.toUpperCase()}"
></button>

@@ -142,68 +158,68 @@ `).join("")}

</div>
`;
const r = e.getBoundingClientRect();
o.style.position = "absolute", o.style.top = `${r.bottom + window.scrollY + 4}px`, o.style.left = `${r.left + window.scrollX}px`, o.style.zIndex = "10000", document.body.appendChild(o), p = e, T();
`, document.body.appendChild(n), d && (d.destroy(), d = null), d = w({
popover: n,
anchor: e,
onClose: p,
gap: 4,
margin: 8,
zIndex: 1e4
}), P();
}
function T() {
if (!o) return;
o.querySelector(".rte-color-picker-close")?.addEventListener("click", () => a()), o.querySelectorAll(".rte-color-swatch").forEach((c) => {
c.addEventListener("click", () => {
const n = c.getAttribute("data-color");
n && (i = n, d(n), a());
function P() {
if (!n) return;
n.querySelector(".rte-color-picker-close")?.addEventListener("click", () => p()), n.querySelectorAll(".rte-color-swatch").forEach((l) => {
l.addEventListener("click", () => {
const r = l.getAttribute("data-color");
r && (i = r, f(r), p());
});
});
const r = o.querySelector(".rte-color-input-native");
r?.addEventListener("change", (c) => {
const n = c.target.value;
i = n, d(n), a();
const t = n.querySelector(".rte-color-input-native");
t?.addEventListener("change", (l) => {
const r = l.target.value;
i = r, f(r), p();
});
const l = o.querySelector(".rte-color-input-text");
l?.addEventListener("change", (c) => {
const n = c.target.value;
/^#[0-9A-Fa-f]{6}$/.test(n) && (i = n, d(n), a());
}), r?.addEventListener("input", (c) => {
const n = c.target.value;
i = n, x(n), b(n), L(n);
}), l?.addEventListener("input", (c) => {
const n = c.target.value;
/^#[0-9A-Fa-f]{6}$/.test(n) && (i = n, x(n), b(n), S(n));
const c = n.querySelector(".rte-color-input-text");
c?.addEventListener("change", (l) => {
const r = l.target.value;
/^#[0-9A-Fa-f]{6}$/.test(r) && (i = r, f(r), p());
}), t?.addEventListener("input", (l) => {
const r = l.target.value;
i = r, m(r), k(r), _(r);
}), c?.addEventListener("input", (l) => {
const r = l.target.value;
/^#[0-9A-Fa-f]{6}$/.test(r) && (i = r, m(r), k(r), $(r));
});
}
function x(e) {
if (!o) return;
const t = o.querySelector(".rte-color-preview-box"), r = o.querySelector(".rte-color-preview-label");
t && (t.style.backgroundColor = e, t.style.border = e === "#ffffff" ? "1px solid #ccc" : "none"), r && (r.textContent = e.toUpperCase());
function m(e) {
if (!n) return;
const o = n.querySelector(".rte-color-preview-box"), t = n.querySelector(".rte-color-preview-label");
o && (o.style.backgroundColor = e, o.style.border = e === "#ffffff" ? "1px solid #ccc" : "none"), t && (t.textContent = e.toUpperCase());
}
function b(e) {
if (!o) return;
o.querySelectorAll(".rte-color-swatch").forEach((r) => {
r.getAttribute("data-color") === e ? r.classList.add("selected") : r.classList.remove("selected");
function k(e) {
if (!n) return;
n.querySelectorAll(".rte-color-swatch").forEach((t) => {
t.getAttribute("data-color") === e ? t.classList.add("selected") : t.classList.remove("selected");
});
}
function S(e) {
if (!o) return;
const t = o.querySelector(".rte-color-input-native");
t && (t.value = e);
function $(e) {
if (!n) return;
const o = n.querySelector(".rte-color-input-native");
o && (o.value = e);
}
function L(e) {
if (!o) return;
const t = o.querySelector(".rte-color-input-text");
t && (t.value = e);
function _(e) {
if (!n) return;
const o = n.querySelector(".rte-color-input-text");
o && (o.value = e);
}
function a() {
o && (o.remove(), o = null), p = null, f = null;
function p() {
d && (d.destroy(), d = null), n && (n.remove(), n = null), g = null;
}
function $() {
if (o)
return a(), !0;
const e = v("openTextColorPicker");
return e ? (E(e), !0) : !1;
function R() {
if (x(), n)
return p(), !0;
const e = E("openTextColorPicker");
return e ? (L(e), !0) : !1;
}
function g() {
if (!window.__textColorPluginInitialized && (window.__textColorPluginInitialized = !0, document.addEventListener("click", (e) => {
if (o && p) {
const t = e.target;
!o.contains(t) && !p.contains(t) && a();
}
}), !document.getElementById("text-color-plugin-styles"))) {
function x() {
if (!window.__textColorPluginInitialized && (window.__textColorPluginInitialized = !0, !document.getElementById("text-color-plugin-styles"))) {
const e = document.createElement("style");

@@ -462,4 +478,4 @@ e.id = "text-color-plugin-styles", e.textContent = `

}
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", g) : setTimeout(g, 100);
const A = () => ({
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", x) : setTimeout(x, 100);
const N = () => ({
name: "textColor",

@@ -475,4 +491,4 @@ marks: {

getAttrs: (e) => {
const r = (e.getAttribute("style") || "").match(/color:\s*([^;]+)/);
return r ? { color: r[1] } : null;
const t = (e.getAttribute("style") || "").match(/color:\s*([^;]+)/);
return t ? { color: t[1] } : null;
}

@@ -483,4 +499,4 @@ },

getAttrs: (e) => {
const t = e.getAttribute("color");
return t ? { color: t } : null;
const o = e.getAttribute("color");
return o ? { color: o } : null;
}

@@ -507,4 +523,4 @@ }

commands: {
openTextColorPicker: () => $(),
setTextColor: (e) => e ? d(e) : !1
openTextColorPicker: () => R(),
setTextColor: (e) => e ? f(e) : !1
},

@@ -514,3 +530,3 @@ keymap: {}

export {
A as TextColorPlugin
N as TextColorPlugin
};

@@ -11,2 +11,44 @@ import type { Plugin } from "@editora/core";

export interface MergeTagItem {
key?: string;
label: string;
category?: string;
preview?: string;
description?: string;
value?: string;
}
export interface MergeTagCategory {
id?: string;
name: string;
tags: MergeTagItem[];
}
export interface MergeTagDialogOptions {
title?: string;
searchPlaceholder?: string;
emptyStateText?: string;
cancelText?: string;
insertText?: string;
showPreview?: boolean;
}
export interface MergeTagPluginOptions {
tags?: MergeTagItem[];
categories?: MergeTagCategory[];
defaultCategory?: string;
dialog?: MergeTagDialogOptions;
tokenTemplate?: string | ((tag: MergeTagItem & { key: string; category: string }) => string);
}
export interface Template {
id: string;
name: string;
category: string;
html: string;
description?: string;
preview?: string;
tags?: string[];
}
export function HeadingPlugin(): Plugin;

@@ -54,4 +96,12 @@ export function BoldPlugin(): Plugin;

export function CodeSamplePlugin(): Plugin;
export function MergeTagPlugin(): Plugin;
export function MergeTagPlugin(options?: MergeTagPluginOptions): Plugin;
export function TemplatePlugin(): Plugin;
export const PREDEFINED_TEMPLATES: Template[];
export function addCustomTemplate(template: Template): boolean;
export function getAllTemplates(): Template[];
export function getTemplatesByCategory(category: string): Template[];
export function getTemplateCategories(): string[];
export function searchTemplates(query: string): Template[];
export function sanitizeTemplate(html: string): string;
export function validateTemplate(template: Template): boolean;
export function CommentsPlugin(): Plugin;

@@ -58,0 +108,0 @@ export function SpellCheckPlugin(): Plugin;

{
"name": "@editora/plugins",
"version": "1.0.7",
"version": "1.0.8",
"description": "40+ Free Premium Plugins for Editora Rich Text Editor. Table editor, code formatting, accessibility, math, media, and more. Free enterprise plugin collection.",

@@ -320,3 +320,3 @@ "author": "Ajay Kumar <ajaykr089@gmail.com>",

"peerDependencies": {
"@editora/core": "^1.0.6"
"@editora/core": "^1.0.7"
},

@@ -328,3 +328,3 @@ "dependencies": {

"devDependencies": {
"@editora/core": "^1.0.6",
"@editora/core": "^1.0.7",
"@types/katex": "^0.16.8",

@@ -331,0 +331,0 @@ "typescript": "^5.0.0",

@@ -598,6 +598,13 @@ # @editora/plugins

tags: [
{ label: 'First Name', value: '{{firstName}}' },
{ label: 'Last Name', value: '{{lastName}}' },
{ label: 'Email', value: '{{email}}' }
]
{ label: 'First Name', value: '{{firstName}}', category: 'User' },
{ label: 'Last Name', value: '{{lastName}}', category: 'User' },
{ label: 'Email', value: '{{email}}', category: 'User' }
],
defaultCategory: 'User',
dialog: {
title: 'Insert Variable',
searchPlaceholder: 'Search variables...',
showPreview: true
},
tokenTemplate: '{value}'
}),

@@ -608,2 +615,41 @@ HistoryPlugin()

`MergeTagPlugin` supports functional customization:
- `tags`: flat list of tags (auto-grouped by `category`)
- `categories`: explicit grouped categories with custom order
- `defaultCategory`: initial tab
- `dialog`: labels/placeholders/preview toggle
- `tokenTemplate`: string template (`{key}`, `{label}`, `{category}`, `{value}`) or formatter function
### Custom Templates
You can register your own templates before initializing the editor:
```typescript
import { TemplatePlugin, addCustomTemplate } from '@editora/plugins';
addCustomTemplate({
id: 'invoice-basic',
name: 'Invoice (Basic)',
category: 'Billing',
description: 'Simple invoice template',
html: `
<h1>Invoice</h1>
<p><strong>Customer:</strong> {{customer.name}}</p>
<p><strong>Date:</strong> {{today}}</p>
<p><strong>Total:</strong> {{invoice.total}}</p>
`,
tags: ['invoice', 'billing']
});
const plugins = [
TemplatePlugin()
];
```
Notes:
- `id` must be unique.
- HTML is sanitized on insertion.
- Use `validateTemplate(template)` if you want to pre-check templates before registering.
## 🔧 TypeScript Support

@@ -610,0 +656,0 @@

"use strict";const u="p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";function i(e){return!!e.cloneContents().querySelector(u)}function s(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=s(e,t);n&&n.dispatchEvent(new Event("input",{bubbles:!0}))}function f(e,t){let o=e.startContainer.nodeType===Node.TEXT_NODE?e.startContainer.parentElement:e.startContainer;for(;o&&o!==document.body;){if(o.classList.contains(t)){const a=document.createRange();if(a.selectNodeContents(o),a.compareBoundaryPoints(Range.START_TO_START,e)<=0&&a.compareBoundaryPoints(Range.END_TO_END,e)>=0)return o}o=o.parentElement}return null}function m(e){try{if(e.savedRange){const r=window.getSelection();r&&(r.removeAllRanges(),r.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 o=f(n,e.className);if(o)return e.styleProperty==="backgroundColor"?o.style.backgroundColor=e.color:o.style.color=e.color,c(o,e.getActiveEditorRoot),!0;s(n.commonAncestorContainer,e.getActiveEditorRoot)?.focus({preventScroll:!0});try{document.execCommand("styleWithCSS",!1,"true")}catch{}let l=!1;if(e.commands.forEach(r=>{l||(l=document.execCommand(r,!1,e.color))}),!l&&!i(n)){const r=document.createElement("span");e.styleProperty==="backgroundColor"?r.style.backgroundColor=e.color:r.style.color=e.color,r.className=e.className;const d=n.extractContents();r.appendChild(d),n.insertNode(r),n.setStartAfter(r),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}}exports.applyColorToSelection=m;
const u = "p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";
function i(e) {
return !!e.cloneContents().querySelector(u);
}
function s(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 = s(e, t);
n && n.dispatchEvent(new Event("input", { bubbles: !0 }));
}
function f(e, t) {
let o = e.startContainer.nodeType === Node.TEXT_NODE ? e.startContainer.parentElement : e.startContainer;
for (; o && o !== document.body; ) {
if (o.classList.contains(t)) {
const l = document.createRange();
if (l.selectNodeContents(o), l.compareBoundaryPoints(Range.START_TO_START, e) <= 0 && l.compareBoundaryPoints(Range.END_TO_END, e) >= 0)
return o;
}
o = o.parentElement;
}
return null;
}
function m(e) {
try {
if (e.savedRange) {
const r = window.getSelection();
r && (r.removeAllRanges(), r.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 o = f(n, e.className);
if (o)
return e.styleProperty === "backgroundColor" ? o.style.backgroundColor = e.color : o.style.color = e.color, c(o, e.getActiveEditorRoot), !0;
s(
n.commonAncestorContainer,
e.getActiveEditorRoot
)?.focus({ preventScroll: !0 });
try {
document.execCommand("styleWithCSS", !1, "true");
} catch {
}
let a = !1;
if (e.commands.forEach((r) => {
a || (a = document.execCommand(r, !1, e.color));
}), !a && !i(n)) {
const r = document.createElement("span");
e.styleProperty === "backgroundColor" ? r.style.backgroundColor = e.color : r.style.color = e.color, r.className = e.className;
const d = n.extractContents();
r.appendChild(d), n.insertNode(r), n.setStartAfter(r), n.collapse(!0), t.removeAllRanges(), t.addRange(n), a = !0;
}
return a ? (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;
}
}
export {
m as a
};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

import { getGlobalApiConfig as s, buildApiUrl as u, getGlobalApiHeaders as p } from "./shared-config.esm.js";
const f = () => ({
name: "document-manager",
toolbar: [
{
label: "Import Word",
command: "importWord",
icon: '<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V15h-2V9h-4V5H5c0-1.1.9-2 2-2Z"></path><path d="M9.5 7A1.5 1.5 0 0 1 11 8.4v7.1A1.5 1.5 0 0 1 9.6 17H2.5A1.5 1.5 0 0 1 1 15.6V8.5A1.5 1.5 0 0 1 2.4 7h7.1Zm-1 2.8-1 2.6-1-2.5v-.1a.6.6 0 0 0-1 0l-.1.1-.9 2.5-1-2.5v-.1a.6.6 0 0 0-1 .4v.1l1.5 4v.1a.6.6 0 0 0 1 0v-.1l1-2.5.9 2.5v.1a.6.6 0 0 0 1 0H8l1.6-4v-.2a.6.6 0 0 0-1.1-.4Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M11.4 18.2a1 1 0 0 0 1.2 1.6l1.4-1V22a1 1 0 1 0 2 0v-3.1l1.4 1a1 1 0 0 0 1.2-1.7L15 15.8l-3.6 2.4Z"></path></svg>',
type: "button"
},
{
label: "Export Word",
command: "exportWord",
icon: '<svg width="24" height="24" focusable="false"><path d="M9.5 7A1.5 1.5 0 0 1 11 8.4v7.1A1.5 1.5 0 0 1 9.6 17H2.5A1.5 1.5 0 0 1 1 15.6V8.5A1.5 1.5 0 0 1 2.4 7h7.1Zm-1 2.8-1 2.6-1-2.5v-.1a.6.6 0 0 0-1 0l-.1.1-.9 2.5-1-2.5v-.1a.6.6 0 0 0-1 .4v.1l1.5 4v.1a.6.6 0 0 0 1 0v-.1l1-2.5.9 2.5v.1a.6.6 0 0 0 1 0H8l1.6-4v-.2a.6.6 0 0 0-1.1-.4Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V17h-2V9h-4V5H7v3H5V5c0-1.1.9-2 2-2ZM15 17a1 1 0 1 0-2 0v3.1l-1.4-1a1 1 0 1 0-1.2 1.7l3.6 2.4 3.6-2.4a1 1 0 0 0-1.2-1.6l-1.4 1V17Z"></path></svg>',
type: "button"
},
{
label: "Export PDF",
command: "exportPdf",
icon: '<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V17h-2V9h-4V5H7v3H5V5c0-1.1.9-2 2-2Z"></path><path d="M2.6 15.2v-1.9h1c.6 0 1-.2 1.4-.5.3-.3.5-.7.5-1.2s-.2-.9-.5-1.2a2 2 0 0 0-1.3-.4H1v5.2h1.6Zm.4-3h-.4v-1.1h.5l.6.1.2.5c0 .1 0 .3-.2.4l-.7.1Zm5.7 3 1-.1c.3 0 .5-.2.7-.4l.5-.8c.2-.3.2-.7.2-1.3v-1l-.5-.8c-.2-.3-.4-.5-.7-.6L8.7 10H6.3v5.2h2.4Zm-.4-1.1H8v-3h.4c.5 0 .8.2 1 .4l.2 1.1-.1 1-.3.3-.8.2Zm5.3 1.2V13h2v-1h-2v-1H16V10h-4v5.2h1.6Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M15 17a1 1 0 1 0-2 0v3.1l-1.4-1a1 1 0 1 0-1.2 1.7l3.6 2.4 3.6-2.4a1 1 0 0 0-1.2-1.6l-1.4 1V17Z"></path></svg>',
type: "button"
}
],
commands: {
importWord: () => {
const r = () => {
const o = window.getSelection();
if (o && o.rangeCount > 0) {
let a = o.getRangeAt(0).startContainer;
for (; a && a !== document.body; ) {
if (a.nodeType === Node.ELEMENT_NODE) {
const i = a;
if (i.getAttribute("contenteditable") === "true")
return i;
}
a = a.parentNode;
}
}
const n = document.activeElement;
if (n?.getAttribute("contenteditable") === "true")
return n;
const e = n?.closest('[contenteditable="true"]');
return e || document.querySelector('[contenteditable="true"]');
}, t = document.createElement("input");
return t.type = "file", t.accept = ".docx", t.onchange = async (o) => {
const n = o.target.files?.[0];
if (n)
try {
const e = r();
if (e) {
const { importFromWord: a } = await import("./documentManager-DRUc1-Cs.mjs").then((d) => d.d), i = await a(n);
e.innerHTML = i, e.dispatchEvent(new Event("input", { bubbles: !0 }));
}
} catch (e) {
console.error("Import failed:", e), alert("Failed to import Word document. Please check the console for details.");
}
}, t.click(), !0;
},
exportWord: async () => {
const r = () => {
const t = window.getSelection();
if (t && t.rangeCount > 0) {
let e = t.getRangeAt(0).startContainer;
for (; e && e !== document.body; ) {
if (e.nodeType === Node.ELEMENT_NODE && e.getAttribute("contenteditable") === "true")
return e;
e = e.parentNode;
}
}
const o = document.activeElement;
return o?.getAttribute("contenteditable") === "true" ? o : o?.closest('[contenteditable="true"]') || document.querySelector('[contenteditable="true"]');
};
try {
const t = r();
if (t) {
const o = t.innerHTML, { exportToWord: n } = await import("./documentManager-DRUc1-Cs.mjs").then((e) => e.d);
await n(o, "document.docx");
}
return !0;
} catch (t) {
return console.error("Export failed:", t), alert("Failed to export to Word. Please check the console for details."), !1;
}
},
exportPdf: async () => {
const r = () => {
const t = window.getSelection();
if (t && t.rangeCount > 0) {
let e = t.getRangeAt(0).startContainer;
for (; e && e !== document.body; ) {
if (e.nodeType === Node.ELEMENT_NODE && e.getAttribute("contenteditable") === "true")
return e;
e = e.parentNode;
}
}
const o = document.activeElement;
return o?.getAttribute("contenteditable") === "true" ? o : o?.closest('[contenteditable="true"]') || document.querySelector('[contenteditable="true"]');
};
try {
const t = r();
if (t) {
const o = t.innerHTML, { exportToPdf: n } = await import("./documentManager-DRUc1-Cs.mjs").then((e) => e.d);
await n(o, "document.pdf", t);
} else
console.error("PDF Export: No editor element found"), alert("No active editor found. Please click in the editor area first.");
return !0;
} catch (t) {
return console.error("PDF Export: Export failed:", t), alert("Failed to export to PDF. Please check the console for details."), !1;
}
}
},
keymap: {}
}), h = {
apiEndpoints: {
exportWord: "/documents/export-word"
},
headers: {
// Add default headers if needed (e.g., API key)
// 'Authorization': 'Bearer YOUR_API_KEY',
// 'X-API-Key': 'YOUR_API_KEY'
},
useClientSideFallback: !0
// Enable fallback by default
};
let l = { ...h };
function v(r) {
l = { ...l, ...r };
}
function c() {
return { ...l };
}
function g(r) {
const t = c(), o = s(), n = t.apiUrl || o.apiUrl;
return u(n, t.apiEndpoints[r]);
}
function b() {
const r = p(), o = c().headers || {};
return { ...r, ...o };
}
export {
f as D,
g as a,
b,
c as g,
v as s
};
"use strict";const l=require("./shared-config.cjs.js"),s=()=>({name:"document-manager",toolbar:[{label:"Import Word",command:"importWord",icon:'<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V15h-2V9h-4V5H5c0-1.1.9-2 2-2Z"></path><path d="M9.5 7A1.5 1.5 0 0 1 11 8.4v7.1A1.5 1.5 0 0 1 9.6 17H2.5A1.5 1.5 0 0 1 1 15.6V8.5A1.5 1.5 0 0 1 2.4 7h7.1Zm-1 2.8-1 2.6-1-2.5v-.1a.6.6 0 0 0-1 0l-.1.1-.9 2.5-1-2.5v-.1a.6.6 0 0 0-1 .4v.1l1.5 4v.1a.6.6 0 0 0 1 0v-.1l1-2.5.9 2.5v.1a.6.6 0 0 0 1 0H8l1.6-4v-.2a.6.6 0 0 0-1.1-.4Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M11.4 18.2a1 1 0 0 0 1.2 1.6l1.4-1V22a1 1 0 1 0 2 0v-3.1l1.4 1a1 1 0 0 0 1.2-1.7L15 15.8l-3.6 2.4Z"></path></svg>',type:"button"},{label:"Export Word",command:"exportWord",icon:'<svg width="24" height="24" focusable="false"><path d="M9.5 7A1.5 1.5 0 0 1 11 8.4v7.1A1.5 1.5 0 0 1 9.6 17H2.5A1.5 1.5 0 0 1 1 15.6V8.5A1.5 1.5 0 0 1 2.4 7h7.1Zm-1 2.8-1 2.6-1-2.5v-.1a.6.6 0 0 0-1 0l-.1.1-.9 2.5-1-2.5v-.1a.6.6 0 0 0-1 .4v.1l1.5 4v.1a.6.6 0 0 0 1 0v-.1l1-2.5.9 2.5v.1a.6.6 0 0 0 1 0H8l1.6-4v-.2a.6.6 0 0 0-1.1-.4Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V17h-2V9h-4V5H7v3H5V5c0-1.1.9-2 2-2ZM15 17a1 1 0 1 0-2 0v3.1l-1.4-1a1 1 0 1 0-1.2 1.7l3.6 2.4 3.6-2.4a1 1 0 0 0-1.2-1.6l-1.4 1V17Z"></path></svg>',type:"button"},{label:"Export PDF",command:"exportPdf",icon:'<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M7 3h7.4L19 7.6V17h-2V9h-4V5H7v3H5V5c0-1.1.9-2 2-2Z"></path><path d="M2.6 15.2v-1.9h1c.6 0 1-.2 1.4-.5.3-.3.5-.7.5-1.2s-.2-.9-.5-1.2a2 2 0 0 0-1.3-.4H1v5.2h1.6Zm.4-3h-.4v-1.1h.5l.6.1.2.5c0 .1 0 .3-.2.4l-.7.1Zm5.7 3 1-.1c.3 0 .5-.2.7-.4l.5-.8c.2-.3.2-.7.2-1.3v-1l-.5-.8c-.2-.3-.4-.5-.7-.6L8.7 10H6.3v5.2h2.4Zm-.4-1.1H8v-3h.4c.5 0 .8.2 1 .4l.2 1.1-.1 1-.3.3-.8.2Zm5.3 1.2V13h2v-1h-2v-1H16V10h-4v5.2h1.6Z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M15 17a1 1 0 1 0-2 0v3.1l-1.4-1a1 1 0 1 0-1.2 1.7l3.6 2.4 3.6-2.4a1 1 0 0 0-1.2-1.6l-1.4 1V17Z"></path></svg>',type:"button"}],commands:{importWord:()=>{const r=()=>{const o=window.getSelection();if(o&&o.rangeCount>0){let i=o.getRangeAt(0).startContainer;for(;i&&i!==document.body;){if(i.nodeType===Node.ELEMENT_NODE){const a=i;if(a.getAttribute("contenteditable")==="true")return a}i=i.parentNode}}const n=document.activeElement;if(n?.getAttribute("contenteditable")==="true")return n;const e=n?.closest('[contenteditable="true"]');return e||document.querySelector('[contenteditable="true"]')},t=document.createElement("input");return t.type="file",t.accept=".docx",t.onchange=async o=>{const n=o.target.files?.[0];if(n)try{const e=r();if(e){const{importFromWord:i}=await Promise.resolve().then(()=>require("./documentManager-_tQQfQi9.js")).then(u=>u.documentManager),a=await i(n);e.innerHTML=a,e.dispatchEvent(new Event("input",{bubbles:!0}))}}catch(e){console.error("Import failed:",e),alert("Failed to import Word document. Please check the console for details.")}},t.click(),!0},exportWord:async()=>{const r=()=>{const t=window.getSelection();if(t&&t.rangeCount>0){let e=t.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE&&e.getAttribute("contenteditable")==="true")return e;e=e.parentNode}}const o=document.activeElement;return o?.getAttribute("contenteditable")==="true"?o:o?.closest('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]')};try{const t=r();if(t){const o=t.innerHTML,{exportToWord:n}=await Promise.resolve().then(()=>require("./documentManager-_tQQfQi9.js")).then(e=>e.documentManager);await n(o,"document.docx")}return!0}catch(t){return console.error("Export failed:",t),alert("Failed to export to Word. Please check the console for details."),!1}},exportPdf:async()=>{const r=()=>{const t=window.getSelection();if(t&&t.rangeCount>0){let e=t.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE&&e.getAttribute("contenteditable")==="true")return e;e=e.parentNode}}const o=document.activeElement;return o?.getAttribute("contenteditable")==="true"?o:o?.closest('[contenteditable="true"]')||document.querySelector('[contenteditable="true"]')};try{const t=r();if(t){const o=t.innerHTML,{exportToPdf:n}=await Promise.resolve().then(()=>require("./documentManager-_tQQfQi9.js")).then(e=>e.documentManager);await n(o,"document.pdf",t)}else console.error("PDF Export: No editor element found"),alert("No active editor found. Please click in the editor area first.");return!0}catch(t){return console.error("PDF Export: Export failed:",t),alert("Failed to export to PDF. Please check the console for details."),!1}}},keymap:{}}),p={apiEndpoints:{exportWord:"/documents/export-word"},headers:{},useClientSideFallback:!0};let c={...p};function h(r){c={...c,...r}}function d(){return{...c}}function g(r){const t=d(),o=l.getGlobalApiConfig(),n=t.apiUrl||o.apiUrl;return l.buildApiUrl(n,t.apiEndpoints[r])}function m(){const r=l.getGlobalApiHeaders(),o=d().headers||{};return{...r,...o}}exports.DocumentManagerPlugin=s;exports.getApiHeaders=m;exports.getApiUrl=g;exports.getDocumentManagerConfig=d;exports.setDocumentManagerConfig=h;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display