@milkdown/preset-commonmark 5.5.0 → 6.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/lib/index.d.ts +34 -1
- package/lib/index.d.ts.map +1 -0
- package/lib/index.es.js +260 -523
- package/lib/index.es.js.map +1 -1
- package/lib/{src/mark → mark}/code-inline.d.ts +1 -1
- package/lib/mark/code-inline.d.ts.map +1 -0
- package/lib/{src/mark → mark}/em.d.ts +1 -1
- package/lib/mark/em.d.ts.map +1 -0
- package/lib/mark/index.d.ts +6 -0
- package/lib/mark/index.d.ts.map +1 -0
- package/lib/{src/mark → mark}/link.d.ts +7 -1
- package/lib/mark/link.d.ts.map +1 -0
- package/lib/{src/mark → mark}/strong.d.ts +1 -1
- package/lib/mark/strong.d.ts.map +1 -0
- package/lib/{src/node → node}/blockquote.d.ts +1 -1
- package/lib/node/blockquote.d.ts.map +1 -0
- package/lib/{src/node → node}/bullet-list.d.ts +1 -1
- package/lib/node/bullet-list.d.ts.map +1 -0
- package/lib/{src/node → node}/code-fence.d.ts +1 -1
- package/lib/node/code-fence.d.ts.map +1 -0
- package/lib/{src/node → node}/doc.d.ts +1 -1
- package/lib/node/doc.d.ts.map +1 -0
- package/lib/{src/node → node}/hardbreak.d.ts +1 -1
- package/lib/node/hardbreak.d.ts.map +1 -0
- package/lib/{src/node → node}/heading.d.ts +1 -1
- package/lib/node/heading.d.ts.map +1 -0
- package/lib/{src/node → node}/hr.d.ts +1 -1
- package/lib/node/hr.d.ts.map +1 -0
- package/lib/{src/node → node}/image.d.ts +5 -5
- package/lib/node/image.d.ts.map +1 -0
- package/lib/{src/node → node}/index.d.ts +2 -2
- package/lib/node/index.d.ts.map +1 -0
- package/lib/{src/node → node}/list-item.d.ts +1 -1
- package/lib/node/list-item.d.ts.map +1 -0
- package/lib/{src/node → node}/ordered-list.d.ts +1 -1
- package/lib/node/ordered-list.d.ts.map +1 -0
- package/lib/{src/node → node}/paragraph.d.ts +1 -1
- package/lib/node/paragraph.d.ts.map +1 -0
- package/lib/{src/node → node}/text.d.ts +1 -1
- package/lib/node/text.d.ts.map +1 -0
- package/lib/{src/plugin → plugin}/filter-html.d.ts +0 -0
- package/lib/plugin/filter-html.d.ts.map +1 -0
- package/lib/plugin/index.d.ts +2 -0
- package/lib/plugin/index.d.ts.map +1 -0
- package/lib/{src/supported-keys.d.ts → supported-keys.d.ts} +0 -0
- package/lib/supported-keys.d.ts.map +1 -0
- package/package.json +33 -10
- package/src/mark/code-inline.ts +1 -12
- package/src/mark/link.ts +92 -18
- package/src/mark/strong.ts +1 -7
- package/src/node/blockquote.ts +1 -14
- package/src/node/code-fence.ts +75 -183
- package/src/node/heading.ts +1 -41
- package/src/node/hr.ts +1 -8
- package/src/node/image.ts +80 -232
- package/src/node/list-item.ts +34 -53
- package/src/node/paragraph.ts +1 -9
- package/lib/src/index.d.ts +0 -34
- package/lib/src/index.d.ts.map +0 -1
- package/lib/src/mark/code-inline.d.ts.map +0 -1
- package/lib/src/mark/em.d.ts.map +0 -1
- package/lib/src/mark/index.d.ts +0 -6
- package/lib/src/mark/index.d.ts.map +0 -1
- package/lib/src/mark/link.d.ts.map +0 -1
- package/lib/src/mark/strong.d.ts.map +0 -1
- package/lib/src/node/blockquote.d.ts.map +0 -1
- package/lib/src/node/bullet-list.d.ts.map +0 -1
- package/lib/src/node/code-fence.d.ts.map +0 -1
- package/lib/src/node/doc.d.ts.map +0 -1
- package/lib/src/node/hardbreak.d.ts.map +0 -1
- package/lib/src/node/heading.d.ts.map +0 -1
- package/lib/src/node/hr.d.ts.map +0 -1
- package/lib/src/node/image.d.ts.map +0 -1
- package/lib/src/node/index.d.ts.map +0 -1
- package/lib/src/node/list-item.d.ts.map +0 -1
- package/lib/src/node/ordered-list.d.ts.map +0 -1
- package/lib/src/node/paragraph.d.ts.map +0 -1
- package/lib/src/node/text.d.ts.map +0 -1
- package/lib/src/plugin/filter-html.d.ts.map +0 -1
- package/lib/src/plugin/index.d.ts +0 -2
- package/lib/src/plugin/index.d.ts.map +0 -1
- package/lib/src/supported-keys.d.ts.map +0 -1
- package/lib/src/types.d.ts +0 -5
package/lib/index.es.js
CHANGED
|
@@ -4,7 +4,7 @@ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj,
|
|
7
|
+
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
8
8
|
var __spreadValues = (a, b) => {
|
|
9
9
|
for (var prop in b || (b = {}))
|
|
10
10
|
if (__hasOwnProp.call(b, prop))
|
|
@@ -18,8 +18,8 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import { createMark, createShortcut, createNode, createPlugin, AtomList } from "@milkdown/utils";
|
|
21
|
-
import { createCmdKey, createCmd, schemaCtx,
|
|
22
|
-
import { markRule, toggleMark, TextSelection, InputRule, wrappingInputRule, wrapIn, textblockTypeInputRule, setBlockType,
|
|
21
|
+
import { createCmdKey, createCmd, schemaCtx, commandsCtx, editorViewCtx } from "@milkdown/core";
|
|
22
|
+
import { markRule, toggleMark, PluginKey, TextSelection, InputRule, Plugin, wrappingInputRule, wrapIn, textblockTypeInputRule, setBlockType, ReplaceStep, AddMarkStep, Selection, findSelectedNodeOfType, splitListItem, sinkListItem, liftListItem } from "@milkdown/prose";
|
|
23
23
|
import links from "remark-inline-links";
|
|
24
24
|
const SupportedKeys = {
|
|
25
25
|
HardBreak: "HardBreak",
|
|
@@ -44,14 +44,6 @@ const SupportedKeys = {
|
|
|
44
44
|
const id$a = "code_inline";
|
|
45
45
|
const ToggleInlineCode = createCmdKey("ToggleInlineCode");
|
|
46
46
|
const codeInline = createMark((utils) => {
|
|
47
|
-
const style = utils.getStyle(({ palette, size, font }, { css }) => css`
|
|
48
|
-
background-color: ${palette("neutral")};
|
|
49
|
-
color: ${palette("background")};
|
|
50
|
-
border-radius: ${size.radius};
|
|
51
|
-
font-weight: 500;
|
|
52
|
-
font-family: ${font.code};
|
|
53
|
-
padding: 0 0.2rem;
|
|
54
|
-
`);
|
|
55
47
|
return {
|
|
56
48
|
id: id$a,
|
|
57
49
|
schema: () => ({
|
|
@@ -59,7 +51,7 @@ const codeInline = createMark((utils) => {
|
|
|
59
51
|
code: true,
|
|
60
52
|
inclusive: false,
|
|
61
53
|
parseDOM: [{ tag: "code" }],
|
|
62
|
-
toDOM: (mark) => ["code", { class: utils.getClassName(mark.attrs, "code-inline"
|
|
54
|
+
toDOM: (mark) => ["code", { class: utils.getClassName(mark.attrs, "code-inline") }],
|
|
63
55
|
parseMarkdown: {
|
|
64
56
|
match: (node) => node.type === "inlineCode",
|
|
65
57
|
runner: (state, node, markType) => {
|
|
@@ -117,23 +109,11 @@ const em = createMark((utils) => ({
|
|
|
117
109
|
[SupportedKeys.Em]: createShortcut(ToggleItalic, "Mod-i")
|
|
118
110
|
}
|
|
119
111
|
}));
|
|
112
|
+
const key$1 = new PluginKey("MILKDOWN_PLUGIN_LINK_INPUT");
|
|
120
113
|
const ToggleLink = createCmdKey("ToggleLink");
|
|
121
114
|
const ModifyLink = createCmdKey("ModifyLink");
|
|
122
115
|
const id$8 = "link";
|
|
123
|
-
const link = createMark((utils) => {
|
|
124
|
-
const style = utils.getStyle((themeTool, { css }) => {
|
|
125
|
-
const lineColor = themeTool.palette("line");
|
|
126
|
-
return css`
|
|
127
|
-
color: ${themeTool.palette("secondary")};
|
|
128
|
-
cursor: pointer;
|
|
129
|
-
transition: all 0.4s ease-in-out;
|
|
130
|
-
font-weight: 500;
|
|
131
|
-
&:hover {
|
|
132
|
-
background-color: ${lineColor};
|
|
133
|
-
box-shadow: 0 0.2rem ${lineColor}, 0 -0.2rem ${lineColor};
|
|
134
|
-
}
|
|
135
|
-
`;
|
|
136
|
-
});
|
|
116
|
+
const link = createMark((utils, options) => {
|
|
137
117
|
return {
|
|
138
118
|
id: id$8,
|
|
139
119
|
schema: () => ({
|
|
@@ -153,7 +133,7 @@ const link = createMark((utils) => {
|
|
|
153
133
|
}
|
|
154
134
|
}
|
|
155
135
|
],
|
|
156
|
-
toDOM: (mark) => ["a", __spreadProps(__spreadValues({}, mark.attrs), { class: utils.getClassName(mark.attrs, id$8
|
|
136
|
+
toDOM: (mark) => ["a", __spreadProps(__spreadValues({}, mark.attrs), { class: utils.getClassName(mark.attrs, id$8) })],
|
|
157
137
|
parseMarkdown: {
|
|
158
138
|
match: (node) => node.type === "link",
|
|
159
139
|
runner: (state, node, markType) => {
|
|
@@ -214,15 +194,78 @@ const link = createMark((utils) => {
|
|
|
214
194
|
}
|
|
215
195
|
return tr;
|
|
216
196
|
})
|
|
217
|
-
]
|
|
197
|
+
],
|
|
198
|
+
prosePlugins: (type, ctx) => {
|
|
199
|
+
var _a, _b, _c;
|
|
200
|
+
const inputChipRenderer = utils.themeManager.get("input-chip", {
|
|
201
|
+
placeholder: (_b = (_a = options == null ? void 0 : options.input) == null ? void 0 : _a.placeholder) != null ? _b : "Input Web Link",
|
|
202
|
+
buttonText: (_c = options == null ? void 0 : options.input) == null ? void 0 : _c.buttonText,
|
|
203
|
+
onUpdate: (value) => {
|
|
204
|
+
ctx.get(commandsCtx).call(ModifyLink, value);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
const shouldDisplay = (view) => {
|
|
208
|
+
const { selection, doc: doc2 } = view.state;
|
|
209
|
+
const { from, to } = selection;
|
|
210
|
+
return selection.empty && selection instanceof TextSelection && doc2.rangeHasMark(from, from === to ? to + 1 : to, type);
|
|
211
|
+
};
|
|
212
|
+
const getCurrentLink = (view) => {
|
|
213
|
+
const { selection } = view.state;
|
|
214
|
+
let node;
|
|
215
|
+
const { from, to } = selection;
|
|
216
|
+
view.state.doc.nodesBetween(from, from === to ? to + 1 : to, (n) => {
|
|
217
|
+
if (type.isInSet(n.marks)) {
|
|
218
|
+
node = n;
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
return;
|
|
222
|
+
});
|
|
223
|
+
if (!node)
|
|
224
|
+
return;
|
|
225
|
+
const mark = node.marks.find((m) => m.type === type);
|
|
226
|
+
if (!mark)
|
|
227
|
+
return;
|
|
228
|
+
const value = mark.attrs["href"];
|
|
229
|
+
return value;
|
|
230
|
+
};
|
|
231
|
+
const renderByView = (view) => {
|
|
232
|
+
if (!view.editable) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const display = shouldDisplay(view);
|
|
236
|
+
if (display) {
|
|
237
|
+
inputChipRenderer.show(view);
|
|
238
|
+
inputChipRenderer.update(getCurrentLink(view));
|
|
239
|
+
} else {
|
|
240
|
+
inputChipRenderer.hide();
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
return [
|
|
244
|
+
new Plugin({
|
|
245
|
+
key: key$1,
|
|
246
|
+
view: (editorView) => {
|
|
247
|
+
inputChipRenderer.init(editorView);
|
|
248
|
+
renderByView(editorView);
|
|
249
|
+
return {
|
|
250
|
+
update: (view, prevState) => {
|
|
251
|
+
const isEqualSelection = (prevState == null ? void 0 : prevState.doc.eq(view.state.doc)) && prevState.selection.eq(view.state.selection);
|
|
252
|
+
if (isEqualSelection)
|
|
253
|
+
return;
|
|
254
|
+
renderByView(view);
|
|
255
|
+
},
|
|
256
|
+
destroy: () => {
|
|
257
|
+
inputChipRenderer.destroy();
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
})
|
|
262
|
+
];
|
|
263
|
+
}
|
|
218
264
|
};
|
|
219
265
|
});
|
|
220
266
|
const id$7 = "strong";
|
|
221
267
|
const ToggleBold = createCmdKey("ToggleBold");
|
|
222
268
|
const strong = createMark((utils) => {
|
|
223
|
-
const style = utils.getStyle((_, { css }) => css`
|
|
224
|
-
font-weight: 600;
|
|
225
|
-
`);
|
|
226
269
|
return {
|
|
227
270
|
id: id$7,
|
|
228
271
|
schema: () => ({
|
|
@@ -231,7 +274,7 @@ const strong = createMark((utils) => {
|
|
|
231
274
|
{ tag: "strong" },
|
|
232
275
|
{ style: "font-style", getAttrs: (value) => value === "bold" }
|
|
233
276
|
],
|
|
234
|
-
toDOM: (mark) => ["strong", { class: utils.getClassName(mark.attrs, id$7
|
|
277
|
+
toDOM: (mark) => ["strong", { class: utils.getClassName(mark.attrs, id$7) }],
|
|
235
278
|
parseMarkdown: {
|
|
236
279
|
match: (node) => node.type === "strong",
|
|
237
280
|
runner: (state, node, markType) => {
|
|
@@ -261,15 +304,6 @@ const marks = [codeInline(), em(), strong(), link()];
|
|
|
261
304
|
const id$6 = "blockquote";
|
|
262
305
|
const WrapInBlockquote = createCmdKey("WrapInBlockquote");
|
|
263
306
|
const blockquote = createNode((utils) => {
|
|
264
|
-
const style = utils.getStyle((themeTool, { css }) => css`
|
|
265
|
-
padding-left: 1.875rem;
|
|
266
|
-
line-height: 1.75rem;
|
|
267
|
-
border-left: 4px solid ${themeTool.palette("primary")};
|
|
268
|
-
* {
|
|
269
|
-
font-size: 1rem;
|
|
270
|
-
line-height: 1.5rem;
|
|
271
|
-
}
|
|
272
|
-
`);
|
|
273
307
|
return {
|
|
274
308
|
id: id$6,
|
|
275
309
|
schema: () => ({
|
|
@@ -277,7 +311,7 @@ const blockquote = createNode((utils) => {
|
|
|
277
311
|
group: "block",
|
|
278
312
|
defining: true,
|
|
279
313
|
parseDOM: [{ tag: "blockquote" }],
|
|
280
|
-
toDOM: (node) => ["blockquote", { class: utils.getClassName(node.attrs, id$6
|
|
314
|
+
toDOM: (node) => ["blockquote", { class: utils.getClassName(node.attrs, id$6) }, 0],
|
|
281
315
|
parseMarkdown: {
|
|
282
316
|
match: ({ type }) => type === id$6,
|
|
283
317
|
runner: (state, node, type) => {
|
|
@@ -353,118 +387,10 @@ const tildeInputRegex = /^~~~(?<language>[a-z]*)?[\s\n]$/;
|
|
|
353
387
|
const TurnIntoCodeFence = createCmdKey("TurnIntoCodeFence");
|
|
354
388
|
const id$5 = "fence";
|
|
355
389
|
const codeFence = createNode((utils, options) => {
|
|
356
|
-
const
|
|
357
|
-
const { shadow, scrollbar, border } = mixin;
|
|
358
|
-
const { lineWidth, radius } = size;
|
|
359
|
-
return css`
|
|
360
|
-
background-color: ${palette("background")};
|
|
361
|
-
color: ${palette("neutral")};
|
|
362
|
-
font-size: 0.85rem;
|
|
363
|
-
padding: 1.2rem 0.4rem 1.4rem;
|
|
364
|
-
border-radius: ${radius};
|
|
365
|
-
font-family: ${font.typography};
|
|
366
|
-
|
|
367
|
-
* {
|
|
368
|
-
margin: 0;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
.code-fence_select-wrapper {
|
|
372
|
-
position: relative;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
.code-fence_value {
|
|
376
|
-
width: 10.25rem;
|
|
377
|
-
box-sizing: border-box;
|
|
378
|
-
border-radius: ${size.radius};
|
|
379
|
-
margin: 0 1.2rem 1.2rem;
|
|
380
|
-
${border()};
|
|
381
|
-
${shadow()};
|
|
382
|
-
cursor: pointer;
|
|
383
|
-
background-color: ${palette("surface")};
|
|
384
|
-
position: relative;
|
|
385
|
-
display: flex;
|
|
386
|
-
color: ${palette("neutral", 0.87)};
|
|
387
|
-
letter-spacing: 0.5px;
|
|
388
|
-
height: 2.625rem;
|
|
389
|
-
align-items: center;
|
|
390
|
-
|
|
391
|
-
& > .icon {
|
|
392
|
-
width: 2.625rem;
|
|
393
|
-
height: 100%;
|
|
394
|
-
display: flex;
|
|
395
|
-
justify-content: center;
|
|
396
|
-
align-items: center;
|
|
397
|
-
color: ${palette("solid", 0.87)};
|
|
398
|
-
border-left: ${lineWidth} solid ${palette("line")};
|
|
399
|
-
|
|
400
|
-
text-align: center;
|
|
401
|
-
transition: all 0.2s ease-in-out;
|
|
402
|
-
&:hover {
|
|
403
|
-
background: ${palette("background")};
|
|
404
|
-
color: ${palette("primary")};
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
> span:first-child {
|
|
409
|
-
padding-left: 1rem;
|
|
410
|
-
flex: 1;
|
|
411
|
-
font-weight: 500;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
.code-fence_select-option {
|
|
416
|
-
list-style: none;
|
|
417
|
-
line-height: 2rem;
|
|
418
|
-
padding-left: 1rem;
|
|
419
|
-
cursor: pointer;
|
|
420
|
-
:hover {
|
|
421
|
-
background: ${palette("secondary", 0.12)};
|
|
422
|
-
color: ${palette("primary")};
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
.code-fence_select {
|
|
427
|
-
&[data-fold='true'] {
|
|
428
|
-
display: none;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
font-weight: 500;
|
|
432
|
-
position: absolute;
|
|
433
|
-
z-index: 1;
|
|
434
|
-
top: 2.625rem;
|
|
435
|
-
box-sizing: border-box;
|
|
436
|
-
left: 1.2rem;
|
|
437
|
-
padding: 0.5rem 0;
|
|
438
|
-
max-height: 16.75rem;
|
|
439
|
-
width: 10.25rem;
|
|
440
|
-
${border()};
|
|
441
|
-
${shadow()};
|
|
442
|
-
background-color: ${palette("surface")};
|
|
443
|
-
border-top: none;
|
|
444
|
-
overflow-y: auto;
|
|
445
|
-
display: flex;
|
|
446
|
-
flex-direction: column;
|
|
447
|
-
|
|
448
|
-
${scrollbar("y")}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
code {
|
|
452
|
-
line-height: 1.5;
|
|
453
|
-
font-family: ${font.code};
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
pre {
|
|
457
|
-
font-family: ${font.code};
|
|
458
|
-
margin: 0 1.2rem !important;
|
|
459
|
-
white-space: pre;
|
|
460
|
-
overflow: auto;
|
|
461
|
-
${scrollbar("x")};
|
|
462
|
-
}
|
|
463
|
-
`;
|
|
464
|
-
});
|
|
390
|
+
const languageList = (options == null ? void 0 : options.languageList) || languageOptions;
|
|
465
391
|
return {
|
|
466
392
|
id: id$5,
|
|
467
|
-
schema: () => ({
|
|
393
|
+
schema: (ctx) => ({
|
|
468
394
|
content: "text*",
|
|
469
395
|
group: "block",
|
|
470
396
|
marks: "",
|
|
@@ -491,13 +417,49 @@ const codeFence = createNode((utils, options) => {
|
|
|
491
417
|
}
|
|
492
418
|
],
|
|
493
419
|
toDOM: (node) => {
|
|
420
|
+
const select = document.createElement("select");
|
|
421
|
+
languageList.forEach((lang) => {
|
|
422
|
+
const option = document.createElement("option");
|
|
423
|
+
option.value = lang;
|
|
424
|
+
option.innerText = !lang ? "--" : lang;
|
|
425
|
+
if (lang === node.attrs["language"]) {
|
|
426
|
+
option.selected = true;
|
|
427
|
+
}
|
|
428
|
+
select.appendChild(option);
|
|
429
|
+
});
|
|
430
|
+
select.onchange = (e) => {
|
|
431
|
+
const target = e.target;
|
|
432
|
+
if (!(target instanceof HTMLSelectElement)) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const view = ctx.get(editorViewCtx);
|
|
436
|
+
if (!view.editable) {
|
|
437
|
+
target.value = node.attrs["language"];
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
const { top, left } = target.getBoundingClientRect();
|
|
441
|
+
const result = view.posAtCoords({ top, left });
|
|
442
|
+
if (!result)
|
|
443
|
+
return;
|
|
444
|
+
const { tr } = view.state;
|
|
445
|
+
view.dispatch(tr.setNodeMarkup(result.inside, void 0, __spreadProps(__spreadValues({}, node.attrs), {
|
|
446
|
+
language: target.value
|
|
447
|
+
})));
|
|
448
|
+
};
|
|
494
449
|
return [
|
|
495
|
-
"
|
|
450
|
+
"div",
|
|
496
451
|
{
|
|
497
|
-
|
|
498
|
-
class: utils.getClassName(node.attrs, "code-fence", style)
|
|
452
|
+
class: "code-fence-container"
|
|
499
453
|
},
|
|
500
|
-
|
|
454
|
+
select,
|
|
455
|
+
[
|
|
456
|
+
"pre",
|
|
457
|
+
{
|
|
458
|
+
"data-language": node.attrs["language"],
|
|
459
|
+
class: utils.getClassName(node.attrs, "code-fence")
|
|
460
|
+
},
|
|
461
|
+
["code", { spellCheck: "false" }, 0]
|
|
462
|
+
]
|
|
501
463
|
];
|
|
502
464
|
},
|
|
503
465
|
parseMarkdown: {
|
|
@@ -540,87 +502,49 @@ const codeFence = createNode((utils, options) => {
|
|
|
540
502
|
shortcuts: {
|
|
541
503
|
[SupportedKeys.CodeFence]: createShortcut(TurnIntoCodeFence, "Mod-Alt-c")
|
|
542
504
|
},
|
|
543
|
-
view: (
|
|
544
|
-
|
|
545
|
-
const
|
|
546
|
-
const select = document.createElement("ul");
|
|
547
|
-
const pre = document.createElement("pre");
|
|
548
|
-
const code = document.createElement("code");
|
|
549
|
-
const valueWrapper = document.createElement("div");
|
|
550
|
-
valueWrapper.className = "code-fence_value";
|
|
551
|
-
const value = document.createElement("span");
|
|
552
|
-
valueWrapper.appendChild(value);
|
|
553
|
-
if (view.editable) {
|
|
554
|
-
valueWrapper.appendChild(ctx.get(themeToolCtx).slots.icon("downArrow"));
|
|
555
|
-
}
|
|
556
|
-
select.className = "code-fence_select";
|
|
557
|
-
select.addEventListener("mousedown", (e) => {
|
|
558
|
-
e.preventDefault();
|
|
559
|
-
e.stopPropagation();
|
|
560
|
-
if (!view.editable)
|
|
561
|
-
return;
|
|
562
|
-
const el = e.target;
|
|
563
|
-
if (!(el instanceof HTMLLIElement))
|
|
564
|
-
return;
|
|
505
|
+
view: () => (node, view, getPos) => {
|
|
506
|
+
let currNode = node;
|
|
507
|
+
const onSelectLanguage = (language) => {
|
|
565
508
|
const { tr } = view.state;
|
|
566
509
|
view.dispatch(tr.setNodeMarkup(getPos(), void 0, {
|
|
567
510
|
fold: true,
|
|
568
|
-
language
|
|
511
|
+
language
|
|
569
512
|
}));
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
e.preventDefault();
|
|
573
|
-
e.stopPropagation();
|
|
574
|
-
if (!view.editable)
|
|
575
|
-
return;
|
|
513
|
+
};
|
|
514
|
+
const onBlur = () => {
|
|
576
515
|
const { tr } = view.state;
|
|
577
|
-
view.dispatch(tr.setNodeMarkup(getPos(), void 0, {
|
|
578
|
-
fold:
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
document.addEventListener("mousedown", () => {
|
|
583
|
-
if (!view.editable || select.dataset["fold"] === "true")
|
|
584
|
-
return;
|
|
516
|
+
view.dispatch(tr.setNodeMarkup(getPos(), void 0, __spreadProps(__spreadValues({}, currNode.attrs), {
|
|
517
|
+
fold: true
|
|
518
|
+
})));
|
|
519
|
+
};
|
|
520
|
+
const onFocus = () => {
|
|
585
521
|
const { tr } = view.state;
|
|
586
|
-
view.dispatch(tr.setNodeMarkup(getPos(), void 0, {
|
|
587
|
-
fold:
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
option.setAttribute("data-value", lang);
|
|
522
|
+
view.dispatch(tr.setNodeMarkup(getPos(), void 0, __spreadProps(__spreadValues({}, currNode.attrs), {
|
|
523
|
+
fold: false
|
|
524
|
+
})));
|
|
525
|
+
};
|
|
526
|
+
const renderer = utils.themeManager.get("code-fence", {
|
|
527
|
+
onBlur,
|
|
528
|
+
onFocus,
|
|
529
|
+
onSelectLanguage,
|
|
530
|
+
editable: () => view.editable,
|
|
531
|
+
languageList
|
|
597
532
|
});
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
selectWrapper.append(select);
|
|
603
|
-
pre.append(code);
|
|
604
|
-
const codeContent = document.createElement("div");
|
|
605
|
-
code.append(codeContent);
|
|
606
|
-
codeContent.style.whiteSpace = "inherit";
|
|
607
|
-
container.append(selectWrapper, pre);
|
|
608
|
-
container.setAttribute("class", utils.getClassName(node.attrs, "code-fence", style));
|
|
609
|
-
container.setAttribute("data-language", node.attrs["language"]);
|
|
610
|
-
value.innerText = node.attrs["language"] || "--";
|
|
611
|
-
select.setAttribute("data-fold", node.attrs["fold"] ? "true" : "false");
|
|
533
|
+
if (!renderer)
|
|
534
|
+
return {};
|
|
535
|
+
const { dom, contentDOM, onUpdate, onDestroy } = renderer;
|
|
536
|
+
onUpdate(currNode);
|
|
612
537
|
return {
|
|
613
|
-
dom
|
|
614
|
-
contentDOM
|
|
538
|
+
dom,
|
|
539
|
+
contentDOM,
|
|
615
540
|
update: (updatedNode) => {
|
|
616
541
|
if (updatedNode.type.name !== id$5)
|
|
617
542
|
return false;
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
value.innerText = lang || "--";
|
|
621
|
-
select.setAttribute("data-fold", updatedNode.attrs["fold"] ? "true" : "false");
|
|
543
|
+
currNode = updatedNode;
|
|
544
|
+
onUpdate(currNode);
|
|
622
545
|
return true;
|
|
623
|
-
}
|
|
546
|
+
},
|
|
547
|
+
destroy: onDestroy
|
|
624
548
|
};
|
|
625
549
|
}
|
|
626
550
|
};
|
|
@@ -718,39 +642,6 @@ const TurnIntoHeading = createCmdKey("TurnIntoHeading");
|
|
|
718
642
|
const headingPluginKey = new PluginKey("MILKDOWN_PLUGIN_ID");
|
|
719
643
|
const heading = createNode((utils) => {
|
|
720
644
|
const id2 = "heading";
|
|
721
|
-
const style = (level) => utils.getStyle((_, { css }) => {
|
|
722
|
-
const headingMap = {
|
|
723
|
-
1: css`
|
|
724
|
-
font-size: 3rem;
|
|
725
|
-
line-height: 3.5rem;
|
|
726
|
-
`,
|
|
727
|
-
2: css`
|
|
728
|
-
font-size: 2.5rem;
|
|
729
|
-
line-height: 3rem;
|
|
730
|
-
`,
|
|
731
|
-
3: css`
|
|
732
|
-
font-size: 2.125rem;
|
|
733
|
-
line-height: 2.25rem;
|
|
734
|
-
`,
|
|
735
|
-
4: css`
|
|
736
|
-
font-size: 1.75rem;
|
|
737
|
-
line-height: 2rem;
|
|
738
|
-
`,
|
|
739
|
-
5: css`
|
|
740
|
-
font-size: 1.5rem;
|
|
741
|
-
line-height: 1.5rem;
|
|
742
|
-
`,
|
|
743
|
-
6: css`
|
|
744
|
-
font-size: 1.25rem;
|
|
745
|
-
line-height: 1.25rem;
|
|
746
|
-
`
|
|
747
|
-
};
|
|
748
|
-
return css`
|
|
749
|
-
${headingMap[level] || ""}
|
|
750
|
-
margin: 2.5rem 0 !important;
|
|
751
|
-
font-weight: 400;
|
|
752
|
-
`;
|
|
753
|
-
});
|
|
754
645
|
return {
|
|
755
646
|
id: id2,
|
|
756
647
|
schema: () => ({
|
|
@@ -779,7 +670,7 @@ const heading = createNode((utils) => {
|
|
|
779
670
|
`h${node.attrs["level"]}`,
|
|
780
671
|
{
|
|
781
672
|
id: node.attrs["id"] || node.textContent.split(" ").join("-").toLocaleLowerCase(),
|
|
782
|
-
class: utils.getClassName(node.attrs, `heading h${node.attrs["level"]}
|
|
673
|
+
class: utils.getClassName(node.attrs, `heading h${node.attrs["level"]}`)
|
|
783
674
|
},
|
|
784
675
|
0
|
|
785
676
|
];
|
|
@@ -873,17 +764,12 @@ const heading = createNode((utils) => {
|
|
|
873
764
|
const id$4 = "hr";
|
|
874
765
|
const InsertHr = createCmdKey("InsertHr");
|
|
875
766
|
const hr = createNode((utils) => {
|
|
876
|
-
const style = utils.getStyle((themeTool, { css }) => css`
|
|
877
|
-
height: ${themeTool.size.lineWidth};
|
|
878
|
-
background-color: ${themeTool.palette("line")};
|
|
879
|
-
border-width: 0;
|
|
880
|
-
`);
|
|
881
767
|
return {
|
|
882
768
|
id: id$4,
|
|
883
769
|
schema: () => ({
|
|
884
770
|
group: "block",
|
|
885
771
|
parseDOM: [{ tag: "hr" }],
|
|
886
|
-
toDOM: (node) => ["hr", { class: utils.getClassName(node.attrs, id$4
|
|
772
|
+
toDOM: (node) => ["hr", { class: utils.getClassName(node.attrs, id$4) }],
|
|
887
773
|
parseMarkdown: {
|
|
888
774
|
match: ({ type }) => type === "thematicBreak",
|
|
889
775
|
runner: (state, _, type) => {
|
|
@@ -930,115 +816,8 @@ const hr = createNode((utils) => {
|
|
|
930
816
|
const ModifyImage = createCmdKey("ModifyImage");
|
|
931
817
|
const InsertImage = createCmdKey("InsertImage");
|
|
932
818
|
const id$3 = "image";
|
|
819
|
+
const key = new PluginKey("MILKDOWN_PLUGIN_IMAGE_INPUT");
|
|
933
820
|
const image = createNode((utils, options) => {
|
|
934
|
-
var _a, _b;
|
|
935
|
-
const placeholder = __spreadValues({
|
|
936
|
-
loading: "Loading...",
|
|
937
|
-
empty: "Add an Image",
|
|
938
|
-
failed: "Image loads failed"
|
|
939
|
-
}, (_a = options == null ? void 0 : options.placeholder) != null ? _a : {});
|
|
940
|
-
const isBlock = (_b = options == null ? void 0 : options.isBlock) != null ? _b : false;
|
|
941
|
-
const containerStyle = utils.getStyle((themeTool, { css }) => css`
|
|
942
|
-
display: inline-block;
|
|
943
|
-
position: relative;
|
|
944
|
-
text-align: center;
|
|
945
|
-
font-size: 0;
|
|
946
|
-
vertical-align: text-bottom;
|
|
947
|
-
line-height: 1;
|
|
948
|
-
|
|
949
|
-
${isBlock ? `
|
|
950
|
-
width: 100%;
|
|
951
|
-
margin: 0 auto;
|
|
952
|
-
` : ""}
|
|
953
|
-
|
|
954
|
-
&.ProseMirror-selectednode::after {
|
|
955
|
-
content: '';
|
|
956
|
-
background: ${themeTool.palette("secondary", 0.38)};
|
|
957
|
-
position: absolute;
|
|
958
|
-
top: 0;
|
|
959
|
-
left: 0;
|
|
960
|
-
right: 0;
|
|
961
|
-
bottom: 0;
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
img {
|
|
965
|
-
max-width: 100%;
|
|
966
|
-
height: auto;
|
|
967
|
-
object-fit: contain;
|
|
968
|
-
margin: 0 2px;
|
|
969
|
-
}
|
|
970
|
-
.icon,
|
|
971
|
-
.placeholder {
|
|
972
|
-
display: none;
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
&.system {
|
|
976
|
-
width: 100%;
|
|
977
|
-
padding: 0 2rem;
|
|
978
|
-
|
|
979
|
-
img {
|
|
980
|
-
width: 0;
|
|
981
|
-
height: 0;
|
|
982
|
-
display: none;
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
.icon,
|
|
986
|
-
.placeholder {
|
|
987
|
-
display: inline;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
box-sizing: border-box;
|
|
991
|
-
height: 3rem;
|
|
992
|
-
background-color: ${themeTool.palette("background")};
|
|
993
|
-
border-radius: ${themeTool.size.radius};
|
|
994
|
-
display: inline-flex;
|
|
995
|
-
gap: 2rem;
|
|
996
|
-
justify-content: flex-start;
|
|
997
|
-
align-items: center;
|
|
998
|
-
.placeholder {
|
|
999
|
-
margin: 0;
|
|
1000
|
-
line-height: 1;
|
|
1001
|
-
&::before {
|
|
1002
|
-
content: '';
|
|
1003
|
-
font-size: 0.875rem;
|
|
1004
|
-
color: ${themeTool.palette("neutral", 0.6)};
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
&.loading {
|
|
1010
|
-
.placeholder {
|
|
1011
|
-
&::before {
|
|
1012
|
-
content: '${placeholder.loading}';
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
&.empty {
|
|
1018
|
-
.placeholder {
|
|
1019
|
-
&::before {
|
|
1020
|
-
content: '${placeholder.empty}';
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
&.failed {
|
|
1026
|
-
.placeholder {
|
|
1027
|
-
&::before {
|
|
1028
|
-
content: '${placeholder.failed}';
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
`);
|
|
1033
|
-
const style = utils.getStyle((_, { css }) => css`
|
|
1034
|
-
display: inline-block;
|
|
1035
|
-
margin: 0 auto;
|
|
1036
|
-
object-fit: contain;
|
|
1037
|
-
width: 100%;
|
|
1038
|
-
position: relative;
|
|
1039
|
-
height: auto;
|
|
1040
|
-
text-align: center;
|
|
1041
|
-
`);
|
|
1042
821
|
return {
|
|
1043
822
|
id: "image",
|
|
1044
823
|
schema: () => ({
|
|
@@ -1053,10 +832,7 @@ const image = createNode((utils, options) => {
|
|
|
1053
832
|
attrs: {
|
|
1054
833
|
src: { default: "" },
|
|
1055
834
|
alt: { default: null },
|
|
1056
|
-
title: { default: null }
|
|
1057
|
-
failed: { default: false },
|
|
1058
|
-
loading: { default: true },
|
|
1059
|
-
width: { default: null }
|
|
835
|
+
title: { default: null }
|
|
1060
836
|
},
|
|
1061
837
|
parseDOM: [
|
|
1062
838
|
{
|
|
@@ -1066,8 +842,6 @@ const image = createNode((utils, options) => {
|
|
|
1066
842
|
throw new Error();
|
|
1067
843
|
}
|
|
1068
844
|
return {
|
|
1069
|
-
failed: dom.classList.contains("failed"),
|
|
1070
|
-
loading: dom.classList.contains("loading"),
|
|
1071
845
|
src: dom.getAttribute("src") || "",
|
|
1072
846
|
alt: dom.getAttribute("alt"),
|
|
1073
847
|
title: dom.getAttribute("title") || dom.getAttribute("alt"),
|
|
@@ -1080,7 +854,7 @@ const image = createNode((utils, options) => {
|
|
|
1080
854
|
return [
|
|
1081
855
|
"img",
|
|
1082
856
|
__spreadProps(__spreadValues({}, node.attrs), {
|
|
1083
|
-
class: utils.getClassName(node.attrs, id$3
|
|
857
|
+
class: utils.getClassName(node.attrs, id$3)
|
|
1084
858
|
})
|
|
1085
859
|
];
|
|
1086
860
|
},
|
|
@@ -1140,103 +914,88 @@ const image = createNode((utils, options) => {
|
|
|
1140
914
|
return tr;
|
|
1141
915
|
})
|
|
1142
916
|
],
|
|
1143
|
-
view: (
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
const
|
|
1147
|
-
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
const setIcon = (name) => {
|
|
1155
|
-
const nextIcon = createIcon(name);
|
|
1156
|
-
container.replaceChild(nextIcon, icon);
|
|
1157
|
-
icon = nextIcon;
|
|
1158
|
-
};
|
|
1159
|
-
const loadImage = (src2) => {
|
|
1160
|
-
container.classList.add("system", "loading");
|
|
1161
|
-
setIcon("loading");
|
|
1162
|
-
const img = document.createElement("img");
|
|
1163
|
-
img.src = src2;
|
|
1164
|
-
img.onerror = () => {
|
|
1165
|
-
const pos = getPos();
|
|
1166
|
-
if (!pos)
|
|
1167
|
-
return;
|
|
1168
|
-
const { tr } = view.state;
|
|
1169
|
-
const _tr = tr.setNodeMarkup(pos, nodeType, __spreadProps(__spreadValues({}, node.attrs), {
|
|
1170
|
-
src: src2,
|
|
1171
|
-
loading: false,
|
|
1172
|
-
failed: true
|
|
1173
|
-
}));
|
|
1174
|
-
view.dispatch(_tr);
|
|
1175
|
-
};
|
|
1176
|
-
img.onload = () => {
|
|
1177
|
-
const { tr } = view.state;
|
|
1178
|
-
const pos = getPos();
|
|
1179
|
-
if (!pos)
|
|
1180
|
-
return;
|
|
1181
|
-
const _tr = tr.setNodeMarkup(pos, nodeType, __spreadProps(__spreadValues({}, node.attrs), {
|
|
1182
|
-
width: img.width,
|
|
1183
|
-
src: src2,
|
|
1184
|
-
loading: false,
|
|
1185
|
-
failed: false
|
|
1186
|
-
}));
|
|
1187
|
-
view.dispatch(_tr);
|
|
1188
|
-
};
|
|
1189
|
-
};
|
|
1190
|
-
const { src, loading, title, alt, width } = node.attrs;
|
|
1191
|
-
content.src = src;
|
|
1192
|
-
content.title = title || alt;
|
|
1193
|
-
content.alt = alt;
|
|
1194
|
-
if (width) {
|
|
1195
|
-
content.width = width;
|
|
1196
|
-
}
|
|
1197
|
-
if (src.length === 0) {
|
|
1198
|
-
container.classList.add("system", "empty");
|
|
1199
|
-
setIcon("image");
|
|
1200
|
-
} else if (loading) {
|
|
1201
|
-
loadImage(src);
|
|
917
|
+
view: () => (node) => {
|
|
918
|
+
var _a, _b;
|
|
919
|
+
let currNode = node;
|
|
920
|
+
const placeholder = (_a = options == null ? void 0 : options.placeholder) != null ? _a : "Add an Image";
|
|
921
|
+
const isBlock = (_b = options == null ? void 0 : options.isBlock) != null ? _b : false;
|
|
922
|
+
const renderer = utils.themeManager.get("image", {
|
|
923
|
+
placeholder,
|
|
924
|
+
isBlock
|
|
925
|
+
});
|
|
926
|
+
if (!renderer) {
|
|
927
|
+
return {};
|
|
1202
928
|
}
|
|
929
|
+
const { dom, onUpdate } = renderer;
|
|
930
|
+
onUpdate(currNode);
|
|
1203
931
|
return {
|
|
1204
|
-
dom
|
|
932
|
+
dom,
|
|
1205
933
|
update: (updatedNode) => {
|
|
1206
934
|
if (updatedNode.type.name !== id$3)
|
|
1207
935
|
return false;
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
content.alt = alt2;
|
|
1211
|
-
content.title = title2 || alt2;
|
|
1212
|
-
if (width2) {
|
|
1213
|
-
content.width = width2;
|
|
1214
|
-
}
|
|
1215
|
-
if (loading2) {
|
|
1216
|
-
loadImage(src2);
|
|
1217
|
-
return true;
|
|
1218
|
-
}
|
|
1219
|
-
if (failed) {
|
|
1220
|
-
container.classList.remove("loading", "empty");
|
|
1221
|
-
container.classList.add("system", "failed");
|
|
1222
|
-
setIcon("brokenImage");
|
|
1223
|
-
return true;
|
|
1224
|
-
}
|
|
1225
|
-
if (src2.length > 0) {
|
|
1226
|
-
container.classList.remove("system", "empty", "loading");
|
|
1227
|
-
return true;
|
|
1228
|
-
}
|
|
1229
|
-
container.classList.add("system", "empty");
|
|
1230
|
-
setIcon("image");
|
|
936
|
+
currNode = updatedNode;
|
|
937
|
+
onUpdate(currNode);
|
|
1231
938
|
return true;
|
|
1232
939
|
},
|
|
1233
940
|
selectNode: () => {
|
|
1234
|
-
|
|
941
|
+
dom.classList.add("ProseMirror-selectednode");
|
|
1235
942
|
},
|
|
1236
943
|
deselectNode: () => {
|
|
1237
|
-
|
|
944
|
+
dom.classList.remove("ProseMirror-selectednode");
|
|
1238
945
|
}
|
|
1239
946
|
};
|
|
947
|
+
},
|
|
948
|
+
prosePlugins: (type, ctx) => {
|
|
949
|
+
var _a, _b, _c;
|
|
950
|
+
const inputChipRenderer = utils.themeManager.get("input-chip", {
|
|
951
|
+
placeholder: (_b = (_a = options == null ? void 0 : options.input) == null ? void 0 : _a.placeholder) != null ? _b : "Input Image Link",
|
|
952
|
+
buttonText: (_c = options == null ? void 0 : options.input) == null ? void 0 : _c.buttonText,
|
|
953
|
+
onUpdate: (value) => {
|
|
954
|
+
ctx.get(commandsCtx).call(ModifyImage, value);
|
|
955
|
+
}
|
|
956
|
+
});
|
|
957
|
+
const shouldDisplay = (view) => {
|
|
958
|
+
return Boolean(type && findSelectedNodeOfType(view.state.selection, type));
|
|
959
|
+
};
|
|
960
|
+
const getCurrentLink = (view) => {
|
|
961
|
+
const result = findSelectedNodeOfType(view.state.selection, type);
|
|
962
|
+
if (!result)
|
|
963
|
+
return;
|
|
964
|
+
const value = result.node.attrs["src"];
|
|
965
|
+
return value;
|
|
966
|
+
};
|
|
967
|
+
const renderByView = (view) => {
|
|
968
|
+
if (!view.editable) {
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
const display = shouldDisplay(view);
|
|
972
|
+
if (display) {
|
|
973
|
+
inputChipRenderer.show(view);
|
|
974
|
+
inputChipRenderer.update(getCurrentLink(view));
|
|
975
|
+
} else {
|
|
976
|
+
inputChipRenderer.hide();
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
return [
|
|
980
|
+
new Plugin({
|
|
981
|
+
key,
|
|
982
|
+
view: (editorView) => {
|
|
983
|
+
inputChipRenderer.init(editorView);
|
|
984
|
+
renderByView(editorView);
|
|
985
|
+
return {
|
|
986
|
+
update: (view, prevState) => {
|
|
987
|
+
const isEqualSelection = (prevState == null ? void 0 : prevState.doc.eq(view.state.doc)) && prevState.selection.eq(view.state.selection);
|
|
988
|
+
if (isEqualSelection)
|
|
989
|
+
return;
|
|
990
|
+
renderByView(view);
|
|
991
|
+
},
|
|
992
|
+
destroy: () => {
|
|
993
|
+
inputChipRenderer.destroy();
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
})
|
|
998
|
+
];
|
|
1240
999
|
}
|
|
1241
1000
|
};
|
|
1242
1001
|
});
|
|
@@ -1244,58 +1003,43 @@ const id$2 = "list_item";
|
|
|
1244
1003
|
const SplitListItem = createCmdKey("SplitListItem");
|
|
1245
1004
|
const SinkListItem = createCmdKey("SinkListItem");
|
|
1246
1005
|
const LiftListItem = createCmdKey("LiftListItem");
|
|
1247
|
-
const listItem = createNode((utils) => {
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
parseMarkdown: {
|
|
1270
|
-
match: ({ type, checked }) => type === "listItem" && checked === null,
|
|
1271
|
-
runner: (state, node, type) => {
|
|
1272
|
-
state.openNode(type);
|
|
1273
|
-
state.next(node.children);
|
|
1274
|
-
state.closeNode();
|
|
1275
|
-
}
|
|
1276
|
-
},
|
|
1277
|
-
toMarkdown: {
|
|
1278
|
-
match: (node) => node.type.name === id$2,
|
|
1279
|
-
runner: (state, node) => {
|
|
1280
|
-
state.openNode("listItem");
|
|
1281
|
-
state.next(node.content);
|
|
1282
|
-
state.closeNode();
|
|
1283
|
-
}
|
|
1006
|
+
const listItem = createNode((utils) => ({
|
|
1007
|
+
id: id$2,
|
|
1008
|
+
schema: () => ({
|
|
1009
|
+
group: "listItem",
|
|
1010
|
+
content: "paragraph block*",
|
|
1011
|
+
defining: true,
|
|
1012
|
+
parseDOM: [{ tag: "li" }],
|
|
1013
|
+
toDOM: (node) => ["li", { class: utils.getClassName(node.attrs, "list-item") }, 0],
|
|
1014
|
+
parseMarkdown: {
|
|
1015
|
+
match: ({ type, checked }) => type === "listItem" && checked === null,
|
|
1016
|
+
runner: (state, node, type) => {
|
|
1017
|
+
state.openNode(type);
|
|
1018
|
+
state.next(node.children);
|
|
1019
|
+
state.closeNode();
|
|
1020
|
+
}
|
|
1021
|
+
},
|
|
1022
|
+
toMarkdown: {
|
|
1023
|
+
match: (node) => node.type.name === id$2,
|
|
1024
|
+
runner: (state, node) => {
|
|
1025
|
+
state.openNode("listItem");
|
|
1026
|
+
state.next(node.content);
|
|
1027
|
+
state.closeNode();
|
|
1284
1028
|
}
|
|
1285
|
-
}),
|
|
1286
|
-
inputRules: (nodeType) => [wrappingInputRule(/^\s*([-+*])\s$/, nodeType)],
|
|
1287
|
-
commands: (nodeType) => [
|
|
1288
|
-
createCmd(SplitListItem, () => splitListItem(nodeType)),
|
|
1289
|
-
createCmd(SinkListItem, () => sinkListItem(nodeType)),
|
|
1290
|
-
createCmd(LiftListItem, () => liftListItem(nodeType))
|
|
1291
|
-
],
|
|
1292
|
-
shortcuts: {
|
|
1293
|
-
[SupportedKeys.NextListItem]: createShortcut(SplitListItem, "Enter"),
|
|
1294
|
-
[SupportedKeys.SinkListItem]: createShortcut(SinkListItem, "Mod-]"),
|
|
1295
|
-
[SupportedKeys.LiftListItem]: createShortcut(LiftListItem, "Mod-[")
|
|
1296
1029
|
}
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1030
|
+
}),
|
|
1031
|
+
inputRules: (nodeType) => [wrappingInputRule(/^\s*([-+*])\s$/, nodeType)],
|
|
1032
|
+
commands: (nodeType) => [
|
|
1033
|
+
createCmd(SplitListItem, () => splitListItem(nodeType)),
|
|
1034
|
+
createCmd(SinkListItem, () => sinkListItem(nodeType)),
|
|
1035
|
+
createCmd(LiftListItem, () => liftListItem(nodeType))
|
|
1036
|
+
],
|
|
1037
|
+
shortcuts: {
|
|
1038
|
+
[SupportedKeys.NextListItem]: createShortcut(SplitListItem, "Enter"),
|
|
1039
|
+
[SupportedKeys.SinkListItem]: createShortcut(SinkListItem, "Mod-]"),
|
|
1040
|
+
[SupportedKeys.LiftListItem]: createShortcut(LiftListItem, "Mod-[")
|
|
1041
|
+
}
|
|
1042
|
+
}));
|
|
1299
1043
|
const WrapInOrderedList = createCmdKey("WrapInOrderedList");
|
|
1300
1044
|
const id$1 = "ordered_list";
|
|
1301
1045
|
const orderedList = createNode((utils) => ({
|
|
@@ -1352,20 +1096,13 @@ const orderedList = createNode((utils) => ({
|
|
|
1352
1096
|
const TurnIntoText = createCmdKey("TurnIntoText");
|
|
1353
1097
|
const id = "paragraph";
|
|
1354
1098
|
const paragraph = createNode((utils) => {
|
|
1355
|
-
const style = utils.getStyle((_, { css }) => {
|
|
1356
|
-
return css`
|
|
1357
|
-
font-size: 1rem;
|
|
1358
|
-
line-height: 1.5;
|
|
1359
|
-
letter-spacing: 0.5px;
|
|
1360
|
-
`;
|
|
1361
|
-
});
|
|
1362
1099
|
return {
|
|
1363
1100
|
id,
|
|
1364
1101
|
schema: () => ({
|
|
1365
1102
|
content: "inline*",
|
|
1366
1103
|
group: "block",
|
|
1367
1104
|
parseDOM: [{ tag: "p" }],
|
|
1368
|
-
toDOM: (node) => ["p", { class: utils.getClassName(node.attrs, id
|
|
1105
|
+
toDOM: (node) => ["p", { class: utils.getClassName(node.attrs, id) }, 0],
|
|
1369
1106
|
parseMarkdown: {
|
|
1370
1107
|
match: (node) => node.type === "paragraph",
|
|
1371
1108
|
runner: (state, node, type) => {
|