@hufe921/canvas-editor 0.9.51 → 0.9.53
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 +39 -0
- package/dist/canvas-editor.es.js +241 -57
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +26 -26
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +3 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +5 -2
- package/dist/src/editor/core/contextmenu/ContextMenu.d.ts +3 -0
- package/dist/src/editor/core/draw/control/Control.d.ts +5 -4
- package/dist/src/editor/core/draw/control/checkbox/CheckboxControl.d.ts +1 -1
- package/dist/src/editor/core/draw/control/select/SelectControl.d.ts +2 -2
- package/dist/src/editor/core/draw/control/text/TextControl.d.ts +1 -1
- package/dist/src/editor/core/override/Override.d.ts +1 -0
- package/dist/src/editor/core/register/Register.d.ts +1 -0
- package/dist/src/editor/dataset/constant/ContextMenu.d.ts +49 -0
- package/dist/src/editor/index.d.ts +2 -1
- package/dist/src/editor/interface/Control.d.ts +13 -5
- package/dist/src/editor/interface/Editor.d.ts +1 -0
- package/dist/src/editor/interface/contextmenu/ContextMenu.d.ts +2 -0
- package/dist/src/editor/utils/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ export declare class Command {
|
|
|
8
8
|
executeBackspace: CommandAdapt['backspace'];
|
|
9
9
|
executeSetRange: CommandAdapt['setRange'];
|
|
10
10
|
executeForceUpdate: CommandAdapt['forceUpdate'];
|
|
11
|
+
executeBlur: CommandAdapt['blur'];
|
|
11
12
|
executeUndo: CommandAdapt['undo'];
|
|
12
13
|
executeRedo: CommandAdapt['redo'];
|
|
13
14
|
executePainter: CommandAdapt['painter'];
|
|
@@ -81,6 +82,7 @@ export declare class Command {
|
|
|
81
82
|
executeDeleteGroup: CommandAdapt['deleteGroup'];
|
|
82
83
|
executeLocationGroup: CommandAdapt['locationGroup'];
|
|
83
84
|
executeSetControlValue: CommandAdapt['setControlValue'];
|
|
85
|
+
executeSetControlExtension: CommandAdapt['setControlExtension'];
|
|
84
86
|
getCatalog: CommandAdapt['getCatalog'];
|
|
85
87
|
getImage: CommandAdapt['getImage'];
|
|
86
88
|
getOptions: CommandAdapt['getOptions'];
|
|
@@ -97,5 +99,6 @@ export declare class Command {
|
|
|
97
99
|
getLocale: CommandAdapt['getLocale'];
|
|
98
100
|
getGroupIds: CommandAdapt['getGroupIds'];
|
|
99
101
|
getControlValue: CommandAdapt['getControlValue'];
|
|
102
|
+
getContainer: CommandAdapt['getContainer'];
|
|
100
103
|
constructor(adapt: CommandAdapt);
|
|
101
104
|
}
|
|
@@ -7,7 +7,7 @@ import { TitleLevel } from '../../dataset/enum/Title';
|
|
|
7
7
|
import { VerticalAlign } from '../../dataset/enum/VerticalAlign';
|
|
8
8
|
import { ICatalog } from '../../interface/Catalog';
|
|
9
9
|
import { DeepRequired } from '../../interface/Common';
|
|
10
|
-
import { IGetControlValueOption, IGetControlValueResult,
|
|
10
|
+
import { IGetControlValueOption, IGetControlValueResult, ISetControlExtensionOption, ISetControlValueOption } from '../../interface/Control';
|
|
11
11
|
import { IAppendElementListOption, IDrawImagePayload, IForceUpdateOption, IGetImageOption, IGetValueOption, IPainterOption } from '../../interface/Draw';
|
|
12
12
|
import { IEditorData, IEditorHTML, IEditorOption, IEditorResult, IEditorText } from '../../interface/Editor';
|
|
13
13
|
import { IElement } from '../../interface/Element';
|
|
@@ -37,6 +37,7 @@ export declare class CommandAdapt {
|
|
|
37
37
|
backspace(): void;
|
|
38
38
|
setRange(startIndex: number, endIndex: number): void;
|
|
39
39
|
forceUpdate(options?: IForceUpdateOption): void;
|
|
40
|
+
blur(): void;
|
|
40
41
|
undo(): void;
|
|
41
42
|
redo(): void;
|
|
42
43
|
painter(options: IPainterOption): void;
|
|
@@ -126,5 +127,7 @@ export declare class CommandAdapt {
|
|
|
126
127
|
getGroupIds(): Promise<string[]>;
|
|
127
128
|
locationGroup(groupId: string): void;
|
|
128
129
|
getControlValue(payload: IGetControlValueOption): IGetControlValueResult | null;
|
|
129
|
-
setControlValue(payload:
|
|
130
|
+
setControlValue(payload: ISetControlValueOption): void;
|
|
131
|
+
setControlExtension(payload: ISetControlExtensionOption): void;
|
|
132
|
+
getContainer(): HTMLDivElement;
|
|
130
133
|
}
|
|
@@ -2,6 +2,7 @@ import { IRegisterContextMenu } from '../../interface/contextmenu/ContextMenu';
|
|
|
2
2
|
import { Command } from '../command/Command';
|
|
3
3
|
import { Draw } from '../draw/Draw';
|
|
4
4
|
export declare class ContextMenu {
|
|
5
|
+
private options;
|
|
5
6
|
private draw;
|
|
6
7
|
private command;
|
|
7
8
|
private range;
|
|
@@ -13,8 +14,10 @@ export declare class ContextMenu {
|
|
|
13
14
|
private contextMenuRelationShip;
|
|
14
15
|
private context;
|
|
15
16
|
constructor(draw: Draw, command: Command);
|
|
17
|
+
getContextMenuList(): IRegisterContextMenu[];
|
|
16
18
|
private _addEvent;
|
|
17
19
|
removeEvent(): void;
|
|
20
|
+
private _filterMenuList;
|
|
18
21
|
private _proxyContextMenuEvent;
|
|
19
22
|
private _handleSideEffect;
|
|
20
23
|
private _getContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IControlInitOption, IControlInstance, IGetControlValueOption, IGetControlValueResult,
|
|
1
|
+
import { IControlInitOption, IControlInstance, IGetControlValueOption, IGetControlValueResult, ISetControlExtensionOption, ISetControlValueOption } from '../../../interface/Control';
|
|
2
2
|
import { IEditorData } from '../../../interface/Editor';
|
|
3
3
|
import { IElement, IElementPosition } from '../../../interface/Element';
|
|
4
4
|
import { IRange } from '../../../interface/Range';
|
|
@@ -31,13 +31,14 @@ export declare class Control {
|
|
|
31
31
|
destroyControl(): void;
|
|
32
32
|
repaintControl(curIndex: number): void;
|
|
33
33
|
moveCursor(position: IControlInitOption): IMoveCursorResult;
|
|
34
|
-
removeControl(startIndex: number): number;
|
|
34
|
+
removeControl(startIndex: number): number | null;
|
|
35
35
|
removePlaceholder(startIndex: number): void;
|
|
36
36
|
addPlaceholder(startIndex: number): void;
|
|
37
37
|
setValue(data: IElement[]): number;
|
|
38
|
-
keydown(evt: KeyboardEvent): number;
|
|
38
|
+
keydown(evt: KeyboardEvent): number | null;
|
|
39
39
|
cut(): number;
|
|
40
40
|
getValueByConceptId(payload: IGetControlValueOption): IGetControlValueResult;
|
|
41
|
-
setValueByConceptId(payload:
|
|
41
|
+
setValueByConceptId(payload: ISetControlValueOption): void;
|
|
42
|
+
setExtensionByConceptId(payload: ISetControlExtensionOption): void;
|
|
42
43
|
}
|
|
43
44
|
export {};
|
|
@@ -10,6 +10,6 @@ export declare class CheckboxControl implements IControlInstance {
|
|
|
10
10
|
getValue(): IElement[];
|
|
11
11
|
setValue(): number;
|
|
12
12
|
setSelect(context?: IControlContext): void;
|
|
13
|
-
keydown(evt: KeyboardEvent): number;
|
|
13
|
+
keydown(evt: KeyboardEvent): number | null;
|
|
14
14
|
cut(): number;
|
|
15
15
|
}
|
|
@@ -9,9 +9,9 @@ export declare class SelectControl implements IControlInstance {
|
|
|
9
9
|
constructor(element: IElement, control: Control);
|
|
10
10
|
getElement(): IElement;
|
|
11
11
|
getCode(): string | null;
|
|
12
|
-
getValue(): IElement[];
|
|
12
|
+
getValue(context?: IControlContext): IElement[];
|
|
13
13
|
setValue(): number;
|
|
14
|
-
keydown(evt: KeyboardEvent): number;
|
|
14
|
+
keydown(evt: KeyboardEvent): number | null;
|
|
15
15
|
cut(): number;
|
|
16
16
|
clearSelect(context?: IControlContext): number;
|
|
17
17
|
setSelect(code: string, context?: IControlContext): void;
|
|
@@ -9,6 +9,6 @@ export declare class TextControl implements IControlInstance {
|
|
|
9
9
|
getValue(): IElement[];
|
|
10
10
|
setValue(data: IElement[], context?: IControlContext): number;
|
|
11
11
|
clearValue(context?: IControlContext): number;
|
|
12
|
-
keydown(evt: KeyboardEvent): number;
|
|
12
|
+
keydown(evt: KeyboardEvent): number | null;
|
|
13
13
|
cut(): number;
|
|
14
14
|
}
|
|
@@ -12,6 +12,7 @@ interface IRegisterPayload {
|
|
|
12
12
|
}
|
|
13
13
|
export declare class Register {
|
|
14
14
|
contextMenuList: (payload: IRegisterContextMenu[]) => void;
|
|
15
|
+
getContextMenuList: () => IRegisterContextMenu[];
|
|
15
16
|
shortcutList: (payload: IRegisterShortcut[]) => void;
|
|
16
17
|
langMap: (locale: string, lang: DeepPartial<ILang>) => void;
|
|
17
18
|
constructor(payload: IRegisterPayload);
|
|
@@ -1,3 +1,52 @@
|
|
|
1
1
|
export declare const NAME_PLACEHOLDER: {
|
|
2
2
|
SELECTED_TEXT: string;
|
|
3
3
|
};
|
|
4
|
+
export declare const INTERNAL_CONTEXT_MENU_KEY: {
|
|
5
|
+
GLOBAL: {
|
|
6
|
+
CUT: string;
|
|
7
|
+
COPY: string;
|
|
8
|
+
PASTE: string;
|
|
9
|
+
SELECT_ALL: string;
|
|
10
|
+
PRINT: string;
|
|
11
|
+
};
|
|
12
|
+
CONTROL: {
|
|
13
|
+
DELETE: string;
|
|
14
|
+
};
|
|
15
|
+
HYPERLINK: {
|
|
16
|
+
DELETE: string;
|
|
17
|
+
CANCEL: string;
|
|
18
|
+
EDIT: string;
|
|
19
|
+
};
|
|
20
|
+
IMAGE: {
|
|
21
|
+
CHANGE: string;
|
|
22
|
+
SAVE_AS: string;
|
|
23
|
+
TEXT_WRAP: string;
|
|
24
|
+
TEXT_WRAP_EMBED: string;
|
|
25
|
+
TEXT_WRAP_UP_DOWN: string;
|
|
26
|
+
};
|
|
27
|
+
TABLE: {
|
|
28
|
+
BORDER: string;
|
|
29
|
+
BORDER_ALL: string;
|
|
30
|
+
BORDER_EMPTY: string;
|
|
31
|
+
BORDER_EXTERNAL: string;
|
|
32
|
+
BORDER_TD: string;
|
|
33
|
+
BORDER_TD_BOTTOM: string;
|
|
34
|
+
BORDER_TD_FORWARD: string;
|
|
35
|
+
BORDER_TD_BACK: string;
|
|
36
|
+
VERTICAL_ALIGN: string;
|
|
37
|
+
VERTICAL_ALIGN_TOP: string;
|
|
38
|
+
VERTICAL_ALIGN_MIDDLE: string;
|
|
39
|
+
VERTICAL_ALIGN_BOTTOM: string;
|
|
40
|
+
INSERT_ROW_COL: string;
|
|
41
|
+
INSERT_TOP_ROW: string;
|
|
42
|
+
INSERT_BOTTOM_ROW: string;
|
|
43
|
+
INSERT_LEFT_COL: string;
|
|
44
|
+
INSERT_RIGHT_COL: string;
|
|
45
|
+
DELETE_ROW_COL: string;
|
|
46
|
+
DELETE_ROW: string;
|
|
47
|
+
DELETE_COL: string;
|
|
48
|
+
DELETE_TABLE: string;
|
|
49
|
+
MERGE_CELL: string;
|
|
50
|
+
CANCEL_MERGE_CELL: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
@@ -28,6 +28,7 @@ import { EventBusMap } from './interface/EventBus';
|
|
|
28
28
|
import { IRangeStyle } from './interface/Listener';
|
|
29
29
|
import { Override } from './core/override/Override';
|
|
30
30
|
import { LETTER_CLASS } from './dataset/constant/Common';
|
|
31
|
+
import { INTERNAL_CONTEXT_MENU_KEY } from './dataset/constant/ContextMenu';
|
|
31
32
|
export default class Editor {
|
|
32
33
|
command: Command;
|
|
33
34
|
listener: Listener;
|
|
@@ -38,5 +39,5 @@ export default class Editor {
|
|
|
38
39
|
use: UsePlugin;
|
|
39
40
|
constructor(container: HTMLDivElement, data: IEditorData | IElement[], options?: IEditorOption);
|
|
40
41
|
}
|
|
41
|
-
export { EDITOR_COMPONENT, LETTER_CLASS, Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, PageMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection, TableBorder, TdBorder, TdSlash, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle, WordBreak };
|
|
42
|
+
export { EDITOR_COMPONENT, LETTER_CLASS, INTERNAL_CONTEXT_MENU_KEY, Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, PageMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection, TableBorder, TdBorder, TdSlash, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle, WordBreak };
|
|
42
43
|
export type { IElement, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang, ICatalog, ICatalogItem, IRangeStyle };
|
|
@@ -17,6 +17,9 @@ export interface IControlCheckbox {
|
|
|
17
17
|
valueSets: IValueSet[];
|
|
18
18
|
checkbox?: ICheckbox;
|
|
19
19
|
}
|
|
20
|
+
export interface IControlRule {
|
|
21
|
+
deletable?: boolean;
|
|
22
|
+
}
|
|
20
23
|
export interface IControlBasic {
|
|
21
24
|
type: ControlType;
|
|
22
25
|
value: IElement[] | null;
|
|
@@ -26,8 +29,9 @@ export interface IControlBasic {
|
|
|
26
29
|
postfix?: string;
|
|
27
30
|
minWidth?: number;
|
|
28
31
|
underline?: boolean;
|
|
32
|
+
extension?: unknown;
|
|
29
33
|
}
|
|
30
|
-
export declare type IControl = IControlBasic & Partial<IControlSelect> & Partial<IControlCheckbox>;
|
|
34
|
+
export declare type IControl = IControlBasic & IControlRule & Partial<IControlSelect> & Partial<IControlCheckbox>;
|
|
31
35
|
export interface IControlOption {
|
|
32
36
|
placeholderColor?: string;
|
|
33
37
|
bracketColor?: string;
|
|
@@ -48,7 +52,7 @@ export interface IControlInstance {
|
|
|
48
52
|
getElement(): IElement;
|
|
49
53
|
getValue(): IElement[];
|
|
50
54
|
setValue(data: IElement[]): number;
|
|
51
|
-
keydown(evt: KeyboardEvent): number;
|
|
55
|
+
keydown(evt: KeyboardEvent): number | null;
|
|
52
56
|
cut(): number;
|
|
53
57
|
}
|
|
54
58
|
export interface IControlContext {
|
|
@@ -58,11 +62,15 @@ export interface IControlContext {
|
|
|
58
62
|
export interface IGetControlValueOption {
|
|
59
63
|
conceptId: string;
|
|
60
64
|
}
|
|
61
|
-
export declare type IGetControlValueResult = {
|
|
65
|
+
export declare type IGetControlValueResult = (Omit<IControl, 'value'> & {
|
|
62
66
|
value: string | null;
|
|
63
67
|
innerText: string | null;
|
|
64
|
-
}[];
|
|
65
|
-
export interface
|
|
68
|
+
})[];
|
|
69
|
+
export interface ISetControlValueOption {
|
|
66
70
|
conceptId: string;
|
|
67
71
|
value: string;
|
|
68
72
|
}
|
|
73
|
+
export interface ISetControlExtensionOption {
|
|
74
|
+
conceptId: string;
|
|
75
|
+
extension: unknown;
|
|
76
|
+
}
|
|
@@ -12,11 +12,13 @@ export interface IContextMenuContext {
|
|
|
12
12
|
zone: EditorZone;
|
|
13
13
|
}
|
|
14
14
|
export interface IRegisterContextMenu {
|
|
15
|
+
key?: string;
|
|
15
16
|
i18nPath?: string;
|
|
16
17
|
isDivider?: boolean;
|
|
17
18
|
icon?: string;
|
|
18
19
|
name?: string;
|
|
19
20
|
shortCut?: string;
|
|
21
|
+
disable?: boolean;
|
|
20
22
|
when?: (payload: IContextMenuContext) => boolean;
|
|
21
23
|
callback?: (command: Command, context: IContextMenuContext) => any;
|
|
22
24
|
childMenus?: IRegisterContextMenu[];
|
|
@@ -12,6 +12,7 @@ export declare function mergeObject<T>(source: T, target: T): T;
|
|
|
12
12
|
export declare function nextTick(fn: Function): void;
|
|
13
13
|
export declare function convertNumberToChinese(num: number): string;
|
|
14
14
|
export declare function cloneProperty<T>(properties: (keyof T)[], sourceElement: T, targetElement: T): void;
|
|
15
|
+
export declare function pickObject<T>(object: T, pickKeys: (keyof T)[]): T;
|
|
15
16
|
export declare function omitObject<T>(object: T, omitKeys: (keyof T)[]): T;
|
|
16
17
|
export declare function convertStringToBase64(input: string): string;
|
|
17
18
|
export declare function findScrollContainer(element: HTMLElement): HTMLElement;
|