@leapfrog/interactive-canvas 1.14.0-beta.1 → 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.
|
@@ -489,6 +489,8 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
489
489
|
return;
|
|
490
490
|
if (object.getType() === ObjectType.TEXT && object.isBulleted())
|
|
491
491
|
actualWidth -= object.getBulletMargin();
|
|
492
|
+
if (object.getType() === ObjectType.TEXT && object.isOrderedList())
|
|
493
|
+
actualWidth -= object.getOrderedListMargin();
|
|
492
494
|
object.setPosition({
|
|
493
495
|
width: actualWidth
|
|
494
496
|
});
|
|
@@ -1893,18 +1895,18 @@ var RichText = /** @class */ (function (_super) {
|
|
|
1893
1895
|
var Text = /** @class */ (function (_super) {
|
|
1894
1896
|
__extends(Text, _super);
|
|
1895
1897
|
function Text(canvas, fabricObject, persistedField) {
|
|
1896
|
-
var
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
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;
|
|
1908
1910
|
}
|
|
1909
1911
|
/**
|
|
1910
1912
|
* @override
|
|
@@ -2235,12 +2237,12 @@ var Text = /** @class */ (function (_super) {
|
|
|
2235
2237
|
* @inheritDoc
|
|
2236
2238
|
*/
|
|
2237
2239
|
Text.prototype.getBulletMargin = function () {
|
|
2238
|
-
var
|
|
2240
|
+
var _this_1 = this;
|
|
2239
2241
|
if (!this.isBulleted())
|
|
2240
2242
|
return 0;
|
|
2241
2243
|
var fontSize = 0;
|
|
2242
2244
|
each(this.fabricObject._textLines, function (textLine, lineIndex) {
|
|
2243
|
-
fontSize = Math.max(fontSize,
|
|
2245
|
+
fontSize = Math.max(fontSize, _this_1.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
|
|
2244
2246
|
});
|
|
2245
2247
|
return fontSize * 0.6;
|
|
2246
2248
|
};
|
|
@@ -2249,12 +2251,12 @@ var Text = /** @class */ (function (_super) {
|
|
|
2249
2251
|
* @inheritDoc
|
|
2250
2252
|
*/
|
|
2251
2253
|
Text.prototype.getOrderedListMargin = function () {
|
|
2252
|
-
var
|
|
2254
|
+
var _this_1 = this;
|
|
2253
2255
|
if (!this.isOrderedList())
|
|
2254
2256
|
return 0;
|
|
2255
2257
|
var fontSize = 0;
|
|
2256
2258
|
each(this.fabricObject._textLines, function (textLine, lineIndex) {
|
|
2257
|
-
fontSize = Math.max(fontSize,
|
|
2259
|
+
fontSize = Math.max(fontSize, _this_1.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
|
|
2258
2260
|
});
|
|
2259
2261
|
return fontSize * 1.5;
|
|
2260
2262
|
};
|
|
@@ -2363,28 +2365,44 @@ var Text = /** @class */ (function (_super) {
|
|
|
2363
2365
|
this.notifyCanvasOfTextChanges();
|
|
2364
2366
|
this.redraw();
|
|
2365
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
|
+
};
|
|
2366
2383
|
Text.prototype.getSizeIncreaseSinceCreation = function () {
|
|
2367
2384
|
return Math.max(0, this.fabricObject.height - this.baseComponentHeight);
|
|
2368
2385
|
};
|
|
2369
2386
|
Text.prototype.removeBullets = function () {
|
|
2370
|
-
var
|
|
2387
|
+
var _this_1 = this;
|
|
2371
2388
|
if (this.data.bulleted) {
|
|
2372
2389
|
var bullets = this.fabricObject["_bullets"];
|
|
2373
2390
|
delete this.fabricObject["_bullets"];
|
|
2374
|
-
each(bullets, function (bullet) { return
|
|
2391
|
+
each(bullets, function (bullet) { return _this_1.canvas.removeFabricObject(bullet); });
|
|
2375
2392
|
this.fabricObject["objectCaching"] = true;
|
|
2376
2393
|
}
|
|
2377
2394
|
};
|
|
2378
2395
|
Text.prototype.removeOrderedList = function () {
|
|
2379
|
-
var
|
|
2396
|
+
var _this_1 = this;
|
|
2380
2397
|
if (this.fabricObject.orderedList) {
|
|
2381
2398
|
var lineNumbers = this.fabricObject["_currentLineNumbers"];
|
|
2382
2399
|
delete this.fabricObject["_currentLineNumbers"];
|
|
2383
|
-
each(lineNumbers, function (lineNumber) { return
|
|
2400
|
+
each(lineNumbers, function (lineNumber) { return _this_1.canvas.removeFabricObject(lineNumber); });
|
|
2384
2401
|
this.fabricObject["objectCaching"] = true;
|
|
2385
2402
|
}
|
|
2386
2403
|
};
|
|
2387
2404
|
Text.prototype.applyBulletListMonkeyPatches = function () {
|
|
2405
|
+
var _this = this;
|
|
2388
2406
|
if (this.data.bulleted)
|
|
2389
2407
|
this.enableBullets();
|
|
2390
2408
|
if (this.fabricObject.orderedList)
|
|
@@ -2542,7 +2560,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2542
2560
|
var yShift = (fabricText.height / 2) + top - fontSize - 1;
|
|
2543
2561
|
var xOffset = (xShift * Math.cos(theta)) - (yShift * Math.sin(theta));
|
|
2544
2562
|
var yOffset = (xShift * Math.sin(theta)) + (yShift * Math.cos(theta));
|
|
2545
|
-
var lineNumber =
|
|
2563
|
+
var lineNumber = _this.getOrderedListStart();
|
|
2546
2564
|
for (var i = 0; i < lineIndex; i++) {
|
|
2547
2565
|
if (currentLineNumbers[i])
|
|
2548
2566
|
lineNumber++;
|
|
@@ -3460,7 +3478,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3460
3478
|
var objects = _(this.objects$.value)
|
|
3461
3479
|
.map(function (x) { return x.persist(); })
|
|
3462
3480
|
.value();
|
|
3463
|
-
var includedProperties = ["id", "orderedList"];
|
|
3481
|
+
var includedProperties = ["id", "orderedList", "orderedListIndex"];
|
|
3464
3482
|
var json = this.fabricCanvas.toJSON(includedProperties);
|
|
3465
3483
|
return {
|
|
3466
3484
|
dimensions: this.dimensions$.value,
|
|
@@ -491,6 +491,8 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
491
491
|
return;
|
|
492
492
|
if (object.getType() === exports.ObjectType.TEXT && object.isBulleted())
|
|
493
493
|
actualWidth -= object.getBulletMargin();
|
|
494
|
+
if (object.getType() === exports.ObjectType.TEXT && object.isOrderedList())
|
|
495
|
+
actualWidth -= object.getOrderedListMargin();
|
|
494
496
|
object.setPosition({
|
|
495
497
|
width: actualWidth
|
|
496
498
|
});
|
|
@@ -1895,18 +1897,18 @@ var RichText = /** @class */ (function (_super) {
|
|
|
1895
1897
|
var Text = /** @class */ (function (_super) {
|
|
1896
1898
|
__extends(Text, _super);
|
|
1897
1899
|
function Text(canvas, fabricObject, persistedField) {
|
|
1898
|
-
var
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
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;
|
|
1910
1912
|
}
|
|
1911
1913
|
/**
|
|
1912
1914
|
* @override
|
|
@@ -2237,12 +2239,12 @@ var Text = /** @class */ (function (_super) {
|
|
|
2237
2239
|
* @inheritDoc
|
|
2238
2240
|
*/
|
|
2239
2241
|
Text.prototype.getBulletMargin = function () {
|
|
2240
|
-
var
|
|
2242
|
+
var _this_1 = this;
|
|
2241
2243
|
if (!this.isBulleted())
|
|
2242
2244
|
return 0;
|
|
2243
2245
|
var fontSize = 0;
|
|
2244
2246
|
_.each(this.fabricObject._textLines, function (textLine, lineIndex) {
|
|
2245
|
-
fontSize = Math.max(fontSize,
|
|
2247
|
+
fontSize = Math.max(fontSize, _this_1.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
|
|
2246
2248
|
});
|
|
2247
2249
|
return fontSize * 0.6;
|
|
2248
2250
|
};
|
|
@@ -2251,12 +2253,12 @@ var Text = /** @class */ (function (_super) {
|
|
|
2251
2253
|
* @inheritDoc
|
|
2252
2254
|
*/
|
|
2253
2255
|
Text.prototype.getOrderedListMargin = function () {
|
|
2254
|
-
var
|
|
2256
|
+
var _this_1 = this;
|
|
2255
2257
|
if (!this.isOrderedList())
|
|
2256
2258
|
return 0;
|
|
2257
2259
|
var fontSize = 0;
|
|
2258
2260
|
_.each(this.fabricObject._textLines, function (textLine, lineIndex) {
|
|
2259
|
-
fontSize = Math.max(fontSize,
|
|
2261
|
+
fontSize = Math.max(fontSize, _this_1.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
|
|
2260
2262
|
});
|
|
2261
2263
|
return fontSize * 1.5;
|
|
2262
2264
|
};
|
|
@@ -2365,28 +2367,44 @@ var Text = /** @class */ (function (_super) {
|
|
|
2365
2367
|
this.notifyCanvasOfTextChanges();
|
|
2366
2368
|
this.redraw();
|
|
2367
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
|
+
};
|
|
2368
2385
|
Text.prototype.getSizeIncreaseSinceCreation = function () {
|
|
2369
2386
|
return Math.max(0, this.fabricObject.height - this.baseComponentHeight);
|
|
2370
2387
|
};
|
|
2371
2388
|
Text.prototype.removeBullets = function () {
|
|
2372
|
-
var
|
|
2389
|
+
var _this_1 = this;
|
|
2373
2390
|
if (this.data.bulleted) {
|
|
2374
2391
|
var bullets = this.fabricObject["_bullets"];
|
|
2375
2392
|
delete this.fabricObject["_bullets"];
|
|
2376
|
-
_.each(bullets, function (bullet) { return
|
|
2393
|
+
_.each(bullets, function (bullet) { return _this_1.canvas.removeFabricObject(bullet); });
|
|
2377
2394
|
this.fabricObject["objectCaching"] = true;
|
|
2378
2395
|
}
|
|
2379
2396
|
};
|
|
2380
2397
|
Text.prototype.removeOrderedList = function () {
|
|
2381
|
-
var
|
|
2398
|
+
var _this_1 = this;
|
|
2382
2399
|
if (this.fabricObject.orderedList) {
|
|
2383
2400
|
var lineNumbers = this.fabricObject["_currentLineNumbers"];
|
|
2384
2401
|
delete this.fabricObject["_currentLineNumbers"];
|
|
2385
|
-
_.each(lineNumbers, function (lineNumber) { return
|
|
2402
|
+
_.each(lineNumbers, function (lineNumber) { return _this_1.canvas.removeFabricObject(lineNumber); });
|
|
2386
2403
|
this.fabricObject["objectCaching"] = true;
|
|
2387
2404
|
}
|
|
2388
2405
|
};
|
|
2389
2406
|
Text.prototype.applyBulletListMonkeyPatches = function () {
|
|
2407
|
+
var _this = this;
|
|
2390
2408
|
if (this.data.bulleted)
|
|
2391
2409
|
this.enableBullets();
|
|
2392
2410
|
if (this.fabricObject.orderedList)
|
|
@@ -2544,7 +2562,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
2544
2562
|
var yShift = (fabricText.height / 2) + top - fontSize - 1;
|
|
2545
2563
|
var xOffset = (xShift * Math.cos(theta)) - (yShift * Math.sin(theta));
|
|
2546
2564
|
var yOffset = (xShift * Math.sin(theta)) + (yShift * Math.cos(theta));
|
|
2547
|
-
var lineNumber =
|
|
2565
|
+
var lineNumber = _this.getOrderedListStart();
|
|
2548
2566
|
for (var i = 0; i < lineIndex; i++) {
|
|
2549
2567
|
if (currentLineNumbers[i])
|
|
2550
2568
|
lineNumber++;
|
|
@@ -3460,7 +3478,7 @@ var AbstractInteractiveCanvas = /** @class */ (function () {
|
|
|
3460
3478
|
var objects = _(this.objects$.value)
|
|
3461
3479
|
.map(function (x) { return x.persist(); })
|
|
3462
3480
|
.value();
|
|
3463
|
-
var includedProperties = ["id", "orderedList"];
|
|
3481
|
+
var includedProperties = ["id", "orderedList", "orderedListIndex"];
|
|
3464
3482
|
var json = this.fabricCanvas.toJSON(includedProperties);
|
|
3465
3483
|
return {
|
|
3466
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;
|