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