@hufe921/canvas-editor 0.9.92 → 0.9.94
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.
- package/CHANGELOG.md +53 -0
- package/dist/canvas-editor.es.js +3866 -3514
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +34 -34
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +1 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +3 -2
- package/dist/src/editor/core/draw/Draw.d.ts +3 -0
- package/dist/src/editor/core/draw/particle/table/TableOperate.d.ts +28 -0
- package/dist/src/editor/core/draw/particle/table/TableTool.d.ts +7 -0
- package/dist/src/editor/core/event/GlobalEvent.d.ts +1 -0
- package/dist/src/editor/core/position/Position.d.ts +5 -1
- package/dist/src/editor/dataset/constant/ContextMenu.d.ts +1 -0
- package/dist/src/editor/dataset/enum/Common.d.ts +1 -0
- package/dist/src/editor/index.d.ts +2 -1
- package/dist/src/editor/interface/Catalog.d.ts +1 -0
- package/dist/src/editor/interface/Control.d.ts +2 -1
- package/dist/src/editor/interface/Draw.d.ts +7 -1
- package/dist/src/editor/interface/Element.d.ts +1 -0
- package/dist/src/editor/interface/Footer.d.ts +1 -0
- package/dist/src/editor/interface/Header.d.ts +1 -0
- package/dist/src/editor/interface/Position.d.ts +11 -3
- package/dist/src/editor/interface/Range.d.ts +2 -0
- package/dist/src/editor/interface/Row.d.ts +1 -0
- package/dist/src/editor/interface/Watermark.d.ts +2 -0
- package/dist/src/editor/utils/element.d.ts +3 -1
- package/dist/src/editor/utils/index.d.ts +2 -0
- package/package.json +1 -1
|
@@ -101,6 +101,7 @@ export declare class Command {
|
|
|
101
101
|
getHTML: CommandAdapt['getHTML'];
|
|
102
102
|
getText: CommandAdapt['getText'];
|
|
103
103
|
getWordCount: CommandAdapt['getWordCount'];
|
|
104
|
+
getCursorPosition: CommandAdapt['getCursorPosition'];
|
|
104
105
|
getRange: CommandAdapt['getRange'];
|
|
105
106
|
getRangeText: CommandAdapt['getRangeText'];
|
|
106
107
|
getRangeContext: CommandAdapt['getRangeContext'];
|
|
@@ -10,7 +10,7 @@ import { DeepRequired } from '../../interface/Common';
|
|
|
10
10
|
import { IGetControlValueOption, IGetControlValueResult, ILocationControlOption, ISetControlExtensionOption, ISetControlHighlightOption, ISetControlProperties, ISetControlValueOption } from '../../interface/Control';
|
|
11
11
|
import { IAppendElementListOption, IDrawImagePayload, IForceUpdateOption, IGetImageOption, IGetValueOption, IPainterOption } from '../../interface/Draw';
|
|
12
12
|
import { IEditorData, IEditorHTML, IEditorOption, IEditorResult, IEditorText, IFocusOption, ISetValueOption, IUpdateOption } from '../../interface/Editor';
|
|
13
|
-
import { IElement, IUpdateElementByIdOption } from '../../interface/Element';
|
|
13
|
+
import { IElement, IElementPosition, IUpdateElementByIdOption } from '../../interface/Element';
|
|
14
14
|
import { IPasteOption, IPositionContextByEvent } from '../../interface/Event';
|
|
15
15
|
import { IMargin } from '../../interface/Margin';
|
|
16
16
|
import { IRange, RangeContext } from '../../interface/Range';
|
|
@@ -25,13 +25,13 @@ export declare class CommandAdapt {
|
|
|
25
25
|
private position;
|
|
26
26
|
private historyManager;
|
|
27
27
|
private canvasEvent;
|
|
28
|
-
private tableTool;
|
|
29
28
|
private options;
|
|
30
29
|
private control;
|
|
31
30
|
private workerManager;
|
|
32
31
|
private searchManager;
|
|
33
32
|
private i18n;
|
|
34
33
|
private zone;
|
|
34
|
+
private tableOperate;
|
|
35
35
|
constructor(draw: Draw);
|
|
36
36
|
mode(payload: EditorMode): void;
|
|
37
37
|
cut(): void;
|
|
@@ -106,6 +106,7 @@ export declare class CommandAdapt {
|
|
|
106
106
|
getHTML(): IEditorHTML;
|
|
107
107
|
getText(): IEditorText;
|
|
108
108
|
getWordCount(): Promise<number>;
|
|
109
|
+
getCursorPosition(): IElementPosition | null;
|
|
109
110
|
getRange(): IRange;
|
|
110
111
|
getRangeText(): string;
|
|
111
112
|
getRangeContext(): RangeContext | null;
|
|
@@ -36,6 +36,7 @@ import { Group } from './interactive/Group';
|
|
|
36
36
|
import { Override } from '../override/Override';
|
|
37
37
|
import { LineBreakParticle } from './particle/LineBreakParticle';
|
|
38
38
|
import { ITd } from '../../interface/table/Td';
|
|
39
|
+
import { TableOperate } from './particle/table/TableOperate';
|
|
39
40
|
export declare class Draw {
|
|
40
41
|
private container;
|
|
41
42
|
private pageContainer;
|
|
@@ -70,6 +71,7 @@ export declare class Draw {
|
|
|
70
71
|
private textParticle;
|
|
71
72
|
private tableParticle;
|
|
72
73
|
private tableTool;
|
|
74
|
+
private tableOperate;
|
|
73
75
|
private pageNumber;
|
|
74
76
|
private lineNumber;
|
|
75
77
|
private waterMark;
|
|
@@ -174,6 +176,7 @@ export declare class Draw {
|
|
|
174
176
|
getPreviewer(): Previewer;
|
|
175
177
|
getImageParticle(): ImageParticle;
|
|
176
178
|
getTableTool(): TableTool;
|
|
179
|
+
getTableOperate(): TableOperate;
|
|
177
180
|
getTableParticle(): TableParticle;
|
|
178
181
|
getHeader(): Header;
|
|
179
182
|
getFooter(): Footer;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TableBorder, VerticalAlign } from '../../../..';
|
|
2
|
+
import { TdBorder, TdSlash } from '../../../../dataset/enum/table/Table';
|
|
3
|
+
import { Draw } from '../../Draw';
|
|
4
|
+
export declare class TableOperate {
|
|
5
|
+
private draw;
|
|
6
|
+
private range;
|
|
7
|
+
private position;
|
|
8
|
+
private tableTool;
|
|
9
|
+
private tableParticle;
|
|
10
|
+
private options;
|
|
11
|
+
constructor(draw: Draw);
|
|
12
|
+
insertTable(row: number, col: number): void;
|
|
13
|
+
insertTableTopRow(): void;
|
|
14
|
+
insertTableBottomRow(): void;
|
|
15
|
+
insertTableLeftCol(): void;
|
|
16
|
+
insertTableRightCol(): void;
|
|
17
|
+
deleteTableRow(): void;
|
|
18
|
+
deleteTableCol(): void;
|
|
19
|
+
deleteTable(): void;
|
|
20
|
+
mergeTableCell(): void;
|
|
21
|
+
cancelMergeTableCell(): void;
|
|
22
|
+
tableTdVerticalAlign(payload: VerticalAlign): void;
|
|
23
|
+
tableBorderType(payload: TableBorder): void;
|
|
24
|
+
tableTdBorderType(payload: TdBorder): void;
|
|
25
|
+
tableTdSlashType(payload: TdSlash): void;
|
|
26
|
+
tableTdBackgroundColor(payload: string): void;
|
|
27
|
+
tableSelectAll(): void;
|
|
28
|
+
}
|
|
@@ -2,13 +2,20 @@ import { Draw } from '../../Draw';
|
|
|
2
2
|
export declare class TableTool {
|
|
3
3
|
private readonly MIN_TD_WIDTH;
|
|
4
4
|
private readonly ROW_COL_OFFSET;
|
|
5
|
+
private readonly ROW_COL_QUICK_WIDTH;
|
|
6
|
+
private readonly ROW_COL_QUICK_OFFSET;
|
|
7
|
+
private readonly ROW_COL_QUICK_POSITION;
|
|
5
8
|
private readonly BORDER_VALUE;
|
|
9
|
+
private readonly TABLE_SELECT_OFFSET;
|
|
6
10
|
private draw;
|
|
7
11
|
private canvas;
|
|
8
12
|
private options;
|
|
9
13
|
private position;
|
|
10
14
|
private container;
|
|
11
15
|
private toolRowContainer;
|
|
16
|
+
private toolRowAddBtn;
|
|
17
|
+
private toolColAddBtn;
|
|
18
|
+
private toolTableSelectBtn;
|
|
12
19
|
private toolColContainer;
|
|
13
20
|
private toolBorderContainer;
|
|
14
21
|
private anchorLine;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IComputePageRowPositionPayload, IComputePageRowPositionResult, IComputeRowPositionPayload, IFloatPosition, IGetFloatPositionByXYPayload } from '../../interface/Position';
|
|
1
|
+
import { IComputePageRowPositionPayload, IComputePageRowPositionResult, IComputeRowPositionPayload, IFloatPosition, IGetFloatPositionByXYPayload, ISetSurroundPositionPayload } from '../../interface/Position';
|
|
2
2
|
import { IElement, IElementPosition } from '../../interface/Element';
|
|
3
3
|
import { ICurrentPosition, IGetPositionByXYPayload, IPositionContext } from '../../interface/Position';
|
|
4
4
|
import { Draw } from '../draw/Draw';
|
|
@@ -30,4 +30,8 @@ export declare class Position {
|
|
|
30
30
|
getPositionByXY(payload: IGetPositionByXYPayload): ICurrentPosition;
|
|
31
31
|
getFloatPositionByXY(payload: IGetFloatPositionByXYPayload): ICurrentPosition | void;
|
|
32
32
|
adjustPositionContext(payload: IGetPositionByXYPayload): ICurrentPosition | null;
|
|
33
|
+
setSurroundPosition(payload: ISetSurroundPositionPayload): {
|
|
34
|
+
x: number;
|
|
35
|
+
rowIncreaseWidth: number;
|
|
36
|
+
};
|
|
33
37
|
}
|
|
@@ -32,6 +32,7 @@ import { LETTER_CLASS } from './dataset/constant/Common';
|
|
|
32
32
|
import { INTERNAL_CONTEXT_MENU_KEY } from './dataset/constant/ContextMenu';
|
|
33
33
|
import { IRange } from './interface/Range';
|
|
34
34
|
import { splitText } from './utils';
|
|
35
|
+
import { createDomFromElementList } from './utils/element';
|
|
35
36
|
import { BackgroundRepeat, BackgroundSize } from './dataset/enum/Background';
|
|
36
37
|
import { TextDecorationStyle } from './dataset/enum/Text';
|
|
37
38
|
import { LineNumberType } from './dataset/enum/LineNumber';
|
|
@@ -45,7 +46,7 @@ export default class Editor {
|
|
|
45
46
|
use: UsePlugin;
|
|
46
47
|
constructor(container: HTMLDivElement, data: IEditorData | IElement[], options?: IEditorOption);
|
|
47
48
|
}
|
|
48
|
-
export { splitText };
|
|
49
|
+
export { splitText, createDomFromElementList };
|
|
49
50
|
export { EDITOR_COMPONENT, LETTER_CLASS, INTERNAL_CONTEXT_MENU_KEY };
|
|
50
51
|
export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, PageMode, RenderMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection, TableBorder, TdBorder, TdSlash, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle, WordBreak, ControlIndentation, BackgroundRepeat, BackgroundSize, TextDecorationStyle, LineNumberType, LocationPosition };
|
|
51
52
|
export type { IElement, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang, ICatalog, ICatalogItem, IRange, IRangeStyle };
|
|
@@ -106,11 +106,12 @@ export type IGetControlValueResult = (Omit<IControl, 'value'> & {
|
|
|
106
106
|
value: string | null;
|
|
107
107
|
innerText: string | null;
|
|
108
108
|
zone: EditorZone;
|
|
109
|
+
elementList?: IElement[];
|
|
109
110
|
})[];
|
|
110
111
|
export interface ISetControlValueOption {
|
|
111
112
|
id?: string;
|
|
112
113
|
conceptId?: string;
|
|
113
|
-
value: string;
|
|
114
|
+
value: string | IElement[];
|
|
114
115
|
}
|
|
115
116
|
export interface ISetControlExtensionOption {
|
|
116
117
|
id?: string;
|
|
@@ -33,7 +33,7 @@ export interface IDrawRowPayload {
|
|
|
33
33
|
}
|
|
34
34
|
export interface IDrawFloatPayload {
|
|
35
35
|
pageNo: number;
|
|
36
|
-
|
|
36
|
+
imgDisplays: ImageDisplay[];
|
|
37
37
|
}
|
|
38
38
|
export interface IDrawPagePayload {
|
|
39
39
|
elementList: IElement[];
|
|
@@ -58,5 +58,11 @@ export interface IGetImageOption {
|
|
|
58
58
|
export interface IComputeRowListPayload {
|
|
59
59
|
innerWidth: number;
|
|
60
60
|
elementList: IElement[];
|
|
61
|
+
startX?: number;
|
|
62
|
+
startY?: number;
|
|
63
|
+
isFromTable?: boolean;
|
|
61
64
|
isPagingMode?: boolean;
|
|
65
|
+
pageHeight?: number;
|
|
66
|
+
mainOuterHeight?: number;
|
|
67
|
+
surroundElementList?: IElement[];
|
|
62
68
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IElement, ImageDisplay, IRange } from '..';
|
|
2
2
|
import { EditorZone } from '../dataset/enum/Editor';
|
|
3
|
-
import { IElementPosition } from './Element';
|
|
4
|
-
import { IRow } from './Row';
|
|
3
|
+
import { IElementFillRect, IElementPosition } from './Element';
|
|
4
|
+
import { IRow, IRowElement } from './Row';
|
|
5
5
|
import { ITd } from './table/Td';
|
|
6
6
|
export interface ICurrentPosition {
|
|
7
7
|
index: number;
|
|
@@ -33,7 +33,7 @@ export interface IGetPositionByXYPayload {
|
|
|
33
33
|
positionList?: IElementPosition[];
|
|
34
34
|
}
|
|
35
35
|
export type IGetFloatPositionByXYPayload = IGetPositionByXYPayload & {
|
|
36
|
-
|
|
36
|
+
imgDisplays: ImageDisplay[];
|
|
37
37
|
};
|
|
38
38
|
export interface IPositionContext {
|
|
39
39
|
isTable: boolean;
|
|
@@ -90,3 +90,11 @@ export interface ILocationPosition {
|
|
|
90
90
|
range: IRange;
|
|
91
91
|
positionContext: IPositionContext;
|
|
92
92
|
}
|
|
93
|
+
export interface ISetSurroundPositionPayload {
|
|
94
|
+
row: IRow;
|
|
95
|
+
rowElement: IRowElement;
|
|
96
|
+
rowElementRect: IElementFillRect;
|
|
97
|
+
pageNo: number;
|
|
98
|
+
availableWidth: number;
|
|
99
|
+
surroundElementList: IElement[];
|
|
100
|
+
}
|
|
@@ -28,6 +28,8 @@ export type RangeContext = {
|
|
|
28
28
|
tableElement: IElement | null;
|
|
29
29
|
selectionText: string | null;
|
|
30
30
|
selectionElementList: IElement[];
|
|
31
|
+
titleId: string | null;
|
|
32
|
+
titleStartPageNo: number | null;
|
|
31
33
|
};
|
|
32
34
|
export interface IRangeParagraphInfo {
|
|
33
35
|
elementList: IElement[];
|
|
@@ -33,7 +33,7 @@ export interface IElementListGroupRowFlex {
|
|
|
33
33
|
data: IElement[];
|
|
34
34
|
}
|
|
35
35
|
export declare function groupElementListByRowFlex(elementList: IElement[]): IElementListGroupRowFlex[];
|
|
36
|
-
export declare function createDomFromElementList(elementList: IElement[], options
|
|
36
|
+
export declare function createDomFromElementList(elementList: IElement[], options?: IEditorOption): HTMLDivElement;
|
|
37
37
|
export declare function convertTextNodeToElement(textNode: Element | Node): IElement | null;
|
|
38
38
|
interface IGetElementListByHTMLOption {
|
|
39
39
|
innerWidth: number;
|
|
@@ -43,4 +43,6 @@ export declare function getTextFromElementList(elementList: IElement[]): string;
|
|
|
43
43
|
export declare function getSlimCloneElementList(elementList: IElement[]): IElement[];
|
|
44
44
|
export declare function getIsBlockElement(element?: IElement): boolean;
|
|
45
45
|
export declare function replaceHTMLElementTag(oldDom: HTMLElement, tagName: keyof HTMLElementTagNameMap): HTMLElement;
|
|
46
|
+
export declare function pickSurroundElementList(elementList: IElement[]): IElement[];
|
|
47
|
+
export declare function deleteSurroundElementList(elementList: IElement[], pageNo: number): void;
|
|
46
48
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IElementFillRect } from '../interface/Element';
|
|
1
2
|
export declare function debounce<T extends unknown[]>(func: (...arg: T) => unknown, delay: number): (this: unknown, ...args: T) => void;
|
|
2
3
|
export declare function throttle<T extends unknown[]>(func: (...arg: T) => unknown, delay: number): (this: unknown, ...args: T) => void;
|
|
3
4
|
export declare function deepCloneOmitKeys<T, K>(obj: T, omitKeys: (keyof K)[]): T;
|
|
@@ -20,3 +21,4 @@ export declare function convertStringToBase64(input: string): string;
|
|
|
20
21
|
export declare function findScrollContainer(element: HTMLElement): HTMLElement;
|
|
21
22
|
export declare function isArrayEqual(arr1: unknown[], arr2: unknown[]): boolean;
|
|
22
23
|
export declare function isObjectEqual(obj1: unknown, obj2: unknown): boolean;
|
|
24
|
+
export declare function isRectIntersect(rect1: IElementFillRect, rect2: IElementFillRect): boolean;
|