wds-editor 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/html.d.ts +5 -1
- package/dist/wds-editor.js +604 -591
- package/dist/wds-editor.js.map +1 -1
- package/dist/wds-editor.min.js +12 -15
- package/dist/wds-editor.min.js.map +1 -1
- package/dist/wds-editor.umd.cjs +4 -7
- package/dist/wds-editor.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/wds-editor.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { TextSelection as
|
|
2
|
-
import { DecorationSet as
|
|
3
|
-
import { redo as
|
|
4
|
-
import { Schema as
|
|
5
|
-
import { addListNodes as
|
|
6
|
-
import { tableNodes as
|
|
7
|
-
import { inputRules as
|
|
8
|
-
import { keymap as
|
|
9
|
-
import { lift as
|
|
10
|
-
import { gapCursor as
|
|
11
|
-
import { dropCursor as
|
|
12
|
-
const
|
|
1
|
+
import { TextSelection as Ve, NodeSelection as he, PluginKey as Gt, Plugin as xt, EditorState as jt } from "prosemirror-state";
|
|
2
|
+
import { DecorationSet as Et, Decoration as St, EditorView as Vt } from "prosemirror-view";
|
|
3
|
+
import { redo as Re, undo as At, redoDepth as Kt, undoDepth as Yt, history as Jt } from "prosemirror-history";
|
|
4
|
+
import { Schema as Tt, DOMParser as Xt, DOMSerializer as Qt, Fragment as Ct, Slice as Dt } from "prosemirror-model";
|
|
5
|
+
import { addListNodes as Zt, sinkListItem as en, liftListItem as Nt, wrapInList as tn, splitListItem as nn } from "prosemirror-schema-list";
|
|
6
|
+
import { tableNodes as rn, isInTable as pe, goToNextCell as ze, addRowAfter as It, tableEditing as on, addRowBefore as an, addColumnBefore as sn, addColumnAfter as ln, deleteRow as cn, deleteColumn as dn, toggleHeaderRow as un, toggleHeaderColumn as hn, mergeCells as pn, splitCell as mn, deleteTable as fn } from "prosemirror-tables";
|
|
7
|
+
import { inputRules as gn, InputRule as bn, textblockTypeInputRule as rt, wrappingInputRule as Ce, undoInputRule as wn } from "prosemirror-inputrules";
|
|
8
|
+
import { keymap as Ke } from "prosemirror-keymap";
|
|
9
|
+
import { lift as Ht, toggleMark as yn, setBlockType as De, wrapIn as vn, chainCommands as kn, exitCode as Mn, baseKeymap as Ln } from "prosemirror-commands";
|
|
10
|
+
import { gapCursor as xn } from "prosemirror-gapcursor";
|
|
11
|
+
import { dropCursor as En } from "prosemirror-dropcursor";
|
|
12
|
+
const Sn = /^(https?:|mailto:|tel:)/i, Ot = /^[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
|
|
18
|
+
return Ot.test(n) && !Sn.test(n) ? null : e;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function ot(t) {
|
|
21
21
|
const e = t.trim();
|
|
22
|
-
return e ? /^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(e) ? `mailto:${e}` : !
|
|
22
|
+
return e ? /^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(e) ? `mailto:${e}` : !Ot.test(e) && !/^[/#?.]/.test(e) && /^[\w-]+(\.[\w-]+)+/.test(e) ? `https://${e}` : q(e) : null;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function An(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
|
|
27
|
+
const it = {
|
|
28
28
|
black: "#000000",
|
|
29
29
|
white: "#ffffff",
|
|
30
30
|
red: "#ff0000",
|
|
@@ -53,23 +53,23 @@ const rt = {
|
|
|
53
53
|
lightgrey: "#d3d3d3",
|
|
54
54
|
darkgray: "#a9a9a9",
|
|
55
55
|
darkgrey: "#a9a9a9"
|
|
56
|
-
},
|
|
56
|
+
}, Ne = (t) => Math.max(0, Math.min(255, Math.round(t))).toString(16).padStart(2, "0");
|
|
57
57
|
function oe(t) {
|
|
58
58
|
if (!t) return null;
|
|
59
59
|
const e = t.trim().toLowerCase().replace(/\s*!important$/, "");
|
|
60
|
-
if (
|
|
60
|
+
if (it[e]) return it[e];
|
|
61
61
|
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 : "#" +
|
|
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));
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function at(t) {
|
|
65
65
|
const e = oe(t);
|
|
66
66
|
return e && e !== "#000000" ? e : null;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function Ie(t) {
|
|
69
69
|
const e = oe(t) ?? oe((t ?? "").split(/\s+(?![^(]*\))/).find((n) => oe(n)));
|
|
70
70
|
return e && e !== "#ffffff" ? e : null;
|
|
71
71
|
}
|
|
72
|
-
const
|
|
72
|
+
const Tn = [
|
|
73
73
|
{ color: "#dc2626", name: "colorRed" },
|
|
74
74
|
{ color: "#ea580c", name: "colorOrange" },
|
|
75
75
|
{ color: "#ca8a04", name: "colorAmber" },
|
|
@@ -80,35 +80,35 @@ const Sn = [
|
|
|
80
80
|
{ color: "#db2777", name: "colorPink" },
|
|
81
81
|
{ color: "#475569", name: "colorSlate" },
|
|
82
82
|
{ color: "#94a3b8", name: "colorGray" }
|
|
83
|
-
],
|
|
83
|
+
], Cn = [
|
|
84
84
|
{ color: "#fef08a", name: "colorYellow" },
|
|
85
85
|
{ color: "#bbf7d0", name: "colorGreen" },
|
|
86
86
|
{ color: "#bae6fd", name: "colorBlue" },
|
|
87
87
|
{ color: "#fbcfe8", name: "colorPink" },
|
|
88
88
|
{ color: "#fed7aa", name: "colorOrange" },
|
|
89
89
|
{ color: "#e9d5ff", name: "colorPurple" }
|
|
90
|
-
],
|
|
91
|
-
function
|
|
90
|
+
], Dn = ["left", "center", "right", "justify"];
|
|
91
|
+
function st(t) {
|
|
92
92
|
const e = (t.style.textAlign || t.getAttribute("align") || "").toLowerCase();
|
|
93
|
-
return
|
|
93
|
+
return Dn.includes(e) && e !== "left" ? e : null;
|
|
94
94
|
}
|
|
95
|
-
function
|
|
95
|
+
function lt(t) {
|
|
96
96
|
return t ? { style: `text-align: ${t}` } : {};
|
|
97
97
|
}
|
|
98
|
-
const
|
|
98
|
+
const Nn = {
|
|
99
99
|
left: "float: left; margin: 0 1em 1em 0",
|
|
100
100
|
right: "float: right; margin: 0 0 1em 1em",
|
|
101
101
|
center: "display: block; margin-left: auto; margin-right: auto"
|
|
102
|
-
},
|
|
102
|
+
}, In = {
|
|
103
103
|
left: "float: left; margin: 0 1em 1em 0",
|
|
104
104
|
right: "float: right; margin: 0 0 1em 1em",
|
|
105
105
|
center: "display: table; margin-left: auto; margin-right: auto"
|
|
106
106
|
};
|
|
107
|
-
function
|
|
107
|
+
function Hn(t) {
|
|
108
108
|
const e = t.style.float || t.getAttribute("align") || "";
|
|
109
109
|
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
110
|
}
|
|
111
|
-
const
|
|
111
|
+
const ct = {
|
|
112
112
|
src: {},
|
|
113
113
|
alt: { default: "" },
|
|
114
114
|
title: { default: null },
|
|
@@ -116,35 +116,35 @@ const st = {
|
|
|
116
116
|
height: { default: null },
|
|
117
117
|
align: { default: null }
|
|
118
118
|
};
|
|
119
|
-
function
|
|
119
|
+
function dt(t, e) {
|
|
120
120
|
const n = q(t.getAttribute("src"));
|
|
121
121
|
return n ? {
|
|
122
122
|
src: n,
|
|
123
123
|
alt: t.getAttribute("alt") ?? "",
|
|
124
124
|
title: t.getAttribute("title"),
|
|
125
|
-
width:
|
|
126
|
-
height:
|
|
127
|
-
align:
|
|
125
|
+
width: ut(t.getAttribute("width") ?? t.style.width),
|
|
126
|
+
height: ut(t.getAttribute("height") ?? t.style.height),
|
|
127
|
+
align: Hn(e)
|
|
128
128
|
} : !1;
|
|
129
129
|
}
|
|
130
130
|
function Be(t, e) {
|
|
131
|
-
const { src: n, alt: r, title: o, width:
|
|
132
|
-
o && (i.title = o),
|
|
133
|
-
const
|
|
134
|
-
return
|
|
131
|
+
const { src: n, alt: r, title: o, width: s, height: l, align: d } = t, i = { src: n, alt: r ?? "" };
|
|
132
|
+
o && (i.title = o), s && (i.width = String(s)), s && l && (i.height = String(l));
|
|
133
|
+
const a = e ? Nn[d] : void 0;
|
|
134
|
+
return a && (i.style = a), i;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function ut(t) {
|
|
137
137
|
const e = /^\s*(\d{1,5})(px)?\s*$/.exec(t ?? "");
|
|
138
138
|
return e ? Number(e[1]) : null;
|
|
139
139
|
}
|
|
140
|
-
const
|
|
140
|
+
const On = {
|
|
141
141
|
doc: { content: "block+" },
|
|
142
142
|
paragraph: {
|
|
143
143
|
content: "inline*",
|
|
144
144
|
group: "block",
|
|
145
145
|
attrs: { align: { default: null } },
|
|
146
|
-
parseDOM: [{ tag: "p", getAttrs: (t) => ({ align:
|
|
147
|
-
toDOM: (t) => ["p",
|
|
146
|
+
parseDOM: [{ tag: "p", getAttrs: (t) => ({ align: st(t) }) }],
|
|
147
|
+
toDOM: (t) => ["p", lt(t.attrs.align), 0]
|
|
148
148
|
},
|
|
149
149
|
heading: {
|
|
150
150
|
content: "inline*",
|
|
@@ -154,9 +154,9 @@ const In = {
|
|
|
154
154
|
parseDOM: [1, 2, 3, 4, 5, 6].map((t) => ({
|
|
155
155
|
tag: `h${t}`,
|
|
156
156
|
// h5/h6 are folded into h4 so pasted content stays inside the supported range
|
|
157
|
-
getAttrs: (e) => ({ level: Math.min(t, 4), align:
|
|
157
|
+
getAttrs: (e) => ({ level: Math.min(t, 4), align: st(e) })
|
|
158
158
|
})),
|
|
159
|
-
toDOM: (t) => [`h${t.attrs.level}`,
|
|
159
|
+
toDOM: (t) => [`h${t.attrs.level}`, lt(t.attrs.align), 0]
|
|
160
160
|
},
|
|
161
161
|
blockquote: {
|
|
162
162
|
content: "block+",
|
|
@@ -192,14 +192,14 @@ const In = {
|
|
|
192
192
|
["code", t.attrs.language ? { class: `language-${t.attrs.language}` } : {}, 0]
|
|
193
193
|
]
|
|
194
194
|
},
|
|
195
|
-
...
|
|
195
|
+
...rn({ tableGroup: "block", cellContent: "block+", cellAttributes: {} }),
|
|
196
196
|
text: { group: "inline" },
|
|
197
197
|
image: {
|
|
198
198
|
inline: !0,
|
|
199
199
|
group: "inline",
|
|
200
200
|
draggable: !0,
|
|
201
|
-
attrs:
|
|
202
|
-
parseDOM: [{ tag: "img[src]", getAttrs: (t) =>
|
|
201
|
+
attrs: ct,
|
|
202
|
+
parseDOM: [{ tag: "img[src]", getAttrs: (t) => dt(t, t) }],
|
|
203
203
|
toDOM: (t) => ["img", Be(t.attrs, !0)]
|
|
204
204
|
},
|
|
205
205
|
/** Image with a caption: <figure><img><figcaption>…</figcaption></figure>. The caption is the node's content. */
|
|
@@ -209,19 +209,19 @@ const In = {
|
|
|
209
209
|
marks: "_",
|
|
210
210
|
draggable: !0,
|
|
211
211
|
isolating: !0,
|
|
212
|
-
attrs:
|
|
212
|
+
attrs: ct,
|
|
213
213
|
parseDOM: [
|
|
214
214
|
{
|
|
215
215
|
tag: "figure",
|
|
216
216
|
getAttrs: (t) => {
|
|
217
217
|
const e = t.querySelector("img");
|
|
218
|
-
return e ?
|
|
218
|
+
return e ? dt(e, t) : !1;
|
|
219
219
|
},
|
|
220
220
|
contentElement: (t) => t.querySelector("figcaption") ?? document.createElement("figcaption")
|
|
221
221
|
}
|
|
222
222
|
],
|
|
223
223
|
toDOM: (t) => {
|
|
224
|
-
const e =
|
|
224
|
+
const e = In[t.attrs.align];
|
|
225
225
|
return ["figure", e ? { style: e } : {}, ["img", Be(t.attrs, !1)], ["figcaption", 0]];
|
|
226
226
|
}
|
|
227
227
|
},
|
|
@@ -232,7 +232,7 @@ const In = {
|
|
|
232
232
|
parseDOM: [{ tag: "br" }],
|
|
233
233
|
toDOM: () => ["br"]
|
|
234
234
|
}
|
|
235
|
-
},
|
|
235
|
+
}, $n = {
|
|
236
236
|
link: {
|
|
237
237
|
attrs: { href: {}, title: { default: null }, target: { default: null } },
|
|
238
238
|
inclusive: !1,
|
|
@@ -294,14 +294,14 @@ const In = {
|
|
|
294
294
|
{
|
|
295
295
|
tag: "span",
|
|
296
296
|
getAttrs: (t) => {
|
|
297
|
-
const e =
|
|
297
|
+
const e = at(t.style.color);
|
|
298
298
|
return e ? { color: e } : !1;
|
|
299
299
|
}
|
|
300
300
|
},
|
|
301
301
|
{
|
|
302
302
|
tag: "font[color]",
|
|
303
303
|
getAttrs: (t) => {
|
|
304
|
-
const e =
|
|
304
|
+
const e = at(t.getAttribute("color"));
|
|
305
305
|
return e ? { color: e } : !1;
|
|
306
306
|
}
|
|
307
307
|
}
|
|
@@ -314,19 +314,19 @@ const In = {
|
|
|
314
314
|
parseDOM: [
|
|
315
315
|
{
|
|
316
316
|
tag: "mark",
|
|
317
|
-
getAttrs: (t) => ({ color:
|
|
317
|
+
getAttrs: (t) => ({ color: Ie(t.style.backgroundColor) ?? "#fef08a" })
|
|
318
318
|
},
|
|
319
319
|
{
|
|
320
320
|
style: "background-color",
|
|
321
321
|
getAttrs: (t) => {
|
|
322
|
-
const e =
|
|
322
|
+
const e = Ie(t);
|
|
323
323
|
return e ? { color: e } : !1;
|
|
324
324
|
}
|
|
325
325
|
},
|
|
326
326
|
{
|
|
327
327
|
style: "background",
|
|
328
328
|
getAttrs: (t) => {
|
|
329
|
-
const e =
|
|
329
|
+
const e = Ie(t);
|
|
330
330
|
return e ? { color: e } : !1;
|
|
331
331
|
}
|
|
332
332
|
}
|
|
@@ -337,61 +337,74 @@ const In = {
|
|
|
337
337
|
parseDOM: [{ tag: "code" }],
|
|
338
338
|
toDOM: () => ["code", 0]
|
|
339
339
|
}
|
|
340
|
-
},
|
|
341
|
-
nodes:
|
|
342
|
-
marks:
|
|
343
|
-
}),
|
|
340
|
+
}, ht = new Tt({ nodes: On, marks: $n }), p = new Tt({
|
|
341
|
+
nodes: Zt(ht.spec.nodes, "paragraph block*", "block"),
|
|
342
|
+
marks: ht.spec.marks
|
|
343
|
+
}), Rn = Qt.fromSchema(p), zn = Xt.fromSchema(p);
|
|
344
344
|
function ge(t) {
|
|
345
345
|
const e = new window.DOMParser().parseFromString(`<!doctype html><body>${t}`, "text/html");
|
|
346
|
-
return
|
|
346
|
+
return zn.parse(e.body);
|
|
347
347
|
}
|
|
348
348
|
function be(t) {
|
|
349
|
-
if (
|
|
349
|
+
if ($t(t)) return "";
|
|
350
350
|
const e = document.createElement("div");
|
|
351
|
-
return e.append(
|
|
351
|
+
return e.append(Rn.serializeFragment(t.content)), e.querySelectorAll("[style]").forEach((n) => n.setAttribute("style", Fn(n.getAttribute("style") ?? ""))), e.innerHTML;
|
|
352
352
|
}
|
|
353
|
-
const
|
|
354
|
-
function
|
|
353
|
+
const Bn = (t, e, n, r) => "#" + [e, n, r].map((o) => (+o).toString(16).padStart(2, "0")).join("");
|
|
354
|
+
function Fn(t) {
|
|
355
355
|
return t.split(";").map((e) => e.trim()).filter(Boolean).map(
|
|
356
|
-
(e) => e.replace(/rgb\(\s*(\d+),\s*(\d+),\s*(\d+)\s*\)/g,
|
|
356
|
+
(e) => e.replace(/rgb\(\s*(\d+),\s*(\d+),\s*(\d+)\s*\)/g, Bn).replace(/(^|[\s:])0px(?![\w.])/g, (n, r) => `${r}0`).replace(/\s*:\s*/, ": ")
|
|
357
357
|
).join("; ");
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function $t(t) {
|
|
360
360
|
const e = t.firstChild;
|
|
361
361
|
return t.childCount === 1 && !!e && e.type === p.nodes.paragraph && e.content.size === 0 && !e.attrs.align;
|
|
362
362
|
}
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
363
|
+
const Fe = /* @__PURE__ */ new Set(["UL", "OL", "BLOCKQUOTE", "TABLE", "THEAD", "TBODY", "TFOOT", "TR", "FIGURE"]), Ue = /* @__PURE__ */ new Set(["LI", "TH", "TD"]), pt = (t) => t.nodeType === 1 && (Fe.has(t.tagName) || Ue.has(t.tagName) || /^(P|H[1-6]|PRE|HR|FIGCAPTION|IMG|DIV)$/.test(t.tagName)), Un = (t) => {
|
|
364
|
+
const n = t.cloneNode(!1).outerHTML;
|
|
365
|
+
return n.slice(0, n.length - `</${t.localName}>`.length);
|
|
366
|
+
};
|
|
367
|
+
function mt(t) {
|
|
368
|
+
const e = document.createElement("div");
|
|
369
|
+
e.innerHTML = t;
|
|
370
|
+
const n = [], r = (o, s) => {
|
|
371
|
+
const l = " ".repeat(s);
|
|
372
|
+
let d = "";
|
|
373
|
+
const i = () => {
|
|
374
|
+
d.trim() && n.push(l + d.trim()), d = "";
|
|
375
|
+
};
|
|
376
|
+
o.childNodes.forEach((a) => {
|
|
377
|
+
if (!pt(a)) {
|
|
378
|
+
d += a.nodeType === 1 ? a.outerHTML : a.nodeType === 3 ? Pn(a.textContent ?? "") : "";
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
i();
|
|
382
|
+
const c = a, u = Array.from(c.childNodes).filter(pt);
|
|
383
|
+
(Ue.has(c.tagName) ? u.length <= 1 && u.every((g) => !Fe.has(g.tagName) && !Ue.has(g.tagName)) : !Fe.has(c.tagName)) ? n.push(l + c.outerHTML) : (n.push(l + Un(c)), r(c, s + 1), n.push(`${l}</${c.localName}>`));
|
|
384
|
+
}), i();
|
|
385
|
+
};
|
|
386
|
+
return r(e, 0), n.join(`
|
|
375
387
|
`);
|
|
376
388
|
}
|
|
389
|
+
const Pn = (t) => t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/ /g, " ");
|
|
377
390
|
function de(t, e) {
|
|
378
|
-
const { from: n, $from: r, to: o, empty:
|
|
379
|
-
return
|
|
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);
|
|
380
393
|
}
|
|
381
|
-
function
|
|
394
|
+
function _n(t) {
|
|
382
395
|
const e = t.selection.$from.parent;
|
|
383
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;
|
|
384
397
|
}
|
|
385
|
-
function
|
|
398
|
+
function Wn(t) {
|
|
386
399
|
return t === "paragraph" ? De(p.nodes.paragraph) : t === "codeBlock" ? De(p.nodes.code_block) : De(p.nodes.heading, { level: Number(t.slice(-1)) });
|
|
387
400
|
}
|
|
388
|
-
const _ = (t) =>
|
|
389
|
-
function
|
|
401
|
+
const _ = (t) => yn(p.marks[t]);
|
|
402
|
+
function Rt(t, e) {
|
|
390
403
|
const { $from: n } = t.selection;
|
|
391
404
|
for (let r = n.depth; r > 0; r--) if (n.node(r).type === e) return !0;
|
|
392
405
|
return !1;
|
|
393
406
|
}
|
|
394
|
-
function
|
|
407
|
+
function ft(t) {
|
|
395
408
|
const { $from: e } = t.selection;
|
|
396
409
|
for (let n = e.depth; n > 0; n--) {
|
|
397
410
|
const r = e.node(n).type;
|
|
@@ -399,47 +412,47 @@ function ht(t) {
|
|
|
399
412
|
}
|
|
400
413
|
return null;
|
|
401
414
|
}
|
|
402
|
-
function
|
|
415
|
+
function gt(t) {
|
|
403
416
|
return (e, n, r) => {
|
|
404
417
|
const { $from: o } = e.selection;
|
|
405
|
-
for (let
|
|
406
|
-
const l = o.node(
|
|
418
|
+
for (let s = o.depth; s > 0; s--) {
|
|
419
|
+
const l = o.node(s);
|
|
407
420
|
if (l.type === p.nodes.bullet_list || l.type === p.nodes.ordered_list)
|
|
408
|
-
return l.type === t ?
|
|
421
|
+
return l.type === t ? Nt(p.nodes.list_item)(e, n, r) : (n && n(e.tr.setNodeMarkup(o.before(s), t)), !0);
|
|
409
422
|
}
|
|
410
|
-
return
|
|
423
|
+
return tn(t)(e, n, r);
|
|
411
424
|
};
|
|
412
425
|
}
|
|
413
|
-
const
|
|
414
|
-
function
|
|
415
|
-
return (t, e) =>
|
|
426
|
+
const Pe = en(p.nodes.list_item), _e = (t, e, n) => Nt(p.nodes.list_item)(t, e, n) || Ht(t, e);
|
|
427
|
+
function qn() {
|
|
428
|
+
return (t, e) => Rt(t, p.nodes.blockquote) ? Ht(t, e) : vn(p.nodes.blockquote)(t, e);
|
|
416
429
|
}
|
|
417
430
|
function j(t) {
|
|
418
431
|
return (e, n) => {
|
|
419
|
-
const r = t === "left" ? null : t, { from: o, to:
|
|
432
|
+
const r = t === "left" ? null : t, { from: o, to: s } = e.selection, l = e.tr;
|
|
420
433
|
let d = !1;
|
|
421
|
-
return e.doc.nodesBetween(o,
|
|
434
|
+
return e.doc.nodesBetween(o, s, (i, a) => i.type === p.nodes.paragraph || i.type === p.nodes.heading ? (d = !0, i.attrs.align !== r && l.setNodeMarkup(a, void 0, { ...i.attrs, align: r }), !1) : !0), d ? (n && n(l), !0) : !1;
|
|
422
435
|
};
|
|
423
436
|
}
|
|
424
437
|
function we(t) {
|
|
425
438
|
return t.selection.$from.parent.attrs.align ?? "left";
|
|
426
439
|
}
|
|
427
|
-
const
|
|
440
|
+
const Gn = (t, e) => {
|
|
428
441
|
const n = p.nodes.horizontal_rule;
|
|
429
442
|
if (!e) return !0;
|
|
430
443
|
const r = t.tr.replaceSelectionWith(n.create()), o = r.selection.$from;
|
|
431
444
|
return !o.nodeAfter && o.parent.type === p.nodes.doc && r.insert(o.pos, p.nodes.paragraph.create()), e(r.scrollIntoView()), !0;
|
|
432
|
-
},
|
|
433
|
-
const { from: n, to: r, empty: o } = t.selection,
|
|
445
|
+
}, jn = (t, e) => {
|
|
446
|
+
const { from: n, to: r, empty: o } = t.selection, s = t.tr;
|
|
434
447
|
if (o)
|
|
435
|
-
|
|
448
|
+
s.setStoredMarks([]);
|
|
436
449
|
else
|
|
437
|
-
for (const l of Object.values(p.marks)) l !== p.marks.link &&
|
|
438
|
-
return t.doc.nodesBetween(n, r, (l, d) => l.isTextblock && l.type !== p.nodes.paragraph ? (
|
|
450
|
+
for (const l of Object.values(p.marks)) l !== p.marks.link && s.removeMark(n, r, l);
|
|
451
|
+
return t.doc.nodesBetween(n, r, (l, d) => l.isTextblock && l.type !== p.nodes.paragraph ? (s.setBlockType(d, d + l.nodeSize, p.nodes.paragraph), !1) : (l.type === p.nodes.paragraph && l.attrs.align && s.setNodeMarkup(d, void 0, { align: null }), !0)), e && e(s), !0;
|
|
439
452
|
};
|
|
440
|
-
function
|
|
441
|
-
const e = p.marks.link, { $from: n, from: r, to: o, empty:
|
|
442
|
-
if (!
|
|
453
|
+
function We(t) {
|
|
454
|
+
const e = p.marks.link, { $from: n, from: r, to: o, empty: s } = t.selection;
|
|
455
|
+
if (!s) {
|
|
443
456
|
let u = null;
|
|
444
457
|
return t.doc.nodesBetween(r, o, (m, g) => {
|
|
445
458
|
const v = e.isInSet(m.marks);
|
|
@@ -449,99 +462,99 @@ function Pe(t) {
|
|
|
449
462
|
const l = e.isInSet(n.marks()) ?? e.isInSet(n.nodeBefore?.marks ?? []);
|
|
450
463
|
if (!l) return null;
|
|
451
464
|
const d = n.start(), i = [];
|
|
452
|
-
let
|
|
465
|
+
let a = 0;
|
|
453
466
|
n.parent.forEach((u) => {
|
|
454
|
-
const m = d +
|
|
467
|
+
const m = d + a, g = m + u.nodeSize;
|
|
455
468
|
if (l.isInSet(u.marks)) {
|
|
456
469
|
const v = i[i.length - 1];
|
|
457
470
|
v && v[1] === m ? v[1] = g : i.push([m, g]);
|
|
458
471
|
}
|
|
459
|
-
|
|
472
|
+
a += u.nodeSize;
|
|
460
473
|
});
|
|
461
474
|
const c = i.find(([u, m]) => u <= n.pos && n.pos <= m);
|
|
462
475
|
return c ? { from: c[0], to: c[1], ...l.attrs } : null;
|
|
463
476
|
}
|
|
464
|
-
function
|
|
477
|
+
function qe(t) {
|
|
465
478
|
const e = t.selection;
|
|
466
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;
|
|
467
480
|
}
|
|
468
|
-
function
|
|
469
|
-
const r = p.nodes.figure.create(n), o = t.doc.resolve(e),
|
|
470
|
-
|
|
481
|
+
function bt(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);
|
|
471
484
|
let l = -1;
|
|
472
|
-
return t.doc.descendants((d, i) => l >= 0 ? !1 : (d.type === p.nodes.figure && d.attrs.src === n.src && d.content.size === 0 && (l = i), !0)), l >= 0 && t.setSelection(
|
|
485
|
+
return t.doc.descendants((d, i) => l >= 0 ? !1 : (d.type === p.nodes.figure && d.attrs.src === n.src && d.content.size === 0 && (l = i), !0)), l >= 0 && t.setSelection(Ve.create(t.doc, l + 1)), t;
|
|
473
486
|
}
|
|
474
|
-
function
|
|
475
|
-
const o = p.nodes.image.create(r),
|
|
476
|
-
return n.content.size &&
|
|
487
|
+
function Vn(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, Ct.from(s)), t.setSelection(he.create(t.doc, e + 1));
|
|
477
490
|
}
|
|
478
|
-
function
|
|
479
|
-
const r = p.nodes, o = (
|
|
480
|
-
return r.table.create(null, Array.from({ length: t }, (
|
|
491
|
+
function Kn(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, l) => o(n && l === 0 ? r.table_header : r.table_cell)));
|
|
481
494
|
}
|
|
482
|
-
function
|
|
495
|
+
function Yn(t, e) {
|
|
483
496
|
return (n, r) => {
|
|
484
497
|
if (pe(n)) return !1;
|
|
485
498
|
if (!r) return !0;
|
|
486
|
-
const o =
|
|
487
|
-
l.parent.type === p.nodes.paragraph && l.parent.content.size === 0 && l.depth === 1 ?
|
|
499
|
+
const o = Kn(t, e), s = n.tr, l = n.selection.$from;
|
|
500
|
+
l.parent.type === p.nodes.paragraph && l.parent.content.size === 0 && l.depth === 1 ? s.replaceWith(l.before(), l.after(), o) : s.replaceSelectionWith(o);
|
|
488
501
|
let i = -1;
|
|
489
|
-
if (
|
|
490
|
-
const
|
|
491
|
-
|
|
502
|
+
if (s.doc.descendants((a, c) => i >= 0 ? !1 : (a === o && (i = c), 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(Ve.create(s.doc, i + 4));
|
|
492
505
|
}
|
|
493
|
-
return r(
|
|
506
|
+
return r(s.scrollIntoView()), !0;
|
|
494
507
|
};
|
|
495
508
|
}
|
|
496
|
-
const
|
|
497
|
-
function
|
|
498
|
-
const n = p.marks[e], { from: r, to: o, empty:
|
|
499
|
-
if (
|
|
509
|
+
const Jn = (t, e, n) => pe(t) ? ze(1)(t, e) || !e || !n ? !0 : (It(t, e), ze(1)(n.state, e)) : !1, Xn = (t, e) => pe(t) && ze(-1)(t, e);
|
|
510
|
+
function Ge(t, e) {
|
|
511
|
+
const n = p.marks[e], { from: r, to: o, empty: s, $from: l } = t.selection;
|
|
512
|
+
if (s) return n.isInSet(t.storedMarks || l.marks())?.attrs.color ?? null;
|
|
500
513
|
let d;
|
|
501
514
|
return t.doc.nodesBetween(r, o, (i) => {
|
|
502
515
|
if (!i.isText || d === null) return;
|
|
503
|
-
const
|
|
504
|
-
d = d === void 0 || d ===
|
|
516
|
+
const a = n.isInSet(i.marks)?.attrs.color ?? null;
|
|
517
|
+
d = d === void 0 || d === a ? a : null;
|
|
505
518
|
}), d ?? null;
|
|
506
519
|
}
|
|
507
|
-
function
|
|
520
|
+
function Qn(t, e) {
|
|
508
521
|
return (n, r) => {
|
|
509
|
-
const o = p.marks[t], { from:
|
|
522
|
+
const o = p.marks[t], { from: s, to: l, empty: d } = n.selection;
|
|
510
523
|
if (!r) return !0;
|
|
511
524
|
const i = n.tr;
|
|
512
|
-
return d ? (i.removeStoredMark(o), e && i.addStoredMark(o.create({ color: e }))) : (i.removeMark(
|
|
525
|
+
return d ? (i.removeStoredMark(o), e && i.addStoredMark(o.create({ color: e }))) : (i.removeMark(s, l, o), e && i.addMark(s, l, o.create({ color: e }))), r(i.scrollIntoView()), !0;
|
|
513
526
|
};
|
|
514
527
|
}
|
|
515
|
-
function
|
|
528
|
+
function Zn() {
|
|
516
529
|
const t = p.nodes;
|
|
517
|
-
return
|
|
530
|
+
return gn({
|
|
518
531
|
rules: [
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
532
|
+
rt(/^(#{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(
|
|
523
536
|
/^(\d+)\.\s$/,
|
|
524
537
|
t.ordered_list,
|
|
525
538
|
(e) => ({ order: +e[1] }),
|
|
526
539
|
(e, n) => n.childCount + n.attrs.order === +e[1]
|
|
527
540
|
),
|
|
528
|
-
|
|
529
|
-
new
|
|
530
|
-
const
|
|
531
|
-
if (
|
|
532
|
-
const l =
|
|
541
|
+
rt(/^```$/, t.code_block),
|
|
542
|
+
new bn(/^(?:---|\*\*\*|___)$/, (e, n, r, o) => {
|
|
543
|
+
const s = e.doc.resolve(r);
|
|
544
|
+
if (s.parent.type !== t.paragraph) return null;
|
|
545
|
+
const l = s.before();
|
|
533
546
|
return e.tr.replaceWith(l, o + 1, [t.horizontal_rule.create(), t.paragraph.create()]);
|
|
534
547
|
})
|
|
535
548
|
]
|
|
536
549
|
});
|
|
537
550
|
}
|
|
538
|
-
function
|
|
539
|
-
const e =
|
|
540
|
-
return
|
|
541
|
-
"Mod-z":
|
|
542
|
-
"Mod-y":
|
|
543
|
-
"Shift-Mod-z":
|
|
544
|
-
Backspace:
|
|
551
|
+
function er(t) {
|
|
552
|
+
const e = kn(Mn, (n, r) => (r && r(n.tr.replaceSelectionWith(p.nodes.hard_break.create()).scrollIntoView()), !0));
|
|
553
|
+
return Ke({
|
|
554
|
+
"Mod-z": At,
|
|
555
|
+
"Mod-y": Re,
|
|
556
|
+
"Shift-Mod-z": Re,
|
|
557
|
+
Backspace: wn,
|
|
545
558
|
"Mod-b": _("strong"),
|
|
546
559
|
"Mod-i": _("em"),
|
|
547
560
|
"Mod-u": _("underline"),
|
|
@@ -550,36 +563,36 @@ function Jn(t) {
|
|
|
550
563
|
"Mod-k": t.link,
|
|
551
564
|
"Shift-Enter": e,
|
|
552
565
|
"Mod-Enter": e,
|
|
553
|
-
Enter:
|
|
554
|
-
Tab:
|
|
555
|
-
"Shift-Tab":
|
|
566
|
+
Enter: nn(p.nodes.list_item),
|
|
567
|
+
Tab: Pe,
|
|
568
|
+
"Shift-Tab": _e
|
|
556
569
|
});
|
|
557
570
|
}
|
|
558
|
-
const
|
|
559
|
-
function
|
|
560
|
-
return new
|
|
571
|
+
const tr = () => Ke(Ln);
|
|
572
|
+
function nr(t) {
|
|
573
|
+
return new xt({
|
|
561
574
|
props: {
|
|
562
575
|
decorations(e) {
|
|
563
576
|
const n = e.doc, r = n.firstChild;
|
|
564
|
-
return !t || n.childCount !== 1 || !r || !r.isTextblock || r.content.size > 0 ? null :
|
|
565
|
-
|
|
577
|
+
return !t || n.childCount !== 1 || !r || !r.isTextblock || r.content.size > 0 ? null : Et.create(n, [
|
|
578
|
+
St.node(0, r.nodeSize, { class: "wds-placeholder", "data-placeholder": t })
|
|
566
579
|
]);
|
|
567
580
|
}
|
|
568
581
|
}
|
|
569
582
|
});
|
|
570
583
|
}
|
|
571
|
-
const Q = new
|
|
572
|
-
function
|
|
573
|
-
return new
|
|
584
|
+
const Q = new Gt("wds-upload");
|
|
585
|
+
function rr() {
|
|
586
|
+
return new xt({
|
|
574
587
|
key: Q,
|
|
575
588
|
state: {
|
|
576
|
-
init: () =>
|
|
589
|
+
init: () => Et.empty,
|
|
577
590
|
apply(t, e) {
|
|
578
591
|
e = e.map(t.mapping, t.doc);
|
|
579
592
|
const n = t.getMeta(Q);
|
|
580
593
|
if (n && "add" in n) {
|
|
581
594
|
const r = document.createElement("span");
|
|
582
|
-
r.className = "wds-upload-placeholder", r.setAttribute("aria-hidden", "true"), e = e.add(t.doc, [
|
|
595
|
+
r.className = "wds-upload-placeholder", r.setAttribute("aria-hidden", "true"), e = e.add(t.doc, [St.widget(n.add.pos, r, { id: n.add.id })]);
|
|
583
596
|
} else n && "remove" in n && (e = e.remove(e.find(void 0, void 0, (r) => r.id === n.remove.id)));
|
|
584
597
|
return e;
|
|
585
598
|
}
|
|
@@ -589,76 +602,76 @@ function Zn() {
|
|
|
589
602
|
}
|
|
590
603
|
});
|
|
591
604
|
}
|
|
592
|
-
function
|
|
605
|
+
function or(t, e) {
|
|
593
606
|
const n = Q.getState(t)?.find(void 0, void 0, (r) => r.id === e);
|
|
594
607
|
return n && n.length ? n[0].from : null;
|
|
595
608
|
}
|
|
596
|
-
const
|
|
597
|
-
undo:
|
|
598
|
-
redo:
|
|
599
|
-
bold:
|
|
600
|
-
italic:
|
|
601
|
-
underline:
|
|
602
|
-
strike:
|
|
603
|
-
code:
|
|
604
|
-
link:
|
|
605
|
-
blockquote:
|
|
606
|
-
bulletList:
|
|
607
|
-
orderedList:
|
|
608
|
-
indent:
|
|
609
|
-
outdent:
|
|
610
|
-
alignLeft:
|
|
611
|
-
alignCenter:
|
|
612
|
-
alignRight:
|
|
613
|
-
alignJustify:
|
|
614
|
-
hr:
|
|
615
|
-
clear:
|
|
616
|
-
source:
|
|
617
|
-
fullscreen:
|
|
618
|
-
close:
|
|
619
|
-
image:
|
|
620
|
-
file:
|
|
621
|
-
folder:
|
|
622
|
-
upload:
|
|
623
|
-
grid:
|
|
624
|
-
list:
|
|
625
|
-
trash:
|
|
626
|
-
table:
|
|
627
|
-
pasteText:
|
|
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"/>'),
|
|
631
|
+
close: E('<path d="M6 6l12 12M18 6 6 18"/>'),
|
|
632
|
+
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"/>'),
|
|
633
|
+
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"/>'),
|
|
634
|
+
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"/>'),
|
|
635
|
+
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"/>'),
|
|
636
|
+
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"/>'),
|
|
637
|
+
list: E('<path d="M9 6h11M9 12h11M9 18h11"/><path d="M4 6h1M4 12h1M4 18h1"/>'),
|
|
638
|
+
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"/>'),
|
|
639
|
+
table: E('<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 10h18M3 15h18M9 4v16M15 4v16"/>'),
|
|
640
|
+
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"/>'),
|
|
628
641
|
// The bar (class wds-swatch-bar) shows the current color through --wds-swatch
|
|
629
|
-
textColor:
|
|
630
|
-
highlight:
|
|
631
|
-
globe:
|
|
632
|
-
},
|
|
633
|
-
undo: { type: "button", label: "undo", icon:
|
|
634
|
-
redo: { type: "button", label: "redo", icon:
|
|
642
|
+
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"/>'),
|
|
643
|
+
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"/>'),
|
|
644
|
+
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"/>')
|
|
645
|
+
}, H = (t) => (e) => e.exec(t), ir = {
|
|
646
|
+
undo: { type: "button", label: "undo", icon: L.undo, shortcut: "Mod+Z", run: (t) => t.undo(), enabled: (t) => Yt(t) > 0 },
|
|
647
|
+
redo: { type: "button", label: "redo", icon: L.redo, shortcut: "Mod+Y", run: (t) => t.redo(), enabled: (t) => Kt(t) > 0 },
|
|
635
648
|
blocks: { type: "blocks" },
|
|
636
|
-
bold: { type: "button", label: "bold", icon:
|
|
637
|
-
italic: { type: "button", label: "italic", icon:
|
|
638
|
-
underline: { type: "button", label: "underline", icon:
|
|
639
|
-
strike: { type: "button", label: "strike", icon:
|
|
640
|
-
textColor: { type: "button", label: "textColor", icon:
|
|
641
|
-
highlight: { type: "button", label: "highlight", icon:
|
|
642
|
-
code: { type: "button", label: "code", icon:
|
|
643
|
-
link: { type: "button", label: "link", icon:
|
|
644
|
-
image: { type: "button", label: "image", icon:
|
|
645
|
-
file: { type: "button", label: "file", icon:
|
|
646
|
-
table: { type: "button", label: "table", icon:
|
|
647
|
-
blockquote: { type: "button", label: "blockquote", icon:
|
|
648
|
-
bulletList: { type: "button", label: "bulletList", icon:
|
|
649
|
-
orderedList: { type: "button", label: "orderedList", icon:
|
|
650
|
-
outdent: { type: "button", label: "outdent", icon:
|
|
651
|
-
indent: { type: "button", label: "indent", icon:
|
|
652
|
-
alignLeft: { type: "button", label: "alignLeft", icon:
|
|
653
|
-
alignCenter: { type: "button", label: "alignCenter", icon:
|
|
654
|
-
alignRight: { type: "button", label: "alignRight", icon:
|
|
655
|
-
alignJustify: { type: "button", label: "alignJustify", icon:
|
|
656
|
-
hr: { type: "button", label: "hr", icon:
|
|
657
|
-
clear: { type: "button", label: "clear", icon:
|
|
658
|
-
pasteText: { type: "button", label: "pasteText", icon:
|
|
659
|
-
source: { type: "button", label: "source", icon:
|
|
660
|
-
fullscreen: { type: "button", label: "fullscreen", icon:
|
|
661
|
-
},
|
|
649
|
+
bold: { type: "button", label: "bold", icon: L.bold, shortcut: "Mod+B", run: H(_("strong")), active: (t) => de(t, p.marks.strong) },
|
|
650
|
+
italic: { type: "button", label: "italic", icon: L.italic, shortcut: "Mod+I", run: H(_("em")), active: (t) => de(t, p.marks.em) },
|
|
651
|
+
underline: { type: "button", label: "underline", icon: L.underline, shortcut: "Mod+U", run: H(_("underline")), active: (t) => de(t, p.marks.underline) },
|
|
652
|
+
strike: { type: "button", label: "strike", icon: L.strike, run: H(_("strike")), active: (t) => de(t, p.marks.strike) },
|
|
653
|
+
textColor: { type: "button", label: "textColor", icon: L.textColor, popup: !0, run: (t, e) => t.openColorPicker("textColor", e), swatch: (t) => Ge(t, "textColor") },
|
|
654
|
+
highlight: { type: "button", label: "highlight", icon: L.highlight, popup: !0, run: (t, e) => t.openColorPicker("highlight", e), swatch: (t) => Ge(t, "highlight") },
|
|
655
|
+
code: { type: "button", label: "code", icon: L.code, run: H(_("code")), active: (t) => de(t, p.marks.code) },
|
|
656
|
+
link: { type: "button", label: "link", icon: L.link, shortcut: "Mod+K", run: (t) => t.openLinkDialog(), active: (t) => !!We(t) },
|
|
657
|
+
image: { type: "button", label: "image", icon: L.image, run: (t) => t.openImageDialog(), active: (t) => !!qe(t) },
|
|
658
|
+
file: { type: "button", label: "file", icon: L.file, run: (t) => t.openFileManager("file"), available: (t) => t.hasFileManager() },
|
|
659
|
+
table: { type: "button", label: "table", icon: L.table, popup: !0, run: (t, e) => t.openTableMenu(e), active: (t) => pe(t) },
|
|
660
|
+
blockquote: { type: "button", label: "blockquote", icon: L.blockquote, run: H(qn()), active: (t) => Rt(t, p.nodes.blockquote) },
|
|
661
|
+
bulletList: { type: "button", label: "bulletList", icon: L.bulletList, run: H(gt(p.nodes.bullet_list)), active: (t) => ft(t) === p.nodes.bullet_list },
|
|
662
|
+
orderedList: { type: "button", label: "orderedList", icon: L.orderedList, run: H(gt(p.nodes.ordered_list)), active: (t) => ft(t) === p.nodes.ordered_list },
|
|
663
|
+
outdent: { type: "button", label: "outdent", icon: L.outdent, run: H(_e), enabled: (t) => _e(t) },
|
|
664
|
+
indent: { type: "button", label: "indent", icon: L.indent, run: H(Pe), enabled: (t) => Pe(t) },
|
|
665
|
+
alignLeft: { type: "button", label: "alignLeft", icon: L.alignLeft, run: H(j("left")), active: (t) => we(t) === "left", enabled: (t) => j("left")(t) },
|
|
666
|
+
alignCenter: { type: "button", label: "alignCenter", icon: L.alignCenter, run: H(j("center")), active: (t) => we(t) === "center", enabled: (t) => j("center")(t) },
|
|
667
|
+
alignRight: { type: "button", label: "alignRight", icon: L.alignRight, run: H(j("right")), active: (t) => we(t) === "right", enabled: (t) => j("right")(t) },
|
|
668
|
+
alignJustify: { type: "button", label: "alignJustify", icon: L.alignJustify, run: H(j("justify")), active: (t) => we(t) === "justify", enabled: (t) => j("justify")(t) },
|
|
669
|
+
hr: { type: "button", label: "hr", icon: L.hr, run: H(Gn) },
|
|
670
|
+
clear: { type: "button", label: "clear", icon: L.clear, run: H(jn) },
|
|
671
|
+
pasteText: { type: "button", label: "pasteText", icon: L.pasteText, run: (t) => t.togglePlainPaste(), active: (t, e) => e.isPlainPaste() },
|
|
672
|
+
source: { type: "button", label: "source", icon: L.source, run: (t) => t.toggleSource(), active: (t, e) => e.isSourceMode(), inSource: !0 },
|
|
673
|
+
fullscreen: { type: "button", label: "fullscreen", icon: L.fullscreen, run: (t) => t.toggleFullscreen(), active: (t, e) => e.isFullscreen(), inSource: !0 }
|
|
674
|
+
}, ar = [
|
|
662
675
|
"undo",
|
|
663
676
|
"redo",
|
|
664
677
|
"|",
|
|
@@ -693,26 +706,26 @@ const S = (t) => `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" st
|
|
|
693
706
|
"|",
|
|
694
707
|
"source",
|
|
695
708
|
"fullscreen"
|
|
696
|
-
],
|
|
709
|
+
], sr = [
|
|
697
710
|
["paragraph", "paragraph"],
|
|
698
711
|
["heading1", "heading1"],
|
|
699
712
|
["heading2", "heading2"],
|
|
700
713
|
["heading3", "heading3"],
|
|
701
714
|
["heading4", "heading4"],
|
|
702
715
|
["codeBlock", "codeBlock"]
|
|
703
|
-
],
|
|
704
|
-
function
|
|
716
|
+
], lr = typeof navigator < "u" && /Mac|iP(hone|ad|od)/.test(navigator.platform || navigator.userAgent), cr = (t) => t.replace("Mod", lr ? "⌘" : "Ctrl");
|
|
717
|
+
function dr(t, e, n) {
|
|
705
718
|
const r = document.createElement("div");
|
|
706
719
|
r.className = "wds-toolbar", r.setAttribute("role", "toolbar"), r.setAttribute("aria-label", n.toolbarLabel);
|
|
707
720
|
const o = [];
|
|
708
|
-
let
|
|
709
|
-
|
|
721
|
+
let s = document.createElement("div");
|
|
722
|
+
s.className = "wds-group", r.append(s);
|
|
710
723
|
for (const d of e) {
|
|
711
724
|
if (d === "|") {
|
|
712
|
-
|
|
725
|
+
s.childElementCount && (s = document.createElement("div"), s.className = "wds-group", r.append(s));
|
|
713
726
|
continue;
|
|
714
727
|
}
|
|
715
|
-
const i =
|
|
728
|
+
const i = ir[d];
|
|
716
729
|
if (!i) {
|
|
717
730
|
console.warn(`[WDS Editor] Unknown toolbar item "${d}".`);
|
|
718
731
|
continue;
|
|
@@ -720,60 +733,60 @@ function ar(t, e, n) {
|
|
|
720
733
|
if (i.type === "blocks") {
|
|
721
734
|
const u = document.createElement("select");
|
|
722
735
|
u.className = "wds-select", u.setAttribute("aria-label", n.blockType), u.title = n.blockType;
|
|
723
|
-
for (const [g, v] of
|
|
736
|
+
for (const [g, v] of sr) {
|
|
724
737
|
const D = document.createElement("option");
|
|
725
738
|
D.value = g, D.textContent = n[v], u.append(D);
|
|
726
739
|
}
|
|
727
740
|
const m = document.createElement("option");
|
|
728
741
|
m.value = "", m.textContent = "—", m.hidden = !0, u.append(m), u.addEventListener("change", () => {
|
|
729
|
-
u.value && t.exec(
|
|
730
|
-
}),
|
|
731
|
-
u.value =
|
|
742
|
+
u.value && t.exec(Wn(u.value)), t.focus();
|
|
743
|
+
}), s.append(u), o.push((g) => {
|
|
744
|
+
u.value = _n(g) ?? "", u.disabled = t.isSourceMode() || t.isReadOnly();
|
|
732
745
|
});
|
|
733
746
|
continue;
|
|
734
747
|
}
|
|
735
748
|
if (i.available && !i.available(t)) continue;
|
|
736
|
-
const
|
|
737
|
-
|
|
749
|
+
const a = document.createElement("button");
|
|
750
|
+
a.type = "button", a.className = "wds-button-tool", a.innerHTML = i.icon;
|
|
738
751
|
const c = n[i.label];
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
}),
|
|
752
|
+
a.setAttribute("aria-label", c), a.title = i.shortcut ? `${c} (${cr(i.shortcut)})` : c, 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", () => {
|
|
753
|
+
a.disabled || i.run(t, a);
|
|
754
|
+
}), s.append(a), o.push((u) => {
|
|
742
755
|
const m = t.isSourceMode() && !i.inSource || t.isReadOnly() && !i.inSource;
|
|
743
|
-
if (
|
|
756
|
+
if (a.disabled = m || (i.enabled ? !i.enabled(u, t) : !1), i.swatch) {
|
|
744
757
|
const g = m ? null : i.swatch(u);
|
|
745
|
-
g ?
|
|
758
|
+
g ? a.style.setProperty("--wds-swatch", g) : a.style.removeProperty("--wds-swatch");
|
|
746
759
|
}
|
|
747
760
|
if (i.active) {
|
|
748
761
|
const g = !m && i.active(u, t);
|
|
749
|
-
|
|
762
|
+
a.classList.toggle("is-active", g), a.setAttribute("aria-pressed", String(g));
|
|
750
763
|
}
|
|
751
764
|
});
|
|
752
765
|
}
|
|
753
766
|
return r.addEventListener("keydown", (d) => {
|
|
754
767
|
if (d.key !== "ArrowRight" && d.key !== "ArrowLeft" && d.key !== "Home" && d.key !== "End" || d.target.tagName === "SELECT" && (d.key === "Home" || d.key === "End")) return;
|
|
755
|
-
const i = [...r.querySelectorAll("button:not([disabled]), select:not([disabled])")],
|
|
756
|
-
if (
|
|
768
|
+
const i = [...r.querySelectorAll("button:not([disabled]), select:not([disabled])")], a = i.indexOf(document.activeElement);
|
|
769
|
+
if (a < 0) return;
|
|
757
770
|
d.preventDefault();
|
|
758
|
-
const c = d.key === "Home" ? 0 : d.key === "End" ? i.length - 1 : (
|
|
771
|
+
const c = d.key === "Home" ? 0 : d.key === "End" ? i.length - 1 : (a + (d.key === "ArrowRight" ? 1 : -1) + i.length) % i.length;
|
|
759
772
|
i.forEach((u) => u.tabIndex = -1), i[c].tabIndex = 0, i[c].focus();
|
|
760
773
|
}), { element: r, update: (d) => {
|
|
761
|
-
o.forEach((
|
|
774
|
+
o.forEach((a) => a(d));
|
|
762
775
|
const i = [...r.querySelectorAll("button, select")];
|
|
763
|
-
if (!i.some((
|
|
776
|
+
if (!i.some((a) => a.tabIndex === 0 && !a.disabled)) {
|
|
764
777
|
i.forEach((c) => c.tabIndex = -1);
|
|
765
|
-
const
|
|
766
|
-
|
|
778
|
+
const a = i.find((c) => !c.disabled);
|
|
779
|
+
a && (a.tabIndex = 0);
|
|
767
780
|
}
|
|
768
781
|
} };
|
|
769
782
|
}
|
|
770
|
-
function
|
|
783
|
+
function zt(t, e, n, r) {
|
|
771
784
|
const o = document.createElement("span");
|
|
772
785
|
o.className = "wds-image";
|
|
773
|
-
const
|
|
774
|
-
|
|
786
|
+
const s = document.createElement("img");
|
|
787
|
+
s.draggable = !1;
|
|
775
788
|
const l = document.createElement("span");
|
|
776
|
-
l.className = "wds-resize-handle", l.title = r.resizeLabel, l.setAttribute("aria-hidden", "true"), o.append(
|
|
789
|
+
l.className = "wds-resize-handle", l.title = r.resizeLabel, l.setAttribute("aria-hidden", "true"), o.append(s, l);
|
|
777
790
|
const d = () => {
|
|
778
791
|
const c = e();
|
|
779
792
|
c !== void 0 && t.dispatch(t.state.tr.setSelection(he.create(t.state.doc, c)));
|
|
@@ -786,38 +799,38 @@ function Ht(t, e, n, r) {
|
|
|
786
799
|
l.setPointerCapture(c.pointerId);
|
|
787
800
|
} catch {
|
|
788
801
|
}
|
|
789
|
-
const u = c.clientX, m =
|
|
802
|
+
const u = c.clientX, m = s.getBoundingClientRect().width, g = Math.max(40, t.dom.clientWidth - 8);
|
|
790
803
|
let v = m;
|
|
791
|
-
const D = (
|
|
792
|
-
v = Math.round(Math.min(g, Math.max(40, m +
|
|
793
|
-
},
|
|
794
|
-
i = !1, window.removeEventListener("pointermove", D), window.removeEventListener("pointerup",
|
|
795
|
-
const
|
|
796
|
-
if (
|
|
797
|
-
const
|
|
798
|
-
t.dispatch(y.setSelection(he.create(y.doc,
|
|
804
|
+
const D = (T) => {
|
|
805
|
+
v = Math.round(Math.min(g, Math.max(40, m + T.clientX - u))), s.style.width = `${v}px`, s.style.height = "auto", o.dataset.size = `${v}px`;
|
|
806
|
+
}, C = () => {
|
|
807
|
+
i = !1, window.removeEventListener("pointermove", D), window.removeEventListener("pointerup", C), window.removeEventListener("pointercancel", C), delete o.dataset.size, s.style.width = "", s.style.height = "";
|
|
808
|
+
const T = e();
|
|
809
|
+
if (T === void 0 || Math.abs(v - m) < 2) return;
|
|
810
|
+
const O = n(), y = t.state.tr.setNodeMarkup(T, void 0, { ...O.attrs, width: v, height: null });
|
|
811
|
+
t.dispatch(y.setSelection(he.create(y.doc, T)));
|
|
799
812
|
};
|
|
800
|
-
window.addEventListener("pointermove", D), window.addEventListener("pointerup",
|
|
813
|
+
window.addEventListener("pointermove", D), window.addEventListener("pointerup", C), window.addEventListener("pointercancel", C);
|
|
801
814
|
}), o.addEventListener("dblclick", (c) => {
|
|
802
815
|
if (!t.editable) return;
|
|
803
816
|
c.preventDefault(), d();
|
|
804
817
|
const u = e();
|
|
805
818
|
u !== void 0 && r.onEdit(u);
|
|
806
|
-
}), { box: o, img:
|
|
819
|
+
}), { box: o, img: s, handle: l, select: d, render: (c) => {
|
|
807
820
|
const u = Be(c.attrs, !1);
|
|
808
821
|
for (const m of ["src", "alt", "title", "width", "height"])
|
|
809
|
-
u[m] !== void 0 ?
|
|
822
|
+
u[m] !== void 0 ? s.setAttribute(m, u[m]) : s.removeAttribute(m);
|
|
810
823
|
}, isResizing: () => i };
|
|
811
824
|
}
|
|
812
|
-
const
|
|
825
|
+
const Bt = (t, e) => {
|
|
813
826
|
t.classList.remove("wds-align-left", "wds-align-center", "wds-align-right"), e && t.classList.add(`wds-align-${e}`);
|
|
814
827
|
};
|
|
815
|
-
class
|
|
828
|
+
class ur {
|
|
816
829
|
constructor(e, n, r, o) {
|
|
817
|
-
this.node = e, this.parts =
|
|
830
|
+
this.node = e, this.parts = zt(n, r, () => this.node, o), this.dom = this.parts.box, this.render();
|
|
818
831
|
}
|
|
819
832
|
render() {
|
|
820
|
-
this.parts.render(this.node),
|
|
833
|
+
this.parts.render(this.node), Bt(this.dom, this.node.attrs.align);
|
|
821
834
|
}
|
|
822
835
|
update(e) {
|
|
823
836
|
return e.type !== this.node.type ? !1 : (this.node = e, this.render(), !0);
|
|
@@ -829,14 +842,14 @@ class sr {
|
|
|
829
842
|
return !0;
|
|
830
843
|
}
|
|
831
844
|
}
|
|
832
|
-
class
|
|
845
|
+
class hr {
|
|
833
846
|
constructor(e, n, r, o) {
|
|
834
|
-
this.node = e, this.dom = document.createElement("figure"), this.dom.className = "wds-figure", this.parts =
|
|
835
|
-
|
|
847
|
+
this.node = e, this.dom = document.createElement("figure"), this.dom.className = "wds-figure", this.parts = zt(n, r, () => this.node, o), this.parts.box.contentEditable = "false", this.parts.box.addEventListener("mousedown", (s) => {
|
|
848
|
+
s.target === this.parts.handle || s.detail > 1 || (s.preventDefault(), this.parts.select(), n.focus());
|
|
836
849
|
}), this.contentDOM = document.createElement("figcaption"), this.contentDOM.dataset.placeholder = o.captionPlaceholder, this.dom.append(this.parts.box, this.contentDOM), this.render();
|
|
837
850
|
}
|
|
838
851
|
render() {
|
|
839
|
-
this.parts.render(this.node),
|
|
852
|
+
this.parts.render(this.node), Bt(this.dom, this.node.attrs.align), this.dom.classList.toggle("is-empty", this.node.content.size === 0);
|
|
840
853
|
}
|
|
841
854
|
update(e) {
|
|
842
855
|
return e.type !== this.node.type ? !1 : (this.node = e, this.render(), !0);
|
|
@@ -849,14 +862,14 @@ class lr {
|
|
|
849
862
|
}
|
|
850
863
|
}
|
|
851
864
|
let ye = null;
|
|
852
|
-
function
|
|
865
|
+
function Ft() {
|
|
853
866
|
ye?.close();
|
|
854
867
|
}
|
|
855
|
-
function
|
|
856
|
-
|
|
868
|
+
function Ye(t, e, n, r) {
|
|
869
|
+
Ft();
|
|
857
870
|
const o = document.createElement("div");
|
|
858
871
|
o.className = `wds-menu ${n}`, e.append(o);
|
|
859
|
-
const
|
|
872
|
+
const s = () => {
|
|
860
873
|
const u = t.getBoundingClientRect();
|
|
861
874
|
o.style.maxHeight = "";
|
|
862
875
|
const m = o.offsetWidth, g = o.offsetHeight;
|
|
@@ -866,7 +879,7 @@ function Ve(t, e, n, r) {
|
|
|
866
879
|
}, l = (u) => {
|
|
867
880
|
if (u.target instanceof Node && o.contains(u.target)) return;
|
|
868
881
|
const m = t.getBoundingClientRect();
|
|
869
|
-
m.bottom < 0 || m.top > window.innerHeight || !t.isConnected ? c() :
|
|
882
|
+
m.bottom < 0 || m.top > window.innerHeight || !t.isConnected ? c() : s();
|
|
870
883
|
};
|
|
871
884
|
t.setAttribute("aria-expanded", "true");
|
|
872
885
|
const d = (u) => {
|
|
@@ -874,14 +887,14 @@ function Ve(t, e, n, r) {
|
|
|
874
887
|
}, i = (u) => {
|
|
875
888
|
u.key === "Escape" && (u.preventDefault(), u.stopPropagation(), c(!0));
|
|
876
889
|
};
|
|
877
|
-
let
|
|
890
|
+
let a = !1;
|
|
878
891
|
function c(u = !1) {
|
|
879
|
-
|
|
892
|
+
a || (a = !0, o.remove(), t.setAttribute("aria-expanded", "false"), document.removeEventListener("mousedown", d, !0), window.removeEventListener("scroll", l, !0), window.removeEventListener("resize", l), o.removeEventListener("keydown", i), ye?.close === c && (ye = null), u && t.focus());
|
|
880
893
|
}
|
|
881
|
-
return document.addEventListener("mousedown", d, !0), window.addEventListener("scroll", l, !0), window.addEventListener("resize", l), o.addEventListener("keydown", i), ye = { close: c }, { popup: o, place:
|
|
894
|
+
return document.addEventListener("mousedown", d, !0), window.addEventListener("scroll", l, !0), window.addEventListener("resize", l), o.addEventListener("keydown", i), ye = { close: c }, { popup: o, place: s, close: c };
|
|
882
895
|
}
|
|
883
|
-
function
|
|
884
|
-
const { popup: o, place:
|
|
896
|
+
function pr(t, e, n, r) {
|
|
897
|
+
const { popup: o, place: s, close: l } = Ye(t, e, "wds-menu-list");
|
|
885
898
|
o.setAttribute("role", "menu"), o.setAttribute("aria-label", r);
|
|
886
899
|
for (const i of n) {
|
|
887
900
|
if (i === "|") {
|
|
@@ -889,20 +902,20 @@ function cr(t, e, n, r) {
|
|
|
889
902
|
c.className = "wds-menu-sep", c.setAttribute("role", "separator"), o.append(c);
|
|
890
903
|
continue;
|
|
891
904
|
}
|
|
892
|
-
const
|
|
893
|
-
|
|
905
|
+
const a = document.createElement("button");
|
|
906
|
+
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", (c) => c.preventDefault()), a.addEventListener("click", () => {
|
|
894
907
|
l(), i.run();
|
|
895
|
-
}), o.append(
|
|
908
|
+
}), o.append(a);
|
|
896
909
|
}
|
|
897
910
|
const d = () => [...o.querySelectorAll(".wds-menu-item:not(:disabled)")];
|
|
898
911
|
o.addEventListener("keydown", (i) => {
|
|
899
|
-
const
|
|
912
|
+
const a = d(), c = a.indexOf(document.activeElement);
|
|
900
913
|
let u = -1;
|
|
901
|
-
i.key === "ArrowDown" ? u = (c + 1) %
|
|
902
|
-
}),
|
|
914
|
+
i.key === "ArrowDown" ? u = (c + 1) % a.length : i.key === "ArrowUp" ? u = (c - 1 + a.length) % a.length : i.key === "Home" ? u = 0 : i.key === "End" ? u = a.length - 1 : i.key === "Tab" && l(), u >= 0 && (i.preventDefault(), a[u]?.focus());
|
|
915
|
+
}), s(), d()[0]?.focus();
|
|
903
916
|
}
|
|
904
|
-
function
|
|
905
|
-
const { popup: d, place: i, close:
|
|
917
|
+
function mr(t, e, n, r, o) {
|
|
918
|
+
const { popup: d, place: i, close: a } = Ye(t, e, "wds-table-picker");
|
|
906
919
|
d.setAttribute("role", "dialog"), d.setAttribute("aria-label", n);
|
|
907
920
|
const c = document.createElement("div");
|
|
908
921
|
c.className = "wds-picker-grid", c.style.gridTemplateColumns = "repeat(10, 1fr)", c.tabIndex = 0, c.setAttribute("role", "grid"), c.setAttribute("aria-label", n);
|
|
@@ -911,43 +924,43 @@ function dr(t, e, n, r, o) {
|
|
|
911
924
|
const m = [];
|
|
912
925
|
let g = 3, v = 3;
|
|
913
926
|
const D = () => {
|
|
914
|
-
m.forEach((
|
|
927
|
+
m.forEach((C, T) => C.classList.toggle("is-on", Math.floor(T / 10) < g && T % 10 < v)), u.textContent = r(g, v), c.setAttribute("aria-valuetext", u.textContent);
|
|
915
928
|
};
|
|
916
|
-
for (let
|
|
917
|
-
for (let
|
|
918
|
-
const
|
|
919
|
-
|
|
920
|
-
g =
|
|
921
|
-
}),
|
|
922
|
-
|
|
923
|
-
}), m.push(
|
|
929
|
+
for (let C = 0; C < 8; C++)
|
|
930
|
+
for (let T = 0; T < 10; T++) {
|
|
931
|
+
const O = document.createElement("span");
|
|
932
|
+
O.className = "wds-picker-cell", O.addEventListener("mouseenter", () => {
|
|
933
|
+
g = C + 1, v = T + 1, D();
|
|
934
|
+
}), O.addEventListener("mousedown", (y) => y.preventDefault()), O.addEventListener("click", () => {
|
|
935
|
+
a(), o(C + 1, T + 1);
|
|
936
|
+
}), m.push(O), c.append(O);
|
|
924
937
|
}
|
|
925
|
-
c.addEventListener("keydown", (
|
|
926
|
-
const
|
|
927
|
-
C
|
|
938
|
+
c.addEventListener("keydown", (C) => {
|
|
939
|
+
const T = { ArrowRight: [0, 1], ArrowLeft: [0, -1], ArrowDown: [1, 0], ArrowUp: [-1, 0] };
|
|
940
|
+
T[C.key] ? (C.preventDefault(), g = Math.min(8, Math.max(1, g + T[C.key][0])), v = Math.min(10, Math.max(1, v + T[C.key][1])), D()) : C.key === "Enter" || C.key === " " ? (C.preventDefault(), a(), o(g, v)) : C.key === "Tab" && a();
|
|
928
941
|
}), d.append(c, u), D(), i(), c.focus();
|
|
929
942
|
}
|
|
930
|
-
function
|
|
931
|
-
const { popup: r, place: o, close:
|
|
943
|
+
function fr(t, e, n) {
|
|
944
|
+
const { popup: r, place: o, close: s } = Ye(t, e, "wds-color-picker");
|
|
932
945
|
r.setAttribute("role", "dialog"), r.setAttribute("aria-label", n.label);
|
|
933
|
-
const l = (
|
|
934
|
-
|
|
946
|
+
const l = (a) => {
|
|
947
|
+
s(), n.onPick(a);
|
|
935
948
|
}, d = document.createElement("button");
|
|
936
|
-
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", (
|
|
949
|
+
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", () => l(null));
|
|
937
950
|
const i = document.createElement("div");
|
|
938
951
|
i.className = "wds-swatches", i.style.gridTemplateColumns = `repeat(${n.columns}, 1fr)`;
|
|
939
|
-
for (const
|
|
952
|
+
for (const a of n.swatches) {
|
|
940
953
|
const c = document.createElement("button");
|
|
941
|
-
c.type = "button", c.className = "wds-swatch", c.style.background =
|
|
942
|
-
const u =
|
|
943
|
-
c.setAttribute("aria-pressed", String(u)), u && c.classList.add("is-current"), c.addEventListener("mousedown", (m) => m.preventDefault()), c.addEventListener("click", () => l(
|
|
954
|
+
c.type = "button", c.className = "wds-swatch", c.style.background = a.color, c.title = a.label, c.setAttribute("aria-label", a.label);
|
|
955
|
+
const u = a.color === n.current;
|
|
956
|
+
c.setAttribute("aria-pressed", String(u)), u && c.classList.add("is-current"), c.addEventListener("mousedown", (m) => m.preventDefault()), c.addEventListener("click", () => l(a.color)), i.append(c);
|
|
944
957
|
}
|
|
945
|
-
r.append(d, i), r.addEventListener("keydown", (
|
|
958
|
+
r.append(d, i), r.addEventListener("keydown", (a) => {
|
|
946
959
|
const c = [d, ...i.querySelectorAll(".wds-swatch")], u = c.indexOf(document.activeElement);
|
|
947
960
|
if (u < 0) return;
|
|
948
961
|
const m = n.columns;
|
|
949
962
|
let g = -1;
|
|
950
|
-
|
|
963
|
+
a.key === "ArrowRight" ? g = Math.min(c.length - 1, u + 1) : a.key === "ArrowLeft" ? g = Math.max(0, u - 1) : a.key === "ArrowDown" ? g = u === 0 ? 1 : Math.min(c.length - 1, u + m) : a.key === "ArrowUp" ? g = u <= m ? 0 : u - m : a.key === "Tab" && s(), g >= 0 && (a.preventDefault(), c[g].focus());
|
|
951
964
|
}), o(), (i.querySelector(".is-current") ?? i.querySelector(".wds-swatch"))?.focus();
|
|
952
965
|
}
|
|
953
966
|
const ve = {
|
|
@@ -1069,7 +1082,7 @@ const ve = {
|
|
|
1069
1082
|
colorPink: "Pink",
|
|
1070
1083
|
colorSlate: "Slate",
|
|
1071
1084
|
colorGray: "Gray"
|
|
1072
|
-
},
|
|
1085
|
+
}, gr = {
|
|
1073
1086
|
undo: "Geri al",
|
|
1074
1087
|
redo: "Yinele",
|
|
1075
1088
|
blockType: "Metin stili",
|
|
@@ -1188,11 +1201,11 @@ const ve = {
|
|
|
1188
1201
|
colorPink: "Pembe",
|
|
1189
1202
|
colorSlate: "Arduvaz",
|
|
1190
1203
|
colorGray: "Gri"
|
|
1191
|
-
}, ke = { en: ve, tr:
|
|
1192
|
-
function
|
|
1204
|
+
}, ke = { en: ve, tr: gr };
|
|
1205
|
+
function br(t, e) {
|
|
1193
1206
|
ke[t.toLowerCase()] = { ...ve, ...ke[t.toLowerCase()], ...e };
|
|
1194
1207
|
}
|
|
1195
|
-
function
|
|
1208
|
+
function wr(t) {
|
|
1196
1209
|
if (t && typeof t == "object") return { ...ve, ...t };
|
|
1197
1210
|
const e = (t || (typeof navigator < "u" ? navigator.language : "en") || "en").toLowerCase();
|
|
1198
1211
|
return ke[e] ?? ke[e.split("-")[0]] ?? ve;
|
|
@@ -1200,21 +1213,21 @@ function mr(t) {
|
|
|
1200
1213
|
function V(t, e) {
|
|
1201
1214
|
return t.replace(/\{(\w+)\}/g, (n, r) => e[r] ?? n);
|
|
1202
1215
|
}
|
|
1203
|
-
let
|
|
1204
|
-
function
|
|
1205
|
-
const n = `wds-dlg-${++
|
|
1216
|
+
let yr = 0;
|
|
1217
|
+
function wt(t, e) {
|
|
1218
|
+
const n = `wds-dlg-${++yr}`, r = document.createElement("dialog");
|
|
1206
1219
|
r.className = "wds-dialog", r.setAttribute("aria-labelledby", `${n}-title`);
|
|
1207
1220
|
const o = document.createElement("form");
|
|
1208
1221
|
o.method = "dialog", o.noValidate = !0;
|
|
1209
|
-
const
|
|
1210
|
-
|
|
1222
|
+
const s = document.createElement("div");
|
|
1223
|
+
s.className = "wds-dialog-header";
|
|
1211
1224
|
const l = document.createElement("h2");
|
|
1212
1225
|
l.id = `${n}-title`, l.textContent = e.title;
|
|
1213
1226
|
const d = document.createElement("button");
|
|
1214
|
-
d.type = "button", d.className = "wds-icon-button", d.setAttribute("aria-label", e.closeLabel), d.innerHTML =
|
|
1227
|
+
d.type = "button", d.className = "wds-icon-button", d.setAttribute("aria-label", e.closeLabel), d.innerHTML = L.close, s.append(l, d);
|
|
1215
1228
|
const i = document.createElement("div");
|
|
1216
1229
|
i.className = "wds-dialog-body";
|
|
1217
|
-
const
|
|
1230
|
+
const a = /* @__PURE__ */ new Map();
|
|
1218
1231
|
for (const y of e.fields) {
|
|
1219
1232
|
if (y.type === "select") {
|
|
1220
1233
|
const A = document.createElement("select");
|
|
@@ -1224,24 +1237,24 @@ function ft(t, e) {
|
|
|
1224
1237
|
G.value = $.value, G.textContent = $.label, A.append(G);
|
|
1225
1238
|
}
|
|
1226
1239
|
A.value = typeof y.value == "string" ? y.value : "";
|
|
1227
|
-
const
|
|
1228
|
-
|
|
1240
|
+
const I = document.createElement("label");
|
|
1241
|
+
I.className = "wds-label", I.htmlFor = A.id, I.textContent = y.label, i.append(I, A), a.set(y.name, A);
|
|
1229
1242
|
continue;
|
|
1230
1243
|
}
|
|
1231
|
-
const
|
|
1232
|
-
if (
|
|
1233
|
-
|
|
1244
|
+
const x = document.createElement("input");
|
|
1245
|
+
if (x.id = `${n}-${y.name}`, x.name = y.name, y.type === "checkbox") {
|
|
1246
|
+
x.type = "checkbox", x.checked = !!y.value;
|
|
1234
1247
|
const A = document.createElement("label");
|
|
1235
|
-
A.className = "wds-check", A.htmlFor =
|
|
1248
|
+
A.className = "wds-check", A.htmlFor = x.id, A.append(x, document.createTextNode(y.label)), i.append(A);
|
|
1236
1249
|
} else {
|
|
1237
|
-
|
|
1250
|
+
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);
|
|
1238
1251
|
const A = document.createElement("label");
|
|
1239
|
-
if (A.className = "wds-label", A.htmlFor =
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1252
|
+
if (A.className = "wds-label", A.htmlFor = x.id, A.textContent = y.label, i.append(A, x), y.hint) {
|
|
1253
|
+
const I = document.createElement("p");
|
|
1254
|
+
I.className = "wds-hint", I.id = `${x.id}-hint`, I.textContent = y.hint, x.setAttribute("aria-describedby", I.id), i.append(I);
|
|
1242
1255
|
}
|
|
1243
1256
|
}
|
|
1244
|
-
|
|
1257
|
+
a.set(y.name, x);
|
|
1245
1258
|
}
|
|
1246
1259
|
const c = document.createElement("p");
|
|
1247
1260
|
c.className = "wds-dialog-error", c.setAttribute("role", "alert"), c.hidden = !0, i.append(c);
|
|
@@ -1249,7 +1262,7 @@ function ft(t, e) {
|
|
|
1249
1262
|
if (u.className = "wds-dialog-footer", e.extraAction) {
|
|
1250
1263
|
const y = document.createElement("button");
|
|
1251
1264
|
y.type = "button", y.className = "wds-button wds-button-danger", y.textContent = e.extraAction.label, y.addEventListener("click", () => {
|
|
1252
|
-
e.extraAction.onClick(),
|
|
1265
|
+
e.extraAction.onClick(), T();
|
|
1253
1266
|
}), u.append(y);
|
|
1254
1267
|
}
|
|
1255
1268
|
const m = document.createElement("span");
|
|
@@ -1257,53 +1270,53 @@ function ft(t, e) {
|
|
|
1257
1270
|
const g = document.createElement("button");
|
|
1258
1271
|
g.type = "button", g.className = "wds-button", g.textContent = e.cancelLabel;
|
|
1259
1272
|
const v = document.createElement("button");
|
|
1260
|
-
v.type = "submit", v.className = "wds-button wds-button-primary", v.textContent = e.submitLabel, u.append(m, g, v), o.append(
|
|
1273
|
+
v.type = "submit", v.className = "wds-button wds-button-primary", v.textContent = e.submitLabel, u.append(m, g, v), o.append(s, i, u), r.append(o), t.append(r);
|
|
1261
1274
|
const D = () => {
|
|
1262
1275
|
const y = {};
|
|
1263
|
-
return
|
|
1276
|
+
return a.forEach((x, A) => y[A] = x instanceof HTMLInputElement && x.type === "checkbox" ? x.checked : x.value), y;
|
|
1264
1277
|
};
|
|
1265
|
-
let
|
|
1266
|
-
function
|
|
1267
|
-
|
|
1278
|
+
let C = !1;
|
|
1279
|
+
function T() {
|
|
1280
|
+
C || (C = !0, r.open && r.close(), r.remove(), e.onClose?.());
|
|
1268
1281
|
}
|
|
1269
1282
|
o.addEventListener("submit", (y) => {
|
|
1270
1283
|
y.preventDefault();
|
|
1271
|
-
const
|
|
1284
|
+
const x = D(), A = e.validate?.(x) ?? null;
|
|
1272
1285
|
if (A) {
|
|
1273
|
-
c.textContent = A, c.hidden = !1, [...
|
|
1286
|
+
c.textContent = A, c.hidden = !1, [...a.values()][0]?.focus();
|
|
1274
1287
|
return;
|
|
1275
1288
|
}
|
|
1276
|
-
e.onSubmit(
|
|
1277
|
-
}), g.addEventListener("click",
|
|
1278
|
-
y.target === r &&
|
|
1289
|
+
e.onSubmit(x), T();
|
|
1290
|
+
}), g.addEventListener("click", T), d.addEventListener("click", T), r.addEventListener("close", T), r.addEventListener("click", (y) => {
|
|
1291
|
+
y.target === r && T();
|
|
1279
1292
|
}), r.showModal();
|
|
1280
|
-
const
|
|
1281
|
-
return
|
|
1293
|
+
const O = [...a.values()].find((y) => y instanceof HTMLInputElement && y.type !== "checkbox");
|
|
1294
|
+
return O?.focus(), O?.select(), T;
|
|
1282
1295
|
}
|
|
1283
|
-
const K = (t) => typeof t == "string" && t.trim() ? t : void 0,
|
|
1284
|
-
function
|
|
1296
|
+
const K = (t) => typeof t == "string" && t.trim() ? t : void 0, He = (t) => typeof t == "number" && Number.isFinite(t) && t >= 0 ? t : void 0;
|
|
1297
|
+
function Ut(t) {
|
|
1285
1298
|
if (!t || typeof t != "object") return null;
|
|
1286
1299
|
const e = t, n = q(K(e.url)), r = K(e.name);
|
|
1287
1300
|
if (!n || !r) return null;
|
|
1288
|
-
const o = { url: n, name: r },
|
|
1289
|
-
|
|
1301
|
+
const o = { url: n, name: r }, s = He(e.size), l = He(e.width), d = He(e.height);
|
|
1302
|
+
s !== void 0 && (o.size = s), l !== void 0 && (o.width = l), d !== void 0 && (o.height = d), K(e.type) && (o.type = e.type.toLowerCase());
|
|
1290
1303
|
const i = q(K(e.thumb));
|
|
1291
1304
|
return i && (o.thumb = i), K(e.modified) && !Number.isNaN(Date.parse(e.modified)) && (o.modified = e.modified), o;
|
|
1292
1305
|
}
|
|
1293
|
-
function
|
|
1294
|
-
const n = Array.isArray(t) ? { files: t } : t && typeof t == "object" ? t : {}, r = (Array.isArray(n.files) ? n.files : []).map(
|
|
1306
|
+
function vr(t, e = "/") {
|
|
1307
|
+
const n = Array.isArray(t) ? { files: t } : t && typeof t == "object" ? t : {}, r = (Array.isArray(n.files) ? n.files : []).map(Ut).filter((s) => !!s), o = (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: je(s.path) }));
|
|
1295
1308
|
return {
|
|
1296
|
-
path:
|
|
1309
|
+
path: je(K(n.path) ?? e),
|
|
1297
1310
|
folders: o,
|
|
1298
1311
|
files: r,
|
|
1299
1312
|
hasMore: n.hasMore === !0,
|
|
1300
1313
|
serverSearch: typeof n.q == "string"
|
|
1301
1314
|
};
|
|
1302
1315
|
}
|
|
1303
|
-
function
|
|
1316
|
+
function je(t) {
|
|
1304
1317
|
return "/" + t.split("/").filter((n) => n && n !== "." && n !== "..").join("/");
|
|
1305
1318
|
}
|
|
1306
|
-
const
|
|
1319
|
+
const kr = /\.(jpe?g|png|gif|webp|avif|svg|bmp|ico)$/i, Mr = {
|
|
1307
1320
|
jpg: "image/jpeg",
|
|
1308
1321
|
jpeg: "image/jpeg",
|
|
1309
1322
|
png: "image/png",
|
|
@@ -1323,23 +1336,23 @@ const br = /\.(jpe?g|png|gif|webp|avif|svg|bmp|ico)$/i, wr = {
|
|
|
1323
1336
|
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
1324
1337
|
mp4: "video/mp4",
|
|
1325
1338
|
mp3: "audio/mpeg"
|
|
1326
|
-
},
|
|
1327
|
-
function
|
|
1328
|
-
return t.type ||
|
|
1339
|
+
}, Pt = (t) => (/\.([a-z0-9]+)$/i.exec(t)?.[1] ?? "").toLowerCase();
|
|
1340
|
+
function _t(t) {
|
|
1341
|
+
return t.type || Mr[Pt(t.name)] || "";
|
|
1329
1342
|
}
|
|
1330
1343
|
function ue(t) {
|
|
1331
|
-
const e =
|
|
1332
|
-
return e ? e.startsWith("image/") :
|
|
1344
|
+
const e = _t(t);
|
|
1345
|
+
return e ? e.startsWith("image/") : kr.test(t.url ?? t.name);
|
|
1333
1346
|
}
|
|
1334
|
-
function
|
|
1347
|
+
function yt(t, e) {
|
|
1335
1348
|
if (!e || !e.trim()) return !0;
|
|
1336
|
-
const n =
|
|
1349
|
+
const n = _t(t), r = "." + Pt(t.name);
|
|
1337
1350
|
return e.split(",").some((o) => {
|
|
1338
|
-
const
|
|
1339
|
-
return
|
|
1351
|
+
const s = o.trim().toLowerCase();
|
|
1352
|
+
return s ? s.startsWith(".") ? r === s : s.endsWith("/*") ? n.startsWith(s.slice(0, -1)) : n === s : !1;
|
|
1340
1353
|
});
|
|
1341
1354
|
}
|
|
1342
|
-
function
|
|
1355
|
+
function vt(t) {
|
|
1343
1356
|
if (t === void 0) return "";
|
|
1344
1357
|
if (t < 1024) return `${t} B`;
|
|
1345
1358
|
const e = ["KB", "MB", "GB"];
|
|
@@ -1350,7 +1363,7 @@ function bt(t) {
|
|
|
1350
1363
|
}
|
|
1351
1364
|
class P extends Error {
|
|
1352
1365
|
}
|
|
1353
|
-
async function
|
|
1366
|
+
async function kt(t) {
|
|
1354
1367
|
try {
|
|
1355
1368
|
const e = await t.clone().json();
|
|
1356
1369
|
if (e && typeof e.error == "string") return e.error;
|
|
@@ -1358,12 +1371,12 @@ async function wt(t) {
|
|
|
1358
1371
|
}
|
|
1359
1372
|
return `HTTP ${t.status}`;
|
|
1360
1373
|
}
|
|
1361
|
-
function
|
|
1374
|
+
function Lr(t, e) {
|
|
1362
1375
|
const n = new URL(t, document.baseURI);
|
|
1363
1376
|
for (const [r, o] of Object.entries(e)) o && n.searchParams.set(r, o);
|
|
1364
1377
|
return n.href;
|
|
1365
1378
|
}
|
|
1366
|
-
class
|
|
1379
|
+
class xr {
|
|
1367
1380
|
constructor(e) {
|
|
1368
1381
|
this.options = e;
|
|
1369
1382
|
}
|
|
@@ -1381,44 +1394,44 @@ class vr {
|
|
|
1381
1394
|
};
|
|
1382
1395
|
}
|
|
1383
1396
|
async list(e, n, r, o) {
|
|
1384
|
-
const
|
|
1397
|
+
const s = Lr(this.options.listUrl, { path: e, q: n, page: r > 1 ? String(r) : "" });
|
|
1385
1398
|
let l;
|
|
1386
1399
|
try {
|
|
1387
|
-
l = await fetch(
|
|
1400
|
+
l = await fetch(s, { ...this.init(), signal: o });
|
|
1388
1401
|
} catch (i) {
|
|
1389
1402
|
throw i.name === "AbortError" ? i : new P(i.message || "Network error");
|
|
1390
1403
|
}
|
|
1391
|
-
if (!l.ok) throw new P(await
|
|
1404
|
+
if (!l.ok) throw new P(await kt(l));
|
|
1392
1405
|
let d;
|
|
1393
1406
|
try {
|
|
1394
1407
|
d = await l.json();
|
|
1395
1408
|
} catch {
|
|
1396
1409
|
throw new P("Invalid JSON");
|
|
1397
1410
|
}
|
|
1398
|
-
return
|
|
1411
|
+
return vr(d, e);
|
|
1399
1412
|
}
|
|
1400
1413
|
/** Multipart upload with progress (XMLHttpRequest, because fetch has no upload progress). */
|
|
1401
1414
|
upload(e, n, r) {
|
|
1402
|
-
const { uploadUrl: o, headers:
|
|
1415
|
+
const { uploadUrl: o, headers: s = {}, withCredentials: l } = this.options;
|
|
1403
1416
|
return o ? new Promise((d, i) => {
|
|
1404
|
-
const
|
|
1405
|
-
|
|
1406
|
-
for (const [u, m] of Object.entries(
|
|
1407
|
-
|
|
1417
|
+
const a = new XMLHttpRequest();
|
|
1418
|
+
a.open("POST", new URL(o, document.baseURI).href), a.withCredentials = !!l, a.setRequestHeader("Accept", "application/json");
|
|
1419
|
+
for (const [u, m] of Object.entries(s)) a.setRequestHeader(u, m);
|
|
1420
|
+
a.upload.onprogress = (u) => u.lengthComputable && r?.(u.loaded / u.total), a.onerror = () => i(new P("Network error")), a.onload = () => {
|
|
1408
1421
|
let u = null;
|
|
1409
1422
|
try {
|
|
1410
|
-
u = JSON.parse(
|
|
1423
|
+
u = JSON.parse(a.responseText);
|
|
1411
1424
|
} catch {
|
|
1412
1425
|
}
|
|
1413
|
-
if (
|
|
1414
|
-
i(new P(typeof u?.error == "string" ? u.error : `HTTP ${
|
|
1426
|
+
if (a.status < 200 || a.status >= 300) {
|
|
1427
|
+
i(new P(typeof u?.error == "string" ? u.error : `HTTP ${a.status}`));
|
|
1415
1428
|
return;
|
|
1416
1429
|
}
|
|
1417
|
-
const m =
|
|
1430
|
+
const m = Ut(u?.file);
|
|
1418
1431
|
m ? d(m) : i(new P("Invalid upload response"));
|
|
1419
1432
|
};
|
|
1420
1433
|
const c = new FormData();
|
|
1421
|
-
c.append("file", e, e.name), c.append("path", n),
|
|
1434
|
+
c.append("file", e, e.name), c.append("path", n), a.send(c);
|
|
1422
1435
|
}) : Promise.reject(new P("Upload is not configured"));
|
|
1423
1436
|
}
|
|
1424
1437
|
async remove(e) {
|
|
@@ -1433,38 +1446,38 @@ class vr {
|
|
|
1433
1446
|
} catch (o) {
|
|
1434
1447
|
throw new P(o.message || "Network error");
|
|
1435
1448
|
}
|
|
1436
|
-
if (!r.ok) throw new P(await
|
|
1449
|
+
if (!r.ok) throw new P(await kt(r));
|
|
1437
1450
|
}
|
|
1438
1451
|
}
|
|
1439
1452
|
const b = (t, e, n) => {
|
|
1440
1453
|
const r = document.createElement(t);
|
|
1441
1454
|
return e && (r.className = e), n !== void 0 && (r.textContent = n), r;
|
|
1442
|
-
},
|
|
1455
|
+
}, Oe = (t, e, n = "wds-icon-button") => {
|
|
1443
1456
|
const r = b("button", n);
|
|
1444
1457
|
return r.type = "button", r.innerHTML = t, r.setAttribute("aria-label", e), r.title = e, r;
|
|
1445
|
-
},
|
|
1458
|
+
}, Er = [
|
|
1446
1459
|
["", "alignNone"],
|
|
1447
1460
|
["left", "alignLeftShort"],
|
|
1448
1461
|
["center", "alignCenterShort"],
|
|
1449
1462
|
["right", "alignRightShort"]
|
|
1450
1463
|
];
|
|
1451
|
-
class
|
|
1464
|
+
class Sr {
|
|
1452
1465
|
constructor(e, n, r) {
|
|
1453
1466
|
this.host = e, this.api = n, this.t = r, this.path = "/", this.view = "grid", this.sort = "newest";
|
|
1454
1467
|
}
|
|
1455
1468
|
open(e) {
|
|
1456
1469
|
const n = this.t, r = e.accept ?? "";
|
|
1457
|
-
let o = [],
|
|
1470
|
+
let o = [], s = [], l = 1, d = !1, i = !1, a = "", c = null, u = null, m = 0, g = !1;
|
|
1458
1471
|
const v = b("dialog", "wds-dialog wds-fm");
|
|
1459
1472
|
v.setAttribute("aria-labelledby", "wds-fm-title");
|
|
1460
|
-
const D = b("div", "wds-dialog-header"),
|
|
1461
|
-
|
|
1462
|
-
const
|
|
1463
|
-
D.append(
|
|
1464
|
-
const
|
|
1473
|
+
const D = b("div", "wds-dialog-header"), C = b("h2", void 0, n.fmTitle);
|
|
1474
|
+
C.id = "wds-fm-title";
|
|
1475
|
+
const T = Oe(L.close, n.close);
|
|
1476
|
+
D.append(C, T);
|
|
1477
|
+
const O = b("div", "wds-fm-bar"), y = b("nav", "wds-fm-crumbs");
|
|
1465
1478
|
y.setAttribute("aria-label", n.fmBreadcrumb);
|
|
1466
|
-
const
|
|
1467
|
-
|
|
1479
|
+
const x = b("input", "wds-input wds-fm-search");
|
|
1480
|
+
x.type = "search", x.placeholder = n.fmSearch, x.setAttribute("aria-label", n.fmSearch);
|
|
1468
1481
|
const A = b("select", "wds-input wds-fm-sort");
|
|
1469
1482
|
A.setAttribute("aria-label", n.fmSort), A.title = n.fmSort;
|
|
1470
1483
|
for (const [h, f] of [["newest", "fmSortNewest"], ["name", "fmSortName"], ["largest", "fmSortLargest"]]) {
|
|
@@ -1472,40 +1485,40 @@ class Mr {
|
|
|
1472
1485
|
M.value = h, A.append(M);
|
|
1473
1486
|
}
|
|
1474
1487
|
A.value = this.sort;
|
|
1475
|
-
const
|
|
1488
|
+
const I = Oe(this.view === "grid" ? L.list : L.grid, this.view === "grid" ? n.fmList : n.fmGrid), $ = b("input");
|
|
1476
1489
|
$.type = "file", $.multiple = !0, $.hidden = !0, r && ($.accept = r);
|
|
1477
1490
|
const G = b("button", "wds-button wds-button-primary wds-fm-upload");
|
|
1478
|
-
G.type = "button", G.innerHTML = `${
|
|
1491
|
+
G.type = "button", G.innerHTML = `${L.upload}<span>${$e(n.fmUpload)}</span>`;
|
|
1479
1492
|
const Me = b("div", "wds-fm-tools");
|
|
1480
|
-
Me.append(
|
|
1481
|
-
const
|
|
1493
|
+
Me.append(x, A, I), this.api.canUpload && Me.append(G, $), O.append(y, Me);
|
|
1494
|
+
const Je = b("div", "wds-fm-main"), W = b("div", "wds-fm-browser"), Le = b("div", "wds-fm-uploads"), B = b("ul", `wds-fm-items is-${this.view}`);
|
|
1482
1495
|
B.setAttribute("aria-label", n.fmTitle);
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1496
|
+
const N = b("p", "wds-fm-status");
|
|
1497
|
+
N.setAttribute("role", "status");
|
|
1485
1498
|
const Z = b("button", "wds-button", n.fmRetry);
|
|
1486
1499
|
Z.type = "button", Z.hidden = !0;
|
|
1487
1500
|
const ee = b("button", "wds-button wds-fm-more", n.fmLoadMore);
|
|
1488
1501
|
ee.type = "button", ee.hidden = !0;
|
|
1489
|
-
const
|
|
1490
|
-
|
|
1502
|
+
const Xe = b("div", "wds-fm-drop", n.fmDrop);
|
|
1503
|
+
Xe.setAttribute("aria-hidden", "true"), W.append(Le, B, N, Z, ee, Xe);
|
|
1491
1504
|
const F = b("aside", "wds-fm-details");
|
|
1492
|
-
F.setAttribute("aria-label", n.imageEdit),
|
|
1493
|
-
const
|
|
1505
|
+
F.setAttribute("aria-label", n.imageEdit), Je.append(W, F);
|
|
1506
|
+
const xe = b("div", "wds-dialog-footer");
|
|
1494
1507
|
if (e.onFromUrl) {
|
|
1495
1508
|
const h = b("button", "wds-button wds-fm-fromurl");
|
|
1496
|
-
h.type = "button", h.innerHTML = `${
|
|
1509
|
+
h.type = "button", h.innerHTML = `${L.globe}<span>${$e(n.fmFromUrl)}</span>`, h.addEventListener("click", () => {
|
|
1497
1510
|
X(), e.onFromUrl();
|
|
1498
|
-
}),
|
|
1511
|
+
}), xe.append(h);
|
|
1499
1512
|
}
|
|
1500
|
-
const
|
|
1501
|
-
|
|
1513
|
+
const Ee = b("button", "wds-button", n.cancel);
|
|
1514
|
+
Ee.type = "button";
|
|
1502
1515
|
const ie = b("button", "wds-button wds-button-primary", n.insert);
|
|
1503
|
-
ie.type = "button", ie.disabled = !0,
|
|
1516
|
+
ie.type = "button", ie.disabled = !0, xe.append(b("span", "wds-spacer"), Ee, ie), v.append(D, O, Je, xe), this.host.append(v);
|
|
1504
1517
|
let ae = null, U = null, se = null, Y = null, le = null;
|
|
1505
1518
|
const me = (h, f, M, w) => {
|
|
1506
1519
|
f.id = M;
|
|
1507
|
-
const
|
|
1508
|
-
if (
|
|
1520
|
+
const S = b("label", "wds-label", h);
|
|
1521
|
+
if (S.htmlFor = M, F.append(S, f), w) {
|
|
1509
1522
|
const k = b("p", "wds-hint", w);
|
|
1510
1523
|
k.id = `${M}-hint`, f.setAttribute("aria-describedby", k.id), F.append(k);
|
|
1511
1524
|
}
|
|
@@ -1514,23 +1527,23 @@ class Mr {
|
|
|
1514
1527
|
F.append(b("p", "wds-fm-placeholder", n.fmNoSelection));
|
|
1515
1528
|
return;
|
|
1516
1529
|
}
|
|
1517
|
-
const h = c, f = b("div", "wds-fm-preview"), M = b("p", "wds-fm-filename", h.name), w = b("p", "wds-fm-facts"),
|
|
1530
|
+
const h = c, f = b("div", "wds-fm-preview"), M = b("p", "wds-fm-filename", h.name), w = b("p", "wds-fm-facts"), S = () => [
|
|
1518
1531
|
h.width && h.height ? `${h.width} × ${h.height}` : "",
|
|
1519
|
-
|
|
1532
|
+
vt(h.size),
|
|
1520
1533
|
h.modified ? new Date(h.modified).toLocaleDateString() : ""
|
|
1521
1534
|
].filter(Boolean).join(" · ");
|
|
1522
|
-
if (w.textContent =
|
|
1535
|
+
if (w.textContent = S(), ue(h)) {
|
|
1523
1536
|
const k = b("img");
|
|
1524
1537
|
k.alt = "", !h.thumb && !(h.width && h.height) && k.addEventListener("load", () => {
|
|
1525
|
-
!k.naturalWidth || c !== h || (h.width = k.naturalWidth, h.height = k.naturalHeight, w.textContent =
|
|
1538
|
+
!k.naturalWidth || c !== h || (h.width = k.naturalWidth, h.height = k.naturalHeight, w.textContent = S(), U && !U.placeholder && (U.placeholder = String(h.width)));
|
|
1526
1539
|
}, { once: !0 }), k.src = h.thumb ?? h.url, f.append(k);
|
|
1527
1540
|
} else
|
|
1528
|
-
f.innerHTML =
|
|
1541
|
+
f.innerHTML = L.file;
|
|
1529
1542
|
if (F.append(f, M, w), e.mode === "image" && ue(h)) {
|
|
1530
1543
|
ae = b("input", "wds-input"), ae.value = h.name.replace(/\.[a-z0-9]+$/i, "").replace(/[-_]+/g, " "), me(n.imageAlt, ae, "wds-fm-alt", n.imageAltHint), U = b("input", "wds-input"), U.inputMode = "numeric", U.placeholder = h.width ? String(h.width) : "", me(n.imageWidth, U, "wds-fm-width"), se = b("select", "wds-input");
|
|
1531
|
-
for (const [
|
|
1532
|
-
const te = b("option", void 0, n[
|
|
1533
|
-
te.value =
|
|
1544
|
+
for (const [R, z] of Er) {
|
|
1545
|
+
const te = b("option", void 0, n[z]);
|
|
1546
|
+
te.value = R, se.append(te);
|
|
1534
1547
|
}
|
|
1535
1548
|
me(n.imageAlign, se, "wds-fm-align"), Y = b("input"), Y.type = "checkbox", Y.id = "wds-fm-caption";
|
|
1536
1549
|
const k = b("label", "wds-check");
|
|
@@ -1539,105 +1552,105 @@ class Mr {
|
|
|
1539
1552
|
le = b("input", "wds-input"), le.value = h.name, me(n.fmLinkText, le, "wds-fm-text");
|
|
1540
1553
|
if (this.api.canDelete) {
|
|
1541
1554
|
const k = b("button", "wds-button wds-button-danger wds-fm-delete");
|
|
1542
|
-
k.type = "button", k.innerHTML = `${
|
|
1555
|
+
k.type = "button", k.innerHTML = `${L.trash}<span>${$e(n.fmDelete)}</span>`, k.addEventListener("click", () => qt(h)), F.append(k);
|
|
1543
1556
|
}
|
|
1544
|
-
},
|
|
1545
|
-
const h =
|
|
1546
|
-
return this.sort === "name" ? f.sort((w,
|
|
1547
|
-
},
|
|
1557
|
+
}, Wt = () => {
|
|
1558
|
+
const h = a.trim().toLocaleLowerCase(), f = o.filter((w) => yt(w, r) && (i || !h || w.name.toLocaleLowerCase().includes(h))), M = (w) => w.modified ? Date.parse(w.modified) : -1 / 0;
|
|
1559
|
+
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;
|
|
1560
|
+
}, Se = () => {
|
|
1548
1561
|
y.replaceChildren();
|
|
1549
1562
|
const h = this.path.split("/").filter(Boolean), f = [[n.fmRoot, "/"], ...h.map((M, w) => [M, "/" + h.slice(0, w + 1).join("/")])];
|
|
1550
|
-
f.forEach(([M, w],
|
|
1551
|
-
if (
|
|
1563
|
+
f.forEach(([M, w], S) => {
|
|
1564
|
+
if (S && y.append(b("span", "wds-fm-sep", "/")), S === f.length - 1) {
|
|
1552
1565
|
const k = b("span", "wds-fm-crumb is-current", M);
|
|
1553
1566
|
k.setAttribute("aria-current", "location"), y.append(k);
|
|
1554
1567
|
} else {
|
|
1555
1568
|
const k = b("button", "wds-fm-crumb", M);
|
|
1556
|
-
k.type = "button", k.addEventListener("click", () =>
|
|
1569
|
+
k.type = "button", k.addEventListener("click", () => et(w)), y.append(k);
|
|
1557
1570
|
}
|
|
1558
1571
|
});
|
|
1559
1572
|
}, J = () => {
|
|
1560
1573
|
B.className = `wds-fm-items is-${this.view}`, B.replaceChildren();
|
|
1561
|
-
const h = !
|
|
1574
|
+
const h = !a.trim();
|
|
1562
1575
|
if (h)
|
|
1563
|
-
for (const w of
|
|
1564
|
-
const
|
|
1565
|
-
|
|
1576
|
+
for (const w of s) {
|
|
1577
|
+
const S = Ze(L.folder, w.name, n.fmFolder, !0);
|
|
1578
|
+
S.addEventListener("click", () => et(w.path)), B.append(Qe(S));
|
|
1566
1579
|
}
|
|
1567
|
-
const f =
|
|
1580
|
+
const f = Wt();
|
|
1568
1581
|
for (const w of f) {
|
|
1569
|
-
const
|
|
1570
|
-
if (
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1582
|
+
const S = ue(w) ? w.thumb ?? w.url : null, k = Ze(S ? "" : L.file, w.name, [vt(w.size), w.width && w.height ? `${w.width}×${w.height}` : ""].filter(Boolean).join(" · "), !1);
|
|
1583
|
+
if (S) {
|
|
1584
|
+
const z = b("img");
|
|
1585
|
+
z.loading = "lazy", z.decoding = "async", z.alt = "", z.src = S, k.querySelector(".wds-fm-thumb").append(z);
|
|
1573
1586
|
}
|
|
1574
1587
|
k.dataset.url = w.url;
|
|
1575
|
-
const
|
|
1576
|
-
k.classList.toggle("is-selected",
|
|
1577
|
-
Ae(w),
|
|
1578
|
-
}), B.append(
|
|
1588
|
+
const R = c?.url === w.url;
|
|
1589
|
+
k.classList.toggle("is-selected", R), k.setAttribute("aria-pressed", String(R)), k.addEventListener("click", () => Ae(w)), k.addEventListener("dblclick", () => {
|
|
1590
|
+
Ae(w), Te();
|
|
1591
|
+
}), B.append(Qe(k));
|
|
1579
1592
|
}
|
|
1580
|
-
const M = !f.length && !(h &&
|
|
1581
|
-
!
|
|
1582
|
-
},
|
|
1593
|
+
const M = !f.length && !(h && s.length);
|
|
1594
|
+
!N.dataset.busy && !N.dataset.error && (N.textContent = M ? a.trim() ? n.fmNoResults : n.fmEmpty : ""), ee.hidden = !d || !!N.dataset.busy;
|
|
1595
|
+
}, Qe = (h) => {
|
|
1583
1596
|
const f = b("li");
|
|
1584
1597
|
return f.append(h), f;
|
|
1585
|
-
},
|
|
1586
|
-
const
|
|
1587
|
-
|
|
1598
|
+
}, Ze = (h, f, M, w) => {
|
|
1599
|
+
const S = b("button", `wds-fm-item${w ? " is-folder" : ""}`);
|
|
1600
|
+
S.type = "button";
|
|
1588
1601
|
const k = b("span", "wds-fm-thumb");
|
|
1589
1602
|
k.innerHTML = h;
|
|
1590
|
-
const
|
|
1591
|
-
|
|
1592
|
-
const
|
|
1593
|
-
return
|
|
1603
|
+
const R = b("span", "wds-fm-name", f);
|
|
1604
|
+
R.title = f;
|
|
1605
|
+
const z = b("span", "wds-fm-meta", M);
|
|
1606
|
+
return S.append(k, R, z), S;
|
|
1594
1607
|
}, Ae = (h) => {
|
|
1595
1608
|
c = h, B.querySelectorAll(".wds-fm-item[data-url]").forEach((f) => {
|
|
1596
1609
|
const M = f.dataset.url === h.url;
|
|
1597
1610
|
f.classList.toggle("is-selected", M), f.setAttribute("aria-pressed", String(M));
|
|
1598
1611
|
}), fe();
|
|
1599
1612
|
}, ce = async (h) => {
|
|
1600
|
-
u?.abort(), u = new AbortController(), h && (l = 1, o = [],
|
|
1613
|
+
u?.abort(), u = new AbortController(), h && (l = 1, o = [], s = []), N.dataset.busy = "1", delete N.dataset.error, N.textContent = n.fmLoading, Z.hidden = !0, ee.hidden = !0, h && J();
|
|
1601
1614
|
try {
|
|
1602
|
-
const f = await this.api.list(this.path,
|
|
1615
|
+
const f = await this.api.list(this.path, a.trim(), l, u.signal);
|
|
1603
1616
|
if (g) return;
|
|
1604
|
-
this.path = f.path, i = f.serverSearch, d = f.hasMore,
|
|
1617
|
+
this.path = f.path, i = f.serverSearch, d = f.hasMore, s = h ? f.folders : s;
|
|
1605
1618
|
const M = new Set(o.map((w) => w.url));
|
|
1606
|
-
o = [...o, ...f.files.filter((w) => !M.has(w.url))], delete
|
|
1619
|
+
o = [...o, ...f.files.filter((w) => !M.has(w.url))], delete N.dataset.busy, N.textContent = "", Se(), J();
|
|
1607
1620
|
} catch (f) {
|
|
1608
1621
|
if (f.name === "AbortError" || g) return;
|
|
1609
|
-
delete
|
|
1622
|
+
delete N.dataset.busy, N.dataset.error = "1", N.textContent = V(n.fmListFailed, { error: f.message }), N.setAttribute("role", "alert"), Z.hidden = !1;
|
|
1610
1623
|
}
|
|
1611
|
-
},
|
|
1612
|
-
this.path =
|
|
1613
|
-
},
|
|
1624
|
+
}, et = (h) => {
|
|
1625
|
+
this.path = je(h), a = "", x.value = "", c = null, fe(), Se(), ce(!0).then(() => B.querySelector(".wds-fm-item")?.focus());
|
|
1626
|
+
}, tt = (h) => {
|
|
1614
1627
|
for (const f of Array.from(h)) {
|
|
1615
1628
|
const M = b("div", "wds-fm-upload-row"), w = b("span", "wds-fm-upload-name", V(n.fmUploading, { name: f.name }));
|
|
1616
|
-
if (!
|
|
1617
|
-
|
|
1629
|
+
if (!yt(f, r)) {
|
|
1630
|
+
nt(M, V(n.fmNotAllowed, { name: f.name })), Le.append(M);
|
|
1618
1631
|
continue;
|
|
1619
1632
|
}
|
|
1620
|
-
const
|
|
1621
|
-
|
|
1622
|
-
g || (M.remove(), o = [k, ...o.filter((
|
|
1633
|
+
const S = b("progress");
|
|
1634
|
+
S.max = 1, S.value = 0, M.append(w, S), Le.append(M), this.api.upload(f, this.path, (k) => S.value = k).then((k) => {
|
|
1635
|
+
g || (M.remove(), o = [k, ...o.filter((R) => R.url !== k.url)], J(), Ae(k), e.onUpload?.(k));
|
|
1623
1636
|
}).catch((k) => {
|
|
1624
|
-
g || (M.replaceChildren(),
|
|
1637
|
+
g || (M.replaceChildren(), nt(M, V(n.fmUploadFailed, { name: f.name, error: k.message })));
|
|
1625
1638
|
});
|
|
1626
1639
|
}
|
|
1627
|
-
},
|
|
1640
|
+
}, nt = (h, f) => {
|
|
1628
1641
|
h.classList.add("is-error");
|
|
1629
1642
|
const M = b("span", "wds-fm-upload-name", f);
|
|
1630
1643
|
M.setAttribute("role", "alert");
|
|
1631
|
-
const w =
|
|
1644
|
+
const w = Oe(L.close, n.close);
|
|
1632
1645
|
w.addEventListener("click", () => h.remove()), h.append(M, w);
|
|
1633
|
-
},
|
|
1646
|
+
}, qt = async (h) => {
|
|
1634
1647
|
if (window.confirm(V(n.fmDeleteConfirm, { name: h.name })))
|
|
1635
1648
|
try {
|
|
1636
1649
|
await this.api.remove(h.url), o = o.filter((f) => f.url !== h.url), c = null, fe(), J();
|
|
1637
1650
|
} catch (f) {
|
|
1638
|
-
|
|
1651
|
+
N.dataset.error = "1", N.setAttribute("role", "alert"), N.textContent = V(n.fmDeleteFailed, { error: f.message });
|
|
1639
1652
|
}
|
|
1640
|
-
},
|
|
1653
|
+
}, Te = () => {
|
|
1641
1654
|
if (!c) return;
|
|
1642
1655
|
const h = U ? parseInt(U.value, 10) : NaN;
|
|
1643
1656
|
e.onPick({
|
|
@@ -1652,22 +1665,22 @@ class Mr {
|
|
|
1652
1665
|
function X() {
|
|
1653
1666
|
g || (g = !0, u?.abort(), window.clearTimeout(m), v.open && v.close(), v.remove(), e.onClose?.());
|
|
1654
1667
|
}
|
|
1655
|
-
if (
|
|
1656
|
-
|
|
1668
|
+
if (T.addEventListener("click", X), Ee.addEventListener("click", X), ie.addEventListener("click", Te), v.addEventListener("close", X), v.addEventListener("click", (h) => h.target === v && X()), Z.addEventListener("click", () => {
|
|
1669
|
+
N.setAttribute("role", "status"), ce(!0);
|
|
1657
1670
|
}), ee.addEventListener("click", () => {
|
|
1658
1671
|
l++, ce(!1);
|
|
1659
1672
|
}), A.addEventListener("change", () => {
|
|
1660
1673
|
this.sort = A.value, J();
|
|
1661
|
-
}),
|
|
1662
|
-
this.view = this.view === "grid" ? "list" : "grid",
|
|
1674
|
+
}), I.addEventListener("click", () => {
|
|
1675
|
+
this.view = this.view === "grid" ? "list" : "grid", I.innerHTML = this.view === "grid" ? L.list : L.grid;
|
|
1663
1676
|
const h = this.view === "grid" ? n.fmList : n.fmGrid;
|
|
1664
|
-
|
|
1665
|
-
}),
|
|
1677
|
+
I.setAttribute("aria-label", h), I.title = h, J();
|
|
1678
|
+
}), x.addEventListener("input", () => {
|
|
1666
1679
|
window.clearTimeout(m), m = window.setTimeout(() => {
|
|
1667
|
-
|
|
1680
|
+
a = x.value, !i && !d ? J() : ce(!0);
|
|
1668
1681
|
}, 250);
|
|
1669
1682
|
}), G.addEventListener("click", () => $.click()), $.addEventListener("change", () => {
|
|
1670
|
-
$.files?.length &&
|
|
1683
|
+
$.files?.length && tt($.files), $.value = "";
|
|
1671
1684
|
}), this.api.canUpload) {
|
|
1672
1685
|
let h = 0;
|
|
1673
1686
|
W.addEventListener("dragenter", (f) => {
|
|
@@ -1677,7 +1690,7 @@ class Mr {
|
|
|
1677
1690
|
}), W.addEventListener("dragover", (f) => {
|
|
1678
1691
|
f.dataTransfer?.types.includes("Files") && f.preventDefault();
|
|
1679
1692
|
}), W.addEventListener("drop", (f) => {
|
|
1680
|
-
f.preventDefault(), h = 0, W.classList.remove("is-dragging"), f.dataTransfer?.files.length &&
|
|
1693
|
+
f.preventDefault(), h = 0, W.classList.remove("is-dragging"), f.dataTransfer?.files.length && tt(f.dataTransfer.files);
|
|
1681
1694
|
});
|
|
1682
1695
|
}
|
|
1683
1696
|
return B.addEventListener("keydown", (h) => {
|
|
@@ -1685,53 +1698,53 @@ class Mr {
|
|
|
1685
1698
|
const M = [...B.querySelectorAll(".wds-fm-item")], w = M.indexOf(document.activeElement);
|
|
1686
1699
|
if (w < 0) return;
|
|
1687
1700
|
h.preventDefault();
|
|
1688
|
-
const
|
|
1689
|
-
M[
|
|
1701
|
+
const S = M[0].offsetTop, k = this.view === "list" ? 1 : Math.max(1, M.findIndex((te) => te.offsetTop !== S) === -1 ? M.length : M.findIndex((te) => te.offsetTop !== S)), R = { ArrowRight: 1, ArrowLeft: -1, ArrowDown: k, ArrowUp: -k }, z = h.key === "Home" ? 0 : h.key === "End" ? M.length - 1 : Math.min(M.length - 1, Math.max(0, w + R[h.key]));
|
|
1702
|
+
M[z].focus();
|
|
1690
1703
|
}), F.addEventListener("keydown", (h) => {
|
|
1691
|
-
h.key === "Enter" && h.target.tagName === "INPUT" && (h.preventDefault(),
|
|
1692
|
-
}),
|
|
1704
|
+
h.key === "Enter" && h.target.tagName === "INPUT" && (h.preventDefault(), Te());
|
|
1705
|
+
}), Se(), fe(), v.showModal(), x.focus(), ce(!0), X;
|
|
1693
1706
|
}
|
|
1694
1707
|
}
|
|
1695
1708
|
function $e(t) {
|
|
1696
1709
|
const e = document.createElement("span");
|
|
1697
1710
|
return e.textContent = t, e.innerHTML;
|
|
1698
1711
|
}
|
|
1699
|
-
const ne = /* @__PURE__ */ new WeakMap(),
|
|
1700
|
-
function
|
|
1701
|
-
return t === !1 ? [] : t === void 0 || t === "default" ?
|
|
1712
|
+
const ne = /* @__PURE__ */ new WeakMap(), Mt = (t) => t === void 0 ? void 0 : typeof t == "number" ? `${t}px` : t;
|
|
1713
|
+
function Ar(t) {
|
|
1714
|
+
return t === !1 ? [] : t === void 0 || t === "default" ? ar : Array.isArray(t) ? t : t.split(/\s+/).filter(Boolean);
|
|
1702
1715
|
}
|
|
1703
1716
|
const re = class re {
|
|
1704
1717
|
constructor(e, n = {}) {
|
|
1705
1718
|
if (this.listeners = /* @__PURE__ */ new Map(), this.notice = null, this.noticeTimer = 0, this.onFormSubmit = () => this.syncTarget(), this.onKeydown = (i) => {
|
|
1706
1719
|
i.key === "Escape" && this.fullscreen && this.toggleFullscreen();
|
|
1707
1720
|
}, this.sourceMode = !1, this.plainPaste = !1, this.fullscreen = !1, this.destroyed = !1, ne.has(e)) throw new Error("[WDS Editor] This element already has an editor. Use WDSEditor.get() or destroy() first.");
|
|
1708
|
-
this.target = e, this.options = n, this.t =
|
|
1721
|
+
this.target = e, this.options = n, this.t = wr(n.language), this.readOnly = !!n.readOnly, this.textarea = e instanceof HTMLTextAreaElement ? e : null, this.originalContent = this.textarea ? this.textarea.value : e.innerHTML;
|
|
1709
1722
|
const r = n.content ?? this.originalContent;
|
|
1710
|
-
this.root = document.createElement("div"), this.root.className = "wds-editor", this.root.dataset.theme = n.theme ?? "light", this.fileManager = n.fileManager?.listUrl ? new
|
|
1711
|
-
const o =
|
|
1712
|
-
o ? (this.contentWrap.style.height = o, this.root.classList.add("wds-fixed-height")) : this.contentWrap.style.minHeight =
|
|
1713
|
-
const
|
|
1723
|
+
this.root = document.createElement("div"), this.root.className = "wds-editor", this.root.dataset.theme = n.theme ?? "light", this.fileManager = n.fileManager?.listUrl ? new Sr(this.root, new xr(n.fileManager), this.t) : null, this.contentWrap = document.createElement("div"), this.contentWrap.className = "wds-content-wrap";
|
|
1724
|
+
const o = Mt(n.height);
|
|
1725
|
+
o ? (this.contentWrap.style.height = o, this.root.classList.add("wds-fixed-height")) : this.contentWrap.style.minHeight = Mt(n.minHeight ?? 240), this.sourceArea = document.createElement("textarea"), this.sourceArea.className = "wds-source", this.sourceArea.spellcheck = !1, this.sourceArea.hidden = !0, this.sourceArea.setAttribute("aria-label", this.t.sourceLabel);
|
|
1726
|
+
const s = jt.create({
|
|
1714
1727
|
schema: p,
|
|
1715
1728
|
doc: ge(r),
|
|
1716
1729
|
plugins: [
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
Yn(),
|
|
1720
|
-
Jn({ link: () => (this.openLinkDialog(), !0) }),
|
|
1721
|
-
Xn(),
|
|
1722
|
-
Vt(),
|
|
1723
|
-
Qn(n.placeholder ?? ""),
|
|
1730
|
+
on(),
|
|
1731
|
+
Ke({ Tab: Jn, "Shift-Tab": Xn }),
|
|
1724
1732
|
Zn(),
|
|
1725
|
-
|
|
1726
|
-
|
|
1733
|
+
er({ link: () => (this.openLinkDialog(), !0) }),
|
|
1734
|
+
tr(),
|
|
1735
|
+
Jt(),
|
|
1736
|
+
nr(n.placeholder ?? ""),
|
|
1737
|
+
rr(),
|
|
1738
|
+
xn(),
|
|
1739
|
+
En({ class: "wds-dropcursor", color: !1 })
|
|
1727
1740
|
]
|
|
1728
1741
|
}), l = {
|
|
1729
1742
|
onEdit: () => this.openImageUrlDialog(),
|
|
1730
1743
|
resizeLabel: this.t.resizeImage,
|
|
1731
1744
|
captionPlaceholder: this.t.captionPlaceholder
|
|
1732
1745
|
};
|
|
1733
|
-
this.view = new
|
|
1734
|
-
state:
|
|
1746
|
+
this.view = new Vt(this.contentWrap, {
|
|
1747
|
+
state: s,
|
|
1735
1748
|
editable: () => !this.readOnly,
|
|
1736
1749
|
attributes: {
|
|
1737
1750
|
class: "wds-content",
|
|
@@ -1740,37 +1753,37 @@ const re = class re {
|
|
|
1740
1753
|
"aria-label": this.t.editorLabel
|
|
1741
1754
|
},
|
|
1742
1755
|
dispatchTransaction: (i) => this.dispatch(i),
|
|
1743
|
-
transformPastedHTML:
|
|
1744
|
-
handlePaste: (i,
|
|
1745
|
-
const c =
|
|
1756
|
+
transformPastedHTML: An,
|
|
1757
|
+
handlePaste: (i, a) => {
|
|
1758
|
+
const c = a.clipboardData;
|
|
1746
1759
|
if (this.plainPaste && c) {
|
|
1747
1760
|
const m = c.getData("text/plain");
|
|
1748
1761
|
if (m)
|
|
1749
|
-
return i.dispatch(i.state.tr.replaceSelection(
|
|
1762
|
+
return i.dispatch(i.state.tr.replaceSelection(Tr(m)).scrollIntoView()), !0;
|
|
1750
1763
|
}
|
|
1751
1764
|
if (!c?.files.length || !this.canUploadInline() || c.getData("text/plain")) return !1;
|
|
1752
1765
|
const u = [...c.files].filter((m) => m.type.startsWith("image/"));
|
|
1753
1766
|
return u.length ? (this.uploadFiles(u), !0) : !1;
|
|
1754
1767
|
},
|
|
1755
|
-
handleDrop: (i,
|
|
1756
|
-
const m =
|
|
1768
|
+
handleDrop: (i, a, c, u) => {
|
|
1769
|
+
const m = a.dataTransfer?.files;
|
|
1757
1770
|
if (u || !m?.length || !this.canUploadInline()) return !1;
|
|
1758
|
-
const g = i.posAtCoords({ left:
|
|
1759
|
-
return
|
|
1771
|
+
const g = i.posAtCoords({ left: a.clientX, top: a.clientY })?.pos;
|
|
1772
|
+
return a.preventDefault(), this.uploadFiles([...m], g), !0;
|
|
1760
1773
|
},
|
|
1761
1774
|
nodeViews: {
|
|
1762
|
-
image: (i,
|
|
1763
|
-
figure: (i,
|
|
1775
|
+
image: (i, a, c) => new ur(i, a, c, l),
|
|
1776
|
+
figure: (i, a, c) => new hr(i, a, c, l)
|
|
1764
1777
|
},
|
|
1765
1778
|
handleDOMEvents: {
|
|
1766
1779
|
focus: () => (this.root.classList.add("is-focused"), this.emit("focus"), !1),
|
|
1767
1780
|
blur: () => (this.root.classList.remove("is-focused"), this.emit("blur"), !1)
|
|
1768
1781
|
}
|
|
1769
|
-
}), this.contentWrap.append(this.sourceArea), this.toolbar =
|
|
1782
|
+
}), this.contentWrap.append(this.sourceArea), this.toolbar = dr(this, Ar(n.toolbar), this.t), this.toolbar.element.childElementCount && this.toolbar.element.firstElementChild.childElementCount && this.root.append(this.toolbar.element), this.root.append(this.contentWrap);
|
|
1770
1783
|
const d = document.createElement("div");
|
|
1771
1784
|
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) {
|
|
1772
1785
|
const i = document.createElement("a");
|
|
1773
|
-
i.className = "wds-branding", i.href = "https://webdevsnippets.com/wds-editor", i.target = "_blank", i.rel = "noopener", i.innerHTML = `${
|
|
1786
|
+
i.className = "wds-branding", i.href = "https://webdevsnippets.com/wds-editor", i.target = "_blank", i.rel = "noopener", i.innerHTML = `${Cr(this.t.poweredBy)} <strong>WDS Editor</strong>`, d.append(i);
|
|
1774
1787
|
}
|
|
1775
1788
|
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), ne.set(e, this), this.lastHtml = this.getHTML(), this.syncTarget(), this.refresh(), this.emit("init");
|
|
1776
1789
|
}
|
|
@@ -1795,13 +1808,13 @@ const re = class re {
|
|
|
1795
1808
|
}
|
|
1796
1809
|
/** Replaces the whole content. The change can be undone. */
|
|
1797
1810
|
setHTML(e) {
|
|
1798
|
-
this.sourceMode && (this.sourceArea.value =
|
|
1811
|
+
this.sourceMode && (this.sourceArea.value = mt(e));
|
|
1799
1812
|
const n = ge(e), r = this.view.state.tr.replaceWith(0, this.view.state.doc.content.size, n.content);
|
|
1800
|
-
this.dispatch(r.setSelection(
|
|
1813
|
+
this.dispatch(r.setSelection(Ve.atStart(r.doc)));
|
|
1801
1814
|
}
|
|
1802
1815
|
/** Inserts HTML at the cursor (replacing the selection). */
|
|
1803
1816
|
insertHTML(e) {
|
|
1804
|
-
const n = ge(e), r =
|
|
1817
|
+
const n = ge(e), r = Dt.maxOpen(n.content);
|
|
1805
1818
|
this.dispatch(this.view.state.tr.replaceSelection(r).scrollIntoView());
|
|
1806
1819
|
}
|
|
1807
1820
|
getText() {
|
|
@@ -1812,7 +1825,7 @@ const re = class re {
|
|
|
1812
1825
|
`);
|
|
1813
1826
|
}
|
|
1814
1827
|
isEmpty() {
|
|
1815
|
-
return
|
|
1828
|
+
return $t(this.view.state.doc);
|
|
1816
1829
|
}
|
|
1817
1830
|
// ---------- state ----------
|
|
1818
1831
|
focus() {
|
|
@@ -1831,17 +1844,17 @@ const re = class re {
|
|
|
1831
1844
|
return this.view.focus(), n;
|
|
1832
1845
|
}
|
|
1833
1846
|
undo() {
|
|
1834
|
-
this.exec(
|
|
1847
|
+
this.exec(At);
|
|
1835
1848
|
}
|
|
1836
1849
|
redo() {
|
|
1837
|
-
this.exec(
|
|
1850
|
+
this.exec(Re);
|
|
1838
1851
|
}
|
|
1839
1852
|
// ---------- views ----------
|
|
1840
1853
|
isSourceMode() {
|
|
1841
1854
|
return this.sourceMode;
|
|
1842
1855
|
}
|
|
1843
1856
|
toggleSource() {
|
|
1844
|
-
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 =
|
|
1857
|
+
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 = mt(be(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();
|
|
1845
1858
|
}
|
|
1846
1859
|
isFullscreen() {
|
|
1847
1860
|
return this.fullscreen;
|
|
@@ -1852,8 +1865,8 @@ const re = class re {
|
|
|
1852
1865
|
// ---------- link dialog ----------
|
|
1853
1866
|
openLinkDialog() {
|
|
1854
1867
|
if (this.readOnly || this.sourceMode) return;
|
|
1855
|
-
const e = this.view.state, n =
|
|
1856
|
-
|
|
1868
|
+
const e = this.view.state, n = We(e), { from: r, to: o, empty: s } = e.selection, l = s ? "" : e.doc.textBetween(r, o, " "), d = s && !n, i = this.t;
|
|
1869
|
+
wt(this.root, {
|
|
1857
1870
|
title: i.link,
|
|
1858
1871
|
closeLabel: i.close,
|
|
1859
1872
|
submitLabel: i.save,
|
|
@@ -1865,14 +1878,14 @@ const re = class re {
|
|
|
1865
1878
|
{ name: "newTab", label: i.linkNewTab, type: "checkbox", value: n?.target === "_blank" }
|
|
1866
1879
|
],
|
|
1867
1880
|
extraAction: n ? { label: i.remove, onClick: () => this.removeLink() } : void 0,
|
|
1868
|
-
validate: (
|
|
1869
|
-
onSubmit: (
|
|
1870
|
-
const c =
|
|
1881
|
+
validate: (a) => ot(String(a.href)) ? null : i.linkInvalid,
|
|
1882
|
+
onSubmit: (a) => {
|
|
1883
|
+
const c = ot(String(a.href)), u = { href: c, title: String(a.title).trim() || null, target: a.newTab ? "_blank" : null }, m = p.marks.link.create(u), g = this.view.state;
|
|
1871
1884
|
let v = g.tr;
|
|
1872
1885
|
if (n)
|
|
1873
1886
|
v = v.removeMark(n.from, n.to, p.marks.link).addMark(n.from, n.to, m);
|
|
1874
1887
|
else if (d) {
|
|
1875
|
-
const D = String(
|
|
1888
|
+
const D = String(a.text ?? "").trim() || c.replace(/^mailto:/, "");
|
|
1876
1889
|
v = v.replaceSelectionWith(p.text(D, [m]), !1);
|
|
1877
1890
|
} else
|
|
1878
1891
|
v = v.addMark(g.selection.from, g.selection.to, m);
|
|
@@ -1882,7 +1895,7 @@ const re = class re {
|
|
|
1882
1895
|
});
|
|
1883
1896
|
}
|
|
1884
1897
|
removeLink() {
|
|
1885
|
-
const e =
|
|
1898
|
+
const e = We(this.view.state);
|
|
1886
1899
|
e && this.dispatch(this.view.state.tr.removeMark(e.from, e.to, p.marks.link));
|
|
1887
1900
|
}
|
|
1888
1901
|
// ---------- images and files ----------
|
|
@@ -1902,7 +1915,7 @@ const re = class re {
|
|
|
1902
1915
|
height: e.width ? e.height ?? null : null,
|
|
1903
1916
|
align: e.align ?? null
|
|
1904
1917
|
}), o = this.view.state.tr.replaceSelectionWith(r);
|
|
1905
|
-
return e.caption &&
|
|
1918
|
+
return e.caption && bt(o, o.selection.from - 1, r.attrs), this.dispatch(o.scrollIntoView()), !0;
|
|
1906
1919
|
}
|
|
1907
1920
|
/**
|
|
1908
1921
|
* Image button: edits the selected image, otherwise opens the file manager (when configured)
|
|
@@ -1910,7 +1923,7 @@ const re = class re {
|
|
|
1910
1923
|
*/
|
|
1911
1924
|
openImageDialog() {
|
|
1912
1925
|
if (this.readOnly || this.sourceMode) return;
|
|
1913
|
-
|
|
1926
|
+
qe(this.view.state) || !this.fileManager ? this.openImageUrlDialog() : this.openFileManager("image");
|
|
1914
1927
|
}
|
|
1915
1928
|
/** Opens the file manager. "image" lists images (accept option, default image/*), "file" lists every file. */
|
|
1916
1929
|
openFileManager(e = "image") {
|
|
@@ -1919,16 +1932,16 @@ const re = class re {
|
|
|
1919
1932
|
accept: e === "image" ? this.options.fileManager?.accept ?? "image/*" : "",
|
|
1920
1933
|
onFromUrl: e === "image" ? () => this.openImageUrlDialog() : void 0,
|
|
1921
1934
|
onUpload: (n) => this.emit("upload", n),
|
|
1922
|
-
onPick: ({ file: n, alt: r, width: o, align:
|
|
1923
|
-
e === "image" && ue(n) ? this.insertImage({ src: n.url, alt: r, width: o, align:
|
|
1935
|
+
onPick: ({ file: n, alt: r, width: o, align: s, text: l, caption: d }) => {
|
|
1936
|
+
e === "image" && ue(n) ? this.insertImage({ src: n.url, alt: r, width: o, align: s, caption: d }) : this.insertFileLink(n, l), this.emit("fileSelect", n);
|
|
1924
1937
|
},
|
|
1925
1938
|
onClose: () => this.view.focus()
|
|
1926
1939
|
});
|
|
1927
1940
|
}
|
|
1928
1941
|
/** Dialog for an image by URL, or for editing the selected image (alt text, width, alignment). */
|
|
1929
1942
|
openImageUrlDialog() {
|
|
1930
|
-
const e = this.t, n =
|
|
1931
|
-
|
|
1943
|
+
const e = this.t, n = qe(this.view.state), r = n?.attrs ?? {};
|
|
1944
|
+
wt(this.root, {
|
|
1932
1945
|
title: n ? e.imageEdit : e.image,
|
|
1933
1946
|
closeLabel: e.close,
|
|
1934
1947
|
submitLabel: n ? e.save : e.insert,
|
|
@@ -1953,15 +1966,15 @@ const re = class re {
|
|
|
1953
1966
|
],
|
|
1954
1967
|
validate: (o) => q(String(o.src)) && !/^(mailto|tel):/i.test(String(o.src).trim()) ? null : e.imageInvalid,
|
|
1955
1968
|
onSubmit: (o) => {
|
|
1956
|
-
const
|
|
1969
|
+
const s = parseInt(String(o.width), 10), l = {
|
|
1957
1970
|
src: q(String(o.src)),
|
|
1958
1971
|
alt: String(o.alt).trim(),
|
|
1959
|
-
width:
|
|
1972
|
+
width: s > 0 ? s : null,
|
|
1960
1973
|
align: String(o.align) || null
|
|
1961
1974
|
}, d = !!o.caption;
|
|
1962
1975
|
if (n) {
|
|
1963
|
-
const i = l.width && l.width === r.width ? r.height ?? null : null,
|
|
1964
|
-
d && !n.figure ?
|
|
1976
|
+
const i = l.width && l.width === r.width ? r.height ?? null : null, a = { ...r, ...l, height: i }, c = this.view.state.tr;
|
|
1977
|
+
d && !n.figure ? bt(c, n.pos, a) : !d && n.figure ? Vn(c, n.pos, n.node, a) : c.setNodeMarkup(n.pos, void 0, a).setSelection(he.create(c.doc, n.pos)), this.dispatch(c.scrollIntoView());
|
|
1965
1978
|
} else
|
|
1966
1979
|
this.insertImage({ ...l, caption: d });
|
|
1967
1980
|
},
|
|
@@ -1974,45 +1987,45 @@ const re = class re {
|
|
|
1974
1987
|
if (this.readOnly || this.sourceMode) return;
|
|
1975
1988
|
const n = this.t, r = this.view.state;
|
|
1976
1989
|
if (!pe(r)) {
|
|
1977
|
-
|
|
1990
|
+
mr(
|
|
1978
1991
|
e,
|
|
1979
1992
|
this.root,
|
|
1980
1993
|
n.tableInsert,
|
|
1981
1994
|
(l, d) => V(n.tableSize, { rows: String(l), cols: String(d) }),
|
|
1982
|
-
(l, d) => this.exec(
|
|
1995
|
+
(l, d) => this.exec(Yn(l, d))
|
|
1983
1996
|
);
|
|
1984
1997
|
return;
|
|
1985
1998
|
}
|
|
1986
|
-
const o = (l, d, i = !1) => ({ label: l, danger: i, enabled: d(r), run: () => this.exec(d) }),
|
|
1987
|
-
o(n.rowAbove,
|
|
1988
|
-
o(n.rowBelow,
|
|
1989
|
-
o(n.colLeft,
|
|
1990
|
-
o(n.colRight,
|
|
1999
|
+
const o = (l, d, i = !1) => ({ label: l, danger: i, enabled: d(r), run: () => this.exec(d) }), s = [
|
|
2000
|
+
o(n.rowAbove, an),
|
|
2001
|
+
o(n.rowBelow, It),
|
|
2002
|
+
o(n.colLeft, sn),
|
|
2003
|
+
o(n.colRight, ln),
|
|
1991
2004
|
"|",
|
|
1992
|
-
o(n.deleteRow,
|
|
1993
|
-
o(n.deleteCol,
|
|
2005
|
+
o(n.deleteRow, cn),
|
|
2006
|
+
o(n.deleteCol, dn),
|
|
1994
2007
|
"|",
|
|
1995
|
-
o(n.headerRow,
|
|
1996
|
-
o(n.headerCol,
|
|
1997
|
-
o(n.mergeCells,
|
|
1998
|
-
o(n.splitCell,
|
|
2008
|
+
o(n.headerRow, un),
|
|
2009
|
+
o(n.headerCol, hn),
|
|
2010
|
+
o(n.mergeCells, pn),
|
|
2011
|
+
o(n.splitCell, mn),
|
|
1999
2012
|
"|",
|
|
2000
|
-
o(n.deleteTable,
|
|
2013
|
+
o(n.deleteTable, fn, !0)
|
|
2001
2014
|
];
|
|
2002
|
-
|
|
2015
|
+
pr(e, this.root, s, n.table);
|
|
2003
2016
|
}
|
|
2004
2017
|
// ---------- colors ----------
|
|
2005
2018
|
/** Opens the text color or highlight palette under the given toolbar button. */
|
|
2006
2019
|
openColorPicker(e, n) {
|
|
2007
2020
|
if (this.readOnly || this.sourceMode) return;
|
|
2008
|
-
const r = this.t,
|
|
2009
|
-
|
|
2021
|
+
const r = this.t, s = ((e === "textColor" ? this.options.colors?.text : this.options.colors?.highlight) ?? (e === "textColor" ? Tn : Cn)).map((l) => typeof l == "string" ? { color: l, name: l } : l).map((l) => ({ color: oe(l.color), label: r[l.name] ?? l.name })).filter((l) => !!l.color);
|
|
2022
|
+
fr(n, this.root, {
|
|
2010
2023
|
label: e === "textColor" ? r.textColor : r.highlight,
|
|
2011
2024
|
removeLabel: e === "textColor" ? r.removeColor : r.removeHighlight,
|
|
2012
|
-
swatches:
|
|
2025
|
+
swatches: s,
|
|
2013
2026
|
columns: e === "textColor" ? 5 : 6,
|
|
2014
|
-
current:
|
|
2015
|
-
onPick: (l) => this.exec(
|
|
2027
|
+
current: Ge(this.view.state, e),
|
|
2028
|
+
onPick: (l) => this.exec(Qn(e, l))
|
|
2016
2029
|
});
|
|
2017
2030
|
}
|
|
2018
2031
|
// ---------- paste ----------
|
|
@@ -2027,7 +2040,7 @@ const re = class re {
|
|
|
2027
2040
|
insertFileLink(e, n) {
|
|
2028
2041
|
const r = q(e.url);
|
|
2029
2042
|
if (!r || this.readOnly || this.sourceMode) return;
|
|
2030
|
-
const o = p.marks.link.create({ href: r }),
|
|
2043
|
+
const o = p.marks.link.create({ href: r }), s = this.view.state, l = s.selection.empty ? s.tr.replaceSelectionWith(p.text(n || e.name, [o]), !1) : s.tr.addMark(s.selection.from, s.selection.to, o);
|
|
2031
2044
|
this.dispatch(l.scrollIntoView());
|
|
2032
2045
|
}
|
|
2033
2046
|
canUploadInline() {
|
|
@@ -2041,18 +2054,18 @@ const re = class re {
|
|
|
2041
2054
|
if (!this.canUploadInline()) return;
|
|
2042
2055
|
const r = this.fileManager.api;
|
|
2043
2056
|
for (const o of e) {
|
|
2044
|
-
const
|
|
2057
|
+
const s = {};
|
|
2045
2058
|
let l = this.view.state.tr;
|
|
2046
2059
|
n === void 0 && !l.selection.empty && (l = l.deleteSelection());
|
|
2047
2060
|
const d = n ?? l.selection.from;
|
|
2048
|
-
this.dispatch(l.setMeta(Q, { add: { id:
|
|
2061
|
+
this.dispatch(l.setMeta(Q, { add: { id: s, pos: d } })), r.upload(o, this.fileManager.path).then((i) => {
|
|
2049
2062
|
if (this.destroyed) return;
|
|
2050
|
-
const
|
|
2051
|
-
if (
|
|
2063
|
+
const a = or(this.view.state, s);
|
|
2064
|
+
if (a === null) return;
|
|
2052
2065
|
const c = ue(i) ? p.nodes.image.create({ src: i.url, alt: "" }) : p.text(i.name, [p.marks.link.create({ href: i.url })]);
|
|
2053
|
-
this.dispatch(this.view.state.tr.replaceWith(
|
|
2066
|
+
this.dispatch(this.view.state.tr.replaceWith(a, a, c).setMeta(Q, { remove: { id: s } })), this.emit("upload", i);
|
|
2054
2067
|
}).catch((i) => {
|
|
2055
|
-
this.destroyed || (this.dispatch(this.view.state.tr.setMeta(Q, { remove: { id:
|
|
2068
|
+
this.destroyed || (this.dispatch(this.view.state.tr.setMeta(Q, { remove: { id: s } })), this.showNotice(V(this.t.fmUploadFailed, { name: o.name, error: i.message })));
|
|
2056
2069
|
});
|
|
2057
2070
|
}
|
|
2058
2071
|
}
|
|
@@ -2072,7 +2085,7 @@ const re = class re {
|
|
|
2072
2085
|
if (this.destroyed) return;
|
|
2073
2086
|
this.emit("destroy");
|
|
2074
2087
|
const e = this.getHTML();
|
|
2075
|
-
this.destroyed = !0, window.clearTimeout(this.noticeTimer),
|
|
2088
|
+
this.destroyed = !0, window.clearTimeout(this.noticeTimer), Ft(), 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, ne.delete(this.target), this.listeners.clear();
|
|
2076
2089
|
}
|
|
2077
2090
|
// ---------- internals ----------
|
|
2078
2091
|
dispatch(e) {
|
|
@@ -2110,31 +2123,31 @@ const re = class re {
|
|
|
2110
2123
|
});
|
|
2111
2124
|
}
|
|
2112
2125
|
};
|
|
2113
|
-
re.version = "1.0.
|
|
2114
|
-
let
|
|
2115
|
-
function
|
|
2126
|
+
re.version = "1.0.1", re.addLanguage = br;
|
|
2127
|
+
let Lt = re;
|
|
2128
|
+
function Tr(t) {
|
|
2116
2129
|
const e = t.replace(/\r\n?/g, `
|
|
2117
2130
|
`).split(/\n{2,}/).map((n) => {
|
|
2118
2131
|
const o = n.split(`
|
|
2119
|
-
`).flatMap((
|
|
2132
|
+
`).flatMap((s, l) => [...l ? [p.nodes.hard_break.create()] : [], ...s ? [p.text(s)] : []]);
|
|
2120
2133
|
return p.nodes.paragraph.create(null, o);
|
|
2121
2134
|
});
|
|
2122
|
-
return new
|
|
2135
|
+
return new Dt(Ct.from(e), 1, 1);
|
|
2123
2136
|
}
|
|
2124
|
-
function
|
|
2137
|
+
function Cr(t) {
|
|
2125
2138
|
const e = document.createElement("span");
|
|
2126
2139
|
return e.textContent = t, e.innerHTML;
|
|
2127
2140
|
}
|
|
2128
2141
|
export {
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2142
|
+
ar as DEFAULT_TOOLBAR,
|
|
2143
|
+
Lt as WDSEditor,
|
|
2144
|
+
br as addLanguage,
|
|
2132
2145
|
ve as en,
|
|
2133
2146
|
ue as isImage,
|
|
2134
|
-
|
|
2135
|
-
|
|
2147
|
+
yt as matchesAccept,
|
|
2148
|
+
vr as normalizeList,
|
|
2136
2149
|
p as schema,
|
|
2137
|
-
|
|
2138
|
-
|
|
2150
|
+
ir as toolbarItems,
|
|
2151
|
+
gr as tr
|
|
2139
2152
|
};
|
|
2140
2153
|
//# sourceMappingURL=wds-editor.js.map
|