@milkdown/preset-commonmark 5.3.0 → 5.3.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.
- package/lib/index.d.ts +1 -34
- package/lib/index.es.js +118 -58
- package/lib/index.es.js.map +1 -1
- package/lib/src/index.d.ts +34 -0
- package/lib/src/index.d.ts.map +1 -0
- package/lib/{mark → src/mark}/code-inline.d.ts +1 -1
- package/lib/src/mark/code-inline.d.ts.map +1 -0
- package/lib/{mark → src/mark}/em.d.ts +1 -1
- package/lib/src/mark/em.d.ts.map +1 -0
- package/lib/src/mark/index.d.ts +6 -0
- package/lib/src/mark/index.d.ts.map +1 -0
- package/lib/{mark → src/mark}/link.d.ts +1 -1
- package/lib/src/mark/link.d.ts.map +1 -0
- package/lib/{mark → src/mark}/strong.d.ts +1 -1
- package/lib/src/mark/strong.d.ts.map +1 -0
- package/lib/{node → src/node}/blockquote.d.ts +1 -1
- package/lib/src/node/blockquote.d.ts.map +1 -0
- package/lib/{node → src/node}/bullet-list.d.ts +1 -1
- package/lib/src/node/bullet-list.d.ts.map +1 -0
- package/lib/{node → src/node}/code-fence.d.ts +1 -1
- package/lib/src/node/code-fence.d.ts.map +1 -0
- package/lib/{node → src/node}/doc.d.ts +1 -1
- package/lib/src/node/doc.d.ts.map +1 -0
- package/lib/{node → src/node}/hardbreak.d.ts +1 -1
- package/lib/src/node/hardbreak.d.ts.map +1 -0
- package/lib/{node → src/node}/heading.d.ts +3 -1
- package/lib/src/node/heading.d.ts.map +1 -0
- package/lib/{node → src/node}/hr.d.ts +1 -1
- package/lib/src/node/hr.d.ts.map +1 -0
- package/lib/{node → src/node}/image.d.ts +1 -1
- package/lib/src/node/image.d.ts.map +1 -0
- package/lib/{node → src/node}/index.d.ts +2 -2
- package/lib/src/node/index.d.ts.map +1 -0
- package/lib/{node → src/node}/list-item.d.ts +1 -1
- package/lib/src/node/list-item.d.ts.map +1 -0
- package/lib/{node → src/node}/ordered-list.d.ts +1 -1
- package/lib/src/node/ordered-list.d.ts.map +1 -0
- package/lib/{node → src/node}/paragraph.d.ts +1 -1
- package/lib/src/node/paragraph.d.ts.map +1 -0
- package/lib/{node → src/node}/text.d.ts +1 -1
- package/lib/src/node/text.d.ts.map +1 -0
- package/lib/{plugin → src/plugin}/filter-html.d.ts +0 -0
- package/lib/src/plugin/filter-html.d.ts.map +1 -0
- package/lib/src/plugin/index.d.ts +2 -0
- package/lib/src/plugin/index.d.ts.map +1 -0
- package/lib/{supported-keys.d.ts → src/supported-keys.d.ts} +0 -0
- package/lib/src/supported-keys.d.ts.map +1 -0
- package/lib/src/types.d.ts +5 -0
- package/package.json +10 -23
- package/src/mark/code-inline.ts +6 -7
- package/src/mark/link.ts +1 -2
- package/src/mark/strong.ts +1 -2
- package/src/node/blockquote.ts +1 -2
- package/src/node/bullet-list.ts +1 -1
- package/src/node/code-fence.ts +7 -6
- package/src/node/heading.ts +75 -28
- package/src/node/hr.ts +1 -2
- package/src/node/image.ts +20 -9
- package/src/node/list-item.ts +1 -2
- package/src/node/ordered-list.ts +1 -1
- package/src/node/paragraph.ts +8 -9
- package/lib/index.cjs.js +0 -261
- package/lib/index.cjs.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/mark/code-inline.d.ts.map +0 -1
- package/lib/mark/em.d.ts.map +0 -1
- package/lib/mark/index.d.ts +0 -6
- package/lib/mark/index.d.ts.map +0 -1
- package/lib/mark/link.d.ts.map +0 -1
- package/lib/mark/strong.d.ts.map +0 -1
- package/lib/node/blockquote.d.ts.map +0 -1
- package/lib/node/bullet-list.d.ts.map +0 -1
- package/lib/node/code-fence.d.ts.map +0 -1
- package/lib/node/doc.d.ts.map +0 -1
- package/lib/node/hardbreak.d.ts.map +0 -1
- package/lib/node/heading.d.ts.map +0 -1
- package/lib/node/hr.d.ts.map +0 -1
- package/lib/node/image.d.ts.map +0 -1
- package/lib/node/index.d.ts.map +0 -1
- package/lib/node/list-item.d.ts.map +0 -1
- package/lib/node/ordered-list.d.ts.map +0 -1
- package/lib/node/paragraph.d.ts.map +0 -1
- package/lib/node/text.d.ts.map +0 -1
- package/lib/plugin/filter-html.d.ts.map +0 -1
- package/lib/plugin/index.d.ts +0 -2
- package/lib/plugin/index.d.ts.map +0 -1
- package/lib/supported-keys.d.ts.map +0 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { PluginKey } from '@milkdown/prose';
|
|
1
2
|
import { SupportedKeys } from '../supported-keys';
|
|
2
3
|
declare type Keys = SupportedKeys['H1'] | SupportedKeys['H2'] | SupportedKeys['H3'] | SupportedKeys['H4'] | SupportedKeys['H5'] | SupportedKeys['H6'];
|
|
3
4
|
export declare const TurnIntoHeading: import("@milkdown/core").CmdKey<number>;
|
|
4
|
-
export declare const
|
|
5
|
+
export declare const headingPluginKey: PluginKey<any, any>;
|
|
6
|
+
export declare const heading: import("@milkdown/utils/lib/src/types").WithExtend<Keys, import("@milkdown/utils").UnknownRecord, import("prosemirror-model").NodeType<any>, {
|
|
5
7
|
id: string;
|
|
6
8
|
schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
|
|
7
9
|
view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["heading.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,SAAS,EAAwC,MAAM,iBAAiB,CAAC;AAG1F,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,yCAAyB,CAAC;AAEtD,eAAO,MAAM,gBAAgB,qBAAsC,CAAC;AAEpE,eAAO,MAAM,OAAO;;;;EAiIlB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const InsertHr: import("@milkdown/core").CmdKey<string>;
|
|
2
|
-
export declare const hr: import("@milkdown/utils/lib/types").WithExtend<string, import("@milkdown/utils").UnknownRecord, import("prosemirror-model").NodeType<any>, {
|
|
2
|
+
export declare const hr: import("@milkdown/utils/lib/src/types").WithExtend<string, import("@milkdown/utils").UnknownRecord, import("prosemirror-model").NodeType<any>, {
|
|
3
3
|
id: string;
|
|
4
4
|
schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
|
|
5
5
|
view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hr.d.ts","sourceRoot":"","sources":["hr.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,QAAQ,yCAAyB,CAAC;AAC/C,eAAO,MAAM,EAAE;;;;EAyDb,CAAC"}
|
|
@@ -8,7 +8,7 @@ export declare type ImageOptions = {
|
|
|
8
8
|
failed: string;
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
|
-
export declare const image: import("@milkdown/utils/lib/types").WithExtend<string, ImageOptions, import("prosemirror-model").NodeType<any>, {
|
|
11
|
+
export declare const image: import("@milkdown/utils/lib/src/types").WithExtend<string, ImageOptions, import("prosemirror-model").NodeType<any>, {
|
|
12
12
|
id: string;
|
|
13
13
|
schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
|
|
14
14
|
view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["image.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,WAAW,yCAAyB,CAAC;AAClD,eAAO,MAAM,WAAW,yCAAyB,CAAC;AAElD,oBAAY,YAAY,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE;QACT,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAClB,CAAC;CACL,CAAC;AAEF,eAAO,MAAM,KAAK;;;;EAyVhB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const nodes: ((import("@milkdown/utils/lib/types").Metadata<import("@milkdown/utils/lib/types").GetPlugin<"CodeFence", {
|
|
1
|
+
export declare const nodes: ((import("@milkdown/utils/lib/src/types").Metadata<import("@milkdown/utils/lib/src/types").GetPlugin<"CodeFence", {
|
|
2
2
|
languageList?: string[] | undefined;
|
|
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))[];
|
|
3
|
+
}>> & import("@milkdown/core").MilkdownPlugin) | (import("@milkdown/utils/lib/src/types").Metadata<import("@milkdown/utils/lib/src/types").GetPlugin<string, import("./image").ImageOptions>> & import("@milkdown/core").MilkdownPlugin))[];
|
|
4
4
|
export * from './blockquote';
|
|
5
5
|
export * from './bullet-list';
|
|
6
6
|
export * from './code-fence';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,KAAK;;2OAajB,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,7 +3,7 @@ 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/lib/types").WithExtend<Keys, import("@milkdown/utils").UnknownRecord, import("prosemirror-model").NodeType<any>, {
|
|
6
|
+
export declare const listItem: import("@milkdown/utils/lib/src/types").WithExtend<Keys, import("@milkdown/utils").UnknownRecord, import("prosemirror-model").NodeType<any>, {
|
|
7
7
|
id: string;
|
|
8
8
|
schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
|
|
9
9
|
view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-item.d.ts","sourceRoot":"","sources":["list-item.ts"],"names":[],"mappings":"AAKA,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,4CAAiB,CAAC;AAC5C,eAAO,MAAM,YAAY,4CAAiB,CAAC;AAC3C,eAAO,MAAM,YAAY,4CAAiB,CAAC;AAE3C,eAAO,MAAM,QAAQ;;;;EAuDnB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const WrapInOrderedList: import("@milkdown/core").CmdKey<undefined>;
|
|
2
|
-
export declare const orderedList: import("@milkdown/utils/lib/types").WithExtend<"OrderedList", import("@milkdown/utils").UnknownRecord, import("prosemirror-model").NodeType<any>, {
|
|
2
|
+
export declare const orderedList: import("@milkdown/utils/lib/src/types").WithExtend<"OrderedList", import("@milkdown/utils").UnknownRecord, import("prosemirror-model").NodeType<any>, {
|
|
3
3
|
id: string;
|
|
4
4
|
schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
|
|
5
5
|
view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ordered-list.d.ts","sourceRoot":"","sources":["ordered-list.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,iBAAiB,4CAAiB,CAAC;AAGhD,eAAO,MAAM,WAAW;;;;EAwDrB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const TurnIntoText: import("@milkdown/core").CmdKey<undefined>;
|
|
2
|
-
export declare const paragraph: import("@milkdown/utils/lib/types").WithExtend<"Text", import("@milkdown/utils").UnknownRecord, import("prosemirror-model").NodeType<any>, {
|
|
2
|
+
export declare const paragraph: import("@milkdown/utils/lib/src/types").WithExtend<"Text", import("@milkdown/utils").UnknownRecord, import("prosemirror-model").NodeType<any>, {
|
|
3
3
|
id: string;
|
|
4
4
|
schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
|
|
5
5
|
view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["paragraph.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,YAAY,4CAAiB,CAAC;AAG3C,eAAO,MAAM,SAAS;;;;EA0CpB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const text: import("@milkdown/utils/lib/types").WithExtend<string, import("@milkdown/utils").UnknownRecord, import("prosemirror-model").NodeType<any>, {
|
|
1
|
+
export declare const text: import("@milkdown/utils/lib/src/types").WithExtend<string, import("@milkdown/utils").UnknownRecord, import("prosemirror-model").NodeType<any>, {
|
|
2
2
|
id: string;
|
|
3
3
|
schema: (ctx: import("@milkdown/core").Ctx) => import("@milkdown/core").NodeSchema;
|
|
4
4
|
view?: ((ctx: import("@milkdown/core").Ctx) => import("@milkdown/prose").NodeViewFactory) | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["text.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,IAAI;;;;EAiBd,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-html.d.ts","sourceRoot":"","sources":["filter-html.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,IAAI,EAAU,MAAM,OAAO,CAAC;AA0B9C,eAAO,MAAM,gBAAgB,eACE,IAAI,SAUlC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,iBAAiB,oMAI7B,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supported-keys.d.ts","sourceRoot":"","sources":["supported-keys.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;CAmBhB,CAAC;AAEX,oBAAY,aAAa,GAAG,OAAO,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/preset-commonmark",
|
|
3
|
-
"version": "5.3.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "5.3.4",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./lib/index.es.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"import": "./lib/index.es.js",
|
|
10
|
-
"require": "./lib/index.cjs.js"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
7
|
"sideEffects": false,
|
|
14
8
|
"license": "MIT",
|
|
15
9
|
"files": [
|
|
@@ -22,26 +16,19 @@
|
|
|
22
16
|
"markdown",
|
|
23
17
|
"commonmark"
|
|
24
18
|
],
|
|
25
|
-
"peerDependencies": {
|
|
26
|
-
"@milkdown/core": "*"
|
|
27
|
-
},
|
|
28
19
|
"dependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@milkdown/
|
|
20
|
+
"@milkdown/prose": "5.3.4",
|
|
21
|
+
"@milkdown/core": "5.3.4",
|
|
22
|
+
"@milkdown/design-system": "5.3.4",
|
|
23
|
+
"@milkdown/utils": "5.3.4",
|
|
31
24
|
"remark-inline-links": "^6.0.0",
|
|
32
25
|
"tslib": "^2.3.1"
|
|
33
26
|
},
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"@milkdown/prose": "5.3.0",
|
|
36
|
-
"@milkdown/core": "5.3.0",
|
|
37
|
-
"@milkdown/design-system": "5.3.0"
|
|
38
|
-
},
|
|
39
27
|
"scripts": {
|
|
40
|
-
"start": "vite",
|
|
41
|
-
"
|
|
42
|
-
"test": "jest",
|
|
28
|
+
"start": "vite build --watch",
|
|
29
|
+
"test": "vitest",
|
|
43
30
|
"tsc": "tsc --noEmit",
|
|
44
|
-
"build": "vite build
|
|
31
|
+
"build": "vite build"
|
|
45
32
|
},
|
|
46
33
|
"readme": "# @milkdown/preset-commonmark\n\nCommon mark preset for [milkdown](https://saul-mirone.github.io/milkdown/).\nAdd support for commonmark.\n\n# Example Usage\n\n```typescript\nimport { Editor } from '@milkdown/core';\nimport { nord } from '@milkdown/theme-nord';\n\nimport { commonmark } from '@milkdown/preset-commonmark';\n\nEditor.make().use(nord).use(commonmark).create();\n```\n\n## Custom Keymap\n\n```typescript\nimport { commonmarkNodes, commonmarkPlugins, blockquote, SupportedKeys } from '@milkdown/preset-commonmark';\n\nconst nodes = commonmarkNodes.configure(blockquote, {\n keymap: {\n [SupportedKeys.Blockquote]: 'Mod-Shift-b',\n },\n});\n\nEditor.make().use(commonmarkPlugins).use(nodes);\n```\n\nKeymap supported:\n\n- HardBreak\n- Blockquote\n- BulletList\n- OrderedList\n- CodeFence\n- H1\n- H2\n- H3\n- H4\n- H5\n- H6\n- Text\n- CodeInline\n- Em\n- Bold\n- NextListItem\n- SinkListItem\n- LiftListItem\n\n## Custom Style\n\n```typescript\nimport { commonmark, Paragraph, Heading } from '@milkdown/commonmark';\n\nconst nodes = commonmark\n .configure(Paragraph, {\n className: () =>\n 'my-custom-paragraph'\n })\n .configure(Heading, {\n className: (attrs) =>\n `my-custom-heading my-h${attrs.level}`\n })\n\nnew Editor({ ... }).use(nodes);\n```\n\n## Other Options\n\n### Image\n\n- placeholder\n - loading: _string_. The placeholder of loading status.\n - empty: _string_. The placeholder of empty status.\n - failed: _string_. The placeholder of failed status.\n\n### CodeFence\n\n- languageList: _string[]_. The selectable languages list of code fence needs to be enabled.\n\n# License\n\nMilkdown is open sourced software licensed under [MIT license](https://github.com/Saul-Mirone/milkdown/blob/main/LICENSE).\n"
|
|
47
34
|
}
|
package/src/mark/code-inline.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { css } from '@emotion/css';
|
|
3
2
|
import { createCmd, createCmdKey } from '@milkdown/core';
|
|
4
3
|
import { markRule, toggleMark } from '@milkdown/prose';
|
|
5
4
|
import { createMark, createShortcut } from '@milkdown/utils';
|
|
@@ -13,7 +12,7 @@ export const ToggleInlineCode = createCmdKey();
|
|
|
13
12
|
|
|
14
13
|
export const codeInline = createMark<Keys>((utils) => {
|
|
15
14
|
const style = utils.getStyle(
|
|
16
|
-
({ palette, size, font }) =>
|
|
15
|
+
({ palette, size, font }, { css }) =>
|
|
17
16
|
css`
|
|
18
17
|
background-color: ${palette('neutral')};
|
|
19
18
|
color: ${palette('background')};
|
|
@@ -26,7 +25,9 @@ export const codeInline = createMark<Keys>((utils) => {
|
|
|
26
25
|
return {
|
|
27
26
|
id,
|
|
28
27
|
schema: () => ({
|
|
29
|
-
|
|
28
|
+
priority: 100,
|
|
29
|
+
code: true,
|
|
30
|
+
inclusive: false,
|
|
30
31
|
parseDOM: [{ tag: 'code' }],
|
|
31
32
|
toDOM: (mark) => ['code', { class: utils.getClassName(mark.attrs, 'code-inline', style) }],
|
|
32
33
|
parseMarkdown: {
|
|
@@ -39,10 +40,8 @@ export const codeInline = createMark<Keys>((utils) => {
|
|
|
39
40
|
},
|
|
40
41
|
toMarkdown: {
|
|
41
42
|
match: (mark) => mark.type.name === id,
|
|
42
|
-
runner: (state,
|
|
43
|
-
state.
|
|
44
|
-
|
|
45
|
-
return true;
|
|
43
|
+
runner: (state, mark, node) => {
|
|
44
|
+
state.withMark(mark, 'inlineCode', node.text || '');
|
|
46
45
|
},
|
|
47
46
|
},
|
|
48
47
|
}),
|
package/src/mark/link.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { css } from '@emotion/css';
|
|
3
2
|
import { createCmd, createCmdKey, schemaCtx } from '@milkdown/core';
|
|
4
3
|
import { InputRule, Node as ProseNode, TextSelection, toggleMark } from '@milkdown/prose';
|
|
5
4
|
import { createMark } from '@milkdown/utils';
|
|
@@ -8,7 +7,7 @@ export const ToggleLink = createCmdKey<string>();
|
|
|
8
7
|
export const ModifyLink = createCmdKey<string>();
|
|
9
8
|
const id = 'link';
|
|
10
9
|
export const link = createMark((utils) => {
|
|
11
|
-
const style = utils.getStyle((themeTool) => {
|
|
10
|
+
const style = utils.getStyle((themeTool, { css }) => {
|
|
12
11
|
const lineColor = themeTool.palette('line');
|
|
13
12
|
|
|
14
13
|
return css`
|
package/src/mark/strong.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { css } from '@emotion/css';
|
|
3
2
|
import { createCmd, createCmdKey } from '@milkdown/core';
|
|
4
3
|
import { markRule, toggleMark } from '@milkdown/prose';
|
|
5
4
|
import { createMark, createShortcut } from '@milkdown/utils';
|
|
@@ -11,7 +10,7 @@ const id = 'strong';
|
|
|
11
10
|
export const ToggleBold = createCmdKey();
|
|
12
11
|
export const strong = createMark<Keys>((utils) => {
|
|
13
12
|
const style = utils.getStyle(
|
|
14
|
-
() =>
|
|
13
|
+
(_, { css }) =>
|
|
15
14
|
css`
|
|
16
15
|
font-weight: 600;
|
|
17
16
|
`,
|
package/src/node/blockquote.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { css } from '@emotion/css';
|
|
3
2
|
import { createCmd, createCmdKey } from '@milkdown/core';
|
|
4
3
|
import { wrapIn, wrappingInputRule } from '@milkdown/prose';
|
|
5
4
|
import { createNode, createShortcut } from '@milkdown/utils';
|
|
@@ -14,7 +13,7 @@ export const WrapInBlockquote = createCmdKey();
|
|
|
14
13
|
|
|
15
14
|
export const blockquote = createNode<Keys>((utils) => {
|
|
16
15
|
const style = utils.getStyle(
|
|
17
|
-
(themeTool) =>
|
|
16
|
+
(themeTool, { css }) =>
|
|
18
17
|
css`
|
|
19
18
|
padding-left: 1.875rem;
|
|
20
19
|
line-height: 1.75rem;
|
package/src/node/bullet-list.ts
CHANGED
|
@@ -36,7 +36,7 @@ export const bulletList = createNode<Keys>((utils) => {
|
|
|
36
36
|
inputRules: (nodeType) => [wrappingInputRule(/^\s*([-+*])\s$/, nodeType)],
|
|
37
37
|
commands: (nodeType) => [createCmd(WrapInBulletList, () => wrapIn(nodeType))],
|
|
38
38
|
shortcuts: {
|
|
39
|
-
[SupportedKeys.BulletList]: createShortcut(WrapInBulletList, 'Mod-
|
|
39
|
+
[SupportedKeys.BulletList]: createShortcut(WrapInBulletList, 'Mod-Alt-8'),
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
42
|
});
|
package/src/node/code-fence.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { css } from '@emotion/css';
|
|
3
2
|
import { createCmd, createCmdKey, themeToolCtx } from '@milkdown/core';
|
|
4
3
|
import { setBlockType, textblockTypeInputRule } from '@milkdown/prose';
|
|
5
4
|
import { createNode, createShortcut } from '@milkdown/utils';
|
|
@@ -34,7 +33,7 @@ export const TurnIntoCodeFence = createCmdKey();
|
|
|
34
33
|
|
|
35
34
|
const id = 'fence';
|
|
36
35
|
export const codeFence = createNode<Keys, { languageList?: string[] }>((utils, options) => {
|
|
37
|
-
const style = utils.getStyle(({ palette, mixin, size, font }) => {
|
|
36
|
+
const style = utils.getStyle(({ palette, mixin, size, font }, { css }) => {
|
|
38
37
|
const { shadow, scrollbar, border } = mixin;
|
|
39
38
|
const { lineWidth, radius } = size;
|
|
40
39
|
return css`
|
|
@@ -69,7 +68,7 @@ export const codeFence = createNode<Keys, { languageList?: string[] }>((utils, o
|
|
|
69
68
|
height: 2.625rem;
|
|
70
69
|
align-items: center;
|
|
71
70
|
|
|
72
|
-
& >
|
|
71
|
+
& > .icon {
|
|
73
72
|
width: 2.625rem;
|
|
74
73
|
height: 100%;
|
|
75
74
|
display: flex;
|
|
@@ -171,12 +170,12 @@ export const codeFence = createNode<Keys, { languageList?: string[] }>((utils, o
|
|
|
171
170
|
],
|
|
172
171
|
toDOM: (node) => {
|
|
173
172
|
return [
|
|
174
|
-
'
|
|
173
|
+
'pre',
|
|
175
174
|
{
|
|
176
175
|
'data-language': node.attrs.language,
|
|
177
176
|
class: utils.getClassName(node.attrs, 'code-fence', style),
|
|
178
177
|
},
|
|
179
|
-
['
|
|
178
|
+
['code', { spellCheck: 'false' }, 0],
|
|
180
179
|
];
|
|
181
180
|
},
|
|
182
181
|
parseMarkdown: {
|
|
@@ -227,7 +226,9 @@ export const codeFence = createNode<Keys, { languageList?: string[] }>((utils, o
|
|
|
227
226
|
valueWrapper.className = 'code-fence_value';
|
|
228
227
|
const value = document.createElement('span');
|
|
229
228
|
valueWrapper.appendChild(value);
|
|
230
|
-
|
|
229
|
+
if (view.editable) {
|
|
230
|
+
valueWrapper.appendChild(ctx.get(themeToolCtx).slots.icon('downArrow'));
|
|
231
|
+
}
|
|
231
232
|
|
|
232
233
|
select.className = 'code-fence_select';
|
|
233
234
|
select.addEventListener('mousedown', (e) => {
|
package/src/node/heading.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { css } from '@emotion/css';
|
|
3
2
|
import { createCmd, createCmdKey } from '@milkdown/core';
|
|
4
|
-
import { setBlockType, textblockTypeInputRule } from '@milkdown/prose';
|
|
3
|
+
import { Plugin, PluginKey, setBlockType, textblockTypeInputRule } from '@milkdown/prose';
|
|
5
4
|
import { createNode, createShortcut } from '@milkdown/utils';
|
|
6
5
|
|
|
7
6
|
import { SupportedKeys } from '../supported-keys';
|
|
@@ -20,50 +19,75 @@ type Keys =
|
|
|
20
19
|
|
|
21
20
|
export const TurnIntoHeading = createCmdKey<number>();
|
|
22
21
|
|
|
23
|
-
export const
|
|
22
|
+
export const headingPluginKey = new PluginKey('MILKDOWN_PLUGIN_ID');
|
|
23
|
+
|
|
24
|
+
export const heading = createNode<Keys>((utils) => {
|
|
24
25
|
const id = 'heading';
|
|
25
|
-
const headingMap: Record<number, string> = {
|
|
26
|
-
1: css`
|
|
27
|
-
font-size: 3rem;
|
|
28
|
-
line-height: 3.5rem;
|
|
29
|
-
`,
|
|
30
|
-
2: css`
|
|
31
|
-
font-size: 2.125rem;
|
|
32
|
-
line-height: 2.25rem;
|
|
33
|
-
`,
|
|
34
|
-
3: css`
|
|
35
|
-
font-size: 1.5rem;
|
|
36
|
-
line-height: 1.5rem;
|
|
37
|
-
`,
|
|
38
|
-
};
|
|
39
26
|
|
|
40
27
|
const style = (level: number) =>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
28
|
+
utils.getStyle((_, { css }) => {
|
|
29
|
+
const headingMap: Record<number, string> = {
|
|
30
|
+
1: css`
|
|
31
|
+
font-size: 3rem;
|
|
32
|
+
line-height: 3.5rem;
|
|
33
|
+
`,
|
|
34
|
+
2: css`
|
|
35
|
+
font-size: 2.5rem;
|
|
36
|
+
line-height: 3rem;
|
|
37
|
+
`,
|
|
38
|
+
3: css`
|
|
39
|
+
font-size: 2.125rem;
|
|
40
|
+
line-height: 2.25rem;
|
|
41
|
+
`,
|
|
42
|
+
4: css`
|
|
43
|
+
font-size: 1.75rem;
|
|
44
|
+
line-height: 2rem;
|
|
45
|
+
`,
|
|
46
|
+
5: css`
|
|
47
|
+
font-size: 1.5rem;
|
|
48
|
+
line-height: 1.5rem;
|
|
49
|
+
`,
|
|
50
|
+
6: css`
|
|
51
|
+
font-size: 1.25rem;
|
|
52
|
+
line-height: 1.25rem;
|
|
53
|
+
`,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return css`
|
|
57
|
+
${headingMap[level] || ''}
|
|
58
|
+
margin: 2.5rem 0 !important;
|
|
59
|
+
font-weight: 400;
|
|
60
|
+
`;
|
|
61
|
+
});
|
|
48
62
|
|
|
49
63
|
return {
|
|
50
64
|
id,
|
|
51
65
|
schema: () => ({
|
|
52
66
|
content: 'inline*',
|
|
53
67
|
group: 'block',
|
|
68
|
+
defining: true,
|
|
54
69
|
attrs: {
|
|
55
|
-
level: {
|
|
56
|
-
default: 1,
|
|
57
|
-
},
|
|
58
70
|
id: {
|
|
59
71
|
default: '',
|
|
60
72
|
},
|
|
73
|
+
level: {
|
|
74
|
+
default: 1,
|
|
75
|
+
},
|
|
61
76
|
},
|
|
62
|
-
parseDOM: headingIndex.map((x) => ({
|
|
77
|
+
parseDOM: headingIndex.map((x) => ({
|
|
78
|
+
tag: `h${x}`,
|
|
79
|
+
getAttrs: (node) => {
|
|
80
|
+
if (!(node instanceof HTMLElement)) {
|
|
81
|
+
throw new Error();
|
|
82
|
+
}
|
|
83
|
+
return { level: x, id: node.id };
|
|
84
|
+
},
|
|
85
|
+
})),
|
|
63
86
|
toDOM: (node) => {
|
|
64
87
|
return [
|
|
65
88
|
`h${node.attrs.level}`,
|
|
66
89
|
{
|
|
90
|
+
id: node.attrs.id || node.textContent.split(' ').join('-').toLocaleLowerCase(),
|
|
67
91
|
class: utils.getClassName(node.attrs, `heading h${node.attrs.level}`, style(node.attrs.level)),
|
|
68
92
|
},
|
|
69
93
|
0,
|
|
@@ -102,5 +126,28 @@ export const heading = createNode<Keys>((utils, options) => {
|
|
|
102
126
|
[SupportedKeys.H5]: createShortcut(TurnIntoHeading, 'Mod-Alt-5', 5),
|
|
103
127
|
[SupportedKeys.H6]: createShortcut(TurnIntoHeading, 'Mod-Alt-6', 6),
|
|
104
128
|
},
|
|
129
|
+
prosePlugins: (type) => [
|
|
130
|
+
new Plugin({
|
|
131
|
+
key: headingPluginKey,
|
|
132
|
+
appendTransaction: (transactions, _, nextState) => {
|
|
133
|
+
const tr = nextState.tr;
|
|
134
|
+
let modified = false;
|
|
135
|
+
if (transactions.some((transaction) => transaction.docChanged)) {
|
|
136
|
+
nextState.doc.descendants((node, pos) => {
|
|
137
|
+
if (node.type === type) {
|
|
138
|
+
const attrs = node.attrs;
|
|
139
|
+
tr.setNodeMarkup(pos, undefined, {
|
|
140
|
+
...attrs,
|
|
141
|
+
id: node.textContent.split(' ').join('-').toLocaleLowerCase(),
|
|
142
|
+
});
|
|
143
|
+
modified = true;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return modified ? tr : null;
|
|
149
|
+
},
|
|
150
|
+
}),
|
|
151
|
+
],
|
|
105
152
|
};
|
|
106
153
|
});
|
package/src/node/hr.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { css } from '@emotion/css';
|
|
3
2
|
import { createCmd, createCmdKey, schemaCtx } from '@milkdown/core';
|
|
4
3
|
import { InputRule, Selection } from '@milkdown/prose';
|
|
5
4
|
import { createNode } from '@milkdown/utils';
|
|
@@ -8,7 +7,7 @@ const id = 'hr';
|
|
|
8
7
|
export const InsertHr = createCmdKey<string>();
|
|
9
8
|
export const hr = createNode((utils) => {
|
|
10
9
|
const style = utils.getStyle(
|
|
11
|
-
(themeTool) => css`
|
|
10
|
+
(themeTool, { css }) => css`
|
|
12
11
|
height: ${themeTool.size.lineWidth};
|
|
13
12
|
background-color: ${themeTool.palette('line')};
|
|
14
13
|
border-width: 0;
|
package/src/node/image.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { css } from '@emotion/css';
|
|
3
2
|
import { createCmd, createCmdKey, themeToolCtx } from '@milkdown/core';
|
|
4
3
|
import type { Icon } from '@milkdown/design-system';
|
|
5
4
|
import { findSelectedNodeOfType, InputRule } from '@milkdown/prose';
|
|
@@ -16,6 +15,7 @@ export type ImageOptions = {
|
|
|
16
15
|
failed: string;
|
|
17
16
|
};
|
|
18
17
|
};
|
|
18
|
+
|
|
19
19
|
export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
20
20
|
const placeholder = {
|
|
21
21
|
loading: 'Loading...',
|
|
@@ -25,7 +25,7 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
25
25
|
};
|
|
26
26
|
const isBlock = options?.isBlock ?? false;
|
|
27
27
|
const containerStyle = utils.getStyle(
|
|
28
|
-
(themeTool) =>
|
|
28
|
+
(themeTool, { css }) =>
|
|
29
29
|
css`
|
|
30
30
|
display: inline-block;
|
|
31
31
|
position: relative;
|
|
@@ -123,7 +123,7 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
123
123
|
);
|
|
124
124
|
|
|
125
125
|
const style = utils.getStyle(
|
|
126
|
-
() =>
|
|
126
|
+
(_, { css }) =>
|
|
127
127
|
css`
|
|
128
128
|
display: inline-block;
|
|
129
129
|
margin: 0 auto;
|
|
@@ -152,7 +152,7 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
152
152
|
title: { default: null },
|
|
153
153
|
failed: { default: false },
|
|
154
154
|
loading: { default: true },
|
|
155
|
-
width: { default:
|
|
155
|
+
width: { default: null },
|
|
156
156
|
},
|
|
157
157
|
parseDOM: [
|
|
158
158
|
{
|
|
@@ -167,7 +167,7 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
167
167
|
src: dom.getAttribute('src') || '',
|
|
168
168
|
alt: dom.getAttribute('alt'),
|
|
169
169
|
title: dom.getAttribute('title') || dom.getAttribute('alt'),
|
|
170
|
-
width: dom.getAttribute('width')
|
|
170
|
+
width: dom.getAttribute('width'),
|
|
171
171
|
};
|
|
172
172
|
},
|
|
173
173
|
},
|
|
@@ -276,8 +276,11 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
276
276
|
img.src = src;
|
|
277
277
|
|
|
278
278
|
img.onerror = () => {
|
|
279
|
+
const pos = getPos();
|
|
280
|
+
if (!pos) return;
|
|
281
|
+
|
|
279
282
|
const { tr } = view.state;
|
|
280
|
-
const _tr = tr.setNodeMarkup(
|
|
283
|
+
const _tr = tr.setNodeMarkup(pos, nodeType, {
|
|
281
284
|
...node.attrs,
|
|
282
285
|
src,
|
|
283
286
|
loading: false,
|
|
@@ -288,7 +291,11 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
288
291
|
|
|
289
292
|
img.onload = () => {
|
|
290
293
|
const { tr } = view.state;
|
|
291
|
-
|
|
294
|
+
|
|
295
|
+
const pos = getPos();
|
|
296
|
+
if (!pos) return;
|
|
297
|
+
|
|
298
|
+
const _tr = tr.setNodeMarkup(pos, nodeType, {
|
|
292
299
|
...node.attrs,
|
|
293
300
|
width: img.width,
|
|
294
301
|
src,
|
|
@@ -303,7 +310,9 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
303
310
|
content.src = src;
|
|
304
311
|
content.title = title || alt;
|
|
305
312
|
content.alt = alt;
|
|
306
|
-
|
|
313
|
+
if (width) {
|
|
314
|
+
content.width = width;
|
|
315
|
+
}
|
|
307
316
|
|
|
308
317
|
if (src.length === 0) {
|
|
309
318
|
container.classList.add('system', 'empty');
|
|
@@ -321,7 +330,9 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
321
330
|
content.src = src;
|
|
322
331
|
content.alt = alt;
|
|
323
332
|
content.title = title || alt;
|
|
324
|
-
|
|
333
|
+
if (width) {
|
|
334
|
+
content.width = width;
|
|
335
|
+
}
|
|
325
336
|
if (loading) {
|
|
326
337
|
loadImage(src);
|
|
327
338
|
return true;
|
package/src/node/list-item.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { css } from '@emotion/css';
|
|
3
2
|
import { createCmd, createCmdKey } from '@milkdown/core';
|
|
4
3
|
import { liftListItem, sinkListItem, splitListItem, wrappingInputRule } from '@milkdown/prose';
|
|
5
4
|
import { createNode, createShortcut } from '@milkdown/utils';
|
|
@@ -16,7 +15,7 @@ export const LiftListItem = createCmdKey();
|
|
|
16
15
|
|
|
17
16
|
export const listItem = createNode<Keys>((utils) => {
|
|
18
17
|
const style = utils.getStyle(
|
|
19
|
-
(themeTool) =>
|
|
18
|
+
(themeTool, { css }) =>
|
|
20
19
|
css`
|
|
21
20
|
&,
|
|
22
21
|
& > * {
|
package/src/node/ordered-list.ts
CHANGED
|
@@ -64,6 +64,6 @@ export const orderedList = createNode<Keys>((utils) => ({
|
|
|
64
64
|
],
|
|
65
65
|
commands: (nodeType) => [createCmd(WrapInOrderedList, () => wrapIn(nodeType))],
|
|
66
66
|
shortcuts: {
|
|
67
|
-
[SupportedKeys.OrderedList]: createShortcut(WrapInOrderedList, 'Mod-
|
|
67
|
+
[SupportedKeys.OrderedList]: createShortcut(WrapInOrderedList, 'Mod-Alt-7'),
|
|
68
68
|
},
|
|
69
69
|
}));
|