@milkdown/preset-commonmark 7.1.0 → 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.
Files changed (72) hide show
  1. package/lib/__internal__/index.d.ts +3 -0
  2. package/lib/__internal__/index.d.ts.map +1 -0
  3. package/lib/__internal__/serialize-text.d.ts +4 -0
  4. package/lib/__internal__/serialize-text.d.ts.map +1 -0
  5. package/lib/__internal__/with-meta.d.ts +3 -0
  6. package/lib/__internal__/with-meta.d.ts.map +1 -0
  7. package/lib/index.es.js +1195 -678
  8. package/lib/index.es.js.map +1 -1
  9. package/lib/mark/emphasis.d.ts +1 -1
  10. package/lib/mark/emphasis.d.ts.map +1 -1
  11. package/lib/mark/inline-code.d.ts +1 -1
  12. package/lib/mark/inline-code.d.ts.map +1 -1
  13. package/lib/mark/link.d.ts +1 -1
  14. package/lib/mark/link.d.ts.map +1 -1
  15. package/lib/mark/strong.d.ts +1 -1
  16. package/lib/mark/strong.d.ts.map +1 -1
  17. package/lib/node/blockquote.d.ts.map +1 -1
  18. package/lib/node/bullet-list.d.ts.map +1 -1
  19. package/lib/node/code-block.d.ts.map +1 -1
  20. package/lib/node/doc.d.ts.map +1 -1
  21. package/lib/node/hardbreak.d.ts.map +1 -1
  22. package/lib/node/heading.d.ts.map +1 -1
  23. package/lib/node/hr.d.ts.map +1 -1
  24. package/lib/node/html.d.ts.map +1 -1
  25. package/lib/node/image.d.ts.map +1 -1
  26. package/lib/node/list-item.d.ts.map +1 -1
  27. package/lib/node/ordered-list.d.ts.map +1 -1
  28. package/lib/node/paragraph.d.ts.map +1 -1
  29. package/lib/node/text.d.ts.map +1 -1
  30. package/lib/plugin/hardbreak-clear-mark-plugin.d.ts.map +1 -1
  31. package/lib/plugin/hardbreak-filter-plugin.d.ts.map +1 -1
  32. package/lib/plugin/inline-nodes-cursor-plugin.d.ts.map +1 -1
  33. package/lib/plugin/inline-sync-plugin/config.d.ts.map +1 -1
  34. package/lib/plugin/inline-sync-plugin/inline-sync-plugin.d.ts.map +1 -1
  35. package/lib/plugin/remark-add-order-in-list-plugin.d.ts.map +1 -1
  36. package/lib/plugin/remark-html-transformer.d.ts.map +1 -1
  37. package/lib/plugin/remark-inline-link-plugin.d.ts.map +1 -1
  38. package/lib/plugin/remark-line-break.d.ts.map +1 -1
  39. package/lib/plugin/sync-heading-id-plugin.d.ts.map +1 -1
  40. package/lib/plugin/sync-list-order-plugin.d.ts.map +1 -1
  41. package/package.json +13 -10
  42. package/src/__internal__/index.ts +3 -0
  43. package/src/__internal__/serialize-text.ts +22 -0
  44. package/src/__internal__/with-meta.ts +16 -0
  45. package/src/mark/emphasis.ts +31 -0
  46. package/src/mark/inline-code.ts +31 -0
  47. package/src/mark/link.ts +21 -0
  48. package/src/mark/strong.ts +31 -0
  49. package/src/node/blockquote.ts +36 -0
  50. package/src/node/bullet-list.ts +36 -0
  51. package/src/node/code-block.ts +41 -0
  52. package/src/node/doc.ts +6 -0
  53. package/src/node/hardbreak.ts +32 -0
  54. package/src/node/heading.ts +49 -20
  55. package/src/node/hr.ts +26 -0
  56. package/src/node/html.ts +16 -0
  57. package/src/node/image.ts +31 -0
  58. package/src/node/list-item.ts +41 -0
  59. package/src/node/ordered-list.ts +36 -0
  60. package/src/node/paragraph.ts +31 -16
  61. package/src/node/text.ts +6 -0
  62. package/src/plugin/hardbreak-clear-mark-plugin.ts +7 -1
  63. package/src/plugin/hardbreak-filter-plugin.ts +11 -0
  64. package/src/plugin/inline-nodes-cursor-plugin.ts +6 -0
  65. package/src/plugin/inline-sync-plugin/config.ts +6 -0
  66. package/src/plugin/inline-sync-plugin/inline-sync-plugin.ts +8 -0
  67. package/src/plugin/remark-add-order-in-list-plugin.ts +6 -0
  68. package/src/plugin/remark-html-transformer.ts +6 -0
  69. package/src/plugin/remark-inline-link-plugin.ts +6 -0
  70. package/src/plugin/remark-line-break.ts +6 -0
  71. package/src/plugin/sync-heading-id-plugin.ts +6 -0
  72. package/src/plugin/sync-list-order-plugin.ts +6 -0
@@ -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/hardbreak'
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
+ })
@@ -4,6 +4,7 @@ import type { Node, NodeType } from '@milkdown/prose/model'
4
4
  import type { Transaction } from '@milkdown/prose/state'
5
5
  import { $ctx } from '@milkdown/utils'
6
6
 
7
+ import { withMeta } from '../../__internal__'
7
8
  import { swap } from './utils'
8
9
 
9
10
  /// @internal
@@ -70,3 +71,8 @@ export const defaultConfig: InlineSyncConfig = {
70
71
  ///
71
72
  /// You can find the default config [here](https://github.com/Milkdown/milkdown/blob/main/packages/preset-commonmark/src/plugin/inline-sync-plugin/config.ts).
72
73
  export const inlineSyncConfig = $ctx<InlineSyncConfig, 'inlineSyncConfig'>(defaultConfig, 'inlineSyncConfig')
74
+
75
+ withMeta(inlineSyncConfig, {
76
+ displayName: 'Ctx<inlineSyncConfig>',
77
+ group: 'Prose',
78
+ })
@@ -4,6 +4,7 @@ import { editorViewCtx } from '@milkdown/core'
4
4
  import { Plugin, PluginKey } from '@milkdown/prose/state'
5
5
  import { $prose } from '@milkdown/utils'
6
6
 
7
+ import { withMeta } from '../../__internal__'
7
8
  import { inlineSyncConfig } from './config'
8
9
  import { getContextByState } from './context'
9
10
  import { runReplacer } from './replacer'
@@ -59,8 +60,15 @@ export const inlineSyncPlugin = $prose((ctx: Ctx) => {
59
60
  runReplacer(ctx, inlineSyncPluginKey, state, dispatch, prevNode.attrs)
60
61
  })
61
62
 
63
+ tr.setMeta('addToHistory', false)
64
+
62
65
  return null
63
66
  },
64
67
  },
65
68
  })
66
69
  })
70
+
71
+ withMeta(inlineSyncPlugin, {
72
+ displayName: 'Prose<inlineSyncPlugin>',
73
+ group: 'Prose',
74
+ })
@@ -2,6 +2,7 @@
2
2
  import { $remark } from '@milkdown/utils'
3
3
  import type { Node, Parent } from 'unist'
4
4
  import { visit } from 'unist-util-visit'
5
+ import { withMeta } from '../__internal__'
5
6
 
6
7
  /// This plugin is used to add order in list for remark AST.
7
8
  export const remarkAddOrderInListPlugin = $remark(() => () => (tree: Node) => {
@@ -14,3 +15,8 @@ export const remarkAddOrderInListPlugin = $remark(() => () => (tree: Node) => {
14
15
  }
15
16
  })
16
17
  })
18
+
19
+ withMeta(remarkAddOrderInListPlugin, {
20
+ displayName: 'Remark<remarkAddOrderInListPlugin>',
21
+ group: 'Remark',
22
+ })
@@ -1,6 +1,7 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
2
  import { $remark } from '@milkdown/utils'
3
3
  import type { Literal, Node, Parent } from 'unist'
4
+ import { withMeta } from '../__internal__'
4
5
 
5
6
  const isParent = (node: Node): node is Parent => !!(node as Parent).children
6
7
  const isHTML = (node: Node): node is Literal<string> => node.type === 'html'
@@ -47,3 +48,8 @@ export const remarkHtmlTransformer = $remark(() => () => (tree: Node) => {
47
48
  return [node]
48
49
  })
49
50
  })
51
+
52
+ withMeta(remarkHtmlTransformer, {
53
+ displayName: 'Remark<remarkHtmlTransformer>',
54
+ group: 'Remark',
55
+ })
@@ -1,6 +1,12 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
2
  import { $remark } from '@milkdown/utils'
3
3
  import remarkInlineLinks from 'remark-inline-links'
4
+ import { withMeta } from '../__internal__'
4
5
 
5
6
  /// This plugin wraps [remark-inline-links](https://github.com/remarkjs/remark-inline-links).
6
7
  export const remarkInlineLinkPlugin = $remark(() => remarkInlineLinks)
8
+
9
+ withMeta(remarkInlineLinkPlugin, {
10
+ displayName: 'Remark<remarkInlineLinkPlugin>',
11
+ group: 'Remark',
12
+ })
@@ -2,6 +2,7 @@
2
2
  import { $remark } from '@milkdown/utils'
3
3
  import type { Literal, Node, Parent } from 'unist'
4
4
  import { visit } from 'unist-util-visit'
5
+ import { withMeta } from '../__internal__'
5
6
 
6
7
  /// This plugin is used to add inline line break for remark AST.
7
8
  /// The inline line break should be treated as a `space`.
@@ -42,3 +43,8 @@ export const remarkLineBreak = $remark(() => () => (tree: Node) => {
42
43
  return index + result.length
43
44
  })
44
45
  })
46
+
47
+ withMeta(remarkLineBreak, {
48
+ displayName: 'Remark<remarkLineBreak>',
49
+ group: 'Remark',
50
+ })
@@ -3,6 +3,7 @@ import { Plugin, PluginKey } from '@milkdown/prose/state'
3
3
  import type { EditorView } from '@milkdown/prose/view'
4
4
  import { $prose } from '@milkdown/utils'
5
5
  import { headingIdGenerator, headingSchema } from '../node/heading'
6
+ import { withMeta } from '../__internal__'
6
7
 
7
8
  /// This plugin is used to sync the heading id when the heading content changes.
8
9
  /// It will use the `headingIdGenerator` to generate the id.
@@ -53,3 +54,8 @@ export const syncHeadingIdPlugin = $prose((ctx) => {
53
54
  },
54
55
  })
55
56
  })
57
+
58
+ withMeta(syncHeadingIdPlugin, {
59
+ displayName: 'Prose<syncHeadingIdPlugin>',
60
+ group: 'Prose',
61
+ })
@@ -6,6 +6,7 @@ import { listItemSchema } from '../node/list-item'
6
6
 
7
7
  import { orderedListSchema } from '../node/ordered-list'
8
8
  import { bulletListSchema } from '../node'
9
+ import { withMeta } from '../__internal__'
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(() => {
@@ -82,3 +83,8 @@ export const syncListOrderPlugin = $prose(() => {
82
83
  },
83
84
  })
84
85
  })
86
+
87
+ withMeta(syncListOrderPlugin, {
88
+ displayName: 'Prose<syncListOrderPlugin>',
89
+ group: 'Prose',
90
+ })