@milkdown/preset-commonmark 6.1.3 → 6.2.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/index.d.ts +2 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.es.js +106 -20
- 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/index.d.ts +1 -1
- package/lib/mark/index.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 +1 -5
- package/lib/node/hardbreak.d.ts.map +1 -1
- package/lib/node/heading.d.ts +4 -5
- 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/index.d.ts +1 -1
- package/lib/plugin/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/mark/link.ts +53 -8
- package/src/node/code-fence.ts +3 -3
- package/src/node/hardbreak.ts +16 -2
- package/src/node/heading.ts +42 -11
- package/src/node/hr.ts +4 -2
- package/src/node/image.ts +2 -2
- package/src/node/index.ts +3 -1
- package/src/node/paragraph.ts +12 -2
- package/src/plugin/inline-nodes-cursor.ts +1 -1
|
@@ -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":"AA+BA,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,3 @@
|
|
|
1
1
|
export declare const InsertHardbreak: import("@milkdown/core").CmdKey<undefined>;
|
|
2
|
-
export declare const hardbreak: 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 hardbreak: import("@milkdown/utils").NodeCreator<"HardBreak", import("@milkdown/utils").UnknownRecord>;
|
|
7
3
|
//# 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
|
|
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,6FAkFpB,CAAC"}
|
package/lib/node/heading.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { Node } from '@milkdown/prose/model';
|
|
1
2
|
import { PluginKey } from '@milkdown/prose/state';
|
|
2
3
|
import { SupportedKeys } from '../supported-keys';
|
|
3
4
|
declare type Keys = SupportedKeys['H1'] | SupportedKeys['H2'] | SupportedKeys['H3'] | SupportedKeys['H4'] | SupportedKeys['H5'] | SupportedKeys['H6'];
|
|
4
5
|
export declare const TurnIntoHeading: import("@milkdown/core").CmdKey<number>;
|
|
5
|
-
export declare const headingPluginKey: PluginKey<any
|
|
6
|
-
export declare const heading: import("@milkdown/utils
|
|
7
|
-
|
|
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 headingPluginKey: PluginKey<any>;
|
|
7
|
+
export declare const heading: import("@milkdown/utils").NodeCreator<Keys, {
|
|
8
|
+
getId: (node: Node) => string;
|
|
10
9
|
}>;
|
|
11
10
|
export {};
|
|
12
11
|
//# 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":"AAIA,OAAO,EAAY,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACvD,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,gBAA+B,CAAC;AAS7D,eAAO,MAAM,OAAO;kBAAoC,IAAI,KAAK,MAAM;EA8JrE,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":"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
|
|
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,6DAoMhB,CAAC"}
|
package/lib/node/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}>> & import("@milkdown/core").MilkdownPlugin) | (import("@milkdown/utils/lib/types").Metadata<import("@milkdown/utils/lib/types").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":"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
|
|
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,sFAoClB,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":"AAUA,eAAO,MAAM,iBAAiB,4CAAoC,CAAC;AAGnE,eAAO,MAAM,WAAW
|
|
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,+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"}
|
package/lib/plugin/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const commonmarkPlugins: (import("@milkdown/utils
|
|
1
|
+
export declare const commonmarkPlugins: (import("@milkdown/utils").Metadata<import("@milkdown/utils").GetPlugin<string, import("@milkdown/utils").UnknownRecord>> & import("@milkdown/core").MilkdownPlugin)[];
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,wKAK7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/preset-commonmark",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
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.
|
|
21
|
-
"@milkdown/prose": "6.
|
|
20
|
+
"@milkdown/core": "6.2.0",
|
|
21
|
+
"@milkdown/prose": "6.2.0",
|
|
22
22
|
"@types/unist": "^2.0.6"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@milkdown/prose": "^6.0.1"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@milkdown/utils": "6.
|
|
29
|
+
"@milkdown/utils": "6.2.0",
|
|
30
30
|
"remark-inline-links": "^6.0.0",
|
|
31
31
|
"tslib": "^2.3.1"
|
|
32
32
|
},
|
package/src/mark/link.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
2
|
import { commandsCtx, createCmd, createCmdKey, schemaCtx, ThemeInputChipType } from '@milkdown/core';
|
|
3
|
+
import { calculateTextPosition } from '@milkdown/prose';
|
|
3
4
|
import { toggleMark } from '@milkdown/prose/commands';
|
|
4
5
|
import { InputRule } from '@milkdown/prose/inputrules';
|
|
5
6
|
import { Node as ProseNode } from '@milkdown/prose/model';
|
|
6
|
-
import { Plugin, PluginKey, TextSelection } from '@milkdown/prose/state';
|
|
7
|
+
import { NodeSelection, Plugin, PluginKey, TextSelection } from '@milkdown/prose/state';
|
|
7
8
|
import { EditorView } from '@milkdown/prose/view';
|
|
8
9
|
import { createMark } from '@milkdown/utils';
|
|
9
10
|
|
|
@@ -69,8 +70,9 @@ export const link = createMark<string, LinkOptions>((utils, options) => {
|
|
|
69
70
|
let node: ProseNode | undefined;
|
|
70
71
|
let pos = -1;
|
|
71
72
|
const { selection } = state;
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
const { from, to } = selection;
|
|
74
|
+
state.doc.nodesBetween(from, from === to ? to + 1 : to, (n, p) => {
|
|
75
|
+
if (marks['link']?.isInSet(n.marks)) {
|
|
74
76
|
node = n;
|
|
75
77
|
pos = p;
|
|
76
78
|
return false;
|
|
@@ -85,7 +87,8 @@ export const link = createMark<string, LinkOptions>((utils, options) => {
|
|
|
85
87
|
const start = pos;
|
|
86
88
|
const end = pos + node.nodeSize;
|
|
87
89
|
const { tr } = state;
|
|
88
|
-
const linkMark = marks
|
|
90
|
+
const linkMark = marks['link']?.create({ ...mark.attrs, href });
|
|
91
|
+
if (!linkMark) return false;
|
|
89
92
|
dispatch(
|
|
90
93
|
tr
|
|
91
94
|
.removeMark(start, end, mark)
|
|
@@ -114,6 +117,7 @@ export const link = createMark<string, LinkOptions>((utils, options) => {
|
|
|
114
117
|
}),
|
|
115
118
|
],
|
|
116
119
|
prosePlugins: (type, ctx) => {
|
|
120
|
+
let renderOnTop = false;
|
|
117
121
|
return [
|
|
118
122
|
new Plugin({
|
|
119
123
|
key,
|
|
@@ -124,20 +128,59 @@ export const link = createMark<string, LinkOptions>((utils, options) => {
|
|
|
124
128
|
onUpdate: (value) => {
|
|
125
129
|
ctx.get(commandsCtx).call(ModifyLink, value);
|
|
126
130
|
},
|
|
131
|
+
calculatePosition: (view, input) => {
|
|
132
|
+
calculateTextPosition(view, input, (start, end, target, parent) => {
|
|
133
|
+
const $editor = view.dom.parentElement;
|
|
134
|
+
if (!$editor) {
|
|
135
|
+
throw new Error();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const selectionWidth = end.left - start.left;
|
|
139
|
+
let left = start.left - parent.left - (target.width - selectionWidth) / 2;
|
|
140
|
+
let top = start.bottom - parent.top + 14 + $editor.scrollTop;
|
|
141
|
+
|
|
142
|
+
if (renderOnTop) {
|
|
143
|
+
top = start.top - parent.top - target.height - 14 + $editor.scrollTop;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (left < 0) left = 0;
|
|
147
|
+
|
|
148
|
+
return [top, left];
|
|
149
|
+
});
|
|
150
|
+
},
|
|
127
151
|
});
|
|
128
152
|
if (!inputChipRenderer) return {};
|
|
129
153
|
const shouldDisplay = (view: EditorView) => {
|
|
130
154
|
const { selection, doc } = view.state;
|
|
131
155
|
const { from, to } = selection;
|
|
132
156
|
|
|
133
|
-
|
|
134
|
-
|
|
157
|
+
if (!view.hasFocus()) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (
|
|
135
162
|
selection.empty &&
|
|
136
163
|
selection instanceof TextSelection &&
|
|
137
164
|
to < doc.content.size &&
|
|
138
165
|
from < doc.content.size &&
|
|
139
166
|
doc.rangeHasMark(from, from === to ? to + 1 : to, type)
|
|
140
|
-
)
|
|
167
|
+
) {
|
|
168
|
+
renderOnTop = false;
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (selection instanceof NodeSelection) {
|
|
173
|
+
const { node } = selection;
|
|
174
|
+
if (
|
|
175
|
+
node.type.name === 'image' &&
|
|
176
|
+
node.marks.findIndex((mark) => mark.type.name === id) > -1
|
|
177
|
+
) {
|
|
178
|
+
renderOnTop = true;
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return false;
|
|
141
184
|
};
|
|
142
185
|
const getCurrentLink = (view: EditorView) => {
|
|
143
186
|
const { selection } = view.state;
|
|
@@ -179,7 +222,9 @@ export const link = createMark<string, LinkOptions>((utils, options) => {
|
|
|
179
222
|
prevState?.doc.eq(view.state.doc) && prevState.selection.eq(view.state.selection);
|
|
180
223
|
if (isEqualSelection) return;
|
|
181
224
|
|
|
182
|
-
|
|
225
|
+
requestAnimationFrame(() => {
|
|
226
|
+
renderByView(view);
|
|
227
|
+
});
|
|
183
228
|
},
|
|
184
229
|
destroy: () => {
|
|
185
230
|
inputChipRenderer.destroy();
|
package/src/node/code-fence.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { createCmd, createCmdKey, editorViewCtx, ThemeCodeFenceType } from '@mil
|
|
|
3
3
|
import { setBlockType } from '@milkdown/prose/commands';
|
|
4
4
|
import { textblockTypeInputRule } from '@milkdown/prose/inputrules';
|
|
5
5
|
import { Fragment } from '@milkdown/prose/model';
|
|
6
|
+
import { NodeView } from '@milkdown/prose/view';
|
|
6
7
|
import { createNode, createShortcut } from '@milkdown/utils';
|
|
7
8
|
|
|
8
9
|
import { SupportedKeys } from '../supported-keys';
|
|
@@ -68,8 +69,7 @@ export const codeFence = createNode<Keys, { languageList?: string[] }>((utils, o
|
|
|
68
69
|
throw new Error('Parse DOM error.');
|
|
69
70
|
}
|
|
70
71
|
const textNode = schema.text(dom.querySelector('pre')?.textContent ?? '');
|
|
71
|
-
|
|
72
|
-
return Fragment.from<any>(textNode);
|
|
72
|
+
return Fragment.from(textNode);
|
|
73
73
|
},
|
|
74
74
|
},
|
|
75
75
|
{
|
|
@@ -211,7 +211,7 @@ export const codeFence = createNode<Keys, { languageList?: string[] }>((utils, o
|
|
|
211
211
|
editable: () => view.editable,
|
|
212
212
|
languageList,
|
|
213
213
|
});
|
|
214
|
-
if (!renderer) return {};
|
|
214
|
+
if (!renderer) return {} as NodeView;
|
|
215
215
|
|
|
216
216
|
const { dom, contentDOM, onUpdate, onDestroy } = renderer;
|
|
217
217
|
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
|
|
|
@@ -34,7 +34,21 @@ export const hardbreak = createNode<Keys>((utils) => {
|
|
|
34
34
|
}),
|
|
35
35
|
commands: (type) => [
|
|
36
36
|
createCmd(InsertHardbreak, () => (state, dispatch) => {
|
|
37
|
-
|
|
37
|
+
const { selection, tr } = state;
|
|
38
|
+
if (selection.empty) {
|
|
39
|
+
// Transform two successive hardbreak into a new line
|
|
40
|
+
const node = selection.$from.node();
|
|
41
|
+
if (node.childCount > 0 && node.lastChild?.type.name === 'hardbreak') {
|
|
42
|
+
dispatch?.(
|
|
43
|
+
tr
|
|
44
|
+
.replaceRangeWith(selection.to - 1, selection.to, state.schema.node('paragraph'))
|
|
45
|
+
.setSelection(Selection.near(tr.doc.resolve(selection.to)))
|
|
46
|
+
.scrollIntoView(),
|
|
47
|
+
);
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
dispatch?.(tr.setMeta('hardbreak', true).replaceSelectionWith(type.create()).scrollIntoView());
|
|
38
52
|
return true;
|
|
39
53
|
}),
|
|
40
54
|
],
|
package/src/node/heading.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createCmd, createCmdKey, editorViewCtx } from '@milkdown/core';
|
|
3
3
|
import { setBlockType } from '@milkdown/prose/commands';
|
|
4
4
|
import { textblockTypeInputRule } from '@milkdown/prose/inputrules';
|
|
5
|
-
import { Node } from '@milkdown/prose/model';
|
|
5
|
+
import { Fragment, Node } from '@milkdown/prose/model';
|
|
6
6
|
import { EditorState, Plugin, PluginKey, Transaction } from '@milkdown/prose/state';
|
|
7
7
|
import { createNode, createShortcut } from '@milkdown/utils';
|
|
8
8
|
|
|
@@ -24,9 +24,18 @@ export const TurnIntoHeading = createCmdKey<number>('TurnIntoHeading');
|
|
|
24
24
|
|
|
25
25
|
export const headingPluginKey = new PluginKey('MILKDOWN_ID');
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const createId = (node: Node) =>
|
|
28
|
+
node.textContent
|
|
29
|
+
.replace(/[\p{P}\p{S}]/gu, '')
|
|
30
|
+
.replace(/\s/g, '-')
|
|
31
|
+
.toLowerCase()
|
|
32
|
+
.trim();
|
|
33
|
+
|
|
34
|
+
export const heading = createNode<Keys, { getId: (node: Node) => string }>((utils, options) => {
|
|
28
35
|
const id = 'heading';
|
|
29
36
|
|
|
37
|
+
const getId = options?.getId ?? createId;
|
|
38
|
+
|
|
30
39
|
return {
|
|
31
40
|
id,
|
|
32
41
|
schema: () => ({
|
|
@@ -54,7 +63,7 @@ export const heading = createNode<Keys>((utils) => {
|
|
|
54
63
|
return [
|
|
55
64
|
`h${node.attrs['level']}`,
|
|
56
65
|
{
|
|
57
|
-
id: node.attrs['id'] || node
|
|
66
|
+
id: node.attrs['id'] || getId(node),
|
|
58
67
|
class: utils.getClassName(node.attrs, `heading h${node.attrs['level']}`),
|
|
59
68
|
},
|
|
60
69
|
0,
|
|
@@ -73,7 +82,19 @@ export const heading = createNode<Keys>((utils) => {
|
|
|
73
82
|
match: (node) => node.type.name === id,
|
|
74
83
|
runner: (state, node) => {
|
|
75
84
|
state.openNode('heading', undefined, { depth: node.attrs['level'] });
|
|
76
|
-
|
|
85
|
+
const lastIsHardbreak = node.childCount >= 1 && node.lastChild?.type.name === 'hardbreak';
|
|
86
|
+
if (lastIsHardbreak) {
|
|
87
|
+
const contentArr: Node[] = [];
|
|
88
|
+
node.content.forEach((n, _, i) => {
|
|
89
|
+
if (i === node.childCount - 1) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
contentArr.push(n);
|
|
93
|
+
});
|
|
94
|
+
state.next(Fragment.fromArray(contentArr));
|
|
95
|
+
} else {
|
|
96
|
+
state.next(node.content);
|
|
97
|
+
}
|
|
77
98
|
state.closeNode();
|
|
78
99
|
},
|
|
79
100
|
},
|
|
@@ -95,12 +116,6 @@ export const heading = createNode<Keys>((utils) => {
|
|
|
95
116
|
},
|
|
96
117
|
prosePlugins: (type, ctx) => {
|
|
97
118
|
let lock = false;
|
|
98
|
-
const createId = (node: Node) => {
|
|
99
|
-
return node.textContent
|
|
100
|
-
.replace(/[\p{P}\p{S}]/gu, '')
|
|
101
|
-
.replace(/\s/g, '')
|
|
102
|
-
.trim();
|
|
103
|
-
};
|
|
104
119
|
const walkThrough = (state: EditorState, callback: (tr: Transaction) => void) => {
|
|
105
120
|
const tr = state.tr;
|
|
106
121
|
state.doc.descendants((node, pos) => {
|
|
@@ -109,7 +124,7 @@ export const heading = createNode<Keys>((utils) => {
|
|
|
109
124
|
return;
|
|
110
125
|
}
|
|
111
126
|
const attrs = node.attrs;
|
|
112
|
-
const id =
|
|
127
|
+
const id = getId(node);
|
|
113
128
|
|
|
114
129
|
if (attrs['id'] !== id) {
|
|
115
130
|
tr.setMeta(headingPluginKey, true).setNodeMarkup(pos, undefined, {
|
|
@@ -154,6 +169,22 @@ export const heading = createNode<Keys>((utils) => {
|
|
|
154
169
|
|
|
155
170
|
return tr;
|
|
156
171
|
},
|
|
172
|
+
view: (view) => {
|
|
173
|
+
const doc = view.state.doc;
|
|
174
|
+
let tr = view.state.tr;
|
|
175
|
+
doc.descendants((node, pos) => {
|
|
176
|
+
if (node.type.name === 'heading' && node.attrs['level']) {
|
|
177
|
+
if (!node.attrs['id']) {
|
|
178
|
+
tr = tr.setNodeMarkup(pos, undefined, {
|
|
179
|
+
...node.attrs,
|
|
180
|
+
id: getId(node),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
view.dispatch(tr);
|
|
186
|
+
return {};
|
|
187
|
+
},
|
|
157
188
|
}),
|
|
158
189
|
];
|
|
159
190
|
},
|
package/src/node/hr.ts
CHANGED
|
@@ -40,13 +40,15 @@ export const hr = createNode((utils) => {
|
|
|
40
40
|
commands: (type, ctx) => [
|
|
41
41
|
createCmd(InsertHr, () => (state, dispatch) => {
|
|
42
42
|
if (!dispatch) return true;
|
|
43
|
+
|
|
44
|
+
const paragraph = ctx.get(schemaCtx).node('paragraph');
|
|
43
45
|
const { tr, selection } = state;
|
|
44
|
-
const from = selection
|
|
46
|
+
const { from } = selection;
|
|
45
47
|
const node = type.create();
|
|
46
48
|
if (!node) {
|
|
47
49
|
return true;
|
|
48
50
|
}
|
|
49
|
-
const _tr = tr.replaceSelectionWith(node).insert(from,
|
|
51
|
+
const _tr = tr.replaceSelectionWith(node).insert(from, paragraph);
|
|
50
52
|
const sel = Selection.findFrom(_tr.doc.resolve(from), 1, true);
|
|
51
53
|
if (!sel) {
|
|
52
54
|
return true;
|
package/src/node/image.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { commandsCtx, createCmd, createCmdKey, ThemeImageType, ThemeInputChipTyp
|
|
|
3
3
|
import { findSelectedNodeOfType } from '@milkdown/prose';
|
|
4
4
|
import { InputRule } from '@milkdown/prose/inputrules';
|
|
5
5
|
import { Plugin, PluginKey } from '@milkdown/prose/state';
|
|
6
|
-
import { EditorView } from '@milkdown/prose/view';
|
|
6
|
+
import { EditorView, NodeView } from '@milkdown/prose/view';
|
|
7
7
|
import { createNode } from '@milkdown/utils';
|
|
8
8
|
|
|
9
9
|
export const ModifyImage = createCmdKey<string>('ModifyImage');
|
|
@@ -134,7 +134,7 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
134
134
|
});
|
|
135
135
|
|
|
136
136
|
if (!renderer) {
|
|
137
|
-
return {};
|
|
137
|
+
return {} as NodeView;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
const { dom, onUpdate } = renderer;
|
package/src/node/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
+
import { AtomPlugin } from '@milkdown/utils';
|
|
3
|
+
|
|
2
4
|
import { blockquote } from './blockquote';
|
|
3
5
|
import { bulletList } from './bullet-list';
|
|
4
6
|
import { codeFence } from './code-fence';
|
|
@@ -12,7 +14,7 @@ import { orderedList } from './ordered-list';
|
|
|
12
14
|
import { paragraph } from './paragraph';
|
|
13
15
|
import { text } from './text';
|
|
14
16
|
|
|
15
|
-
export const nodes = [
|
|
17
|
+
export const nodes: AtomPlugin[] = [
|
|
16
18
|
doc(),
|
|
17
19
|
paragraph(),
|
|
18
20
|
hardbreak(),
|
package/src/node/paragraph.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
2
|
import { createCmd, createCmdKey } from '@milkdown/core';
|
|
3
3
|
import { setBlockType } from '@milkdown/prose/commands';
|
|
4
|
+
import { Fragment, Node } from '@milkdown/prose/model';
|
|
4
5
|
import { createNode, createShortcut } from '@milkdown/utils';
|
|
5
6
|
|
|
6
7
|
import { SupportedKeys } from '../supported-keys';
|
|
@@ -34,8 +35,17 @@ export const paragraph = createNode<Keys>((utils) => {
|
|
|
34
35
|
match: (node) => node.type.name === 'paragraph',
|
|
35
36
|
runner: (state, node) => {
|
|
36
37
|
state.openNode('paragraph');
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
38
|
+
const lastIsHardbreak = node.childCount >= 1 && node.lastChild?.type.name === 'hardbreak';
|
|
39
|
+
if (lastIsHardbreak) {
|
|
40
|
+
const contentArr: Node[] = [];
|
|
41
|
+
node.content.forEach((n, _, i) => {
|
|
42
|
+
if (i === node.childCount - 1) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
contentArr.push(n);
|
|
46
|
+
});
|
|
47
|
+
state.next(Fragment.fromArray(contentArr));
|
|
48
|
+
} else {
|
|
39
49
|
state.next(node.content);
|
|
40
50
|
}
|
|
41
51
|
state.closeNode();
|
|
@@ -32,7 +32,7 @@ export const inlineNodesCursorPlugin: Plugin = new Plugin({
|
|
|
32
32
|
handleDOMEvents: {
|
|
33
33
|
beforeinput: (view, e) => {
|
|
34
34
|
const active = inlineNodesCursorPlugin.getState(view.state);
|
|
35
|
-
if (active) {
|
|
35
|
+
if (active && e instanceof InputEvent) {
|
|
36
36
|
const from = view.state.selection.from;
|
|
37
37
|
e.preventDefault();
|
|
38
38
|
view.dispatch(view.state.tr.insertText(e.data || '', from));
|