@leapfrog/interactive-canvas 2.0.20-beta-3 → 2.0.20-beta-5
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.
|
@@ -1067,7 +1067,7 @@ class BackgroundImage extends AbstractCanvasObject {
|
|
|
1067
1067
|
scaleX: widthPx / this.fabricObject.width,
|
|
1068
1068
|
scaleY: heightPx / this.fabricObject.height
|
|
1069
1069
|
});
|
|
1070
|
-
this.
|
|
1070
|
+
this.canvas.sendObjectToBack(this.fabricObject);
|
|
1071
1071
|
this.updateDimensions();
|
|
1072
1072
|
}
|
|
1073
1073
|
/**
|
|
@@ -1224,7 +1224,9 @@ class Border extends AbstractCanvasObject {
|
|
|
1224
1224
|
top: 0,
|
|
1225
1225
|
left: 0,
|
|
1226
1226
|
width: this.canvas.getDimensions().widthPx - this.strokeWidth$.value,
|
|
1227
|
-
height: this.canvas.getDimensions().heightPx - this.strokeWidth$.value
|
|
1227
|
+
height: this.canvas.getDimensions().heightPx - this.strokeWidth$.value,
|
|
1228
|
+
selectable: false,
|
|
1229
|
+
evented: false
|
|
1228
1230
|
});
|
|
1229
1231
|
}
|
|
1230
1232
|
/**
|
|
@@ -1776,7 +1778,7 @@ class Text extends AbstractCanvasObject {
|
|
|
1776
1778
|
this.textSelection$ = new BehaviorSubject(new TextSelection(this.fabricObject, this.fontLibrary));
|
|
1777
1779
|
this.fabricObject.set({ strokeWidth: 0 });
|
|
1778
1780
|
this.fabricObject.on("text:changed", () => this.onTextChange());
|
|
1779
|
-
this.fabricObject.on("
|
|
1781
|
+
this.fabricObject.on("selection:changed", () => this.onSelectionChange());
|
|
1780
1782
|
this.applyBulletListMonkeyPatches();
|
|
1781
1783
|
}
|
|
1782
1784
|
/**
|
|
@@ -2043,7 +2045,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2043
2045
|
else {
|
|
2044
2046
|
this.fabricObject.set({ textBackgroundColor: color });
|
|
2045
2047
|
}
|
|
2046
|
-
this.fabricObject.
|
|
2048
|
+
this.fabricObject.dirty = true;
|
|
2047
2049
|
this.redraw();
|
|
2048
2050
|
this.updateTextSelection();
|
|
2049
2051
|
}
|
|
@@ -2101,7 +2103,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2101
2103
|
* @inheritDoc
|
|
2102
2104
|
*/
|
|
2103
2105
|
setBackgroundColor(color) {
|
|
2104
|
-
this.fabricObject.set("backgroundColor"
|
|
2106
|
+
this.fabricObject.set({ "backgroundColor": color });
|
|
2105
2107
|
this.redraw();
|
|
2106
2108
|
}
|
|
2107
2109
|
/**
|
|
@@ -2182,9 +2184,11 @@ class Text extends AbstractCanvasObject {
|
|
|
2182
2184
|
enterEditing() {
|
|
2183
2185
|
if (!this.isEditing()) {
|
|
2184
2186
|
this.fabricObject.enterEditing();
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2187
|
+
setTimeout(() => {
|
|
2188
|
+
this.focus();
|
|
2189
|
+
this.selectAllText();
|
|
2190
|
+
this.redraw();
|
|
2191
|
+
}, 0);
|
|
2188
2192
|
}
|
|
2189
2193
|
}
|
|
2190
2194
|
/**
|
|
@@ -3358,8 +3362,6 @@ class AbstractInteractiveCanvas {
|
|
|
3358
3362
|
}
|
|
3359
3363
|
setMultiSelect(value) {
|
|
3360
3364
|
this.fabricCanvas.selection = value;
|
|
3361
|
-
this.fabricCanvas.selectionColor = value ? "rgba(0,0,0,0.1)" : "transparent"; // Adjust selection color
|
|
3362
|
-
this.fabricCanvas.selectionBorderColor = "transparent";
|
|
3363
3365
|
this.fabricCanvas.selectionKey = value ? "shiftKey" : null;
|
|
3364
3366
|
}
|
|
3365
3367
|
/**
|
|
@@ -3601,12 +3603,7 @@ class AbstractInteractiveCanvas {
|
|
|
3601
3603
|
}
|
|
3602
3604
|
findObject(id) {
|
|
3603
3605
|
//Don't use strict compare here. fabric ids are numbers while ad builder ids are strings... mostly.
|
|
3604
|
-
|
|
3605
|
-
const foundObject = _.find(this.objects$.value, (object) => object.getId() == id);
|
|
3606
|
-
if (!foundObject) {
|
|
3607
|
-
throw new Error(`Object with id [${id}] not found`);
|
|
3608
|
-
}
|
|
3609
|
-
return foundObject;
|
|
3606
|
+
return _.find(this.objects$.value, (object) => object.getId() == id);
|
|
3610
3607
|
}
|
|
3611
3608
|
/**
|
|
3612
3609
|
* Reset zoom and canvas dimensions to 1:1 scale, execute a function, then return the canvas to
|
|
@@ -3687,7 +3684,6 @@ class AbstractInteractiveCanvas {
|
|
|
3687
3684
|
class SelectionData {
|
|
3688
3685
|
constructor(objects) {
|
|
3689
3686
|
this.objects = objects;
|
|
3690
|
-
console.log(objects[0], "objects");
|
|
3691
3687
|
this.empty = this.objects.length < 1;
|
|
3692
3688
|
const selectedObject = this.objects[0];
|
|
3693
3689
|
this.isText = (selectedObject === null || selectedObject === void 0 ? void 0 : selectedObject.getType()) === ObjectType.TEXT
|
|
@@ -3832,9 +3828,10 @@ class InteractiveCanvas extends AbstractInteractiveCanvas {
|
|
|
3832
3828
|
this.enterTextSelectionModeIfRequired();
|
|
3833
3829
|
}
|
|
3834
3830
|
enterTextSelectionModeIfRequired() {
|
|
3831
|
+
var _a, _b;
|
|
3835
3832
|
if (!this.profile$.value.enterTextEditImmediatelyOnSelect && !this.layoutManager$.value.enterTextEditImmediatelyOnSelect)
|
|
3836
3833
|
return;
|
|
3837
|
-
if (
|
|
3834
|
+
if (((_b = (_a = this.selection$.value) === null || _a === void 0 ? void 0 : _a.objects[0]) === null || _b === void 0 ? void 0 : _b.getType()) !== ObjectType.TEXT)
|
|
3838
3835
|
return;
|
|
3839
3836
|
const text = this.selection$.value.objects[0];
|
|
3840
3837
|
text.enterEditing();
|
|
@@ -1088,7 +1088,7 @@ class BackgroundImage extends AbstractCanvasObject {
|
|
|
1088
1088
|
scaleX: widthPx / this.fabricObject.width,
|
|
1089
1089
|
scaleY: heightPx / this.fabricObject.height
|
|
1090
1090
|
});
|
|
1091
|
-
this.
|
|
1091
|
+
this.canvas.sendObjectToBack(this.fabricObject);
|
|
1092
1092
|
this.updateDimensions();
|
|
1093
1093
|
}
|
|
1094
1094
|
/**
|
|
@@ -1245,7 +1245,9 @@ class Border extends AbstractCanvasObject {
|
|
|
1245
1245
|
top: 0,
|
|
1246
1246
|
left: 0,
|
|
1247
1247
|
width: this.canvas.getDimensions().widthPx - this.strokeWidth$.value,
|
|
1248
|
-
height: this.canvas.getDimensions().heightPx - this.strokeWidth$.value
|
|
1248
|
+
height: this.canvas.getDimensions().heightPx - this.strokeWidth$.value,
|
|
1249
|
+
selectable: false,
|
|
1250
|
+
evented: false
|
|
1249
1251
|
});
|
|
1250
1252
|
}
|
|
1251
1253
|
/**
|
|
@@ -1797,7 +1799,7 @@ class Text extends AbstractCanvasObject {
|
|
|
1797
1799
|
this.textSelection$ = new rxjs.BehaviorSubject(new TextSelection(this.fabricObject, this.fontLibrary));
|
|
1798
1800
|
this.fabricObject.set({ strokeWidth: 0 });
|
|
1799
1801
|
this.fabricObject.on("text:changed", () => this.onTextChange());
|
|
1800
|
-
this.fabricObject.on("
|
|
1802
|
+
this.fabricObject.on("selection:changed", () => this.onSelectionChange());
|
|
1801
1803
|
this.applyBulletListMonkeyPatches();
|
|
1802
1804
|
}
|
|
1803
1805
|
/**
|
|
@@ -2064,7 +2066,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2064
2066
|
else {
|
|
2065
2067
|
this.fabricObject.set({ textBackgroundColor: color });
|
|
2066
2068
|
}
|
|
2067
|
-
this.fabricObject.
|
|
2069
|
+
this.fabricObject.dirty = true;
|
|
2068
2070
|
this.redraw();
|
|
2069
2071
|
this.updateTextSelection();
|
|
2070
2072
|
}
|
|
@@ -2122,7 +2124,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2122
2124
|
* @inheritDoc
|
|
2123
2125
|
*/
|
|
2124
2126
|
setBackgroundColor(color) {
|
|
2125
|
-
this.fabricObject.set("backgroundColor"
|
|
2127
|
+
this.fabricObject.set({ "backgroundColor": color });
|
|
2126
2128
|
this.redraw();
|
|
2127
2129
|
}
|
|
2128
2130
|
/**
|
|
@@ -2203,9 +2205,11 @@ class Text extends AbstractCanvasObject {
|
|
|
2203
2205
|
enterEditing() {
|
|
2204
2206
|
if (!this.isEditing()) {
|
|
2205
2207
|
this.fabricObject.enterEditing();
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2208
|
+
setTimeout(() => {
|
|
2209
|
+
this.focus();
|
|
2210
|
+
this.selectAllText();
|
|
2211
|
+
this.redraw();
|
|
2212
|
+
}, 0);
|
|
2209
2213
|
}
|
|
2210
2214
|
}
|
|
2211
2215
|
/**
|
|
@@ -3379,8 +3383,6 @@ class AbstractInteractiveCanvas {
|
|
|
3379
3383
|
}
|
|
3380
3384
|
setMultiSelect(value) {
|
|
3381
3385
|
this.fabricCanvas.selection = value;
|
|
3382
|
-
this.fabricCanvas.selectionColor = value ? "rgba(0,0,0,0.1)" : "transparent"; // Adjust selection color
|
|
3383
|
-
this.fabricCanvas.selectionBorderColor = "transparent";
|
|
3384
3386
|
this.fabricCanvas.selectionKey = value ? "shiftKey" : null;
|
|
3385
3387
|
}
|
|
3386
3388
|
/**
|
|
@@ -3622,12 +3624,7 @@ class AbstractInteractiveCanvas {
|
|
|
3622
3624
|
}
|
|
3623
3625
|
findObject(id) {
|
|
3624
3626
|
//Don't use strict compare here. fabric ids are numbers while ad builder ids are strings... mostly.
|
|
3625
|
-
|
|
3626
|
-
const foundObject = _.find(this.objects$.value, (object) => object.getId() == id);
|
|
3627
|
-
if (!foundObject) {
|
|
3628
|
-
throw new Error(`Object with id [${id}] not found`);
|
|
3629
|
-
}
|
|
3630
|
-
return foundObject;
|
|
3627
|
+
return _.find(this.objects$.value, (object) => object.getId() == id);
|
|
3631
3628
|
}
|
|
3632
3629
|
/**
|
|
3633
3630
|
* Reset zoom and canvas dimensions to 1:1 scale, execute a function, then return the canvas to
|
|
@@ -3708,7 +3705,6 @@ class AbstractInteractiveCanvas {
|
|
|
3708
3705
|
class SelectionData {
|
|
3709
3706
|
constructor(objects) {
|
|
3710
3707
|
this.objects = objects;
|
|
3711
|
-
console.log(objects[0], "objects");
|
|
3712
3708
|
this.empty = this.objects.length < 1;
|
|
3713
3709
|
const selectedObject = this.objects[0];
|
|
3714
3710
|
this.isText = (selectedObject === null || selectedObject === void 0 ? void 0 : selectedObject.getType()) === exports.ObjectType.TEXT
|
|
@@ -3853,9 +3849,10 @@ class InteractiveCanvas extends AbstractInteractiveCanvas {
|
|
|
3853
3849
|
this.enterTextSelectionModeIfRequired();
|
|
3854
3850
|
}
|
|
3855
3851
|
enterTextSelectionModeIfRequired() {
|
|
3852
|
+
var _a, _b;
|
|
3856
3853
|
if (!this.profile$.value.enterTextEditImmediatelyOnSelect && !this.layoutManager$.value.enterTextEditImmediatelyOnSelect)
|
|
3857
3854
|
return;
|
|
3858
|
-
if (
|
|
3855
|
+
if (((_b = (_a = this.selection$.value) === null || _a === void 0 ? void 0 : _a.objects[0]) === null || _b === void 0 ? void 0 : _b.getType()) !== exports.ObjectType.TEXT)
|
|
3859
3856
|
return;
|
|
3860
3857
|
const text = this.selection$.value.objects[0];
|
|
3861
3858
|
text.enterEditing();
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import { ExtendedFabricObject } from "./extended-fabric-object.interface";
|
|
2
2
|
import * as fabric from "fabric";
|
|
3
|
-
|
|
3
|
+
import { TEvent, TPointerEvent } from "fabric";
|
|
4
|
+
export interface ExtendedFabricTextbox extends fabric.Textbox, ExtendedFabricObject {
|
|
4
5
|
_isOrderedList?: boolean;
|
|
5
6
|
_orderedListStart?: number;
|
|
6
7
|
_orderedListMarkerEntities?: fabric.Textbox[];
|
|
7
8
|
_bullets?: Record<number, fabric.Object>;
|
|
9
|
+
_setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick<this, 'fill'>): any;
|
|
10
|
+
_setStrokeStyles(ctx: CanvasRenderingContext2D, decl: Pick<this, 'stroke' | 'strokeWidth' | 'strokeLineCap' | 'strokeDashOffset' | 'strokeLineJoin' | 'strokeMiterLimit'>): any;
|
|
11
|
+
fire(eventName: string, options?: any): any;
|
|
12
|
+
off(eventName?: any, handler?: (e: TEvent) => void): any;
|
|
13
|
+
on: any;
|
|
14
|
+
onDeselect: any;
|
|
15
|
+
once: any;
|
|
16
|
+
renderDragSourceEffect(_e: DragEvent): void;
|
|
17
|
+
renderDragSourceEffect(): void;
|
|
18
|
+
set(options: Partial<this>): any;
|
|
19
|
+
shouldStartDragging(_e: TPointerEvent): boolean;
|
|
20
|
+
shouldStartDragging(): boolean;
|
|
21
|
+
toObject(propertiesToInclude?: string[]): any;
|
|
22
|
+
toObject<T extends Omit<Partial<any>, keyof any>, K extends keyof T = never>(propertiesToInclude?: K[]): Pick<any, any>;
|
|
23
|
+
type: string;
|
|
24
|
+
selectAll(): any;
|
|
25
|
+
exitEditing(): any;
|
|
8
26
|
}
|