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