@wangeditor-next/yjs-for-react 0.1.12 → 0.1.14

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.
@@ -4,10 +4,11 @@
4
4
  */
5
5
  import { ImageElement } from 'packages/basic-modules/src/modules/image/custom-types';
6
6
  import { VideoElement } from 'packages/video-module/src/module/custom-types';
7
- import { Node, NodeEntry, Range } from 'slate';
7
+ import { Descendant, Node, NodeEntry, Range } from 'slate';
8
8
  import { IDomEditor } from '../editor/interface';
9
9
  import { IMenuGroup } from '../menus/interface';
10
10
  import { IUploadConfig } from '../upload';
11
+ import { DOMElement } from '../utils/dom';
11
12
  interface IHoverbarConf {
12
13
  [key: string]: {
13
14
  match?: (editor: IDomEditor, n: Node) => boolean;
@@ -15,6 +16,25 @@ interface IHoverbarConf {
15
16
  };
16
17
  }
17
18
  export type AlertType = 'success' | 'info' | 'warning' | 'error';
19
+ /**
20
+ * EditorEvents 包含所有编辑器的生命周期事件。
21
+ *
22
+ * @property {string} CREATED - 编辑器创建后触发,用于初始化操作。
23
+ * @property {string} DESTROYED - 编辑器销毁时触发,用于清理操作。
24
+ * @property {string} CHANGE - 编辑器内容发生变化时触发,通常用于监听输入或变动。
25
+ * @property {string} SCROLL - 编辑器滚动时触发,用于同步滚动状态或执行相关操作。
26
+ * @property {string} FULLSCREEN - 编辑器进入全屏时触发,通常用于调整布局或容器尺寸。
27
+ * @property {string} UNFULLSCREEN - 编辑器退出全屏时触发,恢复原始布局状态。
28
+ */
29
+ export declare const EditorEvents: {
30
+ readonly CREATED: "created";
31
+ readonly DESTROYED: "destroyed";
32
+ readonly CHANGE: "change";
33
+ readonly SCROLL: "scroll";
34
+ readonly FULLSCREEN: "fullscreen";
35
+ readonly UNFULLSCREEN: "unFullScreen";
36
+ };
37
+ export type EditorEventType = typeof EditorEvents[keyof typeof EditorEvents];
18
38
  export interface ISingleMenuConfig {
19
39
  [key: string]: any;
20
40
  iconSvg?: string;
@@ -70,10 +90,10 @@ interface IInsertVideoConfig {
70
90
  checkVideo: (src: string, poster: string) => string | boolean | undefined;
71
91
  parseVideoSrc: (url: string) => string;
72
92
  }
73
- interface IUploadVideoConfig extends IUploadConfig {
93
+ export interface IUploadVideoConfig extends IUploadConfig {
74
94
  }
75
- interface IUploadImageConfig extends IUploadConfig {
76
- base64LimitSize?: number;
95
+ export interface IUploadImageConfig extends IUploadConfig {
96
+ base64LimitSize: number;
77
97
  }
78
98
  interface ICodeLangConfig {
79
99
  codeLangs: {
@@ -188,4 +208,12 @@ export interface IToolbarConfig {
188
208
  excludeKeys: Array<string>;
189
209
  modalAppendToBody: boolean;
190
210
  }
211
+ type PluginFnType = <T extends IDomEditor>(editor: T) => T;
212
+ export interface ICreateOption {
213
+ selector: string | DOMElement;
214
+ config: Partial<IEditorConfig>;
215
+ content?: Descendant[];
216
+ html?: string;
217
+ plugins: PluginFnType[];
218
+ }
191
219
  export {};
@@ -2,20 +2,9 @@
2
2
  * @description create editor
3
3
  * @author wangfupeng
4
4
  */
5
- import { Descendant } from 'slate';
5
+ import { ICreateOption } from '../config/interface';
6
6
  import { IDomEditor } from '../editor/interface';
7
- import { IEditorConfig } from '../config/interface';
8
- import type { DOMElement } from '../utils/dom';
9
- type PluginFnType = <T extends IDomEditor>(editor: T) => T;
10
- interface ICreateOption {
11
- selector: string | DOMElement;
12
- config: Partial<IEditorConfig>;
13
- content?: Descendant[];
14
- html?: string;
15
- plugins: PluginFnType[];
16
- }
17
7
  /**
18
8
  * 创建编辑器
19
9
  */
20
- export default function (option: Partial<ICreateOption>): import("slate").BaseEditor & IDomEditor & import("slate-history").HistoryEditor;
21
- export {};
10
+ export default function (option: Partial<ICreateOption>): IDomEditor;
@@ -28,3 +28,10 @@ export declare function genDefaultContent(): {
28
28
  * @param html html 字符串
29
29
  */
30
30
  export declare function htmlToContent(editor: IDomEditor, html?: string): Descendant[];
31
+ /**
32
+ * 初始化内容(要在 config 和 plugins 后面)
33
+ */
34
+ export declare function initializeContent(editor: IDomEditor, options: {
35
+ html?: string;
36
+ content?: Descendant[];
37
+ }): Descendant[];
@@ -3,15 +3,15 @@
3
3
  * @author wangfupeng
4
4
  */
5
5
  import './assets/index.less';
6
- import { RenderStyleFnType, IRenderElemConf } from './render/index';
7
- import { styleToHtmlFnType, IElemToHtmlConf } from './to-html/index';
8
- import { IPreParseHtmlConf, ParseStyleHtmlFnType, IParseElemHtmlConf } from './parse-html/index';
9
- import { IRegisterMenuConf } from './menus/index';
10
6
  import { IDomEditor } from './editor/interface';
7
+ import { IRegisterMenuConf } from './menus/index';
8
+ import { IParseElemHtmlConf, IPreParseHtmlConf, ParseStyleHtmlFnType } from './parse-html/index';
9
+ import { IRenderElemConf, RenderStyleFnType } from './render/index';
10
+ import { IElemToHtmlConf, styleToHtmlFnType } from './to-html/index';
11
11
  export * from './create/index';
12
- export { IEditorConfig, IToolbarConfig } from './config/interface';
13
- export * from './editor/interface';
12
+ export { IEditorConfig, IToolbarConfig, IUploadImageConfig, IUploadVideoConfig, } from './config/interface';
14
13
  export * from './editor/dom-editor';
14
+ export * from './editor/interface';
15
15
  export * from './render/index';
16
16
  export * from './to-html/index';
17
17
  export * from './parse-html/index';
@@ -2,9 +2,9 @@
2
2
  * @description classic toolbar
3
3
  * @author wangfupeng
4
4
  */
5
- import { Dom7Array, DOMElement } from '../../utils/dom';
6
- import { IButtonMenu, ISelectMenu, IDropPanelMenu, IModalMenu } from '../interface';
7
5
  import { IToolbarConfig } from '../../config/interface';
6
+ import { Dom7Array, DOMElement } from '../../utils/dom';
7
+ import { IButtonMenu, IDropPanelMenu, IModalMenu, ISelectMenu } from '../interface';
8
8
  type MenuType = IButtonMenu | ISelectMenu | IDropPanelMenu | IModalMenu;
9
9
  declare class Toolbar {
10
10
  $box: Dom7Array;
@@ -6,6 +6,7 @@ import { UppyFile } from '@uppy/core';
6
6
  type FilesType = {
7
7
  [key: string]: UppyFile<{}, {}>;
8
8
  };
9
+ type InsertFn = (src: string, poster?: string, alt?: string, href?: string) => void | Promise<void>;
9
10
  /**
10
11
  * 配置参考 https://uppy.io/docs/uppy/
11
12
  */
@@ -24,5 +25,9 @@ export interface IUploadConfig {
24
25
  onProgress?: (progress: number) => void;
25
26
  onFailed: (file: UppyFile<{}, {}>, response: any) => void;
26
27
  onError: (file: UppyFile<{}, {}>, error: any, res: any) => void;
28
+ allowedFileTypes?: string[];
29
+ customInsert?: (res: any, insertFn: InsertFn) => void;
30
+ customUpload?: (files: File, insertFn: InsertFn) => void;
31
+ customBrowseAndUpload?: (insertFn: InsertFn) => void;
27
32
  }
28
33
  export {};
@@ -2,14 +2,5 @@
2
2
  * @description upload image config
3
3
  * @author wangfupeng
4
4
  */
5
- import { IUploadConfig } from '@wangeditor-next/core';
6
- type InsertFn = (src: string, alt: string, href: string) => void;
7
- export type IUploadConfigForImage = IUploadConfig & {
8
- allowedFileTypes?: string[];
9
- customInsert?: (res: any, insertFn: InsertFn) => void;
10
- customUpload?: (files: File, insertFn: InsertFn) => void;
11
- base64LimitSize: number;
12
- customBrowseAndUpload?: (insertFn: InsertFn) => void;
13
- };
14
- export declare function genUploadImageConfig(): IUploadConfigForImage;
15
- export {};
5
+ import { IUploadImageConfig } from '@wangeditor-next/core';
6
+ export declare function genUploadImageConfig(): IUploadImageConfig;
@@ -6,5 +6,5 @@ import UploadImageMenu from './UploadImageMenu';
6
6
  export declare const uploadImageMenuConf: {
7
7
  key: string;
8
8
  factory(): UploadImageMenu;
9
- config: import("./config").IUploadConfigForImage;
9
+ config: import("@wangeditor-next/core").IUploadImageConfig;
10
10
  };
@@ -2,16 +2,9 @@
2
2
  * @description video menu config
3
3
  * @author wangfupeng
4
4
  */
5
- import { IUploadConfig } from '@wangeditor-next/core';
5
+ import { IUploadVideoConfig } from '@wangeditor-next/core';
6
6
  import { VideoElement } from '../custom-types';
7
- type InsertFn = (src: string, poster: string) => void;
8
- export type IUploadConfigForVideo = IUploadConfig & {
9
- allowedFileTypes?: string[];
10
- customInsert?: (res: any, insertFn: InsertFn) => void;
11
- customUpload?: (files: File, insertFn: InsertFn) => void;
12
- customBrowseAndUpload?: (insertFn: InsertFn) => void;
13
- };
14
- export declare function genUploadVideoMenuConfig(): IUploadConfigForVideo;
7
+ export declare function genUploadVideoMenuConfig(): IUploadVideoConfig;
15
8
  /**
16
9
  * 生成插入网络视频的配置
17
10
  */
@@ -30,4 +23,3 @@ export declare function genInsertVideoMenuConfig(): {
30
23
  */
31
24
  parseVideoSrc(src: string): string;
32
25
  };
33
- export {};
@@ -18,7 +18,7 @@ export declare const insertVideoMenuConf: {
18
18
  export declare const uploadVideoMenuConf: {
19
19
  key: string;
20
20
  factory(): UploadVideoMenu;
21
- config: import("./config").IUploadConfigForVideo;
21
+ config: import("@wangeditor-next/core").IUploadVideoConfig;
22
22
  };
23
23
  export declare const editorVideoSizeMenuConf: {
24
24
  key: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wangeditor-next/yjs-for-react",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "React specific components/utils for wangeditor-next-yjs.",
5
5
  "author": "cycleccc <2991205548@qq.com>",
6
6
  "type": "module",
@@ -56,9 +56,9 @@
56
56
  "y-protocols": "^1.0.5"
57
57
  },
58
58
  "peerDependencies": {
59
- "@wangeditor-next/core": "1.7.13",
59
+ "@wangeditor-next/core": "1.7.15",
60
60
  "@wangeditor-next/editor": "5.6.4",
61
- "@wangeditor-next/yjs": "^0.1.11",
61
+ "@wangeditor-next/yjs": "^0.1.13",
62
62
  "react": ">=16.8.0",
63
63
  "slate": "^0.72.0",
64
64
  "yjs": "^13.5.29"