@blocknote/core 0.7.1-alpha.0 → 0.8.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 (71) hide show
  1. package/dist/blocknote.js +1428 -1252
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +2 -2
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/package.json +3 -3
  7. package/src/BlockNoteEditor.ts +100 -53
  8. package/src/BlockNoteExtensions.ts +24 -14
  9. package/src/api/blockManipulation/blockManipulation.test.ts +6 -3
  10. package/src/api/blockManipulation/blockManipulation.ts +7 -6
  11. package/src/api/formatConversions/formatConversions.test.ts +13 -8
  12. package/src/api/formatConversions/formatConversions.ts +15 -12
  13. package/src/api/nodeConversions/nodeConversions.test.ts +29 -10
  14. package/src/api/nodeConversions/nodeConversions.ts +33 -12
  15. package/src/api/nodeConversions/testUtil.ts +8 -4
  16. package/src/editor.module.css +0 -1
  17. package/src/extensions/Blocks/api/block.ts +229 -0
  18. package/src/extensions/Blocks/api/blockTypes.ts +158 -71
  19. package/src/extensions/Blocks/api/cursorPositionTypes.ts +5 -5
  20. package/src/extensions/Blocks/api/defaultBlocks.ts +44 -0
  21. package/src/extensions/Blocks/api/selectionTypes.ts +3 -3
  22. package/src/extensions/Blocks/api/serialization.ts +29 -0
  23. package/src/extensions/Blocks/index.ts +0 -8
  24. package/src/extensions/Blocks/nodes/Block.module.css +24 -12
  25. package/src/extensions/Blocks/nodes/BlockContainer.ts +8 -4
  26. package/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.ts +4 -4
  27. package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +5 -5
  28. package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +100 -97
  29. package/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.ts +4 -4
  30. package/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.ts +11 -9
  31. package/src/extensions/DraggableBlocks/DraggableBlocksExtension.ts +6 -5
  32. package/src/extensions/DraggableBlocks/DraggableBlocksPlugin.ts +12 -11
  33. package/src/extensions/FormattingToolbar/FormattingToolbarExtension.ts +21 -16
  34. package/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.ts +9 -5
  35. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +30 -42
  36. package/src/extensions/Placeholder/PlaceholderExtension.ts +1 -0
  37. package/src/extensions/SlashMenu/BaseSlashMenuItem.ts +5 -2
  38. package/src/extensions/SlashMenu/SlashMenuExtension.ts +37 -33
  39. package/src/extensions/SlashMenu/defaultSlashMenuItems.tsx +14 -10
  40. package/src/extensions/SlashMenu/index.ts +2 -2
  41. package/src/index.ts +4 -0
  42. package/src/shared/plugins/suggestion/SuggestionPlugin.ts +29 -13
  43. package/types/src/BlockNoteEditor.d.ts +37 -23
  44. package/types/src/BlockNoteExtensions.d.ts +15 -8
  45. package/types/src/api/blockManipulation/blockManipulation.d.ts +4 -4
  46. package/types/src/api/formatConversions/formatConversions.d.ts +5 -5
  47. package/types/src/api/nodeConversions/nodeConversions.d.ts +3 -3
  48. package/types/src/api/nodeConversions/testUtil.d.ts +2 -2
  49. package/types/src/extensions/Blocks/api/block.d.ts +2 -4
  50. package/types/src/extensions/Blocks/api/blockTypes.d.ts +77 -33
  51. package/types/src/extensions/Blocks/api/cursorPositionTypes.d.ts +5 -5
  52. package/types/src/extensions/Blocks/api/defaultBlocks.d.ts +4 -4
  53. package/types/src/extensions/Blocks/api/selectionTypes.d.ts +3 -3
  54. package/types/src/extensions/Blocks/api/serialization.d.ts +2 -0
  55. package/types/src/extensions/Blocks/nodes/BlockContainer.d.ts +3 -3
  56. package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.d.ts +1 -2
  57. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +1 -2
  58. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +1 -2
  59. package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.d.ts +1 -2
  60. package/types/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.d.ts +7 -7
  61. package/types/src/extensions/DraggableBlocks/DraggableBlocksExtension.d.ts +5 -4
  62. package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +11 -10
  63. package/types/src/extensions/FormattingToolbar/FormattingToolbarExtension.d.ts +6 -5
  64. package/types/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.d.ts +4 -3
  65. package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +16 -19
  66. package/types/src/extensions/SlashMenu/BaseSlashMenuItem.d.ts +4 -3
  67. package/types/src/extensions/SlashMenu/SlashMenuExtension.d.ts +5 -4
  68. package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +66 -1
  69. package/types/src/extensions/SlashMenu/index.d.ts +2 -2
  70. package/types/src/index.d.ts +4 -0
  71. package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +5 -4
package/dist/blocknote.js CHANGED
@@ -1,87 +1,487 @@
1
- var Et = Object.defineProperty;
2
- var Ct = (o, t, e) => t in o ? Et(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var u = (o, t, e) => (Ct(o, typeof t != "symbol" ? t + "" : t, e), e);
4
- import { Extension as E, findChildren as G, combineTransactionSteps as Mt, getChangedRanges as Bt, findChildrenInRange as Tt, Mark as rt, Node as S, mergeAttributes as w, InputRule as j, findParentNode as wt, isTextSelection as St, isNodeSelection as xt, posToDOMRect as nt, getMarkRange as X, extensions as N, Editor as It } from "@tiptap/core";
5
- import { Slice as P, Fragment as L, DOMSerializer as Pt, DOMParser as Lt } from "prosemirror-model";
6
- import { Plugin as C, PluginKey as v, TextSelection as Q, Selection as $, NodeSelection as _t } from "prosemirror-state";
7
- import { v4 as At } from "uuid";
8
- import it from "rehype-parse";
9
- import Nt from "rehype-remark";
10
- import st from "rehype-stringify";
11
- import at from "remark-gfm";
12
- import Ht from "remark-parse";
13
- import Ot from "remark-rehype";
14
- import Dt from "remark-stringify";
15
- import { unified as W } from "unified";
16
- import { fromDom as Z } from "hast-util-from-dom";
17
- import { Bold as Ft } from "@tiptap/extension-bold";
18
- import { Code as Rt } from "@tiptap/extension-code";
19
- import zt from "@tiptap/extension-collaboration";
20
- import Ut from "@tiptap/extension-collaboration-cursor";
21
- import { Dropcursor as $t } from "@tiptap/extension-dropcursor";
22
- import { Gapcursor as Gt } from "@tiptap/extension-gapcursor";
23
- import { HardBreak as qt } from "@tiptap/extension-hard-break";
24
- import { History as jt } from "@tiptap/extension-history";
25
- import { Italic as Wt } from "@tiptap/extension-italic";
26
- import { Link as lt } from "@tiptap/extension-link";
27
- import { Strike as Yt } from "@tiptap/extension-strike";
28
- import { Text as Kt } from "@tiptap/extension-text";
29
- import { Underline as Vt } from "@tiptap/extension-underline";
30
- import * as Jt from "prosemirror-view";
1
+ var Lt = Object.defineProperty;
2
+ var At = (o, e, t) => e in o ? Lt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var h = (o, e, t) => (At(o, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { Node as R, InputRule as V, mergeAttributes as w, Extension as v, findChildren as j, combineTransactionSteps as Nt, getChangedRanges as Ht, findChildrenInRange as Ot, Mark as it, findParentNode as Dt, isTextSelection as Ft, isNodeSelection as Rt, posToDOMRect as st, getMarkRange as Q, extensions as A, Editor as zt } from "@tiptap/core";
5
+ import { PluginKey as E, Plugin as C, TextSelection as tt, Selection as G, NodeSelection as Ut } from "prosemirror-state";
6
+ import { Slice as I, Fragment as _, DOMSerializer as q, DOMParser as $t } from "prosemirror-model";
7
+ import { v4 as Gt } from "uuid";
8
+ import at from "rehype-parse";
9
+ import jt from "rehype-remark";
10
+ import lt from "rehype-stringify";
11
+ import dt from "remark-gfm";
12
+ import qt from "remark-parse";
13
+ import Wt from "remark-rehype";
14
+ import Vt from "remark-stringify";
15
+ import { unified as Y } from "unified";
16
+ import { fromDom as et } from "hast-util-from-dom";
17
+ import { Bold as Yt } from "@tiptap/extension-bold";
18
+ import { Code as Kt } from "@tiptap/extension-code";
19
+ import Jt from "@tiptap/extension-collaboration";
20
+ import Xt from "@tiptap/extension-collaboration-cursor";
21
+ import { Dropcursor as Zt } from "@tiptap/extension-dropcursor";
22
+ import { Gapcursor as Qt } from "@tiptap/extension-gapcursor";
23
+ import { HardBreak as te } from "@tiptap/extension-hard-break";
24
+ import { History as ee } from "@tiptap/extension-history";
25
+ import { Italic as oe } from "@tiptap/extension-italic";
26
+ import { Link as ct } from "@tiptap/extension-link";
27
+ import { Strike as ne } from "@tiptap/extension-strike";
28
+ import { Text as re } from "@tiptap/extension-text";
29
+ import { Underline as ie } from "@tiptap/extension-underline";
30
+ import * as se from "prosemirror-view";
31
31
  import { Decoration as D, DecorationSet as F } from "prosemirror-view";
32
- const O = [
33
- "backgroundColor",
34
- "textColor",
35
- "textAlignment"
36
- ], tt = {
37
- paragraph: /* @__PURE__ */ new Set([...O]),
38
- heading: /* @__PURE__ */ new Set([
39
- ...O,
40
- "level"
41
- ]),
42
- numberedListItem: /* @__PURE__ */ new Set([
43
- ...O
44
- ]),
45
- bulletListItem: /* @__PURE__ */ new Set([...O])
46
- };
47
- function g(o, t) {
48
- if (t < 0 || t > o.nodeSize)
32
+ const ut = "_blockOuter_1a5p7_5", ht = "_block_1a5p7_5", pt = "_reactNodeViewRenderer_1a5p7_17", mt = "_blockContent_1a5p7_22", ft = "_blockGroup_1a5p7_42", gt = "_isEmpty_1a5p7_240", kt = "_inlineContent_1a5p7_240", bt = "_isFilter_1a5p7_241", yt = "_hasAnchor_1a5p7_263", k = {
33
+ blockOuter: ut,
34
+ block: ht,
35
+ reactNodeViewRenderer: pt,
36
+ blockContent: mt,
37
+ blockGroup: ft,
38
+ isEmpty: gt,
39
+ inlineContent: kt,
40
+ isFilter: bt,
41
+ hasAnchor: yt
42
+ }, Vo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
43
+ __proto__: null,
44
+ block: ht,
45
+ blockContent: mt,
46
+ blockGroup: ft,
47
+ blockOuter: ut,
48
+ default: k,
49
+ hasAnchor: yt,
50
+ inlineContent: kt,
51
+ isEmpty: gt,
52
+ isFilter: bt,
53
+ reactNodeViewRenderer: pt
54
+ }, Symbol.toStringTag, { value: "Module" }));
55
+ function ot(o) {
56
+ return "data-" + o.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
57
+ }
58
+ function ae(o) {
59
+ const e = {};
60
+ return Object.entries(o.propSchema).forEach(([t, n]) => {
61
+ e[t] = {
62
+ default: n.default,
63
+ keepOnSplit: !0,
64
+ // Props are displayed in kebab-case as HTML attributes. If a prop's
65
+ // value is the same as its default, we don't display an HTML
66
+ // attribute for it.
67
+ parseHTML: (r) => r.getAttribute(ot(t)),
68
+ renderHTML: (r) => r[t] !== n.default ? {
69
+ [ot(t)]: r[t]
70
+ } : {}
71
+ };
72
+ }), e;
73
+ }
74
+ function le(o) {
75
+ return [
76
+ {
77
+ tag: "div[data-content-type=" + o.type + "]"
78
+ }
79
+ ];
80
+ }
81
+ function de(o, e) {
82
+ const t = document.createElement("div");
83
+ t.setAttribute("data-content-type", o.type);
84
+ for (const [r, i] of Object.entries(e))
85
+ t.setAttribute(r, i);
86
+ let n;
87
+ return o.containsInlineContent ? (n = document.createElement("div"), t.appendChild(n)) : n = void 0, n !== void 0 ? {
88
+ dom: t,
89
+ contentDOM: n
90
+ } : {
91
+ dom: t
92
+ };
93
+ }
94
+ function Yo(o) {
95
+ return {
96
+ node: H({
97
+ name: o.type,
98
+ content: o.containsInlineContent ? "inline*" : "",
99
+ selectable: o.containsInlineContent,
100
+ addOptions() {
101
+ return {
102
+ editor: void 0
103
+ };
104
+ },
105
+ addAttributes() {
106
+ return ae(o);
107
+ },
108
+ parseHTML() {
109
+ return le(o);
110
+ },
111
+ renderHTML({ HTMLAttributes: t }) {
112
+ return de(o, t);
113
+ },
114
+ addNodeView() {
115
+ return ({ HTMLAttributes: t, getPos: n }) => {
116
+ const r = document.createElement("div");
117
+ r.className = k.blockContent, r.setAttribute("data-content-type", o.type);
118
+ for (const [p, m] of Object.entries(t))
119
+ r.setAttribute(p, m);
120
+ const i = this.options.editor;
121
+ if (typeof n == "boolean")
122
+ throw new Error(
123
+ "Cannot find node position as getPos is a boolean, not a function."
124
+ );
125
+ const a = n(), d = i._tiptapEditor.state.doc.resolve(a).node().attrs.id, c = i.getBlock(d);
126
+ if (c.type !== o.type)
127
+ throw new Error("Block type does not match");
128
+ const u = o.render(c, i);
129
+ return "contentDOM" in u && (u.contentDOM.className = `${u.contentDOM.className ? u.contentDOM.className + " " : ""}${k.inlineContent}`), r.appendChild(u.dom), "contentDOM" in u ? {
130
+ dom: r,
131
+ contentDOM: u.contentDOM
132
+ } : {
133
+ dom: r
134
+ };
135
+ };
136
+ }
137
+ }),
138
+ propSchema: o.propSchema
139
+ };
140
+ }
141
+ function H(o) {
142
+ return R.create({
143
+ ...o,
144
+ group: "blockContent"
145
+ });
146
+ }
147
+ const ce = H({
148
+ name: "heading",
149
+ content: "inline*",
150
+ addAttributes() {
151
+ return {
152
+ level: {
153
+ default: "1",
154
+ // instead of "level" attributes, use "data-level"
155
+ parseHTML: (o) => o.getAttribute("data-level"),
156
+ renderHTML: (o) => ({
157
+ "data-level": o.level
158
+ })
159
+ }
160
+ };
161
+ },
162
+ addInputRules() {
163
+ return [
164
+ ...["1", "2", "3"].map((o) => new V({
165
+ find: new RegExp(`^(#{${parseInt(o)}})\\s$`),
166
+ handler: ({ state: e, chain: t, range: n }) => {
167
+ t().BNUpdateBlock(e.selection.from, {
168
+ type: "heading",
169
+ props: {
170
+ level: o
171
+ }
172
+ }).deleteRange({ from: n.from, to: n.to });
173
+ }
174
+ }))
175
+ ];
176
+ },
177
+ parseHTML() {
178
+ return [
179
+ {
180
+ tag: "h1",
181
+ attrs: { level: "1" },
182
+ node: "heading"
183
+ },
184
+ {
185
+ tag: "h2",
186
+ attrs: { level: "2" },
187
+ node: "heading"
188
+ },
189
+ {
190
+ tag: "h3",
191
+ attrs: { level: "3" },
192
+ node: "heading"
193
+ }
194
+ ];
195
+ },
196
+ renderHTML({ node: o, HTMLAttributes: e }) {
197
+ return [
198
+ "div",
199
+ w(e, {
200
+ class: k.blockContent,
201
+ "data-content-type": this.name
202
+ }),
203
+ ["h" + o.attrs.level, { class: k.inlineContent }, 0]
204
+ ];
205
+ }
206
+ });
207
+ function g(o, e) {
208
+ if (e < 0 || e > o.nodeSize)
49
209
  return;
50
- const e = o.resolve(t), r = e.depth;
51
- let n = e.node(r), i = r;
210
+ const t = o.resolve(e), n = t.depth;
211
+ let r = t.node(n), i = n;
52
212
  for (; ; ) {
53
213
  if (i < 0)
54
214
  return;
55
- if (n.type.name === "blockContainer")
215
+ if (r.type.name === "blockContainer")
56
216
  break;
57
- i -= 1, n = e.node(i);
217
+ i -= 1, r = t.node(i);
58
218
  }
59
- const a = n.attrs.id, s = n.firstChild, l = s.type, d = n.childCount === 2 ? n.lastChild.childCount : 0, c = e.start(i), h = e.end(i);
219
+ const a = r.attrs.id, s = r.firstChild, l = s.type, d = r.childCount === 2 ? r.lastChild.childCount : 0, c = t.start(i), u = t.end(i);
60
220
  return {
61
221
  id: a,
62
- node: n,
222
+ node: r,
63
223
  contentNode: s,
64
224
  contentType: l,
65
225
  numChildBlocks: d,
66
226
  startPos: c,
67
- endPos: h,
227
+ endPos: u,
68
228
  depth: i
69
229
  };
70
230
  }
71
- function Xt(o, t = JSON.stringify) {
72
- const e = {};
73
- return o.filter((r) => {
74
- const n = t(r);
75
- return Object.prototype.hasOwnProperty.call(e, n) ? !1 : e[n] = !0;
231
+ const vt = (o) => {
232
+ const { node: e, contentType: t } = g(
233
+ o.state.doc,
234
+ o.state.selection.from
235
+ ), n = o.state.selection.anchor === o.state.selection.head;
236
+ return !t.name.endsWith("ListItem") || !n ? !1 : o.commands.first(({ state: r, chain: i, commands: a }) => [
237
+ () => (
238
+ // Changes list item block to a text block if the content is empty.
239
+ a.command(() => e.textContent.length === 0 ? a.BNUpdateBlock(r.selection.from, {
240
+ type: "paragraph",
241
+ props: {}
242
+ }) : !1)
243
+ ),
244
+ () => (
245
+ // Splits the current block, moving content inside that's after the cursor to a new block of the same type
246
+ // below.
247
+ a.command(() => e.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
248
+ )
249
+ ]);
250
+ }, ue = H({
251
+ name: "bulletListItem",
252
+ content: "inline*",
253
+ addInputRules() {
254
+ return [
255
+ // Creates an unordered list when starting with "-", "+", or "*".
256
+ new V({
257
+ find: new RegExp("^[-+*]\\s$"),
258
+ handler: ({ state: o, chain: e, range: t }) => {
259
+ e().BNUpdateBlock(o.selection.from, {
260
+ type: "bulletListItem",
261
+ props: {}
262
+ }).deleteRange({ from: t.from, to: t.to });
263
+ }
264
+ })
265
+ ];
266
+ },
267
+ addKeyboardShortcuts() {
268
+ return {
269
+ Enter: () => vt(this.editor)
270
+ };
271
+ },
272
+ parseHTML() {
273
+ return [
274
+ // Case for regular HTML list structure.
275
+ {
276
+ tag: "li",
277
+ getAttrs: (o) => {
278
+ if (typeof o == "string")
279
+ return !1;
280
+ const e = o.parentElement;
281
+ return e === null ? !1 : e.tagName === "UL" ? {} : !1;
282
+ },
283
+ node: "bulletListItem"
284
+ },
285
+ // Case for BlockNote list structure.
286
+ {
287
+ tag: "p",
288
+ getAttrs: (o) => {
289
+ if (typeof o == "string")
290
+ return !1;
291
+ const e = o.parentElement;
292
+ return e === null ? !1 : e.getAttribute("data-content-type") === "bulletListItem" ? {} : !1;
293
+ },
294
+ priority: 300,
295
+ node: "bulletListItem"
296
+ }
297
+ ];
298
+ },
299
+ renderHTML({ HTMLAttributes: o }) {
300
+ return [
301
+ "div",
302
+ w(o, {
303
+ class: k.blockContent,
304
+ "data-content-type": this.name
305
+ }),
306
+ ["p", { class: k.inlineContent }, 0]
307
+ ];
308
+ }
309
+ }), he = new E("numbered-list-indexing"), pe = () => new C({
310
+ key: he,
311
+ appendTransaction: (o, e, t) => {
312
+ const n = t.tr;
313
+ n.setMeta("numberedListIndexing", !0);
314
+ let r = !1;
315
+ return t.doc.descendants((i, a) => {
316
+ if (i.type.name === "blockContainer" && i.firstChild.type.name === "numberedListItem") {
317
+ let s = "1";
318
+ const l = a === 1, d = g(n.doc, a + 1);
319
+ if (d === void 0)
320
+ return;
321
+ if (!l) {
322
+ const p = g(n.doc, a - 2);
323
+ if (p === void 0)
324
+ return;
325
+ if (!(d.depth !== p.depth)) {
326
+ const f = p.contentNode;
327
+ if (p.contentType.name === "numberedListItem") {
328
+ const U = f.attrs.index;
329
+ s = (parseInt(U) + 1).toString();
330
+ }
331
+ }
332
+ }
333
+ d.contentNode.attrs.index !== s && (r = !0, n.setNodeMarkup(a + 1, void 0, {
334
+ index: s
335
+ }));
336
+ }
337
+ }), r ? n : null;
338
+ }
339
+ }), me = H({
340
+ name: "numberedListItem",
341
+ content: "inline*",
342
+ addAttributes() {
343
+ return {
344
+ index: {
345
+ default: null,
346
+ parseHTML: (o) => o.getAttribute("data-index"),
347
+ renderHTML: (o) => ({
348
+ "data-index": o.index
349
+ })
350
+ }
351
+ };
352
+ },
353
+ addInputRules() {
354
+ return [
355
+ // Creates an ordered list when starting with "1.".
356
+ new V({
357
+ find: new RegExp("^1\\.\\s$"),
358
+ handler: ({ state: o, chain: e, range: t }) => {
359
+ e().BNUpdateBlock(o.selection.from, {
360
+ type: "numberedListItem",
361
+ props: {}
362
+ }).deleteRange({ from: t.from, to: t.to });
363
+ }
364
+ })
365
+ ];
366
+ },
367
+ addKeyboardShortcuts() {
368
+ return {
369
+ Enter: () => vt(this.editor)
370
+ };
371
+ },
372
+ addProseMirrorPlugins() {
373
+ return [pe()];
374
+ },
375
+ parseHTML() {
376
+ return [
377
+ // Case for regular HTML list structure.
378
+ // (e.g.: when pasting from other apps)
379
+ {
380
+ tag: "li",
381
+ getAttrs: (o) => {
382
+ if (typeof o == "string")
383
+ return !1;
384
+ const e = o.parentElement;
385
+ return e === null ? !1 : e.tagName === "OL" ? {} : !1;
386
+ },
387
+ node: "numberedListItem"
388
+ },
389
+ // Case for BlockNote list structure.
390
+ // (e.g.: when pasting from blocknote)
391
+ {
392
+ tag: "p",
393
+ getAttrs: (o) => {
394
+ if (typeof o == "string")
395
+ return !1;
396
+ const e = o.parentElement;
397
+ return e === null ? !1 : e.getAttribute("data-content-type") === "numberedListItem" ? {} : !1;
398
+ },
399
+ priority: 300,
400
+ node: "numberedListItem"
401
+ }
402
+ ];
403
+ },
404
+ renderHTML({ HTMLAttributes: o }) {
405
+ return [
406
+ "div",
407
+ w(o, {
408
+ class: k.blockContent,
409
+ "data-content-type": this.name
410
+ }),
411
+ // we use a <p> tag, because for <li> tags we'd need to add a <ul> parent for around siblings to be semantically correct,
412
+ // which would be quite cumbersome
413
+ ["p", { class: k.inlineContent }, 0]
414
+ ];
415
+ }
416
+ }), fe = H({
417
+ name: "paragraph",
418
+ content: "inline*",
419
+ parseHTML() {
420
+ return [
421
+ {
422
+ tag: "p",
423
+ priority: 200,
424
+ node: "paragraph"
425
+ }
426
+ ];
427
+ },
428
+ renderHTML({ HTMLAttributes: o }) {
429
+ return [
430
+ "div",
431
+ w(o, {
432
+ class: k.blockContent,
433
+ "data-content-type": this.name
434
+ }),
435
+ ["p", { class: k.inlineContent }, 0]
436
+ ];
437
+ }
438
+ }), N = {
439
+ backgroundColor: {
440
+ default: "transparent"
441
+ },
442
+ textColor: {
443
+ default: "black"
444
+ // TODO
445
+ },
446
+ textAlignment: {
447
+ default: "left",
448
+ values: ["left", "center", "right", "justify"]
449
+ }
450
+ }, ge = {
451
+ paragraph: {
452
+ propSchema: N,
453
+ node: fe
454
+ },
455
+ heading: {
456
+ propSchema: {
457
+ ...N,
458
+ level: { default: "1", values: ["1", "2", "3"] }
459
+ },
460
+ node: ce
461
+ },
462
+ bulletListItem: {
463
+ propSchema: N,
464
+ node: ue
465
+ },
466
+ numberedListItem: {
467
+ propSchema: N,
468
+ node: me
469
+ }
470
+ };
471
+ function ke(o, e = JSON.stringify) {
472
+ const t = {};
473
+ return o.filter((n) => {
474
+ const r = e(n);
475
+ return Object.prototype.hasOwnProperty.call(t, r) ? !1 : t[r] = !0;
76
476
  });
77
477
  }
78
- function Qt(o) {
79
- const t = o.filter(
80
- (r, n) => o.indexOf(r) !== n
478
+ function be(o) {
479
+ const e = o.filter(
480
+ (n, r) => o.indexOf(n) !== r
81
481
  );
82
- return Xt(t);
482
+ return ke(e);
83
483
  }
84
- const Y = E.create({
484
+ const K = v.create({
85
485
  name: "uniqueID",
86
486
  // we’ll set a very high priority to make sure this runs first
87
487
  // and is compatible with `appendTransaction` hooks of other extensions
@@ -90,7 +490,7 @@ const Y = E.create({
90
490
  return {
91
491
  attributeName: "id",
92
492
  types: [],
93
- generateID: () => window.__TEST_OPTIONS ? (window.__TEST_OPTIONS.mockID === void 0 ? window.__TEST_OPTIONS.mockID = 0 : window.__TEST_OPTIONS.mockID++, window.__TEST_OPTIONS.mockID.toString()) : At(),
493
+ generateID: () => window.__TEST_OPTIONS ? (window.__TEST_OPTIONS.mockID === void 0 ? window.__TEST_OPTIONS.mockID = 0 : window.__TEST_OPTIONS.mockID++, window.__TEST_OPTIONS.mockID.toString()) : Gt(),
94
494
  filterTransaction: null
95
495
  };
96
496
  },
@@ -116,48 +516,48 @@ const Y = E.create({
116
516
  (l) => l.name === "collaboration"
117
517
  ))
118
518
  return;
119
- const { view: o, state: t } = this.editor, { tr: e, doc: r } = t, { types: n, attributeName: i, generateID: a } = this.options;
120
- G(r, (l) => n.includes(l.type.name) && l.attrs[i] === null).forEach(({ node: l, pos: d }) => {
121
- e.setNodeMarkup(d, void 0, {
519
+ const { view: o, state: e } = this.editor, { tr: t, doc: n } = e, { types: r, attributeName: i, generateID: a } = this.options;
520
+ j(n, (l) => r.includes(l.type.name) && l.attrs[i] === null).forEach(({ node: l, pos: d }) => {
521
+ t.setNodeMarkup(d, void 0, {
122
522
  ...l.attrs,
123
523
  [i]: a()
124
524
  });
125
- }), e.setMeta("addToHistory", !1), o.dispatch(e);
525
+ }), t.setMeta("addToHistory", !1), o.dispatch(t);
126
526
  },
127
527
  addProseMirrorPlugins() {
128
- let o = null, t = !1;
528
+ let o = null, e = !1;
129
529
  return [
130
530
  new C({
131
- key: new v("uniqueID"),
132
- appendTransaction: (e, r, n) => {
133
- const i = e.some((m) => m.docChanged) && !r.doc.eq(n.doc), a = this.options.filterTransaction && e.some((m) => {
134
- var y, k;
135
- return !(!((k = (y = this.options).filterTransaction) === null || k === void 0) && k.call(y, m));
531
+ key: new E("uniqueID"),
532
+ appendTransaction: (t, n, r) => {
533
+ const i = t.some((f) => f.docChanged) && !n.doc.eq(r.doc), a = this.options.filterTransaction && t.some((f) => {
534
+ var y, b;
535
+ return !(!((b = (y = this.options).filterTransaction) === null || b === void 0) && b.call(y, f));
136
536
  });
137
537
  if (!i || a)
138
538
  return;
139
- const { tr: s } = n, { types: l, attributeName: d, generateID: c } = this.options, h = Mt(
140
- r.doc,
141
- e
142
- ), { mapping: f } = h;
143
- if (Bt(h).forEach(({ newRange: m }) => {
144
- const y = Tt(
145
- n.doc,
146
- m,
539
+ const { tr: s } = r, { types: l, attributeName: d, generateID: c } = this.options, u = Nt(
540
+ n.doc,
541
+ t
542
+ ), { mapping: p } = u;
543
+ if (Ht(u).forEach(({ newRange: f }) => {
544
+ const y = Ot(
545
+ r.doc,
546
+ f,
147
547
  (M) => l.includes(M.type.name)
148
- ), k = y.map(({ node: M }) => M.attrs[d]).filter((M) => M !== null), z = Qt(k);
149
- y.forEach(({ node: M, pos: H }) => {
150
- var U;
151
- const J = (U = s.doc.nodeAt(H)) === null || U === void 0 ? void 0 : U.attrs[d];
152
- if (J === null) {
153
- s.setNodeMarkup(H, void 0, {
548
+ ), b = y.map(({ node: M }) => M.attrs[d]).filter((M) => M !== null), U = be(b);
549
+ y.forEach(({ node: M, pos: O }) => {
550
+ var $;
551
+ const Z = ($ = s.doc.nodeAt(O)) === null || $ === void 0 ? void 0 : $.attrs[d];
552
+ if (Z === null) {
553
+ s.setNodeMarkup(O, void 0, {
154
554
  ...M.attrs,
155
555
  [d]: c()
156
556
  });
157
557
  return;
158
558
  }
159
- const { deleted: vt } = f.invert().mapResult(H);
160
- vt && z.includes(J) && s.setNodeMarkup(H, void 0, {
559
+ const { deleted: Pt } = p.invert().mapResult(O);
560
+ Pt && U.includes(Z) && s.setNodeMarkup(O, void 0, {
161
561
  ...M.attrs,
162
562
  [d]: c()
163
563
  });
@@ -166,14 +566,14 @@ const Y = E.create({
166
566
  return s;
167
567
  },
168
568
  // we register a global drag handler to track the current drag source element
169
- view(e) {
170
- const r = (n) => {
569
+ view(t) {
570
+ const n = (r) => {
171
571
  var i;
172
- o = !((i = e.dom.parentElement) === null || i === void 0) && i.contains(n.target) ? e.dom.parentElement : null;
572
+ o = !((i = t.dom.parentElement) === null || i === void 0) && i.contains(r.target) ? t.dom.parentElement : null;
173
573
  };
174
- return window.addEventListener("dragstart", r), {
574
+ return window.addEventListener("dragstart", n), {
175
575
  destroy() {
176
- window.removeEventListener("dragstart", r);
576
+ window.removeEventListener("dragstart", n);
177
577
  }
178
578
  };
179
579
  },
@@ -183,44 +583,44 @@ const Y = E.create({
183
583
  handleDOMEvents: {
184
584
  // only create new ids for dropped content while holding `alt`
185
585
  // or content is dragged from another editor
186
- drop: (e, r) => {
187
- var n;
188
- return (o !== e.dom.parentElement || ((n = r.dataTransfer) === null || n === void 0 ? void 0 : n.effectAllowed) === "copy") && (o = null, t = !0), !1;
586
+ drop: (t, n) => {
587
+ var r;
588
+ return (o !== t.dom.parentElement || ((r = n.dataTransfer) === null || r === void 0 ? void 0 : r.effectAllowed) === "copy") && (o = null, e = !0), !1;
189
589
  },
190
590
  // always create new ids on pasted content
191
- paste: () => (t = !0, !1)
591
+ paste: () => (e = !0, !1)
192
592
  },
193
593
  // we’ll remove ids for every pasted node
194
594
  // so we can create a new one within `appendTransaction`
195
- transformPasted: (e) => {
196
- if (!t)
197
- return e;
198
- const { types: r, attributeName: n } = this.options, i = (a) => {
595
+ transformPasted: (t) => {
596
+ if (!e)
597
+ return t;
598
+ const { types: n, attributeName: r } = this.options, i = (a) => {
199
599
  const s = [];
200
600
  return a.forEach((l) => {
201
601
  if (l.isText) {
202
602
  s.push(l);
203
603
  return;
204
604
  }
205
- if (!r.includes(l.type.name)) {
605
+ if (!n.includes(l.type.name)) {
206
606
  s.push(l.copy(i(l.content)));
207
607
  return;
208
608
  }
209
609
  const d = l.type.create(
210
610
  {
211
611
  ...l.attrs,
212
- [n]: null
612
+ [r]: null
213
613
  },
214
614
  i(l.content),
215
615
  l.marks
216
616
  );
217
617
  s.push(d);
218
- }), L.from(s);
618
+ }), _.from(s);
219
619
  };
220
- return t = !1, new P(
221
- i(e.content),
222
- e.openStart,
223
- e.openEnd
620
+ return e = !1, new I(
621
+ i(t.content),
622
+ t.openStart,
623
+ t.openEnd
224
624
  );
225
625
  }
226
626
  }
@@ -228,306 +628,310 @@ const Y = E.create({
228
628
  ];
229
629
  }
230
630
  });
231
- class Zt extends Error {
232
- constructor(t) {
233
- super(`Unreachable case: ${t}`);
631
+ class ye extends Error {
632
+ constructor(e) {
633
+ super(`Unreachable case: ${e}`);
234
634
  }
235
635
  }
236
- const dt = /* @__PURE__ */ new Set([
636
+ const Et = /* @__PURE__ */ new Set([
237
637
  "bold",
238
638
  "italic",
239
639
  "underline",
240
640
  "strike",
241
641
  "code"
242
- ]), ct = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
243
- function te(o, t) {
244
- const e = [];
245
- for (const [r, n] of Object.entries(o.styles))
246
- dt.has(r) ? e.push(t.mark(r)) : ct.has(r) && e.push(t.mark(r, { color: n }));
247
- return t.text(o.text, e);
642
+ ]), Ct = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
643
+ function ve(o, e) {
644
+ const t = [];
645
+ for (const [n, r] of Object.entries(o.styles))
646
+ Et.has(n) ? t.push(e.mark(n)) : Ct.has(n) && t.push(e.mark(n, { color: r }));
647
+ return e.text(o.text, t);
248
648
  }
249
- function ee(o, t) {
250
- const e = t.marks.link.create({
649
+ function Ee(o, e) {
650
+ const t = e.marks.link.create({
251
651
  href: o.href
252
652
  });
253
- return ut(o.content, t).map((r) => r.mark([...r.marks, e]));
653
+ return Mt(o.content, e).map((n) => n.mark([...n.marks, t]));
254
654
  }
255
- function ut(o, t) {
256
- let e = [];
655
+ function Mt(o, e) {
656
+ let t = [];
257
657
  if (typeof o == "string")
258
- return e.push(t.text(o)), e;
259
- for (const r of o)
260
- e.push(te(r, t));
261
- return e;
658
+ return t.push(e.text(o)), t;
659
+ for (const n of o)
660
+ t.push(ve(n, e));
661
+ return t;
262
662
  }
263
- function ht(o, t) {
264
- let e = [];
265
- for (const r of o)
266
- if (r.type === "link")
267
- e.push(...ee(r, t));
268
- else if (r.type === "text")
269
- e.push(...ut([r], t));
663
+ function Bt(o, e) {
664
+ let t = [];
665
+ for (const n of o)
666
+ if (n.type === "link")
667
+ t.push(...Ee(n, e));
668
+ else if (n.type === "text")
669
+ t.push(...Mt([n], e));
270
670
  else
271
- throw new Zt(r);
272
- return e;
671
+ throw new ye(n);
672
+ return t;
273
673
  }
274
- function R(o, t) {
275
- let e = o.id;
276
- e === void 0 && (e = Y.options.generateID());
277
- let r = o.type;
278
- r === void 0 && (r = "paragraph");
279
- let n;
674
+ function z(o, e) {
675
+ let t = o.id;
676
+ t === void 0 && (t = K.options.generateID());
677
+ let n = o.type;
678
+ n === void 0 && (n = "paragraph");
679
+ let r;
280
680
  if (!o.content)
281
- n = t.nodes[r].create(o.props);
681
+ r = e.nodes[n].create(o.props);
282
682
  else if (typeof o.content == "string")
283
- n = t.nodes[r].create(
683
+ r = e.nodes[n].create(
284
684
  o.props,
285
- t.text(o.content)
685
+ e.text(o.content)
286
686
  );
287
687
  else {
288
- const s = ht(o.content, t);
289
- n = t.nodes[r].create(o.props, s);
688
+ const s = Bt(o.content, e);
689
+ r = e.nodes[n].create(o.props, s);
290
690
  }
291
691
  const i = [];
292
692
  if (o.children)
293
693
  for (const s of o.children)
294
- i.push(R(s, t));
295
- const a = t.nodes.blockGroup.create({}, i);
296
- return t.nodes.blockContainer.create(
694
+ i.push(z(s, e));
695
+ const a = e.nodes.blockGroup.create({}, i);
696
+ return e.nodes.blockContainer.create(
297
697
  {
298
- id: e,
698
+ id: t,
299
699
  ...o.props
300
700
  },
301
- i.length > 0 ? [n, a] : n
701
+ i.length > 0 ? [r, a] : r
302
702
  );
303
703
  }
304
- function oe(o) {
305
- const t = [];
306
- let e;
307
- return o.content.forEach((r) => {
308
- const n = {};
704
+ function Ce(o) {
705
+ const e = [];
706
+ let t;
707
+ return o.content.forEach((n) => {
708
+ const r = {};
309
709
  let i;
310
- for (const a of r.marks)
710
+ for (const a of n.marks)
311
711
  if (a.type.name === "link")
312
712
  i = a;
313
- else if (dt.has(a.type.name))
314
- n[a.type.name] = !0;
315
- else if (ct.has(a.type.name))
316
- n[a.type.name] = a.attrs.color;
713
+ else if (Et.has(a.type.name))
714
+ r[a.type.name] = !0;
715
+ else if (Ct.has(a.type.name))
716
+ r[a.type.name] = a.attrs.color;
317
717
  else
318
718
  throw Error("Mark is of an unrecognized type: " + a.type.name);
319
- i && e && i.attrs.href === e.href ? e.content.push({
719
+ i && t && i.attrs.href === t.href ? t.content.push({
320
720
  type: "text",
321
- text: r.textContent,
322
- styles: n
323
- }) : i ? (e = {
721
+ text: n.textContent,
722
+ styles: r
723
+ }) : i ? (t = {
324
724
  type: "link",
325
725
  href: i.attrs.href,
326
726
  content: [
327
727
  {
328
728
  type: "text",
329
- text: r.textContent,
330
- styles: n
729
+ text: n.textContent,
730
+ styles: r
331
731
  }
332
732
  ]
333
- }, t.push(e)) : (t.push({
733
+ }, e.push(t)) : (e.push({
334
734
  type: "text",
335
- text: r.textContent,
336
- styles: n
337
- }), e = void 0);
338
- }), t;
735
+ text: n.textContent,
736
+ styles: r
737
+ }), t = void 0);
738
+ }), e;
339
739
  }
340
- function B(o, t) {
740
+ function B(o, e, t) {
341
741
  if (o.type.name !== "blockContainer")
342
742
  throw Error(
343
743
  "Node must be of type blockContainer, but is of type" + o.type.name + "."
344
744
  );
345
- const e = t == null ? void 0 : t.get(o);
346
- if (e)
347
- return e;
745
+ const n = t == null ? void 0 : t.get(o);
746
+ if (n)
747
+ return n;
348
748
  const r = g(o, 0);
349
- let n = r.id;
350
- n === null && (n = Y.options.generateID());
351
- const i = {};
352
- for (const [d, c] of Object.entries({
749
+ let i = r.id;
750
+ i === null && (i = K.options.generateID());
751
+ const a = {};
752
+ for (const [c, u] of Object.entries({
353
753
  ...r.node.attrs,
354
754
  ...r.contentNode.attrs
355
755
  })) {
356
- if (!(r.contentType.name in tt))
756
+ const p = e[r.contentType.name];
757
+ if (!p)
357
758
  throw Error(
358
759
  "Block is of an unrecognized type: " + r.contentType.name
359
760
  );
360
- tt[r.contentType.name].has(d) && (i[d] = c);
761
+ const m = p.propSchema;
762
+ c in m ? a[c] = u : c !== "id" && !(c in N) && console.warn("Block has an unrecognized attribute: " + c);
361
763
  }
362
- const a = oe(r.contentNode), s = [];
363
- for (let d = 0; d < r.numChildBlocks; d++)
364
- s.push(B(r.node.lastChild.child(d)));
365
- const l = {
366
- id: n,
764
+ const s = Ce(r.contentNode), l = [];
765
+ for (let c = 0; c < r.numChildBlocks; c++)
766
+ l.push(
767
+ B(r.node.lastChild.child(c), e, t)
768
+ );
769
+ const d = {
770
+ id: i,
367
771
  type: r.contentType.name,
368
- props: i,
369
- content: a,
370
- children: s
772
+ props: a,
773
+ content: s,
774
+ children: l
371
775
  };
372
- return t == null || t.set(o, l), l;
776
+ return t == null || t.set(o, d), d;
373
777
  }
374
- function K(o, t) {
375
- let e, r;
376
- if (t.firstChild.descendants((n, i) => e ? !1 : n.type.name !== "blockContainer" || n.attrs.id !== o ? !0 : (e = n, r = i + 1, !1)), e === void 0 || r === void 0)
778
+ function J(o, e) {
779
+ let t, n;
780
+ if (e.firstChild.descendants((r, i) => t ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== o ? !0 : (t = r, n = i + 1, !1)), t === void 0 || n === void 0)
377
781
  throw Error("Could not find block in the editor with matching ID.");
378
782
  return {
379
- node: e,
380
- posBeforeNode: r
783
+ node: t,
784
+ posBeforeNode: n
381
785
  };
382
786
  }
383
- function pt(o, t, e = "before", r) {
384
- const n = typeof t == "string" ? t : t.id, i = [];
787
+ function Tt(o, e, t = "before", n) {
788
+ const r = typeof e == "string" ? e : e.id, i = [];
385
789
  for (const d of o)
386
- i.push(R(d, r.schema));
790
+ i.push(z(d, n.schema));
387
791
  let a = -1;
388
- const { node: s, posBeforeNode: l } = K(n, r.state.doc);
389
- if (e === "before" && (a = l), e === "after" && (a = l + s.nodeSize), e === "nested") {
792
+ const { node: s, posBeforeNode: l } = J(r, n.state.doc);
793
+ if (t === "before" && (a = l), t === "after" && (a = l + s.nodeSize), t === "nested") {
390
794
  if (s.childCount < 2) {
391
795
  a = l + s.firstChild.nodeSize + 1;
392
- const d = r.state.schema.nodes.blockGroup.create(
796
+ const d = n.state.schema.nodes.blockGroup.create(
393
797
  {},
394
798
  i
395
799
  );
396
- r.view.dispatch(
397
- r.state.tr.insert(a, d)
800
+ n.view.dispatch(
801
+ n.state.tr.insert(a, d)
398
802
  );
399
803
  return;
400
804
  }
401
805
  a = l + s.firstChild.nodeSize + 2;
402
806
  }
403
- r.view.dispatch(r.state.tr.insert(a, i));
807
+ n.view.dispatch(n.state.tr.insert(a, i));
404
808
  }
405
- function re(o, t, e) {
406
- const r = typeof o == "string" ? o : o.id, { posBeforeNode: n } = K(r, e.state.doc);
407
- e.commands.BNUpdateBlock(n + 1, t);
809
+ function Me(o, e, t) {
810
+ const n = typeof o == "string" ? o : o.id, { posBeforeNode: r } = J(n, t.state.doc);
811
+ t.commands.BNUpdateBlock(r + 1, e);
408
812
  }
409
- function ft(o, t) {
410
- const e = new Set(
813
+ function wt(o, e) {
814
+ const t = new Set(
411
815
  o.map(
412
- (n) => typeof n == "string" ? n : n.id
816
+ (r) => typeof r == "string" ? r : r.id
413
817
  )
414
818
  );
415
- let r = 0;
416
- if (t.state.doc.descendants((n, i) => {
417
- if (e.size === 0)
819
+ let n = 0;
820
+ if (e.state.doc.descendants((r, i) => {
821
+ if (t.size === 0)
418
822
  return !1;
419
- if (n.type.name !== "blockContainer" || !e.has(n.attrs.id))
823
+ if (r.type.name !== "blockContainer" || !t.has(r.attrs.id))
420
824
  return !0;
421
- e.delete(n.attrs.id);
422
- const a = t.state.doc.nodeSize;
423
- t.commands.BNDeleteBlock(i - r + 1);
424
- const s = t.state.doc.nodeSize;
425
- return r += a - s, !1;
426
- }), e.size > 0) {
427
- let n = [...e].join(`
825
+ t.delete(r.attrs.id);
826
+ const a = e.state.doc.nodeSize;
827
+ e.commands.BNDeleteBlock(i - n + 1);
828
+ const s = e.state.doc.nodeSize;
829
+ return n += a - s, !1;
830
+ }), t.size > 0) {
831
+ let r = [...t].join(`
428
832
  `);
429
833
  throw Error(
430
- "Blocks with the following IDs could not be found in the editor: " + n
834
+ "Blocks with the following IDs could not be found in the editor: " + r
431
835
  );
432
836
  }
433
837
  }
434
- function ne(o, t, e) {
435
- pt(t, o[0], "before", e), ft(o, e);
838
+ function Be(o, e, t) {
839
+ Tt(e, o[0], "before", t), wt(o, t);
436
840
  }
437
- function ie() {
438
- const o = (t) => {
439
- let e = t.children.length;
440
- for (let r = 0; r < e; r++) {
441
- const n = t.children[r];
442
- if (n.type === "element" && (o(n), n.tagName === "u"))
443
- if (n.children.length > 0) {
444
- t.children.splice(r, 1, ...n.children);
445
- const i = n.children.length - 1;
446
- e += i, r += i;
841
+ function Te() {
842
+ const o = (e) => {
843
+ let t = e.children.length;
844
+ for (let n = 0; n < t; n++) {
845
+ const r = e.children[n];
846
+ if (r.type === "element" && (o(r), r.tagName === "u"))
847
+ if (r.children.length > 0) {
848
+ e.children.splice(n, 1, ...r.children);
849
+ const i = r.children.length - 1;
850
+ t += i, n += i;
447
851
  } else
448
- t.children.splice(r, 1), e--, r--;
852
+ e.children.splice(n, 1), t--, n--;
449
853
  }
450
854
  };
451
855
  return o;
452
856
  }
453
- function se(o) {
454
- const t = /* @__PURE__ */ new Set([
857
+ function we(o) {
858
+ const e = /* @__PURE__ */ new Set([
455
859
  ...o.orderedListItemBlockTypes,
456
860
  ...o.unorderedListItemBlockTypes
457
- ]), e = (r) => {
458
- let n = r.children.length, i;
459
- for (let a = 0; a < n; a++) {
460
- const l = r.children[a].children[0], d = l.children[0], c = l.children.length === 2 ? l.children[1] : null, h = t.has(
861
+ ]), t = (n) => {
862
+ let r = n.children.length, i;
863
+ for (let a = 0; a < r; a++) {
864
+ const l = n.children[a].children[0], d = l.children[0], c = l.children.length === 2 ? l.children[1] : null, u = e.has(
461
865
  d.properties.dataContentType
462
- ), f = h ? o.orderedListItemBlockTypes.has(
866
+ ), p = u ? o.orderedListItemBlockTypes.has(
463
867
  d.properties.dataContentType
464
868
  ) ? "ol" : "ul" : null;
465
- if (c !== null && e(c), i && i.tagName !== f) {
466
- r.children.splice(
869
+ if (c !== null && t(c), i && i.tagName !== p) {
870
+ n.children.splice(
467
871
  a - i.children.length,
468
872
  i.children.length,
469
873
  i
470
874
  );
471
- const p = i.children.length - 1;
472
- a -= p, n -= p, i = void 0;
875
+ const m = i.children.length - 1;
876
+ a -= m, r -= m, i = void 0;
473
877
  }
474
- if (h) {
475
- i || (i = Z(
476
- document.createElement(f)
878
+ if (u) {
879
+ i || (i = et(
880
+ document.createElement(p)
477
881
  ));
478
- const p = Z(
882
+ const m = et(
479
883
  document.createElement("li")
480
884
  );
481
- p.children.push(d.children[0]), c !== null && p.children.push(...c.children), i.children.push(p);
885
+ m.children.push(d.children[0]), c !== null && m.children.push(...c.children), i.children.push(m);
482
886
  } else if (c !== null) {
483
- r.children.splice(a + 1, 0, ...c.children), r.children[a] = d.children[0];
484
- const p = c.children.length;
485
- a += p, n += p;
887
+ n.children.splice(a + 1, 0, ...c.children), n.children[a] = d.children[0];
888
+ const m = c.children.length;
889
+ a += m, r += m;
486
890
  } else
487
- r.children[a] = d.children[0];
891
+ n.children[a] = d.children[0];
488
892
  }
489
- i && r.children.splice(
490
- n - i.children.length,
893
+ i && n.children.splice(
894
+ r - i.children.length,
491
895
  i.children.length,
492
896
  i
493
897
  );
494
898
  };
495
- return e;
899
+ return t;
496
900
  }
497
- async function mt(o, t) {
498
- const e = document.createElement("div"), r = Pt.fromSchema(t);
901
+ async function St(o, e) {
902
+ const t = document.createElement("div"), n = q.fromSchema(e);
499
903
  for (const i of o) {
500
- const a = R(i, t), s = r.serializeNode(a);
501
- e.appendChild(s);
904
+ const a = z(i, e), s = n.serializeNode(a);
905
+ t.appendChild(s);
502
906
  }
503
- return (await W().use(it, { fragment: !0 }).use(se, {
907
+ return (await Y().use(at, { fragment: !0 }).use(we, {
504
908
  orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
505
909
  unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
506
- }).use(st).process(e.innerHTML)).value;
910
+ }).use(lt).process(t.innerHTML)).value;
507
911
  }
508
- async function gt(o, t) {
509
- const e = document.createElement("div");
510
- e.innerHTML = o.trim();
511
- const n = Lt.fromSchema(t).parse(e), i = [];
512
- for (let a = 0; a < n.firstChild.childCount; a++)
513
- i.push(B(n.firstChild.child(a)));
514
- return i;
912
+ async function xt(o, e, t) {
913
+ const n = document.createElement("div");
914
+ n.innerHTML = o.trim();
915
+ const i = $t.fromSchema(t).parse(n), a = [];
916
+ for (let s = 0; s < i.firstChild.childCount; s++)
917
+ a.push(B(i.firstChild.child(s), e));
918
+ return a;
515
919
  }
516
- async function ae(o, t) {
517
- return (await W().use(it, { fragment: !0 }).use(ie).use(Nt).use(at).use(Dt).process(await mt(o, t))).value;
920
+ async function Se(o, e) {
921
+ return (await Y().use(at, { fragment: !0 }).use(Te).use(jt).use(dt).use(Vt).process(await St(o, e))).value;
518
922
  }
519
- async function le(o, t) {
520
- const e = await W().use(Ht).use(at).use(Ot).use(st).process(o);
521
- return gt(e.value, t);
923
+ async function xe(o, e, t) {
924
+ const n = await Y().use(qt).use(dt).use(Wt).use(lt).process(o);
925
+ return xt(n.value, e, t);
522
926
  }
523
- const de = "_bnEditor_ywyu7_3", ce = "_bnRoot_ywyu7_20", ue = "_defaultStyles_ywyu7_35", he = "_dragPreview_ywyu7_69", _ = {
524
- bnEditor: de,
525
- bnRoot: ce,
526
- defaultStyles: ue,
527
- dragPreview: he,
528
- "collaboration-cursor__caret": "_collaboration-cursor__caret_ywyu7_75",
529
- "collaboration-cursor__label": "_collaboration-cursor__label_ywyu7_86"
530
- }, pe = E.create({
927
+ const Ie = "_bnEditor_14aht_3", _e = "_bnRoot_14aht_20", Pe = "_defaultStyles_14aht_35", Le = "_dragPreview_14aht_68", P = {
928
+ bnEditor: Ie,
929
+ bnRoot: _e,
930
+ defaultStyles: Pe,
931
+ dragPreview: Le,
932
+ "collaboration-cursor__caret": "_collaboration-cursor__caret_14aht_74",
933
+ "collaboration-cursor__label": "_collaboration-cursor__label_14aht_85"
934
+ }, Ae = v.create({
531
935
  name: "blockBackgroundColor",
532
936
  addGlobalAttributes() {
533
937
  return [
@@ -547,17 +951,17 @@ const de = "_bnEditor_ywyu7_3", ce = "_bnRoot_ywyu7_20", ue = "_defaultStyles_yw
547
951
  },
548
952
  addCommands() {
549
953
  return {
550
- setBlockBackgroundColor: (o, t) => ({ state: e, view: r }) => {
551
- const n = g(e.doc, o);
552
- return n === void 0 ? !1 : (e.tr.setNodeAttribute(
553
- n.startPos - 1,
954
+ setBlockBackgroundColor: (o, e) => ({ state: t, view: n }) => {
955
+ const r = g(t.doc, o);
956
+ return r === void 0 ? !1 : (t.tr.setNodeAttribute(
957
+ r.startPos - 1,
554
958
  "backgroundColor",
555
- t
556
- ), r.focus(), !0);
959
+ e
960
+ ), n.focus(), !0);
557
961
  }
558
962
  };
559
963
  }
560
- }), fe = rt.create({
964
+ }), Ne = it.create({
561
965
  name: "backgroundColor",
562
966
  addAttributes() {
563
967
  return {
@@ -583,10 +987,10 @@ const de = "_bnEditor_ywyu7_3", ce = "_bnRoot_ywyu7_20", ue = "_defaultStyles_yw
583
987
  },
584
988
  addCommands() {
585
989
  return {
586
- setBackgroundColor: (o) => ({ commands: t }) => o !== "default" ? t.setMark(this.name, { color: o }) : t.unsetMark(this.name)
990
+ setBackgroundColor: (o) => ({ commands: e }) => o !== "default" ? e.setMark(this.name, { color: o }) : e.unsetMark(this.name)
587
991
  };
588
992
  }
589
- }), et = new v("previous-blocks"), me = {
993
+ }), nt = new E("previous-blocks"), He = {
590
994
  // Numbered List Items
591
995
  index: "index",
592
996
  // Headings
@@ -595,17 +999,17 @@ const de = "_bnEditor_ywyu7_3", ce = "_bnRoot_ywyu7_20", ue = "_defaultStyles_yw
595
999
  type: "type",
596
1000
  depth: "depth",
597
1001
  "depth-change": "depth-change"
598
- }, ge = () => {
1002
+ }, Oe = () => {
599
1003
  let o;
600
1004
  return new C({
601
- key: et,
602
- view(t) {
1005
+ key: nt,
1006
+ view(e) {
603
1007
  return {
604
- update: async (e, r) => {
605
- var n;
606
- ((n = this.key) == null ? void 0 : n.getState(e.state).updatedBlocks.size) > 0 && (o = setTimeout(() => {
607
- e.dispatch(
608
- e.state.tr.setMeta(et, { clearUpdate: !0 })
1008
+ update: async (t, n) => {
1009
+ var r;
1010
+ ((r = this.key) == null ? void 0 : r.getState(t.state).updatedBlocks.size) > 0 && (o = setTimeout(() => {
1011
+ t.dispatch(
1012
+ t.state.tr.setMeta(nt, { clearUpdate: !0 })
609
1013
  );
610
1014
  }, 0));
611
1015
  },
@@ -625,68 +1029,60 @@ const de = "_bnEditor_ywyu7_3", ce = "_bnRoot_ywyu7_20", ue = "_defaultStyles_yw
625
1029
  updatedBlocks: /* @__PURE__ */ new Set()
626
1030
  };
627
1031
  },
628
- apply(t, e, r, n) {
629
- if (e.currentTransactionOldBlockAttrs = {}, e.updatedBlocks.clear(), !t.docChanged || r.doc.eq(n.doc))
630
- return e;
631
- const i = {}, a = G(r.doc, (d) => d.attrs.id), s = new Map(
1032
+ apply(e, t, n, r) {
1033
+ if (t.currentTransactionOldBlockAttrs = {}, t.updatedBlocks.clear(), !e.docChanged || n.doc.eq(r.doc))
1034
+ return t;
1035
+ const i = {}, a = j(n.doc, (d) => d.attrs.id), s = new Map(
632
1036
  a.map((d) => [d.node.attrs.id, d])
633
- ), l = G(n.doc, (d) => d.attrs.id);
1037
+ ), l = j(r.doc, (d) => d.attrs.id);
634
1038
  for (let d of l) {
635
- const c = s.get(d.node.attrs.id), h = c == null ? void 0 : c.node.firstChild, f = d.node.firstChild;
636
- if (c && h && f) {
637
- const p = {
638
- index: f.attrs.index,
639
- level: f.attrs.level,
640
- type: f.type.name,
641
- depth: n.doc.resolve(d.pos).depth
1039
+ const c = s.get(d.node.attrs.id), u = c == null ? void 0 : c.node.firstChild, p = d.node.firstChild;
1040
+ if (c && u && p) {
1041
+ const m = {
1042
+ index: p.attrs.index,
1043
+ level: p.attrs.level,
1044
+ type: p.type.name,
1045
+ depth: r.doc.resolve(d.pos).depth
642
1046
  };
643
- let m = {
644
- index: h.attrs.index,
645
- level: h.attrs.level,
646
- type: h.type.name,
647
- depth: r.doc.resolve(c.pos).depth
1047
+ let f = {
1048
+ index: u.attrs.index,
1049
+ level: u.attrs.level,
1050
+ type: u.type.name,
1051
+ depth: n.doc.resolve(c.pos).depth
648
1052
  };
649
- i[d.node.attrs.id] = m, t.getMeta("numberedListIndexing") && (d.node.attrs.id in e.prevTransactionOldBlockAttrs && (m = e.prevTransactionOldBlockAttrs[d.node.attrs.id]), p.type === "numberedListItem" && (m.index = p.index)), e.currentTransactionOldBlockAttrs[d.node.attrs.id] = m, JSON.stringify(m) !== JSON.stringify(p) && (m["depth-change"] = m.depth - p.depth, e.updatedBlocks.add(d.node.attrs.id));
1053
+ i[d.node.attrs.id] = f, e.getMeta("numberedListIndexing") && (d.node.attrs.id in t.prevTransactionOldBlockAttrs && (f = t.prevTransactionOldBlockAttrs[d.node.attrs.id]), m.type === "numberedListItem" && (f.index = m.index)), t.currentTransactionOldBlockAttrs[d.node.attrs.id] = f, JSON.stringify(f) !== JSON.stringify(m) && (f["depth-change"] = f.depth - m.depth, t.updatedBlocks.add(d.node.attrs.id));
650
1054
  }
651
1055
  }
652
- return e.prevTransactionOldBlockAttrs = i, e;
1056
+ return t.prevTransactionOldBlockAttrs = i, t;
653
1057
  }
654
1058
  },
655
1059
  props: {
656
- decorations(t) {
657
- const e = this.getState(t);
658
- if (e.updatedBlocks.size === 0)
1060
+ decorations(e) {
1061
+ const t = this.getState(e);
1062
+ if (t.updatedBlocks.size === 0)
659
1063
  return;
660
- const r = [];
661
- return t.doc.descendants((n, i) => {
662
- if (!n.attrs.id || !e.updatedBlocks.has(n.attrs.id))
1064
+ const n = [];
1065
+ return e.doc.descendants((r, i) => {
1066
+ if (!r.attrs.id || !t.updatedBlocks.has(r.attrs.id))
663
1067
  return;
664
- const a = e.currentTransactionOldBlockAttrs[n.attrs.id], s = {};
1068
+ const a = t.currentTransactionOldBlockAttrs[r.attrs.id], s = {};
665
1069
  for (let [d, c] of Object.entries(a))
666
- s["data-prev-" + me[d]] = c || "none";
667
- const l = D.node(i, i + n.nodeSize, {
1070
+ s["data-prev-" + He[d]] = c || "none";
1071
+ const l = D.node(i, i + r.nodeSize, {
668
1072
  ...s
669
1073
  });
670
- r.push(l);
671
- }), F.create(t.doc, r);
1074
+ n.push(l);
1075
+ }), F.create(e.doc, n);
672
1076
  }
673
1077
  }
674
1078
  });
675
- }, ke = "_blockOuter_1qj38_5", ye = "_blockContent_1qj38_10", be = "_blockGroup_1qj38_30", ve = "_block_1qj38_5", Ee = "_isEmpty_1qj38_228", Ce = "_isFilter_1qj38_229", Me = "_hasAnchor_1qj38_251", b = {
676
- blockOuter: ke,
677
- blockContent: ye,
678
- blockGroup: be,
679
- block: ve,
680
- isEmpty: Ee,
681
- isFilter: Ce,
682
- hasAnchor: Me
683
- }, Be = {
1079
+ }, De = {
684
1080
  blockColor: "data-block-color",
685
1081
  blockStyle: "data-block-style",
686
1082
  id: "data-id",
687
1083
  depth: "data-depth",
688
1084
  depthChange: "data-depth-change"
689
- }, Te = S.create({
1085
+ }, Fe = R.create({
690
1086
  name: "blockContainer",
691
1087
  group: "blockContainer",
692
1088
  // A block always contains content, and optionally a blockGroup which contains nested blocks
@@ -706,10 +1102,10 @@ const de = "_bnEditor_ywyu7_3", ce = "_bnRoot_ywyu7_20", ue = "_defaultStyles_yw
706
1102
  getAttrs: (o) => {
707
1103
  if (typeof o == "string")
708
1104
  return !1;
709
- const t = {};
710
- for (let [e, r] of Object.entries(Be))
711
- o.getAttribute(r) && (t[e] = o.getAttribute(r));
712
- return o.getAttribute("data-node-type") === "blockContainer" ? t : !1;
1105
+ const e = {};
1106
+ for (let [t, n] of Object.entries(De))
1107
+ o.getAttribute(n) && (e[t] = o.getAttribute(n));
1108
+ return o.getAttribute("data-node-type") === "blockContainer" ? e : !1;
713
1109
  }
714
1110
  }
715
1111
  ];
@@ -718,14 +1114,14 @@ const de = "_bnEditor_ywyu7_3", ce = "_bnRoot_ywyu7_20", ue = "_defaultStyles_yw
718
1114
  return [
719
1115
  "div",
720
1116
  w(o, {
721
- class: b.blockOuter,
1117
+ class: k.blockOuter,
722
1118
  "data-node-type": "block-outer"
723
1119
  }),
724
1120
  [
725
1121
  "div",
726
1122
  w(o, {
727
1123
  // TODO: maybe remove html attributes from inner block
728
- class: b.block,
1124
+ class: k.block,
729
1125
  "data-node-type": this.name
730
1126
  }),
731
1127
  0
@@ -735,56 +1131,56 @@ const de = "_bnEditor_ywyu7_3", ce = "_bnRoot_ywyu7_20", ue = "_defaultStyles_yw
735
1131
  addCommands() {
736
1132
  return {
737
1133
  // Creates a new text block at a given position.
738
- BNCreateBlock: (o) => ({ state: t, dispatch: e }) => {
739
- const r = t.schema.nodes.blockContainer.createAndFill();
740
- return e && t.tr.insert(o, r), !0;
1134
+ BNCreateBlock: (o) => ({ state: e, dispatch: t }) => {
1135
+ const n = e.schema.nodes.blockContainer.createAndFill();
1136
+ return t && e.tr.insert(o, n), !0;
741
1137
  },
742
1138
  // Deletes a block at a given position.
743
- BNDeleteBlock: (o) => ({ state: t, dispatch: e }) => {
744
- const r = g(t.doc, o);
745
- if (r === void 0)
1139
+ BNDeleteBlock: (o) => ({ state: e, dispatch: t }) => {
1140
+ const n = g(e.doc, o);
1141
+ if (n === void 0)
746
1142
  return !1;
747
- const { startPos: n, endPos: i } = r;
748
- return e && t.tr.deleteRange(n, i), !0;
1143
+ const { startPos: r, endPos: i } = n;
1144
+ return t && e.tr.deleteRange(r, i), !0;
749
1145
  },
750
1146
  // Updates a block at a given position.
751
- BNUpdateBlock: (o, t) => ({ state: e, dispatch: r }) => {
752
- const n = g(e.doc, o);
753
- if (n === void 0)
1147
+ BNUpdateBlock: (o, e) => ({ state: t, dispatch: n }) => {
1148
+ const r = g(t.doc, o);
1149
+ if (r === void 0)
754
1150
  return !1;
755
- const { startPos: i, endPos: a, node: s, contentNode: l } = n;
756
- if (r) {
757
- if (t.children !== void 0) {
1151
+ const { startPos: i, endPos: a, node: s, contentNode: l } = r;
1152
+ if (n) {
1153
+ if (e.children !== void 0) {
758
1154
  const d = [];
759
- for (const c of t.children)
760
- d.push(R(c, e.schema));
761
- s.childCount === 2 ? e.tr.replace(
1155
+ for (const c of e.children)
1156
+ d.push(z(c, t.schema));
1157
+ s.childCount === 2 ? t.tr.replace(
762
1158
  i + l.nodeSize + 1,
763
1159
  a - 1,
764
- new P(L.from(d), 0, 0)
765
- ) : e.tr.insert(
1160
+ new I(_.from(d), 0, 0)
1161
+ ) : t.tr.insert(
766
1162
  i + l.nodeSize,
767
- e.schema.nodes.blockGroup.create({}, d)
1163
+ t.schema.nodes.blockGroup.create({}, d)
768
1164
  );
769
1165
  }
770
- if (t.content !== void 0) {
1166
+ if (e.content !== void 0) {
771
1167
  let d = [];
772
- typeof t.content == "string" ? d.push(e.schema.text(t.content)) : d = ht(t.content, e.schema), e.tr.replace(
1168
+ typeof e.content == "string" ? d.push(t.schema.text(e.content)) : d = Bt(e.content, t.schema), t.tr.replace(
773
1169
  i + 1,
774
1170
  i + l.nodeSize - 1,
775
- new P(L.from(d), 0, 0)
1171
+ new I(_.from(d), 0, 0)
776
1172
  );
777
1173
  }
778
- e.tr.setNodeMarkup(
1174
+ t.tr.setNodeMarkup(
779
1175
  i,
780
- t.type === void 0 ? void 0 : e.schema.nodes[t.type],
1176
+ e.type === void 0 ? void 0 : t.schema.nodes[e.type],
781
1177
  {
782
1178
  ...l.attrs,
783
- ...t.props
1179
+ ...e.props
784
1180
  }
785
- ), e.tr.setNodeMarkup(i - 1, void 0, {
1181
+ ), t.tr.setNodeMarkup(i - 1, void 0, {
786
1182
  ...s.attrs,
787
- ...t.props
1183
+ ...e.props
788
1184
  });
789
1185
  }
790
1186
  return !0;
@@ -806,55 +1202,55 @@ const de = "_bnEditor_ywyu7_3", ce = "_bnRoot_ywyu7_20", ue = "_defaultStyles_yw
806
1202
  // Block2Block3
807
1203
  // Block4
808
1204
  // Block5
809
- BNMergeBlocks: (o) => ({ state: t, dispatch: e }) => {
810
- const r = t.doc.resolve(o + 1).node().type.name === "blockContainer", n = t.doc.resolve(o - 1).node().type.name === "blockContainer";
811
- if (!r || !n)
1205
+ BNMergeBlocks: (o) => ({ state: e, dispatch: t }) => {
1206
+ const n = e.doc.resolve(o + 1).node().type.name === "blockContainer", r = e.doc.resolve(o - 1).node().type.name === "blockContainer";
1207
+ if (!n || !r)
812
1208
  return !1;
813
1209
  const i = g(
814
- t.doc,
1210
+ e.doc,
815
1211
  o + 1
816
1212
  ), { node: a, contentNode: s, startPos: l, endPos: d, depth: c } = i;
817
1213
  if (a.childCount === 2) {
818
- const p = t.doc.resolve(
1214
+ const m = e.doc.resolve(
819
1215
  l + s.nodeSize + 1
820
- ), m = t.doc.resolve(d - 1), y = p.blockRange(m);
821
- e && t.tr.lift(y, c - 1);
1216
+ ), f = e.doc.resolve(d - 1), y = m.blockRange(f);
1217
+ t && e.tr.lift(y, c - 1);
822
1218
  }
823
- let h = o - 1, f = g(t.doc, h);
824
- for (; f.numChildBlocks > 0; )
825
- if (h--, f = g(t.doc, h), f === void 0)
1219
+ let u = o - 1, p = g(e.doc, u);
1220
+ for (; p.numChildBlocks > 0; )
1221
+ if (u--, p = g(e.doc, u), p === void 0)
826
1222
  return !1;
827
- return e && (t.tr.deleteRange(l, l + s.nodeSize), t.tr.insertText(s.textContent, h - 1), t.tr.setSelection(
828
- new Q(t.doc.resolve(h - 1))
1223
+ return t && (e.tr.deleteRange(l, l + s.nodeSize), e.tr.insertText(s.textContent, u - 1), e.tr.setSelection(
1224
+ new tt(e.doc.resolve(u - 1))
829
1225
  )), !0;
830
1226
  },
831
1227
  // Splits a block at a given position. Content after the position is moved to a new block below, at the same
832
1228
  // nesting level.
833
- BNSplitBlock: (o, t) => ({ state: e, dispatch: r }) => {
834
- const n = g(e.doc, o);
835
- if (n === void 0)
1229
+ BNSplitBlock: (o, e) => ({ state: t, dispatch: n }) => {
1230
+ const r = g(t.doc, o);
1231
+ if (r === void 0)
836
1232
  return !1;
837
- const { contentNode: i, contentType: a, startPos: s, endPos: l, depth: d } = n, c = e.doc.cut(s + 1, o), h = e.doc.cut(o, l - 1), f = e.schema.nodes.blockContainer.createAndFill(), p = l + 1, m = p + 2;
838
- return r && (e.tr.insert(p, f), e.tr.replace(
839
- m,
840
- m + 1,
841
- h.content.size > 0 ? new P(
842
- L.from(h),
1233
+ const { contentNode: i, contentType: a, startPos: s, endPos: l, depth: d } = r, c = t.doc.cut(s + 1, o), u = t.doc.cut(o, l - 1), p = t.schema.nodes.blockContainer.createAndFill(), m = l + 1, f = m + 2;
1234
+ return n && (t.tr.insert(m, p), t.tr.replace(
1235
+ f,
1236
+ f + 1,
1237
+ u.content.size > 0 ? new I(
1238
+ _.from(u),
843
1239
  d + 2,
844
1240
  d + 2
845
1241
  ) : void 0
846
- ), t && e.tr.setBlockType(
847
- m,
848
- m,
849
- e.schema.node(a).type,
1242
+ ), e && t.tr.setBlockType(
1243
+ f,
1244
+ f,
1245
+ t.schema.node(a).type,
850
1246
  i.attrs
851
- ), e.tr.setSelection(
852
- new Q(e.doc.resolve(m))
853
- ), e.tr.replace(
1247
+ ), t.tr.setSelection(
1248
+ new tt(t.doc.resolve(f))
1249
+ ), t.tr.replace(
854
1250
  s + 1,
855
1251
  l - 1,
856
- c.content.size > 0 ? new P(
857
- L.from(c),
1252
+ c.content.size > 0 ? new I(
1253
+ _.from(c),
858
1254
  d + 2,
859
1255
  d + 2
860
1256
  ) : void 0
@@ -863,69 +1259,69 @@ const de = "_bnEditor_ywyu7_3", ce = "_bnRoot_ywyu7_20", ue = "_defaultStyles_yw
863
1259
  };
864
1260
  },
865
1261
  addProseMirrorPlugins() {
866
- return [ge()];
1262
+ return [Oe()];
867
1263
  },
868
1264
  addKeyboardShortcuts() {
869
1265
  return {
870
- Backspace: () => this.editor.commands.first(({ commands: e }) => [
1266
+ Backspace: () => this.editor.commands.first(({ commands: t }) => [
871
1267
  // Deletes the selection if it's not empty.
872
- () => e.deleteSelection(),
1268
+ () => t.deleteSelection(),
873
1269
  // Undoes an input rule if one was triggered in the last editor state change.
874
- () => e.undoInputRule(),
1270
+ () => t.undoInputRule(),
875
1271
  // Reverts block content type to a paragraph if the selection is at the start of the block.
876
- () => e.command(({ state: r }) => {
877
- const { contentType: n } = g(
878
- r.doc,
879
- r.selection.from
880
- ), i = r.selection.$anchor.parentOffset === 0, a = n.name === "paragraph";
881
- return i && !a ? e.BNUpdateBlock(r.selection.from, {
1272
+ () => t.command(({ state: n }) => {
1273
+ const { contentType: r } = g(
1274
+ n.doc,
1275
+ n.selection.from
1276
+ ), i = n.selection.$anchor.parentOffset === 0, a = r.name === "paragraph";
1277
+ return i && !a ? t.BNUpdateBlock(n.selection.from, {
882
1278
  type: "paragraph",
883
1279
  props: {}
884
1280
  }) : !1;
885
1281
  }),
886
1282
  // Removes a level of nesting if the block is indented if the selection is at the start of the block.
887
- () => e.command(({ state: r }) => r.selection.$anchor.parentOffset === 0 ? e.liftListItem("blockContainer") : !1),
1283
+ () => t.command(({ state: n }) => n.selection.$anchor.parentOffset === 0 ? t.liftListItem("blockContainer") : !1),
888
1284
  // Merges block with the previous one if it isn't indented, isn't the first block in the doc, and the selection
889
1285
  // is at the start of the block.
890
- () => e.command(({ state: r }) => {
891
- const { depth: n, startPos: i } = g(
892
- r.doc,
893
- r.selection.from
894
- ), a = r.selection.$anchor.parentOffset === 0, s = r.selection.anchor === r.selection.head, l = i === 2, d = i - 1;
895
- return !l && a && s && n === 2 ? e.BNMergeBlocks(d) : !1;
1286
+ () => t.command(({ state: n }) => {
1287
+ const { depth: r, startPos: i } = g(
1288
+ n.doc,
1289
+ n.selection.from
1290
+ ), a = n.selection.$anchor.parentOffset === 0, s = n.selection.anchor === n.selection.head, l = i === 2, d = i - 1;
1291
+ return !l && a && s && r === 2 ? t.BNMergeBlocks(d) : !1;
896
1292
  })
897
1293
  ]),
898
- Enter: () => this.editor.commands.first(({ commands: e }) => [
1294
+ Enter: () => this.editor.commands.first(({ commands: t }) => [
899
1295
  // Removes a level of nesting if the block is empty & indented, while the selection is also empty & at the start
900
1296
  // of the block.
901
- () => e.command(({ state: r }) => {
902
- const { node: n, depth: i } = g(
903
- r.doc,
904
- r.selection.from
905
- ), a = r.selection.$anchor.parentOffset === 0, s = r.selection.anchor === r.selection.head, l = n.textContent.length === 0, d = i > 2;
906
- return a && s && l && d ? e.liftListItem("blockContainer") : !1;
1297
+ () => t.command(({ state: n }) => {
1298
+ const { node: r, depth: i } = g(
1299
+ n.doc,
1300
+ n.selection.from
1301
+ ), a = n.selection.$anchor.parentOffset === 0, s = n.selection.anchor === n.selection.head, l = r.textContent.length === 0, d = i > 2;
1302
+ return a && s && l && d ? t.liftListItem("blockContainer") : !1;
907
1303
  }),
908
1304
  // Creates a new block and moves the selection to it if the current one is empty, while the selection is also
909
1305
  // empty & at the start of the block.
910
- () => e.command(({ state: r, chain: n }) => {
1306
+ () => t.command(({ state: n, chain: r }) => {
911
1307
  const { node: i, endPos: a } = g(
912
- r.doc,
913
- r.selection.from
914
- ), s = r.selection.$anchor.parentOffset === 0, l = r.selection.anchor === r.selection.head, d = i.textContent.length === 0;
1308
+ n.doc,
1309
+ n.selection.from
1310
+ ), s = n.selection.$anchor.parentOffset === 0, l = n.selection.anchor === n.selection.head, d = i.textContent.length === 0;
915
1311
  if (s && l && d) {
916
- const c = a + 1, h = c + 2;
917
- return n().BNCreateBlock(c).setTextSelection(h).run(), !0;
1312
+ const c = a + 1, u = c + 2;
1313
+ return r().BNCreateBlock(c).setTextSelection(u).run(), !0;
918
1314
  }
919
1315
  return !1;
920
1316
  }),
921
1317
  // Splits the current block, moving content inside that's after the cursor to a new text block below. Also
922
1318
  // deletes the selection beforehand, if it's not empty.
923
- () => e.command(({ state: r, chain: n }) => {
1319
+ () => t.command(({ state: n, chain: r }) => {
924
1320
  const { node: i } = g(
925
- r.doc,
926
- r.selection.from
1321
+ n.doc,
1322
+ n.selection.from
927
1323
  );
928
- return i.textContent.length === 0 ? !1 : (n().deleteSelection().BNSplitBlock(r.selection.from, !1).run(), !0);
1324
+ return i.textContent.length === 0 ? !1 : (r().deleteSelection().BNSplitBlock(n.selection.from, !1).run(), !0);
929
1325
  })
930
1326
  ]),
931
1327
  // Always returning true for tab key presses ensures they're not captured by the browser. Otherwise, they blur the
@@ -963,7 +1359,7 @@ const de = "_bnEditor_ywyu7_3", ce = "_bnRoot_ywyu7_20", ue = "_defaultStyles_yw
963
1359
  })
964
1360
  };
965
1361
  }
966
- }), we = S.create({
1362
+ }), Re = R.create({
967
1363
  name: "blockGroup",
968
1364
  group: "blockGroup",
969
1365
  content: "blockContainer+",
@@ -984,298 +1380,46 @@ const de = "_bnEditor_ywyu7_3", ce = "_bnRoot_ywyu7_20", ue = "_defaultStyles_yw
984
1380
  return [
985
1381
  "div",
986
1382
  w(this.options.HTMLAttributes, o, {
987
- class: b.blockGroup,
1383
+ class: k.blockGroup,
988
1384
  "data-node-type": "blockGroup"
989
1385
  }),
990
1386
  0
991
1387
  ];
992
1388
  }
993
- }), Se = S.create({
994
- name: "paragraph",
995
- group: "blockContent",
996
- content: "inline*",
997
- parseHTML() {
998
- return [
999
- {
1000
- tag: "p",
1001
- priority: 200,
1002
- node: "paragraph"
1003
- }
1004
- ];
1005
- },
1006
- renderHTML({ HTMLAttributes: o }) {
1007
- return [
1008
- "div",
1009
- w(o, {
1010
- class: b.blockContent,
1011
- "data-content-type": this.name
1012
- }),
1013
- ["p", 0]
1014
- ];
1015
- }
1016
- }), xe = S.create({
1017
- name: "heading",
1018
- group: "blockContent",
1019
- content: "inline*",
1020
- addAttributes() {
1021
- return {
1022
- level: {
1023
- default: "1",
1024
- // instead of "level" attributes, use "data-level"
1025
- parseHTML: (o) => o.getAttribute("data-level"),
1026
- renderHTML: (o) => ({
1027
- "data-level": o.level
1028
- })
1029
- }
1030
- };
1031
- },
1032
- addInputRules() {
1033
- return [
1034
- ...["1", "2", "3"].map((o) => new j({
1035
- find: new RegExp(`^(#{${parseInt(o)}})\\s$`),
1036
- handler: ({ state: t, chain: e, range: r }) => {
1037
- e().BNUpdateBlock(t.selection.from, {
1038
- type: "heading",
1039
- props: {
1040
- level: o
1041
- }
1042
- }).deleteRange({ from: r.from, to: r.to });
1043
- }
1044
- }))
1045
- ];
1046
- },
1047
- parseHTML() {
1048
- return [
1049
- {
1050
- tag: "h1",
1051
- attrs: { level: "1" },
1052
- node: "heading"
1053
- },
1054
- {
1055
- tag: "h2",
1056
- attrs: { level: "2" },
1057
- node: "heading"
1058
- },
1059
- {
1060
- tag: "h3",
1061
- attrs: { level: "3" },
1062
- node: "heading"
1063
- }
1064
- ];
1065
- },
1066
- renderHTML({ node: o, HTMLAttributes: t }) {
1067
- return [
1068
- "div",
1069
- w(t, {
1070
- class: b.blockContent,
1071
- "data-content-type": this.name
1072
- }),
1073
- ["h" + o.attrs.level, 0]
1074
- ];
1075
- }
1076
- }), kt = (o) => {
1077
- const { node: t, contentType: e } = g(
1078
- o.state.doc,
1079
- o.state.selection.from
1080
- ), r = o.state.selection.anchor === o.state.selection.head;
1081
- return !e.name.endsWith("ListItem") || !r ? !1 : o.commands.first(({ state: n, chain: i, commands: a }) => [
1082
- () => (
1083
- // Changes list item block to a text block if the content is empty.
1084
- a.command(() => t.textContent.length === 0 ? a.BNUpdateBlock(n.selection.from, {
1085
- type: "paragraph",
1086
- props: {}
1087
- }) : !1)
1088
- ),
1089
- () => (
1090
- // Splits the current block, moving content inside that's after the cursor to a new block of the same type
1091
- // below.
1092
- a.command(() => t.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(n.selection.from, !0).run(), !0) : !1)
1093
- )
1094
- ]);
1095
- }, Ie = S.create({
1096
- name: "bulletListItem",
1097
- group: "blockContent",
1098
- content: "inline*",
1099
- addInputRules() {
1100
- return [
1101
- // Creates an unordered list when starting with "-", "+", or "*".
1102
- new j({
1103
- find: new RegExp("^[-+*]\\s$"),
1104
- handler: ({ state: o, chain: t, range: e }) => {
1105
- t().BNUpdateBlock(o.selection.from, {
1106
- type: "bulletListItem",
1107
- props: {}
1108
- }).deleteRange({ from: e.from, to: e.to });
1109
- }
1110
- })
1111
- ];
1112
- },
1113
- addKeyboardShortcuts() {
1114
- return {
1115
- Enter: () => kt(this.editor)
1116
- };
1117
- },
1118
- parseHTML() {
1119
- return [
1120
- // Case for regular HTML list structure.
1121
- {
1122
- tag: "li",
1123
- getAttrs: (o) => {
1124
- if (typeof o == "string")
1125
- return !1;
1126
- const t = o.parentElement;
1127
- return t === null ? !1 : t.tagName === "UL" ? {} : !1;
1128
- },
1129
- node: "bulletListItem"
1130
- },
1131
- // Case for BlockNote list structure.
1132
- {
1133
- tag: "p",
1134
- getAttrs: (o) => {
1135
- if (typeof o == "string")
1136
- return !1;
1137
- const t = o.parentElement;
1138
- return t === null ? !1 : t.getAttribute("data-content-type") === "bulletListItem" ? {} : !1;
1139
- },
1140
- priority: 300,
1141
- node: "bulletListItem"
1142
- }
1143
- ];
1144
- },
1145
- renderHTML({ HTMLAttributes: o }) {
1146
- return [
1147
- "div",
1148
- w(o, {
1149
- class: b.blockContent,
1150
- "data-content-type": this.name
1151
- }),
1152
- ["p", 0]
1153
- ];
1154
- }
1155
- }), Pe = new v("numbered-list-indexing"), Le = () => new C({
1156
- key: Pe,
1157
- appendTransaction: (o, t, e) => {
1158
- const r = e.tr;
1159
- r.setMeta("numberedListIndexing", !0);
1160
- let n = !1;
1161
- return e.doc.descendants((i, a) => {
1162
- if (i.type.name === "blockContainer" && i.firstChild.type.name === "numberedListItem") {
1163
- let s = "1";
1164
- const l = a === 1, d = g(r.doc, a + 1);
1165
- if (d === void 0)
1166
- return;
1167
- if (!l) {
1168
- const f = g(r.doc, a - 2);
1169
- if (f === void 0)
1170
- return;
1171
- if (!(d.depth !== f.depth)) {
1172
- const m = f.contentNode;
1173
- if (f.contentType.name === "numberedListItem") {
1174
- const z = m.attrs.index;
1175
- s = (parseInt(z) + 1).toString();
1176
- }
1177
- }
1178
- }
1179
- d.contentNode.attrs.index !== s && (n = !0, r.setNodeMarkup(a + 1, void 0, {
1180
- index: s
1181
- }));
1182
- }
1183
- }), n ? r : null;
1184
- }
1185
- }), _e = S.create({
1186
- name: "numberedListItem",
1187
- group: "blockContent",
1188
- content: "inline*",
1189
- addAttributes() {
1190
- return {
1191
- index: {
1192
- default: null,
1193
- parseHTML: (o) => o.getAttribute("data-index"),
1194
- renderHTML: (o) => ({
1195
- "data-index": o.index
1196
- })
1197
- }
1198
- };
1199
- },
1200
- addInputRules() {
1389
+ }), ze = [
1390
+ Fe,
1391
+ Re,
1392
+ R.create({
1393
+ name: "doc",
1394
+ topNode: !0,
1395
+ content: "blockGroup"
1396
+ })
1397
+ ], Ue = (o) => {
1398
+ const e = q.fromSchema(o);
1399
+ return new q(
1400
+ {
1401
+ ...e.nodes
1402
+ // TODO: If a serializer is defined in the config for a custom block, it
1403
+ // should be added here. We still need to figure out how the serializer
1404
+ // should be defined in the custom blocks API though, and implement that,
1405
+ // before we can do this.
1406
+ },
1407
+ e.marks
1408
+ );
1409
+ }, $e = v.create({
1410
+ addProseMirrorPlugins() {
1201
1411
  return [
1202
- // Creates an ordered list when starting with "1.".
1203
- new j({
1204
- find: new RegExp("^1\\.\\s$"),
1205
- handler: ({ state: o, chain: t, range: e }) => {
1206
- t().BNUpdateBlock(o.selection.from, {
1207
- type: "numberedListItem",
1208
- props: {}
1209
- }).deleteRange({ from: e.from, to: e.to });
1412
+ new C({
1413
+ props: {
1414
+ clipboardSerializer: Ue(this.editor.schema)
1210
1415
  }
1211
1416
  })
1212
1417
  ];
1213
- },
1214
- addKeyboardShortcuts() {
1215
- return {
1216
- Enter: () => kt(this.editor)
1217
- };
1218
- },
1219
- addProseMirrorPlugins() {
1220
- return [Le()];
1221
- },
1222
- parseHTML() {
1223
- return [
1224
- // Case for regular HTML list structure.
1225
- // (e.g.: when pasting from other apps)
1226
- {
1227
- tag: "li",
1228
- getAttrs: (o) => {
1229
- if (typeof o == "string")
1230
- return !1;
1231
- const t = o.parentElement;
1232
- return t === null ? !1 : t.tagName === "OL" ? {} : !1;
1233
- },
1234
- node: "numberedListItem"
1235
- },
1236
- // Case for BlockNote list structure.
1237
- // (e.g.: when pasting from blocknote)
1238
- {
1239
- tag: "p",
1240
- getAttrs: (o) => {
1241
- if (typeof o == "string")
1242
- return !1;
1243
- const t = o.parentElement;
1244
- return t === null ? !1 : t.getAttribute("data-content-type") === "numberedListItem" ? {} : !1;
1245
- },
1246
- priority: 300,
1247
- node: "numberedListItem"
1248
- }
1249
- ];
1250
- },
1251
- renderHTML({ HTMLAttributes: o }) {
1252
- return [
1253
- "div",
1254
- w(o, {
1255
- class: b.blockContent,
1256
- "data-content-type": this.name
1257
- }),
1258
- // we use a <p> tag, because for <li> tags we'd need to add a <ul> parent for around siblings to be semantically correct,
1259
- // which would be quite cumbersome
1260
- ["p", 0]
1261
- ];
1262
1418
  }
1263
- }), Ae = [
1264
- Se,
1265
- xe,
1266
- Ie,
1267
- _e,
1268
- Te,
1269
- we,
1270
- S.create({
1271
- name: "doc",
1272
- topNode: !0,
1273
- content: "blockGroup"
1274
- })
1275
- ], Ne = wt(
1419
+ }), Ge = Dt(
1276
1420
  (o) => o.type.name === "blockContainer"
1277
1421
  );
1278
- function q() {
1422
+ function W() {
1279
1423
  return {
1280
1424
  active: !1,
1281
1425
  triggerCharacter: void 0,
@@ -1286,35 +1430,35 @@ function q() {
1286
1430
  decorationId: void 0
1287
1431
  };
1288
1432
  }
1289
- class He {
1433
+ class je {
1290
1434
  constructor({
1291
- editor: t,
1292
- pluginKey: e,
1293
- onSelectItem: r = () => {
1435
+ editor: e,
1436
+ pluginKey: t,
1437
+ onSelectItem: n = () => {
1294
1438
  },
1295
- suggestionsMenuFactory: n
1439
+ suggestionsMenuFactory: r
1296
1440
  }) {
1297
- u(this, "editor");
1298
- u(this, "pluginKey");
1299
- u(this, "suggestionsMenu");
1300
- u(this, "pluginState");
1301
- u(this, "itemCallback");
1302
- u(this, "handleScroll", () => {
1441
+ h(this, "editor");
1442
+ h(this, "pluginKey");
1443
+ h(this, "suggestionsMenu");
1444
+ h(this, "pluginState");
1445
+ h(this, "itemCallback");
1446
+ h(this, "handleScroll", () => {
1303
1447
  this.pluginKey.getState(this.editor._tiptapEditor.state).active && this.suggestionsMenu.render(this.getDynamicParams(), !1);
1304
1448
  });
1305
- this.editor = t, this.pluginKey = e, this.pluginState = q(), this.itemCallback = (i) => {
1306
- t._tiptapEditor.chain().focus().deleteRange({
1449
+ this.editor = e, this.pluginKey = t, this.pluginState = W(), this.itemCallback = (i) => {
1450
+ e._tiptapEditor.chain().focus().deleteRange({
1307
1451
  from: this.pluginState.queryStartPos - this.pluginState.triggerCharacter.length,
1308
- to: t._tiptapEditor.state.selection.from
1309
- }).run(), r({
1452
+ to: e._tiptapEditor.state.selection.from
1453
+ }).run(), n({
1310
1454
  item: i,
1311
- editor: t
1455
+ editor: e
1312
1456
  });
1313
- }, this.suggestionsMenu = n(this.getStaticParams()), document.addEventListener("scroll", this.handleScroll);
1457
+ }, this.suggestionsMenu = r(this.getStaticParams()), document.addEventListener("scroll", this.handleScroll);
1314
1458
  }
1315
- update(t, e) {
1316
- const r = this.pluginKey.getState(e), n = this.pluginKey.getState(t.state), i = !r.active && n.active, a = r.active && !n.active, s = r.active && n.active;
1317
- !i && !s && !a || (this.pluginState = a ? r : n, (a || !this.editor.isEditable) && (this.suggestionsMenu.hide(), this.suggestionsMenu.element.removeEventListener(
1459
+ update(e, t) {
1460
+ const n = this.pluginKey.getState(t), r = this.pluginKey.getState(e.state), i = !n.active && r.active, a = n.active && !r.active, s = n.active && r.active;
1461
+ !i && !s && !a || (this.pluginState = a ? n : r, (a || !this.editor.isEditable) && (this.suggestionsMenu.hide(), this.suggestionsMenu.element.removeEventListener(
1318
1462
  "mousedown",
1319
1463
  (l) => l.preventDefault()
1320
1464
  )), s && this.suggestionsMenu.render(this.getDynamicParams(), !1), i && this.editor.isEditable && (this.suggestionsMenu.render(this.getDynamicParams(), !0), this.suggestionsMenu.element.addEventListener(
@@ -1327,58 +1471,58 @@ class He {
1327
1471
  }
1328
1472
  getStaticParams() {
1329
1473
  return {
1330
- itemCallback: (t) => this.itemCallback(t)
1474
+ itemCallback: (e) => this.itemCallback(e)
1331
1475
  };
1332
1476
  }
1333
1477
  getDynamicParams() {
1334
- const t = document.querySelector(
1478
+ const e = document.querySelector(
1335
1479
  `[data-decoration-id="${this.pluginState.decorationId}"]`
1336
1480
  );
1337
1481
  return {
1338
1482
  items: this.pluginState.items,
1339
1483
  keyboardHoveredItemIndex: this.pluginState.keyboardHoveredItemIndex,
1340
- referenceRect: t.getBoundingClientRect()
1484
+ referenceRect: e.getBoundingClientRect()
1341
1485
  };
1342
1486
  }
1343
1487
  }
1344
- function Oe({
1488
+ function qe({
1345
1489
  pluginKey: o,
1346
- editor: t,
1347
- defaultTriggerCharacter: e,
1348
- suggestionsMenuFactory: r,
1349
- onSelectItem: n = () => {
1490
+ editor: e,
1491
+ defaultTriggerCharacter: t,
1492
+ suggestionsMenuFactory: n,
1493
+ onSelectItem: r = () => {
1350
1494
  },
1351
1495
  items: i = () => []
1352
1496
  }) {
1353
- if (e.length !== 1)
1497
+ if (t.length !== 1)
1354
1498
  throw new Error("'char' should be a single character");
1355
1499
  const a = (s) => {
1356
1500
  s.dispatch(s.state.tr.setMeta(o, { deactivate: !0 }));
1357
1501
  };
1358
1502
  return new C({
1359
1503
  key: o,
1360
- view: (s) => new He({
1361
- editor: t,
1504
+ view: (s) => new je({
1505
+ editor: e,
1362
1506
  pluginKey: o,
1363
1507
  onSelectItem: (l) => {
1364
- a(s), n(l);
1508
+ a(s), r(l);
1365
1509
  },
1366
- suggestionsMenuFactory: r
1510
+ suggestionsMenuFactory: n
1367
1511
  }),
1368
1512
  state: {
1369
1513
  // Initialize the plugin's internal state.
1370
1514
  init() {
1371
- return q();
1515
+ return W();
1372
1516
  },
1373
1517
  // Apply changes to the plugin state from an editor transaction.
1374
1518
  apply(s, l, d, c) {
1375
- var f, p, m, y;
1519
+ var p, m, f, y;
1376
1520
  if (s.getMeta("orderedListIndexing") !== void 0)
1377
1521
  return l;
1378
- if ((f = s.getMeta(o)) != null && f.activate)
1522
+ if ((p = s.getMeta(o)) != null && p.activate)
1379
1523
  return {
1380
1524
  active: !0,
1381
- triggerCharacter: ((p = s.getMeta(o)) == null ? void 0 : p.triggerCharacter) || "",
1525
+ triggerCharacter: ((m = s.getMeta(o)) == null ? void 0 : m.triggerCharacter) || "",
1382
1526
  queryStartPos: c.selection.from,
1383
1527
  items: i(""),
1384
1528
  keyboardHoveredItemIndex: 0,
@@ -1389,60 +1533,60 @@ function Oe({
1389
1533
  };
1390
1534
  if (!l.active)
1391
1535
  return l;
1392
- const h = { ...l };
1393
- if (h.items = i(
1536
+ const u = { ...l };
1537
+ if (u.items = i(
1394
1538
  c.doc.textBetween(l.queryStartPos, c.selection.from)
1395
- ), h.notFoundCount = 0, h.items.length === 0 && (h.notFoundCount = Math.max(
1539
+ ), u.notFoundCount = 0, u.items.length === 0 && (u.notFoundCount = Math.max(
1396
1540
  0,
1397
1541
  l.notFoundCount + (c.selection.from - d.selection.from)
1398
1542
  )), // Highlighting text should hide the menu.
1399
1543
  c.selection.from !== c.selection.to || // Transactions with plugin metadata {deactivate: true} should hide the menu.
1400
- (m = s.getMeta(o)) != null && m.deactivate || // Certain mouse events should hide the menu.
1544
+ (f = s.getMeta(o)) != null && f.deactivate || // Certain mouse events should hide the menu.
1401
1545
  // TODO: Change to global mousedown listener.
1402
1546
  s.getMeta("focus") || s.getMeta("blur") || s.getMeta("pointer") || // Moving the caret before the character which triggered the menu should hide it.
1403
1547
  l.active && c.selection.from < l.queryStartPos || // Entering more than 3 characters, after the last query that matched with at least 1 menu item, should hide
1404
1548
  // the menu.
1405
- h.notFoundCount > 3)
1406
- return q();
1549
+ u.notFoundCount > 3)
1550
+ return W();
1407
1551
  if (((y = s.getMeta(o)) == null ? void 0 : y.selectedItemIndexChanged) !== void 0) {
1408
- let k = s.getMeta(o).selectedItemIndexChanged;
1409
- k < 0 ? k = l.items.length - 1 : k >= l.items.length && (k = 0), h.keyboardHoveredItemIndex = k;
1552
+ let b = s.getMeta(o).selectedItemIndexChanged;
1553
+ b < 0 ? b = l.items.length - 1 : b >= l.items.length && (b = 0), u.keyboardHoveredItemIndex = b;
1410
1554
  }
1411
- return h;
1555
+ return u;
1412
1556
  }
1413
1557
  },
1414
1558
  props: {
1415
1559
  handleKeyDown(s, l) {
1416
1560
  const d = this.getState(s.state).active;
1417
- if (l.key === e && !d)
1561
+ if (l.key === t && !d)
1418
1562
  return s.dispatch(
1419
- s.state.tr.insertText(e).scrollIntoView().setMeta(o, {
1563
+ s.state.tr.insertText(t).scrollIntoView().setMeta(o, {
1420
1564
  activate: !0,
1421
- triggerCharacter: e
1565
+ triggerCharacter: t
1422
1566
  })
1423
1567
  ), !0;
1424
1568
  if (!d)
1425
1569
  return !1;
1426
1570
  const {
1427
1571
  triggerCharacter: c,
1428
- queryStartPos: h,
1429
- items: f,
1430
- keyboardHoveredItemIndex: p
1572
+ queryStartPos: u,
1573
+ items: p,
1574
+ keyboardHoveredItemIndex: m
1431
1575
  } = o.getState(s.state);
1432
1576
  return l.key === "ArrowUp" ? (s.dispatch(
1433
1577
  s.state.tr.setMeta(o, {
1434
- selectedItemIndexChanged: p - 1
1578
+ selectedItemIndexChanged: m - 1
1435
1579
  })
1436
1580
  ), !0) : l.key === "ArrowDown" ? (s.dispatch(
1437
1581
  s.state.tr.setMeta(o, {
1438
- selectedItemIndexChanged: p + 1
1582
+ selectedItemIndexChanged: m + 1
1439
1583
  })
1440
- ), !0) : l.key === "Enter" ? (a(s), t._tiptapEditor.chain().focus().deleteRange({
1441
- from: h - c.length,
1442
- to: t._tiptapEditor.state.selection.from
1443
- }).run(), n({
1444
- item: f[p],
1445
- editor: t
1584
+ ), !0) : l.key === "Enter" ? (a(s), e._tiptapEditor.chain().focus().deleteRange({
1585
+ from: u - c.length,
1586
+ to: e._tiptapEditor.state.selection.from
1587
+ }).run(), r({
1588
+ item: p[m],
1589
+ editor: e
1446
1590
  }), !0) : l.key === "Escape" ? (a(s), !0) : !1;
1447
1591
  },
1448
1592
  // Hides menu in cases where mouse click does not cause an editor state change.
@@ -1451,16 +1595,16 @@ function Oe({
1451
1595
  },
1452
1596
  // Setup decorator on the currently active suggestion.
1453
1597
  decorations(s) {
1454
- const { active: l, decorationId: d, queryStartPos: c, triggerCharacter: h } = this.getState(s);
1598
+ const { active: l, decorationId: d, queryStartPos: c, triggerCharacter: u } = this.getState(s);
1455
1599
  if (!l)
1456
1600
  return null;
1457
- if (h === "") {
1458
- const f = Ne(s.selection);
1459
- if (f)
1601
+ if (u === "") {
1602
+ const p = Ge(s.selection);
1603
+ if (p)
1460
1604
  return F.create(s.doc, [
1461
1605
  D.node(
1462
- f.pos,
1463
- f.pos + f.node.nodeSize,
1606
+ p.pos,
1607
+ p.pos + p.node.nodeSize,
1464
1608
  {
1465
1609
  nodeName: "span",
1466
1610
  class: "suggestion-decorator",
@@ -1471,7 +1615,7 @@ function Oe({
1471
1615
  }
1472
1616
  return F.create(s.doc, [
1473
1617
  D.inline(
1474
- c - h.length,
1618
+ c - u.length,
1475
1619
  c,
1476
1620
  {
1477
1621
  nodeName: "span",
@@ -1484,7 +1628,7 @@ function Oe({
1484
1628
  }
1485
1629
  });
1486
1630
  }
1487
- const V = new v("suggestions-slash-commands"), De = E.create({
1631
+ const X = new E("suggestions-slash-commands"), We = () => v.create({
1488
1632
  name: "slash-command",
1489
1633
  addOptions() {
1490
1634
  return {
@@ -1498,155 +1642,157 @@ const V = new v("suggestions-slash-commands"), De = E.create({
1498
1642
  throw new Error("required args not defined for SlashMenuExtension");
1499
1643
  const o = this.options.commands;
1500
1644
  return [
1501
- Oe({
1502
- pluginKey: V,
1645
+ qe({
1646
+ pluginKey: X,
1503
1647
  editor: this.options.editor,
1504
1648
  defaultTriggerCharacter: "/",
1505
1649
  suggestionsMenuFactory: this.options.slashMenuFactory,
1506
- items: (t) => o.filter((e) => e.match(t)),
1507
- onSelectItem: ({ item: t, editor: e }) => {
1508
- t.execute(e);
1650
+ items: (e) => o.filter(
1651
+ (t) => t.match(e)
1652
+ ),
1653
+ onSelectItem: ({ item: e, editor: t }) => {
1654
+ e.execute(t);
1509
1655
  }
1510
1656
  })
1511
1657
  ];
1512
1658
  }
1513
1659
  });
1514
- class A extends $ {
1515
- constructor(e, r) {
1516
- super(e, r);
1517
- u(this, "nodes");
1518
- const n = e.node();
1519
- this.nodes = [], e.doc.nodesBetween(e.pos, r.pos, (i, a, s) => {
1520
- if (s !== null && s.eq(n))
1660
+ class L extends G {
1661
+ constructor(t, n) {
1662
+ super(t, n);
1663
+ h(this, "nodes");
1664
+ const r = t.node();
1665
+ this.nodes = [], t.doc.nodesBetween(t.pos, n.pos, (i, a, s) => {
1666
+ if (s !== null && s.eq(r))
1521
1667
  return this.nodes.push(i), !1;
1522
1668
  });
1523
1669
  }
1524
- static create(e, r, n = r) {
1525
- return new A(e.resolve(r), e.resolve(n));
1670
+ static create(t, n, r = n) {
1671
+ return new L(t.resolve(n), t.resolve(r));
1526
1672
  }
1527
1673
  content() {
1528
- return new P(L.from(this.nodes), 0, 0);
1674
+ return new I(_.from(this.nodes), 0, 0);
1529
1675
  }
1530
- eq(e) {
1531
- if (!(e instanceof A) || this.nodes.length !== e.nodes.length || this.from !== e.from || this.to !== e.to)
1676
+ eq(t) {
1677
+ if (!(t instanceof L) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to)
1532
1678
  return !1;
1533
- for (let r = 0; r < this.nodes.length; r++)
1534
- if (!this.nodes[r].eq(e.nodes[r]))
1679
+ for (let n = 0; n < this.nodes.length; n++)
1680
+ if (!this.nodes[n].eq(t.nodes[n]))
1535
1681
  return !1;
1536
1682
  return !0;
1537
1683
  }
1538
- map(e, r) {
1539
- let n = r.mapResult(this.from), i = r.mapResult(this.to);
1540
- return i.deleted ? $.near(e.resolve(n.pos)) : n.deleted ? $.near(e.resolve(i.pos)) : new A(
1541
- e.resolve(n.pos),
1542
- e.resolve(i.pos)
1684
+ map(t, n) {
1685
+ let r = n.mapResult(this.from), i = n.mapResult(this.to);
1686
+ return i.deleted ? G.near(t.resolve(r.pos)) : r.deleted ? G.near(t.resolve(i.pos)) : new L(
1687
+ t.resolve(r.pos),
1688
+ t.resolve(i.pos)
1543
1689
  );
1544
1690
  }
1545
1691
  toJSON() {
1546
1692
  return { type: "node", anchor: this.anchor, head: this.head };
1547
1693
  }
1548
1694
  }
1549
- const Fe = Jt.__serializeForClipboard;
1695
+ const Ve = se.__serializeForClipboard;
1550
1696
  let T;
1551
- function yt(o, t) {
1552
- var n;
1553
- if (!t.dom.isConnected)
1697
+ function It(o, e) {
1698
+ var r;
1699
+ if (!e.dom.isConnected)
1554
1700
  return;
1555
- let e = t.posAtCoords(o);
1556
- if (!e)
1701
+ let t = e.posAtCoords(o);
1702
+ if (!t)
1557
1703
  return;
1558
- let r = t.domAtPos(e.pos).node;
1559
- if (r !== t.dom) {
1560
- for (; r && r.parentNode && r.parentNode !== t.dom && !((n = r.hasAttribute) != null && n.call(r, "data-id")); )
1561
- r = r.parentNode;
1562
- if (r)
1563
- return { node: r, id: r.getAttribute("data-id") };
1704
+ let n = e.domAtPos(t.pos).node;
1705
+ if (n !== e.dom) {
1706
+ for (; n && n.parentNode && n.parentNode !== e.dom && !((r = n.hasAttribute) != null && r.call(n, "data-id")); )
1707
+ n = n.parentNode;
1708
+ if (n)
1709
+ return { node: n, id: n.getAttribute("data-id") };
1564
1710
  }
1565
1711
  }
1566
- function Re(o, t) {
1567
- let e = yt(o, t);
1568
- if (e && e.node.nodeType === 1) {
1569
- const r = t.docView;
1570
- let n = r.nearestDesc(e.node, !0);
1571
- return !n || n === r ? null : n.posBefore;
1712
+ function Ye(o, e) {
1713
+ let t = It(o, e);
1714
+ if (t && t.node.nodeType === 1) {
1715
+ const n = e.docView;
1716
+ let r = n.nearestDesc(t.node, !0);
1717
+ return !r || r === n ? null : r.posBefore;
1572
1718
  }
1573
1719
  return null;
1574
1720
  }
1575
- function ze(o, t) {
1576
- let e, r;
1577
- const n = t.resolve(o.from).node().type.spec.group === "blockContent", i = t.resolve(o.to).node().type.spec.group === "blockContent", a = Math.min(o.$anchor.depth, o.$head.depth);
1578
- if (n && i) {
1721
+ function Ke(o, e) {
1722
+ let t, n;
1723
+ const r = e.resolve(o.from).node().type.spec.group === "blockContent", i = e.resolve(o.to).node().type.spec.group === "blockContent", a = Math.min(o.$anchor.depth, o.$head.depth);
1724
+ if (r && i) {
1579
1725
  const s = o.$from.start(a - 1), l = o.$to.end(a - 1);
1580
- e = t.resolve(s - 1).pos, r = t.resolve(l + 1).pos;
1726
+ t = e.resolve(s - 1).pos, n = e.resolve(l + 1).pos;
1581
1727
  } else
1582
- e = o.from, r = o.to;
1583
- return { from: e, to: r };
1728
+ t = o.from, n = o.to;
1729
+ return { from: t, to: n };
1584
1730
  }
1585
- function ot(o, t, e = t) {
1586
- t === e && (e += o.state.doc.resolve(t + 1).node().nodeSize);
1587
- const r = o.domAtPos(t).node.cloneNode(!0), n = o.domAtPos(t).node, i = (c, h) => Array.prototype.indexOf.call(c.children, h), a = i(
1588
- n,
1731
+ function rt(o, e, t = e) {
1732
+ e === t && (t += o.state.doc.resolve(e + 1).node().nodeSize);
1733
+ const n = o.domAtPos(e).node.cloneNode(!0), r = o.domAtPos(e).node, i = (c, u) => Array.prototype.indexOf.call(c.children, u), a = i(
1734
+ r,
1589
1735
  // Expects from position to be just before the first selected block.
1590
- o.domAtPos(t + 1).node.parentElement
1736
+ o.domAtPos(e + 1).node.parentElement
1591
1737
  ), s = i(
1592
- n,
1738
+ r,
1593
1739
  // Expects to position to be just after the last selected block.
1594
- o.domAtPos(e - 1).node.parentElement
1740
+ o.domAtPos(t - 1).node.parentElement
1595
1741
  );
1596
- for (let c = n.childElementCount - 1; c >= 0; c--)
1597
- (c > s || c < a) && r.removeChild(r.children[c]);
1598
- bt(), T = r;
1742
+ for (let c = r.childElementCount - 1; c >= 0; c--)
1743
+ (c > s || c < a) && n.removeChild(n.children[c]);
1744
+ _t(), T = n;
1599
1745
  const d = o.dom.className.split(" ").filter(
1600
1746
  (c) => !c.includes("bn") && !c.includes("ProseMirror") && !c.includes("editor")
1601
1747
  ).join(" ");
1602
- T.className = T.className + " " + _.dragPreview + " " + d, document.body.appendChild(T);
1748
+ T.className = T.className + " " + P.dragPreview + " " + d, document.body.appendChild(T);
1603
1749
  }
1604
- function bt() {
1750
+ function _t() {
1605
1751
  T !== void 0 && (document.body.removeChild(T), T = void 0);
1606
1752
  }
1607
- function Ue(o, t) {
1753
+ function Je(o, e) {
1608
1754
  if (!o.dataTransfer)
1609
1755
  return;
1610
- const e = t.dom.getBoundingClientRect();
1611
- let r = {
1612
- left: e.left + e.width / 2,
1756
+ const t = e.dom.getBoundingClientRect();
1757
+ let n = {
1758
+ left: t.left + t.width / 2,
1613
1759
  // take middle of editor
1614
1760
  top: o.clientY
1615
- }, n = Re(r, t);
1616
- if (n != null) {
1617
- const i = t.state.selection, a = t.state.doc, { from: s, to: l } = ze(i, a), d = s <= n && n < l, c = i.$anchor.node() !== i.$head.node() || i instanceof A;
1618
- d && c ? (t.dispatch(
1619
- t.state.tr.setSelection(A.create(a, s, l))
1620
- ), ot(t, s, l)) : (t.dispatch(
1621
- t.state.tr.setSelection(_t.create(t.state.doc, n))
1622
- ), ot(t, n));
1623
- let h = t.state.selection.content(), { dom: f, text: p } = Fe(t, h);
1624
- o.dataTransfer.clearData(), o.dataTransfer.setData("text/html", f.innerHTML), o.dataTransfer.setData("text/plain", p), o.dataTransfer.effectAllowed = "move", o.dataTransfer.setDragImage(T, 0, 0), t.dragging = { slice: h, move: !0 };
1761
+ }, r = Ye(n, e);
1762
+ if (r != null) {
1763
+ const i = e.state.selection, a = e.state.doc, { from: s, to: l } = Ke(i, a), d = s <= r && r < l, c = i.$anchor.node() !== i.$head.node() || i instanceof L;
1764
+ d && c ? (e.dispatch(
1765
+ e.state.tr.setSelection(L.create(a, s, l))
1766
+ ), rt(e, s, l)) : (e.dispatch(
1767
+ e.state.tr.setSelection(Ut.create(e.state.doc, r))
1768
+ ), rt(e, r));
1769
+ let u = e.state.selection.content(), { dom: p, text: m } = Ve(e, u);
1770
+ o.dataTransfer.clearData(), o.dataTransfer.setData("text/html", p.innerHTML), o.dataTransfer.setData("text/plain", m), o.dataTransfer.effectAllowed = "move", o.dataTransfer.setDragImage(T, 0, 0), e.dragging = { slice: u, move: !0 };
1625
1771
  }
1626
1772
  }
1627
- class $e {
1773
+ class Xe {
1628
1774
  constructor({
1629
- tiptapEditor: t,
1630
- editor: e,
1631
- blockMenuFactory: r,
1632
- horizontalPosAnchoredAtRoot: n
1775
+ tiptapEditor: e,
1776
+ editor: t,
1777
+ blockMenuFactory: n,
1778
+ horizontalPosAnchoredAtRoot: r
1633
1779
  }) {
1634
- u(this, "editor");
1635
- u(this, "ttEditor");
1780
+ h(this, "editor");
1781
+ h(this, "ttEditor");
1636
1782
  // When true, the drag handle with be anchored at the same level as root elements
1637
1783
  // When false, the drag handle with be just to the left of the element
1638
- u(this, "horizontalPosAnchoredAtRoot");
1639
- u(this, "horizontalPosAnchor");
1640
- u(this, "blockMenu");
1641
- u(this, "hoveredBlock");
1784
+ h(this, "horizontalPosAnchoredAtRoot");
1785
+ h(this, "horizontalPosAnchor");
1786
+ h(this, "blockMenu");
1787
+ h(this, "hoveredBlock");
1642
1788
  // Used to check if currently dragged content comes from this editor instance.
1643
- u(this, "isDragging", !1);
1644
- u(this, "menuOpen", !1);
1645
- u(this, "menuFrozen", !1);
1789
+ h(this, "isDragging", !1);
1790
+ h(this, "menuOpen", !1);
1791
+ h(this, "menuFrozen", !1);
1646
1792
  /**
1647
1793
  * Sets isDragging when dragging text.
1648
1794
  */
1649
- u(this, "onDragStart", () => {
1795
+ h(this, "onDragStart", () => {
1650
1796
  this.isDragging = !0;
1651
1797
  });
1652
1798
  /**
@@ -1654,16 +1800,16 @@ class $e {
1654
1800
  * we dispatch a fake event, so that we can still drop the content
1655
1801
  * when dragging / dropping to the side of the editor
1656
1802
  */
1657
- u(this, "onDrop", (t) => {
1658
- if (t.synthetic || !this.isDragging)
1803
+ h(this, "onDrop", (e) => {
1804
+ if (e.synthetic || !this.isDragging)
1659
1805
  return;
1660
- let e = this.ttEditor.view.posAtCoords({
1661
- left: t.clientX,
1662
- top: t.clientY
1806
+ let t = this.ttEditor.view.posAtCoords({
1807
+ left: e.clientX,
1808
+ top: e.clientY
1663
1809
  });
1664
- if (this.isDragging = !1, !e || e.inside === -1) {
1665
- const r = new Event("drop", t), n = this.ttEditor.view.dom.firstChild.getBoundingClientRect();
1666
- r.clientX = n.left + n.width / 2, r.clientY = t.clientY, r.dataTransfer = t.dataTransfer, r.preventDefault = () => t.preventDefault(), r.synthetic = !0, this.ttEditor.view.dom.dispatchEvent(r);
1810
+ if (this.isDragging = !1, !t || t.inside === -1) {
1811
+ const n = new Event("drop", e), r = this.ttEditor.view.dom.firstChild.getBoundingClientRect();
1812
+ n.clientX = r.left + r.width / 2, n.clientY = e.clientY, n.dataTransfer = e.dataTransfer, n.preventDefault = () => e.preventDefault(), n.synthetic = !0, this.ttEditor.view.dom.dispatchEvent(n);
1667
1813
  }
1668
1814
  });
1669
1815
  /**
@@ -1671,69 +1817,69 @@ class $e {
1671
1817
  * we dispatch a fake event, so that we can still drop the content
1672
1818
  * when dragging / dropping to the side of the editor
1673
1819
  */
1674
- u(this, "onDragOver", (t) => {
1675
- if (t.synthetic || !this.isDragging)
1820
+ h(this, "onDragOver", (e) => {
1821
+ if (e.synthetic || !this.isDragging)
1676
1822
  return;
1677
- let e = this.ttEditor.view.posAtCoords({
1678
- left: t.clientX,
1679
- top: t.clientY
1823
+ let t = this.ttEditor.view.posAtCoords({
1824
+ left: e.clientX,
1825
+ top: e.clientY
1680
1826
  });
1681
- if (!e || e.inside === -1) {
1682
- const r = new Event("dragover", t), n = this.ttEditor.view.dom.firstChild.getBoundingClientRect();
1683
- r.clientX = n.left + n.width / 2, r.clientY = t.clientY, r.dataTransfer = t.dataTransfer, r.preventDefault = () => t.preventDefault(), r.synthetic = !0, this.ttEditor.view.dom.dispatchEvent(r);
1827
+ if (!t || t.inside === -1) {
1828
+ const n = new Event("dragover", e), r = this.ttEditor.view.dom.firstChild.getBoundingClientRect();
1829
+ n.clientX = r.left + r.width / 2, n.clientY = e.clientY, n.dataTransfer = e.dataTransfer, n.preventDefault = () => e.preventDefault(), n.synthetic = !0, this.ttEditor.view.dom.dispatchEvent(n);
1684
1830
  }
1685
1831
  });
1686
- u(this, "onKeyDown", (t) => {
1832
+ h(this, "onKeyDown", (e) => {
1687
1833
  this.menuOpen && (this.menuOpen = !1, this.blockMenu.hide()), this.menuFrozen = !1;
1688
1834
  });
1689
- u(this, "onMouseDown", (t) => {
1690
- var e;
1691
- (e = this.blockMenu.element) != null && e.contains(t.target) || (this.menuOpen && (this.menuOpen = !1, this.blockMenu.hide()), this.menuFrozen = !1);
1835
+ h(this, "onMouseDown", (e) => {
1836
+ var t;
1837
+ (t = this.blockMenu.element) != null && t.contains(e.target) || (this.menuOpen && (this.menuOpen = !1, this.blockMenu.hide()), this.menuFrozen = !1);
1692
1838
  });
1693
- u(this, "onMouseMove", (t) => {
1839
+ h(this, "onMouseMove", (e) => {
1694
1840
  var a, s;
1695
1841
  if (this.menuFrozen)
1696
1842
  return;
1697
- const e = this.ttEditor.view.dom.firstChild.getBoundingClientRect();
1698
- this.horizontalPosAnchor = e.x;
1699
- const r = {
1700
- left: e.left + e.width / 2,
1843
+ const t = this.ttEditor.view.dom.firstChild.getBoundingClientRect();
1844
+ this.horizontalPosAnchor = t.x;
1845
+ const n = {
1846
+ left: t.left + t.width / 2,
1701
1847
  // take middle of editor
1702
- top: t.clientY
1703
- }, n = yt(r, this.ttEditor.view);
1704
- if (!n || !this.editor.isEditable) {
1848
+ top: e.clientY
1849
+ }, r = It(n, this.ttEditor.view);
1850
+ if (!r || !this.editor.isEditable) {
1705
1851
  this.menuOpen && (this.menuOpen = !1, this.blockMenu.hide());
1706
1852
  return;
1707
1853
  }
1708
- this.menuOpen && ((a = this.hoveredBlock) != null && a.hasAttribute("data-id")) && ((s = this.hoveredBlock) == null ? void 0 : s.getAttribute("data-id")) === n.id || (this.hoveredBlock = n.node, !n.node.firstChild) || this.editor.isEditable && (this.menuOpen ? this.blockMenu.render(this.getDynamicParams(), !1) : (this.menuOpen = !0, this.blockMenu.render(this.getDynamicParams(), !0)));
1854
+ this.menuOpen && ((a = this.hoveredBlock) != null && a.hasAttribute("data-id")) && ((s = this.hoveredBlock) == null ? void 0 : s.getAttribute("data-id")) === r.id || (this.hoveredBlock = r.node, !r.node.firstChild) || this.editor.isEditable && (this.menuOpen ? this.blockMenu.render(this.getDynamicParams(), !1) : (this.menuOpen = !0, this.blockMenu.render(this.getDynamicParams(), !0)));
1709
1855
  });
1710
- u(this, "onScroll", () => {
1856
+ h(this, "onScroll", () => {
1711
1857
  this.menuOpen && this.blockMenu.render(this.getDynamicParams(), !1);
1712
1858
  });
1713
- this.editor = e, this.ttEditor = t, this.horizontalPosAnchoredAtRoot = n, this.horizontalPosAnchor = this.ttEditor.view.dom.firstChild.getBoundingClientRect().x, this.blockMenu = r(this.getStaticParams()), document.body.addEventListener("drop", this.onDrop, !0), document.body.addEventListener("dragover", this.onDragOver), this.ttEditor.view.dom.addEventListener("dragstart", this.onDragStart), document.body.addEventListener("mousemove", this.onMouseMove, !0), document.addEventListener("scroll", this.onScroll), document.body.addEventListener("mousedown", this.onMouseDown, !0), document.body.addEventListener("keydown", this.onKeyDown, !0);
1859
+ this.editor = t, this.ttEditor = e, this.horizontalPosAnchoredAtRoot = r, this.horizontalPosAnchor = this.ttEditor.view.dom.firstChild.getBoundingClientRect().x, this.blockMenu = n(this.getStaticParams()), document.body.addEventListener("drop", this.onDrop, !0), document.body.addEventListener("dragover", this.onDragOver), this.ttEditor.view.dom.addEventListener("dragstart", this.onDragStart), document.body.addEventListener("mousemove", this.onMouseMove, !0), document.addEventListener("scroll", this.onScroll), document.body.addEventListener("mousedown", this.onMouseDown, !0), document.body.addEventListener("keydown", this.onKeyDown, !0);
1714
1860
  }
1715
1861
  destroy() {
1716
1862
  this.menuOpen && (this.menuOpen = !1, this.blockMenu.hide()), document.body.removeEventListener("mousemove", this.onMouseMove), document.body.removeEventListener("dragover", this.onDragOver), this.ttEditor.view.dom.removeEventListener("dragstart", this.onDragStart), document.body.removeEventListener("drop", this.onDrop), document.body.removeEventListener("mousedown", this.onMouseDown), document.removeEventListener("scroll", this.onScroll), document.body.removeEventListener("keydown", this.onKeyDown);
1717
1863
  }
1718
1864
  addBlock() {
1719
1865
  this.menuOpen = !1, this.menuFrozen = !0, this.blockMenu.hide();
1720
- const e = this.hoveredBlock.firstChild.getBoundingClientRect(), r = this.ttEditor.view.posAtCoords({
1721
- left: e.left + e.width / 2,
1722
- top: e.top + e.height / 2
1866
+ const t = this.hoveredBlock.firstChild.getBoundingClientRect(), n = this.ttEditor.view.posAtCoords({
1867
+ left: t.left + t.width / 2,
1868
+ top: t.top + t.height / 2
1723
1869
  });
1724
- if (!r)
1870
+ if (!n)
1725
1871
  return;
1726
- const n = g(this.ttEditor.state.doc, r.pos);
1727
- if (n === void 0)
1872
+ const r = g(this.ttEditor.state.doc, n.pos);
1873
+ if (r === void 0)
1728
1874
  return;
1729
- const { contentNode: i, endPos: a } = n;
1875
+ const { contentNode: i, endPos: a } = r;
1730
1876
  if (i.textContent.length !== 0) {
1731
1877
  const s = a + 1, l = s + 2;
1732
1878
  this.ttEditor.chain().BNCreateBlock(s).BNUpdateBlock(l, { type: "paragraph", props: {} }).setTextSelection(l).run();
1733
1879
  } else
1734
1880
  this.ttEditor.commands.setTextSelection(a);
1735
1881
  this.ttEditor.view.focus(), this.ttEditor.view.dispatch(
1736
- this.ttEditor.view.state.tr.scrollIntoView().setMeta(V, {
1882
+ this.ttEditor.view.state.tr.scrollIntoView().setMeta(X, {
1737
1883
  // TODO import suggestion plugin key
1738
1884
  activate: !0,
1739
1885
  type: "drag"
@@ -1744,10 +1890,10 @@ class $e {
1744
1890
  return {
1745
1891
  editor: this.editor,
1746
1892
  addBlock: () => this.addBlock(),
1747
- blockDragStart: (t) => {
1748
- this.isDragging = !0, Ue(t, this.ttEditor.view);
1893
+ blockDragStart: (e) => {
1894
+ this.isDragging = !0, Je(e, this.ttEditor.view);
1749
1895
  },
1750
- blockDragEnd: () => bt(),
1896
+ blockDragEnd: () => _t(),
1751
1897
  freezeMenu: () => {
1752
1898
  this.menuFrozen = !0;
1753
1899
  },
@@ -1757,27 +1903,27 @@ class $e {
1757
1903
  };
1758
1904
  }
1759
1905
  getDynamicParams() {
1760
- const e = this.hoveredBlock.firstChild.getBoundingClientRect();
1906
+ const t = this.hoveredBlock.firstChild.getBoundingClientRect();
1761
1907
  return {
1762
1908
  block: this.editor.getBlock(this.hoveredBlock.getAttribute("data-id")),
1763
1909
  referenceRect: new DOMRect(
1764
- this.horizontalPosAnchoredAtRoot ? this.horizontalPosAnchor : e.x,
1765
- e.y,
1766
- e.width,
1767
- e.height
1910
+ this.horizontalPosAnchoredAtRoot ? this.horizontalPosAnchor : t.x,
1911
+ t.y,
1912
+ t.width,
1913
+ t.height
1768
1914
  )
1769
1915
  };
1770
1916
  }
1771
1917
  }
1772
- const Ge = (o) => new C({
1773
- key: new v("DraggableBlocksPlugin"),
1774
- view: () => new $e({
1918
+ const Ze = (o) => new C({
1919
+ key: new E("DraggableBlocksPlugin"),
1920
+ view: () => new Xe({
1775
1921
  tiptapEditor: o.tiptapEditor,
1776
1922
  editor: o.editor,
1777
1923
  blockMenuFactory: o.blockSideMenuFactory,
1778
1924
  horizontalPosAnchoredAtRoot: !0
1779
1925
  })
1780
- }), qe = E.create({
1926
+ }), Qe = () => v.create({
1781
1927
  name: "DraggableBlocksExtension",
1782
1928
  priority: 1e3,
1783
1929
  // Need to be high, in order to hide menu when typing slash
@@ -1787,7 +1933,7 @@ const Ge = (o) => new C({
1787
1933
  "UI Element factory not defined for DraggableBlocksExtension"
1788
1934
  );
1789
1935
  return [
1790
- Ge({
1936
+ Ze({
1791
1937
  tiptapEditor: this.editor,
1792
1938
  editor: this.options.editor,
1793
1939
  blockSideMenuFactory: this.options.blockSideMenuFactory
@@ -1795,82 +1941,79 @@ const Ge = (o) => new C({
1795
1941
  ];
1796
1942
  }
1797
1943
  });
1798
- class je {
1944
+ class to {
1799
1945
  constructor({
1800
- editor: t,
1801
- tiptapEditor: e,
1802
- formattingToolbarFactory: r,
1803
- view: n,
1804
- shouldShow: i
1946
+ editor: e,
1947
+ tiptapEditor: t,
1948
+ formattingToolbarFactory: n,
1949
+ view: r
1805
1950
  }) {
1806
- u(this, "editor");
1807
- u(this, "ttEditor");
1808
- u(this, "view");
1809
- u(this, "formattingToolbar");
1810
- u(this, "preventHide", !1);
1811
- u(this, "preventShow", !1);
1812
- u(this, "toolbarIsOpen", !1);
1813
- u(this, "prevWasEditable", null);
1814
- u(this, "shouldShow", ({ view: t, state: e, from: r, to: n }) => {
1815
- const { doc: i, selection: a } = e, { empty: s } = a, l = !i.textBetween(r, n).length && St(e.selection);
1816
- return !(!t.hasFocus() || s || l);
1951
+ h(this, "editor");
1952
+ h(this, "ttEditor");
1953
+ h(this, "view");
1954
+ h(this, "formattingToolbar");
1955
+ h(this, "preventHide", !1);
1956
+ h(this, "preventShow", !1);
1957
+ h(this, "toolbarIsOpen", !1);
1958
+ h(this, "prevWasEditable", null);
1959
+ h(this, "shouldShow", ({ view: e, state: t, from: n, to: r }) => {
1960
+ const { doc: i, selection: a } = t, { empty: s } = a, l = !i.textBetween(n, r).length && Ft(t.selection);
1961
+ return !(!e.hasFocus() || s || l);
1817
1962
  });
1818
- u(this, "viewMousedownHandler", () => {
1963
+ h(this, "viewMousedownHandler", () => {
1819
1964
  this.preventShow = !0;
1820
1965
  });
1821
- u(this, "viewMouseupHandler", () => {
1966
+ h(this, "viewMouseupHandler", () => {
1822
1967
  this.preventShow = !1, setTimeout(() => this.update(this.ttEditor.view));
1823
1968
  });
1824
- u(this, "dragstartHandler", () => {
1969
+ h(this, "dragstartHandler", () => {
1825
1970
  this.formattingToolbar.hide(), this.toolbarIsOpen = !1;
1826
1971
  });
1827
- u(this, "focusHandler", () => {
1972
+ h(this, "focusHandler", () => {
1828
1973
  setTimeout(() => this.update(this.ttEditor.view));
1829
1974
  });
1830
- u(this, "blurHandler", ({ event: t }) => {
1831
- var e, r;
1975
+ h(this, "blurHandler", ({ event: e }) => {
1976
+ var t, n;
1832
1977
  if (this.preventHide) {
1833
1978
  this.preventHide = !1;
1834
1979
  return;
1835
1980
  }
1836
- t != null && t.relatedTarget && ((r = (e = this.formattingToolbar.element) == null ? void 0 : e.parentNode) != null && r.contains(
1837
- t.relatedTarget
1981
+ e != null && e.relatedTarget && ((n = (t = this.formattingToolbar.element) == null ? void 0 : t.parentNode) != null && n.contains(
1982
+ e.relatedTarget
1838
1983
  )) || this.toolbarIsOpen && (this.formattingToolbar.hide(), this.toolbarIsOpen = !1);
1839
1984
  });
1840
- u(this, "scrollHandler", () => {
1985
+ h(this, "scrollHandler", () => {
1841
1986
  this.toolbarIsOpen && this.formattingToolbar.render(this.getDynamicParams(), !1);
1842
1987
  });
1843
- this.editor = t, this.ttEditor = e, this.view = n, this.formattingToolbar = r(this.getStaticParams()), i && (this.shouldShow = i), this.view.dom.addEventListener("mousedown", this.viewMousedownHandler), this.view.dom.addEventListener("mouseup", this.viewMouseupHandler), this.view.dom.addEventListener("dragstart", this.dragstartHandler), this.ttEditor.on("focus", this.focusHandler), this.ttEditor.on("blur", this.blurHandler), document.addEventListener("scroll", this.scrollHandler);
1988
+ this.editor = e, this.ttEditor = t, this.view = r, this.formattingToolbar = n(this.getStaticParams()), this.view.dom.addEventListener("mousedown", this.viewMousedownHandler), this.view.dom.addEventListener("mouseup", this.viewMouseupHandler), this.view.dom.addEventListener("dragstart", this.dragstartHandler), this.ttEditor.on("focus", this.focusHandler), this.ttEditor.on("blur", this.blurHandler), document.addEventListener("scroll", this.scrollHandler);
1844
1989
  }
1845
- update(t, e) {
1846
- var f;
1847
- const { state: r, composing: n } = t, { doc: i, selection: a } = r, s = e && e.doc.eq(i) && e.selection.eq(a);
1848
- if ((this.prevWasEditable === null || this.prevWasEditable === this.editor.isEditable) && (n || s))
1990
+ update(e, t) {
1991
+ var p;
1992
+ const { state: n, composing: r } = e, { doc: i, selection: a } = n, s = t && t.doc.eq(i) && t.selection.eq(a);
1993
+ if ((this.prevWasEditable === null || this.prevWasEditable === this.editor.isEditable) && (r || s))
1849
1994
  return;
1850
1995
  this.prevWasEditable = this.editor.isEditable;
1851
- const { ranges: l } = a, d = Math.min(...l.map((p) => p.$from.pos)), c = Math.max(...l.map((p) => p.$to.pos)), h = (f = this.shouldShow) == null ? void 0 : f.call(this, {
1852
- editor: this.editor,
1853
- view: t,
1854
- state: r,
1855
- oldState: e,
1996
+ const { ranges: l } = a, d = Math.min(...l.map((m) => m.$from.pos)), c = Math.max(...l.map((m) => m.$to.pos)), u = (p = this.shouldShow) == null ? void 0 : p.call(this, {
1997
+ view: e,
1998
+ state: n,
1856
1999
  from: d,
1857
2000
  to: c
1858
2001
  });
1859
- if (this.editor.isEditable && !this.toolbarIsOpen && !this.preventShow && (h || this.preventHide)) {
2002
+ if (this.editor.isEditable && !this.toolbarIsOpen && !this.preventShow && (u || this.preventHide)) {
1860
2003
  this.formattingToolbar.render(this.getDynamicParams(), !0), this.toolbarIsOpen = !0, this.formattingToolbar.element.addEventListener(
1861
2004
  "mousedown",
1862
- (p) => p.preventDefault()
2005
+ (m) => m.preventDefault()
1863
2006
  );
1864
2007
  return;
1865
2008
  }
1866
- if (this.toolbarIsOpen && !this.preventShow && (h || this.preventHide)) {
2009
+ if (this.toolbarIsOpen && !this.preventShow && (u || this.preventHide)) {
1867
2010
  this.formattingToolbar.render(this.getDynamicParams(), !1);
1868
2011
  return;
1869
2012
  }
1870
- if (this.toolbarIsOpen && !this.preventHide && (!h || this.preventShow || !this.editor.isEditable)) {
2013
+ if (this.toolbarIsOpen && !this.preventHide && (!u || this.preventShow || !this.editor.isEditable)) {
1871
2014
  this.formattingToolbar.hide(), this.toolbarIsOpen = !1, this.formattingToolbar.element.removeEventListener(
1872
2015
  "mousedown",
1873
- (p) => p.preventDefault()
2016
+ (m) => m.preventDefault()
1874
2017
  );
1875
2018
  return;
1876
2019
  }
@@ -1879,13 +2022,13 @@ class je {
1879
2022
  this.view.dom.removeEventListener("mousedown", this.viewMousedownHandler), this.view.dom.removeEventListener("mouseup", this.viewMouseupHandler), this.view.dom.removeEventListener("dragstart", this.dragstartHandler), this.ttEditor.off("focus", this.focusHandler), this.ttEditor.off("blur", this.blurHandler), document.removeEventListener("scroll", this.scrollHandler);
1880
2023
  }
1881
2024
  getSelectionBoundingBox() {
1882
- const { state: t } = this.ttEditor.view, { selection: e } = t, { ranges: r } = e, n = Math.min(...r.map((a) => a.$from.pos)), i = Math.max(...r.map((a) => a.$to.pos));
1883
- if (xt(e)) {
1884
- const a = this.ttEditor.view.nodeDOM(n);
2025
+ const { state: e } = this.ttEditor.view, { selection: t } = e, { ranges: n } = t, r = Math.min(...n.map((a) => a.$from.pos)), i = Math.max(...n.map((a) => a.$to.pos));
2026
+ if (Rt(t)) {
2027
+ const a = this.ttEditor.view.nodeDOM(r);
1885
2028
  if (a)
1886
2029
  return a.getBoundingClientRect();
1887
2030
  }
1888
- return nt(this.ttEditor.view, n, i);
2031
+ return st(this.ttEditor.view, r, i);
1889
2032
  }
1890
2033
  getStaticParams() {
1891
2034
  return {
@@ -1898,10 +2041,10 @@ class je {
1898
2041
  };
1899
2042
  }
1900
2043
  }
1901
- const We = (o) => new C({
1902
- key: new v("FormattingToolbarPlugin"),
1903
- view: (t) => new je({ view: t, ...o })
1904
- }), Ye = E.create({
2044
+ const eo = (o) => new C({
2045
+ key: new E("FormattingToolbarPlugin"),
2046
+ view: (e) => new to({ view: e, ...o })
2047
+ }), oo = () => v.create({
1905
2048
  name: "FormattingToolbarExtension",
1906
2049
  addProseMirrorPlugins() {
1907
2050
  if (!this.options.formattingToolbarFactory || !this.options.editor)
@@ -1909,37 +2052,37 @@ const We = (o) => new C({
1909
2052
  "required args not defined for FormattingToolbarExtension"
1910
2053
  );
1911
2054
  return [
1912
- We({
2055
+ eo({
1913
2056
  tiptapEditor: this.editor,
1914
2057
  editor: this.options.editor,
1915
2058
  formattingToolbarFactory: this.options.formattingToolbarFactory,
1916
- pluginKey: new v("FormattingToolbarPlugin")
2059
+ pluginKey: new E("FormattingToolbarPlugin")
1917
2060
  })
1918
2061
  ];
1919
2062
  }
1920
- }), Ke = new v("HyperlinkToolbarPlugin");
1921
- class Ve {
1922
- constructor({ editor: t, hyperlinkToolbarFactory: e }) {
1923
- u(this, "editor");
1924
- u(this, "hyperlinkToolbar");
1925
- u(this, "menuUpdateTimer");
1926
- u(this, "startMenuUpdateTimer");
1927
- u(this, "stopMenuUpdateTimer");
1928
- u(this, "mouseHoveredHyperlinkMark");
1929
- u(this, "mouseHoveredHyperlinkMarkRange");
1930
- u(this, "keyboardHoveredHyperlinkMark");
1931
- u(this, "keyboardHoveredHyperlinkMarkRange");
1932
- u(this, "hyperlinkMark");
1933
- u(this, "hyperlinkMarkRange");
1934
- u(this, "mouseOverHandler", (t) => {
1935
- if (this.mouseHoveredHyperlinkMark = void 0, this.mouseHoveredHyperlinkMarkRange = void 0, this.stopMenuUpdateTimer(), t.target instanceof HTMLAnchorElement && t.target.nodeName === "A") {
1936
- const e = t.target, r = this.editor.view.posAtDOM(e, 0) + 1, n = this.editor.state.doc.resolve(
1937
- r
1938
- ), i = n.marks();
2063
+ }), no = new E("HyperlinkToolbarPlugin");
2064
+ class ro {
2065
+ constructor({ editor: e, hyperlinkToolbarFactory: t }) {
2066
+ h(this, "editor");
2067
+ h(this, "hyperlinkToolbar");
2068
+ h(this, "menuUpdateTimer");
2069
+ h(this, "startMenuUpdateTimer");
2070
+ h(this, "stopMenuUpdateTimer");
2071
+ h(this, "mouseHoveredHyperlinkMark");
2072
+ h(this, "mouseHoveredHyperlinkMarkRange");
2073
+ h(this, "keyboardHoveredHyperlinkMark");
2074
+ h(this, "keyboardHoveredHyperlinkMarkRange");
2075
+ h(this, "hyperlinkMark");
2076
+ h(this, "hyperlinkMarkRange");
2077
+ h(this, "mouseOverHandler", (e) => {
2078
+ if (this.mouseHoveredHyperlinkMark = void 0, this.mouseHoveredHyperlinkMarkRange = void 0, this.stopMenuUpdateTimer(), e.target instanceof HTMLAnchorElement && e.target.nodeName === "A") {
2079
+ const t = e.target, n = this.editor.view.posAtDOM(t, 0) + 1, r = this.editor.state.doc.resolve(
2080
+ n
2081
+ ), i = r.marks();
1939
2082
  for (const a of i)
1940
2083
  if (a.type.name === this.editor.schema.mark("link").type.name) {
1941
- this.mouseHoveredHyperlinkMark = a, this.mouseHoveredHyperlinkMarkRange = X(
1942
- n,
2084
+ this.mouseHoveredHyperlinkMark = a, this.mouseHoveredHyperlinkMarkRange = Q(
2085
+ r,
1943
2086
  a.type,
1944
2087
  a.attrs
1945
2088
  ) || void 0;
@@ -1948,25 +2091,25 @@ class Ve {
1948
2091
  }
1949
2092
  return this.startMenuUpdateTimer(), !1;
1950
2093
  });
1951
- u(this, "scrollHandler", () => {
2094
+ h(this, "scrollHandler", () => {
1952
2095
  this.hyperlinkMark !== void 0 && this.hyperlinkToolbar.render(this.getDynamicParams(), !1);
1953
2096
  });
1954
- this.editor = t, this.hyperlinkToolbar = e(this.getStaticParams()), this.startMenuUpdateTimer = () => {
2097
+ this.editor = e, this.hyperlinkToolbar = t(this.getStaticParams()), this.startMenuUpdateTimer = () => {
1955
2098
  this.menuUpdateTimer = setTimeout(() => {
1956
2099
  this.update();
1957
2100
  }, 250);
1958
2101
  }, this.stopMenuUpdateTimer = () => (this.menuUpdateTimer && (clearTimeout(this.menuUpdateTimer), this.menuUpdateTimer = void 0), !1), this.editor.view.dom.addEventListener("mouseover", this.mouseOverHandler), document.addEventListener("scroll", this.scrollHandler);
1959
2102
  }
1960
2103
  update() {
1961
- var e, r, n, i;
2104
+ var t, n, r, i;
1962
2105
  if (!this.editor.view.hasFocus())
1963
2106
  return;
1964
- const t = this.hyperlinkMark;
2107
+ const e = this.hyperlinkMark;
1965
2108
  if (this.hyperlinkMark = void 0, this.hyperlinkMarkRange = void 0, this.keyboardHoveredHyperlinkMark = void 0, this.keyboardHoveredHyperlinkMarkRange = void 0, this.editor.state.selection.empty) {
1966
2109
  const a = this.editor.state.selection.$from.marks();
1967
2110
  for (const s of a)
1968
2111
  if (s.type.name === this.editor.schema.mark("link").type.name) {
1969
- this.keyboardHoveredHyperlinkMark = s, this.keyboardHoveredHyperlinkMarkRange = X(
2112
+ this.keyboardHoveredHyperlinkMark = s, this.keyboardHoveredHyperlinkMarkRange = Q(
1970
2113
  this.editor.state.selection.$from,
1971
2114
  s.type,
1972
2115
  s.attrs
@@ -1975,11 +2118,11 @@ class Ve {
1975
2118
  }
1976
2119
  }
1977
2120
  if (this.mouseHoveredHyperlinkMark && (this.hyperlinkMark = this.mouseHoveredHyperlinkMark, this.hyperlinkMarkRange = this.mouseHoveredHyperlinkMarkRange), this.keyboardHoveredHyperlinkMark && (this.hyperlinkMark = this.keyboardHoveredHyperlinkMark, this.hyperlinkMarkRange = this.keyboardHoveredHyperlinkMarkRange), this.hyperlinkMark && this.editor.isEditable) {
1978
- if (this.getDynamicParams(), !t) {
1979
- this.hyperlinkToolbar.render(this.getDynamicParams(), !0), (e = this.hyperlinkToolbar.element) == null || e.addEventListener(
2121
+ if (this.getDynamicParams(), !e) {
2122
+ this.hyperlinkToolbar.render(this.getDynamicParams(), !0), (t = this.hyperlinkToolbar.element) == null || t.addEventListener(
1980
2123
  "mouseleave",
1981
2124
  this.startMenuUpdateTimer
1982
- ), (r = this.hyperlinkToolbar.element) == null || r.addEventListener(
2125
+ ), (n = this.hyperlinkToolbar.element) == null || n.addEventListener(
1983
2126
  "mouseenter",
1984
2127
  this.stopMenuUpdateTimer
1985
2128
  );
@@ -1988,8 +2131,8 @@ class Ve {
1988
2131
  this.hyperlinkToolbar.render(this.getDynamicParams(), !1);
1989
2132
  return;
1990
2133
  }
1991
- if (t && (!this.hyperlinkMark || !this.editor.isEditable)) {
1992
- (n = this.hyperlinkToolbar.element) == null || n.removeEventListener(
2134
+ if (e && (!this.hyperlinkMark || !this.editor.isEditable)) {
2135
+ (r = this.hyperlinkToolbar.element) == null || r.removeEventListener(
1993
2136
  "mouseleave",
1994
2137
  this.startMenuUpdateTimer
1995
2138
  ), (i = this.hyperlinkToolbar.element) == null || i.removeEventListener(
@@ -2007,17 +2150,17 @@ class Ve {
2007
2150
  }
2008
2151
  getStaticParams() {
2009
2152
  return {
2010
- editHyperlink: (t, e) => {
2011
- const r = this.editor.view.state.tr.insertText(
2012
- e,
2153
+ editHyperlink: (e, t) => {
2154
+ const n = this.editor.view.state.tr.insertText(
2155
+ t,
2013
2156
  this.hyperlinkMarkRange.from,
2014
2157
  this.hyperlinkMarkRange.to
2015
2158
  );
2016
- r.addMark(
2159
+ n.addMark(
2017
2160
  this.hyperlinkMarkRange.from,
2018
- this.hyperlinkMarkRange.from + e.length,
2019
- this.editor.schema.mark("link", { href: t })
2020
- ), this.editor.view.dispatch(r), this.editor.view.focus(), this.hyperlinkToolbar.hide();
2161
+ this.hyperlinkMarkRange.from + t.length,
2162
+ this.editor.schema.mark("link", { href: e })
2163
+ ), this.editor.view.dispatch(n), this.editor.view.focus(), this.hyperlinkToolbar.hide();
2021
2164
  },
2022
2165
  deleteHyperlink: () => {
2023
2166
  this.editor.view.dispatch(
@@ -2037,7 +2180,7 @@ class Ve {
2037
2180
  this.hyperlinkMarkRange.from,
2038
2181
  this.hyperlinkMarkRange.to
2039
2182
  ),
2040
- referenceRect: nt(
2183
+ referenceRect: st(
2041
2184
  this.editor.view,
2042
2185
  this.hyperlinkMarkRange.from,
2043
2186
  this.hyperlinkMarkRange.to
@@ -2045,13 +2188,13 @@ class Ve {
2045
2188
  };
2046
2189
  }
2047
2190
  }
2048
- const Je = (o, t) => new C({
2049
- key: Ke,
2050
- view: () => new Ve({
2191
+ const io = (o, e) => new C({
2192
+ key: no,
2193
+ view: () => new ro({
2051
2194
  editor: o,
2052
- hyperlinkToolbarFactory: t.hyperlinkToolbarFactory
2195
+ hyperlinkToolbarFactory: e.hyperlinkToolbarFactory
2053
2196
  })
2054
- }), Xe = lt.extend({
2197
+ }), so = ct.extend({
2055
2198
  priority: 500,
2056
2199
  addProseMirrorPlugins() {
2057
2200
  var o;
@@ -2059,12 +2202,12 @@ const Je = (o, t) => new C({
2059
2202
  throw new Error("UI Element factory not defined for HyperlinkMark");
2060
2203
  return [
2061
2204
  ...((o = this.parent) == null ? void 0 : o.call(this)) || [],
2062
- Je(this.editor, {
2205
+ io(this.editor, {
2063
2206
  hyperlinkToolbarFactory: this.options.hyperlinkToolbarFactory
2064
2207
  })
2065
2208
  ];
2066
2209
  }
2067
- }), Qe = new v("blocknote-placeholder"), Ze = E.create({
2210
+ }), ao = new E("blocknote-placeholder"), lo = v.create({
2068
2211
  name: "placeholder",
2069
2212
  addOptions() {
2070
2213
  return {
@@ -2081,35 +2224,35 @@ const Je = (o, t) => new C({
2081
2224
  addProseMirrorPlugins() {
2082
2225
  return [
2083
2226
  new C({
2084
- key: Qe,
2227
+ key: ao,
2085
2228
  props: {
2086
2229
  decorations: (o) => {
2087
- const { doc: t, selection: e } = o, r = V.getState(o), n = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = e, a = [];
2088
- if (n)
2089
- return t.descendants((s, l) => {
2230
+ const { doc: e, selection: t } = o, n = X.getState(o), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = t, a = [];
2231
+ if (r)
2232
+ return e.descendants((s, l) => {
2090
2233
  const d = i >= l && i <= l + s.nodeSize, c = !s.isLeaf && !s.childCount;
2091
2234
  if ((d || !this.options.showOnlyCurrent) && c) {
2092
- const h = [this.options.emptyNodeClass];
2093
- this.editor.isEmpty && h.push(this.options.emptyEditorClass), d && h.push(this.options.hasAnchorClass), (r == null ? void 0 : r.triggerCharacter) === "" && (r != null && r.active) && h.push(this.options.isFilterClass);
2094
- const f = D.node(l, l + s.nodeSize, {
2095
- class: h.join(" ")
2235
+ const u = [this.options.emptyNodeClass];
2236
+ this.editor.isEmpty && u.push(this.options.emptyEditorClass), d && u.push(this.options.hasAnchorClass), (n == null ? void 0 : n.triggerCharacter) === "" && (n != null && n.active) && u.push(this.options.isFilterClass);
2237
+ const p = D.node(l, l + s.nodeSize, {
2238
+ class: u.join(" ")
2096
2239
  });
2097
- a.push(f);
2240
+ a.push(p);
2098
2241
  }
2099
2242
  return this.options.includeChildren;
2100
- }), F.create(t, a);
2243
+ }), F.create(e, a);
2101
2244
  }
2102
2245
  }
2103
2246
  })
2104
2247
  ];
2105
2248
  }
2106
2249
  });
2107
- class to {
2108
- constructor(t, e) {
2109
- this.name = t, this.match = e;
2250
+ class co {
2251
+ constructor(e, t) {
2252
+ this.name = e, this.match = t;
2110
2253
  }
2111
2254
  }
2112
- class x extends to {
2255
+ class S extends co {
2113
2256
  /**
2114
2257
  * Constructs a new slash-command.
2115
2258
  *
@@ -2117,64 +2260,64 @@ class x extends to {
2117
2260
  * @param execute The callback for creating a new node
2118
2261
  * @param aliases Aliases for this command
2119
2262
  */
2120
- constructor(t, e, r = []) {
2121
- super(t, (n) => this.name.toLowerCase().startsWith(n.toLowerCase()) || this.aliases.filter(
2122
- (i) => i.toLowerCase().startsWith(n.toLowerCase())
2123
- ).length !== 0), this.name = t, this.execute = e, this.aliases = r;
2263
+ constructor(e, t, n = []) {
2264
+ super(e, (r) => this.name.toLowerCase().startsWith(r.toLowerCase()) || this.aliases.filter(
2265
+ (i) => i.toLowerCase().startsWith(r.toLowerCase())
2266
+ ).length !== 0), this.name = e, this.execute = t, this.aliases = n;
2124
2267
  }
2125
2268
  }
2126
- function I(o, t) {
2127
- const e = o.getTextCursorPosition().block;
2128
- e.content.length === 1 && e.content[0].type === "text" && e.content[0].text === "/" || e.content.length === 0 ? o.updateBlock(e, t) : (o.insertBlocks([t], e, "after"), o.setTextCursorPosition(o.getTextCursorPosition().nextBlock));
2269
+ function x(o, e) {
2270
+ const t = o.getTextCursorPosition().block;
2271
+ t.content.length === 1 && t.content[0].type === "text" && t.content[0].text === "/" || t.content.length === 0 ? o.updateBlock(t, e) : (o.insertBlocks([e], t, "after"), o.setTextCursorPosition(o.getTextCursorPosition().nextBlock));
2129
2272
  }
2130
- const eo = [
2273
+ const uo = [
2131
2274
  // Command for creating a level 1 heading
2132
- new x(
2275
+ new S(
2133
2276
  "Heading",
2134
- (o) => I(o, {
2277
+ (o) => x(o, {
2135
2278
  type: "heading",
2136
2279
  props: { level: "1" }
2137
2280
  }),
2138
2281
  ["h", "heading1", "h1"]
2139
2282
  ),
2140
2283
  // Command for creating a level 2 heading
2141
- new x(
2284
+ new S(
2142
2285
  "Heading 2",
2143
- (o) => I(o, {
2286
+ (o) => x(o, {
2144
2287
  type: "heading",
2145
2288
  props: { level: "2" }
2146
2289
  }),
2147
2290
  ["h2", "heading2", "subheading"]
2148
2291
  ),
2149
2292
  // Command for creating a level 3 heading
2150
- new x(
2293
+ new S(
2151
2294
  "Heading 3",
2152
- (o) => I(o, {
2295
+ (o) => x(o, {
2153
2296
  type: "heading",
2154
2297
  props: { level: "3" }
2155
2298
  }),
2156
2299
  ["h3", "heading3", "subheading"]
2157
2300
  ),
2158
2301
  // Command for creating an ordered list
2159
- new x(
2302
+ new S(
2160
2303
  "Numbered List",
2161
- (o) => I(o, {
2304
+ (o) => x(o, {
2162
2305
  type: "numberedListItem"
2163
2306
  }),
2164
2307
  ["li", "list", "numberedlist", "numbered list"]
2165
2308
  ),
2166
2309
  // Command for creating a bullet list
2167
- new x(
2310
+ new S(
2168
2311
  "Bullet List",
2169
- (o) => I(o, {
2312
+ (o) => x(o, {
2170
2313
  type: "bulletListItem"
2171
2314
  }),
2172
2315
  ["ul", "list", "bulletlist", "bullet list"]
2173
2316
  ),
2174
2317
  // Command for creating a paragraph (pretty useless)
2175
- new x(
2318
+ new S(
2176
2319
  "Paragraph",
2177
- (o) => I(o, {
2320
+ (o) => x(o, {
2178
2321
  type: "paragraph"
2179
2322
  }),
2180
2323
  ["p"]
@@ -2270,7 +2413,7 @@ const eo = [
2270
2413
  // TableIcon,
2271
2414
  // "Used to create a simple table"
2272
2415
  // ),
2273
- ], oo = E.create({
2416
+ ], ho = v.create({
2274
2417
  name: "textAlignment",
2275
2418
  addGlobalAttributes() {
2276
2419
  return [
@@ -2292,23 +2435,23 @@ const eo = [
2292
2435
  },
2293
2436
  addCommands() {
2294
2437
  return {
2295
- setTextAlignment: (o) => ({ state: t }) => {
2296
- const e = [], r = g(
2297
- t.doc,
2298
- t.selection.from
2438
+ setTextAlignment: (o) => ({ state: e }) => {
2439
+ const t = [], n = g(
2440
+ e.doc,
2441
+ e.selection.from
2299
2442
  );
2300
- if (r === void 0)
2443
+ if (n === void 0)
2301
2444
  return !1;
2302
- let n = r.startPos;
2303
- for (; n < t.selection.to; )
2304
- t.doc.resolve(n).node().type.spec.group === "blockContent" ? (e.push(n - 1), n += t.doc.resolve(n).node().nodeSize - 1) : n += 1;
2305
- for (const i of e)
2306
- t.tr.setNodeAttribute(i, "textAlignment", o);
2445
+ let r = n.startPos;
2446
+ for (; r < e.selection.to; )
2447
+ e.doc.resolve(r).node().type.spec.group === "blockContent" ? (t.push(r - 1), r += e.doc.resolve(r).node().nodeSize - 1) : r += 1;
2448
+ for (const i of t)
2449
+ e.tr.setNodeAttribute(i, "textAlignment", o);
2307
2450
  return !0;
2308
2451
  }
2309
2452
  };
2310
2453
  }
2311
- }), ro = E.create({
2454
+ }), po = v.create({
2312
2455
  name: "blockTextColor",
2313
2456
  addGlobalAttributes() {
2314
2457
  return [
@@ -2328,13 +2471,13 @@ const eo = [
2328
2471
  },
2329
2472
  addCommands() {
2330
2473
  return {
2331
- setBlockTextColor: (o, t) => ({ state: e, view: r }) => {
2332
- const n = g(e.doc, o);
2333
- return n === void 0 ? !1 : (e.tr.setNodeAttribute(n.startPos - 1, "textColor", t), r.focus(), !0);
2474
+ setBlockTextColor: (o, e) => ({ state: t, view: n }) => {
2475
+ const r = g(t.doc, o);
2476
+ return r === void 0 ? !1 : (t.tr.setNodeAttribute(r.startPos - 1, "textColor", e), n.focus(), !0);
2334
2477
  }
2335
2478
  };
2336
2479
  }
2337
- }), no = rt.create({
2480
+ }), mo = it.create({
2338
2481
  name: "textColor",
2339
2482
  addAttributes() {
2340
2483
  return {
@@ -2360,18 +2503,18 @@ const eo = [
2360
2503
  },
2361
2504
  addCommands() {
2362
2505
  return {
2363
- setTextColor: (o) => ({ commands: t }) => o !== "default" ? t.setMark(this.name, { color: o }) : t.unsetMark(this.name)
2506
+ setTextColor: (o) => ({ commands: e }) => o !== "default" ? e.setMark(this.name, { color: o }) : e.unsetMark(this.name)
2364
2507
  };
2365
2508
  }
2366
- }), io = E.create({
2509
+ }), fo = v.create({
2367
2510
  name: "trailingNode",
2368
2511
  addProseMirrorPlugins() {
2369
- const o = new v(this.name);
2512
+ const o = new E(this.name);
2370
2513
  return [
2371
2514
  new C({
2372
2515
  key: o,
2373
- appendTransaction: (t, e, r) => {
2374
- const { doc: n, tr: i, schema: a } = r, s = o.getState(r), l = n.content.size - 2, d = a.nodes.blockContainer, c = a.nodes.paragraph;
2516
+ appendTransaction: (e, t, n) => {
2517
+ const { doc: r, tr: i, schema: a } = n, s = o.getState(n), l = r.content.size - 2, d = a.nodes.blockContainer, c = a.nodes.paragraph;
2375
2518
  if (s)
2376
2519
  return i.insert(
2377
2520
  l,
@@ -2379,128 +2522,142 @@ const eo = [
2379
2522
  );
2380
2523
  },
2381
2524
  state: {
2382
- init: (t, e) => {
2525
+ init: (e, t) => {
2383
2526
  },
2384
- apply: (t, e) => {
2385
- if (!t.docChanged)
2386
- return e;
2387
- let r = t.doc.lastChild;
2388
- if (!r || r.type.name !== "blockGroup")
2527
+ apply: (e, t) => {
2528
+ if (!e.docChanged)
2529
+ return t;
2530
+ let n = e.doc.lastChild;
2531
+ if (!n || n.type.name !== "blockGroup")
2389
2532
  throw new Error("Expected blockGroup");
2390
- if (r = r.lastChild, !r || r.type.name !== "blockContainer")
2533
+ if (n = n.lastChild, !n || n.type.name !== "blockContainer")
2391
2534
  throw new Error("Expected blockContainer");
2392
- return r.nodeSize > 4;
2535
+ return n.nodeSize > 4;
2393
2536
  }
2394
2537
  }
2395
2538
  })
2396
2539
  ];
2397
2540
  }
2398
- }), so = (o) => {
2399
- const t = [
2400
- N.ClipboardTextSerializer,
2401
- N.Commands,
2402
- N.Editable,
2403
- N.FocusEvents,
2404
- N.Tabindex,
2541
+ }), go = (o) => {
2542
+ const e = [
2543
+ A.ClipboardTextSerializer,
2544
+ A.Commands,
2545
+ A.Editable,
2546
+ A.FocusEvents,
2547
+ A.Tabindex,
2405
2548
  // DevTools,
2406
- Gt,
2549
+ Qt,
2407
2550
  // DropCursor,
2408
- Ze.configure({
2409
- emptyNodeClass: b.isEmpty,
2410
- hasAnchorClass: b.hasAnchor,
2411
- isFilterClass: b.isFilter,
2551
+ lo.configure({
2552
+ emptyNodeClass: k.isEmpty,
2553
+ hasAnchorClass: k.hasAnchor,
2554
+ isFilterClass: k.isFilter,
2412
2555
  includeChildren: !0,
2413
2556
  showOnlyCurrent: !1
2414
2557
  }),
2415
- Y.configure({
2558
+ K.configure({
2416
2559
  types: ["blockContainer"]
2417
2560
  }),
2418
- qt,
2561
+ te,
2419
2562
  // Comments,
2420
2563
  // basics:
2421
- Kt,
2564
+ re,
2422
2565
  // marks:
2423
- Ft,
2424
- Rt,
2425
- Wt,
2426
2566
  Yt,
2427
- Vt,
2428
- no,
2429
- ro,
2430
- fe,
2431
- pe,
2432
- oo,
2567
+ Kt,
2568
+ oe,
2569
+ ne,
2570
+ ie,
2571
+ mo,
2572
+ po,
2573
+ Ne,
2574
+ Ae,
2575
+ ho,
2433
2576
  // custom blocks:
2434
- ...Ae,
2435
- $t.configure({ width: 5, color: "#ddeeff" }),
2577
+ ...ze,
2578
+ ...Object.values(o.blockSchema).map(
2579
+ (t) => t.node.configure({ editor: o.editor })
2580
+ ),
2581
+ $e,
2582
+ Zt.configure({ width: 5, color: "#ddeeff" }),
2436
2583
  // This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
2437
2584
  // should be handled before Enter handlers in other components like splitListItem
2438
- io
2585
+ fo
2439
2586
  ];
2440
2587
  if (o.collaboration) {
2441
- t.push(
2442
- zt.configure({
2588
+ e.push(
2589
+ Jt.configure({
2443
2590
  fragment: o.collaboration.fragment
2444
2591
  })
2445
2592
  );
2446
- const e = (r) => {
2447
- const n = document.createElement("span");
2448
- n.classList.add(_["collaboration-cursor__caret"]), n.setAttribute("style", `border-color: ${r.color}`);
2593
+ const t = (n) => {
2594
+ const r = document.createElement("span");
2595
+ r.classList.add(P["collaboration-cursor__caret"]), r.setAttribute("style", `border-color: ${n.color}`);
2449
2596
  const i = document.createElement("span");
2450
- i.classList.add(_["collaboration-cursor__label"]), i.setAttribute("style", `background-color: ${r.color}`), i.insertBefore(document.createTextNode(r.name), null);
2597
+ i.classList.add(P["collaboration-cursor__label"]), i.setAttribute("style", `background-color: ${n.color}`), i.insertBefore(document.createTextNode(n.name), null);
2451
2598
  const a = document.createTextNode("⁠"), s = document.createTextNode("⁠");
2452
- return n.insertBefore(a, null), n.insertBefore(i, null), n.insertBefore(s, null), n;
2599
+ return r.insertBefore(a, null), r.insertBefore(i, null), r.insertBefore(s, null), r;
2453
2600
  };
2454
- t.push(
2455
- Ut.configure({
2601
+ e.push(
2602
+ Xt.configure({
2456
2603
  user: o.collaboration.user,
2457
- render: o.collaboration.renderCursor || e,
2604
+ render: o.collaboration.renderCursor || t,
2458
2605
  provider: o.collaboration.provider
2459
2606
  })
2460
2607
  );
2461
2608
  } else
2462
- t.push(jt);
2463
- return o.uiFactories.blockSideMenuFactory && t.push(
2464
- qe.configure({
2609
+ e.push(ee);
2610
+ return o.uiFactories.blockSideMenuFactory && e.push(
2611
+ Qe().configure({
2465
2612
  editor: o.editor,
2466
2613
  blockSideMenuFactory: o.uiFactories.blockSideMenuFactory
2467
2614
  })
2468
- ), o.uiFactories.formattingToolbarFactory && t.push(
2469
- Ye.configure({
2615
+ ), o.uiFactories.formattingToolbarFactory && e.push(
2616
+ oo().configure({
2470
2617
  editor: o.editor,
2471
2618
  formattingToolbarFactory: o.uiFactories.formattingToolbarFactory
2472
2619
  })
2473
- ), o.uiFactories.hyperlinkToolbarFactory ? t.push(
2474
- Xe.configure({
2620
+ ), o.uiFactories.hyperlinkToolbarFactory ? e.push(
2621
+ so.configure({
2475
2622
  hyperlinkToolbarFactory: o.uiFactories.hyperlinkToolbarFactory
2476
2623
  })
2477
- ) : t.push(lt), o.uiFactories.slashMenuFactory && t.push(
2478
- De.configure({
2624
+ ) : e.push(ct), o.uiFactories.slashMenuFactory && e.push(
2625
+ We().configure({
2479
2626
  editor: o.editor,
2480
2627
  commands: o.slashCommands,
2481
2628
  slashMenuFactory: o.uiFactories.slashMenuFactory
2482
2629
  })
2483
- ), t;
2484
- }, ao = {
2630
+ ), e;
2631
+ }, ko = {
2485
2632
  enableInputRules: !0,
2486
2633
  enablePasteRules: !0,
2487
2634
  enableCoreExtensions: !1
2488
2635
  };
2489
- class Fo {
2490
- constructor(t = {}) {
2491
- u(this, "_tiptapEditor");
2492
- u(this, "blockCache", /* @__PURE__ */ new WeakMap());
2493
- var n, i, a;
2494
- this.options = t, t = {
2636
+ class Ko {
2637
+ constructor(e = {}) {
2638
+ h(this, "_tiptapEditor");
2639
+ h(this, "blockCache", /* @__PURE__ */ new WeakMap());
2640
+ h(this, "schema");
2641
+ var i, a, s;
2642
+ this.options = e;
2643
+ const t = {
2495
2644
  defaultStyles: !0,
2496
- ...t
2497
- };
2498
- const e = so({
2645
+ // TODO: There's a lot of annoying typing stuff to deal with here. If
2646
+ // BSchema is specified, then options.blockSchema should also be required.
2647
+ // If BSchema is not specified, then options.blockSchema should also not
2648
+ // be defined. Unfortunately, trying to implement these constraints seems
2649
+ // to be a huge pain, hence the `as any` casts.
2650
+ blockSchema: e.blockSchema || ge,
2651
+ ...e
2652
+ }, n = go({
2499
2653
  editor: this,
2500
2654
  uiFactories: t.uiFactories || {},
2501
- slashCommands: t.slashCommands || eo,
2655
+ slashCommands: t.slashCommands || uo,
2656
+ blockSchema: t.blockSchema,
2502
2657
  collaboration: t.collaboration
2503
- }), r = {
2658
+ });
2659
+ this.schema = t.blockSchema;
2660
+ const r = {
2504
2661
  // TODO: This approach to setting initial content is "cleaner" but requires the PM editor schema, which is only
2505
2662
  // created after initializing the TipTap editor. Not sure it's feasible.
2506
2663
  // content:
@@ -2508,36 +2665,36 @@ class Fo {
2508
2665
  // options.initialContent.map((block) =>
2509
2666
  // blockToNode(block, this._tiptapEditor.schema).toJSON()
2510
2667
  // ),
2511
- ...ao,
2668
+ ...ko,
2512
2669
  ...t._tiptapOptions,
2513
2670
  onCreate: () => {
2514
- var s;
2515
- (s = t.onEditorReady) == null || s.call(t, this), t.initialContent && this.replaceBlocks(this.topLevelBlocks, t.initialContent);
2671
+ var l;
2672
+ (l = t.onEditorReady) == null || l.call(t, this), t.initialContent && this.replaceBlocks(this.topLevelBlocks, t.initialContent);
2516
2673
  },
2517
2674
  onUpdate: () => {
2518
- var s;
2519
- (s = t.onEditorContentChange) == null || s.call(t, this);
2675
+ var l;
2676
+ (l = t.onEditorContentChange) == null || l.call(t, this);
2520
2677
  },
2521
2678
  onSelectionUpdate: () => {
2522
- var s;
2523
- (s = t.onTextCursorPositionChange) == null || s.call(t, this);
2679
+ var l;
2680
+ (l = t.onTextCursorPositionChange) == null || l.call(t, this);
2524
2681
  },
2525
- editable: t.editable === void 0 ? !0 : t.editable,
2526
- extensions: t.enableBlockNoteExtensions === !1 ? (n = t._tiptapOptions) == null ? void 0 : n.extensions : [...((i = t._tiptapOptions) == null ? void 0 : i.extensions) || [], ...e],
2682
+ editable: e.editable === void 0 ? !0 : e.editable,
2683
+ extensions: t.enableBlockNoteExtensions === !1 ? (i = t._tiptapOptions) == null ? void 0 : i.extensions : [...((a = t._tiptapOptions) == null ? void 0 : a.extensions) || [], ...n],
2527
2684
  editorProps: {
2528
2685
  attributes: {
2529
- "data-theme": t.theme || "light",
2686
+ "data-theme": e.theme || "light",
2530
2687
  ...t.editorDOMAttributes || {},
2531
2688
  class: [
2532
- _.bnEditor,
2533
- _.bnRoot,
2534
- t.defaultStyles ? _.defaultStyles : "",
2535
- ((a = t.editorDOMAttributes) == null ? void 0 : a.class) || ""
2689
+ P.bnEditor,
2690
+ P.bnRoot,
2691
+ t.defaultStyles ? P.defaultStyles : "",
2692
+ ((s = t.editorDOMAttributes) == null ? void 0 : s.class) || ""
2536
2693
  ].join(" ")
2537
2694
  }
2538
2695
  }
2539
2696
  };
2540
- t.parentElement && (r.element = t.parentElement), this._tiptapEditor = new It(r);
2697
+ t.parentElement && (r.element = t.parentElement), this._tiptapEditor = new zt(r);
2541
2698
  }
2542
2699
  get domElement() {
2543
2700
  return this._tiptapEditor.view.dom;
@@ -2550,55 +2707,62 @@ class Fo {
2550
2707
  * @returns A snapshot of all top-level (non-nested) blocks in the editor.
2551
2708
  */
2552
2709
  get topLevelBlocks() {
2553
- const t = [];
2554
- return this._tiptapEditor.state.doc.firstChild.descendants((e) => (t.push(B(e, this.blockCache)), !1)), t;
2710
+ const e = [];
2711
+ return this._tiptapEditor.state.doc.firstChild.descendants((t) => (e.push(B(t, this.schema, this.blockCache)), !1)), e;
2555
2712
  }
2556
2713
  /**
2557
2714
  * Gets a snapshot of an existing block from the editor.
2558
2715
  * @param blockIdentifier The identifier of an existing block that should be retrieved.
2559
2716
  * @returns The block that matches the identifier, or `undefined` if no matching block was found.
2560
2717
  */
2561
- getBlock(t) {
2562
- const e = typeof t == "string" ? t : t.id;
2563
- let r;
2564
- return this._tiptapEditor.state.doc.firstChild.descendants((n) => typeof r < "u" ? !1 : n.type.name !== "blockContainer" || n.attrs.id !== e ? !0 : (r = B(n, this.blockCache), !1)), r;
2718
+ getBlock(e) {
2719
+ const t = typeof e == "string" ? e : e.id;
2720
+ let n;
2721
+ return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof n < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== t ? !0 : (n = B(r, this.schema, this.blockCache), !1)), n;
2565
2722
  }
2566
2723
  /**
2567
2724
  * Traverses all blocks in the editor depth-first, and executes a callback for each.
2568
2725
  * @param callback The callback to execute for each block. Returning `false` stops the traversal.
2569
2726
  * @param reverse Whether the blocks should be traversed in reverse order.
2570
2727
  */
2571
- forEachBlock(t, e = !1) {
2572
- const r = this.topLevelBlocks.slice();
2573
- e && r.reverse();
2574
- function n(i) {
2728
+ forEachBlock(e, t = !1) {
2729
+ const n = this.topLevelBlocks.slice();
2730
+ t && n.reverse();
2731
+ function r(i) {
2575
2732
  for (const a of i) {
2576
- if (!t(a))
2733
+ if (!e(a))
2577
2734
  return !1;
2578
- const s = e ? a.children.slice().reverse() : a.children;
2579
- if (!n(s))
2735
+ const s = t ? a.children.slice().reverse() : a.children;
2736
+ if (!r(s))
2580
2737
  return !1;
2581
2738
  }
2582
2739
  return !0;
2583
2740
  }
2584
- n(r);
2741
+ r(n);
2742
+ }
2743
+ /**
2744
+ * Executes a callback whenever the editor's contents change.
2745
+ * @param callback The callback to execute.
2746
+ */
2747
+ onEditorContentChange(e) {
2748
+ this._tiptapEditor.on("update", e);
2585
2749
  }
2586
2750
  /**
2587
2751
  * Gets a snapshot of the current text cursor position.
2588
2752
  * @returns A snapshot of the current text cursor position.
2589
2753
  */
2590
2754
  getTextCursorPosition() {
2591
- const { node: t, depth: e, startPos: r, endPos: n } = g(
2755
+ const { node: e, depth: t, startPos: n, endPos: r } = g(
2592
2756
  this._tiptapEditor.state.doc,
2593
2757
  this._tiptapEditor.state.selection.from
2594
- ), i = this._tiptapEditor.state.doc.resolve(n).index(e - 1), a = this._tiptapEditor.state.doc.resolve(n + 1).node().childCount;
2758
+ ), i = this._tiptapEditor.state.doc.resolve(r).index(t - 1), a = this._tiptapEditor.state.doc.resolve(r + 1).node().childCount;
2595
2759
  let s;
2596
- i > 0 && (s = this._tiptapEditor.state.doc.resolve(r - 2).node());
2760
+ i > 0 && (s = this._tiptapEditor.state.doc.resolve(n - 2).node());
2597
2761
  let l;
2598
- return i < a - 1 && (l = this._tiptapEditor.state.doc.resolve(n + 2).node()), {
2599
- block: B(t, this.blockCache),
2600
- prevBlock: s === void 0 ? void 0 : B(s, this.blockCache),
2601
- nextBlock: l === void 0 ? void 0 : B(l, this.blockCache)
2762
+ return i < a - 1 && (l = this._tiptapEditor.state.doc.resolve(r + 2).node()), {
2763
+ block: B(e, this.schema, this.blockCache),
2764
+ prevBlock: s === void 0 ? void 0 : B(s, this.schema, this.blockCache),
2765
+ nextBlock: l === void 0 ? void 0 : B(l, this.schema, this.blockCache)
2602
2766
  };
2603
2767
  }
2604
2768
  /**
@@ -2607,12 +2771,12 @@ class Fo {
2607
2771
  * @param targetBlock The identifier of an existing block that the text cursor should be moved to.
2608
2772
  * @param placement Whether the text cursor should be placed at the start or end of the block.
2609
2773
  */
2610
- setTextCursorPosition(t, e = "start") {
2611
- const r = typeof t == "string" ? t : t.id, { posBeforeNode: n } = K(r, this._tiptapEditor.state.doc), { startPos: i, contentNode: a } = g(
2774
+ setTextCursorPosition(e, t = "start") {
2775
+ const n = typeof e == "string" ? e : e.id, { posBeforeNode: r } = J(n, this._tiptapEditor.state.doc), { startPos: i, contentNode: a } = g(
2612
2776
  this._tiptapEditor.state.doc,
2613
- n + 2
2777
+ r + 2
2614
2778
  );
2615
- e === "start" ? this._tiptapEditor.commands.setTextSelection(i + 1) : this._tiptapEditor.commands.setTextSelection(
2779
+ t === "start" ? this._tiptapEditor.commands.setTextSelection(i + 1) : this._tiptapEditor.commands.setTextSelection(
2616
2780
  i + a.nodeSize - 1
2617
2781
  );
2618
2782
  }
@@ -2622,13 +2786,14 @@ class Fo {
2622
2786
  getSelection() {
2623
2787
  if (this._tiptapEditor.state.selection.from === this._tiptapEditor.state.selection.to)
2624
2788
  return;
2625
- const t = [];
2626
- return this._tiptapEditor.state.doc.descendants((e, r) => e.type.spec.group !== "blockContent" || r + e.nodeSize < this._tiptapEditor.state.selection.from || r > this._tiptapEditor.state.selection.to ? !0 : (t.push(
2789
+ const e = [];
2790
+ return this._tiptapEditor.state.doc.descendants((t, n) => t.type.spec.group !== "blockContent" || n + t.nodeSize < this._tiptapEditor.state.selection.from || n > this._tiptapEditor.state.selection.to ? !0 : (e.push(
2627
2791
  B(
2628
- this._tiptapEditor.state.doc.resolve(r).node(),
2792
+ this._tiptapEditor.state.doc.resolve(n).node(),
2793
+ this.schema,
2629
2794
  this.blockCache
2630
2795
  )
2631
- ), !1)), { blocks: t };
2796
+ ), !1)), { blocks: e };
2632
2797
  }
2633
2798
  /**
2634
2799
  * Checks if the editor is currently editable, or if it's locked.
@@ -2641,8 +2806,8 @@ class Fo {
2641
2806
  * Makes the editor editable or locks it, depending on the argument passed.
2642
2807
  * @param editable True to make the editor editable, or false to lock it.
2643
2808
  */
2644
- set isEditable(t) {
2645
- this._tiptapEditor.setEditable(t);
2809
+ set isEditable(e) {
2810
+ this._tiptapEditor.setEditable(e);
2646
2811
  }
2647
2812
  /**
2648
2813
  * Inserts new blocks into the editor. If a block's `id` is undefined, BlockNote generates one automatically. Throws an
@@ -2652,8 +2817,8 @@ class Fo {
2652
2817
  * @param placement Whether the blocks should be inserted just before, just after, or nested inside the
2653
2818
  * `referenceBlock`. Inserts the blocks at the start of the existing block's children if "nested" is used.
2654
2819
  */
2655
- insertBlocks(t, e, r = "before") {
2656
- pt(t, e, r, this._tiptapEditor);
2820
+ insertBlocks(e, t, n = "before") {
2821
+ Tt(e, t, n, this._tiptapEditor);
2657
2822
  }
2658
2823
  /**
2659
2824
  * Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
@@ -2662,15 +2827,15 @@ class Fo {
2662
2827
  * @param blockToUpdate The block that should be updated.
2663
2828
  * @param update A partial block which defines how the existing block should be changed.
2664
2829
  */
2665
- updateBlock(t, e) {
2666
- re(t, e, this._tiptapEditor);
2830
+ updateBlock(e, t) {
2831
+ Me(e, t, this._tiptapEditor);
2667
2832
  }
2668
2833
  /**
2669
2834
  * Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
2670
2835
  * @param blocksToRemove An array of identifiers for existing blocks that should be removed.
2671
2836
  */
2672
- removeBlocks(t) {
2673
- ft(t, this._tiptapEditor);
2837
+ removeBlocks(e) {
2838
+ wt(e, this._tiptapEditor);
2674
2839
  }
2675
2840
  /**
2676
2841
  * Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
@@ -2679,61 +2844,64 @@ class Fo {
2679
2844
  * @param blocksToRemove An array of blocks that should be replaced.
2680
2845
  * @param blocksToInsert An array of partial blocks to replace the old ones with.
2681
2846
  */
2682
- replaceBlocks(t, e) {
2683
- ne(t, e, this._tiptapEditor);
2847
+ replaceBlocks(e, t) {
2848
+ Be(e, t, this._tiptapEditor);
2684
2849
  }
2685
2850
  /**
2686
2851
  * Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
2687
2852
  */
2688
2853
  getActiveStyles() {
2689
- const t = {}, e = this._tiptapEditor.state.selection.$to.marks(), r = /* @__PURE__ */ new Set([
2854
+ const e = {}, t = this._tiptapEditor.state.selection.$to.marks(), n = /* @__PURE__ */ new Set([
2690
2855
  "bold",
2691
2856
  "italic",
2692
2857
  "underline",
2693
2858
  "strike",
2694
2859
  "code"
2695
- ]), n = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
2696
- for (const i of e)
2697
- r.has(i.type.name) ? t[i.type.name] = !0 : n.has(i.type.name) && (t[i.type.name] = i.attrs.color);
2698
- return t;
2860
+ ]), r = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
2861
+ for (const i of t)
2862
+ n.has(i.type.name) ? e[i.type.name] = !0 : r.has(i.type.name) && (e[i.type.name] = i.attrs.color);
2863
+ return e;
2699
2864
  }
2700
2865
  /**
2701
2866
  * Adds styles to the currently selected content.
2702
2867
  * @param styles The styles to add.
2703
2868
  */
2704
- addStyles(t) {
2705
- const e = /* @__PURE__ */ new Set([
2869
+ addStyles(e) {
2870
+ const t = /* @__PURE__ */ new Set([
2706
2871
  "bold",
2707
2872
  "italic",
2708
2873
  "underline",
2709
2874
  "strike",
2710
2875
  "code"
2711
- ]), r = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
2712
- for (const [n, i] of Object.entries(t))
2713
- e.has(n) ? this._tiptapEditor.commands.setMark(n) : r.has(n) && this._tiptapEditor.commands.setMark(n, { color: i });
2876
+ ]), n = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
2877
+ this._tiptapEditor.view.focus();
2878
+ for (const [r, i] of Object.entries(e))
2879
+ t.has(r) ? this._tiptapEditor.commands.setMark(r) : n.has(r) && this._tiptapEditor.commands.setMark(r, { color: i });
2714
2880
  }
2715
2881
  /**
2716
2882
  * Removes styles from the currently selected content.
2717
2883
  * @param styles The styles to remove.
2718
2884
  */
2719
- removeStyles(t) {
2720
- for (const e of Object.keys(t))
2721
- this._tiptapEditor.commands.unsetMark(e);
2885
+ removeStyles(e) {
2886
+ this._tiptapEditor.view.focus();
2887
+ for (const t of Object.keys(e))
2888
+ this._tiptapEditor.commands.unsetMark(t);
2722
2889
  }
2723
2890
  /**
2724
2891
  * Toggles styles on the currently selected content.
2725
2892
  * @param styles The styles to toggle.
2726
2893
  */
2727
- toggleStyles(t) {
2728
- const e = /* @__PURE__ */ new Set([
2894
+ toggleStyles(e) {
2895
+ const t = /* @__PURE__ */ new Set([
2729
2896
  "bold",
2730
2897
  "italic",
2731
2898
  "underline",
2732
2899
  "strike",
2733
2900
  "code"
2734
- ]), r = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
2735
- for (const [n, i] of Object.entries(t))
2736
- e.has(n) ? this._tiptapEditor.commands.toggleMark(n) : r.has(n) && this._tiptapEditor.commands.toggleMark(n, { color: i });
2901
+ ]), n = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
2902
+ this._tiptapEditor.view.focus();
2903
+ for (const [r, i] of Object.entries(e))
2904
+ t.has(r) ? this._tiptapEditor.commands.toggleMark(r) : n.has(r) && this._tiptapEditor.commands.toggleMark(r, { color: i });
2737
2905
  }
2738
2906
  /**
2739
2907
  * Gets the currently selected text.
@@ -2755,25 +2923,25 @@ class Fo {
2755
2923
  * @param url The link URL.
2756
2924
  * @param text The text to display the link with.
2757
2925
  */
2758
- createLink(t, e) {
2759
- if (t === "")
2926
+ createLink(e, t) {
2927
+ if (e === "")
2760
2928
  return;
2761
- let { from: r, to: n } = this._tiptapEditor.state.selection;
2762
- e || (e = this._tiptapEditor.state.doc.textBetween(r, n));
2763
- const i = this._tiptapEditor.schema.mark("link", { href: t });
2929
+ let { from: n, to: r } = this._tiptapEditor.state.selection;
2930
+ t || (t = this._tiptapEditor.state.doc.textBetween(n, r));
2931
+ const i = this._tiptapEditor.schema.mark("link", { href: e });
2764
2932
  this._tiptapEditor.view.dispatch(
2765
- this._tiptapEditor.view.state.tr.insertText(e, r, n).addMark(r, r + e.length, i)
2933
+ this._tiptapEditor.view.state.tr.insertText(t, n, r).addMark(n, n + t.length, i)
2766
2934
  );
2767
2935
  }
2768
2936
  /**
2769
2937
  * Checks if the block containing the text cursor can be nested.
2770
2938
  */
2771
2939
  canNestBlock() {
2772
- const { startPos: t, depth: e } = g(
2940
+ const { startPos: e, depth: t } = g(
2773
2941
  this._tiptapEditor.state.doc,
2774
2942
  this._tiptapEditor.state.selection.from
2775
2943
  );
2776
- return this._tiptapEditor.state.doc.resolve(t).index(e - 1) > 0;
2944
+ return this._tiptapEditor.state.doc.resolve(e).index(t - 1) > 0;
2777
2945
  }
2778
2946
  /**
2779
2947
  * Nests the block containing the text cursor into the block above it.
@@ -2785,11 +2953,11 @@ class Fo {
2785
2953
  * Checks if the block containing the text cursor is nested.
2786
2954
  */
2787
2955
  canUnnestBlock() {
2788
- const { depth: t } = g(
2956
+ const { depth: e } = g(
2789
2957
  this._tiptapEditor.state.doc,
2790
2958
  this._tiptapEditor.state.selection.from
2791
2959
  );
2792
- return t > 2;
2960
+ return e > 2;
2793
2961
  }
2794
2962
  /**
2795
2963
  * Lifts the block containing the text cursor out of its parent.
@@ -2803,8 +2971,8 @@ class Fo {
2803
2971
  * @param blocks An array of blocks that should be serialized into HTML.
2804
2972
  * @returns The blocks, serialized as an HTML string.
2805
2973
  */
2806
- async blocksToHTML(t) {
2807
- return mt(t, this._tiptapEditor.schema);
2974
+ async blocksToHTML(e) {
2975
+ return St(e, this._tiptapEditor.schema);
2808
2976
  }
2809
2977
  /**
2810
2978
  * Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
@@ -2813,8 +2981,8 @@ class Fo {
2813
2981
  * @param html The HTML string to parse blocks from.
2814
2982
  * @returns The blocks parsed from the HTML string.
2815
2983
  */
2816
- async HTMLToBlocks(t) {
2817
- return gt(t, this._tiptapEditor.schema);
2984
+ async HTMLToBlocks(e) {
2985
+ return xt(e, this.schema, this._tiptapEditor.schema);
2818
2986
  }
2819
2987
  /**
2820
2988
  * Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
@@ -2822,8 +2990,8 @@ class Fo {
2822
2990
  * @param blocks An array of blocks that should be serialized into Markdown.
2823
2991
  * @returns The blocks, serialized as a Markdown string.
2824
2992
  */
2825
- async blocksToMarkdown(t) {
2826
- return ae(t, this._tiptapEditor.schema);
2993
+ async blocksToMarkdown(e) {
2994
+ return Se(e, this._tiptapEditor.schema);
2827
2995
  }
2828
2996
  /**
2829
2997
  * Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
@@ -2832,26 +3000,34 @@ class Fo {
2832
3000
  * @param markdown The Markdown string to parse blocks from.
2833
3001
  * @returns The blocks parsed from the Markdown string.
2834
3002
  */
2835
- async markdownToBlocks(t) {
2836
- return le(t, this._tiptapEditor.schema);
3003
+ async markdownToBlocks(e) {
3004
+ return xe(e, this.schema, this._tiptapEditor.schema);
2837
3005
  }
2838
3006
  /**
2839
3007
  * Updates the user info for the current user that's shown to other collaborators.
2840
3008
  */
2841
- updateCollaborationUserInfo(t) {
3009
+ updateCollaborationUserInfo(e) {
2842
3010
  if (!this.options.collaboration)
2843
3011
  throw new Error(
2844
3012
  "Cannot update collaboration user info when collaboration is disabled."
2845
3013
  );
2846
- this._tiptapEditor.commands.updateUser(t);
3014
+ this._tiptapEditor.commands.updateUser(e);
2847
3015
  }
2848
3016
  }
2849
3017
  export {
2850
- x as BaseSlashMenuItem,
2851
- Fo as BlockNoteEditor,
2852
- tt as blockProps,
2853
- eo as defaultSlashMenuItems,
2854
- so as getBlockNoteExtensions,
2855
- O as globalProps
3018
+ S as BaseSlashMenuItem,
3019
+ Ko as BlockNoteEditor,
3020
+ $e as CustomBlockSerializerExtension,
3021
+ Vo as blockStyles,
3022
+ ot as camelToDataKebab,
3023
+ Yo as createBlockSpec,
3024
+ H as createTipTapBlock,
3025
+ ge as defaultBlockSchema,
3026
+ N as defaultProps,
3027
+ uo as defaultSlashMenuItems,
3028
+ go as getBlockNoteExtensions,
3029
+ le as parse,
3030
+ ae as propsToAttributes,
3031
+ de as render
2856
3032
  };
2857
3033
  //# sourceMappingURL=blocknote.js.map