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