@blocknote/core 0.2.3 → 0.3.0

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