@leapfrog/interactive-canvas 2.0.17-beta-2 → 2.0.18
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 +0 -3
- package/dist/interactive-canvas.es.js +256 -298
- package/dist/interactive-canvas.js +267 -317
- package/dist/mutator/mutable-text.interface.d.ts +0 -6
- package/dist/object/impl/text.d.ts +1 -11
- package/dist/types/selection-data.interface.d.ts +0 -9
- package/dist/types/text-alignment.interface.d.ts +1 -1
- package/package.json +4 -1
|
@@ -3,33 +3,30 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _ = require('lodash');
|
|
6
|
+
var tsOptchain = require('ts-optchain');
|
|
6
7
|
var rxjs = require('rxjs');
|
|
7
8
|
var fabric = require('fabric');
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
12
|
-
|
|
13
|
-
var PIXELS_PER_MM$2 = 3.937;
|
|
10
|
+
var PIXELS_PER_MM = 3.937;
|
|
14
11
|
var MillimeterDimensions = /** @class */ (function () {
|
|
15
12
|
function MillimeterDimensions(width, height) {
|
|
16
13
|
this.widthUnit = "mm";
|
|
17
14
|
this.heightUnit = "mm";
|
|
18
15
|
this.width = width;
|
|
19
16
|
this.widthMm = Math.max(0, width);
|
|
20
|
-
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM
|
|
17
|
+
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM);
|
|
21
18
|
this.height = height;
|
|
22
19
|
this.heightMm = Math.max(0, height);
|
|
23
|
-
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM
|
|
20
|
+
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM);
|
|
24
21
|
}
|
|
25
22
|
MillimeterDimensions.prototype.withSize = function (width, height) {
|
|
26
23
|
return new MillimeterDimensions(width, height);
|
|
27
24
|
};
|
|
28
25
|
MillimeterDimensions.prototype.widthPxToMm = function (px) {
|
|
29
|
-
return px / PIXELS_PER_MM
|
|
26
|
+
return px / PIXELS_PER_MM;
|
|
30
27
|
};
|
|
31
28
|
MillimeterDimensions.prototype.heightPxToMm = function (px) {
|
|
32
|
-
return px / PIXELS_PER_MM
|
|
29
|
+
return px / PIXELS_PER_MM;
|
|
33
30
|
};
|
|
34
31
|
return MillimeterDimensions;
|
|
35
32
|
}());
|
|
@@ -55,8 +52,8 @@ var PixelCanvasDimensions = /** @class */ (function () {
|
|
|
55
52
|
return PixelCanvasDimensions;
|
|
56
53
|
}());
|
|
57
54
|
|
|
58
|
-
var COLUMN_WIDTH_MM
|
|
59
|
-
var GUTTER_WIDTH_MM
|
|
55
|
+
var COLUMN_WIDTH_MM = 41;
|
|
56
|
+
var GUTTER_WIDTH_MM = 3;
|
|
60
57
|
var PIXELS_PER_MM$1 = 3.937;
|
|
61
58
|
var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
62
59
|
function Print6ColCanvasDimensions(width, height) {
|
|
@@ -64,8 +61,8 @@ var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
|
64
61
|
this.heightUnit = "cm";
|
|
65
62
|
this.width = width;
|
|
66
63
|
this.gutterCount = Math.max(0, width - 1);
|
|
67
|
-
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM
|
|
68
|
-
this.columnsTotalMm = width * COLUMN_WIDTH_MM
|
|
64
|
+
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM;
|
|
65
|
+
this.columnsTotalMm = width * COLUMN_WIDTH_MM;
|
|
69
66
|
this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
|
|
70
67
|
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM$1);
|
|
71
68
|
this.height = height;
|
|
@@ -84,119 +81,110 @@ var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
|
84
81
|
return Print6ColCanvasDimensions;
|
|
85
82
|
}());
|
|
86
83
|
|
|
87
|
-
var COLUMN_WIDTH_MM = 30.8772;
|
|
88
|
-
var GUTTER_WIDTH_MM = 2.1053;
|
|
89
|
-
var PIXELS_PER_MM = 3.937;
|
|
84
|
+
var COLUMN_WIDTH_MM$1 = 30.8772;
|
|
85
|
+
var GUTTER_WIDTH_MM$1 = 2.1053;
|
|
86
|
+
var PIXELS_PER_MM$2 = 3.937;
|
|
90
87
|
var Print8ColCanvasDimensions = /** @class */ (function () {
|
|
91
88
|
function Print8ColCanvasDimensions(width, height) {
|
|
92
89
|
this.widthUnit = "column(s)";
|
|
93
90
|
this.heightUnit = "cm";
|
|
94
91
|
this.width = width;
|
|
95
92
|
this.gutterCount = Math.max(0, width - 1);
|
|
96
|
-
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM;
|
|
97
|
-
this.columnsTotalMm = width * COLUMN_WIDTH_MM;
|
|
93
|
+
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM$1;
|
|
94
|
+
this.columnsTotalMm = width * COLUMN_WIDTH_MM$1;
|
|
98
95
|
this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
|
|
99
|
-
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM);
|
|
96
|
+
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM$2);
|
|
100
97
|
this.height = height;
|
|
101
98
|
this.heightMm = Math.max(0, height * 10);
|
|
102
|
-
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM);
|
|
99
|
+
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM$2);
|
|
103
100
|
}
|
|
104
101
|
Print8ColCanvasDimensions.prototype.withSize = function (width, height) {
|
|
105
102
|
return new Print8ColCanvasDimensions(width, height);
|
|
106
103
|
};
|
|
107
104
|
Print8ColCanvasDimensions.prototype.widthPxToMm = function (px) {
|
|
108
|
-
return px / PIXELS_PER_MM;
|
|
105
|
+
return px / PIXELS_PER_MM$2;
|
|
109
106
|
};
|
|
110
107
|
Print8ColCanvasDimensions.prototype.heightPxToMm = function (px) {
|
|
111
|
-
return px / PIXELS_PER_MM;
|
|
108
|
+
return px / PIXELS_PER_MM$2;
|
|
112
109
|
};
|
|
113
110
|
return Print8ColCanvasDimensions;
|
|
114
111
|
}());
|
|
115
112
|
|
|
116
|
-
|
|
117
|
-
Copyright (c) Microsoft Corporation.
|
|
118
|
-
|
|
119
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
120
|
-
purpose with or without fee is hereby granted.
|
|
121
|
-
|
|
122
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
123
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
124
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
125
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
126
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
127
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
128
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
129
|
-
***************************************************************************** */
|
|
130
|
-
/* global Reflect, Promise
|
|
131
|
-
|
|
132
|
-
var extendStatics = function(d, b) {
|
|
133
|
-
extendStatics = Object.setPrototypeOf ||
|
|
134
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
135
|
-
function (d, b) { for (var p in b) if (
|
|
136
|
-
return extendStatics(d, b);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
function __extends(d, b) {
|
|
140
|
-
if (typeof b !== "function" && b !== null)
|
|
141
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
142
|
-
extendStatics(d, b);
|
|
143
|
-
function __() { this.constructor = d; }
|
|
144
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
148
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
149
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
150
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
151
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
152
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
153
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function __generator(thisArg, body) {
|
|
158
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
159
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
160
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
161
|
-
function step(op) {
|
|
162
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
163
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
164
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
165
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
166
|
-
switch (op[0]) {
|
|
167
|
-
case 0: case 1: t = op; break;
|
|
168
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
169
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
170
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
171
|
-
default:
|
|
172
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
173
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
174
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
175
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
176
|
-
if (t[2]) _.ops.pop();
|
|
177
|
-
_.trys.pop(); continue;
|
|
178
|
-
}
|
|
179
|
-
op = body.call(thisArg, _);
|
|
180
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
181
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function __spreadArray(to, from, pack) {
|
|
186
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
187
|
-
if (ar || !(i in from)) {
|
|
188
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
189
|
-
ar[i] = from[i];
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
196
|
-
var e = new Error(message);
|
|
197
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
113
|
+
/*! *****************************************************************************
|
|
114
|
+
Copyright (c) Microsoft Corporation.
|
|
115
|
+
|
|
116
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
117
|
+
purpose with or without fee is hereby granted.
|
|
118
|
+
|
|
119
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
120
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
121
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
122
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
123
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
124
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
125
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
126
|
+
***************************************************************************** */
|
|
127
|
+
/* global Reflect, Promise */
|
|
128
|
+
|
|
129
|
+
var extendStatics = function(d, b) {
|
|
130
|
+
extendStatics = Object.setPrototypeOf ||
|
|
131
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
132
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
133
|
+
return extendStatics(d, b);
|
|
198
134
|
};
|
|
199
135
|
|
|
136
|
+
function __extends(d, b) {
|
|
137
|
+
extendStatics(d, b);
|
|
138
|
+
function __() { this.constructor = d; }
|
|
139
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
143
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
144
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
145
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
146
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
147
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
148
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function __generator(thisArg, body) {
|
|
153
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
154
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
155
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
156
|
+
function step(op) {
|
|
157
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
158
|
+
while (_) try {
|
|
159
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
160
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
161
|
+
switch (op[0]) {
|
|
162
|
+
case 0: case 1: t = op; break;
|
|
163
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
164
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
165
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
166
|
+
default:
|
|
167
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
168
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
169
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
170
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
171
|
+
if (t[2]) _.ops.pop();
|
|
172
|
+
_.trys.pop(); continue;
|
|
173
|
+
}
|
|
174
|
+
op = body.call(thisArg, _);
|
|
175
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
176
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function __spreadArrays() {
|
|
181
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
182
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
183
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
184
|
+
r[k] = a[j];
|
|
185
|
+
return r;
|
|
186
|
+
}
|
|
187
|
+
|
|
200
188
|
var Font = /** @class */ (function () {
|
|
201
189
|
function Font() {
|
|
202
190
|
}
|
|
@@ -299,110 +287,12 @@ var RedrawAllLayoutFunction = /** @class */ (function () {
|
|
|
299
287
|
return RedrawAllLayoutFunction;
|
|
300
288
|
}());
|
|
301
289
|
|
|
302
|
-
var RepositionCutoffsLayoutFunction = /** @class */ (function () {
|
|
303
|
-
function RepositionCutoffsLayoutFunction() {
|
|
304
|
-
}
|
|
305
|
-
RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
|
|
306
|
-
canvas.getObjectsByTypeInternal(exports.ObjectType.CUTOFF)
|
|
307
|
-
.forEach(function (cutoff) { return cutoff.updatePosition(); });
|
|
308
|
-
};
|
|
309
|
-
return RepositionCutoffsLayoutFunction;
|
|
310
|
-
}());
|
|
311
|
-
|
|
312
|
-
var RepositionBordersLayoutFunction = /** @class */ (function () {
|
|
313
|
-
function RepositionBordersLayoutFunction() {
|
|
314
|
-
}
|
|
315
|
-
RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
|
|
316
|
-
canvas.getObjectsByTypeInternal(exports.ObjectType.BORDER)
|
|
317
|
-
.forEach(function (border) { return border.updatePosition(); });
|
|
318
|
-
};
|
|
319
|
-
return RepositionBordersLayoutFunction;
|
|
320
|
-
}());
|
|
321
|
-
|
|
322
|
-
var PinToBottomLayoutFunction = /** @class */ (function () {
|
|
323
|
-
function PinToBottomLayoutFunction() {
|
|
324
|
-
}
|
|
325
|
-
PinToBottomLayoutFunction.prototype.execute = function (canvas) {
|
|
326
|
-
canvas.getObjectsInternal()
|
|
327
|
-
.forEach(function (object) { return object.moveToPinnedPosition(); });
|
|
328
|
-
};
|
|
329
|
-
return PinToBottomLayoutFunction;
|
|
330
|
-
}());
|
|
331
|
-
|
|
332
|
-
var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
333
|
-
function ResizeCanvasLayoutFunction() {
|
|
334
|
-
}
|
|
335
|
-
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
336
|
-
var _a, _b;
|
|
337
|
-
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
338
|
-
return;
|
|
339
|
-
if ((_b = (_a = canvas === null || canvas === void 0 ? void 0 : canvas.getDimensionsRestrictions()) === null || _a === void 0 ? void 0 : _a.fixed) !== null && _b !== void 0 ? _b : false)
|
|
340
|
-
return;
|
|
341
|
-
var currentDimensions = canvas.getDimensions();
|
|
342
|
-
var baseDimensions = canvas.getBaseDimensions();
|
|
343
|
-
var textHeightIncreasePx = ___default["default"](canvas.getObjectsByTypeInternal(exports.ObjectType.TEXT))
|
|
344
|
-
.filter(function (text) { return text.isResizeCanvas(); })
|
|
345
|
-
.reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
|
|
346
|
-
var increase = baseDimensions.withSize(currentDimensions.width, 0);
|
|
347
|
-
while (increase.heightPx < textHeightIncreasePx) {
|
|
348
|
-
increase = increase.withSize(increase.width, increase.height + 1);
|
|
349
|
-
}
|
|
350
|
-
var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
|
|
351
|
-
if (currentDimensions.height !== targetHeight.height) {
|
|
352
|
-
canvas.setDimensions(targetHeight);
|
|
353
|
-
}
|
|
354
|
-
canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
|
|
355
|
-
canvas.redraw();
|
|
356
|
-
};
|
|
357
|
-
return ResizeCanvasLayoutFunction;
|
|
358
|
-
}());
|
|
359
|
-
|
|
360
|
-
exports.LayoutManager = void 0;
|
|
361
290
|
(function (LayoutManager) {
|
|
362
291
|
LayoutManager["LEGACY"] = "LEGACY";
|
|
363
292
|
LayoutManager["STANDARD"] = "STANDARD";
|
|
364
293
|
LayoutManager["ADVANCED"] = "ADVANCED";
|
|
365
294
|
})(exports.LayoutManager || (exports.LayoutManager = {}));
|
|
366
295
|
|
|
367
|
-
var RepositionBackgroundsLayoutFunction = /** @class */ (function () {
|
|
368
|
-
function RepositionBackgroundsLayoutFunction() {
|
|
369
|
-
}
|
|
370
|
-
RepositionBackgroundsLayoutFunction.prototype.execute = function (canvas) {
|
|
371
|
-
canvas.getObjectsByTypeInternal(exports.ObjectType.BACKGROUND_IMAGE)
|
|
372
|
-
.forEach(function (border) { return border.updatePosition(); });
|
|
373
|
-
};
|
|
374
|
-
return RepositionBackgroundsLayoutFunction;
|
|
375
|
-
}());
|
|
376
|
-
|
|
377
|
-
var AdvancedLayoutManager = /** @class */ (function (_super) {
|
|
378
|
-
__extends(AdvancedLayoutManager, _super);
|
|
379
|
-
function AdvancedLayoutManager(canvas) {
|
|
380
|
-
var _this = _super.call(this, canvas) || this;
|
|
381
|
-
_this.key = exports.LayoutManager.ADVANCED;
|
|
382
|
-
_this.pinToBottom = new PinToBottomLayoutFunction();
|
|
383
|
-
_this.redrawAll = new RedrawAllLayoutFunction();
|
|
384
|
-
_this.repositionBorders = new RepositionBordersLayoutFunction();
|
|
385
|
-
_this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
|
|
386
|
-
_this.repositionBackgrounds = new RepositionBackgroundsLayoutFunction();
|
|
387
|
-
_this.resizeCanvas = new ResizeCanvasLayoutFunction();
|
|
388
|
-
return _this;
|
|
389
|
-
}
|
|
390
|
-
AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
391
|
-
this.pinToBottom.execute(this.canvas);
|
|
392
|
-
this.repositionCutoffs.execute(this.canvas);
|
|
393
|
-
this.repositionBorders.execute(this.canvas);
|
|
394
|
-
this.repositionBackgrounds.execute(this.canvas);
|
|
395
|
-
this.redrawAll.execute(this.canvas);
|
|
396
|
-
};
|
|
397
|
-
AdvancedLayoutManager.prototype.onTextChange = function () {
|
|
398
|
-
this.resizeCanvas.execute(this.canvas);
|
|
399
|
-
};
|
|
400
|
-
AdvancedLayoutManager.prototype.onObjectListChange = function () {
|
|
401
|
-
this.redrawAll.execute(this.canvas);
|
|
402
|
-
};
|
|
403
|
-
return AdvancedLayoutManager;
|
|
404
|
-
}(AbstractLayoutManager));
|
|
405
|
-
|
|
406
296
|
var UpdateObjectDimensionsLayoutFunction = /** @class */ (function () {
|
|
407
297
|
function UpdateObjectDimensionsLayoutFunction() {
|
|
408
298
|
}
|
|
@@ -420,7 +310,7 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
420
310
|
var canvasMargin = canvas.getMargin();
|
|
421
311
|
var canvasDimensions = canvas.getDimensions();
|
|
422
312
|
var allObjects = canvas.getObjectsByTypesInternal(exports.ObjectType.TEXT, exports.ObjectType.RICH_TEXT, exports.ObjectType.IMAGE, exports.ObjectType.RECTANGLE, exports.ObjectType.VERTICAL_RULE, exports.ObjectType.HORIZONTAL_RULE);
|
|
423
|
-
var objects =
|
|
313
|
+
var objects = _(allObjects)
|
|
424
314
|
.partition(function (object) { return object.isPinToBottom(); })
|
|
425
315
|
.value();
|
|
426
316
|
var footerObjects = objects[0];
|
|
@@ -444,14 +334,13 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
444
334
|
var currentColumnWidthPercent = 0;
|
|
445
335
|
_.each(footerRows.rows, function (row) {
|
|
446
336
|
_.each(row.objects, function (object) {
|
|
447
|
-
var _a, _b, _c;
|
|
448
337
|
var columnOffset = currentColumnWidthPercent / 100 * layoutAreaWidth;
|
|
449
|
-
var objectMargin = (
|
|
338
|
+
var objectMargin = tsOptchain.oc(object.getMargin()).left(0);
|
|
450
339
|
var left = canvasMargin.left + columnOffset + objectMargin;
|
|
451
340
|
if (object.getType() === exports.ObjectType.VERTICAL_RULE)
|
|
452
341
|
object.setPosition({ height: row.height });
|
|
453
342
|
object.setPosition({
|
|
454
|
-
top: nextObjectTop + (
|
|
343
|
+
top: nextObjectTop + tsOptchain.oc(object.getMargin()).top(0),
|
|
455
344
|
left: left
|
|
456
345
|
});
|
|
457
346
|
currentColumnWidthPercent += object.getColumnWidthPercent();
|
|
@@ -461,7 +350,6 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
461
350
|
});
|
|
462
351
|
};
|
|
463
352
|
StackObjectsLayoutFunction.prototype.layoutBody = function (bodyRows, canvas, footerHeight) {
|
|
464
|
-
var _a, _b, _c, _d;
|
|
465
353
|
var canvasDimensions = canvas.getDimensions();
|
|
466
354
|
var canvasMargin = canvas.getMargin();
|
|
467
355
|
var workableWidth = canvasDimensions.widthPx - canvasMargin.left - canvasMargin.right;
|
|
@@ -474,10 +362,10 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
474
362
|
for (var i = 0; i < bodyRows.rows.length; i++) {
|
|
475
363
|
var row = bodyRows.rows[i];
|
|
476
364
|
var nextRow = bodyRows.rows[i + 1];
|
|
477
|
-
for (var _i = 0,
|
|
478
|
-
var object =
|
|
365
|
+
for (var _i = 0, _a = row.objects; _i < _a.length; _i++) {
|
|
366
|
+
var object = _a[_i];
|
|
479
367
|
var columnOffset = currentColumnWidthPercent / 100 * workableWidth;
|
|
480
|
-
var objectMargin = (
|
|
368
|
+
var objectMargin = tsOptchain.oc(object.getMargin()).left(0);
|
|
481
369
|
var objectLeft = canvasMargin.left + columnOffset + objectMargin;
|
|
482
370
|
if (object.getType() === exports.ObjectType.TEXT && object.isBulleted())
|
|
483
371
|
objectLeft += object.getBulletMargin();
|
|
@@ -486,7 +374,7 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
486
374
|
if (object.getType() === exports.ObjectType.VERTICAL_RULE)
|
|
487
375
|
return;
|
|
488
376
|
object.setPosition({
|
|
489
|
-
top: nextObjectTop + (
|
|
377
|
+
top: nextObjectTop + tsOptchain.oc(object.getMargin()).top(0),
|
|
490
378
|
left: objectLeft
|
|
491
379
|
});
|
|
492
380
|
currentColumnWidthPercent += object.getColumnWidthPercent();
|
|
@@ -494,17 +382,16 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
494
382
|
currentColumnWidthPercent = 0;
|
|
495
383
|
nextObjectTop += row.height;
|
|
496
384
|
var thisRowIsHR = row.objects.length === 1 && row.objects[0].getType() === exports.ObjectType.HORIZONTAL_RULE;
|
|
497
|
-
var nextRowIsHR = (
|
|
385
|
+
var nextRowIsHR = tsOptchain.oc(nextRow).objects.length() === 1 && tsOptchain.oc(nextRow).objects()[0].getType() === exports.ObjectType.HORIZONTAL_RULE;
|
|
498
386
|
if (!thisRowIsHR && !nextRowIsHR) {
|
|
499
387
|
nextObjectTop += spaceSize;
|
|
500
388
|
}
|
|
501
389
|
}
|
|
502
390
|
};
|
|
503
391
|
StackObjectsLayoutFunction.prototype.applyWidths = function (objects, layoutWidth) {
|
|
504
|
-
|
|
505
|
-
var _a, _b;
|
|
392
|
+
_(objects).forEach(function (object) {
|
|
506
393
|
var targetWidth = object.getColumnWidthPercent() / 100 * layoutWidth;
|
|
507
|
-
var actualWidth = targetWidth - (
|
|
394
|
+
var actualWidth = targetWidth - tsOptchain.oc(object.getMargin()).left(0) - tsOptchain.oc(object.getMargin()).right(0);
|
|
508
395
|
if (object.getType() === exports.ObjectType.VERTICAL_RULE)
|
|
509
396
|
return;
|
|
510
397
|
if (object.getType() === exports.ObjectType.TEXT && object.isBulleted())
|
|
@@ -518,11 +405,10 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
518
405
|
});
|
|
519
406
|
};
|
|
520
407
|
StackObjectsLayoutFunction.prototype.adjustCanvasSize = function (canvas, requiredHeight) {
|
|
521
|
-
|
|
522
|
-
if ((_a = canvas === null || canvas === void 0 ? void 0 : canvas.getDimensionsRestrictions()) === null || _a === void 0 ? void 0 : _a.fixed)
|
|
408
|
+
if (tsOptchain.oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
523
409
|
return;
|
|
524
410
|
var dimensions = canvas.getDimensions();
|
|
525
|
-
var minHeight = (
|
|
411
|
+
var minHeight = tsOptchain.oc(canvas.getDimensionsRestrictions()).height.min(MIN_MAGNITUDE);
|
|
526
412
|
var targetDimensions = canvas.getDimensions().withSize(dimensions.width, minHeight);
|
|
527
413
|
while (targetDimensions.heightPx < requiredHeight) {
|
|
528
414
|
targetDimensions = targetDimensions.withSize(dimensions.width, targetDimensions.height + 1);
|
|
@@ -555,19 +441,17 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
555
441
|
return result;
|
|
556
442
|
};
|
|
557
443
|
StackObjectsLayoutFunction.prototype.getObjectHeight = function (element) {
|
|
558
|
-
var _a, _b;
|
|
559
444
|
return element.getBoundingBox().height
|
|
560
|
-
+ (
|
|
561
|
-
+ (
|
|
445
|
+
+ tsOptchain.oc(element.getMargin()).top(0)
|
|
446
|
+
+ tsOptchain.oc(element.getMargin()).bottom(0);
|
|
562
447
|
};
|
|
563
448
|
StackObjectsLayoutFunction.prototype.countSpaces = function (rows) {
|
|
564
|
-
var _a, _b;
|
|
565
449
|
var count = 0;
|
|
566
450
|
for (var i = 0; i < rows.rows.length - 1; i++) {
|
|
567
451
|
var row = rows.rows[i];
|
|
568
452
|
var nextRow = rows.rows[i + 1];
|
|
569
453
|
var thisRowIsHR = row.objects.length === 1 && row.objects[0].getType() === exports.ObjectType.HORIZONTAL_RULE;
|
|
570
|
-
var nextRowIsHR = (
|
|
454
|
+
var nextRowIsHR = tsOptchain.oc(nextRow).objects.length() === 1 && tsOptchain.oc(nextRow).objects()[0].getType() === exports.ObjectType.HORIZONTAL_RULE;
|
|
571
455
|
if (!thisRowIsHR && !nextRowIsHR) {
|
|
572
456
|
count++;
|
|
573
457
|
}
|
|
@@ -577,6 +461,26 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
577
461
|
return StackObjectsLayoutFunction;
|
|
578
462
|
}());
|
|
579
463
|
|
|
464
|
+
var RepositionBordersLayoutFunction = /** @class */ (function () {
|
|
465
|
+
function RepositionBordersLayoutFunction() {
|
|
466
|
+
}
|
|
467
|
+
RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
|
|
468
|
+
canvas.getObjectsByTypeInternal(exports.ObjectType.BORDER)
|
|
469
|
+
.forEach(function (border) { return border.updatePosition(); });
|
|
470
|
+
};
|
|
471
|
+
return RepositionBordersLayoutFunction;
|
|
472
|
+
}());
|
|
473
|
+
|
|
474
|
+
var RepositionBackgroundsLayoutFunction = /** @class */ (function () {
|
|
475
|
+
function RepositionBackgroundsLayoutFunction() {
|
|
476
|
+
}
|
|
477
|
+
RepositionBackgroundsLayoutFunction.prototype.execute = function (canvas) {
|
|
478
|
+
canvas.getObjectsByTypeInternal(exports.ObjectType.BACKGROUND_IMAGE)
|
|
479
|
+
.forEach(function (border) { return border.updatePosition(); });
|
|
480
|
+
};
|
|
481
|
+
return RepositionBackgroundsLayoutFunction;
|
|
482
|
+
}());
|
|
483
|
+
|
|
580
484
|
var StandardLayoutManager = /** @class */ (function (_super) {
|
|
581
485
|
__extends(StandardLayoutManager, _super);
|
|
582
486
|
function StandardLayoutManager(canvas) {
|
|
@@ -809,15 +713,14 @@ var AbstractCanvasObject = /** @class */ (function () {
|
|
|
809
713
|
* @inheritDoc
|
|
810
714
|
*/
|
|
811
715
|
AbstractCanvasObject.prototype.setMargin = function (margin) {
|
|
812
|
-
var _a, _b;
|
|
813
716
|
if (!margin)
|
|
814
717
|
return;
|
|
815
|
-
var newMargin = (
|
|
718
|
+
var newMargin = tsOptchain.oc(this.data).margin({
|
|
816
719
|
top: 0,
|
|
817
720
|
right: 0,
|
|
818
721
|
bottom: 0,
|
|
819
722
|
left: 0
|
|
820
|
-
};
|
|
723
|
+
});
|
|
821
724
|
if (margin.top != undefined)
|
|
822
725
|
newMargin.top = margin.top || 0;
|
|
823
726
|
if (margin.right != undefined)
|
|
@@ -834,8 +737,7 @@ var AbstractCanvasObject = /** @class */ (function () {
|
|
|
834
737
|
* @inheritDoc
|
|
835
738
|
*/
|
|
836
739
|
AbstractCanvasObject.prototype.getColumnWidthPercent = function () {
|
|
837
|
-
|
|
838
|
-
return Math.max(Math.min((_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.columnWidthPercent) !== null && _b !== void 0 ? _b : 100, 100), 0);
|
|
740
|
+
return Math.max(Math.min(tsOptchain.oc(this.data).columnWidthPercent(100), 100), 0);
|
|
839
741
|
};
|
|
840
742
|
/**
|
|
841
743
|
* @override
|
|
@@ -1917,20 +1819,6 @@ var RichText = /** @class */ (function (_super) {
|
|
|
1917
1819
|
return RichText;
|
|
1918
1820
|
}(Image));
|
|
1919
1821
|
|
|
1920
|
-
exports.ObjectType = void 0;
|
|
1921
|
-
(function (ObjectType) {
|
|
1922
|
-
ObjectType["TEXT"] = "TEXT";
|
|
1923
|
-
ObjectType["BORDER"] = "BORDER";
|
|
1924
|
-
ObjectType["IMAGE"] = "IMAGE";
|
|
1925
|
-
ObjectType["RECTANGLE"] = "RECTANGLE";
|
|
1926
|
-
ObjectType["LIBRARY_IMAGE"] = "LIBRARY_IMAGE";
|
|
1927
|
-
ObjectType["CUTOFF"] = "CUTOFF";
|
|
1928
|
-
ObjectType["VERTICAL_RULE"] = "VERTICAL_RULE";
|
|
1929
|
-
ObjectType["HORIZONTAL_RULE"] = "HORIZONTAL_RULE";
|
|
1930
|
-
ObjectType["RICH_TEXT"] = "RICH_TEXT";
|
|
1931
|
-
ObjectType["BACKGROUND_IMAGE"] = "BACKGROUND_IMAGE";
|
|
1932
|
-
})(exports.ObjectType || (exports.ObjectType = {}));
|
|
1933
|
-
|
|
1934
1822
|
var Text = /** @class */ (function (_super) {
|
|
1935
1823
|
__extends(Text, _super);
|
|
1936
1824
|
function Text(canvas, fabricObject, persistedField) {
|
|
@@ -1984,21 +1872,6 @@ var Text = /** @class */ (function (_super) {
|
|
|
1984
1872
|
this.data.userText = this.fabricObject.text;
|
|
1985
1873
|
this.text$.next(this.fabricObject.text);
|
|
1986
1874
|
};
|
|
1987
|
-
Text.prototype.replaceTextWithStyle = function (target, replacement) {
|
|
1988
|
-
var start = this.getText().indexOf(target);
|
|
1989
|
-
var styles = this.getReplacementStyle(target, replacement);
|
|
1990
|
-
this.fabricObject.insertChars(replacement, styles, start, start + target.length);
|
|
1991
|
-
this.redraw();
|
|
1992
|
-
this.data.userText = this.fabricObject.text;
|
|
1993
|
-
this.text$.next(this.fabricObject.text);
|
|
1994
|
-
};
|
|
1995
|
-
Text.prototype.getReplacementStyle = function (target, replacement) {
|
|
1996
|
-
var start = this.getText().indexOf(target);
|
|
1997
|
-
var lineIndex = (this.getText().substring(0, start).split(Text.NEW_LINE).length - 1);
|
|
1998
|
-
var lines = this.getText().split(Text.NEW_LINE);
|
|
1999
|
-
var startWithinLine = lines[lineIndex].indexOf(target);
|
|
2000
|
-
return Array(replacement.length).fill(this.fabricObject.styles[lineIndex][startWithinLine]);
|
|
2001
|
-
};
|
|
2002
1875
|
/**
|
|
2003
1876
|
* @override
|
|
2004
1877
|
* @inheritDoc
|
|
@@ -2113,7 +1986,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2113
1986
|
Text.prototype.setBoldRegion = function (start, end, bold) {
|
|
2114
1987
|
if (bold === void 0) { bold = true; }
|
|
2115
1988
|
if (start > end)
|
|
2116
|
-
throw Error("Bad region specified: ["
|
|
1989
|
+
throw Error("Bad region specified: [" + start + " - " + end + "]");
|
|
2117
1990
|
for (var i = start; i < end; i++) {
|
|
2118
1991
|
var style = this.fabricObject.getStyleAtPosition(i, true);
|
|
2119
1992
|
var font = this.fontLibrary.getFont(style.fontFamily);
|
|
@@ -2144,7 +2017,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2144
2017
|
Text.prototype.setItalicRegion = function (start, end, italic) {
|
|
2145
2018
|
if (italic === void 0) { italic = true; }
|
|
2146
2019
|
if (start > end)
|
|
2147
|
-
throw Error("Bad region specified: ["
|
|
2020
|
+
throw Error("Bad region specified: [" + start + " - " + end + "]");
|
|
2148
2021
|
this.fabricObject.setSelectionStyles({ fontStyle: italic ? "italic" : "" }, start, end);
|
|
2149
2022
|
this.redraw();
|
|
2150
2023
|
};
|
|
@@ -2295,7 +2168,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2295
2168
|
if (!this.isBulleted())
|
|
2296
2169
|
return 0;
|
|
2297
2170
|
var fontSize = 0;
|
|
2298
|
-
|
|
2171
|
+
_.each(this.fabricObject._textLines, function (textLine, lineIndex) {
|
|
2299
2172
|
fontSize = Math.max(fontSize, _this_1.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
|
|
2300
2173
|
});
|
|
2301
2174
|
return fontSize * 0.6;
|
|
@@ -2308,7 +2181,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2308
2181
|
if (!this.isOrderedList())
|
|
2309
2182
|
return 0;
|
|
2310
2183
|
var orderedListMarkerEntities = this.fabricObject._orderedListMarkerEntities;
|
|
2311
|
-
var max =
|
|
2184
|
+
var max = _(orderedListMarkerEntities)
|
|
2312
2185
|
.filter(function (x) { return !!x; })
|
|
2313
2186
|
.map(function (x) { return x.getBoundingRect(true, true).width; })
|
|
2314
2187
|
.max();
|
|
@@ -2374,10 +2247,9 @@ var Text = /** @class */ (function (_super) {
|
|
|
2374
2247
|
* @inheritDoc
|
|
2375
2248
|
*/
|
|
2376
2249
|
Text.prototype.enableBullets = function () {
|
|
2377
|
-
var _a;
|
|
2378
2250
|
this.disableOrderedList();
|
|
2379
2251
|
this.fabricObject["objectCaching"] = false;
|
|
2380
|
-
this.fabricObject["_bullets"] =
|
|
2252
|
+
this.fabricObject["_bullets"] = this.fabricObject["_bullets"] || {};
|
|
2381
2253
|
this.data.bulleted = true;
|
|
2382
2254
|
this.notifyCanvasOfTextChanges();
|
|
2383
2255
|
this.redraw();
|
|
@@ -2444,7 +2316,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2444
2316
|
if (this.data.bulleted) {
|
|
2445
2317
|
var bullets = this.fabricObject["_bullets"];
|
|
2446
2318
|
delete this.fabricObject["_bullets"];
|
|
2447
|
-
|
|
2319
|
+
_.each(bullets, function (bullet) { return _this_1.canvas.removeFabricObject(bullet); });
|
|
2448
2320
|
this.fabricObject["objectCaching"] = true;
|
|
2449
2321
|
}
|
|
2450
2322
|
};
|
|
@@ -2453,7 +2325,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2453
2325
|
if (this.fabricObject._isOrderedList) {
|
|
2454
2326
|
var markerEntities = this.fabricObject._orderedListMarkerEntities;
|
|
2455
2327
|
delete this.fabricObject._orderedListMarkerEntities;
|
|
2456
|
-
|
|
2328
|
+
_.each(markerEntities, function (marker) { return _this_1.canvas.removeFabricObject(marker); });
|
|
2457
2329
|
this.fabricObject["objectCaching"] = true;
|
|
2458
2330
|
}
|
|
2459
2331
|
};
|
|
@@ -2466,13 +2338,12 @@ var Text = /** @class */ (function (_super) {
|
|
|
2466
2338
|
var originalRender = this.fabricObject["_render"];
|
|
2467
2339
|
var fabric = this.canvas.fabric;
|
|
2468
2340
|
this.fabricObject["_render"] = function (ctx) {
|
|
2469
|
-
var _a;
|
|
2470
2341
|
var fabricText = this;
|
|
2471
2342
|
if (fabricText["_bullets"]) {
|
|
2472
2343
|
// Determine list of active bullets
|
|
2473
2344
|
var currentBullets_1 = fabricText["_bullets"];
|
|
2474
2345
|
var activeBullets_1 = {};
|
|
2475
|
-
|
|
2346
|
+
_.each(fabricText._textLines, function (textLine, lineIndex) {
|
|
2476
2347
|
if (textLine.length) {
|
|
2477
2348
|
// Start of real lines will have offset 0 in styleMap
|
|
2478
2349
|
var styleMap = fabricText._styleMap[lineIndex];
|
|
@@ -2506,13 +2377,13 @@ var Text = /** @class */ (function (_super) {
|
|
|
2506
2377
|
var canvas_1 = fabricText.canvas;
|
|
2507
2378
|
var canvasDirty_1 = false;
|
|
2508
2379
|
canvas_1.renderOnAddRemove = false;
|
|
2509
|
-
|
|
2380
|
+
_.each(activeBullets_1, function (bullet) {
|
|
2510
2381
|
if (!canvas_1.contains(bullet)) {
|
|
2511
2382
|
canvas_1.add(bullet);
|
|
2512
2383
|
canvasDirty_1 = true;
|
|
2513
2384
|
}
|
|
2514
2385
|
});
|
|
2515
|
-
|
|
2386
|
+
_.each(currentBullets_1, function (bullet, key) {
|
|
2516
2387
|
if (!activeBullets_1[key]) {
|
|
2517
2388
|
canvas_1.remove(bullet);
|
|
2518
2389
|
canvasDirty_1 = true;
|
|
@@ -2526,9 +2397,9 @@ var Text = /** @class */ (function (_super) {
|
|
|
2526
2397
|
}
|
|
2527
2398
|
}
|
|
2528
2399
|
if (fabricText._isOrderedList) {
|
|
2529
|
-
var existingMarkers_1 =
|
|
2400
|
+
var existingMarkers_1 = fabricText._orderedListMarkerEntities || [];
|
|
2530
2401
|
var activeMarkers_1 = [];
|
|
2531
|
-
|
|
2402
|
+
_.each(fabricText._textLines, function (textLine, lineIndex) {
|
|
2532
2403
|
if (textLine.length) {
|
|
2533
2404
|
// Start of real lines will have offset 0 in styleMap
|
|
2534
2405
|
var styleMap = fabricText._styleMap[lineIndex];
|
|
@@ -2539,7 +2410,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2539
2410
|
}
|
|
2540
2411
|
else {
|
|
2541
2412
|
// Create new marker for this line
|
|
2542
|
-
var textbox = new fabric.Textbox(
|
|
2413
|
+
var textbox = new fabric.Textbox(lineIndex + ".", {
|
|
2543
2414
|
left: 0,
|
|
2544
2415
|
top: 0,
|
|
2545
2416
|
fill: fabricText.fill,
|
|
@@ -2561,7 +2432,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2561
2432
|
var canvas_2 = fabricText.canvas;
|
|
2562
2433
|
var canvasDirty_2 = false;
|
|
2563
2434
|
canvas_2.renderOnAddRemove = false;
|
|
2564
|
-
|
|
2435
|
+
_.each(activeMarkers_1, function (marker) {
|
|
2565
2436
|
if (!marker)
|
|
2566
2437
|
return;
|
|
2567
2438
|
if (!canvas_2.contains(marker)) {
|
|
@@ -2569,7 +2440,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2569
2440
|
canvasDirty_2 = true;
|
|
2570
2441
|
}
|
|
2571
2442
|
});
|
|
2572
|
-
|
|
2443
|
+
_.each(existingMarkers_1, function (marker, key) {
|
|
2573
2444
|
if (!marker)
|
|
2574
2445
|
return;
|
|
2575
2446
|
if (!activeMarkers_1[key]) {
|
|
@@ -2638,7 +2509,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2638
2509
|
left: fabricText.left + xOffset,
|
|
2639
2510
|
top: fabricText.top + yOffset,
|
|
2640
2511
|
angle: fabricText.angle,
|
|
2641
|
-
text:
|
|
2512
|
+
text: lineNumber + "."
|
|
2642
2513
|
});
|
|
2643
2514
|
}
|
|
2644
2515
|
originalRenderTextLine.apply(fabricText, [method, ctx, line, left, top, lineIndex]);
|
|
@@ -2695,7 +2566,6 @@ var Text = /** @class */ (function (_super) {
|
|
|
2695
2566
|
Text.prototype.notifyCanvasOfTextChanges = function () {
|
|
2696
2567
|
this.canvas.notifyTextChanged();
|
|
2697
2568
|
};
|
|
2698
|
-
Text.NEW_LINE = "\n";
|
|
2699
2569
|
return Text;
|
|
2700
2570
|
}(AbstractCanvasObject));
|
|
2701
2571
|
var TextSelection = /** @class */ (function () {
|
|
@@ -2850,7 +2720,6 @@ var DefaultCanvasProfile = /** @class */ (function () {
|
|
|
2850
2720
|
return DefaultCanvasProfile;
|
|
2851
2721
|
}());
|
|
2852
2722
|
|
|
2853
|
-
exports.ImageType = void 0;
|
|
2854
2723
|
(function (ImageType) {
|
|
2855
2724
|
ImageType["DEFAULT"] = "DEFAULT";
|
|
2856
2725
|
ImageType["BACKGROUND"] = "BACKGROUND";
|
|
@@ -2858,6 +2727,19 @@ exports.ImageType = void 0;
|
|
|
2858
2727
|
ImageType["PHOTO"] = "PHOTO";
|
|
2859
2728
|
})(exports.ImageType || (exports.ImageType = {}));
|
|
2860
2729
|
|
|
2730
|
+
(function (ObjectType) {
|
|
2731
|
+
ObjectType["TEXT"] = "TEXT";
|
|
2732
|
+
ObjectType["BORDER"] = "BORDER";
|
|
2733
|
+
ObjectType["IMAGE"] = "IMAGE";
|
|
2734
|
+
ObjectType["RECTANGLE"] = "RECTANGLE";
|
|
2735
|
+
ObjectType["LIBRARY_IMAGE"] = "LIBRARY_IMAGE";
|
|
2736
|
+
ObjectType["CUTOFF"] = "CUTOFF";
|
|
2737
|
+
ObjectType["VERTICAL_RULE"] = "VERTICAL_RULE";
|
|
2738
|
+
ObjectType["HORIZONTAL_RULE"] = "HORIZONTAL_RULE";
|
|
2739
|
+
ObjectType["RICH_TEXT"] = "RICH_TEXT";
|
|
2740
|
+
ObjectType["BACKGROUND_IMAGE"] = "BACKGROUND_IMAGE";
|
|
2741
|
+
})(exports.ObjectType || (exports.ObjectType = {}));
|
|
2742
|
+
|
|
2861
2743
|
var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
2862
2744
|
function AbstractInteractiveCanvas(fabric, fabricCanvas, devicePixelRatio) {
|
|
2863
2745
|
this.fabric = fabric;
|
|
@@ -3039,12 +2921,11 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3039
2921
|
* @inheritDoc
|
|
3040
2922
|
*/
|
|
3041
2923
|
AbstractInteractiveCanvas.prototype.setDimensionRestrictions = function (restrictions) {
|
|
3042
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3043
2924
|
this.dimensionRestrictions$.next(restrictions);
|
|
3044
2925
|
var dimensions = this.getDimensions();
|
|
3045
2926
|
if (this.dimensionsExceedRestrictions(dimensions)) {
|
|
3046
2927
|
var newDimensions = dimensions
|
|
3047
|
-
.withSize(Math.min(Math.max((
|
|
2928
|
+
.withSize(Math.min(Math.max(tsOptchain.oc(restrictions).width.min(dimensions.width), dimensions.width), Math.max(tsOptchain.oc(restrictions).width.max(dimensions.width))), Math.min(Math.max(tsOptchain.oc(restrictions).height.min(dimensions.height), dimensions.height), Math.max(tsOptchain.oc(restrictions).height.max(dimensions.height))));
|
|
3048
2929
|
this.setBaseDimensions(newDimensions);
|
|
3049
2930
|
}
|
|
3050
2931
|
};
|
|
@@ -3113,7 +2994,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3113
2994
|
* @inheritDoc
|
|
3114
2995
|
*/
|
|
3115
2996
|
AbstractInteractiveCanvas.prototype.getObjectsByTypeInternal = function (type) {
|
|
3116
|
-
return
|
|
2997
|
+
return _(this.getObjectsInternal())
|
|
3117
2998
|
.filter(function (object) { return object.getType() === type; })
|
|
3118
2999
|
.value();
|
|
3119
3000
|
};
|
|
@@ -3126,8 +3007,8 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3126
3007
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3127
3008
|
types[_i] = arguments[_i];
|
|
3128
3009
|
}
|
|
3129
|
-
return
|
|
3130
|
-
.filter(function (object) { return
|
|
3010
|
+
return _(this.getObjectsInternal())
|
|
3011
|
+
.filter(function (object) { return _(types).includes(object.getType()); })
|
|
3131
3012
|
.value();
|
|
3132
3013
|
};
|
|
3133
3014
|
/**
|
|
@@ -3144,7 +3025,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3144
3025
|
AbstractInteractiveCanvas.prototype.removeObject = function (target) {
|
|
3145
3026
|
var concreteObject = this.findFabricObject(target.getId());
|
|
3146
3027
|
this.fabricCanvas.remove(concreteObject);
|
|
3147
|
-
this.objects$.next(
|
|
3028
|
+
this.objects$.next(_(this.objects$.value)
|
|
3148
3029
|
.filter(function (object) { return object.getId() !== target.getId(); })
|
|
3149
3030
|
.value());
|
|
3150
3031
|
this.onObjectListChange();
|
|
@@ -3444,7 +3325,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3444
3325
|
* @inheritDoc
|
|
3445
3326
|
*/
|
|
3446
3327
|
AbstractInteractiveCanvas.prototype.setPrefillData = function (data) {
|
|
3447
|
-
|
|
3328
|
+
_(this.getObjectsByTypeInternal(exports.ObjectType.TEXT)).each(function (object) {
|
|
3448
3329
|
var prefillType = object.getPrefillType();
|
|
3449
3330
|
if (prefillType !== undefined) {
|
|
3450
3331
|
object.setText(data[prefillType] || "");
|
|
@@ -3458,10 +3339,10 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3458
3339
|
AbstractInteractiveCanvas.prototype.distributeObjectsVertically = function () {
|
|
3459
3340
|
var margin = this.getMargin();
|
|
3460
3341
|
var canvasHeight = this.getDimensions().heightPx;
|
|
3461
|
-
var objectsToLayout =
|
|
3342
|
+
var objectsToLayout = _(this.getObjectsByTypesInternal(exports.ObjectType.TEXT, exports.ObjectType.IMAGE))
|
|
3462
3343
|
.sortBy(function (x) { return x.getBoundingBox().top; })
|
|
3463
3344
|
.value();
|
|
3464
|
-
var objectsHeight =
|
|
3345
|
+
var objectsHeight = _.reduce(objectsToLayout, function (total, element) { return total + element.getBoundingBox().height; }, 0);
|
|
3465
3346
|
var workableHeight = canvasHeight - margin.top - margin.bottom;
|
|
3466
3347
|
var requiredPadding = workableHeight - objectsHeight;
|
|
3467
3348
|
var spaceBetween = requiredPadding / (objectsToLayout.length - 1);
|
|
@@ -3530,7 +3411,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3530
3411
|
* @inheritDoc
|
|
3531
3412
|
*/
|
|
3532
3413
|
AbstractInteractiveCanvas.prototype.save = function () {
|
|
3533
|
-
var objects =
|
|
3414
|
+
var objects = _(this.objects$.value)
|
|
3534
3415
|
.map(function (x) { return x.persist(); })
|
|
3535
3416
|
.value();
|
|
3536
3417
|
var includedProperties = ["id", "_isSlaveObject", "_isOrderedList", "_orderedListStart"];
|
|
@@ -3635,7 +3516,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3635
3516
|
if (activeObject) {
|
|
3636
3517
|
this.fabricCanvas.setActiveObject(activeObject);
|
|
3637
3518
|
}
|
|
3638
|
-
return
|
|
3519
|
+
return _.replace(base64, /^data:.*;base64,/, "");
|
|
3639
3520
|
};
|
|
3640
3521
|
/**
|
|
3641
3522
|
* @override
|
|
@@ -3673,7 +3554,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3673
3554
|
};
|
|
3674
3555
|
AbstractInteractiveCanvas.prototype.syncObjectList = function () {
|
|
3675
3556
|
var _this = this;
|
|
3676
|
-
var newObjectList =
|
|
3557
|
+
var newObjectList = _(this.fabricCanvas.getObjects())
|
|
3677
3558
|
.map(function (obj) { return _this.findObject(obj.id); })
|
|
3678
3559
|
.filter(function (x) { return x !== undefined; })
|
|
3679
3560
|
.value();
|
|
@@ -3721,7 +3602,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3721
3602
|
};
|
|
3722
3603
|
AbstractInteractiveCanvas.prototype.bindFields = function (persistedFields) {
|
|
3723
3604
|
var _this = this;
|
|
3724
|
-
var bound =
|
|
3605
|
+
var bound = _(persistedFields)
|
|
3725
3606
|
.flatMap(function (field) {
|
|
3726
3607
|
try {
|
|
3727
3608
|
return [_this.bindField(field)];
|
|
@@ -3757,20 +3638,20 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3757
3638
|
case exports.ObjectType.BACKGROUND_IMAGE:
|
|
3758
3639
|
return new BackgroundImage(this, fabricObject, persistedField);
|
|
3759
3640
|
default:
|
|
3760
|
-
throw new Error("Unknown field type: ["
|
|
3641
|
+
throw new Error("Unknown field type: [" + persistedField.type + "]");
|
|
3761
3642
|
}
|
|
3762
3643
|
};
|
|
3763
3644
|
AbstractInteractiveCanvas.prototype.findFabricObject = function (id) {
|
|
3764
3645
|
var objects = this.fabricCanvas.getObjects();
|
|
3765
|
-
var fabricObject =
|
|
3646
|
+
var fabricObject = _.find(objects, function (o) { return o.id == id; });
|
|
3766
3647
|
if (!fabricObject) {
|
|
3767
|
-
throw new Error("Cannot find fabric object with id ["
|
|
3648
|
+
throw new Error("Cannot find fabric object with id [" + id + "]");
|
|
3768
3649
|
}
|
|
3769
3650
|
return fabricObject;
|
|
3770
3651
|
};
|
|
3771
3652
|
AbstractInteractiveCanvas.prototype.findObject = function (id) {
|
|
3772
3653
|
//Don't use strict compare here. fabric ids are numbers while ad builder ids are strings... mostly.
|
|
3773
|
-
return
|
|
3654
|
+
return _.find(this.objects$.value, function (object) { return object.getId() == id; });
|
|
3774
3655
|
};
|
|
3775
3656
|
/**
|
|
3776
3657
|
* Reset zoom and canvas dimensions to 1:1 scale, execute a function, then return the canvas to
|
|
@@ -3808,11 +3689,11 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3808
3689
|
if (!object) {
|
|
3809
3690
|
return null;
|
|
3810
3691
|
}
|
|
3811
|
-
return
|
|
3692
|
+
return _.find(this.objects$.value, function (field) { return field.getId() == object.id; });
|
|
3812
3693
|
};
|
|
3813
3694
|
AbstractInteractiveCanvas.prototype.getFieldsByCanvasObject = function (objects) {
|
|
3814
3695
|
var _this = this;
|
|
3815
|
-
return
|
|
3696
|
+
return _(objects)
|
|
3816
3697
|
.map(function (obj) { return _this.getFieldByCanvasObject(obj); })
|
|
3817
3698
|
.reject(function (x) { return !x; })
|
|
3818
3699
|
.value();
|
|
@@ -3820,7 +3701,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3820
3701
|
AbstractInteractiveCanvas.prototype.calculateImageCaptureCoefficient = function () {
|
|
3821
3702
|
var precision = 3;
|
|
3822
3703
|
var devicePixelRatio = this.devicePixelRatio || 1;
|
|
3823
|
-
return
|
|
3704
|
+
return _.round(2 / devicePixelRatio, precision);
|
|
3824
3705
|
};
|
|
3825
3706
|
AbstractInteractiveCanvas.prototype.randomId = function () {
|
|
3826
3707
|
var min = 0;
|
|
@@ -3829,23 +3710,22 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3829
3710
|
return (new Date()).getTime() + "" + id;
|
|
3830
3711
|
};
|
|
3831
3712
|
AbstractInteractiveCanvas.prototype.getLowestTextPoint = function () {
|
|
3832
|
-
return
|
|
3713
|
+
return _(this.objects$.value)
|
|
3833
3714
|
.filter(function (object) { return object.getType() === exports.ObjectType.TEXT; })
|
|
3834
3715
|
.map(function (text) { return text.getDimensions().top.px + text.getDimensions().height.px; })
|
|
3835
3716
|
.reduce(function (x, y) { return Math.max(x, y); }, 0);
|
|
3836
3717
|
};
|
|
3837
3718
|
AbstractInteractiveCanvas.prototype.trackNewObject = function (object) {
|
|
3838
|
-
this.objects$.next(
|
|
3719
|
+
this.objects$.next(__spreadArrays(this.objects$.value, [object]));
|
|
3839
3720
|
};
|
|
3840
3721
|
AbstractInteractiveCanvas.prototype.dimensionsExceedRestrictions = function (dimensions) {
|
|
3841
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
3842
3722
|
var restrictions = this.dimensionRestrictions$.value;
|
|
3843
|
-
return (
|
|
3844
|
-
|| (
|
|
3845
|
-
|| (
|
|
3846
|
-
|| (
|
|
3847
|
-
|| (
|
|
3848
|
-
|| (
|
|
3723
|
+
return tsOptchain.oc(restrictions).height.min() != undefined && dimensions.height < tsOptchain.oc(restrictions).height.min()
|
|
3724
|
+
|| tsOptchain.oc(restrictions).height.max() != undefined && dimensions.height > tsOptchain.oc(restrictions).height.max()
|
|
3725
|
+
|| tsOptchain.oc(restrictions).width.min() != undefined && dimensions.width < tsOptchain.oc(restrictions).width.min()
|
|
3726
|
+
|| tsOptchain.oc(restrictions).width.max() != undefined && dimensions.width > tsOptchain.oc(restrictions).width.max()
|
|
3727
|
+
|| tsOptchain.oc(restrictions).volume.min() != undefined && dimensions.height * dimensions.width < tsOptchain.oc(restrictions).volume.min()
|
|
3728
|
+
|| tsOptchain.oc(restrictions).volume.max() != undefined && dimensions.height * dimensions.width > tsOptchain.oc(restrictions).volume.max();
|
|
3849
3729
|
};
|
|
3850
3730
|
return AbstractInteractiveCanvas;
|
|
3851
3731
|
}());
|
|
@@ -3857,11 +3737,7 @@ var SelectionData = /** @class */ (function () {
|
|
|
3857
3737
|
this.isText = selectedObject
|
|
3858
3738
|
&& selectedObject.getType() === exports.ObjectType.TEXT
|
|
3859
3739
|
&& selectedObject.isEditing();
|
|
3860
|
-
this.event = {};
|
|
3861
3740
|
}
|
|
3862
|
-
SelectionData.prototype.setEvent = function (event) {
|
|
3863
|
-
this.event = event;
|
|
3864
|
-
};
|
|
3865
3741
|
return SelectionData;
|
|
3866
3742
|
}());
|
|
3867
3743
|
|
|
@@ -3973,9 +3849,9 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3973
3849
|
_this.headless = false;
|
|
3974
3850
|
_this.undoStack = new UndoStack(_this);
|
|
3975
3851
|
//Initialize watchers
|
|
3976
|
-
_this.fabricCanvas.on("selection:updated", function (
|
|
3977
|
-
_this.fabricCanvas.on("selection:created", function (
|
|
3978
|
-
_this.fabricCanvas.on("selection:cleared", function (
|
|
3852
|
+
_this.fabricCanvas.on("selection:updated", function () { return _this.onFabricSelectionChanged(); });
|
|
3853
|
+
_this.fabricCanvas.on("selection:created", function () { return _this.onFabricSelectionChanged(); });
|
|
3854
|
+
_this.fabricCanvas.on("selection:cleared", function () { return _this.onFabricSelectionChanged(); });
|
|
3979
3855
|
_this.fabricCanvas.on("text:editing:entered", function () { return _this.onTextEditing(); });
|
|
3980
3856
|
_this.fabricCanvas.on("text:editing:exited", function () { return _this.onTextEditing(); });
|
|
3981
3857
|
_this.fabricCanvas.on("text:changed", function () { return _this.onTextChange(); });
|
|
@@ -4020,11 +3896,9 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
4020
3896
|
});
|
|
4021
3897
|
});
|
|
4022
3898
|
};
|
|
4023
|
-
InteractiveCanvas.prototype.onFabricSelectionChanged = function (
|
|
3899
|
+
InteractiveCanvas.prototype.onFabricSelectionChanged = function () {
|
|
4024
3900
|
var selected = this.getFieldsByCanvasObject(this.fabricCanvas.getActiveObjects());
|
|
4025
|
-
|
|
4026
|
-
selection.setEvent(event);
|
|
4027
|
-
this.selection$.next(selection);
|
|
3901
|
+
this.selection$.next(new SelectionData(selected));
|
|
4028
3902
|
this.enterTextSelectionModeIfRequired();
|
|
4029
3903
|
};
|
|
4030
3904
|
InteractiveCanvas.prototype.enterTextSelectionModeIfRequired = function () {
|
|
@@ -4042,6 +3916,82 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
4042
3916
|
return InteractiveCanvas;
|
|
4043
3917
|
}(AbstractInteractiveCanvas));
|
|
4044
3918
|
|
|
3919
|
+
var RepositionCutoffsLayoutFunction = /** @class */ (function () {
|
|
3920
|
+
function RepositionCutoffsLayoutFunction() {
|
|
3921
|
+
}
|
|
3922
|
+
RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
|
|
3923
|
+
canvas.getObjectsByTypeInternal(exports.ObjectType.CUTOFF)
|
|
3924
|
+
.forEach(function (cutoff) { return cutoff.updatePosition(); });
|
|
3925
|
+
};
|
|
3926
|
+
return RepositionCutoffsLayoutFunction;
|
|
3927
|
+
}());
|
|
3928
|
+
|
|
3929
|
+
var PinToBottomLayoutFunction = /** @class */ (function () {
|
|
3930
|
+
function PinToBottomLayoutFunction() {
|
|
3931
|
+
}
|
|
3932
|
+
PinToBottomLayoutFunction.prototype.execute = function (canvas) {
|
|
3933
|
+
canvas.getObjectsInternal()
|
|
3934
|
+
.forEach(function (object) { return object.moveToPinnedPosition(); });
|
|
3935
|
+
};
|
|
3936
|
+
return PinToBottomLayoutFunction;
|
|
3937
|
+
}());
|
|
3938
|
+
|
|
3939
|
+
var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
3940
|
+
function ResizeCanvasLayoutFunction() {
|
|
3941
|
+
}
|
|
3942
|
+
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
3943
|
+
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
3944
|
+
return;
|
|
3945
|
+
if (tsOptchain.oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
3946
|
+
return;
|
|
3947
|
+
var currentDimensions = canvas.getDimensions();
|
|
3948
|
+
var baseDimensions = canvas.getBaseDimensions();
|
|
3949
|
+
var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(exports.ObjectType.TEXT))
|
|
3950
|
+
.filter(function (text) { return text.isResizeCanvas(); })
|
|
3951
|
+
.reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
|
|
3952
|
+
var increase = baseDimensions.withSize(currentDimensions.width, 0);
|
|
3953
|
+
while (increase.heightPx < textHeightIncreasePx) {
|
|
3954
|
+
increase = increase.withSize(increase.width, increase.height + 1);
|
|
3955
|
+
}
|
|
3956
|
+
var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
|
|
3957
|
+
if (currentDimensions.height !== targetHeight.height) {
|
|
3958
|
+
canvas.setDimensions(targetHeight);
|
|
3959
|
+
}
|
|
3960
|
+
canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
|
|
3961
|
+
canvas.redraw();
|
|
3962
|
+
};
|
|
3963
|
+
return ResizeCanvasLayoutFunction;
|
|
3964
|
+
}());
|
|
3965
|
+
|
|
3966
|
+
var AdvancedLayoutManager = /** @class */ (function (_super) {
|
|
3967
|
+
__extends(AdvancedLayoutManager, _super);
|
|
3968
|
+
function AdvancedLayoutManager(canvas) {
|
|
3969
|
+
var _this = _super.call(this, canvas) || this;
|
|
3970
|
+
_this.key = exports.LayoutManager.ADVANCED;
|
|
3971
|
+
_this.pinToBottom = new PinToBottomLayoutFunction();
|
|
3972
|
+
_this.redrawAll = new RedrawAllLayoutFunction();
|
|
3973
|
+
_this.repositionBorders = new RepositionBordersLayoutFunction();
|
|
3974
|
+
_this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
|
|
3975
|
+
_this.repositionBackgrounds = new RepositionBackgroundsLayoutFunction();
|
|
3976
|
+
_this.resizeCanvas = new ResizeCanvasLayoutFunction();
|
|
3977
|
+
return _this;
|
|
3978
|
+
}
|
|
3979
|
+
AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
3980
|
+
this.pinToBottom.execute(this.canvas);
|
|
3981
|
+
this.repositionCutoffs.execute(this.canvas);
|
|
3982
|
+
this.repositionBorders.execute(this.canvas);
|
|
3983
|
+
this.repositionBackgrounds.execute(this.canvas);
|
|
3984
|
+
this.redrawAll.execute(this.canvas);
|
|
3985
|
+
};
|
|
3986
|
+
AdvancedLayoutManager.prototype.onTextChange = function () {
|
|
3987
|
+
this.resizeCanvas.execute(this.canvas);
|
|
3988
|
+
};
|
|
3989
|
+
AdvancedLayoutManager.prototype.onObjectListChange = function () {
|
|
3990
|
+
this.redrawAll.execute(this.canvas);
|
|
3991
|
+
};
|
|
3992
|
+
return AdvancedLayoutManager;
|
|
3993
|
+
}(AbstractLayoutManager));
|
|
3994
|
+
|
|
4045
3995
|
exports.AbstractCanvasObject = AbstractCanvasObject;
|
|
4046
3996
|
exports.AbstractInteractiveCanvas = AbstractInteractiveCanvas;
|
|
4047
3997
|
exports.AbstractLayoutManager = AbstractLayoutManager;
|