@milkdown/preset-commonmark 6.5.2 → 6.5.4

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 (88) hide show
  1. package/lib/index.d.ts +1 -1
  2. package/lib/index.d.ts.map +1 -1
  3. package/lib/index.es.js +228 -219
  4. package/lib/index.es.js.map +1 -1
  5. package/lib/mark/code-inline.d.ts +1 -1
  6. package/lib/mark/code-inline.d.ts.map +1 -1
  7. package/lib/mark/em.d.ts +1 -1
  8. package/lib/mark/em.d.ts.map +1 -1
  9. package/lib/mark/index.d.ts.map +1 -1
  10. package/lib/mark/link.d.ts +4 -3
  11. package/lib/mark/link.d.ts.map +1 -1
  12. package/lib/mark/strong.d.ts +1 -1
  13. package/lib/mark/strong.d.ts.map +1 -1
  14. package/lib/node/blockquote.d.ts +1 -1
  15. package/lib/node/blockquote.d.ts.map +1 -1
  16. package/lib/node/bullet-list.d.ts +1 -1
  17. package/lib/node/bullet-list.d.ts.map +1 -1
  18. package/lib/node/code-fence.d.ts.map +1 -1
  19. package/lib/node/doc.d.ts +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 +2 -2
  23. package/lib/node/heading.d.ts.map +1 -1
  24. package/lib/node/hr.d.ts +1 -1
  25. package/lib/node/hr.d.ts.map +1 -1
  26. package/lib/node/image.d.ts +2 -2
  27. package/lib/node/image.d.ts.map +1 -1
  28. package/lib/node/index.d.ts +1 -1
  29. package/lib/node/index.d.ts.map +1 -1
  30. package/lib/node/list-item.d.ts +2 -2
  31. package/lib/node/list-item.d.ts.map +1 -1
  32. package/lib/node/ordered-list.d.ts +1 -1
  33. package/lib/node/ordered-list.d.ts.map +1 -1
  34. package/lib/node/paragraph.d.ts +1 -1
  35. package/lib/node/paragraph.d.ts.map +1 -1
  36. package/lib/node/text.d.ts +1 -1
  37. package/lib/node/text.d.ts.map +1 -1
  38. package/lib/plugin/add-order-in-list.d.ts +1 -1
  39. package/lib/plugin/add-order-in-list.d.ts.map +1 -1
  40. package/lib/plugin/filter-html.d.ts +1 -1
  41. package/lib/plugin/filter-html.d.ts.map +1 -1
  42. package/lib/plugin/index.d.ts +1 -1
  43. package/lib/plugin/index.d.ts.map +1 -1
  44. package/lib/plugin/inline-nodes-cursor.d.ts.map +1 -1
  45. package/lib/plugin/inline-sync/config.d.ts +8 -8
  46. package/lib/plugin/inline-sync/config.d.ts.map +1 -1
  47. package/lib/plugin/inline-sync/context.d.ts +5 -5
  48. package/lib/plugin/inline-sync/context.d.ts.map +1 -1
  49. package/lib/plugin/inline-sync/index.d.ts +1 -1
  50. package/lib/plugin/inline-sync/index.d.ts.map +1 -1
  51. package/lib/plugin/inline-sync/regexp.d.ts.map +1 -1
  52. package/lib/plugin/inline-sync/replacer.d.ts +3 -3
  53. package/lib/plugin/inline-sync/replacer.d.ts.map +1 -1
  54. package/lib/plugin/inline-sync/utils.d.ts +2 -2
  55. package/lib/plugin/inline-sync/utils.d.ts.map +1 -1
  56. package/lib/supported-keys.d.ts +1 -1
  57. package/lib/supported-keys.d.ts.map +1 -1
  58. package/package.json +22 -17
  59. package/src/index.ts +52 -52
  60. package/src/mark/code-inline.ts +56 -55
  61. package/src/mark/em.ts +36 -36
  62. package/src/mark/index.ts +9 -9
  63. package/src/mark/link.ts +250 -223
  64. package/src/mark/strong.ts +37 -37
  65. package/src/node/blockquote.ts +35 -35
  66. package/src/node/bullet-list.ts +65 -65
  67. package/src/node/code-fence.ts +236 -229
  68. package/src/node/doc.ts +21 -21
  69. package/src/node/hardbreak.ts +108 -107
  70. package/src/node/heading.ts +275 -272
  71. package/src/node/hr.ts +55 -55
  72. package/src/node/image.ts +216 -210
  73. package/src/node/index.ts +38 -38
  74. package/src/node/list-item.ts +139 -140
  75. package/src/node/ordered-list.ts +71 -71
  76. package/src/node/paragraph.ts +55 -53
  77. package/src/node/text.ts +18 -18
  78. package/src/plugin/add-order-in-list.ts +15 -15
  79. package/src/plugin/filter-html.ts +31 -33
  80. package/src/plugin/index.ts +13 -13
  81. package/src/plugin/inline-nodes-cursor.ts +78 -79
  82. package/src/plugin/inline-sync/config.ts +46 -45
  83. package/src/plugin/inline-sync/context.ts +88 -83
  84. package/src/plugin/inline-sync/index.ts +46 -42
  85. package/src/plugin/inline-sync/regexp.ts +2 -2
  86. package/src/plugin/inline-sync/replacer.ts +33 -31
  87. package/src/plugin/inline-sync/utils.ts +53 -55
  88. package/src/supported-keys.ts +22 -21
@@ -1,65 +1,66 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
- import { createCmd, createCmdKey } from '@milkdown/core';
3
- import { MarkType } from '@milkdown/prose/model';
4
- import { createMark, createShortcut } from '@milkdown/utils';
2
+ import { createCmd, createCmdKey } from '@milkdown/core'
3
+ import type { MarkType } from '@milkdown/prose/model'
4
+ import { createMark, createShortcut } from '@milkdown/utils'
5
5
 
6
- import { SupportedKeys } from '../supported-keys';
6
+ import { SupportedKeys } from '../supported-keys'
7
7
 
8
- type Keys = SupportedKeys['CodeInline'];
9
- const id = 'code_inline';
8
+ type Keys = SupportedKeys['CodeInline']
9
+ const id = 'code_inline'
10
10
 
11
- export const ToggleInlineCode = createCmdKey('ToggleInlineCode');
11
+ export const ToggleInlineCode = createCmdKey('ToggleInlineCode')
12
12
 
13
13
  export const codeInline = createMark<Keys>((utils) => {
14
- return {
15
- id,
16
- schema: () => ({
17
- priority: 100,
18
- code: true,
19
- inclusive: false,
20
- parseDOM: [{ tag: 'code' }],
21
- toDOM: (mark) => ['code', { class: utils.getClassName(mark.attrs, 'code-inline') }],
22
- parseMarkdown: {
23
- match: (node) => node.type === 'inlineCode',
24
- runner: (state, node, markType) => {
25
- state.openMark(markType);
26
- state.addText(node['value'] as string);
27
- state.closeMark(markType);
28
- },
29
- },
30
- toMarkdown: {
31
- match: (mark) => mark.type.name === id,
32
- runner: (state, mark, node) => {
33
- state.withMark(mark, 'inlineCode', node.text || '');
34
- },
35
- },
36
- }),
37
- commands: (markType) => [
38
- createCmd(ToggleInlineCode, () => (state, dispatch) => {
39
- const { selection, tr } = state;
40
- if (selection.empty) return false;
41
- const { from, to } = selection;
14
+ return {
15
+ id,
16
+ schema: () => ({
17
+ priority: 100,
18
+ code: true,
19
+ inclusive: false,
20
+ parseDOM: [{ tag: 'code' }],
21
+ toDOM: mark => ['code', { class: utils.getClassName(mark.attrs, 'code-inline') }],
22
+ parseMarkdown: {
23
+ match: node => node.type === 'inlineCode',
24
+ runner: (state, node, markType) => {
25
+ state.openMark(markType)
26
+ state.addText(node.value as string)
27
+ state.closeMark(markType)
28
+ },
29
+ },
30
+ toMarkdown: {
31
+ match: mark => mark.type.name === id,
32
+ runner: (state, mark, node) => {
33
+ state.withMark(mark, 'inlineCode', node.text || '')
34
+ },
35
+ },
36
+ }),
37
+ commands: markType => [
38
+ createCmd(ToggleInlineCode, () => (state, dispatch) => {
39
+ const { selection, tr } = state
40
+ if (selection.empty)
41
+ return false
42
+ const { from, to } = selection
42
43
 
43
- const has = state.doc.rangeHasMark(from, to, markType);
44
- if (has) {
45
- dispatch?.(tr.removeMark(from, to, markType));
46
- return true;
47
- }
44
+ const has = state.doc.rangeHasMark(from, to, markType)
45
+ if (has) {
46
+ dispatch?.(tr.removeMark(from, to, markType))
47
+ return true
48
+ }
48
49
 
49
- const restMarksName = Object.keys(state.schema.marks).filter((x) => x !== markType.name);
50
+ const restMarksName = Object.keys(state.schema.marks).filter(x => x !== markType.name)
50
51
 
51
- restMarksName
52
- .map((name) => state.schema.marks[name] as MarkType)
53
- .forEach((t) => {
54
- tr.removeMark(from, to, t);
55
- });
52
+ restMarksName
53
+ .map(name => state.schema.marks[name] as MarkType)
54
+ .forEach((t) => {
55
+ tr.removeMark(from, to, t)
56
+ })
56
57
 
57
- dispatch?.(tr.addMark(from, to, markType.create()));
58
- return true;
59
- }),
60
- ],
61
- shortcuts: {
62
- [SupportedKeys.CodeInline]: createShortcut(ToggleInlineCode, 'Mod-e'),
63
- },
64
- };
65
- });
58
+ dispatch?.(tr.addMark(from, to, markType.create()))
59
+ return true
60
+ }),
61
+ ],
62
+ shortcuts: {
63
+ [SupportedKeys.CodeInline]: createShortcut(ToggleInlineCode, 'Mod-e'),
64
+ },
65
+ }
66
+ })
package/src/mark/em.ts CHANGED
@@ -1,42 +1,42 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
- import { createCmd, createCmdKey } from '@milkdown/core';
3
- import { toggleMark } from '@milkdown/prose/commands';
4
- import { createMark, createShortcut } from '@milkdown/utils';
2
+ import { createCmd, createCmdKey } from '@milkdown/core'
3
+ import { toggleMark } from '@milkdown/prose/commands'
4
+ import { createMark, createShortcut } from '@milkdown/utils'
5
5
 
6
- import { SupportedKeys } from '../supported-keys';
6
+ import { SupportedKeys } from '../supported-keys'
7
7
 
8
- type Keys = SupportedKeys['Em'];
8
+ type Keys = SupportedKeys['Em']
9
9
 
10
- const id = 'em';
10
+ const id = 'em'
11
11
 
12
- export const ToggleItalic = createCmdKey('ToggleItalic');
13
- export const em = createMark<Keys>((utils) => ({
14
- id,
15
- schema: () => ({
16
- inclusive: false,
17
- parseDOM: [
18
- { tag: 'i' },
19
- { tag: 'em' },
20
- { style: 'font-style', getAttrs: (value) => (value === 'italic') as false },
21
- ],
22
- toDOM: (mark) => ['em', { class: utils.getClassName(mark.attrs, id) }],
23
- parseMarkdown: {
24
- match: (node) => node.type === 'emphasis',
25
- runner: (state, node, markType) => {
26
- state.openMark(markType);
27
- state.next(node.children);
28
- state.closeMark(markType);
29
- },
30
- },
31
- toMarkdown: {
32
- match: (mark) => mark.type.name === id,
33
- runner: (state, mark) => {
34
- state.withMark(mark, 'emphasis');
35
- },
36
- },
37
- }),
38
- commands: (markType) => [createCmd(ToggleItalic, () => toggleMark(markType))],
39
- shortcuts: {
40
- [SupportedKeys.Em]: createShortcut(ToggleItalic, 'Mod-i'),
12
+ export const ToggleItalic = createCmdKey('ToggleItalic')
13
+ export const em = createMark<Keys>(utils => ({
14
+ id,
15
+ schema: () => ({
16
+ inclusive: false,
17
+ parseDOM: [
18
+ { tag: 'i' },
19
+ { tag: 'em' },
20
+ { style: 'font-style', getAttrs: value => (value === 'italic') as false },
21
+ ],
22
+ toDOM: mark => ['em', { class: utils.getClassName(mark.attrs, id) }],
23
+ parseMarkdown: {
24
+ match: node => node.type === 'emphasis',
25
+ runner: (state, node, markType) => {
26
+ state.openMark(markType)
27
+ state.next(node.children)
28
+ state.closeMark(markType)
29
+ },
41
30
  },
42
- }));
31
+ toMarkdown: {
32
+ match: mark => mark.type.name === id,
33
+ runner: (state, mark) => {
34
+ state.withMark(mark, 'emphasis')
35
+ },
36
+ },
37
+ }),
38
+ commands: markType => [createCmd(ToggleItalic, () => toggleMark(markType))],
39
+ shortcuts: {
40
+ [SupportedKeys.Em]: createShortcut(ToggleItalic, 'Mod-i'),
41
+ },
42
+ }))
package/src/mark/index.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
- import { codeInline } from './code-inline';
3
- import { em } from './em';
4
- import { link } from './link';
5
- import { strong } from './strong';
2
+ import { codeInline } from './code-inline'
3
+ import { em } from './em'
4
+ import { link } from './link'
5
+ import { strong } from './strong'
6
6
 
7
- export const marks = [codeInline(), em(), strong(), link()];
7
+ export const marks = [codeInline(), em(), strong(), link()]
8
8
 
9
- export * from './code-inline';
10
- export * from './em';
11
- export * from './link';
12
- export * from './strong';
9
+ export * from './code-inline'
10
+ export * from './em'
11
+ export * from './link'
12
+ export * from './strong'