@hufe921/canvas-editor 0.9.137 → 1.0.0
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 +32 -0
- package/README.md +11 -8
- package/dist/assets/catalog-B-cbxN0s.js.map +1 -1
- package/dist/assets/value-B0aX9J3d.js.map +1 -0
- package/dist/assets/wordCount-BWZRHbSB.js.map +1 -0
- package/dist/canvas-editor.js +4886 -2258
- package/dist/canvas-editor.js.map +1 -1
- package/dist/canvas-editor.umd.cjs +41 -37
- package/dist/canvas-editor.umd.cjs.map +1 -1
- package/dist/src/editor/core/cascade/CascadeManager.d.ts +28 -0
- package/dist/src/editor/core/cascade/expression/evaluator.d.ts +14 -0
- package/dist/src/editor/core/cascade/expression/parser.d.ts +36 -0
- package/dist/src/editor/core/cascade/expression/tokenizer.d.ts +19 -0
- package/dist/src/editor/core/command/Command.d.ts +10 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +9 -1
- package/dist/src/editor/core/draw/Draw.d.ts +26 -0
- package/dist/src/editor/core/draw/control/Control.d.ts +3 -0
- package/dist/src/editor/core/draw/interactive/Search.d.ts +1 -0
- package/dist/src/editor/core/draw/particle/ListParticle.d.ts +10 -0
- package/dist/src/editor/core/draw/particle/TraceParticle.d.ts +40 -0
- package/dist/src/editor/core/draw/particle/table/TableOperate.d.ts +3 -0
- package/dist/src/editor/core/draw/particle/table/TablePaging.d.ts +13 -0
- package/dist/src/editor/core/draw/particle/table/TableParticle.d.ts +19 -2
- package/dist/src/editor/core/draw/particle/table/TableTool.d.ts +2 -0
- package/dist/src/editor/core/draw/ruler/Ruler.d.ts +43 -0
- package/dist/src/editor/core/macro/MacroManager.d.ts +25 -0
- package/dist/src/editor/core/position/Position.d.ts +8 -1
- package/dist/src/editor/core/validate/Validate.d.ts +19 -0
- package/dist/src/editor/dataset/constant/ContextMenu.d.ts +2 -0
- package/dist/src/editor/dataset/constant/Element.d.ts +1 -0
- package/dist/src/editor/dataset/constant/Ruler.d.ts +2 -0
- package/dist/src/editor/dataset/constant/Trace.d.ts +2 -0
- package/dist/src/editor/dataset/enum/Editor.d.ts +2 -1
- package/dist/src/editor/dataset/enum/Macro.d.ts +4 -0
- package/dist/src/editor/dataset/enum/Trace.d.ts +4 -0
- package/dist/src/editor/index.d.ts +4 -1
- package/dist/src/editor/interface/Compare.d.ts +5 -0
- package/dist/src/editor/interface/Control.d.ts +46 -0
- package/dist/src/editor/interface/Draw.d.ts +1 -0
- package/dist/src/editor/interface/Editor.d.ts +4 -1
- package/dist/src/editor/interface/Element.d.ts +23 -3
- package/dist/src/editor/interface/Macro.d.ts +19 -0
- package/dist/src/editor/interface/Row.d.ts +8 -1
- package/dist/src/editor/interface/Ruler.d.ts +4 -0
- package/dist/src/editor/interface/Trace.d.ts +11 -0
- package/dist/src/editor/interface/i18n/I18n.d.ts +4 -0
- package/dist/src/editor/interface/i18n/Trace.d.ts +7 -0
- package/dist/src/editor/interface/i18n/Validate.d.ts +15 -0
- package/dist/src/editor/utils/diff.d.ts +7 -0
- package/dist/src/editor/utils/element.d.ts +21 -2
- package/dist/src/editor/utils/table.d.ts +4 -0
- package/package.json +1 -1
- package/dist/assets/value-DeIsXod0.js.map +0 -1
- package/dist/assets/wordCount-Osi0e4qK.js.map +0 -1
|
@@ -56,6 +56,7 @@ export interface IControlRule {
|
|
|
56
56
|
disabled?: boolean;
|
|
57
57
|
pasteDisabled?: boolean;
|
|
58
58
|
hide?: boolean;
|
|
59
|
+
required?: boolean;
|
|
59
60
|
}
|
|
60
61
|
export interface IControlBasic {
|
|
61
62
|
type: ControlType;
|
|
@@ -73,6 +74,9 @@ export interface IControlBasic {
|
|
|
73
74
|
rowFlex?: RowFlex;
|
|
74
75
|
preText?: string;
|
|
75
76
|
postText?: string;
|
|
77
|
+
cascade?: IControlCascadeRule[];
|
|
78
|
+
validation?: IControlValidation;
|
|
79
|
+
compute?: string;
|
|
76
80
|
}
|
|
77
81
|
export interface IControlStyle {
|
|
78
82
|
font?: string;
|
|
@@ -94,6 +98,7 @@ export interface IControlOption {
|
|
|
94
98
|
disabledBackgroundColor?: string;
|
|
95
99
|
existValueBackgroundColor?: string;
|
|
96
100
|
noValueBackgroundColor?: string;
|
|
101
|
+
errorBackgroundColor?: string;
|
|
97
102
|
}
|
|
98
103
|
export interface IControlInitOption {
|
|
99
104
|
index: number;
|
|
@@ -196,3 +201,44 @@ export interface IRemoveControlOption {
|
|
|
196
201
|
id?: string;
|
|
197
202
|
conceptId?: string;
|
|
198
203
|
}
|
|
204
|
+
export type CascadeTargetType = 'control' | 'title';
|
|
205
|
+
export interface ICascadeAction {
|
|
206
|
+
controlId?: string;
|
|
207
|
+
conceptId?: string;
|
|
208
|
+
targetType?: CascadeTargetType;
|
|
209
|
+
effects: {
|
|
210
|
+
hide?: boolean;
|
|
211
|
+
required?: boolean;
|
|
212
|
+
disabled?: boolean;
|
|
213
|
+
deletable?: boolean;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
export interface IControlCascadeRule {
|
|
217
|
+
expression: string;
|
|
218
|
+
actions: ICascadeAction[];
|
|
219
|
+
elseActions?: ICascadeAction[];
|
|
220
|
+
}
|
|
221
|
+
export interface IControlValidation {
|
|
222
|
+
minLength?: number;
|
|
223
|
+
maxLength?: number;
|
|
224
|
+
pattern?: string;
|
|
225
|
+
min?: number;
|
|
226
|
+
max?: number;
|
|
227
|
+
integer?: boolean;
|
|
228
|
+
precision?: number;
|
|
229
|
+
minDate?: string;
|
|
230
|
+
maxDate?: string;
|
|
231
|
+
minChecked?: number;
|
|
232
|
+
maxChecked?: number;
|
|
233
|
+
message?: string;
|
|
234
|
+
}
|
|
235
|
+
export interface IValidateOption {
|
|
236
|
+
zone?: EditorZone;
|
|
237
|
+
errorBackgroundColor?: string;
|
|
238
|
+
}
|
|
239
|
+
export interface IControlValidateResult {
|
|
240
|
+
controlId: string;
|
|
241
|
+
conceptId?: string;
|
|
242
|
+
control: IControl;
|
|
243
|
+
errors: string[];
|
|
244
|
+
}
|
|
@@ -30,6 +30,8 @@ import { IGraffitiData, IGraffitiOption } from './Graffiti';
|
|
|
30
30
|
import { IWhiteSpaceOption } from './WhiteSpace';
|
|
31
31
|
import { IMagnifierOption } from './Magnifier';
|
|
32
32
|
import { IAccessibilityOption } from './Accessibility';
|
|
33
|
+
import { ITraceOption } from './Trace';
|
|
34
|
+
import { IRulerOption } from './Ruler';
|
|
33
35
|
export interface IEditorData {
|
|
34
36
|
header?: IElement[];
|
|
35
37
|
main: IElement[];
|
|
@@ -110,6 +112,8 @@ export interface IEditorOption {
|
|
|
110
112
|
magnifier?: IMagnifierOption;
|
|
111
113
|
accessibility?: IAccessibilityOption;
|
|
112
114
|
column?: IColumnOption;
|
|
115
|
+
trace?: ITraceOption;
|
|
116
|
+
ruler?: IRulerOption;
|
|
113
117
|
}
|
|
114
118
|
export interface IEditorResult {
|
|
115
119
|
version: string;
|
|
@@ -136,7 +140,6 @@ export interface IPrintModeRule {
|
|
|
136
140
|
imagePreviewerDisabled?: boolean;
|
|
137
141
|
backgroundDisabled?: boolean;
|
|
138
142
|
filterEmptyControl?: boolean;
|
|
139
|
-
filterHideElementRow?: boolean;
|
|
140
143
|
areaHideDisabled?: boolean;
|
|
141
144
|
}
|
|
142
145
|
export interface IReadonlyModeRule {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ImageDisplay } from '../dataset/enum/Common';
|
|
2
2
|
import { ControlComponent } from '../dataset/enum/Control';
|
|
3
3
|
import { ElementType } from '../dataset/enum/Element';
|
|
4
|
+
import { TraceType } from '../dataset/enum/Trace';
|
|
4
5
|
import { ListStyle, ListType } from '../dataset/enum/List';
|
|
5
6
|
import { RowFlex } from '../dataset/enum/Row';
|
|
6
7
|
import { TitleLevel } from '../dataset/enum/Title';
|
|
@@ -14,6 +15,7 @@ import { IRadio } from './Radio';
|
|
|
14
15
|
import { ITextDecoration } from './Text';
|
|
15
16
|
import { ITitle } from './Title';
|
|
16
17
|
import { IColgroup } from './table/Colgroup';
|
|
18
|
+
import { ITd } from './table/Td';
|
|
17
19
|
import { ITr } from './table/Tr';
|
|
18
20
|
export interface IElementBasic {
|
|
19
21
|
id?: string;
|
|
@@ -46,6 +48,14 @@ export interface IElementRule {
|
|
|
46
48
|
export interface IElementGroup {
|
|
47
49
|
groupIds?: string[];
|
|
48
50
|
}
|
|
51
|
+
export interface ITraceRecord {
|
|
52
|
+
type: TraceType;
|
|
53
|
+
author?: string;
|
|
54
|
+
timestamp?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface IElementTrace {
|
|
57
|
+
trace?: ITraceRecord[];
|
|
58
|
+
}
|
|
49
59
|
export interface ITitleElement {
|
|
50
60
|
valueList?: IElement[];
|
|
51
61
|
level?: TitleLevel;
|
|
@@ -58,6 +68,7 @@ export interface IListElement {
|
|
|
58
68
|
listStyle?: ListStyle;
|
|
59
69
|
listId?: string;
|
|
60
70
|
listWrap?: boolean;
|
|
71
|
+
listLevel?: number;
|
|
61
72
|
}
|
|
62
73
|
export interface ITableAttr {
|
|
63
74
|
colgroup?: IColgroup[];
|
|
@@ -76,8 +87,6 @@ export interface ITableElement {
|
|
|
76
87
|
trId?: string;
|
|
77
88
|
tableId?: string;
|
|
78
89
|
conceptId?: string;
|
|
79
|
-
pagingId?: string;
|
|
80
|
-
pagingIndex?: number;
|
|
81
90
|
}
|
|
82
91
|
export type ITable = ITableAttr & ITableRule & ITableElement;
|
|
83
92
|
export interface IHyperlinkElement {
|
|
@@ -166,7 +175,7 @@ export interface ILabelElement {
|
|
|
166
175
|
padding?: IPadding;
|
|
167
176
|
};
|
|
168
177
|
}
|
|
169
|
-
export type IElement = IElementBasic & IElementStyle & IElementRule & IElementGroup & ITable & IHyperlinkElement & ISuperscriptSubscript & ISeparator & IControlElement & ICheckboxElement & IRadioElement & ILaTexElement & IDateElement & IImageElement & IBlockElement & ITitleElement & IListElement & IAreaElement & ILabelElement;
|
|
178
|
+
export type IElement = IElementBasic & IElementStyle & IElementRule & IElementGroup & IElementTrace & ITable & IHyperlinkElement & ISuperscriptSubscript & ISeparator & IControlElement & ICheckboxElement & IRadioElement & ILaTexElement & IDateElement & IImageElement & IBlockElement & ITitleElement & IListElement & IAreaElement & ILabelElement;
|
|
170
179
|
export interface IElementMetrics {
|
|
171
180
|
width: number;
|
|
172
181
|
height: number;
|
|
@@ -186,6 +195,7 @@ export interface IElementPosition {
|
|
|
186
195
|
isFirstLetter: boolean;
|
|
187
196
|
isLastLetter: boolean;
|
|
188
197
|
columnIndex?: number;
|
|
198
|
+
tableFragment?: ITableRowFragment;
|
|
189
199
|
coordinate: {
|
|
190
200
|
leftTop: number[];
|
|
191
201
|
leftBottom: number[];
|
|
@@ -193,6 +203,16 @@ export interface IElementPosition {
|
|
|
193
203
|
rightBottom: number[];
|
|
194
204
|
};
|
|
195
205
|
}
|
|
206
|
+
export interface ITableRowFragment {
|
|
207
|
+
startTrIndex: number;
|
|
208
|
+
endTrIndex: number;
|
|
209
|
+
skipHeight: number;
|
|
210
|
+
repeatHeight: number;
|
|
211
|
+
repeatTrIndexes?: number[];
|
|
212
|
+
startSplitTrOffset?: number;
|
|
213
|
+
endSplitTrHeight?: number;
|
|
214
|
+
carriedTds?: ITd[];
|
|
215
|
+
}
|
|
196
216
|
export interface IElementFillRect {
|
|
197
217
|
x: number;
|
|
198
218
|
y: number;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MacroType } from '../dataset/enum/Macro';
|
|
2
|
+
export interface IMacroStep {
|
|
3
|
+
command: string;
|
|
4
|
+
args: unknown[];
|
|
5
|
+
}
|
|
6
|
+
export interface IRecordedMacro {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
type: MacroType.RECORDED;
|
|
10
|
+
steps: IMacroStep[];
|
|
11
|
+
}
|
|
12
|
+
export type IMacroHandler = (...args: unknown[]) => void | Promise<void>;
|
|
13
|
+
export interface IScriptMacro {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
type: MacroType.SCRIPT;
|
|
17
|
+
handler: IMacroHandler;
|
|
18
|
+
}
|
|
19
|
+
export type IMacro = IRecordedMacro | IScriptMacro;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RowFlex } from '../dataset/enum/Row';
|
|
2
|
-
import { IElement, IElementMetrics } from './Element';
|
|
2
|
+
import { IElement, IElementMetrics, IElementPosition, ITableRowFragment } from './Element';
|
|
3
|
+
import { ITd } from './table/Td';
|
|
3
4
|
export type IRowElement = IElement & {
|
|
4
5
|
metrics: IElementMetrics;
|
|
5
6
|
style: string;
|
|
@@ -21,4 +22,10 @@ export interface IRow {
|
|
|
21
22
|
rowIndex: number;
|
|
22
23
|
isSurround?: boolean;
|
|
23
24
|
columnIndex?: number;
|
|
25
|
+
tableFragment?: ITableRowFragment;
|
|
26
|
+
fragmentPosition?: IElementPosition;
|
|
27
|
+
repeatTdPositionList?: {
|
|
28
|
+
td: ITd;
|
|
29
|
+
positionList: IElementPosition[];
|
|
30
|
+
}[];
|
|
24
31
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ITraceOption {
|
|
2
|
+
disabled?: boolean;
|
|
3
|
+
insertColor?: string;
|
|
4
|
+
deleteColor?: string;
|
|
5
|
+
author?: string;
|
|
6
|
+
lineWidth?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface IMarkElementListDeletedOption {
|
|
9
|
+
isIgnoreDeletedRule?: boolean;
|
|
10
|
+
tdDeletable?: boolean;
|
|
11
|
+
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { IDatePickerLang } from '../../core/draw/particle/date/DatePicker';
|
|
2
2
|
import { IContextmenuLang } from '../contextmenu/ContextMenu';
|
|
3
3
|
import { IAccessibilityLang } from './Accessibility';
|
|
4
|
+
import { ITraceLang } from './Trace';
|
|
5
|
+
import { IValidateLang } from './Validate';
|
|
4
6
|
export interface ILang {
|
|
5
7
|
contextmenu: IContextmenuLang;
|
|
6
8
|
datePicker: IDatePickerLang;
|
|
7
9
|
accessibility: IAccessibilityLang;
|
|
10
|
+
trace: ITraceLang;
|
|
11
|
+
validate: IValidateLang;
|
|
8
12
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface IValidateLang {
|
|
2
|
+
required: string;
|
|
3
|
+
minLength: string;
|
|
4
|
+
maxLength: string;
|
|
5
|
+
pattern: string;
|
|
6
|
+
invalidNumber: string;
|
|
7
|
+
min: string;
|
|
8
|
+
max: string;
|
|
9
|
+
integer: string;
|
|
10
|
+
precision: string;
|
|
11
|
+
minDate: string;
|
|
12
|
+
maxDate: string;
|
|
13
|
+
minChecked: string;
|
|
14
|
+
maxChecked: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IElement } from '../interface/Element';
|
|
2
|
+
export interface IDiffOp {
|
|
3
|
+
type: 'equal' | 'insert' | 'delete';
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function diffText(oldText: string, newText: string): IDiffOp[];
|
|
7
|
+
export declare function compareElementList(oldList: IElement[], newList: IElement[]): IElement[];
|
|
@@ -3,6 +3,9 @@ import { RowFlex } from '../dataset/enum/Row';
|
|
|
3
3
|
import { DeepRequired } from '../interface/Common';
|
|
4
4
|
import { IEditorOption } from '../interface/Editor';
|
|
5
5
|
import { IElement } from '../interface/Element';
|
|
6
|
+
export declare function isElementTraceDeleted(element: IElement): boolean;
|
|
7
|
+
export declare function getNonDeletedElementList(elementList: IElement[]): IElement[];
|
|
8
|
+
export declare function getNonTraceElementList(elementList: IElement[]): IElement[];
|
|
6
9
|
export declare function unzipElementList(elementList: IElement[]): IElement[];
|
|
7
10
|
interface IFormatElementListOption {
|
|
8
11
|
isHandleFirstElement?: boolean;
|
|
@@ -19,6 +22,7 @@ interface IZipElementListOption {
|
|
|
19
22
|
extraPickAttrs?: Array<keyof IElement>;
|
|
20
23
|
isClassifyArea?: boolean;
|
|
21
24
|
isClone?: boolean;
|
|
25
|
+
isListValue?: boolean;
|
|
22
26
|
}
|
|
23
27
|
export declare function zipElementList(payload: IElement[], options?: IZipElementListOption): IElement[];
|
|
24
28
|
export declare function convertTextAlignToRowFlex(node: HTMLElement): RowFlex;
|
|
@@ -47,11 +51,26 @@ export interface IGetElementListByHTMLOption {
|
|
|
47
51
|
innerWidth: number;
|
|
48
52
|
}
|
|
49
53
|
export declare function getElementListByHTML(htmlText: string, options: IGetElementListByHTMLOption): IElement[];
|
|
50
|
-
export declare function getTextFromElementList(elementList: IElement[]
|
|
54
|
+
export declare function getTextFromElementList(elementList: IElement[], options?: {
|
|
55
|
+
isClone?: boolean;
|
|
56
|
+
}): string;
|
|
51
57
|
export declare function getSlimCloneElementList(elementList: IElement[]): IElement[];
|
|
52
58
|
export declare function getIsBlockElement(element?: IElement): boolean;
|
|
53
59
|
export declare function replaceHTMLElementTag(oldDom: HTMLElement, tagName: keyof HTMLElementTagNameMap): HTMLElement;
|
|
54
60
|
export declare function pickSurroundElementList(elementList: IElement[]): IElement[];
|
|
55
61
|
export declare function deleteSurroundElementList(elementList: IElement[], pageNo: number): void;
|
|
56
|
-
export declare function getNonHideElementIndex(elementList: IElement[], index: number, position?: LocationPosition): number;
|
|
62
|
+
export declare function getNonHideElementIndex(elementList: IElement[], index: number, position?: LocationPosition, isHidden?: (element: IElement) => boolean): number;
|
|
63
|
+
/**
|
|
64
|
+
* 嵌套感知的边界步进:从 index 按方向移动一位。
|
|
65
|
+
* 若落点 controlId 与 ownerId 相同,返回落点;
|
|
66
|
+
* 若落点 controlId 不同(进入了内层控件段),持续同向步进直到回到 ownerId 或越界。
|
|
67
|
+
* 用于替换边界扫描循环里的 i++ / i--。
|
|
68
|
+
*/
|
|
69
|
+
export declare function scanToOwner(elementList: IElement[], index: number, direction: 1 | -1, ownerId: string): number;
|
|
70
|
+
/**
|
|
71
|
+
* 查找位置所属的最外层控件 controlId。
|
|
72
|
+
* 通过向左扫找到当前控件的 PREFIX,递归检查 PREFIX 前一位是否仍在另一控件段内。
|
|
73
|
+
*/
|
|
74
|
+
export declare function getOutermostOwner(elementList: IElement[], index: number): string | null;
|
|
75
|
+
export declare function visitElementTree(elementList: IElement[], visitor: (element: IElement) => void): void;
|
|
57
76
|
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IColgroup } from '../interface/table/Colgroup';
|
|
2
|
+
export declare function getColgroupWidth(colgroup: IColgroup[]): number;
|
|
3
|
+
export declare function shrinkColgroupToWidth(colgroup: IColgroup[], maxWidth: number, minWidth: number): void;
|
|
4
|
+
export declare function scaleColgroupToWidth(colgroup: IColgroup[], targetWidth: number): void;
|
package/package.json
CHANGED