@wangeditor-next/plugin-formula 3.0.0 → 6.1.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.
@@ -5,7 +5,7 @@
5
5
  import { IDomEditor } from '@wangeditor-next/core';
6
6
  import { Descendant } from 'slate';
7
7
  import { DOMElement } from '../../utils/dom';
8
- import { Header1Element, Header2Element, Header3Element, Header4Element, Header5Element } from './custom-types';
8
+ import { Header1Element, Header2Element, Header3Element, Header4Element, Header5Element, Header6Element } from './custom-types';
9
9
  export declare const parseHeader1HtmlConf: {
10
10
  selector: string;
11
11
  parseElemHtml: (elem: DOMElement, children: Descendant[], editor: IDomEditor) => Header1Element;
@@ -28,5 +28,5 @@ export declare const parseHeader5HtmlConf: {
28
28
  };
29
29
  export declare const parseHeader6HtmlConf: {
30
30
  selector: string;
31
- parseElemHtml: (elem: DOMElement, children: Descendant[], editor: IDomEditor) => Header5Element;
31
+ parseElemHtml: (elem: DOMElement, children: Descendant[], editor: IDomEditor) => Header6Element;
32
32
  };
@@ -2,13 +2,41 @@
2
2
  * @description config interface
3
3
  * @author wangfupeng
4
4
  */
5
- import type { ImageElement } from 'packages/basic-modules/src/modules/image/custom-types';
6
- import type { VideoElement } from 'packages/video-module/src/module/custom-types';
7
5
  import type { Descendant, Node, NodeEntry, Range } from 'slate';
8
6
  import type { IDomEditor } from '../editor/interface';
9
7
  import type { IMenuGroup } from '../menus/interface';
10
8
  import type { IUploadConfig } from '../upload/interface';
11
9
  import type { DOMElement } from '../utils/dom';
10
+ type EmptyText = {
11
+ text: '';
12
+ };
13
+ type ImageElement = {
14
+ type: 'image';
15
+ src: string;
16
+ alt?: string;
17
+ href?: string;
18
+ width?: string;
19
+ height?: string;
20
+ style?: {
21
+ width?: string;
22
+ height?: string;
23
+ };
24
+ children: EmptyText[];
25
+ };
26
+ type VideoElement = {
27
+ type: 'video';
28
+ key?: string;
29
+ src: string;
30
+ poster?: string;
31
+ align?: 'left' | 'center' | 'right';
32
+ width?: string;
33
+ height?: string;
34
+ style?: {
35
+ width?: string;
36
+ height?: string;
37
+ };
38
+ children: EmptyText[];
39
+ };
12
40
  interface IHoverbarConf {
13
41
  [key: string]: {
14
42
  match?: (editor: IDomEditor, n: Node) => boolean;
@@ -2,15 +2,28 @@
2
2
  * @description editor interface
3
3
  * @author wangfupeng
4
4
  */
5
- import { NodeEntryWithContext } from '@wangeditor-next/table-module/src/utils';
6
5
  import ee from 'event-emitter';
7
- import { Ancestor, Editor, Element, Location, Node } from 'slate';
6
+ import { Ancestor, Editor, Element, Location, Node, NodeEntry } from 'slate';
8
7
  import { AlertType, IEditorConfig, IMenuConfig, ISingleMenuConfig } from '../config/interface';
9
8
  import { IPositionStyle } from '../menus/interface';
10
9
  import { DOMElement } from '../utils/dom';
11
10
  export type ElementWithId = Element & {
12
11
  id: string;
13
12
  };
13
+ export type TableSelectionEntry = [
14
+ NodeEntry<Element & {
15
+ type: unknown;
16
+ rowSpan?: number;
17
+ colSpan?: number;
18
+ hidden?: boolean;
19
+ }>,
20
+ {
21
+ rtl: number;
22
+ ltr: number;
23
+ ttb: number;
24
+ btt: number;
25
+ }
26
+ ];
14
27
  type MoveOptions = Parameters<Editor['move']>[0];
15
28
  export type getMenuConfigReturnType<K> = K extends keyof IMenuConfig ? IMenuConfig[K] : ISingleMenuConfig;
16
29
  /**
@@ -59,7 +72,7 @@ export interface IDomEditor extends Editor {
59
72
  move(distance: number, reverse?: boolean): void;
60
73
  moveReverse: (distance: number) => void;
61
74
  restoreSelection: () => void;
62
- getTableSelection?: () => NodeEntryWithContext[][] | null;
75
+ getTableSelection?: () => TableSelectionEntry[][] | null;
63
76
  getSelectionPosition: () => Partial<IPositionStyle>;
64
77
  getNodePosition: (node: Node) => Partial<IPositionStyle>;
65
78
  isSelectedAll: () => boolean;
@@ -7,11 +7,12 @@ import type { IDomEditor } from './editor/interface';
7
7
  import type { IRegisterMenuConf } from './menus/index';
8
8
  import type { IParseElemHtmlConf, IPreParseHtmlConf, ParseStyleHtmlFnType } from './parse-html/index';
9
9
  import type { IRenderElemConf, RenderStyleFnType } from './render/index';
10
- import type { IElemToHtmlConf, styleToHtmlFnType } from './to-html/index';
10
+ import type { HtmlTransformFnType, IElemToHtmlConf, styleToHtmlFnType } from './to-html/index';
11
11
  import createUploaderRuntime from './upload/createUploader';
12
12
  import type { IUploadConfig } from './upload/interface';
13
13
  export * from './create/index';
14
- export type { ClassStylePolicy, IClassStyleUnsupportedPayload, IEditorConfig, IToolbarConfig, IUploadImageConfig, IUploadVideoConfig, StyleClassTokenType, TextStyleMode, } from './config/interface';
14
+ export type { ClassStylePolicy, IClassStyleUnsupportedPayload, IEditorConfig, ISingleMenuConfig, IToolbarConfig, IUploadImageConfig, IUploadVideoConfig, StyleClassTokenType, TextStyleMode, } from './config/interface';
15
+ export { EditorEvents } from './config/interface';
15
16
  export * from './config/style-mode';
16
17
  export * from './editor/dom-editor';
17
18
  export * from './editor/interface';
@@ -35,6 +36,7 @@ export interface IModuleConf {
35
36
  renderStyle: RenderStyleFnType;
36
37
  renderElems: Array<IRenderElemConf>;
37
38
  styleToHtml: styleToHtmlFnType;
39
+ htmlTransform?: HtmlTransformFnType;
38
40
  elemsToHtml: Array<IElemToHtmlConf>;
39
41
  preParseHtml: Array<IPreParseHtmlConf>;
40
42
  parseStyleHtml: ParseStyleHtmlFnType;
@@ -2,6 +2,5 @@
2
2
  * @description formats helper
3
3
  * @author wangfupeng
4
4
  */
5
- import { ElementType } from 'packages/custom-types';
6
- export declare function genElemId(type: ElementType, id: string): string;
5
+ export declare function genElemId(type: string, id: string): string;
7
6
  export declare function genTextId(id: string): string;
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { Descendant, Element as SlateElement } from 'slate';
6
6
  import { IDomEditor } from '../editor/interface';
7
+ import type { INodeToHtmlOptions } from './node2html';
7
8
  export type styleToHtmlFnType = (node: Descendant, elemHtml: string, editor?: IDomEditor) => string;
8
9
  export declare const STYLE_TO_HTML_FN_LIST: styleToHtmlFnType[];
9
10
  /**
@@ -11,6 +12,17 @@ export declare const STYLE_TO_HTML_FN_LIST: styleToHtmlFnType[];
11
12
  * @param fn 处理 toHtml 文本样式的函数
12
13
  */
13
14
  export declare function registerStyleToHtmlHandler(fn: styleToHtmlFnType): void;
15
+ /**
16
+ * Transform the HTML fragments of the document's top-level nodes.
17
+ *
18
+ * Element serializers intentionally stay node-local. Modules that need
19
+ * neighboring blocks to produce valid HTML (for example semantic lists) use
20
+ * this hook after every node has been serialized.
21
+ */
22
+ export type HtmlTransformFnType = (htmlList: string[], nodes: Descendant[], editor: IDomEditor, options: INodeToHtmlOptions) => string[];
23
+ export declare const HTML_TRANSFORM_HANDLER_LIST: HtmlTransformFnType[];
24
+ export declare function registerHtmlTransformHandler(fn: HtmlTransformFnType): void;
25
+ export declare function transformHtml(htmlList: string[], nodes: Descendant[], editor: IDomEditor, options?: INodeToHtmlOptions): string[];
14
26
  interface IElemToHtmlRes {
15
27
  html: string;
16
28
  prefix?: string;
@@ -2,9 +2,8 @@
2
2
  * @description Editor View class
3
3
  * @author wangfupeng
4
4
  */
5
- import type { IEditorConfig, IElemToHtmlConf, IModuleConf, IParseElemHtmlConf, IPreParseHtmlConf, IRegisterMenuConf, IRenderElemConf, IToolbarConfig, ParseStyleHtmlFnType, RenderStyleFnType, styleToHtmlFnType } from '@wangeditor-next/core';
5
+ import type { HtmlTransformFnType, IEditorConfig, IElemToHtmlConf, IModuleConf, IParseElemHtmlConf, IPreParseHtmlConf, IRegisterMenuConf, IRenderElemConf, ISingleMenuConfig, IToolbarConfig, ParseStyleHtmlFnType, RenderStyleFnType, styleToHtmlFnType } from '@wangeditor-next/core';
6
6
  import { IDomEditor } from '@wangeditor-next/core';
7
- import type { ISingleMenuConfig } from 'packages/core/src/config/interface';
8
7
  type PluginType = <T extends IDomEditor>(editor: T) => T;
9
8
  declare class Boot {
10
9
  constructor();
@@ -23,6 +22,7 @@ declare class Boot {
23
22
  static registerRenderStyle(fn: RenderStyleFnType): void;
24
23
  static registerElemToHtml(elemToHtmlConf: IElemToHtmlConf): void;
25
24
  static registerStyleToHtml(fn: styleToHtmlFnType): void;
25
+ static registerHtmlTransform(fn: HtmlTransformFnType): void;
26
26
  static registerPreParseHtml(preParseHtmlConf: IPreParseHtmlConf): void;
27
27
  static registerParseElemHtml(parseElemHtmlConf: IParseElemHtmlConf): void;
28
28
  static registerParseStyleHtml(fn: ParseStyleHtmlFnType): void;
@@ -7,6 +7,9 @@ declare const _default: {
7
7
  unOrderedList: string;
8
8
  orderedList: string;
9
9
  lowerAlphaList: string;
10
+ numberingActions: string;
11
+ continueNumbering: string;
12
+ restartNumbering: string;
10
13
  };
11
14
  };
12
15
  export default _default;
@@ -7,6 +7,9 @@ declare const _default: {
7
7
  unOrderedList: string;
8
8
  orderedList: string;
9
9
  lowerAlphaList: string;
10
+ numberingActions: string;
11
+ continueNumbering: string;
12
+ restartNumbering: string;
10
13
  };
11
14
  };
12
15
  export default _default;
@@ -4,11 +4,24 @@
4
4
  */
5
5
  import { Text } from 'slate';
6
6
  export type OrderedListType = '1' | 'a' | 'A' | 'i' | 'I';
7
+ /**
8
+ * An outline keeps the established list-item wire format and records the
9
+ * heading semantics as additive metadata.
10
+ */
11
+ export type HeadingType = 'header1' | 'header2' | 'header3' | 'header4' | 'header5' | 'header6';
7
12
  export type ListItemElement = {
8
13
  type: 'list-item';
9
14
  ordered: boolean;
10
15
  level: number;
11
16
  start?: number;
12
17
  orderType?: OrderedListType;
18
+ headingType?: HeadingType;
19
+ listMode?: 'outline';
20
+ listRestart?: number;
13
21
  children: Text[];
14
22
  };
23
+ export type OutlineListItemElement = ListItemElement & {
24
+ ordered: true;
25
+ headingType: HeadingType;
26
+ listMode: 'outline';
27
+ };
@@ -1,15 +1,25 @@
1
1
  /**
2
- * @description table menu helpers
3
- * @author wangfupeng
2
+ * @description list helpers
4
3
  */
5
4
  import { IDomEditor } from '@wangeditor-next/core';
6
- import { ListItemElement, OrderedListType } from './custom-types';
5
+ import { Node } from 'slate';
6
+ import { HeadingType, ListItemElement, OrderedListType, OutlineListItemElement } from './custom-types';
7
+ export declare function isListNode(node: Node): node is ListItemElement;
8
+ export declare const isLegacyListItem: typeof isListNode;
9
+ export declare function isHeadingType(value: unknown): value is HeadingType;
10
+ export declare function getHeadingType(node: Node): HeadingType | null;
11
+ export declare function getListIndent(node: Node): number;
12
+ export declare function getListMode(node: Node): 'standard' | 'outline';
13
+ export declare function isOutlineListNode(node: Node): node is OutlineListItemElement;
14
+ export declare function getOutlineLevel(node: Node): number;
7
15
  export declare function getNormalizedOrderedListStart(elem: ListItemElement): number;
8
16
  export declare function getNormalizedOrderedListType(elem: ListItemElement): OrderedListType;
9
17
  export declare function hasSameListConfig(a: ListItemElement, b: ListItemElement): boolean;
18
+ export declare function getOrderedItemNumber(editor: IDomEditor, elem: ListItemElement): number;
19
+ export declare function getOutlineNumber(editor: IDomEditor, elem: ListItemElement): string;
10
20
  /**
11
21
  * 获取上一个同一 level 的 list item
12
- * @param editor 编辑器实例
22
+ * @param editor editor
13
23
  * @param elem elem
14
24
  */
15
25
  export declare function getBrotherListNodeByLevel(editor: IDomEditor, elem: ListItemElement, level?: number): ListItemElement | null;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @description compose semantic outline HTML from additive list-item metadata
3
+ */
4
+ import { HtmlTransformFnType } from '@wangeditor-next/core';
5
+ /**
6
+ * List-item serialization remains backward compatible for ordinary lists.
7
+ * Only outline list items need document-level composition to create valid
8
+ * `ol > li > hN` structure.
9
+ */
10
+ export declare const transformListHtml: HtmlTransformFnType;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @description base menu
2
+ * @description list menu base class
3
3
  * @author wangfupeng
4
4
  */
5
5
  import { IButtonMenu, IDomEditor } from '@wangeditor-next/core';
@@ -11,7 +11,7 @@ declare abstract class BaseMenu implements IButtonMenu {
11
11
  abstract readonly title: string;
12
12
  abstract readonly iconSvg: string;
13
13
  readonly tag = "button";
14
- private getListNode;
14
+ private isTargetListNode;
15
15
  getValue(_editor: IDomEditor): string | boolean;
16
16
  isActive(editor: IDomEditor): boolean;
17
17
  isDisabled(editor: IDomEditor): boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @description outline numbering marker actions
3
+ */
4
+ import { IDomEditor } from '@wangeditor-next/core';
5
+ import { ListItemElement } from './custom-types';
6
+ export declare function continueOutlineNumbering(editor: IDomEditor, node: ListItemElement): void;
7
+ export declare function restartOutlineNumbering(editor: IDomEditor, node: ListItemElement): void;
8
+ export declare function hideOutlineActionPanel(editor: IDomEditor): void;
9
+ export declare function showOutlineActionPanel(editor: IDomEditor, node: ListItemElement, marker: HTMLElement): void;
@@ -1,6 +1,5 @@
1
1
  /**
2
- * @description parse elem html
3
- * @author wangfupeng
2
+ * @description parse list HTML
4
3
  */
5
4
  import { IDomEditor } from '@wangeditor-next/core';
6
5
  import { Descendant } from 'slate';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @description editor 插件,重写 editor API
2
+ * @description list editor plugin
3
3
  * @author wangfupeng
4
4
  */
5
5
  import { IDomEditor } from '@wangeditor-next/core';
@@ -3,4 +3,5 @@
3
3
  * @author wangfupeng
4
4
  */
5
5
  import { IDomEditor } from '@wangeditor-next/core';
6
- export declare const ELEM_TO_EDITOR: WeakMap<import("packages/custom-types").CustomElement, IDomEditor>;
6
+ import { BaseElement } from 'slate';
7
+ export declare const ELEM_TO_EDITOR: WeakMap<BaseElement, IDomEditor>;
@@ -1,4 +1,5 @@
1
1
  import { IButtonMenu, IDomEditor } from '@wangeditor-next/core';
2
+ import { NodeEntry } from 'slate';
2
3
  import TableProperty, { FieldName } from './TableProperty';
3
4
  declare class CellProperty extends TableProperty implements IButtonMenu {
4
5
  readonly title: string;
@@ -8,6 +9,6 @@ declare class CellProperty extends TableProperty implements IButtonMenu {
8
9
  readonly modalWidth = 360;
9
10
  readonly menu = "cell";
10
11
  readonly propertyFields: FieldName[];
11
- getModalContentNode(editor: IDomEditor): import("slate").NodeEntry<import("../../utils").WithType<import("packages/custom-types").CustomElement>>;
12
+ getModalContentNode(editor: IDomEditor): NodeEntry;
12
13
  }
13
14
  export default CellProperty;
@@ -3,6 +3,7 @@
3
3
  * @author hsuna
4
4
  */
5
5
  import { IButtonMenu, IDomEditor } from '@wangeditor-next/core';
6
+ import { NodeEntry } from 'slate';
6
7
  export type FieldName = 'borderStyle' | 'borderColor' | 'borderWidth' | 'backgroundColor' | 'textAlign' | 'verticalAlign';
7
8
  type SelectOption = {
8
9
  value: string;
@@ -35,7 +36,7 @@ declare class TableProperty implements IButtonMenu {
35
36
  isActive(_editor: IDomEditor): boolean;
36
37
  isDisabled(editor: IDomEditor): boolean;
37
38
  exec(_editor: IDomEditor, _value: string | boolean): void;
38
- getModalContentNode(editor: IDomEditor): import("slate").NodeEntry<import("../../utils").WithType<import("packages/custom-types").CustomElement>>;
39
+ getModalContentNode(editor: IDomEditor): NodeEntry;
39
40
  getModalPositionNode(_editor: IDomEditor): null;
40
41
  getModalContentElem(editor: IDomEditor): Element | null;
41
42
  getPanelContentElem(editor: any, { mark, selectedColor, callback }: {
@@ -0,0 +1,21 @@
1
+ import { VNode } from 'snabbdom';
2
+ export type SelectionRect = {
3
+ top: number;
4
+ right: number;
5
+ bottom: number;
6
+ left: number;
7
+ };
8
+ export type SelectionPerimeterSide = 'top' | 'right' | 'bottom' | 'left';
9
+ export type SelectionPerimeterSegment = {
10
+ side: SelectionPerimeterSide;
11
+ offset: number;
12
+ start: number;
13
+ end: number;
14
+ };
15
+ /**
16
+ * Returns the physical perimeter of a set of non-overlapping cell rectangles. Opposing edges
17
+ * cancel only where they overlap, so partially exposed sides of merged cells remain precise.
18
+ */
19
+ export declare function getSelectionPerimeterSegments(rects: SelectionRect[]): SelectionPerimeterSegment[];
20
+ export declare function drawSelectionOverlay(elm: Node | undefined): void;
21
+ export declare function renderSelectionOverlay(): VNode;
@@ -1,5 +1,6 @@
1
+ import { BaseEditor, BaseElement } from 'slate';
1
2
  import { NodeEntryWithContext } from '../utils';
2
3
  /** Weak reference between the `Editor` and the selected elements */
3
- export declare const EDITOR_TO_SELECTION: WeakMap<import("slate").BaseEditor, NodeEntryWithContext[][]>;
4
+ export declare const EDITOR_TO_SELECTION: WeakMap<BaseEditor, NodeEntryWithContext[][]>;
4
5
  /** Weak reference between the `Editor` and a set of the selected elements */
5
- export declare const EDITOR_TO_SELECTION_SET: WeakMap<import("slate").BaseEditor, WeakSet<import("packages/custom-types").CustomElement>>;
6
+ export declare const EDITOR_TO_SELECTION_SET: WeakMap<BaseEditor, WeakSet<BaseElement>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wangeditor-next/plugin-formula",
3
- "version": "3.0.0",
3
+ "version": "6.1.1",
4
4
  "description": "wangEditor next formula 公式",
5
5
  "author": "cycleccc <2991205548@qq.com>",
6
6
  "type": "module",
@@ -38,9 +38,9 @@
38
38
  "@wangeditor-next-shared/rollup-config": "^0.0.2"
39
39
  },
40
40
  "peerDependencies": {
41
- "@wangeditor-next/editor": ">=6.0.0",
42
41
  "katex": "^0.16.0",
43
- "snabbdom": "^3.6.0"
42
+ "snabbdom": "^3.6.0",
43
+ "@wangeditor-next/editor": "^6.1.1"
44
44
  },
45
45
  "dependencies": {
46
46
  "dom7": "^4.0.0",