@hufe921/canvas-editor 0.9.22 → 0.9.23
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 +32 -0
- package/README.md +3 -3
- package/dist/canvas-editor.es.js +401 -127
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +19 -19
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/draw/Draw.d.ts +19 -6
- package/dist/src/editor/core/draw/frame/Header.d.ts +18 -1
- package/dist/src/editor/core/event/CanvasEvent.d.ts +1 -1
- package/dist/src/editor/core/event/handlers/click.d.ts +1 -1
- package/dist/src/editor/core/position/Position.d.ts +8 -4
- package/dist/src/editor/core/range/RangeManager.d.ts +1 -0
- package/dist/src/editor/core/zone/Zone.d.ts +15 -0
- package/dist/src/editor/dataset/constant/Header.d.ts +2 -0
- package/dist/src/editor/dataset/enum/Editor.d.ts +5 -0
- package/dist/src/editor/dataset/enum/Header.d.ts +5 -0
- package/dist/src/editor/index.d.ts +5 -5
- package/dist/src/editor/interface/Draw.d.ts +10 -1
- package/dist/src/editor/interface/Editor.d.ts +7 -2
- package/dist/src/editor/interface/Header.d.ts +3 -4
- package/dist/src/editor/interface/Position.d.ts +2 -0
- package/dist/src/editor/interface/Range.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IDrawOption, IPainterOptions } from '../../interface/Draw';
|
|
2
|
-
import { IEditorOption, IEditorResult } from '../../interface/Editor';
|
|
1
|
+
import { IDrawOption, IDrawRowPayload, IPainterOptions } from '../../interface/Draw';
|
|
2
|
+
import { IEditorData, IEditorOption, IEditorResult } from '../../interface/Editor';
|
|
3
3
|
import { IElement, IElementStyle } from '../../interface/Element';
|
|
4
4
|
import { IRow } from '../../interface/Row';
|
|
5
5
|
import { Cursor } from '../cursor/Cursor';
|
|
@@ -12,6 +12,7 @@ import { Search } from './interactive/Search';
|
|
|
12
12
|
import { ImageParticle } from './particle/ImageParticle';
|
|
13
13
|
import { TableTool } from './particle/table/TableTool';
|
|
14
14
|
import { HyperlinkParticle } from './particle/HyperlinkParticle';
|
|
15
|
+
import { Header } from './frame/Header';
|
|
15
16
|
import { EditorMode, PageMode, PaperDirection } from '../../dataset/enum/Editor';
|
|
16
17
|
import { Control } from './control/Control';
|
|
17
18
|
import { DeepRequired } from '../../interface/Common';
|
|
@@ -21,6 +22,7 @@ import { DateParticle } from './particle/date/DateParticle';
|
|
|
21
22
|
import { IMargin } from '../../interface/Margin';
|
|
22
23
|
import { I18n } from '../i18n/I18n';
|
|
23
24
|
import { ImageObserver } from '../observer/ImageObserver';
|
|
25
|
+
import { Zone } from '../zone/Zone';
|
|
24
26
|
export declare class Draw {
|
|
25
27
|
private container;
|
|
26
28
|
private pageContainer;
|
|
@@ -30,7 +32,10 @@ export declare class Draw {
|
|
|
30
32
|
private mode;
|
|
31
33
|
private options;
|
|
32
34
|
private position;
|
|
35
|
+
private zone;
|
|
36
|
+
private headerElementList;
|
|
33
37
|
private elementList;
|
|
38
|
+
private footerElementList;
|
|
34
39
|
private listener;
|
|
35
40
|
private i18n;
|
|
36
41
|
private canvasEvent;
|
|
@@ -73,7 +78,7 @@ export declare class Draw {
|
|
|
73
78
|
private visiblePageNoList;
|
|
74
79
|
private intersectionPageNo;
|
|
75
80
|
private lazyRenderIntersectionObserver;
|
|
76
|
-
constructor(rootContainer: HTMLElement, options: DeepRequired<IEditorOption>,
|
|
81
|
+
constructor(rootContainer: HTMLElement, options: DeepRequired<IEditorOption>, data: IEditorData, listener: Listener);
|
|
77
82
|
getMode(): EditorMode;
|
|
78
83
|
setMode(payload: EditorMode): void;
|
|
79
84
|
isReadonly(): boolean;
|
|
@@ -81,6 +86,7 @@ export declare class Draw {
|
|
|
81
86
|
getOriginalHeight(): number;
|
|
82
87
|
getWidth(): number;
|
|
83
88
|
getHeight(): number;
|
|
89
|
+
getMainHeight(): number;
|
|
84
90
|
getCanvasWidth(pageNo?: number): number;
|
|
85
91
|
getCanvasHeight(pageNo?: number): number;
|
|
86
92
|
getInnerWidth(): number;
|
|
@@ -110,16 +116,23 @@ export declare class Draw {
|
|
|
110
116
|
getSearch(): Search;
|
|
111
117
|
getHistoryManager(): HistoryManager;
|
|
112
118
|
getPosition(): Position;
|
|
119
|
+
getZone(): Zone;
|
|
113
120
|
getRange(): RangeManager;
|
|
121
|
+
getHeaderElementList(): IElement[];
|
|
122
|
+
getTableElementList(sourceElementList: IElement[]): IElement[];
|
|
114
123
|
getElementList(): IElement[];
|
|
115
|
-
|
|
124
|
+
getMainElementList(): IElement[];
|
|
116
125
|
getOriginalElementList(): IElement[];
|
|
126
|
+
getOriginalMainElementList(): IElement[];
|
|
127
|
+
getFooterElementList(): IElement[];
|
|
128
|
+
insertElementList(payload: IElement[]): void;
|
|
117
129
|
getCanvasEvent(): CanvasEvent;
|
|
118
130
|
getListener(): Listener;
|
|
119
131
|
getCursor(): Cursor;
|
|
120
132
|
getPreviewer(): Previewer;
|
|
121
133
|
getImageParticle(): ImageParticle;
|
|
122
134
|
getTableTool(): TableTool;
|
|
135
|
+
getHeader(): Header;
|
|
123
136
|
getHyperlinkParticle(): HyperlinkParticle;
|
|
124
137
|
getDateParticle(): DateParticle;
|
|
125
138
|
getControl(): Control;
|
|
@@ -145,10 +158,10 @@ export declare class Draw {
|
|
|
145
158
|
private _createPage;
|
|
146
159
|
private _initPageContext;
|
|
147
160
|
private _getFont;
|
|
148
|
-
|
|
161
|
+
computeRowList(innerWidth: number, elementList: IElement[]): IRow[];
|
|
149
162
|
private _computePageList;
|
|
150
163
|
private _drawRichText;
|
|
151
|
-
|
|
164
|
+
drawRow(ctx: CanvasRenderingContext2D, payload: IDrawRowPayload): void;
|
|
152
165
|
private _clearPage;
|
|
153
166
|
private _drawPage;
|
|
154
167
|
private _lazyRender;
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
+
import { IElement, IElementPosition } from '../../../interface/Element';
|
|
1
2
|
import { Draw } from '../Draw';
|
|
2
3
|
export declare class Header {
|
|
3
4
|
private draw;
|
|
5
|
+
private position;
|
|
4
6
|
private options;
|
|
7
|
+
private elementList;
|
|
8
|
+
private rowList;
|
|
9
|
+
private positionList;
|
|
5
10
|
constructor(draw: Draw);
|
|
6
|
-
|
|
11
|
+
setElementList(elementList: IElement[]): void;
|
|
12
|
+
getElementList(): IElement[];
|
|
13
|
+
getPositionList(): IElementPosition[];
|
|
14
|
+
compute(): void;
|
|
15
|
+
private _recovery;
|
|
16
|
+
private _computeRowList;
|
|
17
|
+
private _computePositionList;
|
|
18
|
+
getHeaderTop(): number;
|
|
19
|
+
getMaxHeight(): number;
|
|
20
|
+
getHeight(): number;
|
|
21
|
+
getRowHeight(): number;
|
|
22
|
+
getExtraHeight(): number;
|
|
23
|
+
render(ctx: CanvasRenderingContext2D, pageNo: number): void;
|
|
7
24
|
}
|
|
@@ -36,7 +36,7 @@ export declare class CanvasEvent {
|
|
|
36
36
|
mouseup(evt: MouseEvent): void;
|
|
37
37
|
mouseleave(evt: MouseEvent): void;
|
|
38
38
|
keydown(evt: KeyboardEvent): void;
|
|
39
|
-
dblclick(): void;
|
|
39
|
+
dblclick(evt: MouseEvent): void;
|
|
40
40
|
threeClick(): void;
|
|
41
41
|
input(data: string): void;
|
|
42
42
|
cut(): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CanvasEvent } from '../CanvasEvent';
|
|
2
|
-
declare function dblclick(host: CanvasEvent): void;
|
|
2
|
+
declare function dblclick(host: CanvasEvent, evt: MouseEvent): void;
|
|
3
3
|
declare function threeClick(host: CanvasEvent): void;
|
|
4
4
|
declare const _default: {
|
|
5
5
|
dblclick: typeof dblclick;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IComputePageRowPositionPayload, IComputePageRowPositionResult } from '../../interface/Position';
|
|
2
|
+
import { IElement, IElementPosition } from '../../interface/Element';
|
|
2
3
|
import { ICurrentPosition, IGetPositionByXYPayload, IPositionContext } from '../../interface/Position';
|
|
3
4
|
import { Draw } from '../draw/Draw';
|
|
4
5
|
export declare class Position {
|
|
@@ -8,15 +9,18 @@ export declare class Position {
|
|
|
8
9
|
private draw;
|
|
9
10
|
private options;
|
|
10
11
|
constructor(draw: Draw);
|
|
11
|
-
|
|
12
|
+
getTablePositionList(sourceElementList: IElement[]): IElementPosition[];
|
|
12
13
|
getPositionList(): IElementPosition[];
|
|
14
|
+
getMainPositionList(): IElementPosition[];
|
|
15
|
+
getOriginalPositionList(): IElementPosition[];
|
|
16
|
+
getOriginalMainPositionList(): IElementPosition[];
|
|
13
17
|
setPositionList(payload: IElementPosition[]): void;
|
|
14
|
-
|
|
18
|
+
computePageRowPosition(payload: IComputePageRowPositionPayload): IComputePageRowPositionResult;
|
|
15
19
|
computePositionList(): void;
|
|
16
20
|
setCursorPosition(position: IElementPosition | null): void;
|
|
17
21
|
getCursorPosition(): IElementPosition | null;
|
|
18
22
|
getPositionContext(): IPositionContext;
|
|
19
23
|
setPositionContext(payload: IPositionContext): void;
|
|
20
24
|
getPositionByXY(payload: IGetPositionByXYPayload): ICurrentPosition;
|
|
21
|
-
adjustPositionContext(payload:
|
|
25
|
+
adjustPositionContext(payload: IGetPositionByXYPayload): ICurrentPosition | null;
|
|
22
26
|
}
|
|
@@ -10,6 +10,7 @@ export declare class RangeManager {
|
|
|
10
10
|
private historyManager;
|
|
11
11
|
constructor(draw: Draw);
|
|
12
12
|
getRange(): IRange;
|
|
13
|
+
clearRange(): void;
|
|
13
14
|
getSelection(): IElement[] | null;
|
|
14
15
|
getRangeRow(): RangeRowMap | null;
|
|
15
16
|
getIsPointInRange(x: number, y: number): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EditorZone } from '../../dataset/enum/Editor';
|
|
2
|
+
import { Draw } from '../draw/Draw';
|
|
3
|
+
export declare class Zone {
|
|
4
|
+
private draw;
|
|
5
|
+
private container;
|
|
6
|
+
private currentZone;
|
|
7
|
+
private headerIndicatorContainer;
|
|
8
|
+
constructor(draw: Draw);
|
|
9
|
+
isHeaderActive(): boolean;
|
|
10
|
+
isMainActive(): boolean;
|
|
11
|
+
getZone(): EditorZone;
|
|
12
|
+
setZone(payload: EditorZone): void;
|
|
13
|
+
private _drawHeaderZoneIndicator;
|
|
14
|
+
private _clearHeaderZoneIndicator;
|
|
15
|
+
}
|
|
@@ -15,6 +15,11 @@ export declare enum EditorMode {
|
|
|
15
15
|
CLEAN = "clean",
|
|
16
16
|
READONLY = "readonly"
|
|
17
17
|
}
|
|
18
|
+
export declare enum EditorZone {
|
|
19
|
+
HEADER = "header",
|
|
20
|
+
MAIN = "main",
|
|
21
|
+
FOOTER = "footer"
|
|
22
|
+
}
|
|
18
23
|
export declare enum PageMode {
|
|
19
24
|
PAGING = "paging",
|
|
20
25
|
CONTINUITY = "continuity"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './assets/css/index.css';
|
|
2
|
-
import { IEditorOption, IEditorResult } from './interface/Editor';
|
|
2
|
+
import { IEditorData, IEditorOption, IEditorResult } from './interface/Editor';
|
|
3
3
|
import { IElement } from './interface/Element';
|
|
4
4
|
import { Command } from './core/command/Command';
|
|
5
5
|
import { Listener } from './core/listener/Listener';
|
|
@@ -7,7 +7,7 @@ import { RowFlex } from './dataset/enum/Row';
|
|
|
7
7
|
import { ElementType } from './dataset/enum/Element';
|
|
8
8
|
import { Register } from './core/register/Register';
|
|
9
9
|
import { IContextMenuContext, IRegisterContextMenu } from './interface/contextmenu/ContextMenu';
|
|
10
|
-
import { EditorComponent, EditorMode, PageMode, PaperDirection } from './dataset/enum/Editor';
|
|
10
|
+
import { EditorComponent, EditorZone, EditorMode, PageMode, PaperDirection } from './dataset/enum/Editor';
|
|
11
11
|
import { EDITOR_COMPONENT } from './dataset/constant/Editor';
|
|
12
12
|
import { IWatermark } from './interface/Watermark';
|
|
13
13
|
import { ControlType, ImageDisplay } from './dataset/enum/Control';
|
|
@@ -21,7 +21,7 @@ export default class Editor {
|
|
|
21
21
|
listener: Listener;
|
|
22
22
|
register: Register;
|
|
23
23
|
destroy: Function;
|
|
24
|
-
constructor(container: HTMLDivElement,
|
|
24
|
+
constructor(container: HTMLDivElement, data: IEditorData | IElement[], options?: IEditorOption);
|
|
25
25
|
}
|
|
26
|
-
export { Editor, RowFlex, EditorMode, ElementType, ControlType, EditorComponent, EDITOR_COMPONENT, PageMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection };
|
|
27
|
-
export type { IElement, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang };
|
|
26
|
+
export { Editor, RowFlex, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, EDITOR_COMPONENT, PageMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection };
|
|
27
|
+
export type { IElement, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EditorZone } from '../dataset/enum/Editor';
|
|
2
|
+
import { IElement, IElementPosition } from './Element';
|
|
2
3
|
import { IRow } from './Row';
|
|
3
4
|
export interface IDrawOption {
|
|
4
5
|
curIndex?: number;
|
|
@@ -13,11 +14,19 @@ export interface IDrawImagePayload {
|
|
|
13
14
|
value: string;
|
|
14
15
|
}
|
|
15
16
|
export interface IDrawRowPayload {
|
|
17
|
+
elementList: IElement[];
|
|
16
18
|
positionList: IElementPosition[];
|
|
17
19
|
rowList: IRow[];
|
|
18
20
|
pageNo: number;
|
|
19
21
|
startIndex: number;
|
|
20
22
|
innerWidth: number;
|
|
23
|
+
zone: EditorZone;
|
|
24
|
+
}
|
|
25
|
+
export interface IDrawPagePayload {
|
|
26
|
+
elementList: IElement[];
|
|
27
|
+
positionList: IElementPosition[];
|
|
28
|
+
rowList: IRow[];
|
|
29
|
+
pageNo: number;
|
|
21
30
|
}
|
|
22
31
|
export interface IPainterOptions {
|
|
23
32
|
isDblclick: boolean;
|
|
@@ -6,6 +6,11 @@ import { ICursorOption } from './Cursor';
|
|
|
6
6
|
import { IHeader } from './Header';
|
|
7
7
|
import { IMargin } from './Margin';
|
|
8
8
|
import { IWatermark } from './Watermark';
|
|
9
|
+
export interface IEditorData {
|
|
10
|
+
header?: IElement[];
|
|
11
|
+
main: IElement[];
|
|
12
|
+
footer?: IElement[];
|
|
13
|
+
}
|
|
9
14
|
export interface IEditorOption {
|
|
10
15
|
mode?: EditorMode;
|
|
11
16
|
defaultType?: string;
|
|
@@ -41,6 +46,7 @@ export interface IEditorOption {
|
|
|
41
46
|
defaultHyperlinkColor?: string;
|
|
42
47
|
headerTop?: number;
|
|
43
48
|
paperDirection?: PaperDirection;
|
|
49
|
+
inactiveAlpha?: number;
|
|
44
50
|
header?: IHeader;
|
|
45
51
|
watermark?: IWatermark;
|
|
46
52
|
control?: IControlOption;
|
|
@@ -52,7 +58,6 @@ export interface IEditorResult {
|
|
|
52
58
|
width: number;
|
|
53
59
|
height: number;
|
|
54
60
|
margins: IMargin;
|
|
55
|
-
header?: IHeader;
|
|
56
61
|
watermark?: IWatermark;
|
|
57
|
-
data:
|
|
62
|
+
data: IEditorData;
|
|
58
63
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IElement } from '..';
|
|
2
|
+
import { EditorZone } from '../dataset/enum/Editor';
|
|
2
3
|
import { IElementPosition } from './Element';
|
|
3
4
|
import { IRow } from './Row';
|
|
4
5
|
import { ITd } from './table/Td';
|
|
@@ -15,6 +16,7 @@ export interface ICurrentPosition {
|
|
|
15
16
|
tdId?: string;
|
|
16
17
|
trId?: string;
|
|
17
18
|
tableId?: string;
|
|
19
|
+
zone?: EditorZone;
|
|
18
20
|
}
|
|
19
21
|
export interface IGetPositionByXYPayload {
|
|
20
22
|
x: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EditorZone } from '../dataset/enum/Editor';
|
|
1
2
|
export interface IRange {
|
|
2
3
|
startIndex: number;
|
|
3
4
|
endIndex: number;
|
|
@@ -7,5 +8,6 @@ export interface IRange {
|
|
|
7
8
|
endTdIndex?: number;
|
|
8
9
|
startTrIndex?: number;
|
|
9
10
|
endTrIndex?: number;
|
|
11
|
+
zone?: EditorZone;
|
|
10
12
|
}
|
|
11
13
|
export declare type RangeRowMap = Map<number, Set<number>>;
|