@wangeditor-next/editor 5.6.4 → 5.6.6

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[];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @description Processing blob url
3
+ * @author CodePencil
4
+ */
5
+ /** 提取 blob URL */
6
+ export declare function extractBlobUrlFromImg(html: string): string | null;
7
+ /** 将 blob URL 转换为 base64 */
8
+ export declare function convertBlobUrlToBase64(blobUrl: string): Promise<string | null>;
@@ -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;
@@ -2,5 +2,6 @@
2
2
  * @description formats helper
3
3
  * @author wangfupeng
4
4
  */
5
- export declare function genElemId(id: string): string;
5
+ import { ElementType } from 'packages/custom-types';
6
+ export declare function genElemId(type: ElementType, id: string): string;
6
7
  export declare function genTextId(id: string): string;
@@ -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 {};
@@ -12,9 +12,20 @@ import DOMSelection = globalThis.Selection;
12
12
  import DOMStaticRange = globalThis.StaticRange;
13
13
  export { Dom7Array } from 'dom7';
14
14
  export default $;
15
+ export declare enum NodeType {
16
+ ELEMENT_NODE = 1,
17
+ TEXT_NODE = 3,
18
+ CDATA_SECTION_NODE = 4,
19
+ PROCESSING_INSTRUCTION_NODE = 7,
20
+ COMMENT_NODE = 8,
21
+ DOCUMENT_NODE = 9,
22
+ DOCUMENT_TYPE_NODE = 10,
23
+ DOCUMENT_FRAGMENT_NODE = 11
24
+ }
15
25
  export declare const isDocument: (value: any) => value is Document;
16
26
  export declare const isShadowRoot: (value: any) => value is ShadowRoot;
17
27
  export declare const isDataTransfer: (value: any) => value is DataTransfer;
28
+ export declare const isUnprocessedListElement: (el: Element) => boolean;
18
29
  export declare const isHTMLElememt: (value: any) => value is HTMLElement;
19
30
  export { DOMComment, DOMElement, DOMNode, DOMRange, DOMSelection, DOMStaticRange, DOMText, };
20
31
  export type DOMPoint = [Node, number];
@@ -85,16 +96,6 @@ export declare function getFirstVoidChild(elem: DOMElement): DOMElement | null;
85
96
  * @param handler handler
86
97
  */
87
98
  export declare function walkTextNodes(elem: DOMElement, handler: (textNode: DOMNode, parent: DOMElement) => void): void;
88
- export declare enum NodeType {
89
- ELEMENT_NODE = 1,
90
- TEXT_NODE = 3,
91
- CDATA_SECTION_NODE = 4,
92
- PROCESSING_INSTRUCTION_NODE = 7,
93
- COMMENT_NODE = 8,
94
- DOCUMENT_NODE = 9,
95
- DOCUMENT_TYPE_NODE = 10,
96
- DOCUMENT_FRAGMENT_NODE = 11
97
- }
98
99
  /**
99
100
  * 获取 tagName lower-case
100
101
  * @param $elem $elem