@milkdown/preset-gfm 7.4.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 +9 -5
- package/lib/composed/commands.d.ts.map +1 -1
- package/lib/composed/inputrules.d.ts.map +1 -1
- package/lib/composed/schema.d.ts.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.es.js +816 -669
- 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 +33 -0
- package/lib/node/table/command.d.ts.map +1 -0
- package/lib/node/table/index.d.ts +3 -30
- package/lib/node/table/index.d.ts.map +1 -1
- package/lib/node/table/input.d.ts +3 -0
- package/lib/node/table/input.d.ts.map +1 -0
- package/lib/node/table/schema.d.ts +6 -0
- package/lib/node/table/schema.d.ts.map +1 -0
- package/lib/node/table/utils.d.ts +21 -7
- package/lib/node/table/utils.d.ts.map +1 -1
- package/lib/node/task-list-item.d.ts.map +1 -1
- package/lib/plugin/auto-insert-span-plugin.d.ts +2 -0
- package/lib/plugin/auto-insert-span-plugin.d.ts.map +1 -0
- package/lib/plugin/index.d.ts +2 -1
- package/lib/plugin/index.d.ts.map +1 -1
- package/lib/plugin/keep-table-align-plugin.d.ts +2 -0
- package/lib/plugin/keep-table-align-plugin.d.ts.map +1 -0
- 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 +12 -17
- package/src/__internal__/with-meta.ts +4 -1
- package/src/composed/commands.ts +18 -2
- package/src/composed/inputrules.ts +1 -3
- package/src/composed/plugins.ts +4 -4
- package/src/composed/schema.ts +11 -1
- 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 +304 -0
- package/src/node/table/index.ts +3 -450
- package/src/node/table/input.ts +90 -0
- package/src/node/table/schema.ts +215 -0
- package/src/node/table/utils.ts +163 -96
- package/src/node/task-list-item.ts +100 -88
- package/src/plugin/auto-insert-span-plugin.ts +12 -0
- package/src/plugin/index.ts +2 -1
- package/src/plugin/keep-table-align-plugin.ts +53 -0
- package/src/plugin/remark-gfm-plugin.ts +2 -1
- package/src/plugin/table-editing-plugin.ts +3 -1
- package/lib/plugin/auto-insert-zero-space-plugin.d.ts +0 -2
- package/lib/plugin/auto-insert-zero-space-plugin.d.ts.map +0 -1
- package/src/plugin/auto-insert-zero-space-plugin.ts +0 -55
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-insert-span-plugin.d.ts","sourceRoot":"","sources":["../../src/plugin/auto-insert-span-plugin.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,oBAAoB,kCAAwB,CAAA"}
|
package/lib/plugin/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from './auto-insert-
|
|
1
|
+
export * from './auto-insert-span-plugin';
|
|
2
2
|
export * from './column-resizing-plugin';
|
|
3
3
|
export * from './table-editing-plugin';
|
|
4
4
|
export * from './remark-gfm-plugin';
|
|
5
|
+
export * from './keep-table-align-plugin';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,2BAA2B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keep-table-align-plugin.d.ts","sourceRoot":"","sources":["../../src/plugin/keep-table-align-plugin.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,oBAAoB,kCA+B/B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remark-gfm-plugin.d.ts","sourceRoot":"","sources":["../../src/plugin/remark-gfm-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAKzC,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"remark-gfm-plugin.d.ts","sourceRoot":"","sources":["../../src/plugin/remark-gfm-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAKzC,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CACtC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-editing-plugin.d.ts","sourceRoot":"","sources":["../../src/plugin/table-editing-plugin.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"table-editing-plugin.d.ts","sourceRoot":"","sources":["../../src/plugin/table-editing-plugin.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kBAAkB,kCAE9B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/preset-gfm",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.5.8",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/Milkdown/milkdown.git",
|
|
9
|
-
"directory": "packages/preset-gfm"
|
|
9
|
+
"directory": "packages/plugins/preset-gfm"
|
|
10
10
|
},
|
|
11
11
|
"keywords": [
|
|
12
12
|
"milkdown",
|
|
@@ -34,17 +34,18 @@
|
|
|
34
34
|
"@milkdown/transformer": "^7.2.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
+
"prosemirror-safari-ime-span": "^1.0.1",
|
|
37
38
|
"remark-gfm": "^4.0.0",
|
|
38
39
|
"tslib": "^2.5.0",
|
|
39
|
-
"@milkdown/exception": "7.
|
|
40
|
-
"@milkdown/utils": "7.
|
|
40
|
+
"@milkdown/exception": "7.5.8",
|
|
41
|
+
"@milkdown/utils": "7.5.8"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@milkdown/core": "7.
|
|
44
|
-
"@milkdown/ctx": "7.
|
|
45
|
-
"@milkdown/preset-commonmark": "7.
|
|
46
|
-
"@milkdown/
|
|
47
|
-
"@milkdown/
|
|
44
|
+
"@milkdown/core": "7.5.8",
|
|
45
|
+
"@milkdown/ctx": "7.5.8",
|
|
46
|
+
"@milkdown/preset-commonmark": "7.5.8",
|
|
47
|
+
"@milkdown/transformer": "7.5.8",
|
|
48
|
+
"@milkdown/prose": "7.5.8"
|
|
48
49
|
},
|
|
49
50
|
"nx": {
|
|
50
51
|
"targets": {
|
|
@@ -53,19 +54,13 @@
|
|
|
53
54
|
"{projectRoot}/lib"
|
|
54
55
|
],
|
|
55
56
|
"dependsOn": [
|
|
56
|
-
|
|
57
|
-
"target": "build",
|
|
58
|
-
"projects": "dependencies"
|
|
59
|
-
}
|
|
57
|
+
"build"
|
|
60
58
|
]
|
|
61
59
|
},
|
|
62
60
|
"tsc": {
|
|
63
61
|
"outputs": [],
|
|
64
62
|
"dependsOn": [
|
|
65
|
-
|
|
66
|
-
"target": "build",
|
|
67
|
-
"projects": "dependencies"
|
|
68
|
-
}
|
|
63
|
+
"build"
|
|
69
64
|
]
|
|
70
65
|
}
|
|
71
66
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Meta, MilkdownPlugin } from '@milkdown/ctx'
|
|
2
2
|
|
|
3
|
-
export function withMeta<T extends MilkdownPlugin>(
|
|
3
|
+
export function withMeta<T extends MilkdownPlugin>(
|
|
4
|
+
plugin: T,
|
|
5
|
+
meta: Partial<Meta> & Pick<Meta, 'displayName'>
|
|
6
|
+
): T {
|
|
4
7
|
Object.assign(plugin, {
|
|
5
8
|
meta: {
|
|
6
9
|
package: '@milkdown/preset-gfm',
|
package/src/composed/commands.ts
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { toggleStrikethroughCommand } from '../mark'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
addColAfterCommand,
|
|
4
|
+
addColBeforeCommand,
|
|
5
|
+
addRowAfterCommand,
|
|
6
|
+
addRowBeforeCommand,
|
|
7
|
+
deleteSelectedCellsCommand,
|
|
8
|
+
exitTable,
|
|
9
|
+
goToNextTableCellCommand,
|
|
10
|
+
goToPrevTableCellCommand,
|
|
11
|
+
insertTableCommand,
|
|
12
|
+
moveColCommand,
|
|
13
|
+
moveRowCommand,
|
|
14
|
+
selectColCommand,
|
|
15
|
+
selectRowCommand,
|
|
16
|
+
selectTableCommand,
|
|
17
|
+
setAlignCommand,
|
|
18
|
+
} from '../node'
|
|
3
19
|
|
|
4
20
|
/// @internal
|
|
5
21
|
export const commands = [
|
|
6
22
|
goToNextTableCellCommand,
|
|
7
23
|
goToPrevTableCellCommand,
|
|
8
|
-
|
|
24
|
+
exitTable,
|
|
9
25
|
insertTableCommand,
|
|
10
26
|
moveRowCommand,
|
|
11
27
|
moveColCommand,
|
package/src/composed/plugins.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { MilkdownPlugin } from '@milkdown/ctx'
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
autoInsertSpanPlugin,
|
|
4
|
+
keepTableAlignPlugin,
|
|
5
5
|
remarkGFMPlugin,
|
|
6
6
|
tableEditingPlugin,
|
|
7
7
|
} from '../plugin'
|
|
8
8
|
|
|
9
9
|
/// @internal
|
|
10
10
|
export const plugins: MilkdownPlugin[] = [
|
|
11
|
-
|
|
11
|
+
keepTableAlignPlugin,
|
|
12
|
+
autoInsertSpanPlugin,
|
|
12
13
|
remarkGFMPlugin,
|
|
13
|
-
columnResizingPlugin,
|
|
14
14
|
tableEditingPlugin,
|
|
15
15
|
].flat()
|
package/src/composed/schema.ts
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import type { MilkdownPlugin } from '@milkdown/ctx'
|
|
2
2
|
import { strikethroughAttr, strikethroughSchema } from '../mark'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
extendListItemSchemaForTask,
|
|
5
|
+
footnoteDefinitionSchema,
|
|
6
|
+
footnoteReferenceSchema,
|
|
7
|
+
tableCellSchema,
|
|
8
|
+
tableHeaderRowSchema,
|
|
9
|
+
tableHeaderSchema,
|
|
10
|
+
tableRowSchema,
|
|
11
|
+
tableSchema,
|
|
12
|
+
} from '../node'
|
|
4
13
|
|
|
5
14
|
/// @internal
|
|
6
15
|
export const schema: MilkdownPlugin[] = [
|
|
7
16
|
extendListItemSchemaForTask,
|
|
8
17
|
|
|
9
18
|
tableSchema,
|
|
19
|
+
tableHeaderRowSchema,
|
|
10
20
|
tableRowSchema,
|
|
11
21
|
tableHeaderSchema,
|
|
12
22
|
tableCellSchema,
|
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>',
|