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