@hufe921/canvas-editor 0.9.37 → 0.9.39
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 +37 -0
- package/README.md +7 -7
- package/dist/canvas-editor.es.js +107 -13
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +22 -22
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +2 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +6 -4
- package/dist/src/editor/core/draw/Draw.d.ts +5 -4
- package/dist/src/editor/core/draw/particle/TextParticle.d.ts +5 -0
- package/dist/src/editor/dataset/constant/Regular.d.ts +1 -0
- package/dist/src/editor/dataset/enum/Editor.d.ts +4 -0
- package/dist/src/editor/index.d.ts +2 -2
- package/dist/src/editor/interface/Draw.d.ts +7 -1
- package/dist/src/editor/interface/Editor.d.ts +3 -1
- package/dist/src/editor/interface/Range.d.ts +8 -0
- package/package.json +1 -4
|
@@ -66,6 +66,7 @@ export declare class Command {
|
|
|
66
66
|
executePaperDirection: CommandAdapt['paperDirection'];
|
|
67
67
|
executeSetPaperMargin: CommandAdapt['setPaperMargin'];
|
|
68
68
|
executeInsertElementList: CommandAdapt['insertElementList'];
|
|
69
|
+
executeAppendElementList: CommandAdapt['appendElementList'];
|
|
69
70
|
executeSetValue: CommandAdapt['setValue'];
|
|
70
71
|
executeRemoveControl: CommandAdapt['removeControl'];
|
|
71
72
|
executeSetLocale: CommandAdapt['setLocale'];
|
|
@@ -76,6 +77,7 @@ export declare class Command {
|
|
|
76
77
|
getValue: CommandAdapt['getValue'];
|
|
77
78
|
getWordCount: CommandAdapt['getWordCount'];
|
|
78
79
|
getRangeText: CommandAdapt['getRangeText'];
|
|
80
|
+
getRangeContext: CommandAdapt['getRangeContext'];
|
|
79
81
|
getPaperMargin: CommandAdapt['getPaperMargin'];
|
|
80
82
|
getSearchNavigateInfo: CommandAdapt['getSearchNavigateInfo'];
|
|
81
83
|
constructor(adapt: CommandAdapt);
|
|
@@ -6,15 +6,15 @@ import { TableBorder } from '../../dataset/enum/table/Table';
|
|
|
6
6
|
import { TitleLevel } from '../../dataset/enum/Title';
|
|
7
7
|
import { VerticalAlign } from '../../dataset/enum/VerticalAlign';
|
|
8
8
|
import { ICatalog } from '../../interface/Catalog';
|
|
9
|
-
import { IDrawImagePayload,
|
|
9
|
+
import { IAppendElementListOption, IDrawImagePayload, IGetValueOption, IPainterOption } from '../../interface/Draw';
|
|
10
10
|
import { IEditorData, IEditorResult } from '../../interface/Editor';
|
|
11
11
|
import { IElement } from '../../interface/Element';
|
|
12
12
|
import { IMargin } from '../../interface/Margin';
|
|
13
|
+
import { RangeContext } from '../../interface/Range';
|
|
13
14
|
import { IWatermark } from '../../interface/Watermark';
|
|
14
15
|
import { Draw } from '../draw/Draw';
|
|
15
16
|
import { INavigateInfo } from '../draw/interactive/Search';
|
|
16
17
|
export declare class CommandAdapt {
|
|
17
|
-
private readonly defaultWidth;
|
|
18
18
|
private draw;
|
|
19
19
|
private range;
|
|
20
20
|
private position;
|
|
@@ -36,7 +36,7 @@ export declare class CommandAdapt {
|
|
|
36
36
|
setRange(startIndex: number, endIndex: number): void;
|
|
37
37
|
undo(): void;
|
|
38
38
|
redo(): void;
|
|
39
|
-
painter(options:
|
|
39
|
+
painter(options: IPainterOption): void;
|
|
40
40
|
applyPainterStyle(): void;
|
|
41
41
|
format(): void;
|
|
42
42
|
font(payload: string): void;
|
|
@@ -88,9 +88,10 @@ export declare class CommandAdapt {
|
|
|
88
88
|
saveAsImageElement(): void;
|
|
89
89
|
changeImageDisplay(element: IElement, display: ImageDisplay): void;
|
|
90
90
|
getImage(): Promise<string[]>;
|
|
91
|
-
getValue(): IEditorResult;
|
|
91
|
+
getValue(options?: IGetValueOption): IEditorResult;
|
|
92
92
|
getWordCount(): Promise<number>;
|
|
93
93
|
getRangeText(): string;
|
|
94
|
+
getRangeContext(): RangeContext | null;
|
|
94
95
|
pageMode(payload: PageMode): void;
|
|
95
96
|
pageScaleRecovery(): void;
|
|
96
97
|
pageScaleMinus(): void;
|
|
@@ -100,6 +101,7 @@ export declare class CommandAdapt {
|
|
|
100
101
|
getPaperMargin(): number[];
|
|
101
102
|
setPaperMargin(payload: IMargin): void;
|
|
102
103
|
insertElementList(payload: IElement[]): void;
|
|
104
|
+
appendElementList(elementList: IElement[], options?: IAppendElementListOption): void;
|
|
103
105
|
setValue(payload: Partial<IEditorData>): void;
|
|
104
106
|
removeControl(): void;
|
|
105
107
|
setLocale(payload: string): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDrawOption, IDrawRowPayload,
|
|
1
|
+
import { IAppendElementListOption, IDrawOption, IDrawRowPayload, IGetValueOption, IPainterOption } from '../../interface/Draw';
|
|
2
2
|
import { IEditorData, IEditorOption, IEditorResult } from '../../interface/Editor';
|
|
3
3
|
import { IElement, IElementStyle } from '../../interface/Element';
|
|
4
4
|
import { IRow } from '../../interface/Row';
|
|
@@ -135,6 +135,7 @@ export declare class Draw {
|
|
|
135
135
|
getOriginalMainElementList(): IElement[];
|
|
136
136
|
getFooterElementList(): IElement[];
|
|
137
137
|
insertElementList(payload: IElement[]): void;
|
|
138
|
+
appendElementList(elementList: IElement[], options?: IAppendElementListOption): void;
|
|
138
139
|
spliceElementList(elementList: IElement[], start: number, deleteCount: number, ...items: IElement[]): void;
|
|
139
140
|
getCanvasEvent(): CanvasEvent;
|
|
140
141
|
getListener(): Listener;
|
|
@@ -155,8 +156,8 @@ export declare class Draw {
|
|
|
155
156
|
getRowCount(): number;
|
|
156
157
|
getDataURL(): Promise<string[]>;
|
|
157
158
|
getPainterStyle(): IElementStyle | null;
|
|
158
|
-
getPainterOptions():
|
|
159
|
-
setPainterStyle(payload: IElementStyle | null, options?:
|
|
159
|
+
getPainterOptions(): IPainterOption | null;
|
|
160
|
+
setPainterStyle(payload: IElementStyle | null, options?: IPainterOption): void;
|
|
160
161
|
setDefaultRange(): void;
|
|
161
162
|
getIsPagingMode(): boolean;
|
|
162
163
|
setPageMode(payload: PageMode): void;
|
|
@@ -165,7 +166,7 @@ export declare class Draw {
|
|
|
165
166
|
setPaperSize(width: number, height: number): void;
|
|
166
167
|
setPaperDirection(payload: PaperDirection): void;
|
|
167
168
|
setPaperMargin(payload: IMargin): void;
|
|
168
|
-
getValue(): IEditorResult;
|
|
169
|
+
getValue(options?: IGetValueOption): IEditorResult;
|
|
169
170
|
setValue(payload: Partial<IEditorData>): void;
|
|
170
171
|
private _wrapContainer;
|
|
171
172
|
private _formatContainer;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { IElement } from '../../..';
|
|
2
2
|
import { IRowElement } from '../../../interface/Row';
|
|
3
3
|
import { Draw } from '../Draw';
|
|
4
|
+
export interface IMeasureWordResult {
|
|
5
|
+
width: number;
|
|
6
|
+
endElement: IElement;
|
|
7
|
+
}
|
|
4
8
|
export declare class TextParticle {
|
|
5
9
|
private ctx;
|
|
6
10
|
private curX;
|
|
@@ -10,6 +14,7 @@ export declare class TextParticle {
|
|
|
10
14
|
private curColor?;
|
|
11
15
|
cacheMeasureText: Map<string, TextMetrics>;
|
|
12
16
|
constructor(draw: Draw);
|
|
17
|
+
measureWord(ctx: CanvasRenderingContext2D, elementList: IElement[], curIndex: number): IMeasureWordResult;
|
|
13
18
|
measurePunctuationWidth(ctx: CanvasRenderingContext2D, element: IElement): number;
|
|
14
19
|
measureText(ctx: CanvasRenderingContext2D, element: IElement): TextMetrics;
|
|
15
20
|
complete(): void;
|
|
@@ -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, EditorZone, EditorMode, PageMode, PaperDirection } from './dataset/enum/Editor';
|
|
10
|
+
import { EditorComponent, EditorZone, EditorMode, PageMode, PaperDirection, WordBreak } 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';
|
|
@@ -31,5 +31,5 @@ export default class Editor {
|
|
|
31
31
|
use: UsePlugin;
|
|
32
32
|
constructor(container: HTMLDivElement, data: IEditorData | IElement[], options?: IEditorOption);
|
|
33
33
|
}
|
|
34
|
-
export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, EDITOR_COMPONENT, PageMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection, TableBorder, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle };
|
|
34
|
+
export { Editor, RowFlex, VerticalAlign, EditorZone, EditorMode, ElementType, ControlType, EditorComponent, EDITOR_COMPONENT, PageMode, ImageDisplay, Command, KeyMap, BlockType, PaperDirection, TableBorder, MaxHeightRatio, NumberType, TitleLevel, ListType, ListStyle, WordBreak };
|
|
35
35
|
export type { IElement, IEditorData, IEditorOption, IEditorResult, IContextMenuContext, IRegisterContextMenu, IWatermark, INavigateInfo, IBlock, ILang, ICatalog, ICatalogItem };
|
|
@@ -28,6 +28,12 @@ export interface IDrawPagePayload {
|
|
|
28
28
|
rowList: IRow[];
|
|
29
29
|
pageNo: number;
|
|
30
30
|
}
|
|
31
|
-
export interface
|
|
31
|
+
export interface IPainterOption {
|
|
32
32
|
isDblclick: boolean;
|
|
33
33
|
}
|
|
34
|
+
export interface IGetValueOption {
|
|
35
|
+
pageNo?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface IAppendElementListOption {
|
|
38
|
+
isPrepend?: boolean;
|
|
39
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IElement } from '..';
|
|
2
|
-
import { EditorMode, PageMode, PaperDirection } from '../dataset/enum/Editor';
|
|
2
|
+
import { EditorMode, PageMode, PaperDirection, WordBreak } from '../dataset/enum/Editor';
|
|
3
3
|
import { ICheckboxOption } from './Checkbox';
|
|
4
4
|
import { IControlOption } from './Control';
|
|
5
5
|
import { ICursorOption } from './Cursor';
|
|
@@ -46,10 +46,12 @@ export interface IEditorOption {
|
|
|
46
46
|
pageMode?: PageMode;
|
|
47
47
|
tdPadding?: number;
|
|
48
48
|
defaultTrMinHeight?: number;
|
|
49
|
+
defaultColMinWidth?: number;
|
|
49
50
|
defaultHyperlinkColor?: string;
|
|
50
51
|
paperDirection?: PaperDirection;
|
|
51
52
|
inactiveAlpha?: number;
|
|
52
53
|
historyMaxRecordCount?: number;
|
|
54
|
+
wordBreak?: WordBreak;
|
|
53
55
|
header?: IHeader;
|
|
54
56
|
footer?: IFooter;
|
|
55
57
|
pageNumber?: IPageNumber;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EditorZone } from '../dataset/enum/Editor';
|
|
2
|
+
import { IElement } from './Element';
|
|
2
3
|
export interface IRange {
|
|
3
4
|
startIndex: number;
|
|
4
5
|
endIndex: number;
|
|
@@ -12,3 +13,10 @@ export interface IRange {
|
|
|
12
13
|
}
|
|
13
14
|
export declare type RangeRowArray = Map<number, number[]>;
|
|
14
15
|
export declare type RangeRowMap = Map<number, Set<number>>;
|
|
16
|
+
export declare type RangeContext = {
|
|
17
|
+
isCollapsed: boolean;
|
|
18
|
+
startElement: IElement;
|
|
19
|
+
endElement: IElement;
|
|
20
|
+
startPageNo: number;
|
|
21
|
+
endPageNo: number;
|
|
22
|
+
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@hufe921/canvas-editor",
|
|
3
3
|
"author": "Hufe",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.9.
|
|
5
|
+
"version": "0.9.39",
|
|
6
6
|
"description": "rich text editor by canvas/svg",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -63,9 +63,6 @@
|
|
|
63
63
|
"vitepress": "^1.0.0-alpha.33",
|
|
64
64
|
"vue": "^3.2.45"
|
|
65
65
|
},
|
|
66
|
-
"dependencies": {
|
|
67
|
-
"prismjs": "^1.27.0"
|
|
68
|
-
},
|
|
69
66
|
"simple-git-hooks": {
|
|
70
67
|
"pre-commit": "npm run lint && npm run type:check",
|
|
71
68
|
"commit-msg": "node scripts/verifyCommit.js"
|