@leapfrog/interactive-canvas 1.0.1 → 1.0.3
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.
|
@@ -260,61 +260,6 @@ var RedrawAllLayoutFunction = /** @class */ (function () {
|
|
|
260
260
|
return RedrawAllLayoutFunction;
|
|
261
261
|
}());
|
|
262
262
|
|
|
263
|
-
var RepositionCutoffsLayoutFunction = /** @class */ (function () {
|
|
264
|
-
function RepositionCutoffsLayoutFunction() {
|
|
265
|
-
}
|
|
266
|
-
RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
|
|
267
|
-
canvas.getObjectsByTypeInternal(ObjectType.CUTOFF)
|
|
268
|
-
.forEach(function (cutoff) { return cutoff.updatePosition(); });
|
|
269
|
-
};
|
|
270
|
-
return RepositionCutoffsLayoutFunction;
|
|
271
|
-
}());
|
|
272
|
-
|
|
273
|
-
var RepositionBordersLayoutFunction = /** @class */ (function () {
|
|
274
|
-
function RepositionBordersLayoutFunction() {
|
|
275
|
-
}
|
|
276
|
-
RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
|
|
277
|
-
canvas.getObjectsByTypeInternal(ObjectType.BORDER)
|
|
278
|
-
.forEach(function (border) { return border.updatePosition(); });
|
|
279
|
-
};
|
|
280
|
-
return RepositionBordersLayoutFunction;
|
|
281
|
-
}());
|
|
282
|
-
|
|
283
|
-
var PinToBottomLayoutFunction = /** @class */ (function () {
|
|
284
|
-
function PinToBottomLayoutFunction() {
|
|
285
|
-
}
|
|
286
|
-
PinToBottomLayoutFunction.prototype.execute = function (canvas) {
|
|
287
|
-
canvas.getObjectsInternal()
|
|
288
|
-
.forEach(function (object) { return object.moveToPinnedPosition(); });
|
|
289
|
-
};
|
|
290
|
-
return PinToBottomLayoutFunction;
|
|
291
|
-
}());
|
|
292
|
-
|
|
293
|
-
var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
294
|
-
function ResizeCanvasLayoutFunction() {
|
|
295
|
-
}
|
|
296
|
-
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
297
|
-
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
298
|
-
return;
|
|
299
|
-
var currentDimensions = canvas.getDimensions();
|
|
300
|
-
var baseDimensions = canvas.getBaseDimensions();
|
|
301
|
-
var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(ObjectType.TEXT))
|
|
302
|
-
.filter(function (text) { return text.isResizeCanvas(); })
|
|
303
|
-
.reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
|
|
304
|
-
var increase = baseDimensions.withSize(currentDimensions.width, 0);
|
|
305
|
-
while (increase.heightPx < textHeightIncreasePx) {
|
|
306
|
-
increase = increase.withSize(increase.width, increase.height + 1);
|
|
307
|
-
}
|
|
308
|
-
var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
|
|
309
|
-
if (currentDimensions.height !== targetHeight.height) {
|
|
310
|
-
canvas.setDimensions(targetHeight);
|
|
311
|
-
}
|
|
312
|
-
canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
|
|
313
|
-
canvas.redraw();
|
|
314
|
-
};
|
|
315
|
-
return ResizeCanvasLayoutFunction;
|
|
316
|
-
}());
|
|
317
|
-
|
|
318
263
|
var LayoutManager;
|
|
319
264
|
(function (LayoutManager) {
|
|
320
265
|
LayoutManager["LEGACY"] = "LEGACY";
|
|
@@ -322,33 +267,6 @@ var LayoutManager;
|
|
|
322
267
|
LayoutManager["ADVANCED"] = "ADVANCED";
|
|
323
268
|
})(LayoutManager || (LayoutManager = {}));
|
|
324
269
|
|
|
325
|
-
var AdvancedLayoutManager = /** @class */ (function (_super) {
|
|
326
|
-
__extends(AdvancedLayoutManager, _super);
|
|
327
|
-
function AdvancedLayoutManager(canvas) {
|
|
328
|
-
var _this = _super.call(this, canvas) || this;
|
|
329
|
-
_this.key = LayoutManager.ADVANCED;
|
|
330
|
-
_this.pinToBottom = new PinToBottomLayoutFunction();
|
|
331
|
-
_this.redrawAll = new RedrawAllLayoutFunction();
|
|
332
|
-
_this.repositionBorders = new RepositionBordersLayoutFunction();
|
|
333
|
-
_this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
|
|
334
|
-
_this.resizeCanvas = new ResizeCanvasLayoutFunction();
|
|
335
|
-
return _this;
|
|
336
|
-
}
|
|
337
|
-
AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
338
|
-
this.pinToBottom.execute(this.canvas);
|
|
339
|
-
this.repositionCutoffs.execute(this.canvas);
|
|
340
|
-
this.repositionBorders.execute(this.canvas);
|
|
341
|
-
this.redrawAll.execute(this.canvas);
|
|
342
|
-
};
|
|
343
|
-
AdvancedLayoutManager.prototype.onTextChange = function () {
|
|
344
|
-
this.resizeCanvas.execute(this.canvas);
|
|
345
|
-
};
|
|
346
|
-
AdvancedLayoutManager.prototype.onObjectListChange = function () {
|
|
347
|
-
this.redrawAll.execute(this.canvas);
|
|
348
|
-
};
|
|
349
|
-
return AdvancedLayoutManager;
|
|
350
|
-
}(AbstractLayoutManager));
|
|
351
|
-
|
|
352
270
|
var UpdateObjectDimensionsLayoutFunction = /** @class */ (function () {
|
|
353
271
|
function UpdateObjectDimensionsLayoutFunction() {
|
|
354
272
|
}
|
|
@@ -510,6 +428,16 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
510
428
|
return StackObjectsLayoutFunction;
|
|
511
429
|
}());
|
|
512
430
|
|
|
431
|
+
var RepositionBordersLayoutFunction = /** @class */ (function () {
|
|
432
|
+
function RepositionBordersLayoutFunction() {
|
|
433
|
+
}
|
|
434
|
+
RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
|
|
435
|
+
canvas.getObjectsByTypeInternal(ObjectType.BORDER)
|
|
436
|
+
.forEach(function (border) { return border.updatePosition(); });
|
|
437
|
+
};
|
|
438
|
+
return RepositionBordersLayoutFunction;
|
|
439
|
+
}());
|
|
440
|
+
|
|
513
441
|
var StandardLayoutManager = /** @class */ (function (_super) {
|
|
514
442
|
__extends(StandardLayoutManager, _super);
|
|
515
443
|
function StandardLayoutManager(canvas) {
|
|
@@ -1041,6 +969,26 @@ var Border = /** @class */ (function (_super) {
|
|
|
1041
969
|
this.canvas.notifyMarginChanged();
|
|
1042
970
|
this.redraw();
|
|
1043
971
|
};
|
|
972
|
+
Border.prototype.getPadding = function () {
|
|
973
|
+
return this.data.padding || {
|
|
974
|
+
top: 2,
|
|
975
|
+
right: 2,
|
|
976
|
+
bottom: 2,
|
|
977
|
+
left: 2
|
|
978
|
+
};
|
|
979
|
+
};
|
|
980
|
+
Border.prototype.setPadding = function (padding) {
|
|
981
|
+
if (!padding)
|
|
982
|
+
return;
|
|
983
|
+
this.data.padding = {
|
|
984
|
+
top: padding.top || 2,
|
|
985
|
+
right: padding.right || 2,
|
|
986
|
+
bottom: padding.bottom || 2,
|
|
987
|
+
left: padding.left || 2
|
|
988
|
+
};
|
|
989
|
+
this.canvas.notifyMarginChanged();
|
|
990
|
+
this.redraw();
|
|
991
|
+
};
|
|
1044
992
|
Border.prototype.updatePosition = function () {
|
|
1045
993
|
this.fabricObject.set({
|
|
1046
994
|
strokeWidth: this.strokeWidth$.value,
|
|
@@ -2456,15 +2404,25 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
2456
2404
|
var borderWidth = this.getObjectsByTypeInternal(ObjectType.BORDER)
|
|
2457
2405
|
.map(function (border) { return border.getStrokeWidth(); })
|
|
2458
2406
|
.reduce(function (current, next) { return Math.max(current, next); }, 0);
|
|
2407
|
+
var borderPadding = this.getObjectsByTypeInternal(ObjectType.BORDER)
|
|
2408
|
+
.map(function (border) { return border.getPadding(); })
|
|
2409
|
+
.reduce(function (current, next) {
|
|
2410
|
+
return {
|
|
2411
|
+
top: Math.max(current.top, next.top),
|
|
2412
|
+
right: Math.max(current.right, next.right),
|
|
2413
|
+
bottom: Math.max(current.bottom, next.bottom),
|
|
2414
|
+
left: Math.max(current.bottom, next.bottom)
|
|
2415
|
+
};
|
|
2416
|
+
}, { top: 0, right: 0, bottom: 0, left: 0 });
|
|
2459
2417
|
var cutoffWidth = this.getObjectsByTypeInternal(ObjectType.CUTOFF)
|
|
2460
2418
|
.map(function (border) { return border.getStrokeWidth(); })
|
|
2461
2419
|
.reduce(function (current, next) { return Math.max(current, next); }, 0);
|
|
2462
2420
|
// noinspection JSSuspiciousNameCombination
|
|
2463
2421
|
return {
|
|
2464
|
-
top: borderWidth,
|
|
2465
|
-
right: borderWidth,
|
|
2466
|
-
bottom: Math.max(cutoffWidth, borderWidth),
|
|
2467
|
-
left: borderWidth
|
|
2422
|
+
top: borderWidth + borderPadding.top,
|
|
2423
|
+
right: borderWidth + borderPadding.right,
|
|
2424
|
+
bottom: Math.max(cutoffWidth, borderWidth) + borderPadding.bottom,
|
|
2425
|
+
left: borderWidth + borderPadding.left
|
|
2468
2426
|
};
|
|
2469
2427
|
};
|
|
2470
2428
|
/**
|
|
@@ -3192,4 +3150,76 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3192
3150
|
return InteractiveCanvas;
|
|
3193
3151
|
}(AbstractInteractiveCanvas));
|
|
3194
3152
|
|
|
3153
|
+
var RepositionCutoffsLayoutFunction = /** @class */ (function () {
|
|
3154
|
+
function RepositionCutoffsLayoutFunction() {
|
|
3155
|
+
}
|
|
3156
|
+
RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
|
|
3157
|
+
canvas.getObjectsByTypeInternal(ObjectType.CUTOFF)
|
|
3158
|
+
.forEach(function (cutoff) { return cutoff.updatePosition(); });
|
|
3159
|
+
};
|
|
3160
|
+
return RepositionCutoffsLayoutFunction;
|
|
3161
|
+
}());
|
|
3162
|
+
|
|
3163
|
+
var PinToBottomLayoutFunction = /** @class */ (function () {
|
|
3164
|
+
function PinToBottomLayoutFunction() {
|
|
3165
|
+
}
|
|
3166
|
+
PinToBottomLayoutFunction.prototype.execute = function (canvas) {
|
|
3167
|
+
canvas.getObjectsInternal()
|
|
3168
|
+
.forEach(function (object) { return object.moveToPinnedPosition(); });
|
|
3169
|
+
};
|
|
3170
|
+
return PinToBottomLayoutFunction;
|
|
3171
|
+
}());
|
|
3172
|
+
|
|
3173
|
+
var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
3174
|
+
function ResizeCanvasLayoutFunction() {
|
|
3175
|
+
}
|
|
3176
|
+
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
3177
|
+
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
3178
|
+
return;
|
|
3179
|
+
var currentDimensions = canvas.getDimensions();
|
|
3180
|
+
var baseDimensions = canvas.getBaseDimensions();
|
|
3181
|
+
var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(ObjectType.TEXT))
|
|
3182
|
+
.filter(function (text) { return text.isResizeCanvas(); })
|
|
3183
|
+
.reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
|
|
3184
|
+
var increase = baseDimensions.withSize(currentDimensions.width, 0);
|
|
3185
|
+
while (increase.heightPx < textHeightIncreasePx) {
|
|
3186
|
+
increase = increase.withSize(increase.width, increase.height + 1);
|
|
3187
|
+
}
|
|
3188
|
+
var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
|
|
3189
|
+
if (currentDimensions.height !== targetHeight.height) {
|
|
3190
|
+
canvas.setDimensions(targetHeight);
|
|
3191
|
+
}
|
|
3192
|
+
canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
|
|
3193
|
+
canvas.redraw();
|
|
3194
|
+
};
|
|
3195
|
+
return ResizeCanvasLayoutFunction;
|
|
3196
|
+
}());
|
|
3197
|
+
|
|
3198
|
+
var AdvancedLayoutManager = /** @class */ (function (_super) {
|
|
3199
|
+
__extends(AdvancedLayoutManager, _super);
|
|
3200
|
+
function AdvancedLayoutManager(canvas) {
|
|
3201
|
+
var _this = _super.call(this, canvas) || this;
|
|
3202
|
+
_this.key = LayoutManager.ADVANCED;
|
|
3203
|
+
_this.pinToBottom = new PinToBottomLayoutFunction();
|
|
3204
|
+
_this.redrawAll = new RedrawAllLayoutFunction();
|
|
3205
|
+
_this.repositionBorders = new RepositionBordersLayoutFunction();
|
|
3206
|
+
_this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
|
|
3207
|
+
_this.resizeCanvas = new ResizeCanvasLayoutFunction();
|
|
3208
|
+
return _this;
|
|
3209
|
+
}
|
|
3210
|
+
AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
3211
|
+
this.pinToBottom.execute(this.canvas);
|
|
3212
|
+
this.repositionCutoffs.execute(this.canvas);
|
|
3213
|
+
this.repositionBorders.execute(this.canvas);
|
|
3214
|
+
this.redrawAll.execute(this.canvas);
|
|
3215
|
+
};
|
|
3216
|
+
AdvancedLayoutManager.prototype.onTextChange = function () {
|
|
3217
|
+
this.resizeCanvas.execute(this.canvas);
|
|
3218
|
+
};
|
|
3219
|
+
AdvancedLayoutManager.prototype.onObjectListChange = function () {
|
|
3220
|
+
this.redrawAll.execute(this.canvas);
|
|
3221
|
+
};
|
|
3222
|
+
return AdvancedLayoutManager;
|
|
3223
|
+
}(AbstractLayoutManager));
|
|
3224
|
+
|
|
3195
3225
|
export { AbstractCanvasObject, AbstractInteractiveCanvas, AbstractLayoutManager, AdvancedLayoutManager, Border, CanvasObjectData, Cutoff, DefaultCanvasProfile, Font, FontLibrary, HeadlessInteractiveCanvas, HorizontalRule, Image, ImageType, InteractiveCanvas, LayoutManager, ObjectType, PixelCanvasDimensions, Print6ColCanvasDimensions, Print8ColCanvasDimensions, Rectangle, SelectionData, StandardLayoutManager, Text, UNKNOWN_FONT, UnknownFont, VerticalRule, isMutableBackgroundColor, isMutableColor, isMutableImage, isMutablePosition, isMutableText, isMutableTextStyle };
|
|
@@ -263,94 +263,12 @@ var RedrawAllLayoutFunction = /** @class */ (function () {
|
|
|
263
263
|
return RedrawAllLayoutFunction;
|
|
264
264
|
}());
|
|
265
265
|
|
|
266
|
-
var RepositionCutoffsLayoutFunction = /** @class */ (function () {
|
|
267
|
-
function RepositionCutoffsLayoutFunction() {
|
|
268
|
-
}
|
|
269
|
-
RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
|
|
270
|
-
canvas.getObjectsByTypeInternal(exports.ObjectType.CUTOFF)
|
|
271
|
-
.forEach(function (cutoff) { return cutoff.updatePosition(); });
|
|
272
|
-
};
|
|
273
|
-
return RepositionCutoffsLayoutFunction;
|
|
274
|
-
}());
|
|
275
|
-
|
|
276
|
-
var RepositionBordersLayoutFunction = /** @class */ (function () {
|
|
277
|
-
function RepositionBordersLayoutFunction() {
|
|
278
|
-
}
|
|
279
|
-
RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
|
|
280
|
-
canvas.getObjectsByTypeInternal(exports.ObjectType.BORDER)
|
|
281
|
-
.forEach(function (border) { return border.updatePosition(); });
|
|
282
|
-
};
|
|
283
|
-
return RepositionBordersLayoutFunction;
|
|
284
|
-
}());
|
|
285
|
-
|
|
286
|
-
var PinToBottomLayoutFunction = /** @class */ (function () {
|
|
287
|
-
function PinToBottomLayoutFunction() {
|
|
288
|
-
}
|
|
289
|
-
PinToBottomLayoutFunction.prototype.execute = function (canvas) {
|
|
290
|
-
canvas.getObjectsInternal()
|
|
291
|
-
.forEach(function (object) { return object.moveToPinnedPosition(); });
|
|
292
|
-
};
|
|
293
|
-
return PinToBottomLayoutFunction;
|
|
294
|
-
}());
|
|
295
|
-
|
|
296
|
-
var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
297
|
-
function ResizeCanvasLayoutFunction() {
|
|
298
|
-
}
|
|
299
|
-
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
300
|
-
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
301
|
-
return;
|
|
302
|
-
var currentDimensions = canvas.getDimensions();
|
|
303
|
-
var baseDimensions = canvas.getBaseDimensions();
|
|
304
|
-
var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(exports.ObjectType.TEXT))
|
|
305
|
-
.filter(function (text) { return text.isResizeCanvas(); })
|
|
306
|
-
.reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
|
|
307
|
-
var increase = baseDimensions.withSize(currentDimensions.width, 0);
|
|
308
|
-
while (increase.heightPx < textHeightIncreasePx) {
|
|
309
|
-
increase = increase.withSize(increase.width, increase.height + 1);
|
|
310
|
-
}
|
|
311
|
-
var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
|
|
312
|
-
if (currentDimensions.height !== targetHeight.height) {
|
|
313
|
-
canvas.setDimensions(targetHeight);
|
|
314
|
-
}
|
|
315
|
-
canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
|
|
316
|
-
canvas.redraw();
|
|
317
|
-
};
|
|
318
|
-
return ResizeCanvasLayoutFunction;
|
|
319
|
-
}());
|
|
320
|
-
|
|
321
266
|
(function (LayoutManager) {
|
|
322
267
|
LayoutManager["LEGACY"] = "LEGACY";
|
|
323
268
|
LayoutManager["STANDARD"] = "STANDARD";
|
|
324
269
|
LayoutManager["ADVANCED"] = "ADVANCED";
|
|
325
270
|
})(exports.LayoutManager || (exports.LayoutManager = {}));
|
|
326
271
|
|
|
327
|
-
var AdvancedLayoutManager = /** @class */ (function (_super) {
|
|
328
|
-
__extends(AdvancedLayoutManager, _super);
|
|
329
|
-
function AdvancedLayoutManager(canvas) {
|
|
330
|
-
var _this = _super.call(this, canvas) || this;
|
|
331
|
-
_this.key = exports.LayoutManager.ADVANCED;
|
|
332
|
-
_this.pinToBottom = new PinToBottomLayoutFunction();
|
|
333
|
-
_this.redrawAll = new RedrawAllLayoutFunction();
|
|
334
|
-
_this.repositionBorders = new RepositionBordersLayoutFunction();
|
|
335
|
-
_this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
|
|
336
|
-
_this.resizeCanvas = new ResizeCanvasLayoutFunction();
|
|
337
|
-
return _this;
|
|
338
|
-
}
|
|
339
|
-
AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
340
|
-
this.pinToBottom.execute(this.canvas);
|
|
341
|
-
this.repositionCutoffs.execute(this.canvas);
|
|
342
|
-
this.repositionBorders.execute(this.canvas);
|
|
343
|
-
this.redrawAll.execute(this.canvas);
|
|
344
|
-
};
|
|
345
|
-
AdvancedLayoutManager.prototype.onTextChange = function () {
|
|
346
|
-
this.resizeCanvas.execute(this.canvas);
|
|
347
|
-
};
|
|
348
|
-
AdvancedLayoutManager.prototype.onObjectListChange = function () {
|
|
349
|
-
this.redrawAll.execute(this.canvas);
|
|
350
|
-
};
|
|
351
|
-
return AdvancedLayoutManager;
|
|
352
|
-
}(AbstractLayoutManager));
|
|
353
|
-
|
|
354
272
|
var UpdateObjectDimensionsLayoutFunction = /** @class */ (function () {
|
|
355
273
|
function UpdateObjectDimensionsLayoutFunction() {
|
|
356
274
|
}
|
|
@@ -512,6 +430,16 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
512
430
|
return StackObjectsLayoutFunction;
|
|
513
431
|
}());
|
|
514
432
|
|
|
433
|
+
var RepositionBordersLayoutFunction = /** @class */ (function () {
|
|
434
|
+
function RepositionBordersLayoutFunction() {
|
|
435
|
+
}
|
|
436
|
+
RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
|
|
437
|
+
canvas.getObjectsByTypeInternal(exports.ObjectType.BORDER)
|
|
438
|
+
.forEach(function (border) { return border.updatePosition(); });
|
|
439
|
+
};
|
|
440
|
+
return RepositionBordersLayoutFunction;
|
|
441
|
+
}());
|
|
442
|
+
|
|
515
443
|
var StandardLayoutManager = /** @class */ (function (_super) {
|
|
516
444
|
__extends(StandardLayoutManager, _super);
|
|
517
445
|
function StandardLayoutManager(canvas) {
|
|
@@ -1043,6 +971,26 @@ var Border = /** @class */ (function (_super) {
|
|
|
1043
971
|
this.canvas.notifyMarginChanged();
|
|
1044
972
|
this.redraw();
|
|
1045
973
|
};
|
|
974
|
+
Border.prototype.getPadding = function () {
|
|
975
|
+
return this.data.padding || {
|
|
976
|
+
top: 2,
|
|
977
|
+
right: 2,
|
|
978
|
+
bottom: 2,
|
|
979
|
+
left: 2
|
|
980
|
+
};
|
|
981
|
+
};
|
|
982
|
+
Border.prototype.setPadding = function (padding) {
|
|
983
|
+
if (!padding)
|
|
984
|
+
return;
|
|
985
|
+
this.data.padding = {
|
|
986
|
+
top: padding.top || 2,
|
|
987
|
+
right: padding.right || 2,
|
|
988
|
+
bottom: padding.bottom || 2,
|
|
989
|
+
left: padding.left || 2
|
|
990
|
+
};
|
|
991
|
+
this.canvas.notifyMarginChanged();
|
|
992
|
+
this.redraw();
|
|
993
|
+
};
|
|
1046
994
|
Border.prototype.updatePosition = function () {
|
|
1047
995
|
this.fabricObject.set({
|
|
1048
996
|
strokeWidth: this.strokeWidth$.value,
|
|
@@ -2456,15 +2404,25 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
2456
2404
|
var borderWidth = this.getObjectsByTypeInternal(exports.ObjectType.BORDER)
|
|
2457
2405
|
.map(function (border) { return border.getStrokeWidth(); })
|
|
2458
2406
|
.reduce(function (current, next) { return Math.max(current, next); }, 0);
|
|
2407
|
+
var borderPadding = this.getObjectsByTypeInternal(exports.ObjectType.BORDER)
|
|
2408
|
+
.map(function (border) { return border.getPadding(); })
|
|
2409
|
+
.reduce(function (current, next) {
|
|
2410
|
+
return {
|
|
2411
|
+
top: Math.max(current.top, next.top),
|
|
2412
|
+
right: Math.max(current.right, next.right),
|
|
2413
|
+
bottom: Math.max(current.bottom, next.bottom),
|
|
2414
|
+
left: Math.max(current.bottom, next.bottom)
|
|
2415
|
+
};
|
|
2416
|
+
}, { top: 0, right: 0, bottom: 0, left: 0 });
|
|
2459
2417
|
var cutoffWidth = this.getObjectsByTypeInternal(exports.ObjectType.CUTOFF)
|
|
2460
2418
|
.map(function (border) { return border.getStrokeWidth(); })
|
|
2461
2419
|
.reduce(function (current, next) { return Math.max(current, next); }, 0);
|
|
2462
2420
|
// noinspection JSSuspiciousNameCombination
|
|
2463
2421
|
return {
|
|
2464
|
-
top: borderWidth,
|
|
2465
|
-
right: borderWidth,
|
|
2466
|
-
bottom: Math.max(cutoffWidth, borderWidth),
|
|
2467
|
-
left: borderWidth
|
|
2422
|
+
top: borderWidth + borderPadding.top,
|
|
2423
|
+
right: borderWidth + borderPadding.right,
|
|
2424
|
+
bottom: Math.max(cutoffWidth, borderWidth) + borderPadding.bottom,
|
|
2425
|
+
left: borderWidth + borderPadding.left
|
|
2468
2426
|
};
|
|
2469
2427
|
};
|
|
2470
2428
|
/**
|
|
@@ -3192,6 +3150,78 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3192
3150
|
return InteractiveCanvas;
|
|
3193
3151
|
}(AbstractInteractiveCanvas));
|
|
3194
3152
|
|
|
3153
|
+
var RepositionCutoffsLayoutFunction = /** @class */ (function () {
|
|
3154
|
+
function RepositionCutoffsLayoutFunction() {
|
|
3155
|
+
}
|
|
3156
|
+
RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
|
|
3157
|
+
canvas.getObjectsByTypeInternal(exports.ObjectType.CUTOFF)
|
|
3158
|
+
.forEach(function (cutoff) { return cutoff.updatePosition(); });
|
|
3159
|
+
};
|
|
3160
|
+
return RepositionCutoffsLayoutFunction;
|
|
3161
|
+
}());
|
|
3162
|
+
|
|
3163
|
+
var PinToBottomLayoutFunction = /** @class */ (function () {
|
|
3164
|
+
function PinToBottomLayoutFunction() {
|
|
3165
|
+
}
|
|
3166
|
+
PinToBottomLayoutFunction.prototype.execute = function (canvas) {
|
|
3167
|
+
canvas.getObjectsInternal()
|
|
3168
|
+
.forEach(function (object) { return object.moveToPinnedPosition(); });
|
|
3169
|
+
};
|
|
3170
|
+
return PinToBottomLayoutFunction;
|
|
3171
|
+
}());
|
|
3172
|
+
|
|
3173
|
+
var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
3174
|
+
function ResizeCanvasLayoutFunction() {
|
|
3175
|
+
}
|
|
3176
|
+
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
3177
|
+
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
3178
|
+
return;
|
|
3179
|
+
var currentDimensions = canvas.getDimensions();
|
|
3180
|
+
var baseDimensions = canvas.getBaseDimensions();
|
|
3181
|
+
var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(exports.ObjectType.TEXT))
|
|
3182
|
+
.filter(function (text) { return text.isResizeCanvas(); })
|
|
3183
|
+
.reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
|
|
3184
|
+
var increase = baseDimensions.withSize(currentDimensions.width, 0);
|
|
3185
|
+
while (increase.heightPx < textHeightIncreasePx) {
|
|
3186
|
+
increase = increase.withSize(increase.width, increase.height + 1);
|
|
3187
|
+
}
|
|
3188
|
+
var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
|
|
3189
|
+
if (currentDimensions.height !== targetHeight.height) {
|
|
3190
|
+
canvas.setDimensions(targetHeight);
|
|
3191
|
+
}
|
|
3192
|
+
canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
|
|
3193
|
+
canvas.redraw();
|
|
3194
|
+
};
|
|
3195
|
+
return ResizeCanvasLayoutFunction;
|
|
3196
|
+
}());
|
|
3197
|
+
|
|
3198
|
+
var AdvancedLayoutManager = /** @class */ (function (_super) {
|
|
3199
|
+
__extends(AdvancedLayoutManager, _super);
|
|
3200
|
+
function AdvancedLayoutManager(canvas) {
|
|
3201
|
+
var _this = _super.call(this, canvas) || this;
|
|
3202
|
+
_this.key = exports.LayoutManager.ADVANCED;
|
|
3203
|
+
_this.pinToBottom = new PinToBottomLayoutFunction();
|
|
3204
|
+
_this.redrawAll = new RedrawAllLayoutFunction();
|
|
3205
|
+
_this.repositionBorders = new RepositionBordersLayoutFunction();
|
|
3206
|
+
_this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
|
|
3207
|
+
_this.resizeCanvas = new ResizeCanvasLayoutFunction();
|
|
3208
|
+
return _this;
|
|
3209
|
+
}
|
|
3210
|
+
AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
3211
|
+
this.pinToBottom.execute(this.canvas);
|
|
3212
|
+
this.repositionCutoffs.execute(this.canvas);
|
|
3213
|
+
this.repositionBorders.execute(this.canvas);
|
|
3214
|
+
this.redrawAll.execute(this.canvas);
|
|
3215
|
+
};
|
|
3216
|
+
AdvancedLayoutManager.prototype.onTextChange = function () {
|
|
3217
|
+
this.resizeCanvas.execute(this.canvas);
|
|
3218
|
+
};
|
|
3219
|
+
AdvancedLayoutManager.prototype.onObjectListChange = function () {
|
|
3220
|
+
this.redrawAll.execute(this.canvas);
|
|
3221
|
+
};
|
|
3222
|
+
return AdvancedLayoutManager;
|
|
3223
|
+
}(AbstractLayoutManager));
|
|
3224
|
+
|
|
3195
3225
|
exports.AbstractCanvasObject = AbstractCanvasObject;
|
|
3196
3226
|
exports.AbstractInteractiveCanvas = AbstractInteractiveCanvas;
|
|
3197
3227
|
exports.AbstractLayoutManager = AbstractLayoutManager;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IMargin, ObjectType } from "..";
|
|
1
|
+
import { IMargin, IRect, ObjectType } from "..";
|
|
2
2
|
/**
|
|
3
3
|
* Data for a persisted canvas object.
|
|
4
4
|
*/
|
|
@@ -11,6 +11,7 @@ export declare class CanvasObjectData {
|
|
|
11
11
|
columnWidthPercent?: number;
|
|
12
12
|
color?: string;
|
|
13
13
|
strokeWidth?: number;
|
|
14
|
+
padding?: IRect;
|
|
14
15
|
editable?: boolean;
|
|
15
16
|
prefillType: string;
|
|
16
17
|
sortCaption?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
2
|
import { ICanvasObject } from "../canvas-object.interface";
|
|
3
|
-
import { IInteractiveCanvas, IMutableColor } from "../..";
|
|
3
|
+
import { IInteractiveCanvas, IMutableColor, IRect } from "../..";
|
|
4
4
|
import { AbstractCanvasObject } from "../abstract-canvas-object";
|
|
5
5
|
import { CanvasObjectData } from "../canvas-object-data";
|
|
6
6
|
import { fabric } from "fabric";
|
|
@@ -21,6 +21,15 @@ export interface IBorder extends ICanvasObject, IMutableColor {
|
|
|
21
21
|
* @param width New width.
|
|
22
22
|
*/
|
|
23
23
|
setStrokeWidth(width: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* Get the padding within the border.
|
|
26
|
+
*/
|
|
27
|
+
getPadding(): IRect;
|
|
28
|
+
/**
|
|
29
|
+
* Set the padding within the border.
|
|
30
|
+
* @param padding New padding.
|
|
31
|
+
*/
|
|
32
|
+
setPadding(padding: any): void;
|
|
24
33
|
}
|
|
25
34
|
export declare class Border extends AbstractCanvasObject<fabric.Rect> implements IBorder {
|
|
26
35
|
private readonly strokeWidth$;
|
|
@@ -50,6 +59,8 @@ export declare class Border extends AbstractCanvasObject<fabric.Rect> implements
|
|
|
50
59
|
* @inheritDoc
|
|
51
60
|
*/
|
|
52
61
|
setStrokeWidth(width: number): void;
|
|
62
|
+
getPadding(): IRect;
|
|
63
|
+
setPadding(padding: any): void;
|
|
53
64
|
updatePosition(): void;
|
|
54
65
|
/**
|
|
55
66
|
* @override
|