@milkdown/preset-commonmark 7.7.0 → 7.9.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__/serialize-text.d.ts +1 -1
- package/lib/__internal__/serialize-text.d.ts.map +1 -1
- package/lib/composed/commands.d.ts.map +1 -1
- package/lib/composed/inputrules.d.ts.map +1 -1
- package/lib/composed/keymap.d.ts.map +1 -1
- package/lib/composed/plugins.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 → index.js} +56 -30
- package/lib/index.js.map +1 -0
- package/lib/mark/emphasis.d.ts.map +1 -1
- package/lib/mark/inline-code.d.ts.map +1 -1
- package/lib/mark/link.d.ts.map +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/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/remark-marker-plugin.d.ts.map +1 -1
- package/lib/plugin/remark-preserve-empty-line.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/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +10 -39
- package/src/__internal__/serialize-text.ts +2 -1
- package/src/composed/commands.ts +1 -0
- package/src/composed/inputrules.ts +7 -6
- package/src/composed/keymap.ts +1 -0
- package/src/composed/plugins.ts +1 -0
- package/src/composed/schema.ts +1 -0
- package/src/index.ts +1 -0
- package/src/mark/emphasis.ts +4 -2
- package/src/mark/inline-code.ts +4 -3
- package/src/mark/link.ts +5 -3
- package/src/mark/strong.ts +18 -3
- package/src/node/blockquote.ts +3 -1
- package/src/node/bullet-list.ts +4 -2
- package/src/node/code-block.ts +2 -0
- package/src/node/doc.ts +1 -0
- package/src/node/hardbreak.ts +2 -0
- package/src/node/heading.ts +5 -1
- package/src/node/hr.ts +1 -0
- package/src/node/html.ts +2 -0
- package/src/node/image.ts +4 -3
- package/src/node/list-item.ts +10 -5
- package/src/node/ordered-list.ts +3 -0
- package/src/node/paragraph.ts +8 -2
- package/src/node/text.ts +1 -0
- package/src/plugin/hardbreak-clear-mark-plugin.ts +2 -1
- package/src/plugin/hardbreak-filter-plugin.ts +1 -0
- package/src/plugin/inline-nodes-cursor-plugin.ts +1 -0
- package/src/plugin/remark-add-order-in-list-plugin.ts +1 -0
- package/src/plugin/remark-html-transformer.ts +3 -1
- package/src/plugin/remark-inline-link-plugin.ts +1 -0
- package/src/plugin/remark-line-break.ts +3 -1
- package/src/plugin/remark-marker-plugin.ts +3 -1
- package/src/plugin/remark-preserve-empty-line.ts +6 -4
- package/src/plugin/sync-heading-id-plugin.ts +4 -2
- package/src/plugin/sync-list-order-plugin.ts +5 -4
- package/lib/index.es.js.map +0 -1
package/src/mark/strong.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { commandsCtx, remarkStringifyOptionsCtx } from '@milkdown/core'
|
|
2
|
+
import { markRule } from '@milkdown/prose'
|
|
3
|
+
import { toggleMark } from '@milkdown/prose/commands'
|
|
2
4
|
import {
|
|
3
5
|
$command,
|
|
4
6
|
$inputRule,
|
|
@@ -6,8 +8,7 @@ import {
|
|
|
6
8
|
$markSchema,
|
|
7
9
|
$useKeymap,
|
|
8
10
|
} from '@milkdown/utils'
|
|
9
|
-
|
|
10
|
-
import { markRule } from '@milkdown/prose'
|
|
11
|
+
|
|
11
12
|
import { withMeta } from '../__internal__'
|
|
12
13
|
|
|
13
14
|
/// HTML attributes for the strong mark.
|
|
@@ -23,12 +24,26 @@ export const strongSchema = $markSchema('strong', (ctx) => ({
|
|
|
23
24
|
attrs: {
|
|
24
25
|
marker: {
|
|
25
26
|
default: ctx.get(remarkStringifyOptionsCtx).strong || '*',
|
|
27
|
+
validate: 'string',
|
|
26
28
|
},
|
|
27
29
|
},
|
|
28
30
|
parseDOM: [
|
|
29
|
-
|
|
31
|
+
// This works around a Google Docs misbehavior where
|
|
32
|
+
// pasted content will be inexplicably wrapped in `<b>`
|
|
33
|
+
// tags with a font-weight normal.
|
|
34
|
+
{
|
|
35
|
+
tag: 'b',
|
|
36
|
+
getAttrs: (node: HTMLElement) =>
|
|
37
|
+
node.style.fontWeight != 'normal' && null,
|
|
38
|
+
},
|
|
30
39
|
{ tag: 'strong' },
|
|
31
40
|
{ style: 'font-style', getAttrs: (value) => (value === 'bold') as false },
|
|
41
|
+
{ style: 'font-weight=400', clearMark: (m) => m.type.name == 'strong' },
|
|
42
|
+
{
|
|
43
|
+
style: 'font-weight',
|
|
44
|
+
getAttrs: (value: string) =>
|
|
45
|
+
/^(bold(er)?|[5-9]\d{2,})$/.test(value) && null,
|
|
46
|
+
},
|
|
32
47
|
],
|
|
33
48
|
toDOM: (mark) => ['strong', ctx.get(strongAttr.key)(mark)],
|
|
34
49
|
parseMarkdown: {
|
package/src/node/blockquote.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { $NodeSchema } from '@milkdown/utils'
|
|
2
|
+
|
|
1
3
|
import { commandsCtx } from '@milkdown/core'
|
|
2
4
|
import { wrapIn } from '@milkdown/prose/commands'
|
|
3
5
|
import { wrappingInputRule } from '@milkdown/prose/inputrules'
|
|
4
|
-
import type { $NodeSchema } from '@milkdown/utils'
|
|
5
6
|
import {
|
|
6
7
|
$command,
|
|
7
8
|
$inputRule,
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
$nodeSchema,
|
|
10
11
|
$useKeymap,
|
|
11
12
|
} from '@milkdown/utils'
|
|
13
|
+
|
|
12
14
|
import { withMeta } from '../__internal__'
|
|
13
15
|
|
|
14
16
|
/// HTML attributes for blockquote node.
|
package/src/node/bullet-list.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
$nodeSchema,
|
|
10
10
|
$useKeymap,
|
|
11
11
|
} from '@milkdown/utils'
|
|
12
|
+
|
|
12
13
|
import { withMeta } from '../__internal__'
|
|
13
14
|
|
|
14
15
|
/// HTML attributes for bullet list node.
|
|
@@ -27,6 +28,7 @@ export const bulletListSchema = $nodeSchema('bullet_list', (ctx) => {
|
|
|
27
28
|
attrs: {
|
|
28
29
|
spread: {
|
|
29
30
|
default: false,
|
|
31
|
+
validate: 'boolean',
|
|
30
32
|
},
|
|
31
33
|
},
|
|
32
34
|
parseDOM: [
|
|
@@ -36,7 +38,7 @@ export const bulletListSchema = $nodeSchema('bullet_list', (ctx) => {
|
|
|
36
38
|
if (!(dom instanceof HTMLElement)) throw expectDomTypeError(dom)
|
|
37
39
|
|
|
38
40
|
return {
|
|
39
|
-
spread: dom.dataset.spread,
|
|
41
|
+
spread: dom.dataset.spread === 'true',
|
|
40
42
|
}
|
|
41
43
|
},
|
|
42
44
|
},
|
|
@@ -64,7 +66,7 @@ export const bulletListSchema = $nodeSchema('bullet_list', (ctx) => {
|
|
|
64
66
|
state
|
|
65
67
|
.openNode('list', undefined, {
|
|
66
68
|
ordered: false,
|
|
67
|
-
spread: node.attrs.spread
|
|
69
|
+
spread: node.attrs.spread,
|
|
68
70
|
})
|
|
69
71
|
.next(node.content)
|
|
70
72
|
.closeNode()
|
package/src/node/code-block.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
$nodeSchema,
|
|
10
10
|
$useKeymap,
|
|
11
11
|
} from '@milkdown/utils'
|
|
12
|
+
|
|
12
13
|
import { withMeta } from '../__internal__'
|
|
13
14
|
|
|
14
15
|
/// HTML attributes for code block node.
|
|
@@ -33,6 +34,7 @@ export const codeBlockSchema = $nodeSchema('code_block', (ctx) => {
|
|
|
33
34
|
attrs: {
|
|
34
35
|
language: {
|
|
35
36
|
default: '',
|
|
37
|
+
validate: 'string',
|
|
36
38
|
},
|
|
37
39
|
},
|
|
38
40
|
parseDOM: [
|
package/src/node/doc.ts
CHANGED
package/src/node/hardbreak.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { commandsCtx } from '@milkdown/core'
|
|
2
2
|
import { Selection, TextSelection } from '@milkdown/prose/state'
|
|
3
3
|
import { $command, $nodeAttr, $nodeSchema, $useKeymap } from '@milkdown/utils'
|
|
4
|
+
|
|
4
5
|
import { withMeta } from '../__internal__'
|
|
5
6
|
|
|
6
7
|
/// HTML attributes for the hardbreak node.
|
|
@@ -26,6 +27,7 @@ export const hardbreakSchema = $nodeSchema('hardbreak', (ctx) => ({
|
|
|
26
27
|
attrs: {
|
|
27
28
|
isInline: {
|
|
28
29
|
default: false,
|
|
30
|
+
validate: 'boolean',
|
|
29
31
|
},
|
|
30
32
|
},
|
|
31
33
|
selectable: false,
|
package/src/node/heading.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { Node } from '@milkdown/prose/model'
|
|
2
|
+
|
|
1
3
|
import { commandsCtx, editorViewCtx } from '@milkdown/core'
|
|
2
4
|
import { expectDomTypeError } from '@milkdown/exception'
|
|
3
5
|
import { setBlockType } from '@milkdown/prose/commands'
|
|
4
6
|
import { textblockTypeInputRule } from '@milkdown/prose/inputrules'
|
|
5
|
-
import type { Node } from '@milkdown/prose/model'
|
|
6
7
|
import {
|
|
7
8
|
$command,
|
|
8
9
|
$ctx,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
$nodeSchema,
|
|
12
13
|
$useKeymap,
|
|
13
14
|
} from '@milkdown/utils'
|
|
15
|
+
|
|
14
16
|
import { serializeText, withMeta } from '../__internal__'
|
|
15
17
|
import { paragraphSchema } from './paragraph'
|
|
16
18
|
|
|
@@ -56,9 +58,11 @@ export const headingSchema = $nodeSchema('heading', (ctx) => {
|
|
|
56
58
|
attrs: {
|
|
57
59
|
id: {
|
|
58
60
|
default: '',
|
|
61
|
+
validate: 'string',
|
|
59
62
|
},
|
|
60
63
|
level: {
|
|
61
64
|
default: 1,
|
|
65
|
+
validate: 'number',
|
|
62
66
|
},
|
|
63
67
|
},
|
|
64
68
|
parseDOM: headingIndex.map((x) => ({
|
package/src/node/hr.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { InputRule } from '@milkdown/prose/inputrules'
|
|
2
2
|
import { Selection } from '@milkdown/prose/state'
|
|
3
3
|
import { $command, $inputRule, $nodeAttr, $nodeSchema } from '@milkdown/utils'
|
|
4
|
+
|
|
4
5
|
import { withMeta } from '../__internal__'
|
|
5
6
|
import { paragraphSchema } from './paragraph'
|
|
6
7
|
|
package/src/node/html.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { $nodeAttr, $nodeSchema } from '@milkdown/utils'
|
|
2
|
+
|
|
2
3
|
import { withMeta } from '../__internal__'
|
|
3
4
|
|
|
4
5
|
export const htmlAttr = $nodeAttr('html')
|
|
@@ -16,6 +17,7 @@ export const htmlSchema = $nodeSchema('html', (ctx) => {
|
|
|
16
17
|
attrs: {
|
|
17
18
|
value: {
|
|
18
19
|
default: '',
|
|
20
|
+
validate: 'string',
|
|
19
21
|
},
|
|
20
22
|
},
|
|
21
23
|
toDOM: (node) => {
|
package/src/node/image.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { expectDomTypeError } from '@milkdown/exception'
|
|
|
2
2
|
import { findSelectedNodeOfType } from '@milkdown/prose'
|
|
3
3
|
import { InputRule } from '@milkdown/prose/inputrules'
|
|
4
4
|
import { $command, $inputRule, $nodeAttr, $nodeSchema } from '@milkdown/utils'
|
|
5
|
+
|
|
5
6
|
import { withMeta } from '../__internal__'
|
|
6
7
|
|
|
7
8
|
/// HTML attributes for image node.
|
|
@@ -24,9 +25,9 @@ export const imageSchema = $nodeSchema('image', (ctx) => {
|
|
|
24
25
|
defining: true,
|
|
25
26
|
isolating: true,
|
|
26
27
|
attrs: {
|
|
27
|
-
src: { default: '' },
|
|
28
|
-
alt: { default: '' },
|
|
29
|
-
title: { default: '' },
|
|
28
|
+
src: { default: '', validate: 'string' },
|
|
29
|
+
alt: { default: '', validate: 'string' },
|
|
30
|
+
title: { default: '', validate: 'string' },
|
|
30
31
|
},
|
|
31
32
|
parseDOM: [
|
|
32
33
|
{
|
package/src/node/list-item.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Ctx } from '@milkdown/ctx'
|
|
2
|
+
|
|
1
3
|
import { commandsCtx } from '@milkdown/core'
|
|
2
4
|
import { expectDomTypeError } from '@milkdown/exception'
|
|
3
5
|
import {
|
|
@@ -5,9 +7,9 @@ import {
|
|
|
5
7
|
sinkListItem,
|
|
6
8
|
splitListItem,
|
|
7
9
|
} from '@milkdown/prose/schema-list'
|
|
8
|
-
import { $command, $nodeAttr, $nodeSchema, $useKeymap } from '@milkdown/utils'
|
|
9
10
|
import { type Command, TextSelection } from '@milkdown/prose/state'
|
|
10
|
-
import
|
|
11
|
+
import { $command, $nodeAttr, $nodeSchema, $useKeymap } from '@milkdown/utils'
|
|
12
|
+
|
|
11
13
|
import { withMeta } from '../__internal__'
|
|
12
14
|
|
|
13
15
|
/// HTML attributes for list item node.
|
|
@@ -25,12 +27,15 @@ export const listItemSchema = $nodeSchema('list_item', (ctx) => ({
|
|
|
25
27
|
attrs: {
|
|
26
28
|
label: {
|
|
27
29
|
default: '•',
|
|
30
|
+
validate: 'string',
|
|
28
31
|
},
|
|
29
32
|
listType: {
|
|
30
33
|
default: 'bullet',
|
|
34
|
+
validate: 'string',
|
|
31
35
|
},
|
|
32
36
|
spread: {
|
|
33
|
-
default:
|
|
37
|
+
default: true,
|
|
38
|
+
validate: 'boolean',
|
|
34
39
|
},
|
|
35
40
|
},
|
|
36
41
|
defining: true,
|
|
@@ -43,7 +48,7 @@ export const listItemSchema = $nodeSchema('list_item', (ctx) => ({
|
|
|
43
48
|
return {
|
|
44
49
|
label: dom.dataset.label,
|
|
45
50
|
listType: dom.dataset.listType,
|
|
46
|
-
spread: dom.dataset.spread,
|
|
51
|
+
spread: dom.dataset.spread === 'true',
|
|
47
52
|
}
|
|
48
53
|
},
|
|
49
54
|
},
|
|
@@ -73,7 +78,7 @@ export const listItemSchema = $nodeSchema('list_item', (ctx) => ({
|
|
|
73
78
|
match: (node) => node.type.name === 'list_item',
|
|
74
79
|
runner: (state, node) => {
|
|
75
80
|
state.openNode('listItem', undefined, {
|
|
76
|
-
spread: node.attrs.spread
|
|
81
|
+
spread: node.attrs.spread,
|
|
77
82
|
})
|
|
78
83
|
state.next(node.content)
|
|
79
84
|
state.closeNode()
|
package/src/node/ordered-list.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
$nodeSchema,
|
|
10
10
|
$useKeymap,
|
|
11
11
|
} from '@milkdown/utils'
|
|
12
|
+
|
|
12
13
|
import { withMeta } from '../__internal__'
|
|
13
14
|
|
|
14
15
|
/// HTML attributes for ordered list node.
|
|
@@ -26,9 +27,11 @@ export const orderedListSchema = $nodeSchema('ordered_list', (ctx) => ({
|
|
|
26
27
|
attrs: {
|
|
27
28
|
order: {
|
|
28
29
|
default: 1,
|
|
30
|
+
validate: 'number',
|
|
29
31
|
},
|
|
30
32
|
spread: {
|
|
31
33
|
default: false,
|
|
34
|
+
validate: 'boolean',
|
|
32
35
|
},
|
|
33
36
|
},
|
|
34
37
|
parseDOM: [
|
package/src/node/paragraph.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Ctx } from '@milkdown/ctx'
|
|
2
|
+
|
|
3
|
+
import { commandsCtx, editorViewCtx } from '@milkdown/core'
|
|
2
4
|
import { setBlockType } from '@milkdown/prose/commands'
|
|
3
5
|
import { $command, $nodeAttr, $nodeSchema, $useKeymap } from '@milkdown/utils'
|
|
6
|
+
|
|
4
7
|
import { serializeText, withMeta } from '../__internal__'
|
|
5
8
|
import { remarkPreserveEmptyLinePlugin } from '../plugin/remark-preserve-empty-line'
|
|
6
|
-
import type { Ctx } from '@milkdown/ctx'
|
|
7
9
|
|
|
8
10
|
/// HTML attributes for paragraph node.
|
|
9
11
|
export const paragraphAttr = $nodeAttr('paragraph')
|
|
@@ -32,9 +34,13 @@ export const paragraphSchema = $nodeSchema('paragraph', (ctx) => ({
|
|
|
32
34
|
toMarkdown: {
|
|
33
35
|
match: (node) => node.type.name === 'paragraph',
|
|
34
36
|
runner: (state, node) => {
|
|
37
|
+
const view = ctx.get(editorViewCtx)
|
|
38
|
+
const lastNode = view.state?.doc.lastChild
|
|
39
|
+
|
|
35
40
|
state.openNode('paragraph')
|
|
36
41
|
if (
|
|
37
42
|
(!node.content || node.content.size === 0) &&
|
|
43
|
+
node !== lastNode &&
|
|
38
44
|
shouldPreserveEmptyLine(ctx)
|
|
39
45
|
) {
|
|
40
46
|
state.addNode('html', undefined, '<br />')
|
package/src/node/text.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Plugin, PluginKey } from '@milkdown/prose/state'
|
|
2
2
|
import { AddMarkStep, ReplaceStep } from '@milkdown/prose/transform'
|
|
3
3
|
import { $prose } from '@milkdown/utils'
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import { withMeta } from '../__internal__'
|
|
6
|
+
import { hardbreakSchema } from '../node'
|
|
6
7
|
|
|
7
8
|
/// This plugin is used to clear the marks around the hardbreak node.
|
|
8
9
|
export const hardbreakClearMarkPlugin = $prose((ctx) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Plugin, PluginKey } from '@milkdown/prose/state'
|
|
2
2
|
import { Decoration, DecorationSet } from '@milkdown/prose/view'
|
|
3
3
|
import { $prose } from '@milkdown/utils'
|
|
4
|
+
|
|
4
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).
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { $remark } from '@milkdown/utils'
|
|
2
1
|
import type { Node } from '@milkdown/transformer'
|
|
2
|
+
|
|
3
|
+
import { $remark } from '@milkdown/utils'
|
|
3
4
|
import { visit } from 'unist-util-visit'
|
|
5
|
+
|
|
4
6
|
import { withMeta } from '../__internal__'
|
|
5
7
|
|
|
6
8
|
/// This plugin is used to add inline line break for remark AST.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { $remark } from '@milkdown/utils'
|
|
2
1
|
import type { Node } from '@milkdown/transformer'
|
|
2
|
+
|
|
3
|
+
import { $remark } from '@milkdown/utils'
|
|
3
4
|
import { visit } from 'unist-util-visit'
|
|
5
|
+
|
|
4
6
|
import { withMeta } from '../__internal__'
|
|
5
7
|
|
|
6
8
|
/// This plugin is used to keep the marker (`_` and `*`) of emphasis and strong nodes.
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Node } from '@milkdown/transformer'
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { $remark } from '@milkdown/utils'
|
|
4
|
+
import { visit } from 'unist-util-visit'
|
|
5
|
+
|
|
4
6
|
import { withMeta } from '../__internal__'
|
|
5
7
|
|
|
6
|
-
function
|
|
7
|
-
return visit(ast,
|
|
8
|
+
function visitEmptyLine(ast: Node) {
|
|
9
|
+
return visit(ast, (node: Node & { children?: Node[] }) => {
|
|
8
10
|
if (node.children?.length !== 1) return
|
|
9
11
|
const firstChild = node.children?.[0]
|
|
10
12
|
if (!firstChild || firstChild.type !== 'html') return
|
|
@@ -28,7 +30,7 @@ function visitImage(ast: Node) {
|
|
|
28
30
|
/// This plugin should be used with `linebreakSchema` to work.
|
|
29
31
|
export const remarkPreserveEmptyLinePlugin = $remark(
|
|
30
32
|
'remark-preserve-empty-line',
|
|
31
|
-
() => () =>
|
|
33
|
+
() => () => visitEmptyLine
|
|
32
34
|
)
|
|
33
35
|
|
|
34
36
|
withMeta(remarkPreserveEmptyLinePlugin.plugin, {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Plugin, PluginKey } from '@milkdown/prose/state'
|
|
2
1
|
import type { EditorView } from '@milkdown/prose/view'
|
|
2
|
+
|
|
3
|
+
import { Plugin, PluginKey } from '@milkdown/prose/state'
|
|
3
4
|
import { $prose } from '@milkdown/utils'
|
|
4
|
-
|
|
5
|
+
|
|
5
6
|
import { withMeta } from '../__internal__'
|
|
7
|
+
import { headingIdGenerator, headingSchema } from '../node/heading'
|
|
6
8
|
|
|
7
9
|
/// This plugin is used to sync the heading id when the heading content changes.
|
|
8
10
|
/// It will use the `headingIdGenerator` to generate the id.
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import type { EditorView } from '@milkdown/prose/view'
|
|
2
|
+
|
|
1
3
|
import { Plugin, PluginKey } from '@milkdown/prose/state'
|
|
2
4
|
import { $prose } from '@milkdown/utils'
|
|
3
|
-
import type { EditorView } from '@milkdown/prose/view'
|
|
4
|
-
import { listItemSchema } from '../node/list-item'
|
|
5
5
|
|
|
6
|
-
import { orderedListSchema } from '../node/ordered-list'
|
|
7
|
-
import { bulletListSchema } from '../node'
|
|
8
6
|
import { withMeta } from '../__internal__'
|
|
7
|
+
import { bulletListSchema } from '../node'
|
|
8
|
+
import { listItemSchema } from '../node/list-item'
|
|
9
|
+
import { orderedListSchema } from '../node/ordered-list'
|
|
9
10
|
|
|
10
11
|
/// This plugin is used to keep the label of list item up to date in ordered list.
|
|
11
12
|
export const syncListOrderPlugin = $prose((ctx) => {
|