@milkdown/preset-commonmark 5.5.0 → 6.0.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 +283 -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 +93 -18
- package/src/mark/strong.ts +1 -7
- package/src/node/blockquote.ts +1 -14
- package/src/node/code-fence.ts +94 -184
- package/src/node/heading.ts +1 -41
- package/src/node/hr.ts +1 -8
- package/src/node/image.ts +81 -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/src/node/image.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { createCmd, createCmdKey,
|
|
3
|
-
import
|
|
4
|
-
import { findSelectedNodeOfType, InputRule } from '@milkdown/prose';
|
|
2
|
+
import { commandsCtx, createCmd, createCmdKey, ThemeImageType, ThemeInputChipType } from '@milkdown/core';
|
|
3
|
+
import { EditorView, findSelectedNodeOfType, InputRule, Plugin, PluginKey } from '@milkdown/prose';
|
|
5
4
|
import { createNode } from '@milkdown/utils';
|
|
6
5
|
|
|
7
6
|
export const ModifyImage = createCmdKey<string>('ModifyImage');
|
|
@@ -9,132 +8,15 @@ export const InsertImage = createCmdKey<string>('InsertImage');
|
|
|
9
8
|
const id = 'image';
|
|
10
9
|
export type ImageOptions = {
|
|
11
10
|
isBlock: boolean;
|
|
12
|
-
placeholder:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
placeholder: string;
|
|
12
|
+
input: {
|
|
13
|
+
placeholder: string;
|
|
14
|
+
buttonText?: string;
|
|
16
15
|
};
|
|
17
16
|
};
|
|
17
|
+
const key = new PluginKey('MILKDOWN_PLUGIN_IMAGE_INPUT');
|
|
18
18
|
|
|
19
19
|
export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
20
|
-
const placeholder = {
|
|
21
|
-
loading: 'Loading...',
|
|
22
|
-
empty: 'Add an Image',
|
|
23
|
-
failed: 'Image loads failed',
|
|
24
|
-
...(options?.placeholder ?? {}),
|
|
25
|
-
};
|
|
26
|
-
const isBlock = options?.isBlock ?? false;
|
|
27
|
-
const containerStyle = utils.getStyle(
|
|
28
|
-
(themeTool, { css }) =>
|
|
29
|
-
css`
|
|
30
|
-
display: inline-block;
|
|
31
|
-
position: relative;
|
|
32
|
-
text-align: center;
|
|
33
|
-
font-size: 0;
|
|
34
|
-
vertical-align: text-bottom;
|
|
35
|
-
line-height: 1;
|
|
36
|
-
|
|
37
|
-
${isBlock
|
|
38
|
-
? `
|
|
39
|
-
width: 100%;
|
|
40
|
-
margin: 0 auto;
|
|
41
|
-
`
|
|
42
|
-
: ''}
|
|
43
|
-
|
|
44
|
-
&.ProseMirror-selectednode::after {
|
|
45
|
-
content: '';
|
|
46
|
-
background: ${themeTool.palette('secondary', 0.38)};
|
|
47
|
-
position: absolute;
|
|
48
|
-
top: 0;
|
|
49
|
-
left: 0;
|
|
50
|
-
right: 0;
|
|
51
|
-
bottom: 0;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
img {
|
|
55
|
-
max-width: 100%;
|
|
56
|
-
height: auto;
|
|
57
|
-
object-fit: contain;
|
|
58
|
-
margin: 0 2px;
|
|
59
|
-
}
|
|
60
|
-
.icon,
|
|
61
|
-
.placeholder {
|
|
62
|
-
display: none;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
&.system {
|
|
66
|
-
width: 100%;
|
|
67
|
-
padding: 0 2rem;
|
|
68
|
-
|
|
69
|
-
img {
|
|
70
|
-
width: 0;
|
|
71
|
-
height: 0;
|
|
72
|
-
display: none;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.icon,
|
|
76
|
-
.placeholder {
|
|
77
|
-
display: inline;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
box-sizing: border-box;
|
|
81
|
-
height: 3rem;
|
|
82
|
-
background-color: ${themeTool.palette('background')};
|
|
83
|
-
border-radius: ${themeTool.size.radius};
|
|
84
|
-
display: inline-flex;
|
|
85
|
-
gap: 2rem;
|
|
86
|
-
justify-content: flex-start;
|
|
87
|
-
align-items: center;
|
|
88
|
-
.placeholder {
|
|
89
|
-
margin: 0;
|
|
90
|
-
line-height: 1;
|
|
91
|
-
&::before {
|
|
92
|
-
content: '';
|
|
93
|
-
font-size: 0.875rem;
|
|
94
|
-
color: ${themeTool.palette('neutral', 0.6)};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
&.loading {
|
|
100
|
-
.placeholder {
|
|
101
|
-
&::before {
|
|
102
|
-
content: '${placeholder.loading}';
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
&.empty {
|
|
108
|
-
.placeholder {
|
|
109
|
-
&::before {
|
|
110
|
-
content: '${placeholder.empty}';
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
&.failed {
|
|
116
|
-
.placeholder {
|
|
117
|
-
&::before {
|
|
118
|
-
content: '${placeholder.failed}';
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
`,
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
const style = utils.getStyle(
|
|
126
|
-
(_, { css }) =>
|
|
127
|
-
css`
|
|
128
|
-
display: inline-block;
|
|
129
|
-
margin: 0 auto;
|
|
130
|
-
object-fit: contain;
|
|
131
|
-
width: 100%;
|
|
132
|
-
position: relative;
|
|
133
|
-
height: auto;
|
|
134
|
-
text-align: center;
|
|
135
|
-
`,
|
|
136
|
-
);
|
|
137
|
-
|
|
138
20
|
return {
|
|
139
21
|
id: 'image',
|
|
140
22
|
schema: () => ({
|
|
@@ -150,9 +32,6 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
150
32
|
src: { default: '' },
|
|
151
33
|
alt: { default: null },
|
|
152
34
|
title: { default: null },
|
|
153
|
-
failed: { default: false },
|
|
154
|
-
loading: { default: true },
|
|
155
|
-
width: { default: null },
|
|
156
35
|
},
|
|
157
36
|
parseDOM: [
|
|
158
37
|
{
|
|
@@ -162,8 +41,6 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
162
41
|
throw new Error();
|
|
163
42
|
}
|
|
164
43
|
return {
|
|
165
|
-
failed: dom.classList.contains('failed'),
|
|
166
|
-
loading: dom.classList.contains('loading'),
|
|
167
44
|
src: dom.getAttribute('src') || '',
|
|
168
45
|
alt: dom.getAttribute('alt'),
|
|
169
46
|
title: dom.getAttribute('title') || dom.getAttribute('alt'),
|
|
@@ -177,13 +54,7 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
177
54
|
'img',
|
|
178
55
|
{
|
|
179
56
|
...node.attrs,
|
|
180
|
-
class: utils.getClassName(
|
|
181
|
-
node.attrs,
|
|
182
|
-
id,
|
|
183
|
-
node.attrs['failed'] ? 'failed' : '',
|
|
184
|
-
node.attrs['loading'] ? 'loading' : '',
|
|
185
|
-
style,
|
|
186
|
-
),
|
|
57
|
+
class: utils.getClassName(node.attrs, id),
|
|
187
58
|
},
|
|
188
59
|
];
|
|
189
60
|
},
|
|
@@ -249,116 +120,94 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
249
120
|
},
|
|
250
121
|
),
|
|
251
122
|
],
|
|
252
|
-
view: (
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
container.append(icon, placeholder);
|
|
265
|
-
|
|
266
|
-
const setIcon = (name: Icon) => {
|
|
267
|
-
const nextIcon = createIcon(name);
|
|
268
|
-
container.replaceChild(nextIcon, icon);
|
|
269
|
-
icon = nextIcon;
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
const loadImage = (src: string) => {
|
|
273
|
-
container.classList.add('system', 'loading');
|
|
274
|
-
setIcon('loading');
|
|
275
|
-
const img = document.createElement('img');
|
|
276
|
-
img.src = src;
|
|
277
|
-
|
|
278
|
-
img.onerror = () => {
|
|
279
|
-
const pos = getPos();
|
|
280
|
-
if (!pos) return;
|
|
281
|
-
|
|
282
|
-
const { tr } = view.state;
|
|
283
|
-
const _tr = tr.setNodeMarkup(pos, nodeType, {
|
|
284
|
-
...node.attrs,
|
|
285
|
-
src,
|
|
286
|
-
loading: false,
|
|
287
|
-
failed: true,
|
|
288
|
-
});
|
|
289
|
-
view.dispatch(_tr);
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
img.onload = () => {
|
|
293
|
-
const { tr } = view.state;
|
|
294
|
-
|
|
295
|
-
const pos = getPos();
|
|
296
|
-
if (!pos) return;
|
|
297
|
-
|
|
298
|
-
const _tr = tr.setNodeMarkup(pos, nodeType, {
|
|
299
|
-
...node.attrs,
|
|
300
|
-
width: img.width,
|
|
301
|
-
src,
|
|
302
|
-
loading: false,
|
|
303
|
-
failed: false,
|
|
304
|
-
});
|
|
305
|
-
view.dispatch(_tr);
|
|
306
|
-
};
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
const { src, loading, title, alt, width } = node.attrs;
|
|
310
|
-
content.src = src;
|
|
311
|
-
content.title = title || alt;
|
|
312
|
-
content.alt = alt;
|
|
313
|
-
if (width) {
|
|
314
|
-
content.width = width;
|
|
123
|
+
view: () => (node) => {
|
|
124
|
+
let currNode = node;
|
|
125
|
+
|
|
126
|
+
const placeholder = options?.placeholder ?? 'Add an Image';
|
|
127
|
+
const isBlock = options?.isBlock ?? false;
|
|
128
|
+
const renderer = utils.themeManager.get<ThemeImageType>('image', {
|
|
129
|
+
placeholder,
|
|
130
|
+
isBlock,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
if (!renderer) {
|
|
134
|
+
return {};
|
|
315
135
|
}
|
|
316
136
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
setIcon('image');
|
|
320
|
-
} else if (loading) {
|
|
321
|
-
loadImage(src);
|
|
322
|
-
}
|
|
137
|
+
const { dom, onUpdate } = renderer;
|
|
138
|
+
onUpdate(currNode);
|
|
323
139
|
|
|
324
140
|
return {
|
|
325
|
-
dom
|
|
141
|
+
dom,
|
|
326
142
|
update: (updatedNode) => {
|
|
327
143
|
if (updatedNode.type.name !== id) return false;
|
|
328
144
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
content.alt = alt;
|
|
332
|
-
content.title = title || alt;
|
|
333
|
-
if (width) {
|
|
334
|
-
content.width = width;
|
|
335
|
-
}
|
|
336
|
-
if (loading) {
|
|
337
|
-
loadImage(src);
|
|
338
|
-
return true;
|
|
339
|
-
}
|
|
340
|
-
if (failed) {
|
|
341
|
-
container.classList.remove('loading', 'empty');
|
|
342
|
-
container.classList.add('system', 'failed');
|
|
343
|
-
setIcon('brokenImage');
|
|
344
|
-
return true;
|
|
345
|
-
}
|
|
346
|
-
if (src.length > 0) {
|
|
347
|
-
container.classList.remove('system', 'empty', 'loading');
|
|
348
|
-
return true;
|
|
349
|
-
}
|
|
145
|
+
currNode = updatedNode;
|
|
146
|
+
onUpdate(currNode);
|
|
350
147
|
|
|
351
|
-
container.classList.add('system', 'empty');
|
|
352
|
-
setIcon('image');
|
|
353
148
|
return true;
|
|
354
149
|
},
|
|
355
150
|
selectNode: () => {
|
|
356
|
-
|
|
151
|
+
dom.classList.add('ProseMirror-selectednode');
|
|
357
152
|
},
|
|
358
153
|
deselectNode: () => {
|
|
359
|
-
|
|
154
|
+
dom.classList.remove('ProseMirror-selectednode');
|
|
360
155
|
},
|
|
361
156
|
};
|
|
362
157
|
},
|
|
158
|
+
prosePlugins: (type, ctx) => {
|
|
159
|
+
return [
|
|
160
|
+
new Plugin({
|
|
161
|
+
key,
|
|
162
|
+
view: (editorView) => {
|
|
163
|
+
const inputChipRenderer = utils.themeManager.get<ThemeInputChipType>('input-chip', {
|
|
164
|
+
placeholder: options?.input?.placeholder ?? 'Input Image Link',
|
|
165
|
+
buttonText: options?.input?.buttonText,
|
|
166
|
+
onUpdate: (value) => {
|
|
167
|
+
ctx.get(commandsCtx).call(ModifyImage, value);
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
if (!inputChipRenderer) return {};
|
|
171
|
+
const shouldDisplay = (view: EditorView) => {
|
|
172
|
+
return Boolean(type && findSelectedNodeOfType(view.state.selection, type));
|
|
173
|
+
};
|
|
174
|
+
const getCurrentLink = (view: EditorView) => {
|
|
175
|
+
const result = findSelectedNodeOfType(view.state.selection, type);
|
|
176
|
+
if (!result) return;
|
|
177
|
+
|
|
178
|
+
const value = result.node.attrs['src'];
|
|
179
|
+
return value;
|
|
180
|
+
};
|
|
181
|
+
const renderByView = (view: EditorView) => {
|
|
182
|
+
if (!view.editable) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const display = shouldDisplay(view);
|
|
186
|
+
if (display) {
|
|
187
|
+
inputChipRenderer.show(view);
|
|
188
|
+
inputChipRenderer.update(getCurrentLink(view));
|
|
189
|
+
} else {
|
|
190
|
+
inputChipRenderer.hide();
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
inputChipRenderer.init(editorView);
|
|
194
|
+
renderByView(editorView);
|
|
195
|
+
|
|
196
|
+
return {
|
|
197
|
+
update: (view, prevState) => {
|
|
198
|
+
const isEqualSelection =
|
|
199
|
+
prevState?.doc.eq(view.state.doc) && prevState.selection.eq(view.state.selection);
|
|
200
|
+
if (isEqualSelection) return;
|
|
201
|
+
|
|
202
|
+
renderByView(view);
|
|
203
|
+
},
|
|
204
|
+
destroy: () => {
|
|
205
|
+
inputChipRenderer.destroy();
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
},
|
|
209
|
+
}),
|
|
210
|
+
];
|
|
211
|
+
},
|
|
363
212
|
};
|
|
364
213
|
});
|
package/src/node/list-item.ts
CHANGED
|
@@ -13,59 +13,40 @@ export const SplitListItem = createCmdKey('SplitListItem');
|
|
|
13
13
|
export const SinkListItem = createCmdKey('SinkListItem');
|
|
14
14
|
export const LiftListItem = createCmdKey('LiftListItem');
|
|
15
15
|
|
|
16
|
-
export const listItem = createNode<Keys>((utils) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
`,
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
id,
|
|
36
|
-
schema: () => ({
|
|
37
|
-
group: 'listItem',
|
|
38
|
-
content: 'paragraph block*',
|
|
39
|
-
defining: true,
|
|
40
|
-
parseDOM: [{ tag: 'li' }],
|
|
41
|
-
toDOM: (node) => ['li', { class: utils.getClassName(node.attrs, 'list-item', style) }, 0],
|
|
42
|
-
parseMarkdown: {
|
|
43
|
-
match: ({ type, checked }) => type === 'listItem' && checked === null,
|
|
44
|
-
runner: (state, node, type) => {
|
|
45
|
-
state.openNode(type);
|
|
46
|
-
state.next(node.children);
|
|
47
|
-
state.closeNode();
|
|
48
|
-
},
|
|
16
|
+
export const listItem = createNode<Keys>((utils) => ({
|
|
17
|
+
id,
|
|
18
|
+
schema: () => ({
|
|
19
|
+
group: 'listItem',
|
|
20
|
+
content: 'paragraph block*',
|
|
21
|
+
defining: true,
|
|
22
|
+
parseDOM: [{ tag: 'li' }],
|
|
23
|
+
toDOM: (node) => ['li', { class: utils.getClassName(node.attrs, 'list-item') }, 0],
|
|
24
|
+
parseMarkdown: {
|
|
25
|
+
match: ({ type, checked }) => type === 'listItem' && checked === null,
|
|
26
|
+
runner: (state, node, type) => {
|
|
27
|
+
state.openNode(type);
|
|
28
|
+
state.next(node.children);
|
|
29
|
+
state.closeNode();
|
|
49
30
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
31
|
+
},
|
|
32
|
+
toMarkdown: {
|
|
33
|
+
match: (node) => node.type.name === id,
|
|
34
|
+
runner: (state, node) => {
|
|
35
|
+
state.openNode('listItem');
|
|
36
|
+
state.next(node.content);
|
|
37
|
+
state.closeNode();
|
|
57
38
|
},
|
|
58
|
-
}),
|
|
59
|
-
inputRules: (nodeType) => [wrappingInputRule(/^\s*([-+*])\s$/, nodeType)],
|
|
60
|
-
commands: (nodeType) => [
|
|
61
|
-
createCmd(SplitListItem, () => splitListItem(nodeType)),
|
|
62
|
-
createCmd(SinkListItem, () => sinkListItem(nodeType)),
|
|
63
|
-
createCmd(LiftListItem, () => liftListItem(nodeType)),
|
|
64
|
-
],
|
|
65
|
-
shortcuts: {
|
|
66
|
-
[SupportedKeys.NextListItem]: createShortcut(SplitListItem, 'Enter'),
|
|
67
|
-
[SupportedKeys.SinkListItem]: createShortcut(SinkListItem, 'Mod-]'),
|
|
68
|
-
[SupportedKeys.LiftListItem]: createShortcut(LiftListItem, 'Mod-['),
|
|
69
39
|
},
|
|
70
|
-
}
|
|
71
|
-
|
|
40
|
+
}),
|
|
41
|
+
inputRules: (nodeType) => [wrappingInputRule(/^\s*([-+*])\s$/, nodeType)],
|
|
42
|
+
commands: (nodeType) => [
|
|
43
|
+
createCmd(SplitListItem, () => splitListItem(nodeType)),
|
|
44
|
+
createCmd(SinkListItem, () => sinkListItem(nodeType)),
|
|
45
|
+
createCmd(LiftListItem, () => liftListItem(nodeType)),
|
|
46
|
+
],
|
|
47
|
+
shortcuts: {
|
|
48
|
+
[SupportedKeys.NextListItem]: createShortcut(SplitListItem, 'Enter'),
|
|
49
|
+
[SupportedKeys.SinkListItem]: createShortcut(SinkListItem, 'Mod-]'),
|
|
50
|
+
[SupportedKeys.LiftListItem]: createShortcut(LiftListItem, 'Mod-['),
|
|
51
|
+
},
|
|
52
|
+
}));
|
package/src/node/paragraph.ts
CHANGED
|
@@ -11,21 +11,13 @@ export const TurnIntoText = createCmdKey('TurnIntoText');
|
|
|
11
11
|
|
|
12
12
|
const id = 'paragraph';
|
|
13
13
|
export const paragraph = createNode<Keys>((utils) => {
|
|
14
|
-
const style = utils.getStyle((_, { css }) => {
|
|
15
|
-
return css`
|
|
16
|
-
font-size: 1rem;
|
|
17
|
-
line-height: 1.5;
|
|
18
|
-
letter-spacing: 0.5px;
|
|
19
|
-
`;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
14
|
return {
|
|
23
15
|
id,
|
|
24
16
|
schema: () => ({
|
|
25
17
|
content: 'inline*',
|
|
26
18
|
group: 'block',
|
|
27
19
|
parseDOM: [{ tag: 'p' }],
|
|
28
|
-
toDOM: (node) => ['p', { class: utils.getClassName(node.attrs, id
|
|
20
|
+
toDOM: (node) => ['p', { class: utils.getClassName(node.attrs, id) }, 0],
|
|
29
21
|
parseMarkdown: {
|
|
30
22
|
match: (node) => node.type === 'paragraph',
|
|
31
23
|
runner: (state, node, type) => {
|
package/lib/src/index.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { AtomList } from '@milkdown/utils';
|
|
2
|
-
import { commonmarkPlugins } from './plugin';
|
|
3
|
-
export * from './mark';
|
|
4
|
-
export * from './node';
|
|
5
|
-
export * from './supported-keys';
|
|
6
|
-
export declare const commonmarkNodes: AtomList<(import("@milkdown/utils/lib/src/types").Metadata<import("@milkdown/utils/lib/src/types").GetPlugin<"CodeFence", {
|
|
7
|
-
languageList?: string[] | undefined;
|
|
8
|
-
}>> & import("@milkdown/core").MilkdownPlugin) | (import("@milkdown/utils/lib/src/types").Metadata<import("@milkdown/utils/lib/src/types").GetPlugin<string, import("./node").ImageOptions>> & import("@milkdown/core").MilkdownPlugin)>;
|
|
9
|
-
export { commonmarkPlugins };
|
|
10
|
-
export declare const commonmark: AtomList<(import("@milkdown/utils/lib/src/types").Metadata<import("@milkdown/utils/lib/src/types").GetPlugin<"CodeFence", {
|
|
11
|
-
languageList?: string[] | undefined;
|
|
12
|
-
}>> & import("@milkdown/core").MilkdownPlugin) | (import("@milkdown/utils/lib/src/types").Metadata<import("@milkdown/utils/lib/src/types").GetPlugin<string, import("./node").ImageOptions>> & import("@milkdown/core").MilkdownPlugin)>;
|
|
13
|
-
export declare const commands: {
|
|
14
|
-
readonly ToggleInlineCode: import("@milkdown/core").CmdKey<undefined>;
|
|
15
|
-
readonly ToggleItalic: import("@milkdown/core").CmdKey<undefined>;
|
|
16
|
-
readonly ToggleLink: import("@milkdown/core").CmdKey<string>;
|
|
17
|
-
readonly ToggleBold: import("@milkdown/core").CmdKey<undefined>;
|
|
18
|
-
readonly ModifyLink: import("@milkdown/core").CmdKey<string>;
|
|
19
|
-
readonly ModifyImage: import("@milkdown/core").CmdKey<string>;
|
|
20
|
-
readonly WrapInBlockquote: import("@milkdown/core").CmdKey<undefined>;
|
|
21
|
-
readonly WrapInBulletList: import("@milkdown/core").CmdKey<undefined>;
|
|
22
|
-
readonly WrapInOrderedList: import("@milkdown/core").CmdKey<undefined>;
|
|
23
|
-
readonly TurnIntoCodeFence: import("@milkdown/core").CmdKey<undefined>;
|
|
24
|
-
readonly TurnIntoHeading: import("@milkdown/core").CmdKey<number>;
|
|
25
|
-
readonly TurnIntoText: import("@milkdown/core").CmdKey<undefined>;
|
|
26
|
-
readonly InsertHardbreak: import("@milkdown/core").CmdKey<undefined>;
|
|
27
|
-
readonly InsertHr: import("@milkdown/core").CmdKey<string>;
|
|
28
|
-
readonly InsertImage: import("@milkdown/core").CmdKey<string>;
|
|
29
|
-
readonly SplitListItem: import("@milkdown/core").CmdKey<undefined>;
|
|
30
|
-
readonly SinkListItem: import("@milkdown/core").CmdKey<undefined>;
|
|
31
|
-
readonly LiftListItem: import("@milkdown/core").CmdKey<undefined>;
|
|
32
|
-
};
|
|
33
|
-
export declare type Commands = typeof commands;
|
|
34
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib/src/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAmB3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AAEjC,eAAO,MAAM,eAAe;;wOAAwC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC7B,eAAO,MAAM,UAAU;;wOAA8D,CAAC;AAEtF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;CAwBX,CAAC;AACX,oBAAY,QAAQ,GAAG,OAAO,QAAQ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-inline.d.ts","sourceRoot":"","sources":["code-inline.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,gBAAgB,4CAAmC,CAAC;AAEjE,eAAO,MAAM,UAAU;;;;EAyCrB,CAAC"}
|
package/lib/src/mark/em.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"em.d.ts","sourceRoot":"","sources":["em.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,YAAY,4CAA+B,CAAC;AAEzD,eAAO,MAAM,EAAE;;;;EAgCZ,CAAC"}
|
package/lib/src/mark/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const marks: (import("@milkdown/utils/lib/src/types").Metadata<import("@milkdown/utils/lib/src/types").GetPlugin<string, import("@milkdown/utils").UnknownRecord>> & import("@milkdown/core").MilkdownPlugin)[];
|
|
2
|
-
export * from './code-inline';
|
|
3
|
-
export * from './em';
|
|
4
|
-
export * from './link';
|
|
5
|
-
export * from './strong';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,KAAK,oMAAyC,CAAC;AAE5D,cAAc,eAAe,CAAC;AAC9B,cAAc,MAAM,CAAC;AACrB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["link.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,yCAAqC,CAAC;AAC7D,eAAO,MAAM,UAAU,yCAAqC,CAAC;AAE7D,eAAO,MAAM,IAAI;;;;EA8Gf,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strong.d.ts","sourceRoot":"","sources":["strong.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,UAAU,4CAA6B,CAAC;AACrD,eAAO,MAAM,MAAM;;;;EAwCjB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"blockquote.d.ts","sourceRoot":"","sources":["blockquote.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,gBAAgB,4CAAmC,CAAC;AAEjE,eAAO,MAAM,UAAU;;;;EAyCrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bullet-list.d.ts","sourceRoot":"","sources":["bullet-list.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,gBAAgB,4CAAmC,CAAC;AAEjE,eAAO,MAAM,UAAU;;;;EA8BrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-fence.d.ts","sourceRoot":"","sources":["code-fence.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,kBAAkB,QAAoC,CAAC;AACpE,eAAO,MAAM,eAAe,QAAoC,CAAC;AAEjE,eAAO,MAAM,iBAAiB,4CAAoC,CAAC;AAGnE,eAAO,MAAM,SAAS;;;;;;EA8RpB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["doc.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG;;;;EAoBd,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hardbreak.d.ts","sourceRoot":"","sources":["hardbreak.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,eAAe,4CAAkC,CAAC;AAE/D,eAAO,MAAM,SAAS;;;;EAoEpB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["heading.ts"],"names":[],"mappings":"AAEA,OAAO,EAIH,SAAS,EAIZ,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMlD,aAAK,IAAI,GACH,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,CAAC;AAE1B,eAAO,MAAM,eAAe,yCAA0C,CAAC;AAEvE,eAAO,MAAM,gBAAgB,qBAAsC,CAAC;AAEpE,eAAO,MAAM,OAAO;;;;EA8KlB,CAAC"}
|
package/lib/src/node/hr.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hr.d.ts","sourceRoot":"","sources":["hr.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,QAAQ,yCAAmC,CAAC;AACzD,eAAO,MAAM,EAAE;;;;EAyDb,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["image.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,yCAAsC,CAAC;AAC/D,eAAO,MAAM,WAAW,yCAAsC,CAAC;AAE/D,oBAAY,YAAY,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE;QACT,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAClB,CAAC;CACL,CAAC;AAEF,eAAO,MAAM,KAAK;;;;EAyVhB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,KAAK;;2OAajB,CAAC;AAEF,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-item.d.ts","sourceRoot":"","sources":["list-item.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,aAAK,IAAI,GAAG,aAAa,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;AAI1G,eAAO,MAAM,aAAa,4CAAgC,CAAC;AAC3D,eAAO,MAAM,YAAY,4CAA+B,CAAC;AACzD,eAAO,MAAM,YAAY,4CAA+B,CAAC;AAEzD,eAAO,MAAM,QAAQ;;;;EAuDnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ordered-list.d.ts","sourceRoot":"","sources":["ordered-list.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,iBAAiB,4CAAoC,CAAC;AAGnE,eAAO,MAAM,WAAW;;;;EAwDrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["paragraph.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,YAAY,4CAA+B,CAAC;AAGzD,eAAO,MAAM,SAAS;;;;EA0CpB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["text.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI;;;;EAiBd,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter-html.d.ts","sourceRoot":"","sources":["filter-html.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,IAAI,EAAU,MAAM,OAAO,CAAC;AAgC9C,eAAO,MAAM,gBAAgB,eACE,IAAI,SAUlC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,iBAAiB,oMAI7B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"supported-keys.d.ts","sourceRoot":"","sources":["supported-keys.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;CAmBhB,CAAC;AAEX,oBAAY,aAAa,GAAG,OAAO,aAAa,CAAC"}
|