@leapfrog/interactive-canvas 2.0.24-beta-5 → 2.0.24-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.
@@ -202,11 +202,11 @@ export declare abstract class AbstractInteractiveCanvas implements IInteractiveC
202
202
  * @inheritDoc
203
203
  */
204
204
  sendObjectToBack(target: FabricObject): void;
205
- addImageObject(imageUrl: string): Promise<IImage>;
206
205
  /**
207
206
  * @override
208
207
  * @inheritDoc
209
208
  */
209
+ addImageObject(imageUrl: string): Promise<IImage>;
210
210
  /**
211
211
  * @override
212
212
  * @inheritDoc
@@ -3034,6 +3034,10 @@ class AbstractInteractiveCanvas {
3034
3034
  this.fabricCanvas.requestRenderAll();
3035
3035
  }
3036
3036
  }
3037
+ /**
3038
+ * @override
3039
+ * @inheritDoc
3040
+ */
3037
3041
  addImageObject(imageUrl) {
3038
3042
  return __awaiter(this, void 0, void 0, function* () {
3039
3043
  // Don't let the image be more than half the canvas in size.
@@ -3095,131 +3099,6 @@ class AbstractInteractiveCanvas {
3095
3099
  }
3096
3100
  });
3097
3101
  }
3098
- /* public async addImageObject(imageUrl: string): Promise<IImage> {
3099
- const maxSizeScale = 2;
3100
- const maxWidth = this.dimensions$.value.widthPx / maxSizeScale;
3101
-
3102
- const options = { crossOrigin: "anonymous" };
3103
-
3104
- if (this.headless) {
3105
- const image = await loadImage(imageUrl);
3106
- console.log("image-->",image)
3107
- console.log("Loaded image:", imageUrl, "Width:", image.width, "Height:", image.height);
3108
- return this.createFabricImage(image, maxWidth);
3109
- } else {
3110
- return await new Promise((resolve) => {
3111
- this.fabric.Image.fromURL(imageUrl, options).then((fabricImage: FabricImage) => {
3112
- resolve(this.createFabricImage(fabricImage, maxWidth));
3113
- });
3114
- });
3115
- }
3116
- }
3117
-
3118
- private createFabricImage(image: any, maxWidth: number): IImage {
3119
- const id = this.randomId();
3120
- console.log("image inside createfabricimage-->",image)
3121
- let newScale = 1;
3122
- const curWidth = newScale * image.width;
3123
- if (curWidth > maxWidth) {
3124
- newScale = maxWidth / curWidth;
3125
- }
3126
-
3127
- const fabricImage = new FabricImage(image, {
3128
- id: id,
3129
- scaleX: newScale,
3130
- scaleY: newScale,
3131
- originX: "left",
3132
- originY: "top",
3133
- });
3134
-
3135
- this.fabricCanvas.add(fabricImage);
3136
-
3137
- const object = new Image(this, fabricImage);
3138
- this.trackNewObject(object);
3139
- this.syncObjectList();
3140
-
3141
- return object;
3142
- }*/
3143
- /* public async addImageObject(imageUrl: string): Promise<IImage> {
3144
- const maxSizeScale = 2;
3145
- const maxWidth = this.dimensions$.value.widthPx / maxSizeScale;
3146
-
3147
- // 1. Safe Isomorphic Options: Prevent browser configurations from cracking Server runs
3148
- const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
3149
- const options = isBrowser ? { crossOrigin: "anonymous" } : {};
3150
-
3151
- // 2. Fabric v6 Asynchronous Image Loader
3152
- const fabricImage = await this.fabric.Image.fromURL(imageUrl, options);
3153
-
3154
- const id = this.randomId();
3155
- let newScale = 1;
3156
- const curWidth = newScale * fabricImage.width;
3157
-
3158
- if (curWidth > maxWidth) {
3159
- newScale = maxWidth / curWidth;
3160
- }
3161
-
3162
- fabricImage.set({
3163
- id: id,
3164
- scaleX: newScale,
3165
- scaleY: newScale,
3166
- originX: "left",
3167
- originY: "top"
3168
- } as any);
3169
-
3170
- this.fabricCanvas.add(fabricImage);
3171
-
3172
- // Ensure 'Image' resolves to your internal custom class wrapper, not the native DOM global
3173
- // If your 'Image' class is a domain wrapper (e.g., CustomImageWrapper), name it distinctly to prevent collision.
3174
- const object = new (Image as any)(this, fabricImage);
3175
-
3176
- this.trackNewObject(object);
3177
- this.selectFabricObject(fabricImage);
3178
- this.syncObjectList();
3179
-
3180
- return object;
3181
- }*/
3182
- /**
3183
- * @override
3184
- * @inheritDoc
3185
- */
3186
- /* public async addImageObject(imageUrl: string): Promise<IImage> {
3187
- //Don't let the image be more than half the canvas in size.
3188
- const maxSizeScale = 2;
3189
- const maxWidth = this.dimensions$.value.widthPx / maxSizeScale;
3190
-
3191
- const options = {crossOrigin: "anonymous"};
3192
- return await new Promise((resolve) => {
3193
- this.fabric.Image.fromURL(imageUrl, options).then((fabricImage: FabricImage) => {
3194
- const id = this.randomId();
3195
-
3196
- let newScale = 1;
3197
-
3198
- const curWidth = newScale * fabricImage.width;
3199
- if (curWidth > maxWidth) {
3200
- newScale = maxWidth / curWidth;
3201
- }
3202
-
3203
- fabricImage.set({
3204
- id: id,
3205
- scaleX: newScale,
3206
- scaleY: newScale,
3207
- originX: "left",
3208
- originY: "top"
3209
- } as any);
3210
-
3211
- this.fabricCanvas.add(fabricImage);
3212
-
3213
- const object = new Image(this, fabricImage);
3214
- this.trackNewObject(object);
3215
- this.selectFabricObject(fabricImage);
3216
-
3217
- this.syncObjectList();
3218
-
3219
- resolve(object);
3220
- });
3221
- });
3222
- }*/
3223
3102
  /**
3224
3103
  * @override
3225
3104
  * @inheritDoc
@@ -3234,6 +3113,7 @@ class AbstractInteractiveCanvas {
3234
3113
  const topPx = Math.min(lowestTextPointPx, this.getDimensions().heightPx - fontSizePx);
3235
3114
  const textOptions = {
3236
3115
  id: id,
3116
+ objectCaching: false,
3237
3117
  top: topPx,
3238
3118
  left: 5,
3239
3119
  width: canvasWidthPx - 10,
@@ -3247,7 +3127,9 @@ class AbstractInteractiveCanvas {
3247
3127
  multiLine: true,
3248
3128
  lineHeight: profile.defaultLineHeight,
3249
3129
  charSpacing: profile.defaultCharacterSpacing,
3250
- perPixelTargetFind: false
3130
+ perPixelTargetFind: false,
3131
+ targetFindTolerance: 4,
3132
+ splitByGrapheme: true
3251
3133
  };
3252
3134
  const fabricTextbox = new this.fabric.Textbox("Text goes here", textOptions);
3253
3135
  this.fabricCanvas.add(fabricTextbox);
@@ -3055,6 +3055,10 @@ class AbstractInteractiveCanvas {
3055
3055
  this.fabricCanvas.requestRenderAll();
3056
3056
  }
3057
3057
  }
3058
+ /**
3059
+ * @override
3060
+ * @inheritDoc
3061
+ */
3058
3062
  addImageObject(imageUrl) {
3059
3063
  return __awaiter(this, void 0, void 0, function* () {
3060
3064
  // Don't let the image be more than half the canvas in size.
@@ -3116,131 +3120,6 @@ class AbstractInteractiveCanvas {
3116
3120
  }
3117
3121
  });
3118
3122
  }
3119
- /* public async addImageObject(imageUrl: string): Promise<IImage> {
3120
- const maxSizeScale = 2;
3121
- const maxWidth = this.dimensions$.value.widthPx / maxSizeScale;
3122
-
3123
- const options = { crossOrigin: "anonymous" };
3124
-
3125
- if (this.headless) {
3126
- const image = await loadImage(imageUrl);
3127
- console.log("image-->",image)
3128
- console.log("Loaded image:", imageUrl, "Width:", image.width, "Height:", image.height);
3129
- return this.createFabricImage(image, maxWidth);
3130
- } else {
3131
- return await new Promise((resolve) => {
3132
- this.fabric.Image.fromURL(imageUrl, options).then((fabricImage: FabricImage) => {
3133
- resolve(this.createFabricImage(fabricImage, maxWidth));
3134
- });
3135
- });
3136
- }
3137
- }
3138
-
3139
- private createFabricImage(image: any, maxWidth: number): IImage {
3140
- const id = this.randomId();
3141
- console.log("image inside createfabricimage-->",image)
3142
- let newScale = 1;
3143
- const curWidth = newScale * image.width;
3144
- if (curWidth > maxWidth) {
3145
- newScale = maxWidth / curWidth;
3146
- }
3147
-
3148
- const fabricImage = new FabricImage(image, {
3149
- id: id,
3150
- scaleX: newScale,
3151
- scaleY: newScale,
3152
- originX: "left",
3153
- originY: "top",
3154
- });
3155
-
3156
- this.fabricCanvas.add(fabricImage);
3157
-
3158
- const object = new Image(this, fabricImage);
3159
- this.trackNewObject(object);
3160
- this.syncObjectList();
3161
-
3162
- return object;
3163
- }*/
3164
- /* public async addImageObject(imageUrl: string): Promise<IImage> {
3165
- const maxSizeScale = 2;
3166
- const maxWidth = this.dimensions$.value.widthPx / maxSizeScale;
3167
-
3168
- // 1. Safe Isomorphic Options: Prevent browser configurations from cracking Server runs
3169
- const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
3170
- const options = isBrowser ? { crossOrigin: "anonymous" } : {};
3171
-
3172
- // 2. Fabric v6 Asynchronous Image Loader
3173
- const fabricImage = await this.fabric.Image.fromURL(imageUrl, options);
3174
-
3175
- const id = this.randomId();
3176
- let newScale = 1;
3177
- const curWidth = newScale * fabricImage.width;
3178
-
3179
- if (curWidth > maxWidth) {
3180
- newScale = maxWidth / curWidth;
3181
- }
3182
-
3183
- fabricImage.set({
3184
- id: id,
3185
- scaleX: newScale,
3186
- scaleY: newScale,
3187
- originX: "left",
3188
- originY: "top"
3189
- } as any);
3190
-
3191
- this.fabricCanvas.add(fabricImage);
3192
-
3193
- // Ensure 'Image' resolves to your internal custom class wrapper, not the native DOM global
3194
- // If your 'Image' class is a domain wrapper (e.g., CustomImageWrapper), name it distinctly to prevent collision.
3195
- const object = new (Image as any)(this, fabricImage);
3196
-
3197
- this.trackNewObject(object);
3198
- this.selectFabricObject(fabricImage);
3199
- this.syncObjectList();
3200
-
3201
- return object;
3202
- }*/
3203
- /**
3204
- * @override
3205
- * @inheritDoc
3206
- */
3207
- /* public async addImageObject(imageUrl: string): Promise<IImage> {
3208
- //Don't let the image be more than half the canvas in size.
3209
- const maxSizeScale = 2;
3210
- const maxWidth = this.dimensions$.value.widthPx / maxSizeScale;
3211
-
3212
- const options = {crossOrigin: "anonymous"};
3213
- return await new Promise((resolve) => {
3214
- this.fabric.Image.fromURL(imageUrl, options).then((fabricImage: FabricImage) => {
3215
- const id = this.randomId();
3216
-
3217
- let newScale = 1;
3218
-
3219
- const curWidth = newScale * fabricImage.width;
3220
- if (curWidth > maxWidth) {
3221
- newScale = maxWidth / curWidth;
3222
- }
3223
-
3224
- fabricImage.set({
3225
- id: id,
3226
- scaleX: newScale,
3227
- scaleY: newScale,
3228
- originX: "left",
3229
- originY: "top"
3230
- } as any);
3231
-
3232
- this.fabricCanvas.add(fabricImage);
3233
-
3234
- const object = new Image(this, fabricImage);
3235
- this.trackNewObject(object);
3236
- this.selectFabricObject(fabricImage);
3237
-
3238
- this.syncObjectList();
3239
-
3240
- resolve(object);
3241
- });
3242
- });
3243
- }*/
3244
3123
  /**
3245
3124
  * @override
3246
3125
  * @inheritDoc
@@ -3255,6 +3134,7 @@ class AbstractInteractiveCanvas {
3255
3134
  const topPx = Math.min(lowestTextPointPx, this.getDimensions().heightPx - fontSizePx);
3256
3135
  const textOptions = {
3257
3136
  id: id,
3137
+ objectCaching: false,
3258
3138
  top: topPx,
3259
3139
  left: 5,
3260
3140
  width: canvasWidthPx - 10,
@@ -3268,7 +3148,9 @@ class AbstractInteractiveCanvas {
3268
3148
  multiLine: true,
3269
3149
  lineHeight: profile.defaultLineHeight,
3270
3150
  charSpacing: profile.defaultCharacterSpacing,
3271
- perPixelTargetFind: false
3151
+ perPixelTargetFind: false,
3152
+ targetFindTolerance: 4,
3153
+ splitByGrapheme: true
3272
3154
  };
3273
3155
  const fabricTextbox = new this.fabric.Textbox("Text goes here", textOptions);
3274
3156
  this.fabricCanvas.add(fabricTextbox);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leapfrog/interactive-canvas",
3
- "version": "2.0.24-beta-5",
3
+ "version": "2.0.24-beta-6",
4
4
  "description": "Leapfrog interactive canvas",
5
5
  "files": [
6
6
  "dist"