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