@milkdown/preset-commonmark 5.2.1 → 5.3.3
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 +73 -53
- 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 +1 -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 +13 -25
- 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 +36 -26
- package/src/node/hr.ts +1 -2
- package/src/node/image.ts +10 -7
- 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,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;AACF,eAAO,MAAM,KAAK;;;;EAkVhB,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.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "5.3.3",
|
|
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,25 +16,19 @@
|
|
|
22
16
|
"markdown",
|
|
23
17
|
"commonmark"
|
|
24
18
|
],
|
|
25
|
-
"peerDependencies": {
|
|
26
|
-
"@milkdown/core": "*"
|
|
27
|
-
},
|
|
28
19
|
"dependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@milkdown/
|
|
31
|
-
"
|
|
20
|
+
"@milkdown/prose": "5.3.3",
|
|
21
|
+
"@milkdown/core": "5.3.3",
|
|
22
|
+
"@milkdown/design-system": "5.3.3",
|
|
23
|
+
"@milkdown/utils": "5.3.3",
|
|
24
|
+
"remark-inline-links": "^6.0.0",
|
|
32
25
|
"tslib": "^2.3.1"
|
|
33
26
|
},
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"@milkdown/prose": "5.2.1",
|
|
36
|
-
"@milkdown/core": "5.2.1",
|
|
37
|
-
"@milkdown/design-system": "5.2.1"
|
|
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
|
|
45
|
-
}
|
|
31
|
+
"build": "vite build"
|
|
32
|
+
},
|
|
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"
|
|
46
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,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 { setBlockType, textblockTypeInputRule } from '@milkdown/prose';
|
|
5
4
|
import { createNode, createShortcut } from '@milkdown/utils';
|
|
@@ -20,44 +19,55 @@ type Keys =
|
|
|
20
19
|
|
|
21
20
|
export const TurnIntoHeading = createCmdKey<number>();
|
|
22
21
|
|
|
23
|
-
export const heading = createNode<Keys>((utils
|
|
22
|
+
export const heading = createNode<Keys>((utils) => {
|
|
24
23
|
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
24
|
|
|
40
25
|
const style = (level: number) =>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
26
|
+
utils.getStyle((_, { css }) => {
|
|
27
|
+
const headingMap: Record<number, string> = {
|
|
28
|
+
1: css`
|
|
29
|
+
font-size: 3rem;
|
|
30
|
+
line-height: 3.5rem;
|
|
31
|
+
`,
|
|
32
|
+
2: css`
|
|
33
|
+
font-size: 2.5rem;
|
|
34
|
+
line-height: 3rem;
|
|
35
|
+
`,
|
|
36
|
+
3: css`
|
|
37
|
+
font-size: 2.125rem;
|
|
38
|
+
line-height: 2.25rem;
|
|
39
|
+
`,
|
|
40
|
+
4: css`
|
|
41
|
+
font-size: 1.75rem;
|
|
42
|
+
line-height: 2rem;
|
|
43
|
+
`,
|
|
44
|
+
5: css`
|
|
45
|
+
font-size: 1.5rem;
|
|
46
|
+
line-height: 1.5rem;
|
|
47
|
+
`,
|
|
48
|
+
6: css`
|
|
49
|
+
font-size: 1.25rem;
|
|
50
|
+
line-height: 1.25rem;
|
|
51
|
+
`,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return css`
|
|
55
|
+
${headingMap[level] || ''}
|
|
56
|
+
margin: 2.5rem 0 !important;
|
|
57
|
+
font-weight: 400;
|
|
58
|
+
`;
|
|
59
|
+
});
|
|
48
60
|
|
|
49
61
|
return {
|
|
50
62
|
id,
|
|
51
63
|
schema: () => ({
|
|
52
64
|
content: 'inline*',
|
|
53
65
|
group: 'block',
|
|
66
|
+
defining: true,
|
|
54
67
|
attrs: {
|
|
55
68
|
level: {
|
|
56
69
|
default: 1,
|
|
57
70
|
},
|
|
58
|
-
id: {
|
|
59
|
-
default: '',
|
|
60
|
-
},
|
|
61
71
|
},
|
|
62
72
|
parseDOM: headingIndex.map((x) => ({ tag: `h${x}`, attrs: { level: x } })),
|
|
63
73
|
toDOM: (node) => {
|
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';
|
|
@@ -25,7 +24,7 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
25
24
|
};
|
|
26
25
|
const isBlock = options?.isBlock ?? false;
|
|
27
26
|
const containerStyle = utils.getStyle(
|
|
28
|
-
(themeTool) =>
|
|
27
|
+
(themeTool, { css }) =>
|
|
29
28
|
css`
|
|
30
29
|
display: inline-block;
|
|
31
30
|
position: relative;
|
|
@@ -123,7 +122,7 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
123
122
|
);
|
|
124
123
|
|
|
125
124
|
const style = utils.getStyle(
|
|
126
|
-
() =>
|
|
125
|
+
(_, { css }) =>
|
|
127
126
|
css`
|
|
128
127
|
display: inline-block;
|
|
129
128
|
margin: 0 auto;
|
|
@@ -152,7 +151,7 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
152
151
|
title: { default: null },
|
|
153
152
|
failed: { default: false },
|
|
154
153
|
loading: { default: true },
|
|
155
|
-
width: { default:
|
|
154
|
+
width: { default: null },
|
|
156
155
|
},
|
|
157
156
|
parseDOM: [
|
|
158
157
|
{
|
|
@@ -167,7 +166,7 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
167
166
|
src: dom.getAttribute('src') || '',
|
|
168
167
|
alt: dom.getAttribute('alt'),
|
|
169
168
|
title: dom.getAttribute('title') || dom.getAttribute('alt'),
|
|
170
|
-
width: dom.getAttribute('width')
|
|
169
|
+
width: dom.getAttribute('width'),
|
|
171
170
|
};
|
|
172
171
|
},
|
|
173
172
|
},
|
|
@@ -303,7 +302,9 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
303
302
|
content.src = src;
|
|
304
303
|
content.title = title || alt;
|
|
305
304
|
content.alt = alt;
|
|
306
|
-
|
|
305
|
+
if (width) {
|
|
306
|
+
content.width = width;
|
|
307
|
+
}
|
|
307
308
|
|
|
308
309
|
if (src.length === 0) {
|
|
309
310
|
container.classList.add('system', 'empty');
|
|
@@ -321,7 +322,9 @@ export const image = createNode<string, ImageOptions>((utils, options) => {
|
|
|
321
322
|
content.src = src;
|
|
322
323
|
content.alt = alt;
|
|
323
324
|
content.title = title || alt;
|
|
324
|
-
|
|
325
|
+
if (width) {
|
|
326
|
+
content.width = width;
|
|
327
|
+
}
|
|
325
328
|
if (loading) {
|
|
326
329
|
loadImage(src);
|
|
327
330
|
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
|
}));
|
package/src/node/paragraph.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 { setBlockType } from '@milkdown/prose';
|
|
5
4
|
import { createNode, createShortcut } from '@milkdown/utils';
|
|
@@ -11,14 +10,14 @@ type Keys = SupportedKeys['Text'];
|
|
|
11
10
|
export const TurnIntoText = createCmdKey();
|
|
12
11
|
|
|
13
12
|
const id = 'paragraph';
|
|
14
|
-
export const paragraph = createNode<Keys>((utils
|
|
15
|
-
const style =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
export const paragraph = createNode<Keys>((utils) => {
|
|
14
|
+
const style = utils.getStyle((_, { css }) => {
|
|
15
|
+
return css`
|
|
16
|
+
font-size: 1rem;
|
|
17
|
+
line-height: 1.5;
|
|
18
|
+
letter-spacing: 0.5px;
|
|
19
|
+
`;
|
|
20
|
+
});
|
|
22
21
|
|
|
23
22
|
return {
|
|
24
23
|
id,
|