@clevertask/scribe 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +167 -0
  3. package/dist/SlashCommandList-DYKFukY8.js +3734 -0
  4. package/dist/components/Menu/BarMenu.d.ts +7 -0
  5. package/dist/components/Menu/BarMenu.js +119 -0
  6. package/dist/components/Menu/BubbleMenu.d.ts +7 -0
  7. package/dist/components/Menu/BubbleMenu.js +176 -0
  8. package/dist/components/Scribe/extension/extension-link.d.ts +2 -0
  9. package/dist/components/Scribe/extension/extension-link.js +934 -0
  10. package/dist/components/Scribe/extension/extension-selectedText.d.ts +12 -0
  11. package/dist/components/Scribe/extension/extension-selectedText.js +13 -0
  12. package/dist/components/Scribe/extension/index.d.ts +2 -0
  13. package/dist/components/Scribe/extension/index.js +1647 -0
  14. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.d.ts +5 -0
  15. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +10 -0
  16. package/dist/components/Scribe/extension/slashCommand/index.d.ts +4 -0
  17. package/dist/components/Scribe/extension/slashCommand/index.js +154 -0
  18. package/dist/components/Scribe/extension/slashCommand/items.d.ts +23 -0
  19. package/dist/components/Scribe/extension/slashCommand/items.js +159 -0
  20. package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts +8 -0
  21. package/dist/components/Scribe/extension/slashCommand/renderItems.js +38 -0
  22. package/dist/components/Scribe/index.d.ts +28 -0
  23. package/dist/components/Scribe/index.js +92 -0
  24. package/dist/index-Cu10LNOZ.js +2505 -0
  25. package/dist/index-CzwFCNeI.js +12114 -0
  26. package/dist/main.css +1134 -0
  27. package/dist/main.d.ts +2 -0
  28. package/dist/main.js +10 -0
  29. package/dist/marked.esm-DIt7dqAB.js +1574 -0
  30. package/dist/purify.es-Bzg5nW_L.js +524 -0
  31. package/dist/turndown.browser.es-DwgPoVx0.js +646 -0
  32. package/dist/utils/html-to-markdown.d.ts +1 -0
  33. package/dist/utils/html-to-markdown.js +11 -0
  34. package/dist/utils/index.d.ts +3 -0
  35. package/dist/utils/index.js +8 -0
  36. package/dist/utils/is-in-viewport.d.ts +1 -0
  37. package/dist/utils/is-in-viewport.js +7 -0
  38. package/dist/utils/markdown-to-html.d.ts +1 -0
  39. package/dist/utils/markdown-to-html.js +6 -0
  40. package/dist/vite-env.d.js +1 -0
  41. package/package.json +95 -0
@@ -0,0 +1,1647 @@
1
+ import { E as x, a as H, P, j as ie, b as F, D as B, N as v, m as y, w as E, M as R, k as A, c as C, S as O, t as V, T as I, l as oe, n as ae, o as W, F as G, p as Q, q as le, r as ue, s as de, u as pe, v as ee } from "../../../index-CzwFCNeI.js";
2
+ import { SlashCommand as ce } from "./slashCommand/index.js";
3
+ import { getSuggestionItems as he } from "./slashCommand/items.js";
4
+ import fe from "./slashCommand/renderItems.js";
5
+ import me from "./extension-selectedText.js";
6
+ import ge from "./extension-link.js";
7
+ const ye = x.create({
8
+ name: "placeholder",
9
+ addOptions() {
10
+ return {
11
+ emptyEditorClass: "is-editor-empty",
12
+ emptyNodeClass: "is-empty",
13
+ placeholder: "Write something …",
14
+ showOnlyWhenEditable: !0,
15
+ showOnlyCurrent: !0,
16
+ includeChildren: !1
17
+ };
18
+ },
19
+ addProseMirrorPlugins() {
20
+ return [
21
+ new H({
22
+ key: new P("placeholder"),
23
+ props: {
24
+ decorations: ({ doc: t, selection: e }) => {
25
+ const n = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: r } = e, s = [];
26
+ if (!n)
27
+ return null;
28
+ const i = this.editor.isEmpty;
29
+ return t.descendants((o, a) => {
30
+ const l = r >= a && r <= a + o.nodeSize, u = !o.isLeaf && ie(o);
31
+ if ((l || !this.options.showOnlyCurrent) && u) {
32
+ const p = [this.options.emptyNodeClass];
33
+ i && p.push(this.options.emptyEditorClass);
34
+ const d = F.node(a, a + o.nodeSize, {
35
+ class: p.join(" "),
36
+ "data-placeholder": typeof this.options.placeholder == "function" ? this.options.placeholder({
37
+ editor: this.editor,
38
+ node: o,
39
+ pos: a,
40
+ hasAnchor: l
41
+ }) : this.options.placeholder
42
+ });
43
+ s.push(d);
44
+ }
45
+ return this.options.includeChildren;
46
+ }), B.create(t, s);
47
+ }
48
+ }
49
+ })
50
+ ];
51
+ }
52
+ }), ve = /^\s*>\s$/, be = v.create({
53
+ name: "blockquote",
54
+ addOptions() {
55
+ return {
56
+ HTMLAttributes: {}
57
+ };
58
+ },
59
+ content: "block+",
60
+ group: "block",
61
+ defining: !0,
62
+ parseHTML() {
63
+ return [
64
+ { tag: "blockquote" }
65
+ ];
66
+ },
67
+ renderHTML({ HTMLAttributes: t }) {
68
+ return ["blockquote", y(this.options.HTMLAttributes, t), 0];
69
+ },
70
+ addCommands() {
71
+ return {
72
+ setBlockquote: () => ({ commands: t }) => t.wrapIn(this.name),
73
+ toggleBlockquote: () => ({ commands: t }) => t.toggleWrap(this.name),
74
+ unsetBlockquote: () => ({ commands: t }) => t.lift(this.name)
75
+ };
76
+ },
77
+ addKeyboardShortcuts() {
78
+ return {
79
+ "Mod-Shift-b": () => this.editor.commands.toggleBlockquote()
80
+ };
81
+ },
82
+ addInputRules() {
83
+ return [
84
+ E({
85
+ find: ve,
86
+ type: this.type
87
+ })
88
+ ];
89
+ }
90
+ }), Me = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/, ke = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g, Te = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/, we = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g, Ae = R.create({
91
+ name: "bold",
92
+ addOptions() {
93
+ return {
94
+ HTMLAttributes: {}
95
+ };
96
+ },
97
+ parseHTML() {
98
+ return [
99
+ {
100
+ tag: "strong"
101
+ },
102
+ {
103
+ tag: "b",
104
+ getAttrs: (t) => t.style.fontWeight !== "normal" && null
105
+ },
106
+ {
107
+ style: "font-weight=400",
108
+ clearMark: (t) => t.type.name === this.name
109
+ },
110
+ {
111
+ style: "font-weight",
112
+ getAttrs: (t) => /^(bold(er)?|[5-9]\d{2,})$/.test(t) && null
113
+ }
114
+ ];
115
+ },
116
+ renderHTML({ HTMLAttributes: t }) {
117
+ return ["strong", y(this.options.HTMLAttributes, t), 0];
118
+ },
119
+ addCommands() {
120
+ return {
121
+ setBold: () => ({ commands: t }) => t.setMark(this.name),
122
+ toggleBold: () => ({ commands: t }) => t.toggleMark(this.name),
123
+ unsetBold: () => ({ commands: t }) => t.unsetMark(this.name)
124
+ };
125
+ },
126
+ addKeyboardShortcuts() {
127
+ return {
128
+ "Mod-b": () => this.editor.commands.toggleBold(),
129
+ "Mod-B": () => this.editor.commands.toggleBold()
130
+ };
131
+ },
132
+ addInputRules() {
133
+ return [
134
+ A({
135
+ find: Me,
136
+ type: this.type
137
+ }),
138
+ A({
139
+ find: Te,
140
+ type: this.type
141
+ })
142
+ ];
143
+ },
144
+ addPasteRules() {
145
+ return [
146
+ C({
147
+ find: ke,
148
+ type: this.type
149
+ }),
150
+ C({
151
+ find: we,
152
+ type: this.type
153
+ })
154
+ ];
155
+ }
156
+ }), Ce = "listItem", q = "textStyle", J = /^\s*([-+*])\s$/, Le = v.create({
157
+ name: "bulletList",
158
+ addOptions() {
159
+ return {
160
+ itemTypeName: "listItem",
161
+ HTMLAttributes: {},
162
+ keepMarks: !1,
163
+ keepAttributes: !1
164
+ };
165
+ },
166
+ group: "block list",
167
+ content() {
168
+ return `${this.options.itemTypeName}+`;
169
+ },
170
+ parseHTML() {
171
+ return [
172
+ { tag: "ul" }
173
+ ];
174
+ },
175
+ renderHTML({ HTMLAttributes: t }) {
176
+ return ["ul", y(this.options.HTMLAttributes, t), 0];
177
+ },
178
+ addCommands() {
179
+ return {
180
+ toggleBulletList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(Ce, this.editor.getAttributes(q)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
181
+ };
182
+ },
183
+ addKeyboardShortcuts() {
184
+ return {
185
+ "Mod-Shift-8": () => this.editor.commands.toggleBulletList()
186
+ };
187
+ },
188
+ addInputRules() {
189
+ let t = E({
190
+ find: J,
191
+ type: this.type
192
+ });
193
+ return (this.options.keepMarks || this.options.keepAttributes) && (t = E({
194
+ find: J,
195
+ type: this.type,
196
+ keepMarks: this.options.keepMarks,
197
+ keepAttributes: this.options.keepAttributes,
198
+ getAttributes: () => this.editor.getAttributes(q),
199
+ editor: this.editor
200
+ })), [
201
+ t
202
+ ];
203
+ }
204
+ }), Ie = new RegExp("(?<!`)`([^`]+)`(?!`)"), xe = new RegExp("(?<!`)`([^`]+)`(?!`)", "g"), He = R.create({
205
+ name: "code",
206
+ addOptions() {
207
+ return {
208
+ HTMLAttributes: {}
209
+ };
210
+ },
211
+ excludes: "_",
212
+ code: !0,
213
+ exitable: !0,
214
+ parseHTML() {
215
+ return [
216
+ { tag: "code" }
217
+ ];
218
+ },
219
+ renderHTML({ HTMLAttributes: t }) {
220
+ return ["code", y(this.options.HTMLAttributes, t), 0];
221
+ },
222
+ addCommands() {
223
+ return {
224
+ setCode: () => ({ commands: t }) => t.setMark(this.name),
225
+ toggleCode: () => ({ commands: t }) => t.toggleMark(this.name),
226
+ unsetCode: () => ({ commands: t }) => t.unsetMark(this.name)
227
+ };
228
+ },
229
+ addKeyboardShortcuts() {
230
+ return {
231
+ "Mod-e": () => this.editor.commands.toggleCode()
232
+ };
233
+ },
234
+ addInputRules() {
235
+ return [
236
+ A({
237
+ find: Ie,
238
+ type: this.type
239
+ })
240
+ ];
241
+ },
242
+ addPasteRules() {
243
+ return [
244
+ C({
245
+ find: xe,
246
+ type: this.type
247
+ })
248
+ ];
249
+ }
250
+ }), Se = /^```([a-z]+)?[\s\n]$/, Ee = /^~~~([a-z]+)?[\s\n]$/, Oe = v.create({
251
+ name: "codeBlock",
252
+ addOptions() {
253
+ return {
254
+ languageClassPrefix: "language-",
255
+ exitOnTripleEnter: !0,
256
+ exitOnArrowDown: !0,
257
+ defaultLanguage: null,
258
+ HTMLAttributes: {}
259
+ };
260
+ },
261
+ content: "text*",
262
+ marks: "",
263
+ group: "block",
264
+ code: !0,
265
+ defining: !0,
266
+ addAttributes() {
267
+ return {
268
+ language: {
269
+ default: this.options.defaultLanguage,
270
+ parseHTML: (t) => {
271
+ var e;
272
+ const { languageClassPrefix: n } = this.options, i = [...((e = t.firstElementChild) === null || e === void 0 ? void 0 : e.classList) || []].filter((o) => o.startsWith(n)).map((o) => o.replace(n, ""))[0];
273
+ return i || null;
274
+ },
275
+ rendered: !1
276
+ }
277
+ };
278
+ },
279
+ parseHTML() {
280
+ return [
281
+ {
282
+ tag: "pre",
283
+ preserveWhitespace: "full"
284
+ }
285
+ ];
286
+ },
287
+ renderHTML({ node: t, HTMLAttributes: e }) {
288
+ return [
289
+ "pre",
290
+ y(this.options.HTMLAttributes, e),
291
+ [
292
+ "code",
293
+ {
294
+ class: t.attrs.language ? this.options.languageClassPrefix + t.attrs.language : null
295
+ },
296
+ 0
297
+ ]
298
+ ];
299
+ },
300
+ addCommands() {
301
+ return {
302
+ setCodeBlock: (t) => ({ commands: e }) => e.setNode(this.name, t),
303
+ toggleCodeBlock: (t) => ({ commands: e }) => e.toggleNode(this.name, "paragraph", t)
304
+ };
305
+ },
306
+ addKeyboardShortcuts() {
307
+ return {
308
+ "Mod-Alt-c": () => this.editor.commands.toggleCodeBlock(),
309
+ // remove code block when at start of document or code block is empty
310
+ Backspace: () => {
311
+ const { empty: t, $anchor: e } = this.editor.state.selection, n = e.pos === 1;
312
+ return !t || e.parent.type.name !== this.name ? !1 : n || !e.parent.textContent.length ? this.editor.commands.clearNodes() : !1;
313
+ },
314
+ // exit node on triple enter
315
+ Enter: ({ editor: t }) => {
316
+ if (!this.options.exitOnTripleEnter)
317
+ return !1;
318
+ const { state: e } = t, { selection: n } = e, { $from: r, empty: s } = n;
319
+ if (!s || r.parent.type !== this.type)
320
+ return !1;
321
+ const i = r.parentOffset === r.parent.nodeSize - 2, o = r.parent.textContent.endsWith(`
322
+
323
+ `);
324
+ return !i || !o ? !1 : t.chain().command(({ tr: a }) => (a.delete(r.pos - 2, r.pos), !0)).exitCode().run();
325
+ },
326
+ // exit node on arrow down
327
+ ArrowDown: ({ editor: t }) => {
328
+ if (!this.options.exitOnArrowDown)
329
+ return !1;
330
+ const { state: e } = t, { selection: n, doc: r } = e, { $from: s, empty: i } = n;
331
+ if (!i || s.parent.type !== this.type || !(s.parentOffset === s.parent.nodeSize - 2))
332
+ return !1;
333
+ const a = s.after();
334
+ return a === void 0 ? !1 : r.nodeAt(a) ? t.commands.command(({ tr: u }) => (u.setSelection(O.near(r.resolve(a))), !0)) : t.commands.exitCode();
335
+ }
336
+ };
337
+ },
338
+ addInputRules() {
339
+ return [
340
+ V({
341
+ find: Se,
342
+ type: this.type,
343
+ getAttributes: (t) => ({
344
+ language: t[1]
345
+ })
346
+ }),
347
+ V({
348
+ find: Ee,
349
+ type: this.type,
350
+ getAttributes: (t) => ({
351
+ language: t[1]
352
+ })
353
+ })
354
+ ];
355
+ },
356
+ addProseMirrorPlugins() {
357
+ return [
358
+ // this plugin creates a code block for pasted content from VS Code
359
+ // we can also detect the copied code language
360
+ new H({
361
+ key: new P("codeBlockVSCodeHandler"),
362
+ props: {
363
+ handlePaste: (t, e) => {
364
+ if (!e.clipboardData || this.editor.isActive(this.type.name))
365
+ return !1;
366
+ const n = e.clipboardData.getData("text/plain"), r = e.clipboardData.getData("vscode-editor-data"), s = r ? JSON.parse(r) : void 0, i = s == null ? void 0 : s.mode;
367
+ if (!n || !i)
368
+ return !1;
369
+ const { tr: o, schema: a } = t.state, l = a.text(n.replace(/\r\n?/g, `
370
+ `));
371
+ return o.replaceSelectionWith(this.type.create({ language: i }, l)), o.selection.$from.parent.type !== this.type && o.setSelection(I.near(o.doc.resolve(Math.max(0, o.selection.from - 2)))), o.setMeta("paste", !0), t.dispatch(o), !0;
372
+ }
373
+ }
374
+ })
375
+ ];
376
+ }
377
+ }), Pe = v.create({
378
+ name: "doc",
379
+ topNode: !0,
380
+ content: "block+"
381
+ });
382
+ function Re(t = {}) {
383
+ return new H({
384
+ view(e) {
385
+ return new _e(e, t);
386
+ }
387
+ });
388
+ }
389
+ class _e {
390
+ constructor(e, n) {
391
+ var r;
392
+ this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (r = n.width) !== null && r !== void 0 ? r : 1, this.color = n.color === !1 ? void 0 : n.color || "black", this.class = n.class, this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((s) => {
393
+ let i = (o) => {
394
+ this[s](o);
395
+ };
396
+ return e.dom.addEventListener(s, i), { name: s, handler: i };
397
+ });
398
+ }
399
+ destroy() {
400
+ this.handlers.forEach(({ name: e, handler: n }) => this.editorView.dom.removeEventListener(e, n));
401
+ }
402
+ update(e, n) {
403
+ this.cursorPos != null && n.doc != e.state.doc && (this.cursorPos > e.state.doc.content.size ? this.setCursor(null) : this.updateOverlay());
404
+ }
405
+ setCursor(e) {
406
+ e != this.cursorPos && (this.cursorPos = e, e == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
407
+ }
408
+ updateOverlay() {
409
+ let e = this.editorView.state.doc.resolve(this.cursorPos), n = !e.parent.inlineContent, r;
410
+ if (n) {
411
+ let a = e.nodeBefore, l = e.nodeAfter;
412
+ if (a || l) {
413
+ let u = this.editorView.nodeDOM(this.cursorPos - (a ? a.nodeSize : 0));
414
+ if (u) {
415
+ let p = u.getBoundingClientRect(), d = a ? p.bottom : p.top;
416
+ a && l && (d = (d + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2), r = { left: p.left, right: p.right, top: d - this.width / 2, bottom: d + this.width / 2 };
417
+ }
418
+ }
419
+ }
420
+ if (!r) {
421
+ let a = this.editorView.coordsAtPos(this.cursorPos);
422
+ r = { left: a.left - this.width / 2, right: a.left + this.width / 2, top: a.top, bottom: a.bottom };
423
+ }
424
+ let s = this.editorView.dom.offsetParent;
425
+ this.element || (this.element = s.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);
426
+ let i, o;
427
+ if (!s || s == document.body && getComputedStyle(s).position == "static")
428
+ i = -pageXOffset, o = -pageYOffset;
429
+ else {
430
+ let a = s.getBoundingClientRect();
431
+ i = a.left - s.scrollLeft, o = a.top - s.scrollTop;
432
+ }
433
+ this.element.style.left = r.left - i + "px", this.element.style.top = r.top - o + "px", this.element.style.width = r.right - r.left + "px", this.element.style.height = r.bottom - r.top + "px";
434
+ }
435
+ scheduleRemoval(e) {
436
+ clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), e);
437
+ }
438
+ dragover(e) {
439
+ if (!this.editorView.editable)
440
+ return;
441
+ let n = this.editorView.posAtCoords({ left: e.clientX, top: e.clientY }), r = n && n.inside >= 0 && this.editorView.state.doc.nodeAt(n.inside), s = r && r.type.spec.disableDropCursor, i = typeof s == "function" ? s(this.editorView, n, e) : s;
442
+ if (n && !i) {
443
+ let o = n.pos;
444
+ if (this.editorView.dragging && this.editorView.dragging.slice) {
445
+ let a = oe(this.editorView.state.doc, o, this.editorView.dragging.slice);
446
+ a != null && (o = a);
447
+ }
448
+ this.setCursor(o), this.scheduleRemoval(5e3);
449
+ }
450
+ }
451
+ dragend() {
452
+ this.scheduleRemoval(20);
453
+ }
454
+ drop() {
455
+ this.scheduleRemoval(20);
456
+ }
457
+ dragleave(e) {
458
+ (e.target == this.editorView.dom || !this.editorView.dom.contains(e.relatedTarget)) && this.setCursor(null);
459
+ }
460
+ }
461
+ const Ne = x.create({
462
+ name: "dropCursor",
463
+ addOptions() {
464
+ return {
465
+ color: "currentColor",
466
+ width: 1,
467
+ class: void 0
468
+ };
469
+ },
470
+ addProseMirrorPlugins() {
471
+ return [
472
+ Re(this.options)
473
+ ];
474
+ }
475
+ });
476
+ class h extends O {
477
+ /**
478
+ Create a gap cursor.
479
+ */
480
+ constructor(e) {
481
+ super(e, e);
482
+ }
483
+ map(e, n) {
484
+ let r = e.resolve(n.map(this.head));
485
+ return h.valid(r) ? new h(r) : O.near(r);
486
+ }
487
+ content() {
488
+ return Q.empty;
489
+ }
490
+ eq(e) {
491
+ return e instanceof h && e.head == this.head;
492
+ }
493
+ toJSON() {
494
+ return { type: "gapcursor", pos: this.head };
495
+ }
496
+ /**
497
+ @internal
498
+ */
499
+ static fromJSON(e, n) {
500
+ if (typeof n.pos != "number")
501
+ throw new RangeError("Invalid input for GapCursor.fromJSON");
502
+ return new h(e.resolve(n.pos));
503
+ }
504
+ /**
505
+ @internal
506
+ */
507
+ getBookmark() {
508
+ return new j(this.anchor);
509
+ }
510
+ /**
511
+ @internal
512
+ */
513
+ static valid(e) {
514
+ let n = e.parent;
515
+ if (n.isTextblock || !Be(e) || !$e(e))
516
+ return !1;
517
+ let r = n.type.spec.allowGapCursor;
518
+ if (r != null)
519
+ return r;
520
+ let s = n.contentMatchAt(e.index()).defaultType;
521
+ return s && s.isTextblock;
522
+ }
523
+ /**
524
+ @internal
525
+ */
526
+ static findGapCursorFrom(e, n, r = !1) {
527
+ e: for (; ; ) {
528
+ if (!r && h.valid(e))
529
+ return e;
530
+ let s = e.pos, i = null;
531
+ for (let o = e.depth; ; o--) {
532
+ let a = e.node(o);
533
+ if (n > 0 ? e.indexAfter(o) < a.childCount : e.index(o) > 0) {
534
+ i = a.child(n > 0 ? e.indexAfter(o) : e.index(o) - 1);
535
+ break;
536
+ } else if (o == 0)
537
+ return null;
538
+ s += n;
539
+ let l = e.doc.resolve(s);
540
+ if (h.valid(l))
541
+ return l;
542
+ }
543
+ for (; ; ) {
544
+ let o = n > 0 ? i.firstChild : i.lastChild;
545
+ if (!o) {
546
+ if (i.isAtom && !i.isText && !W.isSelectable(i)) {
547
+ e = e.doc.resolve(s + i.nodeSize * n), r = !1;
548
+ continue e;
549
+ }
550
+ break;
551
+ }
552
+ i = o, s += n;
553
+ let a = e.doc.resolve(s);
554
+ if (h.valid(a))
555
+ return a;
556
+ }
557
+ return null;
558
+ }
559
+ }
560
+ }
561
+ h.prototype.visible = !1;
562
+ h.findFrom = h.findGapCursorFrom;
563
+ O.jsonID("gapcursor", h);
564
+ class j {
565
+ constructor(e) {
566
+ this.pos = e;
567
+ }
568
+ map(e) {
569
+ return new j(e.map(this.pos));
570
+ }
571
+ resolve(e) {
572
+ let n = e.resolve(this.pos);
573
+ return h.valid(n) ? new h(n) : O.near(n);
574
+ }
575
+ }
576
+ function Be(t) {
577
+ for (let e = t.depth; e >= 0; e--) {
578
+ let n = t.index(e), r = t.node(e);
579
+ if (n == 0) {
580
+ if (r.type.spec.isolating)
581
+ return !0;
582
+ continue;
583
+ }
584
+ for (let s = r.child(n - 1); ; s = s.lastChild) {
585
+ if (s.childCount == 0 && !s.inlineContent || s.isAtom || s.type.spec.isolating)
586
+ return !0;
587
+ if (s.inlineContent)
588
+ return !1;
589
+ }
590
+ }
591
+ return !0;
592
+ }
593
+ function $e(t) {
594
+ for (let e = t.depth; e >= 0; e--) {
595
+ let n = t.indexAfter(e), r = t.node(e);
596
+ if (n == r.childCount) {
597
+ if (r.type.spec.isolating)
598
+ return !0;
599
+ continue;
600
+ }
601
+ for (let s = r.child(n); ; s = s.firstChild) {
602
+ if (s.childCount == 0 && !s.inlineContent || s.isAtom || s.type.spec.isolating)
603
+ return !0;
604
+ if (s.inlineContent)
605
+ return !1;
606
+ }
607
+ }
608
+ return !0;
609
+ }
610
+ function De() {
611
+ return new H({
612
+ props: {
613
+ decorations: Fe,
614
+ createSelectionBetween(t, e, n) {
615
+ return e.pos == n.pos && h.valid(n) ? new h(n) : null;
616
+ },
617
+ handleClick: Ke,
618
+ handleKeyDown: ze,
619
+ handleDOMEvents: { beforeinput: Ve }
620
+ }
621
+ });
622
+ }
623
+ const ze = ae({
624
+ ArrowLeft: _("horiz", -1),
625
+ ArrowRight: _("horiz", 1),
626
+ ArrowUp: _("vert", -1),
627
+ ArrowDown: _("vert", 1)
628
+ });
629
+ function _(t, e) {
630
+ const n = t == "vert" ? e > 0 ? "down" : "up" : e > 0 ? "right" : "left";
631
+ return function(r, s, i) {
632
+ let o = r.selection, a = e > 0 ? o.$to : o.$from, l = o.empty;
633
+ if (o instanceof I) {
634
+ if (!i.endOfTextblock(n) || a.depth == 0)
635
+ return !1;
636
+ l = !1, a = r.doc.resolve(e > 0 ? a.after() : a.before());
637
+ }
638
+ let u = h.findGapCursorFrom(a, e, l);
639
+ return u ? (s && s(r.tr.setSelection(new h(u))), !0) : !1;
640
+ };
641
+ }
642
+ function Ke(t, e, n) {
643
+ if (!t || !t.editable)
644
+ return !1;
645
+ let r = t.state.doc.resolve(e);
646
+ if (!h.valid(r))
647
+ return !1;
648
+ let s = t.posAtCoords({ left: n.clientX, top: n.clientY });
649
+ return s && s.inside > -1 && W.isSelectable(t.state.doc.nodeAt(s.inside)) ? !1 : (t.dispatch(t.state.tr.setSelection(new h(r))), !0);
650
+ }
651
+ function Ve(t, e) {
652
+ if (e.inputType != "insertCompositionText" || !(t.state.selection instanceof h))
653
+ return !1;
654
+ let { $from: n } = t.state.selection, r = n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);
655
+ if (!r)
656
+ return !1;
657
+ let s = G.empty;
658
+ for (let o = r.length - 1; o >= 0; o--)
659
+ s = G.from(r[o].createAndFill(null, s));
660
+ let i = t.state.tr.replace(n.pos, n.pos, new Q(s, 0, 0));
661
+ return i.setSelection(I.near(i.doc.resolve(n.pos + 1))), t.dispatch(i), !1;
662
+ }
663
+ function Fe(t) {
664
+ if (!(t.selection instanceof h))
665
+ return null;
666
+ let e = document.createElement("div");
667
+ return e.className = "ProseMirror-gapcursor", B.create(t.doc, [F.widget(t.selection.head, e, { key: "gapcursor" })]);
668
+ }
669
+ const We = x.create({
670
+ name: "gapCursor",
671
+ addProseMirrorPlugins() {
672
+ return [
673
+ De()
674
+ ];
675
+ },
676
+ extendNodeSchema(t) {
677
+ var e;
678
+ const n = {
679
+ name: t.name,
680
+ options: t.options,
681
+ storage: t.storage
682
+ };
683
+ return {
684
+ allowGapCursor: (e = le(ue(t, "allowGapCursor", n))) !== null && e !== void 0 ? e : null
685
+ };
686
+ }
687
+ }), je = v.create({
688
+ name: "hardBreak",
689
+ addOptions() {
690
+ return {
691
+ keepMarks: !0,
692
+ HTMLAttributes: {}
693
+ };
694
+ },
695
+ inline: !0,
696
+ group: "inline",
697
+ selectable: !1,
698
+ linebreakReplacement: !0,
699
+ parseHTML() {
700
+ return [
701
+ { tag: "br" }
702
+ ];
703
+ },
704
+ renderHTML({ HTMLAttributes: t }) {
705
+ return ["br", y(this.options.HTMLAttributes, t)];
706
+ },
707
+ renderText() {
708
+ return `
709
+ `;
710
+ },
711
+ addCommands() {
712
+ return {
713
+ setHardBreak: () => ({ commands: t, chain: e, state: n, editor: r }) => t.first([
714
+ () => t.exitCode(),
715
+ () => t.command(() => {
716
+ const { selection: s, storedMarks: i } = n;
717
+ if (s.$from.parent.type.spec.isolating)
718
+ return !1;
719
+ const { keepMarks: o } = this.options, { splittableMarks: a } = r.extensionManager, l = i || s.$to.parentOffset && s.$from.marks();
720
+ return e().insertContent({ type: this.name }).command(({ tr: u, dispatch: p }) => {
721
+ if (p && l && o) {
722
+ const d = l.filter((c) => a.includes(c.type.name));
723
+ u.ensureMarks(d);
724
+ }
725
+ return !0;
726
+ }).run();
727
+ })
728
+ ])
729
+ };
730
+ },
731
+ addKeyboardShortcuts() {
732
+ return {
733
+ "Mod-Enter": () => this.editor.commands.setHardBreak(),
734
+ "Shift-Enter": () => this.editor.commands.setHardBreak()
735
+ };
736
+ }
737
+ }), Ge = v.create({
738
+ name: "heading",
739
+ addOptions() {
740
+ return {
741
+ levels: [1, 2, 3, 4, 5, 6],
742
+ HTMLAttributes: {}
743
+ };
744
+ },
745
+ content: "inline*",
746
+ group: "block",
747
+ defining: !0,
748
+ addAttributes() {
749
+ return {
750
+ level: {
751
+ default: 1,
752
+ rendered: !1
753
+ }
754
+ };
755
+ },
756
+ parseHTML() {
757
+ return this.options.levels.map((t) => ({
758
+ tag: `h${t}`,
759
+ attrs: { level: t }
760
+ }));
761
+ },
762
+ renderHTML({ node: t, HTMLAttributes: e }) {
763
+ return [`h${this.options.levels.includes(t.attrs.level) ? t.attrs.level : this.options.levels[0]}`, y(this.options.HTMLAttributes, e), 0];
764
+ },
765
+ addCommands() {
766
+ return {
767
+ setHeading: (t) => ({ commands: e }) => this.options.levels.includes(t.level) ? e.setNode(this.name, t) : !1,
768
+ toggleHeading: (t) => ({ commands: e }) => this.options.levels.includes(t.level) ? e.toggleNode(this.name, "paragraph", t) : !1
769
+ };
770
+ },
771
+ addKeyboardShortcuts() {
772
+ return this.options.levels.reduce((t, e) => ({
773
+ ...t,
774
+ [`Mod-Alt-${e}`]: () => this.editor.commands.toggleHeading({ level: e })
775
+ }), {});
776
+ },
777
+ addInputRules() {
778
+ return this.options.levels.map((t) => V({
779
+ find: new RegExp(`^(#{1,${t}})\\s$`),
780
+ type: this.type,
781
+ getAttributes: {
782
+ level: t
783
+ }
784
+ }));
785
+ }
786
+ });
787
+ var $ = 200, g = function() {
788
+ };
789
+ g.prototype.append = function(e) {
790
+ return e.length ? (e = g.from(e), !this.length && e || e.length < $ && this.leafAppend(e) || this.length < $ && e.leafPrepend(this) || this.appendInner(e)) : this;
791
+ };
792
+ g.prototype.prepend = function(e) {
793
+ return e.length ? g.from(e).append(this) : this;
794
+ };
795
+ g.prototype.appendInner = function(e) {
796
+ return new qe(this, e);
797
+ };
798
+ g.prototype.slice = function(e, n) {
799
+ return e === void 0 && (e = 0), n === void 0 && (n = this.length), e >= n ? g.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, n));
800
+ };
801
+ g.prototype.get = function(e) {
802
+ if (!(e < 0 || e >= this.length))
803
+ return this.getInner(e);
804
+ };
805
+ g.prototype.forEach = function(e, n, r) {
806
+ n === void 0 && (n = 0), r === void 0 && (r = this.length), n <= r ? this.forEachInner(e, n, r, 0) : this.forEachInvertedInner(e, n, r, 0);
807
+ };
808
+ g.prototype.map = function(e, n, r) {
809
+ n === void 0 && (n = 0), r === void 0 && (r = this.length);
810
+ var s = [];
811
+ return this.forEach(function(i, o) {
812
+ return s.push(e(i, o));
813
+ }, n, r), s;
814
+ };
815
+ g.from = function(e) {
816
+ return e instanceof g ? e : e && e.length ? new te(e) : g.empty;
817
+ };
818
+ var te = /* @__PURE__ */ function(t) {
819
+ function e(r) {
820
+ t.call(this), this.values = r;
821
+ }
822
+ t && (e.__proto__ = t), e.prototype = Object.create(t && t.prototype), e.prototype.constructor = e;
823
+ var n = { length: { configurable: !0 }, depth: { configurable: !0 } };
824
+ return e.prototype.flatten = function() {
825
+ return this.values;
826
+ }, e.prototype.sliceInner = function(s, i) {
827
+ return s == 0 && i == this.length ? this : new e(this.values.slice(s, i));
828
+ }, e.prototype.getInner = function(s) {
829
+ return this.values[s];
830
+ }, e.prototype.forEachInner = function(s, i, o, a) {
831
+ for (var l = i; l < o; l++)
832
+ if (s(this.values[l], a + l) === !1)
833
+ return !1;
834
+ }, e.prototype.forEachInvertedInner = function(s, i, o, a) {
835
+ for (var l = i - 1; l >= o; l--)
836
+ if (s(this.values[l], a + l) === !1)
837
+ return !1;
838
+ }, e.prototype.leafAppend = function(s) {
839
+ if (this.length + s.length <= $)
840
+ return new e(this.values.concat(s.flatten()));
841
+ }, e.prototype.leafPrepend = function(s) {
842
+ if (this.length + s.length <= $)
843
+ return new e(s.flatten().concat(this.values));
844
+ }, n.length.get = function() {
845
+ return this.values.length;
846
+ }, n.depth.get = function() {
847
+ return 0;
848
+ }, Object.defineProperties(e.prototype, n), e;
849
+ }(g);
850
+ g.empty = new te([]);
851
+ var qe = /* @__PURE__ */ function(t) {
852
+ function e(n, r) {
853
+ t.call(this), this.left = n, this.right = r, this.length = n.length + r.length, this.depth = Math.max(n.depth, r.depth) + 1;
854
+ }
855
+ return t && (e.__proto__ = t), e.prototype = Object.create(t && t.prototype), e.prototype.constructor = e, e.prototype.flatten = function() {
856
+ return this.left.flatten().concat(this.right.flatten());
857
+ }, e.prototype.getInner = function(r) {
858
+ return r < this.left.length ? this.left.get(r) : this.right.get(r - this.left.length);
859
+ }, e.prototype.forEachInner = function(r, s, i, o) {
860
+ var a = this.left.length;
861
+ if (s < a && this.left.forEachInner(r, s, Math.min(i, a), o) === !1 || i > a && this.right.forEachInner(r, Math.max(s - a, 0), Math.min(this.length, i) - a, o + a) === !1)
862
+ return !1;
863
+ }, e.prototype.forEachInvertedInner = function(r, s, i, o) {
864
+ var a = this.left.length;
865
+ if (s > a && this.right.forEachInvertedInner(r, s - a, Math.max(i, a) - a, o + a) === !1 || i < a && this.left.forEachInvertedInner(r, Math.min(s, a), i, o) === !1)
866
+ return !1;
867
+ }, e.prototype.sliceInner = function(r, s) {
868
+ if (r == 0 && s == this.length)
869
+ return this;
870
+ var i = this.left.length;
871
+ return s <= i ? this.left.slice(r, s) : r >= i ? this.right.slice(r - i, s - i) : this.left.slice(r, i).append(this.right.slice(0, s - i));
872
+ }, e.prototype.leafAppend = function(r) {
873
+ var s = this.right.leafAppend(r);
874
+ if (s)
875
+ return new e(this.left, s);
876
+ }, e.prototype.leafPrepend = function(r) {
877
+ var s = this.left.leafPrepend(r);
878
+ if (s)
879
+ return new e(s, this.right);
880
+ }, e.prototype.appendInner = function(r) {
881
+ return this.left.depth >= Math.max(this.right.depth, r.depth) + 1 ? new e(this.left, new e(this.right, r)) : new e(this, r);
882
+ }, e;
883
+ }(g);
884
+ const Je = 500;
885
+ class M {
886
+ constructor(e, n) {
887
+ this.items = e, this.eventCount = n;
888
+ }
889
+ // Pop the latest event off the branch's history and apply it
890
+ // to a document transform.
891
+ popEvent(e, n) {
892
+ if (this.eventCount == 0)
893
+ return null;
894
+ let r = this.items.length;
895
+ for (; ; r--)
896
+ if (this.items.get(r - 1).selection) {
897
+ --r;
898
+ break;
899
+ }
900
+ let s, i;
901
+ n && (s = this.remapping(r, this.items.length), i = s.maps.length);
902
+ let o = e.tr, a, l, u = [], p = [];
903
+ return this.items.forEach((d, c) => {
904
+ if (!d.step) {
905
+ s || (s = this.remapping(r, c + 1), i = s.maps.length), i--, p.push(d);
906
+ return;
907
+ }
908
+ if (s) {
909
+ p.push(new k(d.map));
910
+ let f = d.step.map(s.slice(i)), b;
911
+ f && o.maybeStep(f).doc && (b = o.mapping.maps[o.mapping.maps.length - 1], u.push(new k(b, void 0, void 0, u.length + p.length))), i--, b && s.appendMap(b, i);
912
+ } else
913
+ o.maybeStep(d.step);
914
+ if (d.selection)
915
+ return a = s ? d.selection.map(s.slice(i)) : d.selection, l = new M(this.items.slice(0, r).append(p.reverse().concat(u)), this.eventCount - 1), !1;
916
+ }, this.items.length, 0), { remaining: l, transform: o, selection: a };
917
+ }
918
+ // Create a new branch with the given transform added.
919
+ addTransform(e, n, r, s) {
920
+ let i = [], o = this.eventCount, a = this.items, l = !s && a.length ? a.get(a.length - 1) : null;
921
+ for (let p = 0; p < e.steps.length; p++) {
922
+ let d = e.steps[p].invert(e.docs[p]), c = new k(e.mapping.maps[p], d, n), f;
923
+ (f = l && l.merge(c)) && (c = f, p ? i.pop() : a = a.slice(0, a.length - 1)), i.push(c), n && (o++, n = void 0), s || (l = c);
924
+ }
925
+ let u = o - r.depth;
926
+ return u > Xe && (a = Ue(a, u), o -= u), new M(a.append(i), o);
927
+ }
928
+ remapping(e, n) {
929
+ let r = new de();
930
+ return this.items.forEach((s, i) => {
931
+ let o = s.mirrorOffset != null && i - s.mirrorOffset >= e ? r.maps.length - s.mirrorOffset : void 0;
932
+ r.appendMap(s.map, o);
933
+ }, e, n), r;
934
+ }
935
+ addMaps(e) {
936
+ return this.eventCount == 0 ? this : new M(this.items.append(e.map((n) => new k(n))), this.eventCount);
937
+ }
938
+ // When the collab module receives remote changes, the history has
939
+ // to know about those, so that it can adjust the steps that were
940
+ // rebased on top of the remote changes, and include the position
941
+ // maps for the remote changes in its array of items.
942
+ rebased(e, n) {
943
+ if (!this.eventCount)
944
+ return this;
945
+ let r = [], s = Math.max(0, this.items.length - n), i = e.mapping, o = e.steps.length, a = this.eventCount;
946
+ this.items.forEach((c) => {
947
+ c.selection && a--;
948
+ }, s);
949
+ let l = n;
950
+ this.items.forEach((c) => {
951
+ let f = i.getMirror(--l);
952
+ if (f == null)
953
+ return;
954
+ o = Math.min(o, f);
955
+ let b = i.maps[f];
956
+ if (c.step) {
957
+ let S = e.steps[f].invert(e.docs[f]), L = c.selection && c.selection.map(i.slice(l + 1, f));
958
+ L && a++, r.push(new k(b, S, L));
959
+ } else
960
+ r.push(new k(b));
961
+ }, s);
962
+ let u = [];
963
+ for (let c = n; c < o; c++)
964
+ u.push(new k(i.maps[c]));
965
+ let p = this.items.slice(0, s).append(u).append(r), d = new M(p, a);
966
+ return d.emptyItemCount() > Je && (d = d.compress(this.items.length - r.length)), d;
967
+ }
968
+ emptyItemCount() {
969
+ let e = 0;
970
+ return this.items.forEach((n) => {
971
+ n.step || e++;
972
+ }), e;
973
+ }
974
+ // Compressing a branch means rewriting it to push the air (map-only
975
+ // items) out. During collaboration, these naturally accumulate
976
+ // because each remote change adds one. The `upto` argument is used
977
+ // to ensure that only the items below a given level are compressed,
978
+ // because `rebased` relies on a clean, untouched set of items in
979
+ // order to associate old items with rebased steps.
980
+ compress(e = this.items.length) {
981
+ let n = this.remapping(0, e), r = n.maps.length, s = [], i = 0;
982
+ return this.items.forEach((o, a) => {
983
+ if (a >= e)
984
+ s.push(o), o.selection && i++;
985
+ else if (o.step) {
986
+ let l = o.step.map(n.slice(r)), u = l && l.getMap();
987
+ if (r--, u && n.appendMap(u, r), l) {
988
+ let p = o.selection && o.selection.map(n.slice(r));
989
+ p && i++;
990
+ let d = new k(u.invert(), l, p), c, f = s.length - 1;
991
+ (c = s.length && s[f].merge(d)) ? s[f] = c : s.push(d);
992
+ }
993
+ } else o.map && r--;
994
+ }, this.items.length, 0), new M(g.from(s.reverse()), i);
995
+ }
996
+ }
997
+ M.empty = new M(g.empty, 0);
998
+ function Ue(t, e) {
999
+ let n;
1000
+ return t.forEach((r, s) => {
1001
+ if (r.selection && e-- == 0)
1002
+ return n = s, !1;
1003
+ }), t.slice(n);
1004
+ }
1005
+ class k {
1006
+ constructor(e, n, r, s) {
1007
+ this.map = e, this.step = n, this.selection = r, this.mirrorOffset = s;
1008
+ }
1009
+ merge(e) {
1010
+ if (this.step && e.step && !e.selection) {
1011
+ let n = e.step.merge(this.step);
1012
+ if (n)
1013
+ return new k(n.getMap().invert(), n, this.selection);
1014
+ }
1015
+ }
1016
+ }
1017
+ class T {
1018
+ constructor(e, n, r, s, i) {
1019
+ this.done = e, this.undone = n, this.prevRanges = r, this.prevTime = s, this.prevComposition = i;
1020
+ }
1021
+ }
1022
+ const Xe = 20;
1023
+ function Ye(t, e, n, r) {
1024
+ let s = n.getMeta(w), i;
1025
+ if (s)
1026
+ return s.historyState;
1027
+ n.getMeta(et) && (t = new T(t.done, t.undone, null, 0, -1));
1028
+ let o = n.getMeta("appendedTransaction");
1029
+ if (n.steps.length == 0)
1030
+ return t;
1031
+ if (o && o.getMeta(w))
1032
+ return o.getMeta(w).redo ? new T(t.done.addTransform(n, void 0, r, N(e)), t.undone, U(n.mapping.maps), t.prevTime, t.prevComposition) : new T(t.done, t.undone.addTransform(n, void 0, r, N(e)), null, t.prevTime, t.prevComposition);
1033
+ if (n.getMeta("addToHistory") !== !1 && !(o && o.getMeta("addToHistory") === !1)) {
1034
+ let a = n.getMeta("composition"), l = t.prevTime == 0 || !o && t.prevComposition != a && (t.prevTime < (n.time || 0) - r.newGroupDelay || !Ze(n, t.prevRanges)), u = o ? z(t.prevRanges, n.mapping) : U(n.mapping.maps);
1035
+ return new T(t.done.addTransform(n, l ? e.selection.getBookmark() : void 0, r, N(e)), M.empty, u, n.time, a ?? t.prevComposition);
1036
+ } else return (i = n.getMeta("rebased")) ? new T(t.done.rebased(n, i), t.undone.rebased(n, i), z(t.prevRanges, n.mapping), t.prevTime, t.prevComposition) : new T(t.done.addMaps(n.mapping.maps), t.undone.addMaps(n.mapping.maps), z(t.prevRanges, n.mapping), t.prevTime, t.prevComposition);
1037
+ }
1038
+ function Ze(t, e) {
1039
+ if (!e)
1040
+ return !1;
1041
+ if (!t.docChanged)
1042
+ return !0;
1043
+ let n = !1;
1044
+ return t.mapping.maps[0].forEach((r, s) => {
1045
+ for (let i = 0; i < e.length; i += 2)
1046
+ r <= e[i + 1] && s >= e[i] && (n = !0);
1047
+ }), n;
1048
+ }
1049
+ function U(t) {
1050
+ let e = [];
1051
+ for (let n = t.length - 1; n >= 0 && e.length == 0; n--)
1052
+ t[n].forEach((r, s, i, o) => e.push(i, o));
1053
+ return e;
1054
+ }
1055
+ function z(t, e) {
1056
+ if (!t)
1057
+ return null;
1058
+ let n = [];
1059
+ for (let r = 0; r < t.length; r += 2) {
1060
+ let s = e.map(t[r], 1), i = e.map(t[r + 1], -1);
1061
+ s <= i && n.push(s, i);
1062
+ }
1063
+ return n;
1064
+ }
1065
+ function Qe(t, e, n) {
1066
+ let r = N(e), s = w.get(e).spec.config, i = (n ? t.undone : t.done).popEvent(e, r);
1067
+ if (!i)
1068
+ return null;
1069
+ let o = i.selection.resolve(i.transform.doc), a = (n ? t.done : t.undone).addTransform(i.transform, e.selection.getBookmark(), s, r), l = new T(n ? a : i.remaining, n ? i.remaining : a, null, 0, -1);
1070
+ return i.transform.setSelection(o).setMeta(w, { redo: n, historyState: l });
1071
+ }
1072
+ let K = !1, X = null;
1073
+ function N(t) {
1074
+ let e = t.plugins;
1075
+ if (X != e) {
1076
+ K = !1, X = e;
1077
+ for (let n = 0; n < e.length; n++)
1078
+ if (e[n].spec.historyPreserveItems) {
1079
+ K = !0;
1080
+ break;
1081
+ }
1082
+ }
1083
+ return K;
1084
+ }
1085
+ const w = new P("history"), et = new P("closeHistory");
1086
+ function tt(t = {}) {
1087
+ return t = {
1088
+ depth: t.depth || 100,
1089
+ newGroupDelay: t.newGroupDelay || 500
1090
+ }, new H({
1091
+ key: w,
1092
+ state: {
1093
+ init() {
1094
+ return new T(M.empty, M.empty, null, 0, -1);
1095
+ },
1096
+ apply(e, n, r) {
1097
+ return Ye(n, r, e, t);
1098
+ }
1099
+ },
1100
+ config: t,
1101
+ props: {
1102
+ handleDOMEvents: {
1103
+ beforeinput(e, n) {
1104
+ let r = n.inputType, s = r == "historyUndo" ? re : r == "historyRedo" ? se : null;
1105
+ return s ? (n.preventDefault(), s(e.state, e.dispatch)) : !1;
1106
+ }
1107
+ }
1108
+ }
1109
+ });
1110
+ }
1111
+ function ne(t, e) {
1112
+ return (n, r) => {
1113
+ let s = w.getState(n);
1114
+ if (!s || (t ? s.undone : s.done).eventCount == 0)
1115
+ return !1;
1116
+ if (r) {
1117
+ let i = Qe(s, n, t);
1118
+ i && r(e ? i.scrollIntoView() : i);
1119
+ }
1120
+ return !0;
1121
+ };
1122
+ }
1123
+ const re = ne(!1, !0), se = ne(!0, !0), nt = x.create({
1124
+ name: "history",
1125
+ addOptions() {
1126
+ return {
1127
+ depth: 100,
1128
+ newGroupDelay: 500
1129
+ };
1130
+ },
1131
+ addCommands() {
1132
+ return {
1133
+ undo: () => ({ state: t, dispatch: e }) => re(t, e),
1134
+ redo: () => ({ state: t, dispatch: e }) => se(t, e)
1135
+ };
1136
+ },
1137
+ addProseMirrorPlugins() {
1138
+ return [
1139
+ tt(this.options)
1140
+ ];
1141
+ },
1142
+ addKeyboardShortcuts() {
1143
+ return {
1144
+ "Mod-z": () => this.editor.commands.undo(),
1145
+ "Shift-Mod-z": () => this.editor.commands.redo(),
1146
+ "Mod-y": () => this.editor.commands.redo(),
1147
+ // Russian keyboard layouts
1148
+ "Mod-я": () => this.editor.commands.undo(),
1149
+ "Shift-Mod-я": () => this.editor.commands.redo()
1150
+ };
1151
+ }
1152
+ }), rt = v.create({
1153
+ name: "horizontalRule",
1154
+ addOptions() {
1155
+ return {
1156
+ HTMLAttributes: {}
1157
+ };
1158
+ },
1159
+ group: "block",
1160
+ parseHTML() {
1161
+ return [{ tag: "hr" }];
1162
+ },
1163
+ renderHTML({ HTMLAttributes: t }) {
1164
+ return ["hr", y(this.options.HTMLAttributes, t)];
1165
+ },
1166
+ addCommands() {
1167
+ return {
1168
+ setHorizontalRule: () => ({ chain: t, state: e }) => {
1169
+ const { selection: n } = e, { $from: r, $to: s } = n, i = t();
1170
+ return r.parentOffset === 0 ? i.insertContentAt({
1171
+ from: Math.max(r.pos - 1, 0),
1172
+ to: s.pos
1173
+ }, {
1174
+ type: this.name
1175
+ }) : pe(n) ? i.insertContentAt(s.pos, {
1176
+ type: this.name
1177
+ }) : i.insertContent({ type: this.name }), i.command(({ tr: o, dispatch: a }) => {
1178
+ var l;
1179
+ if (a) {
1180
+ const { $to: u } = o.selection, p = u.end();
1181
+ if (u.nodeAfter)
1182
+ u.nodeAfter.isTextblock ? o.setSelection(I.create(o.doc, u.pos + 1)) : u.nodeAfter.isBlock ? o.setSelection(W.create(o.doc, u.pos)) : o.setSelection(I.create(o.doc, u.pos));
1183
+ else {
1184
+ const d = (l = u.parent.type.contentMatch.defaultType) === null || l === void 0 ? void 0 : l.create();
1185
+ d && (o.insert(p, d), o.setSelection(I.create(o.doc, p + 1)));
1186
+ }
1187
+ o.scrollIntoView();
1188
+ }
1189
+ return !0;
1190
+ }).run();
1191
+ }
1192
+ };
1193
+ },
1194
+ addInputRules() {
1195
+ return [
1196
+ ee({
1197
+ find: /^(?:---|—-|___\s|\*\*\*\s)$/,
1198
+ type: this.type
1199
+ })
1200
+ ];
1201
+ }
1202
+ }), st = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/, it = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g, ot = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/, at = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g, lt = R.create({
1203
+ name: "italic",
1204
+ addOptions() {
1205
+ return {
1206
+ HTMLAttributes: {}
1207
+ };
1208
+ },
1209
+ parseHTML() {
1210
+ return [
1211
+ {
1212
+ tag: "em"
1213
+ },
1214
+ {
1215
+ tag: "i",
1216
+ getAttrs: (t) => t.style.fontStyle !== "normal" && null
1217
+ },
1218
+ {
1219
+ style: "font-style=normal",
1220
+ clearMark: (t) => t.type.name === this.name
1221
+ },
1222
+ {
1223
+ style: "font-style=italic"
1224
+ }
1225
+ ];
1226
+ },
1227
+ renderHTML({ HTMLAttributes: t }) {
1228
+ return ["em", y(this.options.HTMLAttributes, t), 0];
1229
+ },
1230
+ addCommands() {
1231
+ return {
1232
+ setItalic: () => ({ commands: t }) => t.setMark(this.name),
1233
+ toggleItalic: () => ({ commands: t }) => t.toggleMark(this.name),
1234
+ unsetItalic: () => ({ commands: t }) => t.unsetMark(this.name)
1235
+ };
1236
+ },
1237
+ addKeyboardShortcuts() {
1238
+ return {
1239
+ "Mod-i": () => this.editor.commands.toggleItalic(),
1240
+ "Mod-I": () => this.editor.commands.toggleItalic()
1241
+ };
1242
+ },
1243
+ addInputRules() {
1244
+ return [
1245
+ A({
1246
+ find: st,
1247
+ type: this.type
1248
+ }),
1249
+ A({
1250
+ find: ot,
1251
+ type: this.type
1252
+ })
1253
+ ];
1254
+ },
1255
+ addPasteRules() {
1256
+ return [
1257
+ C({
1258
+ find: it,
1259
+ type: this.type
1260
+ }),
1261
+ C({
1262
+ find: at,
1263
+ type: this.type
1264
+ })
1265
+ ];
1266
+ }
1267
+ }), ut = v.create({
1268
+ name: "listItem",
1269
+ addOptions() {
1270
+ return {
1271
+ HTMLAttributes: {},
1272
+ bulletListTypeName: "bulletList",
1273
+ orderedListTypeName: "orderedList"
1274
+ };
1275
+ },
1276
+ content: "paragraph block*",
1277
+ defining: !0,
1278
+ parseHTML() {
1279
+ return [
1280
+ {
1281
+ tag: "li"
1282
+ }
1283
+ ];
1284
+ },
1285
+ renderHTML({ HTMLAttributes: t }) {
1286
+ return ["li", y(this.options.HTMLAttributes, t), 0];
1287
+ },
1288
+ addKeyboardShortcuts() {
1289
+ return {
1290
+ Enter: () => this.editor.commands.splitListItem(this.name),
1291
+ Tab: () => this.editor.commands.sinkListItem(this.name),
1292
+ "Shift-Tab": () => this.editor.commands.liftListItem(this.name)
1293
+ };
1294
+ }
1295
+ }), dt = "listItem", Y = "textStyle", Z = /^(\d+)\.\s$/, pt = v.create({
1296
+ name: "orderedList",
1297
+ addOptions() {
1298
+ return {
1299
+ itemTypeName: "listItem",
1300
+ HTMLAttributes: {},
1301
+ keepMarks: !1,
1302
+ keepAttributes: !1
1303
+ };
1304
+ },
1305
+ group: "block list",
1306
+ content() {
1307
+ return `${this.options.itemTypeName}+`;
1308
+ },
1309
+ addAttributes() {
1310
+ return {
1311
+ start: {
1312
+ default: 1,
1313
+ parseHTML: (t) => t.hasAttribute("start") ? parseInt(t.getAttribute("start") || "", 10) : 1
1314
+ },
1315
+ type: {
1316
+ default: void 0,
1317
+ parseHTML: (t) => t.getAttribute("type")
1318
+ }
1319
+ };
1320
+ },
1321
+ parseHTML() {
1322
+ return [
1323
+ {
1324
+ tag: "ol"
1325
+ }
1326
+ ];
1327
+ },
1328
+ renderHTML({ HTMLAttributes: t }) {
1329
+ const { start: e, ...n } = t;
1330
+ return e === 1 ? ["ol", y(this.options.HTMLAttributes, n), 0] : ["ol", y(this.options.HTMLAttributes, t), 0];
1331
+ },
1332
+ addCommands() {
1333
+ return {
1334
+ toggleOrderedList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(dt, this.editor.getAttributes(Y)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
1335
+ };
1336
+ },
1337
+ addKeyboardShortcuts() {
1338
+ return {
1339
+ "Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
1340
+ };
1341
+ },
1342
+ addInputRules() {
1343
+ let t = E({
1344
+ find: Z,
1345
+ type: this.type,
1346
+ getAttributes: (e) => ({ start: +e[1] }),
1347
+ joinPredicate: (e, n) => n.childCount + n.attrs.start === +e[1]
1348
+ });
1349
+ return (this.options.keepMarks || this.options.keepAttributes) && (t = E({
1350
+ find: Z,
1351
+ type: this.type,
1352
+ keepMarks: this.options.keepMarks,
1353
+ keepAttributes: this.options.keepAttributes,
1354
+ getAttributes: (e) => ({ start: +e[1], ...this.editor.getAttributes(Y) }),
1355
+ joinPredicate: (e, n) => n.childCount + n.attrs.start === +e[1],
1356
+ editor: this.editor
1357
+ })), [
1358
+ t
1359
+ ];
1360
+ }
1361
+ }), ct = v.create({
1362
+ name: "paragraph",
1363
+ priority: 1e3,
1364
+ addOptions() {
1365
+ return {
1366
+ HTMLAttributes: {}
1367
+ };
1368
+ },
1369
+ group: "block",
1370
+ content: "inline*",
1371
+ parseHTML() {
1372
+ return [
1373
+ { tag: "p" }
1374
+ ];
1375
+ },
1376
+ renderHTML({ HTMLAttributes: t }) {
1377
+ return ["p", y(this.options.HTMLAttributes, t), 0];
1378
+ },
1379
+ addCommands() {
1380
+ return {
1381
+ setParagraph: () => ({ commands: t }) => t.setNode(this.name)
1382
+ };
1383
+ },
1384
+ addKeyboardShortcuts() {
1385
+ return {
1386
+ "Mod-Alt-0": () => this.editor.commands.setParagraph()
1387
+ };
1388
+ }
1389
+ }), ht = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, ft = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, mt = R.create({
1390
+ name: "strike",
1391
+ addOptions() {
1392
+ return {
1393
+ HTMLAttributes: {}
1394
+ };
1395
+ },
1396
+ parseHTML() {
1397
+ return [
1398
+ {
1399
+ tag: "s"
1400
+ },
1401
+ {
1402
+ tag: "del"
1403
+ },
1404
+ {
1405
+ tag: "strike"
1406
+ },
1407
+ {
1408
+ style: "text-decoration",
1409
+ consuming: !1,
1410
+ getAttrs: (t) => t.includes("line-through") ? {} : !1
1411
+ }
1412
+ ];
1413
+ },
1414
+ renderHTML({ HTMLAttributes: t }) {
1415
+ return ["s", y(this.options.HTMLAttributes, t), 0];
1416
+ },
1417
+ addCommands() {
1418
+ return {
1419
+ setStrike: () => ({ commands: t }) => t.setMark(this.name),
1420
+ toggleStrike: () => ({ commands: t }) => t.toggleMark(this.name),
1421
+ unsetStrike: () => ({ commands: t }) => t.unsetMark(this.name)
1422
+ };
1423
+ },
1424
+ addKeyboardShortcuts() {
1425
+ return {
1426
+ "Mod-Shift-s": () => this.editor.commands.toggleStrike()
1427
+ };
1428
+ },
1429
+ addInputRules() {
1430
+ return [
1431
+ A({
1432
+ find: ht,
1433
+ type: this.type
1434
+ })
1435
+ ];
1436
+ },
1437
+ addPasteRules() {
1438
+ return [
1439
+ C({
1440
+ find: ft,
1441
+ type: this.type
1442
+ })
1443
+ ];
1444
+ }
1445
+ }), gt = v.create({
1446
+ name: "text",
1447
+ group: "inline"
1448
+ }), yt = x.create({
1449
+ name: "starterKit",
1450
+ addExtensions() {
1451
+ var t, e, n, r, s, i, o, a, l, u, p, d, c, f, b, S, L, D;
1452
+ const m = [];
1453
+ return this.options.bold !== !1 && m.push(Ae.configure((t = this.options) === null || t === void 0 ? void 0 : t.bold)), this.options.blockquote !== !1 && m.push(be.configure((e = this.options) === null || e === void 0 ? void 0 : e.blockquote)), this.options.bulletList !== !1 && m.push(Le.configure((n = this.options) === null || n === void 0 ? void 0 : n.bulletList)), this.options.code !== !1 && m.push(He.configure((r = this.options) === null || r === void 0 ? void 0 : r.code)), this.options.codeBlock !== !1 && m.push(Oe.configure((s = this.options) === null || s === void 0 ? void 0 : s.codeBlock)), this.options.document !== !1 && m.push(Pe.configure((i = this.options) === null || i === void 0 ? void 0 : i.document)), this.options.dropcursor !== !1 && m.push(Ne.configure((o = this.options) === null || o === void 0 ? void 0 : o.dropcursor)), this.options.gapcursor !== !1 && m.push(We.configure((a = this.options) === null || a === void 0 ? void 0 : a.gapcursor)), this.options.hardBreak !== !1 && m.push(je.configure((l = this.options) === null || l === void 0 ? void 0 : l.hardBreak)), this.options.heading !== !1 && m.push(Ge.configure((u = this.options) === null || u === void 0 ? void 0 : u.heading)), this.options.history !== !1 && m.push(nt.configure((p = this.options) === null || p === void 0 ? void 0 : p.history)), this.options.horizontalRule !== !1 && m.push(rt.configure((d = this.options) === null || d === void 0 ? void 0 : d.horizontalRule)), this.options.italic !== !1 && m.push(lt.configure((c = this.options) === null || c === void 0 ? void 0 : c.italic)), this.options.listItem !== !1 && m.push(ut.configure((f = this.options) === null || f === void 0 ? void 0 : f.listItem)), this.options.orderedList !== !1 && m.push(pt.configure((b = this.options) === null || b === void 0 ? void 0 : b.orderedList)), this.options.paragraph !== !1 && m.push(ct.configure((S = this.options) === null || S === void 0 ? void 0 : S.paragraph)), this.options.strike !== !1 && m.push(mt.configure((L = this.options) === null || L === void 0 ? void 0 : L.strike)), this.options.text !== !1 && m.push(gt.configure((D = this.options) === null || D === void 0 ? void 0 : D.text)), m;
1454
+ }
1455
+ }), vt = x.create({
1456
+ name: "focus",
1457
+ addOptions() {
1458
+ return {
1459
+ className: "has-focus",
1460
+ mode: "all"
1461
+ };
1462
+ },
1463
+ addProseMirrorPlugins() {
1464
+ return [
1465
+ new H({
1466
+ key: new P("focus"),
1467
+ props: {
1468
+ decorations: ({ doc: t, selection: e }) => {
1469
+ const { isEditable: n, isFocused: r } = this.editor, { anchor: s } = e, i = [];
1470
+ if (!n || !r)
1471
+ return B.create(t, []);
1472
+ let o = 0;
1473
+ this.options.mode === "deepest" && t.descendants((l, u) => {
1474
+ if (l.isText)
1475
+ return;
1476
+ if (!(s >= u && s <= u + l.nodeSize - 1))
1477
+ return !1;
1478
+ o += 1;
1479
+ });
1480
+ let a = 0;
1481
+ return t.descendants((l, u) => {
1482
+ if (l.isText || !(s >= u && s <= u + l.nodeSize - 1))
1483
+ return !1;
1484
+ if (a += 1, this.options.mode === "deepest" && o - a > 0 || this.options.mode === "shallowest" && a > 1)
1485
+ return this.options.mode === "deepest";
1486
+ i.push(F.node(u, u + l.nodeSize, {
1487
+ class: this.options.className
1488
+ }));
1489
+ }), B.create(t, i);
1490
+ }
1491
+ }
1492
+ })
1493
+ ];
1494
+ }
1495
+ }), bt = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, Mt = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g, kt = R.create({
1496
+ name: "highlight",
1497
+ addOptions() {
1498
+ return {
1499
+ multicolor: !1,
1500
+ HTMLAttributes: {}
1501
+ };
1502
+ },
1503
+ addAttributes() {
1504
+ return this.options.multicolor ? {
1505
+ color: {
1506
+ default: null,
1507
+ parseHTML: (t) => t.getAttribute("data-color") || t.style.backgroundColor,
1508
+ renderHTML: (t) => t.color ? {
1509
+ "data-color": t.color,
1510
+ style: `background-color: ${t.color}; color: inherit`
1511
+ } : {}
1512
+ }
1513
+ } : {};
1514
+ },
1515
+ parseHTML() {
1516
+ return [
1517
+ {
1518
+ tag: "mark"
1519
+ }
1520
+ ];
1521
+ },
1522
+ renderHTML({ HTMLAttributes: t }) {
1523
+ return ["mark", y(this.options.HTMLAttributes, t), 0];
1524
+ },
1525
+ addCommands() {
1526
+ return {
1527
+ setHighlight: (t) => ({ commands: e }) => e.setMark(this.name, t),
1528
+ toggleHighlight: (t) => ({ commands: e }) => e.toggleMark(this.name, t),
1529
+ unsetHighlight: () => ({ commands: t }) => t.unsetMark(this.name)
1530
+ };
1531
+ },
1532
+ addKeyboardShortcuts() {
1533
+ return {
1534
+ "Mod-Shift-h": () => this.editor.commands.toggleHighlight()
1535
+ };
1536
+ },
1537
+ addInputRules() {
1538
+ return [
1539
+ A({
1540
+ find: bt,
1541
+ type: this.type
1542
+ })
1543
+ ];
1544
+ },
1545
+ addPasteRules() {
1546
+ return [
1547
+ C({
1548
+ find: Mt,
1549
+ type: this.type
1550
+ })
1551
+ ];
1552
+ }
1553
+ }), Tt = /(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/, wt = v.create({
1554
+ name: "image",
1555
+ addOptions() {
1556
+ return {
1557
+ inline: !1,
1558
+ allowBase64: !1,
1559
+ HTMLAttributes: {}
1560
+ };
1561
+ },
1562
+ inline() {
1563
+ return this.options.inline;
1564
+ },
1565
+ group() {
1566
+ return this.options.inline ? "inline" : "block";
1567
+ },
1568
+ draggable: !0,
1569
+ addAttributes() {
1570
+ return {
1571
+ src: {
1572
+ default: null
1573
+ },
1574
+ alt: {
1575
+ default: null
1576
+ },
1577
+ title: {
1578
+ default: null
1579
+ }
1580
+ };
1581
+ },
1582
+ parseHTML() {
1583
+ return [
1584
+ {
1585
+ tag: this.options.allowBase64 ? "img[src]" : 'img[src]:not([src^="data:"])'
1586
+ }
1587
+ ];
1588
+ },
1589
+ renderHTML({ HTMLAttributes: t }) {
1590
+ return ["img", y(this.options.HTMLAttributes, t)];
1591
+ },
1592
+ addCommands() {
1593
+ return {
1594
+ setImage: (t) => ({ commands: e }) => e.insertContent({
1595
+ type: this.name,
1596
+ attrs: t
1597
+ })
1598
+ };
1599
+ },
1600
+ addInputRules() {
1601
+ return [
1602
+ ee({
1603
+ find: Tt,
1604
+ type: this.type,
1605
+ getAttributes: (t) => {
1606
+ const [, , e, n, r] = t;
1607
+ return { src: n, alt: e, title: r };
1608
+ }
1609
+ })
1610
+ ];
1611
+ }
1612
+ }), St = (t) => [
1613
+ yt.configure({
1614
+ dropcursor: {
1615
+ width: 4,
1616
+ color: "#ebf6fe"
1617
+ }
1618
+ }),
1619
+ ye.configure({
1620
+ showOnlyWhenEditable: !0,
1621
+ includeChildren: !0,
1622
+ showOnlyCurrent: !1,
1623
+ emptyEditorClass: "is-editor-empty",
1624
+ emptyNodeClass: "is-node-empty",
1625
+ placeholder: ({ editor: e, node: n }) => e.isDestroyed ? "" : n.type.name === "heading" ? `Heading ${n.attrs.level}` : t.placeholderText || 'Type "/" for commands...'
1626
+ }),
1627
+ vt.configure({ mode: "deepest", className: "has-focus" }),
1628
+ ce.configure({
1629
+ slashSuggestion: {
1630
+ items: he,
1631
+ render: fe
1632
+ }
1633
+ }),
1634
+ kt,
1635
+ me,
1636
+ ge,
1637
+ wt.configure({
1638
+ inline: !0,
1639
+ HTMLAttributes: {
1640
+ class: "scribe-image-node"
1641
+ },
1642
+ allowBase64: !0
1643
+ })
1644
+ ];
1645
+ export {
1646
+ St as initExtensions
1647
+ };