@hufe921/canvas-editor 0.9.65 → 0.9.67
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 +42 -0
- package/dist/canvas-editor.es.js +521 -111
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +33 -33
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/CommandAdapt.d.ts +3 -2
- package/dist/src/editor/core/draw/Draw.d.ts +2 -0
- package/dist/src/editor/core/draw/control/text/TextControl.d.ts +1 -1
- package/dist/src/editor/core/draw/particle/ImageParticle.d.ts +6 -0
- package/dist/src/editor/core/draw/particle/previewer/Previewer.d.ts +3 -2
- package/dist/src/editor/core/draw/richtext/AbstractRichText.d.ts +5 -3
- package/dist/src/editor/core/draw/richtext/Underline.d.ts +3 -0
- package/dist/src/editor/core/event/handlers/mousedown.d.ts +1 -0
- package/dist/src/editor/core/position/Position.d.ts +4 -1
- package/dist/src/editor/dataset/constant/ContextMenu.d.ts +2 -0
- package/dist/src/editor/dataset/constant/Element.d.ts +1 -0
- package/dist/src/editor/dataset/enum/Common.d.ts +6 -0
- package/dist/src/editor/dataset/enum/Control.d.ts +0 -4
- package/dist/src/editor/dataset/enum/Text.d.ts +12 -0
- package/dist/src/editor/index.d.ts +4 -2
- package/dist/src/editor/interface/Draw.d.ts +5 -0
- package/dist/src/editor/interface/Element.d.ts +8 -1
- package/dist/src/editor/interface/Listener.d.ts +2 -0
- package/dist/src/editor/interface/Position.d.ts +21 -1
- package/dist/src/editor/interface/Text.d.ts +4 -0
- package/dist/src/editor/interface/table/Td.d.ts +2 -2
- package/dist/src/editor/utils/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ImageDisplay } from '../../dataset/enum/
|
|
1
|
+
import { ImageDisplay } from '../../dataset/enum/Common';
|
|
2
2
|
import { EditorMode, EditorZone, PageMode, PaperDirection } from '../../dataset/enum/Editor';
|
|
3
3
|
import { ListStyle, ListType } from '../../dataset/enum/List';
|
|
4
4
|
import { RowFlex } from '../../dataset/enum/Row';
|
|
@@ -14,6 +14,7 @@ import { IElement } from '../../interface/Element';
|
|
|
14
14
|
import { IPasteOption } from '../../interface/Event';
|
|
15
15
|
import { IMargin } from '../../interface/Margin';
|
|
16
16
|
import { IRange, RangeContext } from '../../interface/Range';
|
|
17
|
+
import { ITextDecoration } from '../../interface/Text';
|
|
17
18
|
import { IWatermark } from '../../interface/Watermark';
|
|
18
19
|
import { Draw } from '../draw/Draw';
|
|
19
20
|
import { INavigateInfo } from '../draw/interactive/Search';
|
|
@@ -52,7 +53,7 @@ export declare class CommandAdapt {
|
|
|
52
53
|
sizeMinus(): void;
|
|
53
54
|
bold(): void;
|
|
54
55
|
italic(): void;
|
|
55
|
-
underline(): void;
|
|
56
|
+
underline(textDecoration?: ITextDecoration): void;
|
|
56
57
|
strikeout(): void;
|
|
57
58
|
superscript(): void;
|
|
58
59
|
subscript(): void;
|
|
@@ -199,6 +199,7 @@ export declare class Draw {
|
|
|
199
199
|
private _computePageList;
|
|
200
200
|
private _drawRichText;
|
|
201
201
|
drawRow(ctx: CanvasRenderingContext2D, payload: IDrawRowPayload): void;
|
|
202
|
+
private _drawFloat;
|
|
202
203
|
private _clearPage;
|
|
203
204
|
private _drawPage;
|
|
204
205
|
private _disconnectLazyRender;
|
|
@@ -206,4 +207,5 @@ export declare class Draw {
|
|
|
206
207
|
private _immediateRender;
|
|
207
208
|
render(payload?: IDrawOption): void;
|
|
208
209
|
destroy(): void;
|
|
210
|
+
clearSideEffect(): void;
|
|
209
211
|
}
|
|
@@ -6,7 +6,7 @@ export declare class TextControl implements IControlInstance {
|
|
|
6
6
|
private control;
|
|
7
7
|
constructor(element: IElement, control: Control);
|
|
8
8
|
getElement(): IElement;
|
|
9
|
-
getValue(): IElement[];
|
|
9
|
+
getValue(context?: IControlContext): IElement[];
|
|
10
10
|
setValue(data: IElement[], context?: IControlContext, options?: IControlRuleOption): number;
|
|
11
11
|
clearValue(context?: IControlContext, options?: IControlRuleOption): number;
|
|
12
12
|
keydown(evt: KeyboardEvent): number | null;
|
|
@@ -5,7 +5,13 @@ export declare class ImageParticle {
|
|
|
5
5
|
private draw;
|
|
6
6
|
protected options: Required<IEditorOption>;
|
|
7
7
|
protected imageCache: Map<string, HTMLImageElement>;
|
|
8
|
+
private container;
|
|
9
|
+
private floatImageContainer;
|
|
10
|
+
private floatImage;
|
|
8
11
|
constructor(draw: Draw);
|
|
12
|
+
createFloatImage(element: IElement): void;
|
|
13
|
+
dragFloatImage(movementX: number, movementY: number): void;
|
|
14
|
+
destroyFloatImage(): void;
|
|
9
15
|
protected addImageObserver(promise: Promise<unknown>): void;
|
|
10
16
|
protected getFallbackImage(width: number, height: number): HTMLImageElement;
|
|
11
17
|
render(ctx: CanvasRenderingContext2D, element: IElement, x: number, y: number): void;
|
|
@@ -23,16 +23,17 @@ export declare class Previewer {
|
|
|
23
23
|
private previewerContainer;
|
|
24
24
|
private previewerImage;
|
|
25
25
|
constructor(draw: Draw);
|
|
26
|
+
private _getElementPosition;
|
|
26
27
|
private _createResizerDom;
|
|
27
28
|
private _keydown;
|
|
28
29
|
private _mousedown;
|
|
29
30
|
private _mousemove;
|
|
30
|
-
private _dblclick;
|
|
31
31
|
private _drawPreviewer;
|
|
32
32
|
_setPreviewerTransform(scale: number, rotate: number, x: number, y: number): void;
|
|
33
33
|
private _clearPreviewer;
|
|
34
34
|
_updateResizerRect(width: number, height: number): void;
|
|
35
35
|
_updateResizerSizeView(width: number, height: number): void;
|
|
36
|
-
|
|
36
|
+
render(): void;
|
|
37
|
+
drawResizer(element: IElement, position?: IElementPosition | null, options?: IPreviewerDrawOption): void;
|
|
37
38
|
clearResizer(): void;
|
|
38
39
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { TextDecorationStyle } from '../../../dataset/enum/Text';
|
|
1
2
|
import { IElementFillRect } from '../../../interface/Element';
|
|
2
3
|
export declare abstract class AbstractRichText {
|
|
3
|
-
fillRect: IElementFillRect;
|
|
4
|
-
fillColor?: string;
|
|
4
|
+
protected fillRect: IElementFillRect;
|
|
5
|
+
protected fillColor?: string;
|
|
6
|
+
protected fillDecorationStyle?: TextDecorationStyle;
|
|
5
7
|
constructor();
|
|
6
8
|
clearFillInfo(): IElementFillRect;
|
|
7
|
-
recordFillInfo(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height?: number, color?: string): void;
|
|
9
|
+
recordFillInfo(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height?: number, color?: string, decorationStyle?: TextDecorationStyle): void;
|
|
8
10
|
abstract render(ctx: CanvasRenderingContext2D): void;
|
|
9
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IComputePageRowPositionPayload, IComputePageRowPositionResult, IComputeRowPositionPayload } from '../../interface/Position';
|
|
1
|
+
import { IComputePageRowPositionPayload, IComputePageRowPositionResult, IComputeRowPositionPayload, IFloatPosition, IGetFloatPositionByXYPayload } 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';
|
|
@@ -6,9 +6,11 @@ export declare class Position {
|
|
|
6
6
|
private cursorPosition;
|
|
7
7
|
private positionContext;
|
|
8
8
|
private positionList;
|
|
9
|
+
private floatPositionList;
|
|
9
10
|
private draw;
|
|
10
11
|
private options;
|
|
11
12
|
constructor(draw: Draw);
|
|
13
|
+
getFloatPositionList(): IFloatPosition[];
|
|
12
14
|
getTablePositionList(sourceElementList: IElement[]): IElementPosition[];
|
|
13
15
|
getPositionList(): IElementPosition[];
|
|
14
16
|
getMainPositionList(): IElementPosition[];
|
|
@@ -24,5 +26,6 @@ export declare class Position {
|
|
|
24
26
|
getPositionContext(): IPositionContext;
|
|
25
27
|
setPositionContext(payload: IPositionContext): void;
|
|
26
28
|
getPositionByXY(payload: IGetPositionByXYPayload): ICurrentPosition;
|
|
29
|
+
getFloatPositionByXY(payload: IGetFloatPositionByXYPayload): ICurrentPosition | void;
|
|
27
30
|
adjustPositionContext(payload: IGetPositionByXYPayload): ICurrentPosition | null;
|
|
28
31
|
}
|
|
@@ -9,6 +9,7 @@ export declare const TABLE_TD_ZIP_ATTR: Array<keyof ITd>;
|
|
|
9
9
|
export declare const TABLE_CONTEXT_ATTR: Array<keyof IElement>;
|
|
10
10
|
export declare const TITLE_CONTEXT_ATTR: Array<keyof IElement>;
|
|
11
11
|
export declare const LIST_CONTEXT_ATTR: Array<keyof IElement>;
|
|
12
|
+
export declare const CONTROL_CONTEXT_ATTR: Array<keyof IElement>;
|
|
12
13
|
export declare const EDITOR_ELEMENT_CONTEXT_ATTR: Array<keyof IElement>;
|
|
13
14
|
export declare const TEXTLIKE_ELEMENT_TYPE: ElementType[];
|
|
14
15
|
export declare const INLINE_ELEMENT_TYPE: ElementType[];
|
|
@@ -10,10 +10,6 @@ export declare enum ControlComponent {
|
|
|
10
10
|
VALUE = "value",
|
|
11
11
|
CHECKBOX = "checkbox"
|
|
12
12
|
}
|
|
13
|
-
export declare enum ImageDisplay {
|
|
14
|
-
INLINE = "inline",
|
|
15
|
-
BLOCK = "block"
|
|
16
|
-
}
|
|
17
13
|
export declare enum ControlIndentation {
|
|
18
14
|
ROW_START = "rowStart",
|
|
19
15
|
VALUE_START = "valueStart"
|
|
@@ -4,13 +4,14 @@ import { IElement } from './interface/Element';
|
|
|
4
4
|
import { Command } from './core/command/Command';
|
|
5
5
|
import { Listener } from './core/listener/Listener';
|
|
6
6
|
import { RowFlex } from './dataset/enum/Row';
|
|
7
|
+
import { ImageDisplay } from './dataset/enum/Common';
|
|
7
8
|
import { ElementType } from './dataset/enum/Element';
|
|
8
9
|
import { Register } from './core/register/Register';
|
|
9
10
|
import { IContextMenuContext, IRegisterContextMenu } from './interface/contextmenu/ContextMenu';
|
|
10
11
|
import { EditorComponent, EditorZone, EditorMode, PageMode, PaperDirection, WordBreak } from './dataset/enum/Editor';
|
|
11
12
|
import { EDITOR_COMPONENT } from './dataset/constant/Editor';
|
|
12
13
|
import { IWatermark } from './interface/Watermark';
|
|
13
|
-
import { ControlIndentation, ControlType
|
|
14
|
+
import { ControlIndentation, ControlType } from './dataset/enum/Control';
|
|
14
15
|
import { INavigateInfo } from './core/draw/interactive/Search';
|
|
15
16
|
import { KeyMap } from './dataset/enum/KeyMap';
|
|
16
17
|
import { BlockType } from './dataset/enum/Block';
|
|
@@ -32,6 +33,7 @@ import { INTERNAL_CONTEXT_MENU_KEY } from './dataset/constant/ContextMenu';
|
|
|
32
33
|
import { IRange } from './interface/Range';
|
|
33
34
|
import { splitText } from './utils';
|
|
34
35
|
import { BackgroundRepeat, BackgroundSize } from './dataset/enum/Background';
|
|
36
|
+
import { TextDecorationStyle } from './dataset/enum/Text';
|
|
35
37
|
export default class Editor {
|
|
36
38
|
command: Command;
|
|
37
39
|
listener: Listener;
|
|
@@ -44,5 +46,5 @@ export default class Editor {
|
|
|
44
46
|
}
|
|
45
47
|
export { splitText };
|
|
46
48
|
export { EDITOR_COMPONENT, LETTER_CLASS, INTERNAL_CONTEXT_MENU_KEY };
|
|
47
|
-
export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, PageMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection, TableBorder, TdBorder, TdSlash, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle, WordBreak, ControlIndentation, BackgroundRepeat, BackgroundSize };
|
|
49
|
+
export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, PageMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection, TableBorder, TdBorder, TdSlash, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle, WordBreak, ControlIndentation, BackgroundRepeat, BackgroundSize, TextDecorationStyle };
|
|
48
50
|
export type { IElement, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang, ICatalog, ICatalogItem, IRange, IRangeStyle };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ImageDisplay } from '../dataset/enum/Common';
|
|
1
2
|
import { EditorMode, EditorZone } from '../dataset/enum/Editor';
|
|
2
3
|
import { IElement, IElementPosition } from './Element';
|
|
3
4
|
import { IRow } from './Row';
|
|
@@ -27,6 +28,10 @@ export interface IDrawRowPayload {
|
|
|
27
28
|
innerWidth: number;
|
|
28
29
|
zone?: EditorZone;
|
|
29
30
|
}
|
|
31
|
+
export interface IDrawFloatPayload {
|
|
32
|
+
pageNo: number;
|
|
33
|
+
imgDisplay: ImageDisplay;
|
|
34
|
+
}
|
|
30
35
|
export interface IDrawPagePayload {
|
|
31
36
|
elementList: IElement[];
|
|
32
37
|
positionList: IElementPosition[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ImageDisplay } from '../dataset/enum/Common';
|
|
2
|
+
import { ControlComponent } from '../dataset/enum/Control';
|
|
2
3
|
import { ElementType } from '../dataset/enum/Element';
|
|
3
4
|
import { ListStyle, ListType } from '../dataset/enum/List';
|
|
4
5
|
import { RowFlex } from '../dataset/enum/Row';
|
|
@@ -7,6 +8,7 @@ import { TableBorder } from '../dataset/enum/table/Table';
|
|
|
7
8
|
import { IBlock } from './Block';
|
|
8
9
|
import { ICheckbox } from './Checkbox';
|
|
9
10
|
import { IControl } from './Control';
|
|
11
|
+
import { ITextDecoration } from './Text';
|
|
10
12
|
import { IColgroup } from './table/Colgroup';
|
|
11
13
|
import { ITr } from './table/Tr';
|
|
12
14
|
export interface IElementBasic {
|
|
@@ -28,6 +30,7 @@ export interface IElementStyle {
|
|
|
28
30
|
rowFlex?: RowFlex;
|
|
29
31
|
rowMargin?: number;
|
|
30
32
|
letterSpacing?: number;
|
|
33
|
+
textDecoration?: ITextDecoration;
|
|
31
34
|
}
|
|
32
35
|
export interface IElementGroup {
|
|
33
36
|
groupIds?: string[];
|
|
@@ -84,6 +87,10 @@ export interface IDateElement {
|
|
|
84
87
|
}
|
|
85
88
|
export interface IImageElement {
|
|
86
89
|
imgDisplay?: ImageDisplay;
|
|
90
|
+
imgFloatPosition?: {
|
|
91
|
+
x: number;
|
|
92
|
+
y: number;
|
|
93
|
+
};
|
|
87
94
|
}
|
|
88
95
|
export interface IBlockElement {
|
|
89
96
|
block?: IBlock;
|
|
@@ -2,6 +2,7 @@ import { EditorZone, ElementType, ListStyle, ListType, PageMode, TitleLevel } fr
|
|
|
2
2
|
import { RowFlex } from '../dataset/enum/Row';
|
|
3
3
|
import { IControl } from './Control';
|
|
4
4
|
import { IEditorResult } from './Editor';
|
|
5
|
+
import { ITextDecoration } from './Text';
|
|
5
6
|
export interface IRangeStyle {
|
|
6
7
|
type: ElementType | null;
|
|
7
8
|
undo: boolean;
|
|
@@ -22,6 +23,7 @@ export interface IRangeStyle {
|
|
|
22
23
|
listType: ListType | null;
|
|
23
24
|
listStyle: ListStyle | null;
|
|
24
25
|
groupIds: string[] | null;
|
|
26
|
+
textDecoration: ITextDecoration | null;
|
|
25
27
|
}
|
|
26
28
|
export declare type IRangeStyleChange = (payload: IRangeStyle) => void;
|
|
27
29
|
export declare type IVisiblePageNoListChange = (payload: number[]) => void;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { IElement } from '..';
|
|
1
|
+
import { IElement, ImageDisplay } from '..';
|
|
2
2
|
import { EditorZone } from '../dataset/enum/Editor';
|
|
3
3
|
import { IElementPosition } from './Element';
|
|
4
4
|
import { IRow } from './Row';
|
|
5
5
|
import { ITd } from './table/Td';
|
|
6
6
|
export interface ICurrentPosition {
|
|
7
7
|
index: number;
|
|
8
|
+
x?: number;
|
|
9
|
+
y?: number;
|
|
8
10
|
isCheckbox?: boolean;
|
|
9
11
|
isControl?: boolean;
|
|
10
12
|
isImage?: boolean;
|
|
@@ -29,6 +31,9 @@ export interface IGetPositionByXYPayload {
|
|
|
29
31
|
elementList?: IElement[];
|
|
30
32
|
positionList?: IElementPosition[];
|
|
31
33
|
}
|
|
34
|
+
export declare type IGetFloatPositionByXYPayload = IGetPositionByXYPayload & {
|
|
35
|
+
imgDisplay: ImageDisplay;
|
|
36
|
+
};
|
|
32
37
|
export interface IPositionContext {
|
|
33
38
|
isTable: boolean;
|
|
34
39
|
isCheckbox?: boolean;
|
|
@@ -53,9 +58,24 @@ export interface IComputePageRowPositionPayload {
|
|
|
53
58
|
startX: number;
|
|
54
59
|
startY: number;
|
|
55
60
|
innerWidth: number;
|
|
61
|
+
isTable?: boolean;
|
|
62
|
+
index?: number;
|
|
63
|
+
tdIndex?: number;
|
|
64
|
+
trIndex?: number;
|
|
65
|
+
tdValueIndex?: number;
|
|
56
66
|
}
|
|
57
67
|
export interface IComputePageRowPositionResult {
|
|
58
68
|
x: number;
|
|
59
69
|
y: number;
|
|
60
70
|
index: number;
|
|
61
71
|
}
|
|
72
|
+
export interface IFloatPosition {
|
|
73
|
+
pageNo: number;
|
|
74
|
+
element: IElement;
|
|
75
|
+
position: IElementPosition;
|
|
76
|
+
isTable?: boolean;
|
|
77
|
+
index?: number;
|
|
78
|
+
tdIndex?: number;
|
|
79
|
+
trIndex?: number;
|
|
80
|
+
tdValueIndex?: number;
|
|
81
|
+
}
|
|
@@ -20,8 +20,8 @@ export interface ITd {
|
|
|
20
20
|
positionList?: IElementPosition[];
|
|
21
21
|
verticalAlign?: VerticalAlign;
|
|
22
22
|
backgroundColor?: string;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
borderTypes?: TdBorder[];
|
|
24
|
+
slashTypes?: TdSlash[];
|
|
25
25
|
mainHeight?: number;
|
|
26
26
|
realHeight?: number;
|
|
27
27
|
realMinHeight?: number;
|
|
@@ -18,3 +18,4 @@ export declare function omitObject<T>(object: T, omitKeys: (keyof T)[]): T;
|
|
|
18
18
|
export declare function convertStringToBase64(input: string): string;
|
|
19
19
|
export declare function findScrollContainer(element: HTMLElement): HTMLElement;
|
|
20
20
|
export declare function isArrayEqual(arr1: unknown[], arr2: unknown[]): boolean;
|
|
21
|
+
export declare function isObjectEqual(obj1: unknown, obj2: unknown): boolean;
|