@blocknote/core 0.2.2 → 0.2.4-alpha.7

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