@leapfrog/interactive-canvas 1.14.0 → 1.14.1
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.
|
@@ -1895,18 +1895,18 @@ var RichText = /** @class */ (function (_super) {
|
|
|
1895
1895
|
var Text = /** @class */ (function (_super) {
|
|
1896
1896
|
__extends(Text, _super);
|
|
1897
1897
|
function Text(canvas, fabricObject, persistedField) {
|
|
1898
|
-
var
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
return
|
|
1898
|
+
var _this_1 = _super.call(this, ObjectType.TEXT, canvas, fabricObject, persistedField) || this;
|
|
1899
|
+
_this_1.canvas = canvas;
|
|
1900
|
+
_this_1.fontLibrary = canvas.getFontLibrary();
|
|
1901
|
+
_this_1.baseComponentHeight = _this_1.fabricObject.height;
|
|
1902
|
+
_this_1.text$ = new BehaviorSubject(_this_1.fabricObject.text);
|
|
1903
|
+
_this_1.data.userText = _this_1.fabricObject.text;
|
|
1904
|
+
_this_1.textSelection$ = new BehaviorSubject(new TextSelection(_this_1.fabricObject, _this_1.fontLibrary));
|
|
1905
|
+
_this_1.fabricObject.set({ strokeWidth: 0 });
|
|
1906
|
+
_this_1.fabricObject.on("changed", function () { return _this_1.onTextChange(); });
|
|
1907
|
+
_this_1.fabricObject.on("selection:changed", function () { return _this_1.onSelectionChange(); });
|
|
1908
|
+
_this_1.applyBulletListMonkeyPatches();
|
|
1909
|
+
return _this_1;
|
|
1910
1910
|
}
|
|
1911
1911
|
/**
|
|
1912
1912
|
* @override
|
|
@@ -2237,12 +2237,12 @@ var Text = /** @class */ (function (_super) {
|
|
|
2237
2237
|
* @inheritDoc
|
|
2238
2238
|
*/
|
|
2239
2239
|
Text.prototype.getBulletMargin = function () {
|
|
2240
|
-
var
|
|
2240
|
+
var _this_1 = this;
|
|
2241
2241
|
if (!this.isBulleted())
|
|
2242
2242
|
return 0;
|
|
2243
2243
|
var fontSize = 0;
|
|
2244
2244
|
each(this.fabricObject._textLines, function (textLine, lineIndex) {
|
|
2245
|
-
fontSize = Math.max(fontSize,
|
|
2245
|
+
fontSize = Math.max(fontSize, _this_1.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
|
|
2246
2246
|
});
|
|
2247
2247
|
return fontSize * 0.6;
|
|
2248
2248
|
};
|
|
@@ -2251,12 +2251,12 @@ var Text = /** @class */ (function (_super) {
|
|
|
2251
2251
|
* @inheritDoc
|
|
2252
2252
|
*/
|
|
2253
2253
|
Text.prototype.getOrderedListMargin = function () {
|
|
2254
|
-
var
|
|
2254
|
+
var _this_1 = this;
|
|
2255
2255
|
if (!this.isOrderedList())
|
|
2256
2256
|
return 0;
|
|
2257
2257
|
var fontSize = 0;
|
|
2258
2258
|
each(this.fabricObject._textLines, function (textLine, lineIndex) {
|
|
2259
|
-
fontSize = Math.max(fontSize,
|
|
2259
|
+
fontSize = Math.max(fontSize, _this_1.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
|
|
2260
2260
|
});
|
|
2261
2261
|
return fontSize * 1.5;
|
|
2262
2262
|
};
|
|
@@ -2365,28 +2365,44 @@ var Text = /** @class */ (function (_super) {
|
|
|
2365
2365
|
this.notifyCanvasOfTextChanges();
|
|
2366
2366
|
this.redraw();
|
|
2367
2367
|
};
|
|
2368
|
+
/**
|
|
2369
|
+
* @override
|
|
2370
|
+
* @inheritDoc
|
|
2371
|
+
*/
|
|
2372
|
+
Text.prototype.setOrderedListStart = function (start) {
|
|
2373
|
+
this.fabricObject.orderedListIndex = start;
|
|
2374
|
+
this.redraw();
|
|
2375
|
+
};
|
|
2376
|
+
/**
|
|
2377
|
+
* @override
|
|
2378
|
+
* @inheritDoc
|
|
2379
|
+
*/
|
|
2380
|
+
Text.prototype.getOrderedListStart = function () {
|
|
2381
|
+
return this.fabricObject.orderedListIndex || 1;
|
|
2382
|
+
};
|
|
2368
2383
|
Text.prototype.getSizeIncreaseSinceCreation = function () {
|
|
2369
2384
|
return Math.max(0, this.fabricObject.height - this.baseComponentHeight);
|
|
2370
2385
|
};
|
|
2371
2386
|
Text.prototype.removeBullets = function () {
|
|
2372
|
-
var
|
|
2387
|
+
var _this_1 = this;
|
|
2373
2388
|
if (this.data.bulleted) {
|
|
2374
2389
|
var bullets = this.fabricObject["_bullets"];
|
|
2375
2390
|
delete this.fabricObject["_bullets"];
|
|
2376
|
-
each(bullets, function (bullet) { return
|
|
2391
|
+
each(bullets, function (bullet) { return _this_1.canvas.removeFabricObject(bullet); });
|
|
2377
2392
|
this.fabricObject["objectCaching"] = true;
|
|
2378
2393
|
}
|
|
2379
2394
|
};
|
|
2380
2395
|
Text.prototype.removeOrderedList = function () {
|
|
2381
|
-
var
|
|
2396
|
+
var _this_1 = this;
|
|
2382
2397
|
if (this.fabricObject.orderedList) {
|
|
2383
2398
|
var lineNumbers = this.fabricObject["_currentLineNumbers"];
|
|
2384
2399
|
delete this.fabricObject["_currentLineNumbers"];
|
|
2385
|
-
each(lineNumbers, function (lineNumber) { return
|
|
2400
|
+
each(lineNumbers, function (lineNumber) { return _this_1.canvas.removeFabricObject(lineNumber); });
|
|
2386
2401
|
this.fabricObject["objectCaching"] = true;
|
|
2387
2402
|
}
|
|
2388
2403
|
};
|
|
2389
2404
|
Text.prototype.applyBulletListMonkeyPatches = function () {
|
|
2405
|
+
var _this = this;
|
|
2390
2406
|
if (this.data.bulleted)
|
|
2391
2407
|
this.enableBullets();
|
|
2392
2408
|
if (this.fabricObject.orderedList)
|
|
@@ -2544,7 +2560,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2544
2560
|
var yShift = (fabricText.height / 2) + top - fontSize - 1;
|
|
2545
2561
|
var xOffset = (xShift * Math.cos(theta)) - (yShift * Math.sin(theta));
|
|
2546
2562
|
var yOffset = (xShift * Math.sin(theta)) + (yShift * Math.cos(theta));
|
|
2547
|
-
var lineNumber =
|
|
2563
|
+
var lineNumber = _this.getOrderedListStart();
|
|
2548
2564
|
for (var i = 0; i < lineIndex; i++) {
|
|
2549
2565
|
if (currentLineNumbers[i])
|
|
2550
2566
|
lineNumber++;
|
|
@@ -3462,7 +3478,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3462
3478
|
var objects = _(this.objects$.value)
|
|
3463
3479
|
.map(function (x) { return x.persist(); })
|
|
3464
3480
|
.value();
|
|
3465
|
-
var includedProperties = ["id", "orderedList"];
|
|
3481
|
+
var includedProperties = ["id", "orderedList", "orderedListIndex"];
|
|
3466
3482
|
var json = this.fabricCanvas.toJSON(includedProperties);
|
|
3467
3483
|
return {
|
|
3468
3484
|
dimensions: this.dimensions$.value,
|
|
@@ -1897,18 +1897,18 @@ var RichText = /** @class */ (function (_super) {
|
|
|
1897
1897
|
var Text = /** @class */ (function (_super) {
|
|
1898
1898
|
__extends(Text, _super);
|
|
1899
1899
|
function Text(canvas, fabricObject, persistedField) {
|
|
1900
|
-
var
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
return
|
|
1900
|
+
var _this_1 = _super.call(this, exports.ObjectType.TEXT, canvas, fabricObject, persistedField) || this;
|
|
1901
|
+
_this_1.canvas = canvas;
|
|
1902
|
+
_this_1.fontLibrary = canvas.getFontLibrary();
|
|
1903
|
+
_this_1.baseComponentHeight = _this_1.fabricObject.height;
|
|
1904
|
+
_this_1.text$ = new rxjs.BehaviorSubject(_this_1.fabricObject.text);
|
|
1905
|
+
_this_1.data.userText = _this_1.fabricObject.text;
|
|
1906
|
+
_this_1.textSelection$ = new rxjs.BehaviorSubject(new TextSelection(_this_1.fabricObject, _this_1.fontLibrary));
|
|
1907
|
+
_this_1.fabricObject.set({ strokeWidth: 0 });
|
|
1908
|
+
_this_1.fabricObject.on("changed", function () { return _this_1.onTextChange(); });
|
|
1909
|
+
_this_1.fabricObject.on("selection:changed", function () { return _this_1.onSelectionChange(); });
|
|
1910
|
+
_this_1.applyBulletListMonkeyPatches();
|
|
1911
|
+
return _this_1;
|
|
1912
1912
|
}
|
|
1913
1913
|
/**
|
|
1914
1914
|
* @override
|
|
@@ -2239,12 +2239,12 @@ var Text = /** @class */ (function (_super) {
|
|
|
2239
2239
|
* @inheritDoc
|
|
2240
2240
|
*/
|
|
2241
2241
|
Text.prototype.getBulletMargin = function () {
|
|
2242
|
-
var
|
|
2242
|
+
var _this_1 = this;
|
|
2243
2243
|
if (!this.isBulleted())
|
|
2244
2244
|
return 0;
|
|
2245
2245
|
var fontSize = 0;
|
|
2246
2246
|
_.each(this.fabricObject._textLines, function (textLine, lineIndex) {
|
|
2247
|
-
fontSize = Math.max(fontSize,
|
|
2247
|
+
fontSize = Math.max(fontSize, _this_1.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
|
|
2248
2248
|
});
|
|
2249
2249
|
return fontSize * 0.6;
|
|
2250
2250
|
};
|
|
@@ -2253,12 +2253,12 @@ var Text = /** @class */ (function (_super) {
|
|
|
2253
2253
|
* @inheritDoc
|
|
2254
2254
|
*/
|
|
2255
2255
|
Text.prototype.getOrderedListMargin = function () {
|
|
2256
|
-
var
|
|
2256
|
+
var _this_1 = this;
|
|
2257
2257
|
if (!this.isOrderedList())
|
|
2258
2258
|
return 0;
|
|
2259
2259
|
var fontSize = 0;
|
|
2260
2260
|
_.each(this.fabricObject._textLines, function (textLine, lineIndex) {
|
|
2261
|
-
fontSize = Math.max(fontSize,
|
|
2261
|
+
fontSize = Math.max(fontSize, _this_1.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
|
|
2262
2262
|
});
|
|
2263
2263
|
return fontSize * 1.5;
|
|
2264
2264
|
};
|
|
@@ -2367,28 +2367,44 @@ var Text = /** @class */ (function (_super) {
|
|
|
2367
2367
|
this.notifyCanvasOfTextChanges();
|
|
2368
2368
|
this.redraw();
|
|
2369
2369
|
};
|
|
2370
|
+
/**
|
|
2371
|
+
* @override
|
|
2372
|
+
* @inheritDoc
|
|
2373
|
+
*/
|
|
2374
|
+
Text.prototype.setOrderedListStart = function (start) {
|
|
2375
|
+
this.fabricObject.orderedListIndex = start;
|
|
2376
|
+
this.redraw();
|
|
2377
|
+
};
|
|
2378
|
+
/**
|
|
2379
|
+
* @override
|
|
2380
|
+
* @inheritDoc
|
|
2381
|
+
*/
|
|
2382
|
+
Text.prototype.getOrderedListStart = function () {
|
|
2383
|
+
return this.fabricObject.orderedListIndex || 1;
|
|
2384
|
+
};
|
|
2370
2385
|
Text.prototype.getSizeIncreaseSinceCreation = function () {
|
|
2371
2386
|
return Math.max(0, this.fabricObject.height - this.baseComponentHeight);
|
|
2372
2387
|
};
|
|
2373
2388
|
Text.prototype.removeBullets = function () {
|
|
2374
|
-
var
|
|
2389
|
+
var _this_1 = this;
|
|
2375
2390
|
if (this.data.bulleted) {
|
|
2376
2391
|
var bullets = this.fabricObject["_bullets"];
|
|
2377
2392
|
delete this.fabricObject["_bullets"];
|
|
2378
|
-
_.each(bullets, function (bullet) { return
|
|
2393
|
+
_.each(bullets, function (bullet) { return _this_1.canvas.removeFabricObject(bullet); });
|
|
2379
2394
|
this.fabricObject["objectCaching"] = true;
|
|
2380
2395
|
}
|
|
2381
2396
|
};
|
|
2382
2397
|
Text.prototype.removeOrderedList = function () {
|
|
2383
|
-
var
|
|
2398
|
+
var _this_1 = this;
|
|
2384
2399
|
if (this.fabricObject.orderedList) {
|
|
2385
2400
|
var lineNumbers = this.fabricObject["_currentLineNumbers"];
|
|
2386
2401
|
delete this.fabricObject["_currentLineNumbers"];
|
|
2387
|
-
_.each(lineNumbers, function (lineNumber) { return
|
|
2402
|
+
_.each(lineNumbers, function (lineNumber) { return _this_1.canvas.removeFabricObject(lineNumber); });
|
|
2388
2403
|
this.fabricObject["objectCaching"] = true;
|
|
2389
2404
|
}
|
|
2390
2405
|
};
|
|
2391
2406
|
Text.prototype.applyBulletListMonkeyPatches = function () {
|
|
2407
|
+
var _this = this;
|
|
2392
2408
|
if (this.data.bulleted)
|
|
2393
2409
|
this.enableBullets();
|
|
2394
2410
|
if (this.fabricObject.orderedList)
|
|
@@ -2546,7 +2562,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2546
2562
|
var yShift = (fabricText.height / 2) + top - fontSize - 1;
|
|
2547
2563
|
var xOffset = (xShift * Math.cos(theta)) - (yShift * Math.sin(theta));
|
|
2548
2564
|
var yOffset = (xShift * Math.sin(theta)) + (yShift * Math.cos(theta));
|
|
2549
|
-
var lineNumber =
|
|
2565
|
+
var lineNumber = _this.getOrderedListStart();
|
|
2550
2566
|
for (var i = 0; i < lineIndex; i++) {
|
|
2551
2567
|
if (currentLineNumbers[i])
|
|
2552
2568
|
lineNumber++;
|
|
@@ -3462,7 +3478,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3462
3478
|
var objects = _(this.objects$.value)
|
|
3463
3479
|
.map(function (x) { return x.persist(); })
|
|
3464
3480
|
.value();
|
|
3465
|
-
var includedProperties = ["id", "orderedList"];
|
|
3481
|
+
var includedProperties = ["id", "orderedList", "orderedListIndex"];
|
|
3466
3482
|
var json = this.fabricCanvas.toJSON(includedProperties);
|
|
3467
3483
|
return {
|
|
3468
3484
|
dimensions: this.dimensions$.value,
|
|
@@ -68,5 +68,13 @@ export interface IMutableText extends ICanvasObject {
|
|
|
68
68
|
* Disable ordered list markers.
|
|
69
69
|
*/
|
|
70
70
|
disableOrderedList(): void;
|
|
71
|
+
/**
|
|
72
|
+
* @param start The start value for the ordered list.
|
|
73
|
+
*/
|
|
74
|
+
setOrderedListStart(start: number): void;
|
|
75
|
+
/**
|
|
76
|
+
* Get the start value for the ordered list.
|
|
77
|
+
*/
|
|
78
|
+
getOrderedListStart(): number;
|
|
71
79
|
}
|
|
72
80
|
export declare function isMutableText(object: any): object is IMutableText;
|
|
@@ -285,6 +285,16 @@ export declare class Text extends AbstractCanvasObject<fabric.Textbox> implement
|
|
|
285
285
|
* @inheritDoc
|
|
286
286
|
*/
|
|
287
287
|
disableOrderedList(): void;
|
|
288
|
+
/**
|
|
289
|
+
* @override
|
|
290
|
+
* @inheritDoc
|
|
291
|
+
*/
|
|
292
|
+
setOrderedListStart(start: number): void;
|
|
293
|
+
/**
|
|
294
|
+
* @override
|
|
295
|
+
* @inheritDoc
|
|
296
|
+
*/
|
|
297
|
+
getOrderedListStart(): number;
|
|
288
298
|
getSizeIncreaseSinceCreation(): number;
|
|
289
299
|
private removeBullets;
|
|
290
300
|
private removeOrderedList;
|