@milkdown/preset-commonmark 7.1.1 → 7.1.2-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/lib/__internal__/index.d.ts +3 -0
- package/lib/__internal__/index.d.ts.map +1 -0
- package/lib/{utils/index.d.ts → __internal__/serialize-text.d.ts} +1 -1
- package/lib/__internal__/serialize-text.d.ts.map +1 -0
- package/lib/__internal__/with-meta.d.ts +3 -0
- package/lib/__internal__/with-meta.d.ts.map +1 -0
- package/lib/index.es.js +1095 -575
- package/lib/index.es.js.map +1 -1
- package/lib/mark/emphasis.d.ts +1 -1
- package/lib/mark/emphasis.d.ts.map +1 -1
- package/lib/mark/inline-code.d.ts +1 -1
- package/lib/mark/inline-code.d.ts.map +1 -1
- package/lib/mark/link.d.ts +1 -1
- package/lib/mark/link.d.ts.map +1 -1
- package/lib/mark/strong.d.ts +1 -1
- package/lib/mark/strong.d.ts.map +1 -1
- package/lib/node/blockquote.d.ts.map +1 -1
- package/lib/node/bullet-list.d.ts.map +1 -1
- package/lib/node/code-block.d.ts.map +1 -1
- package/lib/node/doc.d.ts.map +1 -1
- package/lib/node/hardbreak.d.ts.map +1 -1
- package/lib/node/heading.d.ts.map +1 -1
- package/lib/node/hr.d.ts.map +1 -1
- package/lib/node/html.d.ts.map +1 -1
- package/lib/node/image.d.ts.map +1 -1
- package/lib/node/list-item.d.ts.map +1 -1
- package/lib/node/ordered-list.d.ts.map +1 -1
- package/lib/node/paragraph.d.ts.map +1 -1
- package/lib/node/text.d.ts.map +1 -1
- package/lib/plugin/hardbreak-clear-mark-plugin.d.ts.map +1 -1
- package/lib/plugin/hardbreak-filter-plugin.d.ts.map +1 -1
- package/lib/plugin/inline-nodes-cursor-plugin.d.ts.map +1 -1
- package/lib/plugin/inline-sync-plugin/config.d.ts.map +1 -1
- package/lib/plugin/inline-sync-plugin/inline-sync-plugin.d.ts.map +1 -1
- package/lib/plugin/remark-add-order-in-list-plugin.d.ts.map +1 -1
- package/lib/plugin/remark-html-transformer.d.ts.map +1 -1
- package/lib/plugin/remark-inline-link-plugin.d.ts.map +1 -1
- package/lib/plugin/remark-line-break.d.ts.map +1 -1
- package/lib/plugin/sync-heading-id-plugin.d.ts.map +1 -1
- package/lib/plugin/sync-list-order-plugin.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/__internal__/index.ts +3 -0
- package/src/{utils/index.ts → __internal__/serialize-text.ts} +3 -3
- package/src/__internal__/with-meta.ts +16 -0
- package/src/mark/emphasis.ts +31 -0
- package/src/mark/inline-code.ts +31 -0
- package/src/mark/link.ts +21 -0
- package/src/mark/strong.ts +31 -0
- package/src/node/blockquote.ts +36 -0
- package/src/node/bullet-list.ts +36 -0
- package/src/node/code-block.ts +41 -0
- package/src/node/doc.ts +6 -0
- package/src/node/hardbreak.ts +31 -0
- package/src/node/heading.ts +46 -1
- package/src/node/hr.ts +26 -0
- package/src/node/html.ts +16 -0
- package/src/node/image.ts +31 -0
- package/src/node/list-item.ts +41 -0
- package/src/node/ordered-list.ts +36 -0
- package/src/node/paragraph.ts +30 -1
- package/src/node/text.ts +6 -0
- package/src/plugin/hardbreak-clear-mark-plugin.ts +7 -1
- package/src/plugin/hardbreak-filter-plugin.ts +11 -0
- package/src/plugin/inline-nodes-cursor-plugin.ts +6 -0
- package/src/plugin/inline-sync-plugin/config.ts +6 -0
- package/src/plugin/inline-sync-plugin/inline-sync-plugin.ts +6 -0
- package/src/plugin/remark-add-order-in-list-plugin.ts +6 -0
- package/src/plugin/remark-html-transformer.ts +6 -0
- package/src/plugin/remark-inline-link-plugin.ts +6 -0
- package/src/plugin/remark-line-break.ts +6 -0
- package/src/plugin/sync-heading-id-plugin.ts +6 -0
- package/src/plugin/sync-list-order-plugin.ts +6 -0
- package/lib/utils/index.d.ts.map +0 -1
package/src/node/code-block.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { expectDomTypeError } from '@milkdown/exception'
|
|
|
4
4
|
import { setBlockType } from '@milkdown/prose/commands'
|
|
5
5
|
import { textblockTypeInputRule } from '@milkdown/prose/inputrules'
|
|
6
6
|
import { $command, $inputRule, $nodeAttr, $nodeSchema, $useKeymap } from '@milkdown/utils'
|
|
7
|
+
import { withMeta } from '../__internal__'
|
|
7
8
|
|
|
8
9
|
/// HTML attributes for code block node.
|
|
9
10
|
export const codeBlockAttr = $nodeAttr('codeBlock', () => ({
|
|
@@ -11,6 +12,11 @@ export const codeBlockAttr = $nodeAttr('codeBlock', () => ({
|
|
|
11
12
|
code: {},
|
|
12
13
|
}))
|
|
13
14
|
|
|
15
|
+
withMeta(codeBlockAttr, {
|
|
16
|
+
displayName: 'Attr<codeBlock>',
|
|
17
|
+
group: 'CodeBlock',
|
|
18
|
+
})
|
|
19
|
+
|
|
14
20
|
/// Schema for code block node.
|
|
15
21
|
export const codeBlockSchema = $nodeSchema('code_block', (ctx) => {
|
|
16
22
|
return {
|
|
@@ -70,16 +76,36 @@ export const codeBlockSchema = $nodeSchema('code_block', (ctx) => {
|
|
|
70
76
|
}
|
|
71
77
|
})
|
|
72
78
|
|
|
79
|
+
withMeta(codeBlockSchema.node, {
|
|
80
|
+
displayName: 'NodeSchema<codeBlock>',
|
|
81
|
+
group: 'CodeBlock',
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
withMeta(codeBlockSchema.ctx, {
|
|
85
|
+
displayName: 'NodeSchemaCtx<codeBlock>',
|
|
86
|
+
group: 'CodeBlock',
|
|
87
|
+
})
|
|
88
|
+
|
|
73
89
|
/// A input rule for creating code block.
|
|
74
90
|
/// For example, ` ```javascript ` will create a code block with language javascript.
|
|
75
91
|
export const createCodeBlockInputRule = $inputRule(() => textblockTypeInputRule(/^```(?<language>[a-z]*)?[\s\n]$/, codeBlockSchema.type(), match => ({
|
|
76
92
|
language: match.groups?.language ?? '',
|
|
77
93
|
})))
|
|
78
94
|
|
|
95
|
+
withMeta(createCodeBlockInputRule, {
|
|
96
|
+
displayName: 'InputRule<createCodeBlockInputRule>',
|
|
97
|
+
group: 'CodeBlock',
|
|
98
|
+
})
|
|
99
|
+
|
|
79
100
|
/// A command for creating code block.
|
|
80
101
|
/// You can pass the language of the code block as the parameter.
|
|
81
102
|
export const createCodeBlockCommand = $command('CreateCodeBlock', () => (language = '') => setBlockType(codeBlockSchema.type(), { language }))
|
|
82
103
|
|
|
104
|
+
withMeta(createCodeBlockCommand, {
|
|
105
|
+
displayName: 'Command<createCodeBlockCommand>',
|
|
106
|
+
group: 'CodeBlock',
|
|
107
|
+
})
|
|
108
|
+
|
|
83
109
|
/// A command for updating the code block language of the target position.
|
|
84
110
|
export const updateCodeBlockLanguageCommand = $command('UpdateCodeBlockLanguage', () => ({ pos, language }: { pos: number; language: string } = { pos: -1, language: '' }) => (state, dispatch) => {
|
|
85
111
|
if (pos >= 0) {
|
|
@@ -90,6 +116,11 @@ export const updateCodeBlockLanguageCommand = $command('UpdateCodeBlockLanguage'
|
|
|
90
116
|
return false
|
|
91
117
|
})
|
|
92
118
|
|
|
119
|
+
withMeta(updateCodeBlockLanguageCommand, {
|
|
120
|
+
displayName: 'Command<updateCodeBlockLanguageCommand>',
|
|
121
|
+
group: 'CodeBlock',
|
|
122
|
+
})
|
|
123
|
+
|
|
93
124
|
/// Keymap for code block.
|
|
94
125
|
/// - `Mod-Alt-c`: Create a code block.
|
|
95
126
|
export const codeBlockKeymap = $useKeymap('codeBlockKeymap', {
|
|
@@ -101,3 +132,13 @@ export const codeBlockKeymap = $useKeymap('codeBlockKeymap', {
|
|
|
101
132
|
},
|
|
102
133
|
},
|
|
103
134
|
})
|
|
135
|
+
|
|
136
|
+
withMeta(codeBlockKeymap.ctx, {
|
|
137
|
+
displayName: 'KeymapCtx<codeBlock>',
|
|
138
|
+
group: 'CodeBlock',
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
withMeta(codeBlockKeymap.shortcuts, {
|
|
142
|
+
displayName: 'Keymap<codeBlock>',
|
|
143
|
+
group: 'CodeBlock',
|
|
144
|
+
})
|
package/src/node/doc.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
2
|
import { $node } from '@milkdown/utils'
|
|
3
|
+
import { withMeta } from '../__internal__'
|
|
3
4
|
|
|
4
5
|
/// The top-level document node.
|
|
5
6
|
export const docSchema = $node('doc', () => ({
|
|
@@ -18,3 +19,8 @@ export const docSchema = $node('doc', () => ({
|
|
|
18
19
|
},
|
|
19
20
|
},
|
|
20
21
|
}))
|
|
22
|
+
|
|
23
|
+
withMeta(docSchema, {
|
|
24
|
+
displayName: 'NodeSchema<doc>',
|
|
25
|
+
group: 'Doc',
|
|
26
|
+
})
|
package/src/node/hardbreak.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { commandsCtx } from '@milkdown/core'
|
|
3
3
|
import { Selection } from '@milkdown/prose/state'
|
|
4
4
|
import { $command, $nodeAttr, $nodeSchema, $useKeymap } from '@milkdown/utils'
|
|
5
|
+
import { withMeta } from '../__internal__'
|
|
5
6
|
|
|
6
7
|
/// HTML attributes for the hardbreak node.
|
|
7
8
|
///
|
|
@@ -13,6 +14,11 @@ export const hardbreakAttr = $nodeAttr('hardbreak', (node) => {
|
|
|
13
14
|
}
|
|
14
15
|
})
|
|
15
16
|
|
|
17
|
+
withMeta(hardbreakAttr, {
|
|
18
|
+
displayName: 'Attr<hardbreak>',
|
|
19
|
+
group: 'Hardbreak',
|
|
20
|
+
})
|
|
21
|
+
|
|
16
22
|
/// Hardbreak node schema.
|
|
17
23
|
export const hardbreakSchema = $nodeSchema('hardbreak', ctx => ({
|
|
18
24
|
inline: true,
|
|
@@ -44,6 +50,16 @@ export const hardbreakSchema = $nodeSchema('hardbreak', ctx => ({
|
|
|
44
50
|
},
|
|
45
51
|
}))
|
|
46
52
|
|
|
53
|
+
withMeta(hardbreakSchema.node, {
|
|
54
|
+
displayName: 'NodeSchema<hardbreak>',
|
|
55
|
+
group: 'Hardbreak',
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
withMeta(hardbreakSchema.ctx, {
|
|
59
|
+
displayName: 'NodeSchemaCtx<hardbreak>',
|
|
60
|
+
group: 'Hardbreak',
|
|
61
|
+
})
|
|
62
|
+
|
|
47
63
|
/// Command to insert a hardbreak.
|
|
48
64
|
export const insertHardbreakCommand = $command('InsertHardbreak', () => () => (state, dispatch) => {
|
|
49
65
|
const { selection, tr } = state
|
|
@@ -64,6 +80,11 @@ export const insertHardbreakCommand = $command('InsertHardbreak', () => () => (s
|
|
|
64
80
|
return true
|
|
65
81
|
})
|
|
66
82
|
|
|
83
|
+
withMeta(insertHardbreakCommand, {
|
|
84
|
+
displayName: 'Command<insertHardbreakCommand>',
|
|
85
|
+
group: 'Hardbreak',
|
|
86
|
+
})
|
|
87
|
+
|
|
67
88
|
/// Keymap for the hardbreak node.
|
|
68
89
|
/// - `Shift-Enter` - Insert a hardbreak.
|
|
69
90
|
export const hardbreakKeymap = $useKeymap('hardbreakKeymap', {
|
|
@@ -75,3 +96,13 @@ export const hardbreakKeymap = $useKeymap('hardbreakKeymap', {
|
|
|
75
96
|
},
|
|
76
97
|
},
|
|
77
98
|
})
|
|
99
|
+
|
|
100
|
+
withMeta(hardbreakKeymap.ctx, {
|
|
101
|
+
displayName: 'KeymapCtx<hardbreak>',
|
|
102
|
+
group: 'Hardbreak',
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
withMeta(hardbreakKeymap.shortcuts, {
|
|
106
|
+
displayName: 'Keymap<hardbreak>',
|
|
107
|
+
group: 'Hardbreak',
|
|
108
|
+
})
|
package/src/node/heading.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { textblockTypeInputRule } from '@milkdown/prose/inputrules'
|
|
|
6
6
|
import type { Node } from '@milkdown/prose/model'
|
|
7
7
|
import { $command, $ctx, $inputRule, $nodeAttr, $nodeSchema, $useKeymap } from '@milkdown/utils'
|
|
8
8
|
import slugify from '@sindresorhus/slugify'
|
|
9
|
-
import { serializeText } from '../
|
|
9
|
+
import { serializeText, withMeta } from '../__internal__'
|
|
10
10
|
import { paragraphSchema } from './paragraph'
|
|
11
11
|
|
|
12
12
|
const headingIndex = Array(6)
|
|
@@ -20,9 +20,19 @@ const defaultHeadingIdGenerator = (node: Node) =>
|
|
|
20
20
|
/// You can configure it to generate id in your own way.
|
|
21
21
|
export const headingIdGenerator = $ctx(defaultHeadingIdGenerator, 'headingIdGenerator')
|
|
22
22
|
|
|
23
|
+
withMeta(headingIdGenerator, {
|
|
24
|
+
displayName: 'Ctx<HeadingIdGenerator>',
|
|
25
|
+
group: 'Heading',
|
|
26
|
+
})
|
|
27
|
+
|
|
23
28
|
/// HTML attributes for heading node.
|
|
24
29
|
export const headingAttr = $nodeAttr('heading')
|
|
25
30
|
|
|
31
|
+
withMeta(headingAttr, {
|
|
32
|
+
displayName: 'Attr<heading>',
|
|
33
|
+
group: 'Heading',
|
|
34
|
+
})
|
|
35
|
+
|
|
26
36
|
/// Schema for heading node.
|
|
27
37
|
export const headingSchema = $nodeSchema('heading', (ctx) => {
|
|
28
38
|
const getId = ctx.get(headingIdGenerator.key)
|
|
@@ -77,6 +87,16 @@ export const headingSchema = $nodeSchema('heading', (ctx) => {
|
|
|
77
87
|
}
|
|
78
88
|
})
|
|
79
89
|
|
|
90
|
+
withMeta(headingSchema.node, {
|
|
91
|
+
displayName: 'NodeSchema<heading>',
|
|
92
|
+
group: 'Heading',
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
withMeta(headingSchema.ctx, {
|
|
96
|
+
displayName: 'NodeSchemaCtx<heading>',
|
|
97
|
+
group: 'Heading',
|
|
98
|
+
})
|
|
99
|
+
|
|
80
100
|
/// This input rule can turn the selected block into heading.
|
|
81
101
|
/// You can input numbers of `#` and a `space` to create heading.
|
|
82
102
|
export const wrapInHeadingInputRule = $inputRule((ctx) => {
|
|
@@ -97,6 +117,11 @@ export const wrapInHeadingInputRule = $inputRule((ctx) => {
|
|
|
97
117
|
})
|
|
98
118
|
})
|
|
99
119
|
|
|
120
|
+
withMeta(wrapInHeadingInputRule, {
|
|
121
|
+
displayName: 'InputRule<wrapInHeadingInputRule>',
|
|
122
|
+
group: 'Heading',
|
|
123
|
+
})
|
|
124
|
+
|
|
100
125
|
/// This command can turn the selected block into heading.
|
|
101
126
|
/// You can pass the level of heading to this command.
|
|
102
127
|
/// By default, the level is 1, which means it will create a `h1` element.
|
|
@@ -111,6 +136,11 @@ export const wrapInHeadingCommand = $command('WrapInHeading', () => {
|
|
|
111
136
|
}
|
|
112
137
|
})
|
|
113
138
|
|
|
139
|
+
withMeta(wrapInHeadingCommand, {
|
|
140
|
+
displayName: 'Command<wrapInHeadingCommand>',
|
|
141
|
+
group: 'Heading',
|
|
142
|
+
})
|
|
143
|
+
|
|
114
144
|
/// This command can downgrade the selected heading.
|
|
115
145
|
/// For example, if you have a `h2` element, and you call this command, you will get a `h1` element.
|
|
116
146
|
/// If the element is already a `h1` element, it will turn it into a `p` element.
|
|
@@ -134,6 +164,11 @@ export const downgradeHeadingCommand = $command('DowngradeHeading', () => () =>
|
|
|
134
164
|
return true
|
|
135
165
|
})
|
|
136
166
|
|
|
167
|
+
withMeta(downgradeHeadingCommand, {
|
|
168
|
+
displayName: 'Command<downgradeHeadingCommand>',
|
|
169
|
+
group: 'Heading',
|
|
170
|
+
})
|
|
171
|
+
|
|
137
172
|
/// Keymap for heading node.
|
|
138
173
|
/// - `<Mod-Alt-{1-6}>`: Turn the selected block into `h{1-6}` element.
|
|
139
174
|
/// - `<Delete>/<Backspace>`: Downgrade the selected heading.
|
|
@@ -188,3 +223,13 @@ export const headingKeymap = $useKeymap('headingKeymap', {
|
|
|
188
223
|
},
|
|
189
224
|
},
|
|
190
225
|
})
|
|
226
|
+
|
|
227
|
+
withMeta(headingKeymap.ctx, {
|
|
228
|
+
displayName: 'KeymapCtx<heading>',
|
|
229
|
+
group: 'Heading',
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
withMeta(headingKeymap.shortcuts, {
|
|
233
|
+
displayName: 'Keymap<heading>',
|
|
234
|
+
group: 'Heading',
|
|
235
|
+
})
|
package/src/node/hr.ts
CHANGED
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
import { InputRule } from '@milkdown/prose/inputrules'
|
|
3
3
|
import { Selection } from '@milkdown/prose/state'
|
|
4
4
|
import { $command, $inputRule, $nodeAttr, $nodeSchema } from '@milkdown/utils'
|
|
5
|
+
import { withMeta } from '../__internal__'
|
|
5
6
|
import { paragraphSchema } from './paragraph'
|
|
6
7
|
|
|
7
8
|
/// HTML attributes for the hr node.
|
|
8
9
|
export const hrAttr = $nodeAttr('hr')
|
|
9
10
|
|
|
11
|
+
withMeta(hrAttr, {
|
|
12
|
+
displayName: 'Attr<hr>',
|
|
13
|
+
group: 'Hr',
|
|
14
|
+
})
|
|
15
|
+
|
|
10
16
|
/// Hr node schema.
|
|
11
17
|
export const hrSchema = $nodeSchema('hr', ctx => ({
|
|
12
18
|
group: 'block',
|
|
@@ -26,6 +32,16 @@ export const hrSchema = $nodeSchema('hr', ctx => ({
|
|
|
26
32
|
},
|
|
27
33
|
}))
|
|
28
34
|
|
|
35
|
+
withMeta(hrSchema.node, {
|
|
36
|
+
displayName: 'NodeSchema<hr>',
|
|
37
|
+
group: 'Hr',
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
withMeta(hrSchema.ctx, {
|
|
41
|
+
displayName: 'NodeSchemaCtx<hr>',
|
|
42
|
+
group: 'Hr',
|
|
43
|
+
})
|
|
44
|
+
|
|
29
45
|
/// Input rule to insert a hr.
|
|
30
46
|
/// For example, `---` will be converted to a hr.
|
|
31
47
|
export const insertHrInputRule = $inputRule(() => new InputRule(
|
|
@@ -39,6 +55,11 @@ export const insertHrInputRule = $inputRule(() => new InputRule(
|
|
|
39
55
|
},
|
|
40
56
|
))
|
|
41
57
|
|
|
58
|
+
withMeta(insertHrInputRule, {
|
|
59
|
+
displayName: 'InputRule<insertHrInputRule>',
|
|
60
|
+
group: 'Hr',
|
|
61
|
+
})
|
|
62
|
+
|
|
42
63
|
/// Command to insert a hr.
|
|
43
64
|
export const insertHrCommand = $command('InsertHr', () => () => (state, dispatch) => {
|
|
44
65
|
if (!dispatch)
|
|
@@ -59,3 +80,8 @@ export const insertHrCommand = $command('InsertHr', () => () => (state, dispatch
|
|
|
59
80
|
dispatch(_tr.setSelection(sel).scrollIntoView())
|
|
60
81
|
return true
|
|
61
82
|
})
|
|
83
|
+
|
|
84
|
+
withMeta(insertHrCommand, {
|
|
85
|
+
displayName: 'Command<insertHrCommand>',
|
|
86
|
+
group: 'Hr',
|
|
87
|
+
})
|
package/src/node/html.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
2
|
import { $nodeAttr, $nodeSchema } from '@milkdown/utils'
|
|
3
|
+
import { withMeta } from '../__internal__'
|
|
3
4
|
|
|
4
5
|
export const htmlAttr = $nodeAttr('html')
|
|
5
6
|
|
|
7
|
+
withMeta(htmlAttr, {
|
|
8
|
+
displayName: 'Attr<html>',
|
|
9
|
+
group: 'Html',
|
|
10
|
+
})
|
|
11
|
+
|
|
6
12
|
export const htmlSchema = $nodeSchema('html', (ctx) => {
|
|
7
13
|
return {
|
|
8
14
|
atom: true,
|
|
@@ -45,3 +51,13 @@ export const htmlSchema = $nodeSchema('html', (ctx) => {
|
|
|
45
51
|
},
|
|
46
52
|
}
|
|
47
53
|
})
|
|
54
|
+
|
|
55
|
+
withMeta(htmlSchema.node, {
|
|
56
|
+
displayName: 'NodeSchema<html>',
|
|
57
|
+
group: 'Html',
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
withMeta(htmlSchema.ctx, {
|
|
61
|
+
displayName: 'NodeSchemaCtx<html>',
|
|
62
|
+
group: 'Html',
|
|
63
|
+
})
|
package/src/node/image.ts
CHANGED
|
@@ -3,10 +3,16 @@ import { expectDomTypeError } from '@milkdown/exception'
|
|
|
3
3
|
import { findSelectedNodeOfType } from '@milkdown/prose'
|
|
4
4
|
import { InputRule } from '@milkdown/prose/inputrules'
|
|
5
5
|
import { $command, $inputRule, $nodeAttr, $nodeSchema } from '@milkdown/utils'
|
|
6
|
+
import { withMeta } from '../__internal__'
|
|
6
7
|
|
|
7
8
|
/// HTML attributes for image node.
|
|
8
9
|
export const imageAttr = $nodeAttr('image')
|
|
9
10
|
|
|
11
|
+
withMeta(imageAttr, {
|
|
12
|
+
displayName: 'Attr<image>',
|
|
13
|
+
group: 'Image',
|
|
14
|
+
})
|
|
15
|
+
|
|
10
16
|
/// Schema for image node.
|
|
11
17
|
export const imageSchema = $nodeSchema('image', (ctx) => {
|
|
12
18
|
return {
|
|
@@ -67,6 +73,16 @@ export const imageSchema = $nodeSchema('image', (ctx) => {
|
|
|
67
73
|
}
|
|
68
74
|
})
|
|
69
75
|
|
|
76
|
+
withMeta(imageSchema.node, {
|
|
77
|
+
displayName: 'NodeSchema<image>',
|
|
78
|
+
group: 'Image',
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
withMeta(imageSchema.ctx, {
|
|
82
|
+
displayName: 'NodeSchemaCtx<image>',
|
|
83
|
+
group: 'Image',
|
|
84
|
+
})
|
|
85
|
+
|
|
70
86
|
/// @internal
|
|
71
87
|
export type UpdateImageCommandPayload = {
|
|
72
88
|
src?: string
|
|
@@ -91,6 +107,11 @@ export const insertImageCommand = $command('InsertImage', () => (payload: Update
|
|
|
91
107
|
return true
|
|
92
108
|
})
|
|
93
109
|
|
|
110
|
+
withMeta(insertImageCommand, {
|
|
111
|
+
displayName: 'Command<insertImageCommand>',
|
|
112
|
+
group: 'Image',
|
|
113
|
+
})
|
|
114
|
+
|
|
94
115
|
/// This command will update the selected image node.
|
|
95
116
|
/// You can pass a payload to update `src`, `alt` and `title` for the image node.
|
|
96
117
|
export const updateImageCommand = $command('UpdateImage', () => (payload: UpdateImageCommandPayload = {}) => (state, dispatch) => {
|
|
@@ -113,6 +134,11 @@ export const updateImageCommand = $command('UpdateImage', () => (payload: Update
|
|
|
113
134
|
return true
|
|
114
135
|
})
|
|
115
136
|
|
|
137
|
+
withMeta(updateImageCommand, {
|
|
138
|
+
displayName: 'Command<updateImageCommand>',
|
|
139
|
+
group: 'Image',
|
|
140
|
+
})
|
|
141
|
+
|
|
116
142
|
/// This input rule will insert a image node.
|
|
117
143
|
/// You can input `` to insert a image node.
|
|
118
144
|
/// The `title` is optional.
|
|
@@ -126,3 +152,8 @@ export const insertImageInputRule = $inputRule(() => new InputRule(
|
|
|
126
152
|
return null
|
|
127
153
|
},
|
|
128
154
|
))
|
|
155
|
+
|
|
156
|
+
withMeta(insertImageInputRule, {
|
|
157
|
+
displayName: 'InputRule<insertImageInputRule>',
|
|
158
|
+
group: 'Image',
|
|
159
|
+
})
|
package/src/node/list-item.ts
CHANGED
|
@@ -3,10 +3,16 @@ import { commandsCtx } from '@milkdown/core'
|
|
|
3
3
|
import { expectDomTypeError } from '@milkdown/exception'
|
|
4
4
|
import { liftListItem, sinkListItem, splitListItem } from '@milkdown/prose/schema-list'
|
|
5
5
|
import { $command, $nodeAttr, $nodeSchema, $useKeymap } from '@milkdown/utils'
|
|
6
|
+
import { withMeta } from '../__internal__'
|
|
6
7
|
|
|
7
8
|
/// HTML attributes for list item node.
|
|
8
9
|
export const listItemAttr = $nodeAttr('listItem')
|
|
9
10
|
|
|
11
|
+
withMeta(listItemAttr, {
|
|
12
|
+
displayName: 'Attr<listItem>',
|
|
13
|
+
group: 'ListItem',
|
|
14
|
+
})
|
|
15
|
+
|
|
10
16
|
/// Schema for list item node.
|
|
11
17
|
export const listItemSchema = $nodeSchema('list_item', ctx => ({
|
|
12
18
|
group: 'listItem',
|
|
@@ -69,6 +75,16 @@ export const listItemSchema = $nodeSchema('list_item', ctx => ({
|
|
|
69
75
|
},
|
|
70
76
|
}))
|
|
71
77
|
|
|
78
|
+
withMeta(listItemSchema.node, {
|
|
79
|
+
displayName: 'NodeSchema<listItem>',
|
|
80
|
+
group: 'ListItem',
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
withMeta(listItemSchema.ctx, {
|
|
84
|
+
displayName: 'NodeSchemaCtx<listItem>',
|
|
85
|
+
group: 'ListItem',
|
|
86
|
+
})
|
|
87
|
+
|
|
72
88
|
/// The command to sink list item.
|
|
73
89
|
///
|
|
74
90
|
/// For example:
|
|
@@ -83,6 +99,11 @@ export const listItemSchema = $nodeSchema('list_item', ctx => ({
|
|
|
83
99
|
/// ```
|
|
84
100
|
export const sinkListItemCommand = $command('SinkListItem', () => () => sinkListItem(listItemSchema.type()))
|
|
85
101
|
|
|
102
|
+
withMeta(sinkListItemCommand, {
|
|
103
|
+
displayName: 'Command<sinkListItemCommand>',
|
|
104
|
+
group: 'ListItem',
|
|
105
|
+
})
|
|
106
|
+
|
|
86
107
|
/// The command to lift list item.
|
|
87
108
|
///
|
|
88
109
|
/// For example:
|
|
@@ -97,6 +118,11 @@ export const sinkListItemCommand = $command('SinkListItem', () => () => sinkList
|
|
|
97
118
|
/// ```
|
|
98
119
|
export const liftListItemCommand = $command('SplitListItem', () => () => liftListItem(listItemSchema.type()))
|
|
99
120
|
|
|
121
|
+
withMeta(liftListItemCommand, {
|
|
122
|
+
displayName: 'Command<liftListItemCommand>',
|
|
123
|
+
group: 'ListItem',
|
|
124
|
+
})
|
|
125
|
+
|
|
100
126
|
/// The command to split a list item.
|
|
101
127
|
///
|
|
102
128
|
/// For example:
|
|
@@ -112,6 +138,11 @@ export const liftListItemCommand = $command('SplitListItem', () => () => liftLis
|
|
|
112
138
|
/// ```
|
|
113
139
|
export const splitListItemCommand = $command('SplitListItem', () => () => splitListItem(listItemSchema.type()))
|
|
114
140
|
|
|
141
|
+
withMeta(splitListItemCommand, {
|
|
142
|
+
displayName: 'Command<splitListItemCommand>',
|
|
143
|
+
group: 'ListItem',
|
|
144
|
+
})
|
|
145
|
+
|
|
115
146
|
/// Keymap for list item node.
|
|
116
147
|
/// - `<Enter>`: Split the current list item.
|
|
117
148
|
/// - `<Tab>/<Mod-]>`: Sink the current list item.
|
|
@@ -139,3 +170,13 @@ export const listItemKeymap = $useKeymap('listItemKeymap', {
|
|
|
139
170
|
},
|
|
140
171
|
},
|
|
141
172
|
})
|
|
173
|
+
|
|
174
|
+
withMeta(listItemKeymap.ctx, {
|
|
175
|
+
displayName: 'KeymapCtx<listItem>',
|
|
176
|
+
group: 'ListItem',
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
withMeta(listItemKeymap.shortcuts, {
|
|
180
|
+
displayName: 'Keymap<listItem>',
|
|
181
|
+
group: 'ListItem',
|
|
182
|
+
})
|
package/src/node/ordered-list.ts
CHANGED
|
@@ -4,10 +4,16 @@ import { expectDomTypeError } from '@milkdown/exception'
|
|
|
4
4
|
import { wrapIn } from '@milkdown/prose/commands'
|
|
5
5
|
import { wrappingInputRule } from '@milkdown/prose/inputrules'
|
|
6
6
|
import { $command, $inputRule, $nodeAttr, $nodeSchema, $useKeymap } from '@milkdown/utils'
|
|
7
|
+
import { withMeta } from '../__internal__'
|
|
7
8
|
|
|
8
9
|
/// HTML attributes for ordered list node.
|
|
9
10
|
export const orderedListAttr = $nodeAttr('orderedList')
|
|
10
11
|
|
|
12
|
+
withMeta(orderedListAttr, {
|
|
13
|
+
displayName: 'Attr<orderedList>',
|
|
14
|
+
group: 'OrderedList',
|
|
15
|
+
})
|
|
16
|
+
|
|
11
17
|
/// Schema for ordered list node.
|
|
12
18
|
export const orderedListSchema = $nodeSchema('ordered_list', ctx => ({
|
|
13
19
|
content: 'listItem+',
|
|
@@ -60,6 +66,16 @@ export const orderedListSchema = $nodeSchema('ordered_list', ctx => ({
|
|
|
60
66
|
},
|
|
61
67
|
}))
|
|
62
68
|
|
|
69
|
+
withMeta(orderedListSchema.node, {
|
|
70
|
+
displayName: 'NodeSchema<orderedList>',
|
|
71
|
+
group: 'OrderedList',
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
withMeta(orderedListSchema.ctx, {
|
|
75
|
+
displayName: 'NodeSchemaCtx<orderedList>',
|
|
76
|
+
group: 'OrderedList',
|
|
77
|
+
})
|
|
78
|
+
|
|
63
79
|
/// Input rule for wrapping a block in ordered list node.
|
|
64
80
|
export const wrapInOrderedListInputRule = $inputRule(() => wrappingInputRule(
|
|
65
81
|
/^\s*(\d+)\.\s$/,
|
|
@@ -68,9 +84,19 @@ export const wrapInOrderedListInputRule = $inputRule(() => wrappingInputRule(
|
|
|
68
84
|
(match, node) => node.childCount + node.attrs.order === Number(match[1]),
|
|
69
85
|
))
|
|
70
86
|
|
|
87
|
+
withMeta(wrapInOrderedListInputRule, {
|
|
88
|
+
displayName: 'InputRule<wrapInOrderedListInputRule>',
|
|
89
|
+
group: 'OrderedList',
|
|
90
|
+
})
|
|
91
|
+
|
|
71
92
|
/// Command for wrapping a block in ordered list node.
|
|
72
93
|
export const wrapInOrderedListCommand = $command('WrapInOrderedList', () => () => wrapIn(orderedListSchema.type()))
|
|
73
94
|
|
|
95
|
+
withMeta(wrapInOrderedListCommand, {
|
|
96
|
+
displayName: 'Command<wrapInOrderedListCommand>',
|
|
97
|
+
group: 'OrderedList',
|
|
98
|
+
})
|
|
99
|
+
|
|
74
100
|
/// Keymap for ordered list node.
|
|
75
101
|
/// - `Mod-Alt-7`: Wrap a block in ordered list.
|
|
76
102
|
export const orderedListKeymap = $useKeymap('orderedListKeymap', {
|
|
@@ -82,3 +108,13 @@ export const orderedListKeymap = $useKeymap('orderedListKeymap', {
|
|
|
82
108
|
},
|
|
83
109
|
},
|
|
84
110
|
})
|
|
111
|
+
|
|
112
|
+
withMeta(orderedListKeymap.ctx, {
|
|
113
|
+
displayName: 'KeymapCtx<orderedList>',
|
|
114
|
+
group: 'OrderedList',
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
withMeta(orderedListKeymap.shortcuts, {
|
|
118
|
+
displayName: 'Keymap<orderedList>',
|
|
119
|
+
group: 'OrderedList',
|
|
120
|
+
})
|
package/src/node/paragraph.ts
CHANGED
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
import { commandsCtx } from '@milkdown/core'
|
|
3
3
|
import { setBlockType } from '@milkdown/prose/commands'
|
|
4
4
|
import { $command, $nodeAttr, $nodeSchema, $useKeymap } from '@milkdown/utils'
|
|
5
|
-
import { serializeText } from '../
|
|
5
|
+
import { serializeText, withMeta } from '../__internal__'
|
|
6
6
|
|
|
7
7
|
/// HTML attributes for paragraph node.
|
|
8
8
|
export const paragraphAttr = $nodeAttr('paragraph')
|
|
9
9
|
|
|
10
|
+
withMeta(paragraphAttr, {
|
|
11
|
+
displayName: 'Attr<paragraph>',
|
|
12
|
+
group: 'Paragraph',
|
|
13
|
+
})
|
|
14
|
+
|
|
10
15
|
/// Schema for paragraph node.
|
|
11
16
|
export const paragraphSchema = $nodeSchema('paragraph', ctx => ({
|
|
12
17
|
content: 'inline*',
|
|
@@ -36,9 +41,23 @@ export const paragraphSchema = $nodeSchema('paragraph', ctx => ({
|
|
|
36
41
|
},
|
|
37
42
|
}))
|
|
38
43
|
|
|
44
|
+
withMeta(paragraphSchema.node, {
|
|
45
|
+
displayName: 'NodeSchema<paragraph>',
|
|
46
|
+
group: 'Paragraph',
|
|
47
|
+
})
|
|
48
|
+
withMeta(paragraphSchema.ctx, {
|
|
49
|
+
displayName: 'NodeSchemaCtx<paragraph>',
|
|
50
|
+
group: 'Paragraph',
|
|
51
|
+
})
|
|
52
|
+
|
|
39
53
|
/// This command can turn the selected block into paragraph.
|
|
40
54
|
export const turnIntoTextCommand = $command('TurnIntoText', () => () => setBlockType(paragraphSchema.type()))
|
|
41
55
|
|
|
56
|
+
withMeta(turnIntoTextCommand, {
|
|
57
|
+
displayName: 'Command<turnIntoTextCommand>',
|
|
58
|
+
group: 'Paragraph',
|
|
59
|
+
})
|
|
60
|
+
|
|
42
61
|
/// Keymap for paragraph node.
|
|
43
62
|
/// - `<Mod-Alt-0>`: Turn the selected block into paragraph.
|
|
44
63
|
export const paragraphKeymap = $useKeymap('paragraphKeymap', {
|
|
@@ -50,3 +69,13 @@ export const paragraphKeymap = $useKeymap('paragraphKeymap', {
|
|
|
50
69
|
},
|
|
51
70
|
},
|
|
52
71
|
})
|
|
72
|
+
|
|
73
|
+
withMeta(paragraphKeymap.ctx, {
|
|
74
|
+
displayName: 'KeymapCtx<paragraph>',
|
|
75
|
+
group: 'Paragraph',
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
withMeta(paragraphKeymap.shortcuts, {
|
|
79
|
+
displayName: 'Keymap<paragraph>',
|
|
80
|
+
group: 'Paragraph',
|
|
81
|
+
})
|
package/src/node/text.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
2
|
import { $node } from '@milkdown/utils'
|
|
3
|
+
import { withMeta } from '../__internal__'
|
|
3
4
|
|
|
4
5
|
/// The bottom-level node.
|
|
5
6
|
export const textSchema = $node('text', () => ({
|
|
@@ -17,3 +18,8 @@ export const textSchema = $node('text', () => ({
|
|
|
17
18
|
},
|
|
18
19
|
},
|
|
19
20
|
}))
|
|
21
|
+
|
|
22
|
+
withMeta(textSchema, {
|
|
23
|
+
displayName: 'NodeSchema<text>',
|
|
24
|
+
group: 'Text',
|
|
25
|
+
})
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { Plugin, PluginKey } from '@milkdown/prose/state'
|
|
3
3
|
import { AddMarkStep, ReplaceStep } from '@milkdown/prose/transform'
|
|
4
4
|
import { $prose } from '@milkdown/utils'
|
|
5
|
-
import { hardbreakSchema } from '../node
|
|
5
|
+
import { hardbreakSchema } from '../node'
|
|
6
|
+
import { withMeta } from '../__internal__'
|
|
6
7
|
|
|
7
8
|
/// This plugin is used to clear the marks around the hardbreak node.
|
|
8
9
|
export const hardbreakClearMarkPlugin = $prose(() => {
|
|
@@ -43,3 +44,8 @@ export const hardbreakClearMarkPlugin = $prose(() => {
|
|
|
43
44
|
},
|
|
44
45
|
})
|
|
45
46
|
})
|
|
47
|
+
|
|
48
|
+
withMeta(hardbreakClearMarkPlugin, {
|
|
49
|
+
displayName: 'Prose<hardbreakClearMarkPlugin>',
|
|
50
|
+
group: 'Prose',
|
|
51
|
+
})
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
2
|
import { Plugin, PluginKey } from '@milkdown/prose/state'
|
|
3
3
|
import { $ctx, $prose } from '@milkdown/utils'
|
|
4
|
+
import { withMeta } from '../__internal__'
|
|
4
5
|
|
|
5
6
|
/// This slice contains the nodes that within which the hardbreak will be ignored.
|
|
6
7
|
export const hardbreakFilterNodes = $ctx(['table', 'code_block'], 'hardbreakFilterNodes')
|
|
7
8
|
|
|
9
|
+
withMeta(hardbreakFilterNodes, {
|
|
10
|
+
displayName: 'Ctx<hardbreakFilterNodes>',
|
|
11
|
+
group: 'Prose',
|
|
12
|
+
})
|
|
13
|
+
|
|
8
14
|
/// This plugin is used to filter the hardbreak node.
|
|
9
15
|
/// If the hardbreak is going to be inserted within a node that is in the `hardbreakFilterNodes`, ignore it.
|
|
10
16
|
export const hardbreakFilterPlugin = $prose((ctx) => {
|
|
@@ -31,3 +37,8 @@ export const hardbreakFilterPlugin = $prose((ctx) => {
|
|
|
31
37
|
},
|
|
32
38
|
})
|
|
33
39
|
})
|
|
40
|
+
|
|
41
|
+
withMeta(hardbreakFilterPlugin, {
|
|
42
|
+
displayName: 'Prose<hardbreakFilterPlugin>',
|
|
43
|
+
group: 'Prose',
|
|
44
|
+
})
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Plugin, PluginKey } from '@milkdown/prose/state'
|
|
3
3
|
import { Decoration, DecorationSet } from '@milkdown/prose/view'
|
|
4
4
|
import { $prose } from '@milkdown/utils'
|
|
5
|
+
import { withMeta } from '../__internal__'
|
|
5
6
|
|
|
6
7
|
/// This plugin is to solve the [chrome 98 bug](https://discuss.prosemirror.net/t/cursor-jumps-at-the-end-of-line-when-it-betweens-two-inline-nodes/4641).
|
|
7
8
|
export const inlineNodesCursorPlugin = $prose(() => {
|
|
@@ -88,3 +89,8 @@ export const inlineNodesCursorPlugin = $prose(() => {
|
|
|
88
89
|
|
|
89
90
|
return inlineNodesCursorPlugin
|
|
90
91
|
})
|
|
92
|
+
|
|
93
|
+
withMeta(inlineNodesCursorPlugin, {
|
|
94
|
+
displayName: 'Prose<inlineNodesCursorPlugin>',
|
|
95
|
+
group: 'Prose',
|
|
96
|
+
})
|