@hufe921/canvas-editor 1.0.0 → 1.0.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.
- package/CHANGELOG.md +26 -0
- package/dist/assets/catalog-B-cbxN0s.js.map +1 -1
- package/dist/assets/{value-B0aX9J3d.js.map → value-CLcLo2uw.js.map} +1 -1
- package/dist/assets/wordCount-BWZRHbSB.js.map +1 -1
- package/dist/canvas-editor.js +2536 -2253
- package/dist/canvas-editor.js.map +1 -1
- package/dist/canvas-editor.umd.cjs +50 -38
- package/dist/canvas-editor.umd.cjs.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +1 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +1 -0
- package/dist/src/editor/core/draw/Draw.d.ts +28 -9
- package/dist/src/editor/core/draw/column/ColumnManager.d.ts +4 -3
- package/dist/src/editor/core/draw/control/Control.d.ts +1 -0
- package/dist/src/editor/core/draw/frame/Footer.d.ts +9 -7
- package/dist/src/editor/core/draw/frame/Header.d.ts +9 -7
- package/dist/src/editor/core/draw/frame/PageBorder.d.ts +1 -1
- package/dist/src/editor/core/draw/frame/Watermark.d.ts +1 -1
- package/dist/src/editor/core/draw/particle/HintParticle.d.ts +23 -0
- package/dist/src/editor/core/event/GlobalEvent.d.ts +1 -0
- package/dist/src/editor/dataset/constant/Element.d.ts +1 -0
- package/dist/src/editor/dataset/constant/Hint.d.ts +2 -0
- package/dist/src/editor/interface/Editor.d.ts +2 -0
- package/dist/src/editor/interface/Element.d.ts +6 -1
- package/dist/src/editor/interface/Hint.d.ts +7 -0
- package/dist/src/editor/interface/Row.d.ts +2 -0
- package/dist/src/editor/interface/table/Td.d.ts +1 -0
- package/dist/src/editor/utils/print.d.ts +1 -0
- package/package.json +9 -9
|
@@ -81,6 +81,7 @@ export declare class Command {
|
|
|
81
81
|
executePageScaleAdd: CommandAdapt['pageScaleAdd'];
|
|
82
82
|
executePaperSize: CommandAdapt['paperSize'];
|
|
83
83
|
executePaperDirection: CommandAdapt['paperDirection'];
|
|
84
|
+
executePageDirection: CommandAdapt['pageDirection'];
|
|
84
85
|
executeSetPaperMargin: CommandAdapt['setPaperMargin'];
|
|
85
86
|
executeSetMainBadge: CommandAdapt['setMainBadge'];
|
|
86
87
|
executeSetAreaBadge: CommandAdapt['setAreaBadge'];
|
|
@@ -146,6 +146,7 @@ export declare class CommandAdapt {
|
|
|
146
146
|
pageScaleAdd(): void;
|
|
147
147
|
paperSize(width: number, height: number): void;
|
|
148
148
|
paperDirection(payload: PaperDirection): void;
|
|
149
|
+
pageDirection(payload: PaperDirection | null): void;
|
|
149
150
|
getPaperMargin(): number[];
|
|
150
151
|
setPaperMargin(payload: IMargin): void;
|
|
151
152
|
setMainBadge(payload: IBadge | null): void;
|
|
@@ -21,6 +21,7 @@ import { TableParticle } from './particle/table/TableParticle';
|
|
|
21
21
|
import { TableTool } from './particle/table/TableTool';
|
|
22
22
|
import { Ruler } from './ruler/Ruler';
|
|
23
23
|
import { HyperlinkParticle } from './particle/HyperlinkParticle';
|
|
24
|
+
import { HintParticle } from './particle/HintParticle';
|
|
24
25
|
import { TraceParticle } from './particle/TraceParticle';
|
|
25
26
|
import { Header } from './frame/Header';
|
|
26
27
|
import { SuperscriptParticle } from './particle/SuperscriptParticle';
|
|
@@ -101,6 +102,7 @@ export declare class Draw {
|
|
|
101
102
|
private header;
|
|
102
103
|
private footer;
|
|
103
104
|
private hyperlinkParticle;
|
|
105
|
+
private hintParticle;
|
|
104
106
|
private traceParticle;
|
|
105
107
|
private labelParticle;
|
|
106
108
|
private dateParticle;
|
|
@@ -128,6 +130,7 @@ export declare class Draw {
|
|
|
128
130
|
private WORD_LIKE_REG;
|
|
129
131
|
private rowList;
|
|
130
132
|
private pageRowList;
|
|
133
|
+
private pageDirectionList;
|
|
131
134
|
private painterStyle;
|
|
132
135
|
private painterOptions;
|
|
133
136
|
private visiblePageNoList;
|
|
@@ -153,21 +156,34 @@ export declare class Draw {
|
|
|
153
156
|
setTraceEnabled(enabled: boolean): void;
|
|
154
157
|
setRulerEnabled(enabled: boolean): void;
|
|
155
158
|
deleteElementList(elementList: IElement[], index: number, count?: number, options?: IMarkElementListDeletedOption): IElement[];
|
|
156
|
-
getOriginalWidth(): number;
|
|
157
|
-
getOriginalHeight(): number;
|
|
158
|
-
getWidth(): number;
|
|
159
|
-
getHeight(): number;
|
|
159
|
+
getOriginalWidth(direction?: PaperDirection): number;
|
|
160
|
+
getOriginalHeight(direction?: PaperDirection): number;
|
|
161
|
+
getWidth(direction?: PaperDirection): number;
|
|
162
|
+
getHeight(direction?: PaperDirection): number;
|
|
160
163
|
getMainHeight(): number;
|
|
161
|
-
getMainOuterHeight(pageNo?: number): number;
|
|
164
|
+
getMainOuterHeight(pageNo?: number, direction?: PaperDirection): number;
|
|
162
165
|
getCanvasWidth(pageNo?: number): number;
|
|
163
166
|
getCanvasHeight(pageNo?: number): number;
|
|
164
|
-
getInnerWidth(): number;
|
|
165
|
-
getColumnLayout(): IColumnLayout | null;
|
|
167
|
+
getInnerWidth(direction?: PaperDirection): number;
|
|
168
|
+
getColumnLayout(direction?: PaperDirection): IColumnLayout | null;
|
|
166
169
|
setColumnConfig(config: IColumnOption | null): void;
|
|
167
170
|
getOriginalInnerWidth(): number;
|
|
168
171
|
getContextInnerWidth(): number;
|
|
169
|
-
getMargins(): IMargin;
|
|
170
|
-
getOriginalMargins(): number[];
|
|
172
|
+
getMargins(direction?: PaperDirection): IMargin;
|
|
173
|
+
getOriginalMargins(direction?: PaperDirection): number[];
|
|
174
|
+
getPageDirection(pageNo: number): PaperDirection;
|
|
175
|
+
getPageDirectionList(): PaperDirection[];
|
|
176
|
+
getPageSize(pageNo: number): {
|
|
177
|
+
width: number;
|
|
178
|
+
height: number;
|
|
179
|
+
margins: IMargin;
|
|
180
|
+
innerWidth: number;
|
|
181
|
+
};
|
|
182
|
+
getPageOffset(pageNo: number, isOriginal?: boolean): {
|
|
183
|
+
x: number;
|
|
184
|
+
y: number;
|
|
185
|
+
};
|
|
186
|
+
private _getPageMaxWidth;
|
|
171
187
|
getPageGap(): number;
|
|
172
188
|
getOriginalPageGap(): number;
|
|
173
189
|
getPageNumberBottom(): number;
|
|
@@ -236,6 +252,7 @@ export declare class Draw {
|
|
|
236
252
|
getHeader(): Header;
|
|
237
253
|
getFooter(): Footer;
|
|
238
254
|
getHyperlinkParticle(): HyperlinkParticle;
|
|
255
|
+
getHintParticle(): HintParticle;
|
|
239
256
|
getTraceParticle(): TraceParticle;
|
|
240
257
|
getDateParticle(): DateParticle;
|
|
241
258
|
getListParticle(): ListParticle;
|
|
@@ -263,6 +280,7 @@ export declare class Draw {
|
|
|
263
280
|
setPageDevicePixel(): void;
|
|
264
281
|
setPaperSize(width: number, height: number): void;
|
|
265
282
|
setPaperDirection(payload: PaperDirection): void;
|
|
283
|
+
setPageDirection(payload: PaperDirection | null): void;
|
|
266
284
|
setPaperMargin(payload: IMargin): void;
|
|
267
285
|
getOriginValue(options?: IGetOriginValueOption): Required<IEditorData>;
|
|
268
286
|
getValue(options?: IGetValueOption): IEditorResult;
|
|
@@ -272,6 +290,7 @@ export declare class Draw {
|
|
|
272
290
|
private _formatContainer;
|
|
273
291
|
private _createPageContainer;
|
|
274
292
|
private _createPage;
|
|
293
|
+
private _updatePageSizes;
|
|
275
294
|
private _initPageContext;
|
|
276
295
|
getElementFont(el: IElement, scale?: number): string;
|
|
277
296
|
getElementSize(el: IElement): number;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { IColumnLayout, IColumnOption } from '../../../interface/Column';
|
|
2
|
+
import { PaperDirection } from '../../../dataset/enum/Editor';
|
|
2
3
|
import { Draw } from '../Draw';
|
|
3
4
|
export declare class ColumnManager {
|
|
4
5
|
private draw;
|
|
5
6
|
private options;
|
|
6
|
-
private
|
|
7
|
+
private layoutMap;
|
|
7
8
|
constructor(draw: Draw);
|
|
8
9
|
computeLayout(innerWidth: number, config: IColumnOption | undefined): IColumnLayout | null;
|
|
9
10
|
compute(): void;
|
|
10
|
-
getLayout(): IColumnLayout | null;
|
|
11
|
+
getLayout(direction?: PaperDirection): IColumnLayout | null;
|
|
11
12
|
setConfig(config: IColumnOption | null | undefined): void;
|
|
12
|
-
getOffset(columnIndex: number | undefined): number;
|
|
13
|
+
getOffset(columnIndex: number | undefined, direction?: PaperDirection): number;
|
|
13
14
|
drawSeparator(ctx: CanvasRenderingContext2D, pageNo: number): void;
|
|
14
15
|
}
|
|
@@ -37,6 +37,7 @@ export declare class Control {
|
|
|
37
37
|
getElementList(): IElement[];
|
|
38
38
|
getPosition(): IElementPosition | null;
|
|
39
39
|
getPreY(): number;
|
|
40
|
+
getPreX(): number;
|
|
40
41
|
getRange(): IRange;
|
|
41
42
|
getValueRange(context?: IControlContext): IRange | null;
|
|
42
43
|
shrinkBoundary(context?: IControlContext): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PaperDirection } from '../../../dataset/enum/Editor';
|
|
1
2
|
import { IElement, IElementPosition } from '../../../interface/Element';
|
|
2
3
|
import { IRow } from '../../../interface/Row';
|
|
3
4
|
import { Draw } from '../Draw';
|
|
@@ -7,22 +8,23 @@ export declare class Footer {
|
|
|
7
8
|
private zone;
|
|
8
9
|
private options;
|
|
9
10
|
private elementList;
|
|
10
|
-
private
|
|
11
|
-
private positionList;
|
|
11
|
+
private layoutMap;
|
|
12
12
|
constructor(draw: Draw, data?: IElement[]);
|
|
13
13
|
getRowList(): IRow[];
|
|
14
14
|
setElementList(elementList: IElement[]): void;
|
|
15
15
|
getElementList(): IElement[];
|
|
16
|
-
getPositionList(): IElementPosition[];
|
|
16
|
+
getPositionList(direction?: PaperDirection): IElementPosition[];
|
|
17
17
|
compute(): void;
|
|
18
18
|
recovery(): void;
|
|
19
|
+
private _getLayoutByDirection;
|
|
19
20
|
private _computeRowList;
|
|
20
21
|
private _computePositionList;
|
|
21
22
|
getFooterBottom(pageNo?: number): number;
|
|
22
|
-
getMaxHeight(): number;
|
|
23
|
-
getHeight(pageNo?: number): number;
|
|
24
|
-
getRowHeight(): number;
|
|
25
|
-
getExtraHeight(pageNo?: number): number;
|
|
23
|
+
getMaxHeight(direction?: PaperDirection): number;
|
|
24
|
+
getHeight(pageNo?: number, direction?: PaperDirection): number;
|
|
25
|
+
getRowHeight(direction?: PaperDirection): number;
|
|
26
|
+
getExtraHeight(pageNo?: number, direction?: PaperDirection): number;
|
|
27
|
+
private _resolveDirection;
|
|
26
28
|
isDisabled(pageNo?: number): boolean;
|
|
27
29
|
render(ctx: CanvasRenderingContext2D, pageNo: number): void;
|
|
28
30
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PaperDirection } from '../../../dataset/enum/Editor';
|
|
1
2
|
import { IElement, IElementPosition } from '../../../interface/Element';
|
|
2
3
|
import { IRow } from '../../../interface/Row';
|
|
3
4
|
import { Draw } from '../Draw';
|
|
@@ -7,22 +8,23 @@ export declare class Header {
|
|
|
7
8
|
private zone;
|
|
8
9
|
private options;
|
|
9
10
|
private elementList;
|
|
10
|
-
private
|
|
11
|
-
private positionList;
|
|
11
|
+
private layoutMap;
|
|
12
12
|
constructor(draw: Draw, data?: IElement[]);
|
|
13
13
|
getRowList(): IRow[];
|
|
14
14
|
setElementList(elementList: IElement[]): void;
|
|
15
15
|
getElementList(): IElement[];
|
|
16
|
-
getPositionList(): IElementPosition[];
|
|
16
|
+
getPositionList(direction?: PaperDirection): IElementPosition[];
|
|
17
17
|
compute(): void;
|
|
18
18
|
recovery(): void;
|
|
19
|
+
private _getLayoutByDirection;
|
|
19
20
|
private _computeRowList;
|
|
20
21
|
private _computePositionList;
|
|
21
22
|
getHeaderTop(pageNo?: number): number;
|
|
22
|
-
getMaxHeight(): number;
|
|
23
|
-
getHeight(pageNo?: number): number;
|
|
24
|
-
getRowHeight(): number;
|
|
25
|
-
getExtraHeight(pageNo?: number): number;
|
|
23
|
+
getMaxHeight(direction?: PaperDirection): number;
|
|
24
|
+
getHeight(pageNo?: number, direction?: PaperDirection): number;
|
|
25
|
+
getRowHeight(direction?: PaperDirection): number;
|
|
26
|
+
getExtraHeight(pageNo?: number, direction?: PaperDirection): number;
|
|
27
|
+
private _resolveDirection;
|
|
26
28
|
isDisabled(pageNo?: number): boolean;
|
|
27
29
|
render(ctx: CanvasRenderingContext2D, pageNo: number): void;
|
|
28
30
|
}
|
|
@@ -5,6 +5,6 @@ export declare class Watermark {
|
|
|
5
5
|
private imageCache;
|
|
6
6
|
constructor(draw: Draw);
|
|
7
7
|
renderText(ctx: CanvasRenderingContext2D, pageNo: number): void;
|
|
8
|
-
renderImage(ctx: CanvasRenderingContext2D): void;
|
|
8
|
+
renderImage(ctx: CanvasRenderingContext2D, pageNo: number): void;
|
|
9
9
|
render(ctx: CanvasRenderingContext2D, pageNo: number): void;
|
|
10
10
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IElementPosition } from '../../../interface/Element';
|
|
2
|
+
import { ITd } from '../../../interface/table/Td';
|
|
3
|
+
import { Draw } from '../Draw';
|
|
4
|
+
interface IHintHit {
|
|
5
|
+
hint: string;
|
|
6
|
+
position?: IElementPosition;
|
|
7
|
+
td?: ITd;
|
|
8
|
+
}
|
|
9
|
+
export declare class HintParticle {
|
|
10
|
+
private draw;
|
|
11
|
+
private options;
|
|
12
|
+
private container;
|
|
13
|
+
private hintPopupContainer;
|
|
14
|
+
private hintDom;
|
|
15
|
+
private lastHoverKey;
|
|
16
|
+
constructor(draw: Draw);
|
|
17
|
+
private _createHintPopupDom;
|
|
18
|
+
private _getElementHint;
|
|
19
|
+
drawHintPopup(hit: IHintHit, pageNo: number): void;
|
|
20
|
+
clearHintPopup(): void;
|
|
21
|
+
handleMouseMove(evt: MouseEvent): void;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -5,6 +5,7 @@ import { IControlStyle } from '../../interface/Control';
|
|
|
5
5
|
export declare const EDITOR_ELEMENT_STYLE_ATTR: Array<keyof IElement>;
|
|
6
6
|
export declare const EDITOR_ROW_ATTR: Array<keyof IElement>;
|
|
7
7
|
export declare const EDITOR_TRACE_ATTR: Array<keyof IElement>;
|
|
8
|
+
export declare const EDITOR_HINT_ATTR: Array<keyof IElement>;
|
|
8
9
|
export declare const EDITOR_ELEMENT_PARAGRAPH_STYLE_ATTR: Array<keyof IElement>;
|
|
9
10
|
export declare const EDITOR_ELEMENT_COPY_ATTR: Array<keyof IElement>;
|
|
10
11
|
export declare const EDITOR_ELEMENT_ZIP_ATTR: Array<keyof IElement>;
|
|
@@ -32,6 +32,7 @@ import { IMagnifierOption } from './Magnifier';
|
|
|
32
32
|
import { IAccessibilityOption } from './Accessibility';
|
|
33
33
|
import { ITraceOption } from './Trace';
|
|
34
34
|
import { IRulerOption } from './Ruler';
|
|
35
|
+
import { IHintOption } from './Hint';
|
|
35
36
|
export interface IEditorData {
|
|
36
37
|
header?: IElement[];
|
|
37
38
|
main: IElement[];
|
|
@@ -114,6 +115,7 @@ export interface IEditorOption {
|
|
|
114
115
|
column?: IColumnOption;
|
|
115
116
|
trace?: ITraceOption;
|
|
116
117
|
ruler?: IRulerOption;
|
|
118
|
+
hint?: IHintOption;
|
|
117
119
|
}
|
|
118
120
|
export interface IEditorResult {
|
|
119
121
|
version: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ImageDisplay } from '../dataset/enum/Common';
|
|
2
2
|
import { ControlComponent } from '../dataset/enum/Control';
|
|
3
|
+
import { PaperDirection } from '../dataset/enum/Editor';
|
|
3
4
|
import { ElementType } from '../dataset/enum/Element';
|
|
4
5
|
import { TraceType } from '../dataset/enum/Trace';
|
|
5
6
|
import { ListStyle, ListType } from '../dataset/enum/List';
|
|
@@ -23,6 +24,7 @@ export interface IElementBasic {
|
|
|
23
24
|
value: string;
|
|
24
25
|
extension?: unknown;
|
|
25
26
|
externalId?: string;
|
|
27
|
+
hint?: string;
|
|
26
28
|
}
|
|
27
29
|
export interface IElementStyle {
|
|
28
30
|
font?: string;
|
|
@@ -175,7 +177,10 @@ export interface ILabelElement {
|
|
|
175
177
|
padding?: IPadding;
|
|
176
178
|
};
|
|
177
179
|
}
|
|
178
|
-
export
|
|
180
|
+
export interface IPageBreakElement {
|
|
181
|
+
paperDirection?: PaperDirection;
|
|
182
|
+
}
|
|
183
|
+
export type IElement = IElementBasic & IElementStyle & IElementRule & IElementGroup & IElementTrace & ITable & IHyperlinkElement & ISuperscriptSubscript & ISeparator & IControlElement & ICheckboxElement & IRadioElement & ILaTexElement & IDateElement & IImageElement & IBlockElement & ITitleElement & IListElement & IAreaElement & ILabelElement & IPageBreakElement;
|
|
179
184
|
export interface IElementMetrics {
|
|
180
185
|
width: number;
|
|
181
186
|
height: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PaperDirection } from '../dataset/enum/Editor';
|
|
1
2
|
import { RowFlex } from '../dataset/enum/Row';
|
|
2
3
|
import { IElement, IElementMetrics, IElementPosition, ITableRowFragment } from './Element';
|
|
3
4
|
import { ITd } from './table/Td';
|
|
@@ -13,6 +14,7 @@ export interface IRow {
|
|
|
13
14
|
rowFlex?: RowFlex;
|
|
14
15
|
startIndex: number;
|
|
15
16
|
isPageBreak?: boolean;
|
|
17
|
+
paperDirection?: PaperDirection;
|
|
16
18
|
isList?: boolean;
|
|
17
19
|
listIndex?: number;
|
|
18
20
|
offsetX?: number;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@hufe921/canvas-editor",
|
|
3
3
|
"author": "Hufe",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.1",
|
|
6
6
|
"description": "A Canvas/SVG-based rich text editor",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -53,24 +53,24 @@
|
|
|
53
53
|
"@types/jsdom": "^28.0.3",
|
|
54
54
|
"@types/node": "^24.12.4",
|
|
55
55
|
"@types/prismjs": "^1.26.6",
|
|
56
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
57
|
-
"@typescript-eslint/parser": "^8.
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "^8.67.0",
|
|
57
|
+
"@typescript-eslint/parser": "^8.67.0",
|
|
58
58
|
"@vitest/coverage-v8": "^4.1.6",
|
|
59
|
-
"cypress": "^15.
|
|
59
|
+
"cypress": "^15.20.1",
|
|
60
60
|
"cypress-file-upload": "^5.0.8",
|
|
61
|
-
"eslint": "^10.
|
|
62
|
-
"globals": "^17.
|
|
61
|
+
"eslint": "^10.8.1",
|
|
62
|
+
"globals": "^17.10.0",
|
|
63
63
|
"jsdom": "^29.1.1",
|
|
64
64
|
"simple-git-hooks": "^2.13.1",
|
|
65
65
|
"tslib": "^2.8.1",
|
|
66
66
|
"typescript": "^6.0.3",
|
|
67
|
-
"typescript-eslint": "^8.
|
|
68
|
-
"vite": "^8.
|
|
67
|
+
"typescript-eslint": "^8.67.0",
|
|
68
|
+
"vite": "^8.2.1",
|
|
69
69
|
"vite-plugin-css-injected-by-js": "^5.0.1",
|
|
70
70
|
"vitepress": "^1.6.4",
|
|
71
71
|
"vitest": "^4.1.6",
|
|
72
72
|
"vitest-canvas-mock": "^1.1.4",
|
|
73
|
-
"vue": "^3.5.
|
|
73
|
+
"vue": "^3.5.41"
|
|
74
74
|
},
|
|
75
75
|
"simple-git-hooks": {
|
|
76
76
|
"pre-commit": "npm run lint && npm run type:check",
|