@leapfrog/interactive-canvas 2.0.13 → 2.0.15-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 +3 -0
- package/dist/interactive-canvas.es.js +235 -217
- package/dist/interactive-canvas.js +255 -229
- package/dist/object/impl/text.d.ts +1 -2
- package/dist/types/selection-data.interface.d.ts +9 -0
- package/dist/types/text-alignment.interface.d.ts +1 -1
- package/package.json +8 -8
|
@@ -7,26 +7,30 @@ var tsOptchain = require('ts-optchain');
|
|
|
7
7
|
var rxjs = require('rxjs');
|
|
8
8
|
var fabric = require('fabric');
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
13
|
+
|
|
14
|
+
var PIXELS_PER_MM$2 = 3.937;
|
|
11
15
|
var MillimeterDimensions = /** @class */ (function () {
|
|
12
16
|
function MillimeterDimensions(width, height) {
|
|
13
17
|
this.widthUnit = "mm";
|
|
14
18
|
this.heightUnit = "mm";
|
|
15
19
|
this.width = width;
|
|
16
20
|
this.widthMm = Math.max(0, width);
|
|
17
|
-
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM);
|
|
21
|
+
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM$2);
|
|
18
22
|
this.height = height;
|
|
19
23
|
this.heightMm = Math.max(0, height);
|
|
20
|
-
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM);
|
|
24
|
+
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM$2);
|
|
21
25
|
}
|
|
22
26
|
MillimeterDimensions.prototype.withSize = function (width, height) {
|
|
23
27
|
return new MillimeterDimensions(width, height);
|
|
24
28
|
};
|
|
25
29
|
MillimeterDimensions.prototype.widthPxToMm = function (px) {
|
|
26
|
-
return px / PIXELS_PER_MM;
|
|
30
|
+
return px / PIXELS_PER_MM$2;
|
|
27
31
|
};
|
|
28
32
|
MillimeterDimensions.prototype.heightPxToMm = function (px) {
|
|
29
|
-
return px / PIXELS_PER_MM;
|
|
33
|
+
return px / PIXELS_PER_MM$2;
|
|
30
34
|
};
|
|
31
35
|
return MillimeterDimensions;
|
|
32
36
|
}());
|
|
@@ -52,8 +56,8 @@ var PixelCanvasDimensions = /** @class */ (function () {
|
|
|
52
56
|
return PixelCanvasDimensions;
|
|
53
57
|
}());
|
|
54
58
|
|
|
55
|
-
var COLUMN_WIDTH_MM = 41;
|
|
56
|
-
var GUTTER_WIDTH_MM = 3;
|
|
59
|
+
var COLUMN_WIDTH_MM$1 = 41;
|
|
60
|
+
var GUTTER_WIDTH_MM$1 = 3;
|
|
57
61
|
var PIXELS_PER_MM$1 = 3.937;
|
|
58
62
|
var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
59
63
|
function Print6ColCanvasDimensions(width, height) {
|
|
@@ -61,13 +65,14 @@ var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
|
61
65
|
this.heightUnit = "cm";
|
|
62
66
|
this.width = width;
|
|
63
67
|
this.gutterCount = Math.max(0, width - 1);
|
|
64
|
-
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM;
|
|
65
|
-
this.columnsTotalMm = width * COLUMN_WIDTH_MM;
|
|
68
|
+
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM$1;
|
|
69
|
+
this.columnsTotalMm = width * COLUMN_WIDTH_MM$1;
|
|
66
70
|
this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
|
|
67
71
|
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM$1);
|
|
68
72
|
this.height = height;
|
|
69
73
|
this.heightMm = Math.max(0, height * 10);
|
|
70
74
|
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM$1);
|
|
75
|
+
console.log("interactive canvas");
|
|
71
76
|
}
|
|
72
77
|
Print6ColCanvasDimensions.prototype.withSize = function (width, height) {
|
|
73
78
|
return new Print6ColCanvasDimensions(width, height);
|
|
@@ -81,110 +86,119 @@ var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
|
81
86
|
return Print6ColCanvasDimensions;
|
|
82
87
|
}());
|
|
83
88
|
|
|
84
|
-
var COLUMN_WIDTH_MM
|
|
85
|
-
var GUTTER_WIDTH_MM
|
|
86
|
-
var PIXELS_PER_MM
|
|
89
|
+
var COLUMN_WIDTH_MM = 30.8772;
|
|
90
|
+
var GUTTER_WIDTH_MM = 2.1053;
|
|
91
|
+
var PIXELS_PER_MM = 3.937;
|
|
87
92
|
var Print8ColCanvasDimensions = /** @class */ (function () {
|
|
88
93
|
function Print8ColCanvasDimensions(width, height) {
|
|
89
94
|
this.widthUnit = "column(s)";
|
|
90
95
|
this.heightUnit = "cm";
|
|
91
96
|
this.width = width;
|
|
92
97
|
this.gutterCount = Math.max(0, width - 1);
|
|
93
|
-
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM
|
|
94
|
-
this.columnsTotalMm = width * COLUMN_WIDTH_MM
|
|
98
|
+
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM;
|
|
99
|
+
this.columnsTotalMm = width * COLUMN_WIDTH_MM;
|
|
95
100
|
this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
|
|
96
|
-
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM
|
|
101
|
+
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM);
|
|
97
102
|
this.height = height;
|
|
98
103
|
this.heightMm = Math.max(0, height * 10);
|
|
99
|
-
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM
|
|
104
|
+
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM);
|
|
100
105
|
}
|
|
101
106
|
Print8ColCanvasDimensions.prototype.withSize = function (width, height) {
|
|
102
107
|
return new Print8ColCanvasDimensions(width, height);
|
|
103
108
|
};
|
|
104
109
|
Print8ColCanvasDimensions.prototype.widthPxToMm = function (px) {
|
|
105
|
-
return px / PIXELS_PER_MM
|
|
110
|
+
return px / PIXELS_PER_MM;
|
|
106
111
|
};
|
|
107
112
|
Print8ColCanvasDimensions.prototype.heightPxToMm = function (px) {
|
|
108
|
-
return px / PIXELS_PER_MM
|
|
113
|
+
return px / PIXELS_PER_MM;
|
|
109
114
|
};
|
|
110
115
|
return Print8ColCanvasDimensions;
|
|
111
116
|
}());
|
|
112
117
|
|
|
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 (
|
|
133
|
-
return extendStatics(d, b);
|
|
118
|
+
/******************************************************************************
|
|
119
|
+
Copyright (c) Microsoft Corporation.
|
|
120
|
+
|
|
121
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
122
|
+
purpose with or without fee is hereby granted.
|
|
123
|
+
|
|
124
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
125
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
126
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
127
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
128
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
129
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
130
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
131
|
+
***************************************************************************** */
|
|
132
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
133
|
+
|
|
134
|
+
var extendStatics = function(d, b) {
|
|
135
|
+
extendStatics = Object.setPrototypeOf ||
|
|
136
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
137
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
138
|
+
return extendStatics(d, b);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
function __extends(d, b) {
|
|
142
|
+
if (typeof b !== "function" && b !== null)
|
|
143
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
144
|
+
extendStatics(d, b);
|
|
145
|
+
function __() { this.constructor = d; }
|
|
146
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
150
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
151
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
152
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
153
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
154
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
155
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function __generator(thisArg, body) {
|
|
160
|
+
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);
|
|
161
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
162
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
163
|
+
function step(op) {
|
|
164
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
165
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
166
|
+
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;
|
|
167
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
168
|
+
switch (op[0]) {
|
|
169
|
+
case 0: case 1: t = op; break;
|
|
170
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
171
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
172
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
173
|
+
default:
|
|
174
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
175
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
176
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
177
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
178
|
+
if (t[2]) _.ops.pop();
|
|
179
|
+
_.trys.pop(); continue;
|
|
180
|
+
}
|
|
181
|
+
op = body.call(thisArg, _);
|
|
182
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
183
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function __spreadArray(to, from, pack) {
|
|
188
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
189
|
+
if (ar || !(i in from)) {
|
|
190
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
191
|
+
ar[i] = from[i];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
198
|
+
var e = new Error(message);
|
|
199
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
134
200
|
};
|
|
135
201
|
|
|
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
|
-
|
|
188
202
|
var Font = /** @class */ (function () {
|
|
189
203
|
function Font() {
|
|
190
204
|
}
|
|
@@ -287,12 +301,109 @@ var RedrawAllLayoutFunction = /** @class */ (function () {
|
|
|
287
301
|
return RedrawAllLayoutFunction;
|
|
288
302
|
}());
|
|
289
303
|
|
|
304
|
+
var RepositionCutoffsLayoutFunction = /** @class */ (function () {
|
|
305
|
+
function RepositionCutoffsLayoutFunction() {
|
|
306
|
+
}
|
|
307
|
+
RepositionCutoffsLayoutFunction.prototype.execute = function (canvas) {
|
|
308
|
+
canvas.getObjectsByTypeInternal(exports.ObjectType.CUTOFF)
|
|
309
|
+
.forEach(function (cutoff) { return cutoff.updatePosition(); });
|
|
310
|
+
};
|
|
311
|
+
return RepositionCutoffsLayoutFunction;
|
|
312
|
+
}());
|
|
313
|
+
|
|
314
|
+
var RepositionBordersLayoutFunction = /** @class */ (function () {
|
|
315
|
+
function RepositionBordersLayoutFunction() {
|
|
316
|
+
}
|
|
317
|
+
RepositionBordersLayoutFunction.prototype.execute = function (canvas) {
|
|
318
|
+
canvas.getObjectsByTypeInternal(exports.ObjectType.BORDER)
|
|
319
|
+
.forEach(function (border) { return border.updatePosition(); });
|
|
320
|
+
};
|
|
321
|
+
return RepositionBordersLayoutFunction;
|
|
322
|
+
}());
|
|
323
|
+
|
|
324
|
+
var PinToBottomLayoutFunction = /** @class */ (function () {
|
|
325
|
+
function PinToBottomLayoutFunction() {
|
|
326
|
+
}
|
|
327
|
+
PinToBottomLayoutFunction.prototype.execute = function (canvas) {
|
|
328
|
+
canvas.getObjectsInternal()
|
|
329
|
+
.forEach(function (object) { return object.moveToPinnedPosition(); });
|
|
330
|
+
};
|
|
331
|
+
return PinToBottomLayoutFunction;
|
|
332
|
+
}());
|
|
333
|
+
|
|
334
|
+
var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
335
|
+
function ResizeCanvasLayoutFunction() {
|
|
336
|
+
}
|
|
337
|
+
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
338
|
+
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
339
|
+
return;
|
|
340
|
+
if (tsOptchain.oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
341
|
+
return;
|
|
342
|
+
var currentDimensions = canvas.getDimensions();
|
|
343
|
+
var baseDimensions = canvas.getBaseDimensions();
|
|
344
|
+
var textHeightIncreasePx = ___default["default"](canvas.getObjectsByTypeInternal(exports.ObjectType.TEXT))
|
|
345
|
+
.filter(function (text) { return text.isResizeCanvas(); })
|
|
346
|
+
.reduce(function (x, text) { return x + text.getSizeIncreaseSinceCreation(); }, 0);
|
|
347
|
+
var increase = baseDimensions.withSize(currentDimensions.width, 0);
|
|
348
|
+
while (increase.heightPx < textHeightIncreasePx) {
|
|
349
|
+
increase = increase.withSize(increase.width, increase.height + 1);
|
|
350
|
+
}
|
|
351
|
+
var targetHeight = increase.withSize(increase.width, baseDimensions.height + increase.height);
|
|
352
|
+
if (currentDimensions.height !== targetHeight.height) {
|
|
353
|
+
canvas.setDimensions(targetHeight);
|
|
354
|
+
}
|
|
355
|
+
canvas.getObjectsInternal().forEach(function (object) { return object.setCoords(); });
|
|
356
|
+
canvas.redraw();
|
|
357
|
+
};
|
|
358
|
+
return ResizeCanvasLayoutFunction;
|
|
359
|
+
}());
|
|
360
|
+
|
|
361
|
+
exports.LayoutManager = void 0;
|
|
290
362
|
(function (LayoutManager) {
|
|
291
363
|
LayoutManager["LEGACY"] = "LEGACY";
|
|
292
364
|
LayoutManager["STANDARD"] = "STANDARD";
|
|
293
365
|
LayoutManager["ADVANCED"] = "ADVANCED";
|
|
294
366
|
})(exports.LayoutManager || (exports.LayoutManager = {}));
|
|
295
367
|
|
|
368
|
+
var RepositionBackgroundsLayoutFunction = /** @class */ (function () {
|
|
369
|
+
function RepositionBackgroundsLayoutFunction() {
|
|
370
|
+
}
|
|
371
|
+
RepositionBackgroundsLayoutFunction.prototype.execute = function (canvas) {
|
|
372
|
+
canvas.getObjectsByTypeInternal(exports.ObjectType.BACKGROUND_IMAGE)
|
|
373
|
+
.forEach(function (border) { return border.updatePosition(); });
|
|
374
|
+
};
|
|
375
|
+
return RepositionBackgroundsLayoutFunction;
|
|
376
|
+
}());
|
|
377
|
+
|
|
378
|
+
var AdvancedLayoutManager = /** @class */ (function (_super) {
|
|
379
|
+
__extends(AdvancedLayoutManager, _super);
|
|
380
|
+
function AdvancedLayoutManager(canvas) {
|
|
381
|
+
var _this = _super.call(this, canvas) || this;
|
|
382
|
+
_this.key = exports.LayoutManager.ADVANCED;
|
|
383
|
+
_this.pinToBottom = new PinToBottomLayoutFunction();
|
|
384
|
+
_this.redrawAll = new RedrawAllLayoutFunction();
|
|
385
|
+
_this.repositionBorders = new RepositionBordersLayoutFunction();
|
|
386
|
+
_this.repositionCutoffs = new RepositionCutoffsLayoutFunction();
|
|
387
|
+
_this.repositionBackgrounds = new RepositionBackgroundsLayoutFunction();
|
|
388
|
+
_this.resizeCanvas = new ResizeCanvasLayoutFunction();
|
|
389
|
+
return _this;
|
|
390
|
+
}
|
|
391
|
+
AdvancedLayoutManager.prototype.onCanvasDimensionsChange = function () {
|
|
392
|
+
this.pinToBottom.execute(this.canvas);
|
|
393
|
+
this.repositionCutoffs.execute(this.canvas);
|
|
394
|
+
this.repositionBorders.execute(this.canvas);
|
|
395
|
+
this.repositionBackgrounds.execute(this.canvas);
|
|
396
|
+
this.redrawAll.execute(this.canvas);
|
|
397
|
+
};
|
|
398
|
+
AdvancedLayoutManager.prototype.onTextChange = function () {
|
|
399
|
+
this.resizeCanvas.execute(this.canvas);
|
|
400
|
+
};
|
|
401
|
+
AdvancedLayoutManager.prototype.onObjectListChange = function () {
|
|
402
|
+
this.redrawAll.execute(this.canvas);
|
|
403
|
+
};
|
|
404
|
+
return AdvancedLayoutManager;
|
|
405
|
+
}(AbstractLayoutManager));
|
|
406
|
+
|
|
296
407
|
var UpdateObjectDimensionsLayoutFunction = /** @class */ (function () {
|
|
297
408
|
function UpdateObjectDimensionsLayoutFunction() {
|
|
298
409
|
}
|
|
@@ -310,7 +421,7 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
310
421
|
var canvasMargin = canvas.getMargin();
|
|
311
422
|
var canvasDimensions = canvas.getDimensions();
|
|
312
423
|
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);
|
|
313
|
-
var objects =
|
|
424
|
+
var objects = ___default["default"](allObjects)
|
|
314
425
|
.partition(function (object) { return object.isPinToBottom(); })
|
|
315
426
|
.value();
|
|
316
427
|
var footerObjects = objects[0];
|
|
@@ -389,7 +500,7 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
389
500
|
}
|
|
390
501
|
};
|
|
391
502
|
StackObjectsLayoutFunction.prototype.applyWidths = function (objects, layoutWidth) {
|
|
392
|
-
|
|
503
|
+
___default["default"](objects).forEach(function (object) {
|
|
393
504
|
var targetWidth = object.getColumnWidthPercent() / 100 * layoutWidth;
|
|
394
505
|
var actualWidth = targetWidth - tsOptchain.oc(object.getMargin()).left(0) - tsOptchain.oc(object.getMargin()).right(0);
|
|
395
506
|
if (object.getType() === exports.ObjectType.VERTICAL_RULE)
|
|
@@ -461,26 +572,6 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
461
572
|
return StackObjectsLayoutFunction;
|
|
462
573
|
}());
|
|
463
574
|
|
|
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
|
-
|
|
484
575
|
var StandardLayoutManager = /** @class */ (function (_super) {
|
|
485
576
|
__extends(StandardLayoutManager, _super);
|
|
486
577
|
function StandardLayoutManager(canvas) {
|
|
@@ -1986,7 +2077,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
1986
2077
|
Text.prototype.setBoldRegion = function (start, end, bold) {
|
|
1987
2078
|
if (bold === void 0) { bold = true; }
|
|
1988
2079
|
if (start > end)
|
|
1989
|
-
throw Error("Bad region specified: ["
|
|
2080
|
+
throw Error("Bad region specified: [".concat(start, " - ").concat(end, "]"));
|
|
1990
2081
|
for (var i = start; i < end; i++) {
|
|
1991
2082
|
var style = this.fabricObject.getStyleAtPosition(i, true);
|
|
1992
2083
|
var font = this.fontLibrary.getFont(style.fontFamily);
|
|
@@ -2017,7 +2108,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2017
2108
|
Text.prototype.setItalicRegion = function (start, end, italic) {
|
|
2018
2109
|
if (italic === void 0) { italic = true; }
|
|
2019
2110
|
if (start > end)
|
|
2020
|
-
throw Error("Bad region specified: ["
|
|
2111
|
+
throw Error("Bad region specified: [".concat(start, " - ").concat(end, "]"));
|
|
2021
2112
|
this.fabricObject.setSelectionStyles({ fontStyle: italic ? "italic" : "" }, start, end);
|
|
2022
2113
|
this.redraw();
|
|
2023
2114
|
};
|
|
@@ -2168,7 +2259,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2168
2259
|
if (!this.isBulleted())
|
|
2169
2260
|
return 0;
|
|
2170
2261
|
var fontSize = 0;
|
|
2171
|
-
|
|
2262
|
+
___default["default"].each(this.fabricObject._textLines, function (textLine, lineIndex) {
|
|
2172
2263
|
fontSize = Math.max(fontSize, _this_1.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
|
|
2173
2264
|
});
|
|
2174
2265
|
return fontSize * 0.6;
|
|
@@ -2181,7 +2272,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2181
2272
|
if (!this.isOrderedList())
|
|
2182
2273
|
return 0;
|
|
2183
2274
|
var orderedListMarkerEntities = this.fabricObject._orderedListMarkerEntities;
|
|
2184
|
-
var max =
|
|
2275
|
+
var max = ___default["default"](orderedListMarkerEntities)
|
|
2185
2276
|
.filter(function (x) { return !!x; })
|
|
2186
2277
|
.map(function (x) { return x.getBoundingRect(true, true).width; })
|
|
2187
2278
|
.max();
|
|
@@ -2316,7 +2407,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2316
2407
|
if (this.data.bulleted) {
|
|
2317
2408
|
var bullets = this.fabricObject["_bullets"];
|
|
2318
2409
|
delete this.fabricObject["_bullets"];
|
|
2319
|
-
|
|
2410
|
+
___default["default"].each(bullets, function (bullet) { return _this_1.canvas.removeFabricObject(bullet); });
|
|
2320
2411
|
this.fabricObject["objectCaching"] = true;
|
|
2321
2412
|
}
|
|
2322
2413
|
};
|
|
@@ -2325,7 +2416,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2325
2416
|
if (this.fabricObject._isOrderedList) {
|
|
2326
2417
|
var markerEntities = this.fabricObject._orderedListMarkerEntities;
|
|
2327
2418
|
delete this.fabricObject._orderedListMarkerEntities;
|
|
2328
|
-
|
|
2419
|
+
___default["default"].each(markerEntities, function (marker) { return _this_1.canvas.removeFabricObject(marker); });
|
|
2329
2420
|
this.fabricObject["objectCaching"] = true;
|
|
2330
2421
|
}
|
|
2331
2422
|
};
|
|
@@ -2339,11 +2430,12 @@ var Text = /** @class */ (function (_super) {
|
|
|
2339
2430
|
var fabric = this.canvas.fabric;
|
|
2340
2431
|
this.fabricObject["_render"] = function (ctx) {
|
|
2341
2432
|
var fabricText = this;
|
|
2433
|
+
console.log('fabricText 123', fabricText);
|
|
2342
2434
|
if (fabricText["_bullets"]) {
|
|
2343
2435
|
// Determine list of active bullets
|
|
2344
2436
|
var currentBullets_1 = fabricText["_bullets"];
|
|
2345
2437
|
var activeBullets_1 = {};
|
|
2346
|
-
|
|
2438
|
+
___default["default"].each(fabricText._textLines, function (textLine, lineIndex) {
|
|
2347
2439
|
if (textLine.length) {
|
|
2348
2440
|
// Start of real lines will have offset 0 in styleMap
|
|
2349
2441
|
var styleMap = fabricText._styleMap[lineIndex];
|
|
@@ -2377,13 +2469,13 @@ var Text = /** @class */ (function (_super) {
|
|
|
2377
2469
|
var canvas_1 = fabricText.canvas;
|
|
2378
2470
|
var canvasDirty_1 = false;
|
|
2379
2471
|
canvas_1.renderOnAddRemove = false;
|
|
2380
|
-
|
|
2472
|
+
___default["default"].each(activeBullets_1, function (bullet) {
|
|
2381
2473
|
if (!canvas_1.contains(bullet)) {
|
|
2382
2474
|
canvas_1.add(bullet);
|
|
2383
2475
|
canvasDirty_1 = true;
|
|
2384
2476
|
}
|
|
2385
2477
|
});
|
|
2386
|
-
|
|
2478
|
+
___default["default"].each(currentBullets_1, function (bullet, key) {
|
|
2387
2479
|
if (!activeBullets_1[key]) {
|
|
2388
2480
|
canvas_1.remove(bullet);
|
|
2389
2481
|
canvasDirty_1 = true;
|
|
@@ -2399,7 +2491,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2399
2491
|
if (fabricText._isOrderedList) {
|
|
2400
2492
|
var existingMarkers_1 = fabricText._orderedListMarkerEntities || [];
|
|
2401
2493
|
var activeMarkers_1 = [];
|
|
2402
|
-
|
|
2494
|
+
___default["default"].each(fabricText._textLines, function (textLine, lineIndex) {
|
|
2403
2495
|
if (textLine.length) {
|
|
2404
2496
|
// Start of real lines will have offset 0 in styleMap
|
|
2405
2497
|
var styleMap = fabricText._styleMap[lineIndex];
|
|
@@ -2410,7 +2502,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2410
2502
|
}
|
|
2411
2503
|
else {
|
|
2412
2504
|
// Create new marker for this line
|
|
2413
|
-
var textbox = new fabric.Textbox(lineIndex
|
|
2505
|
+
var textbox = new fabric.Textbox("".concat(lineIndex, "."), {
|
|
2414
2506
|
left: 0,
|
|
2415
2507
|
top: 0,
|
|
2416
2508
|
fill: fabricText.fill,
|
|
@@ -2432,7 +2524,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2432
2524
|
var canvas_2 = fabricText.canvas;
|
|
2433
2525
|
var canvasDirty_2 = false;
|
|
2434
2526
|
canvas_2.renderOnAddRemove = false;
|
|
2435
|
-
|
|
2527
|
+
___default["default"].each(activeMarkers_1, function (marker) {
|
|
2436
2528
|
if (!marker)
|
|
2437
2529
|
return;
|
|
2438
2530
|
if (!canvas_2.contains(marker)) {
|
|
@@ -2440,7 +2532,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2440
2532
|
canvasDirty_2 = true;
|
|
2441
2533
|
}
|
|
2442
2534
|
});
|
|
2443
|
-
|
|
2535
|
+
___default["default"].each(existingMarkers_1, function (marker, key) {
|
|
2444
2536
|
if (!marker)
|
|
2445
2537
|
return;
|
|
2446
2538
|
if (!activeMarkers_1[key]) {
|
|
@@ -2509,7 +2601,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2509
2601
|
left: fabricText.left + xOffset,
|
|
2510
2602
|
top: fabricText.top + yOffset,
|
|
2511
2603
|
angle: fabricText.angle,
|
|
2512
|
-
text: lineNumber
|
|
2604
|
+
text: "".concat(lineNumber, ".")
|
|
2513
2605
|
});
|
|
2514
2606
|
}
|
|
2515
2607
|
originalRenderTextLine.apply(fabricText, [method, ctx, line, left, top, lineIndex]);
|
|
@@ -2720,6 +2812,7 @@ var DefaultCanvasProfile = /** @class */ (function () {
|
|
|
2720
2812
|
return DefaultCanvasProfile;
|
|
2721
2813
|
}());
|
|
2722
2814
|
|
|
2815
|
+
exports.ImageType = void 0;
|
|
2723
2816
|
(function (ImageType) {
|
|
2724
2817
|
ImageType["DEFAULT"] = "DEFAULT";
|
|
2725
2818
|
ImageType["BACKGROUND"] = "BACKGROUND";
|
|
@@ -2727,6 +2820,7 @@ var DefaultCanvasProfile = /** @class */ (function () {
|
|
|
2727
2820
|
ImageType["PHOTO"] = "PHOTO";
|
|
2728
2821
|
})(exports.ImageType || (exports.ImageType = {}));
|
|
2729
2822
|
|
|
2823
|
+
exports.ObjectType = void 0;
|
|
2730
2824
|
(function (ObjectType) {
|
|
2731
2825
|
ObjectType["TEXT"] = "TEXT";
|
|
2732
2826
|
ObjectType["BORDER"] = "BORDER";
|
|
@@ -2747,6 +2841,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
2747
2841
|
this.devicePixelRatio = devicePixelRatio;
|
|
2748
2842
|
this.fontLibrary = new FontLibrary();
|
|
2749
2843
|
this.dimensionChangeRejections$ = new rxjs.Subject();
|
|
2844
|
+
console.log(" **** Hello world");
|
|
2750
2845
|
this.IMAGE_CAPTURE_COEFFICIENT = this.calculateImageCaptureCoefficient();
|
|
2751
2846
|
/**
|
|
2752
2847
|
* Fabric defaults to only 2 decimal places when saving, which causes havoc on the scaling of large images.
|
|
@@ -2994,7 +3089,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
2994
3089
|
* @inheritDoc
|
|
2995
3090
|
*/
|
|
2996
3091
|
AbstractInteractiveCanvas.prototype.getObjectsByTypeInternal = function (type) {
|
|
2997
|
-
return
|
|
3092
|
+
return ___default["default"](this.getObjectsInternal())
|
|
2998
3093
|
.filter(function (object) { return object.getType() === type; })
|
|
2999
3094
|
.value();
|
|
3000
3095
|
};
|
|
@@ -3007,8 +3102,8 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3007
3102
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3008
3103
|
types[_i] = arguments[_i];
|
|
3009
3104
|
}
|
|
3010
|
-
return
|
|
3011
|
-
.filter(function (object) { return
|
|
3105
|
+
return ___default["default"](this.getObjectsInternal())
|
|
3106
|
+
.filter(function (object) { return ___default["default"](types).includes(object.getType()); })
|
|
3012
3107
|
.value();
|
|
3013
3108
|
};
|
|
3014
3109
|
/**
|
|
@@ -3025,7 +3120,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3025
3120
|
AbstractInteractiveCanvas.prototype.removeObject = function (target) {
|
|
3026
3121
|
var concreteObject = this.findFabricObject(target.getId());
|
|
3027
3122
|
this.fabricCanvas.remove(concreteObject);
|
|
3028
|
-
this.objects$.next(
|
|
3123
|
+
this.objects$.next(___default["default"](this.objects$.value)
|
|
3029
3124
|
.filter(function (object) { return object.getId() !== target.getId(); })
|
|
3030
3125
|
.value());
|
|
3031
3126
|
this.onObjectListChange();
|
|
@@ -3325,7 +3420,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3325
3420
|
* @inheritDoc
|
|
3326
3421
|
*/
|
|
3327
3422
|
AbstractInteractiveCanvas.prototype.setPrefillData = function (data) {
|
|
3328
|
-
|
|
3423
|
+
___default["default"](this.getObjectsByTypeInternal(exports.ObjectType.TEXT)).each(function (object) {
|
|
3329
3424
|
var prefillType = object.getPrefillType();
|
|
3330
3425
|
if (prefillType !== undefined) {
|
|
3331
3426
|
object.setText(data[prefillType] || "");
|
|
@@ -3339,10 +3434,10 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3339
3434
|
AbstractInteractiveCanvas.prototype.distributeObjectsVertically = function () {
|
|
3340
3435
|
var margin = this.getMargin();
|
|
3341
3436
|
var canvasHeight = this.getDimensions().heightPx;
|
|
3342
|
-
var objectsToLayout =
|
|
3437
|
+
var objectsToLayout = ___default["default"](this.getObjectsByTypesInternal(exports.ObjectType.TEXT, exports.ObjectType.IMAGE))
|
|
3343
3438
|
.sortBy(function (x) { return x.getBoundingBox().top; })
|
|
3344
3439
|
.value();
|
|
3345
|
-
var objectsHeight =
|
|
3440
|
+
var objectsHeight = ___default["default"].reduce(objectsToLayout, function (total, element) { return total + element.getBoundingBox().height; }, 0);
|
|
3346
3441
|
var workableHeight = canvasHeight - margin.top - margin.bottom;
|
|
3347
3442
|
var requiredPadding = workableHeight - objectsHeight;
|
|
3348
3443
|
var spaceBetween = requiredPadding / (objectsToLayout.length - 1);
|
|
@@ -3411,7 +3506,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3411
3506
|
* @inheritDoc
|
|
3412
3507
|
*/
|
|
3413
3508
|
AbstractInteractiveCanvas.prototype.save = function () {
|
|
3414
|
-
var objects =
|
|
3509
|
+
var objects = ___default["default"](this.objects$.value)
|
|
3415
3510
|
.map(function (x) { return x.persist(); })
|
|
3416
3511
|
.value();
|
|
3417
3512
|
var includedProperties = ["id", "_isSlaveObject", "_isOrderedList", "_orderedListStart"];
|
|
@@ -3438,6 +3533,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3438
3533
|
if (!(canvasState.canvasJson != undefined)) return [3 /*break*/, 2];
|
|
3439
3534
|
json_1 = JSON.parse(canvasState.canvasJson);
|
|
3440
3535
|
return [4 /*yield*/, new Promise(function (resolve) {
|
|
3536
|
+
console.log('resolve', resolve);
|
|
3441
3537
|
_this.fabricCanvas.loadFromJSON(json_1, function () { return resolve(); });
|
|
3442
3538
|
})];
|
|
3443
3539
|
case 1:
|
|
@@ -3504,7 +3600,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3504
3600
|
*/
|
|
3505
3601
|
AbstractInteractiveCanvas.prototype.toImage = function (multiplier) {
|
|
3506
3602
|
var _this = this;
|
|
3507
|
-
console.log("Multiplier in interactive canvas : %s", multiplier);
|
|
3603
|
+
console.log("Multiplier in interactive canvas !!! : %s", multiplier);
|
|
3508
3604
|
var activeObject = this.fabricCanvas.getActiveObject();
|
|
3509
3605
|
this.fabricCanvas.discardActiveObject().renderAll();
|
|
3510
3606
|
var options = {
|
|
@@ -3516,7 +3612,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3516
3612
|
if (activeObject) {
|
|
3517
3613
|
this.fabricCanvas.setActiveObject(activeObject);
|
|
3518
3614
|
}
|
|
3519
|
-
return
|
|
3615
|
+
return ___default["default"].replace(base64, /^data:.*;base64,/, "");
|
|
3520
3616
|
};
|
|
3521
3617
|
/**
|
|
3522
3618
|
* @override
|
|
@@ -3554,7 +3650,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3554
3650
|
};
|
|
3555
3651
|
AbstractInteractiveCanvas.prototype.syncObjectList = function () {
|
|
3556
3652
|
var _this = this;
|
|
3557
|
-
var newObjectList =
|
|
3653
|
+
var newObjectList = ___default["default"](this.fabricCanvas.getObjects())
|
|
3558
3654
|
.map(function (obj) { return _this.findObject(obj.id); })
|
|
3559
3655
|
.filter(function (x) { return x !== undefined; })
|
|
3560
3656
|
.value();
|
|
@@ -3602,7 +3698,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3602
3698
|
};
|
|
3603
3699
|
AbstractInteractiveCanvas.prototype.bindFields = function (persistedFields) {
|
|
3604
3700
|
var _this = this;
|
|
3605
|
-
var bound =
|
|
3701
|
+
var bound = ___default["default"](persistedFields)
|
|
3606
3702
|
.flatMap(function (field) {
|
|
3607
3703
|
try {
|
|
3608
3704
|
return [_this.bindField(field)];
|
|
@@ -3638,20 +3734,20 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3638
3734
|
case exports.ObjectType.BACKGROUND_IMAGE:
|
|
3639
3735
|
return new BackgroundImage(this, fabricObject, persistedField);
|
|
3640
3736
|
default:
|
|
3641
|
-
throw new Error("Unknown field type: ["
|
|
3737
|
+
throw new Error("Unknown field type: [".concat(persistedField.type, "]"));
|
|
3642
3738
|
}
|
|
3643
3739
|
};
|
|
3644
3740
|
AbstractInteractiveCanvas.prototype.findFabricObject = function (id) {
|
|
3645
3741
|
var objects = this.fabricCanvas.getObjects();
|
|
3646
|
-
var fabricObject =
|
|
3742
|
+
var fabricObject = ___default["default"].find(objects, function (o) { return o.id == id; });
|
|
3647
3743
|
if (!fabricObject) {
|
|
3648
|
-
throw new Error("Cannot find fabric object with id ["
|
|
3744
|
+
throw new Error("Cannot find fabric object with id [".concat(id, "]"));
|
|
3649
3745
|
}
|
|
3650
3746
|
return fabricObject;
|
|
3651
3747
|
};
|
|
3652
3748
|
AbstractInteractiveCanvas.prototype.findObject = function (id) {
|
|
3653
3749
|
//Don't use strict compare here. fabric ids are numbers while ad builder ids are strings... mostly.
|
|
3654
|
-
return
|
|
3750
|
+
return ___default["default"].find(this.objects$.value, function (object) { return object.getId() == id; });
|
|
3655
3751
|
};
|
|
3656
3752
|
/**
|
|
3657
3753
|
* Reset zoom and canvas dimensions to 1:1 scale, execute a function, then return the canvas to
|
|
@@ -3689,11 +3785,11 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3689
3785
|
if (!object) {
|
|
3690
3786
|
return null;
|
|
3691
3787
|
}
|
|
3692
|
-
return
|
|
3788
|
+
return ___default["default"].find(this.objects$.value, function (field) { return field.getId() == object.id; });
|
|
3693
3789
|
};
|
|
3694
3790
|
AbstractInteractiveCanvas.prototype.getFieldsByCanvasObject = function (objects) {
|
|
3695
3791
|
var _this = this;
|
|
3696
|
-
return
|
|
3792
|
+
return ___default["default"](objects)
|
|
3697
3793
|
.map(function (obj) { return _this.getFieldByCanvasObject(obj); })
|
|
3698
3794
|
.reject(function (x) { return !x; })
|
|
3699
3795
|
.value();
|
|
@@ -3701,7 +3797,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3701
3797
|
AbstractInteractiveCanvas.prototype.calculateImageCaptureCoefficient = function () {
|
|
3702
3798
|
var precision = 3;
|
|
3703
3799
|
var devicePixelRatio = this.devicePixelRatio || 1;
|
|
3704
|
-
return
|
|
3800
|
+
return ___default["default"].round(2 / devicePixelRatio, precision);
|
|
3705
3801
|
};
|
|
3706
3802
|
AbstractInteractiveCanvas.prototype.randomId = function () {
|
|
3707
3803
|
var min = 0;
|
|
@@ -3710,13 +3806,13 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3710
3806
|
return (new Date()).getTime() + "" + id;
|
|
3711
3807
|
};
|
|
3712
3808
|
AbstractInteractiveCanvas.prototype.getLowestTextPoint = function () {
|
|
3713
|
-
return
|
|
3809
|
+
return ___default["default"](this.objects$.value)
|
|
3714
3810
|
.filter(function (object) { return object.getType() === exports.ObjectType.TEXT; })
|
|
3715
3811
|
.map(function (text) { return text.getDimensions().top.px + text.getDimensions().height.px; })
|
|
3716
3812
|
.reduce(function (x, y) { return Math.max(x, y); }, 0);
|
|
3717
3813
|
};
|
|
3718
3814
|
AbstractInteractiveCanvas.prototype.trackNewObject = function (object) {
|
|
3719
|
-
this.objects$.next(
|
|
3815
|
+
this.objects$.next(__spreadArray(__spreadArray([], this.objects$.value, true), [object], false));
|
|
3720
3816
|
};
|
|
3721
3817
|
AbstractInteractiveCanvas.prototype.dimensionsExceedRestrictions = function (dimensions) {
|
|
3722
3818
|
var restrictions = this.dimensionRestrictions$.value;
|
|
@@ -3737,7 +3833,11 @@ var SelectionData = /** @class */ (function () {
|
|
|
3737
3833
|
this.isText = selectedObject
|
|
3738
3834
|
&& selectedObject.getType() === exports.ObjectType.TEXT
|
|
3739
3835
|
&& selectedObject.isEditing();
|
|
3836
|
+
this.event = {};
|
|
3740
3837
|
}
|
|
3838
|
+
SelectionData.prototype.setEvent = function (event) {
|
|
3839
|
+
this.event = event;
|
|
3840
|
+
};
|
|
3741
3841
|
return SelectionData;
|
|
3742
3842
|
}());
|
|
3743
3843
|
|
|
@@ -3849,9 +3949,9 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3849
3949
|
_this.headless = false;
|
|
3850
3950
|
_this.undoStack = new UndoStack(_this);
|
|
3851
3951
|
//Initialize watchers
|
|
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(); });
|
|
3952
|
+
_this.fabricCanvas.on("selection:updated", function (event) { return _this.onFabricSelectionChanged(event); });
|
|
3953
|
+
_this.fabricCanvas.on("selection:created", function (event) { return _this.onFabricSelectionChanged(event); });
|
|
3954
|
+
_this.fabricCanvas.on("selection:cleared", function (event) { return _this.onFabricSelectionChanged(event); });
|
|
3855
3955
|
_this.fabricCanvas.on("text:editing:entered", function () { return _this.onTextEditing(); });
|
|
3856
3956
|
_this.fabricCanvas.on("text:editing:exited", function () { return _this.onTextEditing(); });
|
|
3857
3957
|
_this.fabricCanvas.on("text:changed", function () { return _this.onTextChange(); });
|
|
@@ -3896,9 +3996,11 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3896
3996
|
});
|
|
3897
3997
|
});
|
|
3898
3998
|
};
|
|
3899
|
-
InteractiveCanvas.prototype.onFabricSelectionChanged = function () {
|
|
3999
|
+
InteractiveCanvas.prototype.onFabricSelectionChanged = function (event) {
|
|
3900
4000
|
var selected = this.getFieldsByCanvasObject(this.fabricCanvas.getActiveObjects());
|
|
3901
|
-
|
|
4001
|
+
var selection = new SelectionData(selected);
|
|
4002
|
+
selection.setEvent(event);
|
|
4003
|
+
this.selection$.next(selection);
|
|
3902
4004
|
this.enterTextSelectionModeIfRequired();
|
|
3903
4005
|
};
|
|
3904
4006
|
InteractiveCanvas.prototype.enterTextSelectionModeIfRequired = function () {
|
|
@@ -3916,82 +4018,6 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3916
4018
|
return InteractiveCanvas;
|
|
3917
4019
|
}(AbstractInteractiveCanvas));
|
|
3918
4020
|
|
|
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
|
-
|
|
3995
4021
|
exports.AbstractCanvasObject = AbstractCanvasObject;
|
|
3996
4022
|
exports.AbstractInteractiveCanvas = AbstractInteractiveCanvas;
|
|
3997
4023
|
exports.AbstractLayoutManager = AbstractLayoutManager;
|