c063 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/libs/default-dark-modern.js +14 -13
- package/dist/libs/default-dark-plus.d.ts +2 -0
- package/dist/libs/default-dark-plus.js +16 -0
- package/dist/libs/default-dark.d.ts +2 -0
- package/dist/libs/default-dark.js +16 -0
- package/dist/libs/default-light-modern.d.ts +2 -0
- package/dist/libs/default-light-modern.js +16 -0
- package/dist/libs/default-light-plus.d.ts +2 -0
- package/dist/libs/default-light-plus.js +16 -0
- package/dist/libs/github-dark-colorblind.d.ts +2 -0
- package/dist/libs/github-dark-colorblind.js +16 -0
- package/dist/libs/github-dark-default.d.ts +2 -0
- package/dist/libs/github-dark-default.js +17 -0
- package/dist/libs/github-dark.d.ts +2 -0
- package/dist/libs/github-dark.js +16 -0
- package/dist/libs/github-light-colorblind.d.ts +2 -0
- package/dist/libs/github-light-colorblind.js +16 -0
- package/dist/libs/github-light-default.d.ts +2 -0
- package/dist/libs/github-light-default.js +16 -0
- package/dist/libs/github-light.d.ts +2 -0
- package/dist/libs/github-light.js +16 -0
- package/dist/libs/index.d.ts +13 -2
- package/dist/libs/index.js +23 -3
- package/dist/libs/visual-studio-light.js +3 -2
- package/dist/types/props.d.ts +1 -1
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/index.js +3 -3
- package/package.json +1 -1
- package/src/libs/default-dark-modern.tsx +14 -13
- package/src/libs/default-dark-plus.tsx +18 -0
- package/src/libs/default-dark.tsx +18 -0
- package/src/libs/default-light-modern.tsx +18 -0
- package/src/libs/default-light-plus.tsx +18 -0
- package/src/libs/github-dark-colorblind.tsx +18 -0
- package/src/libs/github-dark-default.tsx +19 -0
- package/src/libs/github-dark.tsx +18 -0
- package/src/libs/github-light-colorblind.tsx +18 -0
- package/src/libs/github-light-default.tsx +18 -0
- package/src/libs/github-light.tsx +18 -0
- package/src/libs/index.tsx +24 -4
- package/src/libs/visual-studio-light.tsx +3 -2
- package/src/types/props.tsx +3 -2
- package/src/utils/index.ts +3 -3
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export const map = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
function: "#dcdcaa",
|
|
3
|
+
keyword1: "#569cd6",
|
|
4
|
+
keyword2: "#c586c0",
|
|
5
|
+
string: "#ce9178",
|
|
6
|
+
number: "#b5cea8",
|
|
7
|
+
comment: "#6a9955",
|
|
8
|
+
variable: "#9cdcfe",
|
|
9
|
+
constant: "#4fc1ff",
|
|
10
|
+
type: "#4ec9b0",
|
|
11
|
+
brackets1: "#ffd700",
|
|
12
|
+
brackets2: "#da70d6",
|
|
13
|
+
brackets3: "#179fff",
|
|
14
|
+
operator: "#d4d4d4",
|
|
15
|
+
default: "#d4d4d4",
|
|
15
16
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const map = {
|
|
2
|
+
function: "#dcdcaa",
|
|
3
|
+
keyword1: "#569cd6",
|
|
4
|
+
keyword2: "#c586c0",
|
|
5
|
+
string: "#ce9178",
|
|
6
|
+
number: "#b5cea8",
|
|
7
|
+
comment: "#6a9955",
|
|
8
|
+
variable: "#9cdcfe",
|
|
9
|
+
constant: "#4fc1ff",
|
|
10
|
+
type: "#4ec9b0",
|
|
11
|
+
brackets1: "#ffd700",
|
|
12
|
+
brackets2: "#da70d6",
|
|
13
|
+
brackets3: "#179fff",
|
|
14
|
+
operator: "#d4d4d4",
|
|
15
|
+
default: "#d4d4d4",
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const map = {
|
|
2
|
+
function: "#d4d4d4",
|
|
3
|
+
keyword1: "#569cd6",
|
|
4
|
+
keyword2: "#569cd6",
|
|
5
|
+
string: "#ce9178",
|
|
6
|
+
number: "#b5cea8",
|
|
7
|
+
comment: "#6a9955",
|
|
8
|
+
variable: "#d4d4d4",
|
|
9
|
+
constant: "#d4d4d4",
|
|
10
|
+
type: "#d4d4d4",
|
|
11
|
+
brackets1: "#ffd700",
|
|
12
|
+
brackets2: "#da70d6",
|
|
13
|
+
brackets3: "#179fff",
|
|
14
|
+
operator: "#d4d4d4",
|
|
15
|
+
default: "#d4d4d4",
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const map = {
|
|
2
|
+
function: "rgb(121, 94, 38)",
|
|
3
|
+
keyword1: "rgb(0, 0, 255)",
|
|
4
|
+
keyword2: "rgb(175, 0, 219)",
|
|
5
|
+
string: "rgb(163, 21, 21)",
|
|
6
|
+
number: "rgb(9, 134, 88)",
|
|
7
|
+
comment: "rgb(0, 128, 0)",
|
|
8
|
+
variable: "rgb(0, 16, 128)",
|
|
9
|
+
constant: "rgb(0, 112, 193)",
|
|
10
|
+
type: "rgb(0, 0, 255)",
|
|
11
|
+
brackets1: "rgb(4, 49, 250)",
|
|
12
|
+
brackets2: "rgb(49, 147, 49)",
|
|
13
|
+
brackets3: "rgb(123, 56, 20)",
|
|
14
|
+
operator: "rgb(0, 0, 0)",
|
|
15
|
+
default: "rgb(0, 0, 0)",
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const map = {
|
|
2
|
+
function: "#795e26",
|
|
3
|
+
keyword1: "#0000ff",
|
|
4
|
+
keyword2: "#af00db",
|
|
5
|
+
string: "#a31515",
|
|
6
|
+
number: "#098658",
|
|
7
|
+
comment: "#008000",
|
|
8
|
+
variable: "#001080",
|
|
9
|
+
constant: "#0070c1",
|
|
10
|
+
type: "#267f99",
|
|
11
|
+
brackets1: "#0431fa",
|
|
12
|
+
brackets2: "#319331",
|
|
13
|
+
brackets3: "#7b3814",
|
|
14
|
+
operator: "#000000",
|
|
15
|
+
default: "#000000",
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const map = {
|
|
2
|
+
function: "rgb(210, 168, 255)",
|
|
3
|
+
keyword1: "rgb(236, 142, 44)",
|
|
4
|
+
keyword2: "rgb(236, 142, 44)",
|
|
5
|
+
string: "rgb(165, 214, 255)",
|
|
6
|
+
number: "rgb(121, 192, 255)",
|
|
7
|
+
comment: "#rgb(139, 148, 158)",
|
|
8
|
+
variable: "rgb(201, 209, 217)",
|
|
9
|
+
constant: "rgb(121, 192, 255)",
|
|
10
|
+
type: "rgb(236, 142, 44)",
|
|
11
|
+
brackets1: "rgb(121, 192, 255)",
|
|
12
|
+
brackets2: "rgb(121, 192, 255)",
|
|
13
|
+
brackets3: "rgb(227, 179, 65)",
|
|
14
|
+
operator: "rgb(236, 142, 44)",
|
|
15
|
+
default: "rgb(201, 209, 217)",
|
|
16
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const map = {
|
|
2
|
+
function: "#d2a8ff",
|
|
3
|
+
keyword1: "#ff7b72",
|
|
4
|
+
keyword2: "#ff7b72",
|
|
5
|
+
string: "#a5d6ff",
|
|
6
|
+
number: "#79c0ff",
|
|
7
|
+
comment: "##6a737d",
|
|
8
|
+
variable: "#e6edf3",
|
|
9
|
+
constant: "#79c0ff",
|
|
10
|
+
type: "#ff7b72",
|
|
11
|
+
brackets1: "#79c0ff",
|
|
12
|
+
brackets2: "#56d364",
|
|
13
|
+
brackets3: "#e3b341",
|
|
14
|
+
brackets4: "#ffa198",
|
|
15
|
+
operator: "#ff7b72",
|
|
16
|
+
default: "#e6edf3",
|
|
17
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const map = {
|
|
2
|
+
function: "#b392f0",
|
|
3
|
+
keyword1: "#f97583",
|
|
4
|
+
keyword2: "#f97583",
|
|
5
|
+
string: "#9ecbff",
|
|
6
|
+
number: "#79b8ff",
|
|
7
|
+
comment: "##6a737d",
|
|
8
|
+
variable: "#e1e4e8",
|
|
9
|
+
constant: "#79b8ff",
|
|
10
|
+
type: "#f97583",
|
|
11
|
+
brackets1: "#79b8ff",
|
|
12
|
+
brackets2: "#ffab70",
|
|
13
|
+
brackets3: "#b392f0",
|
|
14
|
+
operator: "#f97583",
|
|
15
|
+
default: "#e1e4e8",
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const map = {
|
|
2
|
+
function: "#8250df",
|
|
3
|
+
keyword1: "#b35900",
|
|
4
|
+
keyword2: "#b35900",
|
|
5
|
+
string: "#0a3069",
|
|
6
|
+
number: "#0550ae",
|
|
7
|
+
comment: "#6e7781",
|
|
8
|
+
variable: "#24292f",
|
|
9
|
+
constant: "#0550ae",
|
|
10
|
+
type: "#b35900",
|
|
11
|
+
brackets1: "#0969da",
|
|
12
|
+
brackets2: "#0969da",
|
|
13
|
+
brackets3: "#9a6700",
|
|
14
|
+
operator: "#b35900",
|
|
15
|
+
default: "#24292f",
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const map = {
|
|
2
|
+
function: "#8250df",
|
|
3
|
+
keyword1: "#cf222e",
|
|
4
|
+
keyword2: "#cf222e",
|
|
5
|
+
string: "#0a3069",
|
|
6
|
+
number: "##0550ae",
|
|
7
|
+
comment: "#6e7781",
|
|
8
|
+
variable: "#1f2328",
|
|
9
|
+
constant: "#0550ae",
|
|
10
|
+
type: "#cf222e",
|
|
11
|
+
brackets1: "#0969da",
|
|
12
|
+
brackets2: "#1a7f37",
|
|
13
|
+
brackets3: "#9a6700",
|
|
14
|
+
operator: "#cf222e",
|
|
15
|
+
default: "#24292e",
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const map = {
|
|
2
|
+
function: "#6f42c1",
|
|
3
|
+
keyword1: "#d73a49",
|
|
4
|
+
keyword2: "#d73a49",
|
|
5
|
+
string: "#032f62",
|
|
6
|
+
number: "#005cc5",
|
|
7
|
+
comment: "#6a737d",
|
|
8
|
+
variable: "#24292e",
|
|
9
|
+
constant: "#0070c1",
|
|
10
|
+
type: "#6f42c1",
|
|
11
|
+
brackets1: "#005cc5",
|
|
12
|
+
brackets2: "#e36209",
|
|
13
|
+
brackets3: "#5a32a3",
|
|
14
|
+
operator: "#d73a49",
|
|
15
|
+
default: "#24292e",
|
|
16
|
+
};
|
package/dist/libs/index.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import type { CodeTokenType, CodeTheme } from "../types";
|
|
2
|
-
|
|
2
|
+
declare const _themeRegistry: {
|
|
3
3
|
readonly "default-dark-modern": Record<CodeTokenType, import("csstype").Property.Color | undefined>;
|
|
4
|
+
readonly "default-dark": Record<CodeTokenType, import("csstype").Property.Color | undefined>;
|
|
5
|
+
readonly "default-dark-plus": Record<CodeTokenType, import("csstype").Property.Color | undefined>;
|
|
4
6
|
readonly "visual-studio-light": Record<CodeTokenType, import("csstype").Property.Color | undefined>;
|
|
7
|
+
readonly "default-light-plus": Record<CodeTokenType, import("csstype").Property.Color | undefined>;
|
|
8
|
+
readonly "default-light-modern": Record<CodeTokenType, import("csstype").Property.Color | undefined>;
|
|
9
|
+
readonly "github-light": Record<CodeTokenType, import("csstype").Property.Color | undefined>;
|
|
10
|
+
readonly "github-light-default": Record<CodeTokenType, import("csstype").Property.Color | undefined>;
|
|
11
|
+
readonly "github-light-colorblind": Record<CodeTokenType, import("csstype").Property.Color | undefined>;
|
|
12
|
+
readonly "github-dark": Record<CodeTokenType, import("csstype").Property.Color | undefined>;
|
|
13
|
+
readonly "github-dark-default": Record<CodeTokenType, import("csstype").Property.Color | undefined>;
|
|
14
|
+
readonly "github-dark-colorblind": Record<CodeTokenType, import("csstype").Property.Color | undefined>;
|
|
5
15
|
};
|
|
6
|
-
export declare const themes: (keyof typeof
|
|
16
|
+
export declare const themes: (keyof typeof _themeRegistry)[];
|
|
7
17
|
export declare const themeMap: Record<CodeTheme, Record<CodeTokenType, React.CSSProperties["color"]>>;
|
|
18
|
+
export {};
|
package/dist/libs/index.js
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import { map as darkModern } from "./default-dark-modern";
|
|
2
|
+
import { map as dark } from "./default-dark";
|
|
3
|
+
import { map as darkPlus } from "./default-dark-plus";
|
|
2
4
|
import { map as vsLight } from "./visual-studio-light";
|
|
3
|
-
|
|
5
|
+
import { map as lightPlus } from "./default-light-plus";
|
|
6
|
+
import { map as lightModern } from "./default-light-modern";
|
|
7
|
+
import { map as ghLight } from "./github-light";
|
|
8
|
+
import { map as ghLightDefault } from "./github-light-default";
|
|
9
|
+
import { map as ghLightBilnd } from "./github-light-colorblind";
|
|
10
|
+
import { map as ghDark } from "./github-dark";
|
|
11
|
+
import { map as ghDarkDefault } from "./github-dark-default";
|
|
12
|
+
import { map as ghDarkBilnd } from "./github-dark-colorblind";
|
|
13
|
+
const _themeRegistry = {
|
|
4
14
|
"default-dark-modern": darkModern,
|
|
15
|
+
"default-dark": dark,
|
|
16
|
+
"default-dark-plus": darkPlus,
|
|
5
17
|
"visual-studio-light": vsLight,
|
|
18
|
+
"default-light-plus": lightPlus,
|
|
19
|
+
"default-light-modern": lightModern,
|
|
20
|
+
"github-light": ghLight,
|
|
21
|
+
"github-light-default": ghLightDefault,
|
|
22
|
+
"github-light-colorblind": ghLightBilnd,
|
|
23
|
+
"github-dark": ghDark,
|
|
24
|
+
"github-dark-default": ghDarkDefault,
|
|
25
|
+
"github-dark-colorblind": ghDarkBilnd,
|
|
6
26
|
};
|
|
7
27
|
// 自動推導主題名稱
|
|
8
|
-
export const themes = Object.keys(
|
|
28
|
+
export const themes = Object.keys(_themeRegistry);
|
|
9
29
|
// themeMap 保留給外部使用
|
|
10
|
-
export const themeMap =
|
|
30
|
+
export const themeMap = _themeRegistry;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export const map = {
|
|
2
|
+
function: "#000000",
|
|
2
3
|
keyword1: "#0000ff",
|
|
3
4
|
keyword2: "#0000ff",
|
|
4
|
-
string: "#
|
|
5
|
+
string: "#a31515",
|
|
5
6
|
number: "#098658",
|
|
6
7
|
comment: "#008000",
|
|
7
8
|
variable: "#000000",
|
|
@@ -11,5 +12,5 @@ export const map = {
|
|
|
11
12
|
brackets2: "#319331",
|
|
12
13
|
brackets3: "#7b3814",
|
|
13
14
|
operator: "#000000",
|
|
14
|
-
default: "#
|
|
15
|
+
default: "#800000",
|
|
15
16
|
};
|
package/dist/types/props.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ import { AsComponentProps, OverrideProps } from "./common";
|
|
|
23
23
|
* const token: CodeTokenType = "keyword1";
|
|
24
24
|
* const token2: CodeTokenType = "string";
|
|
25
25
|
*/
|
|
26
|
-
export type CodeTokenType = `keyword${
|
|
26
|
+
export type CodeTokenType = `keyword${number}` | "function" | "string" | "number" | "comment" | "type" | "variable" | "constant" | `brackets${number}` | "operator" | "default";
|
|
27
27
|
/**
|
|
28
28
|
* 表示可用的語法高亮主題名稱。
|
|
29
29
|
* 對應 `themes` 陣列中定義的名稱,例如 `"vscode-dark"`。
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ import { CodeTokenBuilder, CodeTokenProps, CodeTokenType } from "../types";
|
|
|
5
5
|
*
|
|
6
6
|
* 使用方式:
|
|
7
7
|
* ```tsx
|
|
8
|
-
* c063
|
|
9
|
-
* c063
|
|
8
|
+
* c063.keyword1("const") // -> { type: "keyword1", children: "const" }
|
|
9
|
+
* c063.string("'hello'", { as: "code" }) // 可自訂 as 或其他 props
|
|
10
10
|
* ```
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
-
* tokens.push(c063
|
|
13
|
+
* tokens.push(c063.keyword1("const"));
|
|
14
14
|
* tokens.push(c063.string("'Hello'"));
|
|
15
15
|
*
|
|
16
16
|
* @returns 一個以 `CodeTokenType` 為 key 的建構器函式集合
|
package/dist/utils/index.js
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
*
|
|
5
5
|
* 使用方式:
|
|
6
6
|
* ```tsx
|
|
7
|
-
* c063
|
|
8
|
-
* c063
|
|
7
|
+
* c063.keyword1("const") // -> { type: "keyword1", children: "const" }
|
|
8
|
+
* c063.string("'hello'", { as: "code" }) // 可自訂 as 或其他 props
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
|
-
* tokens.push(c063
|
|
12
|
+
* tokens.push(c063.keyword1("const"));
|
|
13
13
|
* tokens.push(c063.string("'Hello'"));
|
|
14
14
|
*
|
|
15
15
|
* @returns 一個以 `CodeTokenType` 為 key 的建構器函式集合
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "c063",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.1",
|
|
5
5
|
"description": "A React component for displaying code snippets with syntax highlighting.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { CodeTokenType } from "../types";
|
|
2
2
|
|
|
3
3
|
export const map: Record<CodeTokenType, React.CSSProperties["color"]> = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
function: "#dcdcaa",
|
|
5
|
+
keyword1: "#569cd6",
|
|
6
|
+
keyword2: "#c586c0",
|
|
7
|
+
string: "#ce9178",
|
|
8
|
+
number: "#b5cea8",
|
|
9
|
+
comment: "#6a9955",
|
|
10
|
+
variable: "#9cdcfe",
|
|
11
|
+
constant: "#4fc1ff",
|
|
12
|
+
type: "#4ec9b0",
|
|
13
|
+
brackets1: "#ffd700",
|
|
14
|
+
brackets2: "#da70d6",
|
|
15
|
+
brackets3: "#179fff",
|
|
16
|
+
operator: "#d4d4d4",
|
|
17
|
+
default: "#d4d4d4",
|
|
17
18
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CodeTokenType } from "../types";
|
|
2
|
+
|
|
3
|
+
export const map: Record<CodeTokenType, React.CSSProperties["color"]> = {
|
|
4
|
+
function: "#dcdcaa",
|
|
5
|
+
keyword1: "#569cd6",
|
|
6
|
+
keyword2: "#c586c0",
|
|
7
|
+
string: "#ce9178",
|
|
8
|
+
number: "#b5cea8",
|
|
9
|
+
comment: "#6a9955",
|
|
10
|
+
variable: "#9cdcfe",
|
|
11
|
+
constant: "#4fc1ff",
|
|
12
|
+
type: "#4ec9b0",
|
|
13
|
+
brackets1: "#ffd700",
|
|
14
|
+
brackets2: "#da70d6",
|
|
15
|
+
brackets3: "#179fff",
|
|
16
|
+
operator: "#d4d4d4",
|
|
17
|
+
default: "#d4d4d4",
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CodeTokenType } from "../types";
|
|
2
|
+
|
|
3
|
+
export const map: Record<CodeTokenType, React.CSSProperties["color"]> = {
|
|
4
|
+
function: "#d4d4d4",
|
|
5
|
+
keyword1: "#569cd6",
|
|
6
|
+
keyword2: "#569cd6",
|
|
7
|
+
string: "#ce9178",
|
|
8
|
+
number: "#b5cea8",
|
|
9
|
+
comment: "#6a9955",
|
|
10
|
+
variable: "#d4d4d4",
|
|
11
|
+
constant: "#d4d4d4",
|
|
12
|
+
type: "#d4d4d4",
|
|
13
|
+
brackets1: "#ffd700",
|
|
14
|
+
brackets2: "#da70d6",
|
|
15
|
+
brackets3: "#179fff",
|
|
16
|
+
operator: "#d4d4d4",
|
|
17
|
+
default: "#d4d4d4",
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CodeTokenType } from "../types";
|
|
2
|
+
|
|
3
|
+
export const map: Record<CodeTokenType, React.CSSProperties["color"]> = {
|
|
4
|
+
function: "rgb(121, 94, 38)",
|
|
5
|
+
keyword1: "rgb(0, 0, 255)",
|
|
6
|
+
keyword2: "rgb(175, 0, 219)",
|
|
7
|
+
string: "rgb(163, 21, 21)",
|
|
8
|
+
number: "rgb(9, 134, 88)",
|
|
9
|
+
comment: "rgb(0, 128, 0)",
|
|
10
|
+
variable: "rgb(0, 16, 128)",
|
|
11
|
+
constant: "rgb(0, 112, 193)",
|
|
12
|
+
type: "rgb(0, 0, 255)",
|
|
13
|
+
brackets1: "rgb(4, 49, 250)",
|
|
14
|
+
brackets2: "rgb(49, 147, 49)",
|
|
15
|
+
brackets3: "rgb(123, 56, 20)",
|
|
16
|
+
operator: "rgb(0, 0, 0)",
|
|
17
|
+
default: "rgb(0, 0, 0)",
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CodeTokenType } from "../types";
|
|
2
|
+
|
|
3
|
+
export const map: Record<CodeTokenType, React.CSSProperties["color"]> = {
|
|
4
|
+
function: "#795e26",
|
|
5
|
+
keyword1: "#0000ff",
|
|
6
|
+
keyword2: "#af00db",
|
|
7
|
+
string: "#a31515",
|
|
8
|
+
number: "#098658",
|
|
9
|
+
comment: "#008000",
|
|
10
|
+
variable: "#001080",
|
|
11
|
+
constant: "#0070c1",
|
|
12
|
+
type: "#267f99",
|
|
13
|
+
brackets1: "#0431fa",
|
|
14
|
+
brackets2: "#319331",
|
|
15
|
+
brackets3: "#7b3814",
|
|
16
|
+
operator: "#000000",
|
|
17
|
+
default: "#000000",
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CodeTokenType } from "../types";
|
|
2
|
+
|
|
3
|
+
export const map: Record<CodeTokenType, React.CSSProperties["color"]> = {
|
|
4
|
+
function: "rgb(210, 168, 255)",
|
|
5
|
+
keyword1: "rgb(236, 142, 44)",
|
|
6
|
+
keyword2: "rgb(236, 142, 44)",
|
|
7
|
+
string: "rgb(165, 214, 255)",
|
|
8
|
+
number: "rgb(121, 192, 255)",
|
|
9
|
+
comment: "#rgb(139, 148, 158)",
|
|
10
|
+
variable: "rgb(201, 209, 217)",
|
|
11
|
+
constant: "rgb(121, 192, 255)",
|
|
12
|
+
type: "rgb(236, 142, 44)",
|
|
13
|
+
brackets1: "rgb(121, 192, 255)",
|
|
14
|
+
brackets2: "rgb(121, 192, 255)",
|
|
15
|
+
brackets3: "rgb(227, 179, 65)",
|
|
16
|
+
operator: "rgb(236, 142, 44)",
|
|
17
|
+
default: "rgb(201, 209, 217)",
|
|
18
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CodeTokenType } from "../types";
|
|
2
|
+
|
|
3
|
+
export const map: Record<CodeTokenType, React.CSSProperties["color"]> = {
|
|
4
|
+
function: "#d2a8ff",
|
|
5
|
+
keyword1: "#ff7b72",
|
|
6
|
+
keyword2: "#ff7b72",
|
|
7
|
+
string: "#a5d6ff",
|
|
8
|
+
number: "#79c0ff",
|
|
9
|
+
comment: "##6a737d",
|
|
10
|
+
variable: "#e6edf3",
|
|
11
|
+
constant: "#79c0ff",
|
|
12
|
+
type: "#ff7b72",
|
|
13
|
+
brackets1: "#79c0ff",
|
|
14
|
+
brackets2: "#56d364",
|
|
15
|
+
brackets3: "#e3b341",
|
|
16
|
+
brackets4: "#ffa198",
|
|
17
|
+
operator: "#ff7b72",
|
|
18
|
+
default: "#e6edf3",
|
|
19
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CodeTokenType } from "../types";
|
|
2
|
+
|
|
3
|
+
export const map: Record<CodeTokenType, React.CSSProperties["color"]> = {
|
|
4
|
+
function: "#b392f0",
|
|
5
|
+
keyword1: "#f97583",
|
|
6
|
+
keyword2: "#f97583",
|
|
7
|
+
string: "#9ecbff",
|
|
8
|
+
number: "#79b8ff",
|
|
9
|
+
comment: "##6a737d",
|
|
10
|
+
variable: "#e1e4e8",
|
|
11
|
+
constant: "#79b8ff",
|
|
12
|
+
type: "#f97583",
|
|
13
|
+
brackets1: "#79b8ff",
|
|
14
|
+
brackets2: "#ffab70",
|
|
15
|
+
brackets3: "#b392f0",
|
|
16
|
+
operator: "#f97583",
|
|
17
|
+
default: "#e1e4e8",
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CodeTokenType } from "../types";
|
|
2
|
+
|
|
3
|
+
export const map: Record<CodeTokenType, React.CSSProperties["color"]> = {
|
|
4
|
+
function: "#8250df",
|
|
5
|
+
keyword1: "#b35900",
|
|
6
|
+
keyword2: "#b35900",
|
|
7
|
+
string: "#0a3069",
|
|
8
|
+
number: "#0550ae",
|
|
9
|
+
comment: "#6e7781",
|
|
10
|
+
variable: "#24292f",
|
|
11
|
+
constant: "#0550ae",
|
|
12
|
+
type: "#b35900",
|
|
13
|
+
brackets1: "#0969da",
|
|
14
|
+
brackets2: "#0969da",
|
|
15
|
+
brackets3: "#9a6700",
|
|
16
|
+
operator: "#b35900",
|
|
17
|
+
default: "#24292f",
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CodeTokenType } from "../types";
|
|
2
|
+
|
|
3
|
+
export const map: Record<CodeTokenType, React.CSSProperties["color"]> = {
|
|
4
|
+
function: "#8250df",
|
|
5
|
+
keyword1: "#cf222e",
|
|
6
|
+
keyword2: "#cf222e",
|
|
7
|
+
string: "#0a3069",
|
|
8
|
+
number: "##0550ae",
|
|
9
|
+
comment: "#6e7781",
|
|
10
|
+
variable: "#1f2328",
|
|
11
|
+
constant: "#0550ae",
|
|
12
|
+
type: "#cf222e",
|
|
13
|
+
brackets1: "#0969da",
|
|
14
|
+
brackets2: "#1a7f37",
|
|
15
|
+
brackets3: "#9a6700",
|
|
16
|
+
operator: "#cf222e",
|
|
17
|
+
default: "#24292e",
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CodeTokenType } from "../types";
|
|
2
|
+
|
|
3
|
+
export const map: Record<CodeTokenType, React.CSSProperties["color"]> = {
|
|
4
|
+
function: "#6f42c1",
|
|
5
|
+
keyword1: "#d73a49",
|
|
6
|
+
keyword2: "#d73a49",
|
|
7
|
+
string: "#032f62",
|
|
8
|
+
number: "#005cc5",
|
|
9
|
+
comment: "#6a737d",
|
|
10
|
+
variable: "#24292e",
|
|
11
|
+
constant: "#0070c1",
|
|
12
|
+
type: "#6f42c1",
|
|
13
|
+
brackets1: "#005cc5",
|
|
14
|
+
brackets2: "#e36209",
|
|
15
|
+
brackets3: "#5a32a3",
|
|
16
|
+
operator: "#d73a49",
|
|
17
|
+
default: "#24292e",
|
|
18
|
+
};
|
package/src/libs/index.tsx
CHANGED
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
import type { CodeTokenType, CodeTheme } from "../types";
|
|
2
2
|
import { map as darkModern } from "./default-dark-modern";
|
|
3
|
+
import { map as dark } from "./default-dark";
|
|
4
|
+
import { map as darkPlus } from "./default-dark-plus";
|
|
3
5
|
import { map as vsLight } from "./visual-studio-light";
|
|
6
|
+
import { map as lightPlus } from "./default-light-plus";
|
|
7
|
+
import { map as lightModern } from "./default-light-modern";
|
|
8
|
+
import { map as ghLight } from "./github-light";
|
|
9
|
+
import { map as ghLightDefault } from "./github-light-default";
|
|
10
|
+
import { map as ghLightBilnd } from "./github-light-colorblind";
|
|
11
|
+
import { map as ghDark } from "./github-dark";
|
|
12
|
+
import { map as ghDarkDefault } from "./github-dark-default";
|
|
13
|
+
import { map as ghDarkBilnd } from "./github-dark-colorblind";
|
|
4
14
|
|
|
5
|
-
|
|
15
|
+
const _themeRegistry = {
|
|
6
16
|
"default-dark-modern": darkModern,
|
|
17
|
+
"default-dark": dark,
|
|
18
|
+
"default-dark-plus": darkPlus,
|
|
7
19
|
"visual-studio-light": vsLight,
|
|
20
|
+
"default-light-plus": lightPlus,
|
|
21
|
+
"default-light-modern": lightModern,
|
|
22
|
+
"github-light": ghLight,
|
|
23
|
+
"github-light-default": ghLightDefault,
|
|
24
|
+
"github-light-colorblind": ghLightBilnd,
|
|
25
|
+
"github-dark": ghDark,
|
|
26
|
+
"github-dark-default": ghDarkDefault,
|
|
27
|
+
"github-dark-colorblind": ghDarkBilnd,
|
|
8
28
|
} as const;
|
|
9
29
|
|
|
10
30
|
// 自動推導主題名稱
|
|
11
31
|
export const themes = Object.keys(
|
|
12
|
-
|
|
13
|
-
) as (keyof typeof
|
|
32
|
+
_themeRegistry
|
|
33
|
+
) as (keyof typeof _themeRegistry)[];
|
|
14
34
|
|
|
15
35
|
// themeMap 保留給外部使用
|
|
16
36
|
export const themeMap: Record<
|
|
17
37
|
CodeTheme,
|
|
18
38
|
Record<CodeTokenType, React.CSSProperties["color"]>
|
|
19
|
-
> =
|
|
39
|
+
> = _themeRegistry;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { CodeTokenType } from "../types";
|
|
2
2
|
|
|
3
3
|
export const map: Record<CodeTokenType, React.CSSProperties["color"]> = {
|
|
4
|
+
function: "#000000",
|
|
4
5
|
keyword1: "#0000ff",
|
|
5
6
|
keyword2: "#0000ff",
|
|
6
|
-
string: "#
|
|
7
|
+
string: "#a31515",
|
|
7
8
|
number: "#098658",
|
|
8
9
|
comment: "#008000",
|
|
9
10
|
variable: "#000000",
|
|
@@ -13,5 +14,5 @@ export const map: Record<CodeTokenType, React.CSSProperties["color"]> = {
|
|
|
13
14
|
brackets2: "#319331",
|
|
14
15
|
brackets3: "#7b3814",
|
|
15
16
|
operator: "#000000",
|
|
16
|
-
default: "#
|
|
17
|
+
default: "#800000",
|
|
17
18
|
};
|
package/src/types/props.tsx
CHANGED
|
@@ -24,14 +24,15 @@ import { AsComponentProps, OverrideProps } from "./common";
|
|
|
24
24
|
* const token2: CodeTokenType = "string";
|
|
25
25
|
*/
|
|
26
26
|
export type CodeTokenType =
|
|
27
|
-
| `keyword${
|
|
27
|
+
| `keyword${number}` // 關鍵字,分兩種樣式層級
|
|
28
|
+
| "function" // 函式名
|
|
28
29
|
| "string" // 字串常值:'abc'、"hello"
|
|
29
30
|
| "number" // 數值常量:123、3.14
|
|
30
31
|
| "comment" // 註解內容:// 或 /* */
|
|
31
32
|
| "type" // 類型定義:type、interface、enum
|
|
32
33
|
| "variable" // 變數名、函式名、類別名等識別符號
|
|
33
34
|
| "constant" // 常數值:例如 enum 值、靜態屬性
|
|
34
|
-
| `brackets${
|
|
35
|
+
| `brackets${number}` // 括號配對,多層不同樣式:(), [], {}
|
|
35
36
|
| "operator" // 運算符號:=、+、*、===、<、>= 等
|
|
36
37
|
| "default"; // 其他符號:, ; . ? ! 等
|
|
37
38
|
|
package/src/utils/index.ts
CHANGED
|
@@ -5,12 +5,12 @@ import { CodeTokenBuilder, CodeTokenProps, CodeTokenType } from "../types";
|
|
|
5
5
|
*
|
|
6
6
|
* 使用方式:
|
|
7
7
|
* ```tsx
|
|
8
|
-
* c063
|
|
9
|
-
* c063
|
|
8
|
+
* c063.keyword1("const") // -> { type: "keyword1", children: "const" }
|
|
9
|
+
* c063.string("'hello'", { as: "code" }) // 可自訂 as 或其他 props
|
|
10
10
|
* ```
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
|
-
* tokens.push(c063
|
|
13
|
+
* tokens.push(c063.keyword1("const"));
|
|
14
14
|
* tokens.push(c063.string("'Hello'"));
|
|
15
15
|
*
|
|
16
16
|
* @returns 一個以 `CodeTokenType` 為 key 的建構器函式集合
|