@milkdown/preset-commonmark 7.6.2 → 7.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/index.es.js +1367 -1120
- package/lib/index.es.js.map +1 -1
- package/lib/node/heading.d.ts.map +1 -1
- package/package.json +7 -8
- package/src/node/heading.ts +5 -2
- package/src/node/list-item.ts +1 -1
package/lib/index.es.js
CHANGED
|
@@ -1,266 +1,297 @@
|
|
|
1
|
-
import { $markAttr
|
|
2
|
-
import { remarkStringifyOptionsCtx
|
|
3
|
-
import { toggleMark
|
|
4
|
-
import { Fragment
|
|
5
|
-
import { expectDomTypeError
|
|
6
|
-
import { textblockTypeInputRule
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (!
|
|
18
|
-
|
|
1
|
+
import { $markAttr, $markSchema, $inputRule, $command, $useKeymap, $node, $nodeAttr, $nodeSchema, $ctx, $remark, $prose } from "@milkdown/utils";
|
|
2
|
+
import { remarkStringifyOptionsCtx, commandsCtx, editorViewCtx } from "@milkdown/core";
|
|
3
|
+
import { toggleMark, setBlockType, wrapIn } from "@milkdown/prose/commands";
|
|
4
|
+
import { Fragment } from "@milkdown/prose/model";
|
|
5
|
+
import { expectDomTypeError } from "@milkdown/exception";
|
|
6
|
+
import { textblockTypeInputRule, wrappingInputRule, InputRule } from "@milkdown/prose/inputrules";
|
|
7
|
+
import { TextSelection, Selection, PluginKey, Plugin } from "@milkdown/prose/state";
|
|
8
|
+
import { markRule, findSelectedNodeOfType } from "@milkdown/prose";
|
|
9
|
+
import { sinkListItem, splitListItem, liftListItem } from "@milkdown/prose/schema-list";
|
|
10
|
+
import { ReplaceStep, AddMarkStep } from "@milkdown/prose/transform";
|
|
11
|
+
import { Decoration, DecorationSet } from "@milkdown/prose/view";
|
|
12
|
+
import { visit } from "unist-util-visit";
|
|
13
|
+
import remarkInlineLinks from "remark-inline-links";
|
|
14
|
+
function serializeText(state, node) {
|
|
15
|
+
var _a;
|
|
16
|
+
const lastIsHardBreak = node.childCount >= 1 && ((_a = node.lastChild) == null ? void 0 : _a.type.name) === "hardbreak";
|
|
17
|
+
if (!lastIsHardBreak) {
|
|
18
|
+
state.next(node.content);
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
i
|
|
24
|
-
|
|
21
|
+
const contentArr = [];
|
|
22
|
+
node.content.forEach((n, _, i) => {
|
|
23
|
+
if (i === node.childCount - 1) return;
|
|
24
|
+
contentArr.push(n);
|
|
25
|
+
});
|
|
26
|
+
state.next(Fragment.fromArray(contentArr));
|
|
25
27
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
+
function withMeta(plugin, meta) {
|
|
29
|
+
Object.assign(plugin, {
|
|
28
30
|
meta: {
|
|
29
31
|
package: "@milkdown/preset-commonmark",
|
|
30
|
-
...
|
|
32
|
+
...meta
|
|
31
33
|
}
|
|
32
|
-
})
|
|
34
|
+
});
|
|
35
|
+
return plugin;
|
|
33
36
|
}
|
|
34
|
-
const
|
|
35
|
-
|
|
37
|
+
const emphasisAttr = $markAttr("emphasis");
|
|
38
|
+
withMeta(emphasisAttr, {
|
|
36
39
|
displayName: "Attr<emphasis>",
|
|
37
40
|
group: "Emphasis"
|
|
38
41
|
});
|
|
39
|
-
const
|
|
42
|
+
const emphasisSchema = $markSchema("emphasis", (ctx) => ({
|
|
40
43
|
attrs: {
|
|
41
44
|
marker: {
|
|
42
|
-
default:
|
|
45
|
+
default: ctx.get(remarkStringifyOptionsCtx).emphasis || "*"
|
|
43
46
|
}
|
|
44
47
|
},
|
|
45
48
|
parseDOM: [
|
|
46
49
|
{ tag: "i" },
|
|
47
50
|
{ tag: "em" },
|
|
48
|
-
{ style: "font-style", getAttrs: (
|
|
51
|
+
{ style: "font-style", getAttrs: (value) => value === "italic" }
|
|
49
52
|
],
|
|
50
|
-
toDOM: (
|
|
53
|
+
toDOM: (mark) => ["em", ctx.get(emphasisAttr.key)(mark)],
|
|
51
54
|
parseMarkdown: {
|
|
52
|
-
match: (
|
|
53
|
-
runner: (
|
|
54
|
-
|
|
55
|
+
match: (node) => node.type === "emphasis",
|
|
56
|
+
runner: (state, node, markType) => {
|
|
57
|
+
state.openMark(markType, { marker: node.marker });
|
|
58
|
+
state.next(node.children);
|
|
59
|
+
state.closeMark(markType);
|
|
55
60
|
}
|
|
56
61
|
},
|
|
57
62
|
toMarkdown: {
|
|
58
|
-
match: (
|
|
59
|
-
runner: (
|
|
60
|
-
|
|
61
|
-
marker:
|
|
63
|
+
match: (mark) => mark.type.name === "emphasis",
|
|
64
|
+
runner: (state, mark) => {
|
|
65
|
+
state.withMark(mark, "emphasis", void 0, {
|
|
66
|
+
marker: mark.attrs.marker
|
|
62
67
|
});
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
}));
|
|
66
|
-
|
|
71
|
+
withMeta(emphasisSchema.mark, {
|
|
67
72
|
displayName: "MarkSchema<emphasis>",
|
|
68
73
|
group: "Emphasis"
|
|
69
74
|
});
|
|
70
|
-
|
|
75
|
+
withMeta(emphasisSchema.ctx, {
|
|
71
76
|
displayName: "MarkSchemaCtx<emphasis>",
|
|
72
77
|
group: "Emphasis"
|
|
73
78
|
});
|
|
74
|
-
const
|
|
75
|
-
|
|
79
|
+
const toggleEmphasisCommand = $command("ToggleEmphasis", (ctx) => () => {
|
|
80
|
+
return toggleMark(emphasisSchema.type(ctx));
|
|
81
|
+
});
|
|
82
|
+
withMeta(toggleEmphasisCommand, {
|
|
76
83
|
displayName: "Command<toggleEmphasisCommand>",
|
|
77
84
|
group: "Emphasis"
|
|
78
85
|
});
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}))
|
|
85
|
-
|
|
86
|
+
const emphasisStarInputRule = $inputRule((ctx) => {
|
|
87
|
+
return markRule(/(?:^|[^*])\*([^*]+)\*$/, emphasisSchema.type(ctx), {
|
|
88
|
+
getAttr: () => ({
|
|
89
|
+
marker: "*"
|
|
90
|
+
}),
|
|
91
|
+
updateCaptured: ({ fullMatch, start }) => !fullMatch.startsWith("*") ? { fullMatch: fullMatch.slice(1), start: start + 1 } : {}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
withMeta(emphasisStarInputRule, {
|
|
86
95
|
displayName: "InputRule<emphasis>|Star",
|
|
87
96
|
group: "Emphasis"
|
|
88
97
|
});
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}))
|
|
95
|
-
|
|
98
|
+
const emphasisUnderscoreInputRule = $inputRule((ctx) => {
|
|
99
|
+
return markRule(/(?:^|[^_])_([^_]+)_$/, emphasisSchema.type(ctx), {
|
|
100
|
+
getAttr: () => ({
|
|
101
|
+
marker: "_"
|
|
102
|
+
}),
|
|
103
|
+
updateCaptured: ({ fullMatch, start }) => !fullMatch.startsWith("_") ? { fullMatch: fullMatch.slice(1), start: start + 1 } : {}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
withMeta(emphasisUnderscoreInputRule, {
|
|
96
107
|
displayName: "InputRule<emphasis>|Underscore",
|
|
97
108
|
group: "Emphasis"
|
|
98
109
|
});
|
|
99
|
-
const
|
|
110
|
+
const emphasisKeymap = $useKeymap("emphasisKeymap", {
|
|
100
111
|
ToggleEmphasis: {
|
|
101
112
|
shortcuts: "Mod-i",
|
|
102
|
-
command: (
|
|
103
|
-
const
|
|
104
|
-
return () =>
|
|
113
|
+
command: (ctx) => {
|
|
114
|
+
const commands2 = ctx.get(commandsCtx);
|
|
115
|
+
return () => commands2.call(toggleEmphasisCommand.key);
|
|
105
116
|
}
|
|
106
117
|
}
|
|
107
118
|
});
|
|
108
|
-
|
|
119
|
+
withMeta(emphasisKeymap.ctx, {
|
|
109
120
|
displayName: "KeymapCtx<emphasis>",
|
|
110
121
|
group: "Emphasis"
|
|
111
122
|
});
|
|
112
|
-
|
|
123
|
+
withMeta(emphasisKeymap.shortcuts, {
|
|
113
124
|
displayName: "Keymap<emphasis>",
|
|
114
125
|
group: "Emphasis"
|
|
115
126
|
});
|
|
116
|
-
const
|
|
117
|
-
|
|
127
|
+
const strongAttr = $markAttr("strong");
|
|
128
|
+
withMeta(strongAttr, {
|
|
118
129
|
displayName: "Attr<strong>",
|
|
119
130
|
group: "Strong"
|
|
120
131
|
});
|
|
121
|
-
const
|
|
132
|
+
const strongSchema = $markSchema("strong", (ctx) => ({
|
|
122
133
|
attrs: {
|
|
123
134
|
marker: {
|
|
124
|
-
default:
|
|
135
|
+
default: ctx.get(remarkStringifyOptionsCtx).strong || "*"
|
|
125
136
|
}
|
|
126
137
|
},
|
|
127
138
|
parseDOM: [
|
|
128
139
|
{ tag: "b" },
|
|
129
140
|
{ tag: "strong" },
|
|
130
|
-
{ style: "font-style", getAttrs: (
|
|
141
|
+
{ style: "font-style", getAttrs: (value) => value === "bold" }
|
|
131
142
|
],
|
|
132
|
-
toDOM: (
|
|
143
|
+
toDOM: (mark) => ["strong", ctx.get(strongAttr.key)(mark)],
|
|
133
144
|
parseMarkdown: {
|
|
134
|
-
match: (
|
|
135
|
-
runner: (
|
|
136
|
-
|
|
145
|
+
match: (node) => node.type === "strong",
|
|
146
|
+
runner: (state, node, markType) => {
|
|
147
|
+
state.openMark(markType, { marker: node.marker });
|
|
148
|
+
state.next(node.children);
|
|
149
|
+
state.closeMark(markType);
|
|
137
150
|
}
|
|
138
151
|
},
|
|
139
152
|
toMarkdown: {
|
|
140
|
-
match: (
|
|
141
|
-
runner: (
|
|
142
|
-
|
|
143
|
-
marker:
|
|
153
|
+
match: (mark) => mark.type.name === "strong",
|
|
154
|
+
runner: (state, mark) => {
|
|
155
|
+
state.withMark(mark, "strong", void 0, {
|
|
156
|
+
marker: mark.attrs.marker
|
|
144
157
|
});
|
|
145
158
|
}
|
|
146
159
|
}
|
|
147
160
|
}));
|
|
148
|
-
|
|
161
|
+
withMeta(strongSchema.mark, {
|
|
149
162
|
displayName: "MarkSchema<strong>",
|
|
150
163
|
group: "Strong"
|
|
151
164
|
});
|
|
152
|
-
|
|
165
|
+
withMeta(strongSchema.ctx, {
|
|
153
166
|
displayName: "MarkSchemaCtx<strong>",
|
|
154
167
|
group: "Strong"
|
|
155
168
|
});
|
|
156
|
-
const
|
|
157
|
-
|
|
169
|
+
const toggleStrongCommand = $command("ToggleStrong", (ctx) => () => {
|
|
170
|
+
return toggleMark(strongSchema.type(ctx));
|
|
171
|
+
});
|
|
172
|
+
withMeta(toggleStrongCommand, {
|
|
158
173
|
displayName: "Command<toggleStrongCommand>",
|
|
159
174
|
group: "Strong"
|
|
160
175
|
});
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
176
|
+
const strongInputRule = $inputRule((ctx) => {
|
|
177
|
+
return markRule(/(?:\*\*|__)([^*_]+)(?:\*\*|__)$/, strongSchema.type(ctx), {
|
|
178
|
+
getAttr: (match) => {
|
|
179
|
+
return {
|
|
180
|
+
marker: match[0].startsWith("*") ? "*" : "_"
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
withMeta(strongInputRule, {
|
|
167
186
|
displayName: "InputRule<strong>",
|
|
168
187
|
group: "Strong"
|
|
169
188
|
});
|
|
170
|
-
const
|
|
189
|
+
const strongKeymap = $useKeymap("strongKeymap", {
|
|
171
190
|
ToggleBold: {
|
|
172
191
|
shortcuts: ["Mod-b"],
|
|
173
|
-
command: (
|
|
174
|
-
const
|
|
175
|
-
return () =>
|
|
192
|
+
command: (ctx) => {
|
|
193
|
+
const commands2 = ctx.get(commandsCtx);
|
|
194
|
+
return () => commands2.call(toggleStrongCommand.key);
|
|
176
195
|
}
|
|
177
196
|
}
|
|
178
197
|
});
|
|
179
|
-
|
|
198
|
+
withMeta(strongKeymap.ctx, {
|
|
180
199
|
displayName: "KeymapCtx<strong>",
|
|
181
200
|
group: "Strong"
|
|
182
201
|
});
|
|
183
|
-
|
|
202
|
+
withMeta(strongKeymap.shortcuts, {
|
|
184
203
|
displayName: "Keymap<strong>",
|
|
185
204
|
group: "Strong"
|
|
186
205
|
});
|
|
187
|
-
const
|
|
188
|
-
|
|
206
|
+
const inlineCodeAttr = $markAttr("inlineCode");
|
|
207
|
+
withMeta(inlineCodeAttr, {
|
|
189
208
|
displayName: "Attr<inlineCode>",
|
|
190
209
|
group: "InlineCode"
|
|
191
210
|
});
|
|
192
|
-
const
|
|
211
|
+
const inlineCodeSchema = $markSchema("inlineCode", (ctx) => ({
|
|
193
212
|
priority: 100,
|
|
194
|
-
code:
|
|
195
|
-
inclusive:
|
|
213
|
+
code: true,
|
|
214
|
+
inclusive: false,
|
|
196
215
|
parseDOM: [{ tag: "code" }],
|
|
197
|
-
toDOM: (
|
|
216
|
+
toDOM: (mark) => ["code", ctx.get(inlineCodeAttr.key)(mark)],
|
|
198
217
|
parseMarkdown: {
|
|
199
|
-
match: (
|
|
200
|
-
runner: (
|
|
201
|
-
|
|
218
|
+
match: (node) => node.type === "inlineCode",
|
|
219
|
+
runner: (state, node, markType) => {
|
|
220
|
+
state.openMark(markType);
|
|
221
|
+
state.addText(node.value);
|
|
222
|
+
state.closeMark(markType);
|
|
202
223
|
}
|
|
203
224
|
},
|
|
204
225
|
toMarkdown: {
|
|
205
|
-
match: (
|
|
206
|
-
runner: (
|
|
207
|
-
|
|
226
|
+
match: (mark) => mark.type.name === "inlineCode",
|
|
227
|
+
runner: (state, mark, node) => {
|
|
228
|
+
state.withMark(mark, "inlineCode", node.text || "");
|
|
208
229
|
}
|
|
209
230
|
}
|
|
210
231
|
}));
|
|
211
|
-
|
|
232
|
+
withMeta(inlineCodeSchema.mark, {
|
|
212
233
|
displayName: "MarkSchema<inlineCode>",
|
|
213
234
|
group: "InlineCode"
|
|
214
235
|
});
|
|
215
|
-
|
|
236
|
+
withMeta(inlineCodeSchema.ctx, {
|
|
216
237
|
displayName: "MarkSchemaCtx<inlineCode>",
|
|
217
238
|
group: "InlineCode"
|
|
218
239
|
});
|
|
219
|
-
const
|
|
240
|
+
const toggleInlineCodeCommand = $command(
|
|
220
241
|
"ToggleInlineCode",
|
|
221
|
-
(
|
|
222
|
-
const { selection
|
|
223
|
-
if (
|
|
224
|
-
const { from
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
242
|
+
(ctx) => () => (state, dispatch) => {
|
|
243
|
+
const { selection, tr } = state;
|
|
244
|
+
if (selection.empty) return false;
|
|
245
|
+
const { from, to } = selection;
|
|
246
|
+
const has = state.doc.rangeHasMark(from, to, inlineCodeSchema.type(ctx));
|
|
247
|
+
if (has) {
|
|
248
|
+
dispatch == null ? void 0 : dispatch(tr.removeMark(from, to, inlineCodeSchema.type(ctx)));
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
const restMarksName = Object.keys(state.schema.marks).filter(
|
|
252
|
+
(x) => x !== inlineCodeSchema.type.name
|
|
253
|
+
);
|
|
254
|
+
restMarksName.map((name) => state.schema.marks[name]).forEach((t) => {
|
|
255
|
+
tr.removeMark(from, to, t);
|
|
256
|
+
});
|
|
257
|
+
dispatch == null ? void 0 : dispatch(tr.addMark(from, to, inlineCodeSchema.type(ctx).create()));
|
|
258
|
+
return true;
|
|
230
259
|
}
|
|
231
260
|
);
|
|
232
|
-
|
|
261
|
+
withMeta(toggleInlineCodeCommand, {
|
|
233
262
|
displayName: "Command<toggleInlineCodeCommand>",
|
|
234
263
|
group: "InlineCode"
|
|
235
264
|
});
|
|
236
|
-
const
|
|
237
|
-
|
|
265
|
+
const inlineCodeInputRule = $inputRule((ctx) => {
|
|
266
|
+
return markRule(/(?:`)([^`]+)(?:`)$/, inlineCodeSchema.type(ctx));
|
|
267
|
+
});
|
|
268
|
+
withMeta(inlineCodeInputRule, {
|
|
238
269
|
displayName: "InputRule<inlineCodeInputRule>",
|
|
239
270
|
group: "InlineCode"
|
|
240
271
|
});
|
|
241
|
-
const
|
|
272
|
+
const inlineCodeKeymap = $useKeymap("inlineCodeKeymap", {
|
|
242
273
|
ToggleInlineCode: {
|
|
243
274
|
shortcuts: "Mod-e",
|
|
244
|
-
command: (
|
|
245
|
-
const
|
|
246
|
-
return () =>
|
|
275
|
+
command: (ctx) => {
|
|
276
|
+
const commands2 = ctx.get(commandsCtx);
|
|
277
|
+
return () => commands2.call(toggleInlineCodeCommand.key);
|
|
247
278
|
}
|
|
248
279
|
}
|
|
249
280
|
});
|
|
250
|
-
|
|
281
|
+
withMeta(inlineCodeKeymap.ctx, {
|
|
251
282
|
displayName: "KeymapCtx<inlineCode>",
|
|
252
283
|
group: "InlineCode"
|
|
253
284
|
});
|
|
254
|
-
|
|
285
|
+
withMeta(inlineCodeKeymap.shortcuts, {
|
|
255
286
|
displayName: "Keymap<inlineCode>",
|
|
256
287
|
group: "InlineCode"
|
|
257
288
|
});
|
|
258
|
-
const
|
|
259
|
-
|
|
289
|
+
const linkAttr = $markAttr("link");
|
|
290
|
+
withMeta(linkAttr, {
|
|
260
291
|
displayName: "Attr<link>",
|
|
261
292
|
group: "Link"
|
|
262
293
|
});
|
|
263
|
-
const
|
|
294
|
+
const linkSchema = $markSchema("link", (ctx) => ({
|
|
264
295
|
attrs: {
|
|
265
296
|
href: {},
|
|
266
297
|
title: { default: null }
|
|
@@ -268,165 +299,186 @@ const B = G("link", (t) => ({
|
|
|
268
299
|
parseDOM: [
|
|
269
300
|
{
|
|
270
301
|
tag: "a[href]",
|
|
271
|
-
getAttrs: (
|
|
272
|
-
if (!(
|
|
302
|
+
getAttrs: (dom) => {
|
|
303
|
+
if (!(dom instanceof HTMLElement)) throw expectDomTypeError(dom);
|
|
273
304
|
return {
|
|
274
|
-
href:
|
|
275
|
-
title:
|
|
305
|
+
href: dom.getAttribute("href"),
|
|
306
|
+
title: dom.getAttribute("title")
|
|
276
307
|
};
|
|
277
308
|
}
|
|
278
309
|
}
|
|
279
310
|
],
|
|
280
|
-
toDOM: (
|
|
311
|
+
toDOM: (mark) => ["a", { ...ctx.get(linkAttr.key)(mark), ...mark.attrs }],
|
|
281
312
|
parseMarkdown: {
|
|
282
|
-
match: (
|
|
283
|
-
runner: (
|
|
284
|
-
const
|
|
285
|
-
|
|
313
|
+
match: (node) => node.type === "link",
|
|
314
|
+
runner: (state, node, markType) => {
|
|
315
|
+
const url = node.url;
|
|
316
|
+
const title = node.title;
|
|
317
|
+
state.openMark(markType, { href: url, title });
|
|
318
|
+
state.next(node.children);
|
|
319
|
+
state.closeMark(markType);
|
|
286
320
|
}
|
|
287
321
|
},
|
|
288
322
|
toMarkdown: {
|
|
289
|
-
match: (
|
|
290
|
-
runner: (
|
|
291
|
-
|
|
292
|
-
title:
|
|
293
|
-
url:
|
|
323
|
+
match: (mark) => mark.type.name === "link",
|
|
324
|
+
runner: (state, mark) => {
|
|
325
|
+
state.withMark(mark, "link", void 0, {
|
|
326
|
+
title: mark.attrs.title,
|
|
327
|
+
url: mark.attrs.href
|
|
294
328
|
});
|
|
295
329
|
}
|
|
296
330
|
}
|
|
297
331
|
}));
|
|
298
|
-
|
|
332
|
+
withMeta(linkSchema.mark, {
|
|
299
333
|
displayName: "MarkSchema<link>",
|
|
300
334
|
group: "Link"
|
|
301
335
|
});
|
|
302
|
-
const
|
|
336
|
+
const toggleLinkCommand = $command(
|
|
303
337
|
"ToggleLink",
|
|
304
|
-
(
|
|
338
|
+
(ctx) => (payload = {}) => toggleMark(linkSchema.type(ctx), payload)
|
|
305
339
|
);
|
|
306
|
-
|
|
340
|
+
withMeta(toggleLinkCommand, {
|
|
307
341
|
displayName: "Command<toggleLinkCommand>",
|
|
308
342
|
group: "Link"
|
|
309
343
|
});
|
|
310
|
-
const
|
|
344
|
+
const updateLinkCommand = $command(
|
|
311
345
|
"UpdateLink",
|
|
312
|
-
(
|
|
313
|
-
if (!
|
|
314
|
-
let
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
)
|
|
346
|
+
(ctx) => (payload = {}) => (state, dispatch) => {
|
|
347
|
+
if (!dispatch) return false;
|
|
348
|
+
let node;
|
|
349
|
+
let pos = -1;
|
|
350
|
+
const { selection } = state;
|
|
351
|
+
const { from, to } = selection;
|
|
352
|
+
state.doc.nodesBetween(from, from === to ? to + 1 : to, (n, p) => {
|
|
353
|
+
if (linkSchema.type(ctx).isInSet(n.marks)) {
|
|
354
|
+
node = n;
|
|
355
|
+
pos = p;
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
return void 0;
|
|
359
|
+
});
|
|
360
|
+
if (!node) return false;
|
|
361
|
+
const mark = node.marks.find(({ type }) => type === linkSchema.type(ctx));
|
|
362
|
+
if (!mark) return false;
|
|
363
|
+
const start = pos;
|
|
364
|
+
const end = pos + node.nodeSize;
|
|
365
|
+
const { tr } = state;
|
|
366
|
+
const linkMark = linkSchema.type(ctx).create({ ...mark.attrs, ...payload });
|
|
367
|
+
if (!linkMark) return false;
|
|
368
|
+
dispatch(
|
|
369
|
+
tr.removeMark(start, end, mark).addMark(start, end, linkMark).setSelection(new TextSelection(tr.selection.$anchor)).scrollIntoView()
|
|
370
|
+
);
|
|
371
|
+
return true;
|
|
326
372
|
}
|
|
327
373
|
);
|
|
328
|
-
|
|
374
|
+
withMeta(updateLinkCommand, {
|
|
329
375
|
displayName: "Command<updateLinkCommand>",
|
|
330
376
|
group: "Link"
|
|
331
377
|
});
|
|
332
|
-
const
|
|
378
|
+
const docSchema = $node("doc", () => ({
|
|
333
379
|
content: "block+",
|
|
334
380
|
parseMarkdown: {
|
|
335
|
-
match: ({ type
|
|
336
|
-
runner: (
|
|
337
|
-
|
|
381
|
+
match: ({ type }) => type === "root",
|
|
382
|
+
runner: (state, node, type) => {
|
|
383
|
+
state.injectRoot(node, type);
|
|
338
384
|
}
|
|
339
385
|
},
|
|
340
386
|
toMarkdown: {
|
|
341
|
-
match: (
|
|
342
|
-
runner: (
|
|
343
|
-
|
|
387
|
+
match: (node) => node.type.name === "doc",
|
|
388
|
+
runner: (state, node) => {
|
|
389
|
+
state.openNode("root");
|
|
390
|
+
state.next(node.content);
|
|
344
391
|
}
|
|
345
392
|
}
|
|
346
393
|
}));
|
|
347
|
-
|
|
394
|
+
withMeta(docSchema, {
|
|
348
395
|
displayName: "NodeSchema<doc>",
|
|
349
396
|
group: "Doc"
|
|
350
397
|
});
|
|
351
|
-
const
|
|
352
|
-
|
|
398
|
+
const paragraphAttr = $nodeAttr("paragraph");
|
|
399
|
+
withMeta(paragraphAttr, {
|
|
353
400
|
displayName: "Attr<paragraph>",
|
|
354
401
|
group: "Paragraph"
|
|
355
402
|
});
|
|
356
|
-
const
|
|
403
|
+
const paragraphSchema = $nodeSchema("paragraph", (ctx) => ({
|
|
357
404
|
content: "inline*",
|
|
358
405
|
group: "block",
|
|
359
406
|
parseDOM: [{ tag: "p" }],
|
|
360
|
-
toDOM: (
|
|
407
|
+
toDOM: (node) => ["p", ctx.get(paragraphAttr.key)(node), 0],
|
|
361
408
|
parseMarkdown: {
|
|
362
|
-
match: (
|
|
363
|
-
runner: (
|
|
364
|
-
|
|
409
|
+
match: (node) => node.type === "paragraph",
|
|
410
|
+
runner: (state, node, type) => {
|
|
411
|
+
state.openNode(type);
|
|
412
|
+
if (node.children) state.next(node.children);
|
|
413
|
+
else state.addText(node.value || "");
|
|
414
|
+
state.closeNode();
|
|
365
415
|
}
|
|
366
416
|
},
|
|
367
417
|
toMarkdown: {
|
|
368
|
-
match: (
|
|
369
|
-
runner: (
|
|
370
|
-
|
|
418
|
+
match: (node) => node.type.name === "paragraph",
|
|
419
|
+
runner: (state, node) => {
|
|
420
|
+
state.openNode("paragraph");
|
|
421
|
+
serializeText(state, node);
|
|
422
|
+
state.closeNode();
|
|
371
423
|
}
|
|
372
424
|
}
|
|
373
425
|
}));
|
|
374
|
-
|
|
426
|
+
withMeta(paragraphSchema.node, {
|
|
375
427
|
displayName: "NodeSchema<paragraph>",
|
|
376
428
|
group: "Paragraph"
|
|
377
429
|
});
|
|
378
|
-
|
|
430
|
+
withMeta(paragraphSchema.ctx, {
|
|
379
431
|
displayName: "NodeSchemaCtx<paragraph>",
|
|
380
432
|
group: "Paragraph"
|
|
381
433
|
});
|
|
382
|
-
const
|
|
434
|
+
const turnIntoTextCommand = $command(
|
|
383
435
|
"TurnIntoText",
|
|
384
|
-
(
|
|
436
|
+
(ctx) => () => setBlockType(paragraphSchema.type(ctx))
|
|
385
437
|
);
|
|
386
|
-
|
|
438
|
+
withMeta(turnIntoTextCommand, {
|
|
387
439
|
displayName: "Command<turnIntoTextCommand>",
|
|
388
440
|
group: "Paragraph"
|
|
389
441
|
});
|
|
390
|
-
const
|
|
442
|
+
const paragraphKeymap = $useKeymap("paragraphKeymap", {
|
|
391
443
|
TurnIntoText: {
|
|
392
444
|
shortcuts: "Mod-Alt-0",
|
|
393
|
-
command: (
|
|
394
|
-
const
|
|
395
|
-
return () =>
|
|
445
|
+
command: (ctx) => {
|
|
446
|
+
const commands2 = ctx.get(commandsCtx);
|
|
447
|
+
return () => commands2.call(turnIntoTextCommand.key);
|
|
396
448
|
}
|
|
397
449
|
}
|
|
398
450
|
});
|
|
399
|
-
|
|
451
|
+
withMeta(paragraphKeymap.ctx, {
|
|
400
452
|
displayName: "KeymapCtx<paragraph>",
|
|
401
453
|
group: "Paragraph"
|
|
402
454
|
});
|
|
403
|
-
|
|
455
|
+
withMeta(paragraphKeymap.shortcuts, {
|
|
404
456
|
displayName: "Keymap<paragraph>",
|
|
405
457
|
group: "Paragraph"
|
|
406
458
|
});
|
|
407
|
-
const
|
|
408
|
-
function
|
|
409
|
-
return
|
|
459
|
+
const headingIndex = Array(6).fill(0).map((_, i) => i + 1);
|
|
460
|
+
function defaultHeadingIdGenerator(node) {
|
|
461
|
+
return node.textContent.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-");
|
|
410
462
|
}
|
|
411
|
-
const
|
|
412
|
-
|
|
463
|
+
const headingIdGenerator = $ctx(
|
|
464
|
+
defaultHeadingIdGenerator,
|
|
413
465
|
"headingIdGenerator"
|
|
414
466
|
);
|
|
415
|
-
|
|
467
|
+
withMeta(headingIdGenerator, {
|
|
416
468
|
displayName: "Ctx<HeadingIdGenerator>",
|
|
417
469
|
group: "Heading"
|
|
418
470
|
});
|
|
419
|
-
const
|
|
420
|
-
|
|
471
|
+
const headingAttr = $nodeAttr("heading");
|
|
472
|
+
withMeta(headingAttr, {
|
|
421
473
|
displayName: "Attr<heading>",
|
|
422
474
|
group: "Heading"
|
|
423
475
|
});
|
|
424
|
-
const
|
|
425
|
-
const
|
|
476
|
+
const headingSchema = $nodeSchema("heading", (ctx) => {
|
|
477
|
+
const getId = ctx.get(headingIdGenerator.key);
|
|
426
478
|
return {
|
|
427
479
|
content: "inline*",
|
|
428
480
|
group: "block",
|
|
429
|
-
defining:
|
|
481
|
+
defining: true,
|
|
430
482
|
attrs: {
|
|
431
483
|
id: {
|
|
432
484
|
default: ""
|
|
@@ -435,682 +487,749 @@ const H = I("heading", (t) => {
|
|
|
435
487
|
default: 1
|
|
436
488
|
}
|
|
437
489
|
},
|
|
438
|
-
parseDOM:
|
|
439
|
-
tag: `h${
|
|
440
|
-
getAttrs: (
|
|
441
|
-
if (!(
|
|
442
|
-
return { level:
|
|
490
|
+
parseDOM: headingIndex.map((x) => ({
|
|
491
|
+
tag: `h${x}`,
|
|
492
|
+
getAttrs: (node) => {
|
|
493
|
+
if (!(node instanceof HTMLElement)) throw expectDomTypeError(node);
|
|
494
|
+
return { level: x, id: node.id };
|
|
443
495
|
}
|
|
444
496
|
})),
|
|
445
|
-
toDOM: (
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
497
|
+
toDOM: (node) => {
|
|
498
|
+
return [
|
|
499
|
+
`h${node.attrs.level}`,
|
|
500
|
+
{
|
|
501
|
+
...ctx.get(headingAttr.key)(node),
|
|
502
|
+
id: node.attrs.id || getId(node)
|
|
503
|
+
},
|
|
504
|
+
0
|
|
505
|
+
];
|
|
506
|
+
},
|
|
453
507
|
parseMarkdown: {
|
|
454
|
-
match: ({ type
|
|
455
|
-
runner: (
|
|
456
|
-
const
|
|
457
|
-
|
|
508
|
+
match: ({ type }) => type === "heading",
|
|
509
|
+
runner: (state, node, type) => {
|
|
510
|
+
const depth = node.depth;
|
|
511
|
+
state.openNode(type, { level: depth });
|
|
512
|
+
state.next(node.children);
|
|
513
|
+
state.closeNode();
|
|
458
514
|
}
|
|
459
515
|
},
|
|
460
516
|
toMarkdown: {
|
|
461
|
-
match: (
|
|
462
|
-
runner: (
|
|
463
|
-
|
|
517
|
+
match: (node) => node.type.name === "heading",
|
|
518
|
+
runner: (state, node) => {
|
|
519
|
+
state.openNode("heading", void 0, { depth: node.attrs.level });
|
|
520
|
+
serializeText(state, node);
|
|
521
|
+
state.closeNode();
|
|
464
522
|
}
|
|
465
523
|
}
|
|
466
524
|
};
|
|
467
525
|
});
|
|
468
|
-
|
|
526
|
+
withMeta(headingSchema.node, {
|
|
469
527
|
displayName: "NodeSchema<heading>",
|
|
470
528
|
group: "Heading"
|
|
471
529
|
});
|
|
472
|
-
|
|
530
|
+
withMeta(headingSchema.ctx, {
|
|
473
531
|
displayName: "NodeSchemaCtx<heading>",
|
|
474
532
|
group: "Heading"
|
|
475
533
|
});
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
)
|
|
489
|
-
|
|
534
|
+
const wrapInHeadingInputRule = $inputRule((ctx) => {
|
|
535
|
+
return textblockTypeInputRule(
|
|
536
|
+
/^(?<hashes>#+)\s$/,
|
|
537
|
+
headingSchema.type(ctx),
|
|
538
|
+
(match) => {
|
|
539
|
+
var _a, _b;
|
|
540
|
+
const x = ((_b = (_a = match.groups) == null ? void 0 : _a.hashes) == null ? void 0 : _b.length) || 0;
|
|
541
|
+
const view = ctx.get(editorViewCtx);
|
|
542
|
+
const { $from } = view.state.selection;
|
|
543
|
+
const node = $from.node();
|
|
544
|
+
if (node.type.name === "heading") {
|
|
545
|
+
let level = Number(node.attrs.level) + Number(x);
|
|
546
|
+
if (level > 6) level = 6;
|
|
547
|
+
return { level };
|
|
548
|
+
}
|
|
549
|
+
return { level: x };
|
|
550
|
+
}
|
|
551
|
+
);
|
|
552
|
+
});
|
|
553
|
+
withMeta(wrapInHeadingInputRule, {
|
|
490
554
|
displayName: "InputRule<wrapInHeadingInputRule>",
|
|
491
555
|
group: "Heading"
|
|
492
556
|
});
|
|
493
|
-
const
|
|
494
|
-
|
|
557
|
+
const wrapInHeadingCommand = $command("WrapInHeading", (ctx) => {
|
|
558
|
+
return (level) => {
|
|
559
|
+
level ?? (level = 1);
|
|
560
|
+
if (level < 1) return setBlockType(paragraphSchema.type(ctx));
|
|
561
|
+
return setBlockType(headingSchema.type(ctx), { level });
|
|
562
|
+
};
|
|
563
|
+
});
|
|
564
|
+
withMeta(wrapInHeadingCommand, {
|
|
495
565
|
displayName: "Command<wrapInHeadingCommand>",
|
|
496
566
|
group: "Heading"
|
|
497
567
|
});
|
|
498
|
-
const
|
|
568
|
+
const downgradeHeadingCommand = $command(
|
|
499
569
|
"DowngradeHeading",
|
|
500
|
-
(
|
|
501
|
-
const { $from
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
570
|
+
(ctx) => () => (state, dispatch, view) => {
|
|
571
|
+
const { $from } = state.selection;
|
|
572
|
+
const node = $from.node();
|
|
573
|
+
if (node.type !== headingSchema.type(ctx) || !state.selection.empty || $from.parentOffset !== 0)
|
|
574
|
+
return false;
|
|
575
|
+
const level = node.attrs.level - 1;
|
|
576
|
+
if (!level)
|
|
577
|
+
return setBlockType(paragraphSchema.type(ctx))(state, dispatch, view);
|
|
578
|
+
dispatch == null ? void 0 : dispatch(
|
|
579
|
+
state.tr.setNodeMarkup(state.selection.$from.before(), void 0, {
|
|
580
|
+
...node.attrs,
|
|
581
|
+
level
|
|
509
582
|
})
|
|
510
|
-
)
|
|
583
|
+
);
|
|
584
|
+
return true;
|
|
511
585
|
}
|
|
512
586
|
);
|
|
513
|
-
|
|
587
|
+
withMeta(downgradeHeadingCommand, {
|
|
514
588
|
displayName: "Command<downgradeHeadingCommand>",
|
|
515
589
|
group: "Heading"
|
|
516
590
|
});
|
|
517
|
-
const
|
|
591
|
+
const headingKeymap = $useKeymap("headingKeymap", {
|
|
518
592
|
TurnIntoH1: {
|
|
519
593
|
shortcuts: "Mod-Alt-1",
|
|
520
|
-
command: (
|
|
521
|
-
const
|
|
522
|
-
return () =>
|
|
594
|
+
command: (ctx) => {
|
|
595
|
+
const commands2 = ctx.get(commandsCtx);
|
|
596
|
+
return () => commands2.call(wrapInHeadingCommand.key, 1);
|
|
523
597
|
}
|
|
524
598
|
},
|
|
525
599
|
TurnIntoH2: {
|
|
526
600
|
shortcuts: "Mod-Alt-2",
|
|
527
|
-
command: (
|
|
528
|
-
const
|
|
529
|
-
return () =>
|
|
601
|
+
command: (ctx) => {
|
|
602
|
+
const commands2 = ctx.get(commandsCtx);
|
|
603
|
+
return () => commands2.call(wrapInHeadingCommand.key, 2);
|
|
530
604
|
}
|
|
531
605
|
},
|
|
532
606
|
TurnIntoH3: {
|
|
533
607
|
shortcuts: "Mod-Alt-3",
|
|
534
|
-
command: (
|
|
535
|
-
const
|
|
536
|
-
return () =>
|
|
608
|
+
command: (ctx) => {
|
|
609
|
+
const commands2 = ctx.get(commandsCtx);
|
|
610
|
+
return () => commands2.call(wrapInHeadingCommand.key, 3);
|
|
537
611
|
}
|
|
538
612
|
},
|
|
539
613
|
TurnIntoH4: {
|
|
540
614
|
shortcuts: "Mod-Alt-4",
|
|
541
|
-
command: (
|
|
542
|
-
const
|
|
543
|
-
return () =>
|
|
615
|
+
command: (ctx) => {
|
|
616
|
+
const commands2 = ctx.get(commandsCtx);
|
|
617
|
+
return () => commands2.call(wrapInHeadingCommand.key, 4);
|
|
544
618
|
}
|
|
545
619
|
},
|
|
546
620
|
TurnIntoH5: {
|
|
547
621
|
shortcuts: "Mod-Alt-5",
|
|
548
|
-
command: (
|
|
549
|
-
const
|
|
550
|
-
return () =>
|
|
622
|
+
command: (ctx) => {
|
|
623
|
+
const commands2 = ctx.get(commandsCtx);
|
|
624
|
+
return () => commands2.call(wrapInHeadingCommand.key, 5);
|
|
551
625
|
}
|
|
552
626
|
},
|
|
553
627
|
TurnIntoH6: {
|
|
554
628
|
shortcuts: "Mod-Alt-6",
|
|
555
|
-
command: (
|
|
556
|
-
const
|
|
557
|
-
return () =>
|
|
629
|
+
command: (ctx) => {
|
|
630
|
+
const commands2 = ctx.get(commandsCtx);
|
|
631
|
+
return () => commands2.call(wrapInHeadingCommand.key, 6);
|
|
558
632
|
}
|
|
559
633
|
},
|
|
560
634
|
DowngradeHeading: {
|
|
561
635
|
shortcuts: ["Delete", "Backspace"],
|
|
562
|
-
command: (
|
|
563
|
-
const
|
|
564
|
-
return () =>
|
|
636
|
+
command: (ctx) => {
|
|
637
|
+
const commands2 = ctx.get(commandsCtx);
|
|
638
|
+
return () => commands2.call(downgradeHeadingCommand.key);
|
|
565
639
|
}
|
|
566
640
|
}
|
|
567
641
|
});
|
|
568
|
-
|
|
642
|
+
withMeta(headingKeymap.ctx, {
|
|
569
643
|
displayName: "KeymapCtx<heading>",
|
|
570
644
|
group: "Heading"
|
|
571
645
|
});
|
|
572
|
-
|
|
646
|
+
withMeta(headingKeymap.shortcuts, {
|
|
573
647
|
displayName: "Keymap<heading>",
|
|
574
648
|
group: "Heading"
|
|
575
649
|
});
|
|
576
|
-
const
|
|
577
|
-
|
|
650
|
+
const blockquoteAttr = $nodeAttr("blockquote");
|
|
651
|
+
withMeta(blockquoteAttr, {
|
|
578
652
|
displayName: "Attr<blockquote>",
|
|
579
653
|
group: "Blockquote"
|
|
580
654
|
});
|
|
581
|
-
const
|
|
655
|
+
const blockquoteSchema = $nodeSchema(
|
|
582
656
|
"blockquote",
|
|
583
|
-
(
|
|
657
|
+
(ctx) => ({
|
|
584
658
|
content: "block+",
|
|
585
659
|
group: "block",
|
|
586
|
-
defining:
|
|
660
|
+
defining: true,
|
|
587
661
|
parseDOM: [{ tag: "blockquote" }],
|
|
588
|
-
toDOM: (
|
|
662
|
+
toDOM: (node) => ["blockquote", ctx.get(blockquoteAttr.key)(node), 0],
|
|
589
663
|
parseMarkdown: {
|
|
590
|
-
match: ({ type
|
|
591
|
-
runner: (
|
|
592
|
-
|
|
664
|
+
match: ({ type }) => type === "blockquote",
|
|
665
|
+
runner: (state, node, type) => {
|
|
666
|
+
state.openNode(type).next(node.children).closeNode();
|
|
593
667
|
}
|
|
594
668
|
},
|
|
595
669
|
toMarkdown: {
|
|
596
|
-
match: (
|
|
597
|
-
runner: (
|
|
598
|
-
|
|
670
|
+
match: (node) => node.type.name === "blockquote",
|
|
671
|
+
runner: (state, node) => {
|
|
672
|
+
state.openNode("blockquote").next(node.content).closeNode();
|
|
599
673
|
}
|
|
600
674
|
}
|
|
601
675
|
})
|
|
602
676
|
);
|
|
603
|
-
|
|
677
|
+
withMeta(blockquoteSchema.node, {
|
|
604
678
|
displayName: "NodeSchema<blockquote>",
|
|
605
679
|
group: "Blockquote"
|
|
606
680
|
});
|
|
607
|
-
|
|
681
|
+
withMeta(blockquoteSchema.ctx, {
|
|
608
682
|
displayName: "NodeSchemaCtx<blockquote>",
|
|
609
683
|
group: "Blockquote"
|
|
610
684
|
});
|
|
611
|
-
const
|
|
612
|
-
(
|
|
685
|
+
const wrapInBlockquoteInputRule = $inputRule(
|
|
686
|
+
(ctx) => wrappingInputRule(/^\s*>\s$/, blockquoteSchema.type(ctx))
|
|
613
687
|
);
|
|
614
|
-
|
|
688
|
+
withMeta(wrapInBlockquoteInputRule, {
|
|
615
689
|
displayName: "InputRule<wrapInBlockquoteInputRule>",
|
|
616
690
|
group: "Blockquote"
|
|
617
691
|
});
|
|
618
|
-
const
|
|
692
|
+
const wrapInBlockquoteCommand = $command(
|
|
619
693
|
"WrapInBlockquote",
|
|
620
|
-
(
|
|
694
|
+
(ctx) => () => wrapIn(blockquoteSchema.type(ctx))
|
|
621
695
|
);
|
|
622
|
-
|
|
696
|
+
withMeta(wrapInBlockquoteCommand, {
|
|
623
697
|
displayName: "Command<wrapInBlockquoteCommand>",
|
|
624
698
|
group: "Blockquote"
|
|
625
699
|
});
|
|
626
|
-
const
|
|
700
|
+
const blockquoteKeymap = $useKeymap("blockquoteKeymap", {
|
|
627
701
|
WrapInBlockquote: {
|
|
628
702
|
shortcuts: "Mod-Shift-b",
|
|
629
|
-
command: (
|
|
630
|
-
const
|
|
631
|
-
return () =>
|
|
703
|
+
command: (ctx) => {
|
|
704
|
+
const commands2 = ctx.get(commandsCtx);
|
|
705
|
+
return () => commands2.call(wrapInBlockquoteCommand.key);
|
|
632
706
|
}
|
|
633
707
|
}
|
|
634
708
|
});
|
|
635
|
-
|
|
709
|
+
withMeta(blockquoteKeymap.ctx, {
|
|
636
710
|
displayName: "KeymapCtx<blockquote>",
|
|
637
711
|
group: "Blockquote"
|
|
638
712
|
});
|
|
639
|
-
|
|
713
|
+
withMeta(blockquoteKeymap.shortcuts, {
|
|
640
714
|
displayName: "Keymap<blockquote>",
|
|
641
715
|
group: "Blockquote"
|
|
642
716
|
});
|
|
643
|
-
const
|
|
717
|
+
const codeBlockAttr = $nodeAttr("codeBlock", () => ({
|
|
644
718
|
pre: {},
|
|
645
719
|
code: {}
|
|
646
720
|
}));
|
|
647
|
-
|
|
721
|
+
withMeta(codeBlockAttr, {
|
|
648
722
|
displayName: "Attr<codeBlock>",
|
|
649
723
|
group: "CodeBlock"
|
|
650
724
|
});
|
|
651
|
-
const
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
},
|
|
662
|
-
parseDOM: [
|
|
663
|
-
{
|
|
664
|
-
tag: "pre",
|
|
665
|
-
preserveWhitespace: "full",
|
|
666
|
-
getAttrs: (e) => {
|
|
667
|
-
if (!(e instanceof HTMLElement)) throw A(e);
|
|
668
|
-
return { language: e.dataset.language };
|
|
725
|
+
const codeBlockSchema = $nodeSchema("code_block", (ctx) => {
|
|
726
|
+
return {
|
|
727
|
+
content: "text*",
|
|
728
|
+
group: "block",
|
|
729
|
+
marks: "",
|
|
730
|
+
defining: true,
|
|
731
|
+
code: true,
|
|
732
|
+
attrs: {
|
|
733
|
+
language: {
|
|
734
|
+
default: ""
|
|
669
735
|
}
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
toDOM: (e) => {
|
|
673
|
-
const r = t.get(Ne.key)(e);
|
|
674
|
-
return [
|
|
675
|
-
"pre",
|
|
736
|
+
},
|
|
737
|
+
parseDOM: [
|
|
676
738
|
{
|
|
677
|
-
|
|
678
|
-
"
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
739
|
+
tag: "pre",
|
|
740
|
+
preserveWhitespace: "full",
|
|
741
|
+
getAttrs: (dom) => {
|
|
742
|
+
if (!(dom instanceof HTMLElement)) throw expectDomTypeError(dom);
|
|
743
|
+
return { language: dom.dataset.language };
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
],
|
|
747
|
+
toDOM: (node) => {
|
|
748
|
+
const attr = ctx.get(codeBlockAttr.key)(node);
|
|
749
|
+
return [
|
|
750
|
+
"pre",
|
|
751
|
+
{
|
|
752
|
+
...attr.pre,
|
|
753
|
+
"data-language": node.attrs.language
|
|
754
|
+
},
|
|
755
|
+
["code", attr.code, 0]
|
|
756
|
+
];
|
|
757
|
+
},
|
|
758
|
+
parseMarkdown: {
|
|
759
|
+
match: ({ type }) => type === "code",
|
|
760
|
+
runner: (state, node, type) => {
|
|
761
|
+
const language = node.lang;
|
|
762
|
+
const value = node.value;
|
|
763
|
+
state.openNode(type, { language });
|
|
764
|
+
if (value) state.addText(value);
|
|
765
|
+
state.closeNode();
|
|
766
|
+
}
|
|
767
|
+
},
|
|
768
|
+
toMarkdown: {
|
|
769
|
+
match: (node) => node.type.name === "code_block",
|
|
770
|
+
runner: (state, node) => {
|
|
771
|
+
var _a;
|
|
772
|
+
state.addNode("code", void 0, ((_a = node.content.firstChild) == null ? void 0 : _a.text) || "", {
|
|
773
|
+
lang: node.attrs.language
|
|
774
|
+
});
|
|
775
|
+
}
|
|
697
776
|
}
|
|
698
|
-
}
|
|
699
|
-
})
|
|
700
|
-
|
|
777
|
+
};
|
|
778
|
+
});
|
|
779
|
+
withMeta(codeBlockSchema.node, {
|
|
701
780
|
displayName: "NodeSchema<codeBlock>",
|
|
702
781
|
group: "CodeBlock"
|
|
703
782
|
});
|
|
704
|
-
|
|
783
|
+
withMeta(codeBlockSchema.ctx, {
|
|
705
784
|
displayName: "NodeSchemaCtx<codeBlock>",
|
|
706
785
|
group: "CodeBlock"
|
|
707
786
|
});
|
|
708
|
-
const
|
|
709
|
-
(
|
|
787
|
+
const createCodeBlockInputRule = $inputRule(
|
|
788
|
+
(ctx) => textblockTypeInputRule(
|
|
710
789
|
/^```(?<language>[a-z]*)?[\s\n]$/,
|
|
711
|
-
|
|
712
|
-
(
|
|
713
|
-
var
|
|
790
|
+
codeBlockSchema.type(ctx),
|
|
791
|
+
(match) => {
|
|
792
|
+
var _a;
|
|
714
793
|
return {
|
|
715
|
-
language: ((
|
|
794
|
+
language: ((_a = match.groups) == null ? void 0 : _a.language) ?? ""
|
|
716
795
|
};
|
|
717
796
|
}
|
|
718
797
|
)
|
|
719
798
|
);
|
|
720
|
-
|
|
799
|
+
withMeta(createCodeBlockInputRule, {
|
|
721
800
|
displayName: "InputRule<createCodeBlockInputRule>",
|
|
722
801
|
group: "CodeBlock"
|
|
723
802
|
});
|
|
724
|
-
const
|
|
803
|
+
const createCodeBlockCommand = $command(
|
|
725
804
|
"CreateCodeBlock",
|
|
726
|
-
(
|
|
805
|
+
(ctx) => (language = "") => setBlockType(codeBlockSchema.type(ctx), { language })
|
|
727
806
|
);
|
|
728
|
-
|
|
807
|
+
withMeta(createCodeBlockCommand, {
|
|
729
808
|
displayName: "Command<createCodeBlockCommand>",
|
|
730
809
|
group: "CodeBlock"
|
|
731
810
|
});
|
|
732
|
-
const
|
|
811
|
+
const updateCodeBlockLanguageCommand = $command(
|
|
733
812
|
"UpdateCodeBlockLanguage",
|
|
734
|
-
() => ({ pos
|
|
813
|
+
() => ({ pos, language } = {
|
|
735
814
|
pos: -1,
|
|
736
815
|
language: ""
|
|
737
|
-
}) => (
|
|
816
|
+
}) => (state, dispatch) => {
|
|
817
|
+
if (pos >= 0) {
|
|
818
|
+
dispatch == null ? void 0 : dispatch(state.tr.setNodeAttribute(pos, "language", language));
|
|
819
|
+
return true;
|
|
820
|
+
}
|
|
821
|
+
return false;
|
|
822
|
+
}
|
|
738
823
|
);
|
|
739
|
-
|
|
824
|
+
withMeta(updateCodeBlockLanguageCommand, {
|
|
740
825
|
displayName: "Command<updateCodeBlockLanguageCommand>",
|
|
741
826
|
group: "CodeBlock"
|
|
742
827
|
});
|
|
743
|
-
const
|
|
828
|
+
const codeBlockKeymap = $useKeymap("codeBlockKeymap", {
|
|
744
829
|
CreateCodeBlock: {
|
|
745
830
|
shortcuts: "Mod-Alt-c",
|
|
746
|
-
command: (
|
|
747
|
-
const
|
|
748
|
-
return () =>
|
|
831
|
+
command: (ctx) => {
|
|
832
|
+
const commands2 = ctx.get(commandsCtx);
|
|
833
|
+
return () => commands2.call(createCodeBlockCommand.key);
|
|
749
834
|
}
|
|
750
835
|
}
|
|
751
836
|
});
|
|
752
|
-
|
|
837
|
+
withMeta(codeBlockKeymap.ctx, {
|
|
753
838
|
displayName: "KeymapCtx<codeBlock>",
|
|
754
839
|
group: "CodeBlock"
|
|
755
840
|
});
|
|
756
|
-
|
|
841
|
+
withMeta(codeBlockKeymap.shortcuts, {
|
|
757
842
|
displayName: "Keymap<codeBlock>",
|
|
758
843
|
group: "CodeBlock"
|
|
759
844
|
});
|
|
760
|
-
const
|
|
761
|
-
|
|
845
|
+
const imageAttr = $nodeAttr("image");
|
|
846
|
+
withMeta(imageAttr, {
|
|
762
847
|
displayName: "Attr<image>",
|
|
763
848
|
group: "Image"
|
|
764
849
|
});
|
|
765
|
-
const
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
850
|
+
const imageSchema = $nodeSchema("image", (ctx) => {
|
|
851
|
+
return {
|
|
852
|
+
inline: true,
|
|
853
|
+
group: "inline",
|
|
854
|
+
selectable: true,
|
|
855
|
+
draggable: true,
|
|
856
|
+
marks: "",
|
|
857
|
+
atom: true,
|
|
858
|
+
defining: true,
|
|
859
|
+
isolating: true,
|
|
860
|
+
attrs: {
|
|
861
|
+
src: { default: "" },
|
|
862
|
+
alt: { default: "" },
|
|
863
|
+
title: { default: "" }
|
|
864
|
+
},
|
|
865
|
+
parseDOM: [
|
|
866
|
+
{
|
|
867
|
+
tag: "img[src]",
|
|
868
|
+
getAttrs: (dom) => {
|
|
869
|
+
if (!(dom instanceof HTMLElement)) throw expectDomTypeError(dom);
|
|
870
|
+
return {
|
|
871
|
+
src: dom.getAttribute("src") || "",
|
|
872
|
+
alt: dom.getAttribute("alt") || "",
|
|
873
|
+
title: dom.getAttribute("title") || dom.getAttribute("alt") || ""
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
],
|
|
878
|
+
toDOM: (node) => {
|
|
879
|
+
return ["img", { ...ctx.get(imageAttr.key)(node), ...node.attrs }];
|
|
880
|
+
},
|
|
881
|
+
parseMarkdown: {
|
|
882
|
+
match: ({ type }) => type === "image",
|
|
883
|
+
runner: (state, node, type) => {
|
|
884
|
+
const url = node.url;
|
|
885
|
+
const alt = node.alt;
|
|
886
|
+
const title = node.title;
|
|
887
|
+
state.addNode(type, {
|
|
888
|
+
src: url,
|
|
889
|
+
alt,
|
|
890
|
+
title
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
},
|
|
894
|
+
toMarkdown: {
|
|
895
|
+
match: (node) => node.type.name === "image",
|
|
896
|
+
runner: (state, node) => {
|
|
897
|
+
state.addNode("image", void 0, void 0, {
|
|
898
|
+
title: node.attrs.title,
|
|
899
|
+
url: node.attrs.src,
|
|
900
|
+
alt: node.attrs.alt
|
|
901
|
+
});
|
|
789
902
|
}
|
|
790
903
|
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
match: ({ type: e }) => e === "image",
|
|
795
|
-
runner: (e, r, a) => {
|
|
796
|
-
const o = r.url, s = r.alt, l = r.title;
|
|
797
|
-
e.addNode(a, {
|
|
798
|
-
src: o,
|
|
799
|
-
alt: s,
|
|
800
|
-
title: l
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
},
|
|
804
|
-
toMarkdown: {
|
|
805
|
-
match: (e) => e.type.name === "image",
|
|
806
|
-
runner: (e, r) => {
|
|
807
|
-
e.addNode("image", void 0, void 0, {
|
|
808
|
-
title: r.attrs.title,
|
|
809
|
-
url: r.attrs.src,
|
|
810
|
-
alt: r.attrs.alt
|
|
811
|
-
});
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
}));
|
|
815
|
-
n(O.node, {
|
|
904
|
+
};
|
|
905
|
+
});
|
|
906
|
+
withMeta(imageSchema.node, {
|
|
816
907
|
displayName: "NodeSchema<image>",
|
|
817
908
|
group: "Image"
|
|
818
909
|
});
|
|
819
|
-
|
|
910
|
+
withMeta(imageSchema.ctx, {
|
|
820
911
|
displayName: "NodeSchemaCtx<image>",
|
|
821
912
|
group: "Image"
|
|
822
913
|
});
|
|
823
|
-
const
|
|
914
|
+
const insertImageCommand = $command(
|
|
824
915
|
"InsertImage",
|
|
825
|
-
(
|
|
826
|
-
if (!
|
|
827
|
-
const { src
|
|
828
|
-
|
|
916
|
+
(ctx) => (payload = {}) => (state, dispatch) => {
|
|
917
|
+
if (!dispatch) return true;
|
|
918
|
+
const { src = "", alt = "", title = "" } = payload;
|
|
919
|
+
const node = imageSchema.type(ctx).create({ src, alt, title });
|
|
920
|
+
if (!node) return true;
|
|
921
|
+
dispatch(state.tr.replaceSelectionWith(node).scrollIntoView());
|
|
922
|
+
return true;
|
|
829
923
|
}
|
|
830
924
|
);
|
|
831
|
-
|
|
925
|
+
withMeta(insertImageCommand, {
|
|
832
926
|
displayName: "Command<insertImageCommand>",
|
|
833
927
|
group: "Image"
|
|
834
928
|
});
|
|
835
|
-
const
|
|
929
|
+
const updateImageCommand = $command(
|
|
836
930
|
"UpdateImage",
|
|
837
|
-
(
|
|
838
|
-
const
|
|
839
|
-
|
|
840
|
-
|
|
931
|
+
(ctx) => (payload = {}) => (state, dispatch) => {
|
|
932
|
+
const nodeWithPos = findSelectedNodeOfType(
|
|
933
|
+
state.selection,
|
|
934
|
+
imageSchema.type(ctx)
|
|
935
|
+
);
|
|
936
|
+
if (!nodeWithPos) return false;
|
|
937
|
+
const { node, pos } = nodeWithPos;
|
|
938
|
+
const newAttrs = { ...node.attrs };
|
|
939
|
+
const { src, alt, title } = payload;
|
|
940
|
+
if (src !== void 0) newAttrs.src = src;
|
|
941
|
+
if (alt !== void 0) newAttrs.alt = alt;
|
|
942
|
+
if (title !== void 0) newAttrs.title = title;
|
|
943
|
+
dispatch == null ? void 0 : dispatch(
|
|
944
|
+
state.tr.setNodeMarkup(pos, void 0, newAttrs).scrollIntoView()
|
|
841
945
|
);
|
|
842
|
-
|
|
843
|
-
const { node: s, pos: l } = o, i = { ...s.attrs }, { src: d, alt: m, title: u } = e;
|
|
844
|
-
return d !== void 0 && (i.src = d), m !== void 0 && (i.alt = m), u !== void 0 && (i.title = u), a == null || a(
|
|
845
|
-
r.tr.setNodeMarkup(l, void 0, i).scrollIntoView()
|
|
846
|
-
), !0;
|
|
946
|
+
return true;
|
|
847
947
|
}
|
|
848
948
|
);
|
|
849
|
-
|
|
949
|
+
withMeta(updateImageCommand, {
|
|
850
950
|
displayName: "Command<updateImageCommand>",
|
|
851
951
|
group: "Image"
|
|
852
952
|
});
|
|
853
|
-
const
|
|
854
|
-
(
|
|
953
|
+
const insertImageInputRule = $inputRule(
|
|
954
|
+
(ctx) => new InputRule(
|
|
855
955
|
/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,
|
|
856
|
-
(
|
|
857
|
-
const [
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
956
|
+
(state, match, start, end) => {
|
|
957
|
+
const [matched, alt, src = "", title] = match;
|
|
958
|
+
if (matched)
|
|
959
|
+
return state.tr.replaceWith(
|
|
960
|
+
start,
|
|
961
|
+
end,
|
|
962
|
+
imageSchema.type(ctx).create({ src, alt, title })
|
|
963
|
+
);
|
|
964
|
+
return null;
|
|
863
965
|
}
|
|
864
966
|
)
|
|
865
967
|
);
|
|
866
|
-
|
|
968
|
+
withMeta(insertImageInputRule, {
|
|
867
969
|
displayName: "InputRule<insertImageInputRule>",
|
|
868
970
|
group: "Image"
|
|
869
971
|
});
|
|
870
|
-
const
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
972
|
+
const hardbreakAttr = $nodeAttr("hardbreak", (node) => {
|
|
973
|
+
return {
|
|
974
|
+
"data-type": "hardbreak",
|
|
975
|
+
"data-is-inline": node.attrs.isInline
|
|
976
|
+
};
|
|
977
|
+
});
|
|
978
|
+
withMeta(hardbreakAttr, {
|
|
875
979
|
displayName: "Attr<hardbreak>",
|
|
876
980
|
group: "Hardbreak"
|
|
877
981
|
});
|
|
878
|
-
const
|
|
879
|
-
inline:
|
|
982
|
+
const hardbreakSchema = $nodeSchema("hardbreak", (ctx) => ({
|
|
983
|
+
inline: true,
|
|
880
984
|
group: "inline",
|
|
881
985
|
attrs: {
|
|
882
986
|
isInline: {
|
|
883
|
-
default:
|
|
987
|
+
default: false
|
|
884
988
|
}
|
|
885
989
|
},
|
|
886
|
-
selectable:
|
|
990
|
+
selectable: false,
|
|
887
991
|
parseDOM: [
|
|
888
992
|
{ tag: "br" },
|
|
889
993
|
{
|
|
890
994
|
tag: 'span[data-type="hardbreak"]',
|
|
891
|
-
getAttrs: () => ({ isInline:
|
|
995
|
+
getAttrs: () => ({ isInline: true })
|
|
892
996
|
}
|
|
893
997
|
],
|
|
894
|
-
toDOM: (
|
|
998
|
+
toDOM: (node) => node.attrs.isInline ? ["span", ctx.get(hardbreakAttr.key)(node), " "] : ["br", ctx.get(hardbreakAttr.key)(node)],
|
|
895
999
|
parseMarkdown: {
|
|
896
|
-
match: ({ type
|
|
897
|
-
runner: (
|
|
898
|
-
var
|
|
899
|
-
|
|
900
|
-
isInline:
|
|
1000
|
+
match: ({ type }) => type === "break",
|
|
1001
|
+
runner: (state, node, type) => {
|
|
1002
|
+
var _a;
|
|
1003
|
+
state.addNode(type, {
|
|
1004
|
+
isInline: Boolean(
|
|
1005
|
+
(_a = node.data) == null ? void 0 : _a.isInline
|
|
1006
|
+
)
|
|
901
1007
|
});
|
|
902
1008
|
}
|
|
903
1009
|
},
|
|
904
|
-
leafText: () =>
|
|
905
|
-
`,
|
|
1010
|
+
leafText: () => "\n",
|
|
906
1011
|
toMarkdown: {
|
|
907
|
-
match: (
|
|
908
|
-
runner: (
|
|
909
|
-
|
|
910
|
-
|
|
1012
|
+
match: (node) => node.type.name === "hardbreak",
|
|
1013
|
+
runner: (state, node) => {
|
|
1014
|
+
if (node.attrs.isInline) state.addNode("text", void 0, "\n");
|
|
1015
|
+
else state.addNode("break");
|
|
911
1016
|
}
|
|
912
1017
|
}
|
|
913
1018
|
}));
|
|
914
|
-
|
|
1019
|
+
withMeta(hardbreakSchema.node, {
|
|
915
1020
|
displayName: "NodeSchema<hardbreak>",
|
|
916
1021
|
group: "Hardbreak"
|
|
917
1022
|
});
|
|
918
|
-
|
|
1023
|
+
withMeta(hardbreakSchema.ctx, {
|
|
919
1024
|
displayName: "NodeSchemaCtx<hardbreak>",
|
|
920
1025
|
group: "Hardbreak"
|
|
921
1026
|
});
|
|
922
|
-
const
|
|
1027
|
+
const insertHardbreakCommand = $command(
|
|
923
1028
|
"InsertHardbreak",
|
|
924
|
-
(
|
|
925
|
-
var
|
|
926
|
-
const { selection
|
|
927
|
-
if (!(
|
|
928
|
-
if (
|
|
929
|
-
const
|
|
930
|
-
if (
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
).setSelection(
|
|
937
|
-
)
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
1029
|
+
(ctx) => () => (state, dispatch) => {
|
|
1030
|
+
var _a;
|
|
1031
|
+
const { selection, tr } = state;
|
|
1032
|
+
if (!(selection instanceof TextSelection)) return false;
|
|
1033
|
+
if (selection.empty) {
|
|
1034
|
+
const node = selection.$from.node();
|
|
1035
|
+
if (node.childCount > 0 && ((_a = node.lastChild) == null ? void 0 : _a.type.name) === "hardbreak") {
|
|
1036
|
+
dispatch == null ? void 0 : dispatch(
|
|
1037
|
+
tr.replaceRangeWith(
|
|
1038
|
+
selection.to - 1,
|
|
1039
|
+
selection.to,
|
|
1040
|
+
state.schema.node("paragraph")
|
|
1041
|
+
).setSelection(Selection.near(tr.doc.resolve(selection.to))).scrollIntoView()
|
|
1042
|
+
);
|
|
1043
|
+
return true;
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
dispatch == null ? void 0 : dispatch(
|
|
1047
|
+
tr.setMeta("hardbreak", true).replaceSelectionWith(hardbreakSchema.type(ctx).create()).scrollIntoView()
|
|
1048
|
+
);
|
|
1049
|
+
return true;
|
|
942
1050
|
}
|
|
943
1051
|
);
|
|
944
|
-
|
|
1052
|
+
withMeta(insertHardbreakCommand, {
|
|
945
1053
|
displayName: "Command<insertHardbreakCommand>",
|
|
946
1054
|
group: "Hardbreak"
|
|
947
1055
|
});
|
|
948
|
-
const
|
|
1056
|
+
const hardbreakKeymap = $useKeymap("hardbreakKeymap", {
|
|
949
1057
|
InsertHardbreak: {
|
|
950
1058
|
shortcuts: "Shift-Enter",
|
|
951
|
-
command: (
|
|
952
|
-
const
|
|
953
|
-
return () =>
|
|
1059
|
+
command: (ctx) => {
|
|
1060
|
+
const commands2 = ctx.get(commandsCtx);
|
|
1061
|
+
return () => commands2.call(insertHardbreakCommand.key);
|
|
954
1062
|
}
|
|
955
1063
|
}
|
|
956
1064
|
});
|
|
957
|
-
|
|
1065
|
+
withMeta(hardbreakKeymap.ctx, {
|
|
958
1066
|
displayName: "KeymapCtx<hardbreak>",
|
|
959
1067
|
group: "Hardbreak"
|
|
960
1068
|
});
|
|
961
|
-
|
|
1069
|
+
withMeta(hardbreakKeymap.shortcuts, {
|
|
962
1070
|
displayName: "Keymap<hardbreak>",
|
|
963
1071
|
group: "Hardbreak"
|
|
964
1072
|
});
|
|
965
|
-
const
|
|
966
|
-
|
|
1073
|
+
const hrAttr = $nodeAttr("hr");
|
|
1074
|
+
withMeta(hrAttr, {
|
|
967
1075
|
displayName: "Attr<hr>",
|
|
968
1076
|
group: "Hr"
|
|
969
1077
|
});
|
|
970
|
-
const
|
|
1078
|
+
const hrSchema = $nodeSchema("hr", (ctx) => ({
|
|
971
1079
|
group: "block",
|
|
972
1080
|
parseDOM: [{ tag: "hr" }],
|
|
973
|
-
toDOM: (
|
|
1081
|
+
toDOM: (node) => ["hr", ctx.get(hrAttr.key)(node)],
|
|
974
1082
|
parseMarkdown: {
|
|
975
|
-
match: ({ type
|
|
976
|
-
runner: (
|
|
977
|
-
|
|
1083
|
+
match: ({ type }) => type === "thematicBreak",
|
|
1084
|
+
runner: (state, _, type) => {
|
|
1085
|
+
state.addNode(type);
|
|
978
1086
|
}
|
|
979
1087
|
},
|
|
980
1088
|
toMarkdown: {
|
|
981
|
-
match: (
|
|
982
|
-
runner: (
|
|
983
|
-
|
|
1089
|
+
match: (node) => node.type.name === "hr",
|
|
1090
|
+
runner: (state) => {
|
|
1091
|
+
state.addNode("thematicBreak");
|
|
984
1092
|
}
|
|
985
1093
|
}
|
|
986
1094
|
}));
|
|
987
|
-
|
|
1095
|
+
withMeta(hrSchema.node, {
|
|
988
1096
|
displayName: "NodeSchema<hr>",
|
|
989
1097
|
group: "Hr"
|
|
990
1098
|
});
|
|
991
|
-
|
|
1099
|
+
withMeta(hrSchema.ctx, {
|
|
992
1100
|
displayName: "NodeSchemaCtx<hr>",
|
|
993
1101
|
group: "Hr"
|
|
994
1102
|
});
|
|
995
|
-
const
|
|
996
|
-
(
|
|
997
|
-
const { tr
|
|
998
|
-
|
|
1103
|
+
const insertHrInputRule = $inputRule(
|
|
1104
|
+
(ctx) => new InputRule(/^(?:---|___\s|\*\*\*\s)$/, (state, match, start, end) => {
|
|
1105
|
+
const { tr } = state;
|
|
1106
|
+
if (match[0]) tr.replaceWith(start - 1, end, hrSchema.type(ctx).create());
|
|
1107
|
+
return tr;
|
|
999
1108
|
})
|
|
1000
1109
|
);
|
|
1001
|
-
|
|
1110
|
+
withMeta(insertHrInputRule, {
|
|
1002
1111
|
displayName: "InputRule<insertHrInputRule>",
|
|
1003
1112
|
group: "Hr"
|
|
1004
1113
|
});
|
|
1005
|
-
const
|
|
1114
|
+
const insertHrCommand = $command(
|
|
1006
1115
|
"InsertHr",
|
|
1007
|
-
(
|
|
1008
|
-
if (!
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1116
|
+
(ctx) => () => (state, dispatch) => {
|
|
1117
|
+
if (!dispatch) return true;
|
|
1118
|
+
const paragraph = paragraphSchema.node.type(ctx).create();
|
|
1119
|
+
const { tr, selection } = state;
|
|
1120
|
+
const { from } = selection;
|
|
1121
|
+
const node = hrSchema.type(ctx).create();
|
|
1122
|
+
if (!node) return true;
|
|
1123
|
+
const _tr = tr.replaceSelectionWith(node).insert(from, paragraph);
|
|
1124
|
+
const sel = Selection.findFrom(_tr.doc.resolve(from), 1, true);
|
|
1125
|
+
if (!sel) return true;
|
|
1126
|
+
dispatch(_tr.setSelection(sel).scrollIntoView());
|
|
1127
|
+
return true;
|
|
1013
1128
|
}
|
|
1014
1129
|
);
|
|
1015
|
-
|
|
1130
|
+
withMeta(insertHrCommand, {
|
|
1016
1131
|
displayName: "Command<insertHrCommand>",
|
|
1017
1132
|
group: "Hr"
|
|
1018
1133
|
});
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1134
|
+
const bulletListAttr = $nodeAttr("bulletList");
|
|
1135
|
+
withMeta(bulletListAttr, {
|
|
1021
1136
|
displayName: "Attr<bulletList>",
|
|
1022
1137
|
group: "BulletList"
|
|
1023
1138
|
});
|
|
1024
|
-
const
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
},
|
|
1032
|
-
parseDOM: [
|
|
1033
|
-
{
|
|
1034
|
-
tag: "ul",
|
|
1035
|
-
getAttrs: (e) => {
|
|
1036
|
-
if (!(e instanceof HTMLElement)) throw A(e);
|
|
1037
|
-
return {
|
|
1038
|
-
spread: e.dataset.spread
|
|
1039
|
-
};
|
|
1139
|
+
const bulletListSchema = $nodeSchema("bullet_list", (ctx) => {
|
|
1140
|
+
return {
|
|
1141
|
+
content: "listItem+",
|
|
1142
|
+
group: "block",
|
|
1143
|
+
attrs: {
|
|
1144
|
+
spread: {
|
|
1145
|
+
default: false
|
|
1040
1146
|
}
|
|
1041
|
-
}
|
|
1042
|
-
],
|
|
1043
|
-
toDOM: (e) => [
|
|
1044
|
-
"ul",
|
|
1045
|
-
{
|
|
1046
|
-
...t.get(Se.key)(e),
|
|
1047
|
-
"data-spread": e.attrs.spread
|
|
1048
1147
|
},
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1148
|
+
parseDOM: [
|
|
1149
|
+
{
|
|
1150
|
+
tag: "ul",
|
|
1151
|
+
getAttrs: (dom) => {
|
|
1152
|
+
if (!(dom instanceof HTMLElement)) throw expectDomTypeError(dom);
|
|
1153
|
+
return {
|
|
1154
|
+
spread: dom.dataset.spread
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
],
|
|
1159
|
+
toDOM: (node) => {
|
|
1160
|
+
return [
|
|
1161
|
+
"ul",
|
|
1162
|
+
{
|
|
1163
|
+
...ctx.get(bulletListAttr.key)(node),
|
|
1164
|
+
"data-spread": node.attrs.spread
|
|
1165
|
+
},
|
|
1166
|
+
0
|
|
1167
|
+
];
|
|
1168
|
+
},
|
|
1169
|
+
parseMarkdown: {
|
|
1170
|
+
match: ({ type, ordered }) => type === "list" && !ordered,
|
|
1171
|
+
runner: (state, node, type) => {
|
|
1172
|
+
const spread = node.spread != null ? `${node.spread}` : "false";
|
|
1173
|
+
state.openNode(type, { spread }).next(node.children).closeNode();
|
|
1174
|
+
}
|
|
1175
|
+
},
|
|
1176
|
+
toMarkdown: {
|
|
1177
|
+
match: (node) => node.type.name === "bullet_list",
|
|
1178
|
+
runner: (state, node) => {
|
|
1179
|
+
state.openNode("list", void 0, {
|
|
1180
|
+
ordered: false,
|
|
1181
|
+
spread: node.attrs.spread === "true"
|
|
1182
|
+
}).next(node.content).closeNode();
|
|
1183
|
+
}
|
|
1065
1184
|
}
|
|
1066
|
-
}
|
|
1067
|
-
})
|
|
1068
|
-
|
|
1185
|
+
};
|
|
1186
|
+
});
|
|
1187
|
+
withMeta(bulletListSchema.node, {
|
|
1069
1188
|
displayName: "NodeSchema<bulletList>",
|
|
1070
1189
|
group: "BulletList"
|
|
1071
1190
|
});
|
|
1072
|
-
|
|
1191
|
+
withMeta(bulletListSchema.ctx, {
|
|
1073
1192
|
displayName: "NodeSchemaCtx<bulletList>",
|
|
1074
1193
|
group: "BulletList"
|
|
1075
1194
|
});
|
|
1076
|
-
const
|
|
1077
|
-
(
|
|
1195
|
+
const wrapInBulletListInputRule = $inputRule(
|
|
1196
|
+
(ctx) => wrappingInputRule(/^\s*([-+*])\s$/, bulletListSchema.type(ctx))
|
|
1078
1197
|
);
|
|
1079
|
-
|
|
1198
|
+
withMeta(wrapInBulletListInputRule, {
|
|
1080
1199
|
displayName: "InputRule<wrapInBulletListInputRule>",
|
|
1081
1200
|
group: "BulletList"
|
|
1082
1201
|
});
|
|
1083
|
-
const
|
|
1202
|
+
const wrapInBulletListCommand = $command(
|
|
1084
1203
|
"WrapInBulletList",
|
|
1085
|
-
(
|
|
1204
|
+
(ctx) => () => wrapIn(bulletListSchema.type(ctx))
|
|
1086
1205
|
);
|
|
1087
|
-
|
|
1206
|
+
withMeta(wrapInBulletListCommand, {
|
|
1088
1207
|
displayName: "Command<wrapInBulletListCommand>",
|
|
1089
1208
|
group: "BulletList"
|
|
1090
1209
|
});
|
|
1091
|
-
const
|
|
1210
|
+
const bulletListKeymap = $useKeymap("bulletListKeymap", {
|
|
1092
1211
|
WrapInBulletList: {
|
|
1093
1212
|
shortcuts: "Mod-Alt-8",
|
|
1094
|
-
command: (
|
|
1095
|
-
const
|
|
1096
|
-
return () =>
|
|
1213
|
+
command: (ctx) => {
|
|
1214
|
+
const commands2 = ctx.get(commandsCtx);
|
|
1215
|
+
return () => commands2.call(wrapInBulletListCommand.key);
|
|
1097
1216
|
}
|
|
1098
1217
|
}
|
|
1099
1218
|
});
|
|
1100
|
-
|
|
1219
|
+
withMeta(bulletListKeymap.ctx, {
|
|
1101
1220
|
displayName: "KeymapCtx<bulletListKeymap>",
|
|
1102
1221
|
group: "BulletList"
|
|
1103
1222
|
});
|
|
1104
|
-
|
|
1223
|
+
withMeta(bulletListKeymap.shortcuts, {
|
|
1105
1224
|
displayName: "Keymap<bulletListKeymap>",
|
|
1106
1225
|
group: "BulletList"
|
|
1107
1226
|
});
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1227
|
+
const orderedListAttr = $nodeAttr("orderedList");
|
|
1228
|
+
withMeta(orderedListAttr, {
|
|
1110
1229
|
displayName: "Attr<orderedList>",
|
|
1111
1230
|
group: "OrderedList"
|
|
1112
1231
|
});
|
|
1113
|
-
const
|
|
1232
|
+
const orderedListSchema = $nodeSchema("ordered_list", (ctx) => ({
|
|
1114
1233
|
content: "listItem+",
|
|
1115
1234
|
group: "block",
|
|
1116
1235
|
attrs: {
|
|
@@ -1118,101 +1237,103 @@ const K = I("ordered_list", (t) => ({
|
|
|
1118
1237
|
default: 1
|
|
1119
1238
|
},
|
|
1120
1239
|
spread: {
|
|
1121
|
-
default:
|
|
1240
|
+
default: false
|
|
1122
1241
|
}
|
|
1123
1242
|
},
|
|
1124
1243
|
parseDOM: [
|
|
1125
1244
|
{
|
|
1126
1245
|
tag: "ol",
|
|
1127
|
-
getAttrs: (
|
|
1128
|
-
if (!(
|
|
1246
|
+
getAttrs: (dom) => {
|
|
1247
|
+
if (!(dom instanceof HTMLElement)) throw expectDomTypeError(dom);
|
|
1129
1248
|
return {
|
|
1130
|
-
spread:
|
|
1131
|
-
order:
|
|
1249
|
+
spread: dom.dataset.spread,
|
|
1250
|
+
order: dom.hasAttribute("start") ? Number(dom.getAttribute("start")) : 1
|
|
1132
1251
|
};
|
|
1133
1252
|
}
|
|
1134
1253
|
}
|
|
1135
1254
|
],
|
|
1136
|
-
toDOM: (
|
|
1255
|
+
toDOM: (node) => [
|
|
1137
1256
|
"ol",
|
|
1138
1257
|
{
|
|
1139
|
-
...
|
|
1140
|
-
...
|
|
1141
|
-
"data-spread":
|
|
1258
|
+
...ctx.get(orderedListAttr.key)(node),
|
|
1259
|
+
...node.attrs.order === 1 ? {} : node.attrs.order,
|
|
1260
|
+
"data-spread": node.attrs.spread
|
|
1142
1261
|
},
|
|
1143
1262
|
0
|
|
1144
1263
|
],
|
|
1145
1264
|
parseMarkdown: {
|
|
1146
|
-
match: ({ type
|
|
1147
|
-
runner: (
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1265
|
+
match: ({ type, ordered }) => type === "list" && !!ordered,
|
|
1266
|
+
runner: (state, node, type) => {
|
|
1267
|
+
const spread = node.spread != null ? `${node.spread}` : "true";
|
|
1268
|
+
state.openNode(type, { spread }).next(node.children).closeNode();
|
|
1150
1269
|
}
|
|
1151
1270
|
},
|
|
1152
1271
|
toMarkdown: {
|
|
1153
|
-
match: (
|
|
1154
|
-
runner: (
|
|
1155
|
-
|
|
1156
|
-
ordered:
|
|
1272
|
+
match: (node) => node.type.name === "ordered_list",
|
|
1273
|
+
runner: (state, node) => {
|
|
1274
|
+
state.openNode("list", void 0, {
|
|
1275
|
+
ordered: true,
|
|
1157
1276
|
start: 1,
|
|
1158
|
-
spread:
|
|
1159
|
-
})
|
|
1277
|
+
spread: node.attrs.spread === "true"
|
|
1278
|
+
});
|
|
1279
|
+
state.next(node.content);
|
|
1280
|
+
state.closeNode();
|
|
1160
1281
|
}
|
|
1161
1282
|
}
|
|
1162
1283
|
}));
|
|
1163
|
-
|
|
1284
|
+
withMeta(orderedListSchema.node, {
|
|
1164
1285
|
displayName: "NodeSchema<orderedList>",
|
|
1165
1286
|
group: "OrderedList"
|
|
1166
1287
|
});
|
|
1167
|
-
|
|
1288
|
+
withMeta(orderedListSchema.ctx, {
|
|
1168
1289
|
displayName: "NodeSchemaCtx<orderedList>",
|
|
1169
1290
|
group: "OrderedList"
|
|
1170
1291
|
});
|
|
1171
|
-
const
|
|
1172
|
-
(
|
|
1292
|
+
const wrapInOrderedListInputRule = $inputRule(
|
|
1293
|
+
(ctx) => wrappingInputRule(
|
|
1173
1294
|
/^\s*(\d+)\.\s$/,
|
|
1174
|
-
|
|
1175
|
-
(
|
|
1176
|
-
(
|
|
1295
|
+
orderedListSchema.type(ctx),
|
|
1296
|
+
(match) => ({ order: Number(match[1]) }),
|
|
1297
|
+
(match, node) => node.childCount + node.attrs.order === Number(match[1])
|
|
1177
1298
|
)
|
|
1178
1299
|
);
|
|
1179
|
-
|
|
1300
|
+
withMeta(wrapInOrderedListInputRule, {
|
|
1180
1301
|
displayName: "InputRule<wrapInOrderedListInputRule>",
|
|
1181
1302
|
group: "OrderedList"
|
|
1182
1303
|
});
|
|
1183
|
-
const
|
|
1304
|
+
const wrapInOrderedListCommand = $command(
|
|
1184
1305
|
"WrapInOrderedList",
|
|
1185
|
-
(
|
|
1306
|
+
(ctx) => () => wrapIn(orderedListSchema.type(ctx))
|
|
1186
1307
|
);
|
|
1187
|
-
|
|
1308
|
+
withMeta(wrapInOrderedListCommand, {
|
|
1188
1309
|
displayName: "Command<wrapInOrderedListCommand>",
|
|
1189
1310
|
group: "OrderedList"
|
|
1190
1311
|
});
|
|
1191
|
-
const
|
|
1312
|
+
const orderedListKeymap = $useKeymap("orderedListKeymap", {
|
|
1192
1313
|
WrapInOrderedList: {
|
|
1193
1314
|
shortcuts: "Mod-Alt-7",
|
|
1194
|
-
command: (
|
|
1195
|
-
const
|
|
1196
|
-
return () =>
|
|
1315
|
+
command: (ctx) => {
|
|
1316
|
+
const commands2 = ctx.get(commandsCtx);
|
|
1317
|
+
return () => commands2.call(wrapInOrderedListCommand.key);
|
|
1197
1318
|
}
|
|
1198
1319
|
}
|
|
1199
1320
|
});
|
|
1200
|
-
|
|
1321
|
+
withMeta(orderedListKeymap.ctx, {
|
|
1201
1322
|
displayName: "KeymapCtx<orderedList>",
|
|
1202
1323
|
group: "OrderedList"
|
|
1203
1324
|
});
|
|
1204
|
-
|
|
1325
|
+
withMeta(orderedListKeymap.shortcuts, {
|
|
1205
1326
|
displayName: "Keymap<orderedList>",
|
|
1206
1327
|
group: "OrderedList"
|
|
1207
1328
|
});
|
|
1208
|
-
const
|
|
1209
|
-
|
|
1329
|
+
const listItemAttr = $nodeAttr("listItem");
|
|
1330
|
+
withMeta(listItemAttr, {
|
|
1210
1331
|
displayName: "Attr<listItem>",
|
|
1211
1332
|
group: "ListItem"
|
|
1212
1333
|
});
|
|
1213
|
-
const
|
|
1334
|
+
const listItemSchema = $nodeSchema("list_item", (ctx) => ({
|
|
1214
1335
|
group: "listItem",
|
|
1215
|
-
content: "
|
|
1336
|
+
content: "paragraph block*",
|
|
1216
1337
|
attrs: {
|
|
1217
1338
|
label: {
|
|
1218
1339
|
default: "•"
|
|
@@ -1224,707 +1345,833 @@ const M = I("list_item", (t) => ({
|
|
|
1224
1345
|
default: "true"
|
|
1225
1346
|
}
|
|
1226
1347
|
},
|
|
1227
|
-
defining:
|
|
1348
|
+
defining: true,
|
|
1228
1349
|
parseDOM: [
|
|
1229
1350
|
{
|
|
1230
1351
|
tag: "li",
|
|
1231
|
-
getAttrs: (
|
|
1232
|
-
if (!(
|
|
1352
|
+
getAttrs: (dom) => {
|
|
1353
|
+
if (!(dom instanceof HTMLElement)) throw expectDomTypeError(dom);
|
|
1233
1354
|
return {
|
|
1234
|
-
label:
|
|
1235
|
-
listType:
|
|
1236
|
-
spread:
|
|
1355
|
+
label: dom.dataset.label,
|
|
1356
|
+
listType: dom.dataset.listType,
|
|
1357
|
+
spread: dom.dataset.spread
|
|
1237
1358
|
};
|
|
1238
1359
|
}
|
|
1239
1360
|
}
|
|
1240
1361
|
],
|
|
1241
|
-
toDOM: (
|
|
1362
|
+
toDOM: (node) => [
|
|
1242
1363
|
"li",
|
|
1243
1364
|
{
|
|
1244
|
-
...
|
|
1245
|
-
"data-label":
|
|
1246
|
-
"data-list-type":
|
|
1247
|
-
"data-spread":
|
|
1365
|
+
...ctx.get(listItemAttr.key)(node),
|
|
1366
|
+
"data-label": node.attrs.label,
|
|
1367
|
+
"data-list-type": node.attrs.listType,
|
|
1368
|
+
"data-spread": node.attrs.spread
|
|
1248
1369
|
},
|
|
1249
1370
|
0
|
|
1250
1371
|
],
|
|
1251
1372
|
parseMarkdown: {
|
|
1252
|
-
match: ({ type
|
|
1253
|
-
runner: (
|
|
1254
|
-
const
|
|
1255
|
-
|
|
1373
|
+
match: ({ type }) => type === "listItem",
|
|
1374
|
+
runner: (state, node, type) => {
|
|
1375
|
+
const label = node.label != null ? `${node.label}.` : "•";
|
|
1376
|
+
const listType = node.label != null ? "ordered" : "bullet";
|
|
1377
|
+
const spread = node.spread != null ? `${node.spread}` : "true";
|
|
1378
|
+
state.openNode(type, { label, listType, spread });
|
|
1379
|
+
state.next(node.children);
|
|
1380
|
+
state.closeNode();
|
|
1256
1381
|
}
|
|
1257
1382
|
},
|
|
1258
1383
|
toMarkdown: {
|
|
1259
|
-
match: (
|
|
1260
|
-
runner: (
|
|
1261
|
-
|
|
1262
|
-
spread:
|
|
1263
|
-
})
|
|
1384
|
+
match: (node) => node.type.name === "list_item",
|
|
1385
|
+
runner: (state, node) => {
|
|
1386
|
+
state.openNode("listItem", void 0, {
|
|
1387
|
+
spread: node.attrs.spread === "true"
|
|
1388
|
+
});
|
|
1389
|
+
state.next(node.content);
|
|
1390
|
+
state.closeNode();
|
|
1264
1391
|
}
|
|
1265
1392
|
}
|
|
1266
1393
|
}));
|
|
1267
|
-
|
|
1394
|
+
withMeta(listItemSchema.node, {
|
|
1268
1395
|
displayName: "NodeSchema<listItem>",
|
|
1269
1396
|
group: "ListItem"
|
|
1270
1397
|
});
|
|
1271
|
-
|
|
1398
|
+
withMeta(listItemSchema.ctx, {
|
|
1272
1399
|
displayName: "NodeSchemaCtx<listItem>",
|
|
1273
1400
|
group: "ListItem"
|
|
1274
1401
|
});
|
|
1275
|
-
const
|
|
1402
|
+
const sinkListItemCommand = $command(
|
|
1276
1403
|
"SinkListItem",
|
|
1277
|
-
(
|
|
1404
|
+
(ctx) => () => sinkListItem(listItemSchema.type(ctx))
|
|
1278
1405
|
);
|
|
1279
|
-
|
|
1406
|
+
withMeta(sinkListItemCommand, {
|
|
1280
1407
|
displayName: "Command<sinkListItemCommand>",
|
|
1281
1408
|
group: "ListItem"
|
|
1282
1409
|
});
|
|
1283
|
-
const
|
|
1410
|
+
const liftListItemCommand = $command(
|
|
1284
1411
|
"LiftListItem",
|
|
1285
|
-
(
|
|
1412
|
+
(ctx) => () => liftListItem(listItemSchema.type(ctx))
|
|
1286
1413
|
);
|
|
1287
|
-
|
|
1414
|
+
withMeta(liftListItemCommand, {
|
|
1288
1415
|
displayName: "Command<liftListItemCommand>",
|
|
1289
1416
|
group: "ListItem"
|
|
1290
1417
|
});
|
|
1291
|
-
const
|
|
1418
|
+
const splitListItemCommand = $command(
|
|
1292
1419
|
"SplitListItem",
|
|
1293
|
-
(
|
|
1420
|
+
(ctx) => () => splitListItem(listItemSchema.type(ctx))
|
|
1294
1421
|
);
|
|
1295
|
-
|
|
1422
|
+
withMeta(splitListItemCommand, {
|
|
1296
1423
|
displayName: "Command<splitListItemCommand>",
|
|
1297
1424
|
group: "ListItem"
|
|
1298
1425
|
});
|
|
1299
|
-
function
|
|
1300
|
-
return (
|
|
1301
|
-
const { selection
|
|
1302
|
-
if (!(
|
|
1303
|
-
const { empty
|
|
1304
|
-
if (!
|
|
1305
|
-
const
|
|
1306
|
-
|
|
1426
|
+
function liftFirstListItem(ctx) {
|
|
1427
|
+
return (state, dispatch, view) => {
|
|
1428
|
+
const { selection } = state;
|
|
1429
|
+
if (!(selection instanceof TextSelection)) return false;
|
|
1430
|
+
const { empty, $from } = selection;
|
|
1431
|
+
if (!empty || $from.parentOffset !== 0) return false;
|
|
1432
|
+
const parentItem = $from.node(-1);
|
|
1433
|
+
if (parentItem.type !== listItemSchema.type(ctx) || parentItem.firstChild !== $from.node())
|
|
1434
|
+
return false;
|
|
1435
|
+
const list = $from.node(-2);
|
|
1436
|
+
if (list.childCount > 1) return false;
|
|
1437
|
+
return liftListItem(listItemSchema.type(ctx))(state, dispatch, view);
|
|
1307
1438
|
};
|
|
1308
1439
|
}
|
|
1309
|
-
const
|
|
1440
|
+
const liftFirstListItemCommand = $command(
|
|
1310
1441
|
"LiftFirstListItem",
|
|
1311
|
-
(
|
|
1442
|
+
(ctx) => () => liftFirstListItem(ctx)
|
|
1312
1443
|
);
|
|
1313
|
-
|
|
1444
|
+
withMeta(liftFirstListItemCommand, {
|
|
1314
1445
|
displayName: "Command<liftFirstListItemCommand>",
|
|
1315
1446
|
group: "ListItem"
|
|
1316
1447
|
});
|
|
1317
|
-
const
|
|
1448
|
+
const listItemKeymap = $useKeymap("listItemKeymap", {
|
|
1318
1449
|
NextListItem: {
|
|
1319
1450
|
shortcuts: "Enter",
|
|
1320
|
-
command: (
|
|
1321
|
-
const
|
|
1322
|
-
return () =>
|
|
1451
|
+
command: (ctx) => {
|
|
1452
|
+
const commands2 = ctx.get(commandsCtx);
|
|
1453
|
+
return () => commands2.call(splitListItemCommand.key);
|
|
1323
1454
|
}
|
|
1324
1455
|
},
|
|
1325
1456
|
SinkListItem: {
|
|
1326
1457
|
shortcuts: ["Tab", "Mod-]"],
|
|
1327
|
-
command: (
|
|
1328
|
-
const
|
|
1329
|
-
return () =>
|
|
1458
|
+
command: (ctx) => {
|
|
1459
|
+
const commands2 = ctx.get(commandsCtx);
|
|
1460
|
+
return () => commands2.call(sinkListItemCommand.key);
|
|
1330
1461
|
}
|
|
1331
1462
|
},
|
|
1332
1463
|
LiftListItem: {
|
|
1333
1464
|
shortcuts: ["Shift-Tab", "Mod-["],
|
|
1334
|
-
command: (
|
|
1335
|
-
const
|
|
1336
|
-
return () =>
|
|
1465
|
+
command: (ctx) => {
|
|
1466
|
+
const commands2 = ctx.get(commandsCtx);
|
|
1467
|
+
return () => commands2.call(liftListItemCommand.key);
|
|
1337
1468
|
}
|
|
1338
1469
|
},
|
|
1339
1470
|
LiftFirstListItem: {
|
|
1340
1471
|
shortcuts: ["Backspace", "Delete"],
|
|
1341
|
-
command: (
|
|
1342
|
-
const
|
|
1343
|
-
return () =>
|
|
1472
|
+
command: (ctx) => {
|
|
1473
|
+
const commands2 = ctx.get(commandsCtx);
|
|
1474
|
+
return () => commands2.call(liftFirstListItemCommand.key);
|
|
1344
1475
|
}
|
|
1345
1476
|
}
|
|
1346
1477
|
});
|
|
1347
|
-
|
|
1478
|
+
withMeta(listItemKeymap.ctx, {
|
|
1348
1479
|
displayName: "KeymapCtx<listItem>",
|
|
1349
1480
|
group: "ListItem"
|
|
1350
1481
|
});
|
|
1351
|
-
|
|
1482
|
+
withMeta(listItemKeymap.shortcuts, {
|
|
1352
1483
|
displayName: "Keymap<listItem>",
|
|
1353
1484
|
group: "ListItem"
|
|
1354
1485
|
});
|
|
1355
|
-
const
|
|
1486
|
+
const textSchema = $node("text", () => ({
|
|
1356
1487
|
group: "inline",
|
|
1357
1488
|
parseMarkdown: {
|
|
1358
|
-
match: ({ type
|
|
1359
|
-
runner: (
|
|
1360
|
-
|
|
1489
|
+
match: ({ type }) => type === "text",
|
|
1490
|
+
runner: (state, node) => {
|
|
1491
|
+
state.addText(node.value);
|
|
1361
1492
|
}
|
|
1362
1493
|
},
|
|
1363
1494
|
toMarkdown: {
|
|
1364
|
-
match: (
|
|
1365
|
-
runner: (
|
|
1366
|
-
|
|
1495
|
+
match: (node) => node.type.name === "text",
|
|
1496
|
+
runner: (state, node) => {
|
|
1497
|
+
state.addNode("text", void 0, node.text);
|
|
1367
1498
|
}
|
|
1368
1499
|
}
|
|
1369
1500
|
}));
|
|
1370
|
-
|
|
1501
|
+
withMeta(textSchema, {
|
|
1371
1502
|
displayName: "NodeSchema<text>",
|
|
1372
1503
|
group: "Text"
|
|
1373
1504
|
});
|
|
1374
|
-
const
|
|
1375
|
-
|
|
1505
|
+
const htmlAttr = $nodeAttr("html");
|
|
1506
|
+
withMeta(htmlAttr, {
|
|
1376
1507
|
displayName: "Attr<html>",
|
|
1377
1508
|
group: "Html"
|
|
1378
1509
|
});
|
|
1379
|
-
const
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1510
|
+
const htmlSchema = $nodeSchema("html", (ctx) => {
|
|
1511
|
+
return {
|
|
1512
|
+
atom: true,
|
|
1513
|
+
group: "inline",
|
|
1514
|
+
inline: true,
|
|
1515
|
+
attrs: {
|
|
1516
|
+
value: {
|
|
1517
|
+
default: ""
|
|
1518
|
+
}
|
|
1519
|
+
},
|
|
1520
|
+
toDOM: (node) => {
|
|
1521
|
+
const span = document.createElement("span");
|
|
1522
|
+
const attr = {
|
|
1523
|
+
...ctx.get(htmlAttr.key)(node),
|
|
1524
|
+
"data-value": node.attrs.value,
|
|
1525
|
+
"data-type": "html"
|
|
1526
|
+
};
|
|
1527
|
+
span.textContent = node.attrs.value;
|
|
1528
|
+
return ["span", attr, node.attrs.value];
|
|
1529
|
+
},
|
|
1530
|
+
parseDOM: [
|
|
1531
|
+
{
|
|
1532
|
+
tag: 'span[data-type="html"]',
|
|
1533
|
+
getAttrs: (dom) => {
|
|
1534
|
+
return {
|
|
1535
|
+
value: dom.dataset.value ?? ""
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
],
|
|
1540
|
+
parseMarkdown: {
|
|
1541
|
+
match: ({ type }) => Boolean(type === "html"),
|
|
1542
|
+
runner: (state, node, type) => {
|
|
1543
|
+
state.addNode(type, { value: node.value });
|
|
1544
|
+
}
|
|
1545
|
+
},
|
|
1546
|
+
toMarkdown: {
|
|
1547
|
+
match: (node) => node.type.name === "html",
|
|
1548
|
+
runner: (state, node) => {
|
|
1549
|
+
state.addNode("html", void 0, node.attrs.value);
|
|
1550
|
+
}
|
|
1414
1551
|
}
|
|
1415
|
-
}
|
|
1416
|
-
})
|
|
1417
|
-
|
|
1552
|
+
};
|
|
1553
|
+
});
|
|
1554
|
+
withMeta(htmlSchema.node, {
|
|
1418
1555
|
displayName: "NodeSchema<html>",
|
|
1419
1556
|
group: "Html"
|
|
1420
1557
|
});
|
|
1421
|
-
|
|
1558
|
+
withMeta(htmlSchema.ctx, {
|
|
1422
1559
|
displayName: "NodeSchemaCtx<html>",
|
|
1423
1560
|
group: "Html"
|
|
1424
1561
|
});
|
|
1425
|
-
const
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
].flat()
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1562
|
+
const schema = [
|
|
1563
|
+
docSchema,
|
|
1564
|
+
paragraphAttr,
|
|
1565
|
+
paragraphSchema,
|
|
1566
|
+
headingIdGenerator,
|
|
1567
|
+
headingAttr,
|
|
1568
|
+
headingSchema,
|
|
1569
|
+
hardbreakAttr,
|
|
1570
|
+
hardbreakSchema,
|
|
1571
|
+
blockquoteAttr,
|
|
1572
|
+
blockquoteSchema,
|
|
1573
|
+
codeBlockAttr,
|
|
1574
|
+
codeBlockSchema,
|
|
1575
|
+
hrAttr,
|
|
1576
|
+
hrSchema,
|
|
1577
|
+
imageAttr,
|
|
1578
|
+
imageSchema,
|
|
1579
|
+
bulletListAttr,
|
|
1580
|
+
bulletListSchema,
|
|
1581
|
+
orderedListAttr,
|
|
1582
|
+
orderedListSchema,
|
|
1583
|
+
listItemAttr,
|
|
1584
|
+
listItemSchema,
|
|
1585
|
+
emphasisAttr,
|
|
1586
|
+
emphasisSchema,
|
|
1587
|
+
strongAttr,
|
|
1588
|
+
strongSchema,
|
|
1589
|
+
inlineCodeAttr,
|
|
1590
|
+
inlineCodeSchema,
|
|
1591
|
+
linkAttr,
|
|
1592
|
+
linkSchema,
|
|
1593
|
+
htmlAttr,
|
|
1594
|
+
htmlSchema,
|
|
1595
|
+
textSchema
|
|
1596
|
+
].flat();
|
|
1597
|
+
const inputRules = [
|
|
1598
|
+
wrapInBlockquoteInputRule,
|
|
1599
|
+
wrapInBulletListInputRule,
|
|
1600
|
+
wrapInOrderedListInputRule,
|
|
1601
|
+
createCodeBlockInputRule,
|
|
1602
|
+
insertHrInputRule,
|
|
1603
|
+
wrapInHeadingInputRule
|
|
1604
|
+
].flat();
|
|
1605
|
+
const markInputRules = [
|
|
1606
|
+
emphasisStarInputRule,
|
|
1607
|
+
emphasisUnderscoreInputRule,
|
|
1608
|
+
inlineCodeInputRule,
|
|
1609
|
+
strongInputRule
|
|
1610
|
+
];
|
|
1611
|
+
const commands = [
|
|
1612
|
+
turnIntoTextCommand,
|
|
1613
|
+
wrapInBlockquoteCommand,
|
|
1614
|
+
wrapInHeadingCommand,
|
|
1615
|
+
downgradeHeadingCommand,
|
|
1616
|
+
createCodeBlockCommand,
|
|
1617
|
+
insertHardbreakCommand,
|
|
1618
|
+
insertHrCommand,
|
|
1619
|
+
insertImageCommand,
|
|
1620
|
+
updateImageCommand,
|
|
1621
|
+
wrapInOrderedListCommand,
|
|
1622
|
+
wrapInBulletListCommand,
|
|
1623
|
+
sinkListItemCommand,
|
|
1624
|
+
splitListItemCommand,
|
|
1625
|
+
liftListItemCommand,
|
|
1626
|
+
liftFirstListItemCommand,
|
|
1627
|
+
toggleEmphasisCommand,
|
|
1628
|
+
toggleInlineCodeCommand,
|
|
1629
|
+
toggleStrongCommand,
|
|
1630
|
+
toggleLinkCommand,
|
|
1631
|
+
updateLinkCommand
|
|
1632
|
+
];
|
|
1633
|
+
const keymap = [
|
|
1634
|
+
blockquoteKeymap,
|
|
1635
|
+
codeBlockKeymap,
|
|
1636
|
+
hardbreakKeymap,
|
|
1637
|
+
headingKeymap,
|
|
1638
|
+
listItemKeymap,
|
|
1639
|
+
orderedListKeymap,
|
|
1640
|
+
bulletListKeymap,
|
|
1641
|
+
paragraphKeymap,
|
|
1642
|
+
emphasisKeymap,
|
|
1643
|
+
inlineCodeKeymap,
|
|
1644
|
+
strongKeymap
|
|
1645
|
+
].flat();
|
|
1646
|
+
const remarkAddOrderInListPlugin = $remark(
|
|
1505
1647
|
"remarkAddOrderInList",
|
|
1506
|
-
() => () => (
|
|
1507
|
-
|
|
1508
|
-
if (
|
|
1509
|
-
const
|
|
1510
|
-
|
|
1511
|
-
|
|
1648
|
+
() => () => (tree) => {
|
|
1649
|
+
visit(tree, "list", (node) => {
|
|
1650
|
+
if (node.ordered) {
|
|
1651
|
+
const start = node.start ?? 1;
|
|
1652
|
+
node.children.forEach((child, index) => {
|
|
1653
|
+
child.label = index + start;
|
|
1512
1654
|
});
|
|
1513
1655
|
}
|
|
1514
1656
|
});
|
|
1515
1657
|
}
|
|
1516
1658
|
);
|
|
1517
|
-
|
|
1659
|
+
withMeta(remarkAddOrderInListPlugin.plugin, {
|
|
1518
1660
|
displayName: "Remark<remarkAddOrderInListPlugin>",
|
|
1519
1661
|
group: "Remark"
|
|
1520
1662
|
});
|
|
1521
|
-
|
|
1663
|
+
withMeta(remarkAddOrderInListPlugin.options, {
|
|
1522
1664
|
displayName: "RemarkConfig<remarkAddOrderInListPlugin>",
|
|
1523
1665
|
group: "Remark"
|
|
1524
1666
|
});
|
|
1525
|
-
const
|
|
1667
|
+
const remarkLineBreak = $remark(
|
|
1526
1668
|
"remarkLineBreak",
|
|
1527
|
-
() => () => (
|
|
1528
|
-
const
|
|
1529
|
-
|
|
1530
|
-
|
|
1669
|
+
() => () => (tree) => {
|
|
1670
|
+
const find = /[\t ]*(?:\r?\n|\r)/g;
|
|
1671
|
+
visit(
|
|
1672
|
+
tree,
|
|
1531
1673
|
"text",
|
|
1532
|
-
(
|
|
1533
|
-
if (!
|
|
1534
|
-
const
|
|
1535
|
-
let
|
|
1536
|
-
|
|
1537
|
-
let
|
|
1538
|
-
|
|
1539
|
-
const
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1674
|
+
(node, index, parent) => {
|
|
1675
|
+
if (!node.value || typeof node.value !== "string") return;
|
|
1676
|
+
const result = [];
|
|
1677
|
+
let start = 0;
|
|
1678
|
+
find.lastIndex = 0;
|
|
1679
|
+
let match = find.exec(node.value);
|
|
1680
|
+
while (match) {
|
|
1681
|
+
const position = match.index;
|
|
1682
|
+
if (start !== position)
|
|
1683
|
+
result.push({
|
|
1684
|
+
type: "text",
|
|
1685
|
+
value: node.value.slice(start, position)
|
|
1686
|
+
});
|
|
1687
|
+
result.push({ type: "break", data: { isInline: true } });
|
|
1688
|
+
start = position + match[0].length;
|
|
1689
|
+
match = find.exec(node.value);
|
|
1544
1690
|
}
|
|
1545
|
-
|
|
1546
|
-
|
|
1691
|
+
const hasResultAndIndex = result.length > 0 && parent && typeof index === "number";
|
|
1692
|
+
if (!hasResultAndIndex) return;
|
|
1693
|
+
if (start < node.value.length)
|
|
1694
|
+
result.push({ type: "text", value: node.value.slice(start) });
|
|
1695
|
+
parent.children.splice(index, 1, ...result);
|
|
1696
|
+
return index + result.length;
|
|
1547
1697
|
}
|
|
1548
1698
|
);
|
|
1549
1699
|
}
|
|
1550
1700
|
);
|
|
1551
|
-
|
|
1701
|
+
withMeta(remarkLineBreak.plugin, {
|
|
1552
1702
|
displayName: "Remark<remarkLineBreak>",
|
|
1553
1703
|
group: "Remark"
|
|
1554
1704
|
});
|
|
1555
|
-
|
|
1705
|
+
withMeta(remarkLineBreak.options, {
|
|
1556
1706
|
displayName: "RemarkConfig<remarkLineBreak>",
|
|
1557
1707
|
group: "Remark"
|
|
1558
1708
|
});
|
|
1559
|
-
const
|
|
1709
|
+
const remarkInlineLinkPlugin = $remark(
|
|
1560
1710
|
"remarkInlineLink",
|
|
1561
|
-
() =>
|
|
1711
|
+
() => remarkInlineLinks
|
|
1562
1712
|
);
|
|
1563
|
-
|
|
1713
|
+
withMeta(remarkInlineLinkPlugin.plugin, {
|
|
1564
1714
|
displayName: "Remark<remarkInlineLinkPlugin>",
|
|
1565
1715
|
group: "Remark"
|
|
1566
1716
|
});
|
|
1567
|
-
|
|
1717
|
+
withMeta(remarkInlineLinkPlugin.options, {
|
|
1568
1718
|
displayName: "RemarkConfig<remarkInlineLinkPlugin>",
|
|
1569
1719
|
group: "Remark"
|
|
1570
1720
|
});
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1721
|
+
const isParent = (node) => !!node.children;
|
|
1722
|
+
const isHTML = (node) => node.type === "html";
|
|
1723
|
+
function flatMapWithDepth(ast, fn) {
|
|
1724
|
+
return transform(ast, 0, null)[0];
|
|
1725
|
+
function transform(node, index, parent) {
|
|
1726
|
+
if (isParent(node)) {
|
|
1727
|
+
const out = [];
|
|
1728
|
+
for (let i = 0, n = node.children.length; i < n; i++) {
|
|
1729
|
+
const nthChild = node.children[i];
|
|
1730
|
+
if (nthChild) {
|
|
1731
|
+
const xs = transform(nthChild, i, node);
|
|
1732
|
+
if (xs) {
|
|
1733
|
+
for (let j = 0, m = xs.length; j < m; j++) {
|
|
1734
|
+
const item = xs[j];
|
|
1735
|
+
if (item) out.push(item);
|
|
1585
1736
|
}
|
|
1737
|
+
}
|
|
1586
1738
|
}
|
|
1587
1739
|
}
|
|
1588
|
-
|
|
1740
|
+
node.children = out;
|
|
1589
1741
|
}
|
|
1590
|
-
return
|
|
1742
|
+
return fn(node, index, parent);
|
|
1591
1743
|
}
|
|
1592
1744
|
}
|
|
1593
|
-
const
|
|
1745
|
+
const remarkHtmlTransformer = $remark(
|
|
1594
1746
|
"remarkHTMLTransformer",
|
|
1595
|
-
() => () => (
|
|
1596
|
-
|
|
1747
|
+
() => () => (tree) => {
|
|
1748
|
+
flatMapWithDepth(tree, (node, _index, parent) => {
|
|
1749
|
+
if (!isHTML(node)) return [node];
|
|
1750
|
+
if ((parent == null ? void 0 : parent.type) === "root") {
|
|
1751
|
+
node.children = [{ ...node }];
|
|
1752
|
+
delete node.value;
|
|
1753
|
+
node.type = "paragraph";
|
|
1754
|
+
}
|
|
1755
|
+
return [node];
|
|
1756
|
+
});
|
|
1597
1757
|
}
|
|
1598
1758
|
);
|
|
1599
|
-
|
|
1759
|
+
withMeta(remarkHtmlTransformer.plugin, {
|
|
1600
1760
|
displayName: "Remark<remarkHtmlTransformer>",
|
|
1601
1761
|
group: "Remark"
|
|
1602
1762
|
});
|
|
1603
|
-
|
|
1763
|
+
withMeta(remarkHtmlTransformer.options, {
|
|
1604
1764
|
displayName: "RemarkConfig<remarkHtmlTransformer>",
|
|
1605
1765
|
group: "Remark"
|
|
1606
1766
|
});
|
|
1607
|
-
const
|
|
1767
|
+
const remarkMarker = $remark(
|
|
1608
1768
|
"remarkMarker",
|
|
1609
|
-
() => () => (
|
|
1610
|
-
const
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1769
|
+
() => () => (tree, file) => {
|
|
1770
|
+
const getMarker = (node) => {
|
|
1771
|
+
return file.value.charAt(node.position.start.offset);
|
|
1772
|
+
};
|
|
1773
|
+
visit(
|
|
1774
|
+
tree,
|
|
1775
|
+
(node) => ["strong", "emphasis"].includes(node.type),
|
|
1776
|
+
(node) => {
|
|
1777
|
+
node.marker = getMarker(node);
|
|
1616
1778
|
}
|
|
1617
1779
|
);
|
|
1618
1780
|
}
|
|
1619
1781
|
);
|
|
1620
|
-
|
|
1782
|
+
withMeta(remarkMarker.plugin, {
|
|
1621
1783
|
displayName: "Remark<remarkMarker>",
|
|
1622
1784
|
group: "Remark"
|
|
1623
1785
|
});
|
|
1624
|
-
|
|
1786
|
+
withMeta(remarkMarker.options, {
|
|
1625
1787
|
displayName: "RemarkConfig<remarkMarker>",
|
|
1626
1788
|
group: "Remark"
|
|
1627
1789
|
});
|
|
1628
|
-
const
|
|
1629
|
-
let
|
|
1630
|
-
const
|
|
1790
|
+
const inlineNodesCursorPlugin = $prose(() => {
|
|
1791
|
+
let lock = false;
|
|
1792
|
+
const inlineNodesCursorPluginKey = new PluginKey(
|
|
1631
1793
|
"MILKDOWN_INLINE_NODES_CURSOR"
|
|
1632
|
-
)
|
|
1633
|
-
|
|
1794
|
+
);
|
|
1795
|
+
const inlineNodesCursorPlugin2 = new Plugin({
|
|
1796
|
+
key: inlineNodesCursorPluginKey,
|
|
1634
1797
|
state: {
|
|
1635
1798
|
init() {
|
|
1636
|
-
return
|
|
1799
|
+
return false;
|
|
1637
1800
|
},
|
|
1638
|
-
apply(
|
|
1639
|
-
if (!
|
|
1640
|
-
const
|
|
1641
|
-
|
|
1801
|
+
apply(tr) {
|
|
1802
|
+
if (!tr.selection.empty) return false;
|
|
1803
|
+
const pos = tr.selection.$from;
|
|
1804
|
+
const left = pos.nodeBefore;
|
|
1805
|
+
const right = pos.nodeAfter;
|
|
1806
|
+
if (left && right && left.isInline && !left.isText && right.isInline && !right.isText)
|
|
1807
|
+
return true;
|
|
1808
|
+
return false;
|
|
1642
1809
|
}
|
|
1643
1810
|
},
|
|
1644
1811
|
props: {
|
|
1645
1812
|
handleDOMEvents: {
|
|
1646
|
-
compositionend: (
|
|
1647
|
-
if (
|
|
1648
|
-
|
|
1649
|
-
|
|
1813
|
+
compositionend: (view, e) => {
|
|
1814
|
+
if (lock) {
|
|
1815
|
+
lock = false;
|
|
1816
|
+
requestAnimationFrame(() => {
|
|
1817
|
+
const active = inlineNodesCursorPlugin2.getState(view.state);
|
|
1818
|
+
if (active) {
|
|
1819
|
+
const from = view.state.selection.from;
|
|
1820
|
+
e.preventDefault();
|
|
1821
|
+
view.dispatch(view.state.tr.insertText(e.data || "", from));
|
|
1822
|
+
}
|
|
1823
|
+
});
|
|
1824
|
+
return true;
|
|
1650
1825
|
}
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1826
|
+
return false;
|
|
1827
|
+
},
|
|
1828
|
+
compositionstart: (view) => {
|
|
1829
|
+
const active = inlineNodesCursorPlugin2.getState(view.state);
|
|
1830
|
+
if (active) lock = true;
|
|
1831
|
+
return false;
|
|
1832
|
+
},
|
|
1833
|
+
beforeinput: (view, e) => {
|
|
1834
|
+
const active = inlineNodesCursorPlugin2.getState(view.state);
|
|
1835
|
+
if (active && e instanceof InputEvent && e.data && !lock) {
|
|
1836
|
+
const from = view.state.selection.from;
|
|
1837
|
+
e.preventDefault();
|
|
1838
|
+
view.dispatch(view.state.tr.insertText(e.data || "", from));
|
|
1839
|
+
return true;
|
|
1657
1840
|
}
|
|
1658
|
-
return
|
|
1841
|
+
return false;
|
|
1659
1842
|
}
|
|
1660
1843
|
},
|
|
1661
|
-
decorations(
|
|
1662
|
-
|
|
1663
|
-
|
|
1844
|
+
decorations(state) {
|
|
1845
|
+
const active = inlineNodesCursorPlugin2.getState(state);
|
|
1846
|
+
if (active) {
|
|
1847
|
+
const pos = state.selection.$from;
|
|
1848
|
+
const position = pos.pos;
|
|
1849
|
+
const left = document.createElement("span");
|
|
1850
|
+
const leftDec = Decoration.widget(position, left, {
|
|
1664
1851
|
side: -1
|
|
1665
|
-
})
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1852
|
+
});
|
|
1853
|
+
const right = document.createElement("span");
|
|
1854
|
+
const rightDec = Decoration.widget(position, right);
|
|
1855
|
+
setTimeout(() => {
|
|
1856
|
+
left.contentEditable = "true";
|
|
1857
|
+
right.contentEditable = "true";
|
|
1858
|
+
});
|
|
1859
|
+
return DecorationSet.create(state.doc, [leftDec, rightDec]);
|
|
1669
1860
|
}
|
|
1670
|
-
return
|
|
1861
|
+
return DecorationSet.empty;
|
|
1671
1862
|
}
|
|
1672
1863
|
}
|
|
1673
1864
|
});
|
|
1674
|
-
return
|
|
1865
|
+
return inlineNodesCursorPlugin2;
|
|
1675
1866
|
});
|
|
1676
|
-
|
|
1867
|
+
withMeta(inlineNodesCursorPlugin, {
|
|
1677
1868
|
displayName: "Prose<inlineNodesCursorPlugin>",
|
|
1678
1869
|
group: "Prose"
|
|
1679
1870
|
});
|
|
1680
|
-
const
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
);
|
|
1696
|
-
}
|
|
1697
|
-
if (s instanceof Kt) {
|
|
1698
|
-
let d = a.tr;
|
|
1699
|
-
const { from: m, to: u } = s;
|
|
1700
|
-
return a.doc.nodesBetween(m, u, (p, k) => {
|
|
1701
|
-
p.type === S.type(t) && (d = d.setNodeMarkup(
|
|
1702
|
-
k,
|
|
1703
|
-
S.type(t),
|
|
1871
|
+
const hardbreakClearMarkPlugin = $prose((ctx) => {
|
|
1872
|
+
return new Plugin({
|
|
1873
|
+
key: new PluginKey("MILKDOWN_HARDBREAK_MARKS"),
|
|
1874
|
+
appendTransaction: (trs, _oldState, newState) => {
|
|
1875
|
+
if (!trs.length) return;
|
|
1876
|
+
const [tr] = trs;
|
|
1877
|
+
if (!tr) return;
|
|
1878
|
+
const [step] = tr.steps;
|
|
1879
|
+
const isInsertHr = tr.getMeta("hardbreak");
|
|
1880
|
+
if (isInsertHr) {
|
|
1881
|
+
if (!(step instanceof ReplaceStep)) return;
|
|
1882
|
+
const { from } = step;
|
|
1883
|
+
return newState.tr.setNodeMarkup(
|
|
1884
|
+
from,
|
|
1885
|
+
hardbreakSchema.type(ctx),
|
|
1704
1886
|
void 0,
|
|
1705
1887
|
[]
|
|
1706
|
-
)
|
|
1707
|
-
}
|
|
1888
|
+
);
|
|
1889
|
+
}
|
|
1890
|
+
const isAddMarkStep = step instanceof AddMarkStep;
|
|
1891
|
+
if (isAddMarkStep) {
|
|
1892
|
+
let _tr = newState.tr;
|
|
1893
|
+
const { from, to } = step;
|
|
1894
|
+
newState.doc.nodesBetween(from, to, (node, pos) => {
|
|
1895
|
+
if (node.type === hardbreakSchema.type(ctx))
|
|
1896
|
+
_tr = _tr.setNodeMarkup(
|
|
1897
|
+
pos,
|
|
1898
|
+
hardbreakSchema.type(ctx),
|
|
1899
|
+
void 0,
|
|
1900
|
+
[]
|
|
1901
|
+
);
|
|
1902
|
+
});
|
|
1903
|
+
return _tr;
|
|
1904
|
+
}
|
|
1905
|
+
return void 0;
|
|
1708
1906
|
}
|
|
1709
|
-
}
|
|
1710
|
-
})
|
|
1711
|
-
|
|
1907
|
+
});
|
|
1908
|
+
});
|
|
1909
|
+
withMeta(hardbreakClearMarkPlugin, {
|
|
1712
1910
|
displayName: "Prose<hardbreakClearMarkPlugin>",
|
|
1713
1911
|
group: "Prose"
|
|
1714
1912
|
});
|
|
1715
|
-
const
|
|
1913
|
+
const hardbreakFilterNodes = $ctx(
|
|
1716
1914
|
["table", "code_block"],
|
|
1717
1915
|
"hardbreakFilterNodes"
|
|
1718
1916
|
);
|
|
1719
|
-
|
|
1917
|
+
withMeta(hardbreakFilterNodes, {
|
|
1720
1918
|
displayName: "Ctx<hardbreakFilterNodes>",
|
|
1721
1919
|
group: "Prose"
|
|
1722
1920
|
});
|
|
1723
|
-
const
|
|
1724
|
-
const
|
|
1725
|
-
return new
|
|
1726
|
-
key: new
|
|
1727
|
-
filterTransaction: (
|
|
1728
|
-
const
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1921
|
+
const hardbreakFilterPlugin = $prose((ctx) => {
|
|
1922
|
+
const notIn = ctx.get(hardbreakFilterNodes.key);
|
|
1923
|
+
return new Plugin({
|
|
1924
|
+
key: new PluginKey("MILKDOWN_HARDBREAK_FILTER"),
|
|
1925
|
+
filterTransaction: (tr, state) => {
|
|
1926
|
+
const isInsertHr = tr.getMeta("hardbreak");
|
|
1927
|
+
const [step] = tr.steps;
|
|
1928
|
+
if (isInsertHr && step) {
|
|
1929
|
+
const { from } = step;
|
|
1930
|
+
const $from = state.doc.resolve(from);
|
|
1931
|
+
let curDepth = $from.depth;
|
|
1932
|
+
let canApply = true;
|
|
1933
|
+
while (curDepth > 0) {
|
|
1934
|
+
if (notIn.includes($from.node(curDepth).type.name)) canApply = false;
|
|
1935
|
+
curDepth--;
|
|
1936
|
+
}
|
|
1937
|
+
return canApply;
|
|
1735
1938
|
}
|
|
1736
|
-
return
|
|
1939
|
+
return true;
|
|
1737
1940
|
}
|
|
1738
1941
|
});
|
|
1739
1942
|
});
|
|
1740
|
-
|
|
1943
|
+
withMeta(hardbreakFilterPlugin, {
|
|
1741
1944
|
displayName: "Prose<hardbreakFilterPlugin>",
|
|
1742
1945
|
group: "Prose"
|
|
1743
1946
|
});
|
|
1744
|
-
const
|
|
1745
|
-
const
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
const
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1947
|
+
const syncHeadingIdPlugin = $prose((ctx) => {
|
|
1948
|
+
const headingIdPluginKey = new PluginKey("MILKDOWN_HEADING_ID");
|
|
1949
|
+
const updateId = (view) => {
|
|
1950
|
+
if (view.composing) return;
|
|
1951
|
+
const getId = ctx.get(headingIdGenerator.key);
|
|
1952
|
+
const tr = view.state.tr.setMeta("addToHistory", false);
|
|
1953
|
+
let found = false;
|
|
1954
|
+
const idMap = {};
|
|
1955
|
+
view.state.doc.descendants((node, pos) => {
|
|
1956
|
+
if (node.type === headingSchema.type(ctx)) {
|
|
1957
|
+
if (node.textContent.trim().length === 0) return;
|
|
1958
|
+
const attrs = node.attrs;
|
|
1959
|
+
let id = getId(node);
|
|
1960
|
+
if (idMap[id]) {
|
|
1961
|
+
idMap[id] += 1;
|
|
1962
|
+
id += `-#${idMap[id]}`;
|
|
1963
|
+
} else {
|
|
1964
|
+
idMap[id] = 1;
|
|
1965
|
+
}
|
|
1966
|
+
if (attrs.id !== id) {
|
|
1967
|
+
found = true;
|
|
1968
|
+
tr.setMeta(headingIdPluginKey, true).setNodeMarkup(pos, void 0, {
|
|
1969
|
+
...attrs,
|
|
1970
|
+
id
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1759
1973
|
}
|
|
1760
|
-
})
|
|
1974
|
+
});
|
|
1975
|
+
if (found) view.dispatch(tr);
|
|
1761
1976
|
};
|
|
1762
|
-
return new
|
|
1763
|
-
key:
|
|
1764
|
-
view: (
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1977
|
+
return new Plugin({
|
|
1978
|
+
key: headingIdPluginKey,
|
|
1979
|
+
view: (view) => {
|
|
1980
|
+
updateId(view);
|
|
1981
|
+
return {
|
|
1982
|
+
update: (view2, prevState) => {
|
|
1983
|
+
if (view2.state.doc.eq(prevState.doc)) return;
|
|
1984
|
+
updateId(view2);
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1769
1988
|
});
|
|
1770
1989
|
});
|
|
1771
|
-
|
|
1990
|
+
withMeta(syncHeadingIdPlugin, {
|
|
1772
1991
|
displayName: "Prose<syncHeadingIdPlugin>",
|
|
1773
1992
|
group: "Prose"
|
|
1774
1993
|
});
|
|
1775
|
-
const
|
|
1776
|
-
const
|
|
1777
|
-
if (
|
|
1778
|
-
const
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1994
|
+
const syncListOrderPlugin = $prose((ctx) => {
|
|
1995
|
+
const syncOrderLabel = (view) => {
|
|
1996
|
+
if (view.composing || !view.editable) return;
|
|
1997
|
+
const orderedListType = orderedListSchema.type(ctx);
|
|
1998
|
+
const bulletListType = bulletListSchema.type(ctx);
|
|
1999
|
+
const listItemType = listItemSchema.type(ctx);
|
|
2000
|
+
const state = view.state;
|
|
2001
|
+
const handleNodeItem = (attrs, index) => {
|
|
2002
|
+
let changed = false;
|
|
2003
|
+
const expectedLabel = `${index + 1}.`;
|
|
2004
|
+
if (attrs.label !== expectedLabel) {
|
|
2005
|
+
attrs.label = expectedLabel;
|
|
2006
|
+
changed = true;
|
|
2007
|
+
}
|
|
2008
|
+
return changed;
|
|
1782
2009
|
};
|
|
1783
|
-
let
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
2010
|
+
let tr = state.tr;
|
|
2011
|
+
let needDispatch = false;
|
|
2012
|
+
state.doc.descendants((node, pos, parent, index) => {
|
|
2013
|
+
if (node.type === bulletListType) {
|
|
2014
|
+
const base = node.maybeChild(0);
|
|
2015
|
+
if ((base == null ? void 0 : base.type) === listItemType && base.attrs.listType === "ordered") {
|
|
2016
|
+
needDispatch = true;
|
|
2017
|
+
tr.setNodeMarkup(pos, orderedListType, { spread: "true" });
|
|
2018
|
+
node.descendants((child, pos2, _parent, index2) => {
|
|
2019
|
+
if (child.type === listItemType) {
|
|
2020
|
+
const attrs = { ...child.attrs };
|
|
2021
|
+
const changed = handleNodeItem(attrs, index2);
|
|
2022
|
+
if (changed) tr = tr.setNodeMarkup(pos2, void 0, attrs);
|
|
2023
|
+
}
|
|
2024
|
+
return false;
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
} else if (node.type === listItemType && (parent == null ? void 0 : parent.type) === orderedListType) {
|
|
2028
|
+
const attrs = { ...node.attrs };
|
|
2029
|
+
let changed = false;
|
|
2030
|
+
if (attrs.listType !== "ordered") {
|
|
2031
|
+
attrs.listType = "ordered";
|
|
2032
|
+
changed = true;
|
|
2033
|
+
}
|
|
2034
|
+
const base = parent == null ? void 0 : parent.maybeChild(0);
|
|
2035
|
+
if (base) changed = handleNodeItem(attrs, index);
|
|
2036
|
+
if (changed) {
|
|
2037
|
+
tr = tr.setNodeMarkup(pos, void 0, attrs);
|
|
2038
|
+
needDispatch = true;
|
|
2039
|
+
}
|
|
1798
2040
|
}
|
|
1799
|
-
})
|
|
2041
|
+
});
|
|
2042
|
+
if (needDispatch) view.dispatch(tr.setMeta("addToHistory", false));
|
|
1800
2043
|
};
|
|
1801
|
-
return new
|
|
1802
|
-
key: new
|
|
1803
|
-
view: (
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
2044
|
+
return new Plugin({
|
|
2045
|
+
key: new PluginKey("MILKDOWN_KEEP_LIST_ORDER"),
|
|
2046
|
+
view: (view) => {
|
|
2047
|
+
syncOrderLabel(view);
|
|
2048
|
+
return {
|
|
2049
|
+
update: (view2) => {
|
|
2050
|
+
syncOrderLabel(view2);
|
|
2051
|
+
}
|
|
2052
|
+
};
|
|
2053
|
+
}
|
|
1808
2054
|
});
|
|
1809
2055
|
});
|
|
1810
|
-
|
|
2056
|
+
withMeta(syncListOrderPlugin, {
|
|
1811
2057
|
displayName: "Prose<syncListOrderPlugin>",
|
|
1812
2058
|
group: "Prose"
|
|
1813
2059
|
});
|
|
1814
|
-
const
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
].flat()
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
2060
|
+
const plugins = [
|
|
2061
|
+
hardbreakClearMarkPlugin,
|
|
2062
|
+
hardbreakFilterNodes,
|
|
2063
|
+
hardbreakFilterPlugin,
|
|
2064
|
+
inlineNodesCursorPlugin,
|
|
2065
|
+
remarkAddOrderInListPlugin,
|
|
2066
|
+
remarkInlineLinkPlugin,
|
|
2067
|
+
remarkLineBreak,
|
|
2068
|
+
remarkHtmlTransformer,
|
|
2069
|
+
remarkMarker,
|
|
2070
|
+
syncHeadingIdPlugin,
|
|
2071
|
+
syncListOrderPlugin
|
|
2072
|
+
].flat();
|
|
2073
|
+
const commonmark = [
|
|
2074
|
+
schema,
|
|
2075
|
+
inputRules,
|
|
2076
|
+
markInputRules,
|
|
2077
|
+
commands,
|
|
2078
|
+
keymap,
|
|
2079
|
+
plugins
|
|
1833
2080
|
].flat();
|
|
1834
2081
|
export {
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
2082
|
+
blockquoteAttr,
|
|
2083
|
+
blockquoteKeymap,
|
|
2084
|
+
blockquoteSchema,
|
|
2085
|
+
bulletListAttr,
|
|
2086
|
+
bulletListKeymap,
|
|
2087
|
+
bulletListSchema,
|
|
2088
|
+
codeBlockAttr,
|
|
2089
|
+
codeBlockKeymap,
|
|
2090
|
+
codeBlockSchema,
|
|
2091
|
+
commands,
|
|
2092
|
+
commonmark,
|
|
2093
|
+
createCodeBlockCommand,
|
|
2094
|
+
createCodeBlockInputRule,
|
|
2095
|
+
docSchema,
|
|
2096
|
+
downgradeHeadingCommand,
|
|
2097
|
+
emphasisAttr,
|
|
2098
|
+
emphasisKeymap,
|
|
2099
|
+
emphasisSchema,
|
|
2100
|
+
emphasisStarInputRule,
|
|
2101
|
+
emphasisUnderscoreInputRule,
|
|
2102
|
+
hardbreakAttr,
|
|
2103
|
+
hardbreakClearMarkPlugin,
|
|
2104
|
+
hardbreakFilterNodes,
|
|
2105
|
+
hardbreakFilterPlugin,
|
|
2106
|
+
hardbreakKeymap,
|
|
2107
|
+
hardbreakSchema,
|
|
2108
|
+
headingAttr,
|
|
2109
|
+
headingIdGenerator,
|
|
2110
|
+
headingKeymap,
|
|
2111
|
+
headingSchema,
|
|
2112
|
+
hrAttr,
|
|
2113
|
+
hrSchema,
|
|
2114
|
+
htmlAttr,
|
|
2115
|
+
htmlSchema,
|
|
2116
|
+
imageAttr,
|
|
2117
|
+
imageSchema,
|
|
2118
|
+
inlineCodeAttr,
|
|
2119
|
+
inlineCodeInputRule,
|
|
2120
|
+
inlineCodeKeymap,
|
|
2121
|
+
inlineCodeSchema,
|
|
2122
|
+
inlineNodesCursorPlugin,
|
|
2123
|
+
inputRules,
|
|
2124
|
+
insertHardbreakCommand,
|
|
2125
|
+
insertHrCommand,
|
|
2126
|
+
insertHrInputRule,
|
|
2127
|
+
insertImageCommand,
|
|
2128
|
+
insertImageInputRule,
|
|
2129
|
+
keymap,
|
|
2130
|
+
liftFirstListItemCommand,
|
|
2131
|
+
liftListItemCommand,
|
|
2132
|
+
linkAttr,
|
|
2133
|
+
linkSchema,
|
|
2134
|
+
listItemAttr,
|
|
2135
|
+
listItemKeymap,
|
|
2136
|
+
listItemSchema,
|
|
2137
|
+
markInputRules,
|
|
2138
|
+
orderedListAttr,
|
|
2139
|
+
orderedListKeymap,
|
|
2140
|
+
orderedListSchema,
|
|
2141
|
+
paragraphAttr,
|
|
2142
|
+
paragraphKeymap,
|
|
2143
|
+
paragraphSchema,
|
|
2144
|
+
plugins,
|
|
2145
|
+
remarkAddOrderInListPlugin,
|
|
2146
|
+
remarkHtmlTransformer,
|
|
2147
|
+
remarkInlineLinkPlugin,
|
|
2148
|
+
remarkLineBreak,
|
|
2149
|
+
remarkMarker,
|
|
2150
|
+
schema,
|
|
2151
|
+
sinkListItemCommand,
|
|
2152
|
+
splitListItemCommand,
|
|
2153
|
+
strongAttr,
|
|
2154
|
+
strongInputRule,
|
|
2155
|
+
strongKeymap,
|
|
2156
|
+
strongSchema,
|
|
2157
|
+
syncHeadingIdPlugin,
|
|
2158
|
+
syncListOrderPlugin,
|
|
2159
|
+
textSchema,
|
|
2160
|
+
toggleEmphasisCommand,
|
|
2161
|
+
toggleInlineCodeCommand,
|
|
2162
|
+
toggleLinkCommand,
|
|
2163
|
+
toggleStrongCommand,
|
|
2164
|
+
turnIntoTextCommand,
|
|
2165
|
+
updateCodeBlockLanguageCommand,
|
|
2166
|
+
updateImageCommand,
|
|
2167
|
+
updateLinkCommand,
|
|
2168
|
+
wrapInBlockquoteCommand,
|
|
2169
|
+
wrapInBlockquoteInputRule,
|
|
2170
|
+
wrapInBulletListCommand,
|
|
2171
|
+
wrapInBulletListInputRule,
|
|
2172
|
+
wrapInHeadingCommand,
|
|
2173
|
+
wrapInHeadingInputRule,
|
|
2174
|
+
wrapInOrderedListCommand,
|
|
2175
|
+
wrapInOrderedListInputRule
|
|
1929
2176
|
};
|
|
1930
2177
|
//# sourceMappingURL=index.es.js.map
|