@senyao-design-system/editor 0.0.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/README.md +172 -0
- package/dist/components/Editor.d.ts +11 -0
- package/dist/components/GenericEditor.d.ts +8 -0
- package/dist/components/JSONEditor.d.ts +8 -0
- package/dist/components/SQLEditor.d.ts +8 -0
- package/dist/extensions/features.d.ts +23 -0
- package/dist/extensions/index.d.ts +5 -0
- package/dist/extensions/language.d.ts +18 -0
- package/dist/extensions/readOnlyRanges.d.ts +37 -0
- package/dist/extensions/theme.d.ts +20 -0
- package/dist/extensions/utils.d.ts +36 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +46 -0
- package/dist/index.mjs +2192 -0
- package/dist/types/index.d.ts +110 -0
- package/package.json +42 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Extension } from '../../@codemirror/state';
|
|
2
|
+
import { EditorView } from '../../@codemirror/view';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 只读区域范围接口
|
|
6
|
+
*/
|
|
7
|
+
export interface ReadOnlyRange {
|
|
8
|
+
/**
|
|
9
|
+
* 开始位置
|
|
10
|
+
*/
|
|
11
|
+
start: number;
|
|
12
|
+
/**
|
|
13
|
+
* 结束位置
|
|
14
|
+
*/
|
|
15
|
+
end: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 编辑器变更事件数据
|
|
19
|
+
*/
|
|
20
|
+
export interface EditorChangeEvent {
|
|
21
|
+
/**
|
|
22
|
+
* 编辑器的新值
|
|
23
|
+
*/
|
|
24
|
+
value: string;
|
|
25
|
+
/**
|
|
26
|
+
* 当前的只读区域范围
|
|
27
|
+
*/
|
|
28
|
+
readOnlyRanges: ReadOnlyRange[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 基础编辑器属性接口
|
|
32
|
+
*/
|
|
33
|
+
export interface BaseEditorProps {
|
|
34
|
+
/**
|
|
35
|
+
* 编辑器的值
|
|
36
|
+
*/
|
|
37
|
+
value: string;
|
|
38
|
+
/**
|
|
39
|
+
* 编辑器值变化时的回调函数
|
|
40
|
+
*/
|
|
41
|
+
onChange?: (event: EditorChangeEvent) => void;
|
|
42
|
+
/**
|
|
43
|
+
* 编辑器高度,默认 '300px'
|
|
44
|
+
*/
|
|
45
|
+
height?: string | number;
|
|
46
|
+
/**
|
|
47
|
+
* 是否禁用编辑器
|
|
48
|
+
*/
|
|
49
|
+
disabled?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* 编辑器样式类名
|
|
52
|
+
*/
|
|
53
|
+
className?: string;
|
|
54
|
+
/**
|
|
55
|
+
* 编辑器内联样式
|
|
56
|
+
*/
|
|
57
|
+
style?: React.CSSProperties;
|
|
58
|
+
/**
|
|
59
|
+
* 占位文本
|
|
60
|
+
*/
|
|
61
|
+
placeholder?: string;
|
|
62
|
+
/**
|
|
63
|
+
* 编辑器视图创建后的回调
|
|
64
|
+
*/
|
|
65
|
+
onEditorViewCreated?: (view: EditorView) => void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 通用编辑器属性接口
|
|
69
|
+
*/
|
|
70
|
+
export interface EditorProps extends BaseEditorProps {
|
|
71
|
+
/**
|
|
72
|
+
* 编辑器扩展
|
|
73
|
+
*/
|
|
74
|
+
extensions?: Extension[];
|
|
75
|
+
/**
|
|
76
|
+
* 编辑器语言
|
|
77
|
+
*/
|
|
78
|
+
language?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* SQL 编辑器属性接口
|
|
82
|
+
*/
|
|
83
|
+
export interface SQLEditorProps extends BaseEditorProps {
|
|
84
|
+
/**
|
|
85
|
+
* SQL 编辑器扩展
|
|
86
|
+
*/
|
|
87
|
+
extensions?: Extension[];
|
|
88
|
+
/**
|
|
89
|
+
* 不可编辑区域范围
|
|
90
|
+
*/
|
|
91
|
+
readOnlyRanges?: ReadOnlyRange[];
|
|
92
|
+
/**
|
|
93
|
+
* 是否内部管理只读区域(默认为true)
|
|
94
|
+
*/
|
|
95
|
+
manageReadOnlyRanges?: boolean;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* JSON 编辑器属性接口
|
|
99
|
+
*/
|
|
100
|
+
export interface JSONEditorProps extends BaseEditorProps {
|
|
101
|
+
/**
|
|
102
|
+
* JSON 编辑器扩展
|
|
103
|
+
*/
|
|
104
|
+
extensions?: Extension[];
|
|
105
|
+
/**
|
|
106
|
+
* 是否启用格式化功能
|
|
107
|
+
*/
|
|
108
|
+
enableFormatting?: boolean;
|
|
109
|
+
}
|
|
110
|
+
export type { Extension, EditorView };
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@senyao-design-system/editor",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A flexible editor component based on CodeMirror",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "vite build",
|
|
13
|
+
"dev": "vite build --watch"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"react": "^18.0.0",
|
|
17
|
+
"react-dom": "^18.0.0"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@codemirror/autocomplete": "^6.11.1",
|
|
21
|
+
"@codemirror/commands": "^6.3.0",
|
|
22
|
+
"@codemirror/lang-json": "^6.0.1",
|
|
23
|
+
"@codemirror/lang-sql": "^6.5.4",
|
|
24
|
+
"@codemirror/language": "^6.9.3",
|
|
25
|
+
"@codemirror/lint": "^6.4.2",
|
|
26
|
+
"@codemirror/state": "^6.4.0",
|
|
27
|
+
"@codemirror/view": "^6.22.3",
|
|
28
|
+
"@emotion/react": "^11.11.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@emotion/babel-plugin": "^11.11.0",
|
|
32
|
+
"@types/react": "^18.0.0",
|
|
33
|
+
"@types/react-dom": "^18.0.0",
|
|
34
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
35
|
+
"typescript": "^5.0.0",
|
|
36
|
+
"vite": "^5.0.0",
|
|
37
|
+
"vite-plugin-dts": "^3.6.0"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
42
|
+
}
|