@blocknote/core 0.2.2-alpha.0 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/blocknote.js +696 -691
  2. package/dist/blocknote.js.map +1 -1
  3. package/dist/blocknote.umd.cjs +1 -1
  4. package/dist/blocknote.umd.cjs.map +1 -1
  5. package/dist/style.css +1 -1
  6. package/package.json +6 -4
  7. package/src/BlockNoteExtensions.ts +1 -10
  8. package/src/extensions/Blocks/PreviousBlockTypePlugin.ts +22 -26
  9. package/src/extensions/Blocks/apiTypes.ts +48 -0
  10. package/src/extensions/Blocks/helpers/findBlock.ts +3 -1
  11. package/src/extensions/Blocks/helpers/getBlockInfoFromPos.ts +1 -1
  12. package/src/extensions/Blocks/index.ts +10 -8
  13. package/src/extensions/Blocks/nodes/Block.module.css +31 -29
  14. package/src/extensions/Blocks/{BlockAttributes.ts → nodes/BlockAttributes.ts} +0 -0
  15. package/src/extensions/Blocks/nodes/{Block.ts → BlockContainer.ts} +75 -94
  16. package/src/extensions/Blocks/nodes/{BlockTypes/HeadingBlock/HeadingContent.ts → BlockContent/HeadingBlockContent/HeadingBlockContent.ts} +16 -24
  17. package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.ts +76 -0
  18. package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/ListItemKeyboardShortcuts.ts +47 -0
  19. package/src/extensions/Blocks/nodes/{BlockTypes/ListItemBlock/OrderedListItemIndexPlugin.ts → BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.ts} +10 -14
  20. package/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.ts +95 -0
  21. package/src/extensions/Blocks/nodes/{BlockTypes/TextBlock/TextContent.ts → BlockContent/ParagraphBlockContent/ParagraphBlockContent.ts} +3 -8
  22. package/src/extensions/Blocks/nodes/BlockGroup.ts +4 -4
  23. package/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.ts +1 -1
  24. package/src/extensions/DraggableBlocks/DraggableBlocksPlugin.ts +7 -7
  25. package/src/extensions/{Blocks → DraggableBlocks}/MultipleNodeSelection.ts +0 -0
  26. package/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.ts +4 -7
  27. package/src/extensions/FormattingToolbar/FormattingToolbarPlugin.ts +17 -9
  28. package/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.ts +1 -1
  29. package/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.ts +3 -1
  30. package/src/extensions/SlashMenu/defaultCommands.tsx +22 -23
  31. package/src/extensions/TrailingNode/TrailingNodeExtension.ts +4 -4
  32. package/src/extensions/UniqueID/UniqueID.ts +6 -0
  33. package/src/index.ts +2 -1
  34. package/src/shared/EditorElement.ts +12 -6
  35. package/src/shared/plugins/suggestion/SuggestionPlugin.ts +2 -2
  36. package/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.ts +1 -1
  37. package/types/src/BlockNoteEditor.d.ts +1 -1
  38. package/types/src/BlockNoteExtensions.d.ts +1 -3
  39. package/types/src/extensions/Blocks/apiTypes.d.ts +16 -0
  40. package/types/src/extensions/Blocks/helpers/getBlockInfoFromPos.d.ts +1 -1
  41. package/types/src/extensions/Blocks/nodes/BlockAttributes.d.ts +2 -0
  42. package/types/src/extensions/Blocks/nodes/BlockContainer.d.ts +21 -0
  43. package/types/src/extensions/Blocks/nodes/BlockContent/BlockContentTypes.d.ts +4 -0
  44. package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContent.d.ts +2 -0
  45. package/types/src/extensions/Blocks/nodes/BlockContent/HeadingBlockContent/HeadingBlockContentTypes.d.ts +4 -0
  46. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContent.d.ts +2 -0
  47. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/BulletListItemBlockContent/BulletListItemBlockContentTypes.d.ts +2 -0
  48. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/ListItemKeyboardShortcuts.d.ts +2 -0
  49. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListIndexingPlugin.d.ts +2 -0
  50. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContent.d.ts +2 -0
  51. package/types/src/extensions/Blocks/nodes/BlockContent/ListItemBlockContent/NumberedListItemBlockContent/NumberedListItemBlockContentTypes.d.ts +2 -0
  52. package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContent.d.ts +2 -0
  53. package/types/src/extensions/Blocks/nodes/BlockContent/ParagraphBlockContent/ParagraphBlockContentTypes.d.ts +2 -0
  54. package/types/src/extensions/DraggableBlocks/BlockSideMenuFactoryTypes.d.ts +5 -5
  55. package/types/src/extensions/DraggableBlocks/DraggableBlocksExtension.d.ts +1 -1
  56. package/types/src/extensions/DraggableBlocks/DraggableBlocksPlugin.d.ts +2 -2
  57. package/types/src/extensions/DraggableBlocks/MultipleNodeSelection.d.ts +24 -0
  58. package/types/src/extensions/FormattingToolbar/FormattingToolbarFactoryTypes.d.ts +8 -8
  59. package/types/src/extensions/FormattingToolbar/FormattingToolbarPlugin.d.ts +1 -1
  60. package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarFactoryTypes.d.ts +5 -5
  61. package/types/src/extensions/HyperlinkToolbar/HyperlinkToolbarPlugin.d.ts +2 -2
  62. package/types/src/extensions/SlashMenu/SlashMenuExtension.d.ts +1 -1
  63. package/types/src/extensions/SlashMenu/SlashMenuItem.d.ts +1 -1
  64. package/types/src/index.d.ts +2 -1
  65. package/types/src/shared/EditorElement.d.ts +6 -2
  66. package/types/src/shared/plugins/suggestion/SuggestionPlugin.d.ts +3 -3
  67. package/types/src/shared/plugins/suggestion/SuggestionsMenuFactoryTypes.d.ts +5 -5
  68. package/src/extensions/Blocks/nodes/BlockTypes/ListItemBlock/ListItemContent.ts +0 -177
  69. package/src/extensions/Paragraph/FixedParagraph.ts +0 -12
package/dist/blocknote.js CHANGED
@@ -1,47 +1,39 @@
1
1
  var re = Object.defineProperty;
2
- var ie = (o, e, t) => e in o ? re(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var h = (o, e, t) => (ie(o, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { combineTransactionSteps as Q, getChangedRanges as X, findChildren as _, Node as w, mergeAttributes as N, InputRule as U, isTextSelection as se, isNodeSelection as ae, posToDOMRect as Z, Extension as E, findParentNode as de, getMarkRange as K, findChildrenInRange as le, extensions as P, Editor as ce } from "@tiptap/core";
2
+ var ie = (t, e, o) => e in t ? re(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var h = (t, e, o) => (ie(t, typeof e != "symbol" ? e + "" : e, o), o);
4
+ import { combineTransactionSteps as J, getChangedRanges as Q, findChildren as D, Node as T, mergeAttributes as S, InputRule as $, isTextSelection as se, isNodeSelection as ae, posToDOMRect as X, Extension as P, findParentNode as le, getMarkRange as W, findChildrenInRange as de, extensions as N, Editor as ce } from "@tiptap/core";
5
5
  import ue from "@tiptap/extension-bold";
6
6
  import he from "@tiptap/extension-code";
7
7
  import pe from "@tiptap/extension-dropcursor";
8
8
  import me from "@tiptap/extension-gapcursor";
9
9
  import fe from "@tiptap/extension-hard-break";
10
- import { History as ge } from "@tiptap/extension-history";
11
- import ke from "@tiptap/extension-italic";
10
+ import { History as ke } from "@tiptap/extension-history";
11
+ import ge from "@tiptap/extension-italic";
12
12
  import ye from "@tiptap/extension-strike";
13
13
  import be from "@tiptap/extension-text";
14
14
  import ve from "@tiptap/extension-underline";
15
- import { Slice as z, Fragment as ee } from "prosemirror-model";
16
- import { PluginKey as v, Plugin as T, TextSelection as W, Selection as F, NodeSelection as Ie } from "prosemirror-state";
17
- import * as Te from "prosemirror-view";
15
+ import { Slice as z, Fragment as Z } from "prosemirror-model";
16
+ import { PluginKey as B, Plugin as M, TextSelection as K, Selection as F, NodeSelection as Be } from "prosemirror-state";
17
+ import * as Me from "prosemirror-view";
18
18
  import { Decoration as L, DecorationSet as O } from "prosemirror-view";
19
19
  import { escapeRegExp as V } from "lodash";
20
- import { Link as te } from "@tiptap/extension-link";
21
- import Ce from "@tiptap/extension-paragraph";
22
- import { v4 as Be } from "uuid";
23
- const j = {
24
- blockColor: "data-block-color",
25
- blockStyle: "data-block-style",
26
- id: "data-id",
27
- depth: "data-depth",
28
- depthChange: "data-depth-change"
29
- };
30
- function k(o, e) {
31
- if (e <= 0 || e > o.nodeSize)
20
+ import { Link as ee } from "@tiptap/extension-link";
21
+ import { v4 as Ce } from "uuid";
22
+ function g(t, e) {
23
+ if (e <= 0 || e > t.nodeSize)
32
24
  return;
33
- const t = o.resolve(e), n = t.depth;
34
- let r = t.node(n), a = n;
25
+ const o = t.resolve(e), n = o.depth;
26
+ let r = o.node(n), a = n;
35
27
  for (; a >= 0; ) {
36
28
  if (a === 0)
37
29
  return;
38
- if (r.type.name === "block")
30
+ if (r.type.name === "blockContainer")
39
31
  break;
40
- a -= 1, r = t.node(a);
32
+ a -= 1, r = o.node(a);
41
33
  }
42
- const d = r.attrs.id, i = r.firstChild, s = i.type, c = r.childCount === 2 ? r.lastChild.childCount : 0, p = t.start(a), u = t.end(a);
34
+ const l = r.attrs.id, i = r.firstChild, s = i.type, c = r.childCount === 2 ? r.lastChild.childCount : 0, p = o.start(a), u = o.end(a);
43
35
  return {
44
- id: d,
36
+ id: l,
45
37
  node: r,
46
38
  contentNode: i,
47
39
  contentType: s,
@@ -51,18 +43,17 @@ function k(o, e) {
51
43
  depth: a
52
44
  };
53
45
  }
54
- const Y = new v("previous-blocks"), Me = {
55
- listItemType: "list-item-type",
56
- listItemIndex: "list-item-index",
57
- headingLevel: "heading-level",
46
+ const Y = new B("previous-blocks"), we = {
47
+ index: "index",
48
+ level: "level",
58
49
  type: "type",
59
50
  depth: "depth",
60
51
  "depth-change": "depth-change"
61
- }, we = () => new T({
52
+ }, Ie = () => new M({
62
53
  key: Y,
63
- view(o) {
54
+ view(t) {
64
55
  return {
65
- update: async (e, t) => {
56
+ update: async (e, o) => {
66
57
  var n;
67
58
  (n = this.key) != null && n.getState(e.state).needsUpdate && setTimeout(() => {
68
59
  e.dispatch(
@@ -79,31 +70,29 @@ const Y = new v("previous-blocks"), Me = {
79
70
  needsUpdate: !1
80
71
  };
81
72
  },
82
- apply(o, e, t, n) {
83
- if (e.needsUpdate = !1, e.prevBlockAttrs = {}, !o.docChanged || t.doc.eq(n.doc))
73
+ apply(t, e, o, n) {
74
+ if (e.needsUpdate = !1, e.prevBlockAttrs = {}, !t.docChanged || o.doc.eq(n.doc))
84
75
  return e;
85
- const r = Q(t.doc, [o]);
86
- return X(r).forEach(() => {
87
- const d = _(t.doc, (c) => c.attrs.id), i = new Map(
88
- d.map((c) => [c.node.attrs.id, c])
89
- ), s = _(n.doc, (c) => c.attrs.id);
76
+ const r = J(o.doc, [t]);
77
+ return Q(r).forEach(() => {
78
+ const l = D(o.doc, (c) => c.attrs.id), i = new Map(
79
+ l.map((c) => [c.node.attrs.id, c])
80
+ ), s = D(n.doc, (c) => c.attrs.id);
90
81
  for (let c of s) {
91
- const p = i.get(c.node.attrs.id), u = p == null ? void 0 : p.node.firstChild, l = c.node.firstChild;
92
- if (p && u && l) {
82
+ const p = i.get(c.node.attrs.id), u = p == null ? void 0 : p.node.firstChild, d = c.node.firstChild;
83
+ if (p && u && d) {
93
84
  const m = {
94
- listItemType: l.attrs.listItemType,
95
- listItemIndex: l.attrs.listItemIndex,
96
- headingLevel: l.attrs.headingLevel,
97
- type: l.type.name,
85
+ index: d.attrs.index,
86
+ level: d.attrs.level,
87
+ type: d.type.name,
98
88
  depth: n.doc.resolve(c.pos).depth
99
89
  }, f = {
100
- listItemType: u.attrs.listItemType,
101
- listItemIndex: u.attrs.listItemIndex,
102
- headingLevel: u.attrs.headingLevel,
90
+ index: u.attrs.index,
91
+ level: u.attrs.level,
103
92
  type: u.type.name,
104
- depth: t.doc.resolve(p.pos).depth
105
- }, y = f.listItemIndex === null && m.listItemIndex !== null, b = f.listItemIndex !== null && m.listItemIndex !== null && f.listItemIndex === m.listItemIndex, g = f.listItemType === "ordered" && m.listItemType === "ordered" ? y || b : !0;
106
- JSON.stringify(f) !== JSON.stringify(m) && g && (f["depth-change"] = f.depth - m.depth, e.prevBlockAttrs[c.node.attrs.id] = f, console.log(
93
+ depth: o.doc.resolve(p.pos).depth
94
+ }, y = f.index === null && m.index !== null, b = f.index !== null && m.index !== null && f.index === m.index, k = f.type === "numberedListItem" && m.type === "numberedListItem" ? y || b : !0;
95
+ JSON.stringify(f) !== JSON.stringify(m) && k && (f["depth-change"] = f.depth - m.depth, e.prevBlockAttrs[c.node.attrs.id] = f, console.log(
107
96
  "id:",
108
97
  c.node.attrs.id,
109
98
  "previousBlockTypePlugin changes detected, oldAttrs",
@@ -117,42 +106,48 @@ const Y = new v("previous-blocks"), Me = {
117
106
  }
118
107
  },
119
108
  props: {
120
- decorations(o) {
121
- const e = this.getState(o);
109
+ decorations(t) {
110
+ const e = this.getState(t);
122
111
  if (!e.needsUpdate)
123
112
  return;
124
- const t = [];
125
- return o.doc.descendants((n, r) => {
113
+ const o = [];
114
+ return t.doc.descendants((n, r) => {
126
115
  if (!n.attrs.id)
127
116
  return;
128
117
  const a = e.prevBlockAttrs[n.attrs.id];
129
118
  if (!a)
130
119
  return;
131
- const d = {};
120
+ const l = {};
132
121
  for (let [s, c] of Object.entries(a))
133
- d["data-prev-" + Me[s]] = c || "none";
122
+ l["data-prev-" + we[s]] = c || "none";
134
123
  console.log(
135
124
  "previousBlockTypePlugin committing decorations",
136
- d
125
+ l
137
126
  );
138
127
  const i = L.node(r, r + n.nodeSize, {
139
- ...d
128
+ ...l
140
129
  });
141
- t.push(i);
142
- }), O.create(o.doc, t);
130
+ o.push(i);
131
+ }), O.create(t.doc, o);
143
132
  }
144
133
  }
145
- }), Se = "_blockOuter_r256c_5", xe = "_block_r256c_5", Ee = "_blockContent_r256c_25", Pe = "_blockGroup_r256c_53", Ae = "_isEmpty_r256c_238", Ne = "_isFilter_r256c_239", He = "_hasAnchor_r256c_252", I = {
146
- blockOuter: Se,
147
- block: xe,
148
- blockContent: Ee,
149
- blockGroup: Pe,
150
- isEmpty: Ae,
134
+ }), Te = "_blockOuter_6qmsf_5", Ee = "_block_6qmsf_5", xe = "_blockContent_6qmsf_25", Se = "_blockGroup_6qmsf_53", Pe = "_isEmpty_6qmsf_238", Ne = "_isFilter_6qmsf_239", Ae = "_hasAnchor_6qmsf_252", v = {
135
+ blockOuter: Te,
136
+ block: Ee,
137
+ blockContent: xe,
138
+ blockGroup: Se,
139
+ isEmpty: Pe,
151
140
  isFilter: Ne,
152
- hasAnchor: He
153
- }, Le = w.create({
154
- name: "block",
155
- group: "block",
141
+ hasAnchor: Ae
142
+ }, He = {
143
+ blockColor: "data-block-color",
144
+ blockStyle: "data-block-style",
145
+ id: "data-id",
146
+ depth: "data-depth",
147
+ depthChange: "data-depth-change"
148
+ }, Le = T.create({
149
+ name: "blockContainer",
150
+ group: "blockContainer",
156
151
  content: "blockContent blockGroup?",
157
152
  priority: 50,
158
153
  defining: !0,
@@ -175,31 +170,28 @@ const Y = new v("previous-blocks"), Me = {
175
170
  return [
176
171
  {
177
172
  tag: "div",
178
- getAttrs: (o) => {
179
- if (typeof o == "string")
173
+ getAttrs: (t) => {
174
+ if (typeof t == "string")
180
175
  return !1;
181
176
  const e = {};
182
- for (let [t, n] of Object.entries(j))
183
- o.getAttribute(n) && (e[t] = o.getAttribute(n));
184
- return o.getAttribute("data-node-type") === "block" ? e : !1;
177
+ for (let [o, n] of Object.entries(He))
178
+ t.getAttribute(n) && (e[o] = t.getAttribute(n));
179
+ return t.getAttribute("data-node-type") === "blockContainer" ? e : !1;
185
180
  }
186
181
  }
187
182
  ];
188
183
  },
189
- renderHTML({ HTMLAttributes: o }) {
190
- const e = {};
191
- for (let [t, n] of Object.entries(j))
192
- o[t] !== void 0 && (e[n] = o[t]);
184
+ renderHTML({ HTMLAttributes: t }) {
193
185
  return [
194
186
  "div",
195
- N(e, {
196
- class: I.blockOuter,
187
+ S(t, {
188
+ class: v.blockOuter,
197
189
  "data-node-type": "block-outer"
198
190
  }),
199
191
  [
200
192
  "div",
201
- N(e, {
202
- class: I.block,
193
+ S(t, {
194
+ class: v.block,
203
195
  "data-node-type": this.name
204
196
  }),
205
197
  0
@@ -208,219 +200,205 @@ const Y = new v("previous-blocks"), Me = {
208
200
  },
209
201
  addCommands() {
210
202
  return {
211
- BNCreateBlock: (o) => ({ state: e, dispatch: t }) => {
212
- const n = e.schema.nodes.block.createAndFill();
213
- return t && e.tr.insert(o, n), !0;
203
+ BNCreateBlock: (t) => ({ state: e, dispatch: o }) => {
204
+ const n = e.schema.nodes.blockContainer.createAndFill();
205
+ return o && e.tr.insert(t, n), !0;
214
206
  },
215
- BNDeleteBlock: (o) => ({ state: e, view: t, dispatch: n }) => {
216
- const r = k(e.doc, o);
207
+ BNDeleteBlock: (t) => ({ state: e, view: o, dispatch: n }) => {
208
+ const r = g(e.doc, t);
217
209
  if (r === void 0)
218
210
  return !1;
219
- const { startPos: a, endPos: d } = r;
220
- return n && (e.tr.deleteRange(a, d), e.tr.setSelection(
221
- new W(e.doc.resolve(a + 1))
222
- ), t.focus()), !0;
211
+ const { startPos: a, endPos: l } = r;
212
+ return n && (e.tr.deleteRange(a, l), e.tr.setSelection(
213
+ new K(e.doc.resolve(a + 1))
214
+ ), o.focus()), !0;
223
215
  },
224
- BNMergeBlocks: (o) => ({ state: e, dispatch: t }) => {
225
- const n = e.doc.resolve(o + 1).node().type.name === "block", r = e.doc.resolve(o - 1).node().type.name === "block";
216
+ BNMergeBlocks: (t) => ({ state: e, dispatch: o }) => {
217
+ const n = e.doc.resolve(t + 1).node().type.name === "blockContainer", r = e.doc.resolve(t - 1).node().type.name === "blockContainer";
226
218
  if (!n || !r)
227
219
  return !1;
228
- const a = k(
220
+ const a = g(
229
221
  e.doc,
230
- o + 1
231
- ), { node: d, contentNode: i, startPos: s, endPos: c, depth: p } = a;
232
- if (d.childCount === 2) {
222
+ t + 1
223
+ ), { node: l, contentNode: i, startPos: s, endPos: c, depth: p } = a;
224
+ if (l.childCount === 2) {
233
225
  const m = e.doc.resolve(
234
226
  s + i.nodeSize + 1
235
227
  ), f = e.doc.resolve(c - 1), y = m.blockRange(f);
236
- t && e.tr.lift(y, p - 1);
228
+ o && e.tr.lift(y, p - 1);
237
229
  }
238
- let u = o - 1, l = k(e.doc, u);
239
- for (; l.numChildBlocks > 0; )
240
- if (u--, l = k(e.doc, u), l === void 0)
230
+ let u = t - 1, d = g(e.doc, u);
231
+ for (; d.numChildBlocks > 0; )
232
+ if (u--, d = g(e.doc, u), d === void 0)
241
233
  return !1;
242
- return t && (e.tr.deleteRange(s, s + i.nodeSize), e.tr.insertText(i.textContent, u - 1), e.tr.setSelection(
243
- new W(e.doc.resolve(u - 1))
234
+ return o && (e.tr.deleteRange(s, s + i.nodeSize), e.tr.insertText(i.textContent, u - 1), e.tr.setSelection(
235
+ new K(e.doc.resolve(u - 1))
244
236
  )), !0;
245
237
  },
246
- BNSplitBlock: (o, e) => ({ state: t, dispatch: n }) => {
247
- const r = k(t.doc, o);
238
+ BNSplitBlock: (t, e) => ({ state: o, dispatch: n }) => {
239
+ const r = g(o.doc, t);
248
240
  if (r === void 0)
249
241
  return !1;
250
- const { contentNode: a, contentType: d, startPos: i, endPos: s, depth: c } = r, p = s + 1, u = t.doc.textBetween(o, s), l = t.schema.nodes.block.createAndFill(), m = p + 2;
251
- n && (t.tr.insert(p, l), t.tr.insertText(u, m), e && t.tr.setBlockType(
242
+ const { contentNode: a, contentType: l, startPos: i, endPos: s, depth: c } = r, p = s + 1, u = o.doc.textBetween(t, s), d = o.schema.nodes.blockContainer.createAndFill(), m = p + 2;
243
+ n && (o.tr.insert(p, d), o.tr.insertText(u, m), e && o.tr.setBlockType(
252
244
  m,
253
245
  m,
254
- t.schema.node(d).type,
246
+ o.schema.node(l).type,
255
247
  a.attrs
256
248
  ));
257
- const f = t.doc.content.cut(i, o);
258
- return n && t.tr.replace(
249
+ const f = o.doc.content.cut(i, t);
250
+ return n && o.tr.replace(
259
251
  i,
260
252
  s,
261
253
  new z(f, c, c)
262
254
  ), !0;
263
255
  },
264
- BNSetContentType: (o, e) => ({ state: t, dispatch: n }) => {
265
- const r = k(t.doc, o);
256
+ BNUpdateBlock: (t, e) => ({ state: o, dispatch: n }) => {
257
+ const r = g(o.doc, t);
266
258
  if (r === void 0)
267
259
  return !1;
268
- const { startPos: a, contentNode: d } = r;
269
- return n && t.tr.setBlockType(
270
- a + 1,
271
- a + d.nodeSize + 1,
272
- t.schema.node(e.name).type,
273
- e.attrs
260
+ const { node: a, startPos: l, contentNode: i } = r;
261
+ return n && o.tr.setBlockType(
262
+ l + 1,
263
+ l + i.nodeSize + 1,
264
+ o.schema.node(e.type).type,
265
+ {
266
+ ...a.attrs,
267
+ ...e.props
268
+ }
274
269
  ), !0;
275
270
  },
276
- BNCreateBlockOrSetContentType: (o, e) => ({ state: t, chain: n }) => {
277
- const r = k(t.doc, o);
271
+ BNCreateOrUpdateBlock: (t, e) => ({ state: o, chain: n }) => {
272
+ const r = g(o.doc, t);
278
273
  if (r === void 0)
279
274
  return !1;
280
- const { node: a, startPos: d, endPos: i } = r;
275
+ const { node: a, startPos: l, endPos: i } = r;
281
276
  if (a.textContent.length === 0) {
282
- const s = d + 1;
283
- return n().BNSetContentType(o, e).setTextSelection(s).run();
277
+ const s = l + 1;
278
+ return n().BNUpdateBlock(t, e).setTextSelection(s).run();
284
279
  } else {
285
280
  const s = i + 1, c = s + 1;
286
- return n().BNCreateBlock(s).BNSetContentType(c, e).setTextSelection(c).run();
281
+ return n().BNCreateBlock(s).BNUpdateBlock(c, e).setTextSelection(c).run();
287
282
  }
288
283
  }
289
284
  };
290
285
  },
291
286
  addProseMirrorPlugins() {
292
- return [we()];
287
+ return [Ie()];
293
288
  },
294
289
  addKeyboardShortcuts() {
295
290
  return {
296
- Backspace: () => this.editor.commands.first(({ commands: t }) => [
297
- () => t.deleteSelection(),
298
- () => t.undoInputRule(),
299
- () => t.command(({ state: n }) => {
300
- const { contentType: r } = k(
291
+ Backspace: () => this.editor.commands.first(({ commands: o }) => [
292
+ () => o.deleteSelection(),
293
+ () => o.undoInputRule(),
294
+ () => o.command(({ state: n }) => {
295
+ const { contentType: r } = g(
301
296
  n.doc,
302
297
  n.selection.from
303
- ), a = n.selection.$anchor.parentOffset === 0, d = r.name === "textContent";
304
- return a && !d ? t.BNSetContentType(n.selection.from, {
305
- name: "textContent"
298
+ ), a = n.selection.$anchor.parentOffset === 0, l = r.name === "paragraph";
299
+ return a && !l ? o.BNUpdateBlock(n.selection.from, {
300
+ type: "paragraph",
301
+ props: {}
306
302
  }) : !1;
307
303
  }),
308
- () => t.command(({ state: n }) => n.selection.$anchor.parentOffset === 0 ? t.liftListItem("block") : !1),
309
- () => t.command(({ state: n }) => {
310
- const { depth: r, startPos: a } = k(
304
+ () => o.command(({ state: n }) => n.selection.$anchor.parentOffset === 0 ? o.liftListItem("blockContainer") : !1),
305
+ () => o.command(({ state: n }) => {
306
+ const { depth: r, startPos: a } = g(
311
307
  n.doc,
312
308
  n.selection.from
313
- ), d = n.selection.$anchor.parentOffset === 0, i = n.selection.anchor === n.selection.head, s = a === 2, c = a - 1;
314
- return !s && d && i && r === 2 ? t.BNMergeBlocks(c) : !1;
309
+ ), l = n.selection.$anchor.parentOffset === 0, i = n.selection.anchor === n.selection.head, s = a === 2, c = a - 1;
310
+ return !s && l && i && r === 2 ? o.BNMergeBlocks(c) : !1;
315
311
  })
316
312
  ]),
317
- Enter: () => this.editor.commands.first(({ commands: t }) => [
318
- () => t.command(({ state: n }) => {
319
- const { node: r, depth: a } = k(
313
+ Enter: () => this.editor.commands.first(({ commands: o }) => [
314
+ () => o.command(({ state: n }) => {
315
+ const { node: r, depth: a } = g(
320
316
  n.doc,
321
317
  n.selection.from
322
- ), d = n.selection.$anchor.parentOffset === 0, i = n.selection.anchor === n.selection.head, s = r.textContent.length === 0, c = a > 2;
323
- return d && i && s && c ? t.liftListItem("block") : !1;
318
+ ), l = n.selection.$anchor.parentOffset === 0, i = n.selection.anchor === n.selection.head, s = r.textContent.length === 0, c = a > 2;
319
+ return l && i && s && c ? o.liftListItem("blockContainer") : !1;
324
320
  }),
325
- () => t.command(({ state: n, chain: r }) => {
326
- const { node: a, endPos: d } = k(
321
+ () => o.command(({ state: n, chain: r }) => {
322
+ const { node: a, endPos: l } = g(
327
323
  n.doc,
328
324
  n.selection.from
329
325
  ), i = n.selection.$anchor.parentOffset === 0, s = n.selection.anchor === n.selection.head, c = a.textContent.length === 0;
330
326
  if (i && s && c) {
331
- const p = d + 1, u = p + 2;
327
+ const p = l + 1, u = p + 2;
332
328
  return r().BNCreateBlock(p).setTextSelection(u).run(), !0;
333
329
  }
334
330
  return !1;
335
331
  }),
336
- () => t.command(({ state: n, chain: r }) => {
337
- const { node: a } = k(
332
+ () => o.command(({ state: n, chain: r }) => {
333
+ const { node: a } = g(
338
334
  n.doc,
339
335
  n.selection.from
340
336
  );
341
337
  return a.textContent.length === 0 ? !1 : (r().deleteSelection().BNSplitBlock(n.selection.from, !1).run(), !0);
342
338
  })
343
339
  ]),
344
- Tab: () => this.editor.commands.sinkListItem("block"),
345
- "Shift-Tab": () => this.editor.commands.liftListItem("block"),
340
+ Tab: () => (this.editor.commands.sinkListItem("blockContainer"), !0),
341
+ "Shift-Tab": () => (this.editor.commands.liftListItem("blockContainer"), !0),
346
342
  "Mod-Alt-0": () => this.editor.commands.BNCreateBlock(
347
343
  this.editor.state.selection.anchor + 2
348
344
  ),
349
- "Mod-Alt-1": () => this.editor.commands.BNSetContentType(
350
- this.editor.state.selection.anchor,
351
- {
352
- name: "headingContent",
353
- attrs: {
354
- headingLevel: "1"
355
- }
356
- }
357
- ),
358
- "Mod-Alt-2": () => this.editor.commands.BNSetContentType(
359
- this.editor.state.selection.anchor,
360
- {
361
- name: "headingContent",
362
- attrs: {
363
- headingLevel: "2"
364
- }
365
- }
366
- ),
367
- "Mod-Alt-3": () => this.editor.commands.BNSetContentType(
368
- this.editor.state.selection.anchor,
369
- {
370
- name: "headingContent",
371
- attrs: {
372
- headingLevel: "3"
373
- }
345
+ "Mod-Alt-1": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
346
+ type: "heading",
347
+ props: {
348
+ level: "1"
374
349
  }
375
- ),
376
- "Mod-Shift-7": () => this.editor.commands.BNSetContentType(
377
- this.editor.state.selection.anchor,
378
- {
379
- name: "listItemContent",
380
- attrs: {
381
- listItemType: "unordered"
382
- }
350
+ }),
351
+ "Mod-Alt-2": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
352
+ type: "heading",
353
+ props: {
354
+ level: "2"
383
355
  }
384
- ),
385
- "Mod-Shift-8": () => this.editor.commands.BNSetContentType(
386
- this.editor.state.selection.anchor,
387
- {
388
- name: "listItemContent",
389
- attrs: {
390
- listItemType: "ordered"
391
- }
356
+ }),
357
+ "Mod-Alt-3": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
358
+ type: "heading",
359
+ props: {
360
+ level: "3"
392
361
  }
393
- )
362
+ }),
363
+ "Mod-Shift-7": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
364
+ type: "bulletListItem",
365
+ props: {}
366
+ }),
367
+ "Mod-Shift-8": () => this.editor.commands.BNUpdateBlock(this.editor.state.selection.anchor, {
368
+ type: "numberedListItem",
369
+ props: {}
370
+ })
394
371
  };
395
372
  }
396
- }), Oe = w.create({
373
+ }), Oe = T.create({
397
374
  name: "blockGroup",
375
+ group: "blockGroup",
376
+ content: "blockContainer+",
398
377
  addOptions() {
399
378
  return {
400
379
  HTMLAttributes: {}
401
380
  };
402
381
  },
403
- content: "block+",
404
382
  parseHTML() {
405
383
  return [
406
384
  {
407
385
  tag: "div",
408
- getAttrs: (o) => typeof o == "string" ? !1 : o.getAttribute("data-node-type") === "block-group" ? null : !1
386
+ getAttrs: (t) => typeof t == "string" ? !1 : t.getAttribute("data-node-type") === "blockGroup" ? null : !1
409
387
  }
410
388
  ];
411
389
  },
412
- renderHTML({ HTMLAttributes: o }) {
390
+ renderHTML({ HTMLAttributes: t }) {
413
391
  return [
414
392
  "div",
415
- N(this.options.HTMLAttributes, o, {
416
- class: I.blockGroup,
417
- "data-node-type": "block-group"
393
+ S(this.options.HTMLAttributes, t, {
394
+ class: v.blockGroup,
395
+ "data-node-type": "blockGroup"
418
396
  }),
419
397
  0
420
398
  ];
421
399
  }
422
- }), Re = w.create({
423
- name: "textContent",
400
+ }), Re = T.create({
401
+ name: "paragraph",
424
402
  group: "blockContent",
425
403
  content: "inline*",
426
404
  parseHTML() {
@@ -428,7 +406,7 @@ const Y = new v("previous-blocks"), Me = {
428
406
  {
429
407
  tag: "p",
430
408
  priority: 200,
431
- node: "block"
409
+ node: "blockContainer"
432
410
  }
433
411
  ];
434
412
  },
@@ -436,36 +414,36 @@ const Y = new v("previous-blocks"), Me = {
436
414
  return [
437
415
  "div",
438
416
  {
439
- class: I.blockContent,
417
+ class: v.blockContent,
440
418
  "data-content-type": this.name
441
419
  },
442
420
  ["p", 0]
443
421
  ];
444
422
  }
445
- }), Fe = w.create({
446
- name: "headingContent",
423
+ }), Fe = T.create({
424
+ name: "heading",
447
425
  group: "blockContent",
448
426
  content: "inline*",
449
427
  addAttributes() {
450
428
  return {
451
- headingLevel: {
429
+ level: {
452
430
  default: "1",
453
- parseHTML: (o) => o.getAttribute("data-heading-level"),
454
- renderHTML: (o) => ({
455
- "data-heading-level": o.headingLevel
431
+ parseHTML: (t) => t.getAttribute("data-level"),
432
+ renderHTML: (t) => ({
433
+ "data-level": t.level
456
434
  })
457
435
  }
458
436
  };
459
437
  },
460
438
  addInputRules() {
461
439
  return [
462
- ...["1", "2", "3"].map((o) => new U({
463
- find: new RegExp(`^(#{${parseInt(o)}})\\s$`),
464
- handler: ({ state: e, chain: t, range: n }) => {
465
- t().BNSetContentType(e.selection.from, {
466
- name: "headingContent",
467
- attrs: {
468
- headingLevel: o
440
+ ...["1", "2", "3"].map((t) => new $({
441
+ find: new RegExp(`^(#{${parseInt(t)}})\\s$`),
442
+ handler: ({ state: e, chain: o, range: n }) => {
443
+ o().BNUpdateBlock(e.selection.from, {
444
+ type: "heading",
445
+ props: {
446
+ level: t
469
447
  }
470
448
  }).deleteRange({ from: n.from, to: n.to });
471
449
  }
@@ -476,169 +454,196 @@ const Y = new v("previous-blocks"), Me = {
476
454
  return [
477
455
  {
478
456
  tag: "h1",
479
- attrs: { headingLevel: "1" },
480
- node: "block"
457
+ attrs: { level: "1" },
458
+ node: "blockContainer"
481
459
  },
482
460
  {
483
461
  tag: "h2",
484
- attrs: { headingLevel: "2" },
485
- node: "block"
462
+ attrs: { level: "2" },
463
+ node: "blockContainer"
486
464
  },
487
465
  {
488
466
  tag: "h3",
489
- attrs: { headingLevel: "3" },
490
- node: "block"
467
+ attrs: { level: "3" },
468
+ node: "blockContainer"
491
469
  }
492
470
  ];
493
471
  },
494
- renderHTML({ node: o, HTMLAttributes: e }) {
495
- return console.log(o.attrs), [
472
+ renderHTML({ node: t, HTMLAttributes: e }) {
473
+ return [
496
474
  "div",
497
- N(e, {
498
- class: I.blockContent,
475
+ S(e, {
476
+ class: v.blockContent,
499
477
  "data-content-type": this.name
500
478
  }),
501
- ["h" + o.attrs.headingLevel, 0]
479
+ ["h" + t.attrs.level, 0]
502
480
  ];
503
481
  }
504
- }), De = new v("ordered-list-item-index"), _e = () => new T({
482
+ }), te = (t) => {
483
+ const { node: e, contentType: o } = g(
484
+ t.state.doc,
485
+ t.state.selection.from
486
+ ), n = t.state.selection.anchor === t.state.selection.head;
487
+ return !o.name.endsWith("ListItem") || !n ? !1 : t.commands.first(({ state: r, chain: a, commands: l }) => [
488
+ () => l.command(() => e.textContent.length === 0 ? l.BNUpdateBlock(r.selection.from, {
489
+ type: "paragraph",
490
+ props: {}
491
+ }) : !1),
492
+ () => l.command(() => e.textContent.length > 0 ? (a().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
493
+ ]);
494
+ }, _e = T.create({
495
+ name: "bulletListItem",
496
+ group: "blockContent",
497
+ content: "inline*",
498
+ addInputRules() {
499
+ return [
500
+ new $({
501
+ find: new RegExp("^[-+*]\\s$"),
502
+ handler: ({ state: t, chain: e, range: o }) => {
503
+ e().BNUpdateBlock(t.selection.from, {
504
+ type: "bulletListItem",
505
+ props: {}
506
+ }).deleteRange({ from: o.from, to: o.to });
507
+ }
508
+ })
509
+ ];
510
+ },
511
+ addKeyboardShortcuts() {
512
+ return {
513
+ Enter: () => te(this.editor)
514
+ };
515
+ },
516
+ parseHTML() {
517
+ return [
518
+ {
519
+ tag: "li",
520
+ getAttrs: (t) => {
521
+ if (typeof t == "string")
522
+ return !1;
523
+ const e = t.parentElement;
524
+ return e === null ? !1 : e.getAttribute("data-content-type") === "bulletListItem" ? {} : e.tagName === "UL" ? {} : !1;
525
+ },
526
+ node: "blockContainer"
527
+ }
528
+ ];
529
+ },
530
+ renderHTML({ HTMLAttributes: t }) {
531
+ return [
532
+ "div",
533
+ S(t, {
534
+ class: v.blockContent,
535
+ "data-content-type": this.name
536
+ }),
537
+ ["li", 0]
538
+ ];
539
+ }
540
+ }), De = new B("numbered-list-indexing"), Ue = () => new M({
505
541
  key: De,
506
- appendTransaction: (o, e, t) => {
507
- const n = t.tr;
508
- n.setMeta("orderedListIndexing", !0);
542
+ appendTransaction: (t, e, o) => {
543
+ const n = o.tr;
544
+ n.setMeta("numberedListIndexing", !0);
509
545
  let r = !1;
510
- return t.doc.descendants((a, d) => {
511
- if (a.type.name === "block" && a.firstChild.type.name === "listItemContent" && a.firstChild.attrs.listItemType === "ordered") {
546
+ return o.doc.descendants((a, l) => {
547
+ if (a.type.name === "blockContainer" && a.firstChild.type.name === "numberedListItem") {
512
548
  let i = "1";
513
- const s = d === 1, c = k(n.doc, d + 1);
549
+ const s = l === 1, c = g(n.doc, l + 1);
514
550
  if (c === void 0)
515
551
  return;
516
552
  if (!s) {
517
- const l = k(n.doc, d - 2);
518
- if (l === void 0)
553
+ const d = g(n.doc, l - 2);
554
+ if (d === void 0)
519
555
  return;
520
- if (!(c.depth !== l.depth)) {
521
- const f = l.contentNode;
522
- if (l.contentType.name === "listItemContent" && f.attrs.listItemType === "ordered") {
523
- const g = f.attrs.listItemIndex;
524
- i = (parseInt(g) + 1).toString();
556
+ if (!(c.depth !== d.depth)) {
557
+ const f = d.contentNode;
558
+ if (d.contentType.name === "numberedListItem") {
559
+ const k = f.attrs.index;
560
+ i = (parseInt(k) + 1).toString();
525
561
  }
526
562
  }
527
563
  }
528
- c.contentNode.attrs.listItemIndex !== i && (r = !0, n.setNodeMarkup(d + 1, void 0, {
529
- listItemType: "ordered",
530
- listItemIndex: i
564
+ c.contentNode.attrs.index !== i && (r = !0, n.setNodeMarkup(l + 1, void 0, {
565
+ index: i
531
566
  }));
532
567
  }
533
568
  }), r ? n : null;
534
569
  }
535
- }), Ue = w.create({
536
- name: "listItemContent",
570
+ }), $e = T.create({
571
+ name: "numberedListItem",
537
572
  group: "blockContent",
538
573
  content: "inline*",
539
574
  addAttributes() {
540
575
  return {
541
- listItemType: {
542
- default: "unordered",
543
- parseHTML: (o) => o.getAttribute("data-list-item-type"),
544
- renderHTML: (o) => ({
545
- "data-list-item-type": o.listItemType
546
- })
547
- },
548
- listItemIndex: {
576
+ index: {
549
577
  default: null,
550
- parseHTML: (o) => o.getAttribute("data-list-item-index"),
551
- renderHTML: (o) => ({
552
- "data-list-item-index": o.listItemIndex
578
+ parseHTML: (t) => t.getAttribute("data-index"),
579
+ renderHTML: (t) => ({
580
+ "data-index": t.index
553
581
  })
554
582
  }
555
583
  };
556
584
  },
557
585
  addInputRules() {
558
586
  return [
559
- new U({
560
- find: new RegExp("^[-+*]\\s$"),
561
- handler: ({ state: o, chain: e, range: t }) => {
562
- e().BNSetContentType(o.selection.from, {
563
- name: "listItemContent",
564
- attrs: {
565
- listItemType: "unordered"
566
- }
567
- }).deleteRange({ from: t.from, to: t.to });
568
- }
569
- }),
570
- new U({
587
+ new $({
571
588
  find: new RegExp("^1\\.\\s$"),
572
- handler: ({ state: o, chain: e, range: t }) => {
573
- e().BNSetContentType(o.selection.from, {
574
- name: "listItemContent",
575
- attrs: {
576
- listItemType: "ordered"
577
- }
578
- }).deleteRange({ from: t.from, to: t.to });
589
+ handler: ({ state: t, chain: e, range: o }) => {
590
+ e().BNUpdateBlock(t.selection.from, {
591
+ type: "numberedListItem",
592
+ props: {}
593
+ }).deleteRange({ from: o.from, to: o.to });
579
594
  }
580
595
  })
581
596
  ];
582
597
  },
583
598
  addKeyboardShortcuts() {
584
599
  return {
585
- Enter: () => {
586
- const { node: e, contentType: t } = k(
587
- this.editor.state.doc,
588
- this.editor.state.selection.from
589
- ), n = this.editor.state.selection.anchor === this.editor.state.selection.head;
590
- return t.name !== "listItemContent" || !n ? !1 : this.editor.commands.first(({ state: r, chain: a, commands: d }) => [
591
- () => d.command(() => e.textContent.length === 0 ? d.BNSetContentType(r.selection.from, {
592
- name: "textContent"
593
- }) : !1),
594
- () => d.command(() => e.textContent.length > 0 ? (a().deleteSelection().BNSplitBlock(r.selection.from, !0).run(), !0) : !1)
595
- ]);
596
- }
600
+ Enter: () => te(this.editor)
597
601
  };
598
602
  },
599
603
  addProseMirrorPlugins() {
600
- return [_e()];
604
+ return [Ue()];
601
605
  },
602
606
  parseHTML() {
603
607
  return [
604
608
  {
605
609
  tag: "li",
606
- getAttrs: (o) => {
607
- if (typeof o == "string")
610
+ getAttrs: (t) => {
611
+ if (typeof t == "string")
608
612
  return !1;
609
- const e = o.parentElement;
610
- return e === null ? !1 : e.getAttribute("data-content-type") === "listItemContent" ? { listItemType: e.getAttribute("data-list-item-type") } : e.tagName === "UL" ? { listItemType: "unordered" } : e.tagName === "OL" ? { listItemType: "ordered" } : !1;
613
+ const e = t.parentElement;
614
+ return e === null ? !1 : e.getAttribute("data-content-type") === "numberedListItem" ? {} : e.tagName === "OL" ? {} : !1;
611
615
  },
612
- node: "block"
616
+ node: "blockContainer"
613
617
  }
614
618
  ];
615
619
  },
616
- renderHTML({ HTMLAttributes: o }) {
620
+ renderHTML({ HTMLAttributes: t }) {
617
621
  return [
618
622
  "div",
619
- N(o, {
620
- class: I.blockContent,
623
+ S(t, {
624
+ class: v.blockContent,
621
625
  "data-content-type": this.name
622
626
  }),
623
627
  ["li", 0]
624
628
  ];
625
629
  }
626
- }), $e = [
630
+ }), ze = [
627
631
  Re,
628
632
  Fe,
629
- Ue,
633
+ _e,
634
+ $e,
630
635
  Le,
631
636
  Oe,
632
- w.create({
637
+ T.create({
633
638
  name: "doc",
634
639
  topNode: !0,
635
640
  content: "blockGroup"
636
641
  })
637
642
  ];
638
- class ze {
643
+ class qe {
639
644
  constructor({
640
645
  editor: e,
641
- formattingToolbarFactory: t,
646
+ formattingToolbarFactory: o,
642
647
  view: n,
643
648
  shouldShow: r
644
649
  }) {
@@ -648,8 +653,8 @@ class ze {
648
653
  h(this, "preventHide", !1);
649
654
  h(this, "preventShow", !1);
650
655
  h(this, "toolbarIsOpen", !1);
651
- h(this, "shouldShow", ({ view: e, state: t, from: n, to: r }) => {
652
- const { doc: a, selection: d } = t, { empty: i } = d, s = !a.textBetween(n, r).length && se(t.selection);
656
+ h(this, "shouldShow", ({ view: e, state: o, from: n, to: r }) => {
657
+ const { doc: a, selection: l } = o, { empty: i } = l, s = !a.textBetween(n, r).length && se(o.selection);
653
658
  return !(!e.hasFocus() || i || s);
654
659
  });
655
660
  h(this, "viewMousedownHandler", () => {
@@ -665,27 +670,27 @@ class ze {
665
670
  setTimeout(() => this.update(this.editor.view));
666
671
  });
667
672
  h(this, "blurHandler", ({ event: e }) => {
668
- var t, n;
673
+ var o, n;
669
674
  if (this.preventHide) {
670
675
  this.preventHide = !1;
671
676
  return;
672
677
  }
673
- (e == null ? void 0 : e.relatedTarget) && ((n = (t = this.formattingToolbar.element) == null ? void 0 : t.parentNode) == null ? void 0 : n.contains(
678
+ (e == null ? void 0 : e.relatedTarget) && ((n = (o = this.formattingToolbar.element) == null ? void 0 : o.parentNode) == null ? void 0 : n.contains(
674
679
  e.relatedTarget
675
680
  )) || this.toolbarIsOpen && (this.formattingToolbar.hide(), this.toolbarIsOpen = !1);
676
681
  });
677
- this.editor = e, this.view = n, this.formattingToolbar = t(this.getStaticParams()), r && (this.shouldShow = r), this.view.dom.addEventListener("mousedown", this.viewMousedownHandler), this.view.dom.addEventListener("mouseup", this.viewMouseupHandler), this.view.dom.addEventListener("dragstart", this.dragstartHandler), this.editor.on("focus", this.focusHandler), this.editor.on("blur", this.blurHandler);
682
+ this.editor = e, this.view = n, this.formattingToolbar = o(this.getStaticParams()), r && (this.shouldShow = r), this.view.dom.addEventListener("mousedown", this.viewMousedownHandler), this.view.dom.addEventListener("mouseup", this.viewMouseupHandler), this.view.dom.addEventListener("dragstart", this.dragstartHandler), this.editor.on("focus", this.focusHandler), this.editor.on("blur", this.blurHandler);
678
683
  }
679
- update(e, t) {
680
- var l;
681
- const { state: n, composing: r } = e, { doc: a, selection: d } = n, i = t && t.doc.eq(a) && t.selection.eq(d);
684
+ update(e, o) {
685
+ var d;
686
+ const { state: n, composing: r } = e, { doc: a, selection: l } = n, i = o && o.doc.eq(a) && o.selection.eq(l);
682
687
  if (r || i)
683
688
  return;
684
- const { ranges: s } = d, c = Math.min(...s.map((m) => m.$from.pos)), p = Math.max(...s.map((m) => m.$to.pos)), u = (l = this.shouldShow) == null ? void 0 : l.call(this, {
689
+ const { ranges: s } = l, c = Math.min(...s.map((m) => m.$from.pos)), p = Math.max(...s.map((m) => m.$to.pos)), u = (d = this.shouldShow) == null ? void 0 : d.call(this, {
685
690
  editor: this.editor,
686
691
  view: e,
687
692
  state: n,
688
- oldState: t,
693
+ oldState: o,
689
694
  from: c,
690
695
  to: p
691
696
  });
@@ -712,13 +717,13 @@ class ze {
712
717
  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);
713
718
  }
714
719
  getSelectionBoundingBox() {
715
- const { state: e } = this.editor.view, { selection: t } = e, { ranges: n } = t, r = Math.min(...n.map((d) => d.$from.pos)), a = Math.max(...n.map((d) => d.$to.pos));
716
- if (ae(t)) {
717
- const d = this.editor.view.nodeDOM(r);
718
- if (d)
719
- return d.getBoundingClientRect();
720
+ const { state: e } = this.editor.view, { selection: o } = e, { ranges: n } = o, r = Math.min(...n.map((l) => l.$from.pos)), a = Math.max(...n.map((l) => l.$to.pos));
721
+ if (ae(o)) {
722
+ const l = this.editor.view.nodeDOM(r);
723
+ if (l)
724
+ return l.getBoundingClientRect();
720
725
  }
721
- return Z(this.editor.view, r, a);
726
+ return X(this.editor.view, r, a);
722
727
  }
723
728
  getStaticParams() {
724
729
  return {
@@ -734,18 +739,18 @@ class ze {
734
739
  toggleStrike: () => {
735
740
  this.editor.view.focus(), this.editor.commands.toggleStrike();
736
741
  },
737
- setHyperlink: (e, t) => {
742
+ setHyperlink: (e, o) => {
738
743
  if (e === "")
739
744
  return;
740
745
  let { from: n, to: r } = this.editor.state.selection;
741
- t || (t = this.editor.state.doc.textBetween(n, r));
746
+ o || (o = this.editor.state.doc.textBetween(n, r));
742
747
  const a = this.editor.schema.mark("link", { href: e });
743
748
  this.editor.view.dispatch(
744
- this.editor.view.state.tr.insertText(t, n, r).addMark(n, n + t.length, a)
749
+ this.editor.view.state.tr.insertText(o, n, r).addMark(n, n + o.length, a)
745
750
  ), this.editor.view.focus();
746
751
  },
747
- setBlockType: (e) => {
748
- this.editor.view.focus(), this.editor.commands.BNSetContentType(
752
+ updateBlock: (e) => {
753
+ this.editor.view.focus(), this.editor.commands.BNUpdateBlock(
749
754
  this.editor.state.selection.from,
750
755
  e
751
756
  );
@@ -753,6 +758,10 @@ class ze {
753
758
  };
754
759
  }
755
760
  getDynamicParams() {
761
+ const e = g(
762
+ this.editor.state.doc,
763
+ this.editor.state.selection.from
764
+ );
756
765
  return {
757
766
  boldIsActive: this.editor.isActive("bold"),
758
767
  italicIsActive: this.editor.isActive("italic"),
@@ -764,18 +773,18 @@ class ze {
764
773
  this.editor.state.selection.from,
765
774
  this.editor.state.selection.to
766
775
  ),
767
- activeBlockType: {
768
- name: this.editor.state.selection.$from.node().type.name,
769
- attrs: this.editor.state.selection.$from.node().attrs
776
+ block: {
777
+ type: e.contentType.name,
778
+ props: e.contentNode.attrs
770
779
  },
771
- selectionBoundingBox: this.getSelectionBoundingBox()
780
+ referenceRect: this.getSelectionBoundingBox()
772
781
  };
773
782
  }
774
783
  }
775
- const qe = (o) => new T({
776
- key: new v("FormattingToolbarPlugin"),
777
- view: (e) => new ze({ view: e, ...o })
778
- }), Ge = E.create({
784
+ const Ge = (t) => new M({
785
+ key: new B("FormattingToolbarPlugin"),
786
+ view: (e) => new qe({ view: e, ...t })
787
+ }), We = P.create({
779
788
  name: "FormattingToolbarExtension",
780
789
  addProseMirrorPlugins() {
781
790
  if (!this.options.formattingToolbarFactory)
@@ -783,70 +792,40 @@ const qe = (o) => new T({
783
792
  "UI Element factory not defined for FormattingToolbarExtension"
784
793
  );
785
794
  return [
786
- qe({
795
+ Ge({
787
796
  editor: this.editor,
788
797
  formattingToolbarFactory: this.options.formattingToolbarFactory,
789
- pluginKey: new v("FormattingToolbarPlugin")
798
+ pluginKey: new B("FormattingToolbarPlugin")
790
799
  })
791
800
  ];
792
801
  }
793
- });
794
- class A extends F {
795
- constructor(t, n) {
796
- super(t, n);
797
- h(this, "nodes");
798
- const r = t.node();
799
- this.nodes = [], t.doc.nodesBetween(t.pos, n.pos, (a, d, i) => {
800
- if (i !== null && i.eq(r))
801
- return this.nodes.push(a), !1;
802
- });
803
- }
804
- static create(t, n, r = n) {
805
- return new A(t.resolve(n), t.resolve(r));
806
- }
807
- content() {
808
- return new z(ee.from(this.nodes), 0, 0);
809
- }
810
- eq(t) {
811
- if (!(t instanceof A) || this.nodes.length !== t.nodes.length || this.from !== t.from || this.to !== t.to)
812
- return !1;
813
- for (let n = 0; n < this.nodes.length; n++)
814
- if (!this.nodes[n].eq(t.nodes[n]))
815
- return !1;
816
- return !0;
817
- }
818
- map(t, n) {
819
- let r = n.mapResult(this.from), a = n.mapResult(this.to);
820
- return a.deleted ? F.near(t.resolve(r.pos)) : r.deleted ? F.near(t.resolve(a.pos)) : new A(
821
- t.resolve(r.pos),
822
- t.resolve(a.pos)
823
- );
824
- }
825
- toJSON() {
826
- return { type: "node", anchor: this.anchor, head: this.head };
827
- }
828
- }
829
- const Ke = de((o) => o.type.name === "block");
830
- function We(o, e) {
802
+ }), Ke = "_bnEditor_xixap_3", Ve = "_bnRoot_xixap_13", Ye = "_dragPreview_xixap_27", U = {
803
+ bnEditor: Ke,
804
+ bnRoot: Ve,
805
+ dragPreview: Ye
806
+ }, je = le(
807
+ (t) => t.type.name === "blockContainer"
808
+ );
809
+ function Je(t, e) {
831
810
  if (!e.empty)
832
811
  return;
833
- const t = e.$anchor.nodeBefore;
834
- if (!t || !t.text)
812
+ const o = e.$anchor.nodeBefore;
813
+ if (!o || !o.text)
835
814
  return;
836
- const n = new RegExp(`${V(o)}([^${V(o)}]*)$`), r = t.text.match(n);
815
+ const n = new RegExp(`${V(t)}([^${V(t)}]*)$`), r = o.text.match(n);
837
816
  if (!!r)
838
817
  return {
839
818
  query: r[1],
840
819
  range: {
841
- from: e.$anchor.pos - r[1].length - o.length,
820
+ from: e.$anchor.pos - r[1].length - t.length,
842
821
  to: e.$anchor.pos
843
822
  }
844
823
  };
845
824
  }
846
- class Ve {
825
+ class Qe {
847
826
  constructor({
848
827
  editor: e,
849
- pluginKey: t,
828
+ pluginKey: o,
850
829
  onSelectItem: n = () => {
851
830
  },
852
831
  suggestionsMenuFactory: r
@@ -856,7 +835,7 @@ class Ve {
856
835
  h(this, "suggestionsMenu");
857
836
  h(this, "pluginState");
858
837
  h(this, "itemCallback");
859
- this.editor = e, this.pluginKey = t, this.pluginState = {
838
+ this.editor = e, this.pluginKey = o, this.pluginState = {
860
839
  active: !1,
861
840
  range: null,
862
841
  query: null,
@@ -871,9 +850,9 @@ class Ve {
871
850
  range: this.pluginState.range
872
851
  }), this.suggestionsMenu = r(this.getStaticParams());
873
852
  }
874
- update(e, t) {
875
- const n = this.pluginKey.getState(t), r = this.pluginKey.getState(e.state), a = !n.active && r.active, d = n.active && !r.active, i = n.active && r.active;
876
- !a && !i && !d || (this.pluginState = d ? n : r, d && (this.suggestionsMenu.hide(), this.suggestionsMenu.element.removeEventListener(
853
+ update(e, o) {
854
+ const n = this.pluginKey.getState(o), r = this.pluginKey.getState(e.state), a = !n.active && r.active, l = n.active && !r.active, i = n.active && r.active;
855
+ !a && !i && !l || (this.pluginState = l ? n : r, l && (this.suggestionsMenu.hide(), this.suggestionsMenu.element.removeEventListener(
877
856
  "mousedown",
878
857
  (s) => s.preventDefault()
879
858
  )), i && this.suggestionsMenu.render(this.getDynamicParams(), !1), a && (this.suggestionsMenu.render(this.getDynamicParams(), !0), this.suggestionsMenu.element.addEventListener(
@@ -893,31 +872,31 @@ class Ve {
893
872
  return {
894
873
  items: this.pluginState.items,
895
874
  selectedItemIndex: this.pluginState.selectedItemIndex,
896
- queryStartBoundingBox: e.getBoundingClientRect()
875
+ referenceRect: e.getBoundingClientRect()
897
876
  };
898
877
  }
899
878
  }
900
- function je({
901
- pluginKey: o,
879
+ function Xe({
880
+ pluginKey: t,
902
881
  editor: e,
903
- char: t,
882
+ char: o,
904
883
  suggestionsMenuFactory: n,
905
884
  onSelectItem: r = () => {
906
885
  },
907
886
  items: a = () => []
908
887
  }) {
909
- if (t.length !== 1)
888
+ if (o.length !== 1)
910
889
  throw new Error("'char' should be a single character");
911
- const d = (i) => {
912
- i.dispatch(i.state.tr.setMeta(o, { deactivate: !0 }));
890
+ const l = (i) => {
891
+ i.dispatch(i.state.tr.setMeta(t, { deactivate: !0 }));
913
892
  };
914
- return new T({
915
- key: o,
916
- view: (i) => new Ve({
893
+ return new M({
894
+ key: t,
895
+ view: (i) => new Qe({
917
896
  editor: e,
918
- pluginKey: o,
897
+ pluginKey: t,
919
898
  onSelectItem: (s) => {
920
- d(i), r(s);
899
+ l(i), r(s);
921
900
  },
922
901
  suggestionsMenuFactory: n
923
902
  }),
@@ -936,73 +915,73 @@ function je({
936
915
  },
937
916
  apply(i, s, c, p) {
938
917
  var m, f, y, b;
939
- const { selection: u } = i, l = { ...s };
940
- if (i.getMeta("orderedListIndexing") !== void 0)
941
- return l;
942
- if (((m = i.getMeta(o)) == null ? void 0 : m.selectedItemIndexChanged) !== void 0) {
943
- let g = i.getMeta(o).selectedItemIndexChanged;
944
- return g < 0 && (g = s.items.length - 1), g >= s.items.length && (g = 0), l.selectedItemIndex = g, l;
918
+ const { selection: u } = i, d = { ...s };
919
+ if (i.getMeta("numberedListIndexing") !== void 0)
920
+ return d;
921
+ if (((m = i.getMeta(t)) == null ? void 0 : m.selectedItemIndexChanged) !== void 0) {
922
+ let k = i.getMeta(t).selectedItemIndexChanged;
923
+ return k < 0 && (k = s.items.length - 1), k >= s.items.length && (k = 0), d.selectedItemIndex = k, d;
945
924
  }
946
- if (u.from === u.to && !((f = i.getMeta(o)) != null && f.deactivate) && !i.getMeta("focus") && !i.getMeta("blur") && !i.getMeta("pointer")) {
925
+ if (u.from === u.to && !((f = i.getMeta(t)) != null && f.deactivate) && !i.getMeta("focus") && !i.getMeta("blur") && !i.getMeta("pointer")) {
947
926
  if (s.active && u.from <= s.range.from)
948
- l.active = !1;
949
- else if ((y = i.getMeta(o)) != null && y.activate) {
950
- const g = `id_${Math.floor(
927
+ d.active = !1;
928
+ else if ((y = i.getMeta(t)) != null && y.activate) {
929
+ const k = `id_${Math.floor(
951
930
  Math.random() * 4294967295
952
931
  )}`;
953
- l.decorationId = g, l.range = {
932
+ d.decorationId = k, d.range = {
954
933
  from: u.from - 1,
955
934
  to: u.to
956
- }, l.query = "", l.active = !0, l.type = (b = i.getMeta(o)) == null ? void 0 : b.type, l.selectedItemIndex = 0;
935
+ }, d.query = "", d.active = !0, d.type = (b = i.getMeta(t)) == null ? void 0 : b.type, d.selectedItemIndex = 0;
957
936
  } else if (s.active) {
958
- const g = We(
959
- s.type === "slash" ? t : "",
937
+ const k = Je(
938
+ s.type === "slash" ? o : "",
960
939
  p.selection
961
940
  );
962
- if (!g)
941
+ if (!k)
963
942
  throw new Error("active but no match (suggestions)");
964
- l.range = g.range, l.active = !0, l.decorationId = s.decorationId, l.query = g.query, l.selectedItemIndex = 0;
943
+ d.range = k.range, d.active = !0, d.decorationId = s.decorationId, d.query = k.query, d.selectedItemIndex = 0;
965
944
  }
966
945
  } else
967
- l.active = !1;
968
- return l.active && (l.items = a(l.query), l.items.length ? l.notFoundCount = 0 : l.range.to > s.range.to ? l.notFoundCount = s.notFoundCount + 1 : l.notFoundCount = s.notFoundCount, l.notFoundCount > 3 && (l.active = !1)), l.active || (l.decorationId = null, l.range = null, l.query = null, l.notFoundCount = 0, l.items = []), l;
946
+ d.active = !1;
947
+ return d.active && (d.items = a(d.query), d.items.length ? d.notFoundCount = 0 : d.range.to > s.range.to ? d.notFoundCount = s.notFoundCount + 1 : d.notFoundCount = s.notFoundCount, d.notFoundCount > 3 && (d.active = !1)), d.active || (d.decorationId = null, d.range = null, d.query = null, d.notFoundCount = 0, d.items = []), d;
969
948
  }
970
949
  },
971
950
  props: {
972
951
  handleKeyDown(i, s) {
973
952
  const { active: c } = this.getState(i.state);
974
953
  if (c) {
975
- const { items: p, range: u, selectedItemIndex: l } = o.getState(
954
+ const { items: p, range: u, selectedItemIndex: d } = t.getState(
976
955
  i.state
977
956
  );
978
957
  if (s.key === "ArrowUp")
979
958
  return i.dispatch(
980
- i.state.tr.setMeta(o, {
981
- selectedItemIndexChanged: l - 1
959
+ i.state.tr.setMeta(t, {
960
+ selectedItemIndexChanged: d - 1
982
961
  })
983
962
  ), !0;
984
963
  if (s.key === "ArrowDown")
985
964
  return i.dispatch(
986
- i.state.tr.setMeta(o, {
987
- selectedItemIndexChanged: l + 1
965
+ i.state.tr.setMeta(t, {
966
+ selectedItemIndexChanged: d + 1
988
967
  })
989
968
  ), !0;
990
969
  if (s.key === "Enter")
991
- return d(i), r({
992
- item: p[l],
970
+ return l(i), r({
971
+ item: p[d],
993
972
  editor: e,
994
973
  range: u
995
974
  }), !0;
996
975
  if (s.key === "Escape")
997
- return d(i), !0;
998
- } else if (s.key === t)
976
+ return l(i), !0;
977
+ } else if (s.key === o)
999
978
  return i.dispatch(
1000
- i.state.tr.insertText(t).scrollIntoView().setMeta(o, { activate: !0, type: "slash" })
979
+ i.state.tr.insertText(o).scrollIntoView().setMeta(t, { activate: !0, type: "slash" })
1001
980
  ), !0;
1002
981
  return !1;
1003
982
  },
1004
983
  handleClick(i) {
1005
- d(i);
984
+ l(i);
1006
985
  },
1007
986
  decorations(i) {
1008
987
  const { active: s, range: c, decorationId: p, type: u } = this.getState(
@@ -1011,12 +990,12 @@ function je({
1011
990
  if (!s)
1012
991
  return null;
1013
992
  if (u === "drag") {
1014
- const l = Ke(i.selection);
1015
- if (l)
993
+ const d = je(i.selection);
994
+ if (d)
1016
995
  return O.create(i.doc, [
1017
996
  L.node(
1018
- l.pos,
1019
- l.pos + l.node.nodeSize,
997
+ d.pos,
998
+ d.pos + d.node.nodeSize,
1020
999
  {
1021
1000
  nodeName: "span",
1022
1001
  class: "suggestion-decorator",
@@ -1036,101 +1015,100 @@ function je({
1036
1015
  }
1037
1016
  });
1038
1017
  }
1039
- const Ye = () => /Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
1040
- function S(o) {
1041
- return Ye() ? o.replace("Mod", "\u2318") : o.replace("Mod", "Ctrl");
1018
+ const Ze = () => /Mac/.test(navigator.platform) || /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
1019
+ function E(t) {
1020
+ return Ze() ? t.replace("Mod", "\u2318") : t.replace("Mod", "Ctrl");
1042
1021
  }
1043
- var B = /* @__PURE__ */ ((o) => (o.HEADINGS = "Headings", o.BASIC_BLOCKS = "Basic Blocks", o.CODE = "Code Blocks", o.INLINE = "Inline", o.EMBED = "Embed", o.PLUGIN = "Plugin", o))(B || {});
1022
+ var w = /* @__PURE__ */ ((t) => (t.HEADINGS = "Headings", t.BASIC_BLOCKS = "Basic Blocks", t.CODE = "Code Blocks", t.INLINE = "Inline", t.EMBED = "Embed", t.PLUGIN = "Plugin", t))(w || {});
1044
1023
  class x {
1045
- constructor(e, t, n, r = [], a, d) {
1024
+ constructor(e, o, n, r = [], a, l) {
1046
1025
  h(this, "groupName");
1047
- this.name = e, this.group = t, this.execute = n, this.aliases = r, this.hint = a, this.shortcut = d, this.groupName = t;
1026
+ this.name = e, this.group = o, this.execute = n, this.aliases = r, this.hint = a, this.shortcut = l, this.groupName = o;
1048
1027
  }
1049
1028
  match(e) {
1050
1029
  return this.name.toLowerCase().startsWith(e.toLowerCase()) || this.aliases.filter(
1051
- (t) => t.toLowerCase().startsWith(e.toLowerCase())
1030
+ (o) => o.toLowerCase().startsWith(e.toLowerCase())
1052
1031
  ).length !== 0;
1053
1032
  }
1054
1033
  }
1055
- const Je = {
1034
+ const et = {
1056
1035
  heading: new x(
1057
1036
  "Heading",
1058
- B.HEADINGS,
1059
- (o, e) => o.chain().focus().deleteRange(e).BNCreateBlockOrSetContentType(e.from, {
1060
- name: "headingContent",
1061
- attrs: {
1062
- headingLevel: "1"
1037
+ w.HEADINGS,
1038
+ (t, e) => t.chain().focus().deleteRange(e).BNCreateOrUpdateBlock(e.from, {
1039
+ type: "heading",
1040
+ props: {
1041
+ level: "1"
1063
1042
  }
1064
1043
  }).run(),
1065
1044
  ["h", "heading1", "h1"],
1066
1045
  "Used for a top-level heading",
1067
- S("Mod-Alt-1")
1046
+ E("Mod-Alt-1")
1068
1047
  ),
1069
1048
  heading2: new x(
1070
1049
  "Heading 2",
1071
- B.HEADINGS,
1072
- (o, e) => o.chain().focus().deleteRange(e).BNCreateBlockOrSetContentType(e.from, {
1073
- name: "headingContent",
1074
- attrs: {
1075
- headingLevel: "2"
1050
+ w.HEADINGS,
1051
+ (t, e) => t.chain().focus().deleteRange(e).BNCreateOrUpdateBlock(e.from, {
1052
+ type: "heading",
1053
+ props: {
1054
+ level: "2"
1076
1055
  }
1077
1056
  }).run(),
1078
1057
  ["h2", "heading2", "subheading"],
1079
1058
  "Used for key sections",
1080
- S("Mod-Alt-2")
1059
+ E("Mod-Alt-2")
1081
1060
  ),
1082
1061
  heading3: new x(
1083
1062
  "Heading 3",
1084
- B.HEADINGS,
1085
- (o, e) => o.chain().focus().deleteRange(e).BNCreateBlockOrSetContentType(e.from, {
1086
- name: "headingContent",
1087
- attrs: {
1088
- headingLevel: "3"
1063
+ w.HEADINGS,
1064
+ (t, e) => t.chain().focus().deleteRange(e).BNCreateOrUpdateBlock(e.from, {
1065
+ type: "heading",
1066
+ props: {
1067
+ level: "3"
1089
1068
  }
1090
1069
  }).run(),
1091
1070
  ["h3", "heading3", "subheading"],
1092
1071
  "Used for subsections and group headings",
1093
- S("Mod-Alt-3")
1072
+ E("Mod-Alt-3")
1094
1073
  ),
1095
1074
  numberedList: new x(
1096
1075
  "Numbered List",
1097
- B.BASIC_BLOCKS,
1098
- (o, e) => o.chain().focus().deleteRange(e).BNCreateBlockOrSetContentType(e.from, {
1099
- name: "listItemContent",
1100
- attrs: {
1101
- listItemType: "ordered"
1102
- }
1076
+ w.BASIC_BLOCKS,
1077
+ (t, e) => t.chain().focus().deleteRange(e).BNCreateOrUpdateBlock(e.from, {
1078
+ type: "numberedListItem",
1079
+ props: {}
1103
1080
  }).run(),
1104
1081
  ["li", "list", "numberedlist", "numbered list"],
1105
1082
  "Used to display a numbered list",
1106
- S("Mod-Shift-7")
1083
+ E("Mod-Shift-7")
1107
1084
  ),
1108
1085
  bulletList: new x(
1109
1086
  "Bullet List",
1110
- B.BASIC_BLOCKS,
1111
- (o, e) => o.chain().focus().deleteRange(e).BNCreateBlockOrSetContentType(e.from, {
1112
- name: "listItemContent",
1113
- attrs: {
1114
- listItemType: "unordered"
1115
- }
1087
+ w.BASIC_BLOCKS,
1088
+ (t, e) => t.chain().focus().deleteRange(e).BNCreateOrUpdateBlock(e.from, {
1089
+ type: "bulletListItem",
1090
+ props: {}
1116
1091
  }).run(),
1117
1092
  ["ul", "list", "bulletlist", "bullet list"],
1118
1093
  "Used to display an unordered list",
1119
- S("Mod-Shift-8")
1094
+ E("Mod-Shift-8")
1120
1095
  ),
1121
1096
  paragraph: new x(
1122
1097
  "Paragraph",
1123
- B.BASIC_BLOCKS,
1124
- (o, e) => o.chain().focus().deleteRange(e).BNCreateBlockOrSetContentType(e.from, { name: "textContent" }).run(),
1098
+ w.BASIC_BLOCKS,
1099
+ (t, e) => t.chain().focus().deleteRange(e).BNCreateOrUpdateBlock(e.from, {
1100
+ type: "paragraph",
1101
+ props: {}
1102
+ }).run(),
1125
1103
  ["p"],
1126
1104
  "Used for the body of your document",
1127
- S("Mod-Alt-0")
1105
+ E("Mod-Alt-0")
1128
1106
  )
1129
- }, q = new v("suggestions-slash-commands"), Qe = E.create({
1107
+ }, q = new B("suggestions-slash-commands"), tt = P.create({
1130
1108
  name: "slash-command",
1131
1109
  addOptions() {
1132
1110
  return {
1133
- commands: Je,
1111
+ commands: et,
1134
1112
  slashMenuFactory: void 0
1135
1113
  };
1136
1114
  },
@@ -1138,58 +1116,90 @@ const Je = {
1138
1116
  if (!this.options.slashMenuFactory)
1139
1117
  throw new Error("UI Element factory not defined for SlashMenuExtension");
1140
1118
  return [
1141
- je({
1119
+ Xe({
1142
1120
  pluginKey: q,
1143
1121
  editor: this.editor,
1144
1122
  char: "/",
1145
1123
  suggestionsMenuFactory: this.options.slashMenuFactory,
1146
- items: (o) => {
1124
+ items: (t) => {
1147
1125
  const e = [];
1148
- for (const t in this.options.commands)
1149
- e.push(this.options.commands[t]);
1150
- return e.filter((t) => t.match(o));
1126
+ for (const o in this.options.commands)
1127
+ e.push(this.options.commands[o]);
1128
+ return e.filter((o) => o.match(t));
1151
1129
  },
1152
- onSelectItem: ({ item: o, editor: e, range: t }) => {
1153
- o.execute(e, t);
1130
+ onSelectItem: ({ item: t, editor: e, range: o }) => {
1131
+ t.execute(e, o);
1154
1132
  }
1155
1133
  })
1156
1134
  ];
1157
1135
  }
1158
- }), Xe = "_bnEditor_xixap_3", Ze = "_bnRoot_xixap_13", et = "_dragPreview_xixap_27", $ = {
1159
- bnEditor: Xe,
1160
- bnRoot: Ze,
1161
- dragPreview: et
1162
- }, tt = Te.__serializeForClipboard;
1163
- let D, M;
1164
- function ot() {
1165
- if (!D) {
1166
- const o = document.querySelector(
1136
+ });
1137
+ class A extends F {
1138
+ constructor(o, n) {
1139
+ super(o, n);
1140
+ h(this, "nodes");
1141
+ const r = o.node();
1142
+ this.nodes = [], o.doc.nodesBetween(o.pos, n.pos, (a, l, i) => {
1143
+ if (i !== null && i.eq(r))
1144
+ return this.nodes.push(a), !1;
1145
+ });
1146
+ }
1147
+ static create(o, n, r = n) {
1148
+ return new A(o.resolve(n), o.resolve(r));
1149
+ }
1150
+ content() {
1151
+ return new z(Z.from(this.nodes), 0, 0);
1152
+ }
1153
+ eq(o) {
1154
+ if (!(o instanceof A) || this.nodes.length !== o.nodes.length || this.from !== o.from || this.to !== o.to)
1155
+ return !1;
1156
+ for (let n = 0; n < this.nodes.length; n++)
1157
+ if (!this.nodes[n].eq(o.nodes[n]))
1158
+ return !1;
1159
+ return !0;
1160
+ }
1161
+ map(o, n) {
1162
+ let r = n.mapResult(this.from), a = n.mapResult(this.to);
1163
+ return a.deleted ? F.near(o.resolve(r.pos)) : r.deleted ? F.near(o.resolve(a.pos)) : new A(
1164
+ o.resolve(r.pos),
1165
+ o.resolve(a.pos)
1166
+ );
1167
+ }
1168
+ toJSON() {
1169
+ return { type: "node", anchor: this.anchor, head: this.head };
1170
+ }
1171
+ }
1172
+ const ot = Me.__serializeForClipboard;
1173
+ let _, I;
1174
+ function nt() {
1175
+ if (!_) {
1176
+ const t = document.querySelector(
1167
1177
  ".ProseMirror > [class*='blockGroup']"
1168
1178
  );
1169
- o && (D = rt(o).left);
1179
+ t && (_ = it(t).left);
1170
1180
  }
1171
- return D;
1181
+ return _;
1172
1182
  }
1173
- function nt(o) {
1183
+ function rt(t) {
1174
1184
  let e = {
1175
- left: o.left + document.body.scrollLeft,
1176
- top: o.top + document.body.scrollTop,
1177
- width: o.width,
1178
- height: o.height,
1185
+ left: t.left + document.body.scrollLeft,
1186
+ top: t.top + document.body.scrollTop,
1187
+ width: t.width,
1188
+ height: t.height,
1179
1189
  bottom: 0,
1180
1190
  right: 0
1181
1191
  };
1182
1192
  return e.bottom = e.top + e.height, e.right = e.left + e.width, e;
1183
1193
  }
1184
- function rt(o) {
1185
- return nt(o.getBoundingClientRect());
1194
+ function it(t) {
1195
+ return rt(t.getBoundingClientRect());
1186
1196
  }
1187
- function oe(o, e) {
1197
+ function oe(t, e) {
1188
1198
  var r;
1189
- let t = e.posAtCoords(o);
1190
- if (!t)
1199
+ let o = e.posAtCoords(t);
1200
+ if (!o)
1191
1201
  return;
1192
- let n = e.domAtPos(t.pos).node;
1202
+ let n = e.domAtPos(o.pos).node;
1193
1203
  if (n !== e.dom) {
1194
1204
  for (; n && n.parentNode && n.parentNode !== e.dom && !((r = n.hasAttribute) != null && r.call(n, "data-id")); )
1195
1205
  n = n.parentNode;
@@ -1197,63 +1207,63 @@ function oe(o, e) {
1197
1207
  return { node: n, id: n.getAttribute("data-id") };
1198
1208
  }
1199
1209
  }
1200
- function it(o, e) {
1201
- let t = oe(o, e);
1202
- if (t && t.node.nodeType === 1) {
1210
+ function st(t, e) {
1211
+ let o = oe(t, e);
1212
+ if (o && o.node.nodeType === 1) {
1203
1213
  const n = e.docView;
1204
- let r = n.nearestDesc(t.node, !0);
1214
+ let r = n.nearestDesc(o.node, !0);
1205
1215
  return !r || r === n ? null : r.posBefore;
1206
1216
  }
1207
1217
  return null;
1208
1218
  }
1209
- function st(o, e) {
1210
- let t, n;
1211
- const r = e.resolve(o.from).node().type.spec.group === "blockContent", a = e.resolve(o.to).node().type.spec.group === "blockContent", d = Math.min(o.$anchor.depth, o.$head.depth);
1219
+ function at(t, e) {
1220
+ let o, n;
1221
+ const r = e.resolve(t.from).node().type.spec.group === "blockContent", a = e.resolve(t.to).node().type.spec.group === "blockContent", l = Math.min(t.$anchor.depth, t.$head.depth);
1212
1222
  if (r && a) {
1213
- const i = o.$from.start(d - 1), s = o.$to.end(d - 1);
1214
- t = e.resolve(i - 1).pos, n = e.resolve(s + 1).pos;
1223
+ const i = t.$from.start(l - 1), s = t.$to.end(l - 1);
1224
+ o = e.resolve(i - 1).pos, n = e.resolve(s + 1).pos;
1215
1225
  } else
1216
- t = o.from, n = o.to;
1217
- return { from: t, to: n };
1226
+ o = t.from, n = t.to;
1227
+ return { from: o, to: n };
1218
1228
  }
1219
- function J(o, e, t = e) {
1220
- e === t && (t += o.state.doc.resolve(e + 1).node().nodeSize);
1221
- const n = o.domAtPos(e).node.cloneNode(!0), r = o.domAtPos(e).node, a = (s, c) => Array.prototype.indexOf.call(s.children, c), d = a(
1229
+ function j(t, e, o = e) {
1230
+ e === o && (o += t.state.doc.resolve(e + 1).node().nodeSize);
1231
+ const n = t.domAtPos(e).node.cloneNode(!0), r = t.domAtPos(e).node, a = (s, c) => Array.prototype.indexOf.call(s.children, c), l = a(
1222
1232
  r,
1223
- o.domAtPos(e + 1).node.parentElement
1233
+ t.domAtPos(e + 1).node.parentElement
1224
1234
  ), i = a(
1225
1235
  r,
1226
- o.domAtPos(t - 1).node.parentElement
1236
+ t.domAtPos(o - 1).node.parentElement
1227
1237
  );
1228
1238
  for (let s = r.childElementCount - 1; s >= 0; s--)
1229
- (s > i || s < d) && n.removeChild(n.children[s]);
1230
- M = n, M.className = $.dragPreview, document.body.appendChild(M);
1239
+ (s > i || s < l) && n.removeChild(n.children[s]);
1240
+ I = n, I.className = U.dragPreview, document.body.appendChild(I);
1231
1241
  }
1232
- function at() {
1233
- M !== void 0 && (document.body.removeChild(M), M = void 0);
1242
+ function lt() {
1243
+ I !== void 0 && (document.body.removeChild(I), I = void 0);
1234
1244
  }
1235
- function dt(o, e) {
1236
- if (!o.dataTransfer)
1245
+ function dt(t, e) {
1246
+ if (!t.dataTransfer)
1237
1247
  return;
1238
- let t = {
1248
+ let o = {
1239
1249
  left: e.dom.clientWidth / 2,
1240
- top: o.clientY
1241
- }, n = it(t, e);
1250
+ top: t.clientY
1251
+ }, n = st(o, e);
1242
1252
  if (n != null) {
1243
- const r = e.state.selection, a = e.state.doc, { from: d, to: i } = st(r, a), s = d <= n && n < i, c = !r.$anchor.node().eq(r.$head.node());
1253
+ const r = e.state.selection, a = e.state.doc, { from: l, to: i } = at(r, a), s = l <= n && n < i, c = !r.$anchor.node().eq(r.$head.node());
1244
1254
  s && c ? (e.dispatch(
1245
- e.state.tr.setSelection(A.create(a, d, i))
1246
- ), J(e, d, i)) : (e.dispatch(
1247
- e.state.tr.setSelection(Ie.create(e.state.doc, n))
1248
- ), J(e, n));
1249
- let p = e.state.selection.content(), { dom: u, text: l } = tt(e, p);
1250
- o.dataTransfer.clearData(), o.dataTransfer.setData("text/html", u.innerHTML), o.dataTransfer.setData("text/plain", l), o.dataTransfer.effectAllowed = "move", o.dataTransfer.setDragImage(M, 0, 0), e.dragging = { slice: p, move: !0 };
1255
+ e.state.tr.setSelection(A.create(a, l, i))
1256
+ ), j(e, l, i)) : (e.dispatch(
1257
+ e.state.tr.setSelection(Be.create(e.state.doc, n))
1258
+ ), j(e, n));
1259
+ let p = e.state.selection.content(), { dom: u, text: d } = ot(e, p);
1260
+ t.dataTransfer.clearData(), t.dataTransfer.setData("text/html", u.innerHTML), t.dataTransfer.setData("text/plain", d), t.dataTransfer.effectAllowed = "move", t.dataTransfer.setDragImage(I, 0, 0), e.dragging = { slice: p, move: !0 };
1251
1261
  }
1252
1262
  }
1253
- class lt {
1263
+ class ct {
1254
1264
  constructor({
1255
1265
  editor: e,
1256
- blockMenuFactory: t,
1266
+ blockMenuFactory: o,
1257
1267
  horizontalPosAnchoredAtRoot: n
1258
1268
  }) {
1259
1269
  h(this, "editor");
@@ -1262,7 +1272,7 @@ class lt {
1262
1272
  h(this, "hoveredBlock");
1263
1273
  h(this, "menuOpen", !1);
1264
1274
  h(this, "menuFrozen", !1);
1265
- this.editor = e, this.horizontalPosAnchoredAtRoot = n, this.blockMenu = t(this.getStaticParams()), document.body.addEventListener(
1275
+ this.editor = e, this.horizontalPosAnchoredAtRoot = n, this.blockMenu = o(this.getStaticParams()), document.body.addEventListener(
1266
1276
  "mousemove",
1267
1277
  (r) => {
1268
1278
  var s, c;
@@ -1271,14 +1281,14 @@ class lt {
1271
1281
  const a = {
1272
1282
  left: this.editor.view.dom.clientWidth / 2,
1273
1283
  top: r.clientY
1274
- }, d = oe(a, this.editor.view);
1275
- if (!d) {
1284
+ }, l = oe(a, this.editor.view);
1285
+ if (!l) {
1276
1286
  this.menuOpen && (this.menuOpen = !1, this.blockMenu.hide());
1277
1287
  return;
1278
1288
  }
1279
- if (this.menuOpen && ((s = this.hoveredBlock) == null ? void 0 : s.hasAttribute("data-id")) && ((c = this.hoveredBlock) == null ? void 0 : c.getAttribute("data-id")) === d.id)
1289
+ if (this.menuOpen && ((s = this.hoveredBlock) == null ? void 0 : s.hasAttribute("data-id")) && ((c = this.hoveredBlock) == null ? void 0 : c.getAttribute("data-id")) === l.id)
1280
1290
  return;
1281
- const i = d.node.firstChild;
1291
+ const i = l.node.firstChild;
1282
1292
  this.hoveredBlock = i, i && (this.menuOpen ? this.blockMenu.render(this.getDynamicParams(), !1) : (this.menuOpen = !0, this.blockMenu.render(this.getDynamicParams(), !0)));
1283
1293
  },
1284
1294
  !0
@@ -1302,19 +1312,19 @@ class lt {
1302
1312
  }
1303
1313
  addBlock() {
1304
1314
  this.menuOpen = !1, this.menuFrozen = !0, this.blockMenu.hide();
1305
- const e = this.hoveredBlock.getBoundingClientRect(), t = this.editor.view.posAtCoords({
1315
+ const e = this.hoveredBlock.getBoundingClientRect(), o = this.editor.view.posAtCoords({
1306
1316
  left: e.left,
1307
1317
  top: e.top
1308
1318
  });
1309
- if (!t)
1319
+ if (!o)
1310
1320
  return;
1311
- const n = k(this.editor.state.doc, t.pos);
1321
+ const n = g(this.editor.state.doc, o.pos);
1312
1322
  if (n === void 0)
1313
1323
  return;
1314
1324
  const { contentNode: r, endPos: a } = n;
1315
1325
  if (r.textContent.length !== 0) {
1316
- const d = a + 1, i = d + 2;
1317
- this.editor.chain().BNCreateBlock(d).BNSetContentType(i, { name: "textContent" }).setTextSelection(i).run();
1326
+ const l = a + 1, i = l + 2;
1327
+ this.editor.chain().BNCreateBlock(l).BNUpdateBlock(i, { type: "paragraph", props: {} }).setTextSelection(i).run();
1318
1328
  }
1319
1329
  this.editor.view.focus(), this.editor.view.dispatch(
1320
1330
  this.editor.view.state.tr.scrollIntoView().setMeta(q, {
@@ -1325,18 +1335,18 @@ class lt {
1325
1335
  }
1326
1336
  deleteBlock() {
1327
1337
  this.menuOpen = !1, this.blockMenu.hide();
1328
- const e = this.hoveredBlock.getBoundingClientRect(), t = this.editor.view.posAtCoords({
1338
+ const e = this.hoveredBlock.getBoundingClientRect(), o = this.editor.view.posAtCoords({
1329
1339
  left: e.left,
1330
1340
  top: e.top
1331
1341
  });
1332
- !t || this.editor.commands.BNDeleteBlock(t.pos);
1342
+ !o || this.editor.commands.BNDeleteBlock(o.pos);
1333
1343
  }
1334
1344
  getStaticParams() {
1335
1345
  return {
1336
1346
  addBlock: () => this.addBlock(),
1337
1347
  deleteBlock: () => this.deleteBlock(),
1338
1348
  blockDragStart: (e) => dt(e, this.editor.view),
1339
- blockDragEnd: () => at(),
1349
+ blockDragEnd: () => lt(),
1340
1350
  freezeMenu: () => {
1341
1351
  this.menuFrozen = !0;
1342
1352
  },
@@ -1348,8 +1358,8 @@ class lt {
1348
1358
  getDynamicParams() {
1349
1359
  const e = this.hoveredBlock.getBoundingClientRect();
1350
1360
  return {
1351
- blockBoundingBox: new DOMRect(
1352
- this.horizontalPosAnchoredAtRoot ? ot() : e.x,
1361
+ referenceRect: new DOMRect(
1362
+ this.horizontalPosAnchoredAtRoot ? nt() : e.x,
1353
1363
  e.y,
1354
1364
  e.width,
1355
1365
  e.height
@@ -1357,14 +1367,14 @@ class lt {
1357
1367
  };
1358
1368
  }
1359
1369
  }
1360
- const ct = (o) => new T({
1361
- key: new v("DraggableBlocksPlugin"),
1362
- view: () => new lt({
1363
- editor: o.editor,
1364
- blockMenuFactory: o.blockSideMenuFactory,
1370
+ const ut = (t) => new M({
1371
+ key: new B("DraggableBlocksPlugin"),
1372
+ view: () => new ct({
1373
+ editor: t.editor,
1374
+ blockMenuFactory: t.blockSideMenuFactory,
1365
1375
  horizontalPosAnchoredAtRoot: !0
1366
1376
  })
1367
- }), ut = E.create({
1377
+ }), ht = P.create({
1368
1378
  name: "DraggableBlocksExtension",
1369
1379
  priority: 1e3,
1370
1380
  addProseMirrorPlugins() {
@@ -1373,15 +1383,15 @@ const ct = (o) => new T({
1373
1383
  "UI Element factory not defined for DraggableBlocksExtension"
1374
1384
  );
1375
1385
  return [
1376
- ct({
1386
+ ut({
1377
1387
  editor: this.editor,
1378
1388
  blockSideMenuFactory: this.options.blockSideMenuFactory
1379
1389
  })
1380
1390
  ];
1381
1391
  }
1382
- }), ht = new v("HyperlinkToolbarPlugin");
1383
- class pt {
1384
- constructor({ editor: e, hyperlinkToolbarFactory: t }) {
1392
+ }), pt = new B("HyperlinkToolbarPlugin");
1393
+ class mt {
1394
+ constructor({ editor: e, hyperlinkToolbarFactory: o }) {
1385
1395
  h(this, "editor");
1386
1396
  h(this, "hyperlinkToolbar");
1387
1397
  h(this, "menuUpdateTimer");
@@ -1393,19 +1403,19 @@ class pt {
1393
1403
  h(this, "keyboardHoveredHyperlinkMarkRange");
1394
1404
  h(this, "hyperlinkMark");
1395
1405
  h(this, "hyperlinkMarkRange");
1396
- this.editor = e, this.hyperlinkToolbar = t(this.getStaticParams()), this.startMenuUpdateTimer = () => {
1406
+ this.editor = e, this.hyperlinkToolbar = o(this.getStaticParams()), this.startMenuUpdateTimer = () => {
1397
1407
  this.menuUpdateTimer = setTimeout(() => {
1398
1408
  this.update();
1399
1409
  }, 250);
1400
1410
  }, this.stopMenuUpdateTimer = () => (this.menuUpdateTimer && (clearTimeout(this.menuUpdateTimer), this.menuUpdateTimer = void 0), !1), e.view.dom.addEventListener("mouseover", (n) => {
1401
1411
  if (this.mouseHoveredHyperlinkMark = void 0, this.mouseHoveredHyperlinkMarkRange = void 0, this.stopMenuUpdateTimer(), n.target instanceof HTMLAnchorElement && n.target.nodeName === "A") {
1402
- const r = n.target, a = e.view.posAtDOM(r, 0) + 1, d = e.state.doc.resolve(
1412
+ const r = n.target, a = e.view.posAtDOM(r, 0) + 1, l = e.state.doc.resolve(
1403
1413
  a
1404
- ), i = d.marks();
1414
+ ), i = l.marks();
1405
1415
  for (const s of i)
1406
1416
  if (s.type.name === e.schema.mark("link").type.name) {
1407
- this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange = K(
1408
- d,
1417
+ this.mouseHoveredHyperlinkMark = s, this.mouseHoveredHyperlinkMarkRange = W(
1418
+ l,
1409
1419
  s.type,
1410
1420
  s.attrs
1411
1421
  ) || void 0;
@@ -1416,15 +1426,15 @@ class pt {
1416
1426
  });
1417
1427
  }
1418
1428
  update() {
1419
- var t, n, r, a;
1429
+ var o, n, r, a;
1420
1430
  if (!this.editor.view.hasFocus())
1421
1431
  return;
1422
1432
  const e = this.hyperlinkMark;
1423
1433
  if (this.hyperlinkMark = void 0, this.hyperlinkMarkRange = void 0, this.keyboardHoveredHyperlinkMark = void 0, this.keyboardHoveredHyperlinkMarkRange = void 0, this.editor.state.selection.empty) {
1424
- const d = this.editor.state.selection.$from.marks();
1425
- for (const i of d)
1434
+ const l = this.editor.state.selection.$from.marks();
1435
+ for (const i of l)
1426
1436
  if (i.type.name === this.editor.schema.mark("link").type.name) {
1427
- this.keyboardHoveredHyperlinkMark = i, this.keyboardHoveredHyperlinkMarkRange = K(
1437
+ this.keyboardHoveredHyperlinkMark = i, this.keyboardHoveredHyperlinkMarkRange = W(
1428
1438
  this.editor.state.selection.$from,
1429
1439
  i.type,
1430
1440
  i.attrs
@@ -1434,7 +1444,7 @@ class pt {
1434
1444
  }
1435
1445
  if (this.mouseHoveredHyperlinkMark && (this.hyperlinkMark = this.mouseHoveredHyperlinkMark, this.hyperlinkMarkRange = this.mouseHoveredHyperlinkMarkRange), this.keyboardHoveredHyperlinkMark && (this.hyperlinkMark = this.keyboardHoveredHyperlinkMark, this.hyperlinkMarkRange = this.keyboardHoveredHyperlinkMarkRange), this.hyperlinkMark) {
1436
1446
  if (this.getDynamicParams(), !e) {
1437
- this.hyperlinkToolbar.render(this.getDynamicParams(), !0), (t = this.hyperlinkToolbar.element) == null || t.addEventListener(
1447
+ this.hyperlinkToolbar.render(this.getDynamicParams(), !0), (o = this.hyperlinkToolbar.element) == null || o.addEventListener(
1438
1448
  "mouseleave",
1439
1449
  this.startMenuUpdateTimer
1440
1450
  ), (n = this.hyperlinkToolbar.element) == null || n.addEventListener(
@@ -1444,6 +1454,7 @@ class pt {
1444
1454
  return;
1445
1455
  }
1446
1456
  this.hyperlinkToolbar.render(this.getDynamicParams(), !1);
1457
+ return;
1447
1458
  }
1448
1459
  if (!this.hyperlinkMark && e) {
1449
1460
  (r = this.hyperlinkToolbar.element) == null || r.removeEventListener(
@@ -1458,15 +1469,15 @@ class pt {
1458
1469
  }
1459
1470
  getStaticParams() {
1460
1471
  return {
1461
- editHyperlink: (e, t) => {
1472
+ editHyperlink: (e, o) => {
1462
1473
  const n = this.editor.view.state.tr.insertText(
1463
- t,
1474
+ o,
1464
1475
  this.hyperlinkMarkRange.from,
1465
1476
  this.hyperlinkMarkRange.to
1466
1477
  );
1467
1478
  n.addMark(
1468
1479
  this.hyperlinkMarkRange.from,
1469
- this.hyperlinkMarkRange.from + t.length,
1480
+ this.hyperlinkMarkRange.from + o.length,
1470
1481
  this.editor.schema.mark("link", { href: e })
1471
1482
  ), this.editor.view.dispatch(n), this.editor.view.focus(), this.hyperlinkToolbar.hide();
1472
1483
  },
@@ -1488,7 +1499,7 @@ class pt {
1488
1499
  this.hyperlinkMarkRange.from,
1489
1500
  this.hyperlinkMarkRange.to
1490
1501
  ),
1491
- boundingBox: Z(
1502
+ referenceRect: X(
1492
1503
  this.editor.view,
1493
1504
  this.hyperlinkMarkRange.from,
1494
1505
  this.hyperlinkMarkRange.to
@@ -1496,30 +1507,26 @@ class pt {
1496
1507
  };
1497
1508
  }
1498
1509
  }
1499
- const mt = (o, e) => new T({
1500
- key: ht,
1501
- view: () => new pt({
1502
- editor: o,
1510
+ const ft = (t, e) => new M({
1511
+ key: pt,
1512
+ view: () => new mt({
1513
+ editor: t,
1503
1514
  hyperlinkToolbarFactory: e.hyperlinkToolbarFactory
1504
1515
  })
1505
- }), ft = te.extend({
1516
+ }), kt = ee.extend({
1506
1517
  priority: 500,
1507
1518
  addProseMirrorPlugins() {
1508
- var o;
1519
+ var t;
1509
1520
  if (!this.options.hyperlinkToolbarFactory)
1510
1521
  throw new Error("UI Element factory not defined for HyperlinkMark");
1511
1522
  return [
1512
- ...((o = this.parent) == null ? void 0 : o.call(this)) || [],
1513
- mt(this.editor, {
1523
+ ...((t = this.parent) == null ? void 0 : t.call(this)) || [],
1524
+ ft(this.editor, {
1514
1525
  hyperlinkToolbarFactory: this.options.hyperlinkToolbarFactory
1515
1526
  })
1516
1527
  ];
1517
1528
  }
1518
- }), gt = Ce.extend({
1519
- addKeyboardShortcuts: () => ({
1520
- "Mod-Alt-0": () => !1
1521
- })
1522
- }), kt = new v("blocknote-placeholder"), yt = E.create({
1529
+ }), gt = new B("blocknote-placeholder"), yt = P.create({
1523
1530
  name: "placeholder",
1524
1531
  addOptions() {
1525
1532
  return {
@@ -1535,38 +1542,38 @@ const mt = (o, e) => new T({
1535
1542
  },
1536
1543
  addProseMirrorPlugins() {
1537
1544
  return [
1538
- new T({
1539
- key: kt,
1545
+ new M({
1546
+ key: gt,
1540
1547
  props: {
1541
- decorations: (o) => {
1542
- const { doc: e, selection: t } = o, n = q.getState(o), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: a } = t, d = [];
1548
+ decorations: (t) => {
1549
+ const { doc: e, selection: o } = t, n = q.getState(t), r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: a } = o, l = [];
1543
1550
  if (!!r)
1544
1551
  return e.descendants((i, s) => {
1545
1552
  const c = a >= s && a <= s + i.nodeSize, p = !i.isLeaf && !i.childCount;
1546
1553
  if ((c || !this.options.showOnlyCurrent) && p) {
1547
1554
  const u = [this.options.emptyNodeClass];
1548
1555
  this.editor.isEmpty && u.push(this.options.emptyEditorClass), c && u.push(this.options.hasAnchorClass), (n == null ? void 0 : n.type) === "drag" && (n == null ? void 0 : n.active) && u.push(this.options.isFilterClass);
1549
- const l = L.node(s, s + i.nodeSize, {
1556
+ const d = L.node(s, s + i.nodeSize, {
1550
1557
  class: u.join(" ")
1551
1558
  });
1552
- d.push(l);
1559
+ l.push(d);
1553
1560
  }
1554
1561
  return this.options.includeChildren;
1555
- }), O.create(e, d);
1562
+ }), O.create(e, l);
1556
1563
  }
1557
1564
  }
1558
1565
  })
1559
1566
  ];
1560
1567
  }
1561
- }), bt = E.create({
1568
+ }), bt = P.create({
1562
1569
  name: "trailingNode",
1563
1570
  addProseMirrorPlugins() {
1564
- const o = new v(this.name);
1571
+ const t = new B(this.name);
1565
1572
  return [
1566
- new T({
1567
- key: o,
1568
- appendTransaction: (e, t, n) => {
1569
- const { doc: r, tr: a, schema: d } = n, i = o.getState(n), s = r.content.size - 2, c = d.nodes.block, p = d.nodes.textContent;
1573
+ new M({
1574
+ key: t,
1575
+ appendTransaction: (e, o, n) => {
1576
+ const { doc: r, tr: a, schema: l } = n, i = t.getState(n), s = r.content.size - 2, c = l.nodes.blockContainer, p = l.nodes.paragraph;
1570
1577
  if (!!i)
1571
1578
  return a.insert(
1572
1579
  s,
@@ -1574,16 +1581,16 @@ const mt = (o, e) => new T({
1574
1581
  );
1575
1582
  },
1576
1583
  state: {
1577
- init: (e, t) => {
1584
+ init: (e, o) => {
1578
1585
  },
1579
- apply: (e, t) => {
1586
+ apply: (e, o) => {
1580
1587
  if (!e.docChanged)
1581
- return t;
1588
+ return o;
1582
1589
  let n = e.doc.lastChild;
1583
1590
  if (!n || n.type.name !== "blockGroup")
1584
1591
  throw new Error("Expected blockGroup");
1585
- if (n = n.lastChild, !n || n.type.name !== "block")
1586
- throw new Error("Expected block");
1592
+ if (n = n.lastChild, !n || n.type.name !== "blockContainer")
1593
+ throw new Error("Expected blockContainer");
1587
1594
  return n.nodeSize > 4;
1588
1595
  }
1589
1596
  }
@@ -1591,27 +1598,27 @@ const mt = (o, e) => new T({
1591
1598
  ];
1592
1599
  }
1593
1600
  });
1594
- function vt(o, e = JSON.stringify) {
1595
- const t = {};
1596
- return o.filter((n) => {
1601
+ function vt(t, e = JSON.stringify) {
1602
+ const o = {};
1603
+ return t.filter((n) => {
1597
1604
  const r = e(n);
1598
- return Object.prototype.hasOwnProperty.call(t, r) ? !1 : t[r] = !0;
1605
+ return Object.prototype.hasOwnProperty.call(o, r) ? !1 : o[r] = !0;
1599
1606
  });
1600
1607
  }
1601
- function It(o) {
1602
- const e = o.filter(
1603
- (n, r) => o.indexOf(n) !== r
1608
+ function Bt(t) {
1609
+ const e = t.filter(
1610
+ (n, r) => t.indexOf(n) !== r
1604
1611
  );
1605
1612
  return vt(e);
1606
1613
  }
1607
- const Tt = E.create({
1614
+ const Mt = P.create({
1608
1615
  name: "uniqueID",
1609
1616
  priority: 1e4,
1610
1617
  addOptions() {
1611
1618
  return {
1612
1619
  attributeName: "id",
1613
1620
  types: [],
1614
- generateID: () => window.__TEST_OPTIONS ? (window.__TEST_OPTIONS.mockID === void 0 ? window.__TEST_OPTIONS.mockID = 0 : window.__TEST_OPTIONS.mockID++, parseInt(window.__TEST_OPTIONS.mockID)) : Be(),
1621
+ generateID: () => window.__TEST_OPTIONS ? (window.__TEST_OPTIONS.mockID === void 0 ? window.__TEST_OPTIONS.mockID = 0 : window.__TEST_OPTIONS.mockID++, parseInt(window.__TEST_OPTIONS.mockID)) : Ce(),
1615
1622
  filterTransaction: null
1616
1623
  };
1617
1624
  },
@@ -1621,7 +1628,11 @@ const Tt = E.create({
1621
1628
  types: this.options.types,
1622
1629
  attributes: {
1623
1630
  [this.options.attributeName]: {
1624
- default: null
1631
+ default: null,
1632
+ parseHTML: (t) => t.getAttribute(`data-${this.options.attributeName}`),
1633
+ renderHTML: (t) => ({
1634
+ [`data-${this.options.attributeName}`]: t[this.options.attributeName]
1635
+ })
1625
1636
  }
1626
1637
  }
1627
1638
  }
@@ -1632,37 +1643,37 @@ const Tt = E.create({
1632
1643
  (s) => s.name === "collaboration"
1633
1644
  ))
1634
1645
  return;
1635
- const { view: o, state: e } = this.editor, { tr: t, doc: n } = e, { types: r, attributeName: a, generateID: d } = this.options;
1636
- _(n, (s) => r.includes(s.type.name) && s.attrs[a] === null).forEach(({ node: s, pos: c }) => {
1637
- t.setNodeMarkup(c, void 0, {
1646
+ const { view: t, state: e } = this.editor, { tr: o, doc: n } = e, { types: r, attributeName: a, generateID: l } = this.options;
1647
+ D(n, (s) => r.includes(s.type.name) && s.attrs[a] === null).forEach(({ node: s, pos: c }) => {
1648
+ o.setNodeMarkup(c, void 0, {
1638
1649
  ...s.attrs,
1639
- [a]: d()
1650
+ [a]: l()
1640
1651
  });
1641
- }), t.setMeta("addToHistory", !1), o.dispatch(t);
1652
+ }), o.setMeta("addToHistory", !1), t.dispatch(o);
1642
1653
  },
1643
1654
  addProseMirrorPlugins() {
1644
- let o = null, e = !1;
1655
+ let t = null, e = !1;
1645
1656
  return [
1646
- new T({
1647
- key: new v("uniqueID"),
1648
- appendTransaction: (t, n, r) => {
1657
+ new M({
1658
+ key: new B("uniqueID"),
1659
+ appendTransaction: (o, n, r) => {
1649
1660
  console.log("appendTransaction");
1650
- const a = t.some((f) => f.docChanged) && !n.doc.eq(r.doc), d = this.options.filterTransaction && t.some((f) => {
1661
+ const a = o.some((f) => f.docChanged) && !n.doc.eq(r.doc), l = this.options.filterTransaction && o.some((f) => {
1651
1662
  var y, b;
1652
1663
  return !(!((b = (y = this.options).filterTransaction) === null || b === void 0) && b.call(y, f));
1653
1664
  });
1654
- if (!a || d)
1665
+ if (!a || l)
1655
1666
  return;
1656
- const { tr: i } = r, { types: s, attributeName: c, generateID: p } = this.options, u = Q(
1667
+ const { tr: i } = r, { types: s, attributeName: c, generateID: p } = this.options, u = J(
1657
1668
  n.doc,
1658
- t
1659
- ), { mapping: l } = u;
1660
- if (X(u).forEach(({ newRange: f }) => {
1661
- const y = le(
1669
+ o
1670
+ ), { mapping: d } = u;
1671
+ if (Q(u).forEach(({ newRange: f }) => {
1672
+ const y = de(
1662
1673
  r.doc,
1663
1674
  f,
1664
1675
  (C) => s.includes(C.type.name)
1665
- ), b = y.map(({ node: C }) => C.attrs[c]).filter((C) => C !== null), g = It(b);
1676
+ ), b = y.map(({ node: C }) => C.attrs[c]).filter((C) => C !== null), k = Bt(b);
1666
1677
  y.forEach(({ node: C, pos: H }) => {
1667
1678
  var R;
1668
1679
  const G = (R = i.doc.nodeAt(H)) === null || R === void 0 ? void 0 : R.attrs[c];
@@ -1673,8 +1684,8 @@ const Tt = E.create({
1673
1684
  });
1674
1685
  return;
1675
1686
  }
1676
- const { deleted: ne } = l.invert().mapResult(H);
1677
- ne && g.includes(G) && i.setNodeMarkup(H, void 0, {
1687
+ const { deleted: ne } = d.invert().mapResult(H);
1688
+ ne && k.includes(G) && i.setNodeMarkup(H, void 0, {
1678
1689
  ...C.attrs,
1679
1690
  [c]: p()
1680
1691
  });
@@ -1682,10 +1693,10 @@ const Tt = E.create({
1682
1693
  }), !!i.steps.length)
1683
1694
  return i;
1684
1695
  },
1685
- view(t) {
1696
+ view(o) {
1686
1697
  const n = (r) => {
1687
1698
  var a;
1688
- o = !((a = t.dom.parentElement) === null || a === void 0) && a.contains(r.target) ? t.dom.parentElement : null;
1699
+ t = !((a = o.dom.parentElement) === null || a === void 0) && a.contains(r.target) ? o.dom.parentElement : null;
1689
1700
  };
1690
1701
  return window.addEventListener("dragstart", n), {
1691
1702
  destroy() {
@@ -1695,18 +1706,18 @@ const Tt = E.create({
1695
1706
  },
1696
1707
  props: {
1697
1708
  handleDOMEvents: {
1698
- drop: (t, n) => {
1709
+ drop: (o, n) => {
1699
1710
  var r;
1700
- return (o !== t.dom.parentElement || ((r = n.dataTransfer) === null || r === void 0 ? void 0 : r.effectAllowed) === "copy") && (o = null, e = !0), !1;
1711
+ return (t !== o.dom.parentElement || ((r = n.dataTransfer) === null || r === void 0 ? void 0 : r.effectAllowed) === "copy") && (t = null, e = !0), !1;
1701
1712
  },
1702
1713
  paste: () => (e = !0, !1)
1703
1714
  },
1704
- transformPasted: (t) => {
1715
+ transformPasted: (o) => {
1705
1716
  if (!e)
1706
- return t;
1707
- const { types: n, attributeName: r } = this.options, a = (d) => {
1717
+ return o;
1718
+ const { types: n, attributeName: r } = this.options, a = (l) => {
1708
1719
  const i = [];
1709
- return d.forEach((s) => {
1720
+ return l.forEach((s) => {
1710
1721
  if (s.isText) {
1711
1722
  i.push(s);
1712
1723
  return;
@@ -1724,94 +1735,89 @@ const Tt = E.create({
1724
1735
  s.marks
1725
1736
  );
1726
1737
  i.push(c);
1727
- }), ee.from(i);
1738
+ }), Z.from(i);
1728
1739
  };
1729
1740
  return e = !1, new z(
1730
- a(t.content),
1731
- t.openStart,
1732
- t.openEnd
1741
+ a(o.content),
1742
+ o.openStart,
1743
+ o.openEnd
1733
1744
  );
1734
1745
  }
1735
1746
  }
1736
1747
  })
1737
1748
  ];
1738
1749
  }
1739
- }), Kt = w.create({
1740
- name: "doc",
1741
- topNode: !0,
1742
- content: "block+"
1743
- }), Ct = (o) => {
1750
+ }), Ct = (t) => {
1744
1751
  const e = [
1745
- P.ClipboardTextSerializer,
1746
- P.Commands,
1747
- P.Editable,
1748
- P.FocusEvents,
1749
- P.Tabindex,
1752
+ N.ClipboardTextSerializer,
1753
+ N.Commands,
1754
+ N.Editable,
1755
+ N.FocusEvents,
1756
+ N.Tabindex,
1750
1757
  me,
1751
1758
  yt.configure({
1752
- emptyNodeClass: I.isEmpty,
1753
- hasAnchorClass: I.hasAnchor,
1754
- isFilterClass: I.isFilter,
1759
+ emptyNodeClass: v.isEmpty,
1760
+ hasAnchorClass: v.hasAnchor,
1761
+ isFilterClass: v.isFilter,
1755
1762
  includeChildren: !0,
1756
1763
  showOnlyCurrent: !1
1757
1764
  }),
1758
- Tt.configure({
1759
- types: ["block"]
1765
+ Mt.configure({
1766
+ types: ["blockContainer"]
1760
1767
  }),
1761
1768
  fe,
1762
1769
  be,
1763
1770
  ue,
1764
1771
  he,
1765
- ke,
1772
+ ge,
1766
1773
  ye,
1767
1774
  ve,
1768
- gt,
1769
- ...$e,
1775
+ ...ze,
1770
1776
  pe.configure({ width: 5, color: "#ddeeff" }),
1771
- ge,
1777
+ ke,
1772
1778
  bt
1773
1779
  ];
1774
- return o.blockSideMenuFactory && e.push(
1775
- ut.configure({
1776
- blockSideMenuFactory: o.blockSideMenuFactory
1780
+ return t.blockSideMenuFactory && e.push(
1781
+ ht.configure({
1782
+ blockSideMenuFactory: t.blockSideMenuFactory
1777
1783
  })
1778
- ), o.formattingToolbarFactory && e.push(
1779
- Ge.configure({
1780
- formattingToolbarFactory: o.formattingToolbarFactory
1784
+ ), t.formattingToolbarFactory && e.push(
1785
+ We.configure({
1786
+ formattingToolbarFactory: t.formattingToolbarFactory
1781
1787
  })
1782
- ), o.hyperlinkToolbarFactory ? e.push(
1783
- ft.configure({
1784
- hyperlinkToolbarFactory: o.hyperlinkToolbarFactory
1788
+ ), t.hyperlinkToolbarFactory ? e.push(
1789
+ kt.configure({
1790
+ hyperlinkToolbarFactory: t.hyperlinkToolbarFactory
1785
1791
  })
1786
- ) : e.push(te), o.slashMenuFactory && e.push(
1787
- Qe.configure({
1788
- slashMenuFactory: o.slashMenuFactory
1792
+ ) : e.push(ee), t.slashMenuFactory && e.push(
1793
+ tt.configure({
1794
+ slashMenuFactory: t.slashMenuFactory
1789
1795
  })
1790
1796
  ), e;
1791
- }, Bt = {
1797
+ }, wt = {
1792
1798
  enableInputRules: !0,
1793
1799
  enablePasteRules: !0,
1794
1800
  enableCoreExtensions: !1
1795
1801
  };
1796
- class Wt {
1802
+ class Gt {
1797
1803
  constructor(e = {}) {
1798
1804
  h(this, "tiptapEditor");
1799
- var a, d, i;
1800
- const t = Ct(
1805
+ var a, l, i;
1806
+ const o = Ct(
1801
1807
  e.uiFactories || {}
1802
1808
  );
1803
- let n = e.disableHistoryExtension ? t.filter((s) => s.name !== "history") : t;
1809
+ let n = e.disableHistoryExtension ? o.filter((s) => s.name !== "history") : o;
1804
1810
  const r = {
1805
- ...Bt,
1811
+ ...wt,
1806
1812
  ...e,
1807
1813
  extensions: e.enableBlockNoteExtensions === !1 ? e.extensions : [...e.extensions || [], ...n],
1808
1814
  editorProps: {
1809
1815
  attributes: {
1810
1816
  ...((a = e.editorProps) == null ? void 0 : a.attributes) || {},
1811
1817
  class: [
1812
- $.bnEditor,
1813
- $.bnRoot,
1814
- ((i = (d = e.editorProps) == null ? void 0 : d.attributes) == null ? void 0 : i.class) || ""
1818
+ U.bnEditor,
1819
+ U.bnRoot,
1820
+ ((i = (l = e.editorProps) == null ? void 0 : l.attributes) == null ? void 0 : i.class) || ""
1815
1821
  ].join(" ")
1816
1822
  }
1817
1823
  }
@@ -1820,9 +1826,8 @@ class Wt {
1820
1826
  }
1821
1827
  }
1822
1828
  export {
1823
- Wt as BlockNoteEditor,
1824
- Kt as Document,
1825
- B as SlashMenuGroups,
1829
+ Gt as BlockNoteEditor,
1830
+ w as SlashMenuGroups,
1826
1831
  x as SlashMenuItem,
1827
1832
  Ct as getBlockNoteExtensions
1828
1833
  };