@leapfrog/interactive-canvas 2.0.15-beta-2 → 2.0.16
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/dist/abstract-interactive-canvas.d.ts +375 -375
- package/dist/dimensions/millimeter-dimensions.d.ts +15 -15
- package/dist/dimensions/pixel-canvas-dimensions.d.ts +13 -13
- package/dist/dimensions/print-6-col-canvas-dimensions.d.ts +18 -18
- package/dist/dimensions/print-8-col-canvas-dimensions.d.ts +18 -18
- package/dist/font/font-library.d.ts +27 -27
- package/dist/font/font-library.interface.d.ts +24 -24
- package/dist/font/font.interface.d.ts +20 -20
- package/dist/font/unknown-font.d.ts +6 -6
- package/dist/headless-interactive-canvas.d.ts +10 -10
- package/dist/index.d.ts +54 -54
- package/dist/interactive-canvas.d.ts +25 -25
- package/dist/interactive-canvas.es.js +3855 -3864
- package/dist/interactive-canvas.interface.d.ts +297 -297
- package/dist/interactive-canvas.js +3855 -3868
- package/dist/layout/abstract-layout-manager.d.ts +17 -17
- package/dist/layout/advanced-layout-manager.d.ts +16 -16
- package/dist/layout/function/pin-to-bottom.layout-function.d.ts +4 -4
- package/dist/layout/function/redraw-all.layout-function.d.ts +4 -4
- package/dist/layout/function/reposition-backgrounds.layout-function.d.ts +4 -4
- package/dist/layout/function/reposition-borders.layout-function.d.ts +4 -4
- package/dist/layout/function/reposition-cutoffs.layout-function.d.ts +4 -4
- package/dist/layout/function/resize-canvas.layout-function.d.ts +4 -4
- package/dist/layout/function/stack-objects.layout-function.d.ts +11 -11
- package/dist/layout/function/update-object-dimensions.layout-function.d.ts +4 -4
- package/dist/layout/layout-manager.enum.d.ts +5 -5
- package/dist/layout/layout-manager.interface.d.ts +13 -13
- package/dist/layout/standard-layout-manager.d.ts +40 -40
- package/dist/mutator/mutable-background-color.interface.d.ts +15 -15
- package/dist/mutator/mutable-color.interface.d.ts +6 -6
- package/dist/mutator/mutable-image.interface.d.ts +28 -28
- package/dist/mutator/mutable-position.interface.d.ts +63 -63
- package/dist/mutator/mutable-stroke.interface.d.ts +8 -8
- package/dist/mutator/mutable-text-style.interface.d.ts +163 -163
- package/dist/mutator/mutable-text.interface.d.ts +80 -80
- package/dist/object/abstract-canvas-object.d.ts +207 -207
- package/dist/object/canvas-object-data.d.ts +24 -24
- package/dist/object/canvas-object.interface.d.ts +109 -109
- package/dist/object/impl/background-image.d.ts +38 -38
- package/dist/object/impl/border.d.ts +70 -70
- package/dist/object/impl/cutoff.d.ts +59 -59
- package/dist/object/impl/extended-fabric-object.interface.d.ts +7 -7
- package/dist/object/impl/extended-fabric-textbox.interface.d.ts +7 -7
- package/dist/object/impl/horizontal-rule.d.ts +83 -83
- package/dist/object/impl/image.d.ts +76 -76
- package/dist/object/impl/rectangle.d.ts +78 -78
- package/dist/object/impl/rich-text.d.ts +39 -39
- package/dist/object/impl/text.d.ts +322 -322
- package/dist/object/impl/vertical-rule.d.ts +83 -83
- package/dist/profile/canvas-profile.interface.d.ts +22 -22
- package/dist/profile/default-canvas-profile.d.ts +23 -23
- package/dist/types/canvas-dimension-restrictions.interface.d.ts +15 -15
- package/dist/types/canvas-dimensions.interface.d.ts +21 -21
- package/dist/types/canvas-state.interface.d.ts +11 -11
- package/dist/types/dimension-restrictions.interface.d.ts +6 -6
- package/dist/types/image-type.enum.d.ts +6 -6
- package/dist/types/margin.interface.d.ts +6 -6
- package/dist/types/object-dimensions.interface.d.ts +23 -23
- package/dist/types/object-type.enum.d.ts +12 -12
- package/dist/types/overflow.interface.d.ts +4 -4
- package/dist/types/position.interface.d.ts +9 -9
- package/dist/types/rect.interface.d.ts +6 -6
- package/dist/types/selection-data.interface.d.ts +28 -28
- package/dist/types/text-alignment.interface.d.ts +1 -1
- package/dist/undo-stack.d.ts +27 -27
- package/dist/undo-stack.interface.d.ts +6 -6
- package/package.json +1 -1
|
@@ -1,375 +1,375 @@
|
|
|
1
|
-
import { BehaviorSubject, Observable, Subject } from "rxjs";
|
|
2
|
-
import { ICutoff } from "./object/impl/cutoff";
|
|
3
|
-
import { IRectangle } from "./object/impl/rectangle";
|
|
4
|
-
import { IBorder } from "./object/impl/border";
|
|
5
|
-
import { IImage } from "./object/impl/image";
|
|
6
|
-
import { IText } from "./object/impl/text";
|
|
7
|
-
import { ILayoutManager } from "./layout/layout-manager.interface";
|
|
8
|
-
import { LayoutManager } from "./layout/layout-manager.enum";
|
|
9
|
-
import { IVerticalRule } from "./object/impl/vertical-rule";
|
|
10
|
-
import { IHorizontalRule } from "./object/impl/horizontal-rule";
|
|
11
|
-
import { IInteractiveCanvas } from "./interactive-canvas.interface";
|
|
12
|
-
import { ICanvasProfile } from "./profile/canvas-profile.interface";
|
|
13
|
-
import { IFontLibrary } from "./font/font-library.interface";
|
|
14
|
-
import { ICanvasDimensions } from "./types/canvas-dimensions.interface";
|
|
15
|
-
import { ICanvasDimensionRestrictions } from "./types/canvas-dimension-restrictions.interface";
|
|
16
|
-
import { AbstractCanvasObject } from "./object/abstract-canvas-object";
|
|
17
|
-
import { IRect } from "./types/rect.interface";
|
|
18
|
-
import { ObjectType } from "./types/object-type.enum";
|
|
19
|
-
import { ICanvasObject } from "./object/canvas-object.interface";
|
|
20
|
-
import { ISelectionData } from "./types/selection-data.interface";
|
|
21
|
-
import { ICanvasState } from "./types/canvas-state.interface";
|
|
22
|
-
import { ITextSelection } from "./mutator/mutable-text-style.interface";
|
|
23
|
-
import { fabric } from "fabric";
|
|
24
|
-
import { IRichText } from "./object/impl/rich-text";
|
|
25
|
-
import { IBackgroundImage } from "./object/impl/background-image";
|
|
26
|
-
import { IEvent } from "fabric/fabric-impl";
|
|
27
|
-
export declare abstract class AbstractInteractiveCanvas implements IInteractiveCanvas {
|
|
28
|
-
fabric: any;
|
|
29
|
-
protected readonly fabricCanvas: fabric.Canvas;
|
|
30
|
-
protected devicePixelRatio: number;
|
|
31
|
-
protected readonly IMAGE_CAPTURE_COEFFICIENT: number;
|
|
32
|
-
abstract readonly headless: boolean;
|
|
33
|
-
protected readonly fontLibrary: IFontLibrary;
|
|
34
|
-
protected readonly profile$: BehaviorSubject<ICanvasProfile>;
|
|
35
|
-
protected readonly layoutManager$: BehaviorSubject<ILayoutManager>;
|
|
36
|
-
protected readonly backgroundColor$: BehaviorSubject<string>;
|
|
37
|
-
protected readonly dimensions$: BehaviorSubject<ICanvasDimensions>;
|
|
38
|
-
protected readonly dimensionRestrictions$: BehaviorSubject<ICanvasDimensionRestrictions>;
|
|
39
|
-
protected readonly dimensionChangeRejections$: Subject<ICanvasDimensions>;
|
|
40
|
-
protected readonly zoom$: BehaviorSubject<number>;
|
|
41
|
-
protected readonly objects$: BehaviorSubject<Array<AbstractCanvasObject<any>>>;
|
|
42
|
-
protected readonly selection$: BehaviorSubject<SelectionData>;
|
|
43
|
-
protected baseDimensions: ICanvasDimensions;
|
|
44
|
-
protected constructor(fabric: any, fabricCanvas: fabric.Canvas, devicePixelRatio: number);
|
|
45
|
-
/**
|
|
46
|
-
* @override
|
|
47
|
-
* @inheritDoc
|
|
48
|
-
*/
|
|
49
|
-
getFontLibrary(): IFontLibrary;
|
|
50
|
-
/**
|
|
51
|
-
* @override
|
|
52
|
-
* @inheritDoc
|
|
53
|
-
*/
|
|
54
|
-
getProfile(): ICanvasProfile;
|
|
55
|
-
/**
|
|
56
|
-
* @override
|
|
57
|
-
* @inheritDoc
|
|
58
|
-
*/
|
|
59
|
-
getProfile$(): Observable<ICanvasProfile>;
|
|
60
|
-
/**
|
|
61
|
-
* @override
|
|
62
|
-
* @inheritDoc
|
|
63
|
-
*/
|
|
64
|
-
setProfile(profile: ICanvasProfile): void;
|
|
65
|
-
/**
|
|
66
|
-
* @override
|
|
67
|
-
* @inheritDoc
|
|
68
|
-
*/
|
|
69
|
-
getLayoutManager(): ILayoutManager;
|
|
70
|
-
/**
|
|
71
|
-
* @override
|
|
72
|
-
* @inheritDoc
|
|
73
|
-
*/
|
|
74
|
-
getLayoutManager$(): Observable<ILayoutManager>;
|
|
75
|
-
/**
|
|
76
|
-
* @override
|
|
77
|
-
* @inheritDoc
|
|
78
|
-
*/
|
|
79
|
-
setLayoutManager(layoutManager: LayoutManager): void;
|
|
80
|
-
/**
|
|
81
|
-
* @override
|
|
82
|
-
* @inheritDoc
|
|
83
|
-
*/
|
|
84
|
-
getBackgroundColor(): string;
|
|
85
|
-
/**
|
|
86
|
-
* @override
|
|
87
|
-
* @inheritDoc
|
|
88
|
-
*/
|
|
89
|
-
getBackgroundColor$(): Observable<string>;
|
|
90
|
-
/**
|
|
91
|
-
* @override
|
|
92
|
-
* @inheritDoc
|
|
93
|
-
*/
|
|
94
|
-
setBackgroundColor(color?: string): void;
|
|
95
|
-
/**
|
|
96
|
-
* @override
|
|
97
|
-
* @inheritDoc
|
|
98
|
-
*/
|
|
99
|
-
getDimensions(): ICanvasDimensions;
|
|
100
|
-
/**
|
|
101
|
-
* @override
|
|
102
|
-
* @inheritDoc
|
|
103
|
-
*/
|
|
104
|
-
getBaseDimensions(): ICanvasDimensions;
|
|
105
|
-
/**
|
|
106
|
-
* @override
|
|
107
|
-
* @inheritDoc
|
|
108
|
-
*/
|
|
109
|
-
getDimensions$(): Observable<ICanvasDimensions>;
|
|
110
|
-
/**
|
|
111
|
-
* @override
|
|
112
|
-
* @inheritDoc
|
|
113
|
-
*/
|
|
114
|
-
setDimensions(dimensions: ICanvasDimensions): void;
|
|
115
|
-
/**
|
|
116
|
-
* @override
|
|
117
|
-
* @inheritDoc
|
|
118
|
-
*/
|
|
119
|
-
setBaseDimensions(dimensions: ICanvasDimensions): void;
|
|
120
|
-
/**
|
|
121
|
-
* @override
|
|
122
|
-
* @inheritDoc
|
|
123
|
-
*/
|
|
124
|
-
getDimensionChangeRejections$(): Observable<ICanvasDimensions>;
|
|
125
|
-
/**
|
|
126
|
-
* @override
|
|
127
|
-
* @inheritDoc
|
|
128
|
-
*/
|
|
129
|
-
getDimensionsRestrictions(): ICanvasDimensionRestrictions;
|
|
130
|
-
/**
|
|
131
|
-
* @override
|
|
132
|
-
* @inheritDoc
|
|
133
|
-
*/
|
|
134
|
-
getDimensionsRestrictions$(): Observable<ICanvasDimensionRestrictions>;
|
|
135
|
-
/**
|
|
136
|
-
* @override
|
|
137
|
-
* @inheritDoc
|
|
138
|
-
*/
|
|
139
|
-
setDimensionRestrictions(restrictions: ICanvasDimensionRestrictions): void;
|
|
140
|
-
getMargin(): IRect;
|
|
141
|
-
/**
|
|
142
|
-
* @override
|
|
143
|
-
* @inheritDoc
|
|
144
|
-
*/
|
|
145
|
-
getZoom(): number;
|
|
146
|
-
/**
|
|
147
|
-
* @override
|
|
148
|
-
* @inheritDoc
|
|
149
|
-
*/
|
|
150
|
-
getZoom$(): Observable<number>;
|
|
151
|
-
/**
|
|
152
|
-
* @override
|
|
153
|
-
* @inheritDoc
|
|
154
|
-
*/
|
|
155
|
-
setZoom(zoom: number): void;
|
|
156
|
-
/**
|
|
157
|
-
* @override
|
|
158
|
-
* @inheritDoc
|
|
159
|
-
*/
|
|
160
|
-
getObjects(): ICanvasObject[];
|
|
161
|
-
/**
|
|
162
|
-
* Get the list of objects directly.
|
|
163
|
-
*/
|
|
164
|
-
getObjectsInternal(): Array<AbstractCanvasObject<any>>;
|
|
165
|
-
/**
|
|
166
|
-
* @override
|
|
167
|
-
* @inheritDoc
|
|
168
|
-
*/
|
|
169
|
-
getObjectsByTypeInternal<T extends AbstractCanvasObject<any>>(type: ObjectType): T[];
|
|
170
|
-
/**
|
|
171
|
-
* @override
|
|
172
|
-
* @inheritDoc
|
|
173
|
-
*/
|
|
174
|
-
getObjectsByTypesInternal(...types: ObjectType[]): Array<AbstractCanvasObject<any>>;
|
|
175
|
-
/**
|
|
176
|
-
* @override
|
|
177
|
-
* @inheritDoc
|
|
178
|
-
*/
|
|
179
|
-
getObjects$(): Observable<ICanvasObject[]>;
|
|
180
|
-
/**
|
|
181
|
-
* @override
|
|
182
|
-
* @inheritDoc
|
|
183
|
-
*/
|
|
184
|
-
removeObject(target: ICanvasObject): void;
|
|
185
|
-
/**
|
|
186
|
-
* @override
|
|
187
|
-
* @inheritDoc
|
|
188
|
-
*/
|
|
189
|
-
addImageObject(imageUrl: string): Promise<IImage>;
|
|
190
|
-
/**
|
|
191
|
-
* @override
|
|
192
|
-
* @inheritDoc
|
|
193
|
-
*/
|
|
194
|
-
addTextObject(): Promise<IText>;
|
|
195
|
-
/**
|
|
196
|
-
* @override
|
|
197
|
-
* @inheritDoc
|
|
198
|
-
*/
|
|
199
|
-
addRichTextObject(imageUrl: string, htmlContent: string): Promise<IRichText>;
|
|
200
|
-
/**
|
|
201
|
-
* @override
|
|
202
|
-
* @inheritDoc
|
|
203
|
-
*/
|
|
204
|
-
addRectangleObject(): Promise<IRectangle>;
|
|
205
|
-
/**
|
|
206
|
-
* @override
|
|
207
|
-
* @inheritDoc
|
|
208
|
-
*/
|
|
209
|
-
addCutoffObject(): Promise<ICutoff>;
|
|
210
|
-
/**
|
|
211
|
-
* @override
|
|
212
|
-
* @inheritDoc
|
|
213
|
-
*/
|
|
214
|
-
addBorderObject(): Promise<IBorder>;
|
|
215
|
-
/**
|
|
216
|
-
* @override
|
|
217
|
-
* @inheritDoc
|
|
218
|
-
*/
|
|
219
|
-
addVerticalRuleObject(): Promise<IVerticalRule>;
|
|
220
|
-
/**
|
|
221
|
-
* @override
|
|
222
|
-
* @inheritDoc
|
|
223
|
-
*/
|
|
224
|
-
addHorizontalRuleObject(): Promise<IHorizontalRule>;
|
|
225
|
-
/**
|
|
226
|
-
* @override
|
|
227
|
-
* @inheritDoc
|
|
228
|
-
*/
|
|
229
|
-
addBackgroundImageObject(imageUrl: string): Promise<IBackgroundImage>;
|
|
230
|
-
/**
|
|
231
|
-
* @override
|
|
232
|
-
* @inheritDoc
|
|
233
|
-
*/
|
|
234
|
-
setPrefillData(data: {
|
|
235
|
-
[id: string]: string;
|
|
236
|
-
}): void;
|
|
237
|
-
/**
|
|
238
|
-
* @override
|
|
239
|
-
* @inheritDoc
|
|
240
|
-
*/
|
|
241
|
-
distributeObjectsVertically(): void;
|
|
242
|
-
/**
|
|
243
|
-
* @override
|
|
244
|
-
* @inheritDoc
|
|
245
|
-
*/
|
|
246
|
-
getSelection(): ISelectionData;
|
|
247
|
-
/**
|
|
248
|
-
* @override
|
|
249
|
-
* @inheritDoc
|
|
250
|
-
*/
|
|
251
|
-
getSelection$(): Observable<ISelectionData>;
|
|
252
|
-
/**
|
|
253
|
-
* @override
|
|
254
|
-
* @inheritDoc
|
|
255
|
-
*/
|
|
256
|
-
select(object: ICanvasObject): void;
|
|
257
|
-
/**
|
|
258
|
-
* @override
|
|
259
|
-
* @inheritDoc
|
|
260
|
-
*/
|
|
261
|
-
clearSelection(): void;
|
|
262
|
-
setMultiSelect(value: boolean): void;
|
|
263
|
-
/**
|
|
264
|
-
* @override
|
|
265
|
-
* @inheritDoc
|
|
266
|
-
*/
|
|
267
|
-
clear(): void;
|
|
268
|
-
/**
|
|
269
|
-
* @override
|
|
270
|
-
* @inheritDoc
|
|
271
|
-
*/
|
|
272
|
-
save(): ICanvasState;
|
|
273
|
-
/**
|
|
274
|
-
* @override
|
|
275
|
-
* @inheritDoc
|
|
276
|
-
*/
|
|
277
|
-
load(canvasState: ICanvasState): Promise<void>;
|
|
278
|
-
/**
|
|
279
|
-
* Another hack for bullet points... because they use canvas objects to render the bullets, they get saved when the canvas is persisted... and then loaded into a new canvas, but there's
|
|
280
|
-
* nothing linking them to the field that needs bullets, so they end up duplicating every time the canvas is saved/loaded. Since we don't use circles for anything else, this just
|
|
281
|
-
* deletes all circles on canvas load.
|
|
282
|
-
*/
|
|
283
|
-
private removePersistedBullets;
|
|
284
|
-
/**
|
|
285
|
-
* Remove any slave objects persisted to the canvas; their master objects will recreate them.
|
|
286
|
-
*/
|
|
287
|
-
private removeSlaveObjects;
|
|
288
|
-
/**
|
|
289
|
-
* @override
|
|
290
|
-
* @inheritDoc
|
|
291
|
-
*/
|
|
292
|
-
toSvg(): string;
|
|
293
|
-
/**
|
|
294
|
-
* @override
|
|
295
|
-
* @inheritDoc
|
|
296
|
-
*/
|
|
297
|
-
toImage(multiplier?: number): string;
|
|
298
|
-
/**
|
|
299
|
-
* @override
|
|
300
|
-
* @inheritDoc
|
|
301
|
-
*/
|
|
302
|
-
createPNGStream(): any;
|
|
303
|
-
/**
|
|
304
|
-
* @override
|
|
305
|
-
* @inheritDoc
|
|
306
|
-
*/
|
|
307
|
-
registerUndoState(): void;
|
|
308
|
-
/**
|
|
309
|
-
* @override
|
|
310
|
-
* @inheritDoc
|
|
311
|
-
*/
|
|
312
|
-
undo(): Promise<void>;
|
|
313
|
-
/**
|
|
314
|
-
* @override
|
|
315
|
-
* @inheritDoc
|
|
316
|
-
*/
|
|
317
|
-
redo(): Promise<void>;
|
|
318
|
-
/**
|
|
319
|
-
* Redraw the canvas.
|
|
320
|
-
*/
|
|
321
|
-
redraw(): void;
|
|
322
|
-
syncObjectList(): void;
|
|
323
|
-
/**
|
|
324
|
-
* @override
|
|
325
|
-
* @inheritDoc
|
|
326
|
-
*/
|
|
327
|
-
notifyObjectListChanged(): void;
|
|
328
|
-
/**
|
|
329
|
-
* @override
|
|
330
|
-
* @inheritDoc
|
|
331
|
-
*/
|
|
332
|
-
notifyTextChanged(): void;
|
|
333
|
-
/**
|
|
334
|
-
* @override
|
|
335
|
-
* @inheritDoc
|
|
336
|
-
*/
|
|
337
|
-
notifyMarginChanged(): void;
|
|
338
|
-
removeFabricObject(obj: any): void;
|
|
339
|
-
protected selectFabricObject(object: fabric.Object): void;
|
|
340
|
-
protected onTextChange(): void;
|
|
341
|
-
protected onObjectListChange(): void;
|
|
342
|
-
protected onDimensionsChange(): void;
|
|
343
|
-
protected onMarginChange(): void;
|
|
344
|
-
private bindFields;
|
|
345
|
-
private bindField;
|
|
346
|
-
private findFabricObject;
|
|
347
|
-
private findObject;
|
|
348
|
-
/**
|
|
349
|
-
* Reset zoom and canvas dimensions to 1:1 scale, execute a function, then return the canvas to
|
|
350
|
-
* the previous values.
|
|
351
|
-
* @param func Function to execute.
|
|
352
|
-
*/
|
|
353
|
-
private executeWithNormalizedCanvas;
|
|
354
|
-
/**
|
|
355
|
-
* Update the actual dimensions of the canvas by multiplying the requested dimensions by the current zoom factor.
|
|
356
|
-
*/
|
|
357
|
-
private updateCanvasDimensions;
|
|
358
|
-
protected onProfileChanged(profile: ICanvasProfile): void;
|
|
359
|
-
protected getFieldByCanvasObject?(object: any): AbstractCanvasObject<any> | null;
|
|
360
|
-
protected getFieldsByCanvasObject(objects: any[]): Array<AbstractCanvasObject<any>>;
|
|
361
|
-
private calculateImageCaptureCoefficient;
|
|
362
|
-
private randomId;
|
|
363
|
-
private getLowestTextPoint;
|
|
364
|
-
private trackNewObject;
|
|
365
|
-
private dimensionsExceedRestrictions;
|
|
366
|
-
}
|
|
367
|
-
export declare class SelectionData implements ISelectionData {
|
|
368
|
-
readonly empty: boolean;
|
|
369
|
-
readonly objects: Array<AbstractCanvasObject<any>>;
|
|
370
|
-
readonly isText: boolean;
|
|
371
|
-
readonly textSelection: ITextSelection | null;
|
|
372
|
-
event: IEvent<MouseEvent>;
|
|
373
|
-
constructor(objects: Array<AbstractCanvasObject<any>>);
|
|
374
|
-
setEvent(event: IEvent<MouseEvent>): void;
|
|
375
|
-
}
|
|
1
|
+
import { BehaviorSubject, Observable, Subject } from "rxjs";
|
|
2
|
+
import { ICutoff } from "./object/impl/cutoff";
|
|
3
|
+
import { IRectangle } from "./object/impl/rectangle";
|
|
4
|
+
import { IBorder } from "./object/impl/border";
|
|
5
|
+
import { IImage } from "./object/impl/image";
|
|
6
|
+
import { IText } from "./object/impl/text";
|
|
7
|
+
import { ILayoutManager } from "./layout/layout-manager.interface";
|
|
8
|
+
import { LayoutManager } from "./layout/layout-manager.enum";
|
|
9
|
+
import { IVerticalRule } from "./object/impl/vertical-rule";
|
|
10
|
+
import { IHorizontalRule } from "./object/impl/horizontal-rule";
|
|
11
|
+
import { IInteractiveCanvas } from "./interactive-canvas.interface";
|
|
12
|
+
import { ICanvasProfile } from "./profile/canvas-profile.interface";
|
|
13
|
+
import { IFontLibrary } from "./font/font-library.interface";
|
|
14
|
+
import { ICanvasDimensions } from "./types/canvas-dimensions.interface";
|
|
15
|
+
import { ICanvasDimensionRestrictions } from "./types/canvas-dimension-restrictions.interface";
|
|
16
|
+
import { AbstractCanvasObject } from "./object/abstract-canvas-object";
|
|
17
|
+
import { IRect } from "./types/rect.interface";
|
|
18
|
+
import { ObjectType } from "./types/object-type.enum";
|
|
19
|
+
import { ICanvasObject } from "./object/canvas-object.interface";
|
|
20
|
+
import { ISelectionData } from "./types/selection-data.interface";
|
|
21
|
+
import { ICanvasState } from "./types/canvas-state.interface";
|
|
22
|
+
import { ITextSelection } from "./mutator/mutable-text-style.interface";
|
|
23
|
+
import { fabric } from "fabric";
|
|
24
|
+
import { IRichText } from "./object/impl/rich-text";
|
|
25
|
+
import { IBackgroundImage } from "./object/impl/background-image";
|
|
26
|
+
import { IEvent } from "fabric/fabric-impl";
|
|
27
|
+
export declare abstract class AbstractInteractiveCanvas implements IInteractiveCanvas {
|
|
28
|
+
fabric: any;
|
|
29
|
+
protected readonly fabricCanvas: fabric.Canvas;
|
|
30
|
+
protected devicePixelRatio: number;
|
|
31
|
+
protected readonly IMAGE_CAPTURE_COEFFICIENT: number;
|
|
32
|
+
abstract readonly headless: boolean;
|
|
33
|
+
protected readonly fontLibrary: IFontLibrary;
|
|
34
|
+
protected readonly profile$: BehaviorSubject<ICanvasProfile>;
|
|
35
|
+
protected readonly layoutManager$: BehaviorSubject<ILayoutManager>;
|
|
36
|
+
protected readonly backgroundColor$: BehaviorSubject<string>;
|
|
37
|
+
protected readonly dimensions$: BehaviorSubject<ICanvasDimensions>;
|
|
38
|
+
protected readonly dimensionRestrictions$: BehaviorSubject<ICanvasDimensionRestrictions>;
|
|
39
|
+
protected readonly dimensionChangeRejections$: Subject<ICanvasDimensions>;
|
|
40
|
+
protected readonly zoom$: BehaviorSubject<number>;
|
|
41
|
+
protected readonly objects$: BehaviorSubject<Array<AbstractCanvasObject<any>>>;
|
|
42
|
+
protected readonly selection$: BehaviorSubject<SelectionData>;
|
|
43
|
+
protected baseDimensions: ICanvasDimensions;
|
|
44
|
+
protected constructor(fabric: any, fabricCanvas: fabric.Canvas, devicePixelRatio: number);
|
|
45
|
+
/**
|
|
46
|
+
* @override
|
|
47
|
+
* @inheritDoc
|
|
48
|
+
*/
|
|
49
|
+
getFontLibrary(): IFontLibrary;
|
|
50
|
+
/**
|
|
51
|
+
* @override
|
|
52
|
+
* @inheritDoc
|
|
53
|
+
*/
|
|
54
|
+
getProfile(): ICanvasProfile;
|
|
55
|
+
/**
|
|
56
|
+
* @override
|
|
57
|
+
* @inheritDoc
|
|
58
|
+
*/
|
|
59
|
+
getProfile$(): Observable<ICanvasProfile>;
|
|
60
|
+
/**
|
|
61
|
+
* @override
|
|
62
|
+
* @inheritDoc
|
|
63
|
+
*/
|
|
64
|
+
setProfile(profile: ICanvasProfile): void;
|
|
65
|
+
/**
|
|
66
|
+
* @override
|
|
67
|
+
* @inheritDoc
|
|
68
|
+
*/
|
|
69
|
+
getLayoutManager(): ILayoutManager;
|
|
70
|
+
/**
|
|
71
|
+
* @override
|
|
72
|
+
* @inheritDoc
|
|
73
|
+
*/
|
|
74
|
+
getLayoutManager$(): Observable<ILayoutManager>;
|
|
75
|
+
/**
|
|
76
|
+
* @override
|
|
77
|
+
* @inheritDoc
|
|
78
|
+
*/
|
|
79
|
+
setLayoutManager(layoutManager: LayoutManager): void;
|
|
80
|
+
/**
|
|
81
|
+
* @override
|
|
82
|
+
* @inheritDoc
|
|
83
|
+
*/
|
|
84
|
+
getBackgroundColor(): string;
|
|
85
|
+
/**
|
|
86
|
+
* @override
|
|
87
|
+
* @inheritDoc
|
|
88
|
+
*/
|
|
89
|
+
getBackgroundColor$(): Observable<string>;
|
|
90
|
+
/**
|
|
91
|
+
* @override
|
|
92
|
+
* @inheritDoc
|
|
93
|
+
*/
|
|
94
|
+
setBackgroundColor(color?: string): void;
|
|
95
|
+
/**
|
|
96
|
+
* @override
|
|
97
|
+
* @inheritDoc
|
|
98
|
+
*/
|
|
99
|
+
getDimensions(): ICanvasDimensions;
|
|
100
|
+
/**
|
|
101
|
+
* @override
|
|
102
|
+
* @inheritDoc
|
|
103
|
+
*/
|
|
104
|
+
getBaseDimensions(): ICanvasDimensions;
|
|
105
|
+
/**
|
|
106
|
+
* @override
|
|
107
|
+
* @inheritDoc
|
|
108
|
+
*/
|
|
109
|
+
getDimensions$(): Observable<ICanvasDimensions>;
|
|
110
|
+
/**
|
|
111
|
+
* @override
|
|
112
|
+
* @inheritDoc
|
|
113
|
+
*/
|
|
114
|
+
setDimensions(dimensions: ICanvasDimensions): void;
|
|
115
|
+
/**
|
|
116
|
+
* @override
|
|
117
|
+
* @inheritDoc
|
|
118
|
+
*/
|
|
119
|
+
setBaseDimensions(dimensions: ICanvasDimensions): void;
|
|
120
|
+
/**
|
|
121
|
+
* @override
|
|
122
|
+
* @inheritDoc
|
|
123
|
+
*/
|
|
124
|
+
getDimensionChangeRejections$(): Observable<ICanvasDimensions>;
|
|
125
|
+
/**
|
|
126
|
+
* @override
|
|
127
|
+
* @inheritDoc
|
|
128
|
+
*/
|
|
129
|
+
getDimensionsRestrictions(): ICanvasDimensionRestrictions;
|
|
130
|
+
/**
|
|
131
|
+
* @override
|
|
132
|
+
* @inheritDoc
|
|
133
|
+
*/
|
|
134
|
+
getDimensionsRestrictions$(): Observable<ICanvasDimensionRestrictions>;
|
|
135
|
+
/**
|
|
136
|
+
* @override
|
|
137
|
+
* @inheritDoc
|
|
138
|
+
*/
|
|
139
|
+
setDimensionRestrictions(restrictions: ICanvasDimensionRestrictions): void;
|
|
140
|
+
getMargin(): IRect;
|
|
141
|
+
/**
|
|
142
|
+
* @override
|
|
143
|
+
* @inheritDoc
|
|
144
|
+
*/
|
|
145
|
+
getZoom(): number;
|
|
146
|
+
/**
|
|
147
|
+
* @override
|
|
148
|
+
* @inheritDoc
|
|
149
|
+
*/
|
|
150
|
+
getZoom$(): Observable<number>;
|
|
151
|
+
/**
|
|
152
|
+
* @override
|
|
153
|
+
* @inheritDoc
|
|
154
|
+
*/
|
|
155
|
+
setZoom(zoom: number): void;
|
|
156
|
+
/**
|
|
157
|
+
* @override
|
|
158
|
+
* @inheritDoc
|
|
159
|
+
*/
|
|
160
|
+
getObjects(): ICanvasObject[];
|
|
161
|
+
/**
|
|
162
|
+
* Get the list of objects directly.
|
|
163
|
+
*/
|
|
164
|
+
getObjectsInternal(): Array<AbstractCanvasObject<any>>;
|
|
165
|
+
/**
|
|
166
|
+
* @override
|
|
167
|
+
* @inheritDoc
|
|
168
|
+
*/
|
|
169
|
+
getObjectsByTypeInternal<T extends AbstractCanvasObject<any>>(type: ObjectType): T[];
|
|
170
|
+
/**
|
|
171
|
+
* @override
|
|
172
|
+
* @inheritDoc
|
|
173
|
+
*/
|
|
174
|
+
getObjectsByTypesInternal(...types: ObjectType[]): Array<AbstractCanvasObject<any>>;
|
|
175
|
+
/**
|
|
176
|
+
* @override
|
|
177
|
+
* @inheritDoc
|
|
178
|
+
*/
|
|
179
|
+
getObjects$(): Observable<ICanvasObject[]>;
|
|
180
|
+
/**
|
|
181
|
+
* @override
|
|
182
|
+
* @inheritDoc
|
|
183
|
+
*/
|
|
184
|
+
removeObject(target: ICanvasObject): void;
|
|
185
|
+
/**
|
|
186
|
+
* @override
|
|
187
|
+
* @inheritDoc
|
|
188
|
+
*/
|
|
189
|
+
addImageObject(imageUrl: string): Promise<IImage>;
|
|
190
|
+
/**
|
|
191
|
+
* @override
|
|
192
|
+
* @inheritDoc
|
|
193
|
+
*/
|
|
194
|
+
addTextObject(): Promise<IText>;
|
|
195
|
+
/**
|
|
196
|
+
* @override
|
|
197
|
+
* @inheritDoc
|
|
198
|
+
*/
|
|
199
|
+
addRichTextObject(imageUrl: string, htmlContent: string): Promise<IRichText>;
|
|
200
|
+
/**
|
|
201
|
+
* @override
|
|
202
|
+
* @inheritDoc
|
|
203
|
+
*/
|
|
204
|
+
addRectangleObject(): Promise<IRectangle>;
|
|
205
|
+
/**
|
|
206
|
+
* @override
|
|
207
|
+
* @inheritDoc
|
|
208
|
+
*/
|
|
209
|
+
addCutoffObject(): Promise<ICutoff>;
|
|
210
|
+
/**
|
|
211
|
+
* @override
|
|
212
|
+
* @inheritDoc
|
|
213
|
+
*/
|
|
214
|
+
addBorderObject(): Promise<IBorder>;
|
|
215
|
+
/**
|
|
216
|
+
* @override
|
|
217
|
+
* @inheritDoc
|
|
218
|
+
*/
|
|
219
|
+
addVerticalRuleObject(): Promise<IVerticalRule>;
|
|
220
|
+
/**
|
|
221
|
+
* @override
|
|
222
|
+
* @inheritDoc
|
|
223
|
+
*/
|
|
224
|
+
addHorizontalRuleObject(): Promise<IHorizontalRule>;
|
|
225
|
+
/**
|
|
226
|
+
* @override
|
|
227
|
+
* @inheritDoc
|
|
228
|
+
*/
|
|
229
|
+
addBackgroundImageObject(imageUrl: string): Promise<IBackgroundImage>;
|
|
230
|
+
/**
|
|
231
|
+
* @override
|
|
232
|
+
* @inheritDoc
|
|
233
|
+
*/
|
|
234
|
+
setPrefillData(data: {
|
|
235
|
+
[id: string]: string;
|
|
236
|
+
}): void;
|
|
237
|
+
/**
|
|
238
|
+
* @override
|
|
239
|
+
* @inheritDoc
|
|
240
|
+
*/
|
|
241
|
+
distributeObjectsVertically(): void;
|
|
242
|
+
/**
|
|
243
|
+
* @override
|
|
244
|
+
* @inheritDoc
|
|
245
|
+
*/
|
|
246
|
+
getSelection(): ISelectionData;
|
|
247
|
+
/**
|
|
248
|
+
* @override
|
|
249
|
+
* @inheritDoc
|
|
250
|
+
*/
|
|
251
|
+
getSelection$(): Observable<ISelectionData>;
|
|
252
|
+
/**
|
|
253
|
+
* @override
|
|
254
|
+
* @inheritDoc
|
|
255
|
+
*/
|
|
256
|
+
select(object: ICanvasObject): void;
|
|
257
|
+
/**
|
|
258
|
+
* @override
|
|
259
|
+
* @inheritDoc
|
|
260
|
+
*/
|
|
261
|
+
clearSelection(): void;
|
|
262
|
+
setMultiSelect(value: boolean): void;
|
|
263
|
+
/**
|
|
264
|
+
* @override
|
|
265
|
+
* @inheritDoc
|
|
266
|
+
*/
|
|
267
|
+
clear(): void;
|
|
268
|
+
/**
|
|
269
|
+
* @override
|
|
270
|
+
* @inheritDoc
|
|
271
|
+
*/
|
|
272
|
+
save(): ICanvasState;
|
|
273
|
+
/**
|
|
274
|
+
* @override
|
|
275
|
+
* @inheritDoc
|
|
276
|
+
*/
|
|
277
|
+
load(canvasState: ICanvasState): Promise<void>;
|
|
278
|
+
/**
|
|
279
|
+
* Another hack for bullet points... because they use canvas objects to render the bullets, they get saved when the canvas is persisted... and then loaded into a new canvas, but there's
|
|
280
|
+
* nothing linking them to the field that needs bullets, so they end up duplicating every time the canvas is saved/loaded. Since we don't use circles for anything else, this just
|
|
281
|
+
* deletes all circles on canvas load.
|
|
282
|
+
*/
|
|
283
|
+
private removePersistedBullets;
|
|
284
|
+
/**
|
|
285
|
+
* Remove any slave objects persisted to the canvas; their master objects will recreate them.
|
|
286
|
+
*/
|
|
287
|
+
private removeSlaveObjects;
|
|
288
|
+
/**
|
|
289
|
+
* @override
|
|
290
|
+
* @inheritDoc
|
|
291
|
+
*/
|
|
292
|
+
toSvg(): string;
|
|
293
|
+
/**
|
|
294
|
+
* @override
|
|
295
|
+
* @inheritDoc
|
|
296
|
+
*/
|
|
297
|
+
toImage(multiplier?: number): string;
|
|
298
|
+
/**
|
|
299
|
+
* @override
|
|
300
|
+
* @inheritDoc
|
|
301
|
+
*/
|
|
302
|
+
createPNGStream(): any;
|
|
303
|
+
/**
|
|
304
|
+
* @override
|
|
305
|
+
* @inheritDoc
|
|
306
|
+
*/
|
|
307
|
+
registerUndoState(): void;
|
|
308
|
+
/**
|
|
309
|
+
* @override
|
|
310
|
+
* @inheritDoc
|
|
311
|
+
*/
|
|
312
|
+
undo(): Promise<void>;
|
|
313
|
+
/**
|
|
314
|
+
* @override
|
|
315
|
+
* @inheritDoc
|
|
316
|
+
*/
|
|
317
|
+
redo(): Promise<void>;
|
|
318
|
+
/**
|
|
319
|
+
* Redraw the canvas.
|
|
320
|
+
*/
|
|
321
|
+
redraw(): void;
|
|
322
|
+
syncObjectList(): void;
|
|
323
|
+
/**
|
|
324
|
+
* @override
|
|
325
|
+
* @inheritDoc
|
|
326
|
+
*/
|
|
327
|
+
notifyObjectListChanged(): void;
|
|
328
|
+
/**
|
|
329
|
+
* @override
|
|
330
|
+
* @inheritDoc
|
|
331
|
+
*/
|
|
332
|
+
notifyTextChanged(): void;
|
|
333
|
+
/**
|
|
334
|
+
* @override
|
|
335
|
+
* @inheritDoc
|
|
336
|
+
*/
|
|
337
|
+
notifyMarginChanged(): void;
|
|
338
|
+
removeFabricObject(obj: any): void;
|
|
339
|
+
protected selectFabricObject(object: fabric.Object): void;
|
|
340
|
+
protected onTextChange(): void;
|
|
341
|
+
protected onObjectListChange(): void;
|
|
342
|
+
protected onDimensionsChange(): void;
|
|
343
|
+
protected onMarginChange(): void;
|
|
344
|
+
private bindFields;
|
|
345
|
+
private bindField;
|
|
346
|
+
private findFabricObject;
|
|
347
|
+
private findObject;
|
|
348
|
+
/**
|
|
349
|
+
* Reset zoom and canvas dimensions to 1:1 scale, execute a function, then return the canvas to
|
|
350
|
+
* the previous values.
|
|
351
|
+
* @param func Function to execute.
|
|
352
|
+
*/
|
|
353
|
+
private executeWithNormalizedCanvas;
|
|
354
|
+
/**
|
|
355
|
+
* Update the actual dimensions of the canvas by multiplying the requested dimensions by the current zoom factor.
|
|
356
|
+
*/
|
|
357
|
+
private updateCanvasDimensions;
|
|
358
|
+
protected onProfileChanged(profile: ICanvasProfile): void;
|
|
359
|
+
protected getFieldByCanvasObject?(object: any): AbstractCanvasObject<any> | null;
|
|
360
|
+
protected getFieldsByCanvasObject(objects: any[]): Array<AbstractCanvasObject<any>>;
|
|
361
|
+
private calculateImageCaptureCoefficient;
|
|
362
|
+
private randomId;
|
|
363
|
+
private getLowestTextPoint;
|
|
364
|
+
private trackNewObject;
|
|
365
|
+
private dimensionsExceedRestrictions;
|
|
366
|
+
}
|
|
367
|
+
export declare class SelectionData implements ISelectionData {
|
|
368
|
+
readonly empty: boolean;
|
|
369
|
+
readonly objects: Array<AbstractCanvasObject<any>>;
|
|
370
|
+
readonly isText: boolean;
|
|
371
|
+
readonly textSelection: ITextSelection | null;
|
|
372
|
+
event: IEvent<MouseEvent>;
|
|
373
|
+
constructor(objects: Array<AbstractCanvasObject<any>>);
|
|
374
|
+
setEvent(event: IEvent<MouseEvent>): void;
|
|
375
|
+
}
|