@blocknote/core 0.9.4 → 0.9.6

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