remons-markdown-editor 1.0.0-beta.1 → 1.0.0-beta.10
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/App.d.ts +2 -0
- package/dist/MarkdownEditor.d.ts +23 -0
- package/dist/components/Dialog/EditDialog.d.ts +21 -0
- package/dist/components/Editor/codemirrorExtensions.d.ts +12 -0
- package/dist/components/Editor/containerWidget.d.ts +20 -0
- package/dist/components/Editor/index.d.ts +16 -0
- package/dist/components/Panel/SplitPanels.d.ts +7 -0
- package/dist/components/Preview/index.d.ts +10 -0
- package/dist/components/Toolbar/buttons.d.ts +34 -0
- package/dist/components/Toolbar/config.d.ts +6 -0
- package/dist/components/Toolbar/hooks/useToolbar.d.ts +14 -0
- package/dist/components/Toolbar/index.d.ts +13 -0
- package/dist/components/Toolbar/renderers/TablePicker/TableDropdown.d.ts +5 -0
- package/dist/components/Toolbar/renderers/TablePicker/index.d.ts +9 -0
- package/dist/components/Toolbar/renderers/ToolbarItemRenderer.d.ts +7 -0
- package/dist/hooks/useFullscreen.d.ts +4 -0
- package/dist/hooks/useRegisterToolbar.d.ts +101 -0
- package/dist/hooks/useScrollSync.d.ts +6 -0
- package/dist/index.cjs +1480 -1198
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +110 -90
- package/dist/index.d.ts +5 -90
- package/dist/index.js +1456 -1178
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +0 -0
- package/dist/registry/componentRegistry.d.ts +34 -0
- package/dist/types/index.d.ts +148 -0
- package/dist/utils/parseContainer.d.ts +18 -0
- package/dist/utils/writeContainer.d.ts +16 -0
- package/package.json +14 -16
- package/readme.md +235 -7
- package/dist/index.css.map +0 -1
- package/dist/index.d.cts +0 -90
package/dist/index.css
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/* src/components/Toolbar/renderers/TablePicker/index.module.less */
|
|
4
|
-
.container {
|
|
1
|
+
.index-module__container___l6BT- {
|
|
5
2
|
padding: 4px;
|
|
6
3
|
display: block;
|
|
7
4
|
min-width: 200px;
|
|
@@ -10,13 +7,13 @@
|
|
|
10
7
|
border-radius: 6px;
|
|
11
8
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
12
9
|
}
|
|
13
|
-
.
|
|
10
|
+
.index-module__grid___tCZ-r {
|
|
14
11
|
display: grid;
|
|
15
12
|
gap: 2px;
|
|
16
13
|
transition: all 0.1s ease;
|
|
17
14
|
justify-content: flex-start;
|
|
18
15
|
}
|
|
19
|
-
.
|
|
16
|
+
.index-module__grid___tCZ-r .index-module__cell___vTDQz {
|
|
20
17
|
width: 24px;
|
|
21
18
|
height: 24px;
|
|
22
19
|
border: 1px solid #e8e8e8;
|
|
@@ -25,18 +22,18 @@
|
|
|
25
22
|
cursor: pointer;
|
|
26
23
|
transition: all 0.1s ease;
|
|
27
24
|
}
|
|
28
|
-
.
|
|
25
|
+
.index-module__grid___tCZ-r .index-module__cell___vTDQz.index-module__cellActive___0EYvU {
|
|
29
26
|
border-color: #91caff;
|
|
30
27
|
background: #ddf4ff;
|
|
31
28
|
}
|
|
32
|
-
.
|
|
29
|
+
.index-module__hint___dTObk {
|
|
33
30
|
padding: 12px 16px;
|
|
34
31
|
color: #999;
|
|
35
32
|
font-size: 12px;
|
|
36
33
|
text-align: center;
|
|
37
34
|
cursor: pointer;
|
|
38
35
|
}
|
|
39
|
-
.
|
|
36
|
+
.index-module__label___2CmK1 {
|
|
40
37
|
margin-top: 8px;
|
|
41
38
|
font-size: 13px;
|
|
42
39
|
color: #666;
|
|
@@ -44,14 +41,106 @@
|
|
|
44
41
|
min-height: 20px;
|
|
45
42
|
text-align: center;
|
|
46
43
|
}
|
|
44
|
+
html,
|
|
45
|
+
body {
|
|
46
|
+
margin: 0;
|
|
47
|
+
padding: 0;
|
|
48
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
49
|
+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
50
|
+
sans-serif;
|
|
51
|
+
-webkit-font-smoothing: antialiased;
|
|
52
|
+
-moz-osx-font-smoothing: grayscale;
|
|
53
|
+
}
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
.app {
|
|
55
|
+
#markdown-editor {
|
|
50
56
|
height: 100vh;
|
|
57
|
+
width: 100vw;
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* ===== CSS 自定义属性(主题变量) ===== */
|
|
62
|
+
/* 浅色主题(默认) */
|
|
63
|
+
:root,
|
|
64
|
+
[data-theme="light"] {
|
|
65
|
+
--markdown-editor-color-bg-white: rgba(255, 255, 255, 0.6);
|
|
66
|
+
|
|
67
|
+
/* ── 边框(毛玻璃) ── */
|
|
68
|
+
--markdown-editor-color-border: rgba(255, 255, 255, 0.8);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* ===== 深色主题 ===== */
|
|
72
|
+
[data-theme="dark"] {
|
|
73
|
+
--markdown-editor-color-bg-white: rgba(46, 51, 80, 0.8);
|
|
74
|
+
|
|
75
|
+
--markdown-editor-color-border: rgba(255, 255, 255, 0.1);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.ant-anchor-link-title {
|
|
79
|
+
white-space: inherit !important;
|
|
80
|
+
}@font-face {
|
|
81
|
+
font-family: 'Inter';
|
|
82
|
+
font-style: normal;
|
|
83
|
+
font-weight: 400;
|
|
84
|
+
font-display: swap;
|
|
85
|
+
src: url(https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfMZg.ttf) format('truetype');
|
|
86
|
+
}
|
|
87
|
+
@font-face {
|
|
88
|
+
font-family: 'Inter';
|
|
89
|
+
font-style: normal;
|
|
90
|
+
font-weight: 500;
|
|
91
|
+
font-display: swap;
|
|
92
|
+
src: url(https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuI6fMZg.ttf) format('truetype');
|
|
93
|
+
}
|
|
94
|
+
@font-face {
|
|
95
|
+
font-family: 'Inter';
|
|
96
|
+
font-style: normal;
|
|
97
|
+
font-weight: 600;
|
|
98
|
+
font-display: swap;
|
|
99
|
+
src: url(https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuGKYMZg.ttf) format('truetype');
|
|
100
|
+
}
|
|
101
|
+
@font-face {
|
|
102
|
+
font-family: 'Inter';
|
|
103
|
+
font-style: normal;
|
|
104
|
+
font-weight: 700;
|
|
105
|
+
font-display: swap;
|
|
106
|
+
src: url(https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuFuYMZg.ttf) format('truetype');
|
|
107
|
+
}
|
|
108
|
+
@font-face {
|
|
109
|
+
font-family: 'Noto Sans SC';
|
|
110
|
+
font-style: normal;
|
|
111
|
+
font-weight: 400;
|
|
112
|
+
font-display: swap;
|
|
113
|
+
src: url(https://fonts.gstatic.com/s/notosanssc/v40/k3kCo84MPvpLmixcA63oeAL7Iqp5IZJF9bmaG9_FnYw.ttf) format('truetype');
|
|
114
|
+
}
|
|
115
|
+
@font-face {
|
|
116
|
+
font-family: 'Noto Sans SC';
|
|
117
|
+
font-style: normal;
|
|
118
|
+
font-weight: 500;
|
|
119
|
+
font-display: swap;
|
|
120
|
+
src: url(https://fonts.gstatic.com/s/notosanssc/v40/k3kCo84MPvpLmixcA63oeAL7Iqp5IZJF9bmaG-3FnYw.ttf) format('truetype');
|
|
121
|
+
}
|
|
122
|
+
@font-face {
|
|
123
|
+
font-family: 'Noto Sans SC';
|
|
124
|
+
font-style: normal;
|
|
125
|
+
font-weight: 600;
|
|
126
|
+
font-display: swap;
|
|
127
|
+
src: url(https://fonts.gstatic.com/s/notosanssc/v40/k3kCo84MPvpLmixcA63oeAL7Iqp5IZJF9bmaGwHCnYw.ttf) format('truetype');
|
|
128
|
+
}
|
|
129
|
+
@font-face {
|
|
130
|
+
font-family: 'Noto Sans SC';
|
|
131
|
+
font-style: normal;
|
|
132
|
+
font-weight: 700;
|
|
133
|
+
font-display: swap;
|
|
134
|
+
src: url(https://fonts.gstatic.com/s/notosanssc/v40/k3kCo84MPvpLmixcA63oeAL7Iqp5IZJF9bmaGzjCnYw.ttf) format('truetype');
|
|
135
|
+
}
|
|
136
|
+
.markdown-editor-app {
|
|
137
|
+
height: 100%;
|
|
51
138
|
display: flex;
|
|
52
139
|
flex-direction: column;
|
|
140
|
+
background: #f3f3f3;
|
|
141
|
+
border: 1px solid var(--markdown-editor-color-border);
|
|
53
142
|
}
|
|
54
|
-
.app.fullscreen {
|
|
143
|
+
.markdown-editor-app.fullscreen {
|
|
55
144
|
position: fixed;
|
|
56
145
|
top: 0;
|
|
57
146
|
left: 0;
|
|
@@ -67,7 +156,7 @@
|
|
|
67
156
|
display: flex;
|
|
68
157
|
align-items: center;
|
|
69
158
|
padding: 4px 8px;
|
|
70
|
-
background:
|
|
159
|
+
background: var(--markdown-editor-color-bg-white);
|
|
71
160
|
border-bottom: 1px solid #d0d7de;
|
|
72
161
|
gap: 4px;
|
|
73
162
|
overflow-x: auto;
|
|
@@ -94,6 +183,10 @@
|
|
|
94
183
|
transition: background-color 0.15s, color 0.15s;
|
|
95
184
|
white-space: nowrap;
|
|
96
185
|
}
|
|
186
|
+
.toolbar-button svg {
|
|
187
|
+
width: 16px;
|
|
188
|
+
height: 16px;
|
|
189
|
+
}
|
|
97
190
|
.toolbar-button:hover {
|
|
98
191
|
background: #e1e4e8;
|
|
99
192
|
color: #0969da;
|
|
@@ -142,16 +235,7 @@
|
|
|
142
235
|
height: 100%;
|
|
143
236
|
}
|
|
144
237
|
.cm-scroller {
|
|
145
|
-
font-family:
|
|
146
|
-
Consolas,
|
|
147
|
-
Inter,
|
|
148
|
-
Noto Sans SC,
|
|
149
|
-
-apple-system,
|
|
150
|
-
BlinkMacSystemFont,
|
|
151
|
-
Segoe UI,
|
|
152
|
-
PingFang SC,
|
|
153
|
-
Microsoft YaHei,
|
|
154
|
-
sans-serif !important;
|
|
238
|
+
font-family: Consolas, Inter, 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif !important;
|
|
155
239
|
}
|
|
156
240
|
.cm-editor {
|
|
157
241
|
height: 100%;
|
|
@@ -160,78 +244,14 @@
|
|
|
160
244
|
height: 100%;
|
|
161
245
|
overflow: auto;
|
|
162
246
|
}
|
|
247
|
+
/* 通用容器基类 */
|
|
163
248
|
.md-container {
|
|
164
249
|
margin: 16px 0;
|
|
165
250
|
border-radius: 6px;
|
|
166
251
|
border: 1px solid #d0d7de;
|
|
167
252
|
overflow: hidden;
|
|
168
253
|
}
|
|
169
|
-
|
|
170
|
-
background: #f6f8fa;
|
|
171
|
-
}
|
|
172
|
-
.link-card-content {
|
|
173
|
-
padding: 16px;
|
|
174
|
-
}
|
|
175
|
-
.link-card-title {
|
|
176
|
-
margin: 0 0 4px;
|
|
177
|
-
font-size: 16px;
|
|
178
|
-
font-weight: 600;
|
|
179
|
-
}
|
|
180
|
-
.link-card-title a {
|
|
181
|
-
color: #0969da;
|
|
182
|
-
text-decoration: none;
|
|
183
|
-
}
|
|
184
|
-
.link-card-title a:hover {
|
|
185
|
-
text-decoration: underline;
|
|
186
|
-
}
|
|
187
|
-
.link-card-desc {
|
|
188
|
-
margin: 0;
|
|
189
|
-
font-size: 14px;
|
|
190
|
-
color: #57606a;
|
|
191
|
-
line-height: 1.5;
|
|
192
|
-
}
|
|
193
|
-
.link-card-primary {
|
|
194
|
-
background: #ddf4ff;
|
|
195
|
-
border-color: #54aeff;
|
|
196
|
-
}
|
|
197
|
-
.link-card-primary .link-card-title a {
|
|
198
|
-
color: #0550ae;
|
|
199
|
-
}
|
|
200
|
-
.link-card-warning {
|
|
201
|
-
background: #fff8c5;
|
|
202
|
-
border-color: #d4a72c;
|
|
203
|
-
}
|
|
204
|
-
.link-card-warning .link-card-title a {
|
|
205
|
-
color: #7d4e00;
|
|
206
|
-
}
|
|
207
|
-
.note {
|
|
208
|
-
padding: 12px 16px;
|
|
209
|
-
}
|
|
210
|
-
.note-info {
|
|
211
|
-
background: #ddf4ff;
|
|
212
|
-
border-color: #54aeff;
|
|
213
|
-
}
|
|
214
|
-
.note-tip {
|
|
215
|
-
background: #dafbe1;
|
|
216
|
-
border-color: #4ac26b;
|
|
217
|
-
}
|
|
218
|
-
.note-warning {
|
|
219
|
-
background: #fff8c5;
|
|
220
|
-
border-color: #d4a72c;
|
|
221
|
-
}
|
|
222
|
-
.note-danger {
|
|
223
|
-
background: #ffebe9;
|
|
224
|
-
border-color: #fb857b;
|
|
225
|
-
}
|
|
226
|
-
.note-title {
|
|
227
|
-
margin: 0 0 4px;
|
|
228
|
-
font-size: 14px;
|
|
229
|
-
font-weight: 600;
|
|
230
|
-
}
|
|
231
|
-
.note-text {
|
|
232
|
-
font-size: 14px;
|
|
233
|
-
line-height: 1.5;
|
|
234
|
-
}
|
|
254
|
+
/* 编辑弹窗样式 */
|
|
235
255
|
.edit-dialog {
|
|
236
256
|
padding: 8px 0;
|
|
237
257
|
}
|
|
@@ -262,4 +282,4 @@
|
|
|
262
282
|
resize: vertical;
|
|
263
283
|
font-family: inherit;
|
|
264
284
|
}
|
|
265
|
-
|
|
285
|
+
/*$vite$:1*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,90 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
interface MarkdownEditorRef {
|
|
7
|
-
getContent: () => string;
|
|
8
|
-
}
|
|
9
|
-
interface MarkdownEditorProps {
|
|
10
|
-
/** 初始内容 */
|
|
11
|
-
defaultValue?: string;
|
|
12
|
-
/** 受控内容 */
|
|
13
|
-
value?: string;
|
|
14
|
-
/** 内容变化回调 */
|
|
15
|
-
onChange?: (value: string) => void;
|
|
16
|
-
/** 是否显示预览面板 */
|
|
17
|
-
showPreview?: boolean;
|
|
18
|
-
/** 是否支持全屏 */
|
|
19
|
-
fullscreen?: boolean;
|
|
20
|
-
}
|
|
21
|
-
declare const _default: React.ForwardRefExoticComponent<MarkdownEditorProps & React.RefAttributes<MarkdownEditorRef>>;
|
|
22
|
-
|
|
23
|
-
interface ToolbarButtonConfig {
|
|
24
|
-
id?: string;
|
|
25
|
-
icon?: React__default.ComponentType;
|
|
26
|
-
label?: string;
|
|
27
|
-
children?: ToolbarButtonConfig[];
|
|
28
|
-
handler?: (view: EditorView, state: EditorState) => void;
|
|
29
|
-
separatorBefore?: boolean;
|
|
30
|
-
customRender?: () => React__default.ReactNode;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* 弹窗属性配置
|
|
34
|
-
* 用于定义 Markdown 容器中需要填充的属性字段
|
|
35
|
-
*/
|
|
36
|
-
interface DialogField {
|
|
37
|
-
/** 字段键名,用于 Markdown 属性填充 */
|
|
38
|
-
key: string;
|
|
39
|
-
/** 默认值 */
|
|
40
|
-
defaultValue?: string;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* 组件 Schema
|
|
44
|
-
* 每个容器组件(如 :::linkCard)定义可编辑字段和弹窗渲染逻辑
|
|
45
|
-
*/
|
|
46
|
-
interface ComponentSchema {
|
|
47
|
-
/** 容器名称,对应 :::name 语法 */
|
|
48
|
-
name: string;
|
|
49
|
-
/** 工具栏按钮显示的标签 */
|
|
50
|
-
label: string;
|
|
51
|
-
/** 工具栏按钮显示的图标 */
|
|
52
|
-
icon?: React__default.ReactNode;
|
|
53
|
-
/** 弹窗属性配置 — 用于定义 Markdown 内容中需要填充的字段 */
|
|
54
|
-
fields: DialogField[];
|
|
55
|
-
/**
|
|
56
|
-
* 弹窗内容渲染函数(必填)
|
|
57
|
-
* 接收当前属性值和回调函数,由用户完全自定义弹窗内容的渲染
|
|
58
|
-
* @param props 当前属性值,用于回显
|
|
59
|
-
* @param onChange 属性变更回调,用于更新表单值
|
|
60
|
-
* @returns 弹窗内容的 ReactNode
|
|
61
|
-
*/
|
|
62
|
-
renderDialog: (props: Record<string, string>, onChange: (key: string, value: string) => void) => React__default.ReactNode;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 注册自定义容器组件到工具栏。
|
|
67
|
-
* 支持 linkCard 形式的 schema(name + fields + renderDialog)。
|
|
68
|
-
* fields 定义 Markdown 属性字段,renderDialog 定义弹窗内容。
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```tsx
|
|
72
|
-
* const schema: ComponentSchema = {
|
|
73
|
-
* name: 'alert',
|
|
74
|
-
* label: '警告框',
|
|
75
|
-
* icon: <AlertOutlined />,
|
|
76
|
-
* fields: [{ key: 'level', defaultValue: 'info' }],
|
|
77
|
-
* renderDialog: (props, onChange) => (
|
|
78
|
-
* <Input value={props.level} onChange={e => onChange('level', e.target.value)} />
|
|
79
|
-
* ),
|
|
80
|
-
* }
|
|
81
|
-
*
|
|
82
|
-
* function MyPage() {
|
|
83
|
-
* useRegisterToolbar(schema)
|
|
84
|
-
* return <MarkdownEditor />
|
|
85
|
-
* }
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
declare function useRegisterToolbar(schema: ComponentSchema): void;
|
|
89
|
-
|
|
90
|
-
export { type ComponentSchema, type DialogField, _default as MarkdownEditor, type MarkdownEditorProps, type MarkdownEditorRef, type ToolbarButtonConfig, useRegisterToolbar };
|
|
1
|
+
export { default as MarkdownEditor } from './MarkdownEditor';
|
|
2
|
+
export type { MarkdownEditorProps, MarkdownEditorRef } from './MarkdownEditor';
|
|
3
|
+
export { useRegisterToolbar } from './hooks/useRegisterToolbar';
|
|
4
|
+
export type { ComponentSchema, DialogField, ToolbarButtonConfig, ImageUploadConfig, } from './types';
|
|
5
|
+
export type { PreviewOptions } from './components/Preview';
|