@leapfrog/interactive-canvas 2.0.20-beta-4 → 2.0.20-beta-6
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
|
/**
|
|
@@ -1778,7 +1778,7 @@ class Text extends AbstractCanvasObject {
|
|
|
1778
1778
|
this.textSelection$ = new BehaviorSubject(new TextSelection(this.fabricObject, this.fontLibrary));
|
|
1779
1779
|
this.fabricObject.set({ strokeWidth: 0 });
|
|
1780
1780
|
this.fabricObject.on("text:changed", () => this.onTextChange());
|
|
1781
|
-
this.fabricObject.on("
|
|
1781
|
+
this.fabricObject.on("selection:changed", () => this.onSelectionChange());
|
|
1782
1782
|
this.applyBulletListMonkeyPatches();
|
|
1783
1783
|
}
|
|
1784
1784
|
/**
|
|
@@ -2045,7 +2045,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2045
2045
|
else {
|
|
2046
2046
|
this.fabricObject.set({ textBackgroundColor: color });
|
|
2047
2047
|
}
|
|
2048
|
-
this.fabricObject.
|
|
2048
|
+
this.fabricObject.dirty = true;
|
|
2049
2049
|
this.redraw();
|
|
2050
2050
|
this.updateTextSelection();
|
|
2051
2051
|
}
|
|
@@ -2103,7 +2103,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2103
2103
|
* @inheritDoc
|
|
2104
2104
|
*/
|
|
2105
2105
|
setBackgroundColor(color) {
|
|
2106
|
-
this.fabricObject.set("backgroundColor"
|
|
2106
|
+
this.fabricObject.set({ "backgroundColor": color });
|
|
2107
2107
|
this.redraw();
|
|
2108
2108
|
}
|
|
2109
2109
|
/**
|
|
@@ -2184,9 +2184,11 @@ class Text extends AbstractCanvasObject {
|
|
|
2184
2184
|
enterEditing() {
|
|
2185
2185
|
if (!this.isEditing()) {
|
|
2186
2186
|
this.fabricObject.enterEditing();
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2187
|
+
setTimeout(() => {
|
|
2188
|
+
this.focus();
|
|
2189
|
+
this.selectAllText();
|
|
2190
|
+
this.redraw();
|
|
2191
|
+
}, 0);
|
|
2190
2192
|
}
|
|
2191
2193
|
}
|
|
2192
2194
|
/**
|
|
@@ -3777,10 +3779,6 @@ class InteractiveCanvas extends AbstractInteractiveCanvas {
|
|
|
3777
3779
|
this.devicePixelRatio = devicePixelRatio;
|
|
3778
3780
|
this.headless = false;
|
|
3779
3781
|
this.undoStack = new UndoStack(this);
|
|
3780
|
-
const canvasElement = document.getElementById('canvas');
|
|
3781
|
-
const width = canvasElement.clientWidth * devicePixelRatio;
|
|
3782
|
-
const height = canvasElement.clientHeight * devicePixelRatio;
|
|
3783
|
-
this.fabricCanvas.setDimensions({ width, height });
|
|
3784
3782
|
this.fabricCanvas.setViewportTransform([1, 0, 0, 1, 0, 0]);
|
|
3785
3783
|
this.fabricCanvas.setZoom(devicePixelRatio);
|
|
3786
3784
|
//Initialize watchers
|
|
@@ -3826,9 +3824,10 @@ class InteractiveCanvas extends AbstractInteractiveCanvas {
|
|
|
3826
3824
|
this.enterTextSelectionModeIfRequired();
|
|
3827
3825
|
}
|
|
3828
3826
|
enterTextSelectionModeIfRequired() {
|
|
3827
|
+
var _a, _b;
|
|
3829
3828
|
if (!this.profile$.value.enterTextEditImmediatelyOnSelect && !this.layoutManager$.value.enterTextEditImmediatelyOnSelect)
|
|
3830
3829
|
return;
|
|
3831
|
-
if (
|
|
3830
|
+
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)
|
|
3832
3831
|
return;
|
|
3833
3832
|
const text = this.selection$.value.objects[0];
|
|
3834
3833
|
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
|
/**
|
|
@@ -1799,7 +1799,7 @@ class Text extends AbstractCanvasObject {
|
|
|
1799
1799
|
this.textSelection$ = new rxjs.BehaviorSubject(new TextSelection(this.fabricObject, this.fontLibrary));
|
|
1800
1800
|
this.fabricObject.set({ strokeWidth: 0 });
|
|
1801
1801
|
this.fabricObject.on("text:changed", () => this.onTextChange());
|
|
1802
|
-
this.fabricObject.on("
|
|
1802
|
+
this.fabricObject.on("selection:changed", () => this.onSelectionChange());
|
|
1803
1803
|
this.applyBulletListMonkeyPatches();
|
|
1804
1804
|
}
|
|
1805
1805
|
/**
|
|
@@ -2066,7 +2066,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2066
2066
|
else {
|
|
2067
2067
|
this.fabricObject.set({ textBackgroundColor: color });
|
|
2068
2068
|
}
|
|
2069
|
-
this.fabricObject.
|
|
2069
|
+
this.fabricObject.dirty = true;
|
|
2070
2070
|
this.redraw();
|
|
2071
2071
|
this.updateTextSelection();
|
|
2072
2072
|
}
|
|
@@ -2124,7 +2124,7 @@ class Text extends AbstractCanvasObject {
|
|
|
2124
2124
|
* @inheritDoc
|
|
2125
2125
|
*/
|
|
2126
2126
|
setBackgroundColor(color) {
|
|
2127
|
-
this.fabricObject.set("backgroundColor"
|
|
2127
|
+
this.fabricObject.set({ "backgroundColor": color });
|
|
2128
2128
|
this.redraw();
|
|
2129
2129
|
}
|
|
2130
2130
|
/**
|
|
@@ -2205,9 +2205,11 @@ class Text extends AbstractCanvasObject {
|
|
|
2205
2205
|
enterEditing() {
|
|
2206
2206
|
if (!this.isEditing()) {
|
|
2207
2207
|
this.fabricObject.enterEditing();
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2208
|
+
setTimeout(() => {
|
|
2209
|
+
this.focus();
|
|
2210
|
+
this.selectAllText();
|
|
2211
|
+
this.redraw();
|
|
2212
|
+
}, 0);
|
|
2211
2213
|
}
|
|
2212
2214
|
}
|
|
2213
2215
|
/**
|
|
@@ -3798,10 +3800,6 @@ class InteractiveCanvas extends AbstractInteractiveCanvas {
|
|
|
3798
3800
|
this.devicePixelRatio = devicePixelRatio;
|
|
3799
3801
|
this.headless = false;
|
|
3800
3802
|
this.undoStack = new UndoStack(this);
|
|
3801
|
-
const canvasElement = document.getElementById('canvas');
|
|
3802
|
-
const width = canvasElement.clientWidth * devicePixelRatio;
|
|
3803
|
-
const height = canvasElement.clientHeight * devicePixelRatio;
|
|
3804
|
-
this.fabricCanvas.setDimensions({ width, height });
|
|
3805
3803
|
this.fabricCanvas.setViewportTransform([1, 0, 0, 1, 0, 0]);
|
|
3806
3804
|
this.fabricCanvas.setZoom(devicePixelRatio);
|
|
3807
3805
|
//Initialize watchers
|
|
@@ -3847,9 +3845,10 @@ class InteractiveCanvas extends AbstractInteractiveCanvas {
|
|
|
3847
3845
|
this.enterTextSelectionModeIfRequired();
|
|
3848
3846
|
}
|
|
3849
3847
|
enterTextSelectionModeIfRequired() {
|
|
3848
|
+
var _a, _b;
|
|
3850
3849
|
if (!this.profile$.value.enterTextEditImmediatelyOnSelect && !this.layoutManager$.value.enterTextEditImmediatelyOnSelect)
|
|
3851
3850
|
return;
|
|
3852
|
-
if (
|
|
3851
|
+
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)
|
|
3853
3852
|
return;
|
|
3854
3853
|
const text = this.selection$.value.objects[0];
|
|
3855
3854
|
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
|
}
|