remons-markdown-editor 1.0.0-beta.3 → 1.0.0-beta.5

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.
Files changed (33) hide show
  1. package/dist/App.d.ts +2 -0
  2. package/dist/MarkdownEditor.d.ts +23 -0
  3. package/dist/components/Dialog/EditDialog.d.ts +21 -0
  4. package/dist/components/Editor/codemirrorExtensions.d.ts +12 -0
  5. package/dist/components/Editor/containerWidget.d.ts +20 -0
  6. package/dist/components/Editor/index.d.ts +16 -0
  7. package/dist/components/Panel/SplitPanels.d.ts +7 -0
  8. package/dist/components/Preview/index.d.ts +10 -0
  9. package/dist/components/Toolbar/buttons.d.ts +34 -0
  10. package/dist/components/Toolbar/config.d.ts +6 -0
  11. package/dist/components/Toolbar/hooks/useToolbar.d.ts +13 -0
  12. package/dist/components/Toolbar/index.d.ts +13 -0
  13. package/dist/components/Toolbar/renderers/TablePicker/TableDropdown.d.ts +5 -0
  14. package/dist/components/Toolbar/renderers/TablePicker/index.d.ts +9 -0
  15. package/dist/components/Toolbar/renderers/ToolbarItemRenderer.d.ts +7 -0
  16. package/dist/hooks/useFullscreen.d.ts +4 -0
  17. package/dist/hooks/useRegisterToolbar.d.ts +51 -0
  18. package/dist/hooks/useScrollSync.d.ts +5 -0
  19. package/dist/index.cjs +1325 -1207
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.css +108 -88
  22. package/dist/index.d.ts +5 -105
  23. package/dist/index.js +1301 -1187
  24. package/dist/index.js.map +1 -1
  25. package/dist/main.d.ts +0 -0
  26. package/dist/registry/componentRegistry.d.ts +34 -0
  27. package/dist/types/index.d.ts +76 -0
  28. package/dist/utils/parseContainer.d.ts +18 -0
  29. package/dist/utils/writeContainer.d.ts +16 -0
  30. package/package.json +7 -7
  31. package/readme.md +103 -4
  32. package/dist/index.css.map +0 -1
  33. package/dist/index.d.cts +0 -105
package/dist/index.css CHANGED
@@ -1,7 +1,4 @@
1
- @import "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;600;700&display=swap";
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
- .grid {
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
- .grid .cell {
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
- .grid .cell.cellActive {
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
- .hint {
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
- .label {
36
+ .index-module__label___2CmK1 {
40
37
  margin-top: 8px;
41
38
  font-size: 13px;
42
39
  color: #666;
@@ -44,12 +41,108 @@
44
41
  min-height: 20px;
45
42
  text-align: center;
46
43
  }
44
+ * {
45
+ margin: 0;
46
+ padding: 0;
47
+ box-sizing: border-box;
48
+ }
49
+
50
+ body {
51
+ margin: 0;
52
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
53
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
54
+ sans-serif;
55
+ -webkit-font-smoothing: antialiased;
56
+ -moz-osx-font-smoothing: grayscale;
57
+ }
58
+
59
+ #root {
60
+ height: 100vh;
61
+ width: 100vw;
62
+ overflow: hidden;
63
+ }
64
+
65
+ /* ===== CSS 自定义属性(主题变量) ===== */
66
+ /* 浅色主题(默认) */
67
+ :root,
68
+ [data-theme="light"] {
69
+ --markdown-editor-color-bg-white: rgba(255, 255, 255, 0.6);
70
+
71
+ /* ── 边框(毛玻璃) ── */
72
+ --markdown-editor-color-border: rgba(255, 255, 255, 0.8);
73
+ }
47
74
 
48
- /* src/App.css */
75
+ /* ===== 深色主题 ===== */
76
+ [data-theme="dark"] {
77
+ --markdown-editor-color-bg-white: rgba(46, 51, 80, 0.8);
78
+
79
+ --markdown-editor-color-border: rgba(255, 255, 255, 0.1);
80
+ }
81
+
82
+ .ant-anchor-link-title {
83
+ white-space: inherit !important;
84
+ }
85
+ @font-face {
86
+ font-family: 'Inter';
87
+ font-style: normal;
88
+ font-weight: 400;
89
+ font-display: swap;
90
+ src: url(https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfMZg.ttf) format('truetype');
91
+ }
92
+ @font-face {
93
+ font-family: 'Inter';
94
+ font-style: normal;
95
+ font-weight: 500;
96
+ font-display: swap;
97
+ src: url(https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuI6fMZg.ttf) format('truetype');
98
+ }
99
+ @font-face {
100
+ font-family: 'Inter';
101
+ font-style: normal;
102
+ font-weight: 600;
103
+ font-display: swap;
104
+ src: url(https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuGKYMZg.ttf) format('truetype');
105
+ }
106
+ @font-face {
107
+ font-family: 'Inter';
108
+ font-style: normal;
109
+ font-weight: 700;
110
+ font-display: swap;
111
+ src: url(https://fonts.gstatic.com/s/inter/v20/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuFuYMZg.ttf) format('truetype');
112
+ }
113
+ @font-face {
114
+ font-family: 'Noto Sans SC';
115
+ font-style: normal;
116
+ font-weight: 400;
117
+ font-display: swap;
118
+ src: url(https://fonts.gstatic.com/s/notosanssc/v40/k3kCo84MPvpLmixcA63oeAL7Iqp5IZJF9bmaG9_FnYw.ttf) format('truetype');
119
+ }
120
+ @font-face {
121
+ font-family: 'Noto Sans SC';
122
+ font-style: normal;
123
+ font-weight: 500;
124
+ font-display: swap;
125
+ src: url(https://fonts.gstatic.com/s/notosanssc/v40/k3kCo84MPvpLmixcA63oeAL7Iqp5IZJF9bmaG-3FnYw.ttf) format('truetype');
126
+ }
127
+ @font-face {
128
+ font-family: 'Noto Sans SC';
129
+ font-style: normal;
130
+ font-weight: 600;
131
+ font-display: swap;
132
+ src: url(https://fonts.gstatic.com/s/notosanssc/v40/k3kCo84MPvpLmixcA63oeAL7Iqp5IZJF9bmaGwHCnYw.ttf) format('truetype');
133
+ }
134
+ @font-face {
135
+ font-family: 'Noto Sans SC';
136
+ font-style: normal;
137
+ font-weight: 700;
138
+ font-display: swap;
139
+ src: url(https://fonts.gstatic.com/s/notosanssc/v40/k3kCo84MPvpLmixcA63oeAL7Iqp5IZJF9bmaGzjCnYw.ttf) format('truetype');
140
+ }
49
141
  .app {
50
142
  height: 100%;
51
143
  display: flex;
52
144
  flex-direction: column;
145
+ border: 1px solid var(--markdown-editor-color-border);
53
146
  }
54
147
  .app.fullscreen {
55
148
  position: fixed;
@@ -67,7 +160,7 @@
67
160
  display: flex;
68
161
  align-items: center;
69
162
  padding: 4px 8px;
70
- background: #f6f8fa;
163
+ background: var(--markdown-editor-color-bg-white);
71
164
  border-bottom: 1px solid #d0d7de;
72
165
  gap: 4px;
73
166
  overflow-x: auto;
@@ -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
- .link-card {
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
- /*# sourceMappingURL=index.css.map */
285
+ /*$vite$:1*/
package/dist/index.d.ts CHANGED
@@ -1,105 +1,5 @@
1
- import * as react from 'react';
2
- import react__default from 'react';
3
- import { RenderMarkdownProps } from 'remons-render-markdown';
4
- import { EditorView } from '@codemirror/view';
5
- import { EditorState } from '@codemirror/state';
6
-
7
- type PreviewOptions = Omit<RenderMarkdownProps, 'content'> & {
8
- languages?: Record<string, any> | null | undefined;
9
- };
10
-
11
- interface MarkdownEditorRef {
12
- getContent: () => string;
13
- }
14
- interface MarkdownEditorProps {
15
- /** 初始内容 */
16
- defaultValue?: string;
17
- /** 受控内容 */
18
- value?: string;
19
- /** 内容变化回调 */
20
- onChange?: (value: string) => void;
21
- /** 是否显示预览面板 */
22
- showPreview?: boolean;
23
- /** 是否支持全屏 */
24
- fullscreen?: boolean;
25
- /** Preview 渲染配置 */
26
- previewOptions?: PreviewOptions;
27
- }
28
- declare const _default: react.ForwardRefExoticComponent<MarkdownEditorProps & react.RefAttributes<MarkdownEditorRef>>;
29
-
30
- interface ToolbarButtonConfig {
31
- id?: string;
32
- icon?: react__default.ComponentType;
33
- label?: string;
34
- children?: ToolbarButtonConfig[];
35
- handler?: (view: EditorView, state: EditorState) => void;
36
- separatorBefore?: boolean;
37
- customRender?: () => react__default.ReactNode;
38
- }
39
- /**
40
- * 弹窗属性配置
41
- * 用于定义 Markdown 容器中需要填充的属性字段
42
- */
43
- interface DialogField {
44
- /** 字段键名,用于 Markdown 属性填充 */
45
- key: string;
46
- /** 默认值 */
47
- defaultValue?: string;
48
- }
49
- /**
50
- * 组件 Schema
51
- * 每个容器组件(如 :::linkCard)定义可编辑字段和弹窗渲染逻辑
52
- */
53
- interface ComponentSchema {
54
- /** 容器名称,对应 :::name 语法 */
55
- name: string;
56
- /** 工具栏按钮显示的标签 */
57
- label: string;
58
- /** 工具栏按钮显示的图标 */
59
- icon?: react__default.ReactNode;
60
- /** 弹窗属性配置 — 用于定义 Markdown 内容中需要填充的字段 */
61
- fields: DialogField[];
62
- /**
63
- * 弹窗内容渲染函数(必填)
64
- * 接收当前属性值和回调函数,由用户完全自定义弹窗内容的渲染
65
- * @param props 当前属性值,用于回显
66
- * @param onChange 属性变更回调,用于更新表单值
67
- * @returns 弹窗内容的 ReactNode
68
- */
69
- renderDialog: (props: Record<string, string>, onChange: (key: string, value: string) => void) => react__default.ReactNode;
70
- }
71
-
72
- /**
73
- * 注册自定义容器组件到工具栏。支持单个或批量注册。
74
- * 支持 linkCard 形式的 schema(name + fields + renderDialog)。
75
- * fields 定义 Markdown 属性字段,renderDialog 定义弹窗内容。
76
- *
77
- * @example 单个注册
78
- * ```tsx
79
- * const schema: ComponentSchema = {
80
- * name: 'alert',
81
- * label: '警告框',
82
- * icon: <AlertOutlined />,
83
- * fields: [{ key: 'level', defaultValue: 'info' }],
84
- * renderDialog: (props, onChange) => (
85
- * <Input value={props.level} onChange={e => onChange('level', e.target.value)} />
86
- * ),
87
- * }
88
- *
89
- * function MyPage() {
90
- * useRegisterToolbar(schema)
91
- * return <MarkdownEditor />
92
- * }
93
- * ```
94
- *
95
- * @example 批量注册
96
- * ```tsx
97
- * function MyPage() {
98
- * useRegisterToolbar([schema1, schema2, schema3])
99
- * return <MarkdownEditor />
100
- * }
101
- * ```
102
- */
103
- declare function useRegisterToolbar(schemas: ComponentSchema | ComponentSchema[]): void;
104
-
105
- export { type ComponentSchema, type DialogField, _default as MarkdownEditor, type MarkdownEditorProps, type MarkdownEditorRef, type PreviewOptions, 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';