@leapfrog/interactive-canvas 2.0.21-beta-1 → 2.0.21-beta-2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _, { round, each, values, reduce, clone,
|
|
1
|
+
import _, { round, each, values, reduce, clone, isEqual } from 'lodash';
|
|
2
2
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
3
3
|
import * as fabric from 'fabric';
|
|
4
4
|
|
|
@@ -2028,12 +2028,11 @@ class Text extends AbstractCanvasObject {
|
|
|
2028
2028
|
*/
|
|
2029
2029
|
setFontSize(fontSize) {
|
|
2030
2030
|
if (this.hasTextSelection()) {
|
|
2031
|
-
this.fabricObject.setSelectionStyles({ fontSize
|
|
2031
|
+
this.fabricObject.setSelectionStyles({ fontSize });
|
|
2032
2032
|
}
|
|
2033
2033
|
else {
|
|
2034
2034
|
this.fabricObject.set({ fontSize: fontSize });
|
|
2035
2035
|
}
|
|
2036
|
-
this.fabricObject.dirty = true;
|
|
2037
2036
|
this.redraw();
|
|
2038
2037
|
this.updateTextSelection();
|
|
2039
2038
|
}
|
|
@@ -2131,7 +2130,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2131
2130
|
if (!this.isBulleted())
|
|
2132
2131
|
return 0;
|
|
2133
2132
|
let fontSize = 0;
|
|
2134
|
-
each(this.fabricObject._textLines, (textLine, lineIndex) => {
|
|
2133
|
+
_.each(this.fabricObject._textLines, (textLine, lineIndex) => {
|
|
2135
2134
|
fontSize = Math.max(fontSize, this.fabricObject.getValueOfPropertyAt(lineIndex, 0, "fontSize"));
|
|
2136
2135
|
});
|
|
2137
2136
|
return fontSize * 0.6;
|
|
@@ -2144,10 +2143,11 @@ class Text extends AbstractCanvasObject {
|
|
|
2144
2143
|
if (!this.isOrderedList())
|
|
2145
2144
|
return 0;
|
|
2146
2145
|
const orderedListMarkerEntities = this.fabricObject._orderedListMarkerEntities;
|
|
2147
|
-
let
|
|
2146
|
+
let max = _(orderedListMarkerEntities)
|
|
2148
2147
|
.filter((x) => !!x)
|
|
2149
|
-
.map((x) => x.getBoundingRect().width)
|
|
2150
|
-
|
|
2148
|
+
.map((x) => x.getBoundingRect().width)
|
|
2149
|
+
.max();
|
|
2150
|
+
return max ? (max * 1.2) : 0;
|
|
2151
2151
|
}
|
|
2152
2152
|
/**
|
|
2153
2153
|
* @override
|
|
@@ -2281,7 +2281,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2281
2281
|
if (this.data.bulleted) {
|
|
2282
2282
|
const bullets = this.fabricObject["_bullets"];
|
|
2283
2283
|
delete this.fabricObject["_bullets"];
|
|
2284
|
-
each(bullets, (bullet) => this.canvas.removeFabricObject(bullet));
|
|
2284
|
+
_.each(bullets, (bullet) => this.canvas.removeFabricObject(bullet));
|
|
2285
2285
|
this.fabricObject["objectCaching"] = true;
|
|
2286
2286
|
}
|
|
2287
2287
|
}
|
|
@@ -2289,7 +2289,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2289
2289
|
if (this.fabricObject._isOrderedList) {
|
|
2290
2290
|
const markerEntities = this.fabricObject._orderedListMarkerEntities;
|
|
2291
2291
|
delete this.fabricObject._orderedListMarkerEntities;
|
|
2292
|
-
each(markerEntities, (marker) => this.canvas.removeFabricObject(marker));
|
|
2292
|
+
_.each(markerEntities, (marker) => this.canvas.removeFabricObject(marker));
|
|
2293
2293
|
this.fabricObject["objectCaching"] = true;
|
|
2294
2294
|
}
|
|
2295
2295
|
}
|
|
@@ -2306,7 +2306,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2306
2306
|
// Determine list of active bullets
|
|
2307
2307
|
const currentBullets = this.fabricObject.get("_bullets");
|
|
2308
2308
|
const activeBullets = {};
|
|
2309
|
-
each(this.fabricObject._textLines, (textLine, lineIndex) => {
|
|
2309
|
+
_.each(this.fabricObject._textLines, (textLine, lineIndex) => {
|
|
2310
2310
|
if (textLine.length) {
|
|
2311
2311
|
// Start of real lines will have offset 0 in styleMap
|
|
2312
2312
|
const styleMap = this.fabricObject._styleMap[lineIndex];
|
|
@@ -2343,13 +2343,13 @@ class Text extends AbstractCanvasObject {
|
|
|
2343
2343
|
let canvasDirty = false;
|
|
2344
2344
|
if (canvas) {
|
|
2345
2345
|
canvas.renderOnAddRemove = false;
|
|
2346
|
-
each(activeBullets, (bullet) => {
|
|
2346
|
+
_.each(activeBullets, (bullet) => {
|
|
2347
2347
|
if (!canvas.contains(bullet)) {
|
|
2348
2348
|
canvas.add(bullet);
|
|
2349
2349
|
canvasDirty = true;
|
|
2350
2350
|
}
|
|
2351
2351
|
});
|
|
2352
|
-
each(currentBullets, (bullet, key) => {
|
|
2352
|
+
_.each(currentBullets, (bullet, key) => {
|
|
2353
2353
|
if (!activeBullets[key]) {
|
|
2354
2354
|
canvas.remove(bullet);
|
|
2355
2355
|
canvasDirty = true;
|
|
@@ -2366,7 +2366,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2366
2366
|
if (this.fabricObject._isOrderedList) {
|
|
2367
2367
|
const existingMarkers = (_a = this.fabricObject._orderedListMarkerEntities) !== null && _a !== void 0 ? _a : [];
|
|
2368
2368
|
const activeMarkers = [];
|
|
2369
|
-
each(this.fabricObject._textLines, (textLine, lineIndex) => {
|
|
2369
|
+
_.each(this.fabricObject._textLines, (textLine, lineIndex) => {
|
|
2370
2370
|
if (textLine.length) {
|
|
2371
2371
|
// Start of real lines will have offset 0 in styleMap
|
|
2372
2372
|
const styleMap = this.fabricObject._styleMap[lineIndex];
|
|
@@ -2402,7 +2402,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2402
2402
|
let canvasDirty = false;
|
|
2403
2403
|
if (canvas) {
|
|
2404
2404
|
canvas.renderOnAddRemove = false;
|
|
2405
|
-
each(activeMarkers, (marker) => {
|
|
2405
|
+
_.each(activeMarkers, (marker) => {
|
|
2406
2406
|
if (!marker)
|
|
2407
2407
|
return;
|
|
2408
2408
|
if (!canvas.contains(marker)) {
|
|
@@ -2410,7 +2410,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2410
2410
|
canvasDirty = true;
|
|
2411
2411
|
}
|
|
2412
2412
|
});
|
|
2413
|
-
each(existingMarkers, (marker, key) => {
|
|
2413
|
+
_.each(existingMarkers, (marker, key) => {
|
|
2414
2414
|
if (!marker)
|
|
2415
2415
|
return;
|
|
2416
2416
|
if (!activeMarkers[key]) {
|
|
@@ -2049,12 +2049,11 @@ class Text extends AbstractCanvasObject {
|
|
|
2049
2049
|
*/
|
|
2050
2050
|
setFontSize(fontSize) {
|
|
2051
2051
|
if (this.hasTextSelection()) {
|
|
2052
|
-
this.fabricObject.setSelectionStyles({ fontSize
|
|
2052
|
+
this.fabricObject.setSelectionStyles({ fontSize });
|
|
2053
2053
|
}
|
|
2054
2054
|
else {
|
|
2055
2055
|
this.fabricObject.set({ fontSize: fontSize });
|
|
2056
2056
|
}
|
|
2057
|
-
this.fabricObject.dirty = true;
|
|
2058
2057
|
this.redraw();
|
|
2059
2058
|
this.updateTextSelection();
|
|
2060
2059
|
}
|
|
@@ -2165,10 +2164,11 @@ class Text extends AbstractCanvasObject {
|
|
|
2165
2164
|
if (!this.isOrderedList())
|
|
2166
2165
|
return 0;
|
|
2167
2166
|
const orderedListMarkerEntities = this.fabricObject._orderedListMarkerEntities;
|
|
2168
|
-
let
|
|
2167
|
+
let max = _(orderedListMarkerEntities)
|
|
2169
2168
|
.filter((x) => !!x)
|
|
2170
|
-
.map((x) => x.getBoundingRect().width)
|
|
2171
|
-
|
|
2169
|
+
.map((x) => x.getBoundingRect().width)
|
|
2170
|
+
.max();
|
|
2171
|
+
return max ? (max * 1.2) : 0;
|
|
2172
2172
|
}
|
|
2173
2173
|
/**
|
|
2174
2174
|
* @override
|