@hufe921/canvas-editor 0.9.74 → 0.9.76
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 +46 -0
- package/dist/canvas-editor.es.js +438 -80
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +32 -31
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +1 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +2 -0
- package/dist/src/editor/core/draw/Draw.d.ts +6 -0
- package/dist/src/editor/core/draw/control/checkbox/CheckboxControl.d.ts +2 -2
- package/dist/src/editor/core/draw/control/radio/RadioControl.d.ts +5 -0
- package/dist/src/editor/core/draw/particle/LineBreakParticle.d.ts +10 -0
- package/dist/src/editor/core/draw/particle/RadioParticle.d.ts +10 -0
- package/dist/src/editor/dataset/constant/LineBreak.d.ts +2 -0
- package/dist/src/editor/dataset/constant/Radio.d.ts +2 -0
- package/dist/src/editor/dataset/constant/Separator.d.ts +2 -0
- package/dist/src/editor/dataset/enum/Control.d.ts +4 -2
- package/dist/src/editor/dataset/enum/Element.d.ts +1 -0
- package/dist/src/editor/dataset/enum/Row.d.ts +2 -1
- package/dist/src/editor/interface/Checkbox.d.ts +1 -1
- package/dist/src/editor/interface/Control.d.ts +7 -1
- package/dist/src/editor/interface/Draw.d.ts +1 -0
- package/dist/src/editor/interface/Editor.d.ts +6 -0
- package/dist/src/editor/interface/Element.d.ts +7 -1
- package/dist/src/editor/interface/LineBreak.d.ts +5 -0
- package/dist/src/editor/interface/Position.d.ts +2 -0
- package/dist/src/editor/interface/Radio.d.ts +13 -0
- package/dist/src/editor/interface/Row.d.ts +1 -0
- package/dist/src/editor/interface/Separator.d.ts +4 -0
- package/dist/src/editor/interface/Title.d.ts +13 -0
- package/dist/src/editor/utils/clipboard.d.ts +1 -0
- package/package.json +1 -1
|
@@ -108,5 +108,6 @@ export declare class Command {
|
|
|
108
108
|
getControlValue: CommandAdapt['getControlValue'];
|
|
109
109
|
getControlList: CommandAdapt['getControlList'];
|
|
110
110
|
getContainer: CommandAdapt['getContainer'];
|
|
111
|
+
getTitleValue: CommandAdapt['getTitleValue'];
|
|
111
112
|
constructor(adapt: CommandAdapt);
|
|
112
113
|
}
|
|
@@ -15,6 +15,7 @@ import { IPasteOption } from '../../interface/Event';
|
|
|
15
15
|
import { IMargin } from '../../interface/Margin';
|
|
16
16
|
import { IRange, RangeContext } from '../../interface/Range';
|
|
17
17
|
import { ITextDecoration } from '../../interface/Text';
|
|
18
|
+
import { IGetTitleValueOption, IGetTitleValueResult } from '../../interface/Title';
|
|
18
19
|
import { IWatermark } from '../../interface/Watermark';
|
|
19
20
|
import { Draw } from '../draw/Draw';
|
|
20
21
|
import { INavigateInfo } from '../draw/interactive/Search';
|
|
@@ -140,4 +141,5 @@ export declare class CommandAdapt {
|
|
|
140
141
|
setControlHighlight(payload: ISetControlHighlightOption): void;
|
|
141
142
|
getControlList(): IElement[];
|
|
142
143
|
getContainer(): HTMLDivElement;
|
|
144
|
+
getTitleValue(payload: IGetTitleValueOption): IGetTitleValueResult | null;
|
|
143
145
|
}
|
|
@@ -18,6 +18,7 @@ import { Header } from './frame/Header';
|
|
|
18
18
|
import { EditorMode, PageMode, PaperDirection } from '../../dataset/enum/Editor';
|
|
19
19
|
import { Control } from './control/Control';
|
|
20
20
|
import { CheckboxParticle } from './particle/CheckboxParticle';
|
|
21
|
+
import { RadioParticle } from './particle/RadioParticle';
|
|
21
22
|
import { DeepRequired, IPadding } from '../../interface/Common';
|
|
22
23
|
import { WorkerManager } from '../worker/WorkerManager';
|
|
23
24
|
import { Previewer } from './particle/previewer/Previewer';
|
|
@@ -32,6 +33,7 @@ import { EventBus } from '../event/eventbus/EventBus';
|
|
|
32
33
|
import { EventBusMap } from '../../interface/EventBus';
|
|
33
34
|
import { Group } from './interactive/Group';
|
|
34
35
|
import { Override } from '../override/Override';
|
|
36
|
+
import { LineBreakParticle } from './particle/LineBreakParticle';
|
|
35
37
|
export declare class Draw {
|
|
36
38
|
private container;
|
|
37
39
|
private pageContainer;
|
|
@@ -78,8 +80,10 @@ export declare class Draw {
|
|
|
78
80
|
private superscriptParticle;
|
|
79
81
|
private subscriptParticle;
|
|
80
82
|
private checkboxParticle;
|
|
83
|
+
private radioParticle;
|
|
81
84
|
private blockParticle;
|
|
82
85
|
private listParticle;
|
|
86
|
+
private lineBreakParticle;
|
|
83
87
|
private control;
|
|
84
88
|
private workerManager;
|
|
85
89
|
private scrollObserver;
|
|
@@ -141,6 +145,7 @@ export declare class Draw {
|
|
|
141
145
|
getPosition(): Position;
|
|
142
146
|
getZone(): Zone;
|
|
143
147
|
getRange(): RangeManager;
|
|
148
|
+
getLineBreakParticle(): LineBreakParticle;
|
|
144
149
|
getHeaderElementList(): IElement[];
|
|
145
150
|
getTableElementList(sourceElementList: IElement[]): IElement[];
|
|
146
151
|
getElementList(): IElement[];
|
|
@@ -167,6 +172,7 @@ export declare class Draw {
|
|
|
167
172
|
getDateParticle(): DateParticle;
|
|
168
173
|
getListParticle(): ListParticle;
|
|
169
174
|
getCheckboxParticle(): CheckboxParticle;
|
|
175
|
+
getRadioParticle(): RadioParticle;
|
|
170
176
|
getControl(): Control;
|
|
171
177
|
getWorkerManager(): WorkerManager;
|
|
172
178
|
getImageObserver(): ImageObserver;
|
|
@@ -2,8 +2,8 @@ import { IControlContext, IControlInstance, IControlRuleOption } from '../../../
|
|
|
2
2
|
import { IElement } from '../../../../interface/Element';
|
|
3
3
|
import { Control } from '../Control';
|
|
4
4
|
export declare class CheckboxControl implements IControlInstance {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
protected element: IElement;
|
|
6
|
+
protected control: Control;
|
|
7
7
|
constructor(element: IElement, control: Control);
|
|
8
8
|
getElement(): IElement;
|
|
9
9
|
getCode(): string | null;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IControlContext, IControlRuleOption } from '../../../../interface/Control';
|
|
2
|
+
import { CheckboxControl } from '../checkbox/CheckboxControl';
|
|
3
|
+
export declare class RadioControl extends CheckboxControl {
|
|
4
|
+
setSelect(codes: string[], context?: IControlContext, options?: IControlRuleOption): void;
|
|
5
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IRowElement } from '../../../interface/Row';
|
|
2
|
+
import { Draw } from '../Draw';
|
|
3
|
+
export declare class LineBreakParticle {
|
|
4
|
+
private options;
|
|
5
|
+
static readonly WIDTH = 12;
|
|
6
|
+
static readonly HEIGHT = 9;
|
|
7
|
+
static readonly GAP = 3;
|
|
8
|
+
constructor(draw: Draw);
|
|
9
|
+
render(ctx: CanvasRenderingContext2D, element: IRowElement, x: number, y: number): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IElement } from '../../../interface/Element';
|
|
2
|
+
import { IRowElement } from '../../../interface/Row';
|
|
3
|
+
import { Draw } from '../Draw';
|
|
4
|
+
export declare class RadioParticle {
|
|
5
|
+
private draw;
|
|
6
|
+
private options;
|
|
7
|
+
constructor(draw: Draw);
|
|
8
|
+
setSelect(element: IElement): void;
|
|
9
|
+
render(ctx: CanvasRenderingContext2D, element: IRowElement, x: number, y: number): void;
|
|
10
|
+
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
export declare enum ControlType {
|
|
2
2
|
TEXT = "text",
|
|
3
3
|
SELECT = "select",
|
|
4
|
-
CHECKBOX = "checkbox"
|
|
4
|
+
CHECKBOX = "checkbox",
|
|
5
|
+
RADIO = "radio"
|
|
5
6
|
}
|
|
6
7
|
export declare enum ControlComponent {
|
|
7
8
|
PREFIX = "prefix",
|
|
8
9
|
POSTFIX = "postfix",
|
|
9
10
|
PLACEHOLDER = "placeholder",
|
|
10
11
|
VALUE = "value",
|
|
11
|
-
CHECKBOX = "checkbox"
|
|
12
|
+
CHECKBOX = "checkbox",
|
|
13
|
+
RADIO = "radio"
|
|
12
14
|
}
|
|
13
15
|
export declare enum ControlIndentation {
|
|
14
16
|
ROW_START = "rowStart",
|
|
@@ -2,6 +2,7 @@ import { ControlType, ControlIndentation } from '../dataset/enum/Control';
|
|
|
2
2
|
import { EditorZone } from '../dataset/enum/Editor';
|
|
3
3
|
import { ICheckbox } from './Checkbox';
|
|
4
4
|
import { IElement } from './Element';
|
|
5
|
+
import { IRadio } from './Radio';
|
|
5
6
|
import { IRange } from './Range';
|
|
6
7
|
export interface IValueSet {
|
|
7
8
|
value: string;
|
|
@@ -18,6 +19,11 @@ export interface IControlCheckbox {
|
|
|
18
19
|
valueSets: IValueSet[];
|
|
19
20
|
checkbox?: ICheckbox;
|
|
20
21
|
}
|
|
22
|
+
export interface IControlRadio {
|
|
23
|
+
code: string | null;
|
|
24
|
+
valueSets: IValueSet[];
|
|
25
|
+
radio?: IRadio;
|
|
26
|
+
}
|
|
21
27
|
export interface IControlHighlightRule {
|
|
22
28
|
keyword: string;
|
|
23
29
|
alpha?: number;
|
|
@@ -52,7 +58,7 @@ export interface IControlStyle {
|
|
|
52
58
|
italic?: boolean;
|
|
53
59
|
strikeout?: boolean;
|
|
54
60
|
}
|
|
55
|
-
export type IControl = IControlBasic & IControlRule & Partial<IControlSelect> & Partial<IControlCheckbox> & Partial<IControlStyle>;
|
|
61
|
+
export type IControl = IControlBasic & IControlRule & Partial<IControlSelect> & Partial<IControlCheckbox> & Partial<IControlRadio> & Partial<IControlStyle>;
|
|
56
62
|
export interface IControlOption {
|
|
57
63
|
placeholderColor?: string;
|
|
58
64
|
bracketColor?: string;
|
|
@@ -2,12 +2,14 @@ import { IElement } from '..';
|
|
|
2
2
|
import { EditorMode, PageMode, PaperDirection, WordBreak } from '../dataset/enum/Editor';
|
|
3
3
|
import { IBackgroundOption } from './Background';
|
|
4
4
|
import { ICheckboxOption } from './Checkbox';
|
|
5
|
+
import { IRadioOption } from './Radio';
|
|
5
6
|
import { IPadding } from './Common';
|
|
6
7
|
import { IControlOption } from './Control';
|
|
7
8
|
import { ICursorOption } from './Cursor';
|
|
8
9
|
import { IFooter } from './Footer';
|
|
9
10
|
import { IGroup } from './Group';
|
|
10
11
|
import { IHeader } from './Header';
|
|
12
|
+
import { ILineBreakOption } from './LineBreak';
|
|
11
13
|
import { IMargin } from './Margin';
|
|
12
14
|
import { IPageBreak } from './PageBreak';
|
|
13
15
|
import { IPageNumber } from './PageNumber';
|
|
@@ -15,6 +17,7 @@ import { IPlaceholder } from './Placeholder';
|
|
|
15
17
|
import { ITitleOption } from './Title';
|
|
16
18
|
import { IWatermark } from './Watermark';
|
|
17
19
|
import { IZoneOption } from './Zone';
|
|
20
|
+
import { ISeparatorOption } from './Separator';
|
|
18
21
|
export interface IEditorData {
|
|
19
22
|
header?: IElement[];
|
|
20
23
|
main: IElement[];
|
|
@@ -69,6 +72,7 @@ export interface IEditorOption {
|
|
|
69
72
|
watermark?: IWatermark;
|
|
70
73
|
control?: IControlOption;
|
|
71
74
|
checkbox?: ICheckboxOption;
|
|
75
|
+
radio?: IRadioOption;
|
|
72
76
|
cursor?: ICursorOption;
|
|
73
77
|
title?: ITitleOption;
|
|
74
78
|
placeholder?: IPlaceholder;
|
|
@@ -76,6 +80,8 @@ export interface IEditorOption {
|
|
|
76
80
|
pageBreak?: IPageBreak;
|
|
77
81
|
zone?: IZoneOption;
|
|
78
82
|
background?: IBackgroundOption;
|
|
83
|
+
lineBreak?: ILineBreakOption;
|
|
84
|
+
separator?: ISeparatorOption;
|
|
79
85
|
}
|
|
80
86
|
export interface IEditorResult {
|
|
81
87
|
version: string;
|
|
@@ -8,7 +8,9 @@ import { TableBorder } from '../dataset/enum/table/Table';
|
|
|
8
8
|
import { IBlock } from './Block';
|
|
9
9
|
import { ICheckbox } from './Checkbox';
|
|
10
10
|
import { IControl } from './Control';
|
|
11
|
+
import { IRadio } from './Radio';
|
|
11
12
|
import { ITextDecoration } from './Text';
|
|
13
|
+
import { ITitle } from './Title';
|
|
12
14
|
import { IColgroup } from './table/Colgroup';
|
|
13
15
|
import { ITr } from './table/Tr';
|
|
14
16
|
export interface IElementBasic {
|
|
@@ -40,6 +42,7 @@ export interface ITitleElement {
|
|
|
40
42
|
valueList?: IElement[];
|
|
41
43
|
level?: TitleLevel;
|
|
42
44
|
titleId?: string;
|
|
45
|
+
title?: ITitle;
|
|
43
46
|
}
|
|
44
47
|
export interface IListElement {
|
|
45
48
|
valueList?: IElement[];
|
|
@@ -80,6 +83,9 @@ export interface IControlElement {
|
|
|
80
83
|
export interface ICheckboxElement {
|
|
81
84
|
checkbox?: ICheckbox;
|
|
82
85
|
}
|
|
86
|
+
export interface IRadioElement {
|
|
87
|
+
radio?: IRadio;
|
|
88
|
+
}
|
|
83
89
|
export interface ILaTexElement {
|
|
84
90
|
laTexSVG?: string;
|
|
85
91
|
}
|
|
@@ -97,7 +103,7 @@ export interface IImageElement {
|
|
|
97
103
|
export interface IBlockElement {
|
|
98
104
|
block?: IBlock;
|
|
99
105
|
}
|
|
100
|
-
export type IElement = IElementBasic & IElementStyle & IElementGroup & ITable & IHyperlinkElement & ISuperscriptSubscript & ISeparator & IControlElement & ICheckboxElement & ILaTexElement & IDateElement & IImageElement & IBlockElement & ITitleElement & IListElement;
|
|
106
|
+
export type IElement = IElementBasic & IElementStyle & IElementGroup & ITable & IHyperlinkElement & ISuperscriptSubscript & ISeparator & IControlElement & ICheckboxElement & IRadioElement & ILaTexElement & IDateElement & IImageElement & IBlockElement & ITitleElement & IListElement;
|
|
101
107
|
export interface IElementMetrics {
|
|
102
108
|
width: number;
|
|
103
109
|
height: number;
|
|
@@ -8,6 +8,7 @@ export interface ICurrentPosition {
|
|
|
8
8
|
x?: number;
|
|
9
9
|
y?: number;
|
|
10
10
|
isCheckbox?: boolean;
|
|
11
|
+
isRadio?: boolean;
|
|
11
12
|
isControl?: boolean;
|
|
12
13
|
isImage?: boolean;
|
|
13
14
|
isTable?: boolean;
|
|
@@ -37,6 +38,7 @@ export type IGetFloatPositionByXYPayload = IGetPositionByXYPayload & {
|
|
|
37
38
|
export interface IPositionContext {
|
|
38
39
|
isTable: boolean;
|
|
39
40
|
isCheckbox?: boolean;
|
|
41
|
+
isRadio?: boolean;
|
|
40
42
|
isControl?: boolean;
|
|
41
43
|
index?: number;
|
|
42
44
|
trIndex?: number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface IRadio {
|
|
2
|
+
value: boolean | null;
|
|
3
|
+
code?: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface IRadioOption {
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
gap?: number;
|
|
10
|
+
lineWidth?: number;
|
|
11
|
+
fillStyle?: string;
|
|
12
|
+
strokeStyle?: string;
|
|
13
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { EditorZone } from '../dataset/enum/Editor';
|
|
2
|
+
import { IElement } from './Element';
|
|
1
3
|
export interface ITitleSizeOption {
|
|
2
4
|
defaultFirstSize?: number;
|
|
3
5
|
defaultSecondSize?: number;
|
|
@@ -7,3 +9,14 @@ export interface ITitleSizeOption {
|
|
|
7
9
|
defaultSixthSize?: number;
|
|
8
10
|
}
|
|
9
11
|
export type ITitleOption = ITitleSizeOption & {};
|
|
12
|
+
export interface ITitle {
|
|
13
|
+
conceptId?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface IGetTitleValueOption {
|
|
16
|
+
conceptId: string;
|
|
17
|
+
}
|
|
18
|
+
export type IGetTitleValueResult = (ITitle & {
|
|
19
|
+
value: string | null;
|
|
20
|
+
elementList: IElement[];
|
|
21
|
+
zone: EditorZone;
|
|
22
|
+
})[];
|
|
@@ -9,3 +9,4 @@ export declare function getClipboardData(): IClipboardData | null;
|
|
|
9
9
|
export declare function removeClipboardData(): void;
|
|
10
10
|
export declare function writeClipboardItem(text: string, html: string, elementList: IElement[]): void;
|
|
11
11
|
export declare function writeElementList(elementList: IElement[], options: DeepRequired<IEditorOption>): void;
|
|
12
|
+
export declare function getIsClipboardContainFile(clipboardData: DataTransfer): boolean;
|