ablok-components 0.3.34 → 0.3.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ablok-components.es.js +8327 -57
- package/dist/ablok-components.umd.js +36 -112
- package/dist/{index-Ki1Egcx9.mjs → index-BIlA-HIk.mjs} +2358 -2492
- package/dist/{index-Bk6yOA7Y.mjs → index-CYb55fu6.mjs} +16 -22
- package/package.json +1 -1
- package/dist/confetti.module-Dm_JxCnK.mjs +0 -410
- package/dist/index-4swvWhBV.mjs +0 -85
- package/dist/index-B4qukPmD.mjs +0 -47
- package/dist/index-BzE6-pPu.mjs +0 -580
- package/dist/index-C9XBp_Jh.mjs +0 -2333
- package/dist/index-DbvQcSeJ.mjs +0 -1006
- package/dist/index-Dgq1pUHO.mjs +0 -22992
- package/dist/leaflet-src-mwV2C14q.mjs +0 -6336
- package/dist/leaflet-src.esm-BSRIxBxW.mjs +0 -6429
- package/dist/marker-icon-2x-DVSLMKfE.mjs +0 -4
- package/dist/marker-icon-DbhCZIpd.mjs +0 -4
- package/dist/marker-shadow-ZZvxUwqf.mjs +0 -4
- package/dist/vue-datepicker-DjJc0tSE.mjs +0 -9171
- package/dist/vue-leaflet.es-Cn1a0sf0.mjs +0 -1871
package/dist/index-C9XBp_Jh.mjs
DELETED
|
@@ -1,2333 +0,0 @@
|
|
|
1
|
-
import { e as b, a$ as E, aE as y, d as K, aC as B, aB as D, b0 as C, b1 as I, b2 as A, aZ as G, b3 as H, aH as He, i as Ne, at as he, b4 as J, b as w, aP as fe, ar as X, aj as Oe, ai as Re, a2 as me, a0 as _e, a3 as $e, aL as ee, b5 as Be, b6 as De, b7 as te, b8 as ge, b9 as N, ba as j, bb as ze, h as Ke, W as je, as as Ve } from "./index-Ki1Egcx9.mjs";
|
|
2
|
-
import { h as ne, B as We } from "./index-Bk6yOA7Y.mjs";
|
|
3
|
-
import { Link as Fe } from "./index-DbvQcSeJ.mjs";
|
|
4
|
-
var Ue = /^\s*>\s$/, Ge = b.create({
|
|
5
|
-
name: "blockquote",
|
|
6
|
-
addOptions() {
|
|
7
|
-
return {
|
|
8
|
-
HTMLAttributes: {}
|
|
9
|
-
};
|
|
10
|
-
},
|
|
11
|
-
content: "block+",
|
|
12
|
-
group: "block",
|
|
13
|
-
defining: !0,
|
|
14
|
-
parseHTML() {
|
|
15
|
-
return [{ tag: "blockquote" }];
|
|
16
|
-
},
|
|
17
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
18
|
-
return /* @__PURE__ */ ne("blockquote", { ...y(this.options.HTMLAttributes, e), children: /* @__PURE__ */ ne("slot", {}) });
|
|
19
|
-
},
|
|
20
|
-
parseMarkdown: (e, t) => t.createNode("blockquote", void 0, t.parseChildren(e.tokens || [])),
|
|
21
|
-
renderMarkdown: (e, t) => {
|
|
22
|
-
if (!e.content)
|
|
23
|
-
return "";
|
|
24
|
-
const n = ">", s = [];
|
|
25
|
-
return e.content.forEach((r) => {
|
|
26
|
-
const a = t.renderChildren([r]).split(`
|
|
27
|
-
`).map((l) => l.trim() === "" ? n : `${n} ${l}`);
|
|
28
|
-
s.push(a.join(`
|
|
29
|
-
`));
|
|
30
|
-
}), s.join(`
|
|
31
|
-
${n}
|
|
32
|
-
`);
|
|
33
|
-
},
|
|
34
|
-
addCommands() {
|
|
35
|
-
return {
|
|
36
|
-
setBlockquote: () => ({ commands: e }) => e.wrapIn(this.name),
|
|
37
|
-
toggleBlockquote: () => ({ commands: e }) => e.toggleWrap(this.name),
|
|
38
|
-
unsetBlockquote: () => ({ commands: e }) => e.lift(this.name)
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
addKeyboardShortcuts() {
|
|
42
|
-
return {
|
|
43
|
-
"Mod-Shift-b": () => this.editor.commands.toggleBlockquote()
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
addInputRules() {
|
|
47
|
-
return [
|
|
48
|
-
E({
|
|
49
|
-
find: Ue,
|
|
50
|
-
type: this.type
|
|
51
|
-
})
|
|
52
|
-
];
|
|
53
|
-
}
|
|
54
|
-
}), Xe = /(^|[^`])`([^`]+)`(?!`)$/, qe = /(^|[^`])`([^`]+)`(?!`)/g, Ye = K.create({
|
|
55
|
-
name: "code",
|
|
56
|
-
addOptions() {
|
|
57
|
-
return {
|
|
58
|
-
HTMLAttributes: {}
|
|
59
|
-
};
|
|
60
|
-
},
|
|
61
|
-
excludes: "_",
|
|
62
|
-
code: !0,
|
|
63
|
-
exitable: !0,
|
|
64
|
-
parseHTML() {
|
|
65
|
-
return [{ tag: "code" }];
|
|
66
|
-
},
|
|
67
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
68
|
-
return ["code", y(this.options.HTMLAttributes, e), 0];
|
|
69
|
-
},
|
|
70
|
-
markdownTokenName: "codespan",
|
|
71
|
-
parseMarkdown: (e, t) => t.applyMark("code", [{ type: "text", text: e.text || "" }]),
|
|
72
|
-
renderMarkdown: (e, t) => e.content ? `\`${t.renderChildren(e.content)}\`` : "",
|
|
73
|
-
addCommands() {
|
|
74
|
-
return {
|
|
75
|
-
setCode: () => ({ commands: e }) => e.setMark(this.name),
|
|
76
|
-
toggleCode: () => ({ commands: e }) => e.toggleMark(this.name),
|
|
77
|
-
unsetCode: () => ({ commands: e }) => e.unsetMark(this.name)
|
|
78
|
-
};
|
|
79
|
-
},
|
|
80
|
-
addKeyboardShortcuts() {
|
|
81
|
-
return {
|
|
82
|
-
"Mod-e": () => this.editor.commands.toggleCode()
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
|
-
addInputRules() {
|
|
86
|
-
return [
|
|
87
|
-
D({
|
|
88
|
-
find: Xe,
|
|
89
|
-
type: this.type
|
|
90
|
-
})
|
|
91
|
-
];
|
|
92
|
-
},
|
|
93
|
-
addPasteRules() {
|
|
94
|
-
return [
|
|
95
|
-
B({
|
|
96
|
-
find: qe,
|
|
97
|
-
type: this.type
|
|
98
|
-
})
|
|
99
|
-
];
|
|
100
|
-
}
|
|
101
|
-
}), W = 4, Je = /^```([a-z]+)?[\s\n]$/, Ze = /^~~~([a-z]+)?[\s\n]$/, Qe = b.create({
|
|
102
|
-
name: "codeBlock",
|
|
103
|
-
addOptions() {
|
|
104
|
-
return {
|
|
105
|
-
languageClassPrefix: "language-",
|
|
106
|
-
exitOnTripleEnter: !0,
|
|
107
|
-
exitOnArrowDown: !0,
|
|
108
|
-
defaultLanguage: null,
|
|
109
|
-
enableTabIndentation: !1,
|
|
110
|
-
tabSize: W,
|
|
111
|
-
HTMLAttributes: {}
|
|
112
|
-
};
|
|
113
|
-
},
|
|
114
|
-
content: "text*",
|
|
115
|
-
marks: "",
|
|
116
|
-
group: "block",
|
|
117
|
-
code: !0,
|
|
118
|
-
defining: !0,
|
|
119
|
-
addAttributes() {
|
|
120
|
-
return {
|
|
121
|
-
language: {
|
|
122
|
-
default: this.options.defaultLanguage,
|
|
123
|
-
parseHTML: (e) => {
|
|
124
|
-
var t;
|
|
125
|
-
const { languageClassPrefix: n } = this.options;
|
|
126
|
-
if (!n)
|
|
127
|
-
return null;
|
|
128
|
-
const i = [...((t = e.firstElementChild) == null ? void 0 : t.classList) || []].filter((o) => o.startsWith(n)).map((o) => o.replace(n, ""))[0];
|
|
129
|
-
return i || null;
|
|
130
|
-
},
|
|
131
|
-
rendered: !1
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
},
|
|
135
|
-
parseHTML() {
|
|
136
|
-
return [
|
|
137
|
-
{
|
|
138
|
-
tag: "pre",
|
|
139
|
-
preserveWhitespace: "full"
|
|
140
|
-
}
|
|
141
|
-
];
|
|
142
|
-
},
|
|
143
|
-
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
144
|
-
return [
|
|
145
|
-
"pre",
|
|
146
|
-
y(this.options.HTMLAttributes, t),
|
|
147
|
-
[
|
|
148
|
-
"code",
|
|
149
|
-
{
|
|
150
|
-
class: e.attrs.language ? this.options.languageClassPrefix + e.attrs.language : null
|
|
151
|
-
},
|
|
152
|
-
0
|
|
153
|
-
]
|
|
154
|
-
];
|
|
155
|
-
},
|
|
156
|
-
markdownTokenName: "code",
|
|
157
|
-
parseMarkdown: (e, t) => {
|
|
158
|
-
var n;
|
|
159
|
-
return ((n = e.raw) == null ? void 0 : n.startsWith("```")) === !1 && e.codeBlockStyle !== "indented" ? [] : t.createNode(
|
|
160
|
-
"codeBlock",
|
|
161
|
-
{ language: e.lang || null },
|
|
162
|
-
e.text ? [t.createTextNode(e.text)] : []
|
|
163
|
-
);
|
|
164
|
-
},
|
|
165
|
-
renderMarkdown: (e, t) => {
|
|
166
|
-
var n;
|
|
167
|
-
let s = "";
|
|
168
|
-
const r = ((n = e.attrs) == null ? void 0 : n.language) || "";
|
|
169
|
-
return e.content ? s = [`\`\`\`${r}`, t.renderChildren(e.content), "```"].join(`
|
|
170
|
-
`) : s = `\`\`\`${r}
|
|
171
|
-
|
|
172
|
-
\`\`\``, s;
|
|
173
|
-
},
|
|
174
|
-
addCommands() {
|
|
175
|
-
return {
|
|
176
|
-
setCodeBlock: (e) => ({ commands: t }) => t.setNode(this.name, e),
|
|
177
|
-
toggleCodeBlock: (e) => ({ commands: t }) => t.toggleNode(this.name, "paragraph", e)
|
|
178
|
-
};
|
|
179
|
-
},
|
|
180
|
-
addKeyboardShortcuts() {
|
|
181
|
-
return {
|
|
182
|
-
"Mod-Alt-c": () => this.editor.commands.toggleCodeBlock(),
|
|
183
|
-
// remove code block when at start of document or code block is empty
|
|
184
|
-
Backspace: () => {
|
|
185
|
-
const { empty: e, $anchor: t } = this.editor.state.selection, n = t.pos === 1;
|
|
186
|
-
return !e || t.parent.type.name !== this.name ? !1 : n || !t.parent.textContent.length ? this.editor.commands.clearNodes() : !1;
|
|
187
|
-
},
|
|
188
|
-
// handle tab indentation
|
|
189
|
-
Tab: ({ editor: e }) => {
|
|
190
|
-
var t;
|
|
191
|
-
if (!this.options.enableTabIndentation)
|
|
192
|
-
return !1;
|
|
193
|
-
const n = (t = this.options.tabSize) != null ? t : W, { state: s } = e, { selection: r } = s, { $from: i, empty: o } = r;
|
|
194
|
-
if (i.parent.type !== this.type)
|
|
195
|
-
return !1;
|
|
196
|
-
const a = " ".repeat(n);
|
|
197
|
-
return o ? e.commands.insertContent(a) : e.commands.command(({ tr: l }) => {
|
|
198
|
-
const { from: u, to: p } = r, h = s.doc.textBetween(u, p, `
|
|
199
|
-
`, `
|
|
200
|
-
`).split(`
|
|
201
|
-
`).map((f) => a + f).join(`
|
|
202
|
-
`);
|
|
203
|
-
return l.replaceWith(u, p, s.schema.text(h)), !0;
|
|
204
|
-
});
|
|
205
|
-
},
|
|
206
|
-
// handle shift+tab reverse indentation
|
|
207
|
-
"Shift-Tab": ({ editor: e }) => {
|
|
208
|
-
var t;
|
|
209
|
-
if (!this.options.enableTabIndentation)
|
|
210
|
-
return !1;
|
|
211
|
-
const n = (t = this.options.tabSize) != null ? t : W, { state: s } = e, { selection: r } = s, { $from: i, empty: o } = r;
|
|
212
|
-
return i.parent.type !== this.type ? !1 : o ? e.commands.command(({ tr: a }) => {
|
|
213
|
-
var l;
|
|
214
|
-
const { pos: u } = i, p = i.start(), d = i.end(), h = s.doc.textBetween(p, d, `
|
|
215
|
-
`, `
|
|
216
|
-
`).split(`
|
|
217
|
-
`);
|
|
218
|
-
let f = 0, m = 0;
|
|
219
|
-
const k = u - p;
|
|
220
|
-
for (let T = 0; T < h.length; T += 1) {
|
|
221
|
-
if (m + h[T].length >= k) {
|
|
222
|
-
f = T;
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
m += h[T].length + 1;
|
|
226
|
-
}
|
|
227
|
-
const Pe = ((l = h[f].match(/^ */)) == null ? void 0 : l[0]) || "", V = Math.min(Pe.length, n);
|
|
228
|
-
if (V === 0)
|
|
229
|
-
return !0;
|
|
230
|
-
let P = p;
|
|
231
|
-
for (let T = 0; T < f; T += 1)
|
|
232
|
-
P += h[T].length + 1;
|
|
233
|
-
return a.delete(P, P + V), u - P <= V && a.setSelection(A.create(a.doc, P)), !0;
|
|
234
|
-
}) : e.commands.command(({ tr: a }) => {
|
|
235
|
-
const { from: l, to: u } = r, c = s.doc.textBetween(l, u, `
|
|
236
|
-
`, `
|
|
237
|
-
`).split(`
|
|
238
|
-
`).map((h) => {
|
|
239
|
-
var f;
|
|
240
|
-
const m = ((f = h.match(/^ */)) == null ? void 0 : f[0]) || "", k = Math.min(m.length, n);
|
|
241
|
-
return h.slice(k);
|
|
242
|
-
}).join(`
|
|
243
|
-
`);
|
|
244
|
-
return a.replaceWith(l, u, s.schema.text(c)), !0;
|
|
245
|
-
});
|
|
246
|
-
},
|
|
247
|
-
// exit node on triple enter
|
|
248
|
-
Enter: ({ editor: e }) => {
|
|
249
|
-
if (!this.options.exitOnTripleEnter)
|
|
250
|
-
return !1;
|
|
251
|
-
const { state: t } = e, { selection: n } = t, { $from: s, empty: r } = n;
|
|
252
|
-
if (!r || s.parent.type !== this.type)
|
|
253
|
-
return !1;
|
|
254
|
-
const i = s.parentOffset === s.parent.nodeSize - 2, o = s.parent.textContent.endsWith(`
|
|
255
|
-
|
|
256
|
-
`);
|
|
257
|
-
return !i || !o ? !1 : e.chain().command(({ tr: a }) => (a.delete(s.pos - 2, s.pos), !0)).exitCode().run();
|
|
258
|
-
},
|
|
259
|
-
// exit node on arrow down
|
|
260
|
-
ArrowDown: ({ editor: e }) => {
|
|
261
|
-
if (!this.options.exitOnArrowDown)
|
|
262
|
-
return !1;
|
|
263
|
-
const { state: t } = e, { selection: n, doc: s } = t, { $from: r, empty: i } = n;
|
|
264
|
-
if (!i || r.parent.type !== this.type || !(r.parentOffset === r.parent.nodeSize - 2))
|
|
265
|
-
return !1;
|
|
266
|
-
const a = r.after();
|
|
267
|
-
return a === void 0 ? !1 : s.nodeAt(a) ? e.commands.command(({ tr: u }) => (u.setSelection(H.near(s.resolve(a))), !0)) : e.commands.exitCode();
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
},
|
|
271
|
-
addInputRules() {
|
|
272
|
-
return [
|
|
273
|
-
G({
|
|
274
|
-
find: Je,
|
|
275
|
-
type: this.type,
|
|
276
|
-
getAttributes: (e) => ({
|
|
277
|
-
language: e[1]
|
|
278
|
-
})
|
|
279
|
-
}),
|
|
280
|
-
G({
|
|
281
|
-
find: Ze,
|
|
282
|
-
type: this.type,
|
|
283
|
-
getAttributes: (e) => ({
|
|
284
|
-
language: e[1]
|
|
285
|
-
})
|
|
286
|
-
})
|
|
287
|
-
];
|
|
288
|
-
},
|
|
289
|
-
addProseMirrorPlugins() {
|
|
290
|
-
return [
|
|
291
|
-
// this plugin creates a code block for pasted content from VS Code
|
|
292
|
-
// we can also detect the copied code language
|
|
293
|
-
new C({
|
|
294
|
-
key: new I("codeBlockVSCodeHandler"),
|
|
295
|
-
props: {
|
|
296
|
-
handlePaste: (e, t) => {
|
|
297
|
-
if (!t.clipboardData || this.editor.isActive(this.type.name))
|
|
298
|
-
return !1;
|
|
299
|
-
const n = t.clipboardData.getData("text/plain"), s = t.clipboardData.getData("vscode-editor-data"), r = s ? JSON.parse(s) : void 0, i = r?.mode;
|
|
300
|
-
if (!n || !i)
|
|
301
|
-
return !1;
|
|
302
|
-
const { tr: o, schema: a } = e.state, l = a.text(n.replace(/\r\n?/g, `
|
|
303
|
-
`));
|
|
304
|
-
return o.replaceSelectionWith(this.type.create({ language: i }, l)), o.selection.$from.parent.type !== this.type && o.setSelection(A.near(o.doc.resolve(Math.max(0, o.selection.from - 2)))), o.setMeta("paste", !0), e.dispatch(o), !0;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
})
|
|
308
|
-
];
|
|
309
|
-
}
|
|
310
|
-
}), et = b.create({
|
|
311
|
-
name: "doc",
|
|
312
|
-
topNode: !0,
|
|
313
|
-
content: "block+",
|
|
314
|
-
renderMarkdown: (e, t) => e.content ? t.renderChildren(e.content, `
|
|
315
|
-
|
|
316
|
-
`) : ""
|
|
317
|
-
}), tt = b.create({
|
|
318
|
-
name: "hardBreak",
|
|
319
|
-
markdownTokenName: "br",
|
|
320
|
-
addOptions() {
|
|
321
|
-
return {
|
|
322
|
-
keepMarks: !0,
|
|
323
|
-
HTMLAttributes: {}
|
|
324
|
-
};
|
|
325
|
-
},
|
|
326
|
-
inline: !0,
|
|
327
|
-
group: "inline",
|
|
328
|
-
selectable: !1,
|
|
329
|
-
linebreakReplacement: !0,
|
|
330
|
-
parseHTML() {
|
|
331
|
-
return [{ tag: "br" }];
|
|
332
|
-
},
|
|
333
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
334
|
-
return ["br", y(this.options.HTMLAttributes, e)];
|
|
335
|
-
},
|
|
336
|
-
renderText() {
|
|
337
|
-
return `
|
|
338
|
-
`;
|
|
339
|
-
},
|
|
340
|
-
renderMarkdown: () => `
|
|
341
|
-
`,
|
|
342
|
-
parseMarkdown: () => ({
|
|
343
|
-
type: "hardBreak"
|
|
344
|
-
}),
|
|
345
|
-
addCommands() {
|
|
346
|
-
return {
|
|
347
|
-
setHardBreak: () => ({ commands: e, chain: t, state: n, editor: s }) => e.first([
|
|
348
|
-
() => e.exitCode(),
|
|
349
|
-
() => e.command(() => {
|
|
350
|
-
const { selection: r, storedMarks: i } = n;
|
|
351
|
-
if (r.$from.parent.type.spec.isolating)
|
|
352
|
-
return !1;
|
|
353
|
-
const { keepMarks: o } = this.options, { splittableMarks: a } = s.extensionManager, l = i || r.$to.parentOffset && r.$from.marks();
|
|
354
|
-
return t().insertContent({ type: this.name }).command(({ tr: u, dispatch: p }) => {
|
|
355
|
-
if (p && l && o) {
|
|
356
|
-
const d = l.filter((c) => a.includes(c.type.name));
|
|
357
|
-
u.ensureMarks(d);
|
|
358
|
-
}
|
|
359
|
-
return !0;
|
|
360
|
-
}).run();
|
|
361
|
-
})
|
|
362
|
-
])
|
|
363
|
-
};
|
|
364
|
-
},
|
|
365
|
-
addKeyboardShortcuts() {
|
|
366
|
-
return {
|
|
367
|
-
"Mod-Enter": () => this.editor.commands.setHardBreak(),
|
|
368
|
-
"Shift-Enter": () => this.editor.commands.setHardBreak()
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
}), nt = b.create({
|
|
372
|
-
name: "heading",
|
|
373
|
-
addOptions() {
|
|
374
|
-
return {
|
|
375
|
-
levels: [1, 2, 3, 4, 5, 6],
|
|
376
|
-
HTMLAttributes: {}
|
|
377
|
-
};
|
|
378
|
-
},
|
|
379
|
-
content: "inline*",
|
|
380
|
-
group: "block",
|
|
381
|
-
defining: !0,
|
|
382
|
-
addAttributes() {
|
|
383
|
-
return {
|
|
384
|
-
level: {
|
|
385
|
-
default: 1,
|
|
386
|
-
rendered: !1
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
},
|
|
390
|
-
parseHTML() {
|
|
391
|
-
return this.options.levels.map((e) => ({
|
|
392
|
-
tag: `h${e}`,
|
|
393
|
-
attrs: { level: e }
|
|
394
|
-
}));
|
|
395
|
-
},
|
|
396
|
-
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
397
|
-
return [`h${this.options.levels.includes(e.attrs.level) ? e.attrs.level : this.options.levels[0]}`, y(this.options.HTMLAttributes, t), 0];
|
|
398
|
-
},
|
|
399
|
-
parseMarkdown: (e, t) => t.createNode("heading", { level: e.depth || 1 }, t.parseInline(e.tokens || [])),
|
|
400
|
-
renderMarkdown: (e, t) => {
|
|
401
|
-
var n;
|
|
402
|
-
const s = (n = e.attrs) != null && n.level ? parseInt(e.attrs.level, 10) : 1, r = "#".repeat(s);
|
|
403
|
-
return e.content ? `${r} ${t.renderChildren(e.content)}` : "";
|
|
404
|
-
},
|
|
405
|
-
addCommands() {
|
|
406
|
-
return {
|
|
407
|
-
setHeading: (e) => ({ commands: t }) => this.options.levels.includes(e.level) ? t.setNode(this.name, e) : !1,
|
|
408
|
-
toggleHeading: (e) => ({ commands: t }) => this.options.levels.includes(e.level) ? t.toggleNode(this.name, "paragraph", e) : !1
|
|
409
|
-
};
|
|
410
|
-
},
|
|
411
|
-
addKeyboardShortcuts() {
|
|
412
|
-
return this.options.levels.reduce(
|
|
413
|
-
(e, t) => ({
|
|
414
|
-
...e,
|
|
415
|
-
[`Mod-Alt-${t}`]: () => this.editor.commands.toggleHeading({ level: t })
|
|
416
|
-
}),
|
|
417
|
-
{}
|
|
418
|
-
);
|
|
419
|
-
},
|
|
420
|
-
addInputRules() {
|
|
421
|
-
return this.options.levels.map((e) => G({
|
|
422
|
-
find: new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),
|
|
423
|
-
type: this.type,
|
|
424
|
-
getAttributes: {
|
|
425
|
-
level: e
|
|
426
|
-
}
|
|
427
|
-
}));
|
|
428
|
-
}
|
|
429
|
-
}), rt = b.create({
|
|
430
|
-
name: "horizontalRule",
|
|
431
|
-
addOptions() {
|
|
432
|
-
return {
|
|
433
|
-
HTMLAttributes: {},
|
|
434
|
-
nextNodeType: "paragraph"
|
|
435
|
-
};
|
|
436
|
-
},
|
|
437
|
-
group: "block",
|
|
438
|
-
parseHTML() {
|
|
439
|
-
return [{ tag: "hr" }];
|
|
440
|
-
},
|
|
441
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
442
|
-
return ["hr", y(this.options.HTMLAttributes, e)];
|
|
443
|
-
},
|
|
444
|
-
markdownTokenName: "hr",
|
|
445
|
-
parseMarkdown: (e, t) => t.createNode("horizontalRule"),
|
|
446
|
-
renderMarkdown: () => "---",
|
|
447
|
-
addCommands() {
|
|
448
|
-
return {
|
|
449
|
-
setHorizontalRule: () => ({ chain: e, state: t }) => {
|
|
450
|
-
if (!Ne(t, t.schema.nodes[this.name]))
|
|
451
|
-
return !1;
|
|
452
|
-
const { selection: n } = t, { $to: s } = n, r = e();
|
|
453
|
-
return he(n) ? r.insertContentAt(s.pos, {
|
|
454
|
-
type: this.name
|
|
455
|
-
}) : r.insertContent({ type: this.name }), r.command(({ state: i, tr: o, dispatch: a }) => {
|
|
456
|
-
if (a) {
|
|
457
|
-
const { $to: l } = o.selection, u = l.end();
|
|
458
|
-
if (l.nodeAfter)
|
|
459
|
-
l.nodeAfter.isTextblock ? o.setSelection(A.create(o.doc, l.pos + 1)) : l.nodeAfter.isBlock ? o.setSelection(J.create(o.doc, l.pos)) : o.setSelection(A.create(o.doc, l.pos));
|
|
460
|
-
else {
|
|
461
|
-
const p = i.schema.nodes[this.options.nextNodeType] || l.parent.type.contentMatch.defaultType, d = p?.create();
|
|
462
|
-
d && (o.insert(u, d), o.setSelection(A.create(o.doc, u + 1)));
|
|
463
|
-
}
|
|
464
|
-
o.scrollIntoView();
|
|
465
|
-
}
|
|
466
|
-
return !0;
|
|
467
|
-
}).run();
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
},
|
|
471
|
-
addInputRules() {
|
|
472
|
-
return [
|
|
473
|
-
He({
|
|
474
|
-
find: /^(?:---|—-|___\s|\*\*\*\s)$/,
|
|
475
|
-
type: this.type
|
|
476
|
-
})
|
|
477
|
-
];
|
|
478
|
-
}
|
|
479
|
-
}), st = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/, it = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g, ot = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/, at = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g, lt = K.create({
|
|
480
|
-
name: "italic",
|
|
481
|
-
addOptions() {
|
|
482
|
-
return {
|
|
483
|
-
HTMLAttributes: {}
|
|
484
|
-
};
|
|
485
|
-
},
|
|
486
|
-
parseHTML() {
|
|
487
|
-
return [
|
|
488
|
-
{
|
|
489
|
-
tag: "em"
|
|
490
|
-
},
|
|
491
|
-
{
|
|
492
|
-
tag: "i",
|
|
493
|
-
getAttrs: (e) => e.style.fontStyle !== "normal" && null
|
|
494
|
-
},
|
|
495
|
-
{
|
|
496
|
-
style: "font-style=normal",
|
|
497
|
-
clearMark: (e) => e.type.name === this.name
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
style: "font-style=italic"
|
|
501
|
-
}
|
|
502
|
-
];
|
|
503
|
-
},
|
|
504
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
505
|
-
return ["em", y(this.options.HTMLAttributes, e), 0];
|
|
506
|
-
},
|
|
507
|
-
addCommands() {
|
|
508
|
-
return {
|
|
509
|
-
setItalic: () => ({ commands: e }) => e.setMark(this.name),
|
|
510
|
-
toggleItalic: () => ({ commands: e }) => e.toggleMark(this.name),
|
|
511
|
-
unsetItalic: () => ({ commands: e }) => e.unsetMark(this.name)
|
|
512
|
-
};
|
|
513
|
-
},
|
|
514
|
-
markdownTokenName: "em",
|
|
515
|
-
parseMarkdown: (e, t) => t.applyMark("italic", t.parseInline(e.tokens || [])),
|
|
516
|
-
renderMarkdown: (e, t) => `*${t.renderChildren(e)}*`,
|
|
517
|
-
addKeyboardShortcuts() {
|
|
518
|
-
return {
|
|
519
|
-
"Mod-i": () => this.editor.commands.toggleItalic(),
|
|
520
|
-
"Mod-I": () => this.editor.commands.toggleItalic()
|
|
521
|
-
};
|
|
522
|
-
},
|
|
523
|
-
addInputRules() {
|
|
524
|
-
return [
|
|
525
|
-
D({
|
|
526
|
-
find: st,
|
|
527
|
-
type: this.type
|
|
528
|
-
}),
|
|
529
|
-
D({
|
|
530
|
-
find: ot,
|
|
531
|
-
type: this.type
|
|
532
|
-
})
|
|
533
|
-
];
|
|
534
|
-
},
|
|
535
|
-
addPasteRules() {
|
|
536
|
-
return [
|
|
537
|
-
B({
|
|
538
|
-
find: it,
|
|
539
|
-
type: this.type
|
|
540
|
-
}),
|
|
541
|
-
B({
|
|
542
|
-
find: at,
|
|
543
|
-
type: this.type
|
|
544
|
-
})
|
|
545
|
-
];
|
|
546
|
-
}
|
|
547
|
-
}), dt = Object.defineProperty, ut = (e, t) => {
|
|
548
|
-
for (var n in t)
|
|
549
|
-
dt(e, n, { get: t[n], enumerable: !0 });
|
|
550
|
-
}, ct = "listItem", re = "textStyle", se = /^\s*([-+*])\s$/, ke = b.create({
|
|
551
|
-
name: "bulletList",
|
|
552
|
-
addOptions() {
|
|
553
|
-
return {
|
|
554
|
-
itemTypeName: "listItem",
|
|
555
|
-
HTMLAttributes: {},
|
|
556
|
-
keepMarks: !1,
|
|
557
|
-
keepAttributes: !1
|
|
558
|
-
};
|
|
559
|
-
},
|
|
560
|
-
group: "block list",
|
|
561
|
-
content() {
|
|
562
|
-
return `${this.options.itemTypeName}+`;
|
|
563
|
-
},
|
|
564
|
-
parseHTML() {
|
|
565
|
-
return [{ tag: "ul" }];
|
|
566
|
-
},
|
|
567
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
568
|
-
return ["ul", y(this.options.HTMLAttributes, e), 0];
|
|
569
|
-
},
|
|
570
|
-
markdownTokenName: "list",
|
|
571
|
-
parseMarkdown: (e, t) => e.type !== "list" || e.ordered ? [] : {
|
|
572
|
-
type: "bulletList",
|
|
573
|
-
content: e.items ? t.parseChildren(e.items) : []
|
|
574
|
-
},
|
|
575
|
-
renderMarkdown: (e, t) => e.content ? t.renderChildren(e.content, `
|
|
576
|
-
`) : "",
|
|
577
|
-
markdownOptions: {
|
|
578
|
-
indentsContent: !0
|
|
579
|
-
},
|
|
580
|
-
addCommands() {
|
|
581
|
-
return {
|
|
582
|
-
toggleBulletList: () => ({ commands: e, chain: t }) => this.options.keepAttributes ? t().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ct, this.editor.getAttributes(re)).run() : e.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
|
|
583
|
-
};
|
|
584
|
-
},
|
|
585
|
-
addKeyboardShortcuts() {
|
|
586
|
-
return {
|
|
587
|
-
"Mod-Shift-8": () => this.editor.commands.toggleBulletList()
|
|
588
|
-
};
|
|
589
|
-
},
|
|
590
|
-
addInputRules() {
|
|
591
|
-
let e = E({
|
|
592
|
-
find: se,
|
|
593
|
-
type: this.type
|
|
594
|
-
});
|
|
595
|
-
return (this.options.keepMarks || this.options.keepAttributes) && (e = E({
|
|
596
|
-
find: se,
|
|
597
|
-
type: this.type,
|
|
598
|
-
keepMarks: this.options.keepMarks,
|
|
599
|
-
keepAttributes: this.options.keepAttributes,
|
|
600
|
-
getAttributes: () => this.editor.getAttributes(re),
|
|
601
|
-
editor: this.editor
|
|
602
|
-
})), [e];
|
|
603
|
-
}
|
|
604
|
-
}), ve = b.create({
|
|
605
|
-
name: "listItem",
|
|
606
|
-
addOptions() {
|
|
607
|
-
return {
|
|
608
|
-
HTMLAttributes: {},
|
|
609
|
-
bulletListTypeName: "bulletList",
|
|
610
|
-
orderedListTypeName: "orderedList"
|
|
611
|
-
};
|
|
612
|
-
},
|
|
613
|
-
content: "paragraph block*",
|
|
614
|
-
defining: !0,
|
|
615
|
-
parseHTML() {
|
|
616
|
-
return [
|
|
617
|
-
{
|
|
618
|
-
tag: "li"
|
|
619
|
-
}
|
|
620
|
-
];
|
|
621
|
-
},
|
|
622
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
623
|
-
return ["li", y(this.options.HTMLAttributes, e), 0];
|
|
624
|
-
},
|
|
625
|
-
markdownTokenName: "list_item",
|
|
626
|
-
parseMarkdown: (e, t) => {
|
|
627
|
-
if (e.type !== "list_item")
|
|
628
|
-
return [];
|
|
629
|
-
let n = [];
|
|
630
|
-
if (e.tokens && e.tokens.length > 0)
|
|
631
|
-
if (e.tokens.some((r) => r.type === "paragraph"))
|
|
632
|
-
n = t.parseChildren(e.tokens);
|
|
633
|
-
else {
|
|
634
|
-
const r = e.tokens[0];
|
|
635
|
-
if (r && r.type === "text" && r.tokens && r.tokens.length > 0) {
|
|
636
|
-
if (n = [
|
|
637
|
-
{
|
|
638
|
-
type: "paragraph",
|
|
639
|
-
content: t.parseInline(r.tokens)
|
|
640
|
-
}
|
|
641
|
-
], e.tokens.length > 1) {
|
|
642
|
-
const o = e.tokens.slice(1), a = t.parseChildren(o);
|
|
643
|
-
n.push(...a);
|
|
644
|
-
}
|
|
645
|
-
} else
|
|
646
|
-
n = t.parseChildren(e.tokens);
|
|
647
|
-
}
|
|
648
|
-
return n.length === 0 && (n = [
|
|
649
|
-
{
|
|
650
|
-
type: "paragraph",
|
|
651
|
-
content: []
|
|
652
|
-
}
|
|
653
|
-
]), {
|
|
654
|
-
type: "listItem",
|
|
655
|
-
content: n
|
|
656
|
-
};
|
|
657
|
-
},
|
|
658
|
-
renderMarkdown: (e, t, n) => fe(
|
|
659
|
-
e,
|
|
660
|
-
t,
|
|
661
|
-
(s) => {
|
|
662
|
-
var r, i;
|
|
663
|
-
return s.parentType === "bulletList" ? "- " : s.parentType === "orderedList" ? `${(((i = (r = s.meta) == null ? void 0 : r.parentAttrs) == null ? void 0 : i.start) || 1) + s.index}. ` : "- ";
|
|
664
|
-
},
|
|
665
|
-
n
|
|
666
|
-
),
|
|
667
|
-
addKeyboardShortcuts() {
|
|
668
|
-
return {
|
|
669
|
-
Enter: () => this.editor.commands.splitListItem(this.name),
|
|
670
|
-
Tab: () => this.editor.commands.sinkListItem(this.name),
|
|
671
|
-
"Shift-Tab": () => this.editor.commands.liftListItem(this.name)
|
|
672
|
-
};
|
|
673
|
-
}
|
|
674
|
-
}), pt = {};
|
|
675
|
-
ut(pt, {
|
|
676
|
-
findListItemPos: () => O,
|
|
677
|
-
getNextListDepth: () => Z,
|
|
678
|
-
handleBackspace: () => q,
|
|
679
|
-
handleDelete: () => Y,
|
|
680
|
-
hasListBefore: () => ye,
|
|
681
|
-
hasListItemAfter: () => ht,
|
|
682
|
-
hasListItemBefore: () => be,
|
|
683
|
-
listItemHasSubList: () => Me,
|
|
684
|
-
nextListIsDeeper: () => we,
|
|
685
|
-
nextListIsHigher: () => Le
|
|
686
|
-
});
|
|
687
|
-
var O = (e, t) => {
|
|
688
|
-
const { $from: n } = t.selection, s = me(e, t.schema);
|
|
689
|
-
let r = null, i = n.depth, o = n.pos, a = null;
|
|
690
|
-
for (; i > 0 && a === null; )
|
|
691
|
-
r = n.node(i), r.type === s ? a = i : (i -= 1, o -= 1);
|
|
692
|
-
return a === null ? null : { $pos: t.doc.resolve(o), depth: a };
|
|
693
|
-
}, Z = (e, t) => {
|
|
694
|
-
const n = O(e, t);
|
|
695
|
-
if (!n)
|
|
696
|
-
return !1;
|
|
697
|
-
const [, s] = _e(t, e, n.$pos.pos + 4);
|
|
698
|
-
return s;
|
|
699
|
-
}, ye = (e, t, n) => {
|
|
700
|
-
const { $anchor: s } = e.selection, r = Math.max(0, s.pos - 2), i = e.doc.resolve(r).node();
|
|
701
|
-
return !(!i || !n.includes(i.type.name));
|
|
702
|
-
}, be = (e, t) => {
|
|
703
|
-
var n;
|
|
704
|
-
const { $anchor: s } = t.selection, r = t.doc.resolve(s.pos - 2);
|
|
705
|
-
return !(r.index() === 0 || ((n = r.nodeBefore) == null ? void 0 : n.type.name) !== e);
|
|
706
|
-
}, Me = (e, t, n) => {
|
|
707
|
-
if (!n)
|
|
708
|
-
return !1;
|
|
709
|
-
const s = me(e, t.schema);
|
|
710
|
-
let r = !1;
|
|
711
|
-
return n.descendants((i) => {
|
|
712
|
-
i.type === s && (r = !0);
|
|
713
|
-
}), r;
|
|
714
|
-
}, q = (e, t, n) => {
|
|
715
|
-
if (e.commands.undoInputRule())
|
|
716
|
-
return !0;
|
|
717
|
-
if (e.state.selection.from !== e.state.selection.to)
|
|
718
|
-
return !1;
|
|
719
|
-
if (!X(e.state, t) && ye(e.state, t, n)) {
|
|
720
|
-
const { $anchor: a } = e.state.selection, l = e.state.doc.resolve(a.before() - 1), u = [];
|
|
721
|
-
l.node().descendants((c, h) => {
|
|
722
|
-
c.type.name === t && u.push({ node: c, pos: h });
|
|
723
|
-
});
|
|
724
|
-
const p = u.at(-1);
|
|
725
|
-
if (!p)
|
|
726
|
-
return !1;
|
|
727
|
-
const d = e.state.doc.resolve(l.start() + p.pos + 1);
|
|
728
|
-
return e.chain().cut({ from: a.start() - 1, to: a.end() + 1 }, d.end()).joinForward().run();
|
|
729
|
-
}
|
|
730
|
-
if (!X(e.state, t) || !Oe(e.state))
|
|
731
|
-
return !1;
|
|
732
|
-
const s = O(t, e.state);
|
|
733
|
-
if (!s)
|
|
734
|
-
return !1;
|
|
735
|
-
const i = e.state.doc.resolve(s.$pos.pos - 2).node(s.depth), o = Me(t, e.state, i);
|
|
736
|
-
return be(t, e.state) && !o ? e.commands.joinItemBackward() : e.chain().liftListItem(t).run();
|
|
737
|
-
}, we = (e, t) => {
|
|
738
|
-
const n = Z(e, t), s = O(e, t);
|
|
739
|
-
return !s || !n ? !1 : n > s.depth;
|
|
740
|
-
}, Le = (e, t) => {
|
|
741
|
-
const n = Z(e, t), s = O(e, t);
|
|
742
|
-
return !s || !n ? !1 : n < s.depth;
|
|
743
|
-
}, Y = (e, t) => {
|
|
744
|
-
if (!X(e.state, t) || !Re(e.state, t))
|
|
745
|
-
return !1;
|
|
746
|
-
const { selection: n } = e.state, { $from: s, $to: r } = n;
|
|
747
|
-
return !n.empty && s.sameParent(r) ? !1 : we(t, e.state) ? e.chain().focus(e.state.selection.from + 4).lift(t).joinBackward().run() : Le(t, e.state) ? e.chain().joinForward().joinBackward().run() : e.commands.joinItemForward();
|
|
748
|
-
}, ht = (e, t) => {
|
|
749
|
-
var n;
|
|
750
|
-
const { $anchor: s } = t.selection, r = t.doc.resolve(s.pos - s.parentOffset - 2);
|
|
751
|
-
return !(r.index() === r.parent.childCount - 1 || ((n = r.nodeAfter) == null ? void 0 : n.type.name) !== e);
|
|
752
|
-
}, Te = w.create({
|
|
753
|
-
name: "listKeymap",
|
|
754
|
-
addOptions() {
|
|
755
|
-
return {
|
|
756
|
-
listTypes: [
|
|
757
|
-
{
|
|
758
|
-
itemName: "listItem",
|
|
759
|
-
wrapperNames: ["bulletList", "orderedList"]
|
|
760
|
-
},
|
|
761
|
-
{
|
|
762
|
-
itemName: "taskItem",
|
|
763
|
-
wrapperNames: ["taskList"]
|
|
764
|
-
}
|
|
765
|
-
]
|
|
766
|
-
};
|
|
767
|
-
},
|
|
768
|
-
addKeyboardShortcuts() {
|
|
769
|
-
return {
|
|
770
|
-
Delete: ({ editor: e }) => {
|
|
771
|
-
let t = !1;
|
|
772
|
-
return this.options.listTypes.forEach(({ itemName: n }) => {
|
|
773
|
-
e.state.schema.nodes[n] !== void 0 && Y(e, n) && (t = !0);
|
|
774
|
-
}), t;
|
|
775
|
-
},
|
|
776
|
-
"Mod-Delete": ({ editor: e }) => {
|
|
777
|
-
let t = !1;
|
|
778
|
-
return this.options.listTypes.forEach(({ itemName: n }) => {
|
|
779
|
-
e.state.schema.nodes[n] !== void 0 && Y(e, n) && (t = !0);
|
|
780
|
-
}), t;
|
|
781
|
-
},
|
|
782
|
-
Backspace: ({ editor: e }) => {
|
|
783
|
-
let t = !1;
|
|
784
|
-
return this.options.listTypes.forEach(({ itemName: n, wrapperNames: s }) => {
|
|
785
|
-
e.state.schema.nodes[n] !== void 0 && q(e, n, s) && (t = !0);
|
|
786
|
-
}), t;
|
|
787
|
-
},
|
|
788
|
-
"Mod-Backspace": ({ editor: e }) => {
|
|
789
|
-
let t = !1;
|
|
790
|
-
return this.options.listTypes.forEach(({ itemName: n, wrapperNames: s }) => {
|
|
791
|
-
e.state.schema.nodes[n] !== void 0 && q(e, n, s) && (t = !0);
|
|
792
|
-
}), t;
|
|
793
|
-
}
|
|
794
|
-
};
|
|
795
|
-
}
|
|
796
|
-
}), ie = /^(\s*)(\d+)\.\s+(.*)$/, ft = /^\s/;
|
|
797
|
-
function mt(e) {
|
|
798
|
-
const t = [];
|
|
799
|
-
let n = 0, s = 0;
|
|
800
|
-
for (; n < e.length; ) {
|
|
801
|
-
const r = e[n], i = r.match(ie);
|
|
802
|
-
if (!i)
|
|
803
|
-
break;
|
|
804
|
-
const [, o, a, l] = i, u = o.length;
|
|
805
|
-
let p = l, d = n + 1;
|
|
806
|
-
const c = [r];
|
|
807
|
-
for (; d < e.length; ) {
|
|
808
|
-
const h = e[d];
|
|
809
|
-
if (h.match(ie))
|
|
810
|
-
break;
|
|
811
|
-
if (h.trim() === "")
|
|
812
|
-
c.push(h), p += `
|
|
813
|
-
`, d += 1;
|
|
814
|
-
else if (h.match(ft))
|
|
815
|
-
c.push(h), p += `
|
|
816
|
-
${h.slice(u + 2)}`, d += 1;
|
|
817
|
-
else
|
|
818
|
-
break;
|
|
819
|
-
}
|
|
820
|
-
t.push({
|
|
821
|
-
indent: u,
|
|
822
|
-
number: parseInt(a, 10),
|
|
823
|
-
content: p.trim(),
|
|
824
|
-
raw: c.join(`
|
|
825
|
-
`)
|
|
826
|
-
}), s = d, n = d;
|
|
827
|
-
}
|
|
828
|
-
return [t, s];
|
|
829
|
-
}
|
|
830
|
-
function Ce(e, t, n) {
|
|
831
|
-
var s;
|
|
832
|
-
const r = [];
|
|
833
|
-
let i = 0;
|
|
834
|
-
for (; i < e.length; ) {
|
|
835
|
-
const o = e[i];
|
|
836
|
-
if (o.indent === t) {
|
|
837
|
-
const a = o.content.split(`
|
|
838
|
-
`), l = ((s = a[0]) == null ? void 0 : s.trim()) || "", u = [];
|
|
839
|
-
l && u.push({
|
|
840
|
-
type: "paragraph",
|
|
841
|
-
raw: l,
|
|
842
|
-
tokens: n.inlineTokens(l)
|
|
843
|
-
});
|
|
844
|
-
const p = a.slice(1).join(`
|
|
845
|
-
`).trim();
|
|
846
|
-
if (p) {
|
|
847
|
-
const h = n.blockTokens(p);
|
|
848
|
-
u.push(...h);
|
|
849
|
-
}
|
|
850
|
-
let d = i + 1;
|
|
851
|
-
const c = [];
|
|
852
|
-
for (; d < e.length && e[d].indent > t; )
|
|
853
|
-
c.push(e[d]), d += 1;
|
|
854
|
-
if (c.length > 0) {
|
|
855
|
-
const h = Math.min(...c.map((m) => m.indent)), f = Ce(c, h, n);
|
|
856
|
-
u.push({
|
|
857
|
-
type: "list",
|
|
858
|
-
ordered: !0,
|
|
859
|
-
start: c[0].number,
|
|
860
|
-
items: f,
|
|
861
|
-
raw: c.map((m) => m.raw).join(`
|
|
862
|
-
`)
|
|
863
|
-
});
|
|
864
|
-
}
|
|
865
|
-
r.push({
|
|
866
|
-
type: "list_item",
|
|
867
|
-
raw: o.raw,
|
|
868
|
-
tokens: u
|
|
869
|
-
}), i = d;
|
|
870
|
-
} else
|
|
871
|
-
i += 1;
|
|
872
|
-
}
|
|
873
|
-
return r;
|
|
874
|
-
}
|
|
875
|
-
function gt(e, t) {
|
|
876
|
-
return e.map((n) => {
|
|
877
|
-
if (n.type !== "list_item")
|
|
878
|
-
return t.parseChildren([n])[0];
|
|
879
|
-
const s = [];
|
|
880
|
-
return n.tokens && n.tokens.length > 0 && n.tokens.forEach((r) => {
|
|
881
|
-
if (r.type === "paragraph" || r.type === "list" || r.type === "blockquote" || r.type === "code")
|
|
882
|
-
s.push(...t.parseChildren([r]));
|
|
883
|
-
else if (r.type === "text" && r.tokens) {
|
|
884
|
-
const i = t.parseChildren([r]);
|
|
885
|
-
s.push({
|
|
886
|
-
type: "paragraph",
|
|
887
|
-
content: i
|
|
888
|
-
});
|
|
889
|
-
} else {
|
|
890
|
-
const i = t.parseChildren([r]);
|
|
891
|
-
i.length > 0 && s.push(...i);
|
|
892
|
-
}
|
|
893
|
-
}), {
|
|
894
|
-
type: "listItem",
|
|
895
|
-
content: s
|
|
896
|
-
};
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
var kt = "listItem", oe = "textStyle", ae = /^(\d+)\.\s$/, xe = b.create({
|
|
900
|
-
name: "orderedList",
|
|
901
|
-
addOptions() {
|
|
902
|
-
return {
|
|
903
|
-
itemTypeName: "listItem",
|
|
904
|
-
HTMLAttributes: {},
|
|
905
|
-
keepMarks: !1,
|
|
906
|
-
keepAttributes: !1
|
|
907
|
-
};
|
|
908
|
-
},
|
|
909
|
-
group: "block list",
|
|
910
|
-
content() {
|
|
911
|
-
return `${this.options.itemTypeName}+`;
|
|
912
|
-
},
|
|
913
|
-
addAttributes() {
|
|
914
|
-
return {
|
|
915
|
-
start: {
|
|
916
|
-
default: 1,
|
|
917
|
-
parseHTML: (e) => e.hasAttribute("start") ? parseInt(e.getAttribute("start") || "", 10) : 1
|
|
918
|
-
},
|
|
919
|
-
type: {
|
|
920
|
-
default: null,
|
|
921
|
-
parseHTML: (e) => e.getAttribute("type")
|
|
922
|
-
}
|
|
923
|
-
};
|
|
924
|
-
},
|
|
925
|
-
parseHTML() {
|
|
926
|
-
return [
|
|
927
|
-
{
|
|
928
|
-
tag: "ol"
|
|
929
|
-
}
|
|
930
|
-
];
|
|
931
|
-
},
|
|
932
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
933
|
-
const { start: t, ...n } = e;
|
|
934
|
-
return t === 1 ? ["ol", y(this.options.HTMLAttributes, n), 0] : ["ol", y(this.options.HTMLAttributes, e), 0];
|
|
935
|
-
},
|
|
936
|
-
markdownTokenName: "list",
|
|
937
|
-
parseMarkdown: (e, t) => {
|
|
938
|
-
if (e.type !== "list" || !e.ordered)
|
|
939
|
-
return [];
|
|
940
|
-
const n = e.start || 1, s = e.items ? gt(e.items, t) : [];
|
|
941
|
-
return n !== 1 ? {
|
|
942
|
-
type: "orderedList",
|
|
943
|
-
attrs: { start: n },
|
|
944
|
-
content: s
|
|
945
|
-
} : {
|
|
946
|
-
type: "orderedList",
|
|
947
|
-
content: s
|
|
948
|
-
};
|
|
949
|
-
},
|
|
950
|
-
renderMarkdown: (e, t) => e.content ? t.renderChildren(e.content, `
|
|
951
|
-
`) : "",
|
|
952
|
-
markdownTokenizer: {
|
|
953
|
-
name: "orderedList",
|
|
954
|
-
level: "block",
|
|
955
|
-
start: (e) => {
|
|
956
|
-
const t = e.match(/^(\s*)(\d+)\.\s+/), n = t?.index;
|
|
957
|
-
return n !== void 0 ? n : -1;
|
|
958
|
-
},
|
|
959
|
-
tokenize: (e, t, n) => {
|
|
960
|
-
var s;
|
|
961
|
-
const r = e.split(`
|
|
962
|
-
`), [i, o] = mt(r);
|
|
963
|
-
if (i.length === 0)
|
|
964
|
-
return;
|
|
965
|
-
const a = Ce(i, 0, n);
|
|
966
|
-
return a.length === 0 ? void 0 : {
|
|
967
|
-
type: "list",
|
|
968
|
-
ordered: !0,
|
|
969
|
-
start: ((s = i[0]) == null ? void 0 : s.number) || 1,
|
|
970
|
-
items: a,
|
|
971
|
-
raw: r.slice(0, o).join(`
|
|
972
|
-
`)
|
|
973
|
-
};
|
|
974
|
-
}
|
|
975
|
-
},
|
|
976
|
-
markdownOptions: {
|
|
977
|
-
indentsContent: !0
|
|
978
|
-
},
|
|
979
|
-
addCommands() {
|
|
980
|
-
return {
|
|
981
|
-
toggleOrderedList: () => ({ commands: e, chain: t }) => this.options.keepAttributes ? t().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(kt, this.editor.getAttributes(oe)).run() : e.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
|
|
982
|
-
};
|
|
983
|
-
},
|
|
984
|
-
addKeyboardShortcuts() {
|
|
985
|
-
return {
|
|
986
|
-
"Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
|
|
987
|
-
};
|
|
988
|
-
},
|
|
989
|
-
addInputRules() {
|
|
990
|
-
let e = E({
|
|
991
|
-
find: ae,
|
|
992
|
-
type: this.type,
|
|
993
|
-
getAttributes: (t) => ({ start: +t[1] }),
|
|
994
|
-
joinPredicate: (t, n) => n.childCount + n.attrs.start === +t[1]
|
|
995
|
-
});
|
|
996
|
-
return (this.options.keepMarks || this.options.keepAttributes) && (e = E({
|
|
997
|
-
find: ae,
|
|
998
|
-
type: this.type,
|
|
999
|
-
keepMarks: this.options.keepMarks,
|
|
1000
|
-
keepAttributes: this.options.keepAttributes,
|
|
1001
|
-
getAttributes: (t) => ({ start: +t[1], ...this.editor.getAttributes(oe) }),
|
|
1002
|
-
joinPredicate: (t, n) => n.childCount + n.attrs.start === +t[1],
|
|
1003
|
-
editor: this.editor
|
|
1004
|
-
})), [e];
|
|
1005
|
-
}
|
|
1006
|
-
}), vt = /^\s*(\[([( |x])?\])\s$/, yt = b.create({
|
|
1007
|
-
name: "taskItem",
|
|
1008
|
-
addOptions() {
|
|
1009
|
-
return {
|
|
1010
|
-
nested: !1,
|
|
1011
|
-
HTMLAttributes: {},
|
|
1012
|
-
taskListTypeName: "taskList",
|
|
1013
|
-
a11y: void 0
|
|
1014
|
-
};
|
|
1015
|
-
},
|
|
1016
|
-
content() {
|
|
1017
|
-
return this.options.nested ? "paragraph block*" : "paragraph+";
|
|
1018
|
-
},
|
|
1019
|
-
defining: !0,
|
|
1020
|
-
addAttributes() {
|
|
1021
|
-
return {
|
|
1022
|
-
checked: {
|
|
1023
|
-
default: !1,
|
|
1024
|
-
keepOnSplit: !1,
|
|
1025
|
-
parseHTML: (e) => {
|
|
1026
|
-
const t = e.getAttribute("data-checked");
|
|
1027
|
-
return t === "" || t === "true";
|
|
1028
|
-
},
|
|
1029
|
-
renderHTML: (e) => ({
|
|
1030
|
-
"data-checked": e.checked
|
|
1031
|
-
})
|
|
1032
|
-
}
|
|
1033
|
-
};
|
|
1034
|
-
},
|
|
1035
|
-
parseHTML() {
|
|
1036
|
-
return [
|
|
1037
|
-
{
|
|
1038
|
-
tag: `li[data-type="${this.name}"]`,
|
|
1039
|
-
priority: 51
|
|
1040
|
-
}
|
|
1041
|
-
];
|
|
1042
|
-
},
|
|
1043
|
-
renderHTML({ node: e, HTMLAttributes: t }) {
|
|
1044
|
-
return [
|
|
1045
|
-
"li",
|
|
1046
|
-
y(this.options.HTMLAttributes, t, {
|
|
1047
|
-
"data-type": this.name
|
|
1048
|
-
}),
|
|
1049
|
-
[
|
|
1050
|
-
"label",
|
|
1051
|
-
[
|
|
1052
|
-
"input",
|
|
1053
|
-
{
|
|
1054
|
-
type: "checkbox",
|
|
1055
|
-
checked: e.attrs.checked ? "checked" : null
|
|
1056
|
-
}
|
|
1057
|
-
],
|
|
1058
|
-
["span"]
|
|
1059
|
-
],
|
|
1060
|
-
["div", 0]
|
|
1061
|
-
];
|
|
1062
|
-
},
|
|
1063
|
-
parseMarkdown: (e, t) => {
|
|
1064
|
-
const n = [];
|
|
1065
|
-
if (e.tokens && e.tokens.length > 0 ? n.push(t.createNode("paragraph", {}, t.parseInline(e.tokens))) : e.text ? n.push(t.createNode("paragraph", {}, [t.createNode("text", { text: e.text })])) : n.push(t.createNode("paragraph", {}, [])), e.nestedTokens && e.nestedTokens.length > 0) {
|
|
1066
|
-
const s = t.parseChildren(e.nestedTokens);
|
|
1067
|
-
n.push(...s);
|
|
1068
|
-
}
|
|
1069
|
-
return t.createNode("taskItem", { checked: e.checked || !1 }, n);
|
|
1070
|
-
},
|
|
1071
|
-
renderMarkdown: (e, t) => {
|
|
1072
|
-
var n;
|
|
1073
|
-
const r = `- [${(n = e.attrs) != null && n.checked ? "x" : " "}] `;
|
|
1074
|
-
return fe(e, t, r);
|
|
1075
|
-
},
|
|
1076
|
-
addKeyboardShortcuts() {
|
|
1077
|
-
const e = {
|
|
1078
|
-
Enter: () => this.editor.commands.splitListItem(this.name),
|
|
1079
|
-
"Shift-Tab": () => this.editor.commands.liftListItem(this.name)
|
|
1080
|
-
};
|
|
1081
|
-
return this.options.nested ? {
|
|
1082
|
-
...e,
|
|
1083
|
-
Tab: () => this.editor.commands.sinkListItem(this.name)
|
|
1084
|
-
} : e;
|
|
1085
|
-
},
|
|
1086
|
-
addNodeView() {
|
|
1087
|
-
return ({ node: e, HTMLAttributes: t, getPos: n, editor: s }) => {
|
|
1088
|
-
const r = document.createElement("li"), i = document.createElement("label"), o = document.createElement("span"), a = document.createElement("input"), l = document.createElement("div"), u = (d) => {
|
|
1089
|
-
var c, h;
|
|
1090
|
-
a.ariaLabel = ((h = (c = this.options.a11y) == null ? void 0 : c.checkboxLabel) == null ? void 0 : h.call(c, d, a.checked)) || `Task item checkbox for ${d.textContent || "empty task item"}`;
|
|
1091
|
-
};
|
|
1092
|
-
u(e), i.contentEditable = "false", a.type = "checkbox", a.addEventListener("mousedown", (d) => d.preventDefault()), a.addEventListener("change", (d) => {
|
|
1093
|
-
if (!s.isEditable && !this.options.onReadOnlyChecked) {
|
|
1094
|
-
a.checked = !a.checked;
|
|
1095
|
-
return;
|
|
1096
|
-
}
|
|
1097
|
-
const { checked: c } = d.target;
|
|
1098
|
-
s.isEditable && typeof n == "function" && s.chain().focus(void 0, { scrollIntoView: !1 }).command(({ tr: h }) => {
|
|
1099
|
-
const f = n();
|
|
1100
|
-
if (typeof f != "number")
|
|
1101
|
-
return !1;
|
|
1102
|
-
const m = h.doc.nodeAt(f);
|
|
1103
|
-
return h.setNodeMarkup(f, void 0, {
|
|
1104
|
-
...m?.attrs,
|
|
1105
|
-
checked: c
|
|
1106
|
-
}), !0;
|
|
1107
|
-
}).run(), !s.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(e, c) || (a.checked = !a.checked));
|
|
1108
|
-
}), Object.entries(this.options.HTMLAttributes).forEach(([d, c]) => {
|
|
1109
|
-
r.setAttribute(d, c);
|
|
1110
|
-
}), r.dataset.checked = e.attrs.checked, a.checked = e.attrs.checked, i.append(a, o), r.append(i, l), Object.entries(t).forEach(([d, c]) => {
|
|
1111
|
-
r.setAttribute(d, c);
|
|
1112
|
-
});
|
|
1113
|
-
let p = new Set(Object.keys(t));
|
|
1114
|
-
return {
|
|
1115
|
-
dom: r,
|
|
1116
|
-
contentDOM: l,
|
|
1117
|
-
update: (d) => {
|
|
1118
|
-
if (d.type !== this.type)
|
|
1119
|
-
return !1;
|
|
1120
|
-
r.dataset.checked = d.attrs.checked, a.checked = d.attrs.checked, u(d);
|
|
1121
|
-
const c = s.extensionManager.attributes, h = $e(d, c), f = new Set(Object.keys(h)), m = this.options.HTMLAttributes;
|
|
1122
|
-
return p.forEach((k) => {
|
|
1123
|
-
f.has(k) || (k in m ? r.setAttribute(k, m[k]) : r.removeAttribute(k));
|
|
1124
|
-
}), Object.entries(h).forEach(([k, R]) => {
|
|
1125
|
-
R == null ? k in m ? r.setAttribute(k, m[k]) : r.removeAttribute(k) : r.setAttribute(k, R);
|
|
1126
|
-
}), p = f, !0;
|
|
1127
|
-
}
|
|
1128
|
-
};
|
|
1129
|
-
};
|
|
1130
|
-
},
|
|
1131
|
-
addInputRules() {
|
|
1132
|
-
return [
|
|
1133
|
-
E({
|
|
1134
|
-
find: vt,
|
|
1135
|
-
type: this.type,
|
|
1136
|
-
getAttributes: (e) => ({
|
|
1137
|
-
checked: e[e.length - 1] === "x"
|
|
1138
|
-
})
|
|
1139
|
-
})
|
|
1140
|
-
];
|
|
1141
|
-
}
|
|
1142
|
-
}), bt = b.create({
|
|
1143
|
-
name: "taskList",
|
|
1144
|
-
addOptions() {
|
|
1145
|
-
return {
|
|
1146
|
-
itemTypeName: "taskItem",
|
|
1147
|
-
HTMLAttributes: {}
|
|
1148
|
-
};
|
|
1149
|
-
},
|
|
1150
|
-
group: "block list",
|
|
1151
|
-
content() {
|
|
1152
|
-
return `${this.options.itemTypeName}+`;
|
|
1153
|
-
},
|
|
1154
|
-
parseHTML() {
|
|
1155
|
-
return [
|
|
1156
|
-
{
|
|
1157
|
-
tag: `ul[data-type="${this.name}"]`,
|
|
1158
|
-
priority: 51
|
|
1159
|
-
}
|
|
1160
|
-
];
|
|
1161
|
-
},
|
|
1162
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
1163
|
-
return ["ul", y(this.options.HTMLAttributes, e, { "data-type": this.name }), 0];
|
|
1164
|
-
},
|
|
1165
|
-
parseMarkdown: (e, t) => t.createNode("taskList", {}, t.parseChildren(e.items || [])),
|
|
1166
|
-
renderMarkdown: (e, t) => e.content ? t.renderChildren(e.content, `
|
|
1167
|
-
`) : "",
|
|
1168
|
-
markdownTokenizer: {
|
|
1169
|
-
name: "taskList",
|
|
1170
|
-
level: "block",
|
|
1171
|
-
start(e) {
|
|
1172
|
-
var t;
|
|
1173
|
-
const n = (t = e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)) == null ? void 0 : t.index;
|
|
1174
|
-
return n !== void 0 ? n : -1;
|
|
1175
|
-
},
|
|
1176
|
-
tokenize(e, t, n) {
|
|
1177
|
-
const s = (i) => {
|
|
1178
|
-
const o = ee(
|
|
1179
|
-
i,
|
|
1180
|
-
{
|
|
1181
|
-
itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,
|
|
1182
|
-
extractItemData: (a) => ({
|
|
1183
|
-
indentLevel: a[1].length,
|
|
1184
|
-
mainContent: a[4],
|
|
1185
|
-
checked: a[3].toLowerCase() === "x"
|
|
1186
|
-
}),
|
|
1187
|
-
createToken: (a, l) => ({
|
|
1188
|
-
type: "taskItem",
|
|
1189
|
-
raw: "",
|
|
1190
|
-
mainContent: a.mainContent,
|
|
1191
|
-
indentLevel: a.indentLevel,
|
|
1192
|
-
checked: a.checked,
|
|
1193
|
-
text: a.mainContent,
|
|
1194
|
-
tokens: n.inlineTokens(a.mainContent),
|
|
1195
|
-
nestedTokens: l
|
|
1196
|
-
}),
|
|
1197
|
-
// Allow recursive nesting
|
|
1198
|
-
customNestedParser: s
|
|
1199
|
-
},
|
|
1200
|
-
n
|
|
1201
|
-
);
|
|
1202
|
-
return o ? [
|
|
1203
|
-
{
|
|
1204
|
-
type: "taskList",
|
|
1205
|
-
raw: o.raw,
|
|
1206
|
-
items: o.items
|
|
1207
|
-
}
|
|
1208
|
-
] : n.blockTokens(i);
|
|
1209
|
-
}, r = ee(
|
|
1210
|
-
e,
|
|
1211
|
-
{
|
|
1212
|
-
itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,
|
|
1213
|
-
extractItemData: (i) => ({
|
|
1214
|
-
indentLevel: i[1].length,
|
|
1215
|
-
mainContent: i[4],
|
|
1216
|
-
checked: i[3].toLowerCase() === "x"
|
|
1217
|
-
}),
|
|
1218
|
-
createToken: (i, o) => ({
|
|
1219
|
-
type: "taskItem",
|
|
1220
|
-
raw: "",
|
|
1221
|
-
mainContent: i.mainContent,
|
|
1222
|
-
indentLevel: i.indentLevel,
|
|
1223
|
-
checked: i.checked,
|
|
1224
|
-
text: i.mainContent,
|
|
1225
|
-
tokens: n.inlineTokens(i.mainContent),
|
|
1226
|
-
nestedTokens: o
|
|
1227
|
-
}),
|
|
1228
|
-
// Use the recursive parser for nested content
|
|
1229
|
-
customNestedParser: s
|
|
1230
|
-
},
|
|
1231
|
-
n
|
|
1232
|
-
);
|
|
1233
|
-
if (r)
|
|
1234
|
-
return {
|
|
1235
|
-
type: "taskList",
|
|
1236
|
-
raw: r.raw,
|
|
1237
|
-
items: r.items
|
|
1238
|
-
};
|
|
1239
|
-
}
|
|
1240
|
-
},
|
|
1241
|
-
markdownOptions: {
|
|
1242
|
-
indentsContent: !0
|
|
1243
|
-
},
|
|
1244
|
-
addCommands() {
|
|
1245
|
-
return {
|
|
1246
|
-
toggleTaskList: () => ({ commands: e }) => e.toggleList(this.name, this.options.itemTypeName)
|
|
1247
|
-
};
|
|
1248
|
-
},
|
|
1249
|
-
addKeyboardShortcuts() {
|
|
1250
|
-
return {
|
|
1251
|
-
"Mod-Shift-9": () => this.editor.commands.toggleTaskList()
|
|
1252
|
-
};
|
|
1253
|
-
}
|
|
1254
|
-
});
|
|
1255
|
-
w.create({
|
|
1256
|
-
name: "listKit",
|
|
1257
|
-
addExtensions() {
|
|
1258
|
-
const e = [];
|
|
1259
|
-
return this.options.bulletList !== !1 && e.push(ke.configure(this.options.bulletList)), this.options.listItem !== !1 && e.push(ve.configure(this.options.listItem)), this.options.listKeymap !== !1 && e.push(Te.configure(this.options.listKeymap)), this.options.orderedList !== !1 && e.push(xe.configure(this.options.orderedList)), this.options.taskItem !== !1 && e.push(yt.configure(this.options.taskItem)), this.options.taskList !== !1 && e.push(bt.configure(this.options.taskList)), e;
|
|
1260
|
-
}
|
|
1261
|
-
});
|
|
1262
|
-
var le = " ", Mt = " ", wt = b.create({
|
|
1263
|
-
name: "paragraph",
|
|
1264
|
-
priority: 1e3,
|
|
1265
|
-
addOptions() {
|
|
1266
|
-
return {
|
|
1267
|
-
HTMLAttributes: {}
|
|
1268
|
-
};
|
|
1269
|
-
},
|
|
1270
|
-
group: "block",
|
|
1271
|
-
content: "inline*",
|
|
1272
|
-
parseHTML() {
|
|
1273
|
-
return [{ tag: "p" }];
|
|
1274
|
-
},
|
|
1275
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
1276
|
-
return ["p", y(this.options.HTMLAttributes, e), 0];
|
|
1277
|
-
},
|
|
1278
|
-
parseMarkdown: (e, t) => {
|
|
1279
|
-
const n = e.tokens || [];
|
|
1280
|
-
if (n.length === 1 && n[0].type === "image")
|
|
1281
|
-
return t.parseChildren([n[0]]);
|
|
1282
|
-
const s = t.parseInline(n);
|
|
1283
|
-
return s.length === 1 && s[0].type === "text" && (s[0].text === le || s[0].text === Mt) ? t.createNode("paragraph", void 0, []) : t.createNode("paragraph", void 0, s);
|
|
1284
|
-
},
|
|
1285
|
-
renderMarkdown: (e, t) => {
|
|
1286
|
-
if (!e)
|
|
1287
|
-
return "";
|
|
1288
|
-
const n = Array.isArray(e.content) ? e.content : [];
|
|
1289
|
-
return n.length === 0 ? le : t.renderChildren(n);
|
|
1290
|
-
},
|
|
1291
|
-
addCommands() {
|
|
1292
|
-
return {
|
|
1293
|
-
setParagraph: () => ({ commands: e }) => e.setNode(this.name)
|
|
1294
|
-
};
|
|
1295
|
-
},
|
|
1296
|
-
addKeyboardShortcuts() {
|
|
1297
|
-
return {
|
|
1298
|
-
"Mod-Alt-0": () => this.editor.commands.setParagraph()
|
|
1299
|
-
};
|
|
1300
|
-
}
|
|
1301
|
-
}), Lt = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, Tt = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, Ct = K.create({
|
|
1302
|
-
name: "strike",
|
|
1303
|
-
addOptions() {
|
|
1304
|
-
return {
|
|
1305
|
-
HTMLAttributes: {}
|
|
1306
|
-
};
|
|
1307
|
-
},
|
|
1308
|
-
parseHTML() {
|
|
1309
|
-
return [
|
|
1310
|
-
{
|
|
1311
|
-
tag: "s"
|
|
1312
|
-
},
|
|
1313
|
-
{
|
|
1314
|
-
tag: "del"
|
|
1315
|
-
},
|
|
1316
|
-
{
|
|
1317
|
-
tag: "strike"
|
|
1318
|
-
},
|
|
1319
|
-
{
|
|
1320
|
-
style: "text-decoration",
|
|
1321
|
-
consuming: !1,
|
|
1322
|
-
getAttrs: (e) => e.includes("line-through") ? {} : !1
|
|
1323
|
-
}
|
|
1324
|
-
];
|
|
1325
|
-
},
|
|
1326
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
1327
|
-
return ["s", y(this.options.HTMLAttributes, e), 0];
|
|
1328
|
-
},
|
|
1329
|
-
markdownTokenName: "del",
|
|
1330
|
-
parseMarkdown: (e, t) => t.applyMark("strike", t.parseInline(e.tokens || [])),
|
|
1331
|
-
renderMarkdown: (e, t) => `~~${t.renderChildren(e)}~~`,
|
|
1332
|
-
addCommands() {
|
|
1333
|
-
return {
|
|
1334
|
-
setStrike: () => ({ commands: e }) => e.setMark(this.name),
|
|
1335
|
-
toggleStrike: () => ({ commands: e }) => e.toggleMark(this.name),
|
|
1336
|
-
unsetStrike: () => ({ commands: e }) => e.unsetMark(this.name)
|
|
1337
|
-
};
|
|
1338
|
-
},
|
|
1339
|
-
addKeyboardShortcuts() {
|
|
1340
|
-
return {
|
|
1341
|
-
"Mod-Shift-s": () => this.editor.commands.toggleStrike()
|
|
1342
|
-
};
|
|
1343
|
-
},
|
|
1344
|
-
addInputRules() {
|
|
1345
|
-
return [
|
|
1346
|
-
D({
|
|
1347
|
-
find: Lt,
|
|
1348
|
-
type: this.type
|
|
1349
|
-
})
|
|
1350
|
-
];
|
|
1351
|
-
},
|
|
1352
|
-
addPasteRules() {
|
|
1353
|
-
return [
|
|
1354
|
-
B({
|
|
1355
|
-
find: Tt,
|
|
1356
|
-
type: this.type
|
|
1357
|
-
})
|
|
1358
|
-
];
|
|
1359
|
-
}
|
|
1360
|
-
}), xt = b.create({
|
|
1361
|
-
name: "text",
|
|
1362
|
-
group: "inline",
|
|
1363
|
-
parseMarkdown: (e) => ({
|
|
1364
|
-
type: "text",
|
|
1365
|
-
text: e.text || ""
|
|
1366
|
-
}),
|
|
1367
|
-
renderMarkdown: (e) => e.text || ""
|
|
1368
|
-
}), It = K.create({
|
|
1369
|
-
name: "underline",
|
|
1370
|
-
addOptions() {
|
|
1371
|
-
return {
|
|
1372
|
-
HTMLAttributes: {}
|
|
1373
|
-
};
|
|
1374
|
-
},
|
|
1375
|
-
parseHTML() {
|
|
1376
|
-
return [
|
|
1377
|
-
{
|
|
1378
|
-
tag: "u"
|
|
1379
|
-
},
|
|
1380
|
-
{
|
|
1381
|
-
style: "text-decoration",
|
|
1382
|
-
consuming: !1,
|
|
1383
|
-
getAttrs: (e) => e.includes("underline") ? {} : !1
|
|
1384
|
-
}
|
|
1385
|
-
];
|
|
1386
|
-
},
|
|
1387
|
-
renderHTML({ HTMLAttributes: e }) {
|
|
1388
|
-
return ["u", y(this.options.HTMLAttributes, e), 0];
|
|
1389
|
-
},
|
|
1390
|
-
parseMarkdown(e, t) {
|
|
1391
|
-
return t.applyMark(this.name || "underline", t.parseInline(e.tokens || []));
|
|
1392
|
-
},
|
|
1393
|
-
renderMarkdown(e, t) {
|
|
1394
|
-
return `++${t.renderChildren(e)}++`;
|
|
1395
|
-
},
|
|
1396
|
-
markdownTokenizer: {
|
|
1397
|
-
name: "underline",
|
|
1398
|
-
level: "inline",
|
|
1399
|
-
start(e) {
|
|
1400
|
-
return e.indexOf("++");
|
|
1401
|
-
},
|
|
1402
|
-
tokenize(e, t, n) {
|
|
1403
|
-
const r = /^(\+\+)([\s\S]+?)(\+\+)/.exec(e);
|
|
1404
|
-
if (!r)
|
|
1405
|
-
return;
|
|
1406
|
-
const i = r[2].trim();
|
|
1407
|
-
return {
|
|
1408
|
-
type: "underline",
|
|
1409
|
-
raw: r[0],
|
|
1410
|
-
text: i,
|
|
1411
|
-
tokens: n.inlineTokens(i)
|
|
1412
|
-
};
|
|
1413
|
-
}
|
|
1414
|
-
},
|
|
1415
|
-
addCommands() {
|
|
1416
|
-
return {
|
|
1417
|
-
setUnderline: () => ({ commands: e }) => e.setMark(this.name),
|
|
1418
|
-
toggleUnderline: () => ({ commands: e }) => e.toggleMark(this.name),
|
|
1419
|
-
unsetUnderline: () => ({ commands: e }) => e.unsetMark(this.name)
|
|
1420
|
-
};
|
|
1421
|
-
},
|
|
1422
|
-
addKeyboardShortcuts() {
|
|
1423
|
-
return {
|
|
1424
|
-
"Mod-u": () => this.editor.commands.toggleUnderline(),
|
|
1425
|
-
"Mod-U": () => this.editor.commands.toggleUnderline()
|
|
1426
|
-
};
|
|
1427
|
-
}
|
|
1428
|
-
});
|
|
1429
|
-
function At(e = {}) {
|
|
1430
|
-
return new C({
|
|
1431
|
-
view(t) {
|
|
1432
|
-
return new St(t, e);
|
|
1433
|
-
}
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
class St {
|
|
1437
|
-
constructor(t, n) {
|
|
1438
|
-
var s;
|
|
1439
|
-
this.editorView = t, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (s = n.width) !== null && s !== void 0 ? s : 1, this.color = n.color === !1 ? void 0 : n.color || "black", this.class = n.class, this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((r) => {
|
|
1440
|
-
let i = (o) => {
|
|
1441
|
-
this[r](o);
|
|
1442
|
-
};
|
|
1443
|
-
return t.dom.addEventListener(r, i), { name: r, handler: i };
|
|
1444
|
-
});
|
|
1445
|
-
}
|
|
1446
|
-
destroy() {
|
|
1447
|
-
this.handlers.forEach(({ name: t, handler: n }) => this.editorView.dom.removeEventListener(t, n));
|
|
1448
|
-
}
|
|
1449
|
-
update(t, n) {
|
|
1450
|
-
this.cursorPos != null && n.doc != t.state.doc && (this.cursorPos > t.state.doc.content.size ? this.setCursor(null) : this.updateOverlay());
|
|
1451
|
-
}
|
|
1452
|
-
setCursor(t) {
|
|
1453
|
-
t != this.cursorPos && (this.cursorPos = t, t == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
|
|
1454
|
-
}
|
|
1455
|
-
updateOverlay() {
|
|
1456
|
-
let t = this.editorView.state.doc.resolve(this.cursorPos), n = !t.parent.inlineContent, s, r = this.editorView.dom, i = r.getBoundingClientRect(), o = i.width / r.offsetWidth, a = i.height / r.offsetHeight;
|
|
1457
|
-
if (n) {
|
|
1458
|
-
let d = t.nodeBefore, c = t.nodeAfter;
|
|
1459
|
-
if (d || c) {
|
|
1460
|
-
let h = this.editorView.nodeDOM(this.cursorPos - (d ? d.nodeSize : 0));
|
|
1461
|
-
if (h) {
|
|
1462
|
-
let f = h.getBoundingClientRect(), m = d ? f.bottom : f.top;
|
|
1463
|
-
d && c && (m = (m + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2);
|
|
1464
|
-
let k = this.width / 2 * a;
|
|
1465
|
-
s = { left: f.left, right: f.right, top: m - k, bottom: m + k };
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
if (!s) {
|
|
1470
|
-
let d = this.editorView.coordsAtPos(this.cursorPos), c = this.width / 2 * o;
|
|
1471
|
-
s = { left: d.left - c, right: d.left + c, top: d.top, bottom: d.bottom };
|
|
1472
|
-
}
|
|
1473
|
-
let l = this.editorView.dom.offsetParent;
|
|
1474
|
-
this.element || (this.element = l.appendChild(document.createElement("div")), this.class && (this.element.className = this.class), this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", this.color && (this.element.style.backgroundColor = this.color)), this.element.classList.toggle("prosemirror-dropcursor-block", n), this.element.classList.toggle("prosemirror-dropcursor-inline", !n);
|
|
1475
|
-
let u, p;
|
|
1476
|
-
if (!l || l == document.body && getComputedStyle(l).position == "static")
|
|
1477
|
-
u = -pageXOffset, p = -pageYOffset;
|
|
1478
|
-
else {
|
|
1479
|
-
let d = l.getBoundingClientRect(), c = d.width / l.offsetWidth, h = d.height / l.offsetHeight;
|
|
1480
|
-
u = d.left - l.scrollLeft * c, p = d.top - l.scrollTop * h;
|
|
1481
|
-
}
|
|
1482
|
-
this.element.style.left = (s.left - u) / o + "px", this.element.style.top = (s.top - p) / a + "px", this.element.style.width = (s.right - s.left) / o + "px", this.element.style.height = (s.bottom - s.top) / a + "px";
|
|
1483
|
-
}
|
|
1484
|
-
scheduleRemoval(t) {
|
|
1485
|
-
clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), t);
|
|
1486
|
-
}
|
|
1487
|
-
dragover(t) {
|
|
1488
|
-
if (!this.editorView.editable)
|
|
1489
|
-
return;
|
|
1490
|
-
let n = this.editorView.posAtCoords({ left: t.clientX, top: t.clientY }), s = n && n.inside >= 0 && this.editorView.state.doc.nodeAt(n.inside), r = s && s.type.spec.disableDropCursor, i = typeof r == "function" ? r(this.editorView, n, t) : r;
|
|
1491
|
-
if (n && !i) {
|
|
1492
|
-
let o = n.pos;
|
|
1493
|
-
if (this.editorView.dragging && this.editorView.dragging.slice) {
|
|
1494
|
-
let a = Be(this.editorView.state.doc, o, this.editorView.dragging.slice);
|
|
1495
|
-
a != null && (o = a);
|
|
1496
|
-
}
|
|
1497
|
-
this.setCursor(o), this.scheduleRemoval(5e3);
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
dragend() {
|
|
1501
|
-
this.scheduleRemoval(20);
|
|
1502
|
-
}
|
|
1503
|
-
drop() {
|
|
1504
|
-
this.scheduleRemoval(20);
|
|
1505
|
-
}
|
|
1506
|
-
dragleave(t) {
|
|
1507
|
-
this.editorView.dom.contains(t.relatedTarget) || this.setCursor(null);
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
class g extends H {
|
|
1511
|
-
/**
|
|
1512
|
-
Create a gap cursor.
|
|
1513
|
-
*/
|
|
1514
|
-
constructor(t) {
|
|
1515
|
-
super(t, t);
|
|
1516
|
-
}
|
|
1517
|
-
map(t, n) {
|
|
1518
|
-
let s = t.resolve(n.map(this.head));
|
|
1519
|
-
return g.valid(s) ? new g(s) : H.near(s);
|
|
1520
|
-
}
|
|
1521
|
-
content() {
|
|
1522
|
-
return ge.empty;
|
|
1523
|
-
}
|
|
1524
|
-
eq(t) {
|
|
1525
|
-
return t instanceof g && t.head == this.head;
|
|
1526
|
-
}
|
|
1527
|
-
toJSON() {
|
|
1528
|
-
return { type: "gapcursor", pos: this.head };
|
|
1529
|
-
}
|
|
1530
|
-
/**
|
|
1531
|
-
@internal
|
|
1532
|
-
*/
|
|
1533
|
-
static fromJSON(t, n) {
|
|
1534
|
-
if (typeof n.pos != "number")
|
|
1535
|
-
throw new RangeError("Invalid input for GapCursor.fromJSON");
|
|
1536
|
-
return new g(t.resolve(n.pos));
|
|
1537
|
-
}
|
|
1538
|
-
/**
|
|
1539
|
-
@internal
|
|
1540
|
-
*/
|
|
1541
|
-
getBookmark() {
|
|
1542
|
-
return new Q(this.anchor);
|
|
1543
|
-
}
|
|
1544
|
-
/**
|
|
1545
|
-
@internal
|
|
1546
|
-
*/
|
|
1547
|
-
static valid(t) {
|
|
1548
|
-
let n = t.parent;
|
|
1549
|
-
if (n.isTextblock || !Et(t) || !Pt(t))
|
|
1550
|
-
return !1;
|
|
1551
|
-
let s = n.type.spec.allowGapCursor;
|
|
1552
|
-
if (s != null)
|
|
1553
|
-
return s;
|
|
1554
|
-
let r = n.contentMatchAt(t.index()).defaultType;
|
|
1555
|
-
return r && r.isTextblock;
|
|
1556
|
-
}
|
|
1557
|
-
/**
|
|
1558
|
-
@internal
|
|
1559
|
-
*/
|
|
1560
|
-
static findGapCursorFrom(t, n, s = !1) {
|
|
1561
|
-
e: for (; ; ) {
|
|
1562
|
-
if (!s && g.valid(t))
|
|
1563
|
-
return t;
|
|
1564
|
-
let r = t.pos, i = null;
|
|
1565
|
-
for (let o = t.depth; ; o--) {
|
|
1566
|
-
let a = t.node(o);
|
|
1567
|
-
if (n > 0 ? t.indexAfter(o) < a.childCount : t.index(o) > 0) {
|
|
1568
|
-
i = a.child(n > 0 ? t.indexAfter(o) : t.index(o) - 1);
|
|
1569
|
-
break;
|
|
1570
|
-
} else if (o == 0)
|
|
1571
|
-
return null;
|
|
1572
|
-
r += n;
|
|
1573
|
-
let l = t.doc.resolve(r);
|
|
1574
|
-
if (g.valid(l))
|
|
1575
|
-
return l;
|
|
1576
|
-
}
|
|
1577
|
-
for (; ; ) {
|
|
1578
|
-
let o = n > 0 ? i.firstChild : i.lastChild;
|
|
1579
|
-
if (!o) {
|
|
1580
|
-
if (i.isAtom && !i.isText && !J.isSelectable(i)) {
|
|
1581
|
-
t = t.doc.resolve(r + i.nodeSize * n), s = !1;
|
|
1582
|
-
continue e;
|
|
1583
|
-
}
|
|
1584
|
-
break;
|
|
1585
|
-
}
|
|
1586
|
-
i = o, r += n;
|
|
1587
|
-
let a = t.doc.resolve(r);
|
|
1588
|
-
if (g.valid(a))
|
|
1589
|
-
return a;
|
|
1590
|
-
}
|
|
1591
|
-
return null;
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
}
|
|
1595
|
-
g.prototype.visible = !1;
|
|
1596
|
-
g.findFrom = g.findGapCursorFrom;
|
|
1597
|
-
H.jsonID("gapcursor", g);
|
|
1598
|
-
class Q {
|
|
1599
|
-
constructor(t) {
|
|
1600
|
-
this.pos = t;
|
|
1601
|
-
}
|
|
1602
|
-
map(t) {
|
|
1603
|
-
return new Q(t.map(this.pos));
|
|
1604
|
-
}
|
|
1605
|
-
resolve(t) {
|
|
1606
|
-
let n = t.resolve(this.pos);
|
|
1607
|
-
return g.valid(n) ? new g(n) : H.near(n);
|
|
1608
|
-
}
|
|
1609
|
-
}
|
|
1610
|
-
function Et(e) {
|
|
1611
|
-
for (let t = e.depth; t >= 0; t--) {
|
|
1612
|
-
let n = e.index(t), s = e.node(t);
|
|
1613
|
-
if (n == 0) {
|
|
1614
|
-
if (s.type.spec.isolating)
|
|
1615
|
-
return !0;
|
|
1616
|
-
continue;
|
|
1617
|
-
}
|
|
1618
|
-
for (let r = s.child(n - 1); ; r = r.lastChild) {
|
|
1619
|
-
if (r.childCount == 0 && !r.inlineContent || r.isAtom || r.type.spec.isolating)
|
|
1620
|
-
return !0;
|
|
1621
|
-
if (r.inlineContent)
|
|
1622
|
-
return !1;
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1625
|
-
return !0;
|
|
1626
|
-
}
|
|
1627
|
-
function Pt(e) {
|
|
1628
|
-
for (let t = e.depth; t >= 0; t--) {
|
|
1629
|
-
let n = e.indexAfter(t), s = e.node(t);
|
|
1630
|
-
if (n == s.childCount) {
|
|
1631
|
-
if (s.type.spec.isolating)
|
|
1632
|
-
return !0;
|
|
1633
|
-
continue;
|
|
1634
|
-
}
|
|
1635
|
-
for (let r = s.child(n); ; r = r.firstChild) {
|
|
1636
|
-
if (r.childCount == 0 && !r.inlineContent || r.isAtom || r.type.spec.isolating)
|
|
1637
|
-
return !0;
|
|
1638
|
-
if (r.inlineContent)
|
|
1639
|
-
return !1;
|
|
1640
|
-
}
|
|
1641
|
-
}
|
|
1642
|
-
return !0;
|
|
1643
|
-
}
|
|
1644
|
-
function Ht() {
|
|
1645
|
-
return new C({
|
|
1646
|
-
props: {
|
|
1647
|
-
decorations: _t,
|
|
1648
|
-
createSelectionBetween(e, t, n) {
|
|
1649
|
-
return t.pos == n.pos && g.valid(n) ? new g(n) : null;
|
|
1650
|
-
},
|
|
1651
|
-
handleClick: Ot,
|
|
1652
|
-
handleKeyDown: Nt,
|
|
1653
|
-
handleDOMEvents: { beforeinput: Rt }
|
|
1654
|
-
}
|
|
1655
|
-
});
|
|
1656
|
-
}
|
|
1657
|
-
const Nt = De({
|
|
1658
|
-
ArrowLeft: _("horiz", -1),
|
|
1659
|
-
ArrowRight: _("horiz", 1),
|
|
1660
|
-
ArrowUp: _("vert", -1),
|
|
1661
|
-
ArrowDown: _("vert", 1)
|
|
1662
|
-
});
|
|
1663
|
-
function _(e, t) {
|
|
1664
|
-
const n = e == "vert" ? t > 0 ? "down" : "up" : t > 0 ? "right" : "left";
|
|
1665
|
-
return function(s, r, i) {
|
|
1666
|
-
let o = s.selection, a = t > 0 ? o.$to : o.$from, l = o.empty;
|
|
1667
|
-
if (o instanceof A) {
|
|
1668
|
-
if (!i.endOfTextblock(n) || a.depth == 0)
|
|
1669
|
-
return !1;
|
|
1670
|
-
l = !1, a = s.doc.resolve(t > 0 ? a.after() : a.before());
|
|
1671
|
-
}
|
|
1672
|
-
let u = g.findGapCursorFrom(a, t, l);
|
|
1673
|
-
return u ? (r && r(s.tr.setSelection(new g(u))), !0) : !1;
|
|
1674
|
-
};
|
|
1675
|
-
}
|
|
1676
|
-
function Ot(e, t, n) {
|
|
1677
|
-
if (!e || !e.editable)
|
|
1678
|
-
return !1;
|
|
1679
|
-
let s = e.state.doc.resolve(t);
|
|
1680
|
-
if (!g.valid(s))
|
|
1681
|
-
return !1;
|
|
1682
|
-
let r = e.posAtCoords({ left: n.clientX, top: n.clientY });
|
|
1683
|
-
return r && r.inside > -1 && J.isSelectable(e.state.doc.nodeAt(r.inside)) ? !1 : (e.dispatch(e.state.tr.setSelection(new g(s))), !0);
|
|
1684
|
-
}
|
|
1685
|
-
function Rt(e, t) {
|
|
1686
|
-
if (t.inputType != "insertCompositionText" || !(e.state.selection instanceof g))
|
|
1687
|
-
return !1;
|
|
1688
|
-
let { $from: n } = e.state.selection, s = n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);
|
|
1689
|
-
if (!s)
|
|
1690
|
-
return !1;
|
|
1691
|
-
let r = te.empty;
|
|
1692
|
-
for (let o = s.length - 1; o >= 0; o--)
|
|
1693
|
-
r = te.from(s[o].createAndFill(null, r));
|
|
1694
|
-
let i = e.state.tr.replace(n.pos, n.pos, new ge(r, 0, 0));
|
|
1695
|
-
return i.setSelection(A.near(i.doc.resolve(n.pos + 1))), e.dispatch(i), !1;
|
|
1696
|
-
}
|
|
1697
|
-
function _t(e) {
|
|
1698
|
-
if (!(e.selection instanceof g))
|
|
1699
|
-
return null;
|
|
1700
|
-
let t = document.createElement("div");
|
|
1701
|
-
return t.className = "ProseMirror-gapcursor", N.create(e.doc, [j.widget(e.selection.head, t, { key: "gapcursor" })]);
|
|
1702
|
-
}
|
|
1703
|
-
var z = 200, v = function() {
|
|
1704
|
-
};
|
|
1705
|
-
v.prototype.append = function(t) {
|
|
1706
|
-
return t.length ? (t = v.from(t), !this.length && t || t.length < z && this.leafAppend(t) || this.length < z && t.leafPrepend(this) || this.appendInner(t)) : this;
|
|
1707
|
-
};
|
|
1708
|
-
v.prototype.prepend = function(t) {
|
|
1709
|
-
return t.length ? v.from(t).append(this) : this;
|
|
1710
|
-
};
|
|
1711
|
-
v.prototype.appendInner = function(t) {
|
|
1712
|
-
return new $t(this, t);
|
|
1713
|
-
};
|
|
1714
|
-
v.prototype.slice = function(t, n) {
|
|
1715
|
-
return t === void 0 && (t = 0), n === void 0 && (n = this.length), t >= n ? v.empty : this.sliceInner(Math.max(0, t), Math.min(this.length, n));
|
|
1716
|
-
};
|
|
1717
|
-
v.prototype.get = function(t) {
|
|
1718
|
-
if (!(t < 0 || t >= this.length))
|
|
1719
|
-
return this.getInner(t);
|
|
1720
|
-
};
|
|
1721
|
-
v.prototype.forEach = function(t, n, s) {
|
|
1722
|
-
n === void 0 && (n = 0), s === void 0 && (s = this.length), n <= s ? this.forEachInner(t, n, s, 0) : this.forEachInvertedInner(t, n, s, 0);
|
|
1723
|
-
};
|
|
1724
|
-
v.prototype.map = function(t, n, s) {
|
|
1725
|
-
n === void 0 && (n = 0), s === void 0 && (s = this.length);
|
|
1726
|
-
var r = [];
|
|
1727
|
-
return this.forEach(function(i, o) {
|
|
1728
|
-
return r.push(t(i, o));
|
|
1729
|
-
}, n, s), r;
|
|
1730
|
-
};
|
|
1731
|
-
v.from = function(t) {
|
|
1732
|
-
return t instanceof v ? t : t && t.length ? new Ie(t) : v.empty;
|
|
1733
|
-
};
|
|
1734
|
-
var Ie = /* @__PURE__ */ (function(e) {
|
|
1735
|
-
function t(s) {
|
|
1736
|
-
e.call(this), this.values = s;
|
|
1737
|
-
}
|
|
1738
|
-
e && (t.__proto__ = e), t.prototype = Object.create(e && e.prototype), t.prototype.constructor = t;
|
|
1739
|
-
var n = { length: { configurable: !0 }, depth: { configurable: !0 } };
|
|
1740
|
-
return t.prototype.flatten = function() {
|
|
1741
|
-
return this.values;
|
|
1742
|
-
}, t.prototype.sliceInner = function(r, i) {
|
|
1743
|
-
return r == 0 && i == this.length ? this : new t(this.values.slice(r, i));
|
|
1744
|
-
}, t.prototype.getInner = function(r) {
|
|
1745
|
-
return this.values[r];
|
|
1746
|
-
}, t.prototype.forEachInner = function(r, i, o, a) {
|
|
1747
|
-
for (var l = i; l < o; l++)
|
|
1748
|
-
if (r(this.values[l], a + l) === !1)
|
|
1749
|
-
return !1;
|
|
1750
|
-
}, t.prototype.forEachInvertedInner = function(r, i, o, a) {
|
|
1751
|
-
for (var l = i - 1; l >= o; l--)
|
|
1752
|
-
if (r(this.values[l], a + l) === !1)
|
|
1753
|
-
return !1;
|
|
1754
|
-
}, t.prototype.leafAppend = function(r) {
|
|
1755
|
-
if (this.length + r.length <= z)
|
|
1756
|
-
return new t(this.values.concat(r.flatten()));
|
|
1757
|
-
}, t.prototype.leafPrepend = function(r) {
|
|
1758
|
-
if (this.length + r.length <= z)
|
|
1759
|
-
return new t(r.flatten().concat(this.values));
|
|
1760
|
-
}, n.length.get = function() {
|
|
1761
|
-
return this.values.length;
|
|
1762
|
-
}, n.depth.get = function() {
|
|
1763
|
-
return 0;
|
|
1764
|
-
}, Object.defineProperties(t.prototype, n), t;
|
|
1765
|
-
})(v);
|
|
1766
|
-
v.empty = new Ie([]);
|
|
1767
|
-
var $t = /* @__PURE__ */ (function(e) {
|
|
1768
|
-
function t(n, s) {
|
|
1769
|
-
e.call(this), this.left = n, this.right = s, this.length = n.length + s.length, this.depth = Math.max(n.depth, s.depth) + 1;
|
|
1770
|
-
}
|
|
1771
|
-
return e && (t.__proto__ = e), t.prototype = Object.create(e && e.prototype), t.prototype.constructor = t, t.prototype.flatten = function() {
|
|
1772
|
-
return this.left.flatten().concat(this.right.flatten());
|
|
1773
|
-
}, t.prototype.getInner = function(s) {
|
|
1774
|
-
return s < this.left.length ? this.left.get(s) : this.right.get(s - this.left.length);
|
|
1775
|
-
}, t.prototype.forEachInner = function(s, r, i, o) {
|
|
1776
|
-
var a = this.left.length;
|
|
1777
|
-
if (r < a && this.left.forEachInner(s, r, Math.min(i, a), o) === !1 || i > a && this.right.forEachInner(s, Math.max(r - a, 0), Math.min(this.length, i) - a, o + a) === !1)
|
|
1778
|
-
return !1;
|
|
1779
|
-
}, t.prototype.forEachInvertedInner = function(s, r, i, o) {
|
|
1780
|
-
var a = this.left.length;
|
|
1781
|
-
if (r > a && this.right.forEachInvertedInner(s, r - a, Math.max(i, a) - a, o + a) === !1 || i < a && this.left.forEachInvertedInner(s, Math.min(r, a), i, o) === !1)
|
|
1782
|
-
return !1;
|
|
1783
|
-
}, t.prototype.sliceInner = function(s, r) {
|
|
1784
|
-
if (s == 0 && r == this.length)
|
|
1785
|
-
return this;
|
|
1786
|
-
var i = this.left.length;
|
|
1787
|
-
return r <= i ? this.left.slice(s, r) : s >= i ? this.right.slice(s - i, r - i) : this.left.slice(s, i).append(this.right.slice(0, r - i));
|
|
1788
|
-
}, t.prototype.leafAppend = function(s) {
|
|
1789
|
-
var r = this.right.leafAppend(s);
|
|
1790
|
-
if (r)
|
|
1791
|
-
return new t(this.left, r);
|
|
1792
|
-
}, t.prototype.leafPrepend = function(s) {
|
|
1793
|
-
var r = this.left.leafPrepend(s);
|
|
1794
|
-
if (r)
|
|
1795
|
-
return new t(r, this.right);
|
|
1796
|
-
}, t.prototype.appendInner = function(s) {
|
|
1797
|
-
return this.left.depth >= Math.max(this.right.depth, s.depth) + 1 ? new t(this.left, new t(this.right, s)) : new t(this, s);
|
|
1798
|
-
}, t;
|
|
1799
|
-
})(v);
|
|
1800
|
-
const Bt = 500;
|
|
1801
|
-
class M {
|
|
1802
|
-
constructor(t, n) {
|
|
1803
|
-
this.items = t, this.eventCount = n;
|
|
1804
|
-
}
|
|
1805
|
-
// Pop the latest event off the branch's history and apply it
|
|
1806
|
-
// to a document transform.
|
|
1807
|
-
popEvent(t, n) {
|
|
1808
|
-
if (this.eventCount == 0)
|
|
1809
|
-
return null;
|
|
1810
|
-
let s = this.items.length;
|
|
1811
|
-
for (; ; s--)
|
|
1812
|
-
if (this.items.get(s - 1).selection) {
|
|
1813
|
-
--s;
|
|
1814
|
-
break;
|
|
1815
|
-
}
|
|
1816
|
-
let r, i;
|
|
1817
|
-
n && (r = this.remapping(s, this.items.length), i = r.maps.length);
|
|
1818
|
-
let o = t.tr, a, l, u = [], p = [];
|
|
1819
|
-
return this.items.forEach((d, c) => {
|
|
1820
|
-
if (!d.step) {
|
|
1821
|
-
r || (r = this.remapping(s, c + 1), i = r.maps.length), i--, p.push(d);
|
|
1822
|
-
return;
|
|
1823
|
-
}
|
|
1824
|
-
if (r) {
|
|
1825
|
-
p.push(new L(d.map));
|
|
1826
|
-
let h = d.step.map(r.slice(i)), f;
|
|
1827
|
-
h && o.maybeStep(h).doc && (f = o.mapping.maps[o.mapping.maps.length - 1], u.push(new L(f, void 0, void 0, u.length + p.length))), i--, f && r.appendMap(f, i);
|
|
1828
|
-
} else
|
|
1829
|
-
o.maybeStep(d.step);
|
|
1830
|
-
if (d.selection)
|
|
1831
|
-
return a = r ? d.selection.map(r.slice(i)) : d.selection, l = new M(this.items.slice(0, s).append(p.reverse().concat(u)), this.eventCount - 1), !1;
|
|
1832
|
-
}, this.items.length, 0), { remaining: l, transform: o, selection: a };
|
|
1833
|
-
}
|
|
1834
|
-
// Create a new branch with the given transform added.
|
|
1835
|
-
addTransform(t, n, s, r) {
|
|
1836
|
-
let i = [], o = this.eventCount, a = this.items, l = !r && a.length ? a.get(a.length - 1) : null;
|
|
1837
|
-
for (let p = 0; p < t.steps.length; p++) {
|
|
1838
|
-
let d = t.steps[p].invert(t.docs[p]), c = new L(t.mapping.maps[p], d, n), h;
|
|
1839
|
-
(h = l && l.merge(c)) && (c = h, p ? i.pop() : a = a.slice(0, a.length - 1)), i.push(c), n && (o++, n = void 0), r || (l = c);
|
|
1840
|
-
}
|
|
1841
|
-
let u = o - s.depth;
|
|
1842
|
-
return u > zt && (a = Dt(a, u), o -= u), new M(a.append(i), o);
|
|
1843
|
-
}
|
|
1844
|
-
remapping(t, n) {
|
|
1845
|
-
let s = new ze();
|
|
1846
|
-
return this.items.forEach((r, i) => {
|
|
1847
|
-
let o = r.mirrorOffset != null && i - r.mirrorOffset >= t ? s.maps.length - r.mirrorOffset : void 0;
|
|
1848
|
-
s.appendMap(r.map, o);
|
|
1849
|
-
}, t, n), s;
|
|
1850
|
-
}
|
|
1851
|
-
addMaps(t) {
|
|
1852
|
-
return this.eventCount == 0 ? this : new M(this.items.append(t.map((n) => new L(n))), this.eventCount);
|
|
1853
|
-
}
|
|
1854
|
-
// When the collab module receives remote changes, the history has
|
|
1855
|
-
// to know about those, so that it can adjust the steps that were
|
|
1856
|
-
// rebased on top of the remote changes, and include the position
|
|
1857
|
-
// maps for the remote changes in its array of items.
|
|
1858
|
-
rebased(t, n) {
|
|
1859
|
-
if (!this.eventCount)
|
|
1860
|
-
return this;
|
|
1861
|
-
let s = [], r = Math.max(0, this.items.length - n), i = t.mapping, o = t.steps.length, a = this.eventCount;
|
|
1862
|
-
this.items.forEach((c) => {
|
|
1863
|
-
c.selection && a--;
|
|
1864
|
-
}, r);
|
|
1865
|
-
let l = n;
|
|
1866
|
-
this.items.forEach((c) => {
|
|
1867
|
-
let h = i.getMirror(--l);
|
|
1868
|
-
if (h == null)
|
|
1869
|
-
return;
|
|
1870
|
-
o = Math.min(o, h);
|
|
1871
|
-
let f = i.maps[h];
|
|
1872
|
-
if (c.step) {
|
|
1873
|
-
let m = t.steps[h].invert(t.docs[h]), k = c.selection && c.selection.map(i.slice(l + 1, h));
|
|
1874
|
-
k && a++, s.push(new L(f, m, k));
|
|
1875
|
-
} else
|
|
1876
|
-
s.push(new L(f));
|
|
1877
|
-
}, r);
|
|
1878
|
-
let u = [];
|
|
1879
|
-
for (let c = n; c < o; c++)
|
|
1880
|
-
u.push(new L(i.maps[c]));
|
|
1881
|
-
let p = this.items.slice(0, r).append(u).append(s), d = new M(p, a);
|
|
1882
|
-
return d.emptyItemCount() > Bt && (d = d.compress(this.items.length - s.length)), d;
|
|
1883
|
-
}
|
|
1884
|
-
emptyItemCount() {
|
|
1885
|
-
let t = 0;
|
|
1886
|
-
return this.items.forEach((n) => {
|
|
1887
|
-
n.step || t++;
|
|
1888
|
-
}), t;
|
|
1889
|
-
}
|
|
1890
|
-
// Compressing a branch means rewriting it to push the air (map-only
|
|
1891
|
-
// items) out. During collaboration, these naturally accumulate
|
|
1892
|
-
// because each remote change adds one. The `upto` argument is used
|
|
1893
|
-
// to ensure that only the items below a given level are compressed,
|
|
1894
|
-
// because `rebased` relies on a clean, untouched set of items in
|
|
1895
|
-
// order to associate old items with rebased steps.
|
|
1896
|
-
compress(t = this.items.length) {
|
|
1897
|
-
let n = this.remapping(0, t), s = n.maps.length, r = [], i = 0;
|
|
1898
|
-
return this.items.forEach((o, a) => {
|
|
1899
|
-
if (a >= t)
|
|
1900
|
-
r.push(o), o.selection && i++;
|
|
1901
|
-
else if (o.step) {
|
|
1902
|
-
let l = o.step.map(n.slice(s)), u = l && l.getMap();
|
|
1903
|
-
if (s--, u && n.appendMap(u, s), l) {
|
|
1904
|
-
let p = o.selection && o.selection.map(n.slice(s));
|
|
1905
|
-
p && i++;
|
|
1906
|
-
let d = new L(u.invert(), l, p), c, h = r.length - 1;
|
|
1907
|
-
(c = r.length && r[h].merge(d)) ? r[h] = c : r.push(d);
|
|
1908
|
-
}
|
|
1909
|
-
} else o.map && s--;
|
|
1910
|
-
}, this.items.length, 0), new M(v.from(r.reverse()), i);
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
M.empty = new M(v.empty, 0);
|
|
1914
|
-
function Dt(e, t) {
|
|
1915
|
-
let n;
|
|
1916
|
-
return e.forEach((s, r) => {
|
|
1917
|
-
if (s.selection && t-- == 0)
|
|
1918
|
-
return n = r, !1;
|
|
1919
|
-
}), e.slice(n);
|
|
1920
|
-
}
|
|
1921
|
-
class L {
|
|
1922
|
-
constructor(t, n, s, r) {
|
|
1923
|
-
this.map = t, this.step = n, this.selection = s, this.mirrorOffset = r;
|
|
1924
|
-
}
|
|
1925
|
-
merge(t) {
|
|
1926
|
-
if (this.step && t.step && !t.selection) {
|
|
1927
|
-
let n = t.step.merge(this.step);
|
|
1928
|
-
if (n)
|
|
1929
|
-
return new L(n.getMap().invert(), n, this.selection);
|
|
1930
|
-
}
|
|
1931
|
-
}
|
|
1932
|
-
}
|
|
1933
|
-
class x {
|
|
1934
|
-
constructor(t, n, s, r, i) {
|
|
1935
|
-
this.done = t, this.undone = n, this.prevRanges = s, this.prevTime = r, this.prevComposition = i;
|
|
1936
|
-
}
|
|
1937
|
-
}
|
|
1938
|
-
const zt = 20;
|
|
1939
|
-
function Kt(e, t, n, s) {
|
|
1940
|
-
let r = n.getMeta(S), i;
|
|
1941
|
-
if (r)
|
|
1942
|
-
return r.historyState;
|
|
1943
|
-
n.getMeta(Wt) && (e = new x(e.done, e.undone, null, 0, -1));
|
|
1944
|
-
let o = n.getMeta("appendedTransaction");
|
|
1945
|
-
if (n.steps.length == 0)
|
|
1946
|
-
return e;
|
|
1947
|
-
if (o && o.getMeta(S))
|
|
1948
|
-
return o.getMeta(S).redo ? new x(e.done.addTransform(n, void 0, s, $(t)), e.undone, de(n.mapping.maps), e.prevTime, e.prevComposition) : new x(e.done, e.undone.addTransform(n, void 0, s, $(t)), null, e.prevTime, e.prevComposition);
|
|
1949
|
-
if (n.getMeta("addToHistory") !== !1 && !(o && o.getMeta("addToHistory") === !1)) {
|
|
1950
|
-
let a = n.getMeta("composition"), l = e.prevTime == 0 || !o && e.prevComposition != a && (e.prevTime < (n.time || 0) - s.newGroupDelay || !jt(n, e.prevRanges)), u = o ? F(e.prevRanges, n.mapping) : de(n.mapping.maps);
|
|
1951
|
-
return new x(e.done.addTransform(n, l ? t.selection.getBookmark() : void 0, s, $(t)), M.empty, u, n.time, a ?? e.prevComposition);
|
|
1952
|
-
} else return (i = n.getMeta("rebased")) ? new x(e.done.rebased(n, i), e.undone.rebased(n, i), F(e.prevRanges, n.mapping), e.prevTime, e.prevComposition) : new x(e.done.addMaps(n.mapping.maps), e.undone.addMaps(n.mapping.maps), F(e.prevRanges, n.mapping), e.prevTime, e.prevComposition);
|
|
1953
|
-
}
|
|
1954
|
-
function jt(e, t) {
|
|
1955
|
-
if (!t)
|
|
1956
|
-
return !1;
|
|
1957
|
-
if (!e.docChanged)
|
|
1958
|
-
return !0;
|
|
1959
|
-
let n = !1;
|
|
1960
|
-
return e.mapping.maps[0].forEach((s, r) => {
|
|
1961
|
-
for (let i = 0; i < t.length; i += 2)
|
|
1962
|
-
s <= t[i + 1] && r >= t[i] && (n = !0);
|
|
1963
|
-
}), n;
|
|
1964
|
-
}
|
|
1965
|
-
function de(e) {
|
|
1966
|
-
let t = [];
|
|
1967
|
-
for (let n = e.length - 1; n >= 0 && t.length == 0; n--)
|
|
1968
|
-
e[n].forEach((s, r, i, o) => t.push(i, o));
|
|
1969
|
-
return t;
|
|
1970
|
-
}
|
|
1971
|
-
function F(e, t) {
|
|
1972
|
-
if (!e)
|
|
1973
|
-
return null;
|
|
1974
|
-
let n = [];
|
|
1975
|
-
for (let s = 0; s < e.length; s += 2) {
|
|
1976
|
-
let r = t.map(e[s], 1), i = t.map(e[s + 1], -1);
|
|
1977
|
-
r <= i && n.push(r, i);
|
|
1978
|
-
}
|
|
1979
|
-
return n;
|
|
1980
|
-
}
|
|
1981
|
-
function Vt(e, t, n) {
|
|
1982
|
-
let s = $(t), r = S.get(t).spec.config, i = (n ? e.undone : e.done).popEvent(t, s);
|
|
1983
|
-
if (!i)
|
|
1984
|
-
return null;
|
|
1985
|
-
let o = i.selection.resolve(i.transform.doc), a = (n ? e.done : e.undone).addTransform(i.transform, t.selection.getBookmark(), r, s), l = new x(n ? a : i.remaining, n ? i.remaining : a, null, 0, -1);
|
|
1986
|
-
return i.transform.setSelection(o).setMeta(S, { redo: n, historyState: l });
|
|
1987
|
-
}
|
|
1988
|
-
let U = !1, ue = null;
|
|
1989
|
-
function $(e) {
|
|
1990
|
-
let t = e.plugins;
|
|
1991
|
-
if (ue != t) {
|
|
1992
|
-
U = !1, ue = t;
|
|
1993
|
-
for (let n = 0; n < t.length; n++)
|
|
1994
|
-
if (t[n].spec.historyPreserveItems) {
|
|
1995
|
-
U = !0;
|
|
1996
|
-
break;
|
|
1997
|
-
}
|
|
1998
|
-
}
|
|
1999
|
-
return U;
|
|
2000
|
-
}
|
|
2001
|
-
const S = new I("history"), Wt = new I("closeHistory");
|
|
2002
|
-
function Ft(e = {}) {
|
|
2003
|
-
return e = {
|
|
2004
|
-
depth: e.depth || 100,
|
|
2005
|
-
newGroupDelay: e.newGroupDelay || 500
|
|
2006
|
-
}, new C({
|
|
2007
|
-
key: S,
|
|
2008
|
-
state: {
|
|
2009
|
-
init() {
|
|
2010
|
-
return new x(M.empty, M.empty, null, 0, -1);
|
|
2011
|
-
},
|
|
2012
|
-
apply(t, n, s) {
|
|
2013
|
-
return Kt(n, s, t, e);
|
|
2014
|
-
}
|
|
2015
|
-
},
|
|
2016
|
-
config: e,
|
|
2017
|
-
props: {
|
|
2018
|
-
handleDOMEvents: {
|
|
2019
|
-
beforeinput(t, n) {
|
|
2020
|
-
let s = n.inputType, r = s == "historyUndo" ? Se : s == "historyRedo" ? Ee : null;
|
|
2021
|
-
return r ? (n.preventDefault(), r(t.state, t.dispatch)) : !1;
|
|
2022
|
-
}
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
|
-
});
|
|
2026
|
-
}
|
|
2027
|
-
function Ae(e, t) {
|
|
2028
|
-
return (n, s) => {
|
|
2029
|
-
let r = S.getState(n);
|
|
2030
|
-
if (!r || (e ? r.undone : r.done).eventCount == 0)
|
|
2031
|
-
return !1;
|
|
2032
|
-
if (s) {
|
|
2033
|
-
let i = Vt(r, n, e);
|
|
2034
|
-
i && s(t ? i.scrollIntoView() : i);
|
|
2035
|
-
}
|
|
2036
|
-
return !0;
|
|
2037
|
-
};
|
|
2038
|
-
}
|
|
2039
|
-
const Se = Ae(!1, !0), Ee = Ae(!0, !0);
|
|
2040
|
-
w.create({
|
|
2041
|
-
name: "characterCount",
|
|
2042
|
-
addOptions() {
|
|
2043
|
-
return {
|
|
2044
|
-
limit: null,
|
|
2045
|
-
mode: "textSize",
|
|
2046
|
-
textCounter: (e) => e.length,
|
|
2047
|
-
wordCounter: (e) => e.split(" ").filter((t) => t !== "").length
|
|
2048
|
-
};
|
|
2049
|
-
},
|
|
2050
|
-
addStorage() {
|
|
2051
|
-
return {
|
|
2052
|
-
characters: () => 0,
|
|
2053
|
-
words: () => 0
|
|
2054
|
-
};
|
|
2055
|
-
},
|
|
2056
|
-
onBeforeCreate() {
|
|
2057
|
-
this.storage.characters = (e) => {
|
|
2058
|
-
const t = e?.node || this.editor.state.doc;
|
|
2059
|
-
if ((e?.mode || this.options.mode) === "textSize") {
|
|
2060
|
-
const s = t.textBetween(0, t.content.size, void 0, " ");
|
|
2061
|
-
return this.options.textCounter(s);
|
|
2062
|
-
}
|
|
2063
|
-
return t.nodeSize;
|
|
2064
|
-
}, this.storage.words = (e) => {
|
|
2065
|
-
const t = e?.node || this.editor.state.doc, n = t.textBetween(0, t.content.size, " ", " ");
|
|
2066
|
-
return this.options.wordCounter(n);
|
|
2067
|
-
};
|
|
2068
|
-
},
|
|
2069
|
-
addProseMirrorPlugins() {
|
|
2070
|
-
let e = !1;
|
|
2071
|
-
return [
|
|
2072
|
-
new C({
|
|
2073
|
-
key: new I("characterCount"),
|
|
2074
|
-
appendTransaction: (t, n, s) => {
|
|
2075
|
-
if (e)
|
|
2076
|
-
return;
|
|
2077
|
-
const r = this.options.limit;
|
|
2078
|
-
if (r == null || r === 0) {
|
|
2079
|
-
e = !0;
|
|
2080
|
-
return;
|
|
2081
|
-
}
|
|
2082
|
-
const i = this.storage.characters({ node: s.doc });
|
|
2083
|
-
if (i > r) {
|
|
2084
|
-
const o = i - r, a = 0, l = o;
|
|
2085
|
-
console.warn(
|
|
2086
|
-
`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`
|
|
2087
|
-
);
|
|
2088
|
-
const u = s.tr.deleteRange(a, l);
|
|
2089
|
-
return e = !0, u;
|
|
2090
|
-
}
|
|
2091
|
-
e = !0;
|
|
2092
|
-
},
|
|
2093
|
-
filterTransaction: (t, n) => {
|
|
2094
|
-
const s = this.options.limit;
|
|
2095
|
-
if (!t.docChanged || s === 0 || s === null || s === void 0)
|
|
2096
|
-
return !0;
|
|
2097
|
-
const r = this.storage.characters({ node: n.doc }), i = this.storage.characters({ node: t.doc });
|
|
2098
|
-
if (i <= s || r > s && i > s && i <= r)
|
|
2099
|
-
return !0;
|
|
2100
|
-
if (r > s && i > s && i > r || !t.getMeta("paste"))
|
|
2101
|
-
return !1;
|
|
2102
|
-
const a = t.selection.$head.pos, l = i - s, u = a - l, p = a;
|
|
2103
|
-
return t.deleteRange(u, p), !(this.storage.characters({ node: t.doc }) > s);
|
|
2104
|
-
}
|
|
2105
|
-
})
|
|
2106
|
-
];
|
|
2107
|
-
}
|
|
2108
|
-
});
|
|
2109
|
-
var Ut = w.create({
|
|
2110
|
-
name: "dropCursor",
|
|
2111
|
-
addOptions() {
|
|
2112
|
-
return {
|
|
2113
|
-
color: "currentColor",
|
|
2114
|
-
width: 1,
|
|
2115
|
-
class: void 0
|
|
2116
|
-
};
|
|
2117
|
-
},
|
|
2118
|
-
addProseMirrorPlugins() {
|
|
2119
|
-
return [At(this.options)];
|
|
2120
|
-
}
|
|
2121
|
-
});
|
|
2122
|
-
w.create({
|
|
2123
|
-
name: "focus",
|
|
2124
|
-
addOptions() {
|
|
2125
|
-
return {
|
|
2126
|
-
className: "has-focus",
|
|
2127
|
-
mode: "all"
|
|
2128
|
-
};
|
|
2129
|
-
},
|
|
2130
|
-
addProseMirrorPlugins() {
|
|
2131
|
-
return [
|
|
2132
|
-
new C({
|
|
2133
|
-
key: new I("focus"),
|
|
2134
|
-
props: {
|
|
2135
|
-
decorations: ({ doc: e, selection: t }) => {
|
|
2136
|
-
const { isEditable: n, isFocused: s } = this.editor, { anchor: r } = t, i = [];
|
|
2137
|
-
if (!n || !s)
|
|
2138
|
-
return N.create(e, []);
|
|
2139
|
-
let o = 0;
|
|
2140
|
-
this.options.mode === "deepest" && e.descendants((l, u) => {
|
|
2141
|
-
if (l.isText)
|
|
2142
|
-
return;
|
|
2143
|
-
if (!(r >= u && r <= u + l.nodeSize - 1))
|
|
2144
|
-
return !1;
|
|
2145
|
-
o += 1;
|
|
2146
|
-
});
|
|
2147
|
-
let a = 0;
|
|
2148
|
-
return e.descendants((l, u) => {
|
|
2149
|
-
if (l.isText || !(r >= u && r <= u + l.nodeSize - 1))
|
|
2150
|
-
return !1;
|
|
2151
|
-
if (a += 1, this.options.mode === "deepest" && o - a > 0 || this.options.mode === "shallowest" && a > 1)
|
|
2152
|
-
return this.options.mode === "deepest";
|
|
2153
|
-
i.push(
|
|
2154
|
-
j.node(u, u + l.nodeSize, {
|
|
2155
|
-
class: this.options.className
|
|
2156
|
-
})
|
|
2157
|
-
);
|
|
2158
|
-
}), N.create(e, i);
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
})
|
|
2162
|
-
];
|
|
2163
|
-
}
|
|
2164
|
-
});
|
|
2165
|
-
var Gt = w.create({
|
|
2166
|
-
name: "gapCursor",
|
|
2167
|
-
addProseMirrorPlugins() {
|
|
2168
|
-
return [Ht()];
|
|
2169
|
-
},
|
|
2170
|
-
extendNodeSchema(e) {
|
|
2171
|
-
var t;
|
|
2172
|
-
const n = {
|
|
2173
|
-
name: e.name,
|
|
2174
|
-
options: e.options,
|
|
2175
|
-
storage: e.storage
|
|
2176
|
-
};
|
|
2177
|
-
return {
|
|
2178
|
-
allowGapCursor: (t = Ke(je(e, "allowGapCursor", n))) != null ? t : null
|
|
2179
|
-
};
|
|
2180
|
-
}
|
|
2181
|
-
}), ce = "placeholder";
|
|
2182
|
-
function Xt(e) {
|
|
2183
|
-
return e.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
|
|
2184
|
-
}
|
|
2185
|
-
w.create({
|
|
2186
|
-
name: "placeholder",
|
|
2187
|
-
addOptions() {
|
|
2188
|
-
return {
|
|
2189
|
-
emptyEditorClass: "is-editor-empty",
|
|
2190
|
-
emptyNodeClass: "is-empty",
|
|
2191
|
-
dataAttribute: ce,
|
|
2192
|
-
placeholder: "Write something …",
|
|
2193
|
-
showOnlyWhenEditable: !0,
|
|
2194
|
-
showOnlyCurrent: !0,
|
|
2195
|
-
includeChildren: !1
|
|
2196
|
-
};
|
|
2197
|
-
},
|
|
2198
|
-
addProseMirrorPlugins() {
|
|
2199
|
-
const e = this.options.dataAttribute ? `data-${Xt(this.options.dataAttribute)}` : `data-${ce}`;
|
|
2200
|
-
return [
|
|
2201
|
-
new C({
|
|
2202
|
-
key: new I("placeholder"),
|
|
2203
|
-
props: {
|
|
2204
|
-
decorations: ({ doc: t, selection: n }) => {
|
|
2205
|
-
const s = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: r } = n, i = [];
|
|
2206
|
-
if (!s)
|
|
2207
|
-
return null;
|
|
2208
|
-
const o = this.editor.isEmpty;
|
|
2209
|
-
return t.descendants((a, l) => {
|
|
2210
|
-
const u = r >= l && r <= l + a.nodeSize, p = !a.isLeaf && Ve(a);
|
|
2211
|
-
if ((u || !this.options.showOnlyCurrent) && p) {
|
|
2212
|
-
const d = [this.options.emptyNodeClass];
|
|
2213
|
-
o && d.push(this.options.emptyEditorClass);
|
|
2214
|
-
const c = j.node(l, l + a.nodeSize, {
|
|
2215
|
-
class: d.join(" "),
|
|
2216
|
-
[e]: typeof this.options.placeholder == "function" ? this.options.placeholder({
|
|
2217
|
-
editor: this.editor,
|
|
2218
|
-
node: a,
|
|
2219
|
-
pos: l,
|
|
2220
|
-
hasAnchor: u
|
|
2221
|
-
}) : this.options.placeholder
|
|
2222
|
-
});
|
|
2223
|
-
i.push(c);
|
|
2224
|
-
}
|
|
2225
|
-
return this.options.includeChildren;
|
|
2226
|
-
}), N.create(t, i);
|
|
2227
|
-
}
|
|
2228
|
-
}
|
|
2229
|
-
})
|
|
2230
|
-
];
|
|
2231
|
-
}
|
|
2232
|
-
});
|
|
2233
|
-
w.create({
|
|
2234
|
-
name: "selection",
|
|
2235
|
-
addOptions() {
|
|
2236
|
-
return {
|
|
2237
|
-
className: "selection"
|
|
2238
|
-
};
|
|
2239
|
-
},
|
|
2240
|
-
addProseMirrorPlugins() {
|
|
2241
|
-
const { editor: e, options: t } = this;
|
|
2242
|
-
return [
|
|
2243
|
-
new C({
|
|
2244
|
-
key: new I("selection"),
|
|
2245
|
-
props: {
|
|
2246
|
-
decorations(n) {
|
|
2247
|
-
return n.selection.empty || e.isFocused || !e.isEditable || he(n.selection) || e.view.dragging ? null : N.create(n.doc, [
|
|
2248
|
-
j.inline(n.selection.from, n.selection.to, {
|
|
2249
|
-
class: t.className
|
|
2250
|
-
})
|
|
2251
|
-
]);
|
|
2252
|
-
}
|
|
2253
|
-
}
|
|
2254
|
-
})
|
|
2255
|
-
];
|
|
2256
|
-
}
|
|
2257
|
-
});
|
|
2258
|
-
function pe({ types: e, node: t }) {
|
|
2259
|
-
return t && Array.isArray(e) && e.includes(t.type) || t?.type === e;
|
|
2260
|
-
}
|
|
2261
|
-
var qt = w.create({
|
|
2262
|
-
name: "trailingNode",
|
|
2263
|
-
addOptions() {
|
|
2264
|
-
return {
|
|
2265
|
-
node: void 0,
|
|
2266
|
-
notAfter: []
|
|
2267
|
-
};
|
|
2268
|
-
},
|
|
2269
|
-
addProseMirrorPlugins() {
|
|
2270
|
-
var e;
|
|
2271
|
-
const t = new I(this.name), n = this.options.node || ((e = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : e.name) || "paragraph", s = Object.entries(this.editor.schema.nodes).map(([, r]) => r).filter((r) => (this.options.notAfter || []).concat(n).includes(r.name));
|
|
2272
|
-
return [
|
|
2273
|
-
new C({
|
|
2274
|
-
key: t,
|
|
2275
|
-
appendTransaction: (r, i, o) => {
|
|
2276
|
-
const { doc: a, tr: l, schema: u } = o, p = t.getState(o), d = a.content.size, c = u.nodes[n];
|
|
2277
|
-
if (p)
|
|
2278
|
-
return l.insert(d, c.create());
|
|
2279
|
-
},
|
|
2280
|
-
state: {
|
|
2281
|
-
init: (r, i) => {
|
|
2282
|
-
const o = i.tr.doc.lastChild;
|
|
2283
|
-
return !pe({ node: o, types: s });
|
|
2284
|
-
},
|
|
2285
|
-
apply: (r, i) => {
|
|
2286
|
-
if (!r.docChanged || r.getMeta("__uniqueIDTransaction"))
|
|
2287
|
-
return i;
|
|
2288
|
-
const o = r.doc.lastChild;
|
|
2289
|
-
return !pe({ node: o, types: s });
|
|
2290
|
-
}
|
|
2291
|
-
}
|
|
2292
|
-
})
|
|
2293
|
-
];
|
|
2294
|
-
}
|
|
2295
|
-
}), Yt = w.create({
|
|
2296
|
-
name: "undoRedo",
|
|
2297
|
-
addOptions() {
|
|
2298
|
-
return {
|
|
2299
|
-
depth: 100,
|
|
2300
|
-
newGroupDelay: 500
|
|
2301
|
-
};
|
|
2302
|
-
},
|
|
2303
|
-
addCommands() {
|
|
2304
|
-
return {
|
|
2305
|
-
undo: () => ({ state: e, dispatch: t }) => Se(e, t),
|
|
2306
|
-
redo: () => ({ state: e, dispatch: t }) => Ee(e, t)
|
|
2307
|
-
};
|
|
2308
|
-
},
|
|
2309
|
-
addProseMirrorPlugins() {
|
|
2310
|
-
return [Ft(this.options)];
|
|
2311
|
-
},
|
|
2312
|
-
addKeyboardShortcuts() {
|
|
2313
|
-
return {
|
|
2314
|
-
"Mod-z": () => this.editor.commands.undo(),
|
|
2315
|
-
"Shift-Mod-z": () => this.editor.commands.redo(),
|
|
2316
|
-
"Mod-y": () => this.editor.commands.redo(),
|
|
2317
|
-
// Russian keyboard layouts
|
|
2318
|
-
"Mod-я": () => this.editor.commands.undo(),
|
|
2319
|
-
"Shift-Mod-я": () => this.editor.commands.redo()
|
|
2320
|
-
};
|
|
2321
|
-
}
|
|
2322
|
-
}), Jt = w.create({
|
|
2323
|
-
name: "starterKit",
|
|
2324
|
-
addExtensions() {
|
|
2325
|
-
var e, t, n, s;
|
|
2326
|
-
const r = [];
|
|
2327
|
-
return this.options.bold !== !1 && r.push(We.configure(this.options.bold)), this.options.blockquote !== !1 && r.push(Ge.configure(this.options.blockquote)), this.options.bulletList !== !1 && r.push(ke.configure(this.options.bulletList)), this.options.code !== !1 && r.push(Ye.configure(this.options.code)), this.options.codeBlock !== !1 && r.push(Qe.configure(this.options.codeBlock)), this.options.document !== !1 && r.push(et.configure(this.options.document)), this.options.dropcursor !== !1 && r.push(Ut.configure(this.options.dropcursor)), this.options.gapcursor !== !1 && r.push(Gt.configure(this.options.gapcursor)), this.options.hardBreak !== !1 && r.push(tt.configure(this.options.hardBreak)), this.options.heading !== !1 && r.push(nt.configure(this.options.heading)), this.options.undoRedo !== !1 && r.push(Yt.configure(this.options.undoRedo)), this.options.horizontalRule !== !1 && r.push(rt.configure(this.options.horizontalRule)), this.options.italic !== !1 && r.push(lt.configure(this.options.italic)), this.options.listItem !== !1 && r.push(ve.configure(this.options.listItem)), this.options.listKeymap !== !1 && r.push(Te.configure((e = this.options) == null ? void 0 : e.listKeymap)), this.options.link !== !1 && r.push(Fe.configure((t = this.options) == null ? void 0 : t.link)), this.options.orderedList !== !1 && r.push(xe.configure(this.options.orderedList)), this.options.paragraph !== !1 && r.push(wt.configure(this.options.paragraph)), this.options.strike !== !1 && r.push(Ct.configure(this.options.strike)), this.options.text !== !1 && r.push(xt.configure(this.options.text)), this.options.underline !== !1 && r.push(It.configure((n = this.options) == null ? void 0 : n.underline)), this.options.trailingNode !== !1 && r.push(qt.configure((s = this.options) == null ? void 0 : s.trailingNode)), r;
|
|
2328
|
-
}
|
|
2329
|
-
}), nn = Jt;
|
|
2330
|
-
export {
|
|
2331
|
-
Jt as StarterKit,
|
|
2332
|
-
nn as default
|
|
2333
|
-
};
|