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