@milkdown/preset-gfm 7.5.0 → 7.5.8
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/__internal__/with-meta.d.ts.map +1 -1
- package/lib/composed/commands.d.ts +6 -6
- package/lib/composed/commands.d.ts.map +1 -1
- package/lib/composed/inputrules.d.ts.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.es.js +407 -323
- package/lib/index.es.js.map +1 -1
- package/lib/mark/strike-through.d.ts.map +1 -1
- package/lib/node/footnote/definition.d.ts.map +1 -1
- package/lib/node/footnote/reference.d.ts.map +1 -1
- package/lib/node/table/command.d.ts +10 -10
- package/lib/node/table/command.d.ts.map +1 -1
- package/lib/node/table/input.d.ts.map +1 -1
- package/lib/node/table/schema.d.ts.map +1 -1
- package/lib/node/table/utils.d.ts.map +1 -1
- package/lib/node/task-list-item.d.ts.map +1 -1
- package/lib/plugin/keep-table-align-plugin.d.ts.map +1 -1
- package/lib/plugin/remark-gfm-plugin.d.ts.map +1 -1
- package/lib/plugin/table-editing-plugin.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/__internal__/with-meta.ts +4 -1
- package/src/composed/commands.ts +17 -1
- package/src/composed/inputrules.ts +1 -3
- package/src/index.ts +16 -2
- package/src/mark/strike-through.ts +21 -9
- package/src/node/footnote/definition.ts +56 -54
- package/src/node/footnote/reference.ts +47 -45
- package/src/node/table/command.ts +169 -93
- package/src/node/table/input.ts +32 -15
- package/src/node/table/schema.ts +12 -13
- package/src/node/table/utils.ts +120 -84
- package/src/node/task-list-item.ts +100 -88
- package/src/plugin/keep-table-align-plugin.ts +7 -14
- package/src/plugin/remark-gfm-plugin.ts +2 -1
- package/src/plugin/table-editing-plugin.ts +3 -1
package/src/index.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
commands,
|
|
3
|
+
inputRules,
|
|
4
|
+
keymap,
|
|
5
|
+
markInputRules,
|
|
6
|
+
plugins,
|
|
7
|
+
schema,
|
|
8
|
+
} from './composed'
|
|
2
9
|
|
|
3
10
|
export * from './node'
|
|
4
11
|
export * from './mark'
|
|
@@ -6,4 +13,11 @@ export * from './plugin'
|
|
|
6
13
|
export * from './composed'
|
|
7
14
|
|
|
8
15
|
/// The GFM preset, includes all the plugins.
|
|
9
|
-
export const gfm = [
|
|
16
|
+
export const gfm = [
|
|
17
|
+
schema,
|
|
18
|
+
inputRules,
|
|
19
|
+
markInputRules,
|
|
20
|
+
keymap,
|
|
21
|
+
commands,
|
|
22
|
+
plugins,
|
|
23
|
+
].flat()
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { commandsCtx } from '@milkdown/core'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
$command,
|
|
4
|
+
$inputRule,
|
|
5
|
+
$markAttr,
|
|
6
|
+
$markSchema,
|
|
7
|
+
$useKeymap,
|
|
8
|
+
} from '@milkdown/utils'
|
|
3
9
|
import { toggleMark } from '@milkdown/prose/commands'
|
|
4
10
|
import { markRule } from '@milkdown/prose'
|
|
5
11
|
import { withMeta } from '../__internal__'
|
|
@@ -13,14 +19,17 @@ withMeta(strikethroughAttr, {
|
|
|
13
19
|
})
|
|
14
20
|
|
|
15
21
|
/// Strikethrough mark schema.
|
|
16
|
-
export const strikethroughSchema = $markSchema('strike_through', ctx => ({
|
|
22
|
+
export const strikethroughSchema = $markSchema('strike_through', (ctx) => ({
|
|
17
23
|
parseDOM: [
|
|
18
24
|
{ tag: 'del' },
|
|
19
|
-
{
|
|
25
|
+
{
|
|
26
|
+
style: 'text-decoration',
|
|
27
|
+
getAttrs: (value) => (value === 'line-through') as false,
|
|
28
|
+
},
|
|
20
29
|
],
|
|
21
|
-
toDOM: mark => ['del', ctx.get(strikethroughAttr.key)(mark)],
|
|
30
|
+
toDOM: (mark) => ['del', ctx.get(strikethroughAttr.key)(mark)],
|
|
22
31
|
parseMarkdown: {
|
|
23
|
-
match: node => node.type === 'delete',
|
|
32
|
+
match: (node) => node.type === 'delete',
|
|
24
33
|
runner: (state, node, markType) => {
|
|
25
34
|
state.openMark(markType)
|
|
26
35
|
state.next(node.children)
|
|
@@ -28,7 +37,7 @@ export const strikethroughSchema = $markSchema('strike_through', ctx => ({
|
|
|
28
37
|
},
|
|
29
38
|
},
|
|
30
39
|
toMarkdown: {
|
|
31
|
-
match: mark => mark.type.name === 'strike_through',
|
|
40
|
+
match: (mark) => mark.type.name === 'strike_through',
|
|
32
41
|
runner: (state, mark) => {
|
|
33
42
|
state.withMark(mark, 'delete')
|
|
34
43
|
},
|
|
@@ -46,9 +55,12 @@ withMeta(strikethroughSchema.ctx, {
|
|
|
46
55
|
})
|
|
47
56
|
|
|
48
57
|
/// A command to toggle the strikethrough mark.
|
|
49
|
-
export const toggleStrikethroughCommand = $command(
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
export const toggleStrikethroughCommand = $command(
|
|
59
|
+
'ToggleStrikeThrough',
|
|
60
|
+
(ctx) => () => {
|
|
61
|
+
return toggleMark(strikethroughSchema.type(ctx))
|
|
62
|
+
}
|
|
63
|
+
)
|
|
52
64
|
|
|
53
65
|
withMeta(toggleStrikethroughCommand, {
|
|
54
66
|
displayName: 'Command<ToggleStrikethrough>',
|
|
@@ -6,67 +6,69 @@ const id = 'footnote_definition'
|
|
|
6
6
|
const markdownId = 'footnoteDefinition'
|
|
7
7
|
|
|
8
8
|
/// Footnote definition node schema.
|
|
9
|
-
export const footnoteDefinitionSchema = $nodeSchema(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
export const footnoteDefinitionSchema = $nodeSchema(
|
|
10
|
+
'footnote_definition',
|
|
11
|
+
() => ({
|
|
12
|
+
group: 'block',
|
|
13
|
+
content: 'block+',
|
|
14
|
+
defining: true,
|
|
15
|
+
attrs: {
|
|
16
|
+
label: {
|
|
17
|
+
default: '',
|
|
18
|
+
},
|
|
16
19
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (!(dom instanceof HTMLElement))
|
|
23
|
-
throw expectDomTypeError(dom)
|
|
20
|
+
parseDOM: [
|
|
21
|
+
{
|
|
22
|
+
tag: `dl[data-type="${id}"]`,
|
|
23
|
+
getAttrs: (dom) => {
|
|
24
|
+
if (!(dom instanceof HTMLElement)) throw expectDomTypeError(dom)
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
return {
|
|
27
|
+
label: dom.dataset.label,
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
contentElement: 'dd',
|
|
28
31
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
toDOM: (node) => {
|
|
33
|
-
const label = node.attrs.label
|
|
32
|
+
],
|
|
33
|
+
toDOM: (node) => {
|
|
34
|
+
const label = node.attrs.label
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
return [
|
|
37
|
+
'dl',
|
|
38
|
+
{
|
|
39
|
+
// TODO: add a prosemirror plugin to sync label on change
|
|
40
|
+
'data-label': label,
|
|
41
|
+
'data-type': id,
|
|
42
|
+
},
|
|
43
|
+
['dt', label],
|
|
44
|
+
['dd', 0],
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
parseMarkdown: {
|
|
48
|
+
match: ({ type }) => type === markdownId,
|
|
49
|
+
runner: (state, node, type) => {
|
|
50
|
+
state
|
|
51
|
+
.openNode(type, {
|
|
52
|
+
label: node.label as string,
|
|
53
|
+
})
|
|
54
|
+
.next(node.children)
|
|
55
|
+
.closeNode()
|
|
41
56
|
},
|
|
42
|
-
['dt', label],
|
|
43
|
-
['dd', 0],
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
|
-
parseMarkdown: {
|
|
47
|
-
match: ({ type }) => type === markdownId,
|
|
48
|
-
runner: (state, node, type) => {
|
|
49
|
-
state
|
|
50
|
-
.openNode(type, {
|
|
51
|
-
label: node.label as string,
|
|
52
|
-
})
|
|
53
|
-
.next(node.children)
|
|
54
|
-
.closeNode()
|
|
55
57
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
toMarkdown: {
|
|
59
|
+
match: (node) => node.type.name === id,
|
|
60
|
+
runner: (state, node) => {
|
|
61
|
+
state
|
|
62
|
+
.openNode(markdownId, undefined, {
|
|
63
|
+
label: node.attrs.label,
|
|
64
|
+
identifier: node.attrs.label,
|
|
65
|
+
})
|
|
66
|
+
.next(node.content)
|
|
67
|
+
.closeNode()
|
|
68
|
+
},
|
|
67
69
|
},
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
+
})
|
|
71
|
+
)
|
|
70
72
|
|
|
71
73
|
withMeta(footnoteDefinitionSchema.ctx, {
|
|
72
74
|
displayName: 'NodeSchemaCtx<footnodeDef>',
|
|
@@ -5,58 +5,60 @@ import { withMeta } from '../../__internal__'
|
|
|
5
5
|
const id = 'footnote_reference'
|
|
6
6
|
|
|
7
7
|
/// Footnote reference node schema.
|
|
8
|
-
export const footnoteReferenceSchema = $nodeSchema(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
export const footnoteReferenceSchema = $nodeSchema(
|
|
9
|
+
'footnote_reference',
|
|
10
|
+
() => ({
|
|
11
|
+
group: 'inline',
|
|
12
|
+
inline: true,
|
|
13
|
+
atom: true,
|
|
14
|
+
attrs: {
|
|
15
|
+
label: {
|
|
16
|
+
default: '',
|
|
17
|
+
},
|
|
15
18
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!(dom instanceof HTMLElement))
|
|
22
|
-
throw expectDomTypeError(dom)
|
|
19
|
+
parseDOM: [
|
|
20
|
+
{
|
|
21
|
+
tag: `sup[data-type="${id}"]`,
|
|
22
|
+
getAttrs: (dom) => {
|
|
23
|
+
if (!(dom instanceof HTMLElement)) throw expectDomTypeError(dom)
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
return {
|
|
26
|
+
label: dom.dataset.label,
|
|
27
|
+
}
|
|
28
|
+
},
|
|
27
29
|
},
|
|
30
|
+
],
|
|
31
|
+
toDOM: (node) => {
|
|
32
|
+
const label = node.attrs.label
|
|
33
|
+
return [
|
|
34
|
+
'sup',
|
|
35
|
+
{
|
|
36
|
+
// TODO: add a prosemirror plugin to sync label on change
|
|
37
|
+
'data-label': label,
|
|
38
|
+
'data-type': id,
|
|
39
|
+
},
|
|
40
|
+
label,
|
|
41
|
+
]
|
|
28
42
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// TODO: add a prosemirror plugin to sync label on change
|
|
36
|
-
'data-label': label,
|
|
37
|
-
'data-type': id,
|
|
43
|
+
parseMarkdown: {
|
|
44
|
+
match: ({ type }) => type === 'footnoteReference',
|
|
45
|
+
runner: (state, node, type) => {
|
|
46
|
+
state.addNode(type, {
|
|
47
|
+
label: node.label as string,
|
|
48
|
+
})
|
|
38
49
|
},
|
|
39
|
-
label,
|
|
40
|
-
]
|
|
41
|
-
},
|
|
42
|
-
parseMarkdown: {
|
|
43
|
-
match: ({ type }) => type === 'footnoteReference',
|
|
44
|
-
runner: (state, node, type) => {
|
|
45
|
-
state.addNode(type, {
|
|
46
|
-
label: node.label as string,
|
|
47
|
-
})
|
|
48
50
|
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
51
|
+
toMarkdown: {
|
|
52
|
+
match: (node) => node.type.name === id,
|
|
53
|
+
runner: (state, node) => {
|
|
54
|
+
state.addNode('footnoteReference', undefined, undefined, {
|
|
55
|
+
label: node.attrs.label,
|
|
56
|
+
identifier: node.attrs.label,
|
|
57
|
+
})
|
|
58
|
+
},
|
|
57
59
|
},
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
+
})
|
|
61
|
+
)
|
|
60
62
|
|
|
61
63
|
withMeta(footnoteReferenceSchema.ctx, {
|
|
62
64
|
displayName: 'NodeSchemaCtx<footnodeRef>',
|