zt-react-milkdown 0.1.0
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 +149 -0
- package/dist/commands-CDrea4WB.cjs +1 -0
- package/dist/commands-DoqeX5uJ.js +36 -0
- package/dist/debounce-Bqj_3iJs.cjs +1 -0
- package/dist/debounce-Cuk3VGPr.js +118 -0
- package/dist/dist-BCCSKc3M.cjs +5 -0
- package/dist/dist-C0PSMrs7.cjs +37 -0
- package/dist/dist-CPVooDwj.cjs +2 -0
- package/dist/dist-CxZn1qUo.js +1584 -0
- package/dist/dist-Cxaq2crg.js +409 -0
- package/dist/dist-DaM7GJv6.js +3499 -0
- package/dist/dist-Dhukmh4L.js +7562 -0
- package/dist/dist-mOpTMw1E.cjs +1 -0
- package/dist/floating-ui.dom-CKbcbmJV.js +883 -0
- package/dist/floating-ui.dom-VaZZ2gzS.cjs +1 -0
- package/dist/index.browser-5LtNN9G9.cjs +1 -0
- package/dist/index.browser-D2DmEB8o.js +26 -0
- package/dist/index.cjs +393 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +43325 -0
- package/dist/lib-38nxOnTd.cjs +4 -0
- package/dist/lib-8Tr6mAln.cjs +1 -0
- package/dist/lib-B0rHJ9lJ.js +28 -0
- package/dist/lib-BJgvZywM.cjs +3 -0
- package/dist/lib-BNOSyYeU.cjs +3 -0
- package/dist/lib-C5AzmhNY.cjs +5 -0
- package/dist/lib-C8xOD1Bp.cjs +1 -0
- package/dist/lib-CCUU16r8.js +1081 -0
- package/dist/lib-CK9MEMX-.js +73 -0
- package/dist/lib-D4HMdvmK.cjs +1 -0
- package/dist/lib-DWZA8C0h.cjs +1 -0
- package/dist/lib-Dbe-cVjv.js +367 -0
- package/dist/lib-DkE7Uq2b.js +1886 -0
- package/dist/lib-DzK_kn7a.js +21 -0
- package/dist/lib-IahjxPWM.cjs +3 -0
- package/dist/lib-m8lKZKxK.js +80 -0
- package/dist/lib-r5eNG0sa.js +754 -0
- package/dist/lib-wmHesNI0.js +2223 -0
- package/dist/rolldown-runtime-CerMd-t8.cjs +1 -0
- package/dist/rolldown-runtime-DnwLefa7.js +23 -0
- package/dist/schema-list-DSdBEAWW.js +171 -0
- package/dist/schema-list-bL8FNes5.cjs +1 -0
- package/dist/src/components/ui/button.d.ts +16 -0
- package/dist/src/components/ui/button.d.ts.map +1 -0
- package/dist/src/components/ui/dialog.d.ts +36 -0
- package/dist/src/components/ui/dialog.d.ts.map +1 -0
- package/dist/src/components/ui/popover.d.ts +14 -0
- package/dist/src/components/ui/popover.d.ts.map +1 -0
- package/dist/src/core/commands.d.ts +7 -0
- package/dist/src/core/commands.d.ts.map +1 -0
- package/dist/src/core/createEditor.d.ts +6 -0
- package/dist/src/core/createEditor.d.ts.map +1 -0
- package/dist/src/core/schema.d.ts +8 -0
- package/dist/src/core/schema.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/lib/editor-overlay-position.d.ts +83 -0
- package/dist/src/lib/editor-overlay-position.d.ts.map +1 -0
- package/dist/src/lib/global-scroll-listener.d.ts +9 -0
- package/dist/src/lib/global-scroll-listener.d.ts.map +1 -0
- package/dist/src/lib/utils.d.ts +6 -0
- package/dist/src/lib/utils.d.ts.map +1 -0
- package/dist/src/local/en-US.d.ts +6 -0
- package/dist/src/local/en-US.d.ts.map +1 -0
- package/dist/src/local/i18n.d.ts +10 -0
- package/dist/src/local/i18n.d.ts.map +1 -0
- package/dist/src/local/zh-CN.d.ts +6 -0
- package/dist/src/local/zh-CN.d.ts.map +1 -0
- package/dist/src/plugins/custom/blockquote/blockquote-backspace-lift.d.ts +5 -0
- package/dist/src/plugins/custom/blockquote/blockquote-backspace-lift.d.ts.map +1 -0
- package/dist/src/plugins/custom/blockquote/index.d.ts +3 -0
- package/dist/src/plugins/custom/blockquote/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/code-block/code-block-editable.d.ts +7 -0
- package/dist/src/plugins/custom/code-block/code-block-editable.d.ts.map +1 -0
- package/dist/src/plugins/custom/code-block/code-block-language-picker.d.ts +7 -0
- package/dist/src/plugins/custom/code-block/code-block-language-picker.d.ts.map +1 -0
- package/dist/src/plugins/custom/code-block/code-block-mod-a-select.d.ts +5 -0
- package/dist/src/plugins/custom/code-block/code-block-mod-a-select.d.ts.map +1 -0
- package/dist/src/plugins/custom/code-block/code-block-prism.d.ts +5 -0
- package/dist/src/plugins/custom/code-block/code-block-prism.d.ts.map +1 -0
- package/dist/src/plugins/custom/code-block/index.d.ts +9 -0
- package/dist/src/plugins/custom/code-block/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/cursor/drop-cursor.d.ts +5 -0
- package/dist/src/plugins/custom/cursor/drop-cursor.d.ts.map +1 -0
- package/dist/src/plugins/custom/cursor/gap-cursor.d.ts +5 -0
- package/dist/src/plugins/custom/cursor/gap-cursor.d.ts.map +1 -0
- package/dist/src/plugins/custom/cursor/index.d.ts +5 -0
- package/dist/src/plugins/custom/cursor/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/image/image-editable.d.ts +7 -0
- package/dist/src/plugins/custom/image/image-editable.d.ts.map +1 -0
- package/dist/src/plugins/custom/image/image-resizable-schema.d.ts +41 -0
- package/dist/src/plugins/custom/image/image-resizable-schema.d.ts.map +1 -0
- package/dist/src/plugins/custom/image/image-upload-dialog/ImageUploadDialog.d.ts +31 -0
- package/dist/src/plugins/custom/image/image-upload-dialog/ImageUploadDialog.d.ts.map +1 -0
- package/dist/src/plugins/custom/image/image-upload-dialog/index.d.ts +20 -0
- package/dist/src/plugins/custom/image/image-upload-dialog/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/image/index.d.ts +7 -0
- package/dist/src/plugins/custom/image/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/indent/index.d.ts +3 -0
- package/dist/src/plugins/custom/indent/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/indent/tab-space-indent.d.ts +5 -0
- package/dist/src/plugins/custom/indent/tab-space-indent.d.ts.map +1 -0
- package/dist/src/plugins/custom/list/index.d.ts +3 -0
- package/dist/src/plugins/custom/list/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/list/task-list-toggle.d.ts +5 -0
- package/dist/src/plugins/custom/list/task-list-toggle.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/index.d.ts +7 -0
- package/dist/src/plugins/custom/math/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-backspace-entry.d.ts +5 -0
- package/dist/src/plugins/custom/math/math-backspace-entry.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-block-editable.d.ts +7 -0
- package/dist/src/plugins/custom/math/math-block-editable.d.ts.map +1 -0
- package/dist/src/plugins/custom/math/math-plugin.d.ts +47 -0
- package/dist/src/plugins/custom/math/math-plugin.d.ts.map +1 -0
- package/dist/src/plugins/custom/selection-tooltip/constants.d.ts +7 -0
- package/dist/src/plugins/custom/selection-tooltip/constants.d.ts.map +1 -0
- package/dist/src/plugins/custom/selection-tooltip/index.d.ts +7 -0
- package/dist/src/plugins/custom/selection-tooltip/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/selection-tooltip/mark-logic.d.ts +25 -0
- package/dist/src/plugins/custom/selection-tooltip/mark-logic.d.ts.map +1 -0
- package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts +21 -0
- package/dist/src/plugins/custom/selection-tooltip/tooltip-view.d.ts.map +1 -0
- package/dist/src/plugins/custom/selection-tooltip/types.d.ts +58 -0
- package/dist/src/plugins/custom/selection-tooltip/types.d.ts.map +1 -0
- package/dist/src/plugins/custom/slash-menu/index.d.ts +9 -0
- package/dist/src/plugins/custom/slash-menu/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-commands.d.ts +6 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-commands.d.ts.map +1 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts +23 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-logic.d.ts.map +1 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-view.d.ts +50 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu-view.d.ts.map +1 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts +15 -0
- package/dist/src/plugins/custom/slash-menu/slash-menu.d.ts.map +1 -0
- package/dist/src/plugins/custom/table/index.d.ts +13 -0
- package/dist/src/plugins/custom/table/index.d.ts.map +1 -0
- package/dist/src/plugins/custom/table/table-arrow-entry.d.ts +5 -0
- package/dist/src/plugins/custom/table/table-arrow-entry.d.ts.map +1 -0
- package/dist/src/plugins/custom/table/table-deletion-actions.d.ts +10 -0
- package/dist/src/plugins/custom/table/table-deletion-actions.d.ts.map +1 -0
- package/dist/src/plugins/custom/table/table-focus-actions.d.ts +7 -0
- package/dist/src/plugins/custom/table/table-focus-actions.d.ts.map +1 -0
- package/dist/src/plugins/custom/table/table-more-actions.d.ts +37 -0
- package/dist/src/plugins/custom/table/table-more-actions.d.ts.map +1 -0
- package/dist/src/plugins/custom/table/table-row-insertion.d.ts +35 -0
- package/dist/src/plugins/custom/table/table-row-insertion.d.ts.map +1 -0
- package/dist/src/plugins/custom/table/table-selection.d.ts +30 -0
- package/dist/src/plugins/custom/table/table-selection.d.ts.map +1 -0
- package/dist/src/plugins/preset-common.d.ts +56 -0
- package/dist/src/plugins/preset-common.d.ts.map +1 -0
- package/dist/src/react/components/MilkdownEditor.d.ts +7 -0
- package/dist/src/react/components/MilkdownEditor.d.ts.map +1 -0
- package/dist/src/react/components/index.d.ts +2 -0
- package/dist/src/react/components/index.d.ts.map +1 -0
- package/dist/src/react/context/EditorContext.d.ts +16 -0
- package/dist/src/react/context/EditorContext.d.ts.map +1 -0
- package/dist/src/react/hooks/useCloseOnGlobalScroll.d.ts +5 -0
- package/dist/src/react/hooks/useCloseOnGlobalScroll.d.ts.map +1 -0
- package/dist/src/react/hooks/useControlledState.d.ts +9 -0
- package/dist/src/react/hooks/useControlledState.d.ts.map +1 -0
- package/dist/src/react/hooks/useMilkdownEditor.d.ts +35 -0
- package/dist/src/react/hooks/useMilkdownEditor.d.ts.map +1 -0
- package/dist/src/types/editor.d.ts +233 -0
- package/dist/src/types/editor.d.ts.map +1 -0
- package/dist/src/types/plugin.d.ts +10 -0
- package/dist/src/types/plugin.d.ts.map +1 -0
- package/dist/src/utils/guard.d.ts +5 -0
- package/dist/src/utils/guard.d.ts.map +1 -0
- package/dist/src/utils/markdown.d.ts +9 -0
- package/dist/src/utils/markdown.d.ts.map +1 -0
- package/dist/state-CHAiIqOA.cjs +1 -0
- package/dist/state-DNxqltZl.js +16 -0
- package/dist/style.css +3 -0
- package/package.json +89 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { EditorI18nMessages } from '../../../types/editor';
|
|
3
|
+
/**
|
|
4
|
+
* 表格更多菜单属性。
|
|
5
|
+
*/
|
|
6
|
+
interface TableMoreActionsProps {
|
|
7
|
+
/** 编辑器文案。 */
|
|
8
|
+
messages: EditorI18nMessages;
|
|
9
|
+
/** Popover Portal 挂载容器。 */
|
|
10
|
+
portalContainer?: HTMLElement | null;
|
|
11
|
+
/** 是否允许在当前行上方插入行。 */
|
|
12
|
+
canInsertRowAbove: boolean;
|
|
13
|
+
/** 是否允许在当前列附近插入列。 */
|
|
14
|
+
canInsertColumn: boolean;
|
|
15
|
+
/** 是否允许删除当前行。 */
|
|
16
|
+
canDeleteRow: boolean;
|
|
17
|
+
/** 是否允许删除当前列。 */
|
|
18
|
+
canDeleteColumn: boolean;
|
|
19
|
+
/** 插入上方行回调。 */
|
|
20
|
+
onInsertRowAbove: () => void;
|
|
21
|
+
/** 插入下方行回调。 */
|
|
22
|
+
onInsertRowBelow: () => void;
|
|
23
|
+
/** 插入左侧列回调。 */
|
|
24
|
+
onInsertColumnLeft: () => void;
|
|
25
|
+
/** 插入右侧列回调。 */
|
|
26
|
+
onInsertColumnRight: () => void;
|
|
27
|
+
/** 删除当前行回调。 */
|
|
28
|
+
onDeleteRow: () => void;
|
|
29
|
+
/** 删除当前列回调。 */
|
|
30
|
+
onDeleteColumn: () => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 渲染表格更多操作菜单。
|
|
34
|
+
*/
|
|
35
|
+
export declare const TableMoreActions: (props: TableMoreActionsProps) => ReactElement;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=table-more-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-more-actions.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/custom/table/table-more-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+D,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAEvG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAKhE;;GAEG;AACH,UAAU,qBAAqB;IAC7B,aAAa;IACb,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,2BAA2B;IAC3B,eAAe,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,qBAAqB;IACrB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,qBAAqB;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,iBAAiB;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB;IACjB,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe;IACf,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,eAAe;IACf,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,eAAe;IACf,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B,eAAe;IACf,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC,eAAe;IACf,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,eAAe;IACf,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,qBAAqB,KAAG,YA6M/D,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EditorView } from '@milkdown/prose/view';
|
|
2
|
+
import { FocusedTable } from './table-selection';
|
|
3
|
+
/**
|
|
4
|
+
* 表格行插入方向。
|
|
5
|
+
*/
|
|
6
|
+
export type TableRowInsertDirection = 'above' | 'below';
|
|
7
|
+
/**
|
|
8
|
+
* 表格列插入方向。
|
|
9
|
+
*/
|
|
10
|
+
export type TableColumnInsertDirection = 'left' | 'right';
|
|
11
|
+
/**
|
|
12
|
+
* 表格单元格对齐方式。
|
|
13
|
+
*/
|
|
14
|
+
export type TableCellAlignment = 'left' | 'center' | 'right';
|
|
15
|
+
/**
|
|
16
|
+
* 在目标行上下插入一行。
|
|
17
|
+
*/
|
|
18
|
+
export declare const insertTableRow: (view: EditorView, focusedTable: FocusedTable, direction: TableRowInsertDirection) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 删除目标行(首行表头不允许删除)。
|
|
21
|
+
*/
|
|
22
|
+
export declare const removeTableRow: (view: EditorView, focusedTable: FocusedTable) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 在目标列左右插入一列。
|
|
25
|
+
*/
|
|
26
|
+
export declare const insertTableColumn: (view: EditorView, focusedTable: FocusedTable, direction: TableColumnInsertDirection) => boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 删除目标列(至少保留一列)。
|
|
29
|
+
*/
|
|
30
|
+
export declare const removeTableColumn: (view: EditorView, focusedTable: FocusedTable) => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* 将目标列设置为指定对齐方式。
|
|
33
|
+
*/
|
|
34
|
+
export declare const alignTableColumn: (view: EditorView, focusedTable: FocusedTable, alignment: TableCellAlignment) => boolean;
|
|
35
|
+
//# sourceMappingURL=table-row-insertion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-row-insertion.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/custom/table/table-row-insertion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGtD;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,OAAO,GAAG,OAAO,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,MAAM,GAAG,OAAO,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAoC7D;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,MAAM,UAAU,EAChB,cAAc,YAAY,EAC1B,WAAW,uBAAuB,KACjC,OAUF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,UAAU,EAAE,cAAc,YAAY,KAAG,OAU7E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,UAAU,EAChB,cAAc,YAAY,EAC1B,WAAW,0BAA0B,KACpC,OAUF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,UAAU,EAAE,cAAc,YAAY,KAAG,OAgBhF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,UAAU,EAAE,cAAc,YAAY,EAAE,WAAW,kBAAkB,KAAG,OA4C9G,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Node as ProseNode } from '@milkdown/prose/model';
|
|
2
|
+
import { EditorState } from '@milkdown/prose/state';
|
|
3
|
+
/**
|
|
4
|
+
* 当前聚焦表格信息。
|
|
5
|
+
*/
|
|
6
|
+
export interface FocusedTable {
|
|
7
|
+
/** 表格节点。 */
|
|
8
|
+
tableNode: ProseNode;
|
|
9
|
+
/** 表格起始位置。 */
|
|
10
|
+
tableStart: number;
|
|
11
|
+
/** 表格节点大小。 */
|
|
12
|
+
tableNodeSize: number;
|
|
13
|
+
/** 当前聚焦行索引。 */
|
|
14
|
+
rowIndex: number;
|
|
15
|
+
/** 当前聚焦列索引。 */
|
|
16
|
+
columnIndex: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 解析当前选区所在表格节点与起始位置。
|
|
20
|
+
*/
|
|
21
|
+
export declare const resolveFocusedTable: (state: EditorState) => FocusedTable | null;
|
|
22
|
+
/**
|
|
23
|
+
* 解析指定表格单元格的文本位置。
|
|
24
|
+
*/
|
|
25
|
+
export declare const resolveCellTextPosition: (tableNode: ProseNode, tableStart: number, rowIndex: number, columnIndex: number) => number | null;
|
|
26
|
+
/**
|
|
27
|
+
* 判断当前聚焦列是否可用于列插入。
|
|
28
|
+
*/
|
|
29
|
+
export declare const isFocusedTableColumnValid: (focusedTable: FocusedTable) => boolean;
|
|
30
|
+
//# sourceMappingURL=table-selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-selection.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/custom/table/table-selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAazD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,YAAY;IACZ,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,WAAW,KAAG,YAAY,GAAG,IAuCvE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAClC,WAAW,SAAS,EACpB,YAAY,MAAM,EAClB,UAAU,MAAM,EAChB,aAAa,MAAM,KAClB,MAAM,GAAG,IAyBX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,GAAI,cAAc,YAAY,KAAG,OAQtE,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { EditorPluginDescriptor } from '../types/plugin';
|
|
2
|
+
/**
|
|
3
|
+
* 默认插件导出集合。
|
|
4
|
+
*/
|
|
5
|
+
export interface PresetPluginExports {
|
|
6
|
+
/** listener 插件实例。 */
|
|
7
|
+
listener: unknown;
|
|
8
|
+
/** commonmark 插件实例。 */
|
|
9
|
+
commonmark: unknown;
|
|
10
|
+
/** gfm 插件实例。 */
|
|
11
|
+
gfm: unknown;
|
|
12
|
+
/** 代码块 prism 高亮插件实例。 */
|
|
13
|
+
codeBlockPrism: unknown;
|
|
14
|
+
/** 代码块语言选择器插件实例。 */
|
|
15
|
+
codeBlockLanguagePicker: unknown;
|
|
16
|
+
/** clipboard 插件实例。 */
|
|
17
|
+
clipboard: unknown;
|
|
18
|
+
/** indent 插件实例。 */
|
|
19
|
+
indent: unknown;
|
|
20
|
+
/** 表格方向键进入插件实例。 */
|
|
21
|
+
tableArrowEntry: unknown;
|
|
22
|
+
/** 公式块 Backspace 进入插件实例。 */
|
|
23
|
+
mathBackspaceEntry: unknown;
|
|
24
|
+
/** 引用块首段 Backspace 提升插件实例。 */
|
|
25
|
+
blockquoteBackspaceLift: unknown;
|
|
26
|
+
/** 表格聚焦操作插件实例。 */
|
|
27
|
+
tableFocusActions: unknown;
|
|
28
|
+
/** 选中文本 tooltip 菜单插件实例。 */
|
|
29
|
+
selectionTooltip: unknown;
|
|
30
|
+
/** 块间光标插件实例。 */
|
|
31
|
+
gapCursor: unknown;
|
|
32
|
+
/** 拖拽落点指示器插件实例。 */
|
|
33
|
+
dropCursor: unknown;
|
|
34
|
+
/** math 插件实例(可为单个插件或插件数组)。 */
|
|
35
|
+
math: unknown | unknown[];
|
|
36
|
+
/** 任务列表交互插件实例。 */
|
|
37
|
+
taskListToggle: unknown;
|
|
38
|
+
/** 全局 Tab 空格缩进插件实例。 */
|
|
39
|
+
tabSpaceIndent: unknown;
|
|
40
|
+
/** 代码块内 Mod-A 全选插件实例。 */
|
|
41
|
+
codeBlockModASelect: unknown;
|
|
42
|
+
/** slash 插件实例(可为 null 表示关闭)。 */
|
|
43
|
+
slash?: unknown | null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 默认插件收集配置。
|
|
47
|
+
*/
|
|
48
|
+
export interface ResolvePresetPluginsOptions {
|
|
49
|
+
/** 是否包含运行时延迟注册插件。 */
|
|
50
|
+
includeRuntime?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 基于显式插件导出收集默认插件。
|
|
54
|
+
*/
|
|
55
|
+
export declare const resolvePresetPlugins: (pluginExports: PresetPluginExports, options?: ResolvePresetPluginsOptions) => EditorPluginDescriptor[];
|
|
56
|
+
//# sourceMappingURL=preset-common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset-common.d.ts","sourceRoot":"","sources":["../../../src/plugins/preset-common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,qBAAqB;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,uBAAuB;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB;IAChB,GAAG,EAAE,OAAO,CAAC;IACb,wBAAwB;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,oBAAoB;IACpB,uBAAuB,EAAE,OAAO,CAAC;IACjC,sBAAsB;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB;IACnB,MAAM,EAAE,OAAO,CAAC;IAChB,mBAAmB;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,4BAA4B;IAC5B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,8BAA8B;IAC9B,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB;IAClB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,2BAA2B;IAC3B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,8BAA8B;IAC9B,IAAI,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC;IAC1B,kBAAkB;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,uBAAuB;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,yBAAyB;IACzB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,gCAAgC;IAChC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,qBAAqB;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAoBD;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAC/B,eAAe,mBAAmB,EAClC,UAAS,2BAAgC,KACxC,sBAAsB,EA+BxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MilkdownEditor.d.ts","sourceRoot":"","sources":["../../../../src/react/components/MilkdownEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAqE9D;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,mBAAmB,KAAG,GAAG,CAAC,OA6F/D,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/react/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EditorTheme } from '../../types/editor';
|
|
2
|
+
/**
|
|
3
|
+
* 定义编辑器上下文的数据结构。
|
|
4
|
+
*/
|
|
5
|
+
export interface EditorContextValue {
|
|
6
|
+
/** 当前主题。 */
|
|
7
|
+
theme: EditorTheme;
|
|
8
|
+
}
|
|
9
|
+
/** 编辑器上下文对象。 */
|
|
10
|
+
declare const EditorContext: import('react').Context<EditorContextValue>;
|
|
11
|
+
/**
|
|
12
|
+
* 暴露编辑器上下文读取 Hook。
|
|
13
|
+
*/
|
|
14
|
+
export declare const useEditorContext: () => EditorContextValue;
|
|
15
|
+
export default EditorContext;
|
|
16
|
+
//# sourceMappingURL=EditorContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorContext.d.ts","sourceRoot":"","sources":["../../../../src/react/context/EditorContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY;IACZ,KAAK,EAAE,WAAW,CAAC;CACpB;AAOD,gBAAgB;AAChB,QAAA,MAAM,aAAa,6CAA+D,CAAC;AAEnF;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAO,kBAEnC,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCloseOnGlobalScroll.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/useCloseOnGlobalScroll.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,SAAS,OAAO,EAAE,SAAS,MAAM,IAAI,KAAG,IAsB9E,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 管理编辑器受控与非受控双模式状态。
|
|
3
|
+
*/
|
|
4
|
+
export declare const useControlledState: (value: string | undefined, defaultValue: string | undefined, onChange: ((markdown: string) => void) | undefined) => {
|
|
5
|
+
markdown: string;
|
|
6
|
+
setMarkdown: (markdown: string) => void;
|
|
7
|
+
isControlled: boolean;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useControlledState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useControlledState.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/useControlledState.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,MAAM,GAAG,SAAS,EACzB,cAAc,MAAM,GAAG,SAAS,EAChC,UAAU,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,KACjD;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,OAAO,CAAC;CAiCvB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EditorI18nMessages, EditorLocale, ImageUploadConfig, SlashMenuConfig } from '../../types/editor';
|
|
2
|
+
/**
|
|
3
|
+
* 定义 useMilkdownEditor 的输入参数。
|
|
4
|
+
*/
|
|
5
|
+
export interface UseMilkdownEditorOptions {
|
|
6
|
+
/** Milkdown 编辑器根容器。 */
|
|
7
|
+
root: HTMLElement | null;
|
|
8
|
+
/** 需要同步到编辑器的 markdown。 */
|
|
9
|
+
markdown: string;
|
|
10
|
+
/** 编辑器内部浮层 Portal 容器。 */
|
|
11
|
+
portalContainer: HTMLElement;
|
|
12
|
+
/** 当前是否可编辑。 */
|
|
13
|
+
editable: boolean;
|
|
14
|
+
/** 内容变更外发的防抖时长(毫秒)。 */
|
|
15
|
+
debounceMs: number;
|
|
16
|
+
/** 编辑器文案。 */
|
|
17
|
+
messages?: EditorI18nMessages;
|
|
18
|
+
/** 编辑器语言。 */
|
|
19
|
+
locale?: EditorLocale;
|
|
20
|
+
/** slash 菜单配置。 */
|
|
21
|
+
slashMenu?: SlashMenuConfig;
|
|
22
|
+
/** 图片上传配置。 */
|
|
23
|
+
imageUpload?: ImageUploadConfig;
|
|
24
|
+
/** 编辑器内容变更回调。 */
|
|
25
|
+
onMarkdownChange: (markdown: string) => void;
|
|
26
|
+
/** 编辑器初始化失败回调。 */
|
|
27
|
+
onInitError?: (error: unknown) => void;
|
|
28
|
+
/** 编辑器初始化成功回调。 */
|
|
29
|
+
onInitReady?: () => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 封装 Milkdown 的创建、销毁与外部同步流程。
|
|
33
|
+
*/
|
|
34
|
+
export declare const useMilkdownEditor: (options: UseMilkdownEditorOptions) => void;
|
|
35
|
+
//# sourceMappingURL=useMilkdownEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMilkdownEditor.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/useMilkdownEditor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoB,kBAAkB,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGjI;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,uBAAuB;IACvB,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,eAAe,EAAE,WAAW,CAAC;IAC7B,eAAe;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa;IACb,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,aAAa;IACb,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,kBAAkB;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,cAAc;IACd,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,iBAAiB;IACjB,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,kBAAkB;IAClB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,kBAAkB;IAClB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAS,wBAAwB,KAAG,IA8HrE,CAAC"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 定义编辑器支持的主题类型。
|
|
4
|
+
*/
|
|
5
|
+
export type EditorTheme = 'light' | 'dark';
|
|
6
|
+
/**
|
|
7
|
+
* 定义编辑器支持的语言类型。
|
|
8
|
+
*/
|
|
9
|
+
export type EditorLocale = 'zh-CN' | 'en-US';
|
|
10
|
+
/**
|
|
11
|
+
* 定义编辑器内置文案结构。
|
|
12
|
+
*/
|
|
13
|
+
export interface EditorI18nMessages {
|
|
14
|
+
/** 空内容占位提示。 */
|
|
15
|
+
placeholder: string;
|
|
16
|
+
/** 编辑器初始化失败提示。 */
|
|
17
|
+
initError: string;
|
|
18
|
+
/** 编辑器区域无障碍标签。 */
|
|
19
|
+
editorAriaLabel: string;
|
|
20
|
+
/** 公式块源码输入无障碍标签。 */
|
|
21
|
+
mathBlockSourceAriaLabel: string;
|
|
22
|
+
/** 公式块复制按钮无障碍标签。 */
|
|
23
|
+
mathBlockCopyAriaLabel: string;
|
|
24
|
+
/** 公式块删除按钮无障碍标签。 */
|
|
25
|
+
mathBlockDeleteAriaLabel: string;
|
|
26
|
+
/** 图片删除按钮无障碍标签。 */
|
|
27
|
+
imageDeleteAriaLabel: string;
|
|
28
|
+
/** 表格删除按钮无障碍标签。 */
|
|
29
|
+
tableDeleteAriaLabel: string;
|
|
30
|
+
/** 表格更多按钮无障碍标签。 */
|
|
31
|
+
tableMoreAriaLabel: string;
|
|
32
|
+
/** 表格列左对齐按钮无障碍标签。 */
|
|
33
|
+
tableAlignLeftAriaLabel: string;
|
|
34
|
+
/** 表格列居中按钮无障碍标签。 */
|
|
35
|
+
tableAlignCenterAriaLabel: string;
|
|
36
|
+
/** 表格列右对齐按钮无障碍标签。 */
|
|
37
|
+
tableAlignRightAriaLabel: string;
|
|
38
|
+
/** 表格上方插入行按钮文案。 */
|
|
39
|
+
tableInsertRowAboveLabel: string;
|
|
40
|
+
/** 表格下方插入行按钮文案。 */
|
|
41
|
+
tableInsertRowBelowLabel: string;
|
|
42
|
+
/** 表格左侧插入列按钮文案。 */
|
|
43
|
+
tableInsertColumnLeftLabel: string;
|
|
44
|
+
/** 表格右侧插入列按钮文案。 */
|
|
45
|
+
tableInsertColumnRightLabel: string;
|
|
46
|
+
/** 表格删除当前行按钮文案。 */
|
|
47
|
+
tableDeleteRowLabel: string;
|
|
48
|
+
/** 表格删除当前列按钮文案。 */
|
|
49
|
+
tableDeleteColumnLabel: string;
|
|
50
|
+
/** 公式渲染失败提示。 */
|
|
51
|
+
mathRenderError: string;
|
|
52
|
+
/** 图片上传弹窗标题。 */
|
|
53
|
+
imageUploadDialogTitle: string;
|
|
54
|
+
/** 图片文件拖拽区域提示。 */
|
|
55
|
+
imageUploadDropLabel: string;
|
|
56
|
+
/** 图片文件选择按钮文案。 */
|
|
57
|
+
imageUploadPickFileLabel: string;
|
|
58
|
+
/** 图片文件上传页签文案。 */
|
|
59
|
+
imageUploadFileTab: string;
|
|
60
|
+
/** 图片链接页签文案。 */
|
|
61
|
+
imageUploadUrlTab: string;
|
|
62
|
+
/** 图片链接输入框占位文案。 */
|
|
63
|
+
imageUploadUrlPlaceholder: string;
|
|
64
|
+
/** 图片链接插入按钮文案。 */
|
|
65
|
+
imageUploadInsertUrlLabel: string;
|
|
66
|
+
/** 图片插入确认按钮文案。 */
|
|
67
|
+
imageUploadConfirmLabel: string;
|
|
68
|
+
/** 图片上传中提示。 */
|
|
69
|
+
imageUploadUploadingLabel: string;
|
|
70
|
+
/** 图片上传取消按钮文案。 */
|
|
71
|
+
imageUploadCancelLabel: string;
|
|
72
|
+
/** 图片加载失败提示。 */
|
|
73
|
+
imageUploadLoadFailed: string;
|
|
74
|
+
/** 图片重新选择提示。 */
|
|
75
|
+
imageUploadReselectHint: string;
|
|
76
|
+
/** 图片格式和大小提示。 */
|
|
77
|
+
imageUploadSupportsAndMax: string;
|
|
78
|
+
/** 文件过大错误提示。 */
|
|
79
|
+
imageUploadFileTooLarge: string;
|
|
80
|
+
/** 文件过大错误提示(带体积占位符)。 */
|
|
81
|
+
imageUploadFileSizeExceeded: string;
|
|
82
|
+
/** 非图片文件错误提示。 */
|
|
83
|
+
imageUploadInvalidType: string;
|
|
84
|
+
/** 上传失败错误提示。 */
|
|
85
|
+
imageUploadFailed: string;
|
|
86
|
+
/** 文件读取失败提示。 */
|
|
87
|
+
imageUploadFileReadFailed: string;
|
|
88
|
+
/** 图片链接格式错误提示。 */
|
|
89
|
+
imageUploadInvalidUrl: string;
|
|
90
|
+
/** 图片链接为空错误提示。 */
|
|
91
|
+
imageUploadUrlRequired: string;
|
|
92
|
+
/** 请选择图片或输入链接提示。 */
|
|
93
|
+
imageUploadSelectOrEnterImage: string;
|
|
94
|
+
/** 图片上传等待提示。 */
|
|
95
|
+
imageUploadUploadingWait: string;
|
|
96
|
+
/** 选区工具栏加粗按钮标题。 */
|
|
97
|
+
selectionTooltipStrongTitle: string;
|
|
98
|
+
/** 选区工具栏斜体按钮标题。 */
|
|
99
|
+
selectionTooltipEmTitle: string;
|
|
100
|
+
/** 选区工具栏删除线按钮标题。 */
|
|
101
|
+
selectionTooltipStrikeTitle: string;
|
|
102
|
+
/** 选区工具栏行内代码按钮标题。 */
|
|
103
|
+
selectionTooltipInlineCodeTitle: string;
|
|
104
|
+
/** 选区工具栏链接按钮标题。 */
|
|
105
|
+
selectionTooltipLinkTitle: string;
|
|
106
|
+
/** 选区链接输入占位文案。 */
|
|
107
|
+
selectionLinkInputPlaceholder: string;
|
|
108
|
+
/** 选区链接保存按钮无障碍文案。 */
|
|
109
|
+
selectionLinkSaveAriaLabel: string;
|
|
110
|
+
/** 选区链接移除按钮无障碍文案。 */
|
|
111
|
+
selectionLinkRemoveAriaLabel: string;
|
|
112
|
+
/** 代码块语言搜索占位文案。 */
|
|
113
|
+
codeBlockLanguageSearchPlaceholder: string;
|
|
114
|
+
/** 代码块纯文本语言文案(text)。 */
|
|
115
|
+
codeBlockLanguagePlainText: string;
|
|
116
|
+
/** 代码块复制按钮无障碍标签。 */
|
|
117
|
+
codeBlockCopyAriaLabel: string;
|
|
118
|
+
/** 代码块删除按钮无障碍标签。 */
|
|
119
|
+
codeBlockDeleteAriaLabel: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 定义 slash 菜单支持的命令类型。
|
|
123
|
+
*/
|
|
124
|
+
export type SlashMenuCommand = 'paragraph' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading5' | 'heading6' | 'bulletList' | 'orderedList' | 'taskList' | 'blockquote' | 'inlineCode' | 'codeBlock' | 'mathBlock' | 'table' | 'image';
|
|
125
|
+
/**
|
|
126
|
+
* 定义图片文件上传处理函数。
|
|
127
|
+
*/
|
|
128
|
+
export type ImageUploadHandler = (file: File) => string | Promise<string>;
|
|
129
|
+
/**
|
|
130
|
+
* 定义图片上传配置。
|
|
131
|
+
*/
|
|
132
|
+
export interface ImageUploadConfig {
|
|
133
|
+
/** 自定义图片上传函数,返回可插入文档的图片链接。 */
|
|
134
|
+
upload?: ImageUploadHandler;
|
|
135
|
+
/** 允许上传的最大文件体积(字节)。 */
|
|
136
|
+
maxFileSize?: number;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* 定义 slash 菜单项结构。
|
|
140
|
+
*/
|
|
141
|
+
export interface SlashMenuItem {
|
|
142
|
+
/** 菜单项唯一标识。 */
|
|
143
|
+
id: string;
|
|
144
|
+
/** 菜单项展示文案。 */
|
|
145
|
+
label: string;
|
|
146
|
+
/** 菜单项分组文案。 */
|
|
147
|
+
group: string;
|
|
148
|
+
/** 菜单项图标键名(对应 lucide-react 图标)。 */
|
|
149
|
+
icon?: string;
|
|
150
|
+
/** 菜单项对应命令。 */
|
|
151
|
+
command: SlashMenuCommand;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* 定义 slash 菜单配置结构。
|
|
155
|
+
*/
|
|
156
|
+
export interface SlashMenuConfig {
|
|
157
|
+
/** 是否启用 slash 菜单。 */
|
|
158
|
+
enabled?: boolean;
|
|
159
|
+
/** 菜单项配置。 */
|
|
160
|
+
items?: SlashMenuItem[];
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 定义编辑器变更事件回调。
|
|
164
|
+
*/
|
|
165
|
+
export type EditorChangeHandler = (markdown: string) => void;
|
|
166
|
+
/**
|
|
167
|
+
* 定义 React 编辑器组件的属性。
|
|
168
|
+
*/
|
|
169
|
+
export interface MilkdownEditorProps {
|
|
170
|
+
/** 编辑器受控值。 */
|
|
171
|
+
value?: string;
|
|
172
|
+
/** 编辑器非受控初始值。 */
|
|
173
|
+
defaultValue?: string;
|
|
174
|
+
/** 编辑器内容变化回调。 */
|
|
175
|
+
onChange?: EditorChangeHandler;
|
|
176
|
+
/** 主题模式。 */
|
|
177
|
+
theme?: EditorTheme;
|
|
178
|
+
/** 编辑器语言。 */
|
|
179
|
+
locale?: EditorLocale;
|
|
180
|
+
/** 编辑器文案覆盖项。 */
|
|
181
|
+
messages?: Partial<EditorI18nMessages>;
|
|
182
|
+
/** 容器样式类名。 */
|
|
183
|
+
className?: string;
|
|
184
|
+
/** 占位提示文案。 */
|
|
185
|
+
placeholder?: string;
|
|
186
|
+
/** 是否可编辑。 */
|
|
187
|
+
editable?: boolean;
|
|
188
|
+
/** 编辑区最大高度,超出后在编辑区内部滚动。 */
|
|
189
|
+
maxHeight?: CSSProperties['maxHeight'];
|
|
190
|
+
/** 内容变更回调的防抖时长(毫秒)。 */
|
|
191
|
+
debounceMs?: number;
|
|
192
|
+
/** 额外头部内容。 */
|
|
193
|
+
headerSlot?: ReactNode;
|
|
194
|
+
/** slash 菜单配置。 */
|
|
195
|
+
slashMenu?: SlashMenuConfig;
|
|
196
|
+
/** 图片上传配置。 */
|
|
197
|
+
imageUpload?: ImageUploadConfig;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* 定义创建编辑器时所需参数。
|
|
201
|
+
*/
|
|
202
|
+
export interface CreateEditorOptions {
|
|
203
|
+
/** 绑定的根节点。 */
|
|
204
|
+
root: HTMLElement;
|
|
205
|
+
/** 编辑器内部浮层 Portal 容器。 */
|
|
206
|
+
portalContainer: HTMLElement;
|
|
207
|
+
/** 初始 Markdown 内容。 */
|
|
208
|
+
markdown: string;
|
|
209
|
+
/** 是否允许编辑。 */
|
|
210
|
+
editable: boolean;
|
|
211
|
+
/** 编辑器文案。 */
|
|
212
|
+
messages?: EditorI18nMessages;
|
|
213
|
+
/** 编辑器语言。 */
|
|
214
|
+
locale?: EditorLocale;
|
|
215
|
+
/** slash 菜单配置。 */
|
|
216
|
+
slashMenu?: SlashMenuConfig;
|
|
217
|
+
/** 图片上传配置。 */
|
|
218
|
+
imageUpload?: ImageUploadConfig;
|
|
219
|
+
/** Markdown 变化事件。 */
|
|
220
|
+
onChange: EditorChangeHandler;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* 定义编辑器实例的控制句柄。
|
|
224
|
+
*/
|
|
225
|
+
export interface EditorController {
|
|
226
|
+
/** 销毁编辑器实例。 */
|
|
227
|
+
destroy: () => Promise<void>;
|
|
228
|
+
/** 同步 Markdown 内容。 */
|
|
229
|
+
setMarkdown: (markdown: string) => Promise<void>;
|
|
230
|
+
/** 同步可编辑状态。 */
|
|
231
|
+
setEditable: (editable: boolean) => Promise<void>;
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../src/types/editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE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MAAM,WAAW,gBAAgB;IAC/B,eAAe;IACf,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,sBAAsB;IACtB,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,eAAe;IACf,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/types/plugin.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,cAAc;IACd,IAAI,EAAE,MAAM,CAAC;IACb,YAAY;IACZ,MAAM,EAAE,OAAO,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../../src/utils/guard.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzD,OAAO,CAAC,EACR,KAAK,MAAM,KACV,OAMF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 归一化 Markdown 字符串,避免出现 undefined 输入。
|
|
3
|
+
*/
|
|
4
|
+
export declare const normalizeMarkdown: (markdown: string | undefined) => string;
|
|
5
|
+
/**
|
|
6
|
+
* 判断 Markdown 内容是否为空,用于占位态展示。
|
|
7
|
+
*/
|
|
8
|
+
export declare const isMarkdownEmpty: (markdown: string) => boolean;
|
|
9
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/utils/markdown.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,GAAG,SAAS,KAAG,MAEhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,KAAG,OAElD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./rolldown-runtime-CerMd-t8.cjs`),t=require(`./dist-BCCSKc3M.cjs`);var n=e.n({AllSelection:()=>t.t,EditorState:()=>t.n,NodeSelection:()=>t.r,Plugin:()=>t.i,PluginKey:()=>t.a,Selection:()=>t.o,SelectionRange:()=>t.s,TextSelection:()=>t.c,Transaction:()=>t.l});Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { n as e } from "./rolldown-runtime-DnwLefa7.js";
|
|
2
|
+
import { a as t, c as n, i as r, l as i, n as a, o, r as s, s as c, t as l } from "./dist-DaM7GJv6.js";
|
|
3
|
+
//#region node_modules/.pnpm/@milkdown+prose@7.20.0/node_modules/@milkdown/prose/lib/state.js
|
|
4
|
+
var u = /* @__PURE__ */ e({
|
|
5
|
+
AllSelection: () => l,
|
|
6
|
+
EditorState: () => a,
|
|
7
|
+
NodeSelection: () => s,
|
|
8
|
+
Plugin: () => r,
|
|
9
|
+
PluginKey: () => t,
|
|
10
|
+
Selection: () => o,
|
|
11
|
+
SelectionRange: () => c,
|
|
12
|
+
TextSelection: () => n,
|
|
13
|
+
Transaction: () => i
|
|
14
|
+
});
|
|
15
|
+
//#endregion
|
|
16
|
+
export { u as t };
|