html-wysiwyg-editor 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +207 -0
- package/dist/index.d.ts +107 -0
- package/dist/wysiwyg-editor.css +1 -0
- package/dist/wysiwyg-editor.js +2450 -0
- package/dist/wysiwyg-editor.js.map +1 -0
- package/dist/wysiwyg-editor.umd.cjs +15 -0
- package/dist/wysiwyg-editor.umd.cjs.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,2450 @@
|
|
|
1
|
+
import { jsx as r, jsxs as k, Fragment as bt } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as p, useEffect as X, useRef as V, useState as z } from "react";
|
|
3
|
+
const {
|
|
4
|
+
entries: Yt,
|
|
5
|
+
setPrototypeOf: It,
|
|
6
|
+
isFrozen: an,
|
|
7
|
+
getPrototypeOf: ln,
|
|
8
|
+
getOwnPropertyDescriptor: cn
|
|
9
|
+
} = Object;
|
|
10
|
+
let {
|
|
11
|
+
freeze: re,
|
|
12
|
+
seal: ce,
|
|
13
|
+
create: Et
|
|
14
|
+
} = Object, {
|
|
15
|
+
apply: yt,
|
|
16
|
+
construct: Tt
|
|
17
|
+
} = typeof Reflect < "u" && Reflect;
|
|
18
|
+
re || (re = function(n) {
|
|
19
|
+
return n;
|
|
20
|
+
});
|
|
21
|
+
ce || (ce = function(n) {
|
|
22
|
+
return n;
|
|
23
|
+
});
|
|
24
|
+
yt || (yt = function(n, o) {
|
|
25
|
+
for (var c = arguments.length, d = new Array(c > 2 ? c - 2 : 0), h = 2; h < c; h++)
|
|
26
|
+
d[h - 2] = arguments[h];
|
|
27
|
+
return n.apply(o, d);
|
|
28
|
+
});
|
|
29
|
+
Tt || (Tt = function(n) {
|
|
30
|
+
for (var o = arguments.length, c = new Array(o > 1 ? o - 1 : 0), d = 1; d < o; d++)
|
|
31
|
+
c[d - 1] = arguments[d];
|
|
32
|
+
return new n(...c);
|
|
33
|
+
});
|
|
34
|
+
const et = oe(Array.prototype.forEach), un = oe(Array.prototype.lastIndexOf), Rt = oe(Array.prototype.pop), Ye = oe(Array.prototype.push), dn = oe(Array.prototype.splice), nt = oe(String.prototype.toLowerCase), ut = oe(String.prototype.toString), dt = oe(String.prototype.match), Xe = oe(String.prototype.replace), mn = oe(String.prototype.indexOf), fn = oe(String.prototype.trim), he = oe(Object.prototype.hasOwnProperty), ne = oe(RegExp.prototype.test), Ke = pn(TypeError);
|
|
35
|
+
function oe(t) {
|
|
36
|
+
return function(n) {
|
|
37
|
+
n instanceof RegExp && (n.lastIndex = 0);
|
|
38
|
+
for (var o = arguments.length, c = new Array(o > 1 ? o - 1 : 0), d = 1; d < o; d++)
|
|
39
|
+
c[d - 1] = arguments[d];
|
|
40
|
+
return yt(t, n, c);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function pn(t) {
|
|
44
|
+
return function() {
|
|
45
|
+
for (var n = arguments.length, o = new Array(n), c = 0; c < n; c++)
|
|
46
|
+
o[c] = arguments[c];
|
|
47
|
+
return Tt(t, o);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function _(t, n) {
|
|
51
|
+
let o = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : nt;
|
|
52
|
+
It && It(t, null);
|
|
53
|
+
let c = n.length;
|
|
54
|
+
for (; c--; ) {
|
|
55
|
+
let d = n[c];
|
|
56
|
+
if (typeof d == "string") {
|
|
57
|
+
const h = o(d);
|
|
58
|
+
h !== d && (an(n) || (n[c] = h), d = h);
|
|
59
|
+
}
|
|
60
|
+
t[d] = !0;
|
|
61
|
+
}
|
|
62
|
+
return t;
|
|
63
|
+
}
|
|
64
|
+
function hn(t) {
|
|
65
|
+
for (let n = 0; n < t.length; n++)
|
|
66
|
+
he(t, n) || (t[n] = null);
|
|
67
|
+
return t;
|
|
68
|
+
}
|
|
69
|
+
function ve(t) {
|
|
70
|
+
const n = Et(null);
|
|
71
|
+
for (const [o, c] of Yt(t))
|
|
72
|
+
he(t, o) && (Array.isArray(c) ? n[o] = hn(c) : c && typeof c == "object" && c.constructor === Object ? n[o] = ve(c) : n[o] = c);
|
|
73
|
+
return n;
|
|
74
|
+
}
|
|
75
|
+
function qe(t, n) {
|
|
76
|
+
for (; t !== null; ) {
|
|
77
|
+
const c = cn(t, n);
|
|
78
|
+
if (c) {
|
|
79
|
+
if (c.get)
|
|
80
|
+
return oe(c.get);
|
|
81
|
+
if (typeof c.value == "function")
|
|
82
|
+
return oe(c.value);
|
|
83
|
+
}
|
|
84
|
+
t = ln(t);
|
|
85
|
+
}
|
|
86
|
+
function o() {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return o;
|
|
90
|
+
}
|
|
91
|
+
const Pt = re(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), mt = re(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), ft = re(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), gn = re(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), pt = re(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), bn = re(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), zt = re(["#text"]), Ft = re(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]), ht = re(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), Ut = re(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), tt = re(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), En = ce(/\{\{[\w\W]*|[\w\W]*\}\}/gm), yn = ce(/<%[\w\W]*|[\w\W]*%>/gm), Tn = ce(/\$\{[\w\W]*/gm), vn = ce(/^data-[\-\w.\u00B7-\uFFFF]+$/), Nn = ce(/^aria-[\-\w]+$/), Xt = ce(
|
|
92
|
+
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
|
|
93
|
+
// eslint-disable-line no-useless-escape
|
|
94
|
+
), An = ce(/^(?:\w+script|data):/i), kn = ce(
|
|
95
|
+
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
|
|
96
|
+
// eslint-disable-line no-control-regex
|
|
97
|
+
), Kt = ce(/^html$/i), wn = ce(/^[a-z][.\w]*(-[.\w]+)+$/i);
|
|
98
|
+
var Bt = /* @__PURE__ */ Object.freeze({
|
|
99
|
+
__proto__: null,
|
|
100
|
+
ARIA_ATTR: Nn,
|
|
101
|
+
ATTR_WHITESPACE: kn,
|
|
102
|
+
CUSTOM_ELEMENT: wn,
|
|
103
|
+
DATA_ATTR: vn,
|
|
104
|
+
DOCTYPE_NAME: Kt,
|
|
105
|
+
ERB_EXPR: yn,
|
|
106
|
+
IS_ALLOWED_URI: Xt,
|
|
107
|
+
IS_SCRIPT_OR_DATA: An,
|
|
108
|
+
MUSTACHE_EXPR: En,
|
|
109
|
+
TMPLIT_EXPR: Tn
|
|
110
|
+
});
|
|
111
|
+
const Ve = {
|
|
112
|
+
element: 1,
|
|
113
|
+
text: 3,
|
|
114
|
+
// Deprecated
|
|
115
|
+
progressingInstruction: 7,
|
|
116
|
+
comment: 8,
|
|
117
|
+
document: 9
|
|
118
|
+
}, Cn = function() {
|
|
119
|
+
return typeof window > "u" ? null : window;
|
|
120
|
+
}, Sn = function(n, o) {
|
|
121
|
+
if (typeof n != "object" || typeof n.createPolicy != "function")
|
|
122
|
+
return null;
|
|
123
|
+
let c = null;
|
|
124
|
+
const d = "data-tt-policy-suffix";
|
|
125
|
+
o && o.hasAttribute(d) && (c = o.getAttribute(d));
|
|
126
|
+
const h = "dompurify" + (c ? "#" + c : "");
|
|
127
|
+
try {
|
|
128
|
+
return n.createPolicy(h, {
|
|
129
|
+
createHTML(u) {
|
|
130
|
+
return u;
|
|
131
|
+
},
|
|
132
|
+
createScriptURL(u) {
|
|
133
|
+
return u;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
} catch {
|
|
137
|
+
return console.warn("TrustedTypes policy " + h + " could not be created."), null;
|
|
138
|
+
}
|
|
139
|
+
}, Ht = function() {
|
|
140
|
+
return {
|
|
141
|
+
afterSanitizeAttributes: [],
|
|
142
|
+
afterSanitizeElements: [],
|
|
143
|
+
afterSanitizeShadowDOM: [],
|
|
144
|
+
beforeSanitizeAttributes: [],
|
|
145
|
+
beforeSanitizeElements: [],
|
|
146
|
+
beforeSanitizeShadowDOM: [],
|
|
147
|
+
uponSanitizeAttribute: [],
|
|
148
|
+
uponSanitizeElement: [],
|
|
149
|
+
uponSanitizeShadowNode: []
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
function qt() {
|
|
153
|
+
let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Cn();
|
|
154
|
+
const n = (E) => qt(E);
|
|
155
|
+
if (n.version = "3.3.1", n.removed = [], !t || !t.document || t.document.nodeType !== Ve.document || !t.Element)
|
|
156
|
+
return n.isSupported = !1, n;
|
|
157
|
+
let {
|
|
158
|
+
document: o
|
|
159
|
+
} = t;
|
|
160
|
+
const c = o, d = c.currentScript, {
|
|
161
|
+
DocumentFragment: h,
|
|
162
|
+
HTMLTemplateElement: u,
|
|
163
|
+
Node: y,
|
|
164
|
+
Element: b,
|
|
165
|
+
NodeFilter: f,
|
|
166
|
+
NamedNodeMap: N = t.NamedNodeMap || t.MozNamedAttrMap,
|
|
167
|
+
HTMLFormElement: T,
|
|
168
|
+
DOMParser: x,
|
|
169
|
+
trustedTypes: A
|
|
170
|
+
} = t, a = b.prototype, i = qe(a, "cloneNode"), v = qe(a, "remove"), F = qe(a, "nextSibling"), q = qe(a, "childNodes"), B = qe(a, "parentNode");
|
|
171
|
+
if (typeof u == "function") {
|
|
172
|
+
const E = o.createElement("template");
|
|
173
|
+
E.content && E.content.ownerDocument && (o = E.content.ownerDocument);
|
|
174
|
+
}
|
|
175
|
+
let L, H = "";
|
|
176
|
+
const {
|
|
177
|
+
implementation: Z,
|
|
178
|
+
createNodeIterator: W,
|
|
179
|
+
createDocumentFragment: Q,
|
|
180
|
+
getElementsByTagName: ue
|
|
181
|
+
} = o, {
|
|
182
|
+
importNode: de
|
|
183
|
+
} = c;
|
|
184
|
+
let R = Ht();
|
|
185
|
+
n.isSupported = typeof Yt == "function" && typeof B == "function" && Z && Z.createHTMLDocument !== void 0;
|
|
186
|
+
const {
|
|
187
|
+
MUSTACHE_EXPR: J,
|
|
188
|
+
ERB_EXPR: ae,
|
|
189
|
+
TMPLIT_EXPR: ge,
|
|
190
|
+
DATA_ATTR: _e,
|
|
191
|
+
ARIA_ATTR: be,
|
|
192
|
+
IS_SCRIPT_OR_DATA: l,
|
|
193
|
+
ATTR_WHITESPACE: m,
|
|
194
|
+
CUSTOM_ELEMENT: D
|
|
195
|
+
} = Bt;
|
|
196
|
+
let {
|
|
197
|
+
IS_ALLOWED_URI: M
|
|
198
|
+
} = Bt, C = null;
|
|
199
|
+
const $ = _({}, [...Pt, ...mt, ...ft, ...pt, ...zt]);
|
|
200
|
+
let G = null;
|
|
201
|
+
const Fe = _({}, [...Ft, ...ht, ...Ut, ...tt]);
|
|
202
|
+
let O = Object.seal(Et(null, {
|
|
203
|
+
tagNameCheck: {
|
|
204
|
+
writable: !0,
|
|
205
|
+
configurable: !1,
|
|
206
|
+
enumerable: !0,
|
|
207
|
+
value: null
|
|
208
|
+
},
|
|
209
|
+
attributeNameCheck: {
|
|
210
|
+
writable: !0,
|
|
211
|
+
configurable: !1,
|
|
212
|
+
enumerable: !0,
|
|
213
|
+
value: null
|
|
214
|
+
},
|
|
215
|
+
allowCustomizedBuiltInElements: {
|
|
216
|
+
writable: !0,
|
|
217
|
+
configurable: !1,
|
|
218
|
+
enumerable: !0,
|
|
219
|
+
value: !1
|
|
220
|
+
}
|
|
221
|
+
})), Ne = null, De = null;
|
|
222
|
+
const me = Object.seal(Et(null, {
|
|
223
|
+
tagCheck: {
|
|
224
|
+
writable: !0,
|
|
225
|
+
configurable: !1,
|
|
226
|
+
enumerable: !0,
|
|
227
|
+
value: null
|
|
228
|
+
},
|
|
229
|
+
attributeCheck: {
|
|
230
|
+
writable: !0,
|
|
231
|
+
configurable: !1,
|
|
232
|
+
enumerable: !0,
|
|
233
|
+
value: null
|
|
234
|
+
}
|
|
235
|
+
}));
|
|
236
|
+
let Me = !0, Oe = !0, Ue = !1, Ie = !0, fe = !1, Ae = !0, w = !1, I = !1, ee = !1, pe = !1, le = !1, Le = !1, Re = !0, Ee = !1;
|
|
237
|
+
const Pe = "user-content-";
|
|
238
|
+
let ke = !0, se = !1, xe = {}, S = null;
|
|
239
|
+
const P = _({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
|
|
240
|
+
let Ge = null;
|
|
241
|
+
const rt = _({}, ["audio", "video", "img", "source", "image", "track"]);
|
|
242
|
+
let ot = null;
|
|
243
|
+
const vt = _({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), je = "http://www.w3.org/1998/Math/MathML", Ze = "http://www.w3.org/2000/svg", we = "http://www.w3.org/1999/xhtml";
|
|
244
|
+
let Be = we, it = !1, st = null;
|
|
245
|
+
const Jt = _({}, [je, Ze, we], ut);
|
|
246
|
+
let Qe = _({}, ["mi", "mo", "mn", "ms", "mtext"]), Je = _({}, ["annotation-xml"]);
|
|
247
|
+
const en = _({}, ["title", "style", "font", "a", "script"]);
|
|
248
|
+
let $e = null;
|
|
249
|
+
const tn = ["application/xhtml+xml", "text/html"], nn = "text/html";
|
|
250
|
+
let K = null, He = null;
|
|
251
|
+
const rn = o.createElement("form"), Nt = function(e) {
|
|
252
|
+
return e instanceof RegExp || e instanceof Function;
|
|
253
|
+
}, at = function() {
|
|
254
|
+
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
255
|
+
if (!(He && He === e)) {
|
|
256
|
+
if ((!e || typeof e != "object") && (e = {}), e = ve(e), $e = // eslint-disable-next-line unicorn/prefer-includes
|
|
257
|
+
tn.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? nn : e.PARSER_MEDIA_TYPE, K = $e === "application/xhtml+xml" ? ut : nt, C = he(e, "ALLOWED_TAGS") ? _({}, e.ALLOWED_TAGS, K) : $, G = he(e, "ALLOWED_ATTR") ? _({}, e.ALLOWED_ATTR, K) : Fe, st = he(e, "ALLOWED_NAMESPACES") ? _({}, e.ALLOWED_NAMESPACES, ut) : Jt, ot = he(e, "ADD_URI_SAFE_ATTR") ? _(ve(vt), e.ADD_URI_SAFE_ATTR, K) : vt, Ge = he(e, "ADD_DATA_URI_TAGS") ? _(ve(rt), e.ADD_DATA_URI_TAGS, K) : rt, S = he(e, "FORBID_CONTENTS") ? _({}, e.FORBID_CONTENTS, K) : P, Ne = he(e, "FORBID_TAGS") ? _({}, e.FORBID_TAGS, K) : ve({}), De = he(e, "FORBID_ATTR") ? _({}, e.FORBID_ATTR, K) : ve({}), xe = he(e, "USE_PROFILES") ? e.USE_PROFILES : !1, Me = e.ALLOW_ARIA_ATTR !== !1, Oe = e.ALLOW_DATA_ATTR !== !1, Ue = e.ALLOW_UNKNOWN_PROTOCOLS || !1, Ie = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, fe = e.SAFE_FOR_TEMPLATES || !1, Ae = e.SAFE_FOR_XML !== !1, w = e.WHOLE_DOCUMENT || !1, pe = e.RETURN_DOM || !1, le = e.RETURN_DOM_FRAGMENT || !1, Le = e.RETURN_TRUSTED_TYPE || !1, ee = e.FORCE_BODY || !1, Re = e.SANITIZE_DOM !== !1, Ee = e.SANITIZE_NAMED_PROPS || !1, ke = e.KEEP_CONTENT !== !1, se = e.IN_PLACE || !1, M = e.ALLOWED_URI_REGEXP || Xt, Be = e.NAMESPACE || we, Qe = e.MATHML_TEXT_INTEGRATION_POINTS || Qe, Je = e.HTML_INTEGRATION_POINTS || Je, O = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && Nt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (O.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && Nt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (O.attributeNameCheck = e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (O.allowCustomizedBuiltInElements = e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), fe && (Oe = !1), le && (pe = !0), xe && (C = _({}, zt), G = [], xe.html === !0 && (_(C, Pt), _(G, Ft)), xe.svg === !0 && (_(C, mt), _(G, ht), _(G, tt)), xe.svgFilters === !0 && (_(C, ft), _(G, ht), _(G, tt)), xe.mathMl === !0 && (_(C, pt), _(G, Ut), _(G, tt))), e.ADD_TAGS && (typeof e.ADD_TAGS == "function" ? me.tagCheck = e.ADD_TAGS : (C === $ && (C = ve(C)), _(C, e.ADD_TAGS, K))), e.ADD_ATTR && (typeof e.ADD_ATTR == "function" ? me.attributeCheck = e.ADD_ATTR : (G === Fe && (G = ve(G)), _(G, e.ADD_ATTR, K))), e.ADD_URI_SAFE_ATTR && _(ot, e.ADD_URI_SAFE_ATTR, K), e.FORBID_CONTENTS && (S === P && (S = ve(S)), _(S, e.FORBID_CONTENTS, K)), e.ADD_FORBID_CONTENTS && (S === P && (S = ve(S)), _(S, e.ADD_FORBID_CONTENTS, K)), ke && (C["#text"] = !0), w && _(C, ["html", "head", "body"]), C.table && (_(C, ["tbody"]), delete Ne.tbody), e.TRUSTED_TYPES_POLICY) {
|
|
258
|
+
if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function")
|
|
259
|
+
throw Ke('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
|
|
260
|
+
if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function")
|
|
261
|
+
throw Ke('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
|
|
262
|
+
L = e.TRUSTED_TYPES_POLICY, H = L.createHTML("");
|
|
263
|
+
} else
|
|
264
|
+
L === void 0 && (L = Sn(A, d)), L !== null && typeof H == "string" && (H = L.createHTML(""));
|
|
265
|
+
re && re(e), He = e;
|
|
266
|
+
}
|
|
267
|
+
}, At = _({}, [...mt, ...ft, ...gn]), kt = _({}, [...pt, ...bn]), on = function(e) {
|
|
268
|
+
let s = B(e);
|
|
269
|
+
(!s || !s.tagName) && (s = {
|
|
270
|
+
namespaceURI: Be,
|
|
271
|
+
tagName: "template"
|
|
272
|
+
});
|
|
273
|
+
const g = nt(e.tagName), U = nt(s.tagName);
|
|
274
|
+
return st[e.namespaceURI] ? e.namespaceURI === Ze ? s.namespaceURI === we ? g === "svg" : s.namespaceURI === je ? g === "svg" && (U === "annotation-xml" || Qe[U]) : !!At[g] : e.namespaceURI === je ? s.namespaceURI === we ? g === "math" : s.namespaceURI === Ze ? g === "math" && Je[U] : !!kt[g] : e.namespaceURI === we ? s.namespaceURI === Ze && !Je[U] || s.namespaceURI === je && !Qe[U] ? !1 : !kt[g] && (en[g] || !At[g]) : !!($e === "application/xhtml+xml" && st[e.namespaceURI]) : !1;
|
|
275
|
+
}, ye = function(e) {
|
|
276
|
+
Ye(n.removed, {
|
|
277
|
+
element: e
|
|
278
|
+
});
|
|
279
|
+
try {
|
|
280
|
+
B(e).removeChild(e);
|
|
281
|
+
} catch {
|
|
282
|
+
v(e);
|
|
283
|
+
}
|
|
284
|
+
}, ze = function(e, s) {
|
|
285
|
+
try {
|
|
286
|
+
Ye(n.removed, {
|
|
287
|
+
attribute: s.getAttributeNode(e),
|
|
288
|
+
from: s
|
|
289
|
+
});
|
|
290
|
+
} catch {
|
|
291
|
+
Ye(n.removed, {
|
|
292
|
+
attribute: null,
|
|
293
|
+
from: s
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
if (s.removeAttribute(e), e === "is")
|
|
297
|
+
if (pe || le)
|
|
298
|
+
try {
|
|
299
|
+
ye(s);
|
|
300
|
+
} catch {
|
|
301
|
+
}
|
|
302
|
+
else
|
|
303
|
+
try {
|
|
304
|
+
s.setAttribute(e, "");
|
|
305
|
+
} catch {
|
|
306
|
+
}
|
|
307
|
+
}, wt = function(e) {
|
|
308
|
+
let s = null, g = null;
|
|
309
|
+
if (ee)
|
|
310
|
+
e = "<remove></remove>" + e;
|
|
311
|
+
else {
|
|
312
|
+
const Y = dt(e, /^[\r\n\t ]+/);
|
|
313
|
+
g = Y && Y[0];
|
|
314
|
+
}
|
|
315
|
+
$e === "application/xhtml+xml" && Be === we && (e = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + e + "</body></html>");
|
|
316
|
+
const U = L ? L.createHTML(e) : e;
|
|
317
|
+
if (Be === we)
|
|
318
|
+
try {
|
|
319
|
+
s = new x().parseFromString(U, $e);
|
|
320
|
+
} catch {
|
|
321
|
+
}
|
|
322
|
+
if (!s || !s.documentElement) {
|
|
323
|
+
s = Z.createDocument(Be, "template", null);
|
|
324
|
+
try {
|
|
325
|
+
s.documentElement.innerHTML = it ? H : U;
|
|
326
|
+
} catch {
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
const te = s.body || s.documentElement;
|
|
330
|
+
return e && g && te.insertBefore(o.createTextNode(g), te.childNodes[0] || null), Be === we ? ue.call(s, w ? "html" : "body")[0] : w ? s.documentElement : te;
|
|
331
|
+
}, Ct = function(e) {
|
|
332
|
+
return W.call(
|
|
333
|
+
e.ownerDocument || e,
|
|
334
|
+
e,
|
|
335
|
+
// eslint-disable-next-line no-bitwise
|
|
336
|
+
f.SHOW_ELEMENT | f.SHOW_COMMENT | f.SHOW_TEXT | f.SHOW_PROCESSING_INSTRUCTION | f.SHOW_CDATA_SECTION,
|
|
337
|
+
null
|
|
338
|
+
);
|
|
339
|
+
}, lt = function(e) {
|
|
340
|
+
return e instanceof T && (typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || !(e.attributes instanceof N) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function");
|
|
341
|
+
}, St = function(e) {
|
|
342
|
+
return typeof y == "function" && e instanceof y;
|
|
343
|
+
};
|
|
344
|
+
function Ce(E, e, s) {
|
|
345
|
+
et(E, (g) => {
|
|
346
|
+
g.call(n, e, s, He);
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
const _t = function(e) {
|
|
350
|
+
let s = null;
|
|
351
|
+
if (Ce(R.beforeSanitizeElements, e, null), lt(e))
|
|
352
|
+
return ye(e), !0;
|
|
353
|
+
const g = K(e.nodeName);
|
|
354
|
+
if (Ce(R.uponSanitizeElement, e, {
|
|
355
|
+
tagName: g,
|
|
356
|
+
allowedTags: C
|
|
357
|
+
}), Ae && e.hasChildNodes() && !St(e.firstElementChild) && ne(/<[/\w!]/g, e.innerHTML) && ne(/<[/\w!]/g, e.textContent) || e.nodeType === Ve.progressingInstruction || Ae && e.nodeType === Ve.comment && ne(/<[/\w]/g, e.data))
|
|
358
|
+
return ye(e), !0;
|
|
359
|
+
if (!(me.tagCheck instanceof Function && me.tagCheck(g)) && (!C[g] || Ne[g])) {
|
|
360
|
+
if (!Ne[g] && xt(g) && (O.tagNameCheck instanceof RegExp && ne(O.tagNameCheck, g) || O.tagNameCheck instanceof Function && O.tagNameCheck(g)))
|
|
361
|
+
return !1;
|
|
362
|
+
if (ke && !S[g]) {
|
|
363
|
+
const U = B(e) || e.parentNode, te = q(e) || e.childNodes;
|
|
364
|
+
if (te && U) {
|
|
365
|
+
const Y = te.length;
|
|
366
|
+
for (let ie = Y - 1; ie >= 0; --ie) {
|
|
367
|
+
const Se = i(te[ie], !0);
|
|
368
|
+
Se.__removalCount = (e.__removalCount || 0) + 1, U.insertBefore(Se, F(e));
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return ye(e), !0;
|
|
373
|
+
}
|
|
374
|
+
return e instanceof b && !on(e) || (g === "noscript" || g === "noembed" || g === "noframes") && ne(/<\/no(script|embed|frames)/i, e.innerHTML) ? (ye(e), !0) : (fe && e.nodeType === Ve.text && (s = e.textContent, et([J, ae, ge], (U) => {
|
|
375
|
+
s = Xe(s, U, " ");
|
|
376
|
+
}), e.textContent !== s && (Ye(n.removed, {
|
|
377
|
+
element: e.cloneNode()
|
|
378
|
+
}), e.textContent = s)), Ce(R.afterSanitizeElements, e, null), !1);
|
|
379
|
+
}, Lt = function(e, s, g) {
|
|
380
|
+
if (Re && (s === "id" || s === "name") && (g in o || g in rn))
|
|
381
|
+
return !1;
|
|
382
|
+
if (!(Oe && !De[s] && ne(_e, s))) {
|
|
383
|
+
if (!(Me && ne(be, s))) {
|
|
384
|
+
if (!(me.attributeCheck instanceof Function && me.attributeCheck(s, e))) {
|
|
385
|
+
if (!G[s] || De[s]) {
|
|
386
|
+
if (
|
|
387
|
+
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
|
|
388
|
+
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
389
|
+
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
|
|
390
|
+
!(xt(e) && (O.tagNameCheck instanceof RegExp && ne(O.tagNameCheck, e) || O.tagNameCheck instanceof Function && O.tagNameCheck(e)) && (O.attributeNameCheck instanceof RegExp && ne(O.attributeNameCheck, s) || O.attributeNameCheck instanceof Function && O.attributeNameCheck(s, e)) || // Alternative, second condition checks if it's an `is`-attribute, AND
|
|
391
|
+
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
|
|
392
|
+
s === "is" && O.allowCustomizedBuiltInElements && (O.tagNameCheck instanceof RegExp && ne(O.tagNameCheck, g) || O.tagNameCheck instanceof Function && O.tagNameCheck(g)))
|
|
393
|
+
) return !1;
|
|
394
|
+
} else if (!ot[s]) {
|
|
395
|
+
if (!ne(M, Xe(g, m, ""))) {
|
|
396
|
+
if (!((s === "src" || s === "xlink:href" || s === "href") && e !== "script" && mn(g, "data:") === 0 && Ge[e])) {
|
|
397
|
+
if (!(Ue && !ne(l, Xe(g, m, "")))) {
|
|
398
|
+
if (g)
|
|
399
|
+
return !1;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return !0;
|
|
408
|
+
}, xt = function(e) {
|
|
409
|
+
return e !== "annotation-xml" && dt(e, D);
|
|
410
|
+
}, Dt = function(e) {
|
|
411
|
+
Ce(R.beforeSanitizeAttributes, e, null);
|
|
412
|
+
const {
|
|
413
|
+
attributes: s
|
|
414
|
+
} = e;
|
|
415
|
+
if (!s || lt(e))
|
|
416
|
+
return;
|
|
417
|
+
const g = {
|
|
418
|
+
attrName: "",
|
|
419
|
+
attrValue: "",
|
|
420
|
+
keepAttr: !0,
|
|
421
|
+
allowedAttributes: G,
|
|
422
|
+
forceKeepAttr: void 0
|
|
423
|
+
};
|
|
424
|
+
let U = s.length;
|
|
425
|
+
for (; U--; ) {
|
|
426
|
+
const te = s[U], {
|
|
427
|
+
name: Y,
|
|
428
|
+
namespaceURI: ie,
|
|
429
|
+
value: Se
|
|
430
|
+
} = te, We = K(Y), ct = Se;
|
|
431
|
+
let j = Y === "value" ? ct : fn(ct);
|
|
432
|
+
if (g.attrName = We, g.attrValue = j, g.keepAttr = !0, g.forceKeepAttr = void 0, Ce(R.uponSanitizeAttribute, e, g), j = g.attrValue, Ee && (We === "id" || We === "name") && (ze(Y, e), j = Pe + j), Ae && ne(/((--!?|])>)|<\/(style|title|textarea)/i, j)) {
|
|
433
|
+
ze(Y, e);
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
if (We === "attributename" && dt(j, "href")) {
|
|
437
|
+
ze(Y, e);
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
if (g.forceKeepAttr)
|
|
441
|
+
continue;
|
|
442
|
+
if (!g.keepAttr) {
|
|
443
|
+
ze(Y, e);
|
|
444
|
+
continue;
|
|
445
|
+
}
|
|
446
|
+
if (!Ie && ne(/\/>/i, j)) {
|
|
447
|
+
ze(Y, e);
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
fe && et([J, ae, ge], (Ot) => {
|
|
451
|
+
j = Xe(j, Ot, " ");
|
|
452
|
+
});
|
|
453
|
+
const Mt = K(e.nodeName);
|
|
454
|
+
if (!Lt(Mt, We, j)) {
|
|
455
|
+
ze(Y, e);
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
if (L && typeof A == "object" && typeof A.getAttributeType == "function" && !ie)
|
|
459
|
+
switch (A.getAttributeType(Mt, We)) {
|
|
460
|
+
case "TrustedHTML": {
|
|
461
|
+
j = L.createHTML(j);
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
case "TrustedScriptURL": {
|
|
465
|
+
j = L.createScriptURL(j);
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
if (j !== ct)
|
|
470
|
+
try {
|
|
471
|
+
ie ? e.setAttributeNS(ie, Y, j) : e.setAttribute(Y, j), lt(e) ? ye(e) : Rt(n.removed);
|
|
472
|
+
} catch {
|
|
473
|
+
ze(Y, e);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
Ce(R.afterSanitizeAttributes, e, null);
|
|
477
|
+
}, sn = function E(e) {
|
|
478
|
+
let s = null;
|
|
479
|
+
const g = Ct(e);
|
|
480
|
+
for (Ce(R.beforeSanitizeShadowDOM, e, null); s = g.nextNode(); )
|
|
481
|
+
Ce(R.uponSanitizeShadowNode, s, null), _t(s), Dt(s), s.content instanceof h && E(s.content);
|
|
482
|
+
Ce(R.afterSanitizeShadowDOM, e, null);
|
|
483
|
+
};
|
|
484
|
+
return n.sanitize = function(E) {
|
|
485
|
+
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, s = null, g = null, U = null, te = null;
|
|
486
|
+
if (it = !E, it && (E = "<!-->"), typeof E != "string" && !St(E))
|
|
487
|
+
if (typeof E.toString == "function") {
|
|
488
|
+
if (E = E.toString(), typeof E != "string")
|
|
489
|
+
throw Ke("dirty is not a string, aborting");
|
|
490
|
+
} else
|
|
491
|
+
throw Ke("toString is not a function");
|
|
492
|
+
if (!n.isSupported)
|
|
493
|
+
return E;
|
|
494
|
+
if (I || at(e), n.removed = [], typeof E == "string" && (se = !1), se) {
|
|
495
|
+
if (E.nodeName) {
|
|
496
|
+
const Se = K(E.nodeName);
|
|
497
|
+
if (!C[Se] || Ne[Se])
|
|
498
|
+
throw Ke("root node is forbidden and cannot be sanitized in-place");
|
|
499
|
+
}
|
|
500
|
+
} else if (E instanceof y)
|
|
501
|
+
s = wt("<!---->"), g = s.ownerDocument.importNode(E, !0), g.nodeType === Ve.element && g.nodeName === "BODY" || g.nodeName === "HTML" ? s = g : s.appendChild(g);
|
|
502
|
+
else {
|
|
503
|
+
if (!pe && !fe && !w && // eslint-disable-next-line unicorn/prefer-includes
|
|
504
|
+
E.indexOf("<") === -1)
|
|
505
|
+
return L && Le ? L.createHTML(E) : E;
|
|
506
|
+
if (s = wt(E), !s)
|
|
507
|
+
return pe ? null : Le ? H : "";
|
|
508
|
+
}
|
|
509
|
+
s && ee && ye(s.firstChild);
|
|
510
|
+
const Y = Ct(se ? E : s);
|
|
511
|
+
for (; U = Y.nextNode(); )
|
|
512
|
+
_t(U), Dt(U), U.content instanceof h && sn(U.content);
|
|
513
|
+
if (se)
|
|
514
|
+
return E;
|
|
515
|
+
if (pe) {
|
|
516
|
+
if (le)
|
|
517
|
+
for (te = Q.call(s.ownerDocument); s.firstChild; )
|
|
518
|
+
te.appendChild(s.firstChild);
|
|
519
|
+
else
|
|
520
|
+
te = s;
|
|
521
|
+
return (G.shadowroot || G.shadowrootmode) && (te = de.call(c, te, !0)), te;
|
|
522
|
+
}
|
|
523
|
+
let ie = w ? s.outerHTML : s.innerHTML;
|
|
524
|
+
return w && C["!doctype"] && s.ownerDocument && s.ownerDocument.doctype && s.ownerDocument.doctype.name && ne(Kt, s.ownerDocument.doctype.name) && (ie = "<!DOCTYPE " + s.ownerDocument.doctype.name + `>
|
|
525
|
+
` + ie), fe && et([J, ae, ge], (Se) => {
|
|
526
|
+
ie = Xe(ie, Se, " ");
|
|
527
|
+
}), L && Le ? L.createHTML(ie) : ie;
|
|
528
|
+
}, n.setConfig = function() {
|
|
529
|
+
let E = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
530
|
+
at(E), I = !0;
|
|
531
|
+
}, n.clearConfig = function() {
|
|
532
|
+
He = null, I = !1;
|
|
533
|
+
}, n.isValidAttribute = function(E, e, s) {
|
|
534
|
+
He || at({});
|
|
535
|
+
const g = K(E), U = K(e);
|
|
536
|
+
return Lt(g, U, s);
|
|
537
|
+
}, n.addHook = function(E, e) {
|
|
538
|
+
typeof e == "function" && Ye(R[E], e);
|
|
539
|
+
}, n.removeHook = function(E, e) {
|
|
540
|
+
if (e !== void 0) {
|
|
541
|
+
const s = un(R[E], e);
|
|
542
|
+
return s === -1 ? void 0 : dn(R[E], s, 1)[0];
|
|
543
|
+
}
|
|
544
|
+
return Rt(R[E]);
|
|
545
|
+
}, n.removeHooks = function(E) {
|
|
546
|
+
R[E] = [];
|
|
547
|
+
}, n.removeAllHooks = function() {
|
|
548
|
+
R = Ht();
|
|
549
|
+
}, n;
|
|
550
|
+
}
|
|
551
|
+
var Vt = qt();
|
|
552
|
+
const jt = [
|
|
553
|
+
// Text formatting
|
|
554
|
+
"p",
|
|
555
|
+
"br",
|
|
556
|
+
"span",
|
|
557
|
+
"div",
|
|
558
|
+
"strong",
|
|
559
|
+
"b",
|
|
560
|
+
"em",
|
|
561
|
+
"i",
|
|
562
|
+
"u",
|
|
563
|
+
"s",
|
|
564
|
+
"strike",
|
|
565
|
+
"del",
|
|
566
|
+
"ins",
|
|
567
|
+
"sub",
|
|
568
|
+
"sup",
|
|
569
|
+
"mark",
|
|
570
|
+
// Headings
|
|
571
|
+
"h1",
|
|
572
|
+
"h2",
|
|
573
|
+
"h3",
|
|
574
|
+
"h4",
|
|
575
|
+
"h5",
|
|
576
|
+
"h6",
|
|
577
|
+
// Lists
|
|
578
|
+
"ul",
|
|
579
|
+
"ol",
|
|
580
|
+
"li",
|
|
581
|
+
// Links & media
|
|
582
|
+
"a",
|
|
583
|
+
"img",
|
|
584
|
+
"video",
|
|
585
|
+
"source",
|
|
586
|
+
"picture",
|
|
587
|
+
"figure",
|
|
588
|
+
"figcaption",
|
|
589
|
+
// Tables
|
|
590
|
+
"table",
|
|
591
|
+
"thead",
|
|
592
|
+
"tbody",
|
|
593
|
+
"tfoot",
|
|
594
|
+
"tr",
|
|
595
|
+
"th",
|
|
596
|
+
"td",
|
|
597
|
+
"caption",
|
|
598
|
+
"colgroup",
|
|
599
|
+
"col",
|
|
600
|
+
// Block elements
|
|
601
|
+
"blockquote",
|
|
602
|
+
"pre",
|
|
603
|
+
"code",
|
|
604
|
+
"hr",
|
|
605
|
+
// Other
|
|
606
|
+
"address",
|
|
607
|
+
"article",
|
|
608
|
+
"aside",
|
|
609
|
+
"details",
|
|
610
|
+
"summary",
|
|
611
|
+
"section",
|
|
612
|
+
"nav",
|
|
613
|
+
"header",
|
|
614
|
+
"footer",
|
|
615
|
+
"main"
|
|
616
|
+
], Zt = [
|
|
617
|
+
// Global attributes
|
|
618
|
+
"id",
|
|
619
|
+
"class",
|
|
620
|
+
"style",
|
|
621
|
+
"title",
|
|
622
|
+
"lang",
|
|
623
|
+
"dir",
|
|
624
|
+
// Links
|
|
625
|
+
"href",
|
|
626
|
+
"target",
|
|
627
|
+
"rel",
|
|
628
|
+
// Media
|
|
629
|
+
"src",
|
|
630
|
+
"alt",
|
|
631
|
+
"width",
|
|
632
|
+
"height",
|
|
633
|
+
"loading",
|
|
634
|
+
"srcset",
|
|
635
|
+
"sizes",
|
|
636
|
+
// Video
|
|
637
|
+
"controls",
|
|
638
|
+
"autoplay",
|
|
639
|
+
"loop",
|
|
640
|
+
"muted",
|
|
641
|
+
"poster",
|
|
642
|
+
"preload",
|
|
643
|
+
// Tables
|
|
644
|
+
"colspan",
|
|
645
|
+
"rowspan",
|
|
646
|
+
"scope",
|
|
647
|
+
"headers",
|
|
648
|
+
// Data attributes (for editor tracking)
|
|
649
|
+
"data-*"
|
|
650
|
+
];
|
|
651
|
+
function gt(t) {
|
|
652
|
+
return Vt.sanitize(t, {
|
|
653
|
+
ALLOWED_TAGS: jt,
|
|
654
|
+
ALLOWED_ATTR: Zt,
|
|
655
|
+
ALLOW_DATA_ATTR: !0,
|
|
656
|
+
// Keep safe URLs only
|
|
657
|
+
ALLOWED_URI_REGEXP: /^(?:(?:https?|mailto|tel):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
function _n(t) {
|
|
661
|
+
return Vt.sanitize(t, {
|
|
662
|
+
ALLOWED_TAGS: jt,
|
|
663
|
+
ALLOWED_ATTR: Zt.filter((o) => !o.startsWith("data-")),
|
|
664
|
+
ALLOW_DATA_ATTR: !1
|
|
665
|
+
}).replace(/<p>\s*<\/p>/gi, "").replace(/<br\s*\/?>\s*$/gi, "").trim();
|
|
666
|
+
}
|
|
667
|
+
function Ln(t) {
|
|
668
|
+
return [
|
|
669
|
+
/<script\b/i,
|
|
670
|
+
/javascript:/i,
|
|
671
|
+
/on\w+\s*=/i,
|
|
672
|
+
// onclick, onerror, etc.
|
|
673
|
+
/<iframe\b/i,
|
|
674
|
+
/<object\b/i,
|
|
675
|
+
/<embed\b/i,
|
|
676
|
+
/data:text\/html/i
|
|
677
|
+
].some((o) => o.test(t));
|
|
678
|
+
}
|
|
679
|
+
function xn({ editorRef: t, onContentChange: n }) {
|
|
680
|
+
const o = p((l) => {
|
|
681
|
+
t.current && document.activeElement !== t.current && t.current.focus(), document.execCommand(l, !1), n();
|
|
682
|
+
}, [t, n]), c = p((l) => document.queryCommandState(l), []), d = p(() => {
|
|
683
|
+
const l = window.getSelection();
|
|
684
|
+
if (!l || !l.rangeCount) return "p";
|
|
685
|
+
let m = l.anchorNode;
|
|
686
|
+
for (; m && m !== t.current; ) {
|
|
687
|
+
if (m.nodeType === Node.ELEMENT_NODE) {
|
|
688
|
+
const D = m.tagName.toLowerCase();
|
|
689
|
+
if (["h1", "h2", "h3", "h4", "h5", "h6", "p"].includes(D))
|
|
690
|
+
return D;
|
|
691
|
+
}
|
|
692
|
+
m = m.parentNode;
|
|
693
|
+
}
|
|
694
|
+
return "p";
|
|
695
|
+
}, [t]), h = p((l) => {
|
|
696
|
+
t.current && document.activeElement !== t.current && t.current.focus(), document.execCommand("formatBlock", !1, l), n();
|
|
697
|
+
}, [t, n]), u = p((l) => {
|
|
698
|
+
t.current && document.activeElement !== t.current && t.current.focus(), document.execCommand(l, !1), n();
|
|
699
|
+
}, [t, n]), y = p((l) => {
|
|
700
|
+
const m = window.getSelection();
|
|
701
|
+
if (!m || !m.rangeCount) return !1;
|
|
702
|
+
let D = m.anchorNode;
|
|
703
|
+
for (; D && D !== t.current; ) {
|
|
704
|
+
if (D.nodeType === Node.ELEMENT_NODE && D.tagName.toLowerCase() === l)
|
|
705
|
+
return !0;
|
|
706
|
+
D = D.parentNode;
|
|
707
|
+
}
|
|
708
|
+
return !1;
|
|
709
|
+
}, [t]), b = p(() => {
|
|
710
|
+
const l = window.getSelection();
|
|
711
|
+
if (!l || !l.rangeCount) return null;
|
|
712
|
+
let m = l.anchorNode;
|
|
713
|
+
for (; m && m !== t.current; ) {
|
|
714
|
+
if (m.nodeType === Node.ELEMENT_NODE && m.tagName === "A")
|
|
715
|
+
return m.href;
|
|
716
|
+
m = m.parentNode;
|
|
717
|
+
}
|
|
718
|
+
return null;
|
|
719
|
+
}, [t]), f = p((l) => {
|
|
720
|
+
t.current && document.activeElement !== t.current && t.current.focus(), document.execCommand("createLink", !1, l), n();
|
|
721
|
+
}, [t, n]), N = p(() => {
|
|
722
|
+
t.current && document.activeElement !== t.current && t.current.focus(), document.execCommand("unlink", !1), n();
|
|
723
|
+
}, [t, n]), T = p((l) => {
|
|
724
|
+
t.current && document.activeElement !== t.current && t.current.focus(), l ? document.execCommand("foreColor", !1, l) : document.execCommand("removeFormat", !1), n();
|
|
725
|
+
}, [t, n]), x = p((l) => {
|
|
726
|
+
t.current && document.activeElement !== t.current && t.current.focus(), l ? document.execCommand("hiliteColor", !1, l) : document.execCommand("removeFormat", !1), n();
|
|
727
|
+
}, [t, n]), A = p(() => {
|
|
728
|
+
const l = document.queryCommandValue("foreColor");
|
|
729
|
+
if (l.startsWith("rgb")) {
|
|
730
|
+
const m = l.match(/\d+/g);
|
|
731
|
+
if (m) {
|
|
732
|
+
const [D, M, C] = m.map(Number);
|
|
733
|
+
return `#${((1 << 24) + (D << 16) + (M << 8) + C).toString(16).slice(1)}`;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return l || "";
|
|
737
|
+
}, []), a = p(() => {
|
|
738
|
+
const l = document.queryCommandValue("backColor");
|
|
739
|
+
if (l.startsWith("rgb")) {
|
|
740
|
+
const m = l.match(/\d+/g);
|
|
741
|
+
if (m) {
|
|
742
|
+
const [D, M, C] = m.map(Number);
|
|
743
|
+
return `#${((1 << 24) + (D << 16) + (M << 8) + C).toString(16).slice(1)}`;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
return l || "";
|
|
747
|
+
}, []), i = p((l) => {
|
|
748
|
+
t.current && document.activeElement !== t.current && t.current.focus(), l && document.execCommand("fontName", !1, l), n();
|
|
749
|
+
}, [t, n]), v = p((l) => {
|
|
750
|
+
t.current && document.activeElement !== t.current && t.current.focus();
|
|
751
|
+
const m = window.getSelection();
|
|
752
|
+
if (m && m.rangeCount > 0 && !m.isCollapsed) {
|
|
753
|
+
const D = m.getRangeAt(0), M = document.createElement("span");
|
|
754
|
+
M.style.fontSize = l;
|
|
755
|
+
try {
|
|
756
|
+
D.surroundContents(M), m.removeAllRanges();
|
|
757
|
+
const C = document.createRange();
|
|
758
|
+
C.selectNodeContents(M), m.addRange(C);
|
|
759
|
+
} catch {
|
|
760
|
+
const C = parseInt(l);
|
|
761
|
+
let $ = 3;
|
|
762
|
+
C <= 12 ? $ = 1 : C <= 14 ? $ = 2 : C <= 16 ? $ = 3 : C <= 18 ? $ = 4 : C <= 24 ? $ = 5 : C <= 32 ? $ = 6 : $ = 7, document.execCommand("fontSize", !1, String($));
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
n();
|
|
766
|
+
}, [t, n]), F = p(() => document.queryCommandValue("fontName") || "", []), q = p(() => {
|
|
767
|
+
const l = window.getSelection();
|
|
768
|
+
if (l && l.rangeCount > 0) {
|
|
769
|
+
let m = l.anchorNode;
|
|
770
|
+
for (; m && m !== t.current; ) {
|
|
771
|
+
if (m.nodeType === Node.ELEMENT_NODE) {
|
|
772
|
+
const M = window.getComputedStyle(m).fontSize;
|
|
773
|
+
if (M) return M;
|
|
774
|
+
}
|
|
775
|
+
m = m.parentNode;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
return "";
|
|
779
|
+
}, [t]), B = p((l) => {
|
|
780
|
+
t.current && document.activeElement !== t.current && t.current.focus(), document.execCommand("justify" + l.charAt(0).toUpperCase() + l.slice(1), !1), n();
|
|
781
|
+
}, [t, n]), L = p(() => {
|
|
782
|
+
const l = window.getSelection();
|
|
783
|
+
if (l && l.rangeCount > 0) {
|
|
784
|
+
let m = l.anchorNode;
|
|
785
|
+
for (; m && m !== t.current; ) {
|
|
786
|
+
if (m.nodeType === Node.ELEMENT_NODE) {
|
|
787
|
+
const M = window.getComputedStyle(m).textAlign;
|
|
788
|
+
if (M === "center" || M === "right" || M === "justify")
|
|
789
|
+
return M;
|
|
790
|
+
if (M === "start" || M === "left")
|
|
791
|
+
return "left";
|
|
792
|
+
}
|
|
793
|
+
m = m.parentNode;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
return "left";
|
|
797
|
+
}, [t]), H = p(() => {
|
|
798
|
+
t.current && document.activeElement !== t.current && t.current.focus(), document.execCommand("formatBlock", !1, "blockquote"), n();
|
|
799
|
+
}, [t, n]), Z = p(() => {
|
|
800
|
+
t.current && document.activeElement !== t.current && t.current.focus();
|
|
801
|
+
const l = window.getSelection();
|
|
802
|
+
if (l && l.rangeCount > 0) {
|
|
803
|
+
const m = l.getRangeAt(0), D = document.createElement("pre"), M = document.createElement("code"), C = m.toString() || "Code here...";
|
|
804
|
+
M.textContent = C, D.appendChild(M), m.deleteContents(), m.insertNode(D);
|
|
805
|
+
const $ = document.createRange();
|
|
806
|
+
$.selectNodeContents(M), l.removeAllRanges(), l.addRange($);
|
|
807
|
+
}
|
|
808
|
+
n();
|
|
809
|
+
}, [t, n]), W = p(() => {
|
|
810
|
+
t.current && document.activeElement !== t.current && t.current.focus(), document.execCommand("insertHorizontalRule", !1), n();
|
|
811
|
+
}, [t, n]), Q = p(() => {
|
|
812
|
+
const l = window.getSelection();
|
|
813
|
+
if (!l || !l.rangeCount) return !1;
|
|
814
|
+
let m = l.anchorNode;
|
|
815
|
+
for (; m && m !== t.current; ) {
|
|
816
|
+
if (m.nodeType === Node.ELEMENT_NODE && m.tagName === "BLOCKQUOTE")
|
|
817
|
+
return !0;
|
|
818
|
+
m = m.parentNode;
|
|
819
|
+
}
|
|
820
|
+
return !1;
|
|
821
|
+
}, [t]), ue = p(() => {
|
|
822
|
+
const l = window.getSelection();
|
|
823
|
+
if (!l || !l.rangeCount) return !1;
|
|
824
|
+
let m = l.anchorNode;
|
|
825
|
+
for (; m && m !== t.current; ) {
|
|
826
|
+
if (m.nodeType === Node.ELEMENT_NODE) {
|
|
827
|
+
const D = m.tagName;
|
|
828
|
+
if (D === "PRE" || D === "CODE")
|
|
829
|
+
return !0;
|
|
830
|
+
}
|
|
831
|
+
m = m.parentNode;
|
|
832
|
+
}
|
|
833
|
+
return !1;
|
|
834
|
+
}, [t]), de = p(() => o("bold"), [o]), R = p(() => o("italic"), [o]), J = p(() => o("underline"), [o]), ae = p(() => o("strikeThrough"), [o]), ge = p(() => u("insertUnorderedList"), [u]), _e = p(() => u("insertOrderedList"), [u]), be = p((l) => {
|
|
835
|
+
if (!(!t.current?.contains(document.activeElement) || !(navigator.platform.toUpperCase().includes("MAC") ? l.metaKey : l.ctrlKey))) {
|
|
836
|
+
switch (l.key.toLowerCase()) {
|
|
837
|
+
case "b":
|
|
838
|
+
l.preventDefault(), de();
|
|
839
|
+
break;
|
|
840
|
+
case "i":
|
|
841
|
+
l.preventDefault(), R();
|
|
842
|
+
break;
|
|
843
|
+
case "u":
|
|
844
|
+
l.preventDefault(), J();
|
|
845
|
+
break;
|
|
846
|
+
}
|
|
847
|
+
l.shiftKey && /^[1-6]$/.test(l.key) && (l.preventDefault(), h(`h${l.key}`)), l.shiftKey && l.key === "0" && (l.preventDefault(), h("p"));
|
|
848
|
+
}
|
|
849
|
+
}, [t, de, R, J, h]);
|
|
850
|
+
return X(() => (document.addEventListener("keydown", be), () => document.removeEventListener("keydown", be)), [be]), {
|
|
851
|
+
toggleBold: de,
|
|
852
|
+
toggleItalic: R,
|
|
853
|
+
toggleUnderline: J,
|
|
854
|
+
toggleStrikethrough: ae,
|
|
855
|
+
toggleBulletList: ge,
|
|
856
|
+
toggleNumberedList: _e,
|
|
857
|
+
setBlockType: h,
|
|
858
|
+
getCurrentBlockType: d,
|
|
859
|
+
isFormatActive: c,
|
|
860
|
+
isInList: y,
|
|
861
|
+
insertLink: f,
|
|
862
|
+
removeLink: N,
|
|
863
|
+
getCurrentLink: b,
|
|
864
|
+
setTextColor: T,
|
|
865
|
+
setBackgroundColor: x,
|
|
866
|
+
getCurrentTextColor: A,
|
|
867
|
+
getCurrentBackgroundColor: a,
|
|
868
|
+
setFontFamily: i,
|
|
869
|
+
setFontSize: v,
|
|
870
|
+
getCurrentFontFamily: F,
|
|
871
|
+
getCurrentFontSize: q,
|
|
872
|
+
setAlignment: B,
|
|
873
|
+
getCurrentAlignment: L,
|
|
874
|
+
insertBlockquote: H,
|
|
875
|
+
insertCodeBlock: Z,
|
|
876
|
+
insertHorizontalRule: W,
|
|
877
|
+
isInBlockquote: Q,
|
|
878
|
+
isInCodeBlock: ue
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
function Dn(t, n = {}) {
|
|
882
|
+
const { maxHistory: o = 50, debounceMs: c = 500 } = n, d = V([]), h = V([]), u = V(t), y = V(null), b = V(t), [f, N] = z({
|
|
883
|
+
canUndo: !1,
|
|
884
|
+
canRedo: !1
|
|
885
|
+
}), T = p(() => {
|
|
886
|
+
N({
|
|
887
|
+
canUndo: d.current.length > 0,
|
|
888
|
+
canRedo: h.current.length > 0
|
|
889
|
+
});
|
|
890
|
+
}, []), x = p((v) => {
|
|
891
|
+
u.current = v, y.current && clearTimeout(y.current), y.current = setTimeout(() => {
|
|
892
|
+
v !== b.current && (d.current.push(b.current), d.current.length > o && d.current.shift(), h.current = [], b.current = v, T());
|
|
893
|
+
}, c);
|
|
894
|
+
}, [o, c, T]), A = p(() => {
|
|
895
|
+
if (d.current.length === 0)
|
|
896
|
+
return null;
|
|
897
|
+
const v = d.current.pop();
|
|
898
|
+
return h.current.push(b.current), u.current = v, b.current = v, T(), v;
|
|
899
|
+
}, [T]), a = p(() => {
|
|
900
|
+
if (h.current.length === 0)
|
|
901
|
+
return null;
|
|
902
|
+
const v = h.current.pop();
|
|
903
|
+
return d.current.push(b.current), u.current = v, b.current = v, T(), v;
|
|
904
|
+
}, [T]), i = p((v) => {
|
|
905
|
+
d.current = [], h.current = [], u.current = v, b.current = v, T();
|
|
906
|
+
}, [T]);
|
|
907
|
+
return X(() => () => {
|
|
908
|
+
y.current && clearTimeout(y.current);
|
|
909
|
+
}, []), {
|
|
910
|
+
pushToHistory: x,
|
|
911
|
+
undo: A,
|
|
912
|
+
redo: a,
|
|
913
|
+
reset: i,
|
|
914
|
+
canUndo: f.canUndo,
|
|
915
|
+
canRedo: f.canRedo
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
const Wt = "p, h1, h2, h3, h4, h5, h6, ul, ol, blockquote, pre, figure, img, video, hr, table";
|
|
919
|
+
function Mn({ editorRef: t, onContentChange: n }) {
|
|
920
|
+
const [o, c] = z({
|
|
921
|
+
isDragging: !1,
|
|
922
|
+
draggedElement: null,
|
|
923
|
+
dropIndicatorY: null,
|
|
924
|
+
dropTarget: null,
|
|
925
|
+
dropPosition: null
|
|
926
|
+
}), d = V(null), h = p((a) => {
|
|
927
|
+
if (!t.current) return null;
|
|
928
|
+
let i = a;
|
|
929
|
+
for (; i && i !== t.current; ) {
|
|
930
|
+
if (i.parentElement === t.current && i.matches(Wt))
|
|
931
|
+
return i;
|
|
932
|
+
i = i.parentElement;
|
|
933
|
+
}
|
|
934
|
+
return null;
|
|
935
|
+
}, [t]), u = p(() => t.current ? Array.from(t.current.querySelectorAll(`:scope > ${Wt}`)) : [], [t]), y = p((a) => {
|
|
936
|
+
const i = document.createElement("div");
|
|
937
|
+
return i.className = "drag-ghost", i.innerHTML = a.outerHTML, i.style.cssText = `
|
|
938
|
+
position: fixed;
|
|
939
|
+
pointer-events: none;
|
|
940
|
+
z-index: 9999;
|
|
941
|
+
opacity: 0.8;
|
|
942
|
+
transform: scale(0.95);
|
|
943
|
+
max-width: 400px;
|
|
944
|
+
background: var(--color-surface);
|
|
945
|
+
border: 1px solid var(--color-accent);
|
|
946
|
+
border-radius: 8px;
|
|
947
|
+
padding: 12px;
|
|
948
|
+
box-shadow: 0 8px 32px rgba(0,0,0,0.2);
|
|
949
|
+
`, document.body.appendChild(i), d.current = i, i;
|
|
950
|
+
}, []), b = p(() => {
|
|
951
|
+
d.current && (d.current.remove(), d.current = null);
|
|
952
|
+
}, []), f = p((a, i) => {
|
|
953
|
+
d.current && (d.current.style.left = `${a + 10}px`, d.current.style.top = `${i + 10}px`);
|
|
954
|
+
}, []), N = p((a, i, v) => {
|
|
955
|
+
let F = null, q = null, B = null;
|
|
956
|
+
for (const L of i) {
|
|
957
|
+
if (L === v) continue;
|
|
958
|
+
const H = L.getBoundingClientRect(), Z = H.top + H.height / 2;
|
|
959
|
+
if (a < Z) {
|
|
960
|
+
F = L, q = "before", B = H.top;
|
|
961
|
+
break;
|
|
962
|
+
} else
|
|
963
|
+
F = L, q = "after", B = H.bottom;
|
|
964
|
+
}
|
|
965
|
+
return { dropTarget: F, dropPosition: q, indicatorY: B };
|
|
966
|
+
}, []), T = p((a, i) => {
|
|
967
|
+
const v = h(a);
|
|
968
|
+
v && (i.preventDefault(), y(v), f(i.clientX, i.clientY), v.classList.add("dragging"), c({
|
|
969
|
+
isDragging: !0,
|
|
970
|
+
draggedElement: v,
|
|
971
|
+
dropIndicatorY: null,
|
|
972
|
+
dropTarget: null,
|
|
973
|
+
dropPosition: null
|
|
974
|
+
}));
|
|
975
|
+
}, [h, y, f]), x = p((a) => {
|
|
976
|
+
if (!o.isDragging || !o.draggedElement) return;
|
|
977
|
+
f(a.clientX, a.clientY);
|
|
978
|
+
const i = u(), { dropTarget: v, dropPosition: F, indicatorY: q } = N(
|
|
979
|
+
a.clientY,
|
|
980
|
+
i,
|
|
981
|
+
o.draggedElement
|
|
982
|
+
);
|
|
983
|
+
c((B) => ({
|
|
984
|
+
...B,
|
|
985
|
+
dropTarget: v,
|
|
986
|
+
dropPosition: F,
|
|
987
|
+
dropIndicatorY: q
|
|
988
|
+
}));
|
|
989
|
+
}, [o.isDragging, o.draggedElement, f, u, N]), A = p(() => {
|
|
990
|
+
if (!o.isDragging) return;
|
|
991
|
+
const { draggedElement: a, dropTarget: i, dropPosition: v } = o;
|
|
992
|
+
a && a.classList.remove("dragging"), b(), a && i && v && t.current && (v === "before" ? i.parentElement?.insertBefore(a, i) : i.parentElement?.insertBefore(a, i.nextSibling), n()), c({
|
|
993
|
+
isDragging: !1,
|
|
994
|
+
draggedElement: null,
|
|
995
|
+
dropIndicatorY: null,
|
|
996
|
+
dropTarget: null,
|
|
997
|
+
dropPosition: null
|
|
998
|
+
});
|
|
999
|
+
}, [o, b, t, n]);
|
|
1000
|
+
return X(() => {
|
|
1001
|
+
if (o.isDragging) {
|
|
1002
|
+
const a = (v) => x(v), i = () => A();
|
|
1003
|
+
return document.addEventListener("mousemove", a), document.addEventListener("mouseup", i), () => {
|
|
1004
|
+
document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", i);
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
}, [o.isDragging, x, A]), {
|
|
1008
|
+
dragState: o,
|
|
1009
|
+
handleDragStart: T,
|
|
1010
|
+
findBlockParent: h
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
function On({
|
|
1014
|
+
isOpen: t,
|
|
1015
|
+
position: n,
|
|
1016
|
+
initialUrl: o = "",
|
|
1017
|
+
onSubmit: c,
|
|
1018
|
+
onRemove: d,
|
|
1019
|
+
onClose: h
|
|
1020
|
+
}) {
|
|
1021
|
+
const [u, y] = z(o), b = V(null);
|
|
1022
|
+
X(() => {
|
|
1023
|
+
t && b.current && (y(o), setTimeout(() => b.current?.focus(), 50));
|
|
1024
|
+
}, [t, o]);
|
|
1025
|
+
const f = (T) => {
|
|
1026
|
+
if (T.preventDefault(), u.trim()) {
|
|
1027
|
+
let x = u.trim();
|
|
1028
|
+
!/^https?:\/\//i.test(x) && !x.startsWith("mailto:") && (x = "https://" + x), c(x);
|
|
1029
|
+
}
|
|
1030
|
+
}, N = (T) => {
|
|
1031
|
+
T.key === "Escape" && h();
|
|
1032
|
+
};
|
|
1033
|
+
return t ? /* @__PURE__ */ r(
|
|
1034
|
+
"div",
|
|
1035
|
+
{
|
|
1036
|
+
className: "link-popover",
|
|
1037
|
+
style: {
|
|
1038
|
+
left: n.x,
|
|
1039
|
+
top: n.y
|
|
1040
|
+
},
|
|
1041
|
+
onMouseDown: (T) => T.stopPropagation(),
|
|
1042
|
+
children: /* @__PURE__ */ k("form", { onSubmit: f, className: "link-form", children: [
|
|
1043
|
+
/* @__PURE__ */ r(
|
|
1044
|
+
"input",
|
|
1045
|
+
{
|
|
1046
|
+
ref: b,
|
|
1047
|
+
type: "text",
|
|
1048
|
+
value: u,
|
|
1049
|
+
onChange: (T) => y(T.target.value),
|
|
1050
|
+
onKeyDown: N,
|
|
1051
|
+
placeholder: "Enter URL...",
|
|
1052
|
+
className: "link-input"
|
|
1053
|
+
}
|
|
1054
|
+
),
|
|
1055
|
+
/* @__PURE__ */ k("div", { className: "link-actions", children: [
|
|
1056
|
+
/* @__PURE__ */ k("button", { type: "submit", className: "link-btn link-btn-primary", disabled: !u.trim(), children: [
|
|
1057
|
+
o ? "Update" : "Add",
|
|
1058
|
+
" Link"
|
|
1059
|
+
] }),
|
|
1060
|
+
o && /* @__PURE__ */ r(
|
|
1061
|
+
"button",
|
|
1062
|
+
{
|
|
1063
|
+
type: "button",
|
|
1064
|
+
className: "link-btn link-btn-danger",
|
|
1065
|
+
onClick: d,
|
|
1066
|
+
children: "Remove"
|
|
1067
|
+
}
|
|
1068
|
+
),
|
|
1069
|
+
/* @__PURE__ */ r(
|
|
1070
|
+
"button",
|
|
1071
|
+
{
|
|
1072
|
+
type: "button",
|
|
1073
|
+
className: "link-btn",
|
|
1074
|
+
onClick: h,
|
|
1075
|
+
children: "Cancel"
|
|
1076
|
+
}
|
|
1077
|
+
)
|
|
1078
|
+
] })
|
|
1079
|
+
] })
|
|
1080
|
+
}
|
|
1081
|
+
) : null;
|
|
1082
|
+
}
|
|
1083
|
+
const In = [
|
|
1084
|
+
// Row 1 - Grayscale
|
|
1085
|
+
["#000000", "#374151", "#6b7280", "#9ca3af", "#d1d5db", "#f3f4f6", "#ffffff"],
|
|
1086
|
+
// Row 2 - Reds
|
|
1087
|
+
["#7f1d1d", "#b91c1c", "#dc2626", "#ef4444", "#f87171", "#fca5a5", "#fee2e2"],
|
|
1088
|
+
// Row 3 - Oranges
|
|
1089
|
+
["#78350f", "#b45309", "#d97706", "#f59e0b", "#fbbf24", "#fcd34d", "#fef3c7"],
|
|
1090
|
+
// Row 4 - Greens
|
|
1091
|
+
["#14532d", "#166534", "#16a34a", "#22c55e", "#4ade80", "#86efac", "#dcfce7"],
|
|
1092
|
+
// Row 5 - Blues
|
|
1093
|
+
["#1e3a8a", "#1d4ed8", "#2563eb", "#3b82f6", "#60a5fa", "#93c5fd", "#dbeafe"],
|
|
1094
|
+
// Row 6 - Purples
|
|
1095
|
+
["#4c1d95", "#6d28d9", "#7c3aed", "#8b5cf6", "#a78bfa", "#c4b5fd", "#ede9fe"],
|
|
1096
|
+
// Row 7 - Pinks
|
|
1097
|
+
["#831843", "#be185d", "#db2777", "#ec4899", "#f472b6", "#f9a8d4", "#fce7f3"]
|
|
1098
|
+
];
|
|
1099
|
+
function Gt({
|
|
1100
|
+
isOpen: t,
|
|
1101
|
+
position: n,
|
|
1102
|
+
currentColor: o,
|
|
1103
|
+
type: c,
|
|
1104
|
+
onSelect: d,
|
|
1105
|
+
onClose: h
|
|
1106
|
+
}) {
|
|
1107
|
+
const [u, y] = z(o || "#000000"), b = V(null);
|
|
1108
|
+
if (X(() => {
|
|
1109
|
+
const A = (a) => {
|
|
1110
|
+
b.current && !b.current.contains(a.target) && h();
|
|
1111
|
+
};
|
|
1112
|
+
if (t)
|
|
1113
|
+
return document.addEventListener("mousedown", A), () => document.removeEventListener("mousedown", A);
|
|
1114
|
+
}, [t, h]), !t) return null;
|
|
1115
|
+
const f = (A) => {
|
|
1116
|
+
d(A), h();
|
|
1117
|
+
}, N = (A) => {
|
|
1118
|
+
y(A.target.value);
|
|
1119
|
+
}, T = () => {
|
|
1120
|
+
d(u), h();
|
|
1121
|
+
}, x = () => {
|
|
1122
|
+
d(""), h();
|
|
1123
|
+
};
|
|
1124
|
+
return /* @__PURE__ */ k(
|
|
1125
|
+
"div",
|
|
1126
|
+
{
|
|
1127
|
+
ref: b,
|
|
1128
|
+
className: "color-picker",
|
|
1129
|
+
style: {
|
|
1130
|
+
left: n.x,
|
|
1131
|
+
top: n.y
|
|
1132
|
+
},
|
|
1133
|
+
onMouseDown: (A) => A.preventDefault(),
|
|
1134
|
+
children: [
|
|
1135
|
+
/* @__PURE__ */ k("div", { className: "color-picker-header", children: [
|
|
1136
|
+
/* @__PURE__ */ r("span", { className: "color-picker-title", children: c === "text" ? "Text Color" : "Background Color" }),
|
|
1137
|
+
/* @__PURE__ */ r("button", { className: "color-picker-close", onClick: h, children: "✕" })
|
|
1138
|
+
] }),
|
|
1139
|
+
/* @__PURE__ */ r("div", { className: "color-presets", children: In.map((A, a) => /* @__PURE__ */ r("div", { className: "color-row", children: A.map((i) => /* @__PURE__ */ r(
|
|
1140
|
+
"button",
|
|
1141
|
+
{
|
|
1142
|
+
type: "button",
|
|
1143
|
+
className: `color-swatch ${i === o ? "active" : ""} ${i === "#ffffff" ? "white" : ""}`,
|
|
1144
|
+
style: { backgroundColor: i },
|
|
1145
|
+
onClick: () => f(i),
|
|
1146
|
+
title: i
|
|
1147
|
+
},
|
|
1148
|
+
i
|
|
1149
|
+
)) }, a)) }),
|
|
1150
|
+
/* @__PURE__ */ k("div", { className: "color-custom", children: [
|
|
1151
|
+
/* @__PURE__ */ r(
|
|
1152
|
+
"input",
|
|
1153
|
+
{
|
|
1154
|
+
type: "color",
|
|
1155
|
+
value: u,
|
|
1156
|
+
onChange: N,
|
|
1157
|
+
className: "color-input-native"
|
|
1158
|
+
}
|
|
1159
|
+
),
|
|
1160
|
+
/* @__PURE__ */ r(
|
|
1161
|
+
"input",
|
|
1162
|
+
{
|
|
1163
|
+
type: "text",
|
|
1164
|
+
value: u,
|
|
1165
|
+
onChange: (A) => y(A.target.value),
|
|
1166
|
+
className: "color-input-text",
|
|
1167
|
+
placeholder: "#000000"
|
|
1168
|
+
}
|
|
1169
|
+
),
|
|
1170
|
+
/* @__PURE__ */ r(
|
|
1171
|
+
"button",
|
|
1172
|
+
{
|
|
1173
|
+
type: "button",
|
|
1174
|
+
className: "color-apply-btn",
|
|
1175
|
+
onClick: T,
|
|
1176
|
+
children: "Apply"
|
|
1177
|
+
}
|
|
1178
|
+
)
|
|
1179
|
+
] }),
|
|
1180
|
+
/* @__PURE__ */ k(
|
|
1181
|
+
"button",
|
|
1182
|
+
{
|
|
1183
|
+
type: "button",
|
|
1184
|
+
className: "color-remove-btn",
|
|
1185
|
+
onClick: x,
|
|
1186
|
+
children: [
|
|
1187
|
+
"Remove ",
|
|
1188
|
+
c === "text" ? "text" : "background",
|
|
1189
|
+
" color"
|
|
1190
|
+
]
|
|
1191
|
+
}
|
|
1192
|
+
)
|
|
1193
|
+
]
|
|
1194
|
+
}
|
|
1195
|
+
);
|
|
1196
|
+
}
|
|
1197
|
+
const Rn = [
|
|
1198
|
+
{ value: "", label: "Default" },
|
|
1199
|
+
{ value: "Arial, sans-serif", label: "Arial" },
|
|
1200
|
+
{ value: "Georgia, serif", label: "Georgia" },
|
|
1201
|
+
{ value: "Times New Roman, serif", label: "Times New Roman" },
|
|
1202
|
+
{ value: "Courier New, monospace", label: "Courier New" },
|
|
1203
|
+
{ value: "Verdana, sans-serif", label: "Verdana" },
|
|
1204
|
+
{ value: "Trebuchet MS, sans-serif", label: "Trebuchet MS" },
|
|
1205
|
+
{ value: "Impact, sans-serif", label: "Impact" },
|
|
1206
|
+
{ value: "Comic Sans MS, cursive", label: "Comic Sans" }
|
|
1207
|
+
], Pn = [
|
|
1208
|
+
{ value: "12px", label: "Small" },
|
|
1209
|
+
{ value: "14px", label: "Normal" },
|
|
1210
|
+
{ value: "16px", label: "Medium" },
|
|
1211
|
+
{ value: "18px", label: "Large" },
|
|
1212
|
+
{ value: "24px", label: "XL" },
|
|
1213
|
+
{ value: "32px", label: "2XL" },
|
|
1214
|
+
{ value: "48px", label: "3XL" }
|
|
1215
|
+
];
|
|
1216
|
+
function zn({
|
|
1217
|
+
isOpen: t,
|
|
1218
|
+
position: n,
|
|
1219
|
+
currentFont: o,
|
|
1220
|
+
currentSize: c,
|
|
1221
|
+
onFontChange: d,
|
|
1222
|
+
onSizeChange: h,
|
|
1223
|
+
onClose: u
|
|
1224
|
+
}) {
|
|
1225
|
+
const [y, b] = z("font"), f = V(null);
|
|
1226
|
+
return X(() => {
|
|
1227
|
+
const N = (T) => {
|
|
1228
|
+
f.current && !f.current.contains(T.target) && u();
|
|
1229
|
+
};
|
|
1230
|
+
if (t)
|
|
1231
|
+
return document.addEventListener("mousedown", N), () => document.removeEventListener("mousedown", N);
|
|
1232
|
+
}, [t, u]), t ? /* @__PURE__ */ k(
|
|
1233
|
+
"div",
|
|
1234
|
+
{
|
|
1235
|
+
ref: f,
|
|
1236
|
+
className: "font-picker",
|
|
1237
|
+
style: {
|
|
1238
|
+
left: n.x,
|
|
1239
|
+
top: n.y
|
|
1240
|
+
},
|
|
1241
|
+
onMouseDown: (N) => N.preventDefault(),
|
|
1242
|
+
children: [
|
|
1243
|
+
/* @__PURE__ */ k("div", { className: "font-picker-header", children: [
|
|
1244
|
+
/* @__PURE__ */ r(
|
|
1245
|
+
"button",
|
|
1246
|
+
{
|
|
1247
|
+
className: `font-tab ${y === "font" ? "active" : ""}`,
|
|
1248
|
+
onClick: () => b("font"),
|
|
1249
|
+
children: "Font"
|
|
1250
|
+
}
|
|
1251
|
+
),
|
|
1252
|
+
/* @__PURE__ */ r(
|
|
1253
|
+
"button",
|
|
1254
|
+
{
|
|
1255
|
+
className: `font-tab ${y === "size" ? "active" : ""}`,
|
|
1256
|
+
onClick: () => b("size"),
|
|
1257
|
+
children: "Size"
|
|
1258
|
+
}
|
|
1259
|
+
),
|
|
1260
|
+
/* @__PURE__ */ r("button", { className: "font-picker-close", onClick: u, children: "✕" })
|
|
1261
|
+
] }),
|
|
1262
|
+
/* @__PURE__ */ r("div", { className: "font-picker-content", children: y === "font" ? /* @__PURE__ */ r("div", { className: "font-list", children: Rn.map(({ value: N, label: T }) => /* @__PURE__ */ r(
|
|
1263
|
+
"button",
|
|
1264
|
+
{
|
|
1265
|
+
type: "button",
|
|
1266
|
+
className: `font-item ${o === N ? "active" : ""}`,
|
|
1267
|
+
style: { fontFamily: N || "inherit" },
|
|
1268
|
+
onClick: () => {
|
|
1269
|
+
d(N), u();
|
|
1270
|
+
},
|
|
1271
|
+
children: T
|
|
1272
|
+
},
|
|
1273
|
+
T
|
|
1274
|
+
)) }) : /* @__PURE__ */ r("div", { className: "size-list", children: Pn.map(({ value: N, label: T }) => /* @__PURE__ */ k(
|
|
1275
|
+
"button",
|
|
1276
|
+
{
|
|
1277
|
+
type: "button",
|
|
1278
|
+
className: `size-item ${c === N ? "active" : ""}`,
|
|
1279
|
+
onClick: () => {
|
|
1280
|
+
h(N), u();
|
|
1281
|
+
},
|
|
1282
|
+
children: [
|
|
1283
|
+
/* @__PURE__ */ r("span", { className: "size-preview", style: { fontSize: N }, children: "Aa" }),
|
|
1284
|
+
/* @__PURE__ */ r("span", { className: "size-label", children: T }),
|
|
1285
|
+
/* @__PURE__ */ r("span", { className: "size-value", children: N })
|
|
1286
|
+
]
|
|
1287
|
+
},
|
|
1288
|
+
N
|
|
1289
|
+
)) }) })
|
|
1290
|
+
]
|
|
1291
|
+
}
|
|
1292
|
+
) : null;
|
|
1293
|
+
}
|
|
1294
|
+
function Fn({
|
|
1295
|
+
isOpen: t,
|
|
1296
|
+
position: n,
|
|
1297
|
+
onInsertBlockquote: o,
|
|
1298
|
+
onInsertCodeBlock: c,
|
|
1299
|
+
onInsertHorizontalRule: d,
|
|
1300
|
+
onClose: h
|
|
1301
|
+
}) {
|
|
1302
|
+
const u = V(null);
|
|
1303
|
+
if (X(() => {
|
|
1304
|
+
const b = (f) => {
|
|
1305
|
+
u.current && !u.current.contains(f.target) && h();
|
|
1306
|
+
};
|
|
1307
|
+
if (t)
|
|
1308
|
+
return document.addEventListener("mousedown", b), () => document.removeEventListener("mousedown", b);
|
|
1309
|
+
}, [t, h]), !t) return null;
|
|
1310
|
+
const y = (b) => {
|
|
1311
|
+
b(), h();
|
|
1312
|
+
};
|
|
1313
|
+
return /* @__PURE__ */ k(
|
|
1314
|
+
"div",
|
|
1315
|
+
{
|
|
1316
|
+
ref: u,
|
|
1317
|
+
className: "insert-menu",
|
|
1318
|
+
style: {
|
|
1319
|
+
left: n.x,
|
|
1320
|
+
top: n.y
|
|
1321
|
+
},
|
|
1322
|
+
onMouseDown: (b) => b.preventDefault(),
|
|
1323
|
+
children: [
|
|
1324
|
+
/* @__PURE__ */ r("div", { className: "insert-menu-header", children: "Insert Block" }),
|
|
1325
|
+
/* @__PURE__ */ k(
|
|
1326
|
+
"button",
|
|
1327
|
+
{
|
|
1328
|
+
type: "button",
|
|
1329
|
+
className: "insert-menu-item",
|
|
1330
|
+
onClick: () => y(o),
|
|
1331
|
+
children: [
|
|
1332
|
+
/* @__PURE__ */ r("span", { className: "insert-icon", children: "❝" }),
|
|
1333
|
+
/* @__PURE__ */ k("div", { className: "insert-info", children: [
|
|
1334
|
+
/* @__PURE__ */ r("span", { className: "insert-label", children: "Blockquote" }),
|
|
1335
|
+
/* @__PURE__ */ r("span", { className: "insert-desc", children: "Add a quote block" })
|
|
1336
|
+
] })
|
|
1337
|
+
]
|
|
1338
|
+
}
|
|
1339
|
+
),
|
|
1340
|
+
/* @__PURE__ */ k(
|
|
1341
|
+
"button",
|
|
1342
|
+
{
|
|
1343
|
+
type: "button",
|
|
1344
|
+
className: "insert-menu-item",
|
|
1345
|
+
onClick: () => y(c),
|
|
1346
|
+
children: [
|
|
1347
|
+
/* @__PURE__ */ r("span", { className: "insert-icon", children: "</>" }),
|
|
1348
|
+
/* @__PURE__ */ k("div", { className: "insert-info", children: [
|
|
1349
|
+
/* @__PURE__ */ r("span", { className: "insert-label", children: "Code Block" }),
|
|
1350
|
+
/* @__PURE__ */ r("span", { className: "insert-desc", children: "Add code snippet" })
|
|
1351
|
+
] })
|
|
1352
|
+
]
|
|
1353
|
+
}
|
|
1354
|
+
),
|
|
1355
|
+
/* @__PURE__ */ k(
|
|
1356
|
+
"button",
|
|
1357
|
+
{
|
|
1358
|
+
type: "button",
|
|
1359
|
+
className: "insert-menu-item",
|
|
1360
|
+
onClick: () => y(d),
|
|
1361
|
+
children: [
|
|
1362
|
+
/* @__PURE__ */ r("span", { className: "insert-icon", children: "―" }),
|
|
1363
|
+
/* @__PURE__ */ k("div", { className: "insert-info", children: [
|
|
1364
|
+
/* @__PURE__ */ r("span", { className: "insert-label", children: "Divider" }),
|
|
1365
|
+
/* @__PURE__ */ r("span", { className: "insert-desc", children: "Horizontal line" })
|
|
1366
|
+
] })
|
|
1367
|
+
]
|
|
1368
|
+
}
|
|
1369
|
+
)
|
|
1370
|
+
]
|
|
1371
|
+
}
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
const $t = [
|
|
1375
|
+
{ value: "p", label: "Paragraph" },
|
|
1376
|
+
{ value: "h1", label: "Heading 1" },
|
|
1377
|
+
{ value: "h2", label: "Heading 2" },
|
|
1378
|
+
{ value: "h3", label: "Heading 3" }
|
|
1379
|
+
];
|
|
1380
|
+
function Un({
|
|
1381
|
+
editorRef: t,
|
|
1382
|
+
formatState: n,
|
|
1383
|
+
onBold: o,
|
|
1384
|
+
onItalic: c,
|
|
1385
|
+
onUnderline: d,
|
|
1386
|
+
onStrikethrough: h,
|
|
1387
|
+
onBlockType: u,
|
|
1388
|
+
onBulletList: y,
|
|
1389
|
+
onNumberedList: b,
|
|
1390
|
+
onInsertLink: f,
|
|
1391
|
+
onRemoveLink: N,
|
|
1392
|
+
onTextColor: T,
|
|
1393
|
+
onBackgroundColor: x,
|
|
1394
|
+
onFontFamily: A,
|
|
1395
|
+
onFontSize: a,
|
|
1396
|
+
onAlignment: i,
|
|
1397
|
+
onInsertBlockquote: v,
|
|
1398
|
+
onInsertCodeBlock: F,
|
|
1399
|
+
onInsertHorizontalRule: q
|
|
1400
|
+
}) {
|
|
1401
|
+
const [B, L] = z({ x: 0, y: 0, visible: !1 }), [H, Z] = z(!1), [W, Q] = z(!1), [ue, de] = z(!1), [R, J] = z(!1), [ae, ge] = z(!1), [_e, be] = z(!1), [l, m] = z({ x: 0, y: 0 }), [D, M] = z({ x: 0, y: 0 }), [C, $] = z({ x: 0, y: 0 }), [G, Fe] = z({ x: 0, y: 0 }), O = p(() => {
|
|
1402
|
+
const w = window.getSelection();
|
|
1403
|
+
if (!w || w.isCollapsed || !w.rangeCount || !t.current) {
|
|
1404
|
+
L((se) => ({ ...se, visible: !1 })), Z(!1);
|
|
1405
|
+
return;
|
|
1406
|
+
}
|
|
1407
|
+
const I = w.getRangeAt(0);
|
|
1408
|
+
if (!t.current.contains(I.commonAncestorContainer)) {
|
|
1409
|
+
L((se) => ({ ...se, visible: !1 })), Z(!1);
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
const ee = I.getBoundingClientRect(), pe = t.current.getBoundingClientRect(), le = 450, Le = 44, Re = 8;
|
|
1413
|
+
let Ee = ee.left + ee.width / 2 - le / 2, Pe = ee.top - Le - Re;
|
|
1414
|
+
const ke = 8;
|
|
1415
|
+
Ee = Math.max(ke, Math.min(Ee, window.innerWidth - le - ke)), Pe < ke && (Pe = ee.bottom + Re), ee.top >= pe.top - 50 && ee.bottom <= pe.bottom + 50 ? L({ x: Ee, y: Pe, visible: !0 }) : L((se) => ({ ...se, visible: !1 }));
|
|
1416
|
+
}, [t]);
|
|
1417
|
+
X(() => {
|
|
1418
|
+
const w = () => {
|
|
1419
|
+
!W && !ue && !R && !ae && requestAnimationFrame(O);
|
|
1420
|
+
}, I = () => {
|
|
1421
|
+
!W && !ue && !R && !ae && setTimeout(O, 10);
|
|
1422
|
+
};
|
|
1423
|
+
return document.addEventListener("selectionchange", w), document.addEventListener("mouseup", I), () => {
|
|
1424
|
+
document.removeEventListener("selectionchange", w), document.removeEventListener("mouseup", I);
|
|
1425
|
+
};
|
|
1426
|
+
}, [O, W, ue, R]), X(() => {
|
|
1427
|
+
const w = () => {
|
|
1428
|
+
O();
|
|
1429
|
+
};
|
|
1430
|
+
return window.addEventListener("scroll", w, !0), () => window.removeEventListener("scroll", w, !0);
|
|
1431
|
+
}, [O]), X(() => {
|
|
1432
|
+
const w = (I) => {
|
|
1433
|
+
const ee = I.target;
|
|
1434
|
+
ee.closest(".block-menu-wrapper") || Z(!1), !ee.closest(".link-popover") && !ee.closest(".link-btn-toolbar") && Q(!1);
|
|
1435
|
+
};
|
|
1436
|
+
if (H || W)
|
|
1437
|
+
return document.addEventListener("mousedown", w), () => document.removeEventListener("mousedown", w);
|
|
1438
|
+
}, [H, W]);
|
|
1439
|
+
const Ne = (w) => {
|
|
1440
|
+
const I = w.target.getBoundingClientRect();
|
|
1441
|
+
m({
|
|
1442
|
+
x: I.left,
|
|
1443
|
+
y: I.bottom + 8
|
|
1444
|
+
}), Q(!0);
|
|
1445
|
+
}, De = (w) => {
|
|
1446
|
+
const I = w.target.getBoundingClientRect();
|
|
1447
|
+
M({
|
|
1448
|
+
x: Math.max(8, I.left - 100),
|
|
1449
|
+
y: I.bottom + 8
|
|
1450
|
+
}), de(!0), J(!1);
|
|
1451
|
+
}, me = (w) => {
|
|
1452
|
+
const I = w.target.getBoundingClientRect();
|
|
1453
|
+
M({
|
|
1454
|
+
x: Math.max(8, I.left - 100),
|
|
1455
|
+
y: I.bottom + 8
|
|
1456
|
+
}), J(!0), de(!1);
|
|
1457
|
+
}, Me = (w) => {
|
|
1458
|
+
const I = w.target.getBoundingClientRect();
|
|
1459
|
+
$({
|
|
1460
|
+
x: Math.max(8, I.left - 50),
|
|
1461
|
+
y: I.bottom + 8
|
|
1462
|
+
}), ge(!0);
|
|
1463
|
+
}, Oe = (w) => {
|
|
1464
|
+
const I = w.target.getBoundingClientRect();
|
|
1465
|
+
Fe({
|
|
1466
|
+
x: Math.max(8, I.left - 50),
|
|
1467
|
+
y: I.bottom + 8
|
|
1468
|
+
}), be(!0);
|
|
1469
|
+
}, Ue = (w) => {
|
|
1470
|
+
f(w), Q(!1);
|
|
1471
|
+
}, Ie = () => {
|
|
1472
|
+
N(), Q(!1);
|
|
1473
|
+
};
|
|
1474
|
+
if (!B.visible)
|
|
1475
|
+
return null;
|
|
1476
|
+
const fe = $t.find((w) => w.value === n.blockType)?.label || "Paragraph", Ae = !!n.currentLink;
|
|
1477
|
+
return /* @__PURE__ */ k(bt, { children: [
|
|
1478
|
+
/* @__PURE__ */ k(
|
|
1479
|
+
"div",
|
|
1480
|
+
{
|
|
1481
|
+
className: "floating-toolbar",
|
|
1482
|
+
style: {
|
|
1483
|
+
left: B.x,
|
|
1484
|
+
top: B.y
|
|
1485
|
+
},
|
|
1486
|
+
onMouseDown: (w) => w.preventDefault(),
|
|
1487
|
+
children: [
|
|
1488
|
+
/* @__PURE__ */ k("div", { className: "block-menu-wrapper", children: [
|
|
1489
|
+
/* @__PURE__ */ k(
|
|
1490
|
+
"button",
|
|
1491
|
+
{
|
|
1492
|
+
type: "button",
|
|
1493
|
+
className: "floating-btn block-btn",
|
|
1494
|
+
onClick: () => Z(!H),
|
|
1495
|
+
title: "Text style",
|
|
1496
|
+
children: [
|
|
1497
|
+
fe,
|
|
1498
|
+
/* @__PURE__ */ r("span", { className: "dropdown-arrow", children: "▾" })
|
|
1499
|
+
]
|
|
1500
|
+
}
|
|
1501
|
+
),
|
|
1502
|
+
H && /* @__PURE__ */ r("div", { className: "block-menu", children: $t.map(({ value: w, label: I }) => /* @__PURE__ */ r(
|
|
1503
|
+
"button",
|
|
1504
|
+
{
|
|
1505
|
+
type: "button",
|
|
1506
|
+
className: `block-menu-item ${n.blockType === w ? "active" : ""}`,
|
|
1507
|
+
onClick: () => {
|
|
1508
|
+
u(w), Z(!1);
|
|
1509
|
+
},
|
|
1510
|
+
children: I
|
|
1511
|
+
},
|
|
1512
|
+
w
|
|
1513
|
+
)) })
|
|
1514
|
+
] }),
|
|
1515
|
+
/* @__PURE__ */ r(
|
|
1516
|
+
"button",
|
|
1517
|
+
{
|
|
1518
|
+
type: "button",
|
|
1519
|
+
className: `floating-btn font-btn ${ae ? "active" : ""}`,
|
|
1520
|
+
onClick: Me,
|
|
1521
|
+
title: "Font & Size",
|
|
1522
|
+
children: "Aa"
|
|
1523
|
+
}
|
|
1524
|
+
),
|
|
1525
|
+
/* @__PURE__ */ r("div", { className: "toolbar-divider" }),
|
|
1526
|
+
/* @__PURE__ */ r(
|
|
1527
|
+
"button",
|
|
1528
|
+
{
|
|
1529
|
+
type: "button",
|
|
1530
|
+
className: `floating-btn ${n.bold ? "active" : ""}`,
|
|
1531
|
+
onClick: o,
|
|
1532
|
+
title: "Bold (Ctrl+B)",
|
|
1533
|
+
children: /* @__PURE__ */ r("strong", { children: "B" })
|
|
1534
|
+
}
|
|
1535
|
+
),
|
|
1536
|
+
/* @__PURE__ */ r(
|
|
1537
|
+
"button",
|
|
1538
|
+
{
|
|
1539
|
+
type: "button",
|
|
1540
|
+
className: `floating-btn ${n.italic ? "active" : ""}`,
|
|
1541
|
+
onClick: c,
|
|
1542
|
+
title: "Italic (Ctrl+I)",
|
|
1543
|
+
children: /* @__PURE__ */ r("em", { children: "I" })
|
|
1544
|
+
}
|
|
1545
|
+
),
|
|
1546
|
+
/* @__PURE__ */ r(
|
|
1547
|
+
"button",
|
|
1548
|
+
{
|
|
1549
|
+
type: "button",
|
|
1550
|
+
className: `floating-btn ${n.underline ? "active" : ""}`,
|
|
1551
|
+
onClick: d,
|
|
1552
|
+
title: "Underline (Ctrl+U)",
|
|
1553
|
+
children: /* @__PURE__ */ r("u", { children: "U" })
|
|
1554
|
+
}
|
|
1555
|
+
),
|
|
1556
|
+
/* @__PURE__ */ r(
|
|
1557
|
+
"button",
|
|
1558
|
+
{
|
|
1559
|
+
type: "button",
|
|
1560
|
+
className: "floating-btn",
|
|
1561
|
+
onClick: h,
|
|
1562
|
+
title: "Strikethrough",
|
|
1563
|
+
children: /* @__PURE__ */ r("s", { children: "S" })
|
|
1564
|
+
}
|
|
1565
|
+
),
|
|
1566
|
+
/* @__PURE__ */ r("div", { className: "toolbar-divider" }),
|
|
1567
|
+
/* @__PURE__ */ k(
|
|
1568
|
+
"button",
|
|
1569
|
+
{
|
|
1570
|
+
type: "button",
|
|
1571
|
+
className: `floating-btn color-btn ${ue ? "active" : ""}`,
|
|
1572
|
+
onClick: De,
|
|
1573
|
+
title: "Text color",
|
|
1574
|
+
children: [
|
|
1575
|
+
/* @__PURE__ */ r("span", { className: "color-icon", children: "A" }),
|
|
1576
|
+
/* @__PURE__ */ r(
|
|
1577
|
+
"span",
|
|
1578
|
+
{
|
|
1579
|
+
className: "color-bar",
|
|
1580
|
+
style: { backgroundColor: n.textColor || "#000000" }
|
|
1581
|
+
}
|
|
1582
|
+
)
|
|
1583
|
+
]
|
|
1584
|
+
}
|
|
1585
|
+
),
|
|
1586
|
+
/* @__PURE__ */ k(
|
|
1587
|
+
"button",
|
|
1588
|
+
{
|
|
1589
|
+
type: "button",
|
|
1590
|
+
className: `floating-btn color-btn ${R ? "active" : ""}`,
|
|
1591
|
+
onClick: me,
|
|
1592
|
+
title: "Background color",
|
|
1593
|
+
children: [
|
|
1594
|
+
/* @__PURE__ */ r("span", { className: "color-icon bg-icon", children: "A" }),
|
|
1595
|
+
/* @__PURE__ */ r(
|
|
1596
|
+
"span",
|
|
1597
|
+
{
|
|
1598
|
+
className: "color-bar",
|
|
1599
|
+
style: { backgroundColor: n.backgroundColor || "transparent" }
|
|
1600
|
+
}
|
|
1601
|
+
)
|
|
1602
|
+
]
|
|
1603
|
+
}
|
|
1604
|
+
),
|
|
1605
|
+
/* @__PURE__ */ r("div", { className: "toolbar-divider" }),
|
|
1606
|
+
/* @__PURE__ */ r(
|
|
1607
|
+
"button",
|
|
1608
|
+
{
|
|
1609
|
+
type: "button",
|
|
1610
|
+
className: `floating-btn link-btn-toolbar ${Ae ? "active" : ""}`,
|
|
1611
|
+
onClick: Ne,
|
|
1612
|
+
title: Ae ? "Edit link (Ctrl+K)" : "Add link (Ctrl+K)",
|
|
1613
|
+
children: "🔗"
|
|
1614
|
+
}
|
|
1615
|
+
),
|
|
1616
|
+
/* @__PURE__ */ r("div", { className: "toolbar-divider" }),
|
|
1617
|
+
/* @__PURE__ */ r(
|
|
1618
|
+
"button",
|
|
1619
|
+
{
|
|
1620
|
+
type: "button",
|
|
1621
|
+
className: `floating-btn ${n.bulletList ? "active" : ""}`,
|
|
1622
|
+
onClick: y,
|
|
1623
|
+
title: "Bullet list",
|
|
1624
|
+
children: "•≡"
|
|
1625
|
+
}
|
|
1626
|
+
),
|
|
1627
|
+
/* @__PURE__ */ r(
|
|
1628
|
+
"button",
|
|
1629
|
+
{
|
|
1630
|
+
type: "button",
|
|
1631
|
+
className: `floating-btn ${n.numberedList ? "active" : ""}`,
|
|
1632
|
+
onClick: b,
|
|
1633
|
+
title: "Numbered list",
|
|
1634
|
+
children: "1."
|
|
1635
|
+
}
|
|
1636
|
+
),
|
|
1637
|
+
/* @__PURE__ */ r("div", { className: "toolbar-divider" }),
|
|
1638
|
+
/* @__PURE__ */ r(
|
|
1639
|
+
"button",
|
|
1640
|
+
{
|
|
1641
|
+
type: "button",
|
|
1642
|
+
className: `floating-btn align-btn ${n.alignment === "left" ? "active" : ""}`,
|
|
1643
|
+
onClick: () => i("left"),
|
|
1644
|
+
title: "Align left",
|
|
1645
|
+
children: /* @__PURE__ */ k("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "currentColor", children: [
|
|
1646
|
+
/* @__PURE__ */ r("rect", { x: "1", y: "2", width: "14", height: "2", rx: "0.5" }),
|
|
1647
|
+
/* @__PURE__ */ r("rect", { x: "1", y: "7", width: "10", height: "2", rx: "0.5" }),
|
|
1648
|
+
/* @__PURE__ */ r("rect", { x: "1", y: "12", width: "12", height: "2", rx: "0.5" })
|
|
1649
|
+
] })
|
|
1650
|
+
}
|
|
1651
|
+
),
|
|
1652
|
+
/* @__PURE__ */ r(
|
|
1653
|
+
"button",
|
|
1654
|
+
{
|
|
1655
|
+
type: "button",
|
|
1656
|
+
className: `floating-btn align-btn ${n.alignment === "center" ? "active" : ""}`,
|
|
1657
|
+
onClick: () => i("center"),
|
|
1658
|
+
title: "Align center",
|
|
1659
|
+
children: /* @__PURE__ */ k("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "currentColor", children: [
|
|
1660
|
+
/* @__PURE__ */ r("rect", { x: "1", y: "2", width: "14", height: "2", rx: "0.5" }),
|
|
1661
|
+
/* @__PURE__ */ r("rect", { x: "3", y: "7", width: "10", height: "2", rx: "0.5" }),
|
|
1662
|
+
/* @__PURE__ */ r("rect", { x: "2", y: "12", width: "12", height: "2", rx: "0.5" })
|
|
1663
|
+
] })
|
|
1664
|
+
}
|
|
1665
|
+
),
|
|
1666
|
+
/* @__PURE__ */ r(
|
|
1667
|
+
"button",
|
|
1668
|
+
{
|
|
1669
|
+
type: "button",
|
|
1670
|
+
className: `floating-btn align-btn ${n.alignment === "right" ? "active" : ""}`,
|
|
1671
|
+
onClick: () => i("right"),
|
|
1672
|
+
title: "Align right",
|
|
1673
|
+
children: /* @__PURE__ */ k("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "currentColor", children: [
|
|
1674
|
+
/* @__PURE__ */ r("rect", { x: "1", y: "2", width: "14", height: "2", rx: "0.5" }),
|
|
1675
|
+
/* @__PURE__ */ r("rect", { x: "5", y: "7", width: "10", height: "2", rx: "0.5" }),
|
|
1676
|
+
/* @__PURE__ */ r("rect", { x: "3", y: "12", width: "12", height: "2", rx: "0.5" })
|
|
1677
|
+
] })
|
|
1678
|
+
}
|
|
1679
|
+
),
|
|
1680
|
+
/* @__PURE__ */ r("div", { className: "toolbar-divider" }),
|
|
1681
|
+
/* @__PURE__ */ r(
|
|
1682
|
+
"button",
|
|
1683
|
+
{
|
|
1684
|
+
type: "button",
|
|
1685
|
+
className: `floating-btn insert-btn ${_e ? "active" : ""}`,
|
|
1686
|
+
onClick: Oe,
|
|
1687
|
+
title: "Insert block",
|
|
1688
|
+
children: "+"
|
|
1689
|
+
}
|
|
1690
|
+
)
|
|
1691
|
+
]
|
|
1692
|
+
}
|
|
1693
|
+
),
|
|
1694
|
+
/* @__PURE__ */ r(
|
|
1695
|
+
On,
|
|
1696
|
+
{
|
|
1697
|
+
isOpen: W,
|
|
1698
|
+
position: l,
|
|
1699
|
+
initialUrl: n.currentLink || "",
|
|
1700
|
+
onSubmit: Ue,
|
|
1701
|
+
onRemove: Ie,
|
|
1702
|
+
onClose: () => Q(!1)
|
|
1703
|
+
}
|
|
1704
|
+
),
|
|
1705
|
+
/* @__PURE__ */ r(
|
|
1706
|
+
Gt,
|
|
1707
|
+
{
|
|
1708
|
+
isOpen: ue,
|
|
1709
|
+
position: D,
|
|
1710
|
+
currentColor: n.textColor,
|
|
1711
|
+
type: "text",
|
|
1712
|
+
onSelect: T,
|
|
1713
|
+
onClose: () => de(!1)
|
|
1714
|
+
}
|
|
1715
|
+
),
|
|
1716
|
+
/* @__PURE__ */ r(
|
|
1717
|
+
Gt,
|
|
1718
|
+
{
|
|
1719
|
+
isOpen: R,
|
|
1720
|
+
position: D,
|
|
1721
|
+
currentColor: n.backgroundColor,
|
|
1722
|
+
type: "background",
|
|
1723
|
+
onSelect: x,
|
|
1724
|
+
onClose: () => J(!1)
|
|
1725
|
+
}
|
|
1726
|
+
),
|
|
1727
|
+
/* @__PURE__ */ r(
|
|
1728
|
+
zn,
|
|
1729
|
+
{
|
|
1730
|
+
isOpen: ae,
|
|
1731
|
+
position: C,
|
|
1732
|
+
currentFont: n.fontFamily,
|
|
1733
|
+
currentSize: n.fontSize,
|
|
1734
|
+
onFontChange: A,
|
|
1735
|
+
onSizeChange: a,
|
|
1736
|
+
onClose: () => ge(!1)
|
|
1737
|
+
}
|
|
1738
|
+
),
|
|
1739
|
+
/* @__PURE__ */ r(
|
|
1740
|
+
Fn,
|
|
1741
|
+
{
|
|
1742
|
+
isOpen: _e,
|
|
1743
|
+
position: G,
|
|
1744
|
+
onInsertBlockquote: v,
|
|
1745
|
+
onInsertCodeBlock: F,
|
|
1746
|
+
onInsertHorizontalRule: q,
|
|
1747
|
+
onClose: () => be(!1)
|
|
1748
|
+
}
|
|
1749
|
+
)
|
|
1750
|
+
] });
|
|
1751
|
+
}
|
|
1752
|
+
function Bn({
|
|
1753
|
+
selectedElement: t,
|
|
1754
|
+
assets: n,
|
|
1755
|
+
onReplace: o,
|
|
1756
|
+
onDelete: c,
|
|
1757
|
+
onUpload: d
|
|
1758
|
+
}) {
|
|
1759
|
+
const [h, u] = z({ x: 0, y: 0, visible: !1 }), [y, b] = z(!1), [f, N] = z(!1), T = p(() => {
|
|
1760
|
+
if (!t) {
|
|
1761
|
+
u((H) => ({ ...H, visible: !1 }));
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
const i = t.getBoundingClientRect(), v = 44, F = 8;
|
|
1765
|
+
let q = i.left + i.width / 2 - 100, B = i.top - v - F;
|
|
1766
|
+
const L = 8;
|
|
1767
|
+
q = Math.max(L, Math.min(q, window.innerWidth - 200 - L)), B < L && (B = i.bottom + F), u({ x: q, y: B, visible: !0 });
|
|
1768
|
+
}, [t]);
|
|
1769
|
+
X(() => {
|
|
1770
|
+
T();
|
|
1771
|
+
const i = () => T();
|
|
1772
|
+
return window.addEventListener("scroll", i, !0), window.addEventListener("resize", T), () => {
|
|
1773
|
+
window.removeEventListener("scroll", i, !0), window.removeEventListener("resize", T);
|
|
1774
|
+
};
|
|
1775
|
+
}, [T]), X(() => {
|
|
1776
|
+
const i = (v) => {
|
|
1777
|
+
const F = v.target;
|
|
1778
|
+
!F.closest(".asset-picker") && !F.closest(".media-toolbar") && b(!1);
|
|
1779
|
+
};
|
|
1780
|
+
if (y)
|
|
1781
|
+
return document.addEventListener("mousedown", i), () => document.removeEventListener("mousedown", i);
|
|
1782
|
+
}, [y]);
|
|
1783
|
+
const x = async (i) => {
|
|
1784
|
+
const v = i.target.files?.[0];
|
|
1785
|
+
if (!(!v || !d)) {
|
|
1786
|
+
N(!0);
|
|
1787
|
+
try {
|
|
1788
|
+
const F = await d(v);
|
|
1789
|
+
o(F), b(!1);
|
|
1790
|
+
} catch (F) {
|
|
1791
|
+
console.error("Upload failed:", F);
|
|
1792
|
+
} finally {
|
|
1793
|
+
N(!1);
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
};
|
|
1797
|
+
if (!h.visible)
|
|
1798
|
+
return null;
|
|
1799
|
+
const A = t?.tagName === "IMG", a = t?.getAttribute("src") || "";
|
|
1800
|
+
return /* @__PURE__ */ k(bt, { children: [
|
|
1801
|
+
/* @__PURE__ */ k(
|
|
1802
|
+
"div",
|
|
1803
|
+
{
|
|
1804
|
+
className: "media-toolbar",
|
|
1805
|
+
style: {
|
|
1806
|
+
left: h.x,
|
|
1807
|
+
top: h.y
|
|
1808
|
+
},
|
|
1809
|
+
onMouseDown: (i) => i.preventDefault(),
|
|
1810
|
+
children: [
|
|
1811
|
+
/* @__PURE__ */ r(
|
|
1812
|
+
"button",
|
|
1813
|
+
{
|
|
1814
|
+
type: "button",
|
|
1815
|
+
className: "media-btn",
|
|
1816
|
+
onClick: () => b(!y),
|
|
1817
|
+
title: "Replace media",
|
|
1818
|
+
children: "🔄 Replace"
|
|
1819
|
+
}
|
|
1820
|
+
),
|
|
1821
|
+
/* @__PURE__ */ r("div", { className: "toolbar-divider" }),
|
|
1822
|
+
/* @__PURE__ */ r(
|
|
1823
|
+
"button",
|
|
1824
|
+
{
|
|
1825
|
+
type: "button",
|
|
1826
|
+
className: "media-btn media-btn-danger",
|
|
1827
|
+
onClick: c,
|
|
1828
|
+
title: "Delete media",
|
|
1829
|
+
children: "🗑️"
|
|
1830
|
+
}
|
|
1831
|
+
)
|
|
1832
|
+
]
|
|
1833
|
+
}
|
|
1834
|
+
),
|
|
1835
|
+
y && /* @__PURE__ */ k(
|
|
1836
|
+
"div",
|
|
1837
|
+
{
|
|
1838
|
+
className: "asset-picker",
|
|
1839
|
+
style: {
|
|
1840
|
+
left: h.x,
|
|
1841
|
+
top: h.y + 52
|
|
1842
|
+
},
|
|
1843
|
+
children: [
|
|
1844
|
+
/* @__PURE__ */ k("div", { className: "asset-picker-header", children: [
|
|
1845
|
+
/* @__PURE__ */ r("span", { className: "asset-picker-title", children: A ? "Replace Image" : "Replace Video" }),
|
|
1846
|
+
/* @__PURE__ */ r(
|
|
1847
|
+
"button",
|
|
1848
|
+
{
|
|
1849
|
+
type: "button",
|
|
1850
|
+
className: "asset-picker-close",
|
|
1851
|
+
onClick: () => b(!1),
|
|
1852
|
+
children: "✕"
|
|
1853
|
+
}
|
|
1854
|
+
)
|
|
1855
|
+
] }),
|
|
1856
|
+
d && /* @__PURE__ */ r("div", { className: "asset-upload", children: /* @__PURE__ */ k("label", { className: "upload-btn", children: [
|
|
1857
|
+
f ? "Uploading..." : "📤 Upload new",
|
|
1858
|
+
/* @__PURE__ */ r(
|
|
1859
|
+
"input",
|
|
1860
|
+
{
|
|
1861
|
+
type: "file",
|
|
1862
|
+
accept: A ? "image/*" : "video/*",
|
|
1863
|
+
onChange: x,
|
|
1864
|
+
disabled: f,
|
|
1865
|
+
hidden: !0
|
|
1866
|
+
}
|
|
1867
|
+
)
|
|
1868
|
+
] }) }),
|
|
1869
|
+
n.length > 0 && /* @__PURE__ */ k(bt, { children: [
|
|
1870
|
+
/* @__PURE__ */ r("div", { className: "asset-divider", children: "or choose from library" }),
|
|
1871
|
+
/* @__PURE__ */ r("div", { className: "asset-grid", children: n.filter((i) => A ? i.type === "image" : i.type === "video").map((i) => /* @__PURE__ */ r(
|
|
1872
|
+
"button",
|
|
1873
|
+
{
|
|
1874
|
+
type: "button",
|
|
1875
|
+
className: `asset-item ${i.url === a ? "active" : ""}`,
|
|
1876
|
+
onClick: () => {
|
|
1877
|
+
o(i.url), b(!1);
|
|
1878
|
+
},
|
|
1879
|
+
title: i.name,
|
|
1880
|
+
children: i.type === "image" ? /* @__PURE__ */ r("img", { src: i.url, alt: i.name }) : /* @__PURE__ */ r("video", { src: i.url })
|
|
1881
|
+
},
|
|
1882
|
+
i.id
|
|
1883
|
+
)) })
|
|
1884
|
+
] }),
|
|
1885
|
+
n.length === 0 && !d && /* @__PURE__ */ r("div", { className: "asset-empty", children: "No assets available" })
|
|
1886
|
+
]
|
|
1887
|
+
}
|
|
1888
|
+
)
|
|
1889
|
+
] });
|
|
1890
|
+
}
|
|
1891
|
+
function Hn({ editorRef: t, onDragStart: n, findBlockParent: o }) {
|
|
1892
|
+
const [c, d] = z({
|
|
1893
|
+
x: 0,
|
|
1894
|
+
y: 0,
|
|
1895
|
+
visible: !1,
|
|
1896
|
+
targetElement: null
|
|
1897
|
+
}), h = V(null), u = V(null), y = V(!1), b = p((a) => {
|
|
1898
|
+
if (!t.current) return;
|
|
1899
|
+
u.current && (clearTimeout(u.current), u.current = null);
|
|
1900
|
+
const i = a.getBoundingClientRect(), v = t.current.getBoundingClientRect();
|
|
1901
|
+
d({
|
|
1902
|
+
x: v.left - 36,
|
|
1903
|
+
y: i.top + i.height / 2 - 12,
|
|
1904
|
+
visible: !0,
|
|
1905
|
+
targetElement: a
|
|
1906
|
+
});
|
|
1907
|
+
}, [t]), f = p((a = 150) => {
|
|
1908
|
+
y.current || (u.current && clearTimeout(u.current), u.current = setTimeout(() => {
|
|
1909
|
+
y.current || d((i) => ({ ...i, visible: !1, targetElement: null }));
|
|
1910
|
+
}, a));
|
|
1911
|
+
}, []), N = p((a) => {
|
|
1912
|
+
if (!t.current) return;
|
|
1913
|
+
const i = a.target;
|
|
1914
|
+
if (i.closest(".drag-handle")) return;
|
|
1915
|
+
const v = o(i);
|
|
1916
|
+
v ? b(v) : f();
|
|
1917
|
+
}, [t, o, b, f]);
|
|
1918
|
+
X(() => {
|
|
1919
|
+
const a = t.current;
|
|
1920
|
+
if (!a) return;
|
|
1921
|
+
const i = (F) => {
|
|
1922
|
+
N(F);
|
|
1923
|
+
}, v = () => {
|
|
1924
|
+
f(300);
|
|
1925
|
+
};
|
|
1926
|
+
return a.addEventListener("mousemove", i), a.addEventListener("mouseleave", v), () => {
|
|
1927
|
+
a.removeEventListener("mousemove", i), a.removeEventListener("mouseleave", v), u.current && clearTimeout(u.current);
|
|
1928
|
+
};
|
|
1929
|
+
}, [t, N, f]);
|
|
1930
|
+
const T = p(() => {
|
|
1931
|
+
y.current = !0, u.current && (clearTimeout(u.current), u.current = null);
|
|
1932
|
+
}, []), x = p(() => {
|
|
1933
|
+
y.current = !1, f(300);
|
|
1934
|
+
}, [f]), A = p((a) => {
|
|
1935
|
+
a.preventDefault(), c.targetElement && n(c.targetElement, a.nativeEvent);
|
|
1936
|
+
}, [c.targetElement, n]);
|
|
1937
|
+
return c.visible ? /* @__PURE__ */ r(
|
|
1938
|
+
"div",
|
|
1939
|
+
{
|
|
1940
|
+
ref: h,
|
|
1941
|
+
className: "drag-handle",
|
|
1942
|
+
style: {
|
|
1943
|
+
left: c.x,
|
|
1944
|
+
top: c.y
|
|
1945
|
+
},
|
|
1946
|
+
onMouseEnter: T,
|
|
1947
|
+
onMouseLeave: x,
|
|
1948
|
+
onMouseDown: A,
|
|
1949
|
+
title: "Drag to reorder",
|
|
1950
|
+
children: /* @__PURE__ */ k("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: [
|
|
1951
|
+
/* @__PURE__ */ r("circle", { cx: "5", cy: "4", r: "1.5" }),
|
|
1952
|
+
/* @__PURE__ */ r("circle", { cx: "11", cy: "4", r: "1.5" }),
|
|
1953
|
+
/* @__PURE__ */ r("circle", { cx: "5", cy: "8", r: "1.5" }),
|
|
1954
|
+
/* @__PURE__ */ r("circle", { cx: "11", cy: "8", r: "1.5" }),
|
|
1955
|
+
/* @__PURE__ */ r("circle", { cx: "5", cy: "12", r: "1.5" }),
|
|
1956
|
+
/* @__PURE__ */ r("circle", { cx: "11", cy: "12", r: "1.5" })
|
|
1957
|
+
] })
|
|
1958
|
+
}
|
|
1959
|
+
) : null;
|
|
1960
|
+
}
|
|
1961
|
+
function Wn({ y: t }) {
|
|
1962
|
+
return t === null ? null : /* @__PURE__ */ k(
|
|
1963
|
+
"div",
|
|
1964
|
+
{
|
|
1965
|
+
className: "drop-indicator",
|
|
1966
|
+
style: { top: t },
|
|
1967
|
+
children: [
|
|
1968
|
+
/* @__PURE__ */ r("div", { className: "drop-indicator-dot" }),
|
|
1969
|
+
/* @__PURE__ */ r("div", { className: "drop-indicator-line" }),
|
|
1970
|
+
/* @__PURE__ */ r("div", { className: "drop-indicator-dot" })
|
|
1971
|
+
]
|
|
1972
|
+
}
|
|
1973
|
+
);
|
|
1974
|
+
}
|
|
1975
|
+
function Gn({ selectedImage: t, onResize: n }) {
|
|
1976
|
+
const [o, c] = z({ x: 0, y: 0, width: 0, height: 0, visible: !1 }), [d, h] = z({
|
|
1977
|
+
isResizing: !1,
|
|
1978
|
+
handle: null,
|
|
1979
|
+
startX: 0,
|
|
1980
|
+
startY: 0,
|
|
1981
|
+
startWidth: 0,
|
|
1982
|
+
startHeight: 0
|
|
1983
|
+
}), u = V(1), y = p(() => {
|
|
1984
|
+
if (!t) {
|
|
1985
|
+
c((N) => ({ ...N, visible: !1 }));
|
|
1986
|
+
return;
|
|
1987
|
+
}
|
|
1988
|
+
const f = t.getBoundingClientRect();
|
|
1989
|
+
c({
|
|
1990
|
+
x: f.left,
|
|
1991
|
+
y: f.top,
|
|
1992
|
+
width: f.width,
|
|
1993
|
+
height: f.height,
|
|
1994
|
+
visible: !0
|
|
1995
|
+
}), u.current = f.width / f.height;
|
|
1996
|
+
}, [t]);
|
|
1997
|
+
X(() => {
|
|
1998
|
+
y();
|
|
1999
|
+
const f = () => y(), N = () => y();
|
|
2000
|
+
return window.addEventListener("scroll", f, !0), window.addEventListener("resize", N), () => {
|
|
2001
|
+
window.removeEventListener("scroll", f, !0), window.removeEventListener("resize", N);
|
|
2002
|
+
};
|
|
2003
|
+
}, [y]);
|
|
2004
|
+
const b = p((f, N) => {
|
|
2005
|
+
if (f.preventDefault(), f.stopPropagation(), !t) return;
|
|
2006
|
+
const T = t.getBoundingClientRect();
|
|
2007
|
+
h({
|
|
2008
|
+
isResizing: !0,
|
|
2009
|
+
handle: N,
|
|
2010
|
+
startX: f.clientX,
|
|
2011
|
+
startY: f.clientY,
|
|
2012
|
+
startWidth: T.width,
|
|
2013
|
+
startHeight: T.height
|
|
2014
|
+
});
|
|
2015
|
+
}, [t]);
|
|
2016
|
+
return X(() => {
|
|
2017
|
+
if (!d.isResizing || !t) return;
|
|
2018
|
+
const f = (T) => {
|
|
2019
|
+
const x = T.clientX - d.startX;
|
|
2020
|
+
let A = d.startWidth, a = d.startHeight;
|
|
2021
|
+
switch (d.handle) {
|
|
2022
|
+
case "se":
|
|
2023
|
+
A = Math.max(50, d.startWidth + x), a = A / u.current;
|
|
2024
|
+
break;
|
|
2025
|
+
case "sw":
|
|
2026
|
+
A = Math.max(50, d.startWidth - x), a = A / u.current;
|
|
2027
|
+
break;
|
|
2028
|
+
case "ne":
|
|
2029
|
+
A = Math.max(50, d.startWidth + x), a = A / u.current;
|
|
2030
|
+
break;
|
|
2031
|
+
case "nw":
|
|
2032
|
+
A = Math.max(50, d.startWidth - x), a = A / u.current;
|
|
2033
|
+
break;
|
|
2034
|
+
}
|
|
2035
|
+
t.style.width = `${A}px`, t.style.height = `${a}px`, c((i) => ({
|
|
2036
|
+
...i,
|
|
2037
|
+
width: A,
|
|
2038
|
+
height: a
|
|
2039
|
+
}));
|
|
2040
|
+
}, N = () => {
|
|
2041
|
+
const T = parseInt(t.style.width), x = parseInt(t.style.height);
|
|
2042
|
+
!isNaN(T) && !isNaN(x) && n(T, x), h({
|
|
2043
|
+
isResizing: !1,
|
|
2044
|
+
handle: null,
|
|
2045
|
+
startX: 0,
|
|
2046
|
+
startY: 0,
|
|
2047
|
+
startWidth: 0,
|
|
2048
|
+
startHeight: 0
|
|
2049
|
+
});
|
|
2050
|
+
};
|
|
2051
|
+
return document.addEventListener("mousemove", f), document.addEventListener("mouseup", N), () => {
|
|
2052
|
+
document.removeEventListener("mousemove", f), document.removeEventListener("mouseup", N);
|
|
2053
|
+
};
|
|
2054
|
+
}, [d, t, n]), o.visible ? /* @__PURE__ */ k(
|
|
2055
|
+
"div",
|
|
2056
|
+
{
|
|
2057
|
+
className: `image-resizer ${d.isResizing ? "resizing" : ""}`,
|
|
2058
|
+
style: {
|
|
2059
|
+
left: o.x,
|
|
2060
|
+
top: o.y,
|
|
2061
|
+
width: o.width,
|
|
2062
|
+
height: o.height
|
|
2063
|
+
},
|
|
2064
|
+
children: [
|
|
2065
|
+
/* @__PURE__ */ r(
|
|
2066
|
+
"div",
|
|
2067
|
+
{
|
|
2068
|
+
className: "resize-handle nw",
|
|
2069
|
+
onMouseDown: (f) => b(f, "nw")
|
|
2070
|
+
}
|
|
2071
|
+
),
|
|
2072
|
+
/* @__PURE__ */ r(
|
|
2073
|
+
"div",
|
|
2074
|
+
{
|
|
2075
|
+
className: "resize-handle ne",
|
|
2076
|
+
onMouseDown: (f) => b(f, "ne")
|
|
2077
|
+
}
|
|
2078
|
+
),
|
|
2079
|
+
/* @__PURE__ */ r(
|
|
2080
|
+
"div",
|
|
2081
|
+
{
|
|
2082
|
+
className: "resize-handle sw",
|
|
2083
|
+
onMouseDown: (f) => b(f, "sw")
|
|
2084
|
+
}
|
|
2085
|
+
),
|
|
2086
|
+
/* @__PURE__ */ r(
|
|
2087
|
+
"div",
|
|
2088
|
+
{
|
|
2089
|
+
className: "resize-handle se",
|
|
2090
|
+
onMouseDown: (f) => b(f, "se")
|
|
2091
|
+
}
|
|
2092
|
+
),
|
|
2093
|
+
d.isResizing && /* @__PURE__ */ k("div", { className: "size-indicator", children: [
|
|
2094
|
+
Math.round(o.width),
|
|
2095
|
+
" × ",
|
|
2096
|
+
Math.round(o.height)
|
|
2097
|
+
] })
|
|
2098
|
+
]
|
|
2099
|
+
}
|
|
2100
|
+
) : null;
|
|
2101
|
+
}
|
|
2102
|
+
const Qt = typeof navigator < "u" && navigator.platform.toUpperCase().includes("MAC"), Te = Qt ? "⌘" : "Ctrl", $n = [
|
|
2103
|
+
{
|
|
2104
|
+
category: "Text Formatting",
|
|
2105
|
+
items: [
|
|
2106
|
+
{ keys: [`${Te}`, "B"], description: "Bold" },
|
|
2107
|
+
{ keys: [`${Te}`, "I"], description: "Italic" },
|
|
2108
|
+
{ keys: [`${Te}`, "U"], description: "Underline" },
|
|
2109
|
+
{ keys: [`${Te}`, "K"], description: "Insert link" }
|
|
2110
|
+
]
|
|
2111
|
+
},
|
|
2112
|
+
{
|
|
2113
|
+
category: "Headings",
|
|
2114
|
+
items: [
|
|
2115
|
+
{ keys: [`${Te}`, "Shift", "1"], description: "Heading 1" },
|
|
2116
|
+
{ keys: [`${Te}`, "Shift", "2"], description: "Heading 2" },
|
|
2117
|
+
{ keys: [`${Te}`, "Shift", "3"], description: "Heading 3" },
|
|
2118
|
+
{ keys: [`${Te}`, "Shift", "0"], description: "Paragraph" }
|
|
2119
|
+
]
|
|
2120
|
+
},
|
|
2121
|
+
{
|
|
2122
|
+
category: "History",
|
|
2123
|
+
items: [
|
|
2124
|
+
{ keys: [`${Te}`, "Z"], description: "Undo" },
|
|
2125
|
+
{ keys: [`${Te}`, "Shift", "Z"], description: "Redo" },
|
|
2126
|
+
...Qt ? [] : [{ keys: ["Ctrl", "Y"], description: "Redo (Alt)" }]
|
|
2127
|
+
]
|
|
2128
|
+
},
|
|
2129
|
+
{
|
|
2130
|
+
category: "Selection",
|
|
2131
|
+
items: [
|
|
2132
|
+
{ keys: ["Esc"], description: "Deselect / Close menu" },
|
|
2133
|
+
{ keys: ["Delete"], description: "Delete selected element" }
|
|
2134
|
+
]
|
|
2135
|
+
}
|
|
2136
|
+
];
|
|
2137
|
+
function Yn({ isOpen: t, onClose: n }) {
|
|
2138
|
+
const o = p((c) => {
|
|
2139
|
+
c.key === "Escape" && n();
|
|
2140
|
+
}, [n]);
|
|
2141
|
+
return X(() => {
|
|
2142
|
+
if (t)
|
|
2143
|
+
return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
|
|
2144
|
+
}, [t, o]), t ? /* @__PURE__ */ r("div", { className: "shortcuts-overlay", onClick: n, children: /* @__PURE__ */ k("div", { className: "shortcuts-modal", onClick: (c) => c.stopPropagation(), children: [
|
|
2145
|
+
/* @__PURE__ */ k("div", { className: "shortcuts-header", children: [
|
|
2146
|
+
/* @__PURE__ */ r("h2", { className: "shortcuts-title", children: "Keyboard Shortcuts" }),
|
|
2147
|
+
/* @__PURE__ */ r("button", { className: "shortcuts-close", onClick: n, children: "✕" })
|
|
2148
|
+
] }),
|
|
2149
|
+
/* @__PURE__ */ r("div", { className: "shortcuts-content", children: $n.map(({ category: c, items: d }) => /* @__PURE__ */ k("div", { className: "shortcuts-section", children: [
|
|
2150
|
+
/* @__PURE__ */ r("h3", { className: "shortcuts-category", children: c }),
|
|
2151
|
+
/* @__PURE__ */ r("div", { className: "shortcuts-list", children: d.map(({ keys: h, description: u }) => /* @__PURE__ */ k("div", { className: "shortcut-item", children: [
|
|
2152
|
+
/* @__PURE__ */ r("span", { className: "shortcut-desc", children: u }),
|
|
2153
|
+
/* @__PURE__ */ r("span", { className: "shortcut-keys", children: h.map((y, b) => /* @__PURE__ */ k("span", { children: [
|
|
2154
|
+
/* @__PURE__ */ r("kbd", { className: "shortcut-key", children: y }),
|
|
2155
|
+
b < h.length - 1 && /* @__PURE__ */ r("span", { className: "shortcut-plus", children: "+" })
|
|
2156
|
+
] }, b)) })
|
|
2157
|
+
] }, u)) })
|
|
2158
|
+
] }, c)) }),
|
|
2159
|
+
/* @__PURE__ */ k("div", { className: "shortcuts-footer", children: [
|
|
2160
|
+
"Press ",
|
|
2161
|
+
/* @__PURE__ */ r("kbd", { children: "Esc" }),
|
|
2162
|
+
" or click outside to close"
|
|
2163
|
+
] })
|
|
2164
|
+
] }) }) : null;
|
|
2165
|
+
}
|
|
2166
|
+
function qn({
|
|
2167
|
+
html: t,
|
|
2168
|
+
onChange: n,
|
|
2169
|
+
placeholder: o = "Start typing...",
|
|
2170
|
+
debounceMs: c = 300,
|
|
2171
|
+
assets: d = [],
|
|
2172
|
+
onUpload: h
|
|
2173
|
+
}) {
|
|
2174
|
+
const u = V(null), y = V(!1), b = V(!1), f = V(void 0), [N, T] = z(!1), [x, A] = z(!1), [a, i] = z(null), [v, F] = z({
|
|
2175
|
+
bold: !1,
|
|
2176
|
+
italic: !1,
|
|
2177
|
+
underline: !1,
|
|
2178
|
+
blockType: "p",
|
|
2179
|
+
bulletList: !1,
|
|
2180
|
+
numberedList: !1,
|
|
2181
|
+
currentLink: null,
|
|
2182
|
+
textColor: "",
|
|
2183
|
+
backgroundColor: "",
|
|
2184
|
+
fontFamily: "",
|
|
2185
|
+
fontSize: "",
|
|
2186
|
+
alignment: "left"
|
|
2187
|
+
}), { pushToHistory: q, undo: B, redo: L, canUndo: H, canRedo: Z } = Dn(t, {
|
|
2188
|
+
maxHistory: 50,
|
|
2189
|
+
debounceMs: 500
|
|
2190
|
+
}), W = p(() => {
|
|
2191
|
+
f.current && clearTimeout(f.current), f.current = setTimeout(() => {
|
|
2192
|
+
if (u.current) {
|
|
2193
|
+
y.current = !0;
|
|
2194
|
+
const S = u.current.innerHTML, P = _n(S);
|
|
2195
|
+
b.current || q(P), b.current = !1, n(P);
|
|
2196
|
+
}
|
|
2197
|
+
}, c);
|
|
2198
|
+
}, [n, c, q]), { dragState: Q, handleDragStart: ue, findBlockParent: de } = Mn({
|
|
2199
|
+
editorRef: u,
|
|
2200
|
+
onContentChange: W
|
|
2201
|
+
}), R = p(() => {
|
|
2202
|
+
const S = B();
|
|
2203
|
+
S !== null && u.current && (b.current = !0, y.current = !0, u.current.innerHTML = gt(S), n(S));
|
|
2204
|
+
}, [B, n]), J = p(() => {
|
|
2205
|
+
const S = L();
|
|
2206
|
+
S !== null && u.current && (b.current = !0, y.current = !0, u.current.innerHTML = gt(S), n(S));
|
|
2207
|
+
}, [L, n]), {
|
|
2208
|
+
toggleBold: ae,
|
|
2209
|
+
toggleItalic: ge,
|
|
2210
|
+
toggleUnderline: _e,
|
|
2211
|
+
toggleStrikethrough: be,
|
|
2212
|
+
toggleBulletList: l,
|
|
2213
|
+
toggleNumberedList: m,
|
|
2214
|
+
setBlockType: D,
|
|
2215
|
+
getCurrentBlockType: M,
|
|
2216
|
+
isFormatActive: C,
|
|
2217
|
+
isInList: $,
|
|
2218
|
+
insertLink: G,
|
|
2219
|
+
removeLink: Fe,
|
|
2220
|
+
getCurrentLink: O,
|
|
2221
|
+
setTextColor: Ne,
|
|
2222
|
+
setBackgroundColor: De,
|
|
2223
|
+
getCurrentTextColor: me,
|
|
2224
|
+
getCurrentBackgroundColor: Me,
|
|
2225
|
+
setFontFamily: Oe,
|
|
2226
|
+
setFontSize: Ue,
|
|
2227
|
+
getCurrentFontFamily: Ie,
|
|
2228
|
+
getCurrentFontSize: fe,
|
|
2229
|
+
setAlignment: Ae,
|
|
2230
|
+
getCurrentAlignment: w,
|
|
2231
|
+
insertBlockquote: I,
|
|
2232
|
+
insertCodeBlock: ee,
|
|
2233
|
+
insertHorizontalRule: pe
|
|
2234
|
+
} = xn({
|
|
2235
|
+
editorRef: u,
|
|
2236
|
+
onContentChange: W
|
|
2237
|
+
}), le = p(() => {
|
|
2238
|
+
F({
|
|
2239
|
+
bold: C("bold"),
|
|
2240
|
+
italic: C("italic"),
|
|
2241
|
+
underline: C("underline"),
|
|
2242
|
+
blockType: M(),
|
|
2243
|
+
bulletList: $("ul"),
|
|
2244
|
+
numberedList: $("ol"),
|
|
2245
|
+
currentLink: O(),
|
|
2246
|
+
textColor: me(),
|
|
2247
|
+
backgroundColor: Me(),
|
|
2248
|
+
fontFamily: Ie(),
|
|
2249
|
+
fontSize: fe(),
|
|
2250
|
+
alignment: w()
|
|
2251
|
+
});
|
|
2252
|
+
}, [
|
|
2253
|
+
C,
|
|
2254
|
+
M,
|
|
2255
|
+
$,
|
|
2256
|
+
O,
|
|
2257
|
+
me,
|
|
2258
|
+
Me,
|
|
2259
|
+
Ie,
|
|
2260
|
+
fe,
|
|
2261
|
+
w
|
|
2262
|
+
]), Le = p(
|
|
2263
|
+
(S) => {
|
|
2264
|
+
const P = S.target;
|
|
2265
|
+
P.tagName === "IMG" || P.tagName === "VIDEO" ? (S.preventDefault(), i(P), P.classList.add("media-selected")) : a && (a.classList.remove("media-selected"), i(null));
|
|
2266
|
+
},
|
|
2267
|
+
[a]
|
|
2268
|
+
), Re = p(
|
|
2269
|
+
(S) => {
|
|
2270
|
+
a && (a.setAttribute("src", S), a.classList.remove("media-selected"), i(null), W());
|
|
2271
|
+
},
|
|
2272
|
+
[a, W]
|
|
2273
|
+
), Ee = p(() => {
|
|
2274
|
+
a && (a.classList.remove("media-selected"), a.remove(), i(null), W());
|
|
2275
|
+
}, [a, W]), Pe = p(
|
|
2276
|
+
(S, P) => {
|
|
2277
|
+
a && a.tagName === "IMG" && (a.setAttribute("width", String(S)), a.setAttribute("height", String(P)), a.style.width = `${S}px`, a.style.height = `${P}px`, W());
|
|
2278
|
+
},
|
|
2279
|
+
[a, W]
|
|
2280
|
+
);
|
|
2281
|
+
X(() => {
|
|
2282
|
+
const S = (P) => {
|
|
2283
|
+
if (a && (P.key === "Delete" || P.key === "Backspace")) {
|
|
2284
|
+
P.preventDefault(), Ee();
|
|
2285
|
+
return;
|
|
2286
|
+
}
|
|
2287
|
+
if (a && P.key === "Escape") {
|
|
2288
|
+
a.classList.remove("media-selected"), i(null);
|
|
2289
|
+
return;
|
|
2290
|
+
}
|
|
2291
|
+
if (!u.current?.contains(document.activeElement))
|
|
2292
|
+
return;
|
|
2293
|
+
const Ge = navigator.platform.toUpperCase().includes("MAC");
|
|
2294
|
+
(Ge ? P.metaKey : P.ctrlKey) && ((P.key === "z" || P.key === "Z") && (P.preventDefault(), P.shiftKey ? J() : R()), P.key === "y" && !Ge && (P.preventDefault(), J()));
|
|
2295
|
+
};
|
|
2296
|
+
return document.addEventListener("keydown", S), () => document.removeEventListener("keydown", S);
|
|
2297
|
+
}, [R, J, a, Ee]), X(() => {
|
|
2298
|
+
if (u.current && !y.current) {
|
|
2299
|
+
Ln(t) && (T(!0), setTimeout(() => T(!1), 3e3));
|
|
2300
|
+
const S = gt(t);
|
|
2301
|
+
u.current.innerHTML !== S && (u.current.innerHTML = S);
|
|
2302
|
+
}
|
|
2303
|
+
y.current = !1;
|
|
2304
|
+
}, [t]);
|
|
2305
|
+
const ke = p(() => {
|
|
2306
|
+
W(), le();
|
|
2307
|
+
}, [W, le]);
|
|
2308
|
+
X(() => {
|
|
2309
|
+
const S = () => {
|
|
2310
|
+
u.current?.contains(document.activeElement) && le();
|
|
2311
|
+
};
|
|
2312
|
+
return document.addEventListener("selectionchange", S), () => document.removeEventListener("selectionchange", S);
|
|
2313
|
+
}, [le]), X(() => () => {
|
|
2314
|
+
f.current && clearTimeout(f.current);
|
|
2315
|
+
}, []);
|
|
2316
|
+
const se = p((S) => {
|
|
2317
|
+
S.preventDefault();
|
|
2318
|
+
}, []), xe = !t || t === "<br>" || t === "<p><br></p>";
|
|
2319
|
+
return /* @__PURE__ */ k(
|
|
2320
|
+
"div",
|
|
2321
|
+
{
|
|
2322
|
+
className: `wysiwyg-editor-wrapper ${Q.isDragging ? "is-dragging" : ""}`,
|
|
2323
|
+
children: [
|
|
2324
|
+
N && /* @__PURE__ */ r("div", { className: "wysiwyg-warning", children: "⚠️ Potentially unsafe content was sanitized" }),
|
|
2325
|
+
!Q.isDragging && /* @__PURE__ */ r(
|
|
2326
|
+
Un,
|
|
2327
|
+
{
|
|
2328
|
+
editorRef: u,
|
|
2329
|
+
formatState: v,
|
|
2330
|
+
onBold: ae,
|
|
2331
|
+
onItalic: ge,
|
|
2332
|
+
onUnderline: _e,
|
|
2333
|
+
onStrikethrough: be,
|
|
2334
|
+
onBlockType: D,
|
|
2335
|
+
onBulletList: l,
|
|
2336
|
+
onNumberedList: m,
|
|
2337
|
+
onInsertLink: G,
|
|
2338
|
+
onRemoveLink: Fe,
|
|
2339
|
+
onTextColor: Ne,
|
|
2340
|
+
onBackgroundColor: De,
|
|
2341
|
+
onFontFamily: Oe,
|
|
2342
|
+
onFontSize: Ue,
|
|
2343
|
+
onAlignment: Ae,
|
|
2344
|
+
onInsertBlockquote: I,
|
|
2345
|
+
onInsertCodeBlock: ee,
|
|
2346
|
+
onInsertHorizontalRule: pe
|
|
2347
|
+
}
|
|
2348
|
+
),
|
|
2349
|
+
!Q.isDragging && /* @__PURE__ */ r(
|
|
2350
|
+
Bn,
|
|
2351
|
+
{
|
|
2352
|
+
selectedElement: a,
|
|
2353
|
+
assets: d,
|
|
2354
|
+
onReplace: Re,
|
|
2355
|
+
onDelete: Ee,
|
|
2356
|
+
onUpload: h
|
|
2357
|
+
}
|
|
2358
|
+
),
|
|
2359
|
+
!Q.isDragging && a?.tagName === "IMG" && /* @__PURE__ */ r(
|
|
2360
|
+
Gn,
|
|
2361
|
+
{
|
|
2362
|
+
selectedImage: a,
|
|
2363
|
+
onResize: Pe
|
|
2364
|
+
}
|
|
2365
|
+
),
|
|
2366
|
+
!Q.isDragging && /* @__PURE__ */ r(
|
|
2367
|
+
Hn,
|
|
2368
|
+
{
|
|
2369
|
+
editorRef: u,
|
|
2370
|
+
onDragStart: ue,
|
|
2371
|
+
findBlockParent: de
|
|
2372
|
+
}
|
|
2373
|
+
),
|
|
2374
|
+
/* @__PURE__ */ r(Wn, { y: Q.dropIndicatorY }),
|
|
2375
|
+
/* @__PURE__ */ k("div", { className: "wysiwyg-hint-bar", children: [
|
|
2376
|
+
/* @__PURE__ */ k("div", { className: "history-buttons", children: [
|
|
2377
|
+
/* @__PURE__ */ r(
|
|
2378
|
+
"button",
|
|
2379
|
+
{
|
|
2380
|
+
type: "button",
|
|
2381
|
+
className: `history-btn ${H ? "" : "disabled"}`,
|
|
2382
|
+
onClick: R,
|
|
2383
|
+
disabled: !H,
|
|
2384
|
+
title: "Undo (Ctrl+Z)",
|
|
2385
|
+
children: "↶ Undo"
|
|
2386
|
+
}
|
|
2387
|
+
),
|
|
2388
|
+
/* @__PURE__ */ r(
|
|
2389
|
+
"button",
|
|
2390
|
+
{
|
|
2391
|
+
type: "button",
|
|
2392
|
+
className: `history-btn ${Z ? "" : "disabled"}`,
|
|
2393
|
+
onClick: J,
|
|
2394
|
+
disabled: !Z,
|
|
2395
|
+
title: "Redo (Ctrl+Shift+Z)",
|
|
2396
|
+
children: "↷ Redo"
|
|
2397
|
+
}
|
|
2398
|
+
)
|
|
2399
|
+
] }),
|
|
2400
|
+
/* @__PURE__ */ r("span", { className: "hint-text", children: "Drag ⋮⋮ to reorder • Select text to format" }),
|
|
2401
|
+
/* @__PURE__ */ r(
|
|
2402
|
+
"button",
|
|
2403
|
+
{
|
|
2404
|
+
type: "button",
|
|
2405
|
+
className: "shortcuts-btn",
|
|
2406
|
+
onClick: () => A(!0),
|
|
2407
|
+
title: "Keyboard shortcuts",
|
|
2408
|
+
children: "⌨️"
|
|
2409
|
+
}
|
|
2410
|
+
)
|
|
2411
|
+
] }),
|
|
2412
|
+
/* @__PURE__ */ r(
|
|
2413
|
+
Yn,
|
|
2414
|
+
{
|
|
2415
|
+
isOpen: x,
|
|
2416
|
+
onClose: () => A(!1)
|
|
2417
|
+
}
|
|
2418
|
+
),
|
|
2419
|
+
/* @__PURE__ */ r(
|
|
2420
|
+
"div",
|
|
2421
|
+
{
|
|
2422
|
+
ref: u,
|
|
2423
|
+
className: `wysiwyg-editor ${xe ? "wysiwyg-editor--empty" : ""}`,
|
|
2424
|
+
contentEditable: !0,
|
|
2425
|
+
suppressContentEditableWarning: !0,
|
|
2426
|
+
onInput: ke,
|
|
2427
|
+
onClick: Le,
|
|
2428
|
+
onDragStart: se,
|
|
2429
|
+
"data-placeholder": o,
|
|
2430
|
+
spellCheck: !0,
|
|
2431
|
+
role: "textbox",
|
|
2432
|
+
"aria-multiline": "true",
|
|
2433
|
+
"aria-label": "Rich text editor",
|
|
2434
|
+
"aria-placeholder": o
|
|
2435
|
+
}
|
|
2436
|
+
)
|
|
2437
|
+
]
|
|
2438
|
+
}
|
|
2439
|
+
);
|
|
2440
|
+
}
|
|
2441
|
+
export {
|
|
2442
|
+
qn as WysiwygEditor,
|
|
2443
|
+
Ln as containsDangerousContent,
|
|
2444
|
+
_n as sanitizeForOutput,
|
|
2445
|
+
gt as sanitizeHtml,
|
|
2446
|
+
Mn as useDragAndDrop,
|
|
2447
|
+
Dn as useHistory,
|
|
2448
|
+
xn as useTextFormatting
|
|
2449
|
+
};
|
|
2450
|
+
//# sourceMappingURL=wysiwyg-editor.js.map
|