@leapfrog/interactive-canvas 0.1.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.
Files changed (58) hide show
  1. package/dist/dimensions/pixel-canvas-dimensions.d.ts +13 -0
  2. package/dist/dimensions/print-6-col-canvas-dimensions.d.ts +18 -0
  3. package/dist/dimensions/print-8-col-canvas-dimensions.d.ts +18 -0
  4. package/dist/font/font-library.d.ts +22 -0
  5. package/dist/font/font-library.interface.d.ts +20 -0
  6. package/dist/font/font.interface.d.ts +20 -0
  7. package/dist/font/unknown-font.d.ts +6 -0
  8. package/dist/index.d.ts +47 -0
  9. package/dist/interactive-canvas.impl.d.ts +305 -0
  10. package/dist/interactive-canvas.interface.d.ts +221 -0
  11. package/dist/interactive-canvas.js +34 -0
  12. package/dist/interactive-canvas.js.map +1 -0
  13. package/dist/interactive-canvas.nomin.js +57456 -0
  14. package/dist/layout/abstract-layout-manager.d.ts +18 -0
  15. package/dist/layout/advanced-layout-manager.d.ts +15 -0
  16. package/dist/layout/function/pin-to-bottom.layout-function.d.ts +4 -0
  17. package/dist/layout/function/redraw-all.layout-function.d.ts +4 -0
  18. package/dist/layout/function/reposition-borders.layout-function.d.ts +4 -0
  19. package/dist/layout/function/reposition-cutoffs.layout-function.d.ts +4 -0
  20. package/dist/layout/function/resize-canvas.layout-function.d.ts +4 -0
  21. package/dist/layout/function/stack-objects.layout-function.d.ts +11 -0
  22. package/dist/layout/function/update-object-dimensions.layout-function.d.ts +4 -0
  23. package/dist/layout/layout-manager.enum.d.ts +5 -0
  24. package/dist/layout/layout-manager.interface.d.ts +13 -0
  25. package/dist/layout/standard-layout-manager.d.ts +36 -0
  26. package/dist/mutator/mutable-background-color.interface.d.ts +15 -0
  27. package/dist/mutator/mutable-color.interface.d.ts +6 -0
  28. package/dist/mutator/mutable-image.interface.d.ts +28 -0
  29. package/dist/mutator/mutable-position.interface.d.ts +33 -0
  30. package/dist/mutator/mutable-text-style.interface.d.ts +149 -0
  31. package/dist/mutator/mutable-text.interface.d.ts +40 -0
  32. package/dist/object/abstract-canvas-object.d.ts +155 -0
  33. package/dist/object/canvas-object-data.d.ts +23 -0
  34. package/dist/object/canvas-object.interface.d.ts +96 -0
  35. package/dist/object/impl/border.d.ts +60 -0
  36. package/dist/object/impl/cutoff.d.ts +60 -0
  37. package/dist/object/impl/horizontal-rule.d.ts +89 -0
  38. package/dist/object/impl/image.d.ts +82 -0
  39. package/dist/object/impl/rectangle.d.ts +59 -0
  40. package/dist/object/impl/text.d.ts +255 -0
  41. package/dist/object/impl/vertical-rule.d.ts +89 -0
  42. package/dist/profile/canvas-profile.interface.d.ts +22 -0
  43. package/dist/profile/default-canvas-profile.d.ts +23 -0
  44. package/dist/types/canvas-dimension-restrictions.interface.d.ts +14 -0
  45. package/dist/types/canvas-dimensions.interface.d.ts +21 -0
  46. package/dist/types/canvas-state.interface.d.ts +11 -0
  47. package/dist/types/dimension-restrictions.interface.d.ts +6 -0
  48. package/dist/types/image-type.enum.d.ts +6 -0
  49. package/dist/types/margin.interface.d.ts +6 -0
  50. package/dist/types/object-dimensions.interface.d.ts +23 -0
  51. package/dist/types/object-type.enum.d.ts +10 -0
  52. package/dist/types/overflow.interface.d.ts +4 -0
  53. package/dist/types/position.interface.d.ts +6 -0
  54. package/dist/types/rect.interface.d.ts +6 -0
  55. package/dist/types/selection-data.interface.d.ts +19 -0
  56. package/dist/types/text-alignment.interface.d.ts +1 -0
  57. package/package.json +32 -0
  58. package/readme.md +43 -0
@@ -0,0 +1,13 @@
1
+ import { ICanvasDimensions } from "..";
2
+ export declare class PixelCanvasDimensions implements ICanvasDimensions {
3
+ readonly width: number;
4
+ readonly widthPx: number;
5
+ readonly widthUnit: string;
6
+ readonly height: number;
7
+ readonly heightPx: number;
8
+ readonly heightUnit: string;
9
+ constructor(width: number, height: number);
10
+ withSize(width: number, height: number): ICanvasDimensions;
11
+ widthPxToMm(px: number): number | undefined;
12
+ heightPxToMm(px: number): number | undefined;
13
+ }
@@ -0,0 +1,18 @@
1
+ import { ICanvasDimensions } from "..";
2
+ export declare class Print6ColCanvasDimensions implements ICanvasDimensions {
3
+ readonly width: number;
4
+ readonly widthPx: number;
5
+ readonly widthMm: number;
6
+ readonly widthUnit: string;
7
+ readonly gutterCount: number;
8
+ readonly gutterTotalMm: number;
9
+ readonly columnsTotalMm: number;
10
+ readonly height: number;
11
+ readonly heightPx: number;
12
+ readonly heightMm: number;
13
+ readonly heightUnit: string;
14
+ constructor(width: number, height: number);
15
+ withSize(width: number, height: number): ICanvasDimensions;
16
+ widthPxToMm(px: number): number | undefined;
17
+ heightPxToMm(px: number): number | undefined;
18
+ }
@@ -0,0 +1,18 @@
1
+ import { ICanvasDimensions } from "..";
2
+ export declare class Print8ColCanvasDimensions implements ICanvasDimensions {
3
+ readonly width: number;
4
+ readonly widthPx: number;
5
+ readonly widthMm: number;
6
+ readonly widthUnit: string;
7
+ readonly gutterCount: number;
8
+ readonly gutterTotalMm: number;
9
+ readonly columnsTotalMm: number;
10
+ readonly height: number;
11
+ readonly heightPx: number;
12
+ readonly heightMm: number;
13
+ readonly heightUnit: string;
14
+ constructor(width: number, height: number);
15
+ withSize(width: number, height: number): ICanvasDimensions;
16
+ widthPxToMm(px: number): number | undefined;
17
+ heightPxToMm(px: number): number | undefined;
18
+ }
@@ -0,0 +1,22 @@
1
+ import { IFont } from "./font.interface";
2
+ import { IFontLibrary } from "./font-library.interface";
3
+ import { UnknownFont } from "./unknown-font";
4
+ export declare const UNKNOWN_FONT: UnknownFont;
5
+ export declare class FontLibrary implements IFontLibrary {
6
+ private readonly _fonts;
7
+ /**
8
+ * @override
9
+ * @inheritDoc
10
+ */
11
+ registerFont(font: IFont): void;
12
+ /**
13
+ * @override
14
+ * @inheritDoc
15
+ */
16
+ getFonts(): IFont[];
17
+ /**
18
+ * @override
19
+ * @inheritDoc
20
+ */
21
+ getFont(family: string): IFont;
22
+ }
@@ -0,0 +1,20 @@
1
+ import { IFont } from "./font.interface";
2
+ /**
3
+ * The font library manages a list of Fonts registered with the canvas.
4
+ */
5
+ export interface IFontLibrary {
6
+ /**
7
+ * Register a font
8
+ */
9
+ registerFont(font: IFont): void;
10
+ /**
11
+ * Get all fonts registered in the library.
12
+ */
13
+ getFonts(): IFont[];
14
+ /**
15
+ * Get a font by family.
16
+ * If font is not recognized, the {@link UNKNOWN_FONT} will be returned.
17
+ * @param name Font family.
18
+ */
19
+ getFont(name: string): IFont;
20
+ }
@@ -0,0 +1,20 @@
1
+ export interface IFont {
2
+ readonly family: string;
3
+ readonly normalWeight: number;
4
+ readonly boldWeight: number;
5
+ /**
6
+ * Returns true if the given font weight is considered bold for this font.
7
+ * @param fontWeight Font weight.
8
+ */
9
+ isBold(fontWeight: number): boolean;
10
+ }
11
+ export declare abstract class Font implements IFont {
12
+ abstract readonly family: string;
13
+ abstract readonly normalWeight: number;
14
+ abstract readonly boldWeight: number;
15
+ /**
16
+ * @override
17
+ * @inheritDoc
18
+ */
19
+ isBold(fontWeight: number): boolean;
20
+ }
@@ -0,0 +1,6 @@
1
+ import { Font } from "./font.interface";
2
+ export declare class UnknownFont extends Font {
3
+ readonly family = "_Unknown_";
4
+ readonly normalWeight = 400;
5
+ readonly boldWeight = 700;
6
+ }
@@ -0,0 +1,47 @@
1
+ export * from "./dimensions/pixel-canvas-dimensions";
2
+ export * from "./dimensions/print-6-col-canvas-dimensions";
3
+ export * from "./dimensions/print-8-col-canvas-dimensions";
4
+ export * from "./font/font-library";
5
+ export * from "./font/font-library.interface";
6
+ export * from "./font/font.interface";
7
+ export * from "./font/unknown-font";
8
+ export * from "./layout/abstract-layout-manager";
9
+ export * from "./layout/advanced-layout-manager";
10
+ export * from "./layout/layout-manager.enum";
11
+ export * from "./layout/layout-manager.interface";
12
+ export * from "./layout/standard-layout-manager";
13
+ export * from "./mutator/mutable-background-color.interface";
14
+ export * from "./mutator/mutable-color.interface";
15
+ export * from "./mutator/mutable-image.interface";
16
+ export * from "./mutator/mutable-position.interface";
17
+ export * from "./mutator/mutable-text.interface";
18
+ export * from "./mutator/mutable-text-style.interface";
19
+ export * from "./object/abstract-canvas-object";
20
+ export * from "./object/canvas-object.interface";
21
+ export * from "./object/canvas-object-data";
22
+ export * from "./object/impl/border";
23
+ export * from "./object/impl/cutoff";
24
+ export * from "./object/impl/horizontal-rule";
25
+ export * from "./object/impl/image";
26
+ export * from "./object/impl/rectangle";
27
+ export * from "./object/impl/text";
28
+ export * from "./object/impl/vertical-rule";
29
+ export * from "./profile/canvas-profile.interface";
30
+ export * from "./profile/default-canvas-profile";
31
+ export * from "./types/canvas-dimension-restrictions.interface";
32
+ export * from "./types/canvas-dimensions.interface";
33
+ export * from "./types/canvas-dimension-restrictions.interface";
34
+ export * from "./types/canvas-dimensions.interface";
35
+ export * from "./types/canvas-state.interface";
36
+ export * from "./types/dimension-restrictions.interface";
37
+ export * from "./types/image-type.enum";
38
+ export * from "./types/margin.interface";
39
+ export * from "./types/object-dimensions.interface";
40
+ export * from "./types/object-type.enum";
41
+ export * from "./types/overflow.interface";
42
+ export * from "./types/position.interface";
43
+ export * from "./types/rect.interface";
44
+ export * from "./types/selection-data.interface";
45
+ export * from "./types/text-alignment.interface";
46
+ export * from "./interactive-canvas.impl";
47
+ export * from "./interactive-canvas.interface";
@@ -0,0 +1,305 @@
1
+ import { Observable } 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
+ export declare class InteractiveCanvas implements IInteractiveCanvas {
23
+ protected devicePixelRatio: number;
24
+ private readonly IMAGE_CAPTURE_COEFFICIENT;
25
+ private readonly fontLibrary;
26
+ private readonly profile$;
27
+ private readonly layoutManager$;
28
+ private readonly backgroundColor$;
29
+ private readonly dimensions$;
30
+ private readonly dimensionRestrictions$;
31
+ private readonly dimensionChangeRejections$;
32
+ private readonly zoom$;
33
+ private readonly objects$;
34
+ private readonly selection$;
35
+ private readonly fabricCanvas;
36
+ private baseDimensions;
37
+ constructor(elementId: string, devicePixelRatio: number);
38
+ /**
39
+ * @override
40
+ * @inheritDoc
41
+ */
42
+ getFontLibrary(): IFontLibrary;
43
+ /**
44
+ * @override
45
+ * @inheritDoc
46
+ */
47
+ getProfile(): ICanvasProfile;
48
+ /**
49
+ * @override
50
+ * @inheritDoc
51
+ */
52
+ getProfile$(): Observable<ICanvasProfile>;
53
+ /**
54
+ * @override
55
+ * @inheritDoc
56
+ */
57
+ setProfile(profile: ICanvasProfile): void;
58
+ /**
59
+ * @override
60
+ * @inheritDoc
61
+ */
62
+ getLayoutManager(): ILayoutManager;
63
+ /**
64
+ * @override
65
+ * @inheritDoc
66
+ */
67
+ getLayoutManager$(): Observable<ILayoutManager>;
68
+ /**
69
+ * @override
70
+ * @inheritDoc
71
+ */
72
+ setLayoutManager(layoutManager: LayoutManager): void;
73
+ /**
74
+ * @override
75
+ * @inheritDoc
76
+ */
77
+ getBackgroundColor(): string;
78
+ /**
79
+ * @override
80
+ * @inheritDoc
81
+ */
82
+ getBackgroundColor$(): Observable<string>;
83
+ /**
84
+ * @override
85
+ * @inheritDoc
86
+ */
87
+ setBackgroundColor(color?: string): void;
88
+ /**
89
+ * @override
90
+ * @inheritDoc
91
+ */
92
+ getDimensions(): ICanvasDimensions;
93
+ /**
94
+ * @override
95
+ * @inheritDoc
96
+ */
97
+ getBaseDimensions(): ICanvasDimensions;
98
+ /**
99
+ * @override
100
+ * @inheritDoc
101
+ */
102
+ getDimensions$(): Observable<ICanvasDimensions>;
103
+ /**
104
+ * @override
105
+ * @inheritDoc
106
+ */
107
+ setDimensions(dimensions: ICanvasDimensions): void;
108
+ /**
109
+ * @override
110
+ * @inheritDoc
111
+ */
112
+ setBaseDimensions(dimensions: ICanvasDimensions): void;
113
+ /**
114
+ * @override
115
+ * @inheritDoc
116
+ */
117
+ getDimensionChangeRejections$(): Observable<ICanvasDimensions>;
118
+ /**
119
+ * @override
120
+ * @inheritDoc
121
+ */
122
+ getDimensionsRestrictions(): ICanvasDimensionRestrictions;
123
+ /**
124
+ * @override
125
+ * @inheritDoc
126
+ */
127
+ getDimensionsRestrictions$(): Observable<ICanvasDimensionRestrictions>;
128
+ /**
129
+ * @override
130
+ * @inheritDoc
131
+ */
132
+ setDimensionRestrictions(restrictions: ICanvasDimensionRestrictions): void;
133
+ getMargin(): IRect;
134
+ /**
135
+ * @override
136
+ * @inheritDoc
137
+ */
138
+ getZoom(): number;
139
+ /**
140
+ * @override
141
+ * @inheritDoc
142
+ */
143
+ getZoom$(): Observable<number>;
144
+ /**
145
+ * @override
146
+ * @inheritDoc
147
+ */
148
+ setZoom(zoom: number): void;
149
+ /**
150
+ * @override
151
+ * @inheritDoc
152
+ */
153
+ getObjects(): ICanvasObject[];
154
+ /**
155
+ * Get the list of objects directly.
156
+ */
157
+ getObjectsInternal(): Array<AbstractCanvasObject<any>>;
158
+ getObjectsByTypeInternal<T extends AbstractCanvasObject<any>>(type: ObjectType): T[];
159
+ getObjectsByTypesInternal(...types: ObjectType[]): Array<AbstractCanvasObject<any>>;
160
+ /**
161
+ * @override
162
+ * @inheritDoc
163
+ */
164
+ getObjects$(): Observable<ICanvasObject[]>;
165
+ /**
166
+ * @override
167
+ * @inheritDoc
168
+ */
169
+ removeObject(target: ICanvasObject): void;
170
+ /**
171
+ * @override
172
+ * @inheritDoc
173
+ */
174
+ addImageObject(imageUrl: string): Observable<IImage>;
175
+ /**
176
+ * @override
177
+ * @inheritDoc
178
+ */
179
+ addTextObject(): Observable<IText>;
180
+ /**
181
+ * @override
182
+ * @inheritDoc
183
+ */
184
+ addRectangleObject(): Observable<IRectangle>;
185
+ /**
186
+ * @override
187
+ * @inheritDoc
188
+ */
189
+ addCutoffObject(): Observable<ICutoff>;
190
+ /**
191
+ * @override
192
+ * @inheritDoc
193
+ */
194
+ addBorderObject(): Observable<IBorder>;
195
+ /**
196
+ * @override
197
+ * @inheritDoc
198
+ */
199
+ addVerticalRuleObject(): Observable<IVerticalRule>;
200
+ /**
201
+ * @override
202
+ * @inheritDoc
203
+ */
204
+ addHorizontalRuleObject(): Observable<IHorizontalRule>;
205
+ /**
206
+ * @override
207
+ * @inheritDoc
208
+ */
209
+ setPrefillData(data: {
210
+ [id: string]: string;
211
+ }): void;
212
+ /**
213
+ * @override
214
+ * @inheritDoc
215
+ */
216
+ distributeObjectsVertically(): void;
217
+ /**
218
+ * @override
219
+ * @inheritDoc
220
+ */
221
+ getSelection(): ISelectionData;
222
+ /**
223
+ * @override
224
+ * @inheritDoc
225
+ */
226
+ getSelection$(): Observable<ISelectionData>;
227
+ /**
228
+ * @override
229
+ * @inheritDoc
230
+ */
231
+ select(object: ICanvasObject): void;
232
+ /**
233
+ * @override
234
+ * @inheritDoc
235
+ */
236
+ clearSelection(): void;
237
+ setMultiSelect(value: boolean): void;
238
+ /**
239
+ * @override
240
+ * @inheritDoc
241
+ */
242
+ clear(): void;
243
+ /**
244
+ * @override
245
+ * @inheritDoc
246
+ */
247
+ save(): ICanvasState;
248
+ /**
249
+ * @override
250
+ * @inheritDoc
251
+ */
252
+ load(canvasState: ICanvasState): Promise<void>;
253
+ /**
254
+ * 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
255
+ * 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
256
+ * deletes all circles on canvas load.
257
+ */
258
+ private removePersistedBullets;
259
+ /**
260
+ * @override
261
+ * @inheritDoc
262
+ */
263
+ toSvg(): string;
264
+ /**
265
+ * @override
266
+ * @inheritDoc
267
+ */
268
+ toImage(): string;
269
+ /**
270
+ * Redraw the canvas.
271
+ */
272
+ redraw(): void;
273
+ syncObjectList(): void;
274
+ onTextChange(): void;
275
+ onObjectListChange(): void;
276
+ onDimensionsChange(): void;
277
+ onMarginChange(): void;
278
+ notifyObjectListChanged(): void;
279
+ removeFabricObject(obj: any): void;
280
+ private bindFields;
281
+ private bindField;
282
+ private findFabricObject;
283
+ private findObject;
284
+ /**
285
+ * Reset zoom and canvas dimensions to 1:1 scale, execute a function, then return the canvas to
286
+ * the previous values.
287
+ * @param func Function to execute.
288
+ */
289
+ private executeWithNormalizedCanvas;
290
+ /**
291
+ * Update the actual dimensions of the canvas by multiplying the requested dimensions by the current zoom factor.
292
+ */
293
+ private updateCanvasDimensions;
294
+ private calculateImageCaptureCoefficient;
295
+ private onProfileChanged;
296
+ private onFabricSelectionChanged;
297
+ private onTextEditing;
298
+ private getFieldByCanvasObject;
299
+ private getFieldsByCanvasObject;
300
+ private randomId;
301
+ private getLowestTextPoint;
302
+ private trackNewObject;
303
+ private enterTextSelectionModeIfRequired;
304
+ private dimensionsExceedRestrictions;
305
+ }
@@ -0,0 +1,221 @@
1
+ import { Observable } from "rxjs";
2
+ import { IImage } from "./object/impl/image";
3
+ import { IText } from "./object/impl/text";
4
+ import { IRectangle } from "./object/impl/rectangle";
5
+ import { ICutoff } from "./object/impl/cutoff";
6
+ import { ILayoutManager } from "./layout/layout-manager.interface";
7
+ import { IBorder } from "./object/impl/border";
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 { IFontLibrary } from "./font/font-library.interface";
12
+ import { ICanvasProfile } from "./profile/canvas-profile.interface";
13
+ import { ICanvasDimensionRestrictions } from "./types/canvas-dimension-restrictions.interface";
14
+ import { IRect } from "./types/rect.interface";
15
+ import { ICanvasObject } from "./object/canvas-object.interface";
16
+ import { ICanvasDimensions } from "./types/canvas-dimensions.interface";
17
+ import { ISelectionData } from "./types/selection-data.interface";
18
+ import { ICanvasState } from "./types/canvas-state.interface";
19
+ /**
20
+ * New leapfrog canvas implementation c. 2019.
21
+ */
22
+ export interface IInteractiveCanvas {
23
+ /**
24
+ * Get the canvas font library.
25
+ */
26
+ getFontLibrary(): IFontLibrary;
27
+ /**
28
+ * Get the current canvas profile.
29
+ * The profile determines what operations are permitted, such as moving or scaling components.
30
+ */
31
+ getProfile(): ICanvasProfile;
32
+ /**
33
+ * Get an observable of the current canvas profile.
34
+ */
35
+ getProfile$(): Observable<ICanvasProfile>;
36
+ /**
37
+ * Set the canvas profile.
38
+ * @param profile New profile.
39
+ */
40
+ setProfile(profile: ICanvasProfile): void;
41
+ /**
42
+ * Get the current layout manager.
43
+ * The layout manager controls how elements on the canvas are laid out.
44
+ */
45
+ getLayoutManager(): ILayoutManager;
46
+ /**
47
+ * Get an observable of the current layout manager.
48
+ */
49
+ getLayoutManager$(): Observable<ILayoutManager>;
50
+ /**
51
+ * Set the layout manager.
52
+ * @param layoutManager New layout manager.
53
+ */
54
+ setLayoutManager(layoutManager: LayoutManager): void;
55
+ /**
56
+ * Get the current canvas background color.
57
+ */
58
+ getBackgroundColor(): string;
59
+ /**
60
+ * Get an observable of the current background color.
61
+ */
62
+ getBackgroundColor$(): Observable<string>;
63
+ /**
64
+ * Set the canvas background color.
65
+ * @param color New color.
66
+ */
67
+ setBackgroundColor(color: string): void;
68
+ /**
69
+ * Get the current canvas dimensions.
70
+ */
71
+ getDimensions(): ICanvasDimensions;
72
+ /**
73
+ * Get the current canvas base dimensions.
74
+ */
75
+ getBaseDimensions(): ICanvasDimensions;
76
+ /**
77
+ * Get an observable of the current canvas dimensions.
78
+ */
79
+ getDimensions$(): Observable<ICanvasDimensions>;
80
+ /**
81
+ * Set new canvas dimensions.
82
+ * @param dimensions New dimensions.
83
+ */
84
+ setDimensions(dimensions: ICanvasDimensions): void;
85
+ /**
86
+ * Set new canvas base dimensions. Automatic resize will occur relative to these base dimensions.
87
+ * @param dimensions New dimensions.
88
+ */
89
+ setBaseDimensions(dimensions: ICanvasDimensions): void;
90
+ /**
91
+ * Get an observable of any rejected dimension changes.
92
+ */
93
+ getDimensionChangeRejections$(): Observable<ICanvasDimensions>;
94
+ /**
95
+ * Set restrictions on canvas dimensions.
96
+ * @param restrictions Optional restrictions.
97
+ */
98
+ setDimensionRestrictions(restrictions: ICanvasDimensionRestrictions): void;
99
+ /**
100
+ * Get an observable of the canvas dimension restrictions.
101
+ */
102
+ getDimensionsRestrictions$(): Observable<ICanvasDimensionRestrictions>;
103
+ /**
104
+ * Get canvas dimension restrictions.
105
+ */
106
+ getDimensionsRestrictions(): ICanvasDimensionRestrictions;
107
+ /**
108
+ * Get the size of the canvas margin (the area occupied by borders/cutoff rules).
109
+ */
110
+ getMargin(): IRect;
111
+ /**
112
+ * Get the current canvas zoom factor.
113
+ */
114
+ getZoom(): number;
115
+ /**
116
+ * Get an observable of the current canvas zoom factor.
117
+ */
118
+ getZoom$(): Observable<number>;
119
+ /**
120
+ * Set a new canvas zoom factor.
121
+ * @param zoom Zoom factor.
122
+ */
123
+ setZoom(zoom: number): void;
124
+ /**
125
+ * Get the current canvas object list.
126
+ */
127
+ getObjects(): ICanvasObject[];
128
+ /**
129
+ * Get an observable of the current canvas object list.
130
+ */
131
+ getObjects$(): Observable<ICanvasObject[]>;
132
+ /**
133
+ * Remove an object from the canvas.
134
+ * @param object The object to remove.
135
+ */
136
+ removeObject(object: ICanvasObject): void;
137
+ /**
138
+ * Add an image object to the canvas.
139
+ * @param imageUrl Url for image content.
140
+ */
141
+ addImageObject(imageUrl: string): Observable<IImage>;
142
+ /**
143
+ * Add a text object to the canvas.
144
+ */
145
+ addTextObject(): Observable<IText>;
146
+ /**
147
+ * Add a rectangle object to the canvas.
148
+ */
149
+ addRectangleObject(): Observable<IRectangle>;
150
+ /**
151
+ * Add a rectangle object to the canvas.
152
+ */
153
+ addCutoffObject(): Observable<ICutoff>;
154
+ /**
155
+ * Add a border object to the canvas.
156
+ */
157
+ addBorderObject(): Observable<IBorder>;
158
+ /**
159
+ * Add a vertical rule object to the canvas.
160
+ */
161
+ addVerticalRuleObject(): Observable<IVerticalRule>;
162
+ /**
163
+ * Add a horizontal rule object to the canvas.
164
+ */
165
+ addHorizontalRuleObject(): Observable<IHorizontalRule>;
166
+ /**
167
+ * Set the data used to prefill text into the canvas.
168
+ * @param data Prefill data.
169
+ */
170
+ setPrefillData(data: {
171
+ [id: string]: string;
172
+ }): void;
173
+ /**
174
+ * Distribute text and image objects equally along the vertical axis.s
175
+ */
176
+ distributeObjectsVertically(): void;
177
+ /**
178
+ * Get data on the current selection.
179
+ */
180
+ getSelection(): ISelectionData;
181
+ /**
182
+ * Get an observable of the current selection data.
183
+ */
184
+ getSelection$(): Observable<ISelectionData>;
185
+ /**
186
+ * Select a field.
187
+ * @param field The field to select.
188
+ */
189
+ select(field: ICanvasObject): void;
190
+ /**
191
+ * Deselects any selected fields.
192
+ */
193
+ clearSelection(): void;
194
+ /**
195
+ * Enable/disable multi select.
196
+ * @param value value.
197
+ */
198
+ setMultiSelect(value: boolean): void;
199
+ /**
200
+ * Clear the canvas.
201
+ */
202
+ clear(): void;
203
+ /**
204
+ * Serialize the canvas for saving.
205
+ * Returns an observable that will complete after the load process is finished.
206
+ */
207
+ save(): ICanvasState;
208
+ /**
209
+ * Load the canvas state from a previously {@link IInteractiveCanvas#save saved} state.
210
+ * @param canvasState Persisted canvas state.
211
+ */
212
+ load(canvasState: ICanvasState): Promise<void>;
213
+ /**
214
+ * Export the canvas to an SVG.
215
+ */
216
+ toSvg(): string;
217
+ /**
218
+ * Export the canvas to a DataUrl image.
219
+ */
220
+ toImage(): string;
221
+ }