@hufe921/canvas-editor 1.0.0 → 1.0.2
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/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 +3116 -2630
- 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 +4 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +6 -1
- package/dist/src/editor/core/draw/Draw.d.ts +31 -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/interactive/Spellcheck.d.ts +20 -0
- 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/dataset/constant/Spellcheck.d.ts +2 -0
- package/dist/src/editor/index.d.ts +2 -2
- package/dist/src/editor/interface/Editor.d.ts +4 -0
- package/dist/src/editor/interface/Element.d.ts +6 -1
- package/dist/src/editor/interface/EventBus.d.ts +4 -1
- package/dist/src/editor/interface/Hint.d.ts +7 -0
- package/dist/src/editor/interface/Listener.d.ts +1 -0
- package/dist/src/editor/interface/Row.d.ts +2 -0
- package/dist/src/editor/interface/Spellcheck.d.ts +27 -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 +12 -12
|
@@ -64,6 +64,7 @@ export declare class Command {
|
|
|
64
64
|
executeAddWatermark: CommandAdapt['addWatermark'];
|
|
65
65
|
executeDeleteWatermark: CommandAdapt['deleteWatermark'];
|
|
66
66
|
executeSearch: CommandAdapt['search'];
|
|
67
|
+
executeSetSpellcheckRangeList: CommandAdapt['setSpellcheckRangeList'];
|
|
67
68
|
executeSearchNavigatePre: CommandAdapt['searchNavigatePre'];
|
|
68
69
|
executeSearchNavigateNext: CommandAdapt['searchNavigateNext'];
|
|
69
70
|
executeReplace: CommandAdapt['replace'];
|
|
@@ -81,6 +82,7 @@ export declare class Command {
|
|
|
81
82
|
executePageScaleAdd: CommandAdapt['pageScaleAdd'];
|
|
82
83
|
executePaperSize: CommandAdapt['paperSize'];
|
|
83
84
|
executePaperDirection: CommandAdapt['paperDirection'];
|
|
85
|
+
executePageDirection: CommandAdapt['pageDirection'];
|
|
84
86
|
executeSetPaperMargin: CommandAdapt['setPaperMargin'];
|
|
85
87
|
executeSetMainBadge: CommandAdapt['setMainBadge'];
|
|
86
88
|
executeSetAreaBadge: CommandAdapt['setAreaBadge'];
|
|
@@ -132,6 +134,7 @@ export declare class Command {
|
|
|
132
134
|
getAreaValue: CommandAdapt['getAreaValue'];
|
|
133
135
|
getHTML: CommandAdapt['getHTML'];
|
|
134
136
|
getText: CommandAdapt['getText'];
|
|
137
|
+
getSpellcheckWordList: CommandAdapt['getSpellcheckWordList'];
|
|
135
138
|
getWordCount: CommandAdapt['getWordCount'];
|
|
136
139
|
getCursorPosition: CommandAdapt['getCursorPosition'];
|
|
137
140
|
getRemainingContentHeight: CommandAdapt['getRemainingContentHeight'];
|
|
@@ -147,6 +150,7 @@ export declare class Command {
|
|
|
147
150
|
getSearchNavigateInfo: CommandAdapt['getSearchNavigateInfo'];
|
|
148
151
|
getLocale: CommandAdapt['getLocale'];
|
|
149
152
|
getGroupIds: CommandAdapt['getGroupIds'];
|
|
153
|
+
getGroupRectList: CommandAdapt['getGroupRectList'];
|
|
150
154
|
getControlValue: CommandAdapt['getControlValue'];
|
|
151
155
|
getControlList: CommandAdapt['getControlList'];
|
|
152
156
|
getContainer: CommandAdapt['getContainer'];
|
|
@@ -16,8 +16,9 @@ import { IColumnOption } from '../../interface/Column';
|
|
|
16
16
|
import { IDeleteElementByIdOption, IElement, IElementPosition, IGetElementByIdOption, IImageCaption, IImageCrop, IInsertElementListOption, IUpdateElementByIdOption } from '../../interface/Element';
|
|
17
17
|
import { ICopyOption, IPasteOption, IPositionContextByEventOption, IPositionContextByEventResult } from '../../interface/Event';
|
|
18
18
|
import { IMargin } from '../../interface/Margin';
|
|
19
|
-
import { IRange, RangeContext } from '../../interface/Range';
|
|
19
|
+
import { IRange, RangeContext, RangeRect } from '../../interface/Range';
|
|
20
20
|
import { IReplaceOption, ISearchOption, ISearchResultContext } from '../../interface/Search';
|
|
21
|
+
import type { ISpellcheckRange } from '../../interface/Spellcheck';
|
|
21
22
|
import { ITextDecoration } from '../../interface/Text';
|
|
22
23
|
import { IGetTitleValueOption, IGetTitleValueResult } from '../../interface/Title';
|
|
23
24
|
import { IWatermark } from '../../interface/Watermark';
|
|
@@ -109,6 +110,8 @@ export declare class CommandAdapt {
|
|
|
109
110
|
deleteWatermark(): void;
|
|
110
111
|
image(payload: IDrawImagePayload): string | null;
|
|
111
112
|
search(payload: string | null, options?: ISearchOption): void;
|
|
113
|
+
setSpellcheckRangeList(payload: ISpellcheckRange[] | null): void;
|
|
114
|
+
getSpellcheckWordList(): import("../../interface/Spellcheck").ISpellcheckWord[];
|
|
112
115
|
searchNavigatePre(): void;
|
|
113
116
|
searchNavigateNext(): void;
|
|
114
117
|
getSearchNavigateInfo(): null | INavigateInfo;
|
|
@@ -146,6 +149,7 @@ export declare class CommandAdapt {
|
|
|
146
149
|
pageScaleAdd(): void;
|
|
147
150
|
paperSize(width: number, height: number): void;
|
|
148
151
|
paperDirection(payload: PaperDirection): void;
|
|
152
|
+
pageDirection(payload: PaperDirection | null): void;
|
|
149
153
|
getPaperMargin(): number[];
|
|
150
154
|
setPaperMargin(payload: IMargin): void;
|
|
151
155
|
setMainBadge(payload: IBadge | null): void;
|
|
@@ -167,6 +171,7 @@ export declare class CommandAdapt {
|
|
|
167
171
|
setGroup(): string | null;
|
|
168
172
|
deleteGroup(groupId: string): void;
|
|
169
173
|
getGroupIds(): Promise<string[]>;
|
|
174
|
+
getGroupRectList(groupId: string): RangeRect[] | null;
|
|
170
175
|
locationGroup(groupId: string): void;
|
|
171
176
|
setZone(zone: EditorZone): void;
|
|
172
177
|
getControlValue(payload: IGetControlValueOption): IGetControlValueResult | null;
|
|
@@ -13,6 +13,7 @@ import { Listener } from '../listener/Listener';
|
|
|
13
13
|
import { Position } from '../position/Position';
|
|
14
14
|
import { RangeManager } from '../range/RangeManager';
|
|
15
15
|
import { Search } from './interactive/Search';
|
|
16
|
+
import { Spellcheck } from './interactive/Spellcheck';
|
|
16
17
|
import { Strikeout } from './richtext/Strikeout';
|
|
17
18
|
import { Underline } from './richtext/Underline';
|
|
18
19
|
import { ImageParticle } from './particle/ImageParticle';
|
|
@@ -21,6 +22,7 @@ import { TableParticle } from './particle/table/TableParticle';
|
|
|
21
22
|
import { TableTool } from './particle/table/TableTool';
|
|
22
23
|
import { Ruler } from './ruler/Ruler';
|
|
23
24
|
import { HyperlinkParticle } from './particle/HyperlinkParticle';
|
|
25
|
+
import { HintParticle } from './particle/HintParticle';
|
|
24
26
|
import { TraceParticle } from './particle/TraceParticle';
|
|
25
27
|
import { Header } from './frame/Header';
|
|
26
28
|
import { SuperscriptParticle } from './particle/SuperscriptParticle';
|
|
@@ -80,6 +82,7 @@ export declare class Draw {
|
|
|
80
82
|
private badge;
|
|
81
83
|
private magnifier;
|
|
82
84
|
private search;
|
|
85
|
+
private spellcheck;
|
|
83
86
|
private group;
|
|
84
87
|
private area;
|
|
85
88
|
private underline;
|
|
@@ -101,6 +104,7 @@ export declare class Draw {
|
|
|
101
104
|
private header;
|
|
102
105
|
private footer;
|
|
103
106
|
private hyperlinkParticle;
|
|
107
|
+
private hintParticle;
|
|
104
108
|
private traceParticle;
|
|
105
109
|
private labelParticle;
|
|
106
110
|
private dateParticle;
|
|
@@ -128,6 +132,7 @@ export declare class Draw {
|
|
|
128
132
|
private WORD_LIKE_REG;
|
|
129
133
|
private rowList;
|
|
130
134
|
private pageRowList;
|
|
135
|
+
private pageDirectionList;
|
|
131
136
|
private painterStyle;
|
|
132
137
|
private painterOptions;
|
|
133
138
|
private visiblePageNoList;
|
|
@@ -153,21 +158,34 @@ export declare class Draw {
|
|
|
153
158
|
setTraceEnabled(enabled: boolean): void;
|
|
154
159
|
setRulerEnabled(enabled: boolean): void;
|
|
155
160
|
deleteElementList(elementList: IElement[], index: number, count?: number, options?: IMarkElementListDeletedOption): IElement[];
|
|
156
|
-
getOriginalWidth(): number;
|
|
157
|
-
getOriginalHeight(): number;
|
|
158
|
-
getWidth(): number;
|
|
159
|
-
getHeight(): number;
|
|
161
|
+
getOriginalWidth(direction?: PaperDirection): number;
|
|
162
|
+
getOriginalHeight(direction?: PaperDirection): number;
|
|
163
|
+
getWidth(direction?: PaperDirection): number;
|
|
164
|
+
getHeight(direction?: PaperDirection): number;
|
|
160
165
|
getMainHeight(): number;
|
|
161
|
-
getMainOuterHeight(pageNo?: number): number;
|
|
166
|
+
getMainOuterHeight(pageNo?: number, direction?: PaperDirection): number;
|
|
162
167
|
getCanvasWidth(pageNo?: number): number;
|
|
163
168
|
getCanvasHeight(pageNo?: number): number;
|
|
164
|
-
getInnerWidth(): number;
|
|
165
|
-
getColumnLayout(): IColumnLayout | null;
|
|
169
|
+
getInnerWidth(direction?: PaperDirection): number;
|
|
170
|
+
getColumnLayout(direction?: PaperDirection): IColumnLayout | null;
|
|
166
171
|
setColumnConfig(config: IColumnOption | null): void;
|
|
167
172
|
getOriginalInnerWidth(): number;
|
|
168
173
|
getContextInnerWidth(): number;
|
|
169
|
-
getMargins(): IMargin;
|
|
170
|
-
getOriginalMargins(): number[];
|
|
174
|
+
getMargins(direction?: PaperDirection): IMargin;
|
|
175
|
+
getOriginalMargins(direction?: PaperDirection): number[];
|
|
176
|
+
getPageDirection(pageNo: number): PaperDirection;
|
|
177
|
+
getPageDirectionList(): PaperDirection[];
|
|
178
|
+
getPageSize(pageNo: number): {
|
|
179
|
+
width: number;
|
|
180
|
+
height: number;
|
|
181
|
+
margins: IMargin;
|
|
182
|
+
innerWidth: number;
|
|
183
|
+
};
|
|
184
|
+
getPageOffset(pageNo: number, isOriginal?: boolean): {
|
|
185
|
+
x: number;
|
|
186
|
+
y: number;
|
|
187
|
+
};
|
|
188
|
+
private _getPageMaxWidth;
|
|
171
189
|
getPageGap(): number;
|
|
172
190
|
getOriginalPageGap(): number;
|
|
173
191
|
getPageNumberBottom(): number;
|
|
@@ -194,6 +212,7 @@ export declare class Draw {
|
|
|
194
212
|
getCtx(): CanvasRenderingContext2D;
|
|
195
213
|
getOptions(): DeepRequired<IEditorOption>;
|
|
196
214
|
getSearch(): Search;
|
|
215
|
+
getSpellcheck(): Spellcheck;
|
|
197
216
|
getGroup(): Group;
|
|
198
217
|
getArea(): Area;
|
|
199
218
|
getBadge(): Badge;
|
|
@@ -236,6 +255,7 @@ export declare class Draw {
|
|
|
236
255
|
getHeader(): Header;
|
|
237
256
|
getFooter(): Footer;
|
|
238
257
|
getHyperlinkParticle(): HyperlinkParticle;
|
|
258
|
+
getHintParticle(): HintParticle;
|
|
239
259
|
getTraceParticle(): TraceParticle;
|
|
240
260
|
getDateParticle(): DateParticle;
|
|
241
261
|
getListParticle(): ListParticle;
|
|
@@ -263,6 +283,7 @@ export declare class Draw {
|
|
|
263
283
|
setPageDevicePixel(): void;
|
|
264
284
|
setPaperSize(width: number, height: number): void;
|
|
265
285
|
setPaperDirection(payload: PaperDirection): void;
|
|
286
|
+
setPageDirection(payload: PaperDirection | null): void;
|
|
266
287
|
setPaperMargin(payload: IMargin): void;
|
|
267
288
|
getOriginValue(options?: IGetOriginValueOption): Required<IEditorData>;
|
|
268
289
|
getValue(options?: IGetValueOption): IEditorResult;
|
|
@@ -272,6 +293,7 @@ export declare class Draw {
|
|
|
272
293
|
private _formatContainer;
|
|
273
294
|
private _createPageContainer;
|
|
274
295
|
private _createPage;
|
|
296
|
+
private _updatePageSizes;
|
|
275
297
|
private _initPageContext;
|
|
276
298
|
getElementFont(el: IElement, scale?: number): string;
|
|
277
299
|
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,20 @@
|
|
|
1
|
+
import type { ISpellcheckContext, ISpellcheckRange, ISpellcheckWord } from '../../../interface/Spellcheck';
|
|
2
|
+
import type { Draw } from '../Draw';
|
|
3
|
+
export declare class Spellcheck {
|
|
4
|
+
private options;
|
|
5
|
+
private draw;
|
|
6
|
+
private position;
|
|
7
|
+
private segmenter;
|
|
8
|
+
private spellcheckRangeList;
|
|
9
|
+
constructor(draw: Draw);
|
|
10
|
+
private _isElementHidden;
|
|
11
|
+
getSpellcheckRangeList(): ISpellcheckRange[];
|
|
12
|
+
private _appendWordList;
|
|
13
|
+
private _collectWordList;
|
|
14
|
+
getSpellcheckWordList(): ISpellcheckWord[];
|
|
15
|
+
setSpellcheckRangeList(payload: ISpellcheckRange[] | null): boolean;
|
|
16
|
+
private _isSameTablePath;
|
|
17
|
+
getRangeByIndex(index: number, context?: ISpellcheckContext): ISpellcheckRange | null;
|
|
18
|
+
private _drawWave;
|
|
19
|
+
render(ctx: CanvasRenderingContext2D, pageIndex: number): void;
|
|
20
|
+
}
|
|
@@ -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,7 +32,7 @@ import { IRangeStyle } from './interface/Listener';
|
|
|
32
32
|
import { Override } from './core/override/Override';
|
|
33
33
|
import { LETTER_CLASS } from './dataset/constant/Common';
|
|
34
34
|
import { INTERNAL_CONTEXT_MENU_KEY } from './dataset/constant/ContextMenu';
|
|
35
|
-
import { IRange } from './interface/Range';
|
|
35
|
+
import { IRange, RangeRect } from './interface/Range';
|
|
36
36
|
import { splitText } from './utils';
|
|
37
37
|
import { createDomFromElementList, getElementListByHTML, getTextFromElementList, type IGetElementListByHTMLOption } from './utils/element';
|
|
38
38
|
import { BackgroundRepeat, BackgroundSize } from './dataset/enum/Background';
|
|
@@ -57,4 +57,4 @@ export default class Editor {
|
|
|
57
57
|
export { splitText, createDomFromElementList, getElementListByHTML, getTextFromElementList };
|
|
58
58
|
export { EDITOR_COMPONENT, LETTER_CLASS, INTERNAL_CONTEXT_MENU_KEY, INTERNAL_SHORTCUT_KEY, EDITOR_CLIPBOARD };
|
|
59
59
|
export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, PageMode, RenderMode, ImageDisplay, Command, KeyMap, BlockType, MacroType, PaperDirection, TableBorder, TdBorder, TdSlash, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle, WordBreak, ControlIndentation, ControlComponent, BackgroundRepeat, BackgroundSize, TextDecorationStyle, LineNumberType, LocationPosition, AreaMode, ControlState, FlexDirection, WatermarkType, WatermarkLayer };
|
|
60
|
-
export type { IElement, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang, ICatalog, ICatalogItem, IRange, IRangeStyle, IBadge, IGetElementListByHTMLOption };
|
|
60
|
+
export type { IElement, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang, ICatalog, ICatalogItem, IRange, IRangeStyle, RangeRect, IBadge, IGetElementListByHTMLOption };
|
|
@@ -32,6 +32,8 @@ 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';
|
|
36
|
+
import type { ISpellcheckOption } from './Spellcheck';
|
|
35
37
|
export interface IEditorData {
|
|
36
38
|
header?: IElement[];
|
|
37
39
|
main: IElement[];
|
|
@@ -62,6 +64,7 @@ export interface IEditorOption {
|
|
|
62
64
|
searchMatchColor?: string;
|
|
63
65
|
searchNavigateMatchColor?: string;
|
|
64
66
|
searchMatchAlpha?: number;
|
|
67
|
+
spellcheck?: ISpellcheckOption;
|
|
65
68
|
highlightAlpha?: number;
|
|
66
69
|
highlightMarginHeight?: number;
|
|
67
70
|
resizerColor?: string;
|
|
@@ -114,6 +117,7 @@ export interface IEditorOption {
|
|
|
114
117
|
column?: IColumnOption;
|
|
115
118
|
trace?: ITraceOption;
|
|
116
119
|
ruler?: IRulerOption;
|
|
120
|
+
hint?: IHintOption;
|
|
117
121
|
}
|
|
118
122
|
export interface IEditorResult {
|
|
119
123
|
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,4 +1,5 @@
|
|
|
1
|
-
import { IContentChange, IControlChange, IControlContentChange, IImageDblclick, IImageMousedown, IImageSizeChange, IInputEventChange, IIntersectionPageNoChange, ILabelMousedown, IMouseEventChange, IPageModeChange, IPageScaleChange, IPageSizeChange, IPositionContextChange, IRangeChange, IRangeStyleChange, ISaved, IVisiblePageNoListChange, IZoneChange } from './Listener';
|
|
1
|
+
import { IContentChange, IControlChange, IControlContentChange, IImageDblclick, IImageMousedown, IImageSizeChange, IInputEventChange, IIntersectionPageNoChange, ILabelMousedown, IMouseEventChange, IPageModeChange, IPageScaleChange, IPageSizeChange, IPositionContextChange, IRangeChange, IRenderChange, IRangeStyleChange, ISaved, IVisiblePageNoListChange, IZoneChange } from './Listener';
|
|
2
|
+
import type { ISpellcheckClick } from './Spellcheck';
|
|
2
3
|
export interface EventBusMap {
|
|
3
4
|
rangeStyleChange: IRangeStyleChange;
|
|
4
5
|
visiblePageNoListChange: IVisiblePageNoListChange;
|
|
@@ -24,4 +25,6 @@ export interface EventBusMap {
|
|
|
24
25
|
imageDblclick: IImageDblclick;
|
|
25
26
|
labelMousedown: ILabelMousedown;
|
|
26
27
|
rangeChange: IRangeChange;
|
|
28
|
+
renderChange: IRenderChange;
|
|
29
|
+
spellcheckClick: ISpellcheckClick;
|
|
27
30
|
}
|
|
@@ -39,6 +39,7 @@ export type IPageSizeChange = (payload: number) => void;
|
|
|
39
39
|
export type IPageScaleChange = (payload: number) => void;
|
|
40
40
|
export type ISaved = (payload: IEditorResult) => void;
|
|
41
41
|
export type IContentChange = () => void;
|
|
42
|
+
export type IRenderChange = () => void;
|
|
42
43
|
export type IControlChange = (payload: IControlChangeResult) => void;
|
|
43
44
|
export type IControlContentChange = (payload: IControlContentChangeResult) => void;
|
|
44
45
|
export type IPageModeChange = (payload: PageMode) => void;
|
|
@@ -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;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ITablePositionContext } from './Position';
|
|
2
|
+
export interface ISpellcheckOption {
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
color?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ISpellcheckContext {
|
|
7
|
+
tableId?: string;
|
|
8
|
+
tableIndex?: number;
|
|
9
|
+
trIndex?: number;
|
|
10
|
+
tdIndex?: number;
|
|
11
|
+
tablePath?: ITablePositionContext[];
|
|
12
|
+
}
|
|
13
|
+
export interface ISpellcheckWord extends ISpellcheckContext {
|
|
14
|
+
word: string;
|
|
15
|
+
startIndex: number;
|
|
16
|
+
endIndex: number;
|
|
17
|
+
}
|
|
18
|
+
export interface ISpellcheckRange extends ISpellcheckContext {
|
|
19
|
+
startIndex: number;
|
|
20
|
+
endIndex: number;
|
|
21
|
+
data?: unknown;
|
|
22
|
+
}
|
|
23
|
+
export interface ISpellcheckClickPayload {
|
|
24
|
+
evt: MouseEvent;
|
|
25
|
+
range: ISpellcheckRange;
|
|
26
|
+
}
|
|
27
|
+
export type ISpellcheckClick = (payload: ISpellcheckClickPayload) => void;
|
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.2",
|
|
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.
|
|
58
|
-
"@vitest/coverage-v8": "^4.1.
|
|
59
|
-
"cypress": "^15.
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "^8.67.0",
|
|
57
|
+
"@typescript-eslint/parser": "^8.67.0",
|
|
58
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
59
|
+
"cypress": "^15.21.0",
|
|
60
60
|
"cypress-file-upload": "^5.0.8",
|
|
61
|
-
"eslint": "^10.
|
|
62
|
-
"globals": "^17.
|
|
61
|
+
"eslint": "^10.8.1",
|
|
62
|
+
"globals": "^17.11.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
|
-
"vitest": "^4.1.
|
|
72
|
-
"vitest-canvas-mock": "^1.1.
|
|
73
|
-
"vue": "^3.5.
|
|
71
|
+
"vitest": "^4.1.11",
|
|
72
|
+
"vitest-canvas-mock": "^1.1.5",
|
|
73
|
+
"vue": "^3.5.41"
|
|
74
74
|
},
|
|
75
75
|
"simple-git-hooks": {
|
|
76
76
|
"pre-commit": "npm run lint && npm run type:check",
|