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