@blocknote/core 0.4.6-alpha.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/blocknote.js CHANGED
@@ -1,9 +1,9 @@
1
1
  var Ce = Object.defineProperty;
2
2
  var Be = (o, e, t) => e in o ? Ce(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
3
  var h = (o, e, t) => (Be(o, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { Extension as C, findChildren as q, combineTransactionSteps as Te, getChangedRanges as we, findChildrenInRange as Me, Mark as ne, Node as E, mergeAttributes as x, InputRule as j, findParentNode as xe, isTextSelection as Ee, isNodeSelection as Ie, posToDOMRect as re, getMarkRange as X, extensions as N, Editor as Se } from "@tiptap/core";
4
+ import { Extension as C, findChildren as $, combineTransactionSteps as Te, getChangedRanges as Me, findChildrenInRange as we, Mark as ne, Node as E, mergeAttributes as x, InputRule as Y, findParentNode as xe, isTextSelection as Ee, isNodeSelection as Ie, posToDOMRect as re, getMarkRange as X, extensions as N, Editor as Se } from "@tiptap/core";
5
5
  import { Slice as A, Fragment as P, DOMSerializer as Ae, DOMParser as Pe } from "prosemirror-model";
6
- import { Plugin as B, PluginKey as v, TextSelection as Q, Selection as U, NodeSelection as Ne } from "prosemirror-state";
6
+ import { Plugin as B, PluginKey as v, TextSelection as Q, Selection as G, NodeSelection as Ne } from "prosemirror-state";
7
7
  import { v4 as Le } from "uuid";
8
8
  import ie from "rehype-parse";
9
9
  import He from "rehype-remark";
@@ -12,21 +12,21 @@ import ae from "remark-gfm";
12
12
  import Oe from "remark-parse";
13
13
  import _e from "remark-rehype";
14
14
  import De from "remark-stringify";
15
- import { unified as Y } from "unified";
15
+ import { unified as W } from "unified";
16
16
  import { fromDom as Z } from "hast-util-from-dom";
17
17
  import { Bold as Fe } from "@tiptap/extension-bold";
18
18
  import { Code as Re } from "@tiptap/extension-code";
19
19
  import { Dropcursor as ze } from "@tiptap/extension-dropcursor";
20
20
  import { Gapcursor as Ue } from "@tiptap/extension-gapcursor";
21
- import { HardBreak as qe } from "@tiptap/extension-hard-break";
22
- import { History as Ge } from "@tiptap/extension-history";
23
- import { Italic as $e } from "@tiptap/extension-italic";
21
+ import { HardBreak as Ge } from "@tiptap/extension-hard-break";
22
+ import { History as $e } from "@tiptap/extension-history";
23
+ import { Italic as qe } from "@tiptap/extension-italic";
24
24
  import { Link as de } from "@tiptap/extension-link";
25
- import { Strike as je } from "@tiptap/extension-strike";
26
- import { Text as Ye } from "@tiptap/extension-text";
27
- import { Underline as We } from "@tiptap/extension-underline";
25
+ import { Strike as Ye } from "@tiptap/extension-strike";
26
+ import { Text as We } from "@tiptap/extension-text";
27
+ import { Underline as je } from "@tiptap/extension-underline";
28
28
  import * as Ve from "prosemirror-view";
29
- import { Decoration as _, DecorationSet as D } from "prosemirror-view";
29
+ import { Decoration as D, DecorationSet as F } from "prosemirror-view";
30
30
  const O = [
31
31
  "backgroundColor",
32
32
  "textColor",
@@ -54,12 +54,12 @@ function k(o, e) {
54
54
  break;
55
55
  i -= 1, r = t.node(i);
56
56
  }
57
- const d = r.attrs.id, s = r.firstChild, a = s.type, l = r.childCount === 2 ? r.lastChild.childCount : 0, c = t.start(i), u = t.end(i);
57
+ const a = r.attrs.id, s = r.firstChild, d = s.type, l = r.childCount === 2 ? r.lastChild.childCount : 0, c = t.start(i), u = t.end(i);
58
58
  return {
59
- id: d,
59
+ id: a,
60
60
  node: r,
61
61
  contentNode: s,
62
- contentType: a,
62
+ contentType: d,
63
63
  numChildBlocks: l,
64
64
  startPos: c,
65
65
  endPos: u,
@@ -79,7 +79,7 @@ function Je(o) {
79
79
  );
80
80
  return Ke(e);
81
81
  }
82
- const W = C.create({
82
+ const j = C.create({
83
83
  name: "uniqueID",
84
84
  // we’ll set a very high priority to make sure this runs first
85
85
  // and is compatible with `appendTransaction` hooks of other extensions
@@ -111,14 +111,14 @@ const W = C.create({
111
111
  // check initial content for missing ids
112
112
  onCreate() {
113
113
  if (this.editor.extensionManager.extensions.find(
114
- (a) => a.name === "collaboration"
114
+ (d) => d.name === "collaboration"
115
115
  ))
116
116
  return;
117
- const { view: o, state: e } = this.editor, { tr: t, doc: n } = e, { types: r, attributeName: i, generateID: d } = this.options;
118
- q(n, (a) => r.includes(a.type.name) && a.attrs[i] === null).forEach(({ node: a, pos: l }) => {
117
+ const { view: o, state: e } = this.editor, { tr: t, doc: n } = e, { types: r, attributeName: i, generateID: a } = this.options;
118
+ $(n, (d) => r.includes(d.type.name) && d.attrs[i] === null).forEach(({ node: d, pos: l }) => {
119
119
  t.setNodeMarkup(l, void 0, {
120
- ...a.attrs,
121
- [i]: d()
120
+ ...d.attrs,
121
+ [i]: a()
122
122
  });
123
123
  }), t.setMeta("addToHistory", !1), o.dispatch(t);
124
124
  },
@@ -128,25 +128,25 @@ const W = C.create({
128
128
  new B({
129
129
  key: new v("uniqueID"),
130
130
  appendTransaction: (t, n, r) => {
131
- const i = t.some((m) => m.docChanged) && !n.doc.eq(r.doc), d = this.options.filterTransaction && t.some((m) => {
131
+ const i = t.some((m) => m.docChanged) && !n.doc.eq(r.doc), a = this.options.filterTransaction && t.some((m) => {
132
132
  var y, g;
133
133
  return !(!((g = (y = this.options).filterTransaction) === null || g === void 0) && g.call(y, m));
134
134
  });
135
- if (!i || d)
135
+ if (!i || a)
136
136
  return;
137
- const { tr: s } = r, { types: a, attributeName: l, generateID: c } = this.options, u = Te(
137
+ const { tr: s } = r, { types: d, attributeName: l, generateID: c } = this.options, u = Te(
138
138
  n.doc,
139
139
  t
140
140
  ), { mapping: f } = u;
141
- if (we(u).forEach(({ newRange: m }) => {
142
- const y = Me(
141
+ if (Me(u).forEach(({ newRange: m }) => {
142
+ const y = we(
143
143
  r.doc,
144
144
  m,
145
- (T) => a.includes(T.type.name)
146
- ), g = y.map(({ node: T }) => T.attrs[l]).filter((T) => T !== null), R = Je(g);
145
+ (T) => d.includes(T.type.name)
146
+ ), g = y.map(({ node: T }) => T.attrs[l]).filter((T) => T !== null), z = Je(g);
147
147
  y.forEach(({ node: T, pos: H }) => {
148
- var z;
149
- const J = (z = s.doc.nodeAt(H)) === null || z === void 0 ? void 0 : z.attrs[l];
148
+ var U;
149
+ const J = (U = s.doc.nodeAt(H)) === null || U === void 0 ? void 0 : U.attrs[l];
150
150
  if (J === null) {
151
151
  s.setNodeMarkup(H, void 0, {
152
152
  ...T.attrs,
@@ -155,7 +155,7 @@ const W = C.create({
155
155
  return;
156
156
  }
157
157
  const { deleted: ve } = f.invert().mapResult(H);
158
- ve && R.includes(J) && s.setNodeMarkup(H, void 0, {
158
+ ve && z.includes(J) && s.setNodeMarkup(H, void 0, {
159
159
  ...T.attrs,
160
160
  [l]: c()
161
161
  });
@@ -193,24 +193,24 @@ const W = C.create({
193
193
  transformPasted: (t) => {
194
194
  if (!e)
195
195
  return t;
196
- const { types: n, attributeName: r } = this.options, i = (d) => {
196
+ const { types: n, attributeName: r } = this.options, i = (a) => {
197
197
  const s = [];
198
- return d.forEach((a) => {
199
- if (a.isText) {
200
- s.push(a);
198
+ return a.forEach((d) => {
199
+ if (d.isText) {
200
+ s.push(d);
201
201
  return;
202
202
  }
203
- if (!n.includes(a.type.name)) {
204
- s.push(a.copy(i(a.content)));
203
+ if (!n.includes(d.type.name)) {
204
+ s.push(d.copy(i(d.content)));
205
205
  return;
206
206
  }
207
- const l = a.type.create(
207
+ const l = d.type.create(
208
208
  {
209
- ...a.attrs,
209
+ ...d.attrs,
210
210
  [r]: null
211
211
  },
212
- i(a.content),
213
- a.marks
212
+ i(d.content),
213
+ d.marks
214
214
  );
215
215
  s.push(l);
216
216
  }), P.from(s);
@@ -268,9 +268,9 @@ function he(o, e) {
268
268
  throw new Xe(n);
269
269
  return t;
270
270
  }
271
- function F(o, e) {
271
+ function R(o, e) {
272
272
  let t = o.id;
273
- t === void 0 && (t = W.options.generateID());
273
+ t === void 0 && (t = j.options.generateID());
274
274
  let n = o.type;
275
275
  n === void 0 && (n = "paragraph");
276
276
  let r;
@@ -288,14 +288,14 @@ function F(o, e) {
288
288
  const i = [];
289
289
  if (o.children)
290
290
  for (const s of o.children)
291
- i.push(F(s, e));
292
- const d = e.nodes.blockGroup.create({}, i);
291
+ i.push(R(s, e));
292
+ const a = e.nodes.blockGroup.create({}, i);
293
293
  return e.nodes.blockContainer.create(
294
294
  {
295
295
  id: t,
296
296
  ...o.props
297
297
  },
298
- i.length > 0 ? [r, d] : r
298
+ i.length > 0 ? [r, a] : r
299
299
  );
300
300
  }
301
301
  function et(o) {
@@ -304,15 +304,15 @@ function et(o) {
304
304
  return o.content.forEach((n) => {
305
305
  const r = {};
306
306
  let i;
307
- for (const d of n.marks)
308
- if (d.type.name === "link")
309
- i = d;
310
- else if (le.has(d.type.name))
311
- r[d.type.name] = !0;
312
- else if (ce.has(d.type.name))
313
- r[d.type.name] = d.attrs.color;
307
+ for (const a of n.marks)
308
+ if (a.type.name === "link")
309
+ i = a;
310
+ else if (le.has(a.type.name))
311
+ r[a.type.name] = !0;
312
+ else if (ce.has(a.type.name))
313
+ r[a.type.name] = a.attrs.color;
314
314
  else
315
- throw Error("Mark is of an unrecognized type: " + d.type.name);
315
+ throw Error("Mark is of an unrecognized type: " + a.type.name);
316
316
  i && t && i.attrs.href === t.href ? t.content.push({
317
317
  type: "text",
318
318
  text: n.textContent,
@@ -334,7 +334,7 @@ function et(o) {
334
334
  }), t = void 0);
335
335
  }), e;
336
336
  }
337
- function M(o, e) {
337
+ function w(o, e) {
338
338
  if (o.type.name !== "blockContainer")
339
339
  throw Error(
340
340
  "Node must be of type blockContainer, but is of type" + o.type.name + "."
@@ -344,7 +344,7 @@ function M(o, e) {
344
344
  return t;
345
345
  const n = k(o, 0);
346
346
  let r = n.id;
347
- r === null && (r = W.options.generateID());
347
+ r === null && (r = j.options.generateID());
348
348
  const i = {};
349
349
  for (const [l, c] of Object.entries({
350
350
  ...n.node.attrs,
@@ -356,17 +356,17 @@ function M(o, e) {
356
356
  );
357
357
  ee[n.contentType.name].has(l) && (i[l] = c);
358
358
  }
359
- const d = et(n.contentNode), s = [];
359
+ const a = et(n.contentNode), s = [];
360
360
  for (let l = 0; l < n.numChildBlocks; l++)
361
- s.push(M(n.node.lastChild.child(l)));
362
- const a = {
361
+ s.push(w(n.node.lastChild.child(l)));
362
+ const d = {
363
363
  id: r,
364
364
  type: n.contentType.name,
365
365
  props: i,
366
- content: d,
366
+ content: a,
367
367
  children: s
368
368
  };
369
- return e == null || e.set(o, a), a;
369
+ return e == null || e.set(o, d), d;
370
370
  }
371
371
  function V(o, e) {
372
372
  let t, n;
@@ -380,24 +380,24 @@ function V(o, e) {
380
380
  function pe(o, e, t = "before", n) {
381
381
  const r = typeof e == "string" ? e : e.id, i = [];
382
382
  for (const l of o)
383
- i.push(F(l, n.schema));
384
- let d = -1;
385
- const { node: s, posBeforeNode: a } = V(r, n.state.doc);
386
- if (t === "before" && (d = a), t === "after" && (d = a + s.nodeSize), t === "nested") {
383
+ i.push(R(l, n.schema));
384
+ let a = -1;
385
+ const { node: s, posBeforeNode: d } = V(r, n.state.doc);
386
+ if (t === "before" && (a = d), t === "after" && (a = d + s.nodeSize), t === "nested") {
387
387
  if (s.childCount < 2) {
388
- d = a + s.firstChild.nodeSize + 1;
388
+ a = d + s.firstChild.nodeSize + 1;
389
389
  const l = n.state.schema.nodes.blockGroup.create(
390
390
  {},
391
391
  i
392
392
  );
393
393
  n.view.dispatch(
394
- n.state.tr.insert(d, l)
394
+ n.state.tr.insert(a, l)
395
395
  );
396
396
  return;
397
397
  }
398
- d = a + s.firstChild.nodeSize + 2;
398
+ a = d + s.firstChild.nodeSize + 2;
399
399
  }
400
- n.view.dispatch(n.state.tr.insert(d, i));
400
+ n.view.dispatch(n.state.tr.insert(a, i));
401
401
  }
402
402
  function tt(o, e, t) {
403
403
  const n = typeof o == "string" ? o : o.id, { posBeforeNode: r } = V(n, t.state.doc);
@@ -416,10 +416,10 @@ function fe(o, e) {
416
416
  if (r.type.name !== "blockContainer" || !t.has(r.attrs.id))
417
417
  return !0;
418
418
  t.delete(r.attrs.id);
419
- const d = e.state.doc.nodeSize;
419
+ const a = e.state.doc.nodeSize;
420
420
  e.commands.BNDeleteBlock(i - n + 1);
421
421
  const s = e.state.doc.nodeSize;
422
- return n += d - s, !1;
422
+ return n += a - s, !1;
423
423
  }), t.size > 0) {
424
424
  let r = [...t].join(`
425
425
  `);
@@ -453,20 +453,20 @@ function rt(o) {
453
453
  ...o.unorderedListItemBlockTypes
454
454
  ]), t = (n) => {
455
455
  let r = n.children.length, i;
456
- for (let d = 0; d < r; d++) {
457
- const a = n.children[d].children[0], l = a.children[0], c = a.children.length === 2 ? a.children[1] : null, u = e.has(
456
+ for (let a = 0; a < r; a++) {
457
+ const d = n.children[a].children[0], l = d.children[0], c = d.children.length === 2 ? d.children[1] : null, u = e.has(
458
458
  l.properties.dataContentType
459
459
  ), f = u ? o.orderedListItemBlockTypes.has(
460
460
  l.properties.dataContentType
461
461
  ) ? "ol" : "ul" : null;
462
462
  if (c !== null && t(c), i && i.tagName !== f) {
463
463
  n.children.splice(
464
- d - i.children.length,
464
+ a - i.children.length,
465
465
  i.children.length,
466
466
  i
467
467
  );
468
468
  const p = i.children.length - 1;
469
- d -= p, r -= p, i = void 0;
469
+ a -= p, r -= p, i = void 0;
470
470
  }
471
471
  if (u) {
472
472
  i || (i = Z(
@@ -477,11 +477,11 @@ function rt(o) {
477
477
  );
478
478
  p.children.push(l.children[0]), c !== null && p.children.push(...c.children), i.children.push(p);
479
479
  } else if (c !== null) {
480
- n.children.splice(d + 1, 0, ...c.children), n.children[d] = l.children[0];
480
+ n.children.splice(a + 1, 0, ...c.children), n.children[a] = l.children[0];
481
481
  const p = c.children.length;
482
- d += p, r += p;
482
+ a += p, r += p;
483
483
  } else
484
- n.children[d] = l.children[0];
484
+ n.children[a] = l.children[0];
485
485
  }
486
486
  i && n.children.splice(
487
487
  r - i.children.length,
@@ -494,10 +494,10 @@ function rt(o) {
494
494
  async function me(o, e) {
495
495
  const t = document.createElement("div"), n = Ae.fromSchema(e);
496
496
  for (const i of o) {
497
- const d = F(i, e), s = n.serializeNode(d);
497
+ const a = R(i, e), s = n.serializeNode(a);
498
498
  t.appendChild(s);
499
499
  }
500
- return (await Y().use(ie, { fragment: !0 }).use(rt, {
500
+ return (await W().use(ie, { fragment: !0 }).use(rt, {
501
501
  orderedListItemBlockTypes: /* @__PURE__ */ new Set(["numberedListItem"]),
502
502
  unorderedListItemBlockTypes: /* @__PURE__ */ new Set(["bulletListItem"])
503
503
  }).use(se).process(t.innerHTML)).value;
@@ -506,15 +506,15 @@ async function ke(o, e) {
506
506
  const t = document.createElement("div");
507
507
  t.innerHTML = o.trim();
508
508
  const r = Pe.fromSchema(e).parse(t), i = [];
509
- for (let d = 0; d < r.firstChild.childCount; d++)
510
- i.push(M(r.firstChild.child(d)));
509
+ for (let a = 0; a < r.firstChild.childCount; a++)
510
+ i.push(w(r.firstChild.child(a)));
511
511
  return i;
512
512
  }
513
513
  async function it(o, e) {
514
- return (await Y().use(ie, { fragment: !0 }).use(nt).use(He).use(ae).use(De).process(await me(o, e))).value;
514
+ return (await W().use(ie, { fragment: !0 }).use(nt).use(He).use(ae).use(De).process(await me(o, e))).value;
515
515
  }
516
516
  async function st(o, e) {
517
- const t = await Y().use(Oe).use(ae).use(_e).use(se).process(o);
517
+ const t = await W().use(Oe).use(ae).use(_e).use(se).process(o);
518
518
  return ke(t.value, e);
519
519
  }
520
520
  const at = C.create({
@@ -618,10 +618,10 @@ const at = C.create({
618
618
  apply(e, t, n, r) {
619
619
  if (t.currentTransactionOldBlockAttrs = {}, t.updatedBlocks.clear(), !e.docChanged || n.doc.eq(r.doc))
620
620
  return t;
621
- const i = {}, d = q(n.doc, (l) => l.attrs.id), s = new Map(
622
- d.map((l) => [l.node.attrs.id, l])
623
- ), a = q(r.doc, (l) => l.attrs.id);
624
- for (let l of a) {
621
+ const i = {}, a = $(n.doc, (l) => l.attrs.id), s = new Map(
622
+ a.map((l) => [l.node.attrs.id, l])
623
+ ), d = $(r.doc, (l) => l.attrs.id);
624
+ for (let l of d) {
625
625
  const c = s.get(l.node.attrs.id), u = c == null ? void 0 : c.node.firstChild, f = l.node.firstChild;
626
626
  if (c && u && f) {
627
627
  const p = {
@@ -651,22 +651,22 @@ const at = C.create({
651
651
  return e.doc.descendants((r, i) => {
652
652
  if (!r.attrs.id || !t.updatedBlocks.has(r.attrs.id))
653
653
  return;
654
- const d = t.currentTransactionOldBlockAttrs[r.attrs.id], s = {};
655
- for (let [l, c] of Object.entries(d))
654
+ const a = t.currentTransactionOldBlockAttrs[r.attrs.id], s = {};
655
+ for (let [l, c] of Object.entries(a))
656
656
  s["data-prev-" + lt[l]] = c || "none";
657
- const a = _.node(i, i + r.nodeSize, {
657
+ const d = D.node(i, i + r.nodeSize, {
658
658
  ...s
659
659
  });
660
- n.push(a);
661
- }), D.create(e.doc, n);
660
+ n.push(d);
661
+ }), F.create(e.doc, n);
662
662
  }
663
663
  }
664
664
  });
665
- }, ut = "_blockOuter_qwsjj_5", ht = "_block_qwsjj_5", pt = "_blockContent_qwsjj_19", ft = "_blockGroup_qwsjj_48", mt = "_isEmpty_qwsjj_237", kt = "_isFilter_qwsjj_238", gt = "_hasAnchor_qwsjj_251", b = {
665
+ }, ut = "_blockOuter_1xym9_5", ht = "_blockContent_1xym9_10", pt = "_blockGroup_1xym9_26", ft = "_block_1xym9_5", mt = "_isEmpty_1xym9_215", kt = "_isFilter_1xym9_216", gt = "_hasAnchor_1xym9_229", b = {
666
666
  blockOuter: ut,
667
- block: ht,
668
- blockContent: pt,
669
- blockGroup: ft,
667
+ blockContent: ht,
668
+ blockGroup: pt,
669
+ block: ft,
670
670
  isEmpty: mt,
671
671
  isFilter: kt,
672
672
  hasAnchor: gt
@@ -742,18 +742,18 @@ const at = C.create({
742
742
  const r = k(t.doc, o);
743
743
  if (r === void 0)
744
744
  return !1;
745
- const { startPos: i, endPos: d, node: s, contentNode: a } = r;
745
+ const { startPos: i, endPos: a, node: s, contentNode: d } = r;
746
746
  if (n) {
747
747
  if (e.children !== void 0) {
748
748
  const l = [];
749
749
  for (const c of e.children)
750
- l.push(F(c, t.schema));
750
+ l.push(R(c, t.schema));
751
751
  s.childCount === 2 ? t.tr.replace(
752
- i + a.nodeSize + 1,
753
- d - 1,
752
+ i + d.nodeSize + 1,
753
+ a - 1,
754
754
  new A(P.from(l), 0, 0)
755
755
  ) : t.tr.insert(
756
- i + a.nodeSize,
756
+ i + d.nodeSize,
757
757
  t.schema.nodes.blockGroup.create({}, l)
758
758
  );
759
759
  }
@@ -761,7 +761,7 @@ const at = C.create({
761
761
  let l = [];
762
762
  typeof e.content == "string" ? l.push(t.schema.text(e.content)) : l = he(e.content, t.schema), t.tr.replace(
763
763
  i + 1,
764
- i + a.nodeSize - 1,
764
+ i + d.nodeSize - 1,
765
765
  new A(P.from(l), 0, 0)
766
766
  );
767
767
  }
@@ -769,7 +769,7 @@ const at = C.create({
769
769
  i,
770
770
  e.type === void 0 ? void 0 : t.schema.nodes[e.type],
771
771
  {
772
- ...a.attrs,
772
+ ...d.attrs,
773
773
  ...e.props
774
774
  }
775
775
  ), t.tr.setNodeMarkup(i - 1, void 0, {
@@ -803,10 +803,10 @@ const at = C.create({
803
803
  const i = k(
804
804
  e.doc,
805
805
  o + 1
806
- ), { node: d, contentNode: s, startPos: a, endPos: l, depth: c } = i;
807
- if (d.childCount === 2) {
806
+ ), { node: a, contentNode: s, startPos: d, endPos: l, depth: c } = i;
807
+ if (a.childCount === 2) {
808
808
  const p = e.doc.resolve(
809
- a + s.nodeSize + 1
809
+ d + s.nodeSize + 1
810
810
  ), m = e.doc.resolve(l - 1), y = p.blockRange(m);
811
811
  t && e.tr.lift(y, c - 1);
812
812
  }
@@ -814,7 +814,7 @@ const at = C.create({
814
814
  for (; f.numChildBlocks > 0; )
815
815
  if (u--, f = k(e.doc, u), f === void 0)
816
816
  return !1;
817
- return t && (e.tr.deleteRange(a, a + s.nodeSize), e.tr.insertText(s.textContent, u - 1), e.tr.setSelection(
817
+ return t && (e.tr.deleteRange(d, d + s.nodeSize), e.tr.insertText(s.textContent, u - 1), e.tr.setSelection(
818
818
  new Q(e.doc.resolve(u - 1))
819
819
  )), !0;
820
820
  },
@@ -824,7 +824,7 @@ const at = C.create({
824
824
  const r = k(t.doc, o);
825
825
  if (r === void 0)
826
826
  return !1;
827
- const { contentNode: i, contentType: d, startPos: s, endPos: a, depth: l } = r, c = t.doc.cut(s + 1, o), u = t.doc.cut(o, a - 1), f = t.schema.nodes.blockContainer.createAndFill(), p = a + 1, m = p + 2;
827
+ const { contentNode: i, contentType: a, startPos: s, endPos: d, depth: l } = r, c = t.doc.cut(s + 1, o), u = t.doc.cut(o, d - 1), f = t.schema.nodes.blockContainer.createAndFill(), p = d + 1, m = p + 2;
828
828
  return n && (t.tr.insert(p, f), t.tr.replace(
829
829
  m,
830
830
  m + 1,
@@ -836,13 +836,13 @@ const at = C.create({
836
836
  ), e && t.tr.setBlockType(
837
837
  m,
838
838
  m,
839
- t.schema.node(d).type,
839
+ t.schema.node(a).type,
840
840
  i.attrs
841
841
  ), t.tr.setSelection(
842
842
  new Q(t.doc.resolve(m))
843
843
  ), t.tr.replace(
844
844
  s + 1,
845
- a - 1,
845
+ d - 1,
846
846
  c.content.size > 0 ? new A(
847
847
  P.from(c),
848
848
  l + 2,
@@ -867,8 +867,8 @@ const at = C.create({
867
867
  const { contentType: r } = k(
868
868
  n.doc,
869
869
  n.selection.from
870
- ), i = n.selection.$anchor.parentOffset === 0, d = r.name === "paragraph";
871
- return i && !d ? t.BNUpdateBlock(n.selection.from, {
870
+ ), i = n.selection.$anchor.parentOffset === 0, a = r.name === "paragraph";
871
+ return i && !a ? t.BNUpdateBlock(n.selection.from, {
872
872
  type: "paragraph",
873
873
  props: {}
874
874
  }) : !1;
@@ -881,8 +881,8 @@ const at = C.create({
881
881
  const { depth: r, startPos: i } = k(
882
882
  n.doc,
883
883
  n.selection.from
884
- ), d = n.selection.$anchor.parentOffset === 0, s = n.selection.anchor === n.selection.head, a = i === 2, l = i - 1;
885
- return !a && d && s && r === 2 ? t.BNMergeBlocks(l) : !1;
884
+ ), a = n.selection.$anchor.parentOffset === 0, s = n.selection.anchor === n.selection.head, d = i === 2, l = i - 1;
885
+ return !d && a && s && r === 2 ? t.BNMergeBlocks(l) : !1;
886
886
  })
887
887
  ]),
888
888
  Enter: () => this.editor.commands.first(({ commands: t }) => [
@@ -892,18 +892,18 @@ const at = C.create({
892
892
  const { node: r, depth: i } = k(
893
893
  n.doc,
894
894
  n.selection.from
895
- ), d = n.selection.$anchor.parentOffset === 0, s = n.selection.anchor === n.selection.head, a = r.textContent.length === 0, l = i > 2;
896
- return d && s && a && l ? t.liftListItem("blockContainer") : !1;
895
+ ), a = n.selection.$anchor.parentOffset === 0, s = n.selection.anchor === n.selection.head, d = r.textContent.length === 0, l = i > 2;
896
+ return a && s && d && l ? t.liftListItem("blockContainer") : !1;
897
897
  }),
898
898
  // Creates a new block and moves the selection to it if the current one is empty, while the selection is also
899
899
  // empty & at the start of the block.
900
900
  () => t.command(({ state: n, chain: r }) => {
901
- const { node: i, endPos: d } = k(
901
+ const { node: i, endPos: a } = k(
902
902
  n.doc,
903
903
  n.selection.from
904
- ), s = n.selection.$anchor.parentOffset === 0, a = n.selection.anchor === n.selection.head, l = i.textContent.length === 0;
905
- if (s && a && l) {
906
- const c = d + 1, u = c + 2;
904
+ ), s = n.selection.$anchor.parentOffset === 0, d = n.selection.anchor === n.selection.head, l = i.textContent.length === 0;
905
+ if (s && d && l) {
906
+ const c = a + 1, u = c + 2;
907
907
  return r().BNCreateBlock(c).setTextSelection(u).run(), !0;
908
908
  }
909
909
  return !1;
@@ -1021,7 +1021,7 @@ const at = C.create({
1021
1021
  },
1022
1022
  addInputRules() {
1023
1023
  return [
1024
- ...["1", "2", "3"].map((o) => new j({
1024
+ ...["1", "2", "3"].map((o) => new Y({
1025
1025
  find: new RegExp(`^(#{${parseInt(o)}})\\s$`),
1026
1026
  handler: ({ state: e, chain: t, range: n }) => {
1027
1027
  t().BNUpdateBlock(e.selection.from, {
@@ -1068,10 +1068,10 @@ const at = C.create({
1068
1068
  o.state.doc,
1069
1069
  o.state.selection.from
1070
1070
  ), n = o.state.selection.anchor === o.state.selection.head;
1071
- return !t.name.endsWith("ListItem") || !n ? !1 : o.commands.first(({ state: r, chain: i, commands: d }) => [
1071
+ return !t.name.endsWith("ListItem") || !n ? !1 : o.commands.first(({ state: r, chain: i, commands: a }) => [
1072
1072
  () => (
1073
1073
  // Changes list item block to a text block if the content is empty.
1074
- d.command(() => e.textContent.length === 0 ? d.BNUpdateBlock(r.selection.from, {
1074
+ a.command(() => e.textContent.length === 0 ? a.BNUpdateBlock(r.selection.from, {
1075
1075
  type: "paragraph",
1076
1076
  props: {}
1077
1077
  }) : !1)
@@ -1079,7 +1079,7 @@ const at = C.create({
1079
1079
  () => (
1080
1080
  // Splits the current block, moving content inside that's after the cursor to a new block of the same type
1081
1081
  // below.
1082
- d.command(() => e.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
1082
+ a.command(() => e.textContent.length > 0 ? (i().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
1083
1083
  )
1084
1084
  ]);
1085
1085
  }, Tt = E.create({
@@ -1089,7 +1089,7 @@ const at = C.create({
1089
1089
  addInputRules() {
1090
1090
  return [
1091
1091
  // Creates an unordered list when starting with "-", "+", or "*".
1092
- new j({
1092
+ new Y({
1093
1093
  find: new RegExp("^[-+*]\\s$"),
1094
1094
  handler: ({ state: o, chain: e, range: t }) => {
1095
1095
  e().BNUpdateBlock(o.selection.from, {
@@ -1142,31 +1142,31 @@ const at = C.create({
1142
1142
  ["p", 0]
1143
1143
  ];
1144
1144
  }
1145
- }), wt = new v("numbered-list-indexing"), Mt = () => new B({
1146
- key: wt,
1145
+ }), Mt = new v("numbered-list-indexing"), wt = () => new B({
1146
+ key: Mt,
1147
1147
  appendTransaction: (o, e, t) => {
1148
1148
  const n = t.tr;
1149
1149
  n.setMeta("numberedListIndexing", !0);
1150
1150
  let r = !1;
1151
- return t.doc.descendants((i, d) => {
1151
+ return t.doc.descendants((i, a) => {
1152
1152
  if (i.type.name === "blockContainer" && i.firstChild.type.name === "numberedListItem") {
1153
1153
  let s = "1";
1154
- const a = d === 1, l = k(n.doc, d + 1);
1154
+ const d = a === 1, l = k(n.doc, a + 1);
1155
1155
  if (l === void 0)
1156
1156
  return;
1157
- if (!a) {
1158
- const f = k(n.doc, d - 2);
1157
+ if (!d) {
1158
+ const f = k(n.doc, a - 2);
1159
1159
  if (f === void 0)
1160
1160
  return;
1161
1161
  if (!(l.depth !== f.depth)) {
1162
1162
  const m = f.contentNode;
1163
1163
  if (f.contentType.name === "numberedListItem") {
1164
- const R = m.attrs.index;
1165
- s = (parseInt(R) + 1).toString();
1164
+ const z = m.attrs.index;
1165
+ s = (parseInt(z) + 1).toString();
1166
1166
  }
1167
1167
  }
1168
1168
  }
1169
- l.contentNode.attrs.index !== s && (r = !0, n.setNodeMarkup(d + 1, void 0, {
1169
+ l.contentNode.attrs.index !== s && (r = !0, n.setNodeMarkup(a + 1, void 0, {
1170
1170
  index: s
1171
1171
  }));
1172
1172
  }
@@ -1190,7 +1190,7 @@ const at = C.create({
1190
1190
  addInputRules() {
1191
1191
  return [
1192
1192
  // Creates an ordered list when starting with "1.".
1193
- new j({
1193
+ new Y({
1194
1194
  find: new RegExp("^1\\.\\s$"),
1195
1195
  handler: ({ state: o, chain: e, range: t }) => {
1196
1196
  e().BNUpdateBlock(o.selection.from, {
@@ -1207,7 +1207,7 @@ const at = C.create({
1207
1207
  };
1208
1208
  },
1209
1209
  addProseMirrorPlugins() {
1210
- return [Mt()];
1210
+ return [wt()];
1211
1211
  },
1212
1212
  parseHTML() {
1213
1213
  return [
@@ -1262,14 +1262,15 @@ const at = C.create({
1262
1262
  topNode: !0,
1263
1263
  content: "blockGroup"
1264
1264
  })
1265
- ], It = "_bnEditor_yxlqg_3", St = "_bnRoot_yxlqg_14", At = "_dragPreview_yxlqg_29", G = {
1265
+ ], It = "_bnEditor_8k3n0_3", St = "_bnRoot_8k3n0_19", At = "_defaultStyles_8k3n0_34", Pt = "_dragPreview_8k3n0_57", _ = {
1266
1266
  bnEditor: It,
1267
1267
  bnRoot: St,
1268
- dragPreview: At
1269
- }, Pt = xe(
1268
+ defaultStyles: At,
1269
+ dragPreview: Pt
1270
+ }, Nt = xe(
1270
1271
  (o) => o.type.name === "blockContainer"
1271
1272
  );
1272
- function $() {
1273
+ function q() {
1273
1274
  return {
1274
1275
  active: !1,
1275
1276
  triggerCharacter: void 0,
@@ -1280,7 +1281,7 @@ function $() {
1280
1281
  decorationId: void 0
1281
1282
  };
1282
1283
  }
1283
- class Nt {
1284
+ class Lt {
1284
1285
  constructor({
1285
1286
  editor: e,
1286
1287
  pluginKey: t,
@@ -1293,7 +1294,7 @@ class Nt {
1293
1294
  h(this, "suggestionsMenu");
1294
1295
  h(this, "pluginState");
1295
1296
  h(this, "itemCallback");
1296
- this.editor = e, this.pluginKey = t, this.pluginState = $(), this.itemCallback = (i) => {
1297
+ this.editor = e, this.pluginKey = t, this.pluginState = q(), this.itemCallback = (i) => {
1297
1298
  e._tiptapEditor.chain().focus().deleteRange({
1298
1299
  from: this.pluginState.queryStartPos - this.pluginState.triggerCharacter.length,
1299
1300
  to: e._tiptapEditor.state.selection.from
@@ -1304,13 +1305,13 @@ class Nt {
1304
1305
  }, this.suggestionsMenu = r(this.getStaticParams());
1305
1306
  }
1306
1307
  update(e, t) {
1307
- const n = this.pluginKey.getState(t), r = this.pluginKey.getState(e.state), i = !n.active && r.active, d = n.active && !r.active, s = n.active && r.active;
1308
- !i && !s && !d || (this.pluginState = d ? n : r, d && (this.suggestionsMenu.hide(), this.suggestionsMenu.element.removeEventListener(
1308
+ const n = this.pluginKey.getState(t), r = this.pluginKey.getState(e.state), i = !n.active && r.active, a = n.active && !r.active, s = n.active && r.active;
1309
+ !i && !s && !a || (this.pluginState = a ? n : r, a && (this.suggestionsMenu.hide(), this.suggestionsMenu.element.removeEventListener(
1309
1310
  "mousedown",
1310
- (a) => a.preventDefault()
1311
+ (d) => d.preventDefault()
1311
1312
  )), s && this.suggestionsMenu.render(this.getDynamicParams(), !1), i && (this.suggestionsMenu.render(this.getDynamicParams(), !0), this.suggestionsMenu.element.addEventListener(
1312
1313
  "mousedown",
1313
- (a) => a.preventDefault()
1314
+ (d) => d.preventDefault()
1314
1315
  )));
1315
1316
  }
1316
1317
  getStaticParams() {
@@ -1329,7 +1330,7 @@ class Nt {
1329
1330
  };
1330
1331
  }
1331
1332
  }
1332
- function Lt({
1333
+ function Ht({
1333
1334
  pluginKey: o,
1334
1335
  editor: e,
1335
1336
  defaultTriggerCharacter: t,
@@ -1340,29 +1341,29 @@ function Lt({
1340
1341
  }) {
1341
1342
  if (t.length !== 1)
1342
1343
  throw new Error("'char' should be a single character");
1343
- const d = (s) => {
1344
+ const a = (s) => {
1344
1345
  s.dispatch(s.state.tr.setMeta(o, { deactivate: !0 }));
1345
1346
  };
1346
1347
  return new B({
1347
1348
  key: o,
1348
- view: (s) => new Nt({
1349
+ view: (s) => new Lt({
1349
1350
  editor: e,
1350
1351
  pluginKey: o,
1351
- onSelectItem: (a) => {
1352
- d(s), r(a);
1352
+ onSelectItem: (d) => {
1353
+ a(s), r(d);
1353
1354
  },
1354
1355
  suggestionsMenuFactory: n
1355
1356
  }),
1356
1357
  state: {
1357
1358
  // Initialize the plugin's internal state.
1358
1359
  init() {
1359
- return $();
1360
+ return q();
1360
1361
  },
1361
1362
  // Apply changes to the plugin state from an editor transaction.
1362
- apply(s, a, l, c) {
1363
+ apply(s, d, l, c) {
1363
1364
  var f, p, m, y;
1364
1365
  if (s.getMeta("orderedListIndexing") !== void 0)
1365
- return a;
1366
+ return d;
1366
1367
  if ((f = s.getMeta(o)) != null && f.activate)
1367
1368
  return {
1368
1369
  active: !0,
@@ -1375,34 +1376,34 @@ function Lt({
1375
1376
  notFoundCount: 0,
1376
1377
  decorationId: `id_${Math.floor(Math.random() * 4294967295)}`
1377
1378
  };
1378
- if (!a.active)
1379
- return a;
1380
- const u = { ...a };
1379
+ if (!d.active)
1380
+ return d;
1381
+ const u = { ...d };
1381
1382
  if (u.items = i(
1382
- c.doc.textBetween(a.queryStartPos, c.selection.from)
1383
+ c.doc.textBetween(d.queryStartPos, c.selection.from)
1383
1384
  ), u.notFoundCount = 0, u.items.length === 0 && (u.notFoundCount = Math.max(
1384
1385
  0,
1385
- a.notFoundCount + (c.selection.from - l.selection.from)
1386
+ d.notFoundCount + (c.selection.from - l.selection.from)
1386
1387
  )), // Highlighting text should hide the menu.
1387
1388
  c.selection.from !== c.selection.to || // Transactions with plugin metadata {deactivate: true} should hide the menu.
1388
1389
  (m = s.getMeta(o)) != null && m.deactivate || // Certain mouse events should hide the menu.
1389
1390
  // TODO: Change to global mousedown listener.
1390
1391
  s.getMeta("focus") || s.getMeta("blur") || s.getMeta("pointer") || // Moving the caret before the character which triggered the menu should hide it.
1391
- a.active && c.selection.from < a.queryStartPos || // Entering more than 3 characters, after the last query that matched with at least 1 menu item, should hide
1392
+ d.active && c.selection.from < d.queryStartPos || // Entering more than 3 characters, after the last query that matched with at least 1 menu item, should hide
1392
1393
  // the menu.
1393
1394
  u.notFoundCount > 3)
1394
- return $();
1395
+ return q();
1395
1396
  if (((y = s.getMeta(o)) == null ? void 0 : y.selectedItemIndexChanged) !== void 0) {
1396
1397
  let g = s.getMeta(o).selectedItemIndexChanged;
1397
- g < 0 ? g = a.items.length - 1 : g >= a.items.length && (g = 0), u.keyboardHoveredItemIndex = g;
1398
+ g < 0 ? g = d.items.length - 1 : g >= d.items.length && (g = 0), u.keyboardHoveredItemIndex = g;
1398
1399
  }
1399
1400
  return u;
1400
1401
  }
1401
1402
  },
1402
1403
  props: {
1403
- handleKeyDown(s, a) {
1404
+ handleKeyDown(s, d) {
1404
1405
  const l = this.getState(s.state).active;
1405
- if (a.key === t && !l)
1406
+ if (d.key === t && !l)
1406
1407
  return s.dispatch(
1407
1408
  s.state.tr.insertText(t).scrollIntoView().setMeta(o, {
1408
1409
  activate: !0,
@@ -1417,36 +1418,36 @@ function Lt({
1417
1418
  items: f,
1418
1419
  keyboardHoveredItemIndex: p
1419
1420
  } = o.getState(s.state);
1420
- return a.key === "ArrowUp" ? (s.dispatch(
1421
+ return d.key === "ArrowUp" ? (s.dispatch(
1421
1422
  s.state.tr.setMeta(o, {
1422
1423
  selectedItemIndexChanged: p - 1
1423
1424
  })
1424
- ), !0) : a.key === "ArrowDown" ? (s.dispatch(
1425
+ ), !0) : d.key === "ArrowDown" ? (s.dispatch(
1425
1426
  s.state.tr.setMeta(o, {
1426
1427
  selectedItemIndexChanged: p + 1
1427
1428
  })
1428
- ), !0) : a.key === "Enter" ? (d(s), e._tiptapEditor.chain().focus().deleteRange({
1429
+ ), !0) : d.key === "Enter" ? (a(s), e._tiptapEditor.chain().focus().deleteRange({
1429
1430
  from: u - c.length,
1430
1431
  to: e._tiptapEditor.state.selection.from
1431
1432
  }).run(), r({
1432
1433
  item: f[p],
1433
1434
  editor: e
1434
- }), !0) : a.key === "Escape" ? (d(s), !0) : !1;
1435
+ }), !0) : d.key === "Escape" ? (a(s), !0) : !1;
1435
1436
  },
1436
1437
  // Hides menu in cases where mouse click does not cause an editor state change.
1437
1438
  handleClick(s) {
1438
- d(s);
1439
+ a(s);
1439
1440
  },
1440
1441
  // Setup decorator on the currently active suggestion.
1441
1442
  decorations(s) {
1442
- const { active: a, decorationId: l, queryStartPos: c, triggerCharacter: u } = this.getState(s);
1443
- if (!a)
1443
+ const { active: d, decorationId: l, queryStartPos: c, triggerCharacter: u } = this.getState(s);
1444
+ if (!d)
1444
1445
  return null;
1445
1446
  if (u === "") {
1446
- const f = Pt(s.selection);
1447
+ const f = Nt(s.selection);
1447
1448
  if (f)
1448
- return D.create(s.doc, [
1449
- _.node(
1449
+ return F.create(s.doc, [
1450
+ D.node(
1450
1451
  f.pos,
1451
1452
  f.pos + f.node.nodeSize,
1452
1453
  {
@@ -1457,8 +1458,8 @@ function Lt({
1457
1458
  )
1458
1459
  ]);
1459
1460
  }
1460
- return D.create(s.doc, [
1461
- _.inline(
1461
+ return F.create(s.doc, [
1462
+ D.inline(
1462
1463
  c - u.length,
1463
1464
  c,
1464
1465
  {
@@ -1472,7 +1473,7 @@ function Lt({
1472
1473
  }
1473
1474
  });
1474
1475
  }
1475
- const K = new v("suggestions-slash-commands"), Ht = C.create({
1476
+ const K = new v("suggestions-slash-commands"), Ot = C.create({
1476
1477
  name: "slash-command",
1477
1478
  addOptions() {
1478
1479
  return {
@@ -1486,7 +1487,7 @@ const K = new v("suggestions-slash-commands"), Ht = C.create({
1486
1487
  throw new Error("required args not defined for SlashMenuExtension");
1487
1488
  const o = this.options.commands;
1488
1489
  return [
1489
- Lt({
1490
+ Ht({
1490
1491
  pluginKey: K,
1491
1492
  editor: this.options.editor,
1492
1493
  defaultTriggerCharacter: "/",
@@ -1499,12 +1500,12 @@ const K = new v("suggestions-slash-commands"), Ht = C.create({
1499
1500
  ];
1500
1501
  }
1501
1502
  });
1502
- class L extends U {
1503
+ class L extends G {
1503
1504
  constructor(t, n) {
1504
1505
  super(t, n);
1505
1506
  h(this, "nodes");
1506
1507
  const r = t.node();
1507
- this.nodes = [], t.doc.nodesBetween(t.pos, n.pos, (i, d, s) => {
1508
+ this.nodes = [], t.doc.nodesBetween(t.pos, n.pos, (i, a, s) => {
1508
1509
  if (s !== null && s.eq(r))
1509
1510
  return this.nodes.push(i), !1;
1510
1511
  });
@@ -1525,7 +1526,7 @@ class L extends U {
1525
1526
  }
1526
1527
  map(t, n) {
1527
1528
  let r = n.mapResult(this.from), i = n.mapResult(this.to);
1528
- return i.deleted ? U.near(t.resolve(r.pos)) : r.deleted ? U.near(t.resolve(i.pos)) : new L(
1529
+ return i.deleted ? G.near(t.resolve(r.pos)) : r.deleted ? G.near(t.resolve(i.pos)) : new L(
1529
1530
  t.resolve(r.pos),
1530
1531
  t.resolve(i.pos)
1531
1532
  );
@@ -1534,10 +1535,12 @@ class L extends U {
1534
1535
  return { type: "node", anchor: this.anchor, head: this.head };
1535
1536
  }
1536
1537
  }
1537
- const Ot = Ve.__serializeForClipboard;
1538
- let w;
1538
+ const _t = Ve.__serializeForClipboard;
1539
+ let M;
1539
1540
  function ye(o, e) {
1540
1541
  var r;
1542
+ if (!e.dom.isConnected)
1543
+ return;
1541
1544
  let t = e.posAtCoords(o);
1542
1545
  if (!t)
1543
1546
  return;
@@ -1549,7 +1552,7 @@ function ye(o, e) {
1549
1552
  return { node: n, id: n.getAttribute("data-id") };
1550
1553
  }
1551
1554
  }
1552
- function _t(o, e) {
1555
+ function Dt(o, e) {
1553
1556
  let t = ye(o, e);
1554
1557
  if (t && t.node.nodeType === 1) {
1555
1558
  const n = e.docView;
@@ -1558,19 +1561,19 @@ function _t(o, e) {
1558
1561
  }
1559
1562
  return null;
1560
1563
  }
1561
- function Dt(o, e) {
1564
+ function Ft(o, e) {
1562
1565
  let t, n;
1563
- const r = e.resolve(o.from).node().type.spec.group === "blockContent", i = e.resolve(o.to).node().type.spec.group === "blockContent", d = Math.min(o.$anchor.depth, o.$head.depth);
1566
+ const r = e.resolve(o.from).node().type.spec.group === "blockContent", i = e.resolve(o.to).node().type.spec.group === "blockContent", a = Math.min(o.$anchor.depth, o.$head.depth);
1564
1567
  if (r && i) {
1565
- const s = o.$from.start(d - 1), a = o.$to.end(d - 1);
1566
- t = e.resolve(s - 1).pos, n = e.resolve(a + 1).pos;
1568
+ const s = o.$from.start(a - 1), d = o.$to.end(a - 1);
1569
+ t = e.resolve(s - 1).pos, n = e.resolve(d + 1).pos;
1567
1570
  } else
1568
1571
  t = o.from, n = o.to;
1569
1572
  return { from: t, to: n };
1570
1573
  }
1571
1574
  function oe(o, e, t = e) {
1572
1575
  e === t && (t += o.state.doc.resolve(e + 1).node().nodeSize);
1573
- const n = o.domAtPos(e).node.cloneNode(!0), r = o.domAtPos(e).node, i = (a, l) => Array.prototype.indexOf.call(a.children, l), d = i(
1576
+ const n = o.domAtPos(e).node.cloneNode(!0), r = o.domAtPos(e).node, i = (c, u) => Array.prototype.indexOf.call(c.children, u), a = i(
1574
1577
  r,
1575
1578
  // Expects from position to be just before the first selected block.
1576
1579
  o.domAtPos(e + 1).node.parentElement
@@ -1579,14 +1582,18 @@ function oe(o, e, t = e) {
1579
1582
  // Expects to position to be just after the last selected block.
1580
1583
  o.domAtPos(t - 1).node.parentElement
1581
1584
  );
1582
- for (let a = r.childElementCount - 1; a >= 0; a--)
1583
- (a > s || a < d) && n.removeChild(n.children[a]);
1584
- be(), w = n, w.className = w.className + " " + G.dragPreview, document.body.appendChild(w);
1585
+ for (let c = r.childElementCount - 1; c >= 0; c--)
1586
+ (c > s || c < a) && n.removeChild(n.children[c]);
1587
+ be(), M = n;
1588
+ const l = o.dom.className.split(" ").filter(
1589
+ (c) => !c.includes("bn") && !c.includes("ProseMirror") && !c.includes("editor")
1590
+ ).join(" ");
1591
+ M.className = M.className + " " + _.dragPreview + " " + l, document.body.appendChild(M);
1585
1592
  }
1586
1593
  function be() {
1587
- w !== void 0 && (document.body.removeChild(w), w = void 0);
1594
+ M !== void 0 && (document.body.removeChild(M), M = void 0);
1588
1595
  }
1589
- function Ft(o, e) {
1596
+ function Rt(o, e) {
1590
1597
  if (!o.dataTransfer)
1591
1598
  return;
1592
1599
  const t = e.dom.getBoundingClientRect();
@@ -1594,19 +1601,19 @@ function Ft(o, e) {
1594
1601
  left: t.left + t.width / 2,
1595
1602
  // take middle of editor
1596
1603
  top: o.clientY
1597
- }, r = _t(n, e);
1604
+ }, r = Dt(n, e);
1598
1605
  if (r != null) {
1599
- const i = e.state.selection, d = e.state.doc, { from: s, to: a } = Dt(i, d), l = s <= r && r < a, c = !i.$anchor.node().eq(i.$head.node());
1606
+ const i = e.state.selection, a = e.state.doc, { from: s, to: d } = Ft(i, a), l = s <= r && r < d, c = !i.$anchor.node().eq(i.$head.node());
1600
1607
  l && c ? (e.dispatch(
1601
- e.state.tr.setSelection(L.create(d, s, a))
1602
- ), oe(e, s, a)) : (e.dispatch(
1608
+ e.state.tr.setSelection(L.create(a, s, d))
1609
+ ), oe(e, s, d)) : (e.dispatch(
1603
1610
  e.state.tr.setSelection(Ne.create(e.state.doc, r))
1604
1611
  ), oe(e, r));
1605
- let u = e.state.selection.content(), { dom: f, text: p } = Ot(e, u);
1606
- o.dataTransfer.clearData(), o.dataTransfer.setData("text/html", f.innerHTML), o.dataTransfer.setData("text/plain", p), o.dataTransfer.effectAllowed = "move", o.dataTransfer.setDragImage(w, 0, 0), e.dragging = { slice: u, move: !0 };
1612
+ let u = e.state.selection.content(), { dom: f, text: p } = _t(e, u);
1613
+ o.dataTransfer.clearData(), o.dataTransfer.setData("text/html", f.innerHTML), o.dataTransfer.setData("text/plain", p), o.dataTransfer.effectAllowed = "move", o.dataTransfer.setDragImage(M, 0, 0), e.dragging = { slice: u, move: !0 };
1607
1614
  }
1608
1615
  }
1609
- class Rt {
1616
+ class zt {
1610
1617
  constructor({
1611
1618
  editor: e,
1612
1619
  blockMenuFactory: t,
@@ -1663,7 +1670,7 @@ class Rt {
1663
1670
  (t = this.blockMenu.element) != null && t.contains(e.target) || (this.menuOpen && (this.menuOpen = !1, this.blockMenu.hide()), this.menuFrozen = !1);
1664
1671
  });
1665
1672
  h(this, "onMouseMove", (e) => {
1666
- var d, s;
1673
+ var a, s;
1667
1674
  if (this.menuFrozen)
1668
1675
  return;
1669
1676
  const t = this.editor.view.dom.firstChild.getBoundingClientRect();
@@ -1677,7 +1684,7 @@ class Rt {
1677
1684
  this.menuOpen && (this.menuOpen = !1, this.blockMenu.hide());
1678
1685
  return;
1679
1686
  }
1680
- if (this.menuOpen && ((d = this.hoveredBlockContent) != null && d.hasAttribute("data-id")) && ((s = this.hoveredBlockContent) == null ? void 0 : s.getAttribute("data-id")) === r.id)
1687
+ if (this.menuOpen && ((a = this.hoveredBlockContent) != null && a.hasAttribute("data-id")) && ((s = this.hoveredBlockContent) == null ? void 0 : s.getAttribute("data-id")) === r.id)
1681
1688
  return;
1682
1689
  const i = r.node.firstChild;
1683
1690
  this.hoveredBlockContent = i, i && (this.menuOpen ? this.blockMenu.render(this.getDynamicParams(), !1) : (this.menuOpen = !0, this.blockMenu.render(this.getDynamicParams(), !0)));
@@ -1700,8 +1707,8 @@ class Rt {
1700
1707
  return;
1701
1708
  const { contentNode: r, endPos: i } = n;
1702
1709
  if (r.textContent.length !== 0) {
1703
- const d = i + 1, s = d + 2;
1704
- this.editor.chain().BNCreateBlock(d).BNUpdateBlock(s, { type: "paragraph", props: {} }).setTextSelection(s).run();
1710
+ const a = i + 1, s = a + 2;
1711
+ this.editor.chain().BNCreateBlock(a).BNUpdateBlock(s, { type: "paragraph", props: {} }).setTextSelection(s).run();
1705
1712
  } else
1706
1713
  this.editor.commands.setTextSelection(i);
1707
1714
  this.editor.view.focus(), this.editor.view.dispatch(
@@ -1740,7 +1747,7 @@ class Rt {
1740
1747
  return {
1741
1748
  addBlock: () => this.addBlock(),
1742
1749
  deleteBlock: () => this.deleteBlock(),
1743
- blockDragStart: (e) => Ft(e, this.editor.view),
1750
+ blockDragStart: (e) => Rt(e, this.editor.view),
1744
1751
  blockDragEnd: () => be(),
1745
1752
  freezeMenu: () => {
1746
1753
  this.menuFrozen = !0;
@@ -1766,14 +1773,14 @@ class Rt {
1766
1773
  };
1767
1774
  }
1768
1775
  }
1769
- const zt = (o) => new B({
1776
+ const Ut = (o) => new B({
1770
1777
  key: new v("DraggableBlocksPlugin"),
1771
- view: () => new Rt({
1778
+ view: () => new zt({
1772
1779
  editor: o.editor,
1773
1780
  blockMenuFactory: o.blockSideMenuFactory,
1774
1781
  horizontalPosAnchoredAtRoot: !0
1775
1782
  })
1776
- }), Ut = C.create({
1783
+ }), Gt = C.create({
1777
1784
  name: "DraggableBlocksExtension",
1778
1785
  priority: 1e3,
1779
1786
  // Need to be high, in order to hide menu when typing slash
@@ -1783,14 +1790,14 @@ const zt = (o) => new B({
1783
1790
  "UI Element factory not defined for DraggableBlocksExtension"
1784
1791
  );
1785
1792
  return [
1786
- zt({
1793
+ Ut({
1787
1794
  editor: this.editor,
1788
1795
  blockSideMenuFactory: this.options.blockSideMenuFactory
1789
1796
  })
1790
1797
  ];
1791
1798
  }
1792
1799
  });
1793
- class qt {
1800
+ class $t {
1794
1801
  constructor({
1795
1802
  editor: e,
1796
1803
  formattingToolbarFactory: t,
@@ -1804,8 +1811,8 @@ class qt {
1804
1811
  h(this, "preventShow", !1);
1805
1812
  h(this, "toolbarIsOpen", !1);
1806
1813
  h(this, "shouldShow", ({ view: e, state: t, from: n, to: r }) => {
1807
- const { doc: i, selection: d } = t, { empty: s } = d, a = !i.textBetween(n, r).length && Ee(t.selection);
1808
- return !(!e.hasFocus() || s || a);
1814
+ const { doc: i, selection: a } = t, { empty: s } = a, d = !i.textBetween(n, r).length && Ee(t.selection);
1815
+ return !(!e.hasFocus() || s || d);
1809
1816
  });
1810
1817
  h(this, "viewMousedownHandler", () => {
1811
1818
  this.preventShow = !0;
@@ -1833,10 +1840,10 @@ class qt {
1833
1840
  }
1834
1841
  update(e, t) {
1835
1842
  var f;
1836
- const { state: n, composing: r } = e, { doc: i, selection: d } = n, s = t && t.doc.eq(i) && t.selection.eq(d);
1843
+ const { state: n, composing: r } = e, { doc: i, selection: a } = n, s = t && t.doc.eq(i) && t.selection.eq(a);
1837
1844
  if (r || s)
1838
1845
  return;
1839
- const { ranges: a } = d, l = Math.min(...a.map((p) => p.$from.pos)), c = Math.max(...a.map((p) => p.$to.pos)), u = (f = this.shouldShow) == null ? void 0 : f.call(this, {
1846
+ const { ranges: d } = a, l = Math.min(...d.map((p) => p.$from.pos)), c = Math.max(...d.map((p) => p.$to.pos)), u = (f = this.shouldShow) == null ? void 0 : f.call(this, {
1840
1847
  editor: this.editor,
1841
1848
  view: e,
1842
1849
  state: n,
@@ -1867,11 +1874,11 @@ class qt {
1867
1874
  this.view.dom.removeEventListener("mousedown", this.viewMousedownHandler), this.view.dom.removeEventListener("mouseup", this.viewMouseupHandler), this.view.dom.removeEventListener("dragstart", this.dragstartHandler), this.editor.off("focus", this.focusHandler), this.editor.off("blur", this.blurHandler);
1868
1875
  }
1869
1876
  getSelectionBoundingBox() {
1870
- const { state: e } = this.editor.view, { selection: t } = e, { ranges: n } = t, r = Math.min(...n.map((d) => d.$from.pos)), i = Math.max(...n.map((d) => d.$to.pos));
1877
+ const { state: e } = this.editor.view, { selection: t } = e, { ranges: n } = t, r = Math.min(...n.map((a) => a.$from.pos)), i = Math.max(...n.map((a) => a.$to.pos));
1871
1878
  if (Ie(t)) {
1872
- const d = this.editor.view.nodeDOM(r);
1873
- if (d)
1874
- return d.getBoundingClientRect();
1879
+ const a = this.editor.view.nodeDOM(r);
1880
+ if (a)
1881
+ return a.getBoundingClientRect();
1875
1882
  }
1876
1883
  return re(this.editor.view, r, i);
1877
1884
  }
@@ -1953,10 +1960,10 @@ class qt {
1953
1960
  };
1954
1961
  }
1955
1962
  }
1956
- const Gt = (o) => new B({
1963
+ const qt = (o) => new B({
1957
1964
  key: new v("FormattingToolbarPlugin"),
1958
- view: (e) => new qt({ view: e, ...o })
1959
- }), $t = C.create({
1965
+ view: (e) => new $t({ view: e, ...o })
1966
+ }), Yt = C.create({
1960
1967
  name: "FormattingToolbarExtension",
1961
1968
  addProseMirrorPlugins() {
1962
1969
  if (!this.options.formattingToolbarFactory)
@@ -1964,15 +1971,15 @@ const Gt = (o) => new B({
1964
1971
  "UI Element factory not defined for FormattingToolbarExtension"
1965
1972
  );
1966
1973
  return [
1967
- Gt({
1974
+ qt({
1968
1975
  editor: this.editor,
1969
1976
  formattingToolbarFactory: this.options.formattingToolbarFactory,
1970
1977
  pluginKey: new v("FormattingToolbarPlugin")
1971
1978
  })
1972
1979
  ];
1973
1980
  }
1974
- }), jt = new v("HyperlinkToolbarPlugin");
1975
- class Yt {
1981
+ }), Wt = new v("HyperlinkToolbarPlugin");
1982
+ class jt {
1976
1983
  constructor({ editor: e, hyperlinkToolbarFactory: t }) {
1977
1984
  h(this, "editor");
1978
1985
  h(this, "hyperlinkToolbar");
@@ -1991,15 +1998,15 @@ class Yt {
1991
1998
  }, 250);
1992
1999
  }, this.stopMenuUpdateTimer = () => (this.menuUpdateTimer && (clearTimeout(this.menuUpdateTimer), this.menuUpdateTimer = void 0), !1), e.view.dom.addEventListener("mouseover", (n) => {
1993
2000
  if (this.mouseHoveredHyperlinkMark = void 0, this.mouseHoveredHyperlinkMarkRange = void 0, this.stopMenuUpdateTimer(), n.target instanceof HTMLAnchorElement && n.target.nodeName === "A") {
1994
- const r = n.target, i = e.view.posAtDOM(r, 0) + 1, d = e.state.doc.resolve(
2001
+ const r = n.target, i = e.view.posAtDOM(r, 0) + 1, a = e.state.doc.resolve(
1995
2002
  i
1996
- ), s = d.marks();
1997
- for (const a of s)
1998
- if (a.type.name === e.schema.mark("link").type.name) {
1999
- this.mouseHoveredHyperlinkMark = a, this.mouseHoveredHyperlinkMarkRange = X(
2000
- d,
2001
- a.type,
2002
- a.attrs
2003
+ ), s = a.marks();
2004
+ for (const d of s)
2005
+ if (d.type.name === e.schema.mark("link").type.name) {
2006
+ this.mouseHoveredHyperlinkMark = d, this.mouseHoveredHyperlinkMarkRange = X(
2007
+ a,
2008
+ d.type,
2009
+ d.attrs
2003
2010
  ) || void 0;
2004
2011
  break;
2005
2012
  }
@@ -2013,8 +2020,8 @@ class Yt {
2013
2020
  return;
2014
2021
  const e = this.hyperlinkMark;
2015
2022
  if (this.hyperlinkMark = void 0, this.hyperlinkMarkRange = void 0, this.keyboardHoveredHyperlinkMark = void 0, this.keyboardHoveredHyperlinkMarkRange = void 0, this.editor.state.selection.empty) {
2016
- const d = this.editor.state.selection.$from.marks();
2017
- for (const s of d)
2023
+ const a = this.editor.state.selection.$from.marks();
2024
+ for (const s of a)
2018
2025
  if (s.type.name === this.editor.schema.mark("link").type.name) {
2019
2026
  this.keyboardHoveredHyperlinkMark = s, this.keyboardHoveredHyperlinkMarkRange = X(
2020
2027
  this.editor.state.selection.$from,
@@ -2089,13 +2096,13 @@ class Yt {
2089
2096
  };
2090
2097
  }
2091
2098
  }
2092
- const Wt = (o, e) => new B({
2093
- key: jt,
2094
- view: () => new Yt({
2099
+ const Vt = (o, e) => new B({
2100
+ key: Wt,
2101
+ view: () => new jt({
2095
2102
  editor: o,
2096
2103
  hyperlinkToolbarFactory: e.hyperlinkToolbarFactory
2097
2104
  })
2098
- }), Vt = de.extend({
2105
+ }), Kt = de.extend({
2099
2106
  priority: 500,
2100
2107
  addProseMirrorPlugins() {
2101
2108
  var o;
@@ -2103,12 +2110,12 @@ const Wt = (o, e) => new B({
2103
2110
  throw new Error("UI Element factory not defined for HyperlinkMark");
2104
2111
  return [
2105
2112
  ...((o = this.parent) == null ? void 0 : o.call(this)) || [],
2106
- Wt(this.editor, {
2113
+ Vt(this.editor, {
2107
2114
  hyperlinkToolbarFactory: this.options.hyperlinkToolbarFactory
2108
2115
  })
2109
2116
  ];
2110
2117
  }
2111
- }), Kt = new v("blocknote-placeholder"), Jt = C.create({
2118
+ }), Jt = new v("blocknote-placeholder"), Xt = C.create({
2112
2119
  name: "placeholder",
2113
2120
  addOptions() {
2114
2121
  return {
@@ -2125,35 +2132,35 @@ const Wt = (o, e) => new B({
2125
2132
  addProseMirrorPlugins() {
2126
2133
  return [
2127
2134
  new B({
2128
- key: Kt,
2135
+ key: Jt,
2129
2136
  props: {
2130
2137
  decorations: (o) => {
2131
- const { doc: e, selection: t } = o, n = K.getState(o), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = t, d = [];
2138
+ const { doc: e, selection: t } = o, n = K.getState(o), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: i } = t, a = [];
2132
2139
  if (r)
2133
- return e.descendants((s, a) => {
2134
- const l = i >= a && i <= a + s.nodeSize, c = !s.isLeaf && !s.childCount;
2140
+ return e.descendants((s, d) => {
2141
+ const l = i >= d && i <= d + s.nodeSize, c = !s.isLeaf && !s.childCount;
2135
2142
  if ((l || !this.options.showOnlyCurrent) && c) {
2136
2143
  const u = [this.options.emptyNodeClass];
2137
2144
  this.editor.isEmpty && u.push(this.options.emptyEditorClass), l && u.push(this.options.hasAnchorClass), (n == null ? void 0 : n.triggerCharacter) === "" && (n != null && n.active) && u.push(this.options.isFilterClass);
2138
- const f = _.node(a, a + s.nodeSize, {
2145
+ const f = D.node(d, d + s.nodeSize, {
2139
2146
  class: u.join(" ")
2140
2147
  });
2141
- d.push(f);
2148
+ a.push(f);
2142
2149
  }
2143
2150
  return this.options.includeChildren;
2144
- }), D.create(e, d);
2151
+ }), F.create(e, a);
2145
2152
  }
2146
2153
  }
2147
2154
  })
2148
2155
  ];
2149
2156
  }
2150
2157
  });
2151
- class Xt {
2158
+ class Qt {
2152
2159
  constructor(e, t) {
2153
2160
  this.name = e, this.match = t;
2154
2161
  }
2155
2162
  }
2156
- class I extends Xt {
2163
+ class I extends Qt {
2157
2164
  /**
2158
2165
  * Constructs a new slash-command.
2159
2166
  *
@@ -2171,7 +2178,7 @@ function S(o, e) {
2171
2178
  const t = o.getTextCursorPosition().block;
2172
2179
  t.content.length === 1 && t.content[0].type === "text" && t.content[0].text === "/" || t.content.length === 0 ? o.updateBlock(t, e) : (o.insertBlocks([e], t, "after"), o.setTextCursorPosition(o.getTextCursorPosition().nextBlock));
2173
2180
  }
2174
- const Qt = [
2181
+ const Zt = [
2175
2182
  // Command for creating a level 1 heading
2176
2183
  new I(
2177
2184
  "Heading",
@@ -2314,7 +2321,7 @@ const Qt = [
2314
2321
  // TableIcon,
2315
2322
  // "Used to create a simple table"
2316
2323
  // ),
2317
- ], Zt = C.create({
2324
+ ], eo = C.create({
2318
2325
  name: "textAlignment",
2319
2326
  addGlobalAttributes() {
2320
2327
  return [
@@ -2352,7 +2359,7 @@ const Qt = [
2352
2359
  }
2353
2360
  };
2354
2361
  }
2355
- }), eo = C.create({
2362
+ }), to = C.create({
2356
2363
  name: "blockTextColor",
2357
2364
  addGlobalAttributes() {
2358
2365
  return [
@@ -2378,7 +2385,7 @@ const Qt = [
2378
2385
  }
2379
2386
  };
2380
2387
  }
2381
- }), to = ne.create({
2388
+ }), oo = ne.create({
2382
2389
  name: "textColor",
2383
2390
  addAttributes() {
2384
2391
  return {
@@ -2407,7 +2414,7 @@ const Qt = [
2407
2414
  setTextColor: (o) => ({ commands: e }) => o !== "default" ? e.setMark(this.name, { color: o }) : e.unsetMark(this.name)
2408
2415
  };
2409
2416
  }
2410
- }), oo = C.create({
2417
+ }), no = C.create({
2411
2418
  name: "trailingNode",
2412
2419
  addProseMirrorPlugins() {
2413
2420
  const o = new v(this.name);
@@ -2415,10 +2422,10 @@ const Qt = [
2415
2422
  new B({
2416
2423
  key: o,
2417
2424
  appendTransaction: (e, t, n) => {
2418
- const { doc: r, tr: i, schema: d } = n, s = o.getState(n), a = r.content.size - 2, l = d.nodes.blockContainer, c = d.nodes.paragraph;
2425
+ const { doc: r, tr: i, schema: a } = n, s = o.getState(n), d = r.content.size - 2, l = a.nodes.blockContainer, c = a.nodes.paragraph;
2419
2426
  if (s)
2420
2427
  return i.insert(
2421
- a,
2428
+ d,
2422
2429
  l.create(void 0, c.create())
2423
2430
  );
2424
2431
  },
@@ -2439,7 +2446,7 @@ const Qt = [
2439
2446
  })
2440
2447
  ];
2441
2448
  }
2442
- }), no = (o) => {
2449
+ }), ro = (o) => {
2443
2450
  const e = [
2444
2451
  N.ClipboardTextSerializer,
2445
2452
  N.Commands,
@@ -2449,96 +2456,108 @@ const Qt = [
2449
2456
  // DevTools,
2450
2457
  Ue,
2451
2458
  // DropCursor,
2452
- Jt.configure({
2459
+ Xt.configure({
2453
2460
  emptyNodeClass: b.isEmpty,
2454
2461
  hasAnchorClass: b.hasAnchor,
2455
2462
  isFilterClass: b.isFilter,
2456
2463
  includeChildren: !0,
2457
2464
  showOnlyCurrent: !1
2458
2465
  }),
2459
- W.configure({
2466
+ j.configure({
2460
2467
  types: ["blockContainer"]
2461
2468
  }),
2462
- qe,
2469
+ Ge,
2463
2470
  // Comments,
2464
2471
  // basics:
2465
- Ye,
2472
+ We,
2466
2473
  // marks:
2467
2474
  Fe,
2468
2475
  Re,
2469
- $e,
2476
+ qe,
2477
+ Ye,
2470
2478
  je,
2471
- We,
2479
+ oo,
2472
2480
  to,
2473
- eo,
2474
2481
  dt,
2475
2482
  at,
2476
- Zt,
2483
+ eo,
2477
2484
  // custom blocks:
2478
2485
  ...Et,
2479
2486
  ze.configure({ width: 5, color: "#ddeeff" }),
2480
- Ge,
2487
+ $e,
2481
2488
  // This needs to be at the bottom of this list, because Key events (such as enter, when selecting a /command),
2482
2489
  // should be handled before Enter handlers in other components like splitListItem
2483
- oo
2490
+ no
2484
2491
  ];
2485
2492
  return o.uiFactories.blockSideMenuFactory && e.push(
2486
- Ut.configure({
2493
+ Gt.configure({
2487
2494
  blockSideMenuFactory: o.uiFactories.blockSideMenuFactory
2488
2495
  })
2489
2496
  ), o.uiFactories.formattingToolbarFactory && e.push(
2490
- $t.configure({
2497
+ Yt.configure({
2491
2498
  formattingToolbarFactory: o.uiFactories.formattingToolbarFactory
2492
2499
  })
2493
2500
  ), o.uiFactories.hyperlinkToolbarFactory ? e.push(
2494
- Vt.configure({
2501
+ Kt.configure({
2495
2502
  hyperlinkToolbarFactory: o.uiFactories.hyperlinkToolbarFactory
2496
2503
  })
2497
2504
  ) : e.push(de), o.uiFactories.slashMenuFactory && e.push(
2498
- Ht.configure({
2505
+ Ot.configure({
2499
2506
  editor: o.editor,
2500
2507
  commands: o.slashCommands,
2501
2508
  slashMenuFactory: o.uiFactories.slashMenuFactory
2502
2509
  })
2503
2510
  ), e;
2504
- }, ro = {
2511
+ }, io = {
2505
2512
  enableInputRules: !0,
2506
2513
  enablePasteRules: !0,
2507
2514
  enableCoreExtensions: !1
2508
2515
  };
2509
- class Lo {
2516
+ class Ho {
2510
2517
  constructor(e = {}) {
2511
2518
  h(this, "_tiptapEditor");
2512
2519
  h(this, "blockCache", /* @__PURE__ */ new WeakMap());
2513
- var i, d, s;
2514
- const t = no({
2520
+ var i, a, s;
2521
+ e = {
2522
+ defaultStyles: !0,
2523
+ ...e
2524
+ };
2525
+ const t = ro({
2515
2526
  editor: this,
2516
2527
  uiFactories: e.uiFactories || {},
2517
- slashCommands: e.slashCommands || Qt
2528
+ slashCommands: e.slashCommands || Zt
2518
2529
  });
2519
- let n = e.disableHistoryExtension ? t.filter((a) => a.name !== "history") : t;
2530
+ let n = e.disableHistoryExtension ? t.filter((d) => d.name !== "history") : t;
2520
2531
  const r = {
2521
- ...ro,
2532
+ // TODO: This approach to setting initial content is "cleaner" but requires the PM editor schema, which is only
2533
+ // created after initializing the TipTap editor. Not sure it's feasible.
2534
+ // content:
2535
+ // options.initialContent &&
2536
+ // options.initialContent.map((block) =>
2537
+ // blockToNode(block, this._tiptapEditor.schema).toJSON()
2538
+ // ),
2539
+ ...io,
2522
2540
  ...e._tiptapOptions,
2523
2541
  onCreate: () => {
2524
- var a;
2525
- (a = e.onEditorReady) == null || a.call(e, this);
2542
+ var d;
2543
+ (d = e.onEditorReady) == null || d.call(e, this), e.initialContent && this.replaceBlocks(this.topLevelBlocks, e.initialContent);
2526
2544
  },
2527
2545
  onUpdate: () => {
2528
- var a;
2529
- (a = e.onEditorContentChange) == null || a.call(e, this);
2546
+ var d;
2547
+ (d = e.onEditorContentChange) == null || d.call(e, this);
2530
2548
  },
2531
2549
  onSelectionUpdate: () => {
2532
- var a;
2533
- (a = e.onTextCursorPositionChange) == null || a.call(e, this);
2550
+ var d;
2551
+ (d = e.onTextCursorPositionChange) == null || d.call(e, this);
2534
2552
  },
2535
- extensions: e.enableBlockNoteExtensions === !1 ? (i = e._tiptapOptions) == null ? void 0 : i.extensions : [...((d = e._tiptapOptions) == null ? void 0 : d.extensions) || [], ...n],
2553
+ extensions: e.enableBlockNoteExtensions === !1 ? (i = e._tiptapOptions) == null ? void 0 : i.extensions : [...((a = e._tiptapOptions) == null ? void 0 : a.extensions) || [], ...n],
2536
2554
  editorProps: {
2537
2555
  attributes: {
2538
2556
  ...e.editorDOMAttributes || {},
2539
2557
  class: [
2540
- G.bnEditor,
2541
- G.bnRoot,
2558
+ _.bnEditor,
2559
+ _.bnRoot,
2560
+ e.defaultStyles ? _.defaultStyles : "",
2542
2561
  ((s = e.editorDOMAttributes) == null ? void 0 : s.class) || ""
2543
2562
  ].join(" ")
2544
2563
  }
@@ -2555,7 +2574,7 @@ class Lo {
2555
2574
  */
2556
2575
  get topLevelBlocks() {
2557
2576
  const e = [];
2558
- return this._tiptapEditor.state.doc.firstChild.descendants((t) => (e.push(M(t, this.blockCache)), !1)), e;
2577
+ return this._tiptapEditor.state.doc.firstChild.descendants((t) => (e.push(w(t, this.blockCache)), !1)), e;
2559
2578
  }
2560
2579
  /**
2561
2580
  * Gets a snapshot of an existing block from the editor.
@@ -2565,7 +2584,7 @@ class Lo {
2565
2584
  getBlock(e) {
2566
2585
  const t = typeof e == "string" ? e : e.id;
2567
2586
  let n;
2568
- return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof n < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== t ? !0 : (n = M(r, this.blockCache), !1)), n;
2587
+ return this._tiptapEditor.state.doc.firstChild.descendants((r) => typeof n < "u" ? !1 : r.type.name !== "blockContainer" || r.attrs.id !== t ? !0 : (n = w(r, this.blockCache), !1)), n;
2569
2588
  }
2570
2589
  /**
2571
2590
  * Traverses all blocks in the editor depth-first, and executes a callback for each.
@@ -2573,15 +2592,19 @@ class Lo {
2573
2592
  * @param reverse Whether the blocks should be traversed in reverse order.
2574
2593
  */
2575
2594
  forEachBlock(e, t = !1) {
2576
- function n(r) {
2577
- if (t)
2578
- for (const i of r.reverse())
2579
- n(i.children), e(i);
2580
- else
2581
- for (const i of r)
2582
- e(i), n(i.children);
2595
+ const n = this.topLevelBlocks.slice();
2596
+ t && n.reverse();
2597
+ function r(i) {
2598
+ for (const a of i) {
2599
+ if (e(a) === !1)
2600
+ return !1;
2601
+ const s = t ? a.children.slice().reverse() : a.children;
2602
+ if (r(s) === !1)
2603
+ return !1;
2604
+ }
2605
+ return !0;
2583
2606
  }
2584
- n(this.topLevelBlocks);
2607
+ r(n);
2585
2608
  }
2586
2609
  /**
2587
2610
  * Gets a snapshot of the current text cursor position.
@@ -2591,14 +2614,14 @@ class Lo {
2591
2614
  const { node: e, depth: t, startPos: n, endPos: r } = k(
2592
2615
  this._tiptapEditor.state.doc,
2593
2616
  this._tiptapEditor.state.selection.from
2594
- ), i = this._tiptapEditor.state.doc.resolve(r).index(t - 1), d = this._tiptapEditor.state.doc.resolve(r + 1).node().childCount;
2617
+ ), i = this._tiptapEditor.state.doc.resolve(r).index(t - 1), a = this._tiptapEditor.state.doc.resolve(r + 1).node().childCount;
2595
2618
  let s;
2596
2619
  i > 0 && (s = this._tiptapEditor.state.doc.resolve(n - 2).node());
2597
- let a;
2598
- return i < d - 1 && (a = this._tiptapEditor.state.doc.resolve(r + 2).node()), {
2599
- block: M(e, this.blockCache),
2600
- prevBlock: s === void 0 ? void 0 : M(s, this.blockCache),
2601
- nextBlock: a === void 0 ? void 0 : M(a, this.blockCache)
2620
+ let d;
2621
+ return i < a - 1 && (d = this._tiptapEditor.state.doc.resolve(r + 2).node()), {
2622
+ block: w(e, this.blockCache),
2623
+ prevBlock: s === void 0 ? void 0 : w(s, this.blockCache),
2624
+ nextBlock: d === void 0 ? void 0 : w(d, this.blockCache)
2602
2625
  };
2603
2626
  }
2604
2627
  /**
@@ -2608,12 +2631,12 @@ class Lo {
2608
2631
  * @param placement Whether the text cursor should be placed at the start or end of the block.
2609
2632
  */
2610
2633
  setTextCursorPosition(e, t = "start") {
2611
- const n = typeof e == "string" ? e : e.id, { posBeforeNode: r } = V(n, this._tiptapEditor.state.doc), { startPos: i, contentNode: d } = k(
2634
+ const n = typeof e == "string" ? e : e.id, { posBeforeNode: r } = V(n, this._tiptapEditor.state.doc), { startPos: i, contentNode: a } = k(
2612
2635
  this._tiptapEditor.state.doc,
2613
2636
  r + 2
2614
2637
  );
2615
2638
  t === "start" ? this._tiptapEditor.commands.setTextSelection(i + 1) : this._tiptapEditor.commands.setTextSelection(
2616
- i + d.nodeSize - 1
2639
+ i + a.nodeSize - 1
2617
2640
  );
2618
2641
  }
2619
2642
  /**
@@ -2695,10 +2718,10 @@ class Lo {
2695
2718
  }
2696
2719
  export {
2697
2720
  I as BaseSlashMenuItem,
2698
- Lo as BlockNoteEditor,
2721
+ Ho as BlockNoteEditor,
2699
2722
  ee as blockProps,
2700
- Qt as defaultSlashMenuItems,
2701
- no as getBlockNoteExtensions,
2723
+ Zt as defaultSlashMenuItems,
2724
+ ro as getBlockNoteExtensions,
2702
2725
  O as globalProps
2703
2726
  };
2704
2727
  //# sourceMappingURL=blocknote.js.map