@milkdown/preset-commonmark 7.3.2 → 7.3.4
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/lib/composed/inputrules.d.ts +2 -1
- package/lib/composed/inputrules.d.ts.map +1 -1
- package/lib/composed/plugins.d.ts.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.es.js +599 -728
- package/lib/index.es.js.map +1 -1
- package/lib/mark/emphasis.d.ts +2 -0
- package/lib/mark/emphasis.d.ts.map +1 -1
- package/lib/mark/inline-code.d.ts +1 -0
- package/lib/mark/inline-code.d.ts.map +1 -1
- package/lib/mark/strong.d.ts +1 -0
- package/lib/mark/strong.d.ts.map +1 -1
- package/lib/plugin/index.d.ts +0 -1
- package/lib/plugin/index.d.ts.map +1 -1
- package/package.json +15 -9
- package/src/composed/inputrules.ts +10 -1
- package/src/composed/plugins.ts +0 -5
- package/src/index.ts +3 -2
- package/src/mark/emphasis.ts +28 -1
- package/src/mark/inline-code.ts +12 -1
- package/src/mark/strong.ts +12 -1
- package/src/plugin/index.ts +0 -2
- package/lib/plugin/inline-sync-plugin/config.d.ts +0 -24
- package/lib/plugin/inline-sync-plugin/config.d.ts.map +0 -1
- package/lib/plugin/inline-sync-plugin/context.d.ts +0 -11
- package/lib/plugin/inline-sync-plugin/context.d.ts.map +0 -1
- package/lib/plugin/inline-sync-plugin/index.d.ts +0 -3
- package/lib/plugin/inline-sync-plugin/index.d.ts.map +0 -1
- package/lib/plugin/inline-sync-plugin/inline-sync-plugin.d.ts +0 -2
- package/lib/plugin/inline-sync-plugin/inline-sync-plugin.d.ts.map +0 -1
- package/lib/plugin/inline-sync-plugin/regexp.d.ts +0 -9
- package/lib/plugin/inline-sync-plugin/regexp.d.ts.map +0 -1
- package/lib/plugin/inline-sync-plugin/replacer.d.ts +0 -5
- package/lib/plugin/inline-sync-plugin/replacer.d.ts.map +0 -1
- package/lib/plugin/inline-sync-plugin/utils.d.ts +0 -9
- package/lib/plugin/inline-sync-plugin/utils.d.ts.map +0 -1
- package/src/plugin/inline-sync-plugin/config.ts +0 -78
- package/src/plugin/inline-sync-plugin/context.ts +0 -121
- package/src/plugin/inline-sync-plugin/index.ts +0 -4
- package/src/plugin/inline-sync-plugin/inline-sync-plugin.ts +0 -72
- package/src/plugin/inline-sync-plugin/regexp.ts +0 -16
- package/src/plugin/inline-sync-plugin/replacer.ts +0 -50
- package/src/plugin/inline-sync-plugin/utils.ts +0 -96
package/lib/index.es.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { $markAttr as V, $markSchema as
|
|
2
|
-
import { remarkStringifyOptionsCtx as
|
|
3
|
-
import { toggleMark as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { expectDomTypeError as
|
|
6
|
-
import { textblockTypeInputRule as
|
|
7
|
-
import
|
|
8
|
-
import { TextSelection as
|
|
9
|
-
import { findSelectedNodeOfType as
|
|
10
|
-
import { sinkListItem as
|
|
11
|
-
import { ReplaceStep as
|
|
12
|
-
import { Decoration as
|
|
13
|
-
import { visit as
|
|
14
|
-
import
|
|
15
|
-
function
|
|
1
|
+
import { $markAttr as V, $markSchema as U, $command as c, $inputRule as h, $useKeymap as f, $node as Qe, $nodeAttr as N, $nodeSchema as I, $ctx as Xe, $remark as D, $prose as _ } from "@milkdown/utils";
|
|
2
|
+
import { remarkStringifyOptionsCtx as Ye, commandsCtx as u, editorViewCtx as wt } from "@milkdown/core";
|
|
3
|
+
import { toggleMark as z, setBlockType as K, wrapIn as J } from "@milkdown/prose/commands";
|
|
4
|
+
import { Fragment as At } from "@milkdown/prose/model";
|
|
5
|
+
import { expectDomTypeError as w } from "@milkdown/exception";
|
|
6
|
+
import { textblockTypeInputRule as Ze, wrappingInputRule as Q, InputRule as et } from "@milkdown/prose/inputrules";
|
|
7
|
+
import Ht from "@sindresorhus/slugify";
|
|
8
|
+
import { TextSelection as X, Selection as tt, PluginKey as E, Plugin as P } from "@milkdown/prose/state";
|
|
9
|
+
import { markRule as G, findSelectedNodeOfType as Bt } from "@milkdown/prose";
|
|
10
|
+
import { sinkListItem as Rt, liftListItem as rt, splitListItem as vt } from "@milkdown/prose/schema-list";
|
|
11
|
+
import { ReplaceStep as Ot, AddMarkStep as Tt } from "@milkdown/prose/transform";
|
|
12
|
+
import { Decoration as ze, DecorationSet as Je } from "@milkdown/prose/view";
|
|
13
|
+
import { visit as Y } from "unist-util-visit";
|
|
14
|
+
import Kt from "remark-inline-links";
|
|
15
|
+
function at(t, e) {
|
|
16
16
|
var o;
|
|
17
17
|
if (!(e.childCount >= 1 && ((o = e.lastChild) == null ? void 0 : o.type.name) === "hardbreak")) {
|
|
18
18
|
t.next(e.content);
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
const a = [];
|
|
22
|
-
e.content.forEach((s,
|
|
23
|
-
|
|
24
|
-
}), t.next(
|
|
22
|
+
e.content.forEach((s, l, i) => {
|
|
23
|
+
i !== e.childCount - 1 && a.push(s);
|
|
24
|
+
}), t.next(At.fromArray(a));
|
|
25
25
|
}
|
|
26
26
|
function n(t, e) {
|
|
27
27
|
return Object.assign(t, {
|
|
@@ -31,15 +31,15 @@ function n(t, e) {
|
|
|
31
31
|
}
|
|
32
32
|
}), t;
|
|
33
33
|
}
|
|
34
|
-
const
|
|
35
|
-
n(
|
|
34
|
+
const Z = V("emphasis");
|
|
35
|
+
n(Z, {
|
|
36
36
|
displayName: "Attr<emphasis>",
|
|
37
37
|
group: "Emphasis"
|
|
38
38
|
});
|
|
39
|
-
const
|
|
39
|
+
const R = U("emphasis", (t) => ({
|
|
40
40
|
attrs: {
|
|
41
41
|
marker: {
|
|
42
|
-
default: t.get(
|
|
42
|
+
default: t.get(Ye).emphasis || "*"
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
parseDOM: [
|
|
@@ -47,7 +47,7 @@ const z = j("emphasis", (t) => ({
|
|
|
47
47
|
{ tag: "em" },
|
|
48
48
|
{ style: "font-style", getAttrs: (e) => e === "italic" }
|
|
49
49
|
],
|
|
50
|
-
toDOM: (e) => ["em", t.get(
|
|
50
|
+
toDOM: (e) => ["em", t.get(Z.key)(e)],
|
|
51
51
|
parseMarkdown: {
|
|
52
52
|
match: (e) => e.type === "emphasis",
|
|
53
53
|
runner: (e, r, a) => {
|
|
@@ -63,45 +63,59 @@ const z = j("emphasis", (t) => ({
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
}));
|
|
66
|
-
n(
|
|
66
|
+
n(R.mark, {
|
|
67
67
|
displayName: "MarkSchema<emphasis>",
|
|
68
68
|
group: "Emphasis"
|
|
69
69
|
});
|
|
70
|
-
n(
|
|
70
|
+
n(R.ctx, {
|
|
71
71
|
displayName: "MarkSchemaCtx<emphasis>",
|
|
72
72
|
group: "Emphasis"
|
|
73
73
|
});
|
|
74
|
-
const
|
|
75
|
-
n(
|
|
74
|
+
const ee = c("ToggleEmphasis", (t) => () => z(R.type(t)));
|
|
75
|
+
n(ee, {
|
|
76
76
|
displayName: "Command<toggleEmphasisCommand>",
|
|
77
77
|
group: "Emphasis"
|
|
78
78
|
});
|
|
79
|
-
const
|
|
79
|
+
const nt = h((t) => G(/(?:^|[^*])\*([^*]+)\*$/, R.type(t), {
|
|
80
|
+
updateCaptured: ({ fullMatch: e, start: r }) => e.startsWith("*") ? {} : { fullMatch: e.slice(1), start: r + 1 }
|
|
81
|
+
}));
|
|
82
|
+
n(nt, {
|
|
83
|
+
displayName: "InputRule<emphasis>|Star",
|
|
84
|
+
group: "Emphasis"
|
|
85
|
+
});
|
|
86
|
+
const ot = h((t) => G(/(?:^|[^_])_([^_]+)_$/, R.type(t), {
|
|
87
|
+
updateCaptured: ({ fullMatch: e, start: r }) => e.startsWith("_") ? {} : { fullMatch: e.slice(1), start: r + 1 }
|
|
88
|
+
}));
|
|
89
|
+
n(ot, {
|
|
90
|
+
displayName: "InputRule<emphasis>|Underscore",
|
|
91
|
+
group: "Emphasis"
|
|
92
|
+
});
|
|
93
|
+
const te = f("emphasisKeymap", {
|
|
80
94
|
ToggleEmphasis: {
|
|
81
95
|
shortcuts: "Mod-i",
|
|
82
96
|
command: (t) => {
|
|
83
|
-
const e = t.get(
|
|
84
|
-
return () => e.call(
|
|
97
|
+
const e = t.get(u);
|
|
98
|
+
return () => e.call(ee.key);
|
|
85
99
|
}
|
|
86
100
|
}
|
|
87
101
|
});
|
|
88
|
-
n(
|
|
102
|
+
n(te.ctx, {
|
|
89
103
|
displayName: "KeymapCtx<emphasis>",
|
|
90
104
|
group: "Emphasis"
|
|
91
105
|
});
|
|
92
|
-
n(
|
|
106
|
+
n(te.shortcuts, {
|
|
93
107
|
displayName: "Keymap<emphasis>",
|
|
94
108
|
group: "Emphasis"
|
|
95
109
|
});
|
|
96
|
-
const
|
|
97
|
-
n(
|
|
110
|
+
const re = V("strong");
|
|
111
|
+
n(re, {
|
|
98
112
|
displayName: "Attr<strong>",
|
|
99
113
|
group: "Strong"
|
|
100
114
|
});
|
|
101
|
-
const
|
|
115
|
+
const $ = U("strong", (t) => ({
|
|
102
116
|
attrs: {
|
|
103
117
|
marker: {
|
|
104
|
-
default: t.get(
|
|
118
|
+
default: t.get(Ye).strong || "*"
|
|
105
119
|
}
|
|
106
120
|
},
|
|
107
121
|
parseDOM: [
|
|
@@ -109,7 +123,7 @@ const U = j("strong", (t) => ({
|
|
|
109
123
|
{ tag: "strong" },
|
|
110
124
|
{ style: "font-style", getAttrs: (e) => e === "bold" }
|
|
111
125
|
],
|
|
112
|
-
toDOM: (e) => ["strong", t.get(
|
|
126
|
+
toDOM: (e) => ["strong", t.get(re.key)(e)],
|
|
113
127
|
parseMarkdown: {
|
|
114
128
|
match: (e) => e.type === "strong",
|
|
115
129
|
runner: (e, r, a) => {
|
|
@@ -125,47 +139,52 @@ const U = j("strong", (t) => ({
|
|
|
125
139
|
}
|
|
126
140
|
}
|
|
127
141
|
}));
|
|
128
|
-
n(
|
|
142
|
+
n($.mark, {
|
|
129
143
|
displayName: "MarkSchema<strong>",
|
|
130
144
|
group: "Strong"
|
|
131
145
|
});
|
|
132
|
-
n(
|
|
146
|
+
n($.ctx, {
|
|
133
147
|
displayName: "MarkSchemaCtx<strong>",
|
|
134
148
|
group: "Strong"
|
|
135
149
|
});
|
|
136
|
-
const
|
|
137
|
-
n(
|
|
150
|
+
const ae = c("ToggleStrong", (t) => () => z($.type(t)));
|
|
151
|
+
n(ae, {
|
|
138
152
|
displayName: "Command<toggleStrongCommand>",
|
|
139
153
|
group: "Strong"
|
|
140
154
|
});
|
|
141
|
-
const
|
|
155
|
+
const st = h((t) => G(/(?:\*\*|__)([^*_]+)(?:\*\*|__)$/, $.type(t)));
|
|
156
|
+
n(st, {
|
|
157
|
+
displayName: "InputRule<strong>",
|
|
158
|
+
group: "Strong"
|
|
159
|
+
});
|
|
160
|
+
const ne = f("strongKeymap", {
|
|
142
161
|
ToggleBold: {
|
|
143
162
|
shortcuts: ["Mod-b"],
|
|
144
163
|
command: (t) => {
|
|
145
|
-
const e = t.get(
|
|
146
|
-
return () => e.call(
|
|
164
|
+
const e = t.get(u);
|
|
165
|
+
return () => e.call(ae.key);
|
|
147
166
|
}
|
|
148
167
|
}
|
|
149
168
|
});
|
|
150
|
-
n(
|
|
169
|
+
n(ne.ctx, {
|
|
151
170
|
displayName: "KeymapCtx<strong>",
|
|
152
171
|
group: "Strong"
|
|
153
172
|
});
|
|
154
|
-
n(
|
|
173
|
+
n(ne.shortcuts, {
|
|
155
174
|
displayName: "Keymap<strong>",
|
|
156
175
|
group: "Strong"
|
|
157
176
|
});
|
|
158
|
-
const
|
|
159
|
-
n(
|
|
177
|
+
const oe = V("inlineCode");
|
|
178
|
+
n(oe, {
|
|
160
179
|
displayName: "Attr<inlineCode>",
|
|
161
180
|
group: "InlineCode"
|
|
162
181
|
});
|
|
163
|
-
const x =
|
|
182
|
+
const x = U("inlineCode", (t) => ({
|
|
164
183
|
priority: 100,
|
|
165
184
|
code: !0,
|
|
166
185
|
inclusive: !1,
|
|
167
186
|
parseDOM: [{ tag: "code" }],
|
|
168
|
-
toDOM: (e) => ["code", t.get(
|
|
187
|
+
toDOM: (e) => ["code", t.get(oe.key)(e)],
|
|
169
188
|
parseMarkdown: {
|
|
170
189
|
match: (e) => e.type === "inlineCode",
|
|
171
190
|
runner: (e, r, a) => {
|
|
@@ -187,42 +206,47 @@ n(x.ctx, {
|
|
|
187
206
|
displayName: "MarkSchemaCtx<inlineCode>",
|
|
188
207
|
group: "InlineCode"
|
|
189
208
|
});
|
|
190
|
-
const
|
|
209
|
+
const se = c("ToggleInlineCode", (t) => () => (e, r) => {
|
|
191
210
|
const { selection: a, tr: o } = e;
|
|
192
211
|
if (a.empty)
|
|
193
212
|
return !1;
|
|
194
|
-
const { from: s, to:
|
|
195
|
-
return e.doc.rangeHasMark(s,
|
|
196
|
-
o.removeMark(s,
|
|
197
|
-
}), r == null || r(o.addMark(s,
|
|
213
|
+
const { from: s, to: l } = a;
|
|
214
|
+
return e.doc.rangeHasMark(s, l, x.type(t)) ? (r == null || r(o.removeMark(s, l, x.type(t))), !0) : (Object.keys(e.schema.marks).filter((m) => m !== x.type.name).map((m) => e.schema.marks[m]).forEach((m) => {
|
|
215
|
+
o.removeMark(s, l, m);
|
|
216
|
+
}), r == null || r(o.addMark(s, l, x.type(t).create())), !0);
|
|
198
217
|
});
|
|
199
|
-
n(
|
|
218
|
+
n(se, {
|
|
200
219
|
displayName: "Command<toggleInlineCodeCommand>",
|
|
201
220
|
group: "InlineCode"
|
|
202
221
|
});
|
|
203
|
-
const
|
|
222
|
+
const lt = h((t) => G(/(?:\`)([^\`]+)(?:\`)$/, x.type(t)));
|
|
223
|
+
n(lt, {
|
|
224
|
+
displayName: "InputRule<inlineCodeInputRule>",
|
|
225
|
+
group: "InlineCode"
|
|
226
|
+
});
|
|
227
|
+
const le = f("inlineCodeKeymap", {
|
|
204
228
|
ToggleInlineCode: {
|
|
205
229
|
shortcuts: "Mod-e",
|
|
206
230
|
command: (t) => {
|
|
207
|
-
const e = t.get(
|
|
208
|
-
return () => e.call(
|
|
231
|
+
const e = t.get(u);
|
|
232
|
+
return () => e.call(se.key);
|
|
209
233
|
}
|
|
210
234
|
}
|
|
211
235
|
});
|
|
212
|
-
n(
|
|
236
|
+
n(le.ctx, {
|
|
213
237
|
displayName: "KeymapCtx<inlineCode>",
|
|
214
238
|
group: "InlineCode"
|
|
215
239
|
});
|
|
216
|
-
n(
|
|
240
|
+
n(le.shortcuts, {
|
|
217
241
|
displayName: "Keymap<inlineCode>",
|
|
218
242
|
group: "InlineCode"
|
|
219
243
|
});
|
|
220
|
-
const
|
|
221
|
-
n(
|
|
244
|
+
const ie = V("link");
|
|
245
|
+
n(ie, {
|
|
222
246
|
displayName: "Attr<link>",
|
|
223
247
|
group: "Link"
|
|
224
248
|
});
|
|
225
|
-
const B =
|
|
249
|
+
const B = U("link", (t) => ({
|
|
226
250
|
attrs: {
|
|
227
251
|
href: {},
|
|
228
252
|
title: { default: null }
|
|
@@ -232,12 +256,12 @@ const B = j("link", (t) => ({
|
|
|
232
256
|
tag: "a[href]",
|
|
233
257
|
getAttrs: (e) => {
|
|
234
258
|
if (!(e instanceof HTMLElement))
|
|
235
|
-
throw
|
|
259
|
+
throw w(e);
|
|
236
260
|
return { href: e.getAttribute("href"), title: e.getAttribute("title") };
|
|
237
261
|
}
|
|
238
262
|
}
|
|
239
263
|
],
|
|
240
|
-
toDOM: (e) => ["a", { ...t.get(
|
|
264
|
+
toDOM: (e) => ["a", { ...t.get(ie.key)(e), ...e.attrs }],
|
|
241
265
|
parseMarkdown: {
|
|
242
266
|
match: (e) => e.type === "link",
|
|
243
267
|
runner: (e, r, a) => {
|
|
@@ -259,34 +283,34 @@ n(B.mark, {
|
|
|
259
283
|
displayName: "MarkSchema<link>",
|
|
260
284
|
group: "Link"
|
|
261
285
|
});
|
|
262
|
-
const
|
|
263
|
-
n(
|
|
286
|
+
const it = c("ToggleLink", (t) => (e = {}) => z(B.type(t), e));
|
|
287
|
+
n(it, {
|
|
264
288
|
displayName: "Command<toggleLinkCommand>",
|
|
265
289
|
group: "Link"
|
|
266
290
|
});
|
|
267
|
-
const
|
|
291
|
+
const dt = c("UpdateLink", (t) => (e = {}) => (r, a) => {
|
|
268
292
|
if (!a)
|
|
269
293
|
return !1;
|
|
270
294
|
let o, s = -1;
|
|
271
|
-
const { selection:
|
|
272
|
-
if (r.doc.nodesBetween(
|
|
273
|
-
if (B.type(t).isInSet(
|
|
274
|
-
return o =
|
|
295
|
+
const { selection: l } = r, { from: i, to: d } = l;
|
|
296
|
+
if (r.doc.nodesBetween(i, i === d ? d + 1 : d, (y, b) => {
|
|
297
|
+
if (B.type(t).isInSet(y.marks))
|
|
298
|
+
return o = y, s = b, !1;
|
|
275
299
|
}), !o)
|
|
276
300
|
return !1;
|
|
277
|
-
const
|
|
278
|
-
if (!
|
|
301
|
+
const m = o.marks.find(({ type: y }) => y === B.type(t));
|
|
302
|
+
if (!m)
|
|
279
303
|
return !1;
|
|
280
|
-
const
|
|
281
|
-
return
|
|
282
|
-
|
|
304
|
+
const p = s, k = s + o.nodeSize, { tr: g } = r, C = B.type(t).create({ ...m.attrs, ...e });
|
|
305
|
+
return C ? (a(
|
|
306
|
+
g.removeMark(p, k, m).addMark(p, k, C).setSelection(new X(g.selection.$anchor)).scrollIntoView()
|
|
283
307
|
), !0) : !1;
|
|
284
308
|
});
|
|
285
|
-
n(
|
|
309
|
+
n(dt, {
|
|
286
310
|
displayName: "Command<updateLinkCommand>",
|
|
287
311
|
group: "Link"
|
|
288
312
|
});
|
|
289
|
-
const
|
|
313
|
+
const mt = Qe("doc", () => ({
|
|
290
314
|
content: "block+",
|
|
291
315
|
parseMarkdown: {
|
|
292
316
|
match: ({ type: t }) => t === "root",
|
|
@@ -301,20 +325,20 @@ const gt = ot("doc", () => ({
|
|
|
301
325
|
}
|
|
302
326
|
}
|
|
303
327
|
}));
|
|
304
|
-
n(
|
|
328
|
+
n(mt, {
|
|
305
329
|
displayName: "NodeSchema<doc>",
|
|
306
330
|
group: "Doc"
|
|
307
331
|
});
|
|
308
|
-
const
|
|
309
|
-
n(
|
|
332
|
+
const de = N("paragraph");
|
|
333
|
+
n(de, {
|
|
310
334
|
displayName: "Attr<paragraph>",
|
|
311
335
|
group: "Paragraph"
|
|
312
336
|
});
|
|
313
|
-
const
|
|
337
|
+
const A = I("paragraph", (t) => ({
|
|
314
338
|
content: "inline*",
|
|
315
339
|
group: "block",
|
|
316
340
|
parseDOM: [{ tag: "p" }],
|
|
317
|
-
toDOM: (e) => ["p", t.get(
|
|
341
|
+
toDOM: (e) => ["p", t.get(de.key)(e), 0],
|
|
318
342
|
parseMarkdown: {
|
|
319
343
|
match: (e) => e.type === "paragraph",
|
|
320
344
|
runner: (e, r, a) => {
|
|
@@ -324,56 +348,56 @@ const v = C("paragraph", (t) => ({
|
|
|
324
348
|
toMarkdown: {
|
|
325
349
|
match: (e) => e.type.name === "paragraph",
|
|
326
350
|
runner: (e, r) => {
|
|
327
|
-
e.openNode("paragraph"),
|
|
351
|
+
e.openNode("paragraph"), at(e, r), e.closeNode();
|
|
328
352
|
}
|
|
329
353
|
}
|
|
330
354
|
}));
|
|
331
|
-
n(
|
|
355
|
+
n(A.node, {
|
|
332
356
|
displayName: "NodeSchema<paragraph>",
|
|
333
357
|
group: "Paragraph"
|
|
334
358
|
});
|
|
335
|
-
n(
|
|
359
|
+
n(A.ctx, {
|
|
336
360
|
displayName: "NodeSchemaCtx<paragraph>",
|
|
337
361
|
group: "Paragraph"
|
|
338
362
|
});
|
|
339
|
-
const
|
|
340
|
-
n(
|
|
363
|
+
const me = c("TurnIntoText", (t) => () => K(A.type(t)));
|
|
364
|
+
n(me, {
|
|
341
365
|
displayName: "Command<turnIntoTextCommand>",
|
|
342
366
|
group: "Paragraph"
|
|
343
367
|
});
|
|
344
|
-
const
|
|
368
|
+
const pe = f("paragraphKeymap", {
|
|
345
369
|
TurnIntoText: {
|
|
346
370
|
shortcuts: "Mod-Alt-0",
|
|
347
371
|
command: (t) => {
|
|
348
|
-
const e = t.get(
|
|
349
|
-
return () => e.call(
|
|
372
|
+
const e = t.get(u);
|
|
373
|
+
return () => e.call(me.key);
|
|
350
374
|
}
|
|
351
375
|
}
|
|
352
376
|
});
|
|
353
|
-
n(
|
|
377
|
+
n(pe.ctx, {
|
|
354
378
|
displayName: "KeymapCtx<paragraph>",
|
|
355
379
|
group: "Paragraph"
|
|
356
380
|
});
|
|
357
|
-
n(
|
|
381
|
+
n(pe.shortcuts, {
|
|
358
382
|
displayName: "Keymap<paragraph>",
|
|
359
383
|
group: "Paragraph"
|
|
360
384
|
});
|
|
361
|
-
const
|
|
362
|
-
function
|
|
363
|
-
return
|
|
385
|
+
const Dt = Array(6).fill(0).map((t, e) => e + 1);
|
|
386
|
+
function _t(t) {
|
|
387
|
+
return Ht(t.textContent);
|
|
364
388
|
}
|
|
365
|
-
const
|
|
366
|
-
n(
|
|
389
|
+
const j = Xe(_t, "headingIdGenerator");
|
|
390
|
+
n(j, {
|
|
367
391
|
displayName: "Ctx<HeadingIdGenerator>",
|
|
368
392
|
group: "Heading"
|
|
369
393
|
});
|
|
370
|
-
const
|
|
371
|
-
n(
|
|
394
|
+
const ce = N("heading");
|
|
395
|
+
n(ce, {
|
|
372
396
|
displayName: "Attr<heading>",
|
|
373
397
|
group: "Heading"
|
|
374
398
|
});
|
|
375
|
-
const H =
|
|
376
|
-
const e = t.get(
|
|
399
|
+
const H = I("heading", (t) => {
|
|
400
|
+
const e = t.get(j.key);
|
|
377
401
|
return {
|
|
378
402
|
content: "inline*",
|
|
379
403
|
group: "block",
|
|
@@ -386,18 +410,18 @@ const H = C("heading", (t) => {
|
|
|
386
410
|
default: 1
|
|
387
411
|
}
|
|
388
412
|
},
|
|
389
|
-
parseDOM:
|
|
413
|
+
parseDOM: Dt.map((r) => ({
|
|
390
414
|
tag: `h${r}`,
|
|
391
415
|
getAttrs: (a) => {
|
|
392
416
|
if (!(a instanceof HTMLElement))
|
|
393
|
-
throw
|
|
417
|
+
throw w(a);
|
|
394
418
|
return { level: r, id: a.id };
|
|
395
419
|
}
|
|
396
420
|
})),
|
|
397
421
|
toDOM: (r) => [
|
|
398
422
|
`h${r.attrs.level}`,
|
|
399
423
|
{
|
|
400
|
-
...t.get(
|
|
424
|
+
...t.get(ce.key)(r),
|
|
401
425
|
id: r.attrs.id || e(r)
|
|
402
426
|
},
|
|
403
427
|
0
|
|
@@ -412,7 +436,7 @@ const H = C("heading", (t) => {
|
|
|
412
436
|
toMarkdown: {
|
|
413
437
|
match: (r) => r.type.name === "heading",
|
|
414
438
|
runner: (r, a) => {
|
|
415
|
-
r.openNode("heading", void 0, { depth: a.attrs.level }),
|
|
439
|
+
r.openNode("heading", void 0, { depth: a.attrs.level }), at(r, a), r.closeNode();
|
|
416
440
|
}
|
|
417
441
|
}
|
|
418
442
|
};
|
|
@@ -425,110 +449,110 @@ n(H.ctx, {
|
|
|
425
449
|
displayName: "NodeSchemaCtx<heading>",
|
|
426
450
|
group: "Heading"
|
|
427
451
|
});
|
|
428
|
-
const
|
|
429
|
-
var
|
|
430
|
-
const r = ((
|
|
452
|
+
const pt = h((t) => Ze(/^(?<hashes>#+)\s$/, H.type(t), (e) => {
|
|
453
|
+
var l, i;
|
|
454
|
+
const r = ((i = (l = e.groups) == null ? void 0 : l.hashes) == null ? void 0 : i.length) || 0, a = t.get(wt), { $from: o } = a.state.selection, s = o.node();
|
|
431
455
|
if (s.type.name === "heading") {
|
|
432
|
-
let
|
|
433
|
-
return
|
|
456
|
+
let d = Number(s.attrs.level) + Number(r);
|
|
457
|
+
return d > 6 && (d = 6), { level: d };
|
|
434
458
|
}
|
|
435
459
|
return { level: r };
|
|
436
460
|
}));
|
|
437
|
-
n(
|
|
461
|
+
n(pt, {
|
|
438
462
|
displayName: "InputRule<wrapInHeadingInputRule>",
|
|
439
463
|
group: "Heading"
|
|
440
464
|
});
|
|
441
|
-
const
|
|
442
|
-
n(
|
|
465
|
+
const L = c("WrapInHeading", (t) => (e) => (e ?? (e = 1), e < 1 ? K(A.type(t)) : K(H.type(t), { level: e })));
|
|
466
|
+
n(L, {
|
|
443
467
|
displayName: "Command<wrapInHeadingCommand>",
|
|
444
468
|
group: "Heading"
|
|
445
469
|
});
|
|
446
|
-
const
|
|
470
|
+
const ue = c("DowngradeHeading", (t) => () => (e, r, a) => {
|
|
447
471
|
const { $from: o } = e.selection, s = o.node();
|
|
448
472
|
if (s.type !== H.type(t) || !e.selection.empty || o.parentOffset !== 0)
|
|
449
473
|
return !1;
|
|
450
|
-
const
|
|
451
|
-
return
|
|
474
|
+
const l = s.attrs.level - 1;
|
|
475
|
+
return l ? (r == null || r(
|
|
452
476
|
e.tr.setNodeMarkup(e.selection.$from.before(), void 0, {
|
|
453
477
|
...s.attrs,
|
|
454
|
-
level:
|
|
478
|
+
level: l
|
|
455
479
|
})
|
|
456
|
-
), !0) :
|
|
480
|
+
), !0) : K(A.type(t))(e, r, a);
|
|
457
481
|
});
|
|
458
|
-
n(
|
|
482
|
+
n(ue, {
|
|
459
483
|
displayName: "Command<downgradeHeadingCommand>",
|
|
460
484
|
group: "Heading"
|
|
461
485
|
});
|
|
462
|
-
const
|
|
486
|
+
const ge = f("headingKeymap", {
|
|
463
487
|
TurnIntoH1: {
|
|
464
488
|
shortcuts: "Mod-Alt-1",
|
|
465
489
|
command: (t) => {
|
|
466
|
-
const e = t.get(
|
|
467
|
-
return () => e.call(
|
|
490
|
+
const e = t.get(u);
|
|
491
|
+
return () => e.call(L.key, 1);
|
|
468
492
|
}
|
|
469
493
|
},
|
|
470
494
|
TurnIntoH2: {
|
|
471
495
|
shortcuts: "Mod-Alt-2",
|
|
472
496
|
command: (t) => {
|
|
473
|
-
const e = t.get(
|
|
474
|
-
return () => e.call(
|
|
497
|
+
const e = t.get(u);
|
|
498
|
+
return () => e.call(L.key, 2);
|
|
475
499
|
}
|
|
476
500
|
},
|
|
477
501
|
TurnIntoH3: {
|
|
478
502
|
shortcuts: "Mod-Alt-3",
|
|
479
503
|
command: (t) => {
|
|
480
|
-
const e = t.get(
|
|
481
|
-
return () => e.call(
|
|
504
|
+
const e = t.get(u);
|
|
505
|
+
return () => e.call(L.key, 3);
|
|
482
506
|
}
|
|
483
507
|
},
|
|
484
508
|
TurnIntoH4: {
|
|
485
509
|
shortcuts: "Mod-Alt-4",
|
|
486
510
|
command: (t) => {
|
|
487
|
-
const e = t.get(
|
|
488
|
-
return () => e.call(
|
|
511
|
+
const e = t.get(u);
|
|
512
|
+
return () => e.call(L.key, 4);
|
|
489
513
|
}
|
|
490
514
|
},
|
|
491
515
|
TurnIntoH5: {
|
|
492
516
|
shortcuts: "Mod-Alt-5",
|
|
493
517
|
command: (t) => {
|
|
494
|
-
const e = t.get(
|
|
495
|
-
return () => e.call(
|
|
518
|
+
const e = t.get(u);
|
|
519
|
+
return () => e.call(L.key, 5);
|
|
496
520
|
}
|
|
497
521
|
},
|
|
498
522
|
TurnIntoH6: {
|
|
499
523
|
shortcuts: "Mod-Alt-6",
|
|
500
524
|
command: (t) => {
|
|
501
|
-
const e = t.get(
|
|
502
|
-
return () => e.call(
|
|
525
|
+
const e = t.get(u);
|
|
526
|
+
return () => e.call(L.key, 6);
|
|
503
527
|
}
|
|
504
528
|
},
|
|
505
529
|
DowngradeHeading: {
|
|
506
530
|
shortcuts: ["Delete", "Backspace"],
|
|
507
531
|
command: (t) => {
|
|
508
|
-
const e = t.get(
|
|
509
|
-
return () => e.call(
|
|
532
|
+
const e = t.get(u);
|
|
533
|
+
return () => e.call(ue.key);
|
|
510
534
|
}
|
|
511
535
|
}
|
|
512
536
|
});
|
|
513
|
-
n(
|
|
537
|
+
n(ge.ctx, {
|
|
514
538
|
displayName: "KeymapCtx<heading>",
|
|
515
539
|
group: "Heading"
|
|
516
540
|
});
|
|
517
|
-
n(
|
|
541
|
+
n(ge.shortcuts, {
|
|
518
542
|
displayName: "Keymap<heading>",
|
|
519
543
|
group: "Heading"
|
|
520
544
|
});
|
|
521
|
-
const
|
|
522
|
-
n(
|
|
545
|
+
const ye = N("blockquote");
|
|
546
|
+
n(ye, {
|
|
523
547
|
displayName: "Attr<blockquote>",
|
|
524
548
|
group: "Blockquote"
|
|
525
549
|
});
|
|
526
|
-
const
|
|
550
|
+
const q = I("blockquote", (t) => ({
|
|
527
551
|
content: "block+",
|
|
528
552
|
group: "block",
|
|
529
553
|
defining: !0,
|
|
530
554
|
parseDOM: [{ tag: "blockquote" }],
|
|
531
|
-
toDOM: (e) => ["blockquote", t.get(
|
|
555
|
+
toDOM: (e) => ["blockquote", t.get(ye.key)(e), 0],
|
|
532
556
|
parseMarkdown: {
|
|
533
557
|
match: ({ type: e }) => e === "blockquote",
|
|
534
558
|
runner: (e, r, a) => {
|
|
@@ -542,50 +566,50 @@ const W = C("blockquote", (t) => ({
|
|
|
542
566
|
}
|
|
543
567
|
}
|
|
544
568
|
}));
|
|
545
|
-
n(
|
|
569
|
+
n(q.node, {
|
|
546
570
|
displayName: "NodeSchema<blockquote>",
|
|
547
571
|
group: "Blockquote"
|
|
548
572
|
});
|
|
549
|
-
n(
|
|
573
|
+
n(q.ctx, {
|
|
550
574
|
displayName: "NodeSchemaCtx<blockquote>",
|
|
551
575
|
group: "Blockquote"
|
|
552
576
|
});
|
|
553
|
-
const
|
|
554
|
-
n(
|
|
577
|
+
const ct = h((t) => Q(/^\s*>\s$/, q.type(t)));
|
|
578
|
+
n(ct, {
|
|
555
579
|
displayName: "InputRule<wrapInBlockquoteInputRule>",
|
|
556
580
|
group: "Blockquote"
|
|
557
581
|
});
|
|
558
|
-
const
|
|
559
|
-
n(
|
|
582
|
+
const ke = c("WrapInBlockquote", (t) => () => J(q.type(t)));
|
|
583
|
+
n(ke, {
|
|
560
584
|
displayName: "Command<wrapInBlockquoteCommand>",
|
|
561
585
|
group: "Blockquote"
|
|
562
586
|
});
|
|
563
|
-
const
|
|
587
|
+
const he = f("blockquoteKeymap", {
|
|
564
588
|
WrapInBlockquote: {
|
|
565
589
|
shortcuts: "Mod-Shift-b",
|
|
566
590
|
command: (t) => {
|
|
567
|
-
const e = t.get(
|
|
568
|
-
return () => e.call(
|
|
591
|
+
const e = t.get(u);
|
|
592
|
+
return () => e.call(ke.key);
|
|
569
593
|
}
|
|
570
594
|
}
|
|
571
595
|
});
|
|
572
|
-
n(
|
|
596
|
+
n(he.ctx, {
|
|
573
597
|
displayName: "KeymapCtx<blockquote>",
|
|
574
598
|
group: "Blockquote"
|
|
575
599
|
});
|
|
576
|
-
n(
|
|
600
|
+
n(he.shortcuts, {
|
|
577
601
|
displayName: "Keymap<blockquote>",
|
|
578
602
|
group: "Blockquote"
|
|
579
603
|
});
|
|
580
|
-
const
|
|
604
|
+
const fe = N("codeBlock", () => ({
|
|
581
605
|
pre: {},
|
|
582
606
|
code: {}
|
|
583
607
|
}));
|
|
584
|
-
n(
|
|
608
|
+
n(fe, {
|
|
585
609
|
displayName: "Attr<codeBlock>",
|
|
586
610
|
group: "CodeBlock"
|
|
587
611
|
});
|
|
588
|
-
const
|
|
612
|
+
const W = I("code_block", (t) => ({
|
|
589
613
|
content: "text*",
|
|
590
614
|
group: "block",
|
|
591
615
|
marks: "",
|
|
@@ -602,13 +626,13 @@ const F = C("code_block", (t) => ({
|
|
|
602
626
|
preserveWhitespace: "full",
|
|
603
627
|
getAttrs: (e) => {
|
|
604
628
|
if (!(e instanceof HTMLElement))
|
|
605
|
-
throw
|
|
629
|
+
throw w(e);
|
|
606
630
|
return { language: e.dataset.language };
|
|
607
631
|
}
|
|
608
632
|
}
|
|
609
633
|
],
|
|
610
634
|
toDOM: (e) => {
|
|
611
|
-
const r = t.get(
|
|
635
|
+
const r = t.get(fe.key)(e);
|
|
612
636
|
return [
|
|
613
637
|
"pre",
|
|
614
638
|
{
|
|
@@ -635,57 +659,57 @@ const F = C("code_block", (t) => ({
|
|
|
635
659
|
}
|
|
636
660
|
}
|
|
637
661
|
}));
|
|
638
|
-
n(
|
|
662
|
+
n(W.node, {
|
|
639
663
|
displayName: "NodeSchema<codeBlock>",
|
|
640
664
|
group: "CodeBlock"
|
|
641
665
|
});
|
|
642
|
-
n(
|
|
666
|
+
n(W.ctx, {
|
|
643
667
|
displayName: "NodeSchemaCtx<codeBlock>",
|
|
644
668
|
group: "CodeBlock"
|
|
645
669
|
});
|
|
646
|
-
const
|
|
670
|
+
const ut = h((t) => Ze(/^```(?<language>[a-z]*)?[\s\n]$/, W.type(t), (e) => {
|
|
647
671
|
var r;
|
|
648
672
|
return {
|
|
649
673
|
language: ((r = e.groups) == null ? void 0 : r.language) ?? ""
|
|
650
674
|
};
|
|
651
675
|
}));
|
|
652
|
-
n(
|
|
676
|
+
n(ut, {
|
|
653
677
|
displayName: "InputRule<createCodeBlockInputRule>",
|
|
654
678
|
group: "CodeBlock"
|
|
655
679
|
});
|
|
656
|
-
const
|
|
657
|
-
n(
|
|
680
|
+
const Ne = c("CreateCodeBlock", (t) => (e = "") => K(W.type(t), { language: e }));
|
|
681
|
+
n(Ne, {
|
|
658
682
|
displayName: "Command<createCodeBlockCommand>",
|
|
659
683
|
group: "CodeBlock"
|
|
660
684
|
});
|
|
661
|
-
const
|
|
662
|
-
n(
|
|
685
|
+
const Et = c("UpdateCodeBlockLanguage", () => ({ pos: t, language: e } = { pos: -1, language: "" }) => (r, a) => t >= 0 ? (a == null || a(r.tr.setNodeAttribute(t, "language", e)), !0) : !1);
|
|
686
|
+
n(Et, {
|
|
663
687
|
displayName: "Command<updateCodeBlockLanguageCommand>",
|
|
664
688
|
group: "CodeBlock"
|
|
665
689
|
});
|
|
666
|
-
const
|
|
690
|
+
const Ie = f("codeBlockKeymap", {
|
|
667
691
|
CreateCodeBlock: {
|
|
668
692
|
shortcuts: "Mod-Alt-c",
|
|
669
693
|
command: (t) => {
|
|
670
|
-
const e = t.get(
|
|
671
|
-
return () => e.call(
|
|
694
|
+
const e = t.get(u);
|
|
695
|
+
return () => e.call(Ne.key);
|
|
672
696
|
}
|
|
673
697
|
}
|
|
674
698
|
});
|
|
675
|
-
n(
|
|
699
|
+
n(Ie.ctx, {
|
|
676
700
|
displayName: "KeymapCtx<codeBlock>",
|
|
677
701
|
group: "CodeBlock"
|
|
678
702
|
});
|
|
679
|
-
n(
|
|
703
|
+
n(Ie.shortcuts, {
|
|
680
704
|
displayName: "Keymap<codeBlock>",
|
|
681
705
|
group: "CodeBlock"
|
|
682
706
|
});
|
|
683
|
-
const
|
|
684
|
-
n(
|
|
707
|
+
const Ce = N("image");
|
|
708
|
+
n(Ce, {
|
|
685
709
|
displayName: "Attr<image>",
|
|
686
710
|
group: "Image"
|
|
687
711
|
});
|
|
688
|
-
const
|
|
712
|
+
const v = I("image", (t) => ({
|
|
689
713
|
inline: !0,
|
|
690
714
|
group: "inline",
|
|
691
715
|
selectable: !0,
|
|
@@ -704,7 +728,7 @@ const K = C("image", (t) => ({
|
|
|
704
728
|
tag: "img[src]",
|
|
705
729
|
getAttrs: (e) => {
|
|
706
730
|
if (!(e instanceof HTMLElement))
|
|
707
|
-
throw
|
|
731
|
+
throw w(e);
|
|
708
732
|
return {
|
|
709
733
|
src: e.getAttribute("src") || "",
|
|
710
734
|
alt: e.getAttribute("alt") || "",
|
|
@@ -713,15 +737,15 @@ const K = C("image", (t) => ({
|
|
|
713
737
|
}
|
|
714
738
|
}
|
|
715
739
|
],
|
|
716
|
-
toDOM: (e) => ["img", { ...t.get(
|
|
740
|
+
toDOM: (e) => ["img", { ...t.get(Ce.key)(e), ...e.attrs }],
|
|
717
741
|
parseMarkdown: {
|
|
718
742
|
match: ({ type: e }) => e === "image",
|
|
719
743
|
runner: (e, r, a) => {
|
|
720
|
-
const o = r.url, s = r.alt,
|
|
744
|
+
const o = r.url, s = r.alt, l = r.title;
|
|
721
745
|
e.addNode(a, {
|
|
722
746
|
src: o,
|
|
723
747
|
alt: s,
|
|
724
|
-
title:
|
|
748
|
+
title: l
|
|
725
749
|
});
|
|
726
750
|
}
|
|
727
751
|
},
|
|
@@ -736,54 +760,54 @@ const K = C("image", (t) => ({
|
|
|
736
760
|
}
|
|
737
761
|
}
|
|
738
762
|
}));
|
|
739
|
-
n(
|
|
763
|
+
n(v.node, {
|
|
740
764
|
displayName: "NodeSchema<image>",
|
|
741
765
|
group: "Image"
|
|
742
766
|
});
|
|
743
|
-
n(
|
|
767
|
+
n(v.ctx, {
|
|
744
768
|
displayName: "NodeSchemaCtx<image>",
|
|
745
769
|
group: "Image"
|
|
746
770
|
});
|
|
747
|
-
const
|
|
771
|
+
const gt = c("InsertImage", (t) => (e = {}) => (r, a) => {
|
|
748
772
|
if (!a)
|
|
749
773
|
return !0;
|
|
750
|
-
const { src: o = "", alt: s = "", title:
|
|
751
|
-
return
|
|
774
|
+
const { src: o = "", alt: s = "", title: l = "" } = e, i = v.type(t).create({ src: o, alt: s, title: l });
|
|
775
|
+
return i && a(r.tr.replaceSelectionWith(i).scrollIntoView()), !0;
|
|
752
776
|
});
|
|
753
|
-
n(
|
|
777
|
+
n(gt, {
|
|
754
778
|
displayName: "Command<insertImageCommand>",
|
|
755
779
|
group: "Image"
|
|
756
780
|
});
|
|
757
|
-
const
|
|
758
|
-
const o =
|
|
781
|
+
const yt = c("UpdateImage", (t) => (e = {}) => (r, a) => {
|
|
782
|
+
const o = Bt(r.selection, v.type(t));
|
|
759
783
|
if (!o)
|
|
760
784
|
return !1;
|
|
761
|
-
const { node: s, pos:
|
|
762
|
-
return
|
|
785
|
+
const { node: s, pos: l } = o, i = { ...s.attrs }, { src: d, alt: m, title: p } = e;
|
|
786
|
+
return d !== void 0 && (i.src = d), m !== void 0 && (i.alt = m), p !== void 0 && (i.title = p), a == null || a(r.tr.setNodeMarkup(l, void 0, i).scrollIntoView()), !0;
|
|
763
787
|
});
|
|
764
|
-
n(
|
|
788
|
+
n(yt, {
|
|
765
789
|
displayName: "Command<updateImageCommand>",
|
|
766
790
|
group: "Image"
|
|
767
791
|
});
|
|
768
|
-
const
|
|
792
|
+
const Pt = h((t) => new et(
|
|
769
793
|
/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,
|
|
770
794
|
(e, r, a, o) => {
|
|
771
|
-
const [s,
|
|
772
|
-
return s ? e.tr.replaceWith(a, o,
|
|
795
|
+
const [s, l, i = "", d] = r;
|
|
796
|
+
return s ? e.tr.replaceWith(a, o, v.type(t).create({ src: i, alt: l, title: d })) : null;
|
|
773
797
|
}
|
|
774
798
|
));
|
|
775
|
-
n(
|
|
799
|
+
n(Pt, {
|
|
776
800
|
displayName: "InputRule<insertImageInputRule>",
|
|
777
801
|
group: "Image"
|
|
778
802
|
});
|
|
779
|
-
const
|
|
803
|
+
const Me = N("hardbreak", (t) => ({
|
|
780
804
|
"data-is-inline": t.attrs.isInline
|
|
781
805
|
}));
|
|
782
|
-
n(
|
|
806
|
+
n(Me, {
|
|
783
807
|
displayName: "Attr<hardbreak>",
|
|
784
808
|
group: "Hardbreak"
|
|
785
809
|
});
|
|
786
|
-
const S =
|
|
810
|
+
const S = I("hardbreak", (t) => ({
|
|
787
811
|
inline: !0,
|
|
788
812
|
group: "inline",
|
|
789
813
|
attrs: {
|
|
@@ -793,7 +817,7 @@ const S = C("hardbreak", (t) => ({
|
|
|
793
817
|
},
|
|
794
818
|
selectable: !1,
|
|
795
819
|
parseDOM: [{ tag: "br" }],
|
|
796
|
-
toDOM: (e) => ["br", t.get(
|
|
820
|
+
toDOM: (e) => ["br", t.get(Me.key)(e)],
|
|
797
821
|
parseMarkdown: {
|
|
798
822
|
match: ({ type: e }) => e === "break",
|
|
799
823
|
runner: (e, r, a) => {
|
|
@@ -819,50 +843,50 @@ n(S.ctx, {
|
|
|
819
843
|
displayName: "NodeSchemaCtx<hardbreak>",
|
|
820
844
|
group: "Hardbreak"
|
|
821
845
|
});
|
|
822
|
-
const
|
|
846
|
+
const be = c("InsertHardbreak", (t) => () => (e, r) => {
|
|
823
847
|
var s;
|
|
824
848
|
const { selection: a, tr: o } = e;
|
|
825
|
-
if (!(a instanceof
|
|
849
|
+
if (!(a instanceof X))
|
|
826
850
|
return !1;
|
|
827
851
|
if (a.empty) {
|
|
828
|
-
const
|
|
829
|
-
if (
|
|
852
|
+
const l = a.$from.node();
|
|
853
|
+
if (l.childCount > 0 && ((s = l.lastChild) == null ? void 0 : s.type.name) === "hardbreak")
|
|
830
854
|
return r == null || r(
|
|
831
|
-
o.replaceRangeWith(a.to - 1, a.to, e.schema.node("paragraph")).setSelection(
|
|
855
|
+
o.replaceRangeWith(a.to - 1, a.to, e.schema.node("paragraph")).setSelection(tt.near(o.doc.resolve(a.to))).scrollIntoView()
|
|
832
856
|
), !0;
|
|
833
857
|
}
|
|
834
858
|
return r == null || r(o.setMeta("hardbreak", !0).replaceSelectionWith(S.type(t).create()).scrollIntoView()), !0;
|
|
835
859
|
});
|
|
836
|
-
n(
|
|
860
|
+
n(be, {
|
|
837
861
|
displayName: "Command<insertHardbreakCommand>",
|
|
838
862
|
group: "Hardbreak"
|
|
839
863
|
});
|
|
840
|
-
const
|
|
864
|
+
const Le = f("hardbreakKeymap", {
|
|
841
865
|
InsertHardbreak: {
|
|
842
866
|
shortcuts: "Shift-Enter",
|
|
843
867
|
command: (t) => {
|
|
844
|
-
const e = t.get(
|
|
845
|
-
return () => e.call(
|
|
868
|
+
const e = t.get(u);
|
|
869
|
+
return () => e.call(be.key);
|
|
846
870
|
}
|
|
847
871
|
}
|
|
848
872
|
});
|
|
849
|
-
n(
|
|
873
|
+
n(Le.ctx, {
|
|
850
874
|
displayName: "KeymapCtx<hardbreak>",
|
|
851
875
|
group: "Hardbreak"
|
|
852
876
|
});
|
|
853
|
-
n(
|
|
877
|
+
n(Le.shortcuts, {
|
|
854
878
|
displayName: "Keymap<hardbreak>",
|
|
855
879
|
group: "Hardbreak"
|
|
856
880
|
});
|
|
857
|
-
const
|
|
858
|
-
n(
|
|
881
|
+
const xe = N("hr");
|
|
882
|
+
n(xe, {
|
|
859
883
|
displayName: "Attr<hr>",
|
|
860
884
|
group: "Hr"
|
|
861
885
|
});
|
|
862
|
-
const
|
|
886
|
+
const F = I("hr", (t) => ({
|
|
863
887
|
group: "block",
|
|
864
888
|
parseDOM: [{ tag: "hr" }],
|
|
865
|
-
toDOM: (e) => ["hr", t.get(
|
|
889
|
+
toDOM: (e) => ["hr", t.get(xe.key)(e)],
|
|
866
890
|
parseMarkdown: {
|
|
867
891
|
match: ({ type: e }) => e === "thematicBreak",
|
|
868
892
|
runner: (e, r, a) => {
|
|
@@ -876,44 +900,44 @@ const G = C("hr", (t) => ({
|
|
|
876
900
|
}
|
|
877
901
|
}
|
|
878
902
|
}));
|
|
879
|
-
n(
|
|
903
|
+
n(F.node, {
|
|
880
904
|
displayName: "NodeSchema<hr>",
|
|
881
905
|
group: "Hr"
|
|
882
906
|
});
|
|
883
|
-
n(
|
|
907
|
+
n(F.ctx, {
|
|
884
908
|
displayName: "NodeSchemaCtx<hr>",
|
|
885
909
|
group: "Hr"
|
|
886
910
|
});
|
|
887
|
-
const
|
|
911
|
+
const kt = h((t) => new et(
|
|
888
912
|
/^(?:---|___\s|\*\*\*\s)$/,
|
|
889
913
|
(e, r, a, o) => {
|
|
890
914
|
const { tr: s } = e;
|
|
891
|
-
return r[0] && s.replaceWith(a - 1, o,
|
|
915
|
+
return r[0] && s.replaceWith(a - 1, o, F.type(t).create()), s;
|
|
892
916
|
}
|
|
893
917
|
));
|
|
894
|
-
n(
|
|
918
|
+
n(kt, {
|
|
895
919
|
displayName: "InputRule<insertHrInputRule>",
|
|
896
920
|
group: "Hr"
|
|
897
921
|
});
|
|
898
|
-
const
|
|
922
|
+
const ht = c("InsertHr", (t) => () => (e, r) => {
|
|
899
923
|
if (!r)
|
|
900
924
|
return !0;
|
|
901
|
-
const a =
|
|
902
|
-
if (!
|
|
925
|
+
const a = A.node.type(t).create(), { tr: o, selection: s } = e, { from: l } = s, i = F.type(t).create();
|
|
926
|
+
if (!i)
|
|
903
927
|
return !0;
|
|
904
|
-
const
|
|
905
|
-
return
|
|
928
|
+
const d = o.replaceSelectionWith(i).insert(l, a), m = tt.findFrom(d.doc.resolve(l), 1, !0);
|
|
929
|
+
return m && r(d.setSelection(m).scrollIntoView()), !0;
|
|
906
930
|
});
|
|
907
|
-
n(
|
|
931
|
+
n(ht, {
|
|
908
932
|
displayName: "Command<insertHrCommand>",
|
|
909
933
|
group: "Hr"
|
|
910
934
|
});
|
|
911
|
-
const
|
|
912
|
-
n(
|
|
935
|
+
const Se = N("bulletList");
|
|
936
|
+
n(Se, {
|
|
913
937
|
displayName: "Attr<bulletList>",
|
|
914
938
|
group: "BulletList"
|
|
915
939
|
});
|
|
916
|
-
const
|
|
940
|
+
const O = I("bullet_list", (t) => ({
|
|
917
941
|
content: "listItem+",
|
|
918
942
|
group: "block",
|
|
919
943
|
attrs: {
|
|
@@ -926,7 +950,7 @@ const D = C("bullet_list", (t) => ({
|
|
|
926
950
|
tag: "ul",
|
|
927
951
|
getAttrs: (e) => {
|
|
928
952
|
if (!(e instanceof HTMLElement))
|
|
929
|
-
throw
|
|
953
|
+
throw w(e);
|
|
930
954
|
return {
|
|
931
955
|
spread: e.dataset.spread
|
|
932
956
|
};
|
|
@@ -936,7 +960,7 @@ const D = C("bullet_list", (t) => ({
|
|
|
936
960
|
toDOM: (e) => [
|
|
937
961
|
"ul",
|
|
938
962
|
{
|
|
939
|
-
...t.get(
|
|
963
|
+
...t.get(Se.key)(e),
|
|
940
964
|
"data-spread": e.attrs.spread
|
|
941
965
|
},
|
|
942
966
|
0
|
|
@@ -955,47 +979,47 @@ const D = C("bullet_list", (t) => ({
|
|
|
955
979
|
}
|
|
956
980
|
}
|
|
957
981
|
}));
|
|
958
|
-
n(
|
|
982
|
+
n(O.node, {
|
|
959
983
|
displayName: "NodeSchema<bulletList>",
|
|
960
984
|
group: "BulletList"
|
|
961
985
|
});
|
|
962
|
-
n(
|
|
986
|
+
n(O.ctx, {
|
|
963
987
|
displayName: "NodeSchemaCtx<bulletList>",
|
|
964
988
|
group: "BulletList"
|
|
965
989
|
});
|
|
966
|
-
const
|
|
967
|
-
n(
|
|
990
|
+
const ft = h((t) => Q(/^\s*([-+*])\s$/, O.type(t)));
|
|
991
|
+
n(ft, {
|
|
968
992
|
displayName: "InputRule<wrapInBulletListInputRule>",
|
|
969
993
|
group: "BulletList"
|
|
970
994
|
});
|
|
971
|
-
const
|
|
972
|
-
n(
|
|
995
|
+
const we = c("WrapInBulletList", (t) => () => J(O.type(t)));
|
|
996
|
+
n(we, {
|
|
973
997
|
displayName: "Command<wrapInBulletListCommand>",
|
|
974
998
|
group: "BulletList"
|
|
975
999
|
});
|
|
976
|
-
const
|
|
1000
|
+
const Ae = f("bulletListKeymap", {
|
|
977
1001
|
WrapInBulletList: {
|
|
978
1002
|
shortcuts: "Mod-Alt-8",
|
|
979
1003
|
command: (t) => {
|
|
980
|
-
const e = t.get(
|
|
981
|
-
return () => e.call(
|
|
1004
|
+
const e = t.get(u);
|
|
1005
|
+
return () => e.call(we.key);
|
|
982
1006
|
}
|
|
983
1007
|
}
|
|
984
1008
|
});
|
|
985
|
-
n(
|
|
1009
|
+
n(Ae.ctx, {
|
|
986
1010
|
displayName: "KeymapCtx<bulletListKeymap>",
|
|
987
1011
|
group: "BulletList"
|
|
988
1012
|
});
|
|
989
|
-
n(
|
|
1013
|
+
n(Ae.shortcuts, {
|
|
990
1014
|
displayName: "Keymap<bulletListKeymap>",
|
|
991
1015
|
group: "BulletList"
|
|
992
1016
|
});
|
|
993
|
-
const
|
|
994
|
-
n(
|
|
1017
|
+
const He = N("orderedList");
|
|
1018
|
+
n(He, {
|
|
995
1019
|
displayName: "Attr<orderedList>",
|
|
996
1020
|
group: "OrderedList"
|
|
997
1021
|
});
|
|
998
|
-
const
|
|
1022
|
+
const T = I("ordered_list", (t) => ({
|
|
999
1023
|
content: "listItem+",
|
|
1000
1024
|
group: "block",
|
|
1001
1025
|
attrs: {
|
|
@@ -1011,7 +1035,7 @@ const P = C("ordered_list", (t) => ({
|
|
|
1011
1035
|
tag: "ol",
|
|
1012
1036
|
getAttrs: (e) => {
|
|
1013
1037
|
if (!(e instanceof HTMLElement))
|
|
1014
|
-
throw
|
|
1038
|
+
throw w(e);
|
|
1015
1039
|
return {
|
|
1016
1040
|
spread: e.dataset.spread,
|
|
1017
1041
|
order: e.hasAttribute("start") ? Number(e.getAttribute("start")) : 1
|
|
@@ -1022,7 +1046,7 @@ const P = C("ordered_list", (t) => ({
|
|
|
1022
1046
|
toDOM: (e) => [
|
|
1023
1047
|
"ol",
|
|
1024
1048
|
{
|
|
1025
|
-
...t.get(
|
|
1049
|
+
...t.get(He.key)(e),
|
|
1026
1050
|
...e.attrs.order === 1 ? {} : e.attrs.order,
|
|
1027
1051
|
"data-spread": e.attrs.spread
|
|
1028
1052
|
},
|
|
@@ -1042,52 +1066,52 @@ const P = C("ordered_list", (t) => ({
|
|
|
1042
1066
|
}
|
|
1043
1067
|
}
|
|
1044
1068
|
}));
|
|
1045
|
-
n(
|
|
1069
|
+
n(T.node, {
|
|
1046
1070
|
displayName: "NodeSchema<orderedList>",
|
|
1047
1071
|
group: "OrderedList"
|
|
1048
1072
|
});
|
|
1049
|
-
n(
|
|
1073
|
+
n(T.ctx, {
|
|
1050
1074
|
displayName: "NodeSchemaCtx<orderedList>",
|
|
1051
1075
|
group: "OrderedList"
|
|
1052
1076
|
});
|
|
1053
|
-
const
|
|
1077
|
+
const Nt = h((t) => Q(
|
|
1054
1078
|
/^\s*(\d+)\.\s$/,
|
|
1055
|
-
|
|
1079
|
+
T.type(t),
|
|
1056
1080
|
(e) => ({ order: Number(e[1]) }),
|
|
1057
1081
|
(e, r) => r.childCount + r.attrs.order === Number(e[1])
|
|
1058
1082
|
));
|
|
1059
|
-
n(
|
|
1083
|
+
n(Nt, {
|
|
1060
1084
|
displayName: "InputRule<wrapInOrderedListInputRule>",
|
|
1061
1085
|
group: "OrderedList"
|
|
1062
1086
|
});
|
|
1063
|
-
const
|
|
1064
|
-
n(
|
|
1087
|
+
const Be = c("WrapInOrderedList", (t) => () => J(T.type(t)));
|
|
1088
|
+
n(Be, {
|
|
1065
1089
|
displayName: "Command<wrapInOrderedListCommand>",
|
|
1066
1090
|
group: "OrderedList"
|
|
1067
1091
|
});
|
|
1068
|
-
const
|
|
1092
|
+
const Re = f("orderedListKeymap", {
|
|
1069
1093
|
WrapInOrderedList: {
|
|
1070
1094
|
shortcuts: "Mod-Alt-7",
|
|
1071
1095
|
command: (t) => {
|
|
1072
|
-
const e = t.get(
|
|
1073
|
-
return () => e.call(
|
|
1096
|
+
const e = t.get(u);
|
|
1097
|
+
return () => e.call(Be.key);
|
|
1074
1098
|
}
|
|
1075
1099
|
}
|
|
1076
1100
|
});
|
|
1077
|
-
n(
|
|
1101
|
+
n(Re.ctx, {
|
|
1078
1102
|
displayName: "KeymapCtx<orderedList>",
|
|
1079
1103
|
group: "OrderedList"
|
|
1080
1104
|
});
|
|
1081
|
-
n(
|
|
1105
|
+
n(Re.shortcuts, {
|
|
1082
1106
|
displayName: "Keymap<orderedList>",
|
|
1083
1107
|
group: "OrderedList"
|
|
1084
1108
|
});
|
|
1085
|
-
const
|
|
1086
|
-
n(
|
|
1109
|
+
const ve = N("listItem");
|
|
1110
|
+
n(ve, {
|
|
1087
1111
|
displayName: "Attr<listItem>",
|
|
1088
1112
|
group: "ListItem"
|
|
1089
1113
|
});
|
|
1090
|
-
const M =
|
|
1114
|
+
const M = I("list_item", (t) => ({
|
|
1091
1115
|
group: "listItem",
|
|
1092
1116
|
content: "paragraph block*",
|
|
1093
1117
|
attrs: {
|
|
@@ -1107,7 +1131,7 @@ const M = C("list_item", (t) => ({
|
|
|
1107
1131
|
tag: "li",
|
|
1108
1132
|
getAttrs: (e) => {
|
|
1109
1133
|
if (!(e instanceof HTMLElement))
|
|
1110
|
-
throw
|
|
1134
|
+
throw w(e);
|
|
1111
1135
|
return {
|
|
1112
1136
|
label: e.dataset.label,
|
|
1113
1137
|
listType: e.dataset["list-type"],
|
|
@@ -1119,7 +1143,7 @@ const M = C("list_item", (t) => ({
|
|
|
1119
1143
|
toDOM: (e) => [
|
|
1120
1144
|
"li",
|
|
1121
1145
|
{
|
|
1122
|
-
...t.get(
|
|
1146
|
+
...t.get(ve.key)(e),
|
|
1123
1147
|
"data-label": e.attrs.label,
|
|
1124
1148
|
"data-list-type": e.attrs.listType,
|
|
1125
1149
|
"data-spread": e.attrs.spread
|
|
@@ -1129,8 +1153,8 @@ const M = C("list_item", (t) => ({
|
|
|
1129
1153
|
parseMarkdown: {
|
|
1130
1154
|
match: ({ type: e }) => e === "listItem",
|
|
1131
1155
|
runner: (e, r, a) => {
|
|
1132
|
-
const o = r.label != null ? `${r.label}.` : "•", s = r.label != null ? "ordered" : "bullet",
|
|
1133
|
-
e.openNode(a, { label: o, listType: s, spread:
|
|
1156
|
+
const o = r.label != null ? `${r.label}.` : "•", s = r.label != null ? "ordered" : "bullet", l = r.spread != null ? `${r.spread}` : "true";
|
|
1157
|
+
e.openNode(a, { label: o, listType: s, spread: l }), e.next(r.children), e.closeNode();
|
|
1134
1158
|
}
|
|
1135
1159
|
},
|
|
1136
1160
|
toMarkdown: {
|
|
@@ -1148,77 +1172,77 @@ n(M.ctx, {
|
|
|
1148
1172
|
displayName: "NodeSchemaCtx<listItem>",
|
|
1149
1173
|
group: "ListItem"
|
|
1150
1174
|
});
|
|
1151
|
-
const
|
|
1152
|
-
n(
|
|
1175
|
+
const Oe = c("SinkListItem", (t) => () => Rt(M.type(t)));
|
|
1176
|
+
n(Oe, {
|
|
1153
1177
|
displayName: "Command<sinkListItemCommand>",
|
|
1154
1178
|
group: "ListItem"
|
|
1155
1179
|
});
|
|
1156
|
-
const
|
|
1157
|
-
n(
|
|
1180
|
+
const Te = c("SplitListItem", (t) => () => rt(M.type(t)));
|
|
1181
|
+
n(Te, {
|
|
1158
1182
|
displayName: "Command<liftListItemCommand>",
|
|
1159
1183
|
group: "ListItem"
|
|
1160
1184
|
});
|
|
1161
|
-
const
|
|
1162
|
-
n(
|
|
1185
|
+
const Ke = c("SplitListItem", (t) => () => vt(M.type(t)));
|
|
1186
|
+
n(Ke, {
|
|
1163
1187
|
displayName: "Command<splitListItemCommand>",
|
|
1164
1188
|
group: "ListItem"
|
|
1165
1189
|
});
|
|
1166
|
-
function
|
|
1190
|
+
function $t(t) {
|
|
1167
1191
|
return (e, r, a) => {
|
|
1168
1192
|
const { selection: o } = e;
|
|
1169
|
-
if (!(o instanceof
|
|
1193
|
+
if (!(o instanceof X))
|
|
1170
1194
|
return !1;
|
|
1171
|
-
const { empty: s, $from:
|
|
1172
|
-
if (!s ||
|
|
1195
|
+
const { empty: s, $from: l } = o;
|
|
1196
|
+
if (!s || l.parentOffset !== 0)
|
|
1173
1197
|
return !1;
|
|
1174
|
-
const
|
|
1175
|
-
return
|
|
1198
|
+
const i = l.node(-1);
|
|
1199
|
+
return i.type !== M.type(t) || i.firstChild !== l.node() || l.node(-2).childCount > 1 ? !1 : rt(M.type(t))(e, r, a);
|
|
1176
1200
|
};
|
|
1177
1201
|
}
|
|
1178
|
-
const
|
|
1179
|
-
n(
|
|
1202
|
+
const De = c("LiftFirstListItem", (t) => () => $t(t));
|
|
1203
|
+
n(De, {
|
|
1180
1204
|
displayName: "Command<liftFirstListItemCommand>",
|
|
1181
1205
|
group: "ListItem"
|
|
1182
1206
|
});
|
|
1183
|
-
const
|
|
1207
|
+
const _e = f("listItemKeymap", {
|
|
1184
1208
|
NextListItem: {
|
|
1185
1209
|
shortcuts: "Enter",
|
|
1186
1210
|
command: (t) => {
|
|
1187
|
-
const e = t.get(
|
|
1188
|
-
return () => e.call(
|
|
1211
|
+
const e = t.get(u);
|
|
1212
|
+
return () => e.call(Ke.key);
|
|
1189
1213
|
}
|
|
1190
1214
|
},
|
|
1191
1215
|
SinkListItem: {
|
|
1192
1216
|
shortcuts: ["Tab", "Mod-]"],
|
|
1193
1217
|
command: (t) => {
|
|
1194
|
-
const e = t.get(
|
|
1195
|
-
return () => e.call(
|
|
1218
|
+
const e = t.get(u);
|
|
1219
|
+
return () => e.call(Oe.key);
|
|
1196
1220
|
}
|
|
1197
1221
|
},
|
|
1198
1222
|
LiftListItem: {
|
|
1199
1223
|
shortcuts: ["Shift-Tab", "Mod-["],
|
|
1200
1224
|
command: (t) => {
|
|
1201
|
-
const e = t.get(
|
|
1202
|
-
return () => e.call(
|
|
1225
|
+
const e = t.get(u);
|
|
1226
|
+
return () => e.call(Te.key);
|
|
1203
1227
|
}
|
|
1204
1228
|
},
|
|
1205
1229
|
LiftFirstListItem: {
|
|
1206
1230
|
shortcuts: ["Backspace", "Delete"],
|
|
1207
1231
|
command: (t) => {
|
|
1208
|
-
const e = t.get(
|
|
1209
|
-
return () => e.call(
|
|
1232
|
+
const e = t.get(u);
|
|
1233
|
+
return () => e.call(De.key);
|
|
1210
1234
|
}
|
|
1211
1235
|
}
|
|
1212
1236
|
});
|
|
1213
|
-
n(
|
|
1237
|
+
n(_e.ctx, {
|
|
1214
1238
|
displayName: "KeymapCtx<listItem>",
|
|
1215
1239
|
group: "ListItem"
|
|
1216
1240
|
});
|
|
1217
|
-
n(
|
|
1241
|
+
n(_e.shortcuts, {
|
|
1218
1242
|
displayName: "Keymap<listItem>",
|
|
1219
1243
|
group: "ListItem"
|
|
1220
1244
|
});
|
|
1221
|
-
const
|
|
1245
|
+
const It = Qe("text", () => ({
|
|
1222
1246
|
group: "inline",
|
|
1223
1247
|
parseMarkdown: {
|
|
1224
1248
|
match: ({ type: t }) => t === "text",
|
|
@@ -1233,16 +1257,16 @@ const Lt = ot("text", () => ({
|
|
|
1233
1257
|
}
|
|
1234
1258
|
}
|
|
1235
1259
|
}));
|
|
1236
|
-
n(
|
|
1260
|
+
n(It, {
|
|
1237
1261
|
displayName: "NodeSchema<text>",
|
|
1238
1262
|
group: "Text"
|
|
1239
1263
|
});
|
|
1240
|
-
const
|
|
1241
|
-
n(
|
|
1264
|
+
const Ee = N("html");
|
|
1265
|
+
n(Ee, {
|
|
1242
1266
|
displayName: "Attr<html>",
|
|
1243
1267
|
group: "Html"
|
|
1244
1268
|
});
|
|
1245
|
-
const
|
|
1269
|
+
const Pe = I("html", (t) => ({
|
|
1246
1270
|
atom: !0,
|
|
1247
1271
|
group: "inline",
|
|
1248
1272
|
inline: !0,
|
|
@@ -1253,7 +1277,7 @@ const Ye = C("html", (t) => ({
|
|
|
1253
1277
|
},
|
|
1254
1278
|
toDOM: (e) => {
|
|
1255
1279
|
const r = document.createElement("span"), a = {
|
|
1256
|
-
...t.get(
|
|
1280
|
+
...t.get(Ee.key)(e),
|
|
1257
1281
|
"data-value": e.attrs.value,
|
|
1258
1282
|
"data-type": "html"
|
|
1259
1283
|
};
|
|
@@ -1278,248 +1302,95 @@ const Ye = C("html", (t) => ({
|
|
|
1278
1302
|
}
|
|
1279
1303
|
}
|
|
1280
1304
|
}));
|
|
1281
|
-
n(
|
|
1305
|
+
n(Pe.node, {
|
|
1282
1306
|
displayName: "NodeSchema<html>",
|
|
1283
1307
|
group: "Html"
|
|
1284
1308
|
});
|
|
1285
|
-
n(
|
|
1309
|
+
n(Pe.ctx, {
|
|
1286
1310
|
displayName: "NodeSchemaCtx<html>",
|
|
1287
1311
|
group: "Html"
|
|
1288
1312
|
});
|
|
1289
|
-
const
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1313
|
+
const qt = [
|
|
1314
|
+
mt,
|
|
1315
|
+
de,
|
|
1316
|
+
A,
|
|
1317
|
+
j,
|
|
1318
|
+
ce,
|
|
1295
1319
|
H,
|
|
1296
|
-
|
|
1320
|
+
Me,
|
|
1297
1321
|
S,
|
|
1298
|
-
|
|
1322
|
+
ye,
|
|
1323
|
+
q,
|
|
1324
|
+
fe,
|
|
1299
1325
|
W,
|
|
1300
|
-
|
|
1326
|
+
xe,
|
|
1301
1327
|
F,
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
P,
|
|
1310
|
-
We,
|
|
1328
|
+
Ce,
|
|
1329
|
+
v,
|
|
1330
|
+
Se,
|
|
1331
|
+
O,
|
|
1332
|
+
He,
|
|
1333
|
+
T,
|
|
1334
|
+
ve,
|
|
1311
1335
|
M,
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1336
|
+
Z,
|
|
1337
|
+
R,
|
|
1338
|
+
re,
|
|
1339
|
+
$,
|
|
1340
|
+
oe,
|
|
1317
1341
|
x,
|
|
1318
|
-
|
|
1342
|
+
ie,
|
|
1319
1343
|
B,
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
].flat(),
|
|
1324
|
-
|
|
1325
|
-
Mt,
|
|
1326
|
-
bt,
|
|
1327
|
-
kt,
|
|
1328
|
-
It,
|
|
1329
|
-
yt
|
|
1330
|
-
].flat(), Jt = [
|
|
1331
|
-
Ie,
|
|
1332
|
-
Se,
|
|
1333
|
-
b,
|
|
1334
|
-
be,
|
|
1335
|
-
ve,
|
|
1336
|
-
Te,
|
|
1337
|
-
Ct,
|
|
1344
|
+
Ee,
|
|
1345
|
+
Pe,
|
|
1346
|
+
It
|
|
1347
|
+
].flat(), Wt = [
|
|
1348
|
+
ct,
|
|
1338
1349
|
ft,
|
|
1339
1350
|
Nt,
|
|
1340
|
-
$e,
|
|
1341
|
-
Pe,
|
|
1342
|
-
Fe,
|
|
1343
|
-
Ve,
|
|
1344
|
-
Ge,
|
|
1345
|
-
je,
|
|
1346
|
-
de,
|
|
1347
|
-
he,
|
|
1348
|
-
pe,
|
|
1349
1351
|
ut,
|
|
1352
|
+
kt,
|
|
1350
1353
|
pt
|
|
1351
|
-
],
|
|
1354
|
+
].flat(), Ft = [
|
|
1355
|
+
nt,
|
|
1356
|
+
ot,
|
|
1357
|
+
lt,
|
|
1358
|
+
st
|
|
1359
|
+
], Vt = [
|
|
1360
|
+
me,
|
|
1361
|
+
ke,
|
|
1362
|
+
L,
|
|
1363
|
+
ue,
|
|
1364
|
+
Ne,
|
|
1365
|
+
be,
|
|
1366
|
+
ht,
|
|
1367
|
+
gt,
|
|
1368
|
+
yt,
|
|
1369
|
+
Be,
|
|
1352
1370
|
we,
|
|
1353
|
-
|
|
1354
|
-
|
|
1371
|
+
Oe,
|
|
1372
|
+
Ke,
|
|
1373
|
+
Te,
|
|
1374
|
+
De,
|
|
1375
|
+
ee,
|
|
1376
|
+
se,
|
|
1377
|
+
ae,
|
|
1378
|
+
it,
|
|
1379
|
+
dt
|
|
1380
|
+
], Ut = [
|
|
1381
|
+
he,
|
|
1382
|
+
Ie,
|
|
1355
1383
|
Le,
|
|
1356
|
-
|
|
1357
|
-
qe,
|
|
1384
|
+
ge,
|
|
1358
1385
|
_e,
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
const Z = "", ee = `${Z}*`, te = `${Z}*`, re = `${Z}_`, ae = `${Z}⎽`;
|
|
1368
|
-
function tr(t) {
|
|
1369
|
-
let e = t, r = e.match(Q);
|
|
1370
|
-
for (; r && r.groups; ) {
|
|
1371
|
-
const { span: a } = r.groups;
|
|
1372
|
-
e = e.replace(Q, a), r = e.match(Q);
|
|
1373
|
-
}
|
|
1374
|
-
return e;
|
|
1375
|
-
}
|
|
1376
|
-
function rr(t) {
|
|
1377
|
-
return t.replaceAll(/\\\\\*/g, ee).replaceAll(/\\\\_/g, re).replaceAll(ee, te).replaceAll(re, ae);
|
|
1378
|
-
}
|
|
1379
|
-
function ar(t, e, r) {
|
|
1380
|
-
const a = t.split(""), o = a[e];
|
|
1381
|
-
return a[e] && a[r] && (a[e] = a[r], a[r] = o), a.join("").toString();
|
|
1382
|
-
}
|
|
1383
|
-
function nr(t) {
|
|
1384
|
-
return (e) => e.replace(er(t), "");
|
|
1385
|
-
}
|
|
1386
|
-
function or(t) {
|
|
1387
|
-
return (e) => {
|
|
1388
|
-
const r = e.indexOf(t.hole), a = e.charAt(r - 1), o = e.charAt(r + 1), s = /[^\w]|_/;
|
|
1389
|
-
return o ? a && s.test(a) && s.test(o) ? t.punctuation : t.char : t.punctuation;
|
|
1390
|
-
};
|
|
1391
|
-
}
|
|
1392
|
-
function sr(t, e, r) {
|
|
1393
|
-
let a = e, o = !1;
|
|
1394
|
-
return t.descendants((s) => {
|
|
1395
|
-
var i;
|
|
1396
|
-
if (o)
|
|
1397
|
-
return !1;
|
|
1398
|
-
if (!s.textContent.includes(r))
|
|
1399
|
-
return a += s.nodeSize, !1;
|
|
1400
|
-
if (s.isText) {
|
|
1401
|
-
const l = (i = s.text) == null ? void 0 : i.indexOf(r);
|
|
1402
|
-
if (l != null && l >= 0)
|
|
1403
|
-
return o = !0, a += l, !1;
|
|
1404
|
-
}
|
|
1405
|
-
return a += 1, !0;
|
|
1406
|
-
}), a;
|
|
1407
|
-
}
|
|
1408
|
-
const lr = {
|
|
1409
|
-
placeholderConfig: {
|
|
1410
|
-
hole: "∅",
|
|
1411
|
-
punctuation: "⁂",
|
|
1412
|
-
char: "∴"
|
|
1413
|
-
},
|
|
1414
|
-
globalNodes: ["footnote_definition"],
|
|
1415
|
-
shouldSyncNode: ({ prevNode: t, nextNode: e }) => t.inlineContent && e && t.type === e.type && !t.eq(e),
|
|
1416
|
-
movePlaceholder: (t, e) => {
|
|
1417
|
-
const r = ["*", "_"];
|
|
1418
|
-
let a = e.indexOf(t);
|
|
1419
|
-
for (; r.includes(e[a - 1] || "") && r.includes(e[a + 1] || ""); )
|
|
1420
|
-
e = ar(e, a, a + 1), a = a + 1;
|
|
1421
|
-
return e;
|
|
1422
|
-
}
|
|
1423
|
-
}, _ = ne(lr, "inlineSyncConfig");
|
|
1424
|
-
n(_, {
|
|
1425
|
-
displayName: "Ctx<inlineSyncConfig>",
|
|
1426
|
-
group: "Prose"
|
|
1427
|
-
});
|
|
1428
|
-
function ir(t) {
|
|
1429
|
-
return t.selection.$from.node();
|
|
1430
|
-
}
|
|
1431
|
-
function cr(t, e, r, a) {
|
|
1432
|
-
const o = t.get(Rt), s = e.schema.topNodeType.create(void 0, [r, ...a]);
|
|
1433
|
-
return o(s);
|
|
1434
|
-
}
|
|
1435
|
-
function dr(t, e) {
|
|
1436
|
-
const r = t.get(_.key), a = r.placeholderConfig.hole, [o = "", ...s] = e.split(`
|
|
1437
|
-
|
|
1438
|
-
`), i = (m) => r.movePlaceholder(a, m);
|
|
1439
|
-
let c = Tt(nr(a), i, tr, rr)(o);
|
|
1440
|
-
const d = or(r.placeholderConfig)(c);
|
|
1441
|
-
return c = c.replace(a, d), c = [c, ...s].join(`
|
|
1442
|
-
|
|
1443
|
-
`), [c, d];
|
|
1444
|
-
}
|
|
1445
|
-
function mr(t, e) {
|
|
1446
|
-
const a = t.get(Kt)(e);
|
|
1447
|
-
return a ? a.firstChild : null;
|
|
1448
|
-
}
|
|
1449
|
-
function ur(t, e) {
|
|
1450
|
-
const { globalNodes: r } = t.get(_.key), a = [];
|
|
1451
|
-
return e.doc.descendants((o) => {
|
|
1452
|
-
if (r.includes(o.type.name) || r.includes(o.type))
|
|
1453
|
-
return a.push(o), !1;
|
|
1454
|
-
}), a;
|
|
1455
|
-
}
|
|
1456
|
-
const pr = (t) => t.split(`
|
|
1457
|
-
|
|
1458
|
-
`)[0] || "";
|
|
1459
|
-
function gr(t) {
|
|
1460
|
-
return t.childCount === 1 && t.child(0).type.name === "html";
|
|
1461
|
-
}
|
|
1462
|
-
function xt(t, e) {
|
|
1463
|
-
try {
|
|
1464
|
-
const r = ur(t, e), a = ir(e), o = cr(t, e, a, r), [s, i] = dr(t, o), l = mr(t, s);
|
|
1465
|
-
return !l || a.type !== l.type || gr(l) ? null : (l.attrs = { ...a.attrs }, l.descendants((c) => {
|
|
1466
|
-
var g, u, k;
|
|
1467
|
-
const m = c.marks.find((p) => p.type.name === "link");
|
|
1468
|
-
m && ((g = c.text) != null && g.includes(i)) && m.attrs.href.includes(i) && (m.attrs.href = m.attrs.href.replace(i, "")), ((u = c.text) != null && u.includes(te) || (k = c.text) != null && k.includes(ae)) && (c.text = c.text.replaceAll(te, ee).replaceAll(ae, re));
|
|
1469
|
-
}), {
|
|
1470
|
-
text: pr(s),
|
|
1471
|
-
prevNode: a,
|
|
1472
|
-
nextNode: l,
|
|
1473
|
-
placeholder: i
|
|
1474
|
-
});
|
|
1475
|
-
} catch {
|
|
1476
|
-
return null;
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
function yr(t, e, r, a, o) {
|
|
1480
|
-
var L;
|
|
1481
|
-
const { placeholderConfig: s } = t.get(_.key), i = s.hole;
|
|
1482
|
-
let l = r.tr.setMeta(e, !0).insertText(i, r.selection.from);
|
|
1483
|
-
const c = r.apply(l), d = xt(t, c);
|
|
1484
|
-
if (!d)
|
|
1485
|
-
return;
|
|
1486
|
-
const m = d.text.slice(0, d.text.indexOf(d.placeholder)), { $from: g } = c.selection, u = g.before(), k = g.after(), p = sr(d.nextNode, u, d.placeholder);
|
|
1487
|
-
l = l.replaceWith(u, k, d.nextNode).setNodeMarkup(u, void 0, o).delete(p + 1, p + 2), l = l.setSelection($.near(l.doc.resolve(p + 1))), (Xt.test(m) || ["*", "_", "~"].includes(m.at(-1) || "")) && l.selection instanceof $ && (((L = l.selection.$cursor) == null ? void 0 : L.marks()) ?? []).forEach((J) => {
|
|
1488
|
-
l = l.removeStoredMark(J.type);
|
|
1489
|
-
}), a(l);
|
|
1490
|
-
}
|
|
1491
|
-
const St = O((t) => {
|
|
1492
|
-
let e = null;
|
|
1493
|
-
const r = new T("MILKDOWN_INLINE_SYNC");
|
|
1494
|
-
return new R({
|
|
1495
|
-
key: r,
|
|
1496
|
-
state: {
|
|
1497
|
-
init: () => null,
|
|
1498
|
-
apply: (a, o, s, i) => {
|
|
1499
|
-
var p;
|
|
1500
|
-
const l = t.get(X);
|
|
1501
|
-
if (!((p = l.hasFocus) != null && p.call(l)) || !l.editable || !a.docChanged || a.getMeta(r))
|
|
1502
|
-
return null;
|
|
1503
|
-
const d = xt(t, i);
|
|
1504
|
-
if (!d)
|
|
1505
|
-
return null;
|
|
1506
|
-
e && (cancelAnimationFrame(e), e = null);
|
|
1507
|
-
const { prevNode: m, nextNode: g, text: u } = d, { shouldSyncNode: k } = t.get(_.key);
|
|
1508
|
-
return k({ prevNode: m, nextNode: g, ctx: t, tr: a, text: u }) && (e = requestAnimationFrame(() => {
|
|
1509
|
-
e = null;
|
|
1510
|
-
const { dispatch: f, state: L } = t.get(X);
|
|
1511
|
-
yr(t, r, L, f, m.attrs);
|
|
1512
|
-
})), null;
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
1515
|
-
});
|
|
1516
|
-
});
|
|
1517
|
-
n(St, {
|
|
1518
|
-
displayName: "Prose<inlineSyncPlugin>",
|
|
1519
|
-
group: "Prose"
|
|
1520
|
-
});
|
|
1521
|
-
const Ze = q("remarkAddOrderInList", () => () => (t) => {
|
|
1522
|
-
ie(t, "list", (e) => {
|
|
1386
|
+
Re,
|
|
1387
|
+
Ae,
|
|
1388
|
+
pe,
|
|
1389
|
+
te,
|
|
1390
|
+
le,
|
|
1391
|
+
ne
|
|
1392
|
+
].flat(), $e = D("remarkAddOrderInList", () => () => (t) => {
|
|
1393
|
+
Y(t, "list", (e) => {
|
|
1523
1394
|
if (e.ordered) {
|
|
1524
1395
|
const r = e.start ?? 1;
|
|
1525
1396
|
e.children.forEach((a, o) => {
|
|
@@ -1528,98 +1399,98 @@ const Ze = q("remarkAddOrderInList", () => () => (t) => {
|
|
|
1528
1399
|
}
|
|
1529
1400
|
});
|
|
1530
1401
|
});
|
|
1531
|
-
n(
|
|
1402
|
+
n($e.plugin, {
|
|
1532
1403
|
displayName: "Remark<remarkAddOrderInListPlugin>",
|
|
1533
1404
|
group: "Remark"
|
|
1534
1405
|
});
|
|
1535
|
-
n(
|
|
1406
|
+
n($e.options, {
|
|
1536
1407
|
displayName: "RemarkConfig<remarkAddOrderInListPlugin>",
|
|
1537
1408
|
group: "Remark"
|
|
1538
1409
|
});
|
|
1539
|
-
const
|
|
1410
|
+
const qe = D("remarkLineBreak", () => () => (t) => {
|
|
1540
1411
|
const e = /[\t ]*(?:\r?\n|\r)/g;
|
|
1541
|
-
|
|
1412
|
+
Y(t, "text", (r, a, o) => {
|
|
1542
1413
|
if (!r.value || typeof r.value != "string")
|
|
1543
1414
|
return;
|
|
1544
1415
|
const s = [];
|
|
1545
|
-
let
|
|
1416
|
+
let l = 0;
|
|
1546
1417
|
e.lastIndex = 0;
|
|
1547
|
-
let
|
|
1548
|
-
for (;
|
|
1549
|
-
const
|
|
1550
|
-
|
|
1418
|
+
let i = e.exec(r.value);
|
|
1419
|
+
for (; i; ) {
|
|
1420
|
+
const m = i.index;
|
|
1421
|
+
l !== m && s.push({ type: "text", value: r.value.slice(l, m) }), s.push({ type: "break", data: { isInline: !0 } }), l = m + i[0].length, i = e.exec(r.value);
|
|
1551
1422
|
}
|
|
1552
1423
|
if (s.length > 0 && o && typeof a == "number")
|
|
1553
|
-
return
|
|
1424
|
+
return l < r.value.length && s.push({ type: "text", value: r.value.slice(l) }), o.children.splice(a, 1, ...s), a + s.length;
|
|
1554
1425
|
});
|
|
1555
1426
|
});
|
|
1556
|
-
n(
|
|
1427
|
+
n(qe.plugin, {
|
|
1557
1428
|
displayName: "Remark<remarkLineBreak>",
|
|
1558
1429
|
group: "Remark"
|
|
1559
1430
|
});
|
|
1560
|
-
n(
|
|
1431
|
+
n(qe.options, {
|
|
1561
1432
|
displayName: "RemarkConfig<remarkLineBreak>",
|
|
1562
1433
|
group: "Remark"
|
|
1563
1434
|
});
|
|
1564
|
-
const
|
|
1565
|
-
n(
|
|
1435
|
+
const We = D("remarkInlineLink", () => Kt);
|
|
1436
|
+
n(We.plugin, {
|
|
1566
1437
|
displayName: "Remark<remarkInlineLinkPlugin>",
|
|
1567
1438
|
group: "Remark"
|
|
1568
1439
|
});
|
|
1569
|
-
n(
|
|
1440
|
+
n(We.options, {
|
|
1570
1441
|
displayName: "RemarkConfig<remarkInlineLinkPlugin>",
|
|
1571
1442
|
group: "Remark"
|
|
1572
1443
|
});
|
|
1573
|
-
const
|
|
1574
|
-
function
|
|
1444
|
+
const Gt = (t) => !!t.children, jt = (t) => t.type === "html";
|
|
1445
|
+
function zt(t, e) {
|
|
1575
1446
|
return r(t, 0, null)[0];
|
|
1576
1447
|
function r(a, o, s) {
|
|
1577
|
-
if (
|
|
1578
|
-
const
|
|
1579
|
-
for (let
|
|
1580
|
-
const
|
|
1581
|
-
if (
|
|
1582
|
-
const
|
|
1583
|
-
if (
|
|
1584
|
-
for (let
|
|
1585
|
-
const
|
|
1586
|
-
|
|
1448
|
+
if (Gt(a)) {
|
|
1449
|
+
const l = [];
|
|
1450
|
+
for (let i = 0, d = a.children.length; i < d; i++) {
|
|
1451
|
+
const m = a.children[i];
|
|
1452
|
+
if (m) {
|
|
1453
|
+
const p = r(m, i, a);
|
|
1454
|
+
if (p)
|
|
1455
|
+
for (let k = 0, g = p.length; k < g; k++) {
|
|
1456
|
+
const C = p[k];
|
|
1457
|
+
C && l.push(C);
|
|
1587
1458
|
}
|
|
1588
1459
|
}
|
|
1589
1460
|
}
|
|
1590
|
-
a.children =
|
|
1461
|
+
a.children = l;
|
|
1591
1462
|
}
|
|
1592
1463
|
return e(a, o, s);
|
|
1593
1464
|
}
|
|
1594
1465
|
}
|
|
1595
|
-
const
|
|
1596
|
-
|
|
1466
|
+
const Fe = D("remarkHTMLTransformer", () => () => (t) => {
|
|
1467
|
+
zt(t, (e, r, a) => jt(e) ? ((a == null ? void 0 : a.type) === "root" && (e.children = [{ ...e }], delete e.value, e.type = "paragraph"), [e]) : [e]);
|
|
1597
1468
|
});
|
|
1598
|
-
n(
|
|
1469
|
+
n(Fe.plugin, {
|
|
1599
1470
|
displayName: "Remark<remarkHtmlTransformer>",
|
|
1600
1471
|
group: "Remark"
|
|
1601
1472
|
});
|
|
1602
|
-
n(
|
|
1473
|
+
n(Fe.options, {
|
|
1603
1474
|
displayName: "RemarkConfig<remarkHtmlTransformer>",
|
|
1604
1475
|
group: "Remark"
|
|
1605
1476
|
});
|
|
1606
|
-
const
|
|
1477
|
+
const Ve = D("remarkMarker", () => () => (t, e) => {
|
|
1607
1478
|
const r = (a) => e.value.charAt(a.position.start.offset);
|
|
1608
|
-
|
|
1479
|
+
Y(t, (a) => ["strong", "emphasis"].includes(a.type), (a) => {
|
|
1609
1480
|
a.marker = r(a);
|
|
1610
1481
|
});
|
|
1611
1482
|
});
|
|
1612
|
-
n(
|
|
1483
|
+
n(Ve.plugin, {
|
|
1613
1484
|
displayName: "Remark<remarkMarker>",
|
|
1614
1485
|
group: "Remark"
|
|
1615
1486
|
});
|
|
1616
|
-
n(
|
|
1487
|
+
n(Ve.options, {
|
|
1617
1488
|
displayName: "RemarkConfig<remarkMarker>",
|
|
1618
1489
|
group: "Remark"
|
|
1619
1490
|
});
|
|
1620
|
-
const
|
|
1491
|
+
const Ct = _(() => {
|
|
1621
1492
|
let t = !1;
|
|
1622
|
-
const e = new
|
|
1493
|
+
const e = new E("MILKDOWN_INLINE_NODES_CURSOR"), r = new P({
|
|
1623
1494
|
key: e,
|
|
1624
1495
|
state: {
|
|
1625
1496
|
init() {
|
|
@@ -1628,48 +1499,48 @@ const wt = O(() => {
|
|
|
1628
1499
|
apply(a) {
|
|
1629
1500
|
if (!a.selection.empty)
|
|
1630
1501
|
return !1;
|
|
1631
|
-
const o = a.selection.$from, s = o.nodeBefore,
|
|
1632
|
-
return !!(s &&
|
|
1502
|
+
const o = a.selection.$from, s = o.nodeBefore, l = o.nodeAfter;
|
|
1503
|
+
return !!(s && l && s.isInline && !s.isText && l.isInline && !l.isText);
|
|
1633
1504
|
}
|
|
1634
1505
|
},
|
|
1635
1506
|
props: {
|
|
1636
1507
|
handleDOMEvents: {
|
|
1637
1508
|
compositionend: (a, o) => t ? (t = !1, requestAnimationFrame(() => {
|
|
1638
1509
|
if (r.getState(a.state)) {
|
|
1639
|
-
const
|
|
1640
|
-
o.preventDefault(), a.dispatch(a.state.tr.insertText(o.data || "",
|
|
1510
|
+
const l = a.state.selection.from;
|
|
1511
|
+
o.preventDefault(), a.dispatch(a.state.tr.insertText(o.data || "", l));
|
|
1641
1512
|
}
|
|
1642
1513
|
}), !0) : !1,
|
|
1643
1514
|
compositionstart: (a) => (r.getState(a.state) && (t = !0), !1),
|
|
1644
1515
|
beforeinput: (a, o) => {
|
|
1645
1516
|
if (r.getState(a.state) && o instanceof InputEvent && o.data && !t) {
|
|
1646
|
-
const
|
|
1647
|
-
return o.preventDefault(), a.dispatch(a.state.tr.insertText(o.data || "",
|
|
1517
|
+
const l = a.state.selection.from;
|
|
1518
|
+
return o.preventDefault(), a.dispatch(a.state.tr.insertText(o.data || "", l)), !0;
|
|
1648
1519
|
}
|
|
1649
1520
|
return !1;
|
|
1650
1521
|
}
|
|
1651
1522
|
},
|
|
1652
1523
|
decorations(a) {
|
|
1653
1524
|
if (r.getState(a)) {
|
|
1654
|
-
const
|
|
1525
|
+
const l = a.selection.$from.pos, i = document.createElement("span"), d = ze.widget(l, i, {
|
|
1655
1526
|
side: -1
|
|
1656
|
-
}),
|
|
1527
|
+
}), m = document.createElement("span"), p = ze.widget(l, m);
|
|
1657
1528
|
return setTimeout(() => {
|
|
1658
|
-
|
|
1659
|
-
}),
|
|
1529
|
+
i.contentEditable = "true", m.contentEditable = "true";
|
|
1530
|
+
}), Je.create(a.doc, [d, p]);
|
|
1660
1531
|
}
|
|
1661
|
-
return
|
|
1532
|
+
return Je.empty;
|
|
1662
1533
|
}
|
|
1663
1534
|
}
|
|
1664
1535
|
});
|
|
1665
1536
|
return r;
|
|
1666
1537
|
});
|
|
1667
|
-
n(
|
|
1538
|
+
n(Ct, {
|
|
1668
1539
|
displayName: "Prose<inlineNodesCursorPlugin>",
|
|
1669
1540
|
group: "Prose"
|
|
1670
1541
|
});
|
|
1671
|
-
const
|
|
1672
|
-
key: new
|
|
1542
|
+
const Mt = _((t) => new P({
|
|
1543
|
+
key: new E("MILKDOWN_HARDBREAK_MARKS"),
|
|
1673
1544
|
appendTransaction: (e, r, a) => {
|
|
1674
1545
|
if (!e.length)
|
|
1675
1546
|
return;
|
|
@@ -1678,69 +1549,69 @@ const At = O((t) => new R({
|
|
|
1678
1549
|
return;
|
|
1679
1550
|
const [s] = o.steps;
|
|
1680
1551
|
if (o.getMeta("hardbreak")) {
|
|
1681
|
-
if (!(s instanceof
|
|
1552
|
+
if (!(s instanceof Ot))
|
|
1682
1553
|
return;
|
|
1683
|
-
const { from:
|
|
1684
|
-
return a.tr.setNodeMarkup(
|
|
1554
|
+
const { from: d } = s;
|
|
1555
|
+
return a.tr.setNodeMarkup(d, S.type(t), void 0, []);
|
|
1685
1556
|
}
|
|
1686
|
-
if (s instanceof
|
|
1687
|
-
let
|
|
1688
|
-
const { from:
|
|
1689
|
-
return a.doc.nodesBetween(
|
|
1690
|
-
|
|
1691
|
-
}),
|
|
1557
|
+
if (s instanceof Tt) {
|
|
1558
|
+
let d = a.tr;
|
|
1559
|
+
const { from: m, to: p } = s;
|
|
1560
|
+
return a.doc.nodesBetween(m, p, (k, g) => {
|
|
1561
|
+
k.type === S.type(t) && (d = d.setNodeMarkup(g, S.type(t), void 0, []));
|
|
1562
|
+
}), d;
|
|
1692
1563
|
}
|
|
1693
1564
|
}
|
|
1694
1565
|
}));
|
|
1695
|
-
n(
|
|
1566
|
+
n(Mt, {
|
|
1696
1567
|
displayName: "Prose<hardbreakClearMarkPlugin>",
|
|
1697
1568
|
group: "Prose"
|
|
1698
1569
|
});
|
|
1699
|
-
const
|
|
1700
|
-
n(
|
|
1570
|
+
const Ue = Xe(["table", "code_block"], "hardbreakFilterNodes");
|
|
1571
|
+
n(Ue, {
|
|
1701
1572
|
displayName: "Ctx<hardbreakFilterNodes>",
|
|
1702
1573
|
group: "Prose"
|
|
1703
1574
|
});
|
|
1704
|
-
const
|
|
1705
|
-
const e = t.get(
|
|
1706
|
-
return new
|
|
1707
|
-
key: new
|
|
1575
|
+
const bt = _((t) => {
|
|
1576
|
+
const e = t.get(Ue.key);
|
|
1577
|
+
return new P({
|
|
1578
|
+
key: new E("MILKDOWN_HARDBREAK_FILTER"),
|
|
1708
1579
|
filterTransaction: (r, a) => {
|
|
1709
1580
|
const o = r.getMeta("hardbreak"), [s] = r.steps;
|
|
1710
1581
|
if (o && s) {
|
|
1711
|
-
const { from:
|
|
1712
|
-
let
|
|
1713
|
-
for (;
|
|
1714
|
-
e.includes(
|
|
1715
|
-
return
|
|
1582
|
+
const { from: l } = s, i = a.doc.resolve(l);
|
|
1583
|
+
let d = i.depth, m = !0;
|
|
1584
|
+
for (; d > 0; )
|
|
1585
|
+
e.includes(i.node(d).type.name) && (m = !1), d--;
|
|
1586
|
+
return m;
|
|
1716
1587
|
}
|
|
1717
1588
|
return !0;
|
|
1718
1589
|
}
|
|
1719
1590
|
});
|
|
1720
1591
|
});
|
|
1721
|
-
n(
|
|
1592
|
+
n(bt, {
|
|
1722
1593
|
displayName: "Prose<hardbreakFilterPlugin>",
|
|
1723
1594
|
group: "Prose"
|
|
1724
1595
|
});
|
|
1725
|
-
const
|
|
1726
|
-
const e = new
|
|
1596
|
+
const Lt = _((t) => {
|
|
1597
|
+
const e = new E("MILKDOWN_HEADING_ID"), r = (a) => {
|
|
1727
1598
|
if (a.composing || !a.editable)
|
|
1728
1599
|
return;
|
|
1729
|
-
const o = t.get(
|
|
1730
|
-
let
|
|
1731
|
-
a.state.doc.descendants((
|
|
1732
|
-
if (
|
|
1733
|
-
if (
|
|
1600
|
+
const o = t.get(j.key), s = a.state.tr.setMeta("addToHistory", !1);
|
|
1601
|
+
let l = !1;
|
|
1602
|
+
a.state.doc.descendants((i, d) => {
|
|
1603
|
+
if (i.type === H.type(t)) {
|
|
1604
|
+
if (i.textContent.trim().length === 0)
|
|
1734
1605
|
return;
|
|
1735
|
-
const
|
|
1736
|
-
|
|
1737
|
-
...
|
|
1738
|
-
id:
|
|
1606
|
+
const m = i.attrs, p = o(i);
|
|
1607
|
+
m.id !== p && (l = !0, s.setMeta(e, !0).setNodeMarkup(d, void 0, {
|
|
1608
|
+
...m,
|
|
1609
|
+
id: p
|
|
1739
1610
|
}));
|
|
1740
1611
|
}
|
|
1741
|
-
}),
|
|
1612
|
+
}), l && a.dispatch(s);
|
|
1742
1613
|
};
|
|
1743
|
-
return new
|
|
1614
|
+
return new P({
|
|
1744
1615
|
key: e,
|
|
1745
1616
|
view: (a) => (r(a), {
|
|
1746
1617
|
update: (o) => {
|
|
@@ -1749,39 +1620,39 @@ const Ht = O((t) => {
|
|
|
1749
1620
|
})
|
|
1750
1621
|
});
|
|
1751
1622
|
});
|
|
1752
|
-
n(
|
|
1623
|
+
n(Lt, {
|
|
1753
1624
|
displayName: "Prose<syncHeadingIdPlugin>",
|
|
1754
1625
|
group: "Prose"
|
|
1755
1626
|
});
|
|
1756
|
-
const
|
|
1627
|
+
const xt = _((t) => {
|
|
1757
1628
|
const e = (r) => {
|
|
1758
1629
|
if (r.composing || !r.editable)
|
|
1759
1630
|
return;
|
|
1760
|
-
const a =
|
|
1761
|
-
let
|
|
1762
|
-
const
|
|
1763
|
-
return
|
|
1631
|
+
const a = T.type(t), o = O.type(t), s = M.type(t), l = r.state, i = (p, k) => {
|
|
1632
|
+
let g = !1;
|
|
1633
|
+
const C = `${k + 1}.`;
|
|
1634
|
+
return p.label !== C && (p.label = C, g = !0), g;
|
|
1764
1635
|
};
|
|
1765
|
-
let
|
|
1766
|
-
|
|
1767
|
-
if (
|
|
1768
|
-
const
|
|
1769
|
-
(
|
|
1770
|
-
if (
|
|
1771
|
-
const
|
|
1772
|
-
|
|
1636
|
+
let d = l.tr, m = !1;
|
|
1637
|
+
l.doc.descendants((p, k, g, C) => {
|
|
1638
|
+
if (p.type === o) {
|
|
1639
|
+
const y = p.maybeChild(0);
|
|
1640
|
+
(y == null ? void 0 : y.type) === s && y.attrs.listType === "ordered" && (m = !0, d.setNodeMarkup(k, a, { spread: "true" }), p.descendants((b, Ge, Qt, St) => {
|
|
1641
|
+
if (b.type === s) {
|
|
1642
|
+
const je = { ...b.attrs };
|
|
1643
|
+
i(je, St) && (d = d.setNodeMarkup(Ge, void 0, je));
|
|
1773
1644
|
}
|
|
1774
1645
|
return !1;
|
|
1775
1646
|
}));
|
|
1776
|
-
} else if (
|
|
1777
|
-
const
|
|
1778
|
-
let
|
|
1779
|
-
|
|
1647
|
+
} else if (p.type === s && (g == null ? void 0 : g.type) === a) {
|
|
1648
|
+
const y = { ...p.attrs };
|
|
1649
|
+
let b = !1;
|
|
1650
|
+
y.listType !== "ordered" && (y.listType = "ordered", b = !0), (g == null ? void 0 : g.maybeChild(0)) && (b = i(y, C)), b && (d = d.setNodeMarkup(k, void 0, y), m = !0);
|
|
1780
1651
|
}
|
|
1781
|
-
}),
|
|
1652
|
+
}), m && r.dispatch(d.setMeta("addToHistory", !1));
|
|
1782
1653
|
};
|
|
1783
|
-
return new
|
|
1784
|
-
key: new
|
|
1654
|
+
return new P({
|
|
1655
|
+
key: new E("MILKDOWN_KEEP_LIST_ORDER"),
|
|
1785
1656
|
view: (r) => (e(r), {
|
|
1786
1657
|
update: (a) => {
|
|
1787
1658
|
e(a);
|
|
@@ -1789,117 +1660,117 @@ const Bt = O((t) => {
|
|
|
1789
1660
|
})
|
|
1790
1661
|
});
|
|
1791
1662
|
});
|
|
1792
|
-
n(
|
|
1663
|
+
n(xt, {
|
|
1793
1664
|
displayName: "Prose<syncListOrderPlugin>",
|
|
1794
1665
|
group: "Prose"
|
|
1795
1666
|
});
|
|
1796
|
-
const
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
Bt
|
|
1810
|
-
].flat(), Kr = [Yt, Zt, Jt, Qt, Nr].flat();
|
|
1667
|
+
const Jt = [
|
|
1668
|
+
Mt,
|
|
1669
|
+
Ue,
|
|
1670
|
+
bt,
|
|
1671
|
+
Ct,
|
|
1672
|
+
$e,
|
|
1673
|
+
We,
|
|
1674
|
+
qe,
|
|
1675
|
+
Fe,
|
|
1676
|
+
Ve,
|
|
1677
|
+
Lt,
|
|
1678
|
+
xt
|
|
1679
|
+
].flat(), cr = [qt, Wt, Ft, Vt, Ut, Jt].flat();
|
|
1811
1680
|
export {
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1681
|
+
ye as blockquoteAttr,
|
|
1682
|
+
he as blockquoteKeymap,
|
|
1683
|
+
q as blockquoteSchema,
|
|
1684
|
+
Se as bulletListAttr,
|
|
1685
|
+
Ae as bulletListKeymap,
|
|
1686
|
+
O as bulletListSchema,
|
|
1687
|
+
fe as codeBlockAttr,
|
|
1688
|
+
Ie as codeBlockKeymap,
|
|
1689
|
+
W as codeBlockSchema,
|
|
1690
|
+
Vt as commands,
|
|
1691
|
+
cr as commonmark,
|
|
1692
|
+
Ne as createCodeBlockCommand,
|
|
1693
|
+
ut as createCodeBlockInputRule,
|
|
1694
|
+
mt as docSchema,
|
|
1695
|
+
ue as downgradeHeadingCommand,
|
|
1696
|
+
Z as emphasisAttr,
|
|
1697
|
+
te as emphasisKeymap,
|
|
1698
|
+
R as emphasisSchema,
|
|
1699
|
+
nt as emphasisStarInputRule,
|
|
1700
|
+
ot as emphasisUnderscoreInputRule,
|
|
1701
|
+
Me as hardbreakAttr,
|
|
1702
|
+
Mt as hardbreakClearMarkPlugin,
|
|
1703
|
+
Ue as hardbreakFilterNodes,
|
|
1704
|
+
bt as hardbreakFilterPlugin,
|
|
1705
|
+
Le as hardbreakKeymap,
|
|
1836
1706
|
S as hardbreakSchema,
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1707
|
+
ce as headingAttr,
|
|
1708
|
+
j as headingIdGenerator,
|
|
1709
|
+
ge as headingKeymap,
|
|
1840
1710
|
H as headingSchema,
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1711
|
+
xe as hrAttr,
|
|
1712
|
+
F as hrSchema,
|
|
1713
|
+
Ee as htmlAttr,
|
|
1714
|
+
Pe as htmlSchema,
|
|
1715
|
+
Ce as imageAttr,
|
|
1716
|
+
v as imageSchema,
|
|
1717
|
+
oe as inlineCodeAttr,
|
|
1718
|
+
lt as inlineCodeInputRule,
|
|
1719
|
+
le as inlineCodeKeymap,
|
|
1849
1720
|
x as inlineCodeSchema,
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
Ge as liftListItemCommand,
|
|
1862
|
-
fe as linkAttr,
|
|
1721
|
+
Ct as inlineNodesCursorPlugin,
|
|
1722
|
+
Wt as inputRules,
|
|
1723
|
+
be as insertHardbreakCommand,
|
|
1724
|
+
ht as insertHrCommand,
|
|
1725
|
+
kt as insertHrInputRule,
|
|
1726
|
+
gt as insertImageCommand,
|
|
1727
|
+
Pt as insertImageInputRule,
|
|
1728
|
+
Ut as keymap,
|
|
1729
|
+
De as liftFirstListItemCommand,
|
|
1730
|
+
Te as liftListItemCommand,
|
|
1731
|
+
ie as linkAttr,
|
|
1863
1732
|
B as linkSchema,
|
|
1864
|
-
|
|
1865
|
-
|
|
1733
|
+
ve as listItemAttr,
|
|
1734
|
+
_e as listItemKeymap,
|
|
1866
1735
|
M as listItemSchema,
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
Lt as
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1736
|
+
Ft as markInputRules,
|
|
1737
|
+
He as orderedListAttr,
|
|
1738
|
+
Re as orderedListKeymap,
|
|
1739
|
+
T as orderedListSchema,
|
|
1740
|
+
de as paragraphAttr,
|
|
1741
|
+
pe as paragraphKeymap,
|
|
1742
|
+
A as paragraphSchema,
|
|
1743
|
+
Jt as plugins,
|
|
1744
|
+
$e as remarkAddOrderInListPlugin,
|
|
1745
|
+
Fe as remarkHtmlTransformer,
|
|
1746
|
+
We as remarkInlineLinkPlugin,
|
|
1747
|
+
qe as remarkLineBreak,
|
|
1748
|
+
Ve as remarkMarker,
|
|
1749
|
+
qt as schema,
|
|
1750
|
+
Oe as sinkListItemCommand,
|
|
1751
|
+
Ke as splitListItemCommand,
|
|
1752
|
+
re as strongAttr,
|
|
1753
|
+
st as strongInputRule,
|
|
1754
|
+
ne as strongKeymap,
|
|
1755
|
+
$ as strongSchema,
|
|
1756
|
+
Lt as syncHeadingIdPlugin,
|
|
1757
|
+
xt as syncListOrderPlugin,
|
|
1758
|
+
It as textSchema,
|
|
1759
|
+
ee as toggleEmphasisCommand,
|
|
1760
|
+
se as toggleInlineCodeCommand,
|
|
1761
|
+
it as toggleLinkCommand,
|
|
1762
|
+
ae as toggleStrongCommand,
|
|
1763
|
+
me as turnIntoTextCommand,
|
|
1764
|
+
Et as updateCodeBlockLanguageCommand,
|
|
1765
|
+
yt as updateImageCommand,
|
|
1766
|
+
dt as updateLinkCommand,
|
|
1767
|
+
ke as wrapInBlockquoteCommand,
|
|
1768
|
+
ct as wrapInBlockquoteInputRule,
|
|
1769
|
+
we as wrapInBulletListCommand,
|
|
1770
|
+
ft as wrapInBulletListInputRule,
|
|
1771
|
+
L as wrapInHeadingCommand,
|
|
1772
|
+
pt as wrapInHeadingInputRule,
|
|
1773
|
+
Be as wrapInOrderedListCommand,
|
|
1774
|
+
Nt as wrapInOrderedListInputRule
|
|
1904
1775
|
};
|
|
1905
1776
|
//# sourceMappingURL=index.es.js.map
|