kc-plate-editor 0.2.0 → 0.2.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.
@@ -1,15 +1,34 @@
1
1
  import { Value } from 'platejs';
2
2
  import { ToolbarConfig } from '../../types/toolbar-config';
3
+ import { EditorMode, WordCountResult, OutlineItem, FindOptions, ReplaceOptions } from '../../types/editor-types';
3
4
  import * as React from 'react';
4
5
  export interface PlateEditorProps {
6
+ /** 编辑器内容值(受控模式) */
5
7
  value?: Value;
8
+ /** 内容变化回调 */
6
9
  onChange?: (value: Value) => void;
10
+ /** 自定义插件列表 */
7
11
  plugins?: any[];
12
+ /** 自定义 CSS 类名 */
8
13
  className?: string;
14
+ /** 是否禁用编辑器 */
9
15
  disabled?: boolean;
16
+ /** 是否只读 */
10
17
  readOnly?: boolean;
18
+ /** 挂载时自动聚焦 */
11
19
  autoFocus?: boolean;
20
+ /** 工具栏配置 */
12
21
  toolbarConfig?: ToolbarConfig;
22
+ /** 是否显示工具栏,默认 true */
23
+ showToolbar?: boolean;
24
+ /** 工具栏是否吸顶,默认 true */
25
+ toolbarSticky?: boolean;
26
+ /** 编辑器模式:'edit' | 'view' | 'suggestion' */
27
+ mode?: EditorMode;
28
+ /** 修改状态变化回调 */
29
+ onModifiedChange?: (isModified: boolean) => void;
30
+ /** 全屏状态变化回调 */
31
+ onFullscreenChange?: (isFullscreen: boolean) => void;
13
32
  }
14
33
  export interface PlateEditorRef {
15
34
  getContent: () => Value;
@@ -24,5 +43,29 @@ export interface PlateEditorRef {
24
43
  isEmpty: () => boolean;
25
44
  focus: () => void;
26
45
  blur: () => void;
46
+ isModified: () => boolean;
47
+ resetModifiedState: () => void;
48
+ insertText: (text: string) => void;
49
+ insertMarkdown: (markdown: string) => void;
50
+ toggleMark: (mark: string) => void;
51
+ insertLink: (url: string, text?: string) => void;
52
+ insertImage: (url: string) => void;
53
+ undo: () => void;
54
+ redo: () => void;
55
+ exportAsHtml: (filename?: string) => Promise<void>;
56
+ exportAsMarkdown: (filename?: string) => Promise<void>;
57
+ exportAsPdf: (filename?: string) => Promise<void>;
58
+ exportAsImage: (filename?: string) => Promise<void>;
59
+ find: (searchText: string, options?: FindOptions) => Array<{
60
+ path: number[];
61
+ offset: number;
62
+ length: number;
63
+ }>;
64
+ replace: (searchText: string, replaceText: string, options?: ReplaceOptions) => number;
65
+ getOutline: () => OutlineItem[];
66
+ getWordCount: () => WordCountResult;
67
+ enterFullscreen: () => Promise<void>;
68
+ exitFullscreen: () => Promise<void>;
69
+ isFullscreen: () => boolean;
27
70
  }
28
71
  export declare const PlateEditor: React.ForwardRefExoticComponent<PlateEditorProps & React.RefAttributes<PlateEditorRef>>;
@@ -22,7 +22,7 @@ export interface MyH1Element extends MyTextBlockElement {
22
22
  export interface MyH2Element extends MyTextBlockElement {
23
23
  type: typeof KEYS.h2;
24
24
  }
25
- /** Block props */
25
+ /** 块属性 */
26
26
  export interface MyH3Element extends MyTextBlockElement {
27
27
  type: typeof KEYS.h3;
28
28
  }
@@ -1,5 +1,8 @@
1
1
  import { ToolbarConfig } from '../../../types/toolbar-config';
2
- /**
3
- * Create a configurable toolbar plugin
4
- */
5
- export declare function createConfigurableToolbarKit(config: ToolbarConfig): any[];
2
+ export interface ConfigurableToolbarKitOptions {
3
+ /** 是否显示工具栏,默认 true */
4
+ showToolbar?: boolean;
5
+ /** 工具栏是否吸顶,默认 true */
6
+ toolbarSticky?: boolean;
7
+ }
8
+ export declare function createConfigurableToolbarKit(config: ToolbarConfig, options?: ConfigurableToolbarKitOptions): any[];
@@ -1,5 +1,8 @@
1
1
  import { ToolbarConfig } from '../../types/toolbar-config';
2
2
  export interface ConfigurableToolbarProps {
3
+ /** 工具栏配置 */
3
4
  config: ToolbarConfig;
5
+ /** 是否显示工具栏,默认 true */
6
+ showToolbar?: boolean;
4
7
  }
5
- export declare function ConfigurableToolbar({ config }: ConfigurableToolbarProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function ConfigurableToolbar({ config, showToolbar }: ConfigurableToolbarProps): import("react/jsx-runtime").JSX.Element | null;
@@ -1,2 +1,6 @@
1
1
  import { Toolbar } from './toolbar';
2
- export declare function FixedToolbar(props: React.ComponentProps<typeof Toolbar>): import("react/jsx-runtime").JSX.Element;
2
+ export interface FixedToolbarProps extends React.ComponentProps<typeof Toolbar> {
3
+ /** 工具栏是否吸顶,默认 true */
4
+ sticky?: boolean;
5
+ }
6
+ export declare function FixedToolbar({ sticky, ...props }: FixedToolbarProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ import { ToolbarButton } from './toolbar';
2
+ import * as React from 'react';
3
+ export declare function FullscreenToolbarButton(props: React.ComponentProps<typeof ToolbarButton>): import("react/jsx-runtime").JSX.Element;