@milkdown/preset-commonmark 6.1.5 → 6.3.1

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 (58) hide show
  1. package/lib/index.d.ts +2 -6
  2. package/lib/index.d.ts.map +1 -1
  3. package/lib/index.es.js +1013 -1047
  4. package/lib/index.es.js.map +1 -1
  5. package/lib/mark/code-inline.d.ts +1 -5
  6. package/lib/mark/code-inline.d.ts.map +1 -1
  7. package/lib/mark/em.d.ts +1 -5
  8. package/lib/mark/em.d.ts.map +1 -1
  9. package/lib/mark/link.d.ts +1 -5
  10. package/lib/mark/link.d.ts.map +1 -1
  11. package/lib/mark/strong.d.ts +1 -5
  12. package/lib/mark/strong.d.ts.map +1 -1
  13. package/lib/node/blockquote.d.ts +1 -5
  14. package/lib/node/blockquote.d.ts.map +1 -1
  15. package/lib/node/bullet-list.d.ts +1 -5
  16. package/lib/node/bullet-list.d.ts.map +1 -1
  17. package/lib/node/code-fence.d.ts +1 -5
  18. package/lib/node/code-fence.d.ts.map +1 -1
  19. package/lib/node/doc.d.ts +1 -5
  20. package/lib/node/doc.d.ts.map +1 -1
  21. package/lib/node/hardbreak.d.ts +4 -4
  22. package/lib/node/hardbreak.d.ts.map +1 -1
  23. package/lib/node/heading.d.ts +8 -6
  24. package/lib/node/heading.d.ts.map +1 -1
  25. package/lib/node/hr.d.ts +1 -5
  26. package/lib/node/hr.d.ts.map +1 -1
  27. package/lib/node/image.d.ts +1 -5
  28. package/lib/node/image.d.ts.map +1 -1
  29. package/lib/node/index.d.ts +2 -3
  30. package/lib/node/index.d.ts.map +1 -1
  31. package/lib/node/list-item.d.ts +1 -5
  32. package/lib/node/list-item.d.ts.map +1 -1
  33. package/lib/node/ordered-list.d.ts +1 -5
  34. package/lib/node/ordered-list.d.ts.map +1 -1
  35. package/lib/node/paragraph.d.ts +1 -5
  36. package/lib/node/paragraph.d.ts.map +1 -1
  37. package/lib/node/text.d.ts +1 -5
  38. package/lib/node/text.d.ts.map +1 -1
  39. package/lib/plugin/add-order-in-list.d.ts +3 -0
  40. package/lib/plugin/add-order-in-list.d.ts.map +1 -0
  41. package/lib/plugin/index.d.ts.map +1 -1
  42. package/lib/supported-keys.d.ts +1 -0
  43. package/lib/supported-keys.d.ts.map +1 -1
  44. package/package.json +7 -5
  45. package/src/mark/link.ts +55 -9
  46. package/src/node/code-fence.ts +7 -6
  47. package/src/node/hardbreak.ts +46 -3
  48. package/src/node/heading.ts +264 -117
  49. package/src/node/hr.ts +4 -2
  50. package/src/node/image.ts +4 -3
  51. package/src/node/index.ts +3 -1
  52. package/src/node/list-item.ts +93 -3
  53. package/src/node/ordered-list.ts +2 -1
  54. package/src/node/paragraph.ts +12 -2
  55. package/src/plugin/add-order-in-list.ts +19 -0
  56. package/src/plugin/index.ts +2 -1
  57. package/src/plugin/inline-nodes-cursor.ts +1 -1
  58. package/src/supported-keys.ts +1 -0
@@ -1,11 +1,7 @@
1
1
  export declare const backtickInputRegex: RegExp;
2
2
  export declare const tildeInputRegex: RegExp;
3
3
  export declare const TurnIntoCodeFence: import("@milkdown/core").CmdKey<undefined>;
4
- export declare const codeFence: import("@milkdown/utils").WithExtend<"CodeFence", {
4
+ export declare const codeFence: import("@milkdown/utils").NodeCreator<"CodeFence", {
5
5
  languageList?: string[] | undefined;
6
- }, import("@milkdown/prose/model").NodeType<any>, {
7
- id: string;
8
- schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
9
- view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
10
6
  }>;
11
7
  //# sourceMappingURL=code-fence.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-fence.d.ts","sourceRoot":"","sources":["../../src/node/code-fence.ts"],"names":[],"mappings":"AA8BA,eAAO,MAAM,kBAAkB,QAAoC,CAAC;AACpE,eAAO,MAAM,eAAe,QAAoC,CAAC;AAEjE,eAAO,MAAM,iBAAiB,4CAAoC,CAAC;AAGnE,eAAO,MAAM,SAAS;;;;;;EAoMpB,CAAC"}
1
+ {"version":3,"file":"code-fence.d.ts","sourceRoot":"","sources":["../../src/node/code-fence.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,kBAAkB,QAAoC,CAAC;AACpE,eAAO,MAAM,eAAe,QAAoC,CAAC;AAEjE,eAAO,MAAM,iBAAiB,4CAAoC,CAAC;AAGnE,eAAO,MAAM,SAAS;;EAmMpB,CAAC"}
package/lib/node/doc.d.ts CHANGED
@@ -1,6 +1,2 @@
1
- export declare const doc: import("@milkdown/utils").WithExtend<string, import("@milkdown/utils").UnknownRecord, import("@milkdown/prose/model").NodeType<any>, {
2
- id: string;
3
- schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
4
- view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
5
- }>;
1
+ export declare const doc: import("@milkdown/utils").NodeCreator<string, import("@milkdown/utils").UnknownRecord>;
6
2
  //# sourceMappingURL=doc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/node/doc.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG;;;;EAoBd,CAAC"}
1
+ {"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/node/doc.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG,wFAoBd,CAAC"}
@@ -1,7 +1,7 @@
1
+ import { PluginKey } from '@milkdown/prose/state';
1
2
  export declare const InsertHardbreak: import("@milkdown/core").CmdKey<undefined>;
2
- export declare const hardbreak: import("@milkdown/utils").WithExtend<"HardBreak", import("@milkdown/utils").UnknownRecord, import("@milkdown/prose/model").NodeType<any>, {
3
- id: string;
4
- schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
5
- view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
3
+ export declare const HardbreakFilterPluginKey: PluginKey<any>;
4
+ export declare const hardbreak: import("@milkdown/utils").NodeCreator<"HardBreak", {
5
+ notIn: string[];
6
6
  }>;
7
7
  //# sourceMappingURL=hardbreak.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hardbreak.d.ts","sourceRoot":"","sources":["../../src/node/hardbreak.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,eAAe,4CAAkC,CAAC;AAE/D,eAAO,MAAM,SAAS;;;;EAoEpB,CAAC"}
1
+ {"version":3,"file":"hardbreak.d.ts","sourceRoot":"","sources":["../../src/node/hardbreak.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,SAAS,EAAa,MAAM,uBAAuB,CAAC;AAQrE,eAAO,MAAM,eAAe,4CAAkC,CAAC;AAE/D,eAAO,MAAM,wBAAwB,gBAA6C,CAAC;AAEnF,eAAO,MAAM,SAAS;WAGP,MAAM,EAAE;EA0GrB,CAAC"}
@@ -1,12 +1,14 @@
1
+ import { Node } from '@milkdown/prose/model';
1
2
  import { PluginKey } from '@milkdown/prose/state';
2
3
  import { SupportedKeys } from '../supported-keys';
3
- declare type Keys = SupportedKeys['H1'] | SupportedKeys['H2'] | SupportedKeys['H3'] | SupportedKeys['H4'] | SupportedKeys['H5'] | SupportedKeys['H6'];
4
+ declare type Keys = SupportedKeys['H1'] | SupportedKeys['H2'] | SupportedKeys['H3'] | SupportedKeys['H4'] | SupportedKeys['H5'] | SupportedKeys['H6'] | SupportedKeys['DowngradeHeading'];
4
5
  export declare const TurnIntoHeading: import("@milkdown/core").CmdKey<number>;
5
- export declare const headingPluginKey: PluginKey<any, any>;
6
- export declare const heading: import("@milkdown/utils").WithExtend<Keys, import("@milkdown/utils").UnknownRecord, import("@milkdown/prose/model").NodeType<any>, {
7
- id: string;
8
- schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
9
- view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
6
+ export declare const DowngradeHeading: import("@milkdown/core").CmdKey<undefined>;
7
+ export declare const headingIdPluginKey: PluginKey<any>;
8
+ export declare const headingHashPluginKey: PluginKey<any>;
9
+ export declare const heading: import("@milkdown/utils").NodeCreator<Keys, {
10
+ getId: (node: Node) => string;
11
+ displayHashtag: boolean;
10
12
  }>;
11
13
  export {};
12
14
  //# sourceMappingURL=heading.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../src/node/heading.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuB,SAAS,EAAe,MAAM,uBAAuB,CAAC;AAGpF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMlD,aAAK,IAAI,GACH,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,CAAC;AAE1B,eAAO,MAAM,eAAe,yCAA0C,CAAC;AAEvE,eAAO,MAAM,gBAAgB,qBAA+B,CAAC;AAQ7D,eAAO,MAAM,OAAO;;;;EAgIlB,CAAC"}
1
+ {"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../src/node/heading.ts"],"names":[],"mappings":"AAMA,OAAO,EAAY,IAAI,EAAY,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAuB,SAAS,EAAe,MAAM,uBAAuB,CAAC;AAIpF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMlD,aAAK,IAAI,GACH,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,IAAI,CAAC,GACnB,aAAa,CAAC,kBAAkB,CAAC,CAAC;AAExC,eAAO,MAAM,eAAe,yCAA0C,CAAC;AACvE,eAAO,MAAM,gBAAgB,4CAAmC,CAAC;AAEjE,eAAO,MAAM,kBAAkB,gBAAuC,CAAC;AACvE,eAAO,MAAM,oBAAoB,gBAAyC,CAAC;AA6I3E,eAAO,MAAM,OAAO;kBAAoC,IAAI,KAAK,MAAM;oBAAkB,OAAO;EAwI/F,CAAC"}
package/lib/node/hr.d.ts CHANGED
@@ -1,7 +1,3 @@
1
1
  export declare const InsertHr: import("@milkdown/core").CmdKey<string>;
2
- export declare const hr: import("@milkdown/utils").WithExtend<string, import("@milkdown/utils").UnknownRecord, import("@milkdown/prose/model").NodeType<any>, {
3
- id: string;
4
- schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
5
- view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
6
- }>;
2
+ export declare const hr: import("@milkdown/utils").NodeCreator<string, import("@milkdown/utils").UnknownRecord>;
7
3
  //# sourceMappingURL=hr.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hr.d.ts","sourceRoot":"","sources":["../../src/node/hr.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,QAAQ,yCAAmC,CAAC;AACzD,eAAO,MAAM,EAAE;;;;EAkDb,CAAC"}
1
+ {"version":3,"file":"hr.d.ts","sourceRoot":"","sources":["../../src/node/hr.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,QAAQ,yCAAmC,CAAC;AACzD,eAAO,MAAM,EAAE,wFAoDb,CAAC"}
@@ -8,9 +8,5 @@ export declare type ImageOptions = {
8
8
  buttonText?: string;
9
9
  };
10
10
  };
11
- export declare const image: import("@milkdown/utils").WithExtend<string, ImageOptions, import("@milkdown/prose/model").NodeType<any>, {
12
- id: string;
13
- schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
14
- view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
15
- }>;
11
+ export declare const image: import("@milkdown/utils").NodeCreator<string, ImageOptions>;
16
12
  //# sourceMappingURL=image.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/node/image.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,WAAW,yCAAsC,CAAC;AAC/D,eAAO,MAAM,WAAW,yCAAsC,CAAC;AAE/D,oBAAY,YAAY,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE;QACH,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACL,CAAC;AAGF,eAAO,MAAM,KAAK;;;;EAoMhB,CAAC"}
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/node/image.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,WAAW,yCAAsC,CAAC;AAC/D,eAAO,MAAM,WAAW,yCAAsC,CAAC;AAE/D,oBAAY,YAAY,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE;QACH,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACL,CAAC;AAGF,eAAO,MAAM,KAAK,6DAoMhB,CAAC"}
@@ -1,6 +1,5 @@
1
- export declare const nodes: ((import("@milkdown/utils").Metadata<import("@milkdown/utils").GetPlugin<"CodeFence", {
2
- languageList?: string[] | undefined;
3
- }>> & import("@milkdown/core").MilkdownPlugin) | (import("@milkdown/utils").Metadata<import("@milkdown/utils").GetPlugin<string, import("./image").ImageOptions>> & import("@milkdown/core").MilkdownPlugin))[];
1
+ import { AtomPlugin } from '@milkdown/utils';
2
+ export declare const nodes: AtomPlugin[];
4
3
  export * from './blockquote';
5
4
  export * from './bullet-list';
6
5
  export * from './code-fence';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,KAAK;;+MAajB,CAAC;AAEF,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAe7C,eAAO,MAAM,KAAK,EAAE,UAAU,EAa7B,CAAC;AAEF,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,MAAM,CAAC;AACrB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC"}
@@ -3,10 +3,6 @@ declare type Keys = SupportedKeys['SinkListItem'] | SupportedKeys['LiftListItem'
3
3
  export declare const SplitListItem: import("@milkdown/core").CmdKey<undefined>;
4
4
  export declare const SinkListItem: import("@milkdown/core").CmdKey<undefined>;
5
5
  export declare const LiftListItem: import("@milkdown/core").CmdKey<undefined>;
6
- export declare const listItem: import("@milkdown/utils").WithExtend<Keys, import("@milkdown/utils").UnknownRecord, import("@milkdown/prose/model").NodeType<any>, {
7
- id: string;
8
- schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
9
- view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
10
- }>;
6
+ export declare const listItem: import("@milkdown/utils").NodeCreator<Keys, import("@milkdown/utils").UnknownRecord>;
11
7
  export {};
12
8
  //# sourceMappingURL=list-item.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list-item.d.ts","sourceRoot":"","sources":["../../src/node/list-item.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,aAAK,IAAI,GAAG,aAAa,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;AAI1G,eAAO,MAAM,aAAa,4CAAgC,CAAC;AAC3D,eAAO,MAAM,YAAY,4CAA+B,CAAC;AACzD,eAAO,MAAM,YAAY,4CAA+B,CAAC;AAEzD,eAAO,MAAM,QAAQ;;;;EAoClB,CAAC"}
1
+ {"version":3,"file":"list-item.d.ts","sourceRoot":"","sources":["../../src/node/list-item.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,aAAK,IAAI,GAAG,aAAa,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;AAI1G,eAAO,MAAM,aAAa,4CAAgC,CAAC;AAC3D,eAAO,MAAM,YAAY,4CAA+B,CAAC;AACzD,eAAO,MAAM,YAAY,4CAA+B,CAAC;AAmDzD,eAAO,MAAM,QAAQ,sFAyElB,CAAC"}
@@ -1,7 +1,3 @@
1
1
  export declare const WrapInOrderedList: import("@milkdown/core").CmdKey<undefined>;
2
- export declare const orderedList: import("@milkdown/utils").WithExtend<"OrderedList", import("@milkdown/utils").UnknownRecord, import("@milkdown/prose/model").NodeType<any>, {
3
- id: string;
4
- schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
5
- view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
6
- }>;
2
+ export declare const orderedList: import("@milkdown/utils").NodeCreator<"OrderedList", import("@milkdown/utils").UnknownRecord>;
7
3
  //# sourceMappingURL=ordered-list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ordered-list.d.ts","sourceRoot":"","sources":["../../src/node/ordered-list.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,iBAAiB,4CAAoC,CAAC;AAGnE,eAAO,MAAM,WAAW;;;;EAwDrB,CAAC"}
1
+ {"version":3,"file":"ordered-list.d.ts","sourceRoot":"","sources":["../../src/node/ordered-list.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,iBAAiB,4CAAoC,CAAC;AAGnE,eAAO,MAAM,WAAW,+FAwDrB,CAAC"}
@@ -1,7 +1,3 @@
1
1
  export declare const TurnIntoText: import("@milkdown/core").CmdKey<undefined>;
2
- export declare const paragraph: import("@milkdown/utils").WithExtend<"Text", import("@milkdown/utils").UnknownRecord, import("@milkdown/prose/model").NodeType<any>, {
3
- id: string;
4
- schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
5
- view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
6
- }>;
2
+ export declare const paragraph: import("@milkdown/utils").NodeCreator<"Text", import("@milkdown/utils").UnknownRecord>;
7
3
  //# sourceMappingURL=paragraph.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../src/node/paragraph.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,YAAY,4CAA+B,CAAC;AAGzD,eAAO,MAAM,SAAS;;;;EAqCpB,CAAC"}
1
+ {"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../src/node/paragraph.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,4CAA+B,CAAC;AAGzD,eAAO,MAAM,SAAS,wFA8CpB,CAAC"}
@@ -1,6 +1,2 @@
1
- export declare const text: import("@milkdown/utils").WithExtend<string, import("@milkdown/utils").UnknownRecord, import("@milkdown/prose/model").NodeType<any>, {
2
- id: string;
3
- schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
4
- view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
5
- }>;
1
+ export declare const text: import("@milkdown/utils").NodeCreator<string, import("@milkdown/utils").UnknownRecord>;
6
2
  //# sourceMappingURL=text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/node/text.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI;;;;EAiBd,CAAC"}
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/node/text.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI,wFAiBd,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Node } from 'unist';
2
+ export declare const addOrderInList: () => (ast: Node) => void;
3
+ //# sourceMappingURL=add-order-in-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-order-in-list.d.ts","sourceRoot":"","sources":["../../src/plugin/add-order-in-list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAG7B,eAAO,MAAM,cAAc,cACG,IAAI,SAajC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,wKAK7B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iBAAiB,wKAK7B,CAAC"}
@@ -10,6 +10,7 @@ export declare const SupportedKeys: {
10
10
  readonly H4: "H4";
11
11
  readonly H5: "H5";
12
12
  readonly H6: "H6";
13
+ readonly DowngradeHeading: "DowngradeHeading";
13
14
  readonly Text: "Text";
14
15
  readonly CodeInline: "CodeInline";
15
16
  readonly Em: "Em";
@@ -1 +1 @@
1
- {"version":3,"file":"supported-keys.d.ts","sourceRoot":"","sources":["../src/supported-keys.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;CAmBhB,CAAC;AAEX,oBAAY,aAAa,GAAG,OAAO,aAAa,CAAC"}
1
+ {"version":3,"file":"supported-keys.d.ts","sourceRoot":"","sources":["../src/supported-keys.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;CAoBhB,CAAC;AAEX,oBAAY,aAAa,GAAG,OAAO,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milkdown/preset-commonmark",
3
- "version": "6.1.5",
3
+ "version": "6.3.1",
4
4
  "type": "module",
5
5
  "main": "./lib/index.es.js",
6
6
  "types": "./lib/index.d.ts",
@@ -17,8 +17,8 @@
17
17
  "commonmark"
18
18
  ],
19
19
  "devDependencies": {
20
- "@milkdown/core": "6.1.5",
21
- "@milkdown/prose": "6.1.5",
20
+ "@milkdown/core": "6.3.1",
21
+ "@milkdown/prose": "6.3.1",
22
22
  "@types/unist": "^2.0.6"
23
23
  },
24
24
  "peerDependencies": {
@@ -26,9 +26,11 @@
26
26
  "@milkdown/prose": "^6.0.1"
27
27
  },
28
28
  "dependencies": {
29
- "@milkdown/utils": "6.1.5",
29
+ "@milkdown/utils": "6.3.1",
30
+ "@milkdown/exception": "6.3.1",
31
+ "unist-util-visit": "^4.0.0",
30
32
  "remark-inline-links": "^6.0.0",
31
- "tslib": "^2.3.1"
33
+ "tslib": "^2.4.0"
32
34
  },
33
35
  "nx": {
34
36
  "targets": {
package/src/mark/link.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
2
  import { commandsCtx, createCmd, createCmdKey, schemaCtx, ThemeInputChipType } from '@milkdown/core';
3
+ import { expectDomTypeError, missingRootElement } from '@milkdown/exception';
4
+ import { calculateTextPosition } from '@milkdown/prose';
3
5
  import { toggleMark } from '@milkdown/prose/commands';
4
6
  import { InputRule } from '@milkdown/prose/inputrules';
5
7
  import { Node as ProseNode } from '@milkdown/prose/model';
6
- import { Plugin, PluginKey, TextSelection } from '@milkdown/prose/state';
8
+ import { NodeSelection, Plugin, PluginKey, TextSelection } from '@milkdown/prose/state';
7
9
  import { EditorView } from '@milkdown/prose/view';
8
10
  import { createMark } from '@milkdown/utils';
9
11
 
@@ -32,7 +34,7 @@ export const link = createMark<string, LinkOptions>((utils, options) => {
32
34
  tag: 'a[href]',
33
35
  getAttrs: (dom) => {
34
36
  if (!(dom instanceof HTMLElement)) {
35
- throw new Error();
37
+ throw expectDomTypeError(dom);
36
38
  }
37
39
  return { href: dom.getAttribute('href'), title: dom.getAttribute('title') };
38
40
  },
@@ -69,8 +71,9 @@ export const link = createMark<string, LinkOptions>((utils, options) => {
69
71
  let node: ProseNode | undefined;
70
72
  let pos = -1;
71
73
  const { selection } = state;
72
- state.doc.nodesBetween(selection.from, selection.to, (n, p) => {
73
- if (marks.link.isInSet(n.marks)) {
74
+ const { from, to } = selection;
75
+ state.doc.nodesBetween(from, from === to ? to + 1 : to, (n, p) => {
76
+ if (marks['link']?.isInSet(n.marks)) {
74
77
  node = n;
75
78
  pos = p;
76
79
  return false;
@@ -85,7 +88,8 @@ export const link = createMark<string, LinkOptions>((utils, options) => {
85
88
  const start = pos;
86
89
  const end = pos + node.nodeSize;
87
90
  const { tr } = state;
88
- const linkMark = marks.link.create({ ...mark.attrs, href });
91
+ const linkMark = marks['link']?.create({ ...mark.attrs, href });
92
+ if (!linkMark) return false;
89
93
  dispatch(
90
94
  tr
91
95
  .removeMark(start, end, mark)
@@ -114,6 +118,7 @@ export const link = createMark<string, LinkOptions>((utils, options) => {
114
118
  }),
115
119
  ],
116
120
  prosePlugins: (type, ctx) => {
121
+ let renderOnTop = false;
117
122
  return [
118
123
  new Plugin({
119
124
  key,
@@ -124,20 +129,59 @@ export const link = createMark<string, LinkOptions>((utils, options) => {
124
129
  onUpdate: (value) => {
125
130
  ctx.get(commandsCtx).call(ModifyLink, value);
126
131
  },
132
+ calculatePosition: (view, input) => {
133
+ calculateTextPosition(view, input, (start, end, target, parent) => {
134
+ const $editor = view.dom.parentElement;
135
+ if (!$editor) {
136
+ throw missingRootElement();
137
+ }
138
+
139
+ const selectionWidth = end.left - start.left;
140
+ let left = start.left - parent.left - (target.width - selectionWidth) / 2;
141
+ let top = start.bottom - parent.top + 14 + $editor.scrollTop;
142
+
143
+ if (renderOnTop) {
144
+ top = start.top - parent.top - target.height - 14 + $editor.scrollTop;
145
+ }
146
+
147
+ if (left < 0) left = 0;
148
+
149
+ return [top, left];
150
+ });
151
+ },
127
152
  });
128
153
  if (!inputChipRenderer) return {};
129
154
  const shouldDisplay = (view: EditorView) => {
130
155
  const { selection, doc } = view.state;
131
156
  const { from, to } = selection;
132
157
 
133
- return (
134
- view.hasFocus() &&
158
+ if (!view.hasFocus()) {
159
+ return false;
160
+ }
161
+
162
+ if (
135
163
  selection.empty &&
136
164
  selection instanceof TextSelection &&
137
165
  to < doc.content.size &&
138
166
  from < doc.content.size &&
139
167
  doc.rangeHasMark(from, from === to ? to + 1 : to, type)
140
- );
168
+ ) {
169
+ renderOnTop = false;
170
+ return true;
171
+ }
172
+
173
+ if (selection instanceof NodeSelection) {
174
+ const { node } = selection;
175
+ if (
176
+ node.type.name === 'image' &&
177
+ node.marks.findIndex((mark) => mark.type.name === id) > -1
178
+ ) {
179
+ renderOnTop = true;
180
+ return true;
181
+ }
182
+ }
183
+
184
+ return false;
141
185
  };
142
186
  const getCurrentLink = (view: EditorView) => {
143
187
  const { selection } = view.state;
@@ -179,7 +223,9 @@ export const link = createMark<string, LinkOptions>((utils, options) => {
179
223
  prevState?.doc.eq(view.state.doc) && prevState.selection.eq(view.state.selection);
180
224
  if (isEqualSelection) return;
181
225
 
182
- renderByView(view);
226
+ requestAnimationFrame(() => {
227
+ renderByView(view);
228
+ });
183
229
  },
184
230
  destroy: () => {
185
231
  inputChipRenderer.destroy();
@@ -1,8 +1,10 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
2
  import { createCmd, createCmdKey, editorViewCtx, ThemeCodeFenceType } from '@milkdown/core';
3
+ import { expectDomTypeError } from '@milkdown/exception';
3
4
  import { setBlockType } from '@milkdown/prose/commands';
4
5
  import { textblockTypeInputRule } from '@milkdown/prose/inputrules';
5
6
  import { Fragment } from '@milkdown/prose/model';
7
+ import { NodeView } from '@milkdown/prose/view';
6
8
  import { createNode, createShortcut } from '@milkdown/utils';
7
9
 
8
10
  import { SupportedKeys } from '../supported-keys';
@@ -59,17 +61,16 @@ export const codeFence = createNode<Keys, { languageList?: string[] }>((utils, o
59
61
  preserveWhitespace: 'full',
60
62
  getAttrs: (dom) => {
61
63
  if (!(dom instanceof HTMLElement)) {
62
- throw new Error('Parse DOM error.');
64
+ throw expectDomTypeError(dom);
63
65
  }
64
66
  return { language: dom.querySelector('pre')?.dataset['language'] };
65
67
  },
66
68
  getContent: (dom, schema) => {
67
69
  if (!(dom instanceof HTMLElement)) {
68
- throw new Error('Parse DOM error.');
70
+ throw expectDomTypeError(dom);
69
71
  }
70
72
  const textNode = schema.text(dom.querySelector('pre')?.textContent ?? '');
71
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
- return Fragment.from<any>(textNode);
73
+ return Fragment.from(textNode);
73
74
  },
74
75
  },
75
76
  {
@@ -77,7 +78,7 @@ export const codeFence = createNode<Keys, { languageList?: string[] }>((utils, o
77
78
  preserveWhitespace: 'full',
78
79
  getAttrs: (dom) => {
79
80
  if (!(dom instanceof HTMLElement)) {
80
- throw new Error('Parse DOM error.');
81
+ throw expectDomTypeError(dom);
81
82
  }
82
83
  return { language: dom.dataset['language'] };
83
84
  },
@@ -211,7 +212,7 @@ export const codeFence = createNode<Keys, { languageList?: string[] }>((utils, o
211
212
  editable: () => view.editable,
212
213
  languageList,
213
214
  });
214
- if (!renderer) return {};
215
+ if (!renderer) return {} as NodeView;
215
216
 
216
217
  const { dom, contentDOM, onUpdate, onDestroy } = renderer;
217
218
  onUpdate(currNode);
@@ -1,6 +1,6 @@
1
1
  /* Copyright 2021, Milkdown by Mirone. */
2
2
  import { createCmd, createCmdKey } from '@milkdown/core';
3
- import { Plugin, PluginKey } from '@milkdown/prose/state';
3
+ import { Plugin, PluginKey, Selection } from '@milkdown/prose/state';
4
4
  import { AddMarkStep, ReplaceStep } from '@milkdown/prose/transform';
5
5
  import { createNode, createShortcut } from '@milkdown/utils';
6
6
 
@@ -10,7 +10,15 @@ type Keys = SupportedKeys['HardBreak'];
10
10
 
11
11
  export const InsertHardbreak = createCmdKey('InsertHardbreak');
12
12
 
13
- export const hardbreak = createNode<Keys>((utils) => {
13
+ export const HardbreakFilterPluginKey = new PluginKey('MILKDOWN_HARDBREAK_FILTER');
14
+
15
+ export const hardbreak = createNode<
16
+ Keys,
17
+ {
18
+ notIn: string[];
19
+ }
20
+ >((utils, options) => {
21
+ const notIn = options?.notIn ?? ['table', 'fence'];
14
22
  return {
15
23
  id: 'hardbreak',
16
24
  schema: () => ({
@@ -34,7 +42,21 @@ export const hardbreak = createNode<Keys>((utils) => {
34
42
  }),
35
43
  commands: (type) => [
36
44
  createCmd(InsertHardbreak, () => (state, dispatch) => {
37
- dispatch?.(state.tr.setMeta('hardbreak', true).replaceSelectionWith(type.create()).scrollIntoView());
45
+ const { selection, tr } = state;
46
+ if (selection.empty) {
47
+ // Transform two successive hardbreak into a new line
48
+ const node = selection.$from.node();
49
+ if (node.childCount > 0 && node.lastChild?.type.name === 'hardbreak') {
50
+ dispatch?.(
51
+ tr
52
+ .replaceRangeWith(selection.to - 1, selection.to, state.schema.node('paragraph'))
53
+ .setSelection(Selection.near(tr.doc.resolve(selection.to)))
54
+ .scrollIntoView(),
55
+ );
56
+ return true;
57
+ }
58
+ }
59
+ dispatch?.(tr.setMeta('hardbreak', true).replaceSelectionWith(type.create()).scrollIntoView());
38
60
  return true;
39
61
  }),
40
62
  ],
@@ -42,6 +64,27 @@ export const hardbreak = createNode<Keys>((utils) => {
42
64
  [SupportedKeys.HardBreak]: createShortcut(InsertHardbreak, 'Shift-Enter'),
43
65
  },
44
66
  prosePlugins: (type) => [
67
+ new Plugin({
68
+ key: HardbreakFilterPluginKey,
69
+ filterTransaction: (tr, state) => {
70
+ const isInsertHr = tr.getMeta('hardbreak');
71
+ const [step] = tr.steps;
72
+ if (isInsertHr && step) {
73
+ const { from } = step as unknown as { from: number };
74
+ const $from = state.doc.resolve(from);
75
+ let curDepth = $from.depth;
76
+ let canApply = true;
77
+ while (curDepth > 0) {
78
+ if (notIn.includes($from.node(curDepth).type.name)) {
79
+ canApply = false;
80
+ }
81
+ curDepth--;
82
+ }
83
+ return canApply;
84
+ }
85
+ return true;
86
+ },
87
+ }),
45
88
  new Plugin({
46
89
  key: new PluginKey('MILKDOWN_HARDBREAK_MARKS'),
47
90
  appendTransaction: (trs, _oldState, newState) => {