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