@hufe921/canvas-editor 0.9.72 → 0.9.73
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 +25 -0
- package/dist/canvas-editor.es.js +345 -223
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +31 -31
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/cursor/Cursor.d.ts +1 -1
- package/dist/src/editor/core/draw/Draw.d.ts +2 -2
- package/dist/src/editor/core/draw/control/Control.d.ts +1 -1
- package/dist/src/editor/core/draw/control/interactive/ControlSearch.d.ts +1 -1
- package/dist/src/editor/core/range/RangeManager.d.ts +4 -2
- package/dist/src/editor/dataset/constant/Regular.d.ts +1 -0
- package/dist/src/editor/dataset/enum/List.d.ts +4 -2
- package/dist/src/editor/interface/Catalog.d.ts +1 -1
- package/dist/src/editor/interface/Common.d.ts +5 -5
- package/dist/src/editor/interface/Control.d.ts +4 -4
- package/dist/src/editor/interface/Draw.d.ts +5 -0
- package/dist/src/editor/interface/Editor.d.ts +1 -1
- package/dist/src/editor/interface/Element.d.ts +2 -2
- package/dist/src/editor/interface/Listener.d.ts +10 -10
- package/dist/src/editor/interface/Margin.d.ts +1 -1
- package/dist/src/editor/interface/Plugin.d.ts +2 -2
- package/dist/src/editor/interface/Position.d.ts +1 -1
- package/dist/src/editor/interface/Range.d.ts +8 -4
- package/dist/src/editor/interface/Row.d.ts +1 -1
- package/dist/src/editor/interface/Search.d.ts +1 -1
- package/dist/src/editor/interface/Title.d.ts +1 -1
- package/package.json +6 -6
|
@@ -3,7 +3,7 @@ import { ICursorOption } from '../../interface/Cursor';
|
|
|
3
3
|
import { IElementPosition } from '../../interface/Element';
|
|
4
4
|
import { Draw } from '../draw/Draw';
|
|
5
5
|
import { CanvasEvent } from '../event/CanvasEvent';
|
|
6
|
-
export
|
|
6
|
+
export type IDrawCursorOption = ICursorOption & {
|
|
7
7
|
isShow?: boolean;
|
|
8
8
|
isBlink?: boolean;
|
|
9
9
|
isFocus?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAppendElementListOption, IDrawOption, IDrawRowPayload, IGetImageOption, IGetValueOption, IPainterOption } from '../../interface/Draw';
|
|
1
|
+
import { IAppendElementListOption, IComputeRowListPayload, IDrawOption, IDrawRowPayload, IGetImageOption, 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';
|
|
@@ -196,7 +196,7 @@ export declare class Draw {
|
|
|
196
196
|
private _initPageContext;
|
|
197
197
|
getElementFont(el: IElement, scale?: number): string;
|
|
198
198
|
getElementSize(el: IElement): number;
|
|
199
|
-
computeRowList(
|
|
199
|
+
computeRowList(payload: IComputeRowListPayload): IRow[];
|
|
200
200
|
private _computePageList;
|
|
201
201
|
private _drawHighlight;
|
|
202
202
|
drawRow(ctx: CanvasRenderingContext2D, payload: IDrawRowPayload): void;
|
|
@@ -30,7 +30,7 @@ export declare class Control {
|
|
|
30
30
|
getPosition(): IElementPosition | null;
|
|
31
31
|
getPreY(): number;
|
|
32
32
|
getRange(): IRange;
|
|
33
|
-
shrinkBoundary(): void;
|
|
33
|
+
shrinkBoundary(context?: IControlContext): void;
|
|
34
34
|
getActiveControl(): IControlInstance | null;
|
|
35
35
|
initControl(): void;
|
|
36
36
|
destroyControl(): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IControlHighlight, IControlHighlightRule } from '../../../../interface/Control';
|
|
2
2
|
import { ISearchResult } from '../../../../interface/Search';
|
|
3
3
|
import { Control } from '../Control';
|
|
4
|
-
|
|
4
|
+
type IHighlightMatchResult = (ISearchResult & IControlHighlightRule)[];
|
|
5
5
|
export declare class ControlSearch {
|
|
6
6
|
private draw;
|
|
7
7
|
private options;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { IControlContext } from '../../interface/Control';
|
|
1
2
|
import { IElement } from '../../interface/Element';
|
|
2
|
-
import { IRange, RangeRowArray, RangeRowMap } from '../../interface/Range';
|
|
3
|
+
import { IRange, IRangeParagraphInfo, RangeRowArray, RangeRowMap } from '../../interface/Range';
|
|
3
4
|
import { Draw } from '../draw/Draw';
|
|
4
5
|
export declare class RangeManager {
|
|
5
6
|
private draw;
|
|
@@ -20,6 +21,7 @@ export declare class RangeManager {
|
|
|
20
21
|
getRangeRow(): RangeRowMap | null;
|
|
21
22
|
getRangeRowElementList(): IElement[] | null;
|
|
22
23
|
getRangeParagraph(): RangeRowArray | null;
|
|
24
|
+
getRangeParagraphInfo(): IRangeParagraphInfo | null;
|
|
23
25
|
getRangeParagraphElementList(): IElement[] | null;
|
|
24
26
|
getIsSelectAll(): boolean;
|
|
25
27
|
getIsPointInRange(x: number, y: number): boolean;
|
|
@@ -29,7 +31,7 @@ export declare class RangeManager {
|
|
|
29
31
|
replaceRange(range: IRange): void;
|
|
30
32
|
setRangeStyle(): void;
|
|
31
33
|
recoveryRangeStyle(): void;
|
|
32
|
-
shrinkBoundary(): void;
|
|
34
|
+
shrinkBoundary(context?: IControlContext): void;
|
|
33
35
|
render(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number): void;
|
|
34
36
|
toString(): string;
|
|
35
37
|
}
|
|
@@ -5,7 +5,8 @@ export declare enum ListType {
|
|
|
5
5
|
export declare enum UlStyle {
|
|
6
6
|
DISC = "disc",
|
|
7
7
|
CIRCLE = "circle",
|
|
8
|
-
SQUARE = "square"
|
|
8
|
+
SQUARE = "square",
|
|
9
|
+
CHECKBOX = "checkbox"
|
|
9
10
|
}
|
|
10
11
|
export declare enum OlStyle {
|
|
11
12
|
DECIMAL = "decimal"
|
|
@@ -14,5 +15,6 @@ export declare enum ListStyle {
|
|
|
14
15
|
DISC = "disc",
|
|
15
16
|
CIRCLE = "circle",
|
|
16
17
|
SQUARE = "square",
|
|
17
|
-
DECIMAL = "decimal"
|
|
18
|
+
DECIMAL = "decimal",
|
|
19
|
+
CHECKBOX = "checkbox"
|
|
18
20
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export type Primitive = string | number | boolean | bigint | symbol | undefined | null;
|
|
2
|
+
export type Builtin = Primitive | Function | Date | Error | RegExp;
|
|
3
|
+
export type DeepRequired<T> = T extends Error ? Required<T> : T extends Builtin ? T : T extends Map<infer K, infer V> ? Map<DeepRequired<K>, DeepRequired<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<DeepRequired<K>, DeepRequired<V>> : T extends WeakMap<infer K, infer V> ? WeakMap<DeepRequired<K>, DeepRequired<V>> : T extends Set<infer U> ? Set<DeepRequired<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<DeepRequired<U>> : T extends WeakSet<infer U> ? WeakSet<DeepRequired<U>> : T extends Promise<infer U> ? Promise<DeepRequired<U>> : T extends {} ? {
|
|
4
4
|
[K in keyof T]-?: DeepRequired<T[K]>;
|
|
5
5
|
} : Required<T>;
|
|
6
|
-
export
|
|
6
|
+
export type DeepPartial<T> = {
|
|
7
7
|
[P in keyof T]?: DeepPartial<T[P]>;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type IPadding = [
|
|
10
10
|
top: number,
|
|
11
11
|
right: number,
|
|
12
12
|
bottom: number,
|
|
@@ -43,7 +43,7 @@ export interface IControlBasic {
|
|
|
43
43
|
extension?: unknown;
|
|
44
44
|
indentation?: ControlIndentation;
|
|
45
45
|
}
|
|
46
|
-
export
|
|
46
|
+
export type IControl = IControlBasic & IControlRule & Partial<IControlSelect> & Partial<IControlCheckbox>;
|
|
47
47
|
export interface IControlOption {
|
|
48
48
|
placeholderColor?: string;
|
|
49
49
|
bracketColor?: string;
|
|
@@ -77,7 +77,7 @@ export interface IControlRuleOption {
|
|
|
77
77
|
export interface IGetControlValueOption {
|
|
78
78
|
conceptId: string;
|
|
79
79
|
}
|
|
80
|
-
export
|
|
80
|
+
export type IGetControlValueResult = (Omit<IControl, 'value'> & {
|
|
81
81
|
value: string | null;
|
|
82
82
|
innerText: string | null;
|
|
83
83
|
zone: EditorZone;
|
|
@@ -90,8 +90,8 @@ export interface ISetControlExtensionOption {
|
|
|
90
90
|
conceptId: string;
|
|
91
91
|
extension: unknown;
|
|
92
92
|
}
|
|
93
|
-
export
|
|
94
|
-
export
|
|
93
|
+
export type ISetControlHighlightOption = IControlHighlight[];
|
|
94
|
+
export type ISetControlProperties = {
|
|
95
95
|
conceptId: string;
|
|
96
96
|
properties: Partial<Omit<IControl, 'value'>>;
|
|
97
97
|
};
|
|
@@ -59,7 +59,7 @@ export interface ITableElement {
|
|
|
59
59
|
conceptId?: string;
|
|
60
60
|
pagingId?: string;
|
|
61
61
|
}
|
|
62
|
-
export
|
|
62
|
+
export type ITable = ITableAttr & ITableElement;
|
|
63
63
|
export interface IHyperlinkElement {
|
|
64
64
|
valueList?: IElement[];
|
|
65
65
|
url?: string;
|
|
@@ -96,7 +96,7 @@ export interface IImageElement {
|
|
|
96
96
|
export interface IBlockElement {
|
|
97
97
|
block?: IBlock;
|
|
98
98
|
}
|
|
99
|
-
export
|
|
99
|
+
export type IElement = IElementBasic & IElementStyle & IElementGroup & ITable & IHyperlinkElement & ISuperscriptSubscript & ISeparator & IControlElement & ICheckboxElement & ILaTexElement & IDateElement & IImageElement & IBlockElement & ITitleElement & IListElement;
|
|
100
100
|
export interface IElementMetrics {
|
|
101
101
|
width: number;
|
|
102
102
|
height: number;
|
|
@@ -25,13 +25,13 @@ export interface IRangeStyle {
|
|
|
25
25
|
groupIds: string[] | null;
|
|
26
26
|
textDecoration: ITextDecoration | null;
|
|
27
27
|
}
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
28
|
+
export type IRangeStyleChange = (payload: IRangeStyle) => void;
|
|
29
|
+
export type IVisiblePageNoListChange = (payload: number[]) => void;
|
|
30
|
+
export type IIntersectionPageNoChange = (payload: number) => void;
|
|
31
|
+
export type IPageSizeChange = (payload: number) => void;
|
|
32
|
+
export type IPageScaleChange = (payload: number) => void;
|
|
33
|
+
export type ISaved = (payload: IEditorResult) => void;
|
|
34
|
+
export type IContentChange = () => void;
|
|
35
|
+
export type IControlChange = (payload: IControl | null) => void;
|
|
36
|
+
export type IPageModeChange = (payload: PageMode) => void;
|
|
37
|
+
export type IZoneChange = (payload: EditorZone) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type IMargin = [top: number, right: number, bottom: number, left: number];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import Editor from '..';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type PluginFunction<Options> = (editor: Editor, options?: Options) => any;
|
|
3
|
+
export type UsePlugin = <Options>(pluginFunction: PluginFunction<Options>, options?: Options) => void;
|
|
@@ -31,7 +31,7 @@ export interface IGetPositionByXYPayload {
|
|
|
31
31
|
elementList?: IElement[];
|
|
32
32
|
positionList?: IElementPosition[];
|
|
33
33
|
}
|
|
34
|
-
export
|
|
34
|
+
export type IGetFloatPositionByXYPayload = IGetPositionByXYPayload & {
|
|
35
35
|
imgDisplay: ImageDisplay;
|
|
36
36
|
};
|
|
37
37
|
export interface IPositionContext {
|
|
@@ -11,10 +11,10 @@ export interface IRange {
|
|
|
11
11
|
endTrIndex?: number;
|
|
12
12
|
zone?: EditorZone;
|
|
13
13
|
}
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
14
|
+
export type RangeRowArray = Map<number, number[]>;
|
|
15
|
+
export type RangeRowMap = Map<number, Set<number>>;
|
|
16
|
+
export type RangeRect = IElementFillRect;
|
|
17
|
+
export type RangeContext = {
|
|
18
18
|
isCollapsed: boolean;
|
|
19
19
|
startElement: IElement;
|
|
20
20
|
endElement: IElement;
|
|
@@ -24,3 +24,7 @@ export declare type RangeContext = {
|
|
|
24
24
|
zone: EditorZone;
|
|
25
25
|
isTable: boolean;
|
|
26
26
|
};
|
|
27
|
+
export interface IRangeParagraphInfo {
|
|
28
|
+
elementList: IElement[];
|
|
29
|
+
startIndex: number;
|
|
30
|
+
}
|
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.73",
|
|
6
6
|
"description": "rich text editor by canvas/svg",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"emr"
|
|
31
31
|
],
|
|
32
32
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
33
|
+
"node": ">=16.9.1"
|
|
34
34
|
},
|
|
35
35
|
"type": "module",
|
|
36
36
|
"scripts": {
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@rollup/plugin-typescript": "^10.0.1",
|
|
52
|
-
"@types/node": "
|
|
52
|
+
"@types/node": "16.18.96",
|
|
53
53
|
"@types/prismjs": "^1.26.0",
|
|
54
|
-
"@typescript-eslint/eslint-plugin": "
|
|
55
|
-
"@typescript-eslint/parser": "
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "5.62.0",
|
|
55
|
+
"@typescript-eslint/parser": "5.62.0",
|
|
56
56
|
"cypress": "13.6.0",
|
|
57
57
|
"cypress-file-upload": "^5.0.8",
|
|
58
58
|
"eslint": "7.32.0",
|
|
59
59
|
"simple-git-hooks": "^2.8.1",
|
|
60
|
-
"typescript": "
|
|
60
|
+
"typescript": "4.9.5",
|
|
61
61
|
"vite": "^2.4.2",
|
|
62
62
|
"vite-plugin-css-injected-by-js": "^2.1.1",
|
|
63
63
|
"vitepress": "1.0.0-beta.6",
|