@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.
- package/lib/index.d.ts +2 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.es.js +1013 -1047
- package/lib/index.es.js.map +1 -1
- package/lib/mark/code-inline.d.ts +1 -5
- package/lib/mark/code-inline.d.ts.map +1 -1
- package/lib/mark/em.d.ts +1 -5
- package/lib/mark/em.d.ts.map +1 -1
- package/lib/mark/link.d.ts +1 -5
- package/lib/mark/link.d.ts.map +1 -1
- package/lib/mark/strong.d.ts +1 -5
- package/lib/mark/strong.d.ts.map +1 -1
- package/lib/node/blockquote.d.ts +1 -5
- package/lib/node/blockquote.d.ts.map +1 -1
- package/lib/node/bullet-list.d.ts +1 -5
- package/lib/node/bullet-list.d.ts.map +1 -1
- package/lib/node/code-fence.d.ts +1 -5
- package/lib/node/code-fence.d.ts.map +1 -1
- package/lib/node/doc.d.ts +1 -5
- package/lib/node/doc.d.ts.map +1 -1
- package/lib/node/hardbreak.d.ts +4 -4
- package/lib/node/hardbreak.d.ts.map +1 -1
- package/lib/node/heading.d.ts +8 -6
- package/lib/node/heading.d.ts.map +1 -1
- package/lib/node/hr.d.ts +1 -5
- package/lib/node/hr.d.ts.map +1 -1
- package/lib/node/image.d.ts +1 -5
- package/lib/node/image.d.ts.map +1 -1
- package/lib/node/index.d.ts +2 -3
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/list-item.d.ts +1 -5
- package/lib/node/list-item.d.ts.map +1 -1
- package/lib/node/ordered-list.d.ts +1 -5
- package/lib/node/ordered-list.d.ts.map +1 -1
- package/lib/node/paragraph.d.ts +1 -5
- package/lib/node/paragraph.d.ts.map +1 -1
- package/lib/node/text.d.ts +1 -5
- package/lib/node/text.d.ts.map +1 -1
- package/lib/plugin/add-order-in-list.d.ts +3 -0
- package/lib/plugin/add-order-in-list.d.ts.map +1 -0
- package/lib/plugin/index.d.ts.map +1 -1
- package/lib/supported-keys.d.ts +1 -0
- package/lib/supported-keys.d.ts.map +1 -1
- package/package.json +7 -5
- package/src/mark/link.ts +55 -9
- package/src/node/code-fence.ts +7 -6
- package/src/node/hardbreak.ts +46 -3
- package/src/node/heading.ts +264 -117
- package/src/node/hr.ts +4 -2
- package/src/node/image.ts +4 -3
- package/src/node/index.ts +3 -1
- package/src/node/list-item.ts +93 -3
- package/src/node/ordered-list.ts +2 -1
- package/src/node/paragraph.ts +12 -2
- package/src/plugin/add-order-in-list.ts +19 -0
- package/src/plugin/index.ts +2 -1
- package/src/plugin/inline-nodes-cursor.ts +1 -1
- package/src/supported-keys.ts +1 -0
package/lib/node/code-fence.d.ts
CHANGED
|
@@ -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").
|
|
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":"
|
|
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").
|
|
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
|
package/lib/node/doc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/node/doc.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG
|
|
1
|
+
{"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/node/doc.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,GAAG,wFAoBd,CAAC"}
|
package/lib/node/hardbreak.d.ts
CHANGED
|
@@ -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
|
|
3
|
-
|
|
4
|
-
|
|
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":"
|
|
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"}
|
package/lib/node/heading.d.ts
CHANGED
|
@@ -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
|
|
6
|
-
export declare const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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":"
|
|
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").
|
|
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
|
package/lib/node/hr.d.ts.map
CHANGED
|
@@ -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
|
|
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"}
|
package/lib/node/image.d.ts
CHANGED
|
@@ -8,9 +8,5 @@ export declare type ImageOptions = {
|
|
|
8
8
|
buttonText?: string;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
export declare const image: import("@milkdown/utils").
|
|
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
|
package/lib/node/image.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/node/image.ts"],"names":[],"mappings":"
|
|
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"}
|
package/lib/node/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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';
|
package/lib/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"
|
|
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"}
|
package/lib/node/list-item.d.ts
CHANGED
|
@@ -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").
|
|
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":"
|
|
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").
|
|
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":"
|
|
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"}
|
package/lib/node/paragraph.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
export declare const TurnIntoText: import("@milkdown/core").CmdKey<undefined>;
|
|
2
|
-
export declare const paragraph: import("@milkdown/utils").
|
|
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":"
|
|
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"}
|
package/lib/node/text.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
export declare const text: import("@milkdown/utils").
|
|
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
|
package/lib/node/text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/node/text.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/node/text.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI,wFAiBd,CAAC"}
|
|
@@ -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":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iBAAiB,wKAK7B,CAAC"}
|
package/lib/supported-keys.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supported-keys.d.ts","sourceRoot":"","sources":["../src/supported-keys.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa
|
|
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
|
|
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
|
|
21
|
-
"@milkdown/prose": "6.1
|
|
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
|
|
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.
|
|
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
|
|
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
|
-
|
|
73
|
-
|
|
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
|
|
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
|
-
|
|
134
|
-
|
|
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
|
-
|
|
226
|
+
requestAnimationFrame(() => {
|
|
227
|
+
renderByView(view);
|
|
228
|
+
});
|
|
183
229
|
},
|
|
184
230
|
destroy: () => {
|
|
185
231
|
inputChipRenderer.destroy();
|
package/src/node/code-fence.ts
CHANGED
|
@@ -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
|
|
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
|
|
70
|
+
throw expectDomTypeError(dom);
|
|
69
71
|
}
|
|
70
72
|
const textNode = schema.text(dom.querySelector('pre')?.textContent ?? '');
|
|
71
|
-
|
|
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
|
|
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);
|
package/src/node/hardbreak.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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) => {
|