wds-editor 1.1.0 → 1.2.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.
@@ -1,30 +1,119 @@
1
- import { TextSelection as Ye, NodeSelection as he, PluginKey as Qt, Plugin as Ct, EditorState as Zt } from "prosemirror-state";
2
- import { DecorationSet as Dt, Decoration as Nt, EditorView as en } from "prosemirror-view";
3
- import { redo as Be, undo as It, redoDepth as tn, undoDepth as nn, history as rn } from "prosemirror-history";
4
- import { Schema as Ht, DOMParser as on, DOMSerializer as an, Fragment as Ot, Slice as Rt } from "prosemirror-model";
5
- import { addListNodes as sn, sinkListItem as ln, liftListItem as $t, wrapInList as cn, splitListItem as dn } from "prosemirror-schema-list";
6
- import { tableNodes as un, isInTable as me, goToNextCell as Fe, addRowAfter as zt, tableEditing as hn, addRowBefore as pn, addColumnBefore as mn, addColumnAfter as fn, deleteRow as gn, deleteColumn as bn, toggleHeaderRow as wn, toggleHeaderColumn as yn, mergeCells as vn, splitCell as kn, deleteTable as Mn } from "prosemirror-tables";
7
- import { inputRules as Ln, InputRule as xn, textblockTypeInputRule as it, wrappingInputRule as Ce, undoInputRule as En } from "prosemirror-inputrules";
8
- import { keymap as Je } from "prosemirror-keymap";
9
- import { lift as Bt, toggleMark as Sn, setBlockType as De, wrapIn as An, chainCommands as Tn, exitCode as Cn, baseKeymap as Dn } from "prosemirror-commands";
10
- import { gapCursor as Nn } from "prosemirror-gapcursor";
11
- import { dropCursor as In } from "prosemirror-dropcursor";
12
- const Hn = /^(https?:|mailto:|tel:)/i, Ft = /^[a-z][a-z0-9+.-]*:/i;
1
+ import { NodeSelection as Z, TextSelection as be, PluginKey as Ut, Plugin as it, EditorState as pn } from "prosemirror-state";
2
+ import { DecorationSet as st, Decoration as ot, EditorView as gn } from "prosemirror-view";
3
+ import { redo as je, undo as Wt, redoDepth as bn, undoDepth as wn, history as yn } from "prosemirror-history";
4
+ import { Schema as _t, DOMParser as vn, DOMSerializer as kn, Fragment as Vt, Slice as qt } from "prosemirror-model";
5
+ import { addListNodes as Mn, sinkListItem as xn, liftListItem as Gt, wrapInList as Ln, splitListItem as Sn } from "prosemirror-schema-list";
6
+ import { tableNodes as En, isInTable as we, goToNextCell as Ke, addRowAfter as jt, tableEditing as An, addRowBefore as Tn, addColumnBefore as Cn, addColumnAfter as In, deleteRow as Dn, deleteColumn as Nn, toggleHeaderRow as Rn, toggleHeaderColumn as $n, mergeCells as On, splitCell as Hn, deleteTable as Pn } from "prosemirror-tables";
7
+ import { inputRules as Bn, InputRule as zn, textblockTypeInputRule as gt, wrappingInputRule as $e, undoInputRule as Fn } from "prosemirror-inputrules";
8
+ import { keymap as at } from "prosemirror-keymap";
9
+ import { lift as Kt, toggleMark as Un, setBlockType as Oe, wrapIn as Wn, chainCommands as _n, exitCode as Vn, baseKeymap as qn } from "prosemirror-commands";
10
+ import { gapCursor as Gn } from "prosemirror-gapcursor";
11
+ import { dropCursor as jn } from "prosemirror-dropcursor";
12
+ const Kn = /^(https?:|mailto:|tel:)/i, Yt = /^[a-z][a-z0-9+.-]*:/i;
13
13
  function q(t) {
14
14
  if (t == null) return null;
15
15
  const e = t.trim();
16
16
  if (!e) return null;
17
17
  const n = e.replace(/[\u0000- \u007f-\u009f]/g, "");
18
- return Ft.test(n) && !Hn.test(n) ? null : e;
18
+ return Yt.test(n) && !Kn.test(n) ? null : e;
19
19
  }
20
- function at(t) {
20
+ function bt(t) {
21
21
  const e = t.trim();
22
- return e ? /^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(e) ? `mailto:${e}` : !Ft.test(e) && !/^[/#?.]/.test(e) && /^[\w-]+(\.[\w-]+)+/.test(e) ? `https://${e}` : q(e) : null;
22
+ return e ? /^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(e) ? `mailto:${e}` : !Yt.test(e) && !/^[/#?.]/.test(e) && /^[\w-]+(\.[\w-]+)+/.test(e) ? `https://${e}` : q(e) : null;
23
23
  }
24
- function On(t) {
24
+ function Yn(t) {
25
25
  return t.replace(/<!--[\s\S]*?-->/g, "").replace(/<\/?o:p[^>]*>/gi, "").replace(/<\/?(w|m|v):[^>]*>/gi, "").replace(/<xml[\s\S]*?<\/xml>/gi, "").replace(/<style[\s\S]*?<\/style>/gi, "").replace(/<meta[^>]*>/gi, "").replace(/<link[^>]*>/gi, "");
26
26
  }
27
- const st = {
27
+ const Jn = /^[\w-]{11}$/, Jt = 560;
28
+ function Xn(t) {
29
+ if (!t) return 0;
30
+ if (/^\d+$/.test(t)) return +t;
31
+ const e = t.match(/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/);
32
+ return e ? +(e[1] ?? 0) * 3600 + +(e[2] ?? 0) * 60 + +(e[3] ?? 0) : 0;
33
+ }
34
+ function Le(t) {
35
+ if (!t) return null;
36
+ let e = t.trim();
37
+ const n = e.match(/<iframe[^>]*\ssrc=["']([^"']+)["']/i);
38
+ n && (e = n[1]), e.startsWith("//") && (e = `https:${e}`), /^https?:\/\//i.test(e) || (e = `https://${e}`);
39
+ let r;
40
+ try {
41
+ r = new URL(e.replace(/&amp;/g, "&"));
42
+ } catch {
43
+ return null;
44
+ }
45
+ const i = r.hostname.replace(/^(www|m|music)\./, ""), s = r.pathname.split("/").filter(Boolean);
46
+ if (i === "youtube.com" || i === "youtube-nocookie.com" || i === "youtu.be") {
47
+ let o = null;
48
+ if (i === "youtu.be" ? o = s[0] ?? null : s[0] === "watch" ? o = r.searchParams.get("v") : ["embed", "shorts", "live", "v"].includes(s[0]) && (o = s[1] ?? null), !o || !Jn.test(o)) return null;
49
+ const c = Xn(r.searchParams.get("start") ?? r.searchParams.get("t"));
50
+ return `https://www.youtube-nocookie.com/embed/${o}${c ? `?start=${c}` : ""}`;
51
+ }
52
+ if (i === "vimeo.com" || i === "player.vimeo.com") {
53
+ const o = s.findIndex((l) => /^\d+$/.test(l));
54
+ if (o < 0) return null;
55
+ const c = s[o], a = r.searchParams.get("h") ?? (i === "vimeo.com" && /^[\da-f]+$/i.test(s[o + 1] ?? "") ? s[o + 1] : null);
56
+ return `https://player.vimeo.com/video/${c}${a ? `?h=${a}` : ""}`;
57
+ }
58
+ return null;
59
+ }
60
+ const Qn = (t) => {
61
+ const e = parseInt(t.style.maxWidth, 10), n = parseInt(t.getAttribute("width") ?? "", 10), r = e > 0 ? e : n;
62
+ return r > 0 && r <= 4e3 ? r : null;
63
+ };
64
+ function Xt(t) {
65
+ const e = t.width ?? Jt;
66
+ return {
67
+ src: t.src,
68
+ title: t.title || "Video",
69
+ width: String(e),
70
+ height: String(Math.round(e * 9 / 16)),
71
+ style: `width: 100%; max-width: ${e}px; height: auto; aspect-ratio: 16 / 9; border: 0`,
72
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",
73
+ referrerpolicy: "strict-origin-when-cross-origin",
74
+ loading: "lazy",
75
+ allowfullscreen: "true"
76
+ };
77
+ }
78
+ const Zn = {
79
+ group: "block",
80
+ atom: !0,
81
+ draggable: !0,
82
+ attrs: { src: {}, title: { default: "" }, width: { default: null } },
83
+ parseDOM: [
84
+ {
85
+ tag: "iframe[src]",
86
+ getAttrs: (t) => {
87
+ const e = t, n = Le(e.getAttribute("src"));
88
+ if (!n) return !1;
89
+ const r = e.getAttribute("title") ?? "";
90
+ return { src: n, title: r === "Video" ? "" : r, width: Qn(e) };
91
+ }
92
+ }
93
+ ],
94
+ toDOM: (t) => ["iframe", Xt(t.attrs)]
95
+ };
96
+ class er {
97
+ constructor(e, n, r) {
98
+ this.onEdit = n, this.dom = document.createElement("div"), this.dom.className = "wds-video", this.dom.contentEditable = "false", this.iframe = document.createElement("iframe"), this.dom.append(this.iframe), this.dom.addEventListener("dblclick", () => this.onEdit()), this.render(e);
99
+ }
100
+ render(e) {
101
+ const n = Xt(e.attrs);
102
+ for (const [r, i] of Object.entries(n))
103
+ this.iframe.getAttribute(r) !== i && this.iframe.setAttribute(r, i);
104
+ this.iframe.tabIndex = -1, this.dom.style.maxWidth = `${e.attrs.width ?? Jt}px`;
105
+ }
106
+ update(e) {
107
+ return e.type.name !== "video" ? !1 : (this.render(e), !0);
108
+ }
109
+ stopEvent() {
110
+ return !1;
111
+ }
112
+ ignoreMutation() {
113
+ return !0;
114
+ }
115
+ }
116
+ const wt = {
28
117
  black: "#000000",
29
118
  white: "#ffffff",
30
119
  red: "#ff0000",
@@ -53,23 +142,23 @@ const st = {
53
142
  lightgrey: "#d3d3d3",
54
143
  darkgray: "#a9a9a9",
55
144
  darkgrey: "#a9a9a9"
56
- }, Ne = (t) => Math.max(0, Math.min(255, Math.round(t))).toString(16).padStart(2, "0");
57
- function re(t) {
145
+ }, He = (t) => Math.max(0, Math.min(255, Math.round(t))).toString(16).padStart(2, "0");
146
+ function se(t) {
58
147
  if (!t) return null;
59
148
  const e = t.trim().toLowerCase().replace(/\s*!important$/, "");
60
- if (st[e]) return st[e];
149
+ if (wt[e]) return wt[e];
61
150
  let n = /^#([0-9a-f]{3})$/.exec(e);
62
- return n ? "#" + [...n[1]].map((r) => r + r).join("") : (n = /^#([0-9a-f]{6})(ff)?$/.exec(e), n ? "#" + n[1] : (n = /^rgba?\(\s*(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/.exec(e), n ? n[4] !== void 0 && (n[4].endsWith("%") ? parseFloat(n[4]) / 100 : parseFloat(n[4])) < 1 ? null : "#" + Ne(+n[1]) + Ne(+n[2]) + Ne(+n[3]) : null));
151
+ return n ? "#" + [...n[1]].map((r) => r + r).join("") : (n = /^#([0-9a-f]{6})(ff)?$/.exec(e), n ? "#" + n[1] : (n = /^rgba?\(\s*(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)(?:\s*[,/]\s*([\d.]+%?))?\s*\)$/.exec(e), n ? n[4] !== void 0 && (n[4].endsWith("%") ? parseFloat(n[4]) / 100 : parseFloat(n[4])) < 1 ? null : "#" + He(+n[1]) + He(+n[2]) + He(+n[3]) : null));
63
152
  }
64
- function lt(t) {
65
- const e = re(t);
153
+ function yt(t) {
154
+ const e = se(t);
66
155
  return e && e !== "#000000" ? e : null;
67
156
  }
68
- function Ie(t) {
69
- const e = re(t) ?? re((t ?? "").split(/\s+(?![^(]*\))/).find((n) => re(n)));
157
+ function Pe(t) {
158
+ const e = se(t) ?? se((t ?? "").split(/\s+(?![^(]*\))/).find((n) => se(n)));
70
159
  return e && e !== "#ffffff" ? e : null;
71
160
  }
72
- const Rn = [
161
+ const tr = [
73
162
  { color: "#dc2626", name: "colorRed" },
74
163
  { color: "#ea580c", name: "colorOrange" },
75
164
  { color: "#ca8a04", name: "colorAmber" },
@@ -80,35 +169,35 @@ const Rn = [
80
169
  { color: "#db2777", name: "colorPink" },
81
170
  { color: "#475569", name: "colorSlate" },
82
171
  { color: "#94a3b8", name: "colorGray" }
83
- ], $n = [
172
+ ], nr = [
84
173
  { color: "#fef08a", name: "colorYellow" },
85
174
  { color: "#bbf7d0", name: "colorGreen" },
86
175
  { color: "#bae6fd", name: "colorBlue" },
87
176
  { color: "#fbcfe8", name: "colorPink" },
88
177
  { color: "#fed7aa", name: "colorOrange" },
89
178
  { color: "#e9d5ff", name: "colorPurple" }
90
- ], zn = ["left", "center", "right", "justify"];
91
- function ct(t) {
179
+ ], rr = ["left", "center", "right", "justify"];
180
+ function vt(t) {
92
181
  const e = (t.style.textAlign || t.getAttribute("align") || "").toLowerCase();
93
- return zn.includes(e) && e !== "left" ? e : null;
182
+ return rr.includes(e) && e !== "left" ? e : null;
94
183
  }
95
- function dt(t) {
184
+ function kt(t) {
96
185
  return t ? { style: `text-align: ${t}` } : {};
97
186
  }
98
- const Bn = {
187
+ const ir = {
99
188
  left: "float: left; margin: 0 1em 1em 0",
100
189
  right: "float: right; margin: 0 0 1em 1em",
101
190
  center: "display: block; margin-left: auto; margin-right: auto"
102
- }, Fn = {
191
+ }, sr = {
103
192
  left: "float: left; margin: 0 1em 1em 0",
104
193
  right: "float: right; margin: 0 0 1em 1em",
105
194
  center: "display: table; margin-left: auto; margin-right: auto"
106
195
  };
107
- function Un(t) {
196
+ function or(t) {
108
197
  const e = t.style.float || t.getAttribute("align") || "";
109
198
  return e === "left" || e === "right" ? e : (t.style.display === "block" || t.style.display === "table") && t.style.marginLeft === "auto" && t.style.marginRight === "auto" ? "center" : null;
110
199
  }
111
- const ut = {
200
+ const Mt = {
112
201
  src: {},
113
202
  alt: { default: "" },
114
203
  title: { default: null },
@@ -116,35 +205,35 @@ const ut = {
116
205
  height: { default: null },
117
206
  align: { default: null }
118
207
  };
119
- function ht(t, e) {
208
+ function xt(t, e) {
120
209
  const n = q(t.getAttribute("src"));
121
210
  return n ? {
122
211
  src: n,
123
212
  alt: t.getAttribute("alt") ?? "",
124
213
  title: t.getAttribute("title"),
125
- width: pt(t.getAttribute("width") ?? t.style.width),
126
- height: pt(t.getAttribute("height") ?? t.style.height),
127
- align: Un(e)
214
+ width: Lt(t.getAttribute("width") ?? t.style.width),
215
+ height: Lt(t.getAttribute("height") ?? t.style.height),
216
+ align: or(e)
128
217
  } : !1;
129
218
  }
130
- function Ue(t, e) {
131
- const { src: n, alt: r, title: o, width: s, height: c, align: d } = t, i = { src: n, alt: r ?? "" };
132
- o && (i.title = o), s && (i.width = String(s)), s && c && (i.height = String(c));
133
- const a = e ? Bn[d] : void 0;
134
- return a && (i.style = a), i;
219
+ function Ye(t, e) {
220
+ const { src: n, alt: r, title: i, width: s, height: o, align: c } = t, a = { src: n, alt: r ?? "" };
221
+ i && (a.title = i), s && (a.width = String(s)), s && o && (a.height = String(o));
222
+ const l = e ? ir[c] : void 0;
223
+ return l && (a.style = l), a;
135
224
  }
136
- function pt(t) {
225
+ function Lt(t) {
137
226
  const e = /^\s*(\d{1,5})(px)?\s*$/.exec(t ?? "");
138
227
  return e ? Number(e[1]) : null;
139
228
  }
140
- const Pn = {
229
+ const ar = {
141
230
  doc: { content: "block+" },
142
231
  paragraph: {
143
232
  content: "inline*",
144
233
  group: "block",
145
234
  attrs: { align: { default: null } },
146
- parseDOM: [{ tag: "p", getAttrs: (t) => ({ align: ct(t) }) }],
147
- toDOM: (t) => ["p", dt(t.attrs.align), 0]
235
+ parseDOM: [{ tag: "p", getAttrs: (t) => ({ align: vt(t) }) }],
236
+ toDOM: (t) => ["p", kt(t.attrs.align), 0]
148
237
  },
149
238
  heading: {
150
239
  content: "inline*",
@@ -154,9 +243,9 @@ const Pn = {
154
243
  parseDOM: [1, 2, 3, 4, 5, 6].map((t) => ({
155
244
  tag: `h${t}`,
156
245
  // h5/h6 are folded into h4 so pasted content stays inside the supported range
157
- getAttrs: (e) => ({ level: Math.min(t, 4), align: ct(e) })
246
+ getAttrs: (e) => ({ level: Math.min(t, 4), align: vt(e) })
158
247
  })),
159
- toDOM: (t) => [`h${t.attrs.level}`, dt(t.attrs.align), 0]
248
+ toDOM: (t) => [`h${t.attrs.level}`, kt(t.attrs.align), 0]
160
249
  },
161
250
  blockquote: {
162
251
  content: "block+",
@@ -192,15 +281,15 @@ const Pn = {
192
281
  ["code", t.attrs.language ? { class: `language-${t.attrs.language}` } : {}, 0]
193
282
  ]
194
283
  },
195
- ...un({ tableGroup: "block", cellContent: "block+", cellAttributes: {} }),
284
+ ...En({ tableGroup: "block", cellContent: "block+", cellAttributes: {} }),
196
285
  text: { group: "inline" },
197
286
  image: {
198
287
  inline: !0,
199
288
  group: "inline",
200
289
  draggable: !0,
201
- attrs: ut,
202
- parseDOM: [{ tag: "img[src]", getAttrs: (t) => ht(t, t) }],
203
- toDOM: (t) => ["img", Ue(t.attrs, !0)]
290
+ attrs: Mt,
291
+ parseDOM: [{ tag: "img[src]", getAttrs: (t) => xt(t, t) }],
292
+ toDOM: (t) => ["img", Ye(t.attrs, !0)]
204
293
  },
205
294
  /** Image with a caption: <figure><img><figcaption>…</figcaption></figure>. The caption is the node's content. */
206
295
  figure: {
@@ -209,22 +298,24 @@ const Pn = {
209
298
  marks: "_",
210
299
  draggable: !0,
211
300
  isolating: !0,
212
- attrs: ut,
301
+ attrs: Mt,
213
302
  parseDOM: [
214
303
  {
215
304
  tag: "figure",
216
305
  getAttrs: (t) => {
217
306
  const e = t.querySelector("img");
218
- return e ? ht(e, t) : !1;
307
+ return e ? xt(e, t) : !1;
219
308
  },
220
309
  contentElement: (t) => t.querySelector("figcaption") ?? document.createElement("figcaption")
221
310
  }
222
311
  ],
223
312
  toDOM: (t) => {
224
- const e = Fn[t.attrs.align];
225
- return ["figure", e ? { style: e } : {}, ["img", Ue(t.attrs, !1)], ["figcaption", 0]];
313
+ const e = sr[t.attrs.align];
314
+ return ["figure", e ? { style: e } : {}, ["img", Ye(t.attrs, !1)], ["figcaption", 0]];
226
315
  }
227
316
  },
317
+ /** YouTube / Vimeo player (<iframe>); other iframes are dropped. */
318
+ video: Zn,
228
319
  hard_break: {
229
320
  inline: !0,
230
321
  group: "inline",
@@ -232,7 +323,7 @@ const Pn = {
232
323
  parseDOM: [{ tag: "br" }],
233
324
  toDOM: () => ["br"]
234
325
  }
235
- }, _n = {
326
+ }, lr = {
236
327
  link: {
237
328
  attrs: { href: {}, title: { default: null }, target: { default: null } },
238
329
  inclusive: !1,
@@ -294,14 +385,14 @@ const Pn = {
294
385
  {
295
386
  tag: "span",
296
387
  getAttrs: (t) => {
297
- const e = lt(t.style.color);
388
+ const e = yt(t.style.color);
298
389
  return e ? { color: e } : !1;
299
390
  }
300
391
  },
301
392
  {
302
393
  tag: "font[color]",
303
394
  getAttrs: (t) => {
304
- const e = lt(t.getAttribute("color"));
395
+ const e = yt(t.getAttribute("color"));
305
396
  return e ? { color: e } : !1;
306
397
  }
307
398
  }
@@ -314,247 +405,251 @@ const Pn = {
314
405
  parseDOM: [
315
406
  {
316
407
  tag: "mark",
317
- getAttrs: (t) => ({ color: Ie(t.style.backgroundColor) ?? "#fef08a" })
408
+ getAttrs: (t) => ({ color: Pe(t.style.backgroundColor) ?? "#fef08a" })
318
409
  },
319
410
  {
320
411
  style: "background-color",
321
412
  getAttrs: (t) => {
322
- const e = Ie(t);
413
+ const e = Pe(t);
323
414
  return e ? { color: e } : !1;
324
415
  }
325
416
  },
326
417
  {
327
418
  style: "background",
328
419
  getAttrs: (t) => {
329
- const e = Ie(t);
420
+ const e = Pe(t);
330
421
  return e ? { color: e } : !1;
331
422
  }
332
423
  }
333
424
  ],
334
- toDOM: (t) => ["mark", { style: `background-color: ${re(t.attrs.color) ?? "#fef08a"}` }, 0]
425
+ toDOM: (t) => ["mark", { style: `background-color: ${se(t.attrs.color) ?? "#fef08a"}` }, 0]
335
426
  },
336
427
  code: {
337
428
  parseDOM: [{ tag: "code" }],
338
429
  toDOM: () => ["code", 0]
339
430
  }
340
- }, mt = new Ht({ nodes: Pn, marks: _n }), p = new Ht({
341
- nodes: sn(mt.spec.nodes, "paragraph block*", "block"),
342
- marks: mt.spec.marks
343
- }), Wn = an.fromSchema(p), qn = on.fromSchema(p);
344
- function be(t) {
431
+ }, St = new _t({ nodes: ar, marks: lr }), f = new _t({
432
+ nodes: Mn(St.spec.nodes, "paragraph block*", "block"),
433
+ marks: St.spec.marks
434
+ }), cr = kn.fromSchema(f), dr = vn.fromSchema(f);
435
+ function ke(t) {
345
436
  const e = new window.DOMParser().parseFromString(`<!doctype html><body>${t}`, "text/html");
346
- return qn.parse(e.body);
437
+ return dr.parse(e.body);
347
438
  }
348
- function we(t) {
349
- if (Ut(t)) return "";
439
+ function Me(t) {
440
+ if (Qt(t)) return "";
350
441
  const e = document.createElement("div");
351
- return e.append(Wn.serializeFragment(t.content)), e.querySelectorAll("[style]").forEach((n) => n.setAttribute("style", jn(n.getAttribute("style") ?? ""))), e.innerHTML;
442
+ return e.append(cr.serializeFragment(t.content)), e.querySelectorAll("[style]").forEach((n) => n.setAttribute("style", hr(n.getAttribute("style") ?? ""))), e.innerHTML;
352
443
  }
353
- const Gn = (t, e, n, r) => "#" + [e, n, r].map((o) => (+o).toString(16).padStart(2, "0")).join("");
354
- function jn(t) {
444
+ const ur = (t, e, n, r) => "#" + [e, n, r].map((i) => (+i).toString(16).padStart(2, "0")).join("");
445
+ function hr(t) {
355
446
  return t.split(";").map((e) => e.trim()).filter(Boolean).map(
356
- (e) => e.replace(/rgb\(\s*(\d+),\s*(\d+),\s*(\d+)\s*\)/g, Gn).replace(/(^|[\s:])0px(?![\w.])/g, (n, r) => `${r}0`).replace(/\s*:\s*/, ": ")
447
+ (e) => e.replace(/rgb\(\s*(\d+),\s*(\d+),\s*(\d+)\s*\)/g, ur).replace(/(^|[\s:])0px(?![\w.])/g, (n, r) => `${r}0`).replace(/\s*:\s*/, ": ")
357
448
  ).join("; ");
358
449
  }
359
- function Ut(t) {
450
+ function Qt(t) {
360
451
  const e = t.firstChild;
361
- return t.childCount === 1 && !!e && e.type === p.nodes.paragraph && e.content.size === 0 && !e.attrs.align;
452
+ return t.childCount === 1 && !!e && e.type === f.nodes.paragraph && e.content.size === 0 && !e.attrs.align;
362
453
  }
363
- const Pe = /* @__PURE__ */ new Set(["UL", "OL", "BLOCKQUOTE", "TABLE", "THEAD", "TBODY", "TFOOT", "TR", "FIGURE"]), _e = /* @__PURE__ */ new Set(["LI", "TH", "TD"]), ft = (t) => t.nodeType === 1 && (Pe.has(t.tagName) || _e.has(t.tagName) || /^(P|H[1-6]|PRE|HR|FIGCAPTION|IMG|DIV)$/.test(t.tagName)), Vn = (t) => {
454
+ const Je = /* @__PURE__ */ new Set(["UL", "OL", "BLOCKQUOTE", "TABLE", "THEAD", "TBODY", "TFOOT", "TR", "FIGURE"]), Xe = /* @__PURE__ */ new Set(["LI", "TH", "TD"]), Et = (t) => t.nodeType === 1 && (Je.has(t.tagName) || Xe.has(t.tagName) || /^(P|H[1-6]|PRE|HR|FIGCAPTION|IMG|DIV|IFRAME)$/.test(t.tagName)), fr = (t) => {
364
455
  const n = t.cloneNode(!1).outerHTML;
365
456
  return n.slice(0, n.length - `</${t.localName}>`.length);
366
457
  };
367
- function gt(t) {
458
+ function At(t) {
368
459
  const e = document.createElement("div");
369
460
  e.innerHTML = t;
370
- const n = [], r = (o, s) => {
371
- const c = " ".repeat(s);
372
- let d = "";
373
- const i = () => {
374
- d.trim() && n.push(c + d.trim()), d = "";
461
+ const n = [], r = (i, s) => {
462
+ const o = " ".repeat(s);
463
+ let c = "";
464
+ const a = () => {
465
+ c.trim() && n.push(o + c.trim()), c = "";
375
466
  };
376
- o.childNodes.forEach((a) => {
377
- if (!ft(a)) {
378
- d += a.nodeType === 1 ? a.outerHTML : a.nodeType === 3 ? Kn(a.textContent ?? "") : "";
467
+ i.childNodes.forEach((l) => {
468
+ if (!Et(l)) {
469
+ c += l.nodeType === 1 ? l.outerHTML : l.nodeType === 3 ? mr(l.textContent ?? "") : "";
379
470
  return;
380
471
  }
381
- i();
382
- const l = a, u = Array.from(l.childNodes).filter(ft);
383
- (_e.has(l.tagName) ? u.length <= 1 && u.every((g) => !Pe.has(g.tagName) && !_e.has(g.tagName)) : !Pe.has(l.tagName)) ? n.push(c + l.outerHTML) : (n.push(c + Vn(l)), r(l, s + 1), n.push(`${c}</${l.localName}>`));
384
- }), i();
472
+ a();
473
+ const d = l, u = Array.from(d.childNodes).filter(Et);
474
+ (Xe.has(d.tagName) ? u.length <= 1 && u.every((p) => !Je.has(p.tagName) && !Xe.has(p.tagName)) : !Je.has(d.tagName)) ? n.push(o + d.outerHTML) : (n.push(o + fr(d)), r(d, s + 1), n.push(`${o}</${d.localName}>`));
475
+ }), a();
385
476
  };
386
477
  return r(e, 0), n.join(`
387
478
  `);
388
479
  }
389
- const Kn = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/ /g, "&nbsp;");
390
- function de(t, e) {
391
- const { from: n, $from: r, to: o, empty: s } = t.selection;
392
- return s ? !!e.isInSet(t.storedMarks || r.marks()) : t.doc.rangeHasMark(n, o, e);
480
+ const mr = (t) => t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/ /g, "&nbsp;");
481
+ function fe(t, e) {
482
+ const { from: n, $from: r, to: i, empty: s } = t.selection;
483
+ return s ? !!e.isInSet(t.storedMarks || r.marks()) : t.doc.rangeHasMark(n, i, e);
393
484
  }
394
- function Yn(t) {
485
+ function pr(t) {
395
486
  const e = t.selection.$from.parent;
396
- return e.type === p.nodes.paragraph ? "paragraph" : e.type === p.nodes.code_block ? "codeBlock" : e.type === p.nodes.heading ? `heading${e.attrs.level}` : null;
487
+ return e.type === f.nodes.paragraph ? "paragraph" : e.type === f.nodes.code_block ? "codeBlock" : e.type === f.nodes.heading ? `heading${e.attrs.level}` : null;
397
488
  }
398
- function Jn(t) {
399
- return t === "paragraph" ? De(p.nodes.paragraph) : t === "codeBlock" ? De(p.nodes.code_block) : De(p.nodes.heading, { level: Number(t.slice(-1)) });
489
+ function gr(t) {
490
+ return t === "paragraph" ? Oe(f.nodes.paragraph) : t === "codeBlock" ? Oe(f.nodes.code_block) : Oe(f.nodes.heading, { level: Number(t.slice(-1)) });
400
491
  }
401
- const _ = (t) => Sn(p.marks[t]);
402
- function Pt(t, e) {
492
+ const _ = (t) => Un(f.marks[t]);
493
+ function Zt(t, e) {
403
494
  const { $from: n } = t.selection;
404
495
  for (let r = n.depth; r > 0; r--) if (n.node(r).type === e) return !0;
405
496
  return !1;
406
497
  }
407
- function bt(t) {
498
+ function Tt(t) {
408
499
  const { $from: e } = t.selection;
409
500
  for (let n = e.depth; n > 0; n--) {
410
501
  const r = e.node(n).type;
411
- if (r === p.nodes.bullet_list || r === p.nodes.ordered_list) return r;
502
+ if (r === f.nodes.bullet_list || r === f.nodes.ordered_list) return r;
412
503
  }
413
504
  return null;
414
505
  }
415
- function wt(t) {
506
+ function Ct(t) {
416
507
  return (e, n, r) => {
417
- const { $from: o } = e.selection;
418
- for (let s = o.depth; s > 0; s--) {
419
- const c = o.node(s);
420
- if (c.type === p.nodes.bullet_list || c.type === p.nodes.ordered_list)
421
- return c.type === t ? $t(p.nodes.list_item)(e, n, r) : (n && n(e.tr.setNodeMarkup(o.before(s), t)), !0);
508
+ const { $from: i } = e.selection;
509
+ for (let s = i.depth; s > 0; s--) {
510
+ const o = i.node(s);
511
+ if (o.type === f.nodes.bullet_list || o.type === f.nodes.ordered_list)
512
+ return o.type === t ? Gt(f.nodes.list_item)(e, n, r) : (n && n(e.tr.setNodeMarkup(i.before(s), t)), !0);
422
513
  }
423
- return cn(t)(e, n, r);
514
+ return Ln(t)(e, n, r);
424
515
  };
425
516
  }
426
- const We = ln(p.nodes.list_item), qe = (t, e, n) => $t(p.nodes.list_item)(t, e, n) || Bt(t, e);
427
- function Xn() {
428
- return (t, e) => Pt(t, p.nodes.blockquote) ? Bt(t, e) : An(p.nodes.blockquote)(t, e);
517
+ const Qe = xn(f.nodes.list_item), Ze = (t, e, n) => Gt(f.nodes.list_item)(t, e, n) || Kt(t, e);
518
+ function br() {
519
+ return (t, e) => Zt(t, f.nodes.blockquote) ? Kt(t, e) : Wn(f.nodes.blockquote)(t, e);
429
520
  }
430
- function yt(t, e = "left") {
521
+ function It(t, e = "left") {
431
522
  return (n, r) => {
432
- const o = t === e ? null : t, { from: s, to: c } = n.selection, d = n.tr;
433
- let i = !1;
434
- return n.doc.nodesBetween(s, c, (a, l) => a.type === p.nodes.paragraph || a.type === p.nodes.heading ? (i = !0, a.attrs.align !== o && d.setNodeMarkup(l, void 0, { ...a.attrs, align: o }), !1) : !0), i ? (r && r(d), !0) : !1;
523
+ const i = t === e ? null : t, { from: s, to: o } = n.selection, c = n.tr;
524
+ let a = !1;
525
+ return n.doc.nodesBetween(s, o, (l, d) => l.type === f.nodes.paragraph || l.type === f.nodes.heading ? (a = !0, l.attrs.align !== i && c.setNodeMarkup(d, void 0, { ...l.attrs, align: i }), !1) : !0), a ? (r && r(c), !0) : !1;
435
526
  };
436
527
  }
437
- function Qn(t, e = "left") {
528
+ function wr(t, e = "left") {
438
529
  return t.selection.$from.parent.attrs.align ?? e;
439
530
  }
440
- const Zn = (t, e) => {
441
- const n = p.nodes.horizontal_rule;
531
+ const yr = (t, e) => {
532
+ const n = f.nodes.horizontal_rule;
442
533
  if (!e) return !0;
443
- const r = t.tr.replaceSelectionWith(n.create()), o = r.selection.$from;
444
- return !o.nodeAfter && o.parent.type === p.nodes.doc && r.insert(o.pos, p.nodes.paragraph.create()), e(r.scrollIntoView()), !0;
445
- }, er = (t, e) => {
446
- const { from: n, to: r, empty: o } = t.selection, s = t.tr;
447
- if (o)
534
+ const r = t.tr.replaceSelectionWith(n.create()), i = r.selection.$from;
535
+ return !i.nodeAfter && i.parent.type === f.nodes.doc && r.insert(i.pos, f.nodes.paragraph.create()), e(r.scrollIntoView()), !0;
536
+ }, vr = (t, e) => {
537
+ const { from: n, to: r, empty: i } = t.selection, s = t.tr;
538
+ if (i)
448
539
  s.setStoredMarks([]);
449
540
  else
450
- for (const c of Object.values(p.marks)) c !== p.marks.link && s.removeMark(n, r, c);
451
- return t.doc.nodesBetween(n, r, (c, d) => c.isTextblock && c.type !== p.nodes.paragraph ? (s.setBlockType(d, d + c.nodeSize, p.nodes.paragraph), !1) : (c.type === p.nodes.paragraph && c.attrs.align && s.setNodeMarkup(d, void 0, { align: null }), !0)), e && e(s), !0;
541
+ for (const o of Object.values(f.marks)) o !== f.marks.link && s.removeMark(n, r, o);
542
+ return t.doc.nodesBetween(n, r, (o, c) => o.isTextblock && o.type !== f.nodes.paragraph ? (s.setBlockType(c, c + o.nodeSize, f.nodes.paragraph), !1) : (o.type === f.nodes.paragraph && o.attrs.align && s.setNodeMarkup(c, void 0, { align: null }), !0)), e && e(s), !0;
452
543
  };
453
- function Ge(t) {
454
- const e = p.marks.link, { $from: n, from: r, to: o, empty: s } = t.selection;
544
+ function et(t) {
545
+ const e = f.marks.link, { $from: n, from: r, to: i, empty: s } = t.selection;
455
546
  if (!s) {
456
547
  let u = null;
457
- return t.doc.nodesBetween(r, o, (m, g) => {
458
- const k = e.isInSet(m.marks);
459
- k && !u && (u = { from: Math.max(g, r), to: Math.min(g + m.nodeSize, o), ...k.attrs });
548
+ return t.doc.nodesBetween(r, i, (m, p) => {
549
+ const b = e.isInSet(m.marks);
550
+ b && !u && (u = { from: Math.max(p, r), to: Math.min(p + m.nodeSize, i), ...b.attrs });
460
551
  }), u;
461
552
  }
462
- const c = e.isInSet(n.marks()) ?? e.isInSet(n.nodeBefore?.marks ?? []);
463
- if (!c) return null;
464
- const d = n.start(), i = [];
465
- let a = 0;
553
+ const o = e.isInSet(n.marks()) ?? e.isInSet(n.nodeBefore?.marks ?? []);
554
+ if (!o) return null;
555
+ const c = n.start(), a = [];
556
+ let l = 0;
466
557
  n.parent.forEach((u) => {
467
- const m = d + a, g = m + u.nodeSize;
468
- if (c.isInSet(u.marks)) {
469
- const k = i[i.length - 1];
470
- k && k[1] === m ? k[1] = g : i.push([m, g]);
558
+ const m = c + l, p = m + u.nodeSize;
559
+ if (o.isInSet(u.marks)) {
560
+ const b = a[a.length - 1];
561
+ b && b[1] === m ? b[1] = p : a.push([m, p]);
471
562
  }
472
- a += u.nodeSize;
563
+ l += u.nodeSize;
473
564
  });
474
- const l = i.find(([u, m]) => u <= n.pos && n.pos <= m);
475
- return l ? { from: l[0], to: l[1], ...c.attrs } : null;
565
+ const d = a.find(([u, m]) => u <= n.pos && n.pos <= m);
566
+ return d ? { from: d[0], to: d[1], ...o.attrs } : null;
567
+ }
568
+ function en(t) {
569
+ const e = t.selection;
570
+ return e instanceof Z && e.node.type === f.nodes.video ? { pos: e.from, node: e.node } : null;
476
571
  }
477
- function je(t) {
572
+ function tt(t) {
478
573
  const e = t.selection;
479
- return e instanceof he && (e.node.type === p.nodes.image || e.node.type === p.nodes.figure) ? { pos: e.from, attrs: e.node.attrs, figure: e.node.type === p.nodes.figure, node: e.node } : null;
574
+ return e instanceof Z && (e.node.type === f.nodes.image || e.node.type === f.nodes.figure) ? { pos: e.from, attrs: e.node.attrs, figure: e.node.type === f.nodes.figure, node: e.node } : null;
480
575
  }
481
- function vt(t, e, n) {
482
- const r = p.nodes.figure.create(n), o = t.doc.resolve(e), s = o.parent;
483
- s.type === p.nodes.paragraph && s.childCount === 1 ? t.replaceWith(o.before(), o.after(), r) : t.replaceRangeWith(e, e + 1, r);
484
- let c = -1;
485
- return t.doc.descendants((d, i) => c >= 0 ? !1 : (d.type === p.nodes.figure && d.attrs.src === n.src && d.content.size === 0 && (c = i), !0)), c >= 0 && t.setSelection(Ye.create(t.doc, c + 1)), t;
576
+ function Dt(t, e, n) {
577
+ const r = f.nodes.figure.create(n), i = t.doc.resolve(e), s = i.parent;
578
+ s.type === f.nodes.paragraph && s.childCount === 1 ? t.replaceWith(i.before(), i.after(), r) : t.replaceRangeWith(e, e + 1, r);
579
+ let o = -1;
580
+ return t.doc.descendants((c, a) => o >= 0 ? !1 : (c.type === f.nodes.figure && c.attrs.src === n.src && c.content.size === 0 && (o = a), !0)), o >= 0 && t.setSelection(be.create(t.doc, o + 1)), t;
486
581
  }
487
- function tr(t, e, n, r) {
488
- const o = p.nodes.image.create(r), s = [p.nodes.paragraph.create(null, o)];
489
- return n.content.size && s.push(p.nodes.paragraph.create(null, n.content)), t.replaceWith(e, e + n.nodeSize, Ot.from(s)), t.setSelection(he.create(t.doc, e + 1));
582
+ function kr(t, e, n, r) {
583
+ const i = f.nodes.image.create(r), s = [f.nodes.paragraph.create(null, i)];
584
+ return n.content.size && s.push(f.nodes.paragraph.create(null, n.content)), t.replaceWith(e, e + n.nodeSize, Vt.from(s)), t.setSelection(Z.create(t.doc, e + 1));
490
585
  }
491
- function nr(t, e, n = !0) {
492
- const r = p.nodes, o = (s) => r.table_row.create(null, Array.from({ length: e }, () => s.createAndFill()));
493
- return r.table.create(null, Array.from({ length: t }, (s, c) => o(n && c === 0 ? r.table_header : r.table_cell)));
586
+ function Mr(t, e, n = !0) {
587
+ const r = f.nodes, i = (s) => r.table_row.create(null, Array.from({ length: e }, () => s.createAndFill()));
588
+ return r.table.create(null, Array.from({ length: t }, (s, o) => i(n && o === 0 ? r.table_header : r.table_cell)));
494
589
  }
495
- function rr(t, e) {
590
+ function xr(t, e) {
496
591
  return (n, r) => {
497
- if (me(n)) return !1;
592
+ if (we(n)) return !1;
498
593
  if (!r) return !0;
499
- const o = nr(t, e), s = n.tr, c = n.selection.$from;
500
- c.parent.type === p.nodes.paragraph && c.parent.content.size === 0 && c.depth === 1 ? s.replaceWith(c.before(), c.after(), o) : s.replaceSelectionWith(o);
501
- let i = -1;
502
- if (s.doc.descendants((a, l) => i >= 0 ? !1 : (a === o && (i = l), i < 0 && a.type !== p.nodes.table)), i >= 0) {
503
- const a = i + s.doc.nodeAt(i).nodeSize;
504
- a >= s.doc.content.size && s.insert(a, p.nodes.paragraph.create()), s.setSelection(Ye.create(s.doc, i + 4));
594
+ const i = Mr(t, e), s = n.tr, o = n.selection.$from;
595
+ o.parent.type === f.nodes.paragraph && o.parent.content.size === 0 && o.depth === 1 ? s.replaceWith(o.before(), o.after(), i) : s.replaceSelectionWith(i);
596
+ let a = -1;
597
+ if (s.doc.descendants((l, d) => a >= 0 ? !1 : (l === i && (a = d), a < 0 && l.type !== f.nodes.table)), a >= 0) {
598
+ const l = a + s.doc.nodeAt(a).nodeSize;
599
+ l >= s.doc.content.size && s.insert(l, f.nodes.paragraph.create()), s.setSelection(be.create(s.doc, a + 4));
505
600
  }
506
601
  return r(s.scrollIntoView()), !0;
507
602
  };
508
603
  }
509
- const or = (t, e, n) => me(t) ? Fe(1)(t, e) || !e || !n ? !0 : (zt(t, e), Fe(1)(n.state, e)) : !1, ir = (t, e) => me(t) && Fe(-1)(t, e);
510
- function Ve(t, e) {
511
- const n = p.marks[e], { from: r, to: o, empty: s, $from: c } = t.selection;
512
- if (s) return n.isInSet(t.storedMarks || c.marks())?.attrs.color ?? null;
513
- let d;
514
- return t.doc.nodesBetween(r, o, (i) => {
515
- if (!i.isText || d === null) return;
516
- const a = n.isInSet(i.marks)?.attrs.color ?? null;
517
- d = d === void 0 || d === a ? a : null;
518
- }), d ?? null;
519
- }
520
- function ar(t, e) {
604
+ const Lr = (t, e, n) => we(t) ? Ke(1)(t, e) || !e || !n ? !0 : (jt(t, e), Ke(1)(n.state, e)) : !1, Sr = (t, e) => we(t) && Ke(-1)(t, e);
605
+ function nt(t, e) {
606
+ const n = f.marks[e], { from: r, to: i, empty: s, $from: o } = t.selection;
607
+ if (s) return n.isInSet(t.storedMarks || o.marks())?.attrs.color ?? null;
608
+ let c;
609
+ return t.doc.nodesBetween(r, i, (a) => {
610
+ if (!a.isText || c === null) return;
611
+ const l = n.isInSet(a.marks)?.attrs.color ?? null;
612
+ c = c === void 0 || c === l ? l : null;
613
+ }), c ?? null;
614
+ }
615
+ function Er(t, e) {
521
616
  return (n, r) => {
522
- const o = p.marks[t], { from: s, to: c, empty: d } = n.selection;
617
+ const i = f.marks[t], { from: s, to: o, empty: c } = n.selection;
523
618
  if (!r) return !0;
524
- const i = n.tr;
525
- return d ? (i.removeStoredMark(o), e && i.addStoredMark(o.create({ color: e }))) : (i.removeMark(s, c, o), e && i.addMark(s, c, o.create({ color: e }))), r(i.scrollIntoView()), !0;
619
+ const a = n.tr;
620
+ return c ? (a.removeStoredMark(i), e && a.addStoredMark(i.create({ color: e }))) : (a.removeMark(s, o, i), e && a.addMark(s, o, i.create({ color: e }))), r(a.scrollIntoView()), !0;
526
621
  };
527
622
  }
528
- function sr() {
529
- const t = p.nodes;
530
- return Ln({
623
+ function Ar() {
624
+ const t = f.nodes;
625
+ return Bn({
531
626
  rules: [
532
- it(/^(#{1,4})\s$/, t.heading, (e) => ({ level: e[1].length })),
533
- Ce(/^\s*>\s$/, t.blockquote),
534
- Ce(/^\s*([-+*])\s$/, t.bullet_list),
535
- Ce(
627
+ gt(/^(#{1,4})\s$/, t.heading, (e) => ({ level: e[1].length })),
628
+ $e(/^\s*>\s$/, t.blockquote),
629
+ $e(/^\s*([-+*])\s$/, t.bullet_list),
630
+ $e(
536
631
  /^(\d+)\.\s$/,
537
632
  t.ordered_list,
538
633
  (e) => ({ order: +e[1] }),
539
634
  (e, n) => n.childCount + n.attrs.order === +e[1]
540
635
  ),
541
- it(/^```$/, t.code_block),
542
- new xn(/^(?:---|\*\*\*|___)$/, (e, n, r, o) => {
636
+ gt(/^```$/, t.code_block),
637
+ new zn(/^(?:---|\*\*\*|___)$/, (e, n, r, i) => {
543
638
  const s = e.doc.resolve(r);
544
639
  if (s.parent.type !== t.paragraph) return null;
545
- const c = s.before();
546
- return e.tr.replaceWith(c, o + 1, [t.horizontal_rule.create(), t.paragraph.create()]);
640
+ const o = s.before();
641
+ return e.tr.replaceWith(o, i + 1, [t.horizontal_rule.create(), t.paragraph.create()]);
547
642
  })
548
643
  ]
549
644
  });
550
645
  }
551
- function lr(t) {
552
- const e = Tn(Cn, (n, r) => (r && r(n.tr.replaceSelectionWith(p.nodes.hard_break.create()).scrollIntoView()), !0));
553
- return Je({
554
- "Mod-z": It,
555
- "Mod-y": Be,
556
- "Shift-Mod-z": Be,
557
- Backspace: En,
646
+ function Tr(t) {
647
+ const e = _n(Vn, (n, r) => (r && r(n.tr.replaceSelectionWith(f.nodes.hard_break.create()).scrollIntoView()), !0));
648
+ return at({
649
+ "Mod-z": Wt,
650
+ "Mod-y": je,
651
+ "Shift-Mod-z": je,
652
+ Backspace: Fn,
558
653
  "Mod-b": _("strong"),
559
654
  "Mod-i": _("em"),
560
655
  "Mod-u": _("underline"),
@@ -563,230 +658,236 @@ function lr(t) {
563
658
  "Mod-k": t.link,
564
659
  "Shift-Enter": e,
565
660
  "Mod-Enter": e,
566
- Enter: dn(p.nodes.list_item),
567
- Tab: We,
568
- "Shift-Tab": qe
661
+ Enter: Sn(f.nodes.list_item),
662
+ Tab: Qe,
663
+ "Shift-Tab": Ze
569
664
  });
570
665
  }
571
- const cr = () => Je(Dn);
572
- function dr(t) {
573
- return new Ct({
666
+ const Cr = () => at(qn);
667
+ function Ir(t) {
668
+ return new it({
574
669
  props: {
575
670
  decorations(e) {
576
671
  const n = e.doc, r = n.firstChild;
577
- return !t || n.childCount !== 1 || !r || !r.isTextblock || r.content.size > 0 ? null : Dt.create(n, [
578
- Nt.node(0, r.nodeSize, { class: "wds-placeholder", "data-placeholder": t })
672
+ return !t || n.childCount !== 1 || !r || !r.isTextblock || r.content.size > 0 ? null : st.create(n, [
673
+ ot.node(0, r.nodeSize, { class: "wds-placeholder", "data-placeholder": t })
579
674
  ]);
580
675
  }
581
676
  }
582
677
  });
583
678
  }
584
- const X = new Qt("wds-upload");
585
- function ur() {
586
- return new Ct({
587
- key: X,
679
+ const Q = new Ut("wds-upload");
680
+ function Dr() {
681
+ return new it({
682
+ key: Q,
588
683
  state: {
589
- init: () => Dt.empty,
684
+ init: () => st.empty,
590
685
  apply(t, e) {
591
686
  e = e.map(t.mapping, t.doc);
592
- const n = t.getMeta(X);
687
+ const n = t.getMeta(Q);
593
688
  if (n && "add" in n) {
594
689
  const r = document.createElement("span");
595
- r.className = "wds-upload-placeholder", r.setAttribute("aria-hidden", "true"), e = e.add(t.doc, [Nt.widget(n.add.pos, r, { id: n.add.id })]);
690
+ r.className = "wds-upload-placeholder", r.setAttribute("aria-hidden", "true"), e = e.add(t.doc, [ot.widget(n.add.pos, r, { id: n.add.id })]);
596
691
  } else n && "remove" in n && (e = e.remove(e.find(void 0, void 0, (r) => r.id === n.remove.id)));
597
692
  return e;
598
693
  }
599
694
  },
600
695
  props: {
601
- decorations: (t) => X.getState(t)
696
+ decorations: (t) => Q.getState(t)
602
697
  }
603
698
  });
604
699
  }
605
- function hr(t, e) {
606
- const n = X.getState(t)?.find(void 0, void 0, (r) => r.id === e);
700
+ function Nr(t, e) {
701
+ const n = Q.getState(t)?.find(void 0, void 0, (r) => r.id === e);
607
702
  return n && n.length ? n[0].from : null;
608
703
  }
609
- const E = (t) => `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${t}</svg>`, L = {
610
- undo: E('<path d="M9 14 4 9l5-5"/><path d="M4 9h11a5 5 0 0 1 0 10h-3"/>'),
611
- redo: E('<path d="m15 14 5-5-5-5"/><path d="M20 9H9a5 5 0 0 0 0 10h3"/>'),
612
- bold: E('<path d="M7 5h6a3.5 3.5 0 0 1 0 7H7z"/><path d="M7 12h7a3.5 3.5 0 0 1 0 7H7z"/>'),
613
- italic: E('<path d="M14 5h-4"/><path d="M14 19h-4"/><path d="m14 5-4 14"/><path d="M18 5h-4M10 19H6"/>'),
614
- underline: E('<path d="M7 4v7a5 5 0 0 0 10 0V4"/><path d="M5 20h14"/>'),
615
- strike: E('<path d="M4 12h16"/><path d="M16.5 7.5C16 5.6 14.2 4.5 12 4.5c-2.6 0-4.5 1.4-4.5 3.4 0 1.3.8 2.3 2.4 3"/><path d="M8 16.5c.6 1.9 2.2 3 4.3 3 2.7 0 4.6-1.4 4.6-3.6 0-.9-.3-1.6-.9-2.2"/>'),
616
- code: E('<path d="m9 8-4 4 4 4"/><path d="m15 8 4 4-4 4"/>'),
617
- link: E('<path d="M10 14a4.5 4.5 0 0 0 6.4 0l3-3a4.5 4.5 0 0 0-6.4-6.4l-1 1"/><path d="M14 10a4.5 4.5 0 0 0-6.4 0l-3 3a4.5 4.5 0 0 0 6.4 6.4l1-1"/>'),
618
- blockquote: E('<path d="M5 18c2.5-1 4-3.2 4-6.5V7H5v5h3"/><path d="M14 18c2.5-1 4-3.2 4-6.5V7h-4v5h3"/>'),
619
- bulletList: E('<circle cx="5" cy="7" r="1" fill="currentColor"/><circle cx="5" cy="12" r="1" fill="currentColor"/><circle cx="5" cy="17" r="1" fill="currentColor"/><path d="M9 7h11M9 12h11M9 17h11"/>'),
620
- orderedList: E('<path d="M10 7h10M10 12h10M10 17h10"/><path d="M4 5.5 5.5 5v4"/><path d="M4 14.2c.3-.6.8-.9 1.4-.9.7 0 1.1.4 1.1 1 0 .9-1.4 1.6-2.5 2.7h2.6"/>'),
621
- indent: E('<path d="M4 6h16M10 10h10M10 14h10M4 18h16"/><path d="m4 9.5 3 2.5-3 2.5"/>'),
622
- outdent: E('<path d="M4 6h16M10 10h10M10 14h10M4 18h16"/><path d="m7 9.5-3 2.5 3 2.5"/>'),
623
- alignLeft: E('<path d="M4 6h16M4 10h10M4 14h16M4 18h10"/>'),
624
- alignCenter: E('<path d="M4 6h16M7 10h10M4 14h16M7 18h10"/>'),
625
- alignRight: E('<path d="M4 6h16M10 10h10M4 14h16M10 18h10"/>'),
626
- alignJustify: E('<path d="M4 6h16M4 10h16M4 14h16M4 18h16"/>'),
627
- hr: E('<path d="M3 12h18"/><path d="M8 7h8M8 17h8" opacity=".45"/>'),
628
- clear: E('<path d="M6 5h12"/><path d="M12 5 9 19"/><path d="m15 14 5 5M20 14l-5 5"/>'),
629
- source: E('<path d="m8 7-5 5 5 5"/><path d="m16 7 5 5-5 5"/><path d="m14 4-4 16"/>'),
630
- fullscreen: E('<path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/>'),
704
+ const S = (t) => `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${t}</svg>`, L = {
705
+ undo: S('<path d="M9 14 4 9l5-5"/><path d="M4 9h11a5 5 0 0 1 0 10h-3"/>'),
706
+ redo: S('<path d="m15 14 5-5-5-5"/><path d="M20 9H9a5 5 0 0 0 0 10h3"/>'),
707
+ bold: S('<path d="M7 5h6a3.5 3.5 0 0 1 0 7H7z"/><path d="M7 12h7a3.5 3.5 0 0 1 0 7H7z"/>'),
708
+ italic: S('<path d="M14 5h-4"/><path d="M14 19h-4"/><path d="m14 5-4 14"/><path d="M18 5h-4M10 19H6"/>'),
709
+ underline: S('<path d="M7 4v7a5 5 0 0 0 10 0V4"/><path d="M5 20h14"/>'),
710
+ strike: S('<path d="M4 12h16"/><path d="M16.5 7.5C16 5.6 14.2 4.5 12 4.5c-2.6 0-4.5 1.4-4.5 3.4 0 1.3.8 2.3 2.4 3"/><path d="M8 16.5c.6 1.9 2.2 3 4.3 3 2.7 0 4.6-1.4 4.6-3.6 0-.9-.3-1.6-.9-2.2"/>'),
711
+ code: S('<path d="m9 8-4 4 4 4"/><path d="m15 8 4 4-4 4"/>'),
712
+ link: S('<path d="M10 14a4.5 4.5 0 0 0 6.4 0l3-3a4.5 4.5 0 0 0-6.4-6.4l-1 1"/><path d="M14 10a4.5 4.5 0 0 0-6.4 0l-3 3a4.5 4.5 0 0 0 6.4 6.4l1-1"/>'),
713
+ blockquote: S('<path d="M5 18c2.5-1 4-3.2 4-6.5V7H5v5h3"/><path d="M14 18c2.5-1 4-3.2 4-6.5V7h-4v5h3"/>'),
714
+ bulletList: S('<circle cx="5" cy="7" r="1" fill="currentColor"/><circle cx="5" cy="12" r="1" fill="currentColor"/><circle cx="5" cy="17" r="1" fill="currentColor"/><path d="M9 7h11M9 12h11M9 17h11"/>'),
715
+ orderedList: S('<path d="M10 7h10M10 12h10M10 17h10"/><path d="M4 5.5 5.5 5v4"/><path d="M4 14.2c.3-.6.8-.9 1.4-.9.7 0 1.1.4 1.1 1 0 .9-1.4 1.6-2.5 2.7h2.6"/>'),
716
+ indent: S('<path d="M4 6h16M10 10h10M10 14h10M4 18h16"/><path d="m4 9.5 3 2.5-3 2.5"/>'),
717
+ outdent: S('<path d="M4 6h16M10 10h10M10 14h10M4 18h16"/><path d="m7 9.5-3 2.5 3 2.5"/>'),
718
+ alignLeft: S('<path d="M4 6h16M4 10h10M4 14h16M4 18h10"/>'),
719
+ alignCenter: S('<path d="M4 6h16M7 10h10M4 14h16M7 18h10"/>'),
720
+ alignRight: S('<path d="M4 6h16M10 10h10M4 14h16M10 18h10"/>'),
721
+ alignJustify: S('<path d="M4 6h16M4 10h16M4 14h16M4 18h16"/>'),
722
+ hr: S('<path d="M3 12h18"/><path d="M8 7h8M8 17h8" opacity=".45"/>'),
723
+ clear: S('<path d="M6 5h12"/><path d="M12 5 9 19"/><path d="m15 14 5 5M20 14l-5 5"/>'),
724
+ source: S('<path d="m8 7-5 5 5 5"/><path d="m16 7 5 5-5 5"/><path d="m14 4-4 16"/>'),
725
+ fullscreen: S('<path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/>'),
631
726
  chevron: '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="m6 9 6 6 6-6"/></svg>',
632
- close: E('<path d="M6 6l12 12M18 6 6 18"/>'),
633
- image: E('<rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="8.5" cy="9.5" r="1.5"/><path d="m21 16-5-5-9 9"/>'),
634
- file: E('<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="M9 13h6M9 17h4"/>'),
635
- folder: E('<path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>'),
636
- upload: E('<path d="M12 16V4"/><path d="m7 9 5-5 5 5"/><path d="M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3"/>'),
637
- grid: E('<rect x="4" y="4" width="6" height="6" rx="1"/><rect x="14" y="4" width="6" height="6" rx="1"/><rect x="4" y="14" width="6" height="6" rx="1"/><rect x="14" y="14" width="6" height="6" rx="1"/>'),
638
- list: E('<path d="M9 6h11M9 12h11M9 18h11"/><path d="M4 6h1M4 12h1M4 18h1"/>'),
639
- trash: E('<path d="M4 7h16"/><path d="M10 11v6M14 11v6"/><path d="M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"/><path d="M9 7V4h6v3"/>'),
640
- table: E('<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 10h18M3 15h18M9 4v16M15 4v16"/>'),
641
- pasteText: E('<path d="M9 4h6v3H9z"/><path d="M15 5h2a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2"/><path d="M9 12h6M12 12v6"/>'),
727
+ close: S('<path d="M6 6l12 12M18 6 6 18"/>'),
728
+ image: S('<rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="8.5" cy="9.5" r="1.5"/><path d="m21 16-5-5-9 9"/>'),
729
+ file: S('<path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="M9 13h6M9 17h4"/>'),
730
+ folder: S('<path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>'),
731
+ upload: S('<path d="M12 16V4"/><path d="m7 9 5-5 5 5"/><path d="M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3"/>'),
732
+ grid: S('<rect x="4" y="4" width="6" height="6" rx="1"/><rect x="14" y="4" width="6" height="6" rx="1"/><rect x="4" y="14" width="6" height="6" rx="1"/><rect x="14" y="14" width="6" height="6" rx="1"/>'),
733
+ list: S('<path d="M9 6h11M9 12h11M9 18h11"/><path d="M4 6h1M4 12h1M4 18h1"/>'),
734
+ trash: S('<path d="M4 7h16"/><path d="M10 11v6M14 11v6"/><path d="M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12"/><path d="M9 7V4h6v3"/>'),
735
+ video: S('<rect x="3" y="5" width="18" height="14" rx="3"/><path d="m10 9 5 3-5 3z"/>'),
736
+ search: S('<circle cx="11" cy="11" r="6.5"/><path d="m20 20-4.2-4.2"/>'),
737
+ arrowUp: S('<path d="m6 15 6-6 6 6"/>'),
738
+ arrowDown: S('<path d="m6 9 6 6 6-6"/>'),
739
+ table: S('<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 10h18M3 15h18M9 4v16M15 4v16"/>'),
740
+ pasteText: S('<path d="M9 4h6v3H9z"/><path d="M15 5h2a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2h2"/><path d="M9 12h6M12 12v6"/>'),
642
741
  // The bar (class wds-swatch-bar) shows the current color through --wds-swatch
643
- textColor: E('<path d="m6 16 6-12 6 12"/><path d="M8.5 11h7"/><rect class="wds-swatch-bar" x="3" y="19" width="18" height="3" rx="1" stroke="none"/>'),
644
- highlight: E('<path d="m14 4 5 5-7 7H7v-5z"/><path d="M7 16l-2 2"/><rect class="wds-swatch-bar" x="3" y="19" width="18" height="3" rx="1" stroke="none"/>'),
645
- globe: E('<circle cx="12" cy="12" r="9"/><path d="M3 12h18"/><path d="M12 3a14 14 0 0 1 0 18 14 14 0 0 1 0-18"/>')
646
- }, oe = (t) => getComputedStyle(t).direction === "rtl";
647
- let ve = null;
648
- function _t() {
649
- ve?.close();
650
- }
651
- function Xe(t, e, n, r) {
652
- _t();
653
- const o = document.createElement("div");
654
- o.className = `wds-menu ${n}`, e.append(o);
742
+ textColor: S('<path d="m6 16 6-12 6 12"/><path d="M8.5 11h7"/><rect class="wds-swatch-bar" x="3" y="19" width="18" height="3" rx="1" stroke="none"/>'),
743
+ highlight: S('<path d="m14 4 5 5-7 7H7v-5z"/><path d="M7 16l-2 2"/><rect class="wds-swatch-bar" x="3" y="19" width="18" height="3" rx="1" stroke="none"/>'),
744
+ globe: S('<circle cx="12" cy="12" r="9"/><path d="M3 12h18"/><path d="M12 3a14 14 0 0 1 0 18 14 14 0 0 1 0-18"/>')
745
+ }, ae = (t) => getComputedStyle(t).direction === "rtl";
746
+ let Se = null;
747
+ function tn() {
748
+ Se?.close();
749
+ }
750
+ function lt(t, e, n, r) {
751
+ tn();
752
+ const i = document.createElement("div");
753
+ i.className = `wds-menu ${n}`, e.append(i);
655
754
  const s = () => {
656
755
  const u = t.getBoundingClientRect();
657
- o.style.maxHeight = "";
658
- const m = o.offsetWidth, g = o.offsetHeight, k = oe(e) ? u.right - m : u.left;
659
- o.style.left = `${Math.max(4, Math.min(k, window.innerWidth - m - 4))}px`;
660
- const D = window.innerHeight - u.bottom - 8, A = u.top - 8;
661
- g <= D || D >= A ? (o.style.top = `${u.bottom + 4}px`, g > D && (o.style.maxHeight = `${D}px`)) : (o.style.top = `${Math.max(4, u.top - Math.min(g, A) - 4)}px`, g > A && (o.style.maxHeight = `${A}px`));
662
- }, c = (u) => {
663
- if (u.target instanceof Node && o.contains(u.target)) return;
756
+ i.style.maxHeight = "";
757
+ const m = i.offsetWidth, p = i.offsetHeight, b = ae(e) ? u.right - m : u.left;
758
+ i.style.left = `${Math.max(4, Math.min(b, window.innerWidth - m - 4))}px`;
759
+ const x = window.innerHeight - u.bottom - 8, T = u.top - 8;
760
+ p <= x || x >= T ? (i.style.top = `${u.bottom + 4}px`, p > x && (i.style.maxHeight = `${x}px`)) : (i.style.top = `${Math.max(4, u.top - Math.min(p, T) - 4)}px`, p > T && (i.style.maxHeight = `${T}px`));
761
+ }, o = (u) => {
762
+ if (u.target instanceof Node && i.contains(u.target)) return;
664
763
  const m = t.getBoundingClientRect();
665
- m.bottom < 0 || m.top > window.innerHeight || !t.isConnected ? l() : s();
764
+ m.bottom < 0 || m.top > window.innerHeight || !t.isConnected ? d() : s();
666
765
  };
667
766
  t.setAttribute("aria-expanded", "true");
668
- const d = (u) => {
669
- !o.contains(u.target) && u.target !== t && !t.contains(u.target) && l();
670
- }, i = (u) => {
671
- u.key === "Escape" && (u.preventDefault(), u.stopPropagation(), l(!0));
767
+ const c = (u) => {
768
+ !i.contains(u.target) && u.target !== t && !t.contains(u.target) && d();
769
+ }, a = (u) => {
770
+ u.key === "Escape" && (u.preventDefault(), u.stopPropagation(), d(!0));
672
771
  };
673
- let a = !1;
674
- function l(u = !1) {
675
- a || (a = !0, o.remove(), t.setAttribute("aria-expanded", "false"), document.removeEventListener("mousedown", d, !0), window.removeEventListener("scroll", c, !0), window.removeEventListener("resize", c), o.removeEventListener("keydown", i), ve?.close === l && (ve = null), u && t.focus());
676
- }
677
- return document.addEventListener("mousedown", d, !0), window.addEventListener("scroll", c, !0), window.addEventListener("resize", c), o.addEventListener("keydown", i), ve = { close: l }, { popup: o, place: s, close: l };
678
- }
679
- function pr(t, e, n, r) {
680
- const { popup: o, place: s, close: c } = Xe(t, e, "wds-menu-list");
681
- o.setAttribute("role", "menu"), o.setAttribute("aria-label", r);
682
- for (const i of n) {
683
- if (i === "|") {
684
- const l = document.createElement("div");
685
- l.className = "wds-menu-sep", l.setAttribute("role", "separator"), o.append(l);
772
+ let l = !1;
773
+ function d(u = !1) {
774
+ l || (l = !0, i.remove(), t.setAttribute("aria-expanded", "false"), document.removeEventListener("mousedown", c, !0), window.removeEventListener("scroll", o, !0), window.removeEventListener("resize", o), i.removeEventListener("keydown", a), Se?.close === d && (Se = null), u && t.focus());
775
+ }
776
+ return document.addEventListener("mousedown", c, !0), window.addEventListener("scroll", o, !0), window.addEventListener("resize", o), i.addEventListener("keydown", a), Se = { close: d }, { popup: i, place: s, close: d };
777
+ }
778
+ function Rr(t, e, n, r) {
779
+ const { popup: i, place: s, close: o } = lt(t, e, "wds-menu-list");
780
+ i.setAttribute("role", "menu"), i.setAttribute("aria-label", r);
781
+ for (const a of n) {
782
+ if (a === "|") {
783
+ const d = document.createElement("div");
784
+ d.className = "wds-menu-sep", d.setAttribute("role", "separator"), i.append(d);
686
785
  continue;
687
786
  }
688
- const a = document.createElement("button");
689
- a.type = "button", a.className = `wds-menu-item${i.danger ? " is-danger" : ""}`, a.setAttribute("role", "menuitem"), a.tabIndex = -1, a.innerHTML = i.icon ?? "", a.append(document.createTextNode(i.label)), i.enabled === !1 && (a.disabled = !0), a.addEventListener("mousedown", (l) => l.preventDefault()), a.addEventListener("click", () => {
690
- c(), i.run();
691
- }), o.append(a);
692
- }
693
- const d = () => [...o.querySelectorAll(".wds-menu-item:not(:disabled)")];
694
- o.addEventListener("keydown", (i) => {
695
- const a = d(), l = a.indexOf(document.activeElement);
787
+ const l = document.createElement("button");
788
+ l.type = "button", l.className = `wds-menu-item${a.danger ? " is-danger" : ""}`, l.setAttribute("role", "menuitem"), l.tabIndex = -1, l.innerHTML = a.icon ?? "", l.append(document.createTextNode(a.label)), a.enabled === !1 && (l.disabled = !0), l.addEventListener("mousedown", (d) => d.preventDefault()), l.addEventListener("click", () => {
789
+ o(), a.run();
790
+ }), i.append(l);
791
+ }
792
+ const c = () => [...i.querySelectorAll(".wds-menu-item:not(:disabled)")];
793
+ i.addEventListener("keydown", (a) => {
794
+ const l = c(), d = l.indexOf(document.activeElement);
696
795
  let u = -1;
697
- i.key === "ArrowDown" ? u = (l + 1) % a.length : i.key === "ArrowUp" ? u = (l - 1 + a.length) % a.length : i.key === "Home" ? u = 0 : i.key === "End" ? u = a.length - 1 : i.key === "Tab" && c(), u >= 0 && (i.preventDefault(), a[u]?.focus());
698
- }), s(), d()[0]?.focus();
699
- }
700
- function mr(t, e, n, r, o) {
701
- const { popup: d, place: i, close: a } = Xe(t, e, "wds-table-picker");
702
- d.setAttribute("role", "dialog"), d.setAttribute("aria-label", n);
703
- const l = document.createElement("div");
704
- l.className = "wds-picker-grid", l.style.gridTemplateColumns = "repeat(10, 1fr)", l.tabIndex = 0, l.setAttribute("role", "grid"), l.setAttribute("aria-label", n);
796
+ a.key === "ArrowDown" ? u = (d + 1) % l.length : a.key === "ArrowUp" ? u = (d - 1 + l.length) % l.length : a.key === "Home" ? u = 0 : a.key === "End" ? u = l.length - 1 : a.key === "Tab" && o(), u >= 0 && (a.preventDefault(), l[u]?.focus());
797
+ }), s(), c()[0]?.focus();
798
+ }
799
+ function $r(t, e, n, r, i) {
800
+ const { popup: c, place: a, close: l } = lt(t, e, "wds-table-picker");
801
+ c.setAttribute("role", "dialog"), c.setAttribute("aria-label", n);
802
+ const d = document.createElement("div");
803
+ d.className = "wds-picker-grid", d.style.gridTemplateColumns = "repeat(10, 1fr)", d.tabIndex = 0, d.setAttribute("role", "grid"), d.setAttribute("aria-label", n);
705
804
  const u = document.createElement("div");
706
805
  u.className = "wds-picker-label", u.setAttribute("aria-live", "polite");
707
806
  const m = [];
708
- let g = 3, k = 3;
709
- const D = () => {
710
- m.forEach((A, C) => A.classList.toggle("is-on", Math.floor(C / 10) < g && C % 10 < k)), u.textContent = r(g, k), l.setAttribute("aria-valuetext", u.textContent);
807
+ let p = 3, b = 3;
808
+ const x = () => {
809
+ m.forEach((T, A) => T.classList.toggle("is-on", Math.floor(A / 10) < p && A % 10 < b)), u.textContent = r(p, b), d.setAttribute("aria-valuetext", u.textContent);
711
810
  };
712
- for (let A = 0; A < 8; A++)
713
- for (let C = 0; C < 10; C++) {
714
- const I = document.createElement("span");
715
- I.className = "wds-picker-cell", I.addEventListener("mouseenter", () => {
716
- g = A + 1, k = C + 1, D();
717
- }), I.addEventListener("mousedown", (y) => y.preventDefault()), I.addEventListener("click", () => {
718
- a(), o(A + 1, C + 1);
719
- }), m.push(I), l.append(I);
811
+ for (let T = 0; T < 8; T++)
812
+ for (let A = 0; A < 10; A++) {
813
+ const N = document.createElement("span");
814
+ N.className = "wds-picker-cell", N.addEventListener("mouseenter", () => {
815
+ p = T + 1, b = A + 1, x();
816
+ }), N.addEventListener("mousedown", (v) => v.preventDefault()), N.addEventListener("click", () => {
817
+ l(), i(T + 1, A + 1);
818
+ }), m.push(N), d.append(N);
720
819
  }
721
- l.addEventListener("keydown", (A) => {
722
- const C = oe(l) ? -1 : 1, I = { ArrowRight: [0, C], ArrowLeft: [0, -C], ArrowDown: [1, 0], ArrowUp: [-1, 0] };
723
- I[A.key] ? (A.preventDefault(), g = Math.min(8, Math.max(1, g + I[A.key][0])), k = Math.min(10, Math.max(1, k + I[A.key][1])), D()) : A.key === "Enter" || A.key === " " ? (A.preventDefault(), a(), o(g, k)) : A.key === "Tab" && a();
724
- }), d.append(l, u), D(), i(), l.focus();
820
+ d.addEventListener("keydown", (T) => {
821
+ const A = ae(d) ? -1 : 1, N = { ArrowRight: [0, A], ArrowLeft: [0, -A], ArrowDown: [1, 0], ArrowUp: [-1, 0] };
822
+ N[T.key] ? (T.preventDefault(), p = Math.min(8, Math.max(1, p + N[T.key][0])), b = Math.min(10, Math.max(1, b + N[T.key][1])), x()) : T.key === "Enter" || T.key === " " ? (T.preventDefault(), l(), i(p, b)) : T.key === "Tab" && l();
823
+ }), c.append(d, u), x(), a(), d.focus();
725
824
  }
726
- function fr(t, e, n) {
727
- const { popup: r, place: o, close: s } = Xe(t, e, "wds-color-picker");
825
+ function Or(t, e, n) {
826
+ const { popup: r, place: i, close: s } = lt(t, e, "wds-color-picker");
728
827
  r.setAttribute("role", "dialog"), r.setAttribute("aria-label", n.label);
729
- const c = (a) => {
730
- s(), n.onPick(a);
731
- }, d = document.createElement("button");
732
- d.type = "button", d.className = "wds-menu-item wds-color-remove", d.innerHTML = '<span class="wds-swatch is-none" aria-hidden="true"></span>', d.append(document.createTextNode(n.removeLabel)), d.addEventListener("mousedown", (a) => a.preventDefault()), d.addEventListener("click", () => c(null));
733
- const i = document.createElement("div");
734
- i.className = "wds-swatches", i.style.gridTemplateColumns = `repeat(${n.columns}, 1fr)`;
735
- for (const a of n.swatches) {
736
- const l = document.createElement("button");
737
- l.type = "button", l.className = "wds-swatch", l.style.background = a.color, l.title = a.label, l.setAttribute("aria-label", a.label);
738
- const u = a.color === n.current;
739
- l.setAttribute("aria-pressed", String(u)), u && l.classList.add("is-current"), l.addEventListener("mousedown", (m) => m.preventDefault()), l.addEventListener("click", () => c(a.color)), i.append(l);
740
- }
741
- r.append(d, i), r.addEventListener("keydown", (a) => {
742
- const l = [d, ...i.querySelectorAll(".wds-swatch")], u = l.indexOf(document.activeElement);
828
+ const o = (l) => {
829
+ s(), n.onPick(l);
830
+ }, c = document.createElement("button");
831
+ c.type = "button", c.className = "wds-menu-item wds-color-remove", c.innerHTML = '<span class="wds-swatch is-none" aria-hidden="true"></span>', c.append(document.createTextNode(n.removeLabel)), c.addEventListener("mousedown", (l) => l.preventDefault()), c.addEventListener("click", () => o(null));
832
+ const a = document.createElement("div");
833
+ a.className = "wds-swatches", a.style.gridTemplateColumns = `repeat(${n.columns}, 1fr)`;
834
+ for (const l of n.swatches) {
835
+ const d = document.createElement("button");
836
+ d.type = "button", d.className = "wds-swatch", d.style.background = l.color, d.title = l.label, d.setAttribute("aria-label", l.label);
837
+ const u = l.color === n.current;
838
+ d.setAttribute("aria-pressed", String(u)), u && d.classList.add("is-current"), d.addEventListener("mousedown", (m) => m.preventDefault()), d.addEventListener("click", () => o(l.color)), a.append(d);
839
+ }
840
+ r.append(c, a), r.addEventListener("keydown", (l) => {
841
+ const d = [c, ...a.querySelectorAll(".wds-swatch")], u = d.indexOf(document.activeElement);
743
842
  if (u < 0) return;
744
843
  const m = n.columns;
745
- let g = -1;
746
- const k = oe(r) ? "ArrowLeft" : "ArrowRight", D = oe(r) ? "ArrowRight" : "ArrowLeft";
747
- a.key === k ? g = Math.min(l.length - 1, u + 1) : a.key === D ? g = Math.max(0, u - 1) : a.key === "ArrowDown" ? g = u === 0 ? 1 : Math.min(l.length - 1, u + m) : a.key === "ArrowUp" ? g = u <= m ? 0 : u - m : a.key === "Tab" && s(), g >= 0 && (a.preventDefault(), l[g].focus());
748
- }), o(), (i.querySelector(".is-current") ?? i.querySelector(".wds-swatch"))?.focus();
844
+ let p = -1;
845
+ const b = ae(r) ? "ArrowLeft" : "ArrowRight", x = ae(r) ? "ArrowRight" : "ArrowLeft";
846
+ l.key === b ? p = Math.min(d.length - 1, u + 1) : l.key === x ? p = Math.max(0, u - 1) : l.key === "ArrowDown" ? p = u === 0 ? 1 : Math.min(d.length - 1, u + m) : l.key === "ArrowUp" ? p = u <= m ? 0 : u - m : l.key === "Tab" && s(), p >= 0 && (l.preventDefault(), d[p].focus());
847
+ }), i(), (a.querySelector(".is-current") ?? a.querySelector(".wds-swatch"))?.focus();
749
848
  }
750
- const R = (t) => (e) => e.exec(t), He = (t) => oe(t.root) ? "right" : "left", ye = (t) => {
849
+ const O = (t) => (e) => e.exec(t), Be = (t) => ae(t.root) ? "right" : "left", xe = (t) => {
751
850
  const e = `align${t[0].toUpperCase()}${t.slice(1)}`;
752
851
  return {
753
852
  type: "button",
754
853
  label: e,
755
854
  icon: L[e],
756
- run: (n) => n.exec(yt(t, He(n))),
757
- active: (n, r) => Qn(n, He(r)) === t,
758
- enabled: (n, r) => yt(t, He(r))(n)
855
+ run: (n) => n.exec(It(t, Be(n))),
856
+ active: (n, r) => wr(n, Be(r)) === t,
857
+ enabled: (n, r) => It(t, Be(r))(n)
759
858
  };
760
- }, gr = {
761
- undo: { type: "button", label: "undo", icon: L.undo, shortcut: "Mod+Z", run: (t) => t.undo(), enabled: (t) => nn(t) > 0 },
762
- redo: { type: "button", label: "redo", icon: L.redo, shortcut: "Mod+Y", run: (t) => t.redo(), enabled: (t) => tn(t) > 0 },
859
+ }, Hr = {
860
+ undo: { type: "button", label: "undo", icon: L.undo, shortcut: "Mod+Z", run: (t) => t.undo(), enabled: (t) => wn(t) > 0 },
861
+ redo: { type: "button", label: "redo", icon: L.redo, shortcut: "Mod+Y", run: (t) => t.redo(), enabled: (t) => bn(t) > 0 },
763
862
  blocks: { type: "blocks" },
764
- bold: { type: "button", label: "bold", icon: L.bold, shortcut: "Mod+B", run: R(_("strong")), active: (t) => de(t, p.marks.strong) },
765
- italic: { type: "button", label: "italic", icon: L.italic, shortcut: "Mod+I", run: R(_("em")), active: (t) => de(t, p.marks.em) },
766
- underline: { type: "button", label: "underline", icon: L.underline, shortcut: "Mod+U", run: R(_("underline")), active: (t) => de(t, p.marks.underline) },
767
- strike: { type: "button", label: "strike", icon: L.strike, run: R(_("strike")), active: (t) => de(t, p.marks.strike) },
768
- textColor: { type: "button", label: "textColor", icon: L.textColor, popup: !0, run: (t, e) => t.openColorPicker("textColor", e), swatch: (t) => Ve(t, "textColor") },
769
- highlight: { type: "button", label: "highlight", icon: L.highlight, popup: !0, run: (t, e) => t.openColorPicker("highlight", e), swatch: (t) => Ve(t, "highlight") },
770
- code: { type: "button", label: "code", icon: L.code, run: R(_("code")), active: (t) => de(t, p.marks.code) },
771
- link: { type: "button", label: "link", icon: L.link, shortcut: "Mod+K", run: (t) => t.openLinkDialog(), active: (t) => !!Ge(t) },
772
- image: { type: "button", label: "image", icon: L.image, run: (t) => t.openImageDialog(), active: (t) => !!je(t) },
863
+ bold: { type: "button", label: "bold", icon: L.bold, shortcut: "Mod+B", run: O(_("strong")), active: (t) => fe(t, f.marks.strong) },
864
+ italic: { type: "button", label: "italic", icon: L.italic, shortcut: "Mod+I", run: O(_("em")), active: (t) => fe(t, f.marks.em) },
865
+ underline: { type: "button", label: "underline", icon: L.underline, shortcut: "Mod+U", run: O(_("underline")), active: (t) => fe(t, f.marks.underline) },
866
+ strike: { type: "button", label: "strike", icon: L.strike, run: O(_("strike")), active: (t) => fe(t, f.marks.strike) },
867
+ textColor: { type: "button", label: "textColor", icon: L.textColor, popup: !0, run: (t, e) => t.openColorPicker("textColor", e), swatch: (t) => nt(t, "textColor") },
868
+ highlight: { type: "button", label: "highlight", icon: L.highlight, popup: !0, run: (t, e) => t.openColorPicker("highlight", e), swatch: (t) => nt(t, "highlight") },
869
+ code: { type: "button", label: "code", icon: L.code, run: O(_("code")), active: (t) => fe(t, f.marks.code) },
870
+ link: { type: "button", label: "link", icon: L.link, shortcut: "Mod+K", run: (t) => t.openLinkDialog(), active: (t) => !!et(t) },
871
+ image: { type: "button", label: "image", icon: L.image, run: (t) => t.openImageDialog(), active: (t) => !!tt(t) },
773
872
  file: { type: "button", label: "file", icon: L.file, run: (t) => t.openFileManager("file"), available: (t) => t.hasFileManager() },
774
- table: { type: "button", label: "table", icon: L.table, popup: !0, run: (t, e) => t.openTableMenu(e), active: (t) => me(t) },
775
- blockquote: { type: "button", label: "blockquote", icon: L.blockquote, run: R(Xn()), active: (t) => Pt(t, p.nodes.blockquote) },
776
- bulletList: { type: "button", label: "bulletList", icon: L.bulletList, run: R(wt(p.nodes.bullet_list)), active: (t) => bt(t) === p.nodes.bullet_list },
777
- orderedList: { type: "button", label: "orderedList", icon: L.orderedList, run: R(wt(p.nodes.ordered_list)), active: (t) => bt(t) === p.nodes.ordered_list },
778
- outdent: { type: "button", label: "outdent", icon: L.outdent, run: R(qe), enabled: (t) => qe(t) },
779
- indent: { type: "button", label: "indent", icon: L.indent, run: R(We), enabled: (t) => We(t) },
780
- alignLeft: ye("left"),
781
- alignCenter: ye("center"),
782
- alignRight: ye("right"),
783
- alignJustify: ye("justify"),
784
- hr: { type: "button", label: "hr", icon: L.hr, run: R(Zn) },
785
- clear: { type: "button", label: "clear", icon: L.clear, run: R(er) },
873
+ video: { type: "button", label: "video", icon: L.video, run: (t) => t.openVideoDialog(), active: (t) => !!en(t) },
874
+ find: { type: "button", label: "findReplace", icon: L.search, shortcut: "Mod+F", run: (t) => t.openFind(), active: (t, e) => e.isFindOpen() },
875
+ table: { type: "button", label: "table", icon: L.table, popup: !0, run: (t, e) => t.openTableMenu(e), active: (t) => we(t) },
876
+ blockquote: { type: "button", label: "blockquote", icon: L.blockquote, run: O(br()), active: (t) => Zt(t, f.nodes.blockquote) },
877
+ bulletList: { type: "button", label: "bulletList", icon: L.bulletList, run: O(Ct(f.nodes.bullet_list)), active: (t) => Tt(t) === f.nodes.bullet_list },
878
+ orderedList: { type: "button", label: "orderedList", icon: L.orderedList, run: O(Ct(f.nodes.ordered_list)), active: (t) => Tt(t) === f.nodes.ordered_list },
879
+ outdent: { type: "button", label: "outdent", icon: L.outdent, run: O(Ze), enabled: (t) => Ze(t) },
880
+ indent: { type: "button", label: "indent", icon: L.indent, run: O(Qe), enabled: (t) => Qe(t) },
881
+ alignLeft: xe("left"),
882
+ alignCenter: xe("center"),
883
+ alignRight: xe("right"),
884
+ alignJustify: xe("justify"),
885
+ hr: { type: "button", label: "hr", icon: L.hr, run: O(yr) },
886
+ clear: { type: "button", label: "clear", icon: L.clear, run: O(vr) },
786
887
  pasteText: { type: "button", label: "pasteText", icon: L.pasteText, run: (t) => t.togglePlainPaste(), active: (t, e) => e.isPlainPaste() },
787
888
  source: { type: "button", label: "source", icon: L.source, run: (t) => t.toggleSource(), active: (t, e) => e.isSourceMode(), inSource: !0 },
788
889
  fullscreen: { type: "button", label: "fullscreen", icon: L.fullscreen, run: (t) => t.toggleFullscreen(), active: (t, e) => e.isFullscreen(), inSource: !0 }
789
- }, br = [
890
+ }, Pr = [
790
891
  "undo",
791
892
  "redo",
792
893
  "|",
@@ -803,6 +904,7 @@ const R = (t) => (e) => e.exec(t), He = (t) => oe(t.root) ? "right" : "left", ye
803
904
  "link",
804
905
  "image",
805
906
  "file",
907
+ "video",
806
908
  "table",
807
909
  "blockquote",
808
910
  "bulletList",
@@ -821,131 +923,131 @@ const R = (t) => (e) => e.exec(t), He = (t) => oe(t.root) ? "right" : "left", ye
821
923
  "|",
822
924
  "source",
823
925
  "fullscreen"
824
- ], wr = [
926
+ ], Br = [
825
927
  ["paragraph", "paragraph"],
826
928
  ["heading1", "heading1"],
827
929
  ["heading2", "heading2"],
828
930
  ["heading3", "heading3"],
829
931
  ["heading4", "heading4"],
830
932
  ["codeBlock", "codeBlock"]
831
- ], yr = typeof navigator < "u" && /Mac|iP(hone|ad|od)/.test(navigator.platform || navigator.userAgent), vr = (t) => t.replace("Mod", yr ? "⌘" : "Ctrl");
832
- function kr(t, e, n) {
933
+ ], zr = typeof navigator < "u" && /Mac|iP(hone|ad|od)/.test(navigator.platform || navigator.userAgent), Fr = (t) => t.replace("Mod", zr ? "⌘" : "Ctrl");
934
+ function Ur(t, e, n) {
833
935
  const r = document.createElement("div");
834
936
  r.className = "wds-toolbar", r.setAttribute("role", "toolbar"), r.setAttribute("aria-label", n.toolbarLabel);
835
- const o = [];
937
+ const i = [];
836
938
  let s = document.createElement("div");
837
939
  s.className = "wds-group", r.append(s);
838
- for (const d of e) {
839
- if (d === "|") {
940
+ for (const c of e) {
941
+ if (c === "|") {
840
942
  s.childElementCount && (s = document.createElement("div"), s.className = "wds-group", r.append(s));
841
943
  continue;
842
944
  }
843
- const i = gr[d];
844
- if (!i) {
845
- console.warn(`[WDS Editor] Unknown toolbar item "${d}".`);
945
+ const a = Hr[c];
946
+ if (!a) {
947
+ console.warn(`[WDS Editor] Unknown toolbar item "${c}".`);
846
948
  continue;
847
949
  }
848
- if (i.type === "blocks") {
950
+ if (a.type === "blocks") {
849
951
  const u = document.createElement("select");
850
952
  u.className = "wds-select", u.setAttribute("aria-label", n.blockType), u.title = n.blockType;
851
- for (const [g, k] of wr) {
852
- const D = document.createElement("option");
853
- D.value = g, D.textContent = n[k], u.append(D);
953
+ for (const [p, b] of Br) {
954
+ const x = document.createElement("option");
955
+ x.value = p, x.textContent = n[b], u.append(x);
854
956
  }
855
957
  const m = document.createElement("option");
856
958
  m.value = "", m.textContent = "—", m.hidden = !0, u.append(m), u.addEventListener("change", () => {
857
- u.value && t.exec(Jn(u.value)), t.focus();
858
- }), s.append(u), o.push((g) => {
859
- u.value = Yn(g) ?? "", u.disabled = t.isSourceMode() || t.isReadOnly();
959
+ u.value && t.exec(gr(u.value)), t.focus();
960
+ }), s.append(u), i.push((p) => {
961
+ u.value = pr(p) ?? "", u.disabled = t.isSourceMode() || t.isReadOnly();
860
962
  });
861
963
  continue;
862
964
  }
863
- if (i.available && !i.available(t)) continue;
864
- const a = document.createElement("button");
865
- a.type = "button", a.className = "wds-button-tool", a.innerHTML = i.icon;
866
- const l = n[i.label];
867
- a.setAttribute("aria-label", l), a.title = i.shortcut ? `${l} (${vr(i.shortcut)})` : l, a.dataset.item = d, i.popup && (a.setAttribute("aria-haspopup", "true"), a.setAttribute("aria-expanded", "false")), a.addEventListener("mousedown", (u) => u.preventDefault()), a.addEventListener("click", () => {
868
- a.disabled || i.run(t, a);
869
- }), s.append(a), o.push((u) => {
870
- const m = t.isSourceMode() && !i.inSource || t.isReadOnly() && !i.inSource;
871
- if (a.disabled = m || (i.enabled ? !i.enabled(u, t) : !1), i.swatch) {
872
- const g = m ? null : i.swatch(u);
873
- g ? a.style.setProperty("--wds-swatch", g) : a.style.removeProperty("--wds-swatch");
965
+ if (a.available && !a.available(t)) continue;
966
+ const l = document.createElement("button");
967
+ l.type = "button", l.className = "wds-button-tool", l.innerHTML = a.icon;
968
+ const d = n[a.label];
969
+ l.setAttribute("aria-label", d), l.title = a.shortcut ? `${d} (${Fr(a.shortcut)})` : d, l.dataset.item = c, a.popup && (l.setAttribute("aria-haspopup", "true"), l.setAttribute("aria-expanded", "false")), l.addEventListener("mousedown", (u) => u.preventDefault()), l.addEventListener("click", () => {
970
+ l.disabled || a.run(t, l);
971
+ }), s.append(l), i.push((u) => {
972
+ const m = t.isSourceMode() && !a.inSource || t.isReadOnly() && !a.inSource;
973
+ if (l.disabled = m || (a.enabled ? !a.enabled(u, t) : !1), a.swatch) {
974
+ const p = m ? null : a.swatch(u);
975
+ p ? l.style.setProperty("--wds-swatch", p) : l.style.removeProperty("--wds-swatch");
874
976
  }
875
- if (i.active) {
876
- const g = !m && i.active(u, t);
877
- a.classList.toggle("is-active", g), a.setAttribute("aria-pressed", String(g));
977
+ if (a.active) {
978
+ const p = !m && a.active(u, t);
979
+ l.classList.toggle("is-active", p), l.setAttribute("aria-pressed", String(p));
878
980
  }
879
981
  });
880
982
  }
881
- return r.addEventListener("keydown", (d) => {
882
- if (d.key !== "ArrowRight" && d.key !== "ArrowLeft" && d.key !== "Home" && d.key !== "End" || d.target.tagName === "SELECT" && (d.key === "Home" || d.key === "End")) return;
883
- const i = [...r.querySelectorAll("button:not([disabled]), select:not([disabled])")], a = i.indexOf(document.activeElement);
884
- if (a < 0) return;
885
- d.preventDefault();
886
- const l = d.key === "Home" ? 0 : d.key === "End" ? i.length - 1 : (a + (d.key === "ArrowRight" !== oe(r) ? 1 : -1) + i.length) % i.length;
887
- i.forEach((u) => u.tabIndex = -1), i[l].tabIndex = 0, i[l].focus();
888
- }), { element: r, update: (d) => {
889
- o.forEach((a) => a(d));
890
- const i = [...r.querySelectorAll("button, select")];
891
- if (!i.some((a) => a.tabIndex === 0 && !a.disabled)) {
892
- i.forEach((l) => l.tabIndex = -1);
893
- const a = i.find((l) => !l.disabled);
894
- a && (a.tabIndex = 0);
983
+ return r.addEventListener("keydown", (c) => {
984
+ if (c.key !== "ArrowRight" && c.key !== "ArrowLeft" && c.key !== "Home" && c.key !== "End" || c.target.tagName === "SELECT" && (c.key === "Home" || c.key === "End")) return;
985
+ const a = [...r.querySelectorAll("button:not([disabled]), select:not([disabled])")], l = a.indexOf(document.activeElement);
986
+ if (l < 0) return;
987
+ c.preventDefault();
988
+ const d = c.key === "Home" ? 0 : c.key === "End" ? a.length - 1 : (l + (c.key === "ArrowRight" !== ae(r) ? 1 : -1) + a.length) % a.length;
989
+ a.forEach((u) => u.tabIndex = -1), a[d].tabIndex = 0, a[d].focus();
990
+ }), { element: r, update: (c) => {
991
+ i.forEach((l) => l(c));
992
+ const a = [...r.querySelectorAll("button, select")];
993
+ if (!a.some((l) => l.tabIndex === 0 && !l.disabled)) {
994
+ a.forEach((d) => d.tabIndex = -1);
995
+ const l = a.find((d) => !d.disabled);
996
+ l && (l.tabIndex = 0);
895
997
  }
896
998
  } };
897
999
  }
898
- function Wt(t, e, n, r) {
899
- const o = document.createElement("span");
900
- o.className = "wds-image";
1000
+ function nn(t, e, n, r) {
1001
+ const i = document.createElement("span");
1002
+ i.className = "wds-image";
901
1003
  const s = document.createElement("img");
902
1004
  s.draggable = !1;
903
- const c = document.createElement("span");
904
- c.className = "wds-resize-handle", c.title = r.resizeLabel, c.setAttribute("aria-hidden", "true"), o.append(s, c);
905
- const d = () => {
906
- const l = e();
907
- l !== void 0 && t.dispatch(t.state.tr.setSelection(he.create(t.state.doc, l)));
1005
+ const o = document.createElement("span");
1006
+ o.className = "wds-resize-handle", o.title = r.resizeLabel, o.setAttribute("aria-hidden", "true"), i.append(s, o);
1007
+ const c = () => {
1008
+ const d = e();
1009
+ d !== void 0 && t.dispatch(t.state.tr.setSelection(Z.create(t.state.doc, d)));
908
1010
  };
909
- let i = !1;
910
- return c.addEventListener("pointerdown", (l) => {
1011
+ let a = !1;
1012
+ return o.addEventListener("pointerdown", (d) => {
911
1013
  if (!t.editable) return;
912
- l.preventDefault(), l.stopPropagation(), d(), i = !0;
1014
+ d.preventDefault(), d.stopPropagation(), c(), a = !0;
913
1015
  try {
914
- c.setPointerCapture(l.pointerId);
1016
+ o.setPointerCapture(d.pointerId);
915
1017
  } catch {
916
1018
  }
917
- const u = l.clientX, m = s.getBoundingClientRect().width, g = Math.max(40, t.dom.clientWidth - 8);
918
- let k = m;
919
- const D = (C) => {
920
- k = Math.round(Math.min(g, Math.max(40, m + C.clientX - u))), s.style.width = `${k}px`, s.style.height = "auto", o.dataset.size = `${k}px`;
921
- }, A = () => {
922
- i = !1, window.removeEventListener("pointermove", D), window.removeEventListener("pointerup", A), window.removeEventListener("pointercancel", A), delete o.dataset.size, s.style.width = "", s.style.height = "";
923
- const C = e();
924
- if (C === void 0 || Math.abs(k - m) < 2) return;
925
- const I = n(), y = t.state.tr.setNodeMarkup(C, void 0, { ...I.attrs, width: k, height: null });
926
- t.dispatch(y.setSelection(he.create(y.doc, C)));
1019
+ const u = d.clientX, m = s.getBoundingClientRect().width, p = Math.max(40, t.dom.clientWidth - 8);
1020
+ let b = m;
1021
+ const x = (A) => {
1022
+ b = Math.round(Math.min(p, Math.max(40, m + A.clientX - u))), s.style.width = `${b}px`, s.style.height = "auto", i.dataset.size = `${b}px`;
1023
+ }, T = () => {
1024
+ a = !1, window.removeEventListener("pointermove", x), window.removeEventListener("pointerup", T), window.removeEventListener("pointercancel", T), delete i.dataset.size, s.style.width = "", s.style.height = "";
1025
+ const A = e();
1026
+ if (A === void 0 || Math.abs(b - m) < 2) return;
1027
+ const N = n(), v = t.state.tr.setNodeMarkup(A, void 0, { ...N.attrs, width: b, height: null });
1028
+ t.dispatch(v.setSelection(Z.create(v.doc, A)));
927
1029
  };
928
- window.addEventListener("pointermove", D), window.addEventListener("pointerup", A), window.addEventListener("pointercancel", A);
929
- }), o.addEventListener("dblclick", (l) => {
1030
+ window.addEventListener("pointermove", x), window.addEventListener("pointerup", T), window.addEventListener("pointercancel", T);
1031
+ }), i.addEventListener("dblclick", (d) => {
930
1032
  if (!t.editable) return;
931
- l.preventDefault(), d();
1033
+ d.preventDefault(), c();
932
1034
  const u = e();
933
1035
  u !== void 0 && r.onEdit(u);
934
- }), { box: o, img: s, handle: c, select: d, render: (l) => {
935
- const u = Ue(l.attrs, !1);
1036
+ }), { box: i, img: s, handle: o, select: c, render: (d) => {
1037
+ const u = Ye(d.attrs, !1);
936
1038
  for (const m of ["src", "alt", "title", "width", "height"])
937
1039
  u[m] !== void 0 ? s.setAttribute(m, u[m]) : s.removeAttribute(m);
938
- }, isResizing: () => i };
1040
+ }, isResizing: () => a };
939
1041
  }
940
- const qt = (t, e) => {
1042
+ const rn = (t, e) => {
941
1043
  t.classList.remove("wds-align-left", "wds-align-center", "wds-align-right"), e && t.classList.add(`wds-align-${e}`);
942
1044
  };
943
- class Mr {
944
- constructor(e, n, r, o) {
945
- this.node = e, this.parts = Wt(n, r, () => this.node, o), this.dom = this.parts.box, this.render();
1045
+ class Wr {
1046
+ constructor(e, n, r, i) {
1047
+ this.node = e, this.parts = nn(n, r, () => this.node, i), this.dom = this.parts.box, this.render();
946
1048
  }
947
1049
  render() {
948
- this.parts.render(this.node), qt(this.dom, this.node.attrs.align);
1050
+ this.parts.render(this.node), rn(this.dom, this.node.attrs.align);
949
1051
  }
950
1052
  update(e) {
951
1053
  return e.type !== this.node.type ? !1 : (this.node = e, this.render(), !0);
@@ -957,14 +1059,14 @@ class Mr {
957
1059
  return !0;
958
1060
  }
959
1061
  }
960
- class Lr {
961
- constructor(e, n, r, o) {
962
- this.node = e, this.dom = document.createElement("figure"), this.dom.className = "wds-figure", this.parts = Wt(n, r, () => this.node, o), this.parts.box.contentEditable = "false", this.parts.box.addEventListener("mousedown", (s) => {
1062
+ class _r {
1063
+ constructor(e, n, r, i) {
1064
+ this.node = e, this.dom = document.createElement("figure"), this.dom.className = "wds-figure", this.parts = nn(n, r, () => this.node, i), this.parts.box.contentEditable = "false", this.parts.box.addEventListener("mousedown", (s) => {
963
1065
  s.target === this.parts.handle || s.detail > 1 || (s.preventDefault(), this.parts.select(), n.focus());
964
- }), this.contentDOM = document.createElement("figcaption"), this.contentDOM.dataset.placeholder = o.captionPlaceholder, this.dom.append(this.parts.box, this.contentDOM), this.render();
1066
+ }), this.contentDOM = document.createElement("figcaption"), this.contentDOM.dataset.placeholder = i.captionPlaceholder, this.dom.append(this.parts.box, this.contentDOM), this.render();
965
1067
  }
966
1068
  render() {
967
- this.parts.render(this.node), qt(this.dom, this.node.attrs.align), this.dom.classList.toggle("is-empty", this.node.content.size === 0);
1069
+ this.parts.render(this.node), rn(this.dom, this.node.attrs.align), this.dom.classList.toggle("is-empty", this.node.content.size === 0);
968
1070
  }
969
1071
  update(e) {
970
1072
  return e.type !== this.node.type ? !1 : (this.node = e, this.render(), !0);
@@ -976,7 +1078,7 @@ class Lr {
976
1078
  return !this.contentDOM.contains(e.target);
977
1079
  }
978
1080
  }
979
- const ke = {
1081
+ const Ee = {
980
1082
  undo: "Undo",
981
1083
  redo: "Redo",
982
1084
  blockType: "Text style",
@@ -1096,8 +1198,28 @@ const ke = {
1096
1198
  colorPurple: "Purple",
1097
1199
  colorPink: "Pink",
1098
1200
  colorSlate: "Slate",
1099
- colorGray: "Gray"
1100
- }, xr = {
1201
+ colorGray: "Gray",
1202
+ video: "Video",
1203
+ videoEdit: "Edit video",
1204
+ videoUrl: "YouTube or Vimeo address",
1205
+ videoHint: "Paste the link of the video page or its embed code.",
1206
+ videoTitle: "Title (read by screen readers)",
1207
+ videoInvalid: "Enter a YouTube or Vimeo video address.",
1208
+ findReplace: "Find and replace",
1209
+ find: "Find",
1210
+ replaceWith: "Replace with",
1211
+ findNext: "Next match",
1212
+ findPrevious: "Previous match",
1213
+ replace: "Replace",
1214
+ replaceAll: "Replace all",
1215
+ matchCase: "Match case",
1216
+ matchCount: "{current} of {total}",
1217
+ noMatches: "No results",
1218
+ replacedCount: "{count} replaced",
1219
+ draftFound: "An unsaved draft from {time} was found.",
1220
+ draftRestore: "Restore draft",
1221
+ draftDiscard: "Discard"
1222
+ }, Vr = {
1101
1223
  undo: "Geri al",
1102
1224
  redo: "Yinele",
1103
1225
  blockType: "Metin stili",
@@ -1217,137 +1339,157 @@ const ke = {
1217
1339
  colorPurple: "Mor",
1218
1340
  colorPink: "Pembe",
1219
1341
  colorSlate: "Arduvaz",
1220
- colorGray: "Gri"
1221
- }, pe = { en: ke, tr: xr };
1222
- function Gt(t, e) {
1223
- pe[t.toLowerCase()] = { ...ke, ...pe[t.toLowerCase()], ...e };
1224
- }
1225
- function kt(t) {
1342
+ colorGray: "Gri",
1343
+ video: "Video",
1344
+ videoEdit: "Videoyu düzenle",
1345
+ videoUrl: "YouTube veya Vimeo adresi",
1346
+ videoHint: "Video sayfasının bağlantısını ya da yerleştirme kodunu yapıştırın.",
1347
+ videoTitle: "Başlık (ekran okuyucular okur)",
1348
+ videoInvalid: "Bir YouTube veya Vimeo video adresi girin.",
1349
+ findReplace: "Bul ve değiştir",
1350
+ find: "Bul",
1351
+ replaceWith: "Şununla değiştir",
1352
+ findNext: "Sonraki eşleşme",
1353
+ findPrevious: "Önceki eşleşme",
1354
+ replace: "Değiştir",
1355
+ replaceAll: "Tümünü değiştir",
1356
+ matchCase: "Büyük/küçük harf duyarlı",
1357
+ matchCount: "{current} / {total}",
1358
+ noMatches: "Sonuç yok",
1359
+ replacedCount: "{count} yer değiştirildi",
1360
+ draftFound: "{time} tarihli kaydedilmemiş bir taslak bulundu.",
1361
+ draftRestore: "Taslağı geri yükle",
1362
+ draftDiscard: "Sil"
1363
+ }, ge = { en: Ee, tr: Vr };
1364
+ function sn(t, e) {
1365
+ ge[t.toLowerCase()] = { ...Ee, ...ge[t.toLowerCase()], ...e };
1366
+ }
1367
+ function Nt(t) {
1226
1368
  return globalThis.WDSEditorLang?.[t];
1227
1369
  }
1228
- function Mt(t) {
1229
- return !pe[t] && kt(t) && Gt(t, kt(t)), pe[t];
1370
+ function Rt(t) {
1371
+ return !ge[t] && Nt(t) && sn(t, Nt(t)), ge[t];
1230
1372
  }
1231
- function jt(t) {
1373
+ function on(t) {
1232
1374
  const e = (t || (typeof navigator < "u" ? navigator.language : "en") || "en").toLowerCase();
1233
- if (Mt(e)) return e;
1375
+ if (Rt(e)) return e;
1234
1376
  const n = e.split("-")[0];
1235
- return Mt(n) ? n : "en";
1377
+ return Rt(n) ? n : "en";
1236
1378
  }
1237
- function Er(t) {
1238
- return t && typeof t == "object" ? { ...ke, ...t } : pe[jt(t)] ?? ke;
1379
+ function qr(t) {
1380
+ return t && typeof t == "object" ? { ...Ee, ...t } : ge[on(t)] ?? Ee;
1239
1381
  }
1240
- const Sr = /* @__PURE__ */ new Set(["ar", "he", "fa", "ur", "ps", "yi", "dv", "ckb"]);
1241
- function Ar(t) {
1242
- return Sr.has(t.toLowerCase().split("-")[0]);
1382
+ const Gr = /* @__PURE__ */ new Set(["ar", "he", "fa", "ur", "ps", "yi", "dv", "ckb"]);
1383
+ function jr(t) {
1384
+ return Gr.has(t.toLowerCase().split("-")[0]);
1243
1385
  }
1244
- function j(t, e) {
1245
- return t.replace(/\{(\w+)\}/g, (n, r) => e[r] ?? n);
1386
+ function z(t, e) {
1387
+ return t.replace(/\{(\w+)\}/g, (n, r) => r in e ? String(e[r]) : n);
1246
1388
  }
1247
- let Tr = 0;
1248
- function Lt(t, e) {
1249
- const n = `wds-dlg-${++Tr}`, r = document.createElement("dialog");
1389
+ let Kr = 0;
1390
+ function ze(t, e) {
1391
+ const n = `wds-dlg-${++Kr}`, r = document.createElement("dialog");
1250
1392
  r.className = "wds-dialog", r.setAttribute("aria-labelledby", `${n}-title`);
1251
- const o = document.createElement("form");
1252
- o.method = "dialog", o.noValidate = !0;
1393
+ const i = document.createElement("form");
1394
+ i.method = "dialog", i.noValidate = !0;
1253
1395
  const s = document.createElement("div");
1254
1396
  s.className = "wds-dialog-header";
1255
- const c = document.createElement("h2");
1256
- c.id = `${n}-title`, c.textContent = e.title;
1257
- const d = document.createElement("button");
1258
- d.type = "button", d.className = "wds-icon-button", d.setAttribute("aria-label", e.closeLabel), d.innerHTML = L.close, s.append(c, d);
1259
- const i = document.createElement("div");
1260
- i.className = "wds-dialog-body";
1261
- const a = /* @__PURE__ */ new Map();
1262
- for (const y of e.fields) {
1263
- if (y.type === "select") {
1264
- const T = document.createElement("select");
1265
- T.id = `${n}-${y.name}`, T.name = y.name, T.className = "wds-input";
1266
- for (const O of y.options ?? []) {
1267
- const G = document.createElement("option");
1268
- G.value = O.value, G.textContent = O.label, T.append(G);
1397
+ const o = document.createElement("h2");
1398
+ o.id = `${n}-title`, o.textContent = e.title;
1399
+ const c = document.createElement("button");
1400
+ c.type = "button", c.className = "wds-icon-button", c.setAttribute("aria-label", e.closeLabel), c.innerHTML = L.close, s.append(o, c);
1401
+ const a = document.createElement("div");
1402
+ a.className = "wds-dialog-body";
1403
+ const l = /* @__PURE__ */ new Map();
1404
+ for (const v of e.fields) {
1405
+ if (v.type === "select") {
1406
+ const I = document.createElement("select");
1407
+ I.id = `${n}-${v.name}`, I.name = v.name, I.className = "wds-input";
1408
+ for (const $ of v.options ?? []) {
1409
+ const j = document.createElement("option");
1410
+ j.value = $.value, j.textContent = $.label, I.append(j);
1269
1411
  }
1270
- T.value = typeof y.value == "string" ? y.value : "";
1271
- const H = document.createElement("label");
1272
- H.className = "wds-label", H.htmlFor = T.id, H.textContent = y.label, i.append(H, T), a.set(y.name, T);
1412
+ I.value = typeof v.value == "string" ? v.value : "";
1413
+ const R = document.createElement("label");
1414
+ R.className = "wds-label", R.htmlFor = I.id, R.textContent = v.label, a.append(R, I), l.set(v.name, I);
1273
1415
  continue;
1274
1416
  }
1275
- const x = document.createElement("input");
1276
- if (x.id = `${n}-${y.name}`, x.name = y.name, y.type === "checkbox") {
1277
- x.type = "checkbox", x.checked = !!y.value;
1278
- const T = document.createElement("label");
1279
- T.className = "wds-check", T.htmlFor = x.id, T.append(x, document.createTextNode(y.label)), i.append(T);
1417
+ const E = document.createElement("input");
1418
+ if (E.id = `${n}-${v.name}`, E.name = v.name, v.type === "checkbox") {
1419
+ E.type = "checkbox", E.checked = !!v.value;
1420
+ const I = document.createElement("label");
1421
+ I.className = "wds-check", I.htmlFor = E.id, I.append(E, document.createTextNode(v.label)), a.append(I);
1280
1422
  } else {
1281
- x.type = "text", y.type === "url" && (x.inputMode = "url"), y.type === "number" && (x.inputMode = "numeric"), x.className = "wds-input", x.value = typeof y.value == "string" ? y.value : "", x.autocomplete = "off", x.spellcheck = !1, y.placeholder && (x.placeholder = y.placeholder);
1282
- const T = document.createElement("label");
1283
- if (T.className = "wds-label", T.htmlFor = x.id, T.textContent = y.label, i.append(T, x), y.hint) {
1284
- const H = document.createElement("p");
1285
- H.className = "wds-hint", H.id = `${x.id}-hint`, H.textContent = y.hint, x.setAttribute("aria-describedby", H.id), i.append(H);
1423
+ E.type = "text", v.type === "url" && (E.inputMode = "url"), v.type === "number" && (E.inputMode = "numeric"), E.className = "wds-input", E.value = typeof v.value == "string" ? v.value : "", E.autocomplete = "off", E.spellcheck = !1, v.placeholder && (E.placeholder = v.placeholder);
1424
+ const I = document.createElement("label");
1425
+ if (I.className = "wds-label", I.htmlFor = E.id, I.textContent = v.label, a.append(I, E), v.hint) {
1426
+ const R = document.createElement("p");
1427
+ R.className = "wds-hint", R.id = `${E.id}-hint`, R.textContent = v.hint, E.setAttribute("aria-describedby", R.id), a.append(R);
1286
1428
  }
1287
1429
  }
1288
- a.set(y.name, x);
1430
+ l.set(v.name, E);
1289
1431
  }
1290
- const l = document.createElement("p");
1291
- l.className = "wds-dialog-error", l.setAttribute("role", "alert"), l.hidden = !0, i.append(l);
1432
+ const d = document.createElement("p");
1433
+ d.className = "wds-dialog-error", d.setAttribute("role", "alert"), d.hidden = !0, a.append(d);
1292
1434
  const u = document.createElement("div");
1293
1435
  if (u.className = "wds-dialog-footer", e.extraAction) {
1294
- const y = document.createElement("button");
1295
- y.type = "button", y.className = "wds-button wds-button-danger", y.textContent = e.extraAction.label, y.addEventListener("click", () => {
1296
- e.extraAction.onClick(), C();
1297
- }), u.append(y);
1436
+ const v = document.createElement("button");
1437
+ v.type = "button", v.className = "wds-button wds-button-danger", v.textContent = e.extraAction.label, v.addEventListener("click", () => {
1438
+ e.extraAction.onClick(), A();
1439
+ }), u.append(v);
1298
1440
  }
1299
1441
  const m = document.createElement("span");
1300
1442
  m.className = "wds-spacer";
1301
- const g = document.createElement("button");
1302
- g.type = "button", g.className = "wds-button", g.textContent = e.cancelLabel;
1303
- const k = document.createElement("button");
1304
- k.type = "submit", k.className = "wds-button wds-button-primary", k.textContent = e.submitLabel, u.append(m, g, k), o.append(s, i, u), r.append(o), t.append(r);
1305
- const D = () => {
1306
- const y = {};
1307
- return a.forEach((x, T) => y[T] = x instanceof HTMLInputElement && x.type === "checkbox" ? x.checked : x.value), y;
1443
+ const p = document.createElement("button");
1444
+ p.type = "button", p.className = "wds-button", p.textContent = e.cancelLabel;
1445
+ const b = document.createElement("button");
1446
+ b.type = "submit", b.className = "wds-button wds-button-primary", b.textContent = e.submitLabel, u.append(m, p, b), i.append(s, a, u), r.append(i), t.append(r);
1447
+ const x = () => {
1448
+ const v = {};
1449
+ return l.forEach((E, I) => v[I] = E instanceof HTMLInputElement && E.type === "checkbox" ? E.checked : E.value), v;
1308
1450
  };
1309
- let A = !1;
1310
- function C() {
1311
- A || (A = !0, r.open && r.close(), r.remove(), e.onClose?.());
1312
- }
1313
- o.addEventListener("submit", (y) => {
1314
- y.preventDefault();
1315
- const x = D(), T = e.validate?.(x) ?? null;
1316
- if (T) {
1317
- l.textContent = T, l.hidden = !1, [...a.values()][0]?.focus();
1451
+ let T = !1;
1452
+ function A() {
1453
+ T || (T = !0, r.open && r.close(), r.remove(), e.onClose?.());
1454
+ }
1455
+ i.addEventListener("submit", (v) => {
1456
+ v.preventDefault();
1457
+ const E = x(), I = e.validate?.(E) ?? null;
1458
+ if (I) {
1459
+ d.textContent = I, d.hidden = !1, [...l.values()][0]?.focus();
1318
1460
  return;
1319
1461
  }
1320
- e.onSubmit(x), C();
1321
- }), g.addEventListener("click", C), d.addEventListener("click", C), r.addEventListener("close", C), r.addEventListener("click", (y) => {
1322
- y.target === r && C();
1462
+ e.onSubmit(E), A();
1463
+ }), p.addEventListener("click", A), c.addEventListener("click", A), r.addEventListener("close", A), r.addEventListener("click", (v) => {
1464
+ v.target === r && A();
1323
1465
  }), r.showModal();
1324
- const I = [...a.values()].find((y) => y instanceof HTMLInputElement && y.type !== "checkbox");
1325
- return I?.focus(), I?.select(), C;
1466
+ const N = [...l.values()].find((v) => v instanceof HTMLInputElement && v.type !== "checkbox");
1467
+ return N?.focus(), N?.select(), A;
1326
1468
  }
1327
- const V = (t) => typeof t == "string" && t.trim() ? t : void 0, Oe = (t) => typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : void 0;
1328
- function Vt(t) {
1469
+ const K = (t) => typeof t == "string" && t.trim() ? t : void 0, Fe = (t) => typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : void 0;
1470
+ function an(t) {
1329
1471
  if (!t || typeof t != "object") return null;
1330
- const e = t, n = q(V(e.url)), r = V(e.name);
1472
+ const e = t, n = q(K(e.url)), r = K(e.name);
1331
1473
  if (!n || !r) return null;
1332
- const o = { url: n, name: r }, s = Oe(e.size), c = Oe(e.width), d = Oe(e.height);
1333
- s !== void 0 && (o.size = s), c !== void 0 && (o.width = c), d !== void 0 && (o.height = d), V(e.type) && (o.type = e.type.toLowerCase());
1334
- const i = q(V(e.thumb));
1335
- return i && (o.thumb = i), V(e.modified) && !Number.isNaN(Date.parse(e.modified)) && (o.modified = e.modified), o;
1474
+ const i = { url: n, name: r }, s = Fe(e.size), o = Fe(e.width), c = Fe(e.height);
1475
+ s !== void 0 && (i.size = s), o !== void 0 && (i.width = o), c !== void 0 && (i.height = c), K(e.type) && (i.type = e.type.toLowerCase());
1476
+ const a = q(K(e.thumb));
1477
+ return a && (i.thumb = a), K(e.modified) && !Number.isNaN(Date.parse(e.modified)) && (i.modified = e.modified), i;
1336
1478
  }
1337
- function Cr(t, e = "/") {
1338
- const n = Array.isArray(t) ? { files: t } : t && typeof t == "object" ? t : {}, r = (Array.isArray(n.files) ? n.files : []).map(Vt).filter((s) => !!s), o = (Array.isArray(n.folders) ? n.folders : []).map((s) => s && typeof s == "object" ? s : {}).filter((s) => V(s.name) && V(s.path)).map((s) => ({ name: s.name, path: Ke(s.path) }));
1479
+ function Yr(t, e = "/") {
1480
+ const n = Array.isArray(t) ? { files: t } : t && typeof t == "object" ? t : {}, r = (Array.isArray(n.files) ? n.files : []).map(an).filter((s) => !!s), i = (Array.isArray(n.folders) ? n.folders : []).map((s) => s && typeof s == "object" ? s : {}).filter((s) => K(s.name) && K(s.path)).map((s) => ({ name: s.name, path: rt(s.path) }));
1339
1481
  return {
1340
- path: Ke(V(n.path) ?? e),
1341
- folders: o,
1482
+ path: rt(K(n.path) ?? e),
1483
+ folders: i,
1342
1484
  files: r,
1343
1485
  hasMore: n.hasMore === !0,
1344
1486
  serverSearch: typeof n.q == "string"
1345
1487
  };
1346
1488
  }
1347
- function Ke(t) {
1489
+ function rt(t) {
1348
1490
  return "/" + t.split("/").filter((n) => n && n !== "." && n !== "..").join("/");
1349
1491
  }
1350
- const Dr = /\.(jpe?g|png|gif|webp|avif|svg|bmp|ico)$/i, Nr = {
1492
+ const Jr = /\.(jpe?g|png|gif|webp|avif|svg|bmp|ico)$/i, Xr = {
1351
1493
  jpg: "image/jpeg",
1352
1494
  jpeg: "image/jpeg",
1353
1495
  png: "image/png",
@@ -1367,23 +1509,23 @@ const Dr = /\.(jpe?g|png|gif|webp|avif|svg|bmp|ico)$/i, Nr = {
1367
1509
  xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
1368
1510
  mp4: "video/mp4",
1369
1511
  mp3: "audio/mpeg"
1370
- }, Kt = (t) => (/\.([a-z0-9]+)$/i.exec(t)?.[1] ?? "").toLowerCase();
1371
- function Yt(t) {
1372
- return t.type || Nr[Kt(t.name)] || "";
1512
+ }, ln = (t) => (/\.([a-z0-9]+)$/i.exec(t)?.[1] ?? "").toLowerCase();
1513
+ function cn(t) {
1514
+ return t.type || Xr[ln(t.name)] || "";
1373
1515
  }
1374
- function ue(t) {
1375
- const e = Yt(t);
1376
- return e ? e.startsWith("image/") : Dr.test(t.url ?? t.name);
1516
+ function pe(t) {
1517
+ const e = cn(t);
1518
+ return e ? e.startsWith("image/") : Jr.test(t.url ?? t.name);
1377
1519
  }
1378
- function xt(t, e) {
1520
+ function $t(t, e) {
1379
1521
  if (!e || !e.trim()) return !0;
1380
- const n = Yt(t), r = "." + Kt(t.name);
1381
- return e.split(",").some((o) => {
1382
- const s = o.trim().toLowerCase();
1522
+ const n = cn(t), r = "." + ln(t.name);
1523
+ return e.split(",").some((i) => {
1524
+ const s = i.trim().toLowerCase();
1383
1525
  return s ? s.startsWith(".") ? r === s : s.endsWith("/*") ? n.startsWith(s.slice(0, -1)) : n === s : !1;
1384
1526
  });
1385
1527
  }
1386
- function Et(t) {
1528
+ function Ot(t) {
1387
1529
  if (t === void 0) return "";
1388
1530
  if (t < 1024) return `${t} B`;
1389
1531
  const e = ["KB", "MB", "GB"];
@@ -1392,12 +1534,12 @@ function Et(t) {
1392
1534
  n /= 1024, r++;
1393
1535
  return `${n < 10 ? n.toFixed(1) : Math.round(n)} ${e[r]}`;
1394
1536
  }
1395
- class $ extends Error {
1537
+ class H extends Error {
1396
1538
  constructor(e, n) {
1397
1539
  super(e), this.code = n;
1398
1540
  }
1399
1541
  }
1400
- async function St(t) {
1542
+ async function Ht(t) {
1401
1543
  try {
1402
1544
  const e = await t.clone().json();
1403
1545
  if (e && typeof e.error == "string") return e.error;
@@ -1405,12 +1547,12 @@ async function St(t) {
1405
1547
  }
1406
1548
  return `HTTP ${t.status}`;
1407
1549
  }
1408
- function Ir(t, e) {
1550
+ function Qr(t, e) {
1409
1551
  const n = new URL(t, document.baseURI);
1410
- for (const [r, o] of Object.entries(e)) o && n.searchParams.set(r, o);
1552
+ for (const [r, i] of Object.entries(e)) i && n.searchParams.set(r, i);
1411
1553
  return n.href;
1412
1554
  }
1413
- class Hr {
1555
+ class Zr {
1414
1556
  constructor(e) {
1415
1557
  this.options = e;
1416
1558
  }
@@ -1427,437 +1569,737 @@ class Hr {
1427
1569
  headers: { Accept: "application/json", ...this.options.headers, ...e.headers }
1428
1570
  };
1429
1571
  }
1430
- async list(e, n, r, o) {
1431
- const s = Ir(this.options.listUrl, { path: e, q: n, page: r > 1 ? String(r) : "" });
1432
- let c;
1572
+ async list(e, n, r, i) {
1573
+ const s = Qr(this.options.listUrl, { path: e, q: n, page: r > 1 ? String(r) : "" });
1574
+ let o;
1433
1575
  try {
1434
- c = await fetch(s, { ...this.init(), signal: o });
1435
- } catch (i) {
1436
- throw i.name === "AbortError" ? i : new $(i.message || "Network error", "network");
1576
+ o = await fetch(s, { ...this.init(), signal: i });
1577
+ } catch (a) {
1578
+ throw a.name === "AbortError" ? a : new H(a.message || "Network error", "network");
1437
1579
  }
1438
- if (!c.ok) throw new $(await St(c));
1439
- let d;
1580
+ if (!o.ok) throw new H(await Ht(o));
1581
+ let c;
1440
1582
  try {
1441
- d = await c.json();
1583
+ c = await o.json();
1442
1584
  } catch {
1443
- throw new $("Invalid JSON", "response");
1585
+ throw new H("Invalid JSON", "response");
1444
1586
  }
1445
- return Cr(d, e);
1587
+ return Yr(c, e);
1446
1588
  }
1447
1589
  /** Multipart upload with progress (XMLHttpRequest, because fetch has no upload progress). */
1448
1590
  upload(e, n, r) {
1449
- const { uploadUrl: o, headers: s = {}, withCredentials: c } = this.options;
1450
- return o ? new Promise((d, i) => {
1451
- const a = new XMLHttpRequest();
1452
- a.open("POST", new URL(o, document.baseURI).href), a.withCredentials = !!c, a.setRequestHeader("Accept", "application/json");
1453
- for (const [u, m] of Object.entries(s)) a.setRequestHeader(u, m);
1454
- a.upload.onprogress = (u) => u.lengthComputable && r?.(u.loaded / u.total), a.onerror = () => i(new $("Network error", "network")), a.onload = () => {
1591
+ const { uploadUrl: i, headers: s = {}, withCredentials: o } = this.options;
1592
+ return i ? new Promise((c, a) => {
1593
+ const l = new XMLHttpRequest();
1594
+ l.open("POST", new URL(i, document.baseURI).href), l.withCredentials = !!o, l.setRequestHeader("Accept", "application/json");
1595
+ for (const [u, m] of Object.entries(s)) l.setRequestHeader(u, m);
1596
+ l.upload.onprogress = (u) => u.lengthComputable && r?.(u.loaded / u.total), l.onerror = () => a(new H("Network error", "network")), l.onload = () => {
1455
1597
  let u = null;
1456
1598
  try {
1457
- u = JSON.parse(a.responseText);
1599
+ u = JSON.parse(l.responseText);
1458
1600
  } catch {
1459
1601
  }
1460
- if (a.status < 200 || a.status >= 300) {
1461
- i(new $(typeof u?.error == "string" ? u.error : `HTTP ${a.status}`));
1602
+ if (l.status < 200 || l.status >= 300) {
1603
+ a(new H(typeof u?.error == "string" ? u.error : `HTTP ${l.status}`));
1462
1604
  return;
1463
1605
  }
1464
- const m = Vt(u?.file);
1465
- m ? d(m) : i(new $("Invalid upload response", "response"));
1606
+ const m = an(u?.file);
1607
+ m ? c(m) : a(new H("Invalid upload response", "response"));
1466
1608
  };
1467
- const l = new FormData();
1468
- l.append("file", e, e.name), l.append("path", n), a.send(l);
1469
- }) : Promise.reject(new $("Upload is not configured"));
1609
+ const d = new FormData();
1610
+ d.append("file", e, e.name), d.append("path", n), l.send(d);
1611
+ }) : Promise.reject(new H("Upload is not configured"));
1470
1612
  }
1471
1613
  async remove(e) {
1472
1614
  const { deleteUrl: n } = this.options;
1473
- if (!n) throw new $("Delete is not configured");
1615
+ if (!n) throw new H("Delete is not configured");
1474
1616
  let r;
1475
1617
  try {
1476
1618
  r = await fetch(
1477
1619
  new URL(n, document.baseURI).href,
1478
1620
  this.init({ method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ url: e }) })
1479
1621
  );
1480
- } catch (o) {
1481
- throw new $(o.message || "Network error", "network");
1622
+ } catch (i) {
1623
+ throw new H(i.message || "Network error", "network");
1482
1624
  }
1483
- if (!r.ok) throw new $(await St(r));
1625
+ if (!r.ok) throw new H(await Ht(r));
1484
1626
  }
1485
1627
  }
1486
- function Re(t, e) {
1487
- return t instanceof $ && t.code === "network" ? e.fmNetworkError : t instanceof $ && t.code === "response" ? e.fmInvalidResponse : t?.message ?? "";
1628
+ function Ue(t, e) {
1629
+ return t instanceof H && t.code === "network" ? e.fmNetworkError : t instanceof H && t.code === "response" ? e.fmInvalidResponse : t?.message ?? "";
1488
1630
  }
1489
- const b = (t, e, n) => {
1631
+ const w = (t, e, n) => {
1490
1632
  const r = document.createElement(t);
1491
1633
  return e && (r.className = e), n !== void 0 && (r.textContent = n), r;
1492
- }, $e = (t, e, n = "wds-icon-button") => {
1493
- const r = b("button", n);
1634
+ }, We = (t, e, n = "wds-icon-button") => {
1635
+ const r = w("button", n);
1494
1636
  return r.type = "button", r.innerHTML = t, r.setAttribute("aria-label", e), r.title = e, r;
1495
- }, Or = [
1637
+ }, ei = [
1496
1638
  ["", "alignNone"],
1497
1639
  ["left", "alignLeftShort"],
1498
1640
  ["center", "alignCenterShort"],
1499
1641
  ["right", "alignRightShort"]
1500
1642
  ];
1501
- class Rr {
1643
+ class ti {
1502
1644
  constructor(e, n, r) {
1503
1645
  this.host = e, this.api = n, this.t = r, this.path = "/", this.view = "grid", this.sort = "newest";
1504
1646
  }
1505
1647
  open(e) {
1506
1648
  const n = this.t, r = e.accept ?? "";
1507
- let o = [], s = [], c = 1, d = !1, i = !1, a = "", l = null, u = null, m = 0, g = !1;
1508
- const k = b("dialog", "wds-dialog wds-fm");
1509
- k.setAttribute("aria-labelledby", "wds-fm-title");
1510
- const D = b("div", "wds-dialog-header"), A = b("h2", void 0, n.fmTitle);
1511
- A.id = "wds-fm-title";
1512
- const C = $e(L.close, n.close);
1513
- D.append(A, C);
1514
- const I = b("div", "wds-fm-bar"), y = b("nav", "wds-fm-crumbs");
1515
- y.setAttribute("aria-label", n.fmBreadcrumb);
1516
- const x = b("input", "wds-input wds-fm-search");
1517
- x.type = "search", x.placeholder = n.fmSearch, x.setAttribute("aria-label", n.fmSearch);
1518
- const T = b("select", "wds-input wds-fm-sort");
1519
- T.setAttribute("aria-label", n.fmSort), T.title = n.fmSort;
1520
- for (const [h, f] of [["newest", "fmSortNewest"], ["name", "fmSortName"], ["largest", "fmSortLargest"]]) {
1521
- const M = b("option", void 0, n[f]);
1522
- M.value = h, T.append(M);
1649
+ let i = [], s = [], o = 1, c = !1, a = !1, l = "", d = null, u = null, m = 0, p = !1;
1650
+ const b = w("dialog", "wds-dialog wds-fm");
1651
+ b.setAttribute("aria-labelledby", "wds-fm-title");
1652
+ const x = w("div", "wds-dialog-header"), T = w("h2", void 0, n.fmTitle);
1653
+ T.id = "wds-fm-title";
1654
+ const A = We(L.close, n.close);
1655
+ x.append(T, A);
1656
+ const N = w("div", "wds-fm-bar"), v = w("nav", "wds-fm-crumbs");
1657
+ v.setAttribute("aria-label", n.fmBreadcrumb);
1658
+ const E = w("input", "wds-input wds-fm-search");
1659
+ E.type = "search", E.placeholder = n.fmSearch, E.setAttribute("aria-label", n.fmSearch);
1660
+ const I = w("select", "wds-input wds-fm-sort");
1661
+ I.setAttribute("aria-label", n.fmSort), I.title = n.fmSort;
1662
+ for (const [h, g] of [["newest", "fmSortNewest"], ["name", "fmSortName"], ["largest", "fmSortLargest"]]) {
1663
+ const M = w("option", void 0, n[g]);
1664
+ M.value = h, I.append(M);
1523
1665
  }
1524
- T.value = this.sort;
1525
- const H = $e(this.view === "grid" ? L.list : L.grid, this.view === "grid" ? n.fmList : n.fmGrid), O = b("input");
1526
- O.type = "file", O.multiple = !0, O.hidden = !0, r && (O.accept = r);
1527
- const G = b("button", "wds-button wds-button-primary wds-fm-upload");
1528
- G.type = "button", G.innerHTML = `${L.upload}<span>${ze(n.fmUpload)}</span>`;
1529
- const Me = b("div", "wds-fm-tools");
1530
- Me.append(x, T, H), this.api.canUpload && Me.append(G, O), I.append(y, Me);
1531
- const Qe = b("div", "wds-fm-main"), W = b("div", "wds-fm-browser"), Le = b("div", "wds-fm-uploads"), F = b("ul", `wds-fm-items is-${this.view}`);
1666
+ I.value = this.sort;
1667
+ const R = We(this.view === "grid" ? L.list : L.grid, this.view === "grid" ? n.fmList : n.fmGrid), $ = w("input");
1668
+ $.type = "file", $.multiple = !0, $.hidden = !0, r && ($.accept = r);
1669
+ const j = w("button", "wds-button wds-button-primary wds-fm-upload");
1670
+ j.type = "button", j.innerHTML = `${L.upload}<span>${_e(n.fmUpload)}</span>`;
1671
+ const Ae = w("div", "wds-fm-tools");
1672
+ Ae.append(E, I, R), this.api.canUpload && Ae.append(j, $), N.append(v, Ae);
1673
+ const ct = w("div", "wds-fm-main"), V = w("div", "wds-fm-browser"), Te = w("div", "wds-fm-uploads"), F = w("ul", `wds-fm-items is-${this.view}`);
1532
1674
  F.setAttribute("aria-label", n.fmTitle);
1533
- const N = b("p", "wds-fm-status");
1534
- N.setAttribute("role", "status");
1535
- const Q = b("button", "wds-button", n.fmRetry);
1536
- Q.type = "button", Q.hidden = !0;
1537
- const Z = b("button", "wds-button wds-fm-more", n.fmLoadMore);
1538
- Z.type = "button", Z.hidden = !0;
1539
- const Ze = b("div", "wds-fm-drop", n.fmDrop);
1540
- Ze.setAttribute("aria-hidden", "true"), W.append(Le, F, N, Q, Z, Ze);
1541
- const U = b("aside", "wds-fm-details");
1542
- U.setAttribute("aria-label", n.imageEdit), Qe.append(W, U);
1543
- const xe = b("div", "wds-dialog-footer");
1675
+ const D = w("p", "wds-fm-status");
1676
+ D.setAttribute("role", "status");
1677
+ const ee = w("button", "wds-button", n.fmRetry);
1678
+ ee.type = "button", ee.hidden = !0;
1679
+ const te = w("button", "wds-button wds-fm-more", n.fmLoadMore);
1680
+ te.type = "button", te.hidden = !0;
1681
+ const dt = w("div", "wds-fm-drop", n.fmDrop);
1682
+ dt.setAttribute("aria-hidden", "true"), V.append(Te, F, D, ee, te, dt);
1683
+ const U = w("aside", "wds-fm-details");
1684
+ U.setAttribute("aria-label", n.imageEdit), ct.append(V, U);
1685
+ const Ce = w("div", "wds-dialog-footer");
1544
1686
  if (e.onFromUrl) {
1545
- const h = b("button", "wds-button wds-fm-fromurl");
1546
- h.type = "button", h.innerHTML = `${L.globe}<span>${ze(n.fmFromUrl)}</span>`, h.addEventListener("click", () => {
1547
- J(), e.onFromUrl();
1548
- }), xe.append(h);
1687
+ const h = w("button", "wds-button wds-fm-fromurl");
1688
+ h.type = "button", h.innerHTML = `${L.globe}<span>${_e(n.fmFromUrl)}</span>`, h.addEventListener("click", () => {
1689
+ X(), e.onFromUrl();
1690
+ }), Ce.append(h);
1549
1691
  }
1550
- const Ee = b("button", "wds-button", n.cancel);
1551
- Ee.type = "button";
1552
- const ie = b("button", "wds-button wds-button-primary", n.insert);
1553
- ie.type = "button", ie.disabled = !0, xe.append(b("span", "wds-spacer"), Ee, ie), k.append(D, I, Qe, xe), this.host.append(k);
1554
- let ae = null, P = null, se = null, K = null, le = null;
1555
- const fe = (h, f, M, w) => {
1556
- f.id = M;
1557
- const S = b("label", "wds-label", h);
1558
- if (S.htmlFor = M, U.append(S, f), w) {
1559
- const v = b("p", "wds-hint", w);
1560
- v.id = `${M}-hint`, f.setAttribute("aria-describedby", v.id), U.append(v);
1692
+ const Ie = w("button", "wds-button", n.cancel);
1693
+ Ie.type = "button";
1694
+ const le = w("button", "wds-button wds-button-primary", n.insert);
1695
+ le.type = "button", le.disabled = !0, Ce.append(w("span", "wds-spacer"), Ie, le), b.append(x, N, ct, Ce), this.host.append(b);
1696
+ let ce = null, W = null, de = null, Y = null, ue = null;
1697
+ const ye = (h, g, M, y) => {
1698
+ g.id = M;
1699
+ const C = w("label", "wds-label", h);
1700
+ if (C.htmlFor = M, U.append(C, g), y) {
1701
+ const k = w("p", "wds-hint", y);
1702
+ k.id = `${M}-hint`, g.setAttribute("aria-describedby", k.id), U.append(k);
1561
1703
  }
1562
- }, ge = () => {
1563
- if (U.replaceChildren(), ae = P = le = K = null, se = null, ie.disabled = !l, !l) {
1564
- U.append(b("p", "wds-fm-placeholder", n.fmNoSelection));
1704
+ }, ve = () => {
1705
+ if (U.replaceChildren(), ce = W = ue = Y = null, de = null, le.disabled = !d, !d) {
1706
+ U.append(w("p", "wds-fm-placeholder", n.fmNoSelection));
1565
1707
  return;
1566
1708
  }
1567
- const h = l, f = b("div", "wds-fm-preview"), M = b("p", "wds-fm-filename", h.name), w = b("p", "wds-fm-facts"), S = () => [
1709
+ const h = d, g = w("div", "wds-fm-preview"), M = w("p", "wds-fm-filename", h.name), y = w("p", "wds-fm-facts"), C = () => [
1568
1710
  h.width && h.height ? `${h.width} × ${h.height}` : "",
1569
- Et(h.size),
1711
+ Ot(h.size),
1570
1712
  h.modified ? new Date(h.modified).toLocaleDateString() : ""
1571
1713
  ].filter(Boolean).join(" · ");
1572
- if (w.textContent = S(), ue(h)) {
1573
- const v = b("img");
1574
- v.alt = "", !h.thumb && !(h.width && h.height) && v.addEventListener("load", () => {
1575
- !v.naturalWidth || l !== h || (h.width = v.naturalWidth, h.height = v.naturalHeight, w.textContent = S(), P && !P.placeholder && (P.placeholder = String(h.width)));
1576
- }, { once: !0 }), v.src = h.thumb ?? h.url, f.append(v);
1714
+ if (y.textContent = C(), pe(h)) {
1715
+ const k = w("img");
1716
+ k.alt = "", !h.thumb && !(h.width && h.height) && k.addEventListener("load", () => {
1717
+ !k.naturalWidth || d !== h || (h.width = k.naturalWidth, h.height = k.naturalHeight, y.textContent = C(), W && !W.placeholder && (W.placeholder = String(h.width)));
1718
+ }, { once: !0 }), k.src = h.thumb ?? h.url, g.append(k);
1577
1719
  } else
1578
- f.innerHTML = L.file;
1579
- if (U.append(f, M, w), e.mode === "image" && ue(h)) {
1580
- ae = b("input", "wds-input"), ae.value = h.name.replace(/\.[a-z0-9]+$/i, "").replace(/[-_]+/g, " "), fe(n.imageAlt, ae, "wds-fm-alt", n.imageAltHint), P = b("input", "wds-input"), P.inputMode = "numeric", P.placeholder = h.width ? String(h.width) : "", fe(n.imageWidth, P, "wds-fm-width"), se = b("select", "wds-input");
1581
- for (const [z, B] of Or) {
1582
- const ee = b("option", void 0, n[B]);
1583
- ee.value = z, se.append(ee);
1720
+ g.innerHTML = L.file;
1721
+ if (U.append(g, M, y), e.mode === "image" && pe(h)) {
1722
+ ce = w("input", "wds-input"), ce.value = h.name.replace(/\.[a-z0-9]+$/i, "").replace(/[-_]+/g, " "), ye(n.imageAlt, ce, "wds-fm-alt", n.imageAltHint), W = w("input", "wds-input"), W.inputMode = "numeric", W.placeholder = h.width ? String(h.width) : "", ye(n.imageWidth, W, "wds-fm-width"), de = w("select", "wds-input");
1723
+ for (const [P, B] of ei) {
1724
+ const ne = w("option", void 0, n[B]);
1725
+ ne.value = P, de.append(ne);
1584
1726
  }
1585
- fe(n.imageAlign, se, "wds-fm-align"), K = b("input"), K.type = "checkbox", K.id = "wds-fm-caption";
1586
- const v = b("label", "wds-check");
1587
- v.htmlFor = K.id, v.append(K, document.createTextNode(n.caption)), U.append(v);
1727
+ ye(n.imageAlign, de, "wds-fm-align"), Y = w("input"), Y.type = "checkbox", Y.id = "wds-fm-caption";
1728
+ const k = w("label", "wds-check");
1729
+ k.htmlFor = Y.id, k.append(Y, document.createTextNode(n.caption)), U.append(k);
1588
1730
  } else
1589
- le = b("input", "wds-input"), le.value = h.name, fe(n.fmLinkText, le, "wds-fm-text");
1731
+ ue = w("input", "wds-input"), ue.value = h.name, ye(n.fmLinkText, ue, "wds-fm-text");
1590
1732
  if (this.api.canDelete) {
1591
- const v = b("button", "wds-button wds-button-danger wds-fm-delete");
1592
- v.type = "button", v.innerHTML = `${L.trash}<span>${ze(n.fmDelete)}</span>`, v.addEventListener("click", () => Xt(h)), U.append(v);
1733
+ const k = w("button", "wds-button wds-button-danger wds-fm-delete");
1734
+ k.type = "button", k.innerHTML = `${L.trash}<span>${_e(n.fmDelete)}</span>`, k.addEventListener("click", () => mn(h)), U.append(k);
1593
1735
  }
1594
- }, Jt = () => {
1595
- const h = a.trim().toLocaleLowerCase(), f = o.filter((w) => xt(w, r) && (i || !h || w.name.toLocaleLowerCase().includes(h))), M = (w) => w.modified ? Date.parse(w.modified) : -1 / 0;
1596
- return this.sort === "name" ? f.sort((w, S) => w.name.localeCompare(S.name, void 0, { numeric: !0, sensitivity: "base" })) : this.sort === "largest" ? f.sort((w, S) => (S.size ?? -1) - (w.size ?? -1)) : f.sort((w, S) => M(S) - M(w)), f;
1597
- }, Se = () => {
1598
- y.replaceChildren();
1599
- const h = this.path.split("/").filter(Boolean), f = [[n.fmRoot, "/"], ...h.map((M, w) => [M, "/" + h.slice(0, w + 1).join("/")])];
1600
- f.forEach(([M, w], S) => {
1601
- if (S && y.append(b("span", "wds-fm-sep", "/")), S === f.length - 1) {
1602
- const v = b("span", "wds-fm-crumb is-current", M);
1603
- v.setAttribute("aria-current", "location"), y.append(v);
1736
+ }, fn = () => {
1737
+ const h = l.trim().toLocaleLowerCase(), g = i.filter((y) => $t(y, r) && (a || !h || y.name.toLocaleLowerCase().includes(h))), M = (y) => y.modified ? Date.parse(y.modified) : -1 / 0;
1738
+ return this.sort === "name" ? g.sort((y, C) => y.name.localeCompare(C.name, void 0, { numeric: !0, sensitivity: "base" })) : this.sort === "largest" ? g.sort((y, C) => (C.size ?? -1) - (y.size ?? -1)) : g.sort((y, C) => M(C) - M(y)), g;
1739
+ }, De = () => {
1740
+ v.replaceChildren();
1741
+ const h = this.path.split("/").filter(Boolean), g = [[n.fmRoot, "/"], ...h.map((M, y) => [M, "/" + h.slice(0, y + 1).join("/")])];
1742
+ g.forEach(([M, y], C) => {
1743
+ if (C && v.append(w("span", "wds-fm-sep", "/")), C === g.length - 1) {
1744
+ const k = w("span", "wds-fm-crumb is-current", M);
1745
+ k.setAttribute("aria-current", "location"), v.append(k);
1604
1746
  } else {
1605
- const v = b("button", "wds-fm-crumb", M);
1606
- v.type = "button", v.addEventListener("click", () => nt(w)), y.append(v);
1747
+ const k = w("button", "wds-fm-crumb", M);
1748
+ k.type = "button", k.addEventListener("click", () => ft(y)), v.append(k);
1607
1749
  }
1608
1750
  });
1609
- }, Y = () => {
1751
+ }, J = () => {
1610
1752
  F.className = `wds-fm-items is-${this.view}`, F.replaceChildren();
1611
- const h = !a.trim();
1753
+ const h = !l.trim();
1612
1754
  if (h)
1613
- for (const w of s) {
1614
- const S = tt(L.folder, w.name, n.fmFolder, !0);
1615
- S.addEventListener("click", () => nt(w.path)), F.append(et(S));
1755
+ for (const y of s) {
1756
+ const C = ht(L.folder, y.name, n.fmFolder, !0);
1757
+ C.addEventListener("click", () => ft(y.path)), F.append(ut(C));
1616
1758
  }
1617
- const f = Jt();
1618
- for (const w of f) {
1619
- const S = ue(w) ? w.thumb ?? w.url : null, v = tt(S ? "" : L.file, w.name, [Et(w.size), w.width && w.height ? `${w.width}×${w.height}` : ""].filter(Boolean).join(" · "), !1);
1620
- if (S) {
1621
- const B = b("img");
1622
- B.loading = "lazy", B.decoding = "async", B.alt = "", B.src = S, v.querySelector(".wds-fm-thumb").append(B);
1759
+ const g = fn();
1760
+ for (const y of g) {
1761
+ const C = pe(y) ? y.thumb ?? y.url : null, k = ht(C ? "" : L.file, y.name, [Ot(y.size), y.width && y.height ? `${y.width}×${y.height}` : ""].filter(Boolean).join(" · "), !1);
1762
+ if (C) {
1763
+ const B = w("img");
1764
+ B.loading = "lazy", B.decoding = "async", B.alt = "", B.src = C, k.querySelector(".wds-fm-thumb").append(B);
1623
1765
  }
1624
- v.dataset.url = w.url;
1625
- const z = l?.url === w.url;
1626
- v.classList.toggle("is-selected", z), v.setAttribute("aria-pressed", String(z)), v.addEventListener("click", () => Ae(w)), v.addEventListener("dblclick", () => {
1627
- Ae(w), Te();
1628
- }), F.append(et(v));
1766
+ k.dataset.url = y.url;
1767
+ const P = d?.url === y.url;
1768
+ k.classList.toggle("is-selected", P), k.setAttribute("aria-pressed", String(P)), k.addEventListener("click", () => Ne(y)), k.addEventListener("dblclick", () => {
1769
+ Ne(y), Re();
1770
+ }), F.append(ut(k));
1629
1771
  }
1630
- const M = !f.length && !(h && s.length);
1631
- !N.dataset.busy && !N.dataset.error && (N.textContent = M ? a.trim() ? n.fmNoResults : n.fmEmpty : ""), Z.hidden = !d || !!N.dataset.busy;
1632
- }, et = (h) => {
1633
- const f = b("li");
1634
- return f.append(h), f;
1635
- }, tt = (h, f, M, w) => {
1636
- const S = b("button", `wds-fm-item${w ? " is-folder" : ""}`);
1637
- S.type = "button";
1638
- const v = b("span", "wds-fm-thumb");
1639
- v.innerHTML = h;
1640
- const z = b("span", "wds-fm-name", f);
1641
- z.title = f;
1642
- const B = b("span", "wds-fm-meta", M);
1643
- return S.append(v, z, B), S;
1644
- }, Ae = (h) => {
1645
- l = h, F.querySelectorAll(".wds-fm-item[data-url]").forEach((f) => {
1646
- const M = f.dataset.url === h.url;
1647
- f.classList.toggle("is-selected", M), f.setAttribute("aria-pressed", String(M));
1648
- }), ge();
1649
- }, ce = async (h) => {
1650
- u?.abort(), u = new AbortController(), h && (c = 1, o = [], s = []), N.dataset.busy = "1", delete N.dataset.error, N.textContent = n.fmLoading, Q.hidden = !0, Z.hidden = !0, h && Y();
1772
+ const M = !g.length && !(h && s.length);
1773
+ !D.dataset.busy && !D.dataset.error && (D.textContent = M ? l.trim() ? n.fmNoResults : n.fmEmpty : ""), te.hidden = !c || !!D.dataset.busy;
1774
+ }, ut = (h) => {
1775
+ const g = w("li");
1776
+ return g.append(h), g;
1777
+ }, ht = (h, g, M, y) => {
1778
+ const C = w("button", `wds-fm-item${y ? " is-folder" : ""}`);
1779
+ C.type = "button";
1780
+ const k = w("span", "wds-fm-thumb");
1781
+ k.innerHTML = h;
1782
+ const P = w("span", "wds-fm-name", g);
1783
+ P.title = g;
1784
+ const B = w("span", "wds-fm-meta", M);
1785
+ return C.append(k, P, B), C;
1786
+ }, Ne = (h) => {
1787
+ d = h, F.querySelectorAll(".wds-fm-item[data-url]").forEach((g) => {
1788
+ const M = g.dataset.url === h.url;
1789
+ g.classList.toggle("is-selected", M), g.setAttribute("aria-pressed", String(M));
1790
+ }), ve();
1791
+ }, he = async (h) => {
1792
+ u?.abort(), u = new AbortController(), h && (o = 1, i = [], s = []), D.dataset.busy = "1", delete D.dataset.error, D.textContent = n.fmLoading, ee.hidden = !0, te.hidden = !0, h && J();
1651
1793
  try {
1652
- const f = await this.api.list(this.path, a.trim(), c, u.signal);
1653
- if (g) return;
1654
- this.path = f.path, i = f.serverSearch, d = f.hasMore, s = h ? f.folders : s;
1655
- const M = new Set(o.map((w) => w.url));
1656
- o = [...o, ...f.files.filter((w) => !M.has(w.url))], delete N.dataset.busy, N.textContent = "", Se(), Y();
1657
- } catch (f) {
1658
- if (f.name === "AbortError" || g) return;
1659
- delete N.dataset.busy, N.dataset.error = "1", N.textContent = j(n.fmListFailed, { error: Re(f, n) }), N.setAttribute("role", "alert"), Q.hidden = !1;
1794
+ const g = await this.api.list(this.path, l.trim(), o, u.signal);
1795
+ if (p) return;
1796
+ this.path = g.path, a = g.serverSearch, c = g.hasMore, s = h ? g.folders : s;
1797
+ const M = new Set(i.map((y) => y.url));
1798
+ i = [...i, ...g.files.filter((y) => !M.has(y.url))], delete D.dataset.busy, D.textContent = "", De(), J();
1799
+ } catch (g) {
1800
+ if (g.name === "AbortError" || p) return;
1801
+ delete D.dataset.busy, D.dataset.error = "1", D.textContent = z(n.fmListFailed, { error: Ue(g, n) }), D.setAttribute("role", "alert"), ee.hidden = !1;
1660
1802
  }
1661
- }, nt = (h) => {
1662
- this.path = Ke(h), a = "", x.value = "", l = null, ge(), Se(), ce(!0).then(() => F.querySelector(".wds-fm-item")?.focus());
1663
- }, rt = (h) => {
1664
- for (const f of Array.from(h)) {
1665
- const M = b("div", "wds-fm-upload-row"), w = b("span", "wds-fm-upload-name", j(n.fmUploading, { name: f.name }));
1666
- if (!xt(f, r)) {
1667
- ot(M, j(n.fmNotAllowed, { name: f.name })), Le.append(M);
1803
+ }, ft = (h) => {
1804
+ this.path = rt(h), l = "", E.value = "", d = null, ve(), De(), he(!0).then(() => F.querySelector(".wds-fm-item")?.focus());
1805
+ }, mt = (h) => {
1806
+ for (const g of Array.from(h)) {
1807
+ const M = w("div", "wds-fm-upload-row"), y = w("span", "wds-fm-upload-name", z(n.fmUploading, { name: g.name }));
1808
+ if (!$t(g, r)) {
1809
+ pt(M, z(n.fmNotAllowed, { name: g.name })), Te.append(M);
1668
1810
  continue;
1669
1811
  }
1670
- const S = b("progress");
1671
- S.max = 1, S.value = 0, M.append(w, S), Le.append(M), this.api.upload(f, this.path, (v) => S.value = v).then((v) => {
1672
- g || (M.remove(), o = [v, ...o.filter((z) => z.url !== v.url)], Y(), Ae(v), e.onUpload?.(v));
1673
- }).catch((v) => {
1674
- g || (M.replaceChildren(), ot(M, j(n.fmUploadFailed, { name: f.name, error: Re(v, n) })));
1812
+ const C = w("progress");
1813
+ C.max = 1, C.value = 0, M.append(y, C), Te.append(M), this.api.upload(g, this.path, (k) => C.value = k).then((k) => {
1814
+ p || (M.remove(), i = [k, ...i.filter((P) => P.url !== k.url)], J(), Ne(k), e.onUpload?.(k));
1815
+ }).catch((k) => {
1816
+ p || (M.replaceChildren(), pt(M, z(n.fmUploadFailed, { name: g.name, error: Ue(k, n) })));
1675
1817
  });
1676
1818
  }
1677
- }, ot = (h, f) => {
1819
+ }, pt = (h, g) => {
1678
1820
  h.classList.add("is-error");
1679
- const M = b("span", "wds-fm-upload-name", f);
1821
+ const M = w("span", "wds-fm-upload-name", g);
1680
1822
  M.setAttribute("role", "alert");
1681
- const w = $e(L.close, n.close);
1682
- w.addEventListener("click", () => h.remove()), h.append(M, w);
1683
- }, Xt = async (h) => {
1684
- if (window.confirm(j(n.fmDeleteConfirm, { name: h.name })))
1823
+ const y = We(L.close, n.close);
1824
+ y.addEventListener("click", () => h.remove()), h.append(M, y);
1825
+ }, mn = async (h) => {
1826
+ if (window.confirm(z(n.fmDeleteConfirm, { name: h.name })))
1685
1827
  try {
1686
- await this.api.remove(h.url), o = o.filter((f) => f.url !== h.url), l = null, ge(), Y();
1687
- } catch (f) {
1688
- N.dataset.error = "1", N.setAttribute("role", "alert"), N.textContent = j(n.fmDeleteFailed, { error: Re(f, n) });
1828
+ await this.api.remove(h.url), i = i.filter((g) => g.url !== h.url), d = null, ve(), J();
1829
+ } catch (g) {
1830
+ D.dataset.error = "1", D.setAttribute("role", "alert"), D.textContent = z(n.fmDeleteFailed, { error: Ue(g, n) });
1689
1831
  }
1690
- }, Te = () => {
1691
- if (!l) return;
1692
- const h = P ? parseInt(P.value, 10) : NaN;
1832
+ }, Re = () => {
1833
+ if (!d) return;
1834
+ const h = W ? parseInt(W.value, 10) : NaN;
1693
1835
  e.onPick({
1694
- file: l,
1695
- alt: ae?.value.trim() ?? "",
1836
+ file: d,
1837
+ alt: ce?.value.trim() ?? "",
1696
1838
  width: Number.isFinite(h) && h > 0 ? h : null,
1697
- align: se?.value || null,
1698
- text: le?.value.trim() || l.name,
1699
- caption: !!K?.checked
1700
- }), J();
1839
+ align: de?.value || null,
1840
+ text: ue?.value.trim() || d.name,
1841
+ caption: !!Y?.checked
1842
+ }), X();
1701
1843
  };
1702
- function J() {
1703
- g || (g = !0, u?.abort(), window.clearTimeout(m), k.open && k.close(), k.remove(), e.onClose?.());
1844
+ function X() {
1845
+ p || (p = !0, u?.abort(), window.clearTimeout(m), b.open && b.close(), b.remove(), e.onClose?.());
1704
1846
  }
1705
- if (C.addEventListener("click", J), Ee.addEventListener("click", J), ie.addEventListener("click", Te), k.addEventListener("close", J), k.addEventListener("click", (h) => h.target === k && J()), Q.addEventListener("click", () => {
1706
- N.setAttribute("role", "status"), ce(!0);
1707
- }), Z.addEventListener("click", () => {
1708
- c++, ce(!1);
1709
- }), T.addEventListener("change", () => {
1710
- this.sort = T.value, Y();
1711
- }), H.addEventListener("click", () => {
1712
- this.view = this.view === "grid" ? "list" : "grid", H.innerHTML = this.view === "grid" ? L.list : L.grid;
1847
+ if (A.addEventListener("click", X), Ie.addEventListener("click", X), le.addEventListener("click", Re), b.addEventListener("close", X), b.addEventListener("click", (h) => h.target === b && X()), ee.addEventListener("click", () => {
1848
+ D.setAttribute("role", "status"), he(!0);
1849
+ }), te.addEventListener("click", () => {
1850
+ o++, he(!1);
1851
+ }), I.addEventListener("change", () => {
1852
+ this.sort = I.value, J();
1853
+ }), R.addEventListener("click", () => {
1854
+ this.view = this.view === "grid" ? "list" : "grid", R.innerHTML = this.view === "grid" ? L.list : L.grid;
1713
1855
  const h = this.view === "grid" ? n.fmList : n.fmGrid;
1714
- H.setAttribute("aria-label", h), H.title = h, Y();
1715
- }), x.addEventListener("input", () => {
1856
+ R.setAttribute("aria-label", h), R.title = h, J();
1857
+ }), E.addEventListener("input", () => {
1716
1858
  window.clearTimeout(m), m = window.setTimeout(() => {
1717
- a = x.value, !i && !d ? Y() : ce(!0);
1859
+ l = E.value, !a && !c ? J() : he(!0);
1718
1860
  }, 250);
1719
- }), G.addEventListener("click", () => O.click()), O.addEventListener("change", () => {
1720
- O.files?.length && rt(O.files), O.value = "";
1861
+ }), j.addEventListener("click", () => $.click()), $.addEventListener("change", () => {
1862
+ $.files?.length && mt($.files), $.value = "";
1721
1863
  }), this.api.canUpload) {
1722
1864
  let h = 0;
1723
- W.addEventListener("dragenter", (f) => {
1724
- f.dataTransfer?.types.includes("Files") && (h++, W.classList.add("is-dragging"));
1725
- }), W.addEventListener("dragleave", () => {
1726
- h = Math.max(0, h - 1), h || W.classList.remove("is-dragging");
1727
- }), W.addEventListener("dragover", (f) => {
1728
- f.dataTransfer?.types.includes("Files") && f.preventDefault();
1729
- }), W.addEventListener("drop", (f) => {
1730
- f.preventDefault(), h = 0, W.classList.remove("is-dragging"), f.dataTransfer?.files.length && rt(f.dataTransfer.files);
1865
+ V.addEventListener("dragenter", (g) => {
1866
+ g.dataTransfer?.types.includes("Files") && (h++, V.classList.add("is-dragging"));
1867
+ }), V.addEventListener("dragleave", () => {
1868
+ h = Math.max(0, h - 1), h || V.classList.remove("is-dragging");
1869
+ }), V.addEventListener("dragover", (g) => {
1870
+ g.dataTransfer?.types.includes("Files") && g.preventDefault();
1871
+ }), V.addEventListener("drop", (g) => {
1872
+ g.preventDefault(), h = 0, V.classList.remove("is-dragging"), g.dataTransfer?.files.length && mt(g.dataTransfer.files);
1731
1873
  });
1732
1874
  }
1733
1875
  return F.addEventListener("keydown", (h) => {
1734
1876
  if (!["ArrowRight", "ArrowLeft", "ArrowDown", "ArrowUp", "Home", "End"].includes(h.key)) return;
1735
- const M = [...F.querySelectorAll(".wds-fm-item")], w = M.indexOf(document.activeElement);
1736
- if (w < 0) return;
1877
+ const M = [...F.querySelectorAll(".wds-fm-item")], y = M.indexOf(document.activeElement);
1878
+ if (y < 0) return;
1737
1879
  h.preventDefault();
1738
- const S = M[0].offsetTop, v = this.view === "list" ? 1 : Math.max(1, M.findIndex((ee) => ee.offsetTop !== S) === -1 ? M.length : M.findIndex((ee) => ee.offsetTop !== S)), z = { ArrowRight: 1, ArrowLeft: -1, ArrowDown: v, ArrowUp: -v }, B = h.key === "Home" ? 0 : h.key === "End" ? M.length - 1 : Math.min(M.length - 1, Math.max(0, w + z[h.key]));
1880
+ const C = M[0].offsetTop, k = this.view === "list" ? 1 : Math.max(1, M.findIndex((ne) => ne.offsetTop !== C) === -1 ? M.length : M.findIndex((ne) => ne.offsetTop !== C)), P = { ArrowRight: 1, ArrowLeft: -1, ArrowDown: k, ArrowUp: -k }, B = h.key === "Home" ? 0 : h.key === "End" ? M.length - 1 : Math.min(M.length - 1, Math.max(0, y + P[h.key]));
1739
1881
  M[B].focus();
1740
1882
  }), U.addEventListener("keydown", (h) => {
1741
- h.key === "Enter" && h.target.tagName === "INPUT" && (h.preventDefault(), Te());
1742
- }), Se(), ge(), k.showModal(), x.focus(), ce(!0), J;
1883
+ h.key === "Enter" && h.target.tagName === "INPUT" && (h.preventDefault(), Re());
1884
+ }), De(), ve(), b.showModal(), E.focus(), he(!0), X;
1743
1885
  }
1744
1886
  }
1745
- function ze(t) {
1887
+ function _e(t) {
1746
1888
  const e = document.createElement("span");
1747
1889
  return e.textContent = t, e.innerHTML;
1748
1890
  }
1749
- const te = /* @__PURE__ */ new WeakMap(), At = (t) => t === void 0 ? void 0 : typeof t == "number" ? `${t}px` : t;
1750
- function $r(t) {
1751
- return t === !1 ? [] : t === void 0 || t === "default" ? br : Array.isArray(t) ? t : t.split(/\s+/).filter(Boolean);
1891
+ const Pt = /* @__PURE__ */ new Map();
1892
+ let ni = 0;
1893
+ function ri(t) {
1894
+ const e = [];
1895
+ let n = 0, r = "", i = "";
1896
+ for (let s = 0; s < t.length; s++) {
1897
+ const o = t[s];
1898
+ if (r) {
1899
+ if (o === "\\") {
1900
+ i += o + (t[++s] ?? "");
1901
+ continue;
1902
+ }
1903
+ o === r && (r = "");
1904
+ } else if (o === '"' || o === "'") r = o;
1905
+ else if (o === "(" || o === "[") n++;
1906
+ else if (o === ")" || o === "]") n--;
1907
+ else if (o === "," && n === 0) {
1908
+ e.push(i.trim()), i = "";
1909
+ continue;
1910
+ }
1911
+ i += o;
1912
+ }
1913
+ return i.trim() && e.push(i.trim()), e;
1914
+ }
1915
+ const Ve = /^(?::root|:host|html|body)(?![\w-])((?:\[[^\]]*\]|[.:#][\w-]+(?:\([^)]*\))?)*)/i;
1916
+ function ii(t, e) {
1917
+ return ri(t).map((n) => {
1918
+ let r = n, i = !1, s = "";
1919
+ for (let c = r.match(Ve); c; c = r.match(Ve)) {
1920
+ i = !0, s = c[1] ?? "", r = r.slice(c[0].length).trimStart();
1921
+ const a = r.replace(/^>\s*/, "");
1922
+ a !== r && Ve.test(a) && (r = a);
1923
+ }
1924
+ if (!i) return `${e} ${n}`;
1925
+ const o = e + s;
1926
+ return r ? `${o} ${r}` : o;
1927
+ }).join(", ");
1928
+ }
1929
+ function dn(t, e) {
1930
+ for (const n of Array.from(t))
1931
+ if ("selectorText" in n && typeof n.selectorText == "string") {
1932
+ const r = n;
1933
+ r.selectorText = ii(r.selectorText, e);
1934
+ } else "cssRules" in n && !("name" in n && "appendRule" in n) && dn(n.cssRules, e);
1935
+ }
1936
+ function un(t) {
1937
+ const e = typeof CSSLayerBlockRule < "u";
1938
+ for (let n = 0; n < t.cssRules.length; n++) {
1939
+ const r = t.cssRules[n];
1940
+ if (e && r instanceof CSSLayerStatementRule)
1941
+ t.deleteRule(n--);
1942
+ else if (e && r instanceof CSSLayerBlockRule) {
1943
+ const i = Array.from(r.cssRules, (s) => s.cssText);
1944
+ t.deleteRule(n), i.forEach((s, o) => {
1945
+ try {
1946
+ t.insertRule(s, n + o);
1947
+ } catch {
1948
+ }
1949
+ }), n--;
1950
+ } else typeof CSSGroupingRule < "u" && r instanceof CSSGroupingRule && un(r);
1951
+ }
1952
+ }
1953
+ const si = () => typeof CSSStyleSheet < "u" && "replaceSync" in CSSStyleSheet.prototype && "adoptedStyleSheets" in document;
1954
+ async function oi(t, e) {
1955
+ const n = `:where(.${e})`, r = t.css === void 0 ? [] : Array.isArray(t.css) ? t.css : [t.css], i = await Promise.all(
1956
+ r.map(async (o) => {
1957
+ const c = new URL(o, document.baseURI).href;
1958
+ try {
1959
+ const a = await fetch(c, { credentials: "same-origin" });
1960
+ if (!a.ok) throw new Error(`HTTP ${a.status}`);
1961
+ return { text: await a.text(), baseURL: c };
1962
+ } catch (a) {
1963
+ return console.warn(`[WDS Editor] contentCss could not be loaded: ${c}`, a), null;
1964
+ }
1965
+ })
1966
+ );
1967
+ t.style && i.push({ text: t.style, baseURL: document.baseURI });
1968
+ const s = [];
1969
+ for (const o of i) {
1970
+ if (!o) continue;
1971
+ const c = new CSSStyleSheet({ baseURL: o.baseURL });
1972
+ c.replaceSync(o.text.replace(/@import[^;]*;/g, "")), un(c), dn(c.cssRules, n), s.push(c);
1973
+ }
1974
+ document.adoptedStyleSheets = [...document.adoptedStyleSheets, ...s];
1975
+ }
1976
+ function ai(t) {
1977
+ if (!t.css?.length && !t.style) return null;
1978
+ if (!si())
1979
+ return console.warn("[WDS Editor] contentCss needs constructable stylesheets (all current browsers)."), null;
1980
+ const e = JSON.stringify([t.css, t.style ?? ""]);
1981
+ let n = Pt.get(e);
1982
+ if (!n) {
1983
+ const r = `wds-site-${++ni}`;
1984
+ n = { className: r, ready: oi(t, r) }, Pt.set(e, n);
1985
+ }
1986
+ return n;
1987
+ }
1988
+ const G = new Ut("wds-find");
1989
+ function li(t, e, n) {
1990
+ const r = [];
1991
+ if (!e) return r;
1992
+ const i = n ? e : e.toLowerCase();
1993
+ return t.descendants((s, o) => {
1994
+ if (!s.isTextblock) return !0;
1995
+ let c = "";
1996
+ s.forEach((l) => {
1997
+ c += l.isText ? l.text : "".repeat(l.nodeSize);
1998
+ });
1999
+ const a = n ? c : c.toLowerCase();
2000
+ for (let l = a.indexOf(i); l >= 0; l = a.indexOf(i, l + i.length))
2001
+ r.push({ from: o + 1 + l, to: o + 1 + l + i.length });
2002
+ return !1;
2003
+ }), r;
2004
+ }
2005
+ function ci(t, e) {
2006
+ if (!t.length) return -1;
2007
+ const n = t.findIndex((r) => r.to > e);
2008
+ return n < 0 ? 0 : n;
2009
+ }
2010
+ function di() {
2011
+ return new it({
2012
+ key: G,
2013
+ state: {
2014
+ init: () => ({ query: "", caseSensitive: !1, matches: [], current: -1 }),
2015
+ apply(t, e, n, r) {
2016
+ const i = t.getMeta(G);
2017
+ if (!i && !t.docChanged) return e;
2018
+ const s = i?.query ?? e.query, o = i?.caseSensitive ?? e.caseSensitive, c = li(r.doc, s, o);
2019
+ let a = i?.current ?? (i?.query !== void 0 || i?.caseSensitive !== void 0 ? ci(c, r.selection.from) : e.current);
2020
+ return a >= c.length && (a = c.length ? 0 : -1), a < 0 && c.length && (a = 0), { query: s, caseSensitive: o, matches: c, current: a };
2021
+ }
2022
+ },
2023
+ props: {
2024
+ decorations(t) {
2025
+ const e = G.getState(t);
2026
+ return e?.matches.length ? st.create(
2027
+ t.doc,
2028
+ e.matches.map((n, r) => ot.inline(n.from, n.to, { class: r === e.current ? "wds-find-match wds-find-current" : "wds-find-match" }))
2029
+ ) : null;
2030
+ }
2031
+ }
2032
+ });
2033
+ }
2034
+ const oe = (t) => G.getState(t);
2035
+ function qe(t, e) {
2036
+ const n = oe(t.state);
2037
+ if (!n.matches.length) return;
2038
+ const r = (n.current + e + n.matches.length) % n.matches.length, i = n.matches[r];
2039
+ t.dispatch(t.state.tr.setMeta(G, { current: r }).setSelection(be.create(t.state.doc, i.from, i.to)).scrollIntoView());
2040
+ }
2041
+ function hn(t, e, n) {
2042
+ n ? t.insertText(n, e.from, e.to) : t.delete(e.from, e.to);
2043
+ }
2044
+ function Bt(t, e) {
2045
+ const n = oe(t.state), r = n.matches[n.current];
2046
+ if (!r) return;
2047
+ const i = t.state.tr;
2048
+ hn(i, r, e), i.setMeta(G, { current: n.current }), t.dispatch(i.scrollIntoView());
2049
+ const s = oe(t.state).matches[oe(t.state).current];
2050
+ s && t.dispatch(t.state.tr.setSelection(be.create(t.state.doc, s.from, s.to)).scrollIntoView());
2051
+ }
2052
+ function ui(t, e) {
2053
+ const { matches: n } = oe(t.state);
2054
+ if (!n.length) return 0;
2055
+ const r = t.state.tr;
2056
+ for (let i = n.length - 1; i >= 0; i--) hn(r, n[i], e);
2057
+ return t.dispatch(r.scrollIntoView()), n.length;
2058
+ }
2059
+ function Ge(t, e) {
2060
+ const n = document.createElement("button");
2061
+ return n.type = "button", n.className = "wds-icon-button", n.innerHTML = t, n.setAttribute("aria-label", e), n.title = e, n;
2062
+ }
2063
+ class hi {
2064
+ constructor(e, n, r) {
2065
+ this.view = e, this.t = n, this.onClose = r;
2066
+ const i = this.element = document.createElement("div");
2067
+ i.className = "wds-find", i.setAttribute("role", "search"), i.hidden = !0;
2068
+ const s = (x, T) => {
2069
+ const A = document.createElement("input");
2070
+ return A.type = "text", A.className = "wds-input wds-find-input", A.placeholder = T, A.setAttribute("aria-label", x), A.spellcheck = !1, A;
2071
+ };
2072
+ this.findInput = s(n.find, n.find), this.replaceInput = s(n.replaceWith, n.replaceWith), this.count = document.createElement("span"), this.count.className = "wds-find-count", this.count.setAttribute("aria-live", "polite");
2073
+ const o = Ge(L.arrowUp, n.findPrevious), c = Ge(L.arrowDown, n.findNext), a = document.createElement("button");
2074
+ a.type = "button", a.className = "wds-button", a.textContent = n.replace;
2075
+ const l = document.createElement("button");
2076
+ l.type = "button", l.className = "wds-button", l.textContent = n.replaceAll, this.buttons = [o, c, a, l];
2077
+ const d = document.createElement("label");
2078
+ d.className = "wds-find-case", this.caseInput = document.createElement("input"), this.caseInput.type = "checkbox", d.append(this.caseInput, ` ${n.matchCase}`);
2079
+ const u = Ge(L.close, n.close), m = document.createElement("div");
2080
+ m.className = "wds-find-row", m.append(this.findInput, this.count, o, c);
2081
+ const p = document.createElement("div");
2082
+ p.className = "wds-find-row", p.append(this.replaceInput, a, l), i.append(m, p, d, u);
2083
+ const b = () => e.dispatch(e.state.tr.setMeta(G, { query: this.findInput.value, caseSensitive: this.caseInput.checked }));
2084
+ this.findInput.addEventListener("input", b), this.caseInput.addEventListener("change", b), o.addEventListener("click", () => qe(e, -1)), c.addEventListener("click", () => qe(e, 1)), a.addEventListener("click", () => Bt(e, this.replaceInput.value)), l.addEventListener("click", () => {
2085
+ const x = ui(e, this.replaceInput.value);
2086
+ x && (this.count.textContent = z(n.replacedCount, { count: x }));
2087
+ }), u.addEventListener("click", () => this.close()), i.addEventListener("keydown", (x) => {
2088
+ x.key === "Escape" ? (x.preventDefault(), x.stopPropagation(), this.close()) : x.key === "Enter" && x.target === this.findInput ? (x.preventDefault(), qe(e, x.shiftKey ? -1 : 1)) : x.key === "Enter" && x.target === this.replaceInput && (x.preventDefault(), Bt(e, this.replaceInput.value));
2089
+ });
2090
+ }
2091
+ get isOpen() {
2092
+ return !this.element.hidden;
2093
+ }
2094
+ open() {
2095
+ const { from: e, to: n, empty: r } = this.view.state.selection, i = r ? "" : this.view.state.doc.textBetween(e, n, " ");
2096
+ i && i.length < 100 && !i.includes(`
2097
+ `) && (this.findInput.value = i), this.element.hidden = !1, this.findInput.focus(), this.findInput.select(), this.view.dispatch(this.view.state.tr.setMeta(G, { query: this.findInput.value, caseSensitive: this.caseInput.checked }));
2098
+ }
2099
+ close() {
2100
+ this.element.hidden || (this.element.hidden = !0, this.view.dispatch(this.view.state.tr.setMeta(G, { query: "" })), this.onClose());
2101
+ }
2102
+ /** Updates the "3 of 10" counter and the button states after every transaction. */
2103
+ update(e, n) {
2104
+ if (this.element.hidden) return;
2105
+ const r = oe(e), i = r.matches.length;
2106
+ this.count.textContent = r.query ? i ? z(this.t.matchCount, { current: r.current + 1, total: i }) : this.t.noMatches : "";
2107
+ const s = this.buttons.find((o) => o === document.activeElement);
2108
+ this.buttons.forEach((o, c) => o.disabled = !i || c > 1 && !n), s?.disabled && this.findInput.focus(), this.replaceInput.disabled = !n;
2109
+ }
2110
+ }
2111
+ const fi = "wds-editor:draft:";
2112
+ function me() {
2113
+ try {
2114
+ return window.localStorage;
2115
+ } catch {
2116
+ return null;
2117
+ }
2118
+ }
2119
+ class mi {
2120
+ constructor(e, n, r, i, s, o) {
2121
+ this.host = r, this.before = i, this.t = s, this.restore = o, this.timer = 0, this.pending = null, this.bar = null, this.onPageHide = () => this.flush(), this.key = fi + (e.key ?? n), this.delay = e.delay ?? 1e3, this.expires = e.expires ?? 7, window.addEventListener("pagehide", this.onPageHide);
2122
+ }
2123
+ /** Shows the restore bar when a saved draft differs from the content the editor started with. */
2124
+ check(e) {
2125
+ const n = this.read();
2126
+ if (!n || n.html === e) return;
2127
+ const r = this.bar = document.createElement("div");
2128
+ r.className = "wds-draft", r.setAttribute("role", "status");
2129
+ const i = document.createElement("span"), s = new Date(n.time).toLocaleString(this.host.lang || void 0, { dateStyle: "short", timeStyle: "short" });
2130
+ i.textContent = z(this.t.draftFound, { time: s });
2131
+ const o = document.createElement("button");
2132
+ o.type = "button", o.className = "wds-button wds-button-primary", o.textContent = this.t.draftRestore;
2133
+ const c = document.createElement("button");
2134
+ c.type = "button", c.className = "wds-button", c.textContent = this.t.draftDiscard, o.addEventListener("click", () => {
2135
+ this.hideBar(), this.restore(n.html);
2136
+ }), c.addEventListener("click", () => {
2137
+ this.hideBar(), this.clear();
2138
+ }), r.append(i, o, c), this.host.insertBefore(r, this.before);
2139
+ }
2140
+ /** Called on every content change. While the restore bar is open the old draft is kept. */
2141
+ schedule(e) {
2142
+ this.bar || (this.pending = e, window.clearTimeout(this.timer), this.timer = window.setTimeout(() => this.flush(), this.delay));
2143
+ }
2144
+ flush() {
2145
+ if (window.clearTimeout(this.timer), this.pending === null) return;
2146
+ const e = this.pending;
2147
+ this.pending = null;
2148
+ try {
2149
+ e ? me()?.setItem(this.key, JSON.stringify({ html: e, time: Date.now() })) : me()?.removeItem(this.key);
2150
+ } catch {
2151
+ }
2152
+ }
2153
+ /** Removes the draft (after the content was saved on the server). */
2154
+ clear() {
2155
+ window.clearTimeout(this.timer), this.pending = null;
2156
+ try {
2157
+ me()?.removeItem(this.key);
2158
+ } catch {
2159
+ }
2160
+ }
2161
+ destroy() {
2162
+ this.flush(), this.hideBar(), window.removeEventListener("pagehide", this.onPageHide);
2163
+ }
2164
+ hideBar() {
2165
+ this.bar?.remove(), this.bar = null;
2166
+ }
2167
+ read() {
2168
+ try {
2169
+ const e = me()?.getItem(this.key);
2170
+ if (!e) return null;
2171
+ const n = JSON.parse(e);
2172
+ return typeof n?.html != "string" || typeof n.time != "number" ? null : Date.now() - n.time > this.expires * 864e5 ? (me()?.removeItem(this.key), null) : n;
2173
+ } catch {
2174
+ return null;
2175
+ }
2176
+ }
2177
+ }
2178
+ const re = /* @__PURE__ */ new WeakMap(), zt = (t) => t === void 0 ? void 0 : typeof t == "number" ? `${t}px` : t;
2179
+ function pi(t) {
2180
+ return t === !1 ? [] : t === void 0 || t === "default" ? Pr : Array.isArray(t) ? t : t.split(/\s+/).filter(Boolean);
1752
2181
  }
1753
- const ne = class ne {
2182
+ const ie = class ie {
1754
2183
  constructor(e, n = {}) {
1755
- if (this.listeners = /* @__PURE__ */ new Map(), this.notice = null, this.noticeTimer = 0, this.onFormSubmit = () => this.syncTarget(), this.onKeydown = (i) => {
1756
- i.key === "Escape" && this.fullscreen && this.toggleFullscreen();
1757
- }, this.sourceMode = !1, this.plainPaste = !1, this.fullscreen = !1, this.destroyed = !1, te.has(e)) throw new Error("[WDS Editor] This element already has an editor. Use WDSEditor.get() or destroy() first.");
1758
- this.target = e, this.options = n, this.t = Er(n.language), this.readOnly = !!n.readOnly, this.textarea = e instanceof HTMLTextAreaElement ? e : null, this.originalContent = this.textarea ? this.textarea.value : e.innerHTML;
2184
+ if (this.listeners = /* @__PURE__ */ new Map(), this.notice = null, this.noticeTimer = 0, this.onFormSubmit = () => {
2185
+ this.syncTarget(), this.autosave?.clear();
2186
+ }, this.onKeydown = (d) => {
2187
+ d.key === "Escape" && this.fullscreen && this.toggleFullscreen();
2188
+ }, this.sourceMode = !1, this.plainPaste = !1, this.fullscreen = !1, this.destroyed = !1, re.has(e)) throw new Error("[WDS Editor] This element already has an editor. Use WDSEditor.get() or destroy() first.");
2189
+ this.target = e, this.options = n, this.t = qr(n.language), this.readOnly = !!n.readOnly, this.textarea = e instanceof HTMLTextAreaElement ? e : null, this.originalContent = this.textarea ? this.textarea.value : e.innerHTML;
1759
2190
  const r = n.content ?? this.originalContent;
1760
2191
  if (this.root = document.createElement("div"), this.root.className = "wds-editor", this.root.dataset.theme = n.theme ?? "light", typeof n.language != "object") {
1761
- const i = jt(n.language);
1762
- this.root.lang = i;
1763
- const a = n.dir ?? "auto";
1764
- a === "rtl" || a === "auto" && Ar(i) ? this.root.dir = "rtl" : a === "ltr" && (this.root.dir = "ltr");
2192
+ const d = on(n.language);
2193
+ this.root.lang = d;
2194
+ const u = n.dir ?? "auto";
2195
+ u === "rtl" || u === "auto" && jr(d) ? this.root.dir = "rtl" : u === "ltr" && (this.root.dir = "ltr");
1765
2196
  } else n.dir && n.dir !== "auto" && (this.root.dir = n.dir);
1766
- this.fileManager = n.fileManager?.listUrl ? new Rr(this.root, new Hr(n.fileManager), this.t) : null, this.contentWrap = document.createElement("div"), this.contentWrap.className = "wds-content-wrap";
1767
- const o = At(n.height);
1768
- o ? (this.contentWrap.style.height = o, this.root.classList.add("wds-fixed-height")) : this.contentWrap.style.minHeight = At(n.minHeight ?? 240), this.sourceArea = document.createElement("textarea"), this.sourceArea.className = "wds-source", this.sourceArea.spellcheck = !1, this.sourceArea.dir = "ltr", this.sourceArea.hidden = !0, this.sourceArea.setAttribute("aria-label", this.t.sourceLabel);
1769
- const s = Zt.create({
1770
- schema: p,
1771
- doc: be(r),
2197
+ this.fileManager = n.fileManager?.listUrl ? new ti(this.root, new Zr(n.fileManager), this.t) : null, this.contentWrap = document.createElement("div"), this.contentWrap.className = "wds-content-wrap";
2198
+ const i = zt(n.height);
2199
+ i ? (this.contentWrap.style.height = i, this.root.classList.add("wds-fixed-height")) : this.contentWrap.style.minHeight = zt(n.minHeight ?? 240), this.sourceArea = document.createElement("textarea"), this.sourceArea.className = "wds-source", this.sourceArea.spellcheck = !1, this.sourceArea.dir = "ltr", this.sourceArea.hidden = !0, this.sourceArea.setAttribute("aria-label", this.t.sourceLabel);
2200
+ const s = pn.create({
2201
+ schema: f,
2202
+ doc: ke(r),
1772
2203
  plugins: [
1773
- hn(),
1774
- Je({ Tab: or, "Shift-Tab": ir }),
1775
- sr(),
1776
- lr({ link: () => (this.openLinkDialog(), !0) }),
1777
- cr(),
1778
- rn(),
1779
- dr(n.placeholder ?? ""),
1780
- ur(),
1781
- Nn(),
1782
- In({ class: "wds-dropcursor", color: !1 })
2204
+ An(),
2205
+ at({ Tab: Lr, "Shift-Tab": Sr, "Mod-f": () => (this.openFind(), !0) }),
2206
+ di(),
2207
+ Ar(),
2208
+ Tr({ link: () => (this.openLinkDialog(), !0) }),
2209
+ Cr(),
2210
+ yn(),
2211
+ Ir(n.placeholder ?? ""),
2212
+ Dr(),
2213
+ Gn(),
2214
+ jn({ class: "wds-dropcursor", color: !1 })
1783
2215
  ]
1784
- }), c = {
2216
+ }), o = ai({ css: n.contentCss, style: n.contentStyle });
2217
+ (o || n.contentClass !== void 0) && this.root.classList.add("wds-site-styles"), o && this.contentWrap.classList.add(o.className);
2218
+ const c = ["wds-content", n.contentClass?.trim()].filter(Boolean).join(" "), a = {
1785
2219
  onEdit: () => this.openImageUrlDialog(),
1786
2220
  resizeLabel: this.t.resizeImage,
1787
2221
  captionPlaceholder: this.t.captionPlaceholder
1788
2222
  };
1789
- this.view = new en(this.contentWrap, {
2223
+ this.view = new gn(this.contentWrap, {
1790
2224
  state: s,
1791
2225
  editable: () => !this.readOnly,
1792
2226
  attributes: {
1793
- class: "wds-content",
2227
+ class: c,
1794
2228
  role: "textbox",
1795
2229
  "aria-multiline": "true",
1796
2230
  "aria-label": this.t.editorLabel
1797
2231
  },
1798
- dispatchTransaction: (i) => this.dispatch(i),
1799
- transformPastedHTML: On,
1800
- handlePaste: (i, a) => {
1801
- const l = a.clipboardData;
1802
- if (this.plainPaste && l) {
1803
- const m = l.getData("text/plain");
1804
- if (m)
1805
- return i.dispatch(i.state.tr.replaceSelection(zr(m)).scrollIntoView()), !0;
2232
+ dispatchTransaction: (d) => this.dispatch(d),
2233
+ transformPastedHTML: Yn,
2234
+ handlePaste: (d, u) => {
2235
+ const m = u.clipboardData;
2236
+ if (this.plainPaste && m) {
2237
+ const b = m.getData("text/plain");
2238
+ if (b)
2239
+ return d.dispatch(d.state.tr.replaceSelection(gi(b)).scrollIntoView()), !0;
1806
2240
  }
1807
- if (!l?.files.length || !this.canUploadInline() || l.getData("text/plain")) return !1;
1808
- const u = [...l.files].filter((m) => m.type.startsWith("image/"));
1809
- return u.length ? (this.uploadFiles(u), !0) : !1;
2241
+ if (!m?.files.length || !this.canUploadInline() || m.getData("text/plain")) return !1;
2242
+ const p = [...m.files].filter((b) => b.type.startsWith("image/"));
2243
+ return p.length ? (this.uploadFiles(p), !0) : !1;
1810
2244
  },
1811
- handleDrop: (i, a, l, u) => {
1812
- const m = a.dataTransfer?.files;
1813
- if (u || !m?.length || !this.canUploadInline()) return !1;
1814
- const g = i.posAtCoords({ left: a.clientX, top: a.clientY })?.pos;
1815
- return a.preventDefault(), this.uploadFiles([...m], g), !0;
2245
+ handleDrop: (d, u, m, p) => {
2246
+ const b = u.dataTransfer?.files;
2247
+ if (p || !b?.length || !this.canUploadInline()) return !1;
2248
+ const x = d.posAtCoords({ left: u.clientX, top: u.clientY })?.pos;
2249
+ return u.preventDefault(), this.uploadFiles([...b], x), !0;
1816
2250
  },
1817
2251
  nodeViews: {
1818
- image: (i, a, l) => new Mr(i, a, l, c),
1819
- figure: (i, a, l) => new Lr(i, a, l, c)
2252
+ image: (d, u, m) => new Wr(d, u, m, a),
2253
+ figure: (d, u, m) => new _r(d, u, m, a),
2254
+ video: (d) => new er(d, () => this.openVideoDialog())
1820
2255
  },
1821
2256
  handleDOMEvents: {
1822
2257
  focus: () => (this.root.classList.add("is-focused"), this.emit("focus"), !1),
1823
2258
  blur: () => (this.root.classList.remove("is-focused"), this.emit("blur"), !1)
1824
2259
  }
1825
- }), this.contentWrap.append(this.sourceArea), this.toolbar = kr(this, $r(n.toolbar), this.t), this.toolbar.element.childElementCount && this.toolbar.element.firstElementChild.childElementCount && this.root.append(this.toolbar.element), this.root.append(this.contentWrap);
1826
- const d = document.createElement("div");
1827
- if (d.className = "wds-statusbar", this.counter = n.wordCount === !1 ? null : document.createElement("span"), this.counter && (this.counter.className = "wds-counter", this.counter.setAttribute("aria-live", "off"), d.append(this.counter)), n.branding !== !1) {
1828
- const i = document.createElement("a");
1829
- i.className = "wds-branding", i.href = "https://webdevsnippets.com/wds-editor", i.target = "_blank", i.rel = "noopener", i.innerHTML = `${Br(this.t.poweredBy)} <strong>WDS Editor</strong>`, d.append(i);
2260
+ }), this.contentWrap.append(this.sourceArea), this.toolbar = Ur(this, pi(n.toolbar), this.t), this.toolbar.element.childElementCount && this.toolbar.element.firstElementChild.childElementCount && this.root.append(this.toolbar.element), this.findPanel = new hi(this.view, this.t, () => this.view.focus()), this.root.append(this.findPanel.element, this.contentWrap), this.autosave = n.autosave ? new mi(
2261
+ n.autosave === !0 ? {} : n.autosave,
2262
+ `${location.pathname}#${e.id || e.getAttribute("name") || "editor"}`,
2263
+ this.root,
2264
+ this.contentWrap,
2265
+ this.t,
2266
+ (d) => this.setHTML(d)
2267
+ ) : null;
2268
+ const l = document.createElement("div");
2269
+ if (l.className = "wds-statusbar", this.counter = n.wordCount === !1 ? null : document.createElement("span"), this.counter && (this.counter.className = "wds-counter", this.counter.setAttribute("aria-live", "off"), l.append(this.counter)), n.branding !== !1) {
2270
+ const d = document.createElement("a");
2271
+ d.className = "wds-branding", d.href = "https://webdevsnippets.com/wds-editor", d.target = "_blank", d.rel = "noopener", d.innerHTML = `${bi(this.t.poweredBy)} <strong>WDS Editor</strong>`, l.append(d);
1830
2272
  }
1831
- d.childElementCount && this.root.append(d), this.textarea ? (this.textarea.style.display = "none", this.textarea.after(this.root), this.textarea.form?.addEventListener("submit", this.onFormSubmit)) : e.replaceChildren(this.root), document.addEventListener("keydown", this.onKeydown), te.set(e, this), this.lastHtml = this.getHTML(), this.syncTarget(), this.refresh(), this.emit("init");
2273
+ l.childElementCount && this.root.append(l), this.textarea ? (this.textarea.style.display = "none", this.textarea.after(this.root), this.textarea.form?.addEventListener("submit", this.onFormSubmit)) : e.replaceChildren(this.root), document.addEventListener("keydown", this.onKeydown), re.set(e, this), this.lastHtml = this.getHTML(), this.autosave?.check(this.lastHtml), this.syncTarget(), this.refresh(), this.emit("init");
1832
2274
  }
1833
2275
  /** Creates (or returns the existing) editor for the first element matching options.selector. */
1834
2276
  static init(e) {
1835
2277
  const n = typeof e.selector == "string" ? document.querySelector(e.selector) : e.selector;
1836
2278
  if (!n) throw new Error(`[WDS Editor] No element matches "${String(e.selector)}".`);
1837
- return te.get(n) ?? new ne(n, e);
2279
+ return re.get(n) ?? new ie(n, e);
1838
2280
  }
1839
2281
  /** Creates editors for every element matching options.selector. */
1840
2282
  static initAll(e) {
1841
- return [...document.querySelectorAll(e.selector)].map((n) => te.get(n) ?? new ne(n, e));
2283
+ return [...document.querySelectorAll(e.selector)].map((n) => re.get(n) ?? new ie(n, e));
1842
2284
  }
1843
2285
  /** Returns the editor attached to an element (or selector), if any. */
1844
2286
  static get(e) {
1845
2287
  const n = typeof e == "string" ? document.querySelector(e) : e;
1846
- return n ? te.get(n) : void 0;
2288
+ return n ? re.get(n) : void 0;
1847
2289
  }
1848
2290
  // ---------- content ----------
1849
2291
  getHTML() {
1850
- return this.sourceMode && this.applySource(), we(this.view.state.doc);
2292
+ return this.sourceMode && this.applySource(), Me(this.view.state.doc);
1851
2293
  }
1852
2294
  /** Replaces the whole content. The change can be undone. */
1853
2295
  setHTML(e) {
1854
- this.sourceMode && (this.sourceArea.value = gt(e));
1855
- const n = be(e), r = this.view.state.tr.replaceWith(0, this.view.state.doc.content.size, n.content);
1856
- this.dispatch(r.setSelection(Ye.atStart(r.doc)));
2296
+ this.sourceMode && (this.sourceArea.value = At(e));
2297
+ const n = ke(e), r = this.view.state.tr.replaceWith(0, this.view.state.doc.content.size, n.content);
2298
+ this.dispatch(r.setSelection(be.atStart(r.doc)));
1857
2299
  }
1858
2300
  /** Inserts HTML at the cursor (replacing the selection). */
1859
2301
  insertHTML(e) {
1860
- const n = be(e), r = Rt.maxOpen(n.content);
2302
+ const n = ke(e), r = qt.maxOpen(n.content);
1861
2303
  this.dispatch(this.view.state.tr.replaceSelection(r).scrollIntoView());
1862
2304
  }
1863
2305
  getText() {
@@ -1868,7 +2310,7 @@ const ne = class ne {
1868
2310
  `);
1869
2311
  }
1870
2312
  isEmpty() {
1871
- return Ut(this.view.state.doc);
2313
+ return Qt(this.view.state.doc);
1872
2314
  }
1873
2315
  // ---------- state ----------
1874
2316
  focus() {
@@ -1887,17 +2329,31 @@ const ne = class ne {
1887
2329
  return this.view.focus(), n;
1888
2330
  }
1889
2331
  undo() {
1890
- this.exec(It);
2332
+ this.exec(Wt);
1891
2333
  }
1892
2334
  redo() {
1893
- this.exec(Be);
2335
+ this.exec(je);
1894
2336
  }
1895
2337
  // ---------- views ----------
1896
2338
  isSourceMode() {
1897
2339
  return this.sourceMode;
1898
2340
  }
1899
2341
  toggleSource() {
1900
- this.sourceMode ? (this.applySource(), this.sourceMode = !1, this.sourceArea.hidden = !0, this.view.dom.hidden = !1, this.root.classList.remove("is-source"), this.view.focus()) : (this.sourceArea.value = gt(we(this.view.state.doc)), this.sourceMode = !0, this.view.dom.hidden = !0, this.sourceArea.hidden = !1, this.root.classList.add("is-source"), this.sourceArea.focus()), this.refresh();
2342
+ this.sourceMode ? (this.applySource(), this.sourceMode = !1, this.sourceArea.hidden = !0, this.view.dom.hidden = !1, this.root.classList.remove("is-source"), this.view.focus()) : (this.findPanel.close(), this.sourceArea.value = At(Me(this.view.state.doc)), this.sourceMode = !0, this.view.dom.hidden = !0, this.sourceArea.hidden = !1, this.root.classList.add("is-source"), this.sourceArea.focus()), this.refresh();
2343
+ }
2344
+ /** Removes the autosave draft, e.g. after saving with fetch instead of a form submit. */
2345
+ clearDraft() {
2346
+ this.autosave?.clear();
2347
+ }
2348
+ /** Opens the find and replace bar (Ctrl+F / Cmd+F inside the editor). */
2349
+ openFind() {
2350
+ this.sourceMode || (this.findPanel.open(), this.refresh());
2351
+ }
2352
+ closeFind() {
2353
+ this.findPanel.close();
2354
+ }
2355
+ isFindOpen() {
2356
+ return this.findPanel.isOpen;
1901
2357
  }
1902
2358
  isFullscreen() {
1903
2359
  return this.fullscreen;
@@ -1908,38 +2364,75 @@ const ne = class ne {
1908
2364
  // ---------- link dialog ----------
1909
2365
  openLinkDialog() {
1910
2366
  if (this.readOnly || this.sourceMode) return;
1911
- const e = this.view.state, n = Ge(e), { from: r, to: o, empty: s } = e.selection, c = s ? "" : e.doc.textBetween(r, o, " "), d = s && !n, i = this.t;
1912
- Lt(this.root, {
1913
- title: i.link,
1914
- closeLabel: i.close,
1915
- submitLabel: i.save,
1916
- cancelLabel: i.cancel,
2367
+ const e = this.view.state, n = et(e), { from: r, to: i, empty: s } = e.selection, o = s ? "" : e.doc.textBetween(r, i, " "), c = s && !n, a = this.t;
2368
+ ze(this.root, {
2369
+ title: a.link,
2370
+ closeLabel: a.close,
2371
+ submitLabel: a.save,
2372
+ cancelLabel: a.cancel,
1917
2373
  fields: [
1918
- { name: "href", label: i.linkUrl, type: "url", value: n?.href ?? "", placeholder: "https://" },
1919
- ...d ? [{ name: "text", label: i.linkText, type: "text", value: c }] : [],
1920
- { name: "title", label: i.linkTitle, type: "text", value: n?.title ?? "" },
1921
- { name: "newTab", label: i.linkNewTab, type: "checkbox", value: n?.target === "_blank" }
2374
+ { name: "href", label: a.linkUrl, type: "url", value: n?.href ?? "", placeholder: "https://" },
2375
+ ...c ? [{ name: "text", label: a.linkText, type: "text", value: o }] : [],
2376
+ { name: "title", label: a.linkTitle, type: "text", value: n?.title ?? "" },
2377
+ { name: "newTab", label: a.linkNewTab, type: "checkbox", value: n?.target === "_blank" }
1922
2378
  ],
1923
- extraAction: n ? { label: i.remove, onClick: () => this.removeLink() } : void 0,
1924
- validate: (a) => at(String(a.href)) ? null : i.linkInvalid,
1925
- onSubmit: (a) => {
1926
- const l = at(String(a.href)), u = { href: l, title: String(a.title).trim() || null, target: a.newTab ? "_blank" : null }, m = p.marks.link.create(u), g = this.view.state;
1927
- let k = g.tr;
2379
+ extraAction: n ? { label: a.remove, onClick: () => this.removeLink() } : void 0,
2380
+ validate: (l) => bt(String(l.href)) ? null : a.linkInvalid,
2381
+ onSubmit: (l) => {
2382
+ const d = bt(String(l.href)), u = { href: d, title: String(l.title).trim() || null, target: l.newTab ? "_blank" : null }, m = f.marks.link.create(u), p = this.view.state;
2383
+ let b = p.tr;
1928
2384
  if (n)
1929
- k = k.removeMark(n.from, n.to, p.marks.link).addMark(n.from, n.to, m);
1930
- else if (d) {
1931
- const D = String(a.text ?? "").trim() || l.replace(/^mailto:/, "");
1932
- k = k.replaceSelectionWith(p.text(D, [m]), !1);
2385
+ b = b.removeMark(n.from, n.to, f.marks.link).addMark(n.from, n.to, m);
2386
+ else if (c) {
2387
+ const x = String(l.text ?? "").trim() || d.replace(/^mailto:/, "");
2388
+ b = b.replaceSelectionWith(f.text(x, [m]), !1);
1933
2389
  } else
1934
- k = k.addMark(g.selection.from, g.selection.to, m);
1935
- this.dispatch(k.scrollIntoView());
2390
+ b = b.addMark(p.selection.from, p.selection.to, m);
2391
+ this.dispatch(b.scrollIntoView());
1936
2392
  },
1937
2393
  onClose: () => this.view.focus()
1938
2394
  });
1939
2395
  }
1940
2396
  removeLink() {
1941
- const e = Ge(this.view.state);
1942
- e && this.dispatch(this.view.state.tr.removeMark(e.from, e.to, p.marks.link));
2397
+ const e = et(this.view.state);
2398
+ e && this.dispatch(this.view.state.tr.removeMark(e.from, e.to, f.marks.link));
2399
+ }
2400
+ // ---------- video ----------
2401
+ /**
2402
+ * Inserts a YouTube or Vimeo video (watch page, short link or embed URL) at the cursor.
2403
+ * Returns false for other addresses.
2404
+ */
2405
+ insertVideo(e, n = {}) {
2406
+ const r = Le(e);
2407
+ if (!r || this.readOnly || this.sourceMode) return !1;
2408
+ const i = f.nodes.video.create({ src: r, title: n.title?.trim() ?? "", width: n.width ?? null }), s = this.view.state.tr.replaceSelectionWith(i);
2409
+ return this.dispatch(s.scrollIntoView()), !0;
2410
+ }
2411
+ /** Video button: edits the selected video or asks for a YouTube / Vimeo address. */
2412
+ openVideoDialog() {
2413
+ if (this.readOnly || this.sourceMode) return;
2414
+ const e = this.t, n = en(this.view.state), r = n?.node.attrs ?? {};
2415
+ ze(this.root, {
2416
+ title: n ? e.videoEdit : e.video,
2417
+ closeLabel: e.close,
2418
+ submitLabel: n ? e.save : e.insert,
2419
+ cancelLabel: e.cancel,
2420
+ fields: [
2421
+ { name: "url", label: e.videoUrl, type: "url", value: r.src ?? "", placeholder: "https://www.youtube.com/watch?v=…", hint: e.videoHint },
2422
+ { name: "title", label: e.videoTitle, type: "text", value: r.title ?? "" },
2423
+ { name: "width", label: e.imageWidth, type: "number", value: r.width ? String(r.width) : "", placeholder: "560" }
2424
+ ],
2425
+ validate: (i) => Le(String(i.url)) ? null : e.videoInvalid,
2426
+ onSubmit: (i) => {
2427
+ const s = parseInt(String(i.width), 10), o = { src: Le(String(i.url)), title: String(i.title).trim(), width: s > 0 ? Math.min(s, 4e3) : null };
2428
+ if (n) {
2429
+ const c = this.view.state.tr.setNodeMarkup(n.pos, void 0, o);
2430
+ this.dispatch(c.setSelection(Z.create(c.doc, n.pos)).scrollIntoView());
2431
+ } else
2432
+ this.insertVideo(o.src, o);
2433
+ },
2434
+ onClose: () => this.view.focus()
2435
+ });
1943
2436
  }
1944
2437
  // ---------- images and files ----------
1945
2438
  /** True when a file manager (listUrl) is configured. */
@@ -1950,15 +2443,15 @@ const ne = class ne {
1950
2443
  insertImage(e) {
1951
2444
  const n = q(e.src);
1952
2445
  if (!n || this.readOnly || this.sourceMode) return !1;
1953
- const r = p.nodes.image.create({
2446
+ const r = f.nodes.image.create({
1954
2447
  src: n,
1955
2448
  alt: e.alt ?? "",
1956
2449
  title: e.title ?? null,
1957
2450
  width: e.width ?? null,
1958
2451
  height: e.width ? e.height ?? null : null,
1959
2452
  align: e.align ?? null
1960
- }), o = this.view.state.tr.replaceSelectionWith(r);
1961
- return e.caption && vt(o, o.selection.from - 1, r.attrs), this.dispatch(o.scrollIntoView()), !0;
2453
+ }), i = this.view.state.tr.replaceSelectionWith(r);
2454
+ return e.caption && Dt(i, i.selection.from - 1, r.attrs), this.dispatch(i.scrollIntoView()), !0;
1962
2455
  }
1963
2456
  /**
1964
2457
  * Image button: edits the selected image, otherwise opens the file manager (when configured)
@@ -1966,7 +2459,7 @@ const ne = class ne {
1966
2459
  */
1967
2460
  openImageDialog() {
1968
2461
  if (this.readOnly || this.sourceMode) return;
1969
- je(this.view.state) || !this.fileManager ? this.openImageUrlDialog() : this.openFileManager("image");
2462
+ tt(this.view.state) || !this.fileManager ? this.openImageUrlDialog() : this.openFileManager("image");
1970
2463
  }
1971
2464
  /** Opens the file manager. "image" lists images (accept option, default image/*), "file" lists every file. */
1972
2465
  openFileManager(e = "image") {
@@ -1975,16 +2468,16 @@ const ne = class ne {
1975
2468
  accept: e === "image" ? this.options.fileManager?.accept ?? "image/*" : "",
1976
2469
  onFromUrl: e === "image" ? () => this.openImageUrlDialog() : void 0,
1977
2470
  onUpload: (n) => this.emit("upload", n),
1978
- onPick: ({ file: n, alt: r, width: o, align: s, text: c, caption: d }) => {
1979
- e === "image" && ue(n) ? this.insertImage({ src: n.url, alt: r, width: o, align: s, caption: d }) : this.insertFileLink(n, c), this.emit("fileSelect", n);
2471
+ onPick: ({ file: n, alt: r, width: i, align: s, text: o, caption: c }) => {
2472
+ e === "image" && pe(n) ? this.insertImage({ src: n.url, alt: r, width: i, align: s, caption: c }) : this.insertFileLink(n, o), this.emit("fileSelect", n);
1980
2473
  },
1981
2474
  onClose: () => this.view.focus()
1982
2475
  });
1983
2476
  }
1984
2477
  /** Dialog for an image by URL, or for editing the selected image (alt text, width, alignment). */
1985
2478
  openImageUrlDialog() {
1986
- const e = this.t, n = je(this.view.state), r = n?.attrs ?? {};
1987
- Lt(this.root, {
2479
+ const e = this.t, n = tt(this.view.state), r = n?.attrs ?? {};
2480
+ ze(this.root, {
1988
2481
  title: n ? e.imageEdit : e.image,
1989
2482
  closeLabel: e.close,
1990
2483
  submitLabel: n ? e.save : e.insert,
@@ -2007,19 +2500,19 @@ const ne = class ne {
2007
2500
  },
2008
2501
  { name: "caption", label: e.caption, type: "checkbox", value: !!n?.figure }
2009
2502
  ],
2010
- validate: (o) => q(String(o.src)) && !/^(mailto|tel):/i.test(String(o.src).trim()) ? null : e.imageInvalid,
2011
- onSubmit: (o) => {
2012
- const s = parseInt(String(o.width), 10), c = {
2013
- src: q(String(o.src)),
2014
- alt: String(o.alt).trim(),
2503
+ validate: (i) => q(String(i.src)) && !/^(mailto|tel):/i.test(String(i.src).trim()) ? null : e.imageInvalid,
2504
+ onSubmit: (i) => {
2505
+ const s = parseInt(String(i.width), 10), o = {
2506
+ src: q(String(i.src)),
2507
+ alt: String(i.alt).trim(),
2015
2508
  width: s > 0 ? s : null,
2016
- align: String(o.align) || null
2017
- }, d = !!o.caption;
2509
+ align: String(i.align) || null
2510
+ }, c = !!i.caption;
2018
2511
  if (n) {
2019
- const i = c.width && c.width === r.width ? r.height ?? null : null, a = { ...r, ...c, height: i }, l = this.view.state.tr;
2020
- d && !n.figure ? vt(l, n.pos, a) : !d && n.figure ? tr(l, n.pos, n.node, a) : l.setNodeMarkup(n.pos, void 0, a).setSelection(he.create(l.doc, n.pos)), this.dispatch(l.scrollIntoView());
2512
+ const a = o.width && o.width === r.width ? r.height ?? null : null, l = { ...r, ...o, height: a }, d = this.view.state.tr;
2513
+ c && !n.figure ? Dt(d, n.pos, l) : !c && n.figure ? kr(d, n.pos, n.node, l) : d.setNodeMarkup(n.pos, void 0, l).setSelection(Z.create(d.doc, n.pos)), this.dispatch(d.scrollIntoView());
2021
2514
  } else
2022
- this.insertImage({ ...c, caption: d });
2515
+ this.insertImage({ ...o, caption: c });
2023
2516
  },
2024
2517
  onClose: () => this.view.focus()
2025
2518
  });
@@ -2029,46 +2522,46 @@ const ne = class ne {
2029
2522
  openTableMenu(e) {
2030
2523
  if (this.readOnly || this.sourceMode) return;
2031
2524
  const n = this.t, r = this.view.state;
2032
- if (!me(r)) {
2033
- mr(
2525
+ if (!we(r)) {
2526
+ $r(
2034
2527
  e,
2035
2528
  this.root,
2036
2529
  n.tableInsert,
2037
- (c, d) => j(n.tableSize, { rows: String(c), cols: String(d) }),
2038
- (c, d) => this.exec(rr(c, d))
2530
+ (o, c) => z(n.tableSize, { rows: String(o), cols: String(c) }),
2531
+ (o, c) => this.exec(xr(o, c))
2039
2532
  );
2040
2533
  return;
2041
2534
  }
2042
- const o = (c, d, i = !1) => ({ label: c, danger: i, enabled: d(r), run: () => this.exec(d) }), s = [
2043
- o(n.rowAbove, pn),
2044
- o(n.rowBelow, zt),
2045
- o(n.colLeft, mn),
2046
- o(n.colRight, fn),
2535
+ const i = (o, c, a = !1) => ({ label: o, danger: a, enabled: c(r), run: () => this.exec(c) }), s = [
2536
+ i(n.rowAbove, Tn),
2537
+ i(n.rowBelow, jt),
2538
+ i(n.colLeft, Cn),
2539
+ i(n.colRight, In),
2047
2540
  "|",
2048
- o(n.deleteRow, gn),
2049
- o(n.deleteCol, bn),
2541
+ i(n.deleteRow, Dn),
2542
+ i(n.deleteCol, Nn),
2050
2543
  "|",
2051
- o(n.headerRow, wn),
2052
- o(n.headerCol, yn),
2053
- o(n.mergeCells, vn),
2054
- o(n.splitCell, kn),
2544
+ i(n.headerRow, Rn),
2545
+ i(n.headerCol, $n),
2546
+ i(n.mergeCells, On),
2547
+ i(n.splitCell, Hn),
2055
2548
  "|",
2056
- o(n.deleteTable, Mn, !0)
2549
+ i(n.deleteTable, Pn, !0)
2057
2550
  ];
2058
- pr(e, this.root, s, n.table);
2551
+ Rr(e, this.root, s, n.table);
2059
2552
  }
2060
2553
  // ---------- colors ----------
2061
2554
  /** Opens the text color or highlight palette under the given toolbar button. */
2062
2555
  openColorPicker(e, n) {
2063
2556
  if (this.readOnly || this.sourceMode) return;
2064
- const r = this.t, s = ((e === "textColor" ? this.options.colors?.text : this.options.colors?.highlight) ?? (e === "textColor" ? Rn : $n)).map((c) => typeof c == "string" ? { color: c, name: c } : c).map((c) => ({ color: re(c.color), label: r[c.name] ?? c.name })).filter((c) => !!c.color);
2065
- fr(n, this.root, {
2557
+ const r = this.t, s = ((e === "textColor" ? this.options.colors?.text : this.options.colors?.highlight) ?? (e === "textColor" ? tr : nr)).map((o) => typeof o == "string" ? { color: o, name: o } : o).map((o) => ({ color: se(o.color), label: r[o.name] ?? o.name })).filter((o) => !!o.color);
2558
+ Or(n, this.root, {
2066
2559
  label: e === "textColor" ? r.textColor : r.highlight,
2067
2560
  removeLabel: e === "textColor" ? r.removeColor : r.removeHighlight,
2068
2561
  swatches: s,
2069
2562
  columns: e === "textColor" ? 5 : 6,
2070
- current: Ve(this.view.state, e),
2071
- onPick: (c) => this.exec(ar(e, c))
2563
+ current: nt(this.view.state, e),
2564
+ onPick: (o) => this.exec(Er(e, o))
2072
2565
  });
2073
2566
  }
2074
2567
  // ---------- paste ----------
@@ -2083,8 +2576,8 @@ const ne = class ne {
2083
2576
  insertFileLink(e, n) {
2084
2577
  const r = q(e.url);
2085
2578
  if (!r || this.readOnly || this.sourceMode) return;
2086
- const o = p.marks.link.create({ href: r }), s = this.view.state, c = s.selection.empty ? s.tr.replaceSelectionWith(p.text(n || e.name, [o]), !1) : s.tr.addMark(s.selection.from, s.selection.to, o);
2087
- this.dispatch(c.scrollIntoView());
2579
+ const i = f.marks.link.create({ href: r }), s = this.view.state, o = s.selection.empty ? s.tr.replaceSelectionWith(f.text(n || e.name, [i]), !1) : s.tr.addMark(s.selection.from, s.selection.to, i);
2580
+ this.dispatch(o.scrollIntoView());
2088
2581
  }
2089
2582
  canUploadInline() {
2090
2583
  return !!this.fileManager?.api.canUpload && !this.readOnly && !this.sourceMode;
@@ -2096,19 +2589,19 @@ const ne = class ne {
2096
2589
  uploadFiles(e, n) {
2097
2590
  if (!this.canUploadInline()) return;
2098
2591
  const r = this.fileManager.api;
2099
- for (const o of e) {
2592
+ for (const i of e) {
2100
2593
  const s = {};
2101
- let c = this.view.state.tr;
2102
- n === void 0 && !c.selection.empty && (c = c.deleteSelection());
2103
- const d = n ?? c.selection.from;
2104
- this.dispatch(c.setMeta(X, { add: { id: s, pos: d } })), r.upload(o, this.fileManager.path).then((i) => {
2594
+ let o = this.view.state.tr;
2595
+ n === void 0 && !o.selection.empty && (o = o.deleteSelection());
2596
+ const c = n ?? o.selection.from;
2597
+ this.dispatch(o.setMeta(Q, { add: { id: s, pos: c } })), r.upload(i, this.fileManager.path).then((a) => {
2105
2598
  if (this.destroyed) return;
2106
- const a = hr(this.view.state, s);
2107
- if (a === null) return;
2108
- const l = ue(i) ? p.nodes.image.create({ src: i.url, alt: "" }) : p.text(i.name, [p.marks.link.create({ href: i.url })]);
2109
- this.dispatch(this.view.state.tr.replaceWith(a, a, l).setMeta(X, { remove: { id: s } })), this.emit("upload", i);
2110
- }).catch((i) => {
2111
- this.destroyed || (this.dispatch(this.view.state.tr.setMeta(X, { remove: { id: s } })), this.showNotice(j(this.t.fmUploadFailed, { name: o.name, error: i.message })));
2599
+ const l = Nr(this.view.state, s);
2600
+ if (l === null) return;
2601
+ const d = pe(a) ? f.nodes.image.create({ src: a.url, alt: "" }) : f.text(a.name, [f.marks.link.create({ href: a.url })]);
2602
+ this.dispatch(this.view.state.tr.replaceWith(l, l, d).setMeta(Q, { remove: { id: s } })), this.emit("upload", a);
2603
+ }).catch((a) => {
2604
+ this.destroyed || (this.dispatch(this.view.state.tr.setMeta(Q, { remove: { id: s } })), this.showNotice(z(this.t.fmUploadFailed, { name: i.name, error: a.message })));
2112
2605
  });
2113
2606
  }
2114
2607
  }
@@ -2128,69 +2621,69 @@ const ne = class ne {
2128
2621
  if (this.destroyed) return;
2129
2622
  this.emit("destroy");
2130
2623
  const e = this.getHTML();
2131
- this.destroyed = !0, window.clearTimeout(this.noticeTimer), _t(), this.view.destroy(), document.removeEventListener("keydown", this.onKeydown), this.fullscreen && document.documentElement.classList.remove("wds-noscroll"), this.textarea ? (this.textarea.form?.removeEventListener("submit", this.onFormSubmit), this.textarea.value = e, this.textarea.style.display = "", this.root.remove()) : this.target.innerHTML = e || this.originalContent, te.delete(this.target), this.listeners.clear();
2624
+ this.destroyed = !0, window.clearTimeout(this.noticeTimer), this.autosave?.destroy(), tn(), this.view.destroy(), document.removeEventListener("keydown", this.onKeydown), this.fullscreen && document.documentElement.classList.remove("wds-noscroll"), this.textarea ? (this.textarea.form?.removeEventListener("submit", this.onFormSubmit), this.textarea.value = e, this.textarea.style.display = "", this.root.remove()) : this.target.innerHTML = e || this.originalContent, re.delete(this.target), this.listeners.clear();
2132
2625
  }
2133
2626
  // ---------- internals ----------
2134
2627
  dispatch(e) {
2135
2628
  if (this.destroyed) return;
2136
2629
  const n = this.view.state.apply(e);
2137
2630
  if (this.view.updateState(n), e.docChanged) {
2138
- const r = we(n.doc);
2139
- r !== this.lastHtml && (this.lastHtml = r, this.syncTarget(r), this.options.onChange?.(r, this), this.emit("change"));
2631
+ const r = Me(n.doc);
2632
+ r !== this.lastHtml && (this.lastHtml = r, this.syncTarget(r), this.autosave?.schedule(r), this.options.onChange?.(r, this), this.emit("change"));
2140
2633
  }
2141
2634
  this.refresh();
2142
2635
  }
2143
2636
  applySource() {
2144
- const e = this.sourceArea.value, n = be(e);
2637
+ const e = this.sourceArea.value, n = ke(e);
2145
2638
  if (n.eq(this.view.state.doc)) return;
2146
- const r = this.view.state.tr.replaceWith(0, this.view.state.doc.content.size, n.content), o = this.view.state.apply(r);
2147
- this.view.updateState(o), this.lastHtml = we(o.doc), this.syncTarget(this.lastHtml), this.options.onChange?.(this.lastHtml, this), this.emit("change");
2639
+ const r = this.view.state.tr.replaceWith(0, this.view.state.doc.content.size, n.content), i = this.view.state.apply(r);
2640
+ this.view.updateState(i), this.lastHtml = Me(i.doc), this.syncTarget(this.lastHtml), this.autosave?.schedule(this.lastHtml), this.options.onChange?.(this.lastHtml, this), this.emit("change");
2148
2641
  }
2149
2642
  syncTarget(e) {
2150
2643
  this.textarea && (this.textarea.value = e ?? this.getHTML());
2151
2644
  }
2152
2645
  refresh() {
2153
2646
  const e = this.view.state;
2154
- if (this.toolbar.update(e), this.counter) {
2155
- const n = this.getText(), r = (n.match(/[\p{L}\p{N}][\p{L}\p{N}'’-]*/gu) ?? []).length, o = n.replace(/\n/g, "").length;
2156
- this.counter.textContent = `${r} ${this.t.words} · ${o} ${this.t.characters}`;
2647
+ if (this.toolbar.update(e), this.findPanel?.update(e, !this.readOnly), this.counter) {
2648
+ const n = this.getText(), r = (n.match(/[\p{L}\p{N}][\p{L}\p{N}'’-]*/gu) ?? []).length, i = n.replace(/\n/g, "").length;
2649
+ this.counter.textContent = `${r} ${this.t.words} · ${i} ${this.t.characters}`;
2157
2650
  }
2158
2651
  }
2159
2652
  emit(e, n) {
2160
2653
  this.listeners.get(e)?.forEach((r) => {
2161
2654
  try {
2162
2655
  r(this, n);
2163
- } catch (o) {
2164
- console.error(o);
2656
+ } catch (i) {
2657
+ console.error(i);
2165
2658
  }
2166
2659
  });
2167
2660
  }
2168
2661
  };
2169
- ne.version = "1.1.0", ne.addLanguage = Gt;
2170
- let Tt = ne;
2171
- function zr(t) {
2662
+ ie.version = "1.2.0", ie.addLanguage = sn;
2663
+ let Ft = ie;
2664
+ function gi(t) {
2172
2665
  const e = t.replace(/\r\n?/g, `
2173
2666
  `).split(/\n{2,}/).map((n) => {
2174
- const o = n.split(`
2175
- `).flatMap((s, c) => [...c ? [p.nodes.hard_break.create()] : [], ...s ? [p.text(s)] : []]);
2176
- return p.nodes.paragraph.create(null, o);
2667
+ const i = n.split(`
2668
+ `).flatMap((s, o) => [...o ? [f.nodes.hard_break.create()] : [], ...s ? [f.text(s)] : []]);
2669
+ return f.nodes.paragraph.create(null, i);
2177
2670
  });
2178
- return new Rt(Ot.from(e), 1, 1);
2671
+ return new qt(Vt.from(e), 1, 1);
2179
2672
  }
2180
- function Br(t) {
2673
+ function bi(t) {
2181
2674
  const e = document.createElement("span");
2182
2675
  return e.textContent = t, e.innerHTML;
2183
2676
  }
2184
2677
  export {
2185
- br as DEFAULT_TOOLBAR,
2186
- Tt as WDSEditor,
2187
- Gt as addLanguage,
2188
- ke as en,
2189
- ue as isImage,
2190
- xt as matchesAccept,
2191
- Cr as normalizeList,
2192
- p as schema,
2193
- gr as toolbarItems,
2194
- xr as tr
2678
+ Pr as DEFAULT_TOOLBAR,
2679
+ Ft as WDSEditor,
2680
+ sn as addLanguage,
2681
+ Ee as en,
2682
+ pe as isImage,
2683
+ $t as matchesAccept,
2684
+ Yr as normalizeList,
2685
+ f as schema,
2686
+ Hr as toolbarItems,
2687
+ Vr as tr
2195
2688
  };
2196
2689
  //# sourceMappingURL=wds-editor.js.map