@blocknote/core 0.9.2 → 0.9.4

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 (58) hide show
  1. package/dist/blocknote.js +1562 -1240
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +5 -5
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/package.json +2 -2
  7. package/src/BlockNoteEditor.ts +44 -12
  8. package/src/api/blockManipulation/__snapshots__/blockManipulation.test.ts.snap +21 -21
  9. package/src/api/blockManipulation/blockManipulation.test.ts +8 -11
  10. package/src/api/formatConversions/__snapshots__/formatConversions.test.ts.snap +3 -3
  11. package/src/api/formatConversions/formatConversions.test.ts +5 -5
  12. package/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +3 -3
  13. package/src/api/nodeConversions/nodeConversions.test.ts +10 -4
  14. package/src/api/nodeConversions/nodeConversions.ts +9 -7
  15. package/src/api/nodeConversions/testUtil.ts +3 -3
  16. package/src/editor.module.css +1 -1
  17. package/src/extensions/BackgroundColor/BackgroundColorExtension.ts +5 -3
  18. package/src/extensions/BackgroundColor/BackgroundColorMark.ts +2 -1
  19. package/src/extensions/Blocks/NonEditableBlockPlugin.ts +17 -0
  20. package/src/extensions/Blocks/api/block.ts +29 -16
  21. package/src/extensions/Blocks/api/blockTypes.ts +79 -27
  22. package/src/extensions/Blocks/api/defaultBlocks.ts +13 -41
  23. package/src/extensions/Blocks/api/defaultProps.ts +16 -0
  24. package/src/extensions/Blocks/nodes/Block.module.css +78 -24
  25. package/src/extensions/Blocks/nodes/BlockContainer.ts +45 -45
  26. package/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.ts +61 -13
  27. package/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/ImageBlockContent.ts +305 -0
  28. package/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.ts +13 -0
  29. package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +26 -2
  30. package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +146 -118
  31. package/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.ts +12 -2
  32. package/src/extensions/ImageToolbar/ImageToolbarPlugin.ts +239 -0
  33. package/src/extensions/SlashMenu/defaultSlashMenuItems.ts +47 -6
  34. package/src/extensions/TextColor/TextColorExtension.ts +4 -3
  35. package/src/extensions/TextColor/TextColorMark.ts +2 -1
  36. package/src/extensions/TrailingNode/TrailingNodeExtension.ts +13 -1
  37. package/src/index.ts +4 -0
  38. package/types/src/BlockNoteEditor.d.ts +9 -0
  39. package/types/src/BlockNoteExtensions.d.ts +1 -1
  40. package/types/src/extensions/Blocks/NonEditableBlockPlugin.d.ts +2 -0
  41. package/types/src/extensions/Blocks/api/block.d.ts +7 -8
  42. package/types/src/extensions/Blocks/api/blockTypes.d.ts +29 -20
  43. package/types/src/extensions/Blocks/api/defaultBlocks.d.ts +55 -51
  44. package/types/src/extensions/Blocks/api/defaultProps.d.ts +14 -0
  45. package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.d.ts +43 -9
  46. package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/Image.d.ts +6 -0
  47. package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/ImageBlockContent.d.ts +37 -0
  48. package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.d.ts +1 -0
  49. package/types/src/extensions/Blocks/nodes/BlockContent/ImageBlockContent/uploadToTmpFilesOrg_DEV_ONLY.d.ts +1 -0
  50. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +35 -9
  51. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +35 -9
  52. package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.d.ts +36 -1
  53. package/types/src/extensions/ImageToolbar/ImageToolbarPlugin.d.ts +36 -0
  54. package/types/src/extensions/SlashMenu/defaultSlashMenuItems.d.ts +1 -1
  55. package/types/src/index.d.ts +4 -0
  56. package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +1 -1
  57. package/types/src/extensions/Blocks/nodes/TableCell.d.ts +0 -5
  58. package/types/src/extensions/Blocks/nodes/TableRow.d.ts +0 -5
package/dist/blocknote.js CHANGED
@@ -1,43 +1,43 @@
1
- var Pt = Object.defineProperty;
2
- var Ot = (n, e, t) => e in n ? Pt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var u = (n, e, t) => (Ot(n, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { Extension as T, Mark as lt, Node as U, InputRule as K, mergeAttributes as A, combineTransactionSteps as Dt, getChangedRanges as Rt, findChildrenInRange as Vt, findChildren as tt, findParentNode as zt, extensions as L, isTextSelection as Ut, isNodeSelection as Ft, posToDOMRect as q, getMarkRange as et, Editor as Gt } from "@tiptap/core";
5
- import { Bold as $t } from "@tiptap/extension-bold";
6
- import { Code as jt } from "@tiptap/extension-code";
7
- import qt from "@tiptap/extension-collaboration";
8
- import Wt from "@tiptap/extension-collaboration-cursor";
9
- import { Dropcursor as Yt } from "@tiptap/extension-dropcursor";
10
- import { Gapcursor as Kt } from "@tiptap/extension-gapcursor";
11
- import { HardBreak as Jt } from "@tiptap/extension-hard-break";
12
- import { History as Xt } from "@tiptap/extension-history";
13
- import { Italic as Zt } from "@tiptap/extension-italic";
14
- import { Link as Qt } from "@tiptap/extension-link";
15
- import { Strike as te } from "@tiptap/extension-strike";
16
- import { Text as ee } from "@tiptap/extension-text";
17
- import { Underline as oe } from "@tiptap/extension-underline";
18
- import { Slice as x, Fragment as _, DOMSerializer as W, DOMParser as ne } from "prosemirror-model";
19
- import { PluginKey as S, Plugin as w, TextSelection as ot, Selection as j, NodeSelection as re } from "prosemirror-state";
20
- import { v4 as ie } from "uuid";
21
- import * as se from "prosemirror-view";
22
- import { Decoration as V, DecorationSet as z } from "prosemirror-view";
23
- import dt from "rehype-parse";
24
- import ae from "rehype-remark";
25
- import ct from "rehype-stringify";
26
- import ut from "remark-gfm";
27
- import le from "remark-parse";
28
- import de, { defaultHandlers as ce } from "remark-rehype";
29
- import ue from "remark-stringify";
30
- import { unified as J } from "unified";
31
- import { fromDom as nt } from "hast-util-from-dom";
32
- const pe = "_bnEditor_1pmoa_3", he = "_bnRoot_1pmoa_19", fe = "_defaultStyles_1pmoa_34", me = "_dragPreview_1pmoa_57", H = {
33
- bnEditor: pe,
34
- bnRoot: he,
35
- defaultStyles: fe,
36
- dragPreview: me,
37
- "collaboration-cursor__caret": "_collaboration-cursor__caret_1pmoa_63",
38
- "collaboration-cursor__label": "_collaboration-cursor__label_1pmoa_74"
1
+ var Yt = Object.defineProperty;
2
+ var Jt = (n, e, t) => e in n ? Yt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var u = (n, e, t) => (Jt(n, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { Extension as A, Mark as ht, combineTransactionSteps as Zt, getChangedRanges as Qt, findChildrenInRange as te, findChildren as nt, Node as G, mergeAttributes as N, findParentNode as ee, extensions as R, InputRule as Z, isTextSelection as oe, isNodeSelection as ne, posToDOMRect as K, getMarkRange as rt, Editor as re } from "@tiptap/core";
5
+ import { Bold as ie } from "@tiptap/extension-bold";
6
+ import { Code as se } from "@tiptap/extension-code";
7
+ import ae from "@tiptap/extension-collaboration";
8
+ import le from "@tiptap/extension-collaboration-cursor";
9
+ import { Dropcursor as de } from "@tiptap/extension-dropcursor";
10
+ import { Gapcursor as ce } from "@tiptap/extension-gapcursor";
11
+ import { HardBreak as ue } from "@tiptap/extension-hard-break";
12
+ import { History as pe } from "@tiptap/extension-history";
13
+ import { Italic as he } from "@tiptap/extension-italic";
14
+ import { Link as me } from "@tiptap/extension-link";
15
+ import { Strike as fe } from "@tiptap/extension-strike";
16
+ import { Text as ge } from "@tiptap/extension-text";
17
+ import { Underline as ke } from "@tiptap/extension-underline";
18
+ import { Slice as L, Fragment as P, DOMSerializer as Y, DOMParser as be } from "prosemirror-model";
19
+ import { Plugin as T, PluginKey as B, NodeSelection as mt, TextSelection as it, Selection as X } from "prosemirror-state";
20
+ import { v4 as ye } from "uuid";
21
+ import * as ve from "prosemirror-view";
22
+ import { Decoration as W, DecorationSet as $ } from "prosemirror-view";
23
+ import ft from "rehype-parse";
24
+ import we from "rehype-remark";
25
+ import gt from "rehype-stringify";
26
+ import kt from "remark-gfm";
27
+ import Ce from "remark-parse";
28
+ import Ee, { defaultHandlers as Se } from "remark-rehype";
29
+ import Te from "remark-stringify";
30
+ import { unified as Q } from "unified";
31
+ import { fromDom as st } from "hast-util-from-dom";
32
+ const Me = "_bnEditor_12je0_3", Be = "_bnRoot_12je0_19", xe = "_defaultStyles_12je0_34", Ie = "_dragPreview_12je0_57", D = {
33
+ bnEditor: Me,
34
+ bnRoot: Be,
35
+ defaultStyles: xe,
36
+ dragPreview: Ie,
37
+ "collaboration-cursor__caret": "_collaboration-cursor__caret_12je0_63",
38
+ "collaboration-cursor__label": "_collaboration-cursor__label_12je0_74"
39
39
  };
40
- function pt(n) {
40
+ function bt(n) {
41
41
  const e = n.attrs.id, t = n.firstChild, o = t.type, r = n.childCount === 2 ? n.lastChild.childCount : 0;
42
42
  return {
43
43
  id: e,
@@ -47,7 +47,7 @@ function pt(n) {
47
47
  numChildBlocks: r
48
48
  };
49
49
  }
50
- function k(n, e) {
50
+ function b(n, e) {
51
51
  const o = n.nodeSize - 2;
52
52
  if (e <= 1)
53
53
  for (e = 1 + 1; n.resolve(e).parent.type.name !== "blockContainer" && e < o; )
@@ -67,19 +67,30 @@ function k(n, e) {
67
67
  break;
68
68
  l -= 1, s = r.node(l);
69
69
  }
70
- const { id: a, contentNode: d, contentType: c, numChildBlocks: h } = pt(s), p = r.start(l), f = r.end(l);
70
+ const { id: a, contentNode: d, contentType: c, numChildBlocks: m } = bt(s), h = r.start(l), p = r.end(l);
71
71
  return {
72
72
  id: a,
73
73
  node: s,
74
74
  contentNode: d,
75
75
  contentType: c,
76
- numChildBlocks: h,
77
- startPos: p,
78
- endPos: f,
76
+ numChildBlocks: m,
77
+ startPos: h,
78
+ endPos: p,
79
79
  depth: l
80
80
  };
81
81
  }
82
- const ke = T.create({
82
+ const C = {
83
+ backgroundColor: {
84
+ default: "default"
85
+ },
86
+ textColor: {
87
+ default: "default"
88
+ },
89
+ textAlignment: {
90
+ default: "left",
91
+ values: ["left", "center", "right", "justify"]
92
+ }
93
+ }, Ae = A.create({
83
94
  name: "blockBackgroundColor",
84
95
  addGlobalAttributes() {
85
96
  return [
@@ -87,9 +98,9 @@ const ke = T.create({
87
98
  types: ["blockContainer"],
88
99
  attributes: {
89
100
  backgroundColor: {
90
- default: "default",
91
- parseHTML: (n) => n.hasAttribute("data-background-color") ? n.getAttribute("data-background-color") : "default",
92
- renderHTML: (n) => n.backgroundColor !== "default" && {
101
+ default: C.backgroundColor.default,
102
+ parseHTML: (n) => n.hasAttribute("data-background-color") ? n.getAttribute("data-background-color") : C.backgroundColor.default,
103
+ renderHTML: (n) => n.backgroundColor !== C.backgroundColor.default && {
93
104
  "data-background-color": n.backgroundColor
94
105
  }
95
106
  }
@@ -100,7 +111,7 @@ const ke = T.create({
100
111
  addCommands() {
101
112
  return {
102
113
  setBlockBackgroundColor: (n, e) => ({ state: t, view: o }) => {
103
- const r = k(t.doc, n);
114
+ const r = b(t.doc, n);
104
115
  return r === void 0 ? !1 : (t.tr.setNodeAttribute(
105
116
  r.startPos - 1,
106
117
  "backgroundColor",
@@ -109,7 +120,7 @@ const ke = T.create({
109
120
  }
110
121
  };
111
122
  }
112
- }), ge = lt.create({
123
+ }), _e = ht.create({
113
124
  name: "backgroundColor",
114
125
  addAttributes() {
115
126
  return {
@@ -135,555 +146,55 @@ const ke = T.create({
135
146
  },
136
147
  addCommands() {
137
148
  return {
138
- setBackgroundColor: (n) => ({ commands: e }) => n !== "default" ? e.setMark(this.name, { color: n }) : e.unsetMark(this.name)
149
+ setBackgroundColor: (n) => ({ commands: e }) => n !== C.backgroundColor.default ? e.setMark(this.name, { color: n }) : e.unsetMark(this.name)
139
150
  };
140
151
  }
141
- }), ht = "_blockOuter_7sok8_5", ft = "_block_7sok8_5", mt = "_reactNodeViewRenderer_7sok8_17", kt = "_blockContent_7sok8_22", gt = "_blockGroup_7sok8_42", bt = "_isEmpty_7sok8_240", yt = "_inlineContent_7sok8_240", vt = "_isFilter_7sok8_241", Ct = "_hasAnchor_7sok8_263", y = {
142
- blockOuter: ht,
143
- block: ft,
144
- reactNodeViewRenderer: mt,
145
- blockContent: kt,
146
- blockGroup: gt,
147
- isEmpty: bt,
148
- inlineContent: yt,
149
- isFilter: vt,
150
- hasAnchor: Ct
151
- }, Jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
152
- __proto__: null,
153
- block: ft,
154
- blockContent: kt,
155
- blockGroup: gt,
156
- blockOuter: ht,
157
- default: y,
158
- hasAnchor: Ct,
159
- inlineContent: yt,
160
- isEmpty: bt,
161
- isFilter: vt,
162
- reactNodeViewRenderer: mt
163
- }, Symbol.toStringTag, { value: "Module" })), be = () => /Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
164
- function Xo(n) {
165
- return be() ? n.replace("Mod", "⌘") : n.replace("Mod", "Ctrl");
166
- }
167
- function v(...n) {
168
- return n.filter((e) => e).join(" ");
169
- }
170
- class ye extends Error {
171
- constructor(e) {
172
- super(`Unreachable case: ${e}`);
173
- }
174
- }
175
- function rt(n) {
176
- return "data-" + n.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
177
- }
178
- function ve(n) {
179
- const e = {};
180
- return Object.entries(n.propSchema).forEach(([t, o]) => {
181
- e[t] = {
182
- default: o.default,
183
- keepOnSplit: !0,
184
- // Props are displayed in kebab-case as HTML attributes. If a prop's
185
- // value is the same as its default, we don't display an HTML
186
- // attribute for it.
187
- parseHTML: (r) => r.getAttribute(rt(t)),
188
- renderHTML: (r) => r[t] !== o.default ? {
189
- [rt(t)]: r[t]
190
- } : {}
191
- };
192
- }), e;
193
- }
194
- function Ce(n) {
195
- return [
196
- {
197
- tag: "div[data-content-type=" + n.type + "]"
198
- }
199
- ];
200
- }
201
- function we(n, e) {
202
- const t = document.createElement("div");
203
- t.setAttribute("data-content-type", n.type);
204
- for (const [r, i] of Object.entries(e))
205
- t.setAttribute(r, i);
206
- let o;
207
- return n.containsInlineContent ? (o = document.createElement("div"), t.appendChild(o)) : o = void 0, o !== void 0 ? {
208
- dom: t,
209
- contentDOM: o
210
- } : {
211
- dom: t
212
- };
213
- }
214
- function Zo(n) {
215
- return {
216
- node: O({
217
- name: n.type,
218
- content: n.containsInlineContent ? "inline*" : "",
219
- selectable: n.containsInlineContent,
220
- addAttributes() {
221
- return ve(n);
222
- },
223
- parseHTML() {
224
- return Ce(n);
225
- },
226
- renderHTML({ HTMLAttributes: t }) {
227
- return we(n, t);
228
- },
229
- addNodeView() {
230
- return ({ HTMLAttributes: t, getPos: o }) => {
231
- var f, m;
232
- const r = document.createElement("div"), i = ((f = this.options.domAttributes) == null ? void 0 : f.blockContent) || {};
233
- for (const [g, b] of Object.entries(
234
- i
235
- ))
236
- g !== "class" && r.setAttribute(g, b);
237
- r.className = v(
238
- y.blockContent,
239
- i.class
240
- ), r.setAttribute("data-content-type", n.type);
241
- for (const [g, b] of Object.entries(t))
242
- r.setAttribute(g, b);
243
- const s = this.options.editor;
244
- if (typeof o == "boolean")
245
- throw new Error(
246
- "Cannot find node position as getPos is a boolean, not a function."
247
- );
248
- const l = o(), c = s._tiptapEditor.state.doc.resolve(l).node().attrs.id, h = s.getBlock(c);
249
- if (h.type !== n.type)
250
- throw new Error("Block type does not match");
251
- const p = n.render(h, s);
252
- if ("contentDOM" in p) {
253
- const g = ((m = this.options.domAttributes) == null ? void 0 : m.inlineContent) || {};
254
- for (const [b, C] of Object.entries(
255
- g
256
- ))
257
- b !== "class" && p.contentDOM.setAttribute(b, C);
258
- p.contentDOM.className = v(
259
- p.contentDOM.className,
260
- y.inlineContent,
261
- g.class
262
- );
263
- }
264
- return r.appendChild(p.dom), "contentDOM" in p ? {
265
- dom: r,
266
- contentDOM: p.contentDOM
267
- } : {
268
- dom: r
269
- };
270
- };
271
- }
272
- }),
273
- propSchema: n.propSchema
274
- };
275
- }
276
- function O(n) {
277
- return U.create({
278
- ...n,
279
- group: "blockContent"
152
+ });
153
+ function He(n, e = JSON.stringify) {
154
+ const t = {};
155
+ return n.filter((o) => {
156
+ const r = e(o);
157
+ return Object.prototype.hasOwnProperty.call(t, r) ? !1 : t[r] = !0;
280
158
  });
281
159
  }
282
- const Se = O({
283
- name: "heading",
284
- content: "inline*",
285
- addAttributes() {
160
+ function Le(n) {
161
+ const e = n.filter(
162
+ (o, r) => n.indexOf(o) !== r
163
+ );
164
+ return He(e);
165
+ }
166
+ const j = A.create({
167
+ name: "uniqueID",
168
+ // we’ll set a very high priority to make sure this runs first
169
+ // and is compatible with `appendTransaction` hooks of other extensions
170
+ priority: 1e4,
171
+ addOptions() {
286
172
  return {
287
- level: {
288
- default: "1",
289
- // instead of "level" attributes, use "data-level"
290
- parseHTML: (n) => n.getAttribute("data-level"),
291
- renderHTML: (n) => ({
292
- "data-level": n.level
293
- })
294
- }
295
- };
296
- },
297
- addInputRules() {
298
- return [
299
- ...["1", "2", "3"].map((n) => new K({
300
- find: new RegExp(`^(#{${parseInt(n)}})\\s$`),
301
- handler: ({ state: e, chain: t, range: o }) => {
302
- t().BNUpdateBlock(e.selection.from, {
303
- type: "heading",
304
- props: {
305
- level: n
306
- }
307
- }).deleteRange({ from: o.from, to: o.to });
173
+ attributeName: "id",
174
+ types: [],
175
+ generateID: () => {
176
+ if (typeof window < "u" && window.__TEST_OPTIONS) {
177
+ const n = window.__TEST_OPTIONS;
178
+ return n.mockID === void 0 ? n.mockID = 0 : n.mockID++, n.mockID.toString();
308
179
  }
309
- }))
310
- ];
311
- },
312
- parseHTML() {
313
- return [
314
- {
315
- tag: "h1",
316
- attrs: { level: "1" },
317
- node: "heading"
318
- },
319
- {
320
- tag: "h2",
321
- attrs: { level: "2" },
322
- node: "heading"
180
+ return ye();
323
181
  },
324
- {
325
- tag: "h3",
326
- attrs: { level: "3" },
327
- node: "heading"
328
- }
329
- ];
330
- },
331
- renderHTML({ node: n, HTMLAttributes: e }) {
332
- var r, i;
333
- const t = ((r = this.options.domAttributes) == null ? void 0 : r.blockContent) || {}, o = ((i = this.options.domAttributes) == null ? void 0 : i.inlineContent) || {};
334
- return [
335
- "div",
336
- A(e, {
337
- class: v(
338
- y.blockContent,
339
- t.class
340
- ),
341
- "data-content-type": this.name
342
- }),
343
- [
344
- "h" + n.attrs.level,
345
- {
346
- class: v(
347
- y.inlineContent,
348
- o.class
349
- )
350
- },
351
- 0
352
- ]
353
- ];
354
- }
355
- }), wt = (n) => {
356
- const { node: e, contentType: t } = k(
357
- n.state.doc,
358
- n.state.selection.from
359
- ), o = n.state.selection.anchor === n.state.selection.head;
360
- return !t.name.endsWith("ListItem") || !o ? !1 : n.commands.first(({ state: r, chain: i, commands: s }) => [
361
- () => (
362
- // Changes list item block to a text block if the content is empty.
363
- s.command(() => e.textContent.length === 0 ? s.BNUpdateBlock(r.selection.from, {
364
- type: "paragraph",
365
- props: {}
366
- }) : !1)
367
- ),
368
- () => (
369
- // Splits the current block, moving content inside that's after the cursor to a new block of the same type
370
- // below.
371
- s.command(() => e.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
372
- )
373
- ]);
374
- }, Me = O({
375
- name: "bulletListItem",
376
- content: "inline*",
377
- addInputRules() {
378
- return [
379
- // Creates an unordered list when starting with "-", "+", or "*".
380
- new K({
381
- find: new RegExp("^[-+*]\\s$"),
382
- handler: ({ state: n, chain: e, range: t }) => {
383
- e().BNUpdateBlock(n.selection.from, {
384
- type: "bulletListItem",
385
- props: {}
386
- }).deleteRange({ from: t.from, to: t.to });
387
- }
388
- })
389
- ];
390
- },
391
- addKeyboardShortcuts() {
392
- return {
393
- Enter: () => wt(this.editor)
182
+ filterTransaction: null
394
183
  };
395
184
  },
396
- parseHTML() {
185
+ addGlobalAttributes() {
397
186
  return [
398
- // Case for regular HTML list structure.
399
- {
400
- tag: "li",
401
- getAttrs: (n) => {
402
- if (typeof n == "string")
403
- return !1;
404
- const e = n.parentElement;
405
- return e === null ? !1 : e.tagName === "UL" ? {} : !1;
406
- },
407
- node: "bulletListItem"
408
- },
409
- // Case for BlockNote list structure.
410
187
  {
411
- tag: "p",
412
- getAttrs: (n) => {
413
- if (typeof n == "string")
414
- return !1;
415
- const e = n.parentElement;
416
- return e === null ? !1 : e.getAttribute("data-content-type") === "bulletListItem" ? {} : !1;
417
- },
418
- priority: 300,
419
- node: "bulletListItem"
420
- }
421
- ];
422
- },
423
- renderHTML({ HTMLAttributes: n }) {
424
- var o, r;
425
- const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
426
- return [
427
- "div",
428
- A(n, {
429
- class: v(
430
- y.blockContent,
431
- e.class
432
- ),
433
- "data-content-type": this.name
434
- }),
435
- [
436
- "p",
437
- {
438
- class: v(
439
- y.inlineContent,
440
- t.class
441
- )
442
- },
443
- 0
444
- ]
445
- ];
446
- }
447
- }), Ee = new S("numbered-list-indexing"), Be = () => new w({
448
- key: Ee,
449
- appendTransaction: (n, e, t) => {
450
- const o = t.tr;
451
- o.setMeta("numberedListIndexing", !0);
452
- let r = !1;
453
- return t.doc.descendants((i, s) => {
454
- if (i.type.name === "blockContainer" && i.firstChild.type.name === "numberedListItem") {
455
- let l = "1";
456
- const a = s === 1, d = k(o.doc, s + 1);
457
- if (d === void 0)
458
- return;
459
- if (!a) {
460
- const p = k(o.doc, s - 2);
461
- if (p === void 0)
462
- return;
463
- if (!(d.depth !== p.depth)) {
464
- const m = p.contentNode;
465
- if (p.contentType.name === "numberedListItem") {
466
- const C = m.attrs.index;
467
- l = (parseInt(C) + 1).toString();
468
- }
469
- }
470
- }
471
- d.contentNode.attrs.index !== l && (r = !0, o.setNodeMarkup(s + 1, void 0, {
472
- index: l
473
- }));
474
- }
475
- }), r ? o : null;
476
- }
477
- }), Te = O({
478
- name: "numberedListItem",
479
- content: "inline*",
480
- addAttributes() {
481
- return {
482
- index: {
483
- default: null,
484
- parseHTML: (n) => n.getAttribute("data-index"),
485
- renderHTML: (n) => ({
486
- "data-index": n.index
487
- })
488
- }
489
- };
490
- },
491
- addInputRules() {
492
- return [
493
- // Creates an ordered list when starting with "1.".
494
- new K({
495
- find: new RegExp("^1\\.\\s$"),
496
- handler: ({ state: n, chain: e, range: t }) => {
497
- e().BNUpdateBlock(n.selection.from, {
498
- type: "numberedListItem",
499
- props: {}
500
- }).deleteRange({ from: t.from, to: t.to });
501
- }
502
- })
503
- ];
504
- },
505
- addKeyboardShortcuts() {
506
- return {
507
- Enter: () => wt(this.editor)
508
- };
509
- },
510
- addProseMirrorPlugins() {
511
- return [Be()];
512
- },
513
- parseHTML() {
514
- return [
515
- // Case for regular HTML list structure.
516
- // (e.g.: when pasting from other apps)
517
- {
518
- tag: "li",
519
- getAttrs: (n) => {
520
- if (typeof n == "string")
521
- return !1;
522
- const e = n.parentElement;
523
- return e === null ? !1 : e.tagName === "OL" ? {} : !1;
524
- },
525
- node: "numberedListItem"
526
- },
527
- // Case for BlockNote list structure.
528
- // (e.g.: when pasting from blocknote)
529
- {
530
- tag: "p",
531
- getAttrs: (n) => {
532
- if (typeof n == "string")
533
- return !1;
534
- const e = n.parentElement;
535
- return e === null ? !1 : e.getAttribute("data-content-type") === "numberedListItem" ? {} : !1;
536
- },
537
- priority: 300,
538
- node: "numberedListItem"
539
- }
540
- ];
541
- },
542
- renderHTML({ HTMLAttributes: n }) {
543
- var o, r;
544
- const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
545
- return [
546
- "div",
547
- A(n, {
548
- class: v(
549
- y.blockContent,
550
- e.class
551
- ),
552
- "data-content-type": this.name
553
- }),
554
- // we use a <p> tag, because for <li> tags we'd need to add a <ul> parent for around siblings to be semantically correct,
555
- // which would be quite cumbersome
556
- [
557
- "p",
558
- {
559
- class: v(
560
- y.inlineContent,
561
- t.class
562
- )
563
- },
564
- 0
565
- ]
566
- ];
567
- }
568
- }), xe = O({
569
- name: "paragraph",
570
- content: "inline*",
571
- parseHTML() {
572
- return [
573
- {
574
- tag: "p",
575
- priority: 200,
576
- node: "paragraph"
577
- }
578
- ];
579
- },
580
- renderHTML({ HTMLAttributes: n }) {
581
- var o, r;
582
- const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
583
- return [
584
- "div",
585
- A(
586
- {
587
- ...e,
588
- class: v(
589
- y.blockContent,
590
- e.class
591
- ),
592
- "data-content-type": this.name
593
- },
594
- n
595
- ),
596
- [
597
- "p",
598
- {
599
- ...t,
600
- class: v(
601
- y.inlineContent,
602
- t.class
603
- )
604
- },
605
- 0
606
- ]
607
- ];
608
- }
609
- }), P = {
610
- backgroundColor: {
611
- default: "transparent"
612
- },
613
- textColor: {
614
- default: "black"
615
- // TODO
616
- },
617
- textAlignment: {
618
- default: "left",
619
- values: ["left", "center", "right", "justify"]
620
- }
621
- }, St = {
622
- paragraph: {
623
- propSchema: P,
624
- node: xe
625
- },
626
- heading: {
627
- propSchema: {
628
- ...P,
629
- level: { default: "1", values: ["1", "2", "3"] }
630
- },
631
- node: Se
632
- },
633
- bulletListItem: {
634
- propSchema: P,
635
- node: Me
636
- },
637
- numberedListItem: {
638
- propSchema: P,
639
- node: Te
640
- }
641
- };
642
- function Ae(n, e = JSON.stringify) {
643
- const t = {};
644
- return n.filter((o) => {
645
- const r = e(o);
646
- return Object.prototype.hasOwnProperty.call(t, r) ? !1 : t[r] = !0;
647
- });
648
- }
649
- function Ie(n) {
650
- const e = n.filter(
651
- (o, r) => n.indexOf(o) !== r
652
- );
653
- return Ae(e);
654
- }
655
- const F = T.create({
656
- name: "uniqueID",
657
- // we’ll set a very high priority to make sure this runs first
658
- // and is compatible with `appendTransaction` hooks of other extensions
659
- priority: 1e4,
660
- addOptions() {
661
- return {
662
- attributeName: "id",
663
- types: [],
664
- generateID: () => {
665
- if (typeof window < "u" && window.__TEST_OPTIONS) {
666
- const n = window.__TEST_OPTIONS;
667
- return n.mockID === void 0 ? n.mockID = 0 : n.mockID++, n.mockID.toString();
668
- }
669
- return ie();
670
- },
671
- filterTransaction: null
672
- };
673
- },
674
- addGlobalAttributes() {
675
- return [
676
- {
677
- types: this.options.types,
678
- attributes: {
679
- [this.options.attributeName]: {
680
- default: null,
681
- parseHTML: (n) => n.getAttribute(`data-${this.options.attributeName}`),
682
- renderHTML: (n) => ({
683
- [`data-${this.options.attributeName}`]: n[this.options.attributeName]
684
- })
685
- }
686
- }
188
+ types: this.options.types,
189
+ attributes: {
190
+ [this.options.attributeName]: {
191
+ default: null,
192
+ parseHTML: (n) => n.getAttribute(`data-${this.options.attributeName}`),
193
+ renderHTML: (n) => ({
194
+ [`data-${this.options.attributeName}`]: n[this.options.attributeName]
195
+ })
196
+ }
197
+ }
687
198
  }
688
199
  ];
689
200
  },
@@ -720,38 +231,38 @@ const F = T.create({
720
231
  addProseMirrorPlugins() {
721
232
  let n = null, e = !1;
722
233
  return [
723
- new w({
724
- key: new S("uniqueID"),
234
+ new T({
235
+ key: new B("uniqueID"),
725
236
  appendTransaction: (t, o, r) => {
726
- const i = t.some((m) => m.docChanged) && !o.doc.eq(r.doc), s = this.options.filterTransaction && t.some((m) => {
727
- let g, b;
728
- return !(!((b = (g = this.options).filterTransaction) === null || b === void 0) && b.call(g, m));
237
+ const i = t.some((f) => f.docChanged) && !o.doc.eq(r.doc), s = this.options.filterTransaction && t.some((f) => {
238
+ let k, v;
239
+ return !(!((v = (k = this.options).filterTransaction) === null || v === void 0) && v.call(k, f));
729
240
  });
730
241
  if (!i || s)
731
242
  return;
732
- const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options, h = Dt(
243
+ const { tr: l } = r, { types: a, attributeName: d, generateID: c } = this.options, m = Zt(
733
244
  o.doc,
734
245
  t
735
- ), { mapping: p } = h;
736
- if (Rt(h).forEach(({ newRange: m }) => {
737
- const g = Vt(
246
+ ), { mapping: h } = m;
247
+ if (Qt(m).forEach(({ newRange: f }) => {
248
+ const k = te(
738
249
  r.doc,
739
- m,
740
- (M) => a.includes(M.type.name)
741
- ), b = g.map(({ node: M }) => M.attrs[d]).filter((M) => M !== null), C = Ie(b);
742
- g.forEach(({ node: M, pos: R }) => {
743
- let $;
744
- const Q = ($ = l.doc.nodeAt(R)) === null || $ === void 0 ? void 0 : $.attrs[d];
745
- if (Q === null) {
746
- l.setNodeMarkup(R, void 0, {
747
- ...M.attrs,
250
+ f,
251
+ (E) => a.includes(E.type.name)
252
+ ), v = k.map(({ node: E }) => E.attrs[d]).filter((E) => E !== null), w = Le(v);
253
+ k.forEach(({ node: E, pos: _ }) => {
254
+ let y;
255
+ const M = (y = l.doc.nodeAt(_)) === null || y === void 0 ? void 0 : y.attrs[d];
256
+ if (M === null) {
257
+ l.setNodeMarkup(_, void 0, {
258
+ ...E.attrs,
748
259
  [d]: c()
749
260
  });
750
261
  return;
751
262
  }
752
- const { deleted: Lt } = p.invert().mapResult(R);
753
- Lt && C.includes(Q) && l.setNodeMarkup(R, void 0, {
754
- ...M.attrs,
263
+ const { deleted: ot } = h.invert().mapResult(_);
264
+ ot && w.includes(M) && l.setNodeMarkup(_, void 0, {
265
+ ...E.attrs,
755
266
  [d]: c()
756
267
  });
757
268
  });
@@ -808,9 +319,9 @@ const F = T.create({
808
319
  a.marks
809
320
  );
810
321
  l.push(d);
811
- }), _.from(l);
322
+ }), P.from(l);
812
323
  };
813
- return e = !1, new x(
324
+ return e = !1, new L(
814
325
  i(t.content),
815
326
  t.openStart,
816
327
  t.openEnd
@@ -820,25 +331,37 @@ const F = T.create({
820
331
  })
821
332
  ];
822
333
  }
823
- }), Mt = /* @__PURE__ */ new Set([
334
+ }), Ne = () => /Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
335
+ function Mn(n) {
336
+ return Ne() ? n.replace("Mod", "⌘") : n.replace("Mod", "Ctrl");
337
+ }
338
+ function S(...n) {
339
+ return n.filter((e) => e).join(" ");
340
+ }
341
+ class Pe extends Error {
342
+ constructor(e) {
343
+ super(`Unreachable case: ${e}`);
344
+ }
345
+ }
346
+ const yt = /* @__PURE__ */ new Set([
824
347
  "bold",
825
348
  "italic",
826
349
  "underline",
827
350
  "strike",
828
351
  "code"
829
- ]), Et = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
830
- function it(n, e) {
352
+ ]), vt = /* @__PURE__ */ new Set(["textColor", "backgroundColor"]);
353
+ function at(n, e) {
831
354
  const t = [];
832
355
  for (const [o, r] of Object.entries(n.styles))
833
- Mt.has(o) ? t.push(e.mark(o)) : Et.has(o) && t.push(e.mark(o, { color: r }));
356
+ yt.has(o) ? t.push(e.mark(o)) : vt.has(o) && t.push(e.mark(o, { color: r }));
834
357
  return n.text.split(/(\n)/g).filter((o) => o.length > 0).map((o) => o === `
835
358
  ` ? e.nodes.hardBreak.create() : e.text(o, t));
836
359
  }
837
- function _e(n, e) {
360
+ function De(n, e) {
838
361
  const t = e.marks.link.create({
839
362
  href: n.href
840
363
  });
841
- return Bt(n.content, e).map((o) => {
364
+ return wt(n.content, e).map((o) => {
842
365
  if (o.type.name === "text")
843
366
  return o.mark([...o.marks, t]);
844
367
  if (o.type.name === "hardBreak")
@@ -846,30 +369,30 @@ function _e(n, e) {
846
369
  throw new Error("unexpected node type");
847
370
  });
848
371
  }
849
- function Bt(n, e) {
372
+ function wt(n, e) {
850
373
  const t = [];
851
374
  if (typeof n == "string")
852
375
  return t.push(
853
- ...it({ type: "text", text: n, styles: {} }, e)
376
+ ...at({ type: "text", text: n, styles: {} }, e)
854
377
  ), t;
855
378
  for (const o of n)
856
- t.push(...it(o, e));
379
+ t.push(...at(o, e));
857
380
  return t;
858
381
  }
859
- function Tt(n, e) {
382
+ function Ct(n, e) {
860
383
  const t = [];
861
384
  for (const o of n)
862
385
  if (o.type === "link")
863
- t.push(..._e(o, e));
386
+ t.push(...De(o, e));
864
387
  else if (o.type === "text")
865
- t.push(...Bt([o], e));
388
+ t.push(...wt([o], e));
866
389
  else
867
- throw new ye(o);
390
+ throw new Pe(o);
868
391
  return t;
869
392
  }
870
- function D(n, e) {
393
+ function V(n, e) {
871
394
  let t = n.id;
872
- t === void 0 && (t = F.options.generateID());
395
+ t === void 0 && (t = j.options.generateID());
873
396
  let o = n.type;
874
397
  o === void 0 && (o = "paragraph");
875
398
  let r;
@@ -881,13 +404,13 @@ function D(n, e) {
881
404
  e.text(n.content)
882
405
  );
883
406
  else {
884
- const l = Tt(n.content, e);
407
+ const l = Ct(n.content, e);
885
408
  r = e.nodes[o].create(n.props, l);
886
409
  }
887
410
  const i = [];
888
411
  if (n.children)
889
412
  for (const l of n.children)
890
- i.push(D(l, e));
413
+ i.push(V(l, e));
891
414
  const s = e.nodes.blockGroup.create({}, i);
892
415
  return e.nodes.blockContainer.create(
893
416
  {
@@ -897,7 +420,7 @@ function D(n, e) {
897
420
  i.length > 0 ? [r, s] : r
898
421
  );
899
422
  }
900
- function He(n) {
423
+ function Oe(n) {
901
424
  const e = [];
902
425
  let t;
903
426
  return n.content.forEach((o) => {
@@ -917,9 +440,9 @@ function He(n) {
917
440
  for (const s of o.marks)
918
441
  if (s.type.name === "link")
919
442
  i = s;
920
- else if (Mt.has(s.type.name))
443
+ else if (yt.has(s.type.name))
921
444
  r[s.type.name] = !0;
922
- else if (Et.has(s.type.name))
445
+ else if (vt.has(s.type.name))
923
446
  r[s.type.name] = s.attrs.color;
924
447
  else
925
448
  throw Error("Mark is of an unrecognized type: " + s.type.name);
@@ -974,7 +497,7 @@ function He(n) {
974
497
  };
975
498
  }), t && e.push(t), e;
976
499
  }
977
- function E(n, e, t) {
500
+ function x(n, e, t) {
978
501
  if (n.type.name !== "blockContainer")
979
502
  throw Error(
980
503
  "Node must be of type blockContainer, but is of type" + n.type.name + "."
@@ -982,37 +505,37 @@ function E(n, e, t) {
982
505
  const o = t == null ? void 0 : t.get(n);
983
506
  if (o)
984
507
  return o;
985
- const r = pt(n);
508
+ const r = bt(n);
986
509
  let i = r.id;
987
- i === null && (i = F.options.generateID());
510
+ i === null && (i = j.options.generateID());
988
511
  const s = {};
989
- for (const [c, h] of Object.entries({
512
+ for (const [c, m] of Object.entries({
990
513
  ...n.attrs,
991
514
  ...r.contentNode.attrs
992
515
  })) {
993
- const p = e[r.contentType.name];
994
- if (!p)
516
+ const h = e[r.contentType.name];
517
+ if (!h)
995
518
  throw Error(
996
519
  "Block is of an unrecognized type: " + r.contentType.name
997
520
  );
998
- const f = p.propSchema;
999
- c in f ? s[c] = h : c !== "id" && !(c in P) && console.warn("Block has an unrecognized attribute: " + c);
521
+ const p = h.propSchema;
522
+ c in p ? s[c] = m : c !== "id" && !(c in C) && console.warn("Block has an unrecognized attribute: " + c);
1000
523
  }
1001
- const l = He(r.contentNode), a = [];
524
+ const l = e[r.contentType.name], a = [];
1002
525
  for (let c = 0; c < r.numChildBlocks; c++)
1003
526
  a.push(
1004
- E(n.lastChild.child(c), e, t)
527
+ x(n.lastChild.child(c), e, t)
1005
528
  );
1006
529
  const d = {
1007
530
  id: i,
1008
- type: r.contentType.name,
531
+ type: l.node.name,
1009
532
  props: s,
1010
- content: l,
533
+ content: l.node.config.content === "inline*" ? Oe(r.contentNode) : void 0,
1011
534
  children: a
1012
535
  };
1013
536
  return t == null || t.set(n, d), d;
1014
537
  }
1015
- const st = new S("previous-blocks"), Ne = {
538
+ const lt = new B("previous-blocks"), Re = {
1016
539
  // Numbered List Items
1017
540
  index: "index",
1018
541
  // Headings
@@ -1021,17 +544,17 @@ const st = new S("previous-blocks"), Ne = {
1021
544
  type: "type",
1022
545
  depth: "depth",
1023
546
  "depth-change": "depth-change"
1024
- }, Le = () => {
547
+ }, ze = () => {
1025
548
  let n;
1026
- return new w({
1027
- key: st,
549
+ return new T({
550
+ key: lt,
1028
551
  view(e) {
1029
552
  return {
1030
553
  update: async (t, o) => {
1031
554
  var r;
1032
555
  ((r = this.key) == null ? void 0 : r.getState(t.state).updatedBlocks.size) > 0 && (n = setTimeout(() => {
1033
556
  t.dispatch(
1034
- t.state.tr.setMeta(st, { clearUpdate: !0 })
557
+ t.state.tr.setMeta(lt, { clearUpdate: !0 })
1035
558
  );
1036
559
  }, 0));
1037
560
  },
@@ -1054,25 +577,25 @@ const st = new S("previous-blocks"), Ne = {
1054
577
  apply(e, t, o, r) {
1055
578
  if (t.currentTransactionOldBlockAttrs = {}, t.updatedBlocks.clear(), !e.docChanged || o.doc.eq(r.doc))
1056
579
  return t;
1057
- const i = {}, s = tt(o.doc, (d) => d.attrs.id), l = new Map(
580
+ const i = {}, s = nt(o.doc, (d) => d.attrs.id), l = new Map(
1058
581
  s.map((d) => [d.node.attrs.id, d])
1059
- ), a = tt(r.doc, (d) => d.attrs.id);
582
+ ), a = nt(r.doc, (d) => d.attrs.id);
1060
583
  for (const d of a) {
1061
- const c = l.get(d.node.attrs.id), h = c == null ? void 0 : c.node.firstChild, p = d.node.firstChild;
1062
- if (c && h && p) {
1063
- const f = {
1064
- index: p.attrs.index,
1065
- level: p.attrs.level,
1066
- type: p.type.name,
1067
- depth: r.doc.resolve(d.pos).depth
1068
- };
1069
- let m = {
584
+ const c = l.get(d.node.attrs.id), m = c == null ? void 0 : c.node.firstChild, h = d.node.firstChild;
585
+ if (c && m && h) {
586
+ const p = {
1070
587
  index: h.attrs.index,
1071
588
  level: h.attrs.level,
1072
589
  type: h.type.name,
590
+ depth: r.doc.resolve(d.pos).depth
591
+ };
592
+ let f = {
593
+ index: m.attrs.index,
594
+ level: m.attrs.level,
595
+ type: m.type.name,
1073
596
  depth: o.doc.resolve(c.pos).depth
1074
597
  };
1075
- i[d.node.attrs.id] = m, e.getMeta("numberedListIndexing") && (d.node.attrs.id in t.prevTransactionOldBlockAttrs && (m = t.prevTransactionOldBlockAttrs[d.node.attrs.id]), f.type === "numberedListItem" && (m.index = f.index)), t.currentTransactionOldBlockAttrs[d.node.attrs.id] = m, JSON.stringify(m) !== JSON.stringify(f) && (m["depth-change"] = m.depth - f.depth, t.updatedBlocks.add(d.node.attrs.id));
598
+ i[d.node.attrs.id] = f, e.getMeta("numberedListIndexing") && (d.node.attrs.id in t.prevTransactionOldBlockAttrs && (f = t.prevTransactionOldBlockAttrs[d.node.attrs.id]), p.type === "numberedListItem" && (f.index = p.index)), t.currentTransactionOldBlockAttrs[d.node.attrs.id] = f, JSON.stringify(f) !== JSON.stringify(p) && (f["depth-change"] = f.depth - p.depth, t.updatedBlocks.add(d.node.attrs.id));
1076
599
  }
1077
600
  }
1078
601
  return t.prevTransactionOldBlockAttrs = i, t;
@@ -1089,22 +612,69 @@ const st = new S("previous-blocks"), Ne = {
1089
612
  return;
1090
613
  const s = t.currentTransactionOldBlockAttrs[r.attrs.id], l = {};
1091
614
  for (const [d, c] of Object.entries(s))
1092
- l["data-prev-" + Ne[d]] = c || "none";
1093
- const a = V.node(i, i + r.nodeSize, {
615
+ l["data-prev-" + Re[d]] = c || "none";
616
+ const a = W.node(i, i + r.nodeSize, {
1094
617
  ...l
1095
618
  });
1096
619
  o.push(a);
1097
- }), z.create(e.doc, o);
620
+ }), $.create(e.doc, o);
1098
621
  }
1099
622
  }
1100
623
  });
1101
- }, Pe = {
624
+ }, Et = "_blockOuter_xo7pf_5", St = "_block_xo7pf_5", Tt = "_reactNodeViewRenderer_xo7pf_17", Mt = "_blockContent_xo7pf_22", Bt = "_blockGroup_xo7pf_42", xt = "_wrapper_xo7pf_226", It = "_addImageButton_xo7pf_234", At = "_addImageButtonIcon_xo7pf_250", _t = "_addImageButtonText_xo7pf_256", Ht = "_imageAndCaptionWrapper_xo7pf_260", Lt = "_imageWrapper_xo7pf_266", Nt = "_image_xo7pf_260", Pt = "_resizeHandle_xo7pf_279", Dt = "_caption_xo7pf_294", Ot = "_isEmpty_xo7pf_300", Rt = "_inlineContent_xo7pf_300", zt = "_isFilter_xo7pf_301", Vt = "_hasAnchor_xo7pf_313", g = {
625
+ blockOuter: Et,
626
+ block: St,
627
+ reactNodeViewRenderer: Tt,
628
+ blockContent: Mt,
629
+ blockGroup: Bt,
630
+ wrapper: xt,
631
+ addImageButton: It,
632
+ addImageButtonIcon: At,
633
+ addImageButtonText: _t,
634
+ imageAndCaptionWrapper: Ht,
635
+ imageWrapper: Lt,
636
+ image: Nt,
637
+ resizeHandle: Pt,
638
+ caption: Dt,
639
+ isEmpty: Ot,
640
+ inlineContent: Rt,
641
+ isFilter: zt,
642
+ hasAnchor: Vt
643
+ }, Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
644
+ __proto__: null,
645
+ addImageButton: It,
646
+ addImageButtonIcon: At,
647
+ addImageButtonText: _t,
648
+ block: St,
649
+ blockContent: Mt,
650
+ blockGroup: Bt,
651
+ blockOuter: Et,
652
+ caption: Dt,
653
+ default: g,
654
+ hasAnchor: Vt,
655
+ image: Nt,
656
+ imageAndCaptionWrapper: Ht,
657
+ imageWrapper: Lt,
658
+ inlineContent: Rt,
659
+ isEmpty: Ot,
660
+ isFilter: zt,
661
+ reactNodeViewRenderer: Tt,
662
+ resizeHandle: Pt,
663
+ wrapper: xt
664
+ }, Symbol.toStringTag, { value: "Module" })), Ve = {
1102
665
  blockColor: "data-block-color",
1103
666
  blockStyle: "data-block-style",
1104
667
  id: "data-id",
1105
668
  depth: "data-depth",
1106
669
  depthChange: "data-depth-change"
1107
- }, Oe = U.create({
670
+ }, Ue = new B("non-editable-block"), Fe = () => new T({
671
+ key: Ue,
672
+ props: {
673
+ handleKeyDown: (n, e) => {
674
+ "node" in n.state.selection && e.preventDefault();
675
+ }
676
+ }
677
+ }), We = G.create({
1108
678
  name: "blockContainer",
1109
679
  group: "blockContainer",
1110
680
  // A block always contains content, and optionally a blockGroup which contains nested blocks
@@ -1120,7 +690,7 @@ const st = new S("previous-blocks"), Ne = {
1120
690
  if (typeof n == "string")
1121
691
  return !1;
1122
692
  const e = {};
1123
- for (const [t, o] of Object.entries(Pe))
693
+ for (const [t, o] of Object.entries(Ve))
1124
694
  n.getAttribute(o) && (e[t] = n.getAttribute(o));
1125
695
  return n.getAttribute("data-node-type") === "blockContainer" ? e : !1;
1126
696
  }
@@ -1132,16 +702,16 @@ const st = new S("previous-blocks"), Ne = {
1132
702
  const e = ((t = this.options.domAttributes) == null ? void 0 : t.blockContainer) || {};
1133
703
  return [
1134
704
  "div",
1135
- A(n, {
1136
- class: y.blockOuter,
705
+ N(n, {
706
+ class: g.blockOuter,
1137
707
  "data-node-type": "block-outer"
1138
708
  }),
1139
709
  [
1140
710
  "div",
1141
- A(
711
+ N(
1142
712
  {
1143
713
  ...e,
1144
- class: v(y.block, e.class),
714
+ class: S(g.block, e.class),
1145
715
  "data-node-type": this.name
1146
716
  },
1147
717
  n
@@ -1159,7 +729,7 @@ const st = new S("previous-blocks"), Ne = {
1159
729
  },
1160
730
  // Deletes a block at a given position.
1161
731
  BNDeleteBlock: (n) => ({ state: e, dispatch: t }) => {
1162
- const o = k(e.doc, n);
732
+ const o = b(e.doc, n);
1163
733
  if (o === void 0)
1164
734
  return !1;
1165
735
  const { startPos: r, endPos: i } = o;
@@ -1167,33 +737,43 @@ const st = new S("previous-blocks"), Ne = {
1167
737
  },
1168
738
  // Updates a block at a given position.
1169
739
  BNUpdateBlock: (n, e) => ({ state: t, dispatch: o }) => {
1170
- const r = k(t.doc, n);
740
+ const r = b(t.doc, n);
1171
741
  if (r === void 0)
1172
742
  return !1;
1173
743
  const { startPos: i, endPos: s, node: l, contentNode: a } = r;
1174
744
  if (o) {
1175
745
  if (e.children !== void 0) {
1176
- const d = [];
1177
- for (const c of e.children)
1178
- d.push(D(c, t.schema));
746
+ const p = [];
747
+ for (const f of e.children)
748
+ p.push(V(f, t.schema));
1179
749
  l.childCount === 2 ? t.tr.replace(
1180
750
  i + a.nodeSize + 1,
1181
751
  s - 1,
1182
- new x(_.from(d), 0, 0)
752
+ new L(P.from(p), 0, 0)
1183
753
  ) : t.tr.insert(
1184
754
  i + a.nodeSize,
1185
- t.schema.nodes.blockGroup.create({}, d)
755
+ t.schema.nodes.blockGroup.create({}, p)
1186
756
  );
1187
757
  }
1188
758
  if (e.content !== void 0) {
1189
- let d = [];
1190
- typeof e.content == "string" ? d.push(t.schema.text(e.content)) : d = Tt(e.content, t.schema), t.tr.replace(
759
+ let p = [];
760
+ typeof e.content == "string" ? p.push(t.schema.text(e.content)) : p = Ct(e.content, t.schema), t.tr.replace(
1191
761
  i + 1,
1192
762
  i + a.nodeSize - 1,
1193
- new x(_.from(d), 0, 0)
763
+ new L(P.from(p), 0, 0)
1194
764
  );
1195
765
  }
1196
- t.tr.setNodeMarkup(
766
+ const d = a.type.name, c = e.type || d, m = t.schema.nodes[d].spec.content, h = t.schema.nodes[c].spec.content;
767
+ m === "inline*" && h === "" ? t.tr.replaceWith(
768
+ i,
769
+ s,
770
+ t.schema.nodes[c].create({
771
+ ...a.attrs,
772
+ ...e.props
773
+ })
774
+ ).setSelection(
775
+ new mt(t.tr.doc.resolve(i))
776
+ ) : t.tr.setNodeMarkup(
1197
777
  i,
1198
778
  e.type === void 0 ? void 0 : t.schema.nodes[e.type],
1199
779
  {
@@ -1228,57 +808,57 @@ const st = new S("previous-blocks"), Ne = {
1228
808
  const o = e.doc.resolve(n + 1).node().type.name === "blockContainer", r = e.doc.resolve(n - 1).node().type.name === "blockContainer";
1229
809
  if (!o || !r)
1230
810
  return !1;
1231
- const i = k(
811
+ const i = b(
1232
812
  e.doc,
1233
813
  n + 1
1234
814
  ), { node: s, contentNode: l, startPos: a, endPos: d, depth: c } = i;
1235
815
  if (s.childCount === 2) {
1236
- const f = e.doc.resolve(
816
+ const p = e.doc.resolve(
1237
817
  a + l.nodeSize + 1
1238
- ), m = e.doc.resolve(d - 1), g = f.blockRange(m);
1239
- t && e.tr.lift(g, c - 1);
818
+ ), f = e.doc.resolve(d - 1), k = p.blockRange(f);
819
+ t && e.tr.lift(k, c - 1);
1240
820
  }
1241
- let h = n - 1, p = k(e.doc, h);
1242
- for (; p.numChildBlocks > 0; )
1243
- if (h--, p = k(e.doc, h), p === void 0)
821
+ let m = n - 1, h = b(e.doc, m);
822
+ for (; h.numChildBlocks > 0; )
823
+ if (m--, h = b(e.doc, m), h === void 0)
1244
824
  return !1;
1245
825
  return t && (t(
1246
826
  e.tr.deleteRange(a, a + l.nodeSize).replace(
1247
- h - 1,
827
+ m - 1,
1248
828
  a,
1249
- new x(l.content, 0, 0)
829
+ new L(l.content, 0, 0)
1250
830
  ).scrollIntoView()
1251
831
  ), e.tr.setSelection(
1252
- new ot(e.doc.resolve(h - 1))
832
+ new it(e.doc.resolve(m - 1))
1253
833
  )), !0;
1254
834
  },
1255
835
  // Splits a block at a given position. Content after the position is moved to a new block below, at the same
1256
836
  // nesting level.
1257
837
  BNSplitBlock: (n, e) => ({ state: t, dispatch: o }) => {
1258
- const r = k(t.doc, n);
838
+ const r = b(t.doc, n);
1259
839
  if (r === void 0)
1260
840
  return !1;
1261
- const { contentNode: i, contentType: s, startPos: l, endPos: a, depth: d } = r, c = t.doc.cut(l + 1, n), h = t.doc.cut(n, a - 1), p = t.schema.nodes.blockContainer.createAndFill(), f = a + 1, m = f + 2;
1262
- return o && (t.tr.insert(f, p), t.tr.replace(
1263
- m,
1264
- m + 1,
1265
- h.content.size > 0 ? new x(
1266
- _.from(h),
841
+ const { contentNode: i, contentType: s, startPos: l, endPos: a, depth: d } = r, c = t.doc.cut(l + 1, n), m = t.doc.cut(n, a - 1), h = t.schema.nodes.blockContainer.createAndFill(), p = a + 1, f = p + 2;
842
+ return o && (t.tr.insert(p, h), t.tr.replace(
843
+ f,
844
+ f + 1,
845
+ m.content.size > 0 ? new L(
846
+ P.from(m),
1267
847
  d + 2,
1268
848
  d + 2
1269
849
  ) : void 0
1270
850
  ), e && t.tr.setBlockType(
1271
- m,
1272
- m,
851
+ f,
852
+ f,
1273
853
  t.schema.node(s).type,
1274
854
  i.attrs
1275
855
  ), t.tr.setSelection(
1276
- new ot(t.doc.resolve(m))
856
+ new it(t.doc.resolve(f))
1277
857
  ), t.tr.replace(
1278
858
  l + 1,
1279
859
  a - 1,
1280
- c.content.size > 0 ? new x(
1281
- _.from(c),
860
+ c.content.size > 0 ? new L(
861
+ P.from(c),
1282
862
  d + 2,
1283
863
  d + 2
1284
864
  ) : void 0
@@ -1287,7 +867,7 @@ const st = new S("previous-blocks"), Ne = {
1287
867
  };
1288
868
  },
1289
869
  addProseMirrorPlugins() {
1290
- return [Le()];
870
+ return [ze(), Fe()];
1291
871
  },
1292
872
  addKeyboardShortcuts() {
1293
873
  return {
@@ -1298,7 +878,7 @@ const st = new S("previous-blocks"), Ne = {
1298
878
  () => t.undoInputRule(),
1299
879
  // Reverts block content type to a paragraph if the selection is at the start of the block.
1300
880
  () => t.command(({ state: o }) => {
1301
- const { contentType: r } = k(
881
+ const { contentType: r } = b(
1302
882
  o.doc,
1303
883
  o.selection.from
1304
884
  ), i = o.selection.$anchor.parentOffset === 0, s = r.name === "paragraph";
@@ -1312,7 +892,7 @@ const st = new S("previous-blocks"), Ne = {
1312
892
  // Merges block with the previous one if it isn't indented, isn't the first block in the doc, and the selection
1313
893
  // is at the start of the block.
1314
894
  () => t.command(({ state: o }) => {
1315
- const { depth: r, startPos: i } = k(
895
+ const { depth: r, startPos: i } = b(
1316
896
  o.doc,
1317
897
  o.selection.from
1318
898
  ), s = o.selection.$anchor.parentOffset === 0, l = o.selection.anchor === o.selection.head, a = i === 2, d = i - 1;
@@ -1323,7 +903,7 @@ const st = new S("previous-blocks"), Ne = {
1323
903
  // Removes a level of nesting if the block is empty & indented, while the selection is also empty & at the start
1324
904
  // of the block.
1325
905
  () => t.command(({ state: o }) => {
1326
- const { node: r, depth: i } = k(
906
+ const { node: r, depth: i } = b(
1327
907
  o.doc,
1328
908
  o.selection.from
1329
909
  ), s = o.selection.$anchor.parentOffset === 0, l = o.selection.anchor === o.selection.head, a = r.textContent.length === 0, d = i > 2;
@@ -1332,20 +912,20 @@ const st = new S("previous-blocks"), Ne = {
1332
912
  // Creates a new block and moves the selection to it if the current one is empty, while the selection is also
1333
913
  // empty & at the start of the block.
1334
914
  () => t.command(({ state: o, chain: r }) => {
1335
- const { node: i, endPos: s } = k(
915
+ const { node: i, endPos: s } = b(
1336
916
  o.doc,
1337
917
  o.selection.from
1338
918
  ), l = o.selection.$anchor.parentOffset === 0, a = o.selection.anchor === o.selection.head, d = i.textContent.length === 0;
1339
919
  if (l && a && d) {
1340
- const c = s + 1, h = c + 2;
1341
- return r().BNCreateBlock(c).setTextSelection(h).run(), !0;
920
+ const c = s + 1, m = c + 2;
921
+ return r().BNCreateBlock(c).setTextSelection(m).run(), !0;
1342
922
  }
1343
923
  return !1;
1344
924
  }),
1345
925
  // Splits the current block, moving content inside that's after the cursor to a new text block below. Also
1346
926
  // deletes the selection beforehand, if it's not empty.
1347
927
  () => t.command(({ state: o, chain: r }) => {
1348
- const { node: i } = k(
928
+ const { node: i } = b(
1349
929
  o.doc,
1350
930
  o.selection.from
1351
931
  );
@@ -1358,36 +938,10 @@ const st = new S("previous-blocks"), Ne = {
1358
938
  "Shift-Tab": () => (this.editor.commands.liftListItem("blockContainer"), !0),
1359
939
  "Mod-Alt-0": () => this.editor.commands.BNCreateBlock(
1360
940
  this.editor.state.selection.anchor + 2
1361
- ),
1362
- "Mod-Alt-1": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
1363
- type: "heading",
1364
- props: {
1365
- level: "1"
1366
- }
1367
- }),
1368
- "Mod-Alt-2": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
1369
- type: "heading",
1370
- props: {
1371
- level: "2"
1372
- }
1373
- }),
1374
- "Mod-Alt-3": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
1375
- type: "heading",
1376
- props: {
1377
- level: "3"
1378
- }
1379
- }),
1380
- "Mod-Shift-7": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
1381
- type: "bulletListItem",
1382
- props: {}
1383
- }),
1384
- "Mod-Shift-8": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
1385
- type: "numberedListItem",
1386
- props: {}
1387
- })
941
+ )
1388
942
  };
1389
943
  }
1390
- }), De = U.create({
944
+ }), $e = G.create({
1391
945
  name: "blockGroup",
1392
946
  group: "blockGroup",
1393
947
  content: "blockContainer+",
@@ -1404,11 +958,11 @@ const st = new S("previous-blocks"), Ne = {
1404
958
  const e = ((t = this.options.domAttributes) == null ? void 0 : t.blockGroup) || {};
1405
959
  return [
1406
960
  "div",
1407
- A(
961
+ N(
1408
962
  {
1409
963
  ...e,
1410
- class: v(
1411
- y.blockGroup,
964
+ class: S(
965
+ g.blockGroup,
1412
966
  e.class
1413
967
  ),
1414
968
  "data-node-type": "blockGroup"
@@ -1418,13 +972,13 @@ const st = new S("previous-blocks"), Ne = {
1418
972
  0
1419
973
  ];
1420
974
  }
1421
- }), Re = U.create({
975
+ }), Ge = G.create({
1422
976
  name: "doc",
1423
977
  topNode: !0,
1424
978
  content: "blockGroup"
1425
- }), Ve = (n) => {
1426
- const e = W.fromSchema(n);
1427
- return new W(
979
+ }), je = (n) => {
980
+ const e = Y.fromSchema(n);
981
+ return new Y(
1428
982
  {
1429
983
  ...e.nodes
1430
984
  // TODO: If a serializer is defined in the config for a custom block, it
@@ -1434,18 +988,18 @@ const st = new S("previous-blocks"), Ne = {
1434
988
  },
1435
989
  e.marks
1436
990
  );
1437
- }, ze = T.create({
991
+ }, qe = A.create({
1438
992
  addProseMirrorPlugins() {
1439
993
  return [
1440
- new w({
994
+ new T({
1441
995
  props: {
1442
- clipboardSerializer: Ve(this.editor.schema)
996
+ clipboardSerializer: je(this.editor.schema)
1443
997
  }
1444
998
  })
1445
999
  ];
1446
1000
  }
1447
1001
  });
1448
- class G {
1002
+ class U {
1449
1003
  constructor() {
1450
1004
  // eslint-disable-next-line @typescript-eslint/ban-types
1451
1005
  u(this, "callbacks", {});
@@ -1465,10 +1019,10 @@ class G {
1465
1019
  this.callbacks = {};
1466
1020
  }
1467
1021
  }
1468
- const Ue = zt(
1022
+ const Xe = ee(
1469
1023
  (n) => n.type.name === "blockContainer"
1470
1024
  );
1471
- class Fe {
1025
+ class Ke {
1472
1026
  constructor(e, t, o = () => {
1473
1027
  }) {
1474
1028
  u(this, "suggestionsMenuState");
@@ -1483,7 +1037,7 @@ class Fe {
1483
1037
  this.suggestionsMenuState.referencePos = t.getBoundingClientRect(), this.updateSuggestionsMenu();
1484
1038
  }
1485
1039
  });
1486
- this.editor = e, this.pluginKey = t, this.pluginState = Y(), this.updateSuggestionsMenu = () => {
1040
+ this.editor = e, this.pluginKey = t, this.pluginState = J(), this.updateSuggestionsMenu = () => {
1487
1041
  if (!this.suggestionsMenuState)
1488
1042
  throw new Error("Attempting to update uninitialized suggestions menu");
1489
1043
  o(this.suggestionsMenuState);
@@ -1511,7 +1065,7 @@ class Fe {
1511
1065
  document.removeEventListener("scroll", this.handleScroll);
1512
1066
  }
1513
1067
  }
1514
- function Y() {
1068
+ function J() {
1515
1069
  return {
1516
1070
  active: !1,
1517
1071
  triggerCharacter: void 0,
@@ -1522,7 +1076,7 @@ function Y() {
1522
1076
  decorationId: void 0
1523
1077
  };
1524
1078
  }
1525
- const Ge = (n, e, t, o, r = () => [], i = () => {
1079
+ const Ye = (n, e, t, o, r = () => [], i = () => {
1526
1080
  }) => {
1527
1081
  if (o.length !== 1)
1528
1082
  throw new Error("'char' should be a single character");
@@ -1531,9 +1085,9 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
1531
1085
  a.dispatch(a.state.tr.setMeta(t, { deactivate: !0 }));
1532
1086
  };
1533
1087
  return {
1534
- plugin: new w({
1088
+ plugin: new T({
1535
1089
  key: t,
1536
- view: () => (s = new Fe(
1090
+ view: () => (s = new Ke(
1537
1091
  n,
1538
1092
  t,
1539
1093
  e
@@ -1541,18 +1095,18 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
1541
1095
  state: {
1542
1096
  // Initialize the plugin's internal state.
1543
1097
  init() {
1544
- return Y();
1098
+ return J();
1545
1099
  },
1546
1100
  // Apply changes to the plugin state from an editor transaction.
1547
- apply(a, d, c, h) {
1548
- var f, m, g, b;
1101
+ apply(a, d, c, m) {
1102
+ var p, f, k, v;
1549
1103
  if (a.getMeta("orderedListIndexing") !== void 0)
1550
1104
  return d;
1551
- if ((f = a.getMeta(t)) != null && f.activate)
1105
+ if ((p = a.getMeta(t)) != null && p.activate)
1552
1106
  return {
1553
1107
  active: !0,
1554
- triggerCharacter: ((m = a.getMeta(t)) == null ? void 0 : m.triggerCharacter) || "",
1555
- queryStartPos: h.selection.from,
1108
+ triggerCharacter: ((f = a.getMeta(t)) == null ? void 0 : f.triggerCharacter) || "",
1109
+ queryStartPos: m.selection.from,
1556
1110
  items: r(""),
1557
1111
  keyboardHoveredItemIndex: 0,
1558
1112
  // TODO: Maybe should be 1 if the menu has no possible items? Probably redundant since a menu with no items
@@ -1562,30 +1116,30 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
1562
1116
  };
1563
1117
  if (!d.active)
1564
1118
  return d;
1565
- const p = { ...d };
1566
- if (p.items = r(
1567
- h.doc.textBetween(
1119
+ const h = { ...d };
1120
+ if (h.items = r(
1121
+ m.doc.textBetween(
1568
1122
  d.queryStartPos,
1569
- h.selection.from
1123
+ m.selection.from
1570
1124
  )
1571
- ), p.notFoundCount = 0, p.items.length === 0 && (p.notFoundCount = Math.max(
1125
+ ), h.notFoundCount = 0, h.items.length === 0 && (h.notFoundCount = Math.max(
1572
1126
  0,
1573
- d.notFoundCount + (h.selection.from - c.selection.from)
1127
+ d.notFoundCount + (m.selection.from - c.selection.from)
1574
1128
  )), // Highlighting text should hide the menu.
1575
- h.selection.from !== h.selection.to || // Transactions with plugin metadata {deactivate: true} should hide the menu.
1576
- (g = a.getMeta(t)) != null && g.deactivate || // Certain mouse events should hide the menu.
1129
+ m.selection.from !== m.selection.to || // Transactions with plugin metadata {deactivate: true} should hide the menu.
1130
+ (k = a.getMeta(t)) != null && k.deactivate || // Certain mouse events should hide the menu.
1577
1131
  // TODO: Change to global mousedown listener.
1578
1132
  a.getMeta("focus") || a.getMeta("blur") || a.getMeta("pointer") || // Moving the caret before the character which triggered the menu should hide it.
1579
- d.active && h.selection.from < d.queryStartPos || // Entering more than 3 characters, after the last query that matched with at least 1 menu item, should hide
1133
+ d.active && m.selection.from < d.queryStartPos || // Entering more than 3 characters, after the last query that matched with at least 1 menu item, should hide
1580
1134
  // the menu.
1581
- p.notFoundCount > 3)
1582
- return Y();
1583
- if (((b = a.getMeta(t)) == null ? void 0 : b.selectedItemIndexChanged) !== void 0) {
1584
- let C = a.getMeta(t).selectedItemIndexChanged;
1585
- C < 0 ? C = d.items.length - 1 : C >= d.items.length && (C = 0), p.keyboardHoveredItemIndex = C;
1135
+ h.notFoundCount > 3)
1136
+ return J();
1137
+ if (((v = a.getMeta(t)) == null ? void 0 : v.selectedItemIndexChanged) !== void 0) {
1138
+ let w = a.getMeta(t).selectedItemIndexChanged;
1139
+ w < 0 ? w = d.items.length - 1 : w >= d.items.length && (w = 0), h.keyboardHoveredItemIndex = w;
1586
1140
  } else
1587
- c.selection.from !== h.selection.from && (p.keyboardHoveredItemIndex = 0);
1588
- return p;
1141
+ c.selection.from !== m.selection.from && (h.keyboardHoveredItemIndex = 0);
1142
+ return h;
1589
1143
  }
1590
1144
  },
1591
1145
  props: {
@@ -1601,39 +1155,39 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
1601
1155
  if (!c)
1602
1156
  return !1;
1603
1157
  const {
1604
- triggerCharacter: h,
1605
- queryStartPos: p,
1606
- items: f,
1607
- keyboardHoveredItemIndex: m
1158
+ triggerCharacter: m,
1159
+ queryStartPos: h,
1160
+ items: p,
1161
+ keyboardHoveredItemIndex: f
1608
1162
  } = t.getState(a.state);
1609
1163
  return d.key === "ArrowUp" ? (a.dispatch(
1610
1164
  a.state.tr.setMeta(t, {
1611
- selectedItemIndexChanged: m - 1
1165
+ selectedItemIndexChanged: f - 1
1612
1166
  })
1613
1167
  ), !0) : d.key === "ArrowDown" ? (a.dispatch(
1614
1168
  a.state.tr.setMeta(t, {
1615
- selectedItemIndexChanged: m + 1
1169
+ selectedItemIndexChanged: f + 1
1616
1170
  })
1617
1171
  ), !0) : d.key === "Enter" ? (l(a), n._tiptapEditor.chain().focus().deleteRange({
1618
- from: p - h.length,
1172
+ from: h - m.length,
1619
1173
  to: n._tiptapEditor.state.selection.from
1620
1174
  }).run(), i({
1621
- item: f[m],
1175
+ item: p[f],
1622
1176
  editor: n
1623
1177
  }), !0) : d.key === "Escape" ? (l(a), !0) : !1;
1624
1178
  },
1625
1179
  // Setup decorator on the currently active suggestion.
1626
1180
  decorations(a) {
1627
- const { active: d, decorationId: c, queryStartPos: h, triggerCharacter: p } = this.getState(a);
1181
+ const { active: d, decorationId: c, queryStartPos: m, triggerCharacter: h } = this.getState(a);
1628
1182
  if (!d)
1629
1183
  return null;
1630
- if (p === "") {
1631
- const f = Ue(a.selection);
1632
- if (f)
1633
- return z.create(a.doc, [
1634
- V.node(
1635
- f.pos,
1636
- f.pos + f.node.nodeSize,
1184
+ if (h === "") {
1185
+ const p = Xe(a.selection);
1186
+ if (p)
1187
+ return $.create(a.doc, [
1188
+ W.node(
1189
+ p.pos,
1190
+ p.pos + p.node.nodeSize,
1637
1191
  {
1638
1192
  nodeName: "span",
1639
1193
  class: "suggestion-decorator",
@@ -1642,10 +1196,10 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
1642
1196
  )
1643
1197
  ]);
1644
1198
  }
1645
- return z.create(a.doc, [
1646
- V.inline(
1647
- h - p.length,
1648
- h,
1199
+ return $.create(a.doc, [
1200
+ W.inline(
1201
+ m - h.length,
1202
+ m,
1649
1203
  {
1650
1204
  nodeName: "span",
1651
1205
  class: "suggestion-decorator",
@@ -1666,18 +1220,18 @@ const Ge = (n, e, t, o, r = () => [], i = () => {
1666
1220
  });
1667
1221
  }
1668
1222
  };
1669
- }, X = new S("SlashMenuPlugin");
1670
- class $e extends G {
1223
+ }, tt = new B("SlashMenuPlugin");
1224
+ class Je extends U {
1671
1225
  constructor(t, o) {
1672
1226
  super();
1673
1227
  u(this, "plugin");
1674
1228
  u(this, "itemCallback");
1675
- const r = Ge(
1229
+ const r = Ye(
1676
1230
  t,
1677
1231
  (i) => {
1678
1232
  this.emit("update", i);
1679
1233
  },
1680
- X,
1234
+ tt,
1681
1235
  "/",
1682
1236
  (i) => o.filter(
1683
1237
  ({ name: s, aliases: l }) => s.toLowerCase().startsWith(i.toLowerCase()) || l && l.filter(
@@ -1692,7 +1246,7 @@ class $e extends G {
1692
1246
  return this.on("update", t);
1693
1247
  }
1694
1248
  }
1695
- const je = new S("blocknote-placeholder"), qe = T.create({
1249
+ const Ze = new B("blocknote-placeholder"), Qe = A.create({
1696
1250
  name: "placeholder",
1697
1251
  addOptions() {
1698
1252
  return {
@@ -1708,30 +1262,30 @@ const je = new S("blocknote-placeholder"), qe = T.create({
1708
1262
  },
1709
1263
  addProseMirrorPlugins() {
1710
1264
  return [
1711
- new w({
1712
- key: je,
1265
+ new T({
1266
+ key: Ze,
1713
1267
  props: {
1714
1268
  decorations: (n) => {
1715
- const { doc: e, selection: t } = n, o = X.getState(n), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = t, s = [];
1269
+ const { doc: e, selection: t } = n, o = tt.getState(n), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = t, s = [];
1716
1270
  if (r)
1717
1271
  return e.descendants((l, a) => {
1718
1272
  const d = i >= a && i <= a + l.nodeSize, c = !l.isLeaf && !l.childCount;
1719
1273
  if ((d || !this.options.showOnlyCurrent) && c) {
1720
- const h = [this.options.emptyNodeClass];
1721
- this.editor.isEmpty && h.push(this.options.emptyEditorClass), d && h.push(this.options.hasAnchorClass), (o == null ? void 0 : o.triggerCharacter) === "" && (o != null && o.active) && h.push(this.options.isFilterClass);
1722
- const p = V.node(a, a + l.nodeSize, {
1723
- class: h.join(" ")
1274
+ const m = [this.options.emptyNodeClass];
1275
+ this.editor.isEmpty && m.push(this.options.emptyEditorClass), d && m.push(this.options.hasAnchorClass), (o == null ? void 0 : o.triggerCharacter) === "" && (o != null && o.active) && m.push(this.options.isFilterClass);
1276
+ const h = W.node(a, a + l.nodeSize, {
1277
+ class: m.join(" ")
1724
1278
  });
1725
- s.push(p);
1279
+ s.push(h);
1726
1280
  }
1727
1281
  return this.options.includeChildren;
1728
- }), z.create(e, s);
1282
+ }), $.create(e, s);
1729
1283
  }
1730
1284
  }
1731
1285
  })
1732
1286
  ];
1733
1287
  }
1734
- }), We = T.create({
1288
+ }), to = A.create({
1735
1289
  name: "textAlignment",
1736
1290
  addGlobalAttributes() {
1737
1291
  return [
@@ -1754,7 +1308,7 @@ const je = new S("blocknote-placeholder"), qe = T.create({
1754
1308
  addCommands() {
1755
1309
  return {
1756
1310
  setTextAlignment: (n) => ({ state: e }) => {
1757
- const t = [], o = k(
1311
+ const t = [], o = b(
1758
1312
  e.doc,
1759
1313
  e.selection.from
1760
1314
  );
@@ -1769,7 +1323,7 @@ const je = new S("blocknote-placeholder"), qe = T.create({
1769
1323
  }
1770
1324
  };
1771
1325
  }
1772
- }), Ye = T.create({
1326
+ }), eo = A.create({
1773
1327
  name: "blockTextColor",
1774
1328
  addGlobalAttributes() {
1775
1329
  return [
@@ -1777,9 +1331,9 @@ const je = new S("blocknote-placeholder"), qe = T.create({
1777
1331
  types: ["blockContainer"],
1778
1332
  attributes: {
1779
1333
  textColor: {
1780
- default: "default",
1781
- parseHTML: (n) => n.hasAttribute("data-text-color") ? n.getAttribute("data-text-color") : "default",
1782
- renderHTML: (n) => n.textColor !== "default" && {
1334
+ default: C.textColor.default,
1335
+ parseHTML: (n) => n.hasAttribute("data-text-color") ? n.getAttribute("data-text-color") : C.textColor.default,
1336
+ renderHTML: (n) => n.textColor !== C.textColor.default && {
1783
1337
  "data-text-color": n.textColor
1784
1338
  }
1785
1339
  }
@@ -1790,12 +1344,12 @@ const je = new S("blocknote-placeholder"), qe = T.create({
1790
1344
  addCommands() {
1791
1345
  return {
1792
1346
  setBlockTextColor: (n, e) => ({ state: t, view: o }) => {
1793
- const r = k(t.doc, n);
1347
+ const r = b(t.doc, n);
1794
1348
  return r === void 0 ? !1 : (t.tr.setNodeAttribute(r.startPos - 1, "textColor", e), o.focus(), !0);
1795
1349
  }
1796
1350
  };
1797
1351
  }
1798
- }), Ke = lt.create({
1352
+ }), oo = ht.create({
1799
1353
  name: "textColor",
1800
1354
  addAttributes() {
1801
1355
  return {
@@ -1821,15 +1375,15 @@ const je = new S("blocknote-placeholder"), qe = T.create({
1821
1375
  },
1822
1376
  addCommands() {
1823
1377
  return {
1824
- setTextColor: (n) => ({ commands: e }) => n !== "default" ? e.setMark(this.name, { color: n }) : e.unsetMark(this.name)
1378
+ setTextColor: (n) => ({ commands: e }) => n !== C.textColor.default ? e.setMark(this.name, { color: n }) : e.unsetMark(this.name)
1825
1379
  };
1826
1380
  }
1827
- }), Je = T.create({
1381
+ }), no = A.create({
1828
1382
  name: "trailingNode",
1829
1383
  addProseMirrorPlugins() {
1830
- const n = new S(this.name);
1384
+ const n = new B(this.name);
1831
1385
  return [
1832
- new w({
1386
+ new T({
1833
1387
  key: n,
1834
1388
  appendTransaction: (e, t, o) => {
1835
1389
  const { doc: r, tr: i, schema: s } = o, l = n.getState(o), a = r.content.size - 2, d = s.nodes.blockContainer, c = s.nodes.paragraph;
@@ -1839,278 +1393,994 @@ const je = new S("blocknote-placeholder"), qe = T.create({
1839
1393
  d.create(void 0, c.create())
1840
1394
  );
1841
1395
  },
1842
- state: {
1843
- init: (e, t) => {
1844
- },
1845
- apply: (e, t) => {
1846
- if (!e.docChanged)
1847
- return t;
1848
- let o = e.doc.lastChild;
1849
- if (!o || o.type.name !== "blockGroup")
1850
- throw new Error("Expected blockGroup");
1851
- if (o = o.lastChild, !o || o.type.name !== "blockContainer")
1852
- throw new Error("Expected blockContainer");
1853
- return o.nodeSize > 4;
1854
- }
1855
- }
1856
- })
1396
+ state: {
1397
+ init: (e, t) => {
1398
+ },
1399
+ apply: (e, t) => {
1400
+ if (!e.docChanged)
1401
+ return t;
1402
+ let o = e.doc.lastChild;
1403
+ if (!o || o.type.name !== "blockGroup")
1404
+ throw new Error("Expected blockGroup");
1405
+ if (o = o.lastChild, !o || o.type.name !== "blockContainer")
1406
+ throw new Error("Expected blockContainer");
1407
+ const r = o.firstChild;
1408
+ if (!r)
1409
+ throw new Error("Expected blockContent");
1410
+ return o.nodeSize > 4 || r.type.spec.content !== "inline*";
1411
+ }
1412
+ }
1413
+ })
1414
+ ];
1415
+ }
1416
+ }), ro = (n) => {
1417
+ var t;
1418
+ const e = [
1419
+ R.ClipboardTextSerializer,
1420
+ R.Commands,
1421
+ R.Editable,
1422
+ R.FocusEvents,
1423
+ R.Tabindex,
1424
+ // DevTools,
1425
+ ce,
1426
+ // DropCursor,
1427
+ Qe.configure({
1428
+ emptyNodeClass: g.isEmpty,
1429
+ hasAnchorClass: g.hasAnchor,
1430
+ isFilterClass: g.isFilter,
1431
+ includeChildren: !0,
1432
+ showOnlyCurrent: !1
1433
+ }),
1434
+ j.configure({
1435
+ types: ["blockContainer"]
1436
+ }),
1437
+ ue,
1438
+ // Comments,
1439
+ // basics:
1440
+ ge,
1441
+ // marks:
1442
+ ie,
1443
+ se,
1444
+ he,
1445
+ fe,
1446
+ ke,
1447
+ me,
1448
+ oo,
1449
+ eo,
1450
+ _e,
1451
+ Ae,
1452
+ to,
1453
+ // nodes
1454
+ Ge,
1455
+ We.configure({
1456
+ domAttributes: n.domAttributes
1457
+ }),
1458
+ $e.configure({
1459
+ domAttributes: n.domAttributes
1460
+ }),
1461
+ ...Object.values(n.blockSchema).map(
1462
+ (o) => o.node.configure({
1463
+ editor: n.editor,
1464
+ domAttributes: n.domAttributes
1465
+ })
1466
+ ),
1467
+ qe,
1468
+ de.configure({ width: 5, color: "#ddeeff" }),
1469
+ // This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
1470
+ // should be handled before Enter handlers in other components like splitListItem
1471
+ no
1472
+ ];
1473
+ if (n.collaboration) {
1474
+ if (e.push(
1475
+ ae.configure({
1476
+ fragment: n.collaboration.fragment
1477
+ })
1478
+ ), (t = n.collaboration.provider) != null && t.awareness) {
1479
+ const o = (r) => {
1480
+ const i = document.createElement("span");
1481
+ i.classList.add(D["collaboration-cursor__caret"]), i.setAttribute("style", `border-color: ${r.color}`);
1482
+ const s = document.createElement("span");
1483
+ s.classList.add(D["collaboration-cursor__label"]), s.setAttribute("style", `background-color: ${r.color}`), s.insertBefore(document.createTextNode(r.name), null);
1484
+ const l = document.createTextNode("⁠"), a = document.createTextNode("⁠");
1485
+ return i.insertBefore(l, null), i.insertBefore(s, null), i.insertBefore(a, null), i;
1486
+ };
1487
+ e.push(
1488
+ le.configure({
1489
+ user: n.collaboration.user,
1490
+ render: n.collaboration.renderCursor || o,
1491
+ provider: n.collaboration.provider
1492
+ })
1493
+ );
1494
+ }
1495
+ } else
1496
+ e.push(pe);
1497
+ return e;
1498
+ };
1499
+ function et(n, e) {
1500
+ let t, o;
1501
+ if (e.firstChild.descendants((r, i) => t ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== n ? !0 : (t = r, o = i + 1, !1)), t === void 0 || o === void 0)
1502
+ throw Error("Could not find block in the editor with matching ID.");
1503
+ return {
1504
+ node: t,
1505
+ posBeforeNode: o
1506
+ };
1507
+ }
1508
+ function Ut(n, e, t = "before", o) {
1509
+ const r = typeof e == "string" ? e : e.id, i = [];
1510
+ for (const d of n)
1511
+ i.push(V(d, o.schema));
1512
+ let s = -1;
1513
+ const { node: l, posBeforeNode: a } = et(r, o.state.doc);
1514
+ if (t === "before" && (s = a), t === "after" && (s = a + l.nodeSize), t === "nested") {
1515
+ if (l.childCount < 2) {
1516
+ s = a + l.firstChild.nodeSize + 1;
1517
+ const d = o.state.schema.nodes.blockGroup.create(
1518
+ {},
1519
+ i
1520
+ );
1521
+ o.view.dispatch(
1522
+ o.state.tr.insert(s, d)
1523
+ );
1524
+ return;
1525
+ }
1526
+ s = a + l.firstChild.nodeSize + 2;
1527
+ }
1528
+ o.view.dispatch(o.state.tr.insert(s, i));
1529
+ }
1530
+ function io(n, e, t) {
1531
+ const o = typeof n == "string" ? n : n.id, { posBeforeNode: r } = et(o, t.state.doc);
1532
+ t.commands.BNUpdateBlock(r + 1, e);
1533
+ }
1534
+ function Ft(n, e) {
1535
+ const t = new Set(
1536
+ n.map(
1537
+ (r) => typeof r == "string" ? r : r.id
1538
+ )
1539
+ );
1540
+ let o = 0;
1541
+ if (e.state.doc.descendants((r, i) => {
1542
+ if (t.size === 0)
1543
+ return !1;
1544
+ if (r.type.name !== "blockContainer" || !t.has(r.attrs.id))
1545
+ return !0;
1546
+ t.delete(r.attrs.id);
1547
+ const s = e.state.doc.nodeSize;
1548
+ e.commands.BNDeleteBlock(i - o + 1);
1549
+ const l = e.state.doc.nodeSize;
1550
+ return o += s - l, !1;
1551
+ }), t.size > 0) {
1552
+ const r = [...t].join(`
1553
+ `);
1554
+ throw Error(
1555
+ "Blocks with the following IDs could not be found in the editor: " + r
1556
+ );
1557
+ }
1558
+ }
1559
+ function so(n, e, t) {
1560
+ Ut(e, n[0], "before", t), Ft(n, t);
1561
+ }
1562
+ function ao() {
1563
+ const n = (e) => {
1564
+ let t = e.children.length;
1565
+ for (let o = 0; o < t; o++) {
1566
+ const r = e.children[o];
1567
+ if (r.type === "element" && (n(r), r.tagName === "u"))
1568
+ if (r.children.length > 0) {
1569
+ e.children.splice(o, 1, ...r.children);
1570
+ const i = r.children.length - 1;
1571
+ t += i, o += i;
1572
+ } else
1573
+ e.children.splice(o, 1), t--, o--;
1574
+ }
1575
+ };
1576
+ return n;
1577
+ }
1578
+ function lo(n) {
1579
+ const e = /* @__PURE__ */ new Set([
1580
+ ...n.orderedListItemBlockTypes,
1581
+ ...n.unorderedListItemBlockTypes
1582
+ ]), t = (o) => {
1583
+ let r = o.children.length, i;
1584
+ for (let s = 0; s < r; s++) {
1585
+ const a = o.children[s].children[0], d = a.children[0], c = a.children.length === 2 ? a.children[1] : null, m = e.has(
1586
+ d.properties.dataContentType
1587
+ ), h = m ? n.orderedListItemBlockTypes.has(
1588
+ d.properties.dataContentType
1589
+ ) ? "ol" : "ul" : null;
1590
+ if (c !== null && t(c), i && i.tagName !== h) {
1591
+ o.children.splice(
1592
+ s - i.children.length,
1593
+ i.children.length,
1594
+ i
1595
+ );
1596
+ const p = i.children.length - 1;
1597
+ s -= p, r -= p, i = void 0;
1598
+ }
1599
+ if (m) {
1600
+ i || (i = st(
1601
+ document.createElement(h)
1602
+ ));
1603
+ const p = st(
1604
+ document.createElement("li")
1605
+ );
1606
+ p.children.push(d.children[0]), c !== null && p.children.push(...c.children), i.children.push(p);
1607
+ } else if (c !== null) {
1608
+ o.children.splice(s + 1, 0, ...c.children), o.children[s] = d.children[0];
1609
+ const p = c.children.length;
1610
+ s += p, r += p;
1611
+ } else
1612
+ o.children[s] = d.children[0];
1613
+ }
1614
+ i && o.children.splice(
1615
+ r - i.children.length,
1616
+ i.children.length,
1617
+ i
1618
+ );
1619
+ };
1620
+ return t;
1621
+ }
1622
+ async function Wt(n, e) {
1623
+ const t = document.createElement("div"), o = Y.fromSchema(e);
1624
+ for (const i of n) {
1625
+ const s = V(i, e), l = o.serializeNode(s);
1626
+ t.appendChild(l);
1627
+ }
1628
+ return (await Q().use(ft, { fragment: !0 }).use(lo, {
1629
+ orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
1630
+ unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
1631
+ }).use(gt).process(t.innerHTML)).value;
1632
+ }
1633
+ async function $t(n, e, t) {
1634
+ const o = document.createElement("div");
1635
+ o.innerHTML = n.trim();
1636
+ const i = be.fromSchema(t).parse(o), s = [];
1637
+ for (let l = 0; l < i.firstChild.childCount; l++)
1638
+ s.push(x(i.firstChild.child(l), e));
1639
+ return s;
1640
+ }
1641
+ async function co(n, e) {
1642
+ return (await Q().use(ft, { fragment: !0 }).use(ao).use(we).use(kt).use(Te).process(await Wt(n, e))).value;
1643
+ }
1644
+ function uo(n, e) {
1645
+ const t = e.value ? e.value + `
1646
+ ` : "", o = {};
1647
+ e.lang && (o["data-language"] = e.lang);
1648
+ let r = {
1649
+ type: "element",
1650
+ tagName: "code",
1651
+ properties: o,
1652
+ children: [{ type: "text", value: t }]
1653
+ };
1654
+ return e.meta && (r.data = { meta: e.meta }), n.patch(e, r), r = n.applyData(e, r), r = {
1655
+ type: "element",
1656
+ tagName: "pre",
1657
+ properties: {},
1658
+ children: [r]
1659
+ }, n.patch(e, r), r;
1660
+ }
1661
+ async function po(n, e, t) {
1662
+ const o = await Q().use(Ce).use(kt).use(Ee, {
1663
+ handlers: {
1664
+ ...Se,
1665
+ code: uo
1666
+ }
1667
+ }).use(gt).process(n);
1668
+ return $t(o.value, e, t);
1669
+ }
1670
+ function dt(n) {
1671
+ return "data-" + n.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
1672
+ }
1673
+ function ho(n) {
1674
+ const e = {};
1675
+ return Object.entries(n.propSchema).forEach(([t, o]) => {
1676
+ e[t] = {
1677
+ default: o.default,
1678
+ keepOnSplit: !0,
1679
+ // Props are displayed in kebab-case as HTML attributes. If a prop's
1680
+ // value is the same as its default, we don't display an HTML
1681
+ // attribute for it.
1682
+ parseHTML: (r) => r.getAttribute(dt(t)),
1683
+ renderHTML: (r) => r[t] !== o.default ? {
1684
+ [dt(t)]: r[t]
1685
+ } : {}
1686
+ };
1687
+ }), e;
1688
+ }
1689
+ function mo(n) {
1690
+ return [
1691
+ {
1692
+ tag: "div[data-content-type=" + n.type + "]"
1693
+ }
1694
+ ];
1695
+ }
1696
+ function fo(n, e) {
1697
+ const t = document.createElement("div");
1698
+ t.setAttribute("data-content-type", n.type);
1699
+ for (const [r, i] of Object.entries(e))
1700
+ t.setAttribute(r, i);
1701
+ let o;
1702
+ return n.containsInlineContent ? (o = document.createElement("div"), t.appendChild(o)) : o = void 0, o !== void 0 ? {
1703
+ dom: t,
1704
+ contentDOM: o
1705
+ } : {
1706
+ dom: t
1707
+ };
1708
+ }
1709
+ function go(n) {
1710
+ return {
1711
+ node: F({
1712
+ name: n.type,
1713
+ content: n.containsInlineContent ? "inline*" : "",
1714
+ selectable: !0,
1715
+ addAttributes() {
1716
+ return ho(n);
1717
+ },
1718
+ parseHTML() {
1719
+ return mo(n);
1720
+ },
1721
+ renderHTML({ HTMLAttributes: t }) {
1722
+ return fo(n, t);
1723
+ },
1724
+ addNodeView() {
1725
+ return ({ HTMLAttributes: t, getPos: o }) => {
1726
+ var p, f;
1727
+ const r = document.createElement("div"), i = ((p = this.options.domAttributes) == null ? void 0 : p.blockContent) || {};
1728
+ for (const [k, v] of Object.entries(
1729
+ i
1730
+ ))
1731
+ k !== "class" && r.setAttribute(k, v);
1732
+ r.className = S(
1733
+ g.blockContent,
1734
+ i.class
1735
+ ), r.setAttribute("data-content-type", n.type);
1736
+ for (const [k, v] of Object.entries(t))
1737
+ r.setAttribute(k, v);
1738
+ const s = this.options.editor;
1739
+ if (typeof o == "boolean")
1740
+ throw new Error(
1741
+ "Cannot find node position as getPos is a boolean, not a function."
1742
+ );
1743
+ const l = o(), c = s._tiptapEditor.state.doc.resolve(l).node().attrs.id, m = s.getBlock(c);
1744
+ if (m.type !== n.type)
1745
+ throw new Error("Block type does not match");
1746
+ const h = n.render(m, s);
1747
+ if (n.containsInlineContent) {
1748
+ const k = h.contentDOM, v = ((f = this.options.domAttributes) == null ? void 0 : f.inlineContent) || {};
1749
+ for (const [w, E] of Object.entries(
1750
+ v
1751
+ ))
1752
+ w !== "class" && k.setAttribute(w, E);
1753
+ k.className = S(
1754
+ k.className,
1755
+ g.inlineContent,
1756
+ v.class
1757
+ );
1758
+ }
1759
+ return r.appendChild(h.dom), "contentDOM" in h ? {
1760
+ dom: r,
1761
+ contentDOM: h.contentDOM,
1762
+ destroy: h.destroy
1763
+ } : {
1764
+ dom: r,
1765
+ destroy: h.destroy
1766
+ };
1767
+ };
1768
+ }
1769
+ }),
1770
+ propSchema: n.propSchema
1771
+ };
1772
+ }
1773
+ function F(n) {
1774
+ return G.create({
1775
+ ...n,
1776
+ group: "blockContent",
1777
+ content: n.content
1778
+ });
1779
+ }
1780
+ const ko = {
1781
+ ...C,
1782
+ level: { default: 1, values: [1, 2, 3] }
1783
+ }, bo = F({
1784
+ name: "heading",
1785
+ content: "inline*",
1786
+ addAttributes() {
1787
+ return {
1788
+ level: {
1789
+ default: 1,
1790
+ // instead of "level" attributes, use "data-level"
1791
+ parseHTML: (n) => n.getAttribute("data-level"),
1792
+ renderHTML: (n) => ({
1793
+ "data-level": n.level.toString()
1794
+ })
1795
+ }
1796
+ };
1797
+ },
1798
+ addInputRules() {
1799
+ return [
1800
+ ...[1, 2, 3].map((n) => new Z({
1801
+ find: new RegExp(`^(#{${n}})\\s$`),
1802
+ handler: ({ state: e, chain: t, range: o }) => {
1803
+ t().BNUpdateBlock(e.selection.from, {
1804
+ type: "heading",
1805
+ props: {
1806
+ level: n
1807
+ }
1808
+ }).deleteRange({ from: o.from, to: o.to });
1809
+ }
1810
+ }))
1811
+ ];
1812
+ },
1813
+ addKeyboardShortcuts() {
1814
+ return {
1815
+ "Mod-Alt-1": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
1816
+ type: "heading",
1817
+ props: {
1818
+ level: 1
1819
+ }
1820
+ }),
1821
+ "Mod-Alt-2": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
1822
+ type: "heading",
1823
+ props: {
1824
+ level: 2
1825
+ }
1826
+ }),
1827
+ "Mod-Alt-3": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
1828
+ type: "heading",
1829
+ props: {
1830
+ level: 3
1831
+ }
1832
+ })
1833
+ };
1834
+ },
1835
+ parseHTML() {
1836
+ return [
1837
+ {
1838
+ tag: "h1",
1839
+ attrs: { level: 1 },
1840
+ node: "heading"
1841
+ },
1842
+ {
1843
+ tag: "h2",
1844
+ attrs: { level: 2 },
1845
+ node: "heading"
1846
+ },
1847
+ {
1848
+ tag: "h3",
1849
+ attrs: { level: 3 },
1850
+ node: "heading"
1851
+ }
1852
+ ];
1853
+ },
1854
+ renderHTML({ node: n, HTMLAttributes: e }) {
1855
+ var r, i;
1856
+ const t = ((r = this.options.domAttributes) == null ? void 0 : r.blockContent) || {}, o = ((i = this.options.domAttributes) == null ? void 0 : i.inlineContent) || {};
1857
+ return [
1858
+ "div",
1859
+ N(e, {
1860
+ ...t,
1861
+ class: S(
1862
+ g.blockContent,
1863
+ t.class
1864
+ ),
1865
+ "data-content-type": this.name
1866
+ }),
1867
+ [
1868
+ `h${n.attrs.level}`,
1869
+ {
1870
+ ...o,
1871
+ class: S(
1872
+ g.inlineContent,
1873
+ o.class
1874
+ )
1875
+ },
1876
+ 0
1877
+ ]
1878
+ ];
1879
+ }
1880
+ }), yo = {
1881
+ node: bo,
1882
+ propSchema: ko
1883
+ }, Gt = (n) => {
1884
+ const { node: e, contentType: t } = b(
1885
+ n.state.doc,
1886
+ n.state.selection.from
1887
+ ), o = n.state.selection.anchor === n.state.selection.head;
1888
+ return !t.name.endsWith("ListItem") || !o ? !1 : n.commands.first(({ state: r, chain: i, commands: s }) => [
1889
+ () => (
1890
+ // Changes list item block to a text block if the content is empty.
1891
+ s.command(() => e.textContent.length === 0 ? s.BNUpdateBlock(r.selection.from, {
1892
+ type: "paragraph",
1893
+ props: {}
1894
+ }) : !1)
1895
+ ),
1896
+ () => (
1897
+ // Splits the current block, moving content inside that's after the cursor to a new block of the same type
1898
+ // below.
1899
+ s.command(() => e.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
1900
+ )
1901
+ ]);
1902
+ }, vo = {
1903
+ ...C
1904
+ }, wo = F({
1905
+ name: "bulletListItem",
1906
+ content: "inline*",
1907
+ addInputRules() {
1908
+ return [
1909
+ // Creates an unordered list when starting with "-", "+", or "*".
1910
+ new Z({
1911
+ find: new RegExp("^[-+*]\\s$"),
1912
+ handler: ({ state: n, chain: e, range: t }) => {
1913
+ e().BNUpdateBlock(n.selection.from, {
1914
+ type: "bulletListItem",
1915
+ props: {}
1916
+ }).deleteRange({ from: t.from, to: t.to });
1917
+ }
1918
+ })
1919
+ ];
1920
+ },
1921
+ addKeyboardShortcuts() {
1922
+ return {
1923
+ Enter: () => Gt(this.editor),
1924
+ "Mod-Shift-7": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
1925
+ type: "bulletListItem",
1926
+ props: {}
1927
+ })
1928
+ };
1929
+ },
1930
+ parseHTML() {
1931
+ return [
1932
+ // Case for regular HTML list structure.
1933
+ {
1934
+ tag: "li",
1935
+ getAttrs: (n) => {
1936
+ if (typeof n == "string")
1937
+ return !1;
1938
+ const e = n.parentElement;
1939
+ return e === null ? !1 : e.tagName === "UL" ? {} : !1;
1940
+ },
1941
+ node: "bulletListItem"
1942
+ },
1943
+ // Case for BlockNote list structure.
1944
+ {
1945
+ tag: "p",
1946
+ getAttrs: (n) => {
1947
+ if (typeof n == "string")
1948
+ return !1;
1949
+ const e = n.parentElement;
1950
+ return e === null ? !1 : e.getAttribute("data-content-type") === "bulletListItem" ? {} : !1;
1951
+ },
1952
+ priority: 300,
1953
+ node: "bulletListItem"
1954
+ }
1955
+ ];
1956
+ },
1957
+ renderHTML({ HTMLAttributes: n }) {
1958
+ var o, r;
1959
+ const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
1960
+ return [
1961
+ "div",
1962
+ N(n, {
1963
+ ...e,
1964
+ class: S(
1965
+ g.blockContent,
1966
+ e.class
1967
+ ),
1968
+ "data-content-type": this.name
1969
+ }),
1970
+ [
1971
+ "p",
1972
+ {
1973
+ ...t,
1974
+ class: S(
1975
+ g.inlineContent,
1976
+ t.class
1977
+ )
1978
+ },
1979
+ 0
1980
+ ]
1981
+ ];
1982
+ }
1983
+ }), Co = {
1984
+ node: wo,
1985
+ propSchema: vo
1986
+ }, Eo = new B("numbered-list-indexing"), So = () => new T({
1987
+ key: Eo,
1988
+ appendTransaction: (n, e, t) => {
1989
+ const o = t.tr;
1990
+ o.setMeta("numberedListIndexing", !0);
1991
+ let r = !1;
1992
+ return t.doc.descendants((i, s) => {
1993
+ if (i.type.name === "blockContainer" && i.firstChild.type.name === "numberedListItem") {
1994
+ let l = "1";
1995
+ const a = s === 1, d = b(o.doc, s + 1);
1996
+ if (d === void 0)
1997
+ return;
1998
+ if (!a) {
1999
+ const h = b(o.doc, s - 2);
2000
+ if (h === void 0)
2001
+ return;
2002
+ if (!(d.depth !== h.depth)) {
2003
+ const f = h.contentNode;
2004
+ if (h.contentType.name === "numberedListItem") {
2005
+ const w = f.attrs.index;
2006
+ l = (parseInt(w) + 1).toString();
2007
+ }
2008
+ }
2009
+ }
2010
+ d.contentNode.attrs.index !== l && (r = !0, o.setNodeMarkup(s + 1, void 0, {
2011
+ index: l
2012
+ }));
2013
+ }
2014
+ }), r ? o : null;
2015
+ }
2016
+ }), To = {
2017
+ ...C
2018
+ }, Mo = F({
2019
+ name: "numberedListItem",
2020
+ content: "inline*",
2021
+ addAttributes() {
2022
+ return {
2023
+ index: {
2024
+ default: null,
2025
+ parseHTML: (n) => n.getAttribute("data-index"),
2026
+ renderHTML: (n) => ({
2027
+ "data-index": n.index
2028
+ })
2029
+ }
2030
+ };
2031
+ },
2032
+ addInputRules() {
2033
+ return [
2034
+ // Creates an ordered list when starting with "1.".
2035
+ new Z({
2036
+ find: new RegExp("^1\\.\\s$"),
2037
+ handler: ({ state: n, chain: e, range: t }) => {
2038
+ e().BNUpdateBlock(n.selection.from, {
2039
+ type: "numberedListItem",
2040
+ props: {}
2041
+ }).deleteRange({ from: t.from, to: t.to });
2042
+ }
2043
+ })
2044
+ ];
2045
+ },
2046
+ addKeyboardShortcuts() {
2047
+ return {
2048
+ Enter: () => Gt(this.editor),
2049
+ "Mod-Shift-8": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
2050
+ type: "numberedListItem",
2051
+ props: {}
2052
+ })
2053
+ };
2054
+ },
2055
+ addProseMirrorPlugins() {
2056
+ return [So()];
2057
+ },
2058
+ parseHTML() {
2059
+ return [
2060
+ // Case for regular HTML list structure.
2061
+ // (e.g.: when pasting from other apps)
2062
+ {
2063
+ tag: "li",
2064
+ getAttrs: (n) => {
2065
+ if (typeof n == "string")
2066
+ return !1;
2067
+ const e = n.parentElement;
2068
+ return e === null ? !1 : e.tagName === "OL" ? {} : !1;
2069
+ },
2070
+ node: "numberedListItem"
2071
+ },
2072
+ // Case for BlockNote list structure.
2073
+ // (e.g.: when pasting from blocknote)
2074
+ {
2075
+ tag: "p",
2076
+ getAttrs: (n) => {
2077
+ if (typeof n == "string")
2078
+ return !1;
2079
+ const e = n.parentElement;
2080
+ return e === null ? !1 : e.getAttribute("data-content-type") === "numberedListItem" ? {} : !1;
2081
+ },
2082
+ priority: 300,
2083
+ node: "numberedListItem"
2084
+ }
2085
+ ];
2086
+ },
2087
+ renderHTML({ HTMLAttributes: n }) {
2088
+ var o, r;
2089
+ const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
2090
+ return [
2091
+ "div",
2092
+ N(n, {
2093
+ ...e,
2094
+ class: S(
2095
+ g.blockContent,
2096
+ e.class
2097
+ ),
2098
+ "data-content-type": this.name
2099
+ }),
2100
+ // we use a <p> tag, because for <li> tags we'd need to add a <ul> parent for around siblings to be semantically correct,
2101
+ // which would be quite cumbersome
2102
+ [
2103
+ "p",
2104
+ {
2105
+ ...t,
2106
+ class: S(
2107
+ g.inlineContent,
2108
+ t.class
2109
+ )
2110
+ },
2111
+ 0
2112
+ ]
2113
+ ];
2114
+ }
2115
+ }), Bo = {
2116
+ node: Mo,
2117
+ propSchema: To
2118
+ }, xo = {
2119
+ ...C
2120
+ }, Io = F({
2121
+ name: "paragraph",
2122
+ content: "inline*",
2123
+ parseHTML() {
2124
+ return [
2125
+ {
2126
+ tag: "p",
2127
+ priority: 200,
2128
+ node: "paragraph"
2129
+ }
2130
+ ];
2131
+ },
2132
+ renderHTML({ HTMLAttributes: n }) {
2133
+ var o, r;
2134
+ const e = ((o = this.options.domAttributes) == null ? void 0 : o.blockContent) || {}, t = ((r = this.options.domAttributes) == null ? void 0 : r.inlineContent) || {};
2135
+ return [
2136
+ "div",
2137
+ N(
2138
+ {
2139
+ ...e,
2140
+ class: S(
2141
+ g.blockContent,
2142
+ e.class
2143
+ ),
2144
+ "data-content-type": this.name
2145
+ },
2146
+ n
2147
+ ),
2148
+ [
2149
+ "p",
2150
+ {
2151
+ ...t,
2152
+ class: S(
2153
+ g.inlineContent,
2154
+ t.class
2155
+ )
2156
+ },
2157
+ 0
2158
+ ]
1857
2159
  ];
1858
2160
  }
1859
- }), Xe = (n) => {
1860
- var t;
1861
- const e = [
1862
- L.ClipboardTextSerializer,
1863
- L.Commands,
1864
- L.Editable,
1865
- L.FocusEvents,
1866
- L.Tabindex,
1867
- // DevTools,
1868
- Kt,
1869
- // DropCursor,
1870
- qe.configure({
1871
- emptyNodeClass: y.isEmpty,
1872
- hasAnchorClass: y.hasAnchor,
1873
- isFilterClass: y.isFilter,
1874
- includeChildren: !0,
1875
- showOnlyCurrent: !1
1876
- }),
1877
- F.configure({
1878
- types: ["blockContainer"]
1879
- }),
1880
- Jt,
1881
- // Comments,
1882
- // basics:
1883
- ee,
1884
- // marks:
1885
- $t,
1886
- jt,
1887
- Zt,
1888
- te,
1889
- oe,
1890
- Qt,
1891
- Ke,
1892
- Ye,
1893
- ge,
1894
- ke,
1895
- We,
1896
- // nodes
1897
- Re,
1898
- Oe.configure({
1899
- domAttributes: n.domAttributes
1900
- }),
1901
- De.configure({
1902
- domAttributes: n.domAttributes
1903
- }),
1904
- ...Object.values(n.blockSchema).map(
1905
- (o) => o.node.configure({
1906
- editor: n.editor,
1907
- domAttributes: n.domAttributes
1908
- })
1909
- ),
1910
- ze,
1911
- Yt.configure({ width: 5, color: "#ddeeff" }),
1912
- // This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
1913
- // should be handled before Enter handlers in other components like splitListItem
1914
- Je
1915
- ];
1916
- if (n.collaboration) {
1917
- if (e.push(
1918
- qt.configure({
1919
- fragment: n.collaboration.fragment
1920
- })
1921
- ), (t = n.collaboration.provider) != null && t.awareness) {
1922
- const o = (r) => {
1923
- const i = document.createElement("span");
1924
- i.classList.add(H["collaboration-cursor__caret"]), i.setAttribute("style", `border-color: ${r.color}`);
1925
- const s = document.createElement("span");
1926
- s.classList.add(H["collaboration-cursor__label"]), s.setAttribute("style", `background-color: ${r.color}`), s.insertBefore(document.createTextNode(r.name), null);
1927
- const l = document.createTextNode("⁠"), a = document.createTextNode("⁠");
1928
- return i.insertBefore(l, null), i.insertBefore(s, null), i.insertBefore(a, null), i;
1929
- };
1930
- e.push(
1931
- Wt.configure({
1932
- user: n.collaboration.user,
1933
- render: n.collaboration.renderCursor || o,
1934
- provider: n.collaboration.provider
1935
- })
1936
- );
1937
- }
1938
- } else
1939
- e.push(Xt);
1940
- return e;
2161
+ }), Ao = {
2162
+ node: Io,
2163
+ propSchema: xo
1941
2164
  };
1942
- function Z(n, e) {
1943
- let t, o;
1944
- if (e.firstChild.descendants((r, i) => t ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== n ? !0 : (t = r, o = i + 1, !1)), t === void 0 || o === void 0)
1945
- throw Error("Could not find block in the editor with matching ID.");
1946
- return {
1947
- node: t,
1948
- posBeforeNode: o
1949
- };
1950
- }
1951
- function xt(n, e, t = "before", o) {
1952
- const r = typeof e == "string" ? e : e.id, i = [];
1953
- for (const d of n)
1954
- i.push(D(d, o.schema));
1955
- let s = -1;
1956
- const { node: l, posBeforeNode: a } = Z(r, o.state.doc);
1957
- if (t === "before" && (s = a), t === "after" && (s = a + l.nodeSize), t === "nested") {
1958
- if (l.childCount < 2) {
1959
- s = a + l.firstChild.nodeSize + 1;
1960
- const d = o.state.schema.nodes.blockGroup.create(
1961
- {},
1962
- i
1963
- );
1964
- o.view.dispatch(
1965
- o.state.tr.insert(s, d)
2165
+ class _o {
2166
+ constructor(e, t, o) {
2167
+ u(this, "imageToolbarState");
2168
+ u(this, "updateImageToolbar");
2169
+ u(this, "prevWasEditable", null);
2170
+ u(this, "shouldShow", (e) => "node" in e.selection && e.selection.node.type.name === "image" && e.selection.node.attrs.src === "");
2171
+ u(this, "mouseDownHandler", () => {
2172
+ var e;
2173
+ (e = this.imageToolbarState) != null && e.show && (this.imageToolbarState.show = !1, this.updateImageToolbar());
2174
+ });
2175
+ // For dragging the whole editor.
2176
+ u(this, "dragstartHandler", () => {
2177
+ var e;
2178
+ (e = this.imageToolbarState) != null && e.show && (this.imageToolbarState.show = !1, this.updateImageToolbar());
2179
+ });
2180
+ u(this, "blurHandler", (e) => {
2181
+ var o;
2182
+ const t = this.pmView.dom.parentElement;
2183
+ // An element is clicked.
2184
+ e && e.relatedTarget && // Element is inside the editor.
2185
+ (t === e.relatedTarget || t.contains(e.relatedTarget)) || (o = this.imageToolbarState) != null && o.show && (this.imageToolbarState.show = !1, this.updateImageToolbar());
2186
+ });
2187
+ u(this, "scrollHandler", () => {
2188
+ var e;
2189
+ if ((e = this.imageToolbarState) != null && e.show) {
2190
+ const t = document.querySelector(
2191
+ `[data-node-type="blockContainer"][data-id="${this.imageToolbarState.block.id}"]`
2192
+ );
2193
+ this.imageToolbarState.referencePos = t.getBoundingClientRect(), this.updateImageToolbar();
2194
+ }
2195
+ });
2196
+ this.pluginKey = e, this.pmView = t, this.updateImageToolbar = () => {
2197
+ if (!this.imageToolbarState)
2198
+ throw new Error("Attempting to update uninitialized image toolbar");
2199
+ o(this.imageToolbarState);
2200
+ }, t.dom.addEventListener("mousedown", this.mouseDownHandler), t.dom.addEventListener("dragstart", this.dragstartHandler), t.dom.addEventListener("blur", this.blurHandler), document.addEventListener("scroll", this.scrollHandler);
2201
+ }
2202
+ update(e, t) {
2203
+ var r, i;
2204
+ const o = this.pluginKey.getState(e.state);
2205
+ if (!((r = this.imageToolbarState) != null && r.show) && o.block) {
2206
+ const s = document.querySelector(
2207
+ `[data-node-type="blockContainer"][data-id="${o.block.id}"]`
1966
2208
  );
2209
+ this.imageToolbarState = {
2210
+ show: !0,
2211
+ referencePos: s.getBoundingClientRect(),
2212
+ block: o.block
2213
+ }, this.updateImageToolbar();
1967
2214
  return;
1968
2215
  }
1969
- s = a + l.firstChild.nodeSize + 2;
2216
+ (!e.state.selection.eq(t.selection) || !e.state.doc.eq(t.doc)) && (i = this.imageToolbarState) != null && i.show && (this.imageToolbarState.show = !1, this.updateImageToolbar());
1970
2217
  }
1971
- o.view.dispatch(o.state.tr.insert(s, i));
1972
- }
1973
- function Ze(n, e, t) {
1974
- const o = typeof n == "string" ? n : n.id, { posBeforeNode: r } = Z(o, t.state.doc);
1975
- t.commands.BNUpdateBlock(r + 1, e);
1976
- }
1977
- function At(n, e) {
1978
- const t = new Set(
1979
- n.map(
1980
- (r) => typeof r == "string" ? r : r.id
1981
- )
1982
- );
1983
- let o = 0;
1984
- if (e.state.doc.descendants((r, i) => {
1985
- if (t.size === 0)
1986
- return !1;
1987
- if (r.type.name !== "blockContainer" || !t.has(r.attrs.id))
1988
- return !0;
1989
- t.delete(r.attrs.id);
1990
- const s = e.state.doc.nodeSize;
1991
- e.commands.BNDeleteBlock(i - o + 1);
1992
- const l = e.state.doc.nodeSize;
1993
- return o += s - l, !1;
1994
- }), t.size > 0) {
1995
- const r = [...t].join(`
1996
- `);
1997
- throw Error(
1998
- "Blocks with the following IDs could not be found in the editor: " + r
1999
- );
2218
+ destroy() {
2219
+ this.pmView.dom.removeEventListener("mousedown", this.mouseDownHandler), this.pmView.dom.removeEventListener("dragstart", this.dragstartHandler), this.pmView.dom.removeEventListener("blur", this.blurHandler), document.removeEventListener("scroll", this.scrollHandler);
2000
2220
  }
2001
2221
  }
2002
- function Qe(n, e, t) {
2003
- xt(e, n[0], "before", t), At(n, t);
2004
- }
2005
- function to() {
2006
- const n = (e) => {
2007
- let t = e.children.length;
2008
- for (let o = 0; o < t; o++) {
2009
- const r = e.children[o];
2010
- if (r.type === "element" && (n(r), r.tagName === "u"))
2011
- if (r.children.length > 0) {
2012
- e.children.splice(o, 1, ...r.children);
2013
- const i = r.children.length - 1;
2014
- t += i, o += i;
2015
- } else
2016
- e.children.splice(o, 1), t--, o--;
2017
- }
2018
- };
2019
- return n;
2020
- }
2021
- function eo(n) {
2022
- const e = /* @__PURE__ */ new Set([
2023
- ...n.orderedListItemBlockTypes,
2024
- ...n.unorderedListItemBlockTypes
2025
- ]), t = (o) => {
2026
- let r = o.children.length, i;
2027
- for (let s = 0; s < r; s++) {
2028
- const a = o.children[s].children[0], d = a.children[0], c = a.children.length === 2 ? a.children[1] : null, h = e.has(
2029
- d.properties.dataContentType
2030
- ), p = h ? n.orderedListItemBlockTypes.has(
2031
- d.properties.dataContentType
2032
- ) ? "ol" : "ul" : null;
2033
- if (c !== null && t(c), i && i.tagName !== p) {
2034
- o.children.splice(
2035
- s - i.children.length,
2036
- i.children.length,
2037
- i
2038
- );
2039
- const f = i.children.length - 1;
2040
- s -= f, r -= f, i = void 0;
2222
+ const z = new B("ImageToolbarPlugin");
2223
+ class Ho extends U {
2224
+ constructor(t) {
2225
+ super();
2226
+ u(this, "view");
2227
+ u(this, "plugin");
2228
+ this.plugin = new T({
2229
+ key: z,
2230
+ view: (o) => (this.view = new _o(
2231
+ // editor,
2232
+ z,
2233
+ o,
2234
+ (r) => {
2235
+ this.emit("update", r);
2236
+ }
2237
+ ), this.view),
2238
+ state: {
2239
+ init: () => ({
2240
+ block: void 0
2241
+ }),
2242
+ apply: (o) => {
2243
+ var i;
2244
+ return {
2245
+ block: (i = o.getMeta(z)) == null ? void 0 : i.block
2246
+ };
2247
+ }
2041
2248
  }
2042
- if (h) {
2043
- i || (i = nt(
2044
- document.createElement(p)
2045
- ));
2046
- const f = nt(
2047
- document.createElement("li")
2048
- );
2049
- f.children.push(d.children[0]), c !== null && f.children.push(...c.children), i.children.push(f);
2050
- } else if (c !== null) {
2051
- o.children.splice(s + 1, 0, ...c.children), o.children[s] = d.children[0];
2052
- const f = c.children.length;
2053
- s += f, r += f;
2054
- } else
2055
- o.children[s] = d.children[0];
2056
- }
2057
- i && o.children.splice(
2058
- r - i.children.length,
2059
- i.children.length,
2060
- i
2061
- );
2062
- };
2063
- return t;
2064
- }
2065
- async function It(n, e) {
2066
- const t = document.createElement("div"), o = W.fromSchema(e);
2067
- for (const i of n) {
2068
- const s = D(i, e), l = o.serializeNode(s);
2069
- t.appendChild(l);
2249
+ });
2250
+ }
2251
+ onUpdate(t) {
2252
+ return this.on("update", t);
2070
2253
  }
2071
- return (await J().use(dt, { fragment: !0 }).use(eo, {
2072
- orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
2073
- unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
2074
- }).use(ct).process(t.innerHTML)).value;
2075
2254
  }
2076
- async function _t(n, e, t) {
2255
+ const Lo = {
2256
+ textAlignment: C.textAlignment,
2257
+ backgroundColor: C.backgroundColor,
2258
+ // Image url.
2259
+ url: {
2260
+ default: ""
2261
+ },
2262
+ // Image caption.
2263
+ caption: {
2264
+ default: ""
2265
+ },
2266
+ // Image width in px.
2267
+ width: {
2268
+ default: 512
2269
+ }
2270
+ }, ct = (n) => {
2271
+ switch (n) {
2272
+ case "left":
2273
+ return "flex-start";
2274
+ case "center":
2275
+ return "center";
2276
+ case "right":
2277
+ return "flex-end";
2278
+ default:
2279
+ return "flex-start";
2280
+ }
2281
+ }, ut = 64, No = (n, e) => {
2282
+ const t = document.createElement("div");
2283
+ t.className = g.wrapper, t.style.alignItems = ct(
2284
+ n.props.textAlignment
2285
+ );
2077
2286
  const o = document.createElement("div");
2078
- o.innerHTML = n.trim();
2079
- const i = ne.fromSchema(t).parse(o), s = [];
2080
- for (let l = 0; l < i.firstChild.childCount; l++)
2081
- s.push(E(i.firstChild.child(l), e));
2082
- return s;
2083
- }
2084
- async function oo(n, e) {
2085
- return (await J().use(dt, { fragment: !0 }).use(to).use(ae).use(ut).use(ue).process(await It(n, e))).value;
2086
- }
2087
- function no(n, e) {
2088
- const t = e.value ? e.value + `
2089
- ` : "", o = {};
2090
- e.lang && (o["data-language"] = e.lang);
2091
- let r = {
2092
- type: "element",
2093
- tagName: "code",
2094
- properties: o,
2095
- children: [{ type: "text", value: t }]
2287
+ o.className = g.addImageButton, o.style.display = n.props.url === "" ? "" : "none";
2288
+ const r = document.createElement("div");
2289
+ r.className = g.addImageButtonIcon;
2290
+ const i = document.createElement("p");
2291
+ i.className = g.addImageButtonText, i.innerText = "Add Image";
2292
+ const s = document.createElement("div");
2293
+ s.className = g.imageAndCaptionWrapper, s.style.display = n.props.url !== "" ? "" : "none";
2294
+ const l = document.createElement("div");
2295
+ l.className = g.imageWrapper, l.style.display = n.props.url !== "" ? "" : "none";
2296
+ const a = document.createElement("img");
2297
+ a.className = g.image, a.src = n.props.url, a.alt = "placeholder", a.contentEditable = "false", a.draggable = !1, a.style.width = `${Math.min(
2298
+ n.props.width,
2299
+ e.domElement.firstElementChild.clientWidth
2300
+ )}px`;
2301
+ const d = document.createElement("div");
2302
+ d.className = g.resizeHandle, d.style.left = "4px";
2303
+ const c = document.createElement("div");
2304
+ c.className = g.resizeHandle, c.style.right = "4px";
2305
+ const m = document.createElement("p");
2306
+ m.className = g.caption, m.innerText = n.props.caption, m.style.padding = n.props.caption ? "4px" : "";
2307
+ const h = () => {
2308
+ var q;
2309
+ const y = ((q = e.getSelection()) == null ? void 0 : q.blocks) || [];
2310
+ [e.getTextCursorPosition().block, ...y].find(
2311
+ (Kt) => Kt.id === n.id
2312
+ ) !== void 0 ? (o.style.outline = "4px solid rgb(100, 160, 255)", s.style.outline = "4px solid rgb(100, 160, 255)") : (o.style.outline = "", s.style.outline = "");
2096
2313
  };
2097
- return e.meta && (r.data = { meta: e.meta }), n.patch(e, r), r = n.applyData(e, r), r = {
2098
- type: "element",
2099
- tagName: "pre",
2100
- properties: {},
2101
- children: [r]
2102
- }, n.patch(e, r), r;
2103
- }
2104
- async function ro(n, e, t) {
2105
- const o = await J().use(le).use(ut).use(de, {
2106
- handlers: {
2107
- ...ce,
2108
- code: no
2314
+ e.onEditorContentChange(h), e.onEditorSelectionChange(h);
2315
+ let p;
2316
+ const f = (y) => {
2317
+ if (!p)
2318
+ return;
2319
+ let M;
2320
+ ct(n.props.textAlignment) === "center" ? p.handleUsed === "left" ? M = p.initialWidth + (p.initialClientX - y.clientX) * 2 : M = p.initialWidth + (y.clientX - p.initialClientX) * 2 : p.handleUsed === "left" ? M = p.initialWidth + p.initialClientX - y.clientX : M = p.initialWidth + y.clientX - p.initialClientX, M < ut ? a.style.width = `${ut}px` : M > e.domElement.firstElementChild.clientWidth ? a.style.width = `${e.domElement.firstElementChild.clientWidth}px` : a.style.width = `${M}px`;
2321
+ }, k = (y) => {
2322
+ p && ((!y.target || !l.contains(y.target)) && l.contains(d) && l.contains(c) && (d.style.display = "none", c.style.display = "none"), p = void 0, e.updateBlock(n, {
2323
+ type: "image",
2324
+ props: {
2325
+ // Removes "px" from the end of the width string and converts to float.
2326
+ width: parseFloat(a.style.width.slice(0, -2))
2327
+ }
2328
+ }));
2329
+ }, v = (y) => {
2330
+ y.preventDefault();
2331
+ }, w = () => {
2332
+ e._tiptapEditor.view.dispatch(
2333
+ e._tiptapEditor.state.tr.setMeta(z, {
2334
+ block: n
2335
+ })
2336
+ );
2337
+ }, E = (y) => {
2338
+ y.preventDefault(), d.style.display = "block", c.style.display = "block", p = {
2339
+ handleUsed: "left",
2340
+ initialWidth: n.props.width,
2341
+ initialClientX: y.clientX
2342
+ };
2343
+ }, _ = (y) => {
2344
+ y.preventDefault(), d.style.display = "block", c.style.display = "block", p = {
2345
+ handleUsed: "right",
2346
+ initialWidth: n.props.width,
2347
+ initialClientX: y.clientX
2348
+ };
2349
+ };
2350
+ return t.appendChild(o), o.appendChild(r), o.appendChild(i), t.appendChild(s), s.appendChild(l), l.appendChild(a), l.appendChild(d), l.appendChild(c), s.appendChild(m), window.addEventListener("mousemove", f), window.addEventListener("mouseup", k), o.addEventListener("mousedown", v), o.addEventListener("click", w), d.addEventListener(
2351
+ "mousedown",
2352
+ E
2353
+ ), c.addEventListener(
2354
+ "mousedown",
2355
+ _
2356
+ ), {
2357
+ dom: t,
2358
+ destroy: () => {
2359
+ window.removeEventListener("mousemove", f), window.removeEventListener("mouseup", k), o.removeEventListener(
2360
+ "mousedown",
2361
+ v
2362
+ ), o.removeEventListener("click", w), d.removeEventListener(
2363
+ "mousedown",
2364
+ E
2365
+ ), c.removeEventListener(
2366
+ "mousedown",
2367
+ _
2368
+ );
2109
2369
  }
2110
- }).use(ct).process(n);
2111
- return _t(o.value, e, t);
2112
- }
2113
- class io {
2370
+ };
2371
+ }, Po = go({
2372
+ type: "image",
2373
+ propSchema: Lo,
2374
+ containsInlineContent: !1,
2375
+ render: No
2376
+ }), jt = {
2377
+ paragraph: Ao,
2378
+ heading: yo,
2379
+ bulletListItem: Co,
2380
+ numberedListItem: Bo,
2381
+ image: Po
2382
+ };
2383
+ class Do {
2114
2384
  constructor(e, t, o) {
2115
2385
  u(this, "formattingToolbarState");
2116
2386
  u(this, "updateFormattingToolbar");
@@ -2118,7 +2388,7 @@ class io {
2118
2388
  u(this, "preventShow", !1);
2119
2389
  u(this, "prevWasEditable", null);
2120
2390
  u(this, "shouldShow", ({ view: e, state: t, from: o, to: r }) => {
2121
- const { doc: i, selection: s } = t, { empty: l } = s, a = !i.textBetween(o, r).length && Ut(t.selection);
2391
+ const { doc: i, selection: s } = t, { empty: l } = s, a = !i.textBetween(o, r).length && oe(t.selection);
2122
2392
  return !(!e.hasFocus() || l || a);
2123
2393
  });
2124
2394
  u(this, "viewMousedownHandler", () => {
@@ -2159,25 +2429,25 @@ class io {
2159
2429
  }, t.dom.addEventListener("mousedown", this.viewMousedownHandler), t.dom.addEventListener("mouseup", this.viewMouseupHandler), t.dom.addEventListener("dragstart", this.dragstartHandler), t.dom.addEventListener("focus", this.focusHandler), t.dom.addEventListener("blur", this.blurHandler), document.addEventListener("scroll", this.scrollHandler);
2160
2430
  }
2161
2431
  update(e, t) {
2162
- var p, f;
2432
+ var h, p;
2163
2433
  const { state: o, composing: r } = e, { doc: i, selection: s } = o, l = t && t.doc.eq(i) && t.selection.eq(s);
2164
2434
  if ((this.prevWasEditable === null || this.prevWasEditable === this.editor.isEditable) && (r || l))
2165
2435
  return;
2166
2436
  this.prevWasEditable = this.editor.isEditable;
2167
- const { ranges: a } = s, d = Math.min(...a.map((m) => m.$from.pos)), c = Math.max(...a.map((m) => m.$to.pos)), h = (p = this.shouldShow) == null ? void 0 : p.call(this, {
2437
+ const { ranges: a } = s, d = Math.min(...a.map((f) => f.$from.pos)), c = Math.max(...a.map((f) => f.$to.pos)), m = (h = this.shouldShow) == null ? void 0 : h.call(this, {
2168
2438
  view: e,
2169
2439
  state: o,
2170
2440
  from: d,
2171
2441
  to: c
2172
2442
  });
2173
- if (this.editor.isEditable && !this.preventShow && (h || this.preventHide)) {
2443
+ if (this.editor.isEditable && !this.preventShow && (m || this.preventHide)) {
2174
2444
  this.formattingToolbarState = {
2175
2445
  show: !0,
2176
2446
  referencePos: this.getSelectionBoundingBox()
2177
2447
  }, this.updateFormattingToolbar();
2178
2448
  return;
2179
2449
  }
2180
- if ((f = this.formattingToolbarState) != null && f.show && !this.preventHide && (!h || this.preventShow || !this.editor.isEditable)) {
2450
+ if ((p = this.formattingToolbarState) != null && p.show && !this.preventHide && (!m || this.preventShow || !this.editor.isEditable)) {
2181
2451
  this.formattingToolbarState.show = !1, this.updateFormattingToolbar();
2182
2452
  return;
2183
2453
  }
@@ -2187,25 +2457,25 @@ class io {
2187
2457
  }
2188
2458
  getSelectionBoundingBox() {
2189
2459
  const { state: e } = this.pmView, { selection: t } = e, { ranges: o } = t, r = Math.min(...o.map((s) => s.$from.pos)), i = Math.max(...o.map((s) => s.$to.pos));
2190
- if (Ft(t)) {
2460
+ if (ne(t)) {
2191
2461
  const s = this.pmView.nodeDOM(r);
2192
2462
  if (s)
2193
2463
  return s.getBoundingClientRect();
2194
2464
  }
2195
- return q(this.pmView, r, i);
2465
+ return K(this.pmView, r, i);
2196
2466
  }
2197
2467
  }
2198
- const so = new S(
2468
+ const Oo = new B(
2199
2469
  "FormattingToolbarPlugin"
2200
2470
  );
2201
- class ao extends G {
2471
+ class Ro extends U {
2202
2472
  constructor(t) {
2203
2473
  super();
2204
2474
  u(this, "view");
2205
2475
  u(this, "plugin");
2206
- this.plugin = new w({
2207
- key: so,
2208
- view: (o) => (this.view = new io(t, o, (r) => {
2476
+ this.plugin = new T({
2477
+ key: Oo,
2478
+ view: (o) => (this.view = new Do(t, o, (r) => {
2209
2479
  this.emit("update", r);
2210
2480
  }), this.view)
2211
2481
  });
@@ -2214,7 +2484,7 @@ class ao extends G {
2214
2484
  return this.on("update", t);
2215
2485
  }
2216
2486
  }
2217
- class lo {
2487
+ class zo {
2218
2488
  constructor(e, t, o) {
2219
2489
  u(this, "hyperlinkToolbarState");
2220
2490
  u(this, "updateHyperlinkToolbar");
@@ -2234,7 +2504,7 @@ class lo {
2234
2504
  ), i = r.marks();
2235
2505
  for (const s of i)
2236
2506
  if (s.type.name === this.pmView.state.schema.mark("link").type.name) {
2237
- this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange = et(
2507
+ this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange = rt(
2238
2508
  r,
2239
2509
  s.type,
2240
2510
  s.attrs
@@ -2254,7 +2524,7 @@ class lo {
2254
2524
  });
2255
2525
  u(this, "scrollHandler", () => {
2256
2526
  var e;
2257
- this.hyperlinkMark !== void 0 && (e = this.hyperlinkToolbarState) != null && e.show && (this.hyperlinkToolbarState.referencePos = q(
2527
+ this.hyperlinkMark !== void 0 && (e = this.hyperlinkToolbarState) != null && e.show && (this.hyperlinkToolbarState.referencePos = K(
2258
2528
  this.pmView,
2259
2529
  this.hyperlinkMarkRange.from,
2260
2530
  this.hyperlinkMarkRange.to
@@ -2302,7 +2572,7 @@ class lo {
2302
2572
  const o = this.pmView.state.selection.$from.marks();
2303
2573
  for (const r of o)
2304
2574
  if (r.type.name === this.pmView.state.schema.mark("link").type.name) {
2305
- this.keyboardHoveredHyperlinkMark = r, this.keyboardHoveredHyperlinkMarkRange = et(
2575
+ this.keyboardHoveredHyperlinkMark = r, this.keyboardHoveredHyperlinkMarkRange = rt(
2306
2576
  this.pmView.state.selection.$from,
2307
2577
  r.type,
2308
2578
  r.attrs
@@ -2313,7 +2583,7 @@ class lo {
2313
2583
  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) {
2314
2584
  this.hyperlinkToolbarState = {
2315
2585
  show: !0,
2316
- referencePos: q(
2586
+ referencePos: K(
2317
2587
  this.pmView,
2318
2588
  this.hyperlinkMarkRange.from,
2319
2589
  this.hyperlinkMarkRange.to
@@ -2335,10 +2605,10 @@ class lo {
2335
2605
  this.pmView.dom.removeEventListener("mouseover", this.mouseOverHandler), document.removeEventListener("scroll", this.scrollHandler), document.removeEventListener("click", this.clickHandler, !0);
2336
2606
  }
2337
2607
  }
2338
- const co = new S(
2608
+ const Vo = new B(
2339
2609
  "HyperlinkToolbarPlugin"
2340
2610
  );
2341
- class uo extends G {
2611
+ class Uo extends U {
2342
2612
  constructor(t) {
2343
2613
  super();
2344
2614
  u(this, "view");
@@ -2373,9 +2643,9 @@ class uo extends G {
2373
2643
  u(this, "stopHideTimer", () => {
2374
2644
  this.view.stopMenuUpdateTimer();
2375
2645
  });
2376
- this.plugin = new w({
2377
- key: co,
2378
- view: (o) => (this.view = new lo(t, o, (r) => {
2646
+ this.plugin = new T({
2647
+ key: Vo,
2648
+ view: (o) => (this.view = new zo(t, o, (r) => {
2379
2649
  this.emit("update", r);
2380
2650
  }), this.view)
2381
2651
  });
@@ -2384,7 +2654,7 @@ class uo extends G {
2384
2654
  return this.on("update", t);
2385
2655
  }
2386
2656
  }
2387
- class N extends j {
2657
+ class O extends X {
2388
2658
  constructor(t, o) {
2389
2659
  super(t, o);
2390
2660
  u(this, "nodes");
@@ -2395,13 +2665,13 @@ class N extends j {
2395
2665
  });
2396
2666
  }
2397
2667
  static create(t, o, r = o) {
2398
- return new N(t.resolve(o), t.resolve(r));
2668
+ return new O(t.resolve(o), t.resolve(r));
2399
2669
  }
2400
2670
  content() {
2401
- return new x(_.from(this.nodes), 0, 0);
2671
+ return new L(P.from(this.nodes), 0, 0);
2402
2672
  }
2403
2673
  eq(t) {
2404
- if (!(t instanceof N) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to)
2674
+ if (!(t instanceof O) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to)
2405
2675
  return !1;
2406
2676
  for (let o = 0; o < this.nodes.length; o++)
2407
2677
  if (!this.nodes[o].eq(t.nodes[o]))
@@ -2410,7 +2680,7 @@ class N extends j {
2410
2680
  }
2411
2681
  map(t, o) {
2412
2682
  const r = o.mapResult(this.from), i = o.mapResult(this.to);
2413
- return i.deleted ? j.near(t.resolve(r.pos)) : r.deleted ? j.near(t.resolve(i.pos)) : new N(
2683
+ return i.deleted ? X.near(t.resolve(r.pos)) : r.deleted ? X.near(t.resolve(i.pos)) : new O(
2414
2684
  t.resolve(r.pos),
2415
2685
  t.resolve(i.pos)
2416
2686
  );
@@ -2419,9 +2689,9 @@ class N extends j {
2419
2689
  return { type: "node", anchor: this.anchor, head: this.head };
2420
2690
  }
2421
2691
  }
2422
- const po = se.__serializeForClipboard;
2423
- let B;
2424
- function Ht(n, e) {
2692
+ const Fo = ve.__serializeForClipboard;
2693
+ let I;
2694
+ function qt(n, e) {
2425
2695
  var r;
2426
2696
  if (!e.dom.isConnected)
2427
2697
  return;
@@ -2436,15 +2706,15 @@ function Ht(n, e) {
2436
2706
  return { node: o, id: o.getAttribute("data-id") };
2437
2707
  }
2438
2708
  }
2439
- function ho(n, e) {
2440
- const t = Ht(n, e);
2709
+ function Wo(n, e) {
2710
+ const t = qt(n, e);
2441
2711
  if (t && t.node.nodeType === 1) {
2442
2712
  const o = e.docView, r = o.nearestDesc(t.node, !0);
2443
2713
  return !r || r === o ? null : r.posBefore;
2444
2714
  }
2445
2715
  return null;
2446
2716
  }
2447
- function fo(n, e) {
2717
+ function $o(n, e) {
2448
2718
  let t, o;
2449
2719
  const r = e.resolve(n.from).node().type.spec.group === "blockContent", i = e.resolve(n.to).node().type.spec.group === "blockContent", s = Math.min(n.$anchor.depth, n.$head.depth);
2450
2720
  if (r && i) {
@@ -2454,9 +2724,9 @@ function fo(n, e) {
2454
2724
  t = n.from, o = n.to;
2455
2725
  return { from: t, to: o };
2456
2726
  }
2457
- function at(n, e, t = e) {
2727
+ function pt(n, e, t = e) {
2458
2728
  e === t && (t += n.state.doc.resolve(e + 1).node().nodeSize);
2459
- const o = n.domAtPos(e).node.cloneNode(!0), r = n.domAtPos(e).node, i = (c, h) => Array.prototype.indexOf.call(c.children, h), s = i(
2729
+ const o = n.domAtPos(e).node.cloneNode(!0), r = n.domAtPos(e).node, i = (c, m) => Array.prototype.indexOf.call(c.children, m), s = i(
2460
2730
  r,
2461
2731
  // Expects from position to be just before the first selected block.
2462
2732
  n.domAtPos(e + 1).node.parentElement
@@ -2467,35 +2737,35 @@ function at(n, e, t = e) {
2467
2737
  );
2468
2738
  for (let c = r.childElementCount - 1; c >= 0; c--)
2469
2739
  (c > l || c < s) && o.removeChild(o.children[c]);
2470
- Nt(), B = o;
2740
+ Xt(), I = o;
2471
2741
  const d = n.dom.className.split(" ").filter(
2472
2742
  (c) => !c.includes("bn") && !c.includes("ProseMirror") && !c.includes("editor")
2473
2743
  ).join(" ");
2474
- B.className = B.className + " " + H.dragPreview + " " + d, document.body.appendChild(B);
2744
+ I.className = I.className + " " + D.dragPreview + " " + d, document.body.appendChild(I);
2475
2745
  }
2476
- function Nt() {
2477
- B !== void 0 && (document.body.removeChild(B), B = void 0);
2746
+ function Xt() {
2747
+ I !== void 0 && (document.body.removeChild(I), I = void 0);
2478
2748
  }
2479
- function mo(n, e) {
2749
+ function Go(n, e) {
2480
2750
  if (!n.dataTransfer)
2481
2751
  return;
2482
2752
  const t = e.dom.getBoundingClientRect(), o = {
2483
2753
  left: t.left + t.width / 2,
2484
2754
  // take middle of editor
2485
2755
  top: n.clientY
2486
- }, r = ho(o, e);
2756
+ }, r = Wo(o, e);
2487
2757
  if (r != null) {
2488
- const i = e.state.selection, s = e.state.doc, { from: l, to: a } = fo(i, s), d = l <= r && r < a, c = i.$anchor.node() !== i.$head.node() || i instanceof N;
2758
+ const i = e.state.selection, s = e.state.doc, { from: l, to: a } = $o(i, s), d = l <= r && r < a, c = i.$anchor.node() !== i.$head.node() || i instanceof O;
2489
2759
  d && c ? (e.dispatch(
2490
- e.state.tr.setSelection(N.create(s, l, a))
2491
- ), at(e, l, a)) : (e.dispatch(
2492
- e.state.tr.setSelection(re.create(e.state.doc, r))
2493
- ), at(e, r));
2494
- const h = e.state.selection.content(), { dom: p, text: f } = po(e, h);
2495
- n.dataTransfer.clearData(), n.dataTransfer.setData("text/html", p.innerHTML), n.dataTransfer.setData("text/plain", f), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(B, 0, 0), e.dragging = { slice: h, move: !0 };
2760
+ e.state.tr.setSelection(O.create(s, l, a))
2761
+ ), pt(e, l, a)) : (e.dispatch(
2762
+ e.state.tr.setSelection(mt.create(e.state.doc, r))
2763
+ ), pt(e, r));
2764
+ const m = e.state.selection.content(), { dom: h, text: p } = Fo(e, m);
2765
+ n.dataTransfer.clearData(), n.dataTransfer.setData("text/html", h.innerHTML), n.dataTransfer.setData("text/plain", p), n.dataTransfer.effectAllowed = "move", n.dataTransfer.setDragImage(I, 0, 0), e.dragging = { slice: m, move: !0 };
2496
2766
  }
2497
2767
  }
2498
- class ko {
2768
+ class jo {
2499
2769
  constructor(e, t, o) {
2500
2770
  u(this, "sideMenuState");
2501
2771
  // When true, the drag handle with be anchored at the same level as root elements
@@ -2552,7 +2822,7 @@ class ko {
2552
2822
  (t = this.sideMenuState) != null && t.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState)), this.menuFrozen = !1;
2553
2823
  });
2554
2824
  u(this, "onMouseMove", (e) => {
2555
- var d, c, h, p, f;
2825
+ var d, c, m, h, p;
2556
2826
  if (this.menuFrozen)
2557
2827
  return;
2558
2828
  const t = this.pmView.dom.firstChild.getBoundingClientRect(), o = this.pmView.dom.getBoundingClientRect(), r = e.clientX >= o.left && e.clientX <= o.right && e.clientY >= o.top && e.clientY <= o.bottom, i = this.pmView.dom.parentElement;
@@ -2570,24 +2840,24 @@ class ko {
2570
2840
  left: t.left + t.width / 2,
2571
2841
  // take middle of editor
2572
2842
  top: e.clientY
2573
- }, l = Ht(s, this.pmView);
2843
+ }, l = qt(s, this.pmView);
2574
2844
  if (!l || !this.editor.isEditable) {
2575
2845
  (c = this.sideMenuState) != null && c.show && (this.sideMenuState.show = !1, this.updateSideMenu(this.sideMenuState));
2576
2846
  return;
2577
2847
  }
2578
- if ((h = this.sideMenuState) != null && h.show && ((p = this.hoveredBlock) != null && p.hasAttribute("data-id")) && ((f = this.hoveredBlock) == null ? void 0 : f.getAttribute("data-id")) === l.id)
2848
+ if ((m = this.sideMenuState) != null && m.show && ((h = this.hoveredBlock) != null && h.hasAttribute("data-id")) && ((p = this.hoveredBlock) == null ? void 0 : p.getAttribute("data-id")) === l.id)
2579
2849
  return;
2580
2850
  this.hoveredBlock = l.node;
2581
2851
  const a = l.node.firstChild;
2582
2852
  if (a && this.editor.isEditable) {
2583
- const m = a.getBoundingClientRect();
2853
+ const f = a.getBoundingClientRect();
2584
2854
  this.sideMenuState = {
2585
2855
  show: !0,
2586
2856
  referencePos: new DOMRect(
2587
- this.horizontalPosAnchoredAtRoot ? this.horizontalPosAnchor : m.x,
2588
- m.y,
2589
- m.width,
2590
- m.height
2857
+ this.horizontalPosAnchoredAtRoot ? this.horizontalPosAnchor : f.x,
2858
+ f.y,
2859
+ f.width,
2860
+ f.height
2591
2861
  ),
2592
2862
  block: this.editor.getBlock(
2593
2863
  this.hoveredBlock.getAttribute("data-id")
@@ -2622,7 +2892,7 @@ class ko {
2622
2892
  });
2623
2893
  if (!o)
2624
2894
  return;
2625
- const r = k(
2895
+ const r = b(
2626
2896
  this.editor._tiptapEditor.state.doc,
2627
2897
  o.pos
2628
2898
  );
@@ -2635,7 +2905,7 @@ class ko {
2635
2905
  } else
2636
2906
  this.editor._tiptapEditor.commands.setTextSelection(s);
2637
2907
  this.pmView.focus(), this.pmView.dispatch(
2638
- this.pmView.state.tr.scrollIntoView().setMeta(X, {
2908
+ this.pmView.state.tr.scrollIntoView().setMeta(tt, {
2639
2909
  // TODO import suggestion plugin key
2640
2910
  activate: !0,
2641
2911
  type: "drag"
@@ -2643,8 +2913,8 @@ class ko {
2643
2913
  );
2644
2914
  }
2645
2915
  }
2646
- const go = new S("SideMenuPlugin");
2647
- class bo extends G {
2916
+ const qo = new B("SideMenuPlugin");
2917
+ class Xo extends U {
2648
2918
  constructor(t) {
2649
2919
  super();
2650
2920
  u(this, "sideMenuView");
@@ -2658,12 +2928,12 @@ class bo extends G {
2658
2928
  * Handles drag & drop events for blocks.
2659
2929
  */
2660
2930
  u(this, "blockDragStart", (t) => {
2661
- this.sideMenuView.isDragging = !0, mo(t, this.editor.prosemirrorView);
2931
+ this.sideMenuView.isDragging = !0, Go(t, this.editor.prosemirrorView);
2662
2932
  });
2663
2933
  /**
2664
2934
  * Handles drag & drop events for blocks.
2665
2935
  */
2666
- u(this, "blockDragEnd", () => Nt());
2936
+ u(this, "blockDragEnd", () => Xt());
2667
2937
  /**
2668
2938
  * Freezes the side menu. When frozen, the side menu will stay
2669
2939
  * attached to the same block regardless of which block is hovered by the
@@ -2676,9 +2946,9 @@ class bo extends G {
2676
2946
  * mouse cursor.
2677
2947
  */
2678
2948
  u(this, "unfreezeMenu", () => this.sideMenuView.menuFrozen = !1);
2679
- this.editor = t, this.plugin = new w({
2680
- key: go,
2681
- view: (o) => (this.sideMenuView = new ko(
2949
+ this.editor = t, this.plugin = new T({
2950
+ key: qo,
2951
+ view: (o) => (this.sideMenuView = new jo(
2682
2952
  t,
2683
2953
  o,
2684
2954
  (r) => {
@@ -2691,59 +2961,88 @@ class bo extends G {
2691
2961
  return this.on("update", t);
2692
2962
  }
2693
2963
  }
2694
- function I(n, e) {
2964
+ function H(n, e) {
2695
2965
  const t = n.getTextCursorPosition().block;
2966
+ if (t.content === void 0)
2967
+ throw new Error(
2968
+ "Slash Menu open in a block that doesn't contain inline content."
2969
+ );
2696
2970
  t.content.length === 1 && t.content[0].type === "text" && t.content[0].text === "/" || t.content.length === 0 ? n.updateBlock(t, e) : (n.insertBlocks([e], t, "after"), n.setTextCursorPosition(n.getTextCursorPosition().nextBlock));
2697
2971
  }
2698
- const yo = (n = St) => {
2972
+ const Ko = (n = jt) => {
2699
2973
  var t, o, r;
2700
2974
  const e = [];
2701
- return "heading" in n && "level" in n.heading.propSchema && ((t = n.heading.propSchema.level.values) != null && t.includes("1") && e.push({
2975
+ return "heading" in n && "level" in n.heading.propSchema && ((t = n.heading.propSchema.level.values) != null && t.includes(1) && e.push({
2702
2976
  name: "Heading",
2703
2977
  aliases: ["h", "heading1", "h1"],
2704
- execute: (i) => I(i, {
2978
+ execute: (i) => H(i, {
2705
2979
  type: "heading",
2706
- props: { level: "1" }
2980
+ props: { level: 1 }
2707
2981
  })
2708
- }), (o = n.heading.propSchema.level.values) != null && o.includes("2") && e.push({
2982
+ }), (o = n.heading.propSchema.level.values) != null && o.includes(2) && e.push({
2709
2983
  name: "Heading 2",
2710
2984
  aliases: ["h2", "heading2", "subheading"],
2711
- execute: (i) => I(i, {
2985
+ execute: (i) => H(i, {
2712
2986
  type: "heading",
2713
- props: { level: "2" }
2987
+ props: { level: 2 }
2714
2988
  })
2715
- }), (r = n.heading.propSchema.level.values) != null && r.includes("3") && e.push({
2989
+ }), (r = n.heading.propSchema.level.values) != null && r.includes(3) && e.push({
2716
2990
  name: "Heading 3",
2717
2991
  aliases: ["h3", "heading3", "subheading"],
2718
- execute: (i) => I(i, {
2992
+ execute: (i) => H(i, {
2719
2993
  type: "heading",
2720
- props: { level: "3" }
2994
+ props: { level: 3 }
2721
2995
  })
2722
2996
  })), "bulletListItem" in n && e.push({
2723
2997
  name: "Bullet List",
2724
2998
  aliases: ["ul", "list", "bulletlist", "bullet list"],
2725
- execute: (i) => I(i, {
2999
+ execute: (i) => H(i, {
2726
3000
  type: "bulletListItem"
2727
3001
  })
2728
3002
  }), "numberedListItem" in n && e.push({
2729
3003
  name: "Numbered List",
2730
3004
  aliases: ["li", "list", "numberedlist", "numbered list"],
2731
- execute: (i) => I(i, {
3005
+ execute: (i) => H(i, {
2732
3006
  type: "numberedListItem"
2733
3007
  })
2734
3008
  }), "paragraph" in n && e.push({
2735
3009
  name: "Paragraph",
2736
3010
  aliases: ["p"],
2737
- execute: (i) => I(i, {
3011
+ execute: (i) => H(i, {
2738
3012
  type: "paragraph"
2739
3013
  })
3014
+ }), "image" in n && e.push({
3015
+ name: "Image",
3016
+ aliases: [
3017
+ "image",
3018
+ "imageUpload",
3019
+ "upload",
3020
+ "img",
3021
+ "picture",
3022
+ "media",
3023
+ "url",
3024
+ "drive",
3025
+ "dropbox"
3026
+ ],
3027
+ execute: (i) => {
3028
+ H(i, {
3029
+ type: "image"
3030
+ }), i.setTextCursorPosition(
3031
+ i.getTextCursorPosition().nextBlock,
3032
+ "start"
3033
+ ), i._tiptapEditor.view.dispatch(
3034
+ i._tiptapEditor.state.tr.setMeta(z, {
3035
+ block: i.getTextCursorPosition().prevBlock
3036
+ })
3037
+ );
3038
+ }
2740
3039
  }), e;
2741
- }, vo = {
3040
+ }, Yo = {
2742
3041
  enableInputRules: !0,
2743
3042
  enablePasteRules: !0,
2744
3043
  enableCoreExtensions: !1
2745
3044
  };
2746
- class Qo {
3045
+ class xn {
2747
3046
  constructor(e = {}) {
2748
3047
  u(this, "_tiptapEditor");
2749
3048
  u(this, "blockCache", /* @__PURE__ */ new WeakMap());
@@ -2753,7 +3052,9 @@ class Qo {
2753
3052
  u(this, "formattingToolbar");
2754
3053
  u(this, "slashMenu");
2755
3054
  u(this, "hyperlinkToolbar");
2756
- var l, a, d, c, h;
3055
+ u(this, "imageToolbar");
3056
+ u(this, "uploadFile");
3057
+ var l, a, d, c, m;
2757
3058
  this.options = e;
2758
3059
  const t = {
2759
3060
  defaultStyles: !0,
@@ -2762,73 +3063,76 @@ class Qo {
2762
3063
  // If BSchema is not specified, then options.blockSchema should also not
2763
3064
  // be defined. Unfortunately, trying to implement these constraints seems
2764
3065
  // to be a huge pain, hence the `as any` casts.
2765
- blockSchema: e.blockSchema || St,
3066
+ blockSchema: e.blockSchema || jt,
2766
3067
  ...e
2767
3068
  };
2768
- this.sideMenu = new bo(this), this.formattingToolbar = new ao(this), this.slashMenu = new $e(
3069
+ this.sideMenu = new Xo(this), this.formattingToolbar = new Ro(this), this.slashMenu = new Je(
2769
3070
  this,
2770
- t.slashMenuItems || yo(t.blockSchema)
2771
- ), this.hyperlinkToolbar = new uo(this);
2772
- const o = Xe({
3071
+ t.slashMenuItems || Ko(t.blockSchema)
3072
+ ), this.hyperlinkToolbar = new Uo(this), this.imageToolbar = new Ho(this);
3073
+ const o = ro({
2773
3074
  editor: this,
2774
3075
  domAttributes: t.domAttributes || {},
2775
3076
  blockSchema: t.blockSchema,
2776
3077
  collaboration: t.collaboration
2777
- }), r = T.create({
3078
+ }), r = A.create({
2778
3079
  name: "BlockNoteUIExtension",
2779
3080
  addProseMirrorPlugins: () => [
2780
3081
  this.sideMenu.plugin,
2781
3082
  this.formattingToolbar.plugin,
2782
3083
  this.slashMenu.plugin,
2783
- this.hyperlinkToolbar.plugin
3084
+ this.hyperlinkToolbar.plugin,
3085
+ this.imageToolbar.plugin
2784
3086
  ]
2785
3087
  });
2786
- o.push(r), this.schema = t.blockSchema;
3088
+ o.push(r), this.schema = t.blockSchema, this.uploadFile = t.uploadFile;
2787
3089
  const i = t.initialContent || (e.collaboration ? void 0 : [
2788
3090
  {
2789
3091
  type: "paragraph",
2790
- id: F.options.generateID()
3092
+ id: j.options.generateID()
2791
3093
  }
2792
3094
  ]), s = {
2793
- ...vo,
3095
+ ...Yo,
2794
3096
  ...t._tiptapOptions,
2795
- onCreate: () => {
2796
- var p;
2797
- (p = t.onEditorReady) == null || p.call(t, this), this.ready = !0;
2798
- },
2799
- onBeforeCreate(p) {
3097
+ onBeforeCreate(h) {
2800
3098
  if (!i)
2801
3099
  return;
2802
- const f = p.editor.schema, m = i.map((b) => D(b, f)), g = f.node(
3100
+ const p = h.editor.schema, f = p.node(
2803
3101
  "doc",
2804
3102
  void 0,
2805
- f.node("blockGroup", void 0, m)
3103
+ p.node("blockGroup", void 0, [
3104
+ V({ id: "initialBlock", type: "paragraph" }, p)
3105
+ ])
2806
3106
  );
2807
- p.editor.options.content = g.toJSON();
3107
+ h.editor.options.content = f.toJSON();
3108
+ },
3109
+ onCreate: () => {
3110
+ var h;
3111
+ i !== void 0 && this.replaceBlocks(this.topLevelBlocks, i), (h = t.onEditorReady) == null || h.call(t, this), this.ready = !0;
2808
3112
  },
2809
3113
  onUpdate: () => {
2810
- var p;
2811
- this.ready && ((p = t.onEditorContentChange) == null || p.call(t, this));
3114
+ var h;
3115
+ this.ready && ((h = t.onEditorContentChange) == null || h.call(t, this));
2812
3116
  },
2813
3117
  onSelectionUpdate: () => {
2814
- var p;
2815
- this.ready && ((p = t.onTextCursorPositionChange) == null || p.call(t, this));
3118
+ var h;
3119
+ this.ready && ((h = t.onTextCursorPositionChange) == null || h.call(t, this));
2816
3120
  },
2817
3121
  editable: e.editable === void 0 ? !0 : e.editable,
2818
3122
  extensions: t.enableBlockNoteExtensions === !1 ? (l = t._tiptapOptions) == null ? void 0 : l.extensions : [...((a = t._tiptapOptions) == null ? void 0 : a.extensions) || [], ...o],
2819
3123
  editorProps: {
2820
3124
  attributes: {
2821
3125
  ...(d = t.domAttributes) == null ? void 0 : d.editor,
2822
- class: v(
2823
- H.bnEditor,
2824
- H.bnRoot,
2825
- t.defaultStyles ? H.defaultStyles : "",
2826
- ((h = (c = t.domAttributes) == null ? void 0 : c.editor) == null ? void 0 : h.class) || ""
3126
+ class: S(
3127
+ D.bnEditor,
3128
+ D.bnRoot,
3129
+ t.defaultStyles ? D.defaultStyles : "",
3130
+ ((m = (c = t.domAttributes) == null ? void 0 : c.editor) == null ? void 0 : m.class) || ""
2827
3131
  )
2828
3132
  }
2829
3133
  }
2830
3134
  };
2831
- t.parentElement && (s.element = t.parentElement), this._tiptapEditor = new Gt(s);
3135
+ t.parentElement && (s.element = t.parentElement), this._tiptapEditor = new re(s);
2832
3136
  }
2833
3137
  get prosemirrorView() {
2834
3138
  return this._tiptapEditor.view;
@@ -2848,7 +3152,7 @@ class Qo {
2848
3152
  */
2849
3153
  get topLevelBlocks() {
2850
3154
  const e = [];
2851
- return this._tiptapEditor.state.doc.firstChild.descendants((t) => (e.push(E(t, this.schema, this.blockCache)), !1)), e;
3155
+ return this._tiptapEditor.state.doc.firstChild.descendants((t) => (e.push(x(t, this.schema, this.blockCache)), !1)), e;
2852
3156
  }
2853
3157
  /**
2854
3158
  * Gets a snapshot of an existing block from the editor.
@@ -2858,7 +3162,7 @@ class Qo {
2858
3162
  getBlock(e) {
2859
3163
  const t = typeof e == "string" ? e : e.id;
2860
3164
  let o;
2861
- return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof o < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== t ? !0 : (o = E(r, this.schema, this.blockCache), !1)), o;
3165
+ return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof o < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== t ? !0 : (o = x(r, this.schema, this.blockCache), !1)), o;
2862
3166
  }
2863
3167
  /**
2864
3168
  * Traverses all blocks in the editor depth-first, and executes a callback for each.
@@ -2899,7 +3203,7 @@ class Qo {
2899
3203
  * @returns A snapshot of the current text cursor position.
2900
3204
  */
2901
3205
  getTextCursorPosition() {
2902
- const { node: e, depth: t, startPos: o, endPos: r } = k(
3206
+ const { node: e, depth: t, startPos: o, endPos: r } = b(
2903
3207
  this._tiptapEditor.state.doc,
2904
3208
  this._tiptapEditor.state.selection.from
2905
3209
  ), i = this._tiptapEditor.state.doc.resolve(r).index(t - 1), s = this._tiptapEditor.state.doc.resolve(r + 1).node().childCount;
@@ -2907,9 +3211,9 @@ class Qo {
2907
3211
  i > 0 && (l = this._tiptapEditor.state.doc.resolve(o - 2).node());
2908
3212
  let a;
2909
3213
  return i < s - 1 && (a = this._tiptapEditor.state.doc.resolve(r + 2).node()), {
2910
- block: E(e, this.schema, this.blockCache),
2911
- prevBlock: l === void 0 ? void 0 : E(l, this.schema, this.blockCache),
2912
- nextBlock: a === void 0 ? void 0 : E(a, this.schema, this.blockCache)
3214
+ block: x(e, this.schema, this.blockCache),
3215
+ prevBlock: l === void 0 ? void 0 : x(l, this.schema, this.blockCache),
3216
+ nextBlock: a === void 0 ? void 0 : x(a, this.schema, this.blockCache)
2913
3217
  };
2914
3218
  }
2915
3219
  /**
@@ -2919,10 +3223,14 @@ class Qo {
2919
3223
  * @param placement Whether the text cursor should be placed at the start or end of the block.
2920
3224
  */
2921
3225
  setTextCursorPosition(e, t = "start") {
2922
- const o = typeof e == "string" ? e : e.id, { posBeforeNode: r } = Z(o, this._tiptapEditor.state.doc), { startPos: i, contentNode: s } = k(
3226
+ const o = typeof e == "string" ? e : e.id, { posBeforeNode: r } = et(o, this._tiptapEditor.state.doc), { startPos: i, contentNode: s } = b(
2923
3227
  this._tiptapEditor.state.doc,
2924
3228
  r + 2
2925
3229
  );
3230
+ if (s.type.spec.content === "") {
3231
+ this._tiptapEditor.commands.setNodeSelection(i);
3232
+ return;
3233
+ }
2926
3234
  t === "start" ? this._tiptapEditor.commands.setTextSelection(i + 1) : this._tiptapEditor.commands.setTextSelection(
2927
3235
  i + s.nodeSize - 1
2928
3236
  );
@@ -2931,11 +3239,11 @@ class Qo {
2931
3239
  * Gets a snapshot of the current selection.
2932
3240
  */
2933
3241
  getSelection() {
2934
- if (this._tiptapEditor.state.selection.from === this._tiptapEditor.state.selection.to)
3242
+ if (this._tiptapEditor.state.selection.from === this._tiptapEditor.state.selection.to || "node" in this._tiptapEditor.state.selection)
2935
3243
  return;
2936
3244
  const e = [];
2937
3245
  return this._tiptapEditor.state.doc.descendants((t, o) => t.type.spec.group !== "blockContent" || o + t.nodeSize < this._tiptapEditor.state.selection.from || o > this._tiptapEditor.state.selection.to ? !0 : (e.push(
2938
- E(
3246
+ x(
2939
3247
  this._tiptapEditor.state.doc.resolve(o).node(),
2940
3248
  this.schema,
2941
3249
  this.blockCache
@@ -2965,7 +3273,7 @@ class Qo {
2965
3273
  * `referenceBlock`. Inserts the blocks at the start of the existing block's children if "nested" is used.
2966
3274
  */
2967
3275
  insertBlocks(e, t, o = "before") {
2968
- xt(e, t, o, this._tiptapEditor);
3276
+ Ut(e, t, o, this._tiptapEditor);
2969
3277
  }
2970
3278
  /**
2971
3279
  * Updates an existing block in the editor. Since updatedBlock is a PartialBlock object, some fields might not be
@@ -2975,14 +3283,14 @@ class Qo {
2975
3283
  * @param update A partial block which defines how the existing block should be changed.
2976
3284
  */
2977
3285
  updateBlock(e, t) {
2978
- Ze(e, t, this._tiptapEditor);
3286
+ io(e, t, this._tiptapEditor);
2979
3287
  }
2980
3288
  /**
2981
3289
  * Removes existing blocks from the editor. Throws an error if any of the blocks could not be found.
2982
3290
  * @param blocksToRemove An array of identifiers for existing blocks that should be removed.
2983
3291
  */
2984
3292
  removeBlocks(e) {
2985
- At(e, this._tiptapEditor);
3293
+ Ft(e, this._tiptapEditor);
2986
3294
  }
2987
3295
  /**
2988
3296
  * Replaces existing blocks in the editor with new blocks. If the blocks that should be removed are not adjacent or
@@ -2992,7 +3300,7 @@ class Qo {
2992
3300
  * @param blocksToInsert An array of partial blocks to replace the old ones with.
2993
3301
  */
2994
3302
  replaceBlocks(e, t) {
2995
- Qe(e, t, this._tiptapEditor);
3303
+ so(e, t, this._tiptapEditor);
2996
3304
  }
2997
3305
  /**
2998
3306
  * Gets the active text styles at the text cursor position or at the end of the current selection if it's active.
@@ -3084,7 +3392,7 @@ class Qo {
3084
3392
  * Checks if the block containing the text cursor can be nested.
3085
3393
  */
3086
3394
  canNestBlock() {
3087
- const { startPos: e, depth: t } = k(
3395
+ const { startPos: e, depth: t } = b(
3088
3396
  this._tiptapEditor.state.doc,
3089
3397
  this._tiptapEditor.state.selection.from
3090
3398
  );
@@ -3100,7 +3408,7 @@ class Qo {
3100
3408
  * Checks if the block containing the text cursor is nested.
3101
3409
  */
3102
3410
  canUnnestBlock() {
3103
- const { depth: e } = k(
3411
+ const { depth: e } = b(
3104
3412
  this._tiptapEditor.state.doc,
3105
3413
  this._tiptapEditor.state.selection.from
3106
3414
  );
@@ -3119,7 +3427,7 @@ class Qo {
3119
3427
  * @returns The blocks, serialized as an HTML string.
3120
3428
  */
3121
3429
  async blocksToHTML(e) {
3122
- return It(e, this._tiptapEditor.schema);
3430
+ return Wt(e, this._tiptapEditor.schema);
3123
3431
  }
3124
3432
  /**
3125
3433
  * Parses blocks from an HTML string. Tries to create `Block` objects out of any HTML block-level elements, and
@@ -3129,7 +3437,7 @@ class Qo {
3129
3437
  * @returns The blocks parsed from the HTML string.
3130
3438
  */
3131
3439
  async HTMLToBlocks(e) {
3132
- return _t(e, this.schema, this._tiptapEditor.schema);
3440
+ return $t(e, this.schema, this._tiptapEditor.schema);
3133
3441
  }
3134
3442
  /**
3135
3443
  * Serializes blocks into a Markdown string. The output is simplified as Markdown does not support all features of
@@ -3138,7 +3446,7 @@ class Qo {
3138
3446
  * @returns The blocks, serialized as a Markdown string.
3139
3447
  */
3140
3448
  async blocksToMarkdown(e) {
3141
- return oo(e, this._tiptapEditor.schema);
3449
+ return co(e, this._tiptapEditor.schema);
3142
3450
  }
3143
3451
  /**
3144
3452
  * Creates a list of blocks from a Markdown string. Tries to create `Block` and `InlineNode` objects based on
@@ -3148,7 +3456,7 @@ class Qo {
3148
3456
  * @returns The blocks parsed from the Markdown string.
3149
3457
  */
3150
3458
  async markdownToBlocks(e) {
3151
- return ro(e, this.schema, this._tiptapEditor.schema);
3459
+ return po(e, this.schema, this._tiptapEditor.schema);
3152
3460
  }
3153
3461
  /**
3154
3462
  * Updates the user info for the current user that's shown to other collaborators.
@@ -3161,34 +3469,48 @@ class Qo {
3161
3469
  this._tiptapEditor.commands.updateUser(e);
3162
3470
  }
3163
3471
  }
3472
+ const In = async (n) => {
3473
+ const e = new FormData();
3474
+ return e.append("file", n), (await (await fetch("https://tmpfiles.org/api/v1/upload", {
3475
+ method: "POST",
3476
+ body: e
3477
+ })).json()).data.url.replace(
3478
+ "tmpfiles.org/",
3479
+ "tmpfiles.org/dl/"
3480
+ );
3481
+ };
3164
3482
  export {
3165
- Qo as BlockNoteEditor,
3166
- ze as CustomBlockSerializerExtension,
3167
- ao as FormattingToolbarProsemirrorPlugin,
3168
- io as FormattingToolbarView,
3169
- uo as HyperlinkToolbarProsemirrorPlugin,
3170
- bo as SideMenuProsemirrorPlugin,
3171
- ko as SideMenuView,
3172
- $e as SlashMenuProsemirrorPlugin,
3173
- ye as UnreachableCaseError,
3174
- Jo as blockStyles,
3175
- rt as camelToDataKebab,
3176
- Zo as createBlockSpec,
3177
- O as createTipTapBlock,
3178
- St as defaultBlockSchema,
3179
- P as defaultProps,
3180
- Xo as formatKeyboardShortcut,
3181
- so as formattingToolbarPluginKey,
3182
- Xe as getBlockNoteExtensions,
3183
- yo as getDefaultSlashMenuItems,
3184
- co as hyperlinkToolbarPluginKey,
3185
- be as isAppleOS,
3186
- v as mergeCSSClasses,
3187
- Ce as parse,
3188
- ve as propsToAttributes,
3189
- we as render,
3190
- Ge as setupSuggestionsMenu,
3191
- go as sideMenuPluginKey,
3192
- X as slashMenuPluginKey
3483
+ xn as BlockNoteEditor,
3484
+ qe as CustomBlockSerializerExtension,
3485
+ Ro as FormattingToolbarProsemirrorPlugin,
3486
+ Do as FormattingToolbarView,
3487
+ Uo as HyperlinkToolbarProsemirrorPlugin,
3488
+ Ho as ImageToolbarProsemirrorPlugin,
3489
+ _o as ImageToolbarView,
3490
+ Xo as SideMenuProsemirrorPlugin,
3491
+ jo as SideMenuView,
3492
+ Je as SlashMenuProsemirrorPlugin,
3493
+ Pe as UnreachableCaseError,
3494
+ Bn as blockStyles,
3495
+ dt as camelToDataKebab,
3496
+ go as createBlockSpec,
3497
+ F as createTipTapBlock,
3498
+ jt as defaultBlockSchema,
3499
+ C as defaultProps,
3500
+ Mn as formatKeyboardShortcut,
3501
+ Oo as formattingToolbarPluginKey,
3502
+ ro as getBlockNoteExtensions,
3503
+ Ko as getDefaultSlashMenuItems,
3504
+ Vo as hyperlinkToolbarPluginKey,
3505
+ z as imageToolbarPluginKey,
3506
+ Ne as isAppleOS,
3507
+ S as mergeCSSClasses,
3508
+ mo as parse,
3509
+ ho as propsToAttributes,
3510
+ fo as render,
3511
+ Ye as setupSuggestionsMenu,
3512
+ qo as sideMenuPluginKey,
3513
+ tt as slashMenuPluginKey,
3514
+ In as uploadToTmpFilesDotOrg_DEV_ONLY
3193
3515
  };
3194
3516
  //# sourceMappingURL=blocknote.js.map