@vizel/core 0.0.1-alpha.5 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components.css +1 -1
- package/dist/components.css.map +1 -1
- package/dist/index.d.ts +230 -15
- package/dist/index.js +78 -75
- package/dist/index10.js +1 -1
- package/dist/index11.js +4 -4
- package/dist/index14.js +1 -1
- package/dist/index15.js +134 -127
- package/dist/index17.js +2 -2
- package/dist/index18.js +1 -1
- package/dist/index19.js +86 -86
- package/dist/index20.js +2 -2
- package/dist/index21.js +2 -2
- package/dist/index22.js +16 -13
- package/dist/index24.js +164 -11
- package/dist/index25.js +12 -53
- package/dist/index26.js +49 -136
- package/dist/index27.js +132 -59
- package/dist/index28.js +66 -32
- package/dist/index29.js +35 -21
- package/dist/index3.js +91 -90
- package/dist/index30.js +23 -9
- package/dist/index31.js +9 -147
- package/dist/index32.js +138 -256
- package/dist/index33.js +258 -85
- package/dist/index34.js +84 -55
- package/dist/index35.js +64 -4
- package/dist/index36.js +4 -123
- package/dist/index37.js +111 -315
- package/dist/index38.js +321 -481
- package/dist/index39.js +12 -47
- package/dist/index4.js +1 -1
- package/dist/index40.js +463 -655
- package/dist/index41.js +48 -4
- package/dist/index42.js +694 -4
- package/dist/index43.js +4 -238
- package/dist/index44.js +4 -82
- package/dist/index45.js +237 -16
- package/dist/index46.js +81 -57
- package/dist/index47.js +17 -15
- package/dist/index48.js +57 -285
- package/dist/index49.js +15 -202
- package/dist/index5.js +78 -68
- package/dist/index50.js +281 -1497
- package/dist/index51.js +202 -5
- package/dist/index52.js +1408 -1467
- package/dist/index53.js +5 -723
- package/dist/index54.js +1109 -81
- package/dist/index55.js +703 -226
- package/dist/index56.js +84 -3
- package/dist/index57.js +219 -1205
- package/dist/index58.js +3 -734
- package/dist/index59.js +1232 -21
- package/dist/index6.js +1 -1
- package/dist/index60.js +734 -10
- package/dist/index61.js +21 -7
- package/dist/index62.js +10 -8
- package/dist/index63.js +6 -13
- package/dist/index64.js +7 -18
- package/dist/index65.js +12 -23
- package/dist/index66.js +17 -53
- package/dist/index67.js +23 -1059
- package/dist/index68.js +54 -90
- package/dist/index69.js +1061 -98
- package/dist/index7.js +108 -96
- package/dist/index70.js +98 -4
- package/dist/index71.js +93 -0
- package/dist/index72.js +6 -0
- package/dist/index8.js +1 -1
- package/dist/index9.js +75 -65
- package/dist/mathematics.css +1 -0
- package/dist/mathematics.css.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +90 -52
package/dist/index40.js
CHANGED
|
@@ -1,681 +1,489 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
(!n || !n.marks || !n.marks.map((r) => r.type).includes(s)) && t.push(s);
|
|
13
|
-
}), t;
|
|
14
|
-
}
|
|
15
|
-
function F(e, n) {
|
|
16
|
-
const t = [];
|
|
17
|
-
return Array.from(n.entries()).forEach(([s, r]) => {
|
|
18
|
-
e.has(s) || t.push({ type: s, mark: r });
|
|
19
|
-
}), t;
|
|
20
|
-
}
|
|
21
|
-
function N(e, n, t, s) {
|
|
22
|
-
const r = !t, i = t && t.type === "text" && (!t.marks || t.marks.length === 0), o = t && t.type === "text" && t.marks && !s(n, new Map(t.marks.map((d) => [d.type, d]))), l = [];
|
|
23
|
-
if (r || i || o)
|
|
24
|
-
if (t && t.type === "text" && t.marks) {
|
|
25
|
-
const d = new Map(t.marks.map((a) => [a.type, a]));
|
|
26
|
-
Array.from(e.keys()).forEach((a) => {
|
|
27
|
-
d.has(a) || l.push(a);
|
|
28
|
-
});
|
|
29
|
-
} else (r || i) && l.push(...Array.from(e.keys()));
|
|
30
|
-
return l;
|
|
31
|
-
}
|
|
32
|
-
function $(e, n) {
|
|
33
|
-
let t = "";
|
|
34
|
-
return Array.from(e.keys()).reverse().forEach((s) => {
|
|
35
|
-
const r = e.get(s), i = n(s, r);
|
|
36
|
-
i && (t = i + t);
|
|
37
|
-
}), e.clear(), t;
|
|
38
|
-
}
|
|
39
|
-
function S(e, n, t) {
|
|
40
|
-
let s = "";
|
|
41
|
-
return Array.from(e.entries()).forEach(([r, i]) => {
|
|
42
|
-
const o = t(r, i);
|
|
43
|
-
o && (s += o), n.set(r, i);
|
|
44
|
-
}), s;
|
|
45
|
-
}
|
|
46
|
-
function R(e) {
|
|
47
|
-
const t = (e.raw || e.text || "").match(/^(\s*)[-+*]\s+\[([ xX])\]\s+/);
|
|
48
|
-
return t ? { isTask: !0, checked: t[2].toLowerCase() === "x", indentLevel: t[1].length } : { isTask: !1, indentLevel: 0 };
|
|
49
|
-
}
|
|
50
|
-
function E(e, n) {
|
|
51
|
-
return typeof e != "string" ? "json" : n;
|
|
52
|
-
}
|
|
53
|
-
var j = class {
|
|
54
|
-
/**
|
|
55
|
-
* Create a MarkdownManager.
|
|
56
|
-
* @param options.marked Optional marked instance to use (injected).
|
|
57
|
-
* @param options.markedOptions Optional options to pass to marked.setOptions
|
|
58
|
-
* @param options.indentation Indentation settings (style and size).
|
|
59
|
-
* @param options.extensions An array of Tiptap extensions to register for markdown parsing and rendering.
|
|
60
|
-
*/
|
|
61
|
-
constructor(e) {
|
|
62
|
-
this.baseExtensions = [], this.extensions = [], this.lastParseResult = null;
|
|
63
|
-
var n, t, s, r, i;
|
|
64
|
-
this.markedInstance = (n = e?.marked) != null ? n : P, this.lexer = new this.markedInstance.Lexer(), this.indentStyle = (s = (t = e?.indentation) == null ? void 0 : t.style) != null ? s : "space", this.indentSize = (i = (r = e?.indentation) == null ? void 0 : r.size) != null ? i : 2, this.baseExtensions = e?.extensions || [], e?.markedOptions && typeof this.markedInstance.setOptions == "function" && this.markedInstance.setOptions(e.markedOptions), this.registry = /* @__PURE__ */ new Map(), this.nodeTypeRegistry = /* @__PURE__ */ new Map(), e?.extensions && (this.baseExtensions = e.extensions, z(e.extensions).forEach((l) => this.registerExtension(l, !1))), this.lexer = new this.markedInstance.Lexer();
|
|
65
|
-
}
|
|
66
|
-
/** Returns the underlying marked instance. */
|
|
67
|
-
get instance() {
|
|
68
|
-
return this.markedInstance;
|
|
69
|
-
}
|
|
70
|
-
/** Returns the correct indentCharacter (space or tab) */
|
|
71
|
-
get indentCharacter() {
|
|
72
|
-
return this.indentStyle === "space" ? " " : " ";
|
|
73
|
-
}
|
|
74
|
-
/** Returns the correct indentString repeated X times */
|
|
75
|
-
get indentString() {
|
|
76
|
-
return this.indentCharacter.repeat(this.indentSize);
|
|
77
|
-
}
|
|
78
|
-
/** Helper to quickly check whether a marked instance is available. */
|
|
79
|
-
hasMarked() {
|
|
80
|
-
return !!this.markedInstance;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Register a Tiptap extension (Node/Mark/Extension). This will read
|
|
84
|
-
* `markdownName`, `parseMarkdown`, `renderMarkdown` and `priority` from the
|
|
85
|
-
* extension config (using the same resolution used across the codebase).
|
|
86
|
-
*/
|
|
87
|
-
registerExtension(e, n = !0) {
|
|
88
|
-
var t, s;
|
|
89
|
-
this.extensions.push(e);
|
|
90
|
-
const r = e.name, i = C(e, "markdownTokenName") || r, o = C(e, "parseMarkdown"), l = C(e, "renderMarkdown"), d = C(e, "markdownTokenizer"), a = (t = C(e, "markdownOptions")) != null ? t : null, c = (s = a?.indentsContent) != null ? s : !1, p = {
|
|
91
|
-
tokenName: i,
|
|
92
|
-
nodeName: r,
|
|
93
|
-
parseMarkdown: o,
|
|
94
|
-
renderMarkdown: l,
|
|
95
|
-
isIndenting: c,
|
|
96
|
-
tokenizer: d
|
|
97
|
-
};
|
|
98
|
-
if (i && o) {
|
|
99
|
-
const u = this.registry.get(i) || [];
|
|
100
|
-
u.push(p), this.registry.set(i, u);
|
|
101
|
-
}
|
|
102
|
-
if (l) {
|
|
103
|
-
const u = this.nodeTypeRegistry.get(r) || [];
|
|
104
|
-
u.push(p), this.nodeTypeRegistry.set(r, u);
|
|
105
|
-
}
|
|
106
|
-
d && this.hasMarked() && (this.registerTokenizer(d), n && (this.lexer = new this.markedInstance.Lexer()));
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Register a custom tokenizer with marked.js for parsing non-standard markdown syntax.
|
|
110
|
-
*/
|
|
111
|
-
registerTokenizer(e) {
|
|
112
|
-
if (!this.hasMarked())
|
|
113
|
-
return;
|
|
114
|
-
const { name: n, start: t, level: s = "inline", tokenize: r } = e, l = {
|
|
115
|
-
inlineTokens: (c) => this.lexer.inlineTokens(c),
|
|
116
|
-
blockTokens: (c) => this.lexer.blockTokens(c)
|
|
117
|
-
};
|
|
118
|
-
let d;
|
|
119
|
-
t ? d = typeof t == "function" ? t : (c) => c.indexOf(t) : d = (c) => {
|
|
120
|
-
const p = r(c, [], l);
|
|
121
|
-
return p && p.raw ? c.indexOf(p.raw) : -1;
|
|
122
|
-
};
|
|
123
|
-
const a = {
|
|
124
|
-
name: n,
|
|
125
|
-
level: s,
|
|
126
|
-
start: d,
|
|
127
|
-
tokenizer: (c, p) => {
|
|
128
|
-
const u = r(c, p, l);
|
|
129
|
-
if (u && u.type)
|
|
130
|
-
return {
|
|
131
|
-
...u,
|
|
132
|
-
type: u.type || n,
|
|
133
|
-
raw: u.raw || "",
|
|
134
|
-
tokens: u.tokens || []
|
|
135
|
-
};
|
|
136
|
-
},
|
|
137
|
-
childTokens: []
|
|
138
|
-
};
|
|
139
|
-
this.markedInstance.use({
|
|
140
|
-
extensions: [a]
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
/** Get registered handlers for a token type and try each until one succeeds. */
|
|
144
|
-
getHandlersForToken(e) {
|
|
145
|
-
try {
|
|
146
|
-
return this.registry.get(e) || [];
|
|
147
|
-
} catch {
|
|
148
|
-
return [];
|
|
149
|
-
}
|
|
1
|
+
import { Slice as m, Fragment as J } from "./index59.js";
|
|
2
|
+
import { ReplaceStep as x, ReplaceAroundStep as C } from "./index60.js";
|
|
3
|
+
const k = /* @__PURE__ */ Object.create(null);
|
|
4
|
+
class l {
|
|
5
|
+
/**
|
|
6
|
+
Initialize a selection with the head and anchor and ranges. If no
|
|
7
|
+
ranges are given, constructs a single range across `$anchor` and
|
|
8
|
+
`$head`.
|
|
9
|
+
*/
|
|
10
|
+
constructor(e, t, n) {
|
|
11
|
+
this.$anchor = e, this.$head = t, this.ranges = n || [new E(e.min(t), e.max(t))];
|
|
150
12
|
}
|
|
151
|
-
/**
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const t = this.getHandlersForNodeType(e);
|
|
157
|
-
return t.length > 0 ? t[0] : void 0;
|
|
158
|
-
}
|
|
159
|
-
/** Get registered handlers for a node type (for rendering). */
|
|
160
|
-
getHandlersForNodeType(e) {
|
|
161
|
-
try {
|
|
162
|
-
return this.nodeTypeRegistry.get(e) || [];
|
|
163
|
-
} catch {
|
|
164
|
-
return [];
|
|
165
|
-
}
|
|
13
|
+
/**
|
|
14
|
+
The selection's anchor, as an unresolved position.
|
|
15
|
+
*/
|
|
16
|
+
get anchor() {
|
|
17
|
+
return this.$anchor.pos;
|
|
166
18
|
}
|
|
167
19
|
/**
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return e.map((n) => this.parseToken(n)).filter((n) => n !== null).flatMap((n) => Array.isArray(n) ? n : [n]);
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Parse a single token into Tiptap JSON using the appropriate registered handler.
|
|
194
|
-
*/
|
|
195
|
-
parseToken(e) {
|
|
196
|
-
if (!e.type)
|
|
197
|
-
return null;
|
|
198
|
-
if (e.type === "list")
|
|
199
|
-
return this.parseListToken(e);
|
|
200
|
-
const n = this.getHandlersForToken(e.type), t = this.createParseHelpers();
|
|
201
|
-
if (n.find((r) => {
|
|
202
|
-
if (!r.parseMarkdown)
|
|
203
|
-
return !1;
|
|
204
|
-
const i = r.parseMarkdown(e, t), o = this.normalizeParseResult(i);
|
|
205
|
-
return o && (!Array.isArray(o) || o.length > 0) ? (this.lastParseResult = o, !0) : !1;
|
|
206
|
-
}) && this.lastParseResult) {
|
|
207
|
-
const r = this.lastParseResult;
|
|
208
|
-
return this.lastParseResult = null, r;
|
|
209
|
-
}
|
|
210
|
-
return this.parseFallbackToken(e);
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Parse a list token, handling mixed bullet and task list items by splitting them into separate lists.
|
|
214
|
-
* This ensures that consecutive task items and bullet items are grouped and parsed as separate list nodes.
|
|
215
|
-
*
|
|
216
|
-
* @param token The list token to parse
|
|
217
|
-
* @returns Array of parsed list nodes, or null if parsing fails
|
|
218
|
-
*/
|
|
219
|
-
parseListToken(e) {
|
|
220
|
-
if (!e.items || e.items.length === 0)
|
|
221
|
-
return this.parseTokenWithHandlers(e);
|
|
222
|
-
const n = e.items.some((l) => R(l).isTask), t = e.items.some((l) => !R(l).isTask);
|
|
223
|
-
if (!n || !t || this.getHandlersForToken("taskList").length === 0)
|
|
224
|
-
return this.parseTokenWithHandlers(e);
|
|
225
|
-
const s = [];
|
|
226
|
-
let r = [], i = null;
|
|
227
|
-
for (let l = 0; l < e.items.length; l += 1) {
|
|
228
|
-
const d = e.items[l], { isTask: a, checked: c, indentLevel: p } = R(d);
|
|
229
|
-
let u = d;
|
|
230
|
-
if (a) {
|
|
231
|
-
const m = (d.raw || d.text || "").split(`
|
|
232
|
-
`), g = m[0].match(/^\s*[-+*]\s+\[([ xX])\]\s+(.*)$/), h = g ? g[2] : "";
|
|
233
|
-
let k = [];
|
|
234
|
-
if (m.length > 1 && m.slice(1).join(`
|
|
235
|
-
`).trim()) {
|
|
236
|
-
const T = m.slice(1), v = T.filter((A) => A.trim());
|
|
237
|
-
if (v.length > 0) {
|
|
238
|
-
const A = Math.min(...v.map((x) => x.length - x.trimStart().length)), I = T.map((x) => x.trim() ? x.slice(A) : "").join(`
|
|
239
|
-
`).trim();
|
|
240
|
-
I && (k = this.markedInstance.lexer(`${I}
|
|
241
|
-
`));
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
u = {
|
|
245
|
-
type: "taskItem",
|
|
246
|
-
raw: "",
|
|
247
|
-
mainContent: h,
|
|
248
|
-
indentLevel: p,
|
|
249
|
-
checked: c ?? !1,
|
|
250
|
-
text: h,
|
|
251
|
-
tokens: this.lexer.inlineTokens(h),
|
|
252
|
-
nestedTokens: k
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
const w = a ? "taskList" : "list";
|
|
256
|
-
i !== w ? (r.length > 0 && s.push({ type: i, items: r }), r = [u], i = w) : r.push(u);
|
|
257
|
-
}
|
|
258
|
-
r.length > 0 && s.push({ type: i, items: r });
|
|
259
|
-
const o = [];
|
|
260
|
-
for (let l = 0; l < s.length; l += 1) {
|
|
261
|
-
const d = s[l], a = { ...e, type: d.type, items: d.items }, c = this.parseToken(a);
|
|
262
|
-
c && (Array.isArray(c) ? o.push(...c) : o.push(c));
|
|
263
|
-
}
|
|
264
|
-
return o.length > 0 ? o : null;
|
|
20
|
+
The selection's head.
|
|
21
|
+
*/
|
|
22
|
+
get head() {
|
|
23
|
+
return this.$head.pos;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
The lower bound of the selection's main range.
|
|
27
|
+
*/
|
|
28
|
+
get from() {
|
|
29
|
+
return this.$from.pos;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
The upper bound of the selection's main range.
|
|
33
|
+
*/
|
|
34
|
+
get to() {
|
|
35
|
+
return this.$to.pos;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
The resolved lower bound of the selection's main range.
|
|
39
|
+
*/
|
|
40
|
+
get $from() {
|
|
41
|
+
return this.ranges[0].$from;
|
|
265
42
|
}
|
|
266
43
|
/**
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
44
|
+
The resolved upper bound of the selection's main range.
|
|
45
|
+
*/
|
|
46
|
+
get $to() {
|
|
47
|
+
return this.ranges[0].$to;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
Indicates whether the selection contains any content.
|
|
51
|
+
*/
|
|
52
|
+
get empty() {
|
|
53
|
+
let e = this.ranges;
|
|
54
|
+
for (let t = 0; t < e.length; t++)
|
|
55
|
+
if (e[t].$from.pos != e[t].$to.pos)
|
|
275
56
|
return !1;
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return this.
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}),
|
|
297
|
-
createNode: (e, n, t) => {
|
|
298
|
-
const s = {
|
|
299
|
-
type: e,
|
|
300
|
-
attrs: n || void 0,
|
|
301
|
-
content: t || void 0
|
|
302
|
-
};
|
|
303
|
-
return (!n || Object.keys(n).length === 0) && delete s.attrs, s;
|
|
304
|
-
},
|
|
305
|
-
applyMark: (e, n, t) => ({
|
|
306
|
-
mark: e,
|
|
307
|
-
content: n,
|
|
308
|
-
attrs: t && Object.keys(t).length > 0 ? t : void 0
|
|
309
|
-
})
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Escape special regex characters in a string.
|
|
314
|
-
*/
|
|
315
|
-
escapeRegex(e) {
|
|
316
|
-
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Parse inline tokens (bold, italic, links, etc.) into text nodes with marks.
|
|
320
|
-
* This is the complex part that handles mark nesting and boundaries.
|
|
321
|
-
*/
|
|
322
|
-
parseInlineTokens(e) {
|
|
323
|
-
var n, t, s, r;
|
|
324
|
-
const i = [];
|
|
325
|
-
for (let o = 0; o < e.length; o += 1) {
|
|
326
|
-
const l = e[o];
|
|
327
|
-
if (l.type === "text")
|
|
328
|
-
i.push({
|
|
329
|
-
type: "text",
|
|
330
|
-
text: l.text || ""
|
|
331
|
-
});
|
|
332
|
-
else if (l.type === "html") {
|
|
333
|
-
const d = ((t = (n = l.raw) != null ? n : l.text) != null ? t : "").toString(), a = /^<\/[\s]*[\w-]+/i.test(d), c = d.match(/^<[\s]*([\w-]+)(\s|>|\/|$)/i);
|
|
334
|
-
if (!a && c && !/\/>$/.test(d)) {
|
|
335
|
-
const u = c[1], w = this.escapeRegex(u), M = new RegExp(`^<\\/\\s*${w}\\b`, "i");
|
|
336
|
-
let m = -1;
|
|
337
|
-
const g = [d];
|
|
338
|
-
for (let h = o + 1; h < e.length; h += 1) {
|
|
339
|
-
const k = e[h], f = ((r = (s = k.raw) != null ? s : k.text) != null ? r : "").toString();
|
|
340
|
-
if (g.push(f), k.type === "html" && M.test(f)) {
|
|
341
|
-
m = h;
|
|
342
|
-
break;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
if (m !== -1) {
|
|
346
|
-
const h = g.join(""), k = {
|
|
347
|
-
type: "html",
|
|
348
|
-
raw: h,
|
|
349
|
-
text: h,
|
|
350
|
-
block: !1
|
|
351
|
-
}, f = this.parseHTMLToken(k);
|
|
352
|
-
if (f) {
|
|
353
|
-
const T = this.normalizeParseResult(f);
|
|
354
|
-
Array.isArray(T) ? i.push(...T) : T && i.push(T);
|
|
355
|
-
}
|
|
356
|
-
o = m;
|
|
357
|
-
continue;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
const p = this.parseHTMLToken(l);
|
|
361
|
-
if (p) {
|
|
362
|
-
const u = this.normalizeParseResult(p);
|
|
363
|
-
Array.isArray(u) ? i.push(...u) : u && i.push(u);
|
|
364
|
-
}
|
|
365
|
-
} else if (l.type) {
|
|
366
|
-
const d = this.getHandlerForToken(l.type);
|
|
367
|
-
if (d && d.parseMarkdown) {
|
|
368
|
-
const a = this.createParseHelpers(), c = d.parseMarkdown(l, a);
|
|
369
|
-
if (this.isMarkResult(c)) {
|
|
370
|
-
const p = this.applyMarkToContent(c.mark, c.content, c.attrs);
|
|
371
|
-
i.push(...p);
|
|
372
|
-
} else {
|
|
373
|
-
const p = this.normalizeParseResult(c);
|
|
374
|
-
Array.isArray(p) ? i.push(...p) : p && i.push(p);
|
|
375
|
-
}
|
|
376
|
-
} else l.tokens && i.push(...this.parseInlineTokens(l.tokens));
|
|
377
|
-
}
|
|
57
|
+
return !0;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
Get the content of this selection as a slice.
|
|
61
|
+
*/
|
|
62
|
+
content() {
|
|
63
|
+
return this.$from.doc.slice(this.from, this.to, !0);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
Replace the selection with a slice or, if no slice is given,
|
|
67
|
+
delete the selection. Will append to the given transaction.
|
|
68
|
+
*/
|
|
69
|
+
replace(e, t = m.empty) {
|
|
70
|
+
let n = t.content.lastChild, i = null;
|
|
71
|
+
for (let s = 0; s < t.openEnd; s++)
|
|
72
|
+
i = n, n = n.lastChild;
|
|
73
|
+
let o = e.steps.length, a = this.ranges;
|
|
74
|
+
for (let s = 0; s < a.length; s++) {
|
|
75
|
+
let { $from: h, $to: g } = a[s], f = e.mapping.slice(o);
|
|
76
|
+
e.replaceRange(f.map(h.pos), f.map(g.pos), s ? m.empty : t), s == 0 && b(e, o, (n ? n.isInline : i && i.isTextblock) ? -1 : 1);
|
|
378
77
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
...s,
|
|
390
|
-
marks: [...r, i]
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
return {
|
|
394
|
-
...s,
|
|
395
|
-
content: s.content ? this.applyMarkToContent(e, s.content, t) : void 0
|
|
396
|
-
};
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
/**
|
|
400
|
-
* Check if a parse result represents a mark to be applied.
|
|
401
|
-
*/
|
|
402
|
-
isMarkResult(e) {
|
|
403
|
-
return e && typeof e == "object" && "mark" in e;
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* Normalize parse results to ensure they're valid JSONContent.
|
|
407
|
-
*/
|
|
408
|
-
normalizeParseResult(e) {
|
|
409
|
-
return e ? this.isMarkResult(e) ? e.content : e : null;
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Fallback parsing for common tokens when no specific handler is registered.
|
|
413
|
-
*/
|
|
414
|
-
parseFallbackToken(e) {
|
|
415
|
-
switch (e.type) {
|
|
416
|
-
case "paragraph":
|
|
417
|
-
return {
|
|
418
|
-
type: "paragraph",
|
|
419
|
-
content: e.tokens ? this.parseInlineTokens(e.tokens) : []
|
|
420
|
-
};
|
|
421
|
-
case "heading":
|
|
422
|
-
return {
|
|
423
|
-
type: "heading",
|
|
424
|
-
attrs: { level: e.depth || 1 },
|
|
425
|
-
content: e.tokens ? this.parseInlineTokens(e.tokens) : []
|
|
426
|
-
};
|
|
427
|
-
case "text":
|
|
428
|
-
return {
|
|
429
|
-
type: "text",
|
|
430
|
-
text: e.text || ""
|
|
431
|
-
};
|
|
432
|
-
case "html":
|
|
433
|
-
return this.parseHTMLToken(e);
|
|
434
|
-
case "space":
|
|
435
|
-
return null;
|
|
436
|
-
default:
|
|
437
|
-
return e.tokens ? this.parseTokens(e.tokens) : null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
Replace the selection with the given node, appending the changes
|
|
81
|
+
to the given transaction.
|
|
82
|
+
*/
|
|
83
|
+
replaceWith(e, t) {
|
|
84
|
+
let n = e.steps.length, i = this.ranges;
|
|
85
|
+
for (let o = 0; o < i.length; o++) {
|
|
86
|
+
let { $from: a, $to: s } = i[o], h = e.mapping.slice(n), g = h.map(a.pos), f = h.map(s.pos);
|
|
87
|
+
o ? e.deleteRange(g, f) : (e.replaceRangeWith(g, f, t), b(e, n, t.isInline ? -1 : 1));
|
|
438
88
|
}
|
|
439
89
|
}
|
|
440
90
|
/**
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
return
|
|
451
|
-
|
|
452
|
-
|
|
91
|
+
Find a valid cursor or leaf node selection starting at the given
|
|
92
|
+
position and searching back if `dir` is negative, and forward if
|
|
93
|
+
positive. When `textOnly` is true, only consider cursor
|
|
94
|
+
selections. Will return null when no valid selection position is
|
|
95
|
+
found.
|
|
96
|
+
*/
|
|
97
|
+
static findFrom(e, t, n = !1) {
|
|
98
|
+
let i = e.parent.inlineContent ? new c(e) : d(e.node(0), e.parent, e.pos, e.index(), t, n);
|
|
99
|
+
if (i)
|
|
100
|
+
return i;
|
|
101
|
+
for (let o = e.depth - 1; o >= 0; o--) {
|
|
102
|
+
let a = t < 0 ? d(e.node(0), e.node(o), e.before(o + 1), e.index(o), t, n) : d(e.node(0), e.node(o), e.after(o + 1), e.index(o) + 1, t, n);
|
|
103
|
+
if (a)
|
|
104
|
+
return a;
|
|
453
105
|
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
Find a valid cursor or leaf node selection near the given
|
|
110
|
+
position. Searches forward first by default, but if `bias` is
|
|
111
|
+
negative, it will search backwards first.
|
|
112
|
+
*/
|
|
113
|
+
static near(e, t = 1) {
|
|
114
|
+
return this.findFrom(e, t) || this.findFrom(e, -t) || new p(e.node(0));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
Find the cursor or leaf node selection closest to the start of
|
|
118
|
+
the given document. Will return an
|
|
119
|
+
[`AllSelection`](https://prosemirror.net/docs/ref/#state.AllSelection) if no valid position
|
|
120
|
+
exists.
|
|
121
|
+
*/
|
|
122
|
+
static atStart(e) {
|
|
123
|
+
return d(e, e, 0, 0, 1) || new p(e);
|
|
454
124
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* Get the opening markdown syntax for a mark type.
|
|
539
|
-
*/
|
|
540
|
-
getMarkOpening(e, n) {
|
|
541
|
-
const t = this.getHandlersForNodeType(e), s = t.length > 0 ? t[0] : void 0;
|
|
542
|
-
if (!s || !s.renderMarkdown)
|
|
543
|
-
return "";
|
|
544
|
-
const r = "__TIPTAP_MARKDOWN_PLACEHOLDER__", i = {
|
|
545
|
-
type: e,
|
|
546
|
-
attrs: n.attrs || {},
|
|
547
|
-
content: [{ type: "text", text: r }]
|
|
548
|
-
};
|
|
549
|
-
try {
|
|
550
|
-
const o = s.renderMarkdown(
|
|
551
|
-
i,
|
|
552
|
-
{
|
|
553
|
-
renderChildren: () => r,
|
|
554
|
-
indent: (d) => d,
|
|
555
|
-
wrapInBlock: (d, a) => d + a
|
|
556
|
-
},
|
|
557
|
-
{ index: 0, level: 0, parentType: "text", meta: {} }
|
|
558
|
-
), l = o.indexOf(r);
|
|
559
|
-
return l >= 0 ? o.substring(0, l) : "";
|
|
560
|
-
} catch (o) {
|
|
561
|
-
throw new Error(`Failed to get mark opening for ${e}: ${o}`);
|
|
125
|
+
/**
|
|
126
|
+
Find the cursor or leaf node selection closest to the end of the
|
|
127
|
+
given document.
|
|
128
|
+
*/
|
|
129
|
+
static atEnd(e) {
|
|
130
|
+
return d(e, e, e.content.size, e.childCount, -1) || new p(e);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
Deserialize the JSON representation of a selection. Must be
|
|
134
|
+
implemented for custom classes (as a static class method).
|
|
135
|
+
*/
|
|
136
|
+
static fromJSON(e, t) {
|
|
137
|
+
if (!t || !t.type)
|
|
138
|
+
throw new RangeError("Invalid input for Selection.fromJSON");
|
|
139
|
+
let n = k[t.type];
|
|
140
|
+
if (!n)
|
|
141
|
+
throw new RangeError(`No selection type ${t.type} defined`);
|
|
142
|
+
return n.fromJSON(e, t);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
To be able to deserialize selections from JSON, custom selection
|
|
146
|
+
classes must register themselves with an ID string, so that they
|
|
147
|
+
can be disambiguated. Try to pick something that's unlikely to
|
|
148
|
+
clash with classes from other modules.
|
|
149
|
+
*/
|
|
150
|
+
static jsonID(e, t) {
|
|
151
|
+
if (e in k)
|
|
152
|
+
throw new RangeError("Duplicate use of selection JSON ID " + e);
|
|
153
|
+
return k[e] = t, t.prototype.jsonID = e, t;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
Get a [bookmark](https://prosemirror.net/docs/ref/#state.SelectionBookmark) for this selection,
|
|
157
|
+
which is a value that can be mapped without having access to a
|
|
158
|
+
current document, and later resolved to a real selection for a
|
|
159
|
+
given document again. (This is used mostly by the history to
|
|
160
|
+
track and restore old selections.) The default implementation of
|
|
161
|
+
this method just converts the selection to a text selection and
|
|
162
|
+
returns the bookmark for that.
|
|
163
|
+
*/
|
|
164
|
+
getBookmark() {
|
|
165
|
+
return c.between(this.$anchor, this.$head).getBookmark();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
l.prototype.visible = !0;
|
|
169
|
+
class E {
|
|
170
|
+
/**
|
|
171
|
+
Create a range.
|
|
172
|
+
*/
|
|
173
|
+
constructor(e, t) {
|
|
174
|
+
this.$from = e, this.$to = t;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
let I = !1;
|
|
178
|
+
function F(r) {
|
|
179
|
+
!I && !r.parent.inlineContent && (I = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + r.parent.type.name + ")"));
|
|
180
|
+
}
|
|
181
|
+
class c extends l {
|
|
182
|
+
/**
|
|
183
|
+
Construct a text selection between the given points.
|
|
184
|
+
*/
|
|
185
|
+
constructor(e, t = e) {
|
|
186
|
+
F(e), F(t), super(e, t);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
Returns a resolved position if this is a cursor selection (an
|
|
190
|
+
empty text selection), and null otherwise.
|
|
191
|
+
*/
|
|
192
|
+
get $cursor() {
|
|
193
|
+
return this.$anchor.pos == this.$head.pos ? this.$head : null;
|
|
194
|
+
}
|
|
195
|
+
map(e, t) {
|
|
196
|
+
let n = e.resolve(t.map(this.head));
|
|
197
|
+
if (!n.parent.inlineContent)
|
|
198
|
+
return l.near(n);
|
|
199
|
+
let i = e.resolve(t.map(this.anchor));
|
|
200
|
+
return new c(i.parent.inlineContent ? i : n, n);
|
|
201
|
+
}
|
|
202
|
+
replace(e, t = m.empty) {
|
|
203
|
+
if (super.replace(e, t), t == m.empty) {
|
|
204
|
+
let n = this.$from.marksAcross(this.$to);
|
|
205
|
+
n && e.ensureMarks(n);
|
|
562
206
|
}
|
|
563
207
|
}
|
|
208
|
+
eq(e) {
|
|
209
|
+
return e instanceof c && e.anchor == this.anchor && e.head == this.head;
|
|
210
|
+
}
|
|
211
|
+
getBookmark() {
|
|
212
|
+
return new y(this.anchor, this.head);
|
|
213
|
+
}
|
|
214
|
+
toJSON() {
|
|
215
|
+
return { type: "text", anchor: this.anchor, head: this.head };
|
|
216
|
+
}
|
|
564
217
|
/**
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
218
|
+
@internal
|
|
219
|
+
*/
|
|
220
|
+
static fromJSON(e, t) {
|
|
221
|
+
if (typeof t.anchor != "number" || typeof t.head != "number")
|
|
222
|
+
throw new RangeError("Invalid input for TextSelection.fromJSON");
|
|
223
|
+
return new c(e.resolve(t.anchor), e.resolve(t.head));
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
Create a text selection from non-resolved positions.
|
|
227
|
+
*/
|
|
228
|
+
static create(e, t, n = t) {
|
|
229
|
+
let i = e.resolve(t);
|
|
230
|
+
return new this(i, n == t ? i : e.resolve(n));
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
Return a text selection that spans the given positions or, if
|
|
234
|
+
they aren't text positions, find a text selection near them.
|
|
235
|
+
`bias` determines whether the method searches forward (default)
|
|
236
|
+
or backwards (negative number) first. Will fall back to calling
|
|
237
|
+
[`Selection.near`](https://prosemirror.net/docs/ref/#state.Selection^near) when the document
|
|
238
|
+
doesn't contain a valid text position.
|
|
239
|
+
*/
|
|
240
|
+
static between(e, t, n) {
|
|
241
|
+
let i = e.pos - t.pos;
|
|
242
|
+
if ((!n || i) && (n = i >= 0 ? 1 : -1), !t.parent.inlineContent) {
|
|
243
|
+
let o = l.findFrom(t, n, !0) || l.findFrom(t, -n, !0);
|
|
244
|
+
if (o)
|
|
245
|
+
t = o.$head;
|
|
246
|
+
else
|
|
247
|
+
return l.near(t, n);
|
|
589
248
|
}
|
|
249
|
+
return e.parent.inlineContent || (i == 0 ? e = t : (e = (l.findFrom(e, -n, !0) || l.findFrom(e, n, !0)).$anchor, e.pos < t.pos != i < 0 && (e = t))), new c(e, t);
|
|
590
250
|
}
|
|
251
|
+
}
|
|
252
|
+
l.jsonID("text", c);
|
|
253
|
+
class y {
|
|
254
|
+
constructor(e, t) {
|
|
255
|
+
this.anchor = e, this.head = t;
|
|
256
|
+
}
|
|
257
|
+
map(e) {
|
|
258
|
+
return new y(e.map(this.anchor), e.map(this.head));
|
|
259
|
+
}
|
|
260
|
+
resolve(e) {
|
|
261
|
+
return c.between(e.resolve(this.anchor), e.resolve(this.head));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
class u extends l {
|
|
591
265
|
/**
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
266
|
+
Create a node selection. Does not verify the validity of its
|
|
267
|
+
argument.
|
|
268
|
+
*/
|
|
269
|
+
constructor(e) {
|
|
270
|
+
let t = e.nodeAfter, n = e.node(0).resolve(e.pos + t.nodeSize);
|
|
271
|
+
super(e, n), this.node = t;
|
|
272
|
+
}
|
|
273
|
+
map(e, t) {
|
|
274
|
+
let { deleted: n, pos: i } = t.mapResult(this.anchor), o = e.resolve(i);
|
|
275
|
+
return n ? l.near(o) : new u(o);
|
|
276
|
+
}
|
|
277
|
+
content() {
|
|
278
|
+
return new m(J.from(this.node), 0, 0);
|
|
279
|
+
}
|
|
280
|
+
eq(e) {
|
|
281
|
+
return e instanceof u && e.anchor == this.anchor;
|
|
282
|
+
}
|
|
283
|
+
toJSON() {
|
|
284
|
+
return { type: "node", anchor: this.anchor };
|
|
285
|
+
}
|
|
286
|
+
getBookmark() {
|
|
287
|
+
return new v(this.anchor);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
@internal
|
|
291
|
+
*/
|
|
292
|
+
static fromJSON(e, t) {
|
|
293
|
+
if (typeof t.anchor != "number")
|
|
294
|
+
throw new RangeError("Invalid input for NodeSelection.fromJSON");
|
|
295
|
+
return new u(e.resolve(t.anchor));
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
Create a node selection from non-resolved positions.
|
|
299
|
+
*/
|
|
300
|
+
static create(e, t) {
|
|
301
|
+
return new u(e.resolve(t));
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
Determines whether the given node may be selected as a node
|
|
305
|
+
selection.
|
|
306
|
+
*/
|
|
307
|
+
static isSelectable(e) {
|
|
308
|
+
return !e.isText && e.type.spec.selectable !== !1;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
u.prototype.visible = !1;
|
|
312
|
+
l.jsonID("node", u);
|
|
313
|
+
class v {
|
|
314
|
+
constructor(e) {
|
|
315
|
+
this.anchor = e;
|
|
316
|
+
}
|
|
317
|
+
map(e) {
|
|
318
|
+
let { deleted: t, pos: n } = e.mapResult(this.anchor);
|
|
319
|
+
return t ? new y(n, n) : new v(n);
|
|
320
|
+
}
|
|
321
|
+
resolve(e) {
|
|
322
|
+
let t = e.resolve(this.anchor), n = t.nodeAfter;
|
|
323
|
+
return n && u.isSelectable(n) ? new u(t) : l.near(t);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
class p extends l {
|
|
327
|
+
/**
|
|
328
|
+
Create an all-selection over the given document.
|
|
329
|
+
*/
|
|
330
|
+
constructor(e) {
|
|
331
|
+
super(e.resolve(0), e.resolve(e.content.size));
|
|
332
|
+
}
|
|
333
|
+
replace(e, t = m.empty) {
|
|
334
|
+
if (t == m.empty) {
|
|
335
|
+
e.delete(0, e.doc.content.size);
|
|
336
|
+
let n = l.atStart(e.doc);
|
|
337
|
+
n.eq(e.selection) || e.setSelection(n);
|
|
338
|
+
} else
|
|
339
|
+
super.replace(e, t);
|
|
340
|
+
}
|
|
341
|
+
toJSON() {
|
|
342
|
+
return { type: "all" };
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
@internal
|
|
346
|
+
*/
|
|
347
|
+
static fromJSON(e) {
|
|
348
|
+
return new p(e);
|
|
596
349
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
350
|
+
map(e) {
|
|
351
|
+
return new p(e);
|
|
352
|
+
}
|
|
353
|
+
eq(e) {
|
|
354
|
+
return e instanceof p;
|
|
355
|
+
}
|
|
356
|
+
getBookmark() {
|
|
357
|
+
return D;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
l.jsonID("all", p);
|
|
361
|
+
const D = {
|
|
362
|
+
map() {
|
|
363
|
+
return this;
|
|
364
|
+
},
|
|
365
|
+
resolve(r) {
|
|
366
|
+
return new p(r);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
function d(r, e, t, n, i, o = !1) {
|
|
370
|
+
if (e.inlineContent)
|
|
371
|
+
return c.create(r, t);
|
|
372
|
+
for (let a = n - (i > 0 ? 0 : 1); i > 0 ? a < e.childCount : a >= 0; a += i) {
|
|
373
|
+
let s = e.child(a);
|
|
374
|
+
if (s.isAtom) {
|
|
375
|
+
if (!o && u.isSelectable(s))
|
|
376
|
+
return u.create(r, t - (i < 0 ? s.nodeSize : 0));
|
|
377
|
+
} else {
|
|
378
|
+
let h = d(r, s, t + i, i < 0 ? s.childCount : 0, i, o);
|
|
379
|
+
if (h)
|
|
380
|
+
return h;
|
|
381
|
+
}
|
|
382
|
+
t += s.nodeSize * i;
|
|
383
|
+
}
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
function b(r, e, t) {
|
|
387
|
+
let n = r.steps.length - 1;
|
|
388
|
+
if (n < e)
|
|
389
|
+
return;
|
|
390
|
+
let i = r.steps[n];
|
|
391
|
+
if (!(i instanceof x || i instanceof C))
|
|
392
|
+
return;
|
|
393
|
+
let o = r.mapping.maps[n], a;
|
|
394
|
+
o.forEach((s, h, g, f) => {
|
|
395
|
+
a == null && (a = f);
|
|
396
|
+
}), r.setSelection(l.near(r.doc.resolve(a), t));
|
|
397
|
+
}
|
|
398
|
+
function N(r, e) {
|
|
399
|
+
return !e || !r ? r : r.bind(e);
|
|
400
|
+
}
|
|
401
|
+
class w {
|
|
402
|
+
constructor(e, t, n) {
|
|
403
|
+
this.name = e, this.init = N(t.init, n), this.apply = N(t.apply, n);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
new w("doc", {
|
|
407
|
+
init(r) {
|
|
408
|
+
return r.doc || r.schema.topNodeType.createAndFill();
|
|
409
|
+
},
|
|
410
|
+
apply(r) {
|
|
411
|
+
return r.doc;
|
|
412
|
+
}
|
|
413
|
+
}), new w("selection", {
|
|
414
|
+
init(r, e) {
|
|
415
|
+
return r.selection || l.atStart(e.doc);
|
|
605
416
|
},
|
|
606
|
-
|
|
607
|
-
return
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
return y.setContent(e, n);
|
|
613
|
-
const s = this.editor.markdown.parse(e);
|
|
614
|
-
return y.setContent(s, n);
|
|
615
|
-
},
|
|
616
|
-
insertContent: (e, n) => {
|
|
617
|
-
if (!n?.contentType)
|
|
618
|
-
return y.insertContent(e, n);
|
|
619
|
-
if (E(e, n?.contentType) !== "markdown" || !this.editor.markdown)
|
|
620
|
-
return y.insertContent(e, n);
|
|
621
|
-
const s = this.editor.markdown.parse(e);
|
|
622
|
-
return y.insertContent(s, n);
|
|
623
|
-
},
|
|
624
|
-
insertContentAt: (e, n, t) => {
|
|
625
|
-
if (!t?.contentType)
|
|
626
|
-
return y.insertContentAt(e, n, t);
|
|
627
|
-
if (E(n, t?.contentType) !== "markdown" || !this.editor.markdown)
|
|
628
|
-
return y.insertContentAt(e, n, t);
|
|
629
|
-
const r = this.editor.markdown.parse(n);
|
|
630
|
-
return y.insertContentAt(e, r, t);
|
|
631
|
-
}
|
|
632
|
-
};
|
|
417
|
+
apply(r) {
|
|
418
|
+
return r.selection;
|
|
419
|
+
}
|
|
420
|
+
}), new w("storedMarks", {
|
|
421
|
+
init(r) {
|
|
422
|
+
return r.storedMarks || null;
|
|
633
423
|
},
|
|
634
|
-
|
|
635
|
-
return
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
extensions: []
|
|
641
|
-
})
|
|
642
|
-
};
|
|
424
|
+
apply(r, e, t, n) {
|
|
425
|
+
return n.selection.$cursor ? r.storedMarks : null;
|
|
426
|
+
}
|
|
427
|
+
}), new w("scrollToSelection", {
|
|
428
|
+
init() {
|
|
429
|
+
return 0;
|
|
643
430
|
},
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
console.error(
|
|
647
|
-
"[tiptap][markdown]: There is already a `markdown` property on the editor instance. This might lead to unexpected behavior."
|
|
648
|
-
);
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
if (this.storage.manager = new b({
|
|
652
|
-
indentation: this.options.indentation,
|
|
653
|
-
marked: this.options.marked,
|
|
654
|
-
markedOptions: this.options.markedOptions,
|
|
655
|
-
extensions: this.editor.extensionManager.baseExtensions
|
|
656
|
-
}), this.editor.markdown = this.storage.manager, this.editor.getMarkdown = () => this.storage.manager.serialize(this.editor.getJSON()), !this.editor.options.contentType || E(this.editor.options.content, this.editor.options.contentType) !== "markdown")
|
|
657
|
-
return;
|
|
658
|
-
if (!this.editor.markdown)
|
|
659
|
-
throw new Error(
|
|
660
|
-
'[tiptap][markdown]: The `contentType` option is set to "markdown", but the Markdown extension is not added to the editor. Please add the Markdown extension to use this feature.'
|
|
661
|
-
);
|
|
662
|
-
if (this.editor.options.content === void 0 || typeof this.editor.options.content != "string")
|
|
663
|
-
throw new Error(
|
|
664
|
-
'[tiptap][markdown]: The `contentType` option is set to "markdown", but the initial content is not a string. Please provide the initial content as a markdown string.'
|
|
665
|
-
);
|
|
666
|
-
const n = this.editor.markdown.parse(this.editor.options.content);
|
|
667
|
-
this.editor.options.content = n;
|
|
431
|
+
apply(r, e) {
|
|
432
|
+
return r.scrolledIntoView ? e + 1 : e;
|
|
668
433
|
}
|
|
669
434
|
});
|
|
435
|
+
function O(r, e, t) {
|
|
436
|
+
for (let n in r) {
|
|
437
|
+
let i = r[n];
|
|
438
|
+
i instanceof Function ? i = i.bind(e) : n == "handleDOMEvents" && (i = O(i, e, {})), t[n] = i;
|
|
439
|
+
}
|
|
440
|
+
return t;
|
|
441
|
+
}
|
|
442
|
+
class A {
|
|
443
|
+
/**
|
|
444
|
+
Create a plugin.
|
|
445
|
+
*/
|
|
446
|
+
constructor(e) {
|
|
447
|
+
this.spec = e, this.props = {}, e.props && O(e.props, this, this.props), this.key = e.key ? e.key.key : R("plugin");
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
Extract the plugin's state field from an editor state.
|
|
451
|
+
*/
|
|
452
|
+
getState(e) {
|
|
453
|
+
return e[this.key];
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
const S = /* @__PURE__ */ Object.create(null);
|
|
457
|
+
function R(r) {
|
|
458
|
+
return r in S ? r + "$" + ++S[r] : (S[r] = 0, r + "$");
|
|
459
|
+
}
|
|
460
|
+
class T {
|
|
461
|
+
/**
|
|
462
|
+
Create a plugin key.
|
|
463
|
+
*/
|
|
464
|
+
constructor(e = "key") {
|
|
465
|
+
this.key = R(e);
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
Get the active plugin with this key, if any, from an editor
|
|
469
|
+
state.
|
|
470
|
+
*/
|
|
471
|
+
get(e) {
|
|
472
|
+
return e.config.pluginsByKey[this.key];
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
Get the plugin's state from an editor state.
|
|
476
|
+
*/
|
|
477
|
+
getState(e) {
|
|
478
|
+
return e[this.key];
|
|
479
|
+
}
|
|
480
|
+
}
|
|
670
481
|
export {
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
R as isTaskItem,
|
|
679
|
-
S as reopenMarksAfterNode,
|
|
680
|
-
_ as wrapInMarkdownBlock
|
|
482
|
+
p as AllSelection,
|
|
483
|
+
u as NodeSelection,
|
|
484
|
+
A as Plugin,
|
|
485
|
+
T as PluginKey,
|
|
486
|
+
l as Selection,
|
|
487
|
+
E as SelectionRange,
|
|
488
|
+
c as TextSelection
|
|
681
489
|
};
|