@wangeditor-next/plugin-float-image 2.0.8 → 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.
Files changed (38) hide show
  1. package/README.md +6 -6
  2. package/dist/basic-modules/src/modules/header/parse-elem-html.d.ts +2 -2
  3. package/dist/core/src/config/interface.d.ts +30 -2
  4. package/dist/core/src/editor/dom-editor.d.ts +1 -0
  5. package/dist/core/src/editor/interface.d.ts +16 -3
  6. package/dist/core/src/index.d.ts +4 -2
  7. package/dist/core/src/render/helper.d.ts +1 -2
  8. package/dist/core/src/to-html/index.d.ts +12 -0
  9. package/dist/editor/src/Boot.d.ts +2 -2
  10. package/dist/list-module/src/locale/en.d.ts +3 -0
  11. package/dist/list-module/src/locale/zh-CN.d.ts +3 -0
  12. package/dist/list-module/src/module/custom-types.d.ts +13 -0
  13. package/dist/list-module/src/module/helpers.d.ts +14 -4
  14. package/dist/list-module/src/module/html-transform.d.ts +10 -0
  15. package/dist/list-module/src/module/menu/BaseMenu.d.ts +2 -2
  16. package/dist/list-module/src/module/outline-actions.d.ts +9 -0
  17. package/dist/list-module/src/module/parse-elem-html.d.ts +1 -2
  18. package/dist/list-module/src/module/plugin.d.ts +1 -1
  19. package/dist/list-module/src/utils/maps.d.ts +2 -1
  20. package/dist/table-module/src/locale/en.d.ts +13 -0
  21. package/dist/table-module/src/locale/zh-CN.d.ts +13 -0
  22. package/dist/table-module/src/module/cell-selection.d.ts +11 -0
  23. package/dist/table-module/src/module/column-resize.d.ts +3 -3
  24. package/dist/table-module/src/module/custom-types.d.ts +1 -0
  25. package/dist/table-module/src/module/helpers.d.ts +5 -0
  26. package/dist/table-module/src/module/menu/CellProperty.d.ts +5 -3
  27. package/dist/table-module/src/module/menu/TableProperty.d.ts +21 -7
  28. package/dist/table-module/src/module/render-elem/selection-overlay.d.ts +21 -0
  29. package/dist/table-module/src/module/row-resize.d.ts +2 -2
  30. package/dist/table-module/src/module/weak-maps.d.ts +3 -2
  31. package/dist/video-module/src/constants/svg.d.ts +3 -0
  32. package/dist/video-module/src/locale/en.d.ts +3 -0
  33. package/dist/video-module/src/locale/zh-CN.d.ts +3 -0
  34. package/dist/video-module/src/module/alignment.d.ts +10 -0
  35. package/dist/video-module/src/module/custom-types.d.ts +2 -1
  36. package/dist/video-module/src/module/menu/VideoAlignMenu.d.ts +18 -0
  37. package/dist/video-module/src/module/menu/index.d.ts +13 -0
  38. package/package.json +4 -4
package/README.md CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  <br/>
6
6
  <br/>
7
- <a href="https://github.com/hqwlkj/wangEditor-plugin-float-image/releases">
8
- <img src="https://img.shields.io/github/v/release/hqwlkj/wangEditor-plugin-float-image" alt=""/>
7
+ <a href="https://www.npmjs.com/package/@wangeditor-next/plugin-float-image">
8
+ <img src="https://img.shields.io/npm/v/%40wangeditor-next%2Fplugin-float-image" alt=""/>
9
9
  </a>
10
- <a href="https://www.npmjs.com/package/wangeditor-plugin-float-image">
11
- <img src="https://img.shields.io/github/downloads/hqwlkj/wangEditor-plugin-float-image/total" alt=""/>
10
+ <a href="https://www.npmjs.com/package/@wangeditor-next/plugin-float-image">
11
+ <img src="https://img.shields.io/npm/dm/%40wangeditor-next%2Fplugin-float-image" alt=""/>
12
12
  </a>
13
13
 
14
14
  ## 介绍
@@ -35,7 +35,7 @@ npm i @wangeditor-next/plugin-float-image
35
35
 
36
36
  ```js
37
37
  import { Boot } from '@wangeditor-next/editor'
38
- import floatImageModule from 'wangeditor-plugin-float-image'
38
+ import floatImageModule from '@wangeditor-next/plugin-float-image'
39
39
 
40
40
  // 注册。要在创建编辑器之前注册,且只能注册一次,不可重复注册。
41
41
  Boot.registerModule(floatImageModule)
@@ -91,4 +91,4 @@ const editorConfig: Partial<IEditorConfig> = {
91
91
 
92
92
  ## 许可证
93
93
 
94
- [MIT](https://github.com/hqwlkj/wangEditor-plugin-float-image/blob/master/LICENSE)
94
+ [MIT](https://github.com/wangeditor-next/wangEditor-next/blob/master/LICENSE)
@@ -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;
@@ -109,6 +109,7 @@ export declare const DomEditor: {
109
109
  getNodeType(node: Node): string;
110
110
  checkNodeType(node: Node, type: string): boolean;
111
111
  getNodesStr(nodes: Node[]): string;
112
+ getSelectedVoidNode(editor: IDomEditor): Element | null;
112
113
  getSelectedElems(editor: IDomEditor): Element[];
113
114
  getSelectedNodeByType(editor: IDomEditor, type: string): Node | null;
114
115
  getSelectedTextNode(editor: IDomEditor): Node | null;
@@ -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>;
@@ -6,9 +6,17 @@ declare const _default: {
6
6
  tableModule: {
7
7
  modal: {
8
8
  border: string;
9
+ borderColor: string;
10
+ borderStyle: string;
9
11
  borderWidth: string;
12
+ borderWidthDefault: string;
10
13
  bgColor: string;
11
14
  align: string;
15
+ verticalAlign: string;
16
+ width: string;
17
+ widthAuto: string;
18
+ widthFull: string;
19
+ mixed: string;
12
20
  ok: string;
13
21
  };
14
22
  color: {
@@ -26,6 +34,11 @@ declare const _default: {
26
34
  inset: string;
27
35
  outset: string;
28
36
  };
37
+ verticalAlign: {
38
+ top: string;
39
+ middle: string;
40
+ bottom: string;
41
+ };
29
42
  deleteCol: string;
30
43
  deleteRow: string;
31
44
  deleteTable: string;
@@ -6,9 +6,17 @@ declare const _default: {
6
6
  tableModule: {
7
7
  modal: {
8
8
  border: string;
9
+ borderColor: string;
10
+ borderStyle: string;
9
11
  borderWidth: string;
12
+ borderWidthDefault: string;
10
13
  bgColor: string;
11
14
  align: string;
15
+ verticalAlign: string;
16
+ width: string;
17
+ widthAuto: string;
18
+ widthFull: string;
19
+ mixed: string;
12
20
  ok: string;
13
21
  };
14
22
  color: {
@@ -26,6 +34,11 @@ declare const _default: {
26
34
  inset: string;
27
35
  outset: string;
28
36
  };
37
+ verticalAlign: {
38
+ top: string;
39
+ middle: string;
40
+ bottom: string;
41
+ };
29
42
  deleteCol: string;
30
43
  deleteRow: string;
31
44
  deleteTable: string;
@@ -0,0 +1,11 @@
1
+ import { IDomEditor } from '@wangeditor-next/core';
2
+ import { Path, Range } from 'slate';
3
+ /** Builds a directional Slate range that includes both boundary cells completely. */
4
+ export declare function getCellDragSelectionRange(editor: IDomEditor, anchorPath: Path, targetPath: Path): Range;
5
+ /** Records the starting cell without disturbing native text selection inside that cell. */
6
+ export declare function handleCellDragSelectionMouseDown(editor: IDomEditor, event: MouseEvent): void;
7
+ /**
8
+ * Takes over only after the pointer crosses into another cell. This avoids Chrome collapsing the
9
+ * native range for wrapped cells while preserving ordinary text selection within one cell.
10
+ */
11
+ export declare function handleCellDragSelectionMouseMove(editor: IDomEditor, event: MouseEvent): void;
@@ -4,8 +4,8 @@ import { Element as SlateElement } from 'slate';
4
4
  * 用于计算拖动 cell 时,cell 宽度变化的比例
5
5
  */
6
6
  export declare function getColumnWidthRatios(columnWidths: number[]): number[];
7
- export declare function observerTableResize(editor: IDomEditor, elm: Node | undefined): void;
8
- export declare function unObserveTableResize(): void;
7
+ export declare function unObserveTableResize(elm?: Node): void;
8
+ export declare function observerTableResize(editor: IDomEditor, elm: Node | undefined, elemNode: SlateElement): void;
9
9
  /**
10
10
  * 鼠标移动时,判断在哪个 Cell border 上
11
11
  * Class 先 visible 后 highlight @跟随飞书
@@ -16,5 +16,5 @@ export declare function handleCellBorderVisible(editor: IDomEditor, elemNode: Sl
16
16
  * 设置 class highlight
17
17
  * 将 render-cell.tsx 拖动功能迁移至 div.column-resize
18
18
  */
19
- export declare function handleCellBorderHighlight(editor: IDomEditor, e: MouseEvent): void;
19
+ export declare function handleCellBorderHighlight(editor: IDomEditor, elemNode: SlateElement, e: MouseEvent): void;
20
20
  export declare function handleCellBorderMouseDown(editor: IDomEditor, elemNode: SlateElement): void;
@@ -10,6 +10,7 @@ export type TableCellProperty = {
10
10
  borderStyle?: string;
11
11
  borderColor?: string;
12
12
  textAlign?: string;
13
+ verticalAlign?: string;
13
14
  };
14
15
  export type TableCellElement = {
15
16
  type: 'table-cell';
@@ -3,7 +3,12 @@
3
3
  * @author wangfupeng
4
4
  */
5
5
  import { IDomEditor } from '@wangeditor-next/core';
6
+ import { Element as SlateElement } from 'slate';
6
7
  import { TableCellElement, TableElement } from './custom-types';
8
+ /**
9
+ * Update a rendered table by its own path instead of relying on the current selection.
10
+ */
11
+ export declare function setTableNodeProps(editor: IDomEditor, tableNode: SlateElement, props: Partial<TableElement>): void;
7
12
  /**
8
13
  * 获取第一行所有 cells
9
14
  * @param tableNode table node
@@ -1,12 +1,14 @@
1
1
  import { IButtonMenu, IDomEditor } from '@wangeditor-next/core';
2
- import TableProperty from './TableProperty';
2
+ import { NodeEntry } from 'slate';
3
+ import TableProperty, { FieldName } from './TableProperty';
3
4
  declare class CellProperty extends TableProperty implements IButtonMenu {
4
5
  readonly title: string;
5
6
  readonly iconSvg = "<svg viewBox=\"0 0 20 20\"><path d=\"m11.105 18-.17 1H2.5A1.5 1.5 0 0 1 1 17.5v-15A1.5 1.5 0 0 1 2.5 1h15A1.5 1.5 0 0 1 19 2.5v9.975l-.85-.124-.15-.302V8h-5v4h.021l-.172.351-1.916.28-.151.027c-.287.063-.54.182-.755.341L8 13v5h3.105zM2 12h5V8H2v4zm10-4H8v4h4V8zM2 2v5h5V2H2zm0 16h5v-5H2v5zM13 7h5V2h-5v5zM8 2v5h4V2H8z\" opacity=\".6\"/><path d=\"m15.5 11.5 1.323 2.68 2.957.43-2.14 2.085.505 2.946L15.5 18.25l-2.645 1.39.505-2.945-2.14-2.086 2.957-.43L15.5 11.5zM13 6a1 1 0 0 1 1 1v3.172a2.047 2.047 0 0 0-.293.443l-.858 1.736-1.916.28-.151.027A1.976 1.976 0 0 0 9.315 14H7a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h6zm-1 2H8v4h4V8z\"/></svg>";
6
7
  readonly tag = "button";
7
8
  readonly showModal = true;
8
- readonly modalWidth = 300;
9
+ readonly modalWidth = 360;
9
10
  readonly menu = "cell";
10
- getModalContentNode(editor: IDomEditor): import("slate").NodeEntry<import("../../utils").WithType<import("packages/custom-types").CustomElement>>;
11
+ readonly propertyFields: FieldName[];
12
+ getModalContentNode(editor: IDomEditor): NodeEntry;
11
13
  }
12
14
  export default CellProperty;
@@ -3,27 +3,40 @@
3
3
  * @author hsuna
4
4
  */
5
5
  import { IButtonMenu, IDomEditor } from '@wangeditor-next/core';
6
+ import { NodeEntry } from 'slate';
7
+ export type FieldName = 'borderStyle' | 'borderColor' | 'borderWidth' | 'backgroundColor' | 'textAlign' | 'verticalAlign';
8
+ type SelectOption = {
9
+ value: string;
10
+ label: string;
11
+ };
12
+ type SegmentOption = SelectOption & {
13
+ svg?: string;
14
+ };
6
15
  declare class TableProperty implements IButtonMenu {
7
16
  readonly title: string;
8
17
  iconSvg: string;
9
18
  readonly tag = "button";
10
19
  readonly showModal = true;
11
- readonly modalWidth = 300;
20
+ readonly modalWidth: number;
12
21
  readonly menu: string;
22
+ readonly propertyFields: FieldName[];
13
23
  readonly borderStyle: {
14
24
  value: string;
15
25
  label: string;
16
26
  }[];
17
- readonly textAlignOptions: {
18
- value: string;
19
- label: string;
20
- svg: string;
21
- }[];
27
+ readonly textAlignOptions: SegmentOption[];
28
+ readonly verticalAlignOptions: SegmentOption[];
29
+ private renderRow;
30
+ private createFieldControl;
31
+ private renderSelect;
32
+ private renderNumber;
33
+ private renderColor;
34
+ private renderSegment;
22
35
  getValue(_editor: IDomEditor): string | boolean;
23
36
  isActive(_editor: IDomEditor): boolean;
24
37
  isDisabled(editor: IDomEditor): boolean;
25
38
  exec(_editor: IDomEditor, _value: string | boolean): void;
26
- getModalContentNode(editor: IDomEditor): import("slate").NodeEntry<import("../../utils").WithType<import("packages/custom-types").CustomElement>>;
39
+ getModalContentNode(editor: IDomEditor): NodeEntry;
27
40
  getModalPositionNode(_editor: IDomEditor): null;
28
41
  getModalContentElem(editor: IDomEditor): Element | null;
29
42
  getPanelContentElem(editor: any, { mark, selectedColor, callback }: {
@@ -31,5 +44,6 @@ declare class TableProperty implements IButtonMenu {
31
44
  selectedColor: any;
32
45
  callback: any;
33
46
  }): import("dom7").Dom7Array;
47
+ updateColorPanelActive($panel: any, selectedColor: string): void;
34
48
  }
35
49
  export default TableProperty;
@@ -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;
@@ -11,5 +11,5 @@ export declare function handleRowBorderVisible(editor: IDomEditor, elemNode: Sla
11
11
  /**
12
12
  * 设置行拖拽高亮
13
13
  */
14
- export declare function handleRowBorderHighlight(editor: IDomEditor, e: MouseEvent): void;
15
- export declare function handleRowBorderMouseDown(editor: IDomEditor, _elemNode: SlateElement): void;
14
+ export declare function handleRowBorderHighlight(editor: IDomEditor, elemNode: SlateElement, e: MouseEvent): void;
15
+ export declare function handleRowBorderMouseDown(editor: IDomEditor, elemNode: SlateElement): void;
@@ -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>>;
@@ -10,3 +10,6 @@
10
10
  export declare const VIDEO_SVG = "<svg viewBox=\"0 0 1024 1024\"><path d=\"M981.184 160.096C837.568 139.456 678.848 128 512 128S186.432 139.456 42.816 160.096C15.296 267.808 0 386.848 0 512s15.264 244.16 42.816 351.904C186.464 884.544 345.152 896 512 896s325.568-11.456 469.184-32.096C1008.704 756.192 1024 637.152 1024 512s-15.264-244.16-42.816-351.904zM384 704V320l320 192-320 192z\"></path></svg>";
11
11
  export declare const UPLOAD_VIDEO_SVG = "<svg viewBox=\"0 0 1056 1024\"><path d=\"M805.902261 521.819882a251.441452 251.441452 0 0 0-251.011972 246.600033 251.051015 251.051015 0 1 0 502.023944 8.823877 253.237463 253.237463 0 0 0-251.011972-255.42391z m59.463561 240.001647v129.898403h-116.701631v-129.898403h-44.041298l101.279368-103.504859 101.279368 103.504859z\" p-id=\"6802\"></path><path d=\"M788.254507 0.000781H99.094092A98.663439 98.663439 0 0 0 0.001171 99.093701v590.067495a98.663439 98.663439 0 0 0 99.092921 99.092921h411.7549a266.434235 266.434235 0 0 1-2.186448-41.815807 275.843767 275.843767 0 0 1 275.180024-270.729042 270.650955 270.650955 0 0 1 103.504859 19.834201V99.093701A101.51363 101.51363 0 0 0 788.254507 0.000781zM295.054441 640.747004V147.507894l394.146189 246.600033z\"></path></svg>";
12
12
  export declare const PENCIL_SVG = "<svg viewBox=\"0 0 1024 1024\"><path d=\"M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z\"></path></svg>";
13
+ export declare const VIDEO_ALIGN_LEFT_SVG = "<svg viewBox=\"0 0 1024 1024\"><path d=\"M768 793.6v102.4H51.2v-102.4h716.8z m204.8-230.4v102.4H51.2v-102.4h921.6z m-204.8-230.4v102.4H51.2v-102.4h716.8zM972.8 102.4v102.4H51.2V102.4h921.6z\"></path></svg>";
14
+ export declare const VIDEO_ALIGN_CENTER_SVG = "<svg viewBox=\"0 0 1024 1024\"><path d=\"M870.4 793.6v102.4H153.6v-102.4h716.8z m102.4-230.4v102.4H51.2v-102.4h921.6z m-102.4-230.4v102.4H153.6v-102.4h716.8zM972.8 102.4v102.4H51.2V102.4h921.6z\"></path></svg>";
15
+ export declare const VIDEO_ALIGN_RIGHT_SVG = "<svg viewBox=\"0 0 1024 1024\"><path d=\"M972.8 793.6v102.4H256v-102.4h716.8z m0-230.4v102.4H51.2v-102.4h921.6z m0-230.4v102.4H256v-102.4h716.8zM972.8 102.4v102.4H51.2V102.4h921.6z\"></path></svg>";
@@ -16,6 +16,9 @@ declare const _default: {
16
16
  edit: string;
17
17
  width: string;
18
18
  height: string;
19
+ alignLeft: string;
20
+ alignCenter: string;
21
+ alignRight: string;
19
22
  };
20
23
  };
21
24
  export default _default;
@@ -16,6 +16,9 @@ declare const _default: {
16
16
  edit: string;
17
17
  width: string;
18
18
  height: string;
19
+ alignLeft: string;
20
+ alignCenter: string;
21
+ alignRight: string;
19
22
  };
20
23
  };
21
24
  export default _default;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @description video alignment helpers
3
+ */
4
+ import { Element } from 'slate';
5
+ import { VideoAlign } from './custom-types';
6
+ export declare const DEFAULT_VIDEO_ALIGN: VideoAlign;
7
+ export declare function normalizeVideoAlign(value: unknown): VideoAlign;
8
+ export declare function getVideoAlign(elemNode: Element): VideoAlign;
9
+ export declare function getVideoAlignClass(align: VideoAlign): string;
10
+ export declare function getVideoJustifyContent(align: VideoAlign): string;
@@ -9,12 +9,13 @@ export type videoStyle = {
9
9
  width?: string;
10
10
  height?: string;
11
11
  };
12
+ export type VideoAlign = 'left' | 'center' | 'right';
12
13
  export type VideoElement = {
13
14
  type: 'video';
14
15
  key?: string;
15
16
  src: string;
16
17
  poster?: string;
17
- textAlign?: string;
18
+ align?: VideoAlign;
18
19
  width?: string;
19
20
  height?: string;
20
21
  style?: videoStyle;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @description align video menu
3
+ */
4
+ import { IButtonMenu, IDomEditor } from '@wangeditor-next/core';
5
+ import { VideoAlign } from '../custom-types';
6
+ declare class VideoAlignMenu implements IButtonMenu {
7
+ readonly align: VideoAlign;
8
+ readonly iconSvg: string;
9
+ readonly tag = "button";
10
+ readonly title: string;
11
+ constructor(align: VideoAlign, titleKey: string, iconSvg: string);
12
+ private getSelectedVideo;
13
+ getValue(editor: IDomEditor): string | boolean;
14
+ isActive(editor: IDomEditor): boolean;
15
+ isDisabled(editor: IDomEditor): boolean;
16
+ exec(editor: IDomEditor, _value: string | boolean): void;
17
+ }
18
+ export default VideoAlignMenu;
@@ -6,6 +6,7 @@ import EditorVideoSizeMenu from './EditVideoSizeMenu';
6
6
  import EditorVideoSrcMenu from './EditVideoSrcMenu';
7
7
  import InsertVideoMenu from './InsertVideoMenu';
8
8
  import UploadVideoMenu from './UploadVideoMenu';
9
+ import VideoAlignMenu from './VideoAlignMenu';
9
10
  export declare const insertVideoMenuConf: {
10
11
  key: string;
11
12
  factory(): InsertVideoMenu;
@@ -28,3 +29,15 @@ export declare const editorVideoSrcMenuConf: {
28
29
  key: string;
29
30
  factory(): EditorVideoSrcMenu;
30
31
  };
32
+ export declare const videoAlignLeftMenuConf: {
33
+ key: string;
34
+ factory(): VideoAlignMenu;
35
+ };
36
+ export declare const videoAlignCenterMenuConf: {
37
+ key: string;
38
+ factory(): VideoAlignMenu;
39
+ };
40
+ export declare const videoAlignRightMenuConf: {
41
+ key: string;
42
+ factory(): VideoAlignMenu;
43
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wangeditor-next/plugin-float-image",
3
- "version": "2.0.8",
3
+ "version": "6.1.1",
4
4
  "description": "wangEditor float image plugin",
5
5
  "author": "cycleccc <2991205548@qq.com>",
6
6
  "type": "module",
@@ -31,13 +31,13 @@
31
31
  "url": "git+https://github.com/wangeditor-next/wangEditor-next.git"
32
32
  },
33
33
  "bugs": {
34
- "url": "https://github.com/wangeditor-next/wangeditor-next/issues"
34
+ "url": "https://github.com/wangeditor-next/wangEditor-next/issues"
35
35
  },
36
36
  "peerDependencies": {
37
- "@wangeditor-next/editor": ">=5.7.8",
38
37
  "dom7": "^3.0.0 || ^4.0.0",
39
38
  "slate": "^0.124.0",
40
- "snabbdom": "^3.6.0"
39
+ "snabbdom": "^3.6.0",
40
+ "@wangeditor-next/editor": "^6.1.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@wangeditor-next-shared/rollup-config": "^0.0.2"