@leapfrog/interactive-canvas 2.0.24-beta-4 → 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.
@@ -3062,8 +3066,6 @@ class AbstractInteractiveCanvas {
3062
3066
  },
3063
3067
  });
3064
3068
  this.fabricCanvas.add(fabricImage);
3065
- const canvasObjectData = new CanvasObjectData(ObjectType.IMAGE, id);
3066
- canvasObjectData.imagePath = imageUrl;
3067
3069
  const object = new Image(this, fabricImage);
3068
3070
  this.trackNewObject(object);
3069
3071
  this.syncObjectList();
@@ -3097,131 +3099,6 @@ class AbstractInteractiveCanvas {
3097
3099
  }
3098
3100
  });
3099
3101
  }
3100
- /* public async addImageObject(imageUrl: string): Promise<IImage> {
3101
- const maxSizeScale = 2;
3102
- const maxWidth = this.dimensions$.value.widthPx / maxSizeScale;
3103
-
3104
- const options = { crossOrigin: "anonymous" };
3105
-
3106
- if (this.headless) {
3107
- const image = await loadImage(imageUrl);
3108
- console.log("image-->",image)
3109
- console.log("Loaded image:", imageUrl, "Width:", image.width, "Height:", image.height);
3110
- return this.createFabricImage(image, maxWidth);
3111
- } else {
3112
- return await new Promise((resolve) => {
3113
- this.fabric.Image.fromURL(imageUrl, options).then((fabricImage: FabricImage) => {
3114
- resolve(this.createFabricImage(fabricImage, maxWidth));
3115
- });
3116
- });
3117
- }
3118
- }
3119
-
3120
- private createFabricImage(image: any, maxWidth: number): IImage {
3121
- const id = this.randomId();
3122
- console.log("image inside createfabricimage-->",image)
3123
- let newScale = 1;
3124
- const curWidth = newScale * image.width;
3125
- if (curWidth > maxWidth) {
3126
- newScale = maxWidth / curWidth;
3127
- }
3128
-
3129
- const fabricImage = new FabricImage(image, {
3130
- id: id,
3131
- scaleX: newScale,
3132
- scaleY: newScale,
3133
- originX: "left",
3134
- originY: "top",
3135
- });
3136
-
3137
- this.fabricCanvas.add(fabricImage);
3138
-
3139
- const object = new Image(this, fabricImage);
3140
- this.trackNewObject(object);
3141
- this.syncObjectList();
3142
-
3143
- return object;
3144
- }*/
3145
- /* public async addImageObject(imageUrl: string): Promise<IImage> {
3146
- const maxSizeScale = 2;
3147
- const maxWidth = this.dimensions$.value.widthPx / maxSizeScale;
3148
-
3149
- // 1. Safe Isomorphic Options: Prevent browser configurations from cracking Server runs
3150
- const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
3151
- const options = isBrowser ? { crossOrigin: "anonymous" } : {};
3152
-
3153
- // 2. Fabric v6 Asynchronous Image Loader
3154
- const fabricImage = await this.fabric.Image.fromURL(imageUrl, options);
3155
-
3156
- const id = this.randomId();
3157
- let newScale = 1;
3158
- const curWidth = newScale * fabricImage.width;
3159
-
3160
- if (curWidth > maxWidth) {
3161
- newScale = maxWidth / curWidth;
3162
- }
3163
-
3164
- fabricImage.set({
3165
- id: id,
3166
- scaleX: newScale,
3167
- scaleY: newScale,
3168
- originX: "left",
3169
- originY: "top"
3170
- } as any);
3171
-
3172
- this.fabricCanvas.add(fabricImage);
3173
-
3174
- // Ensure 'Image' resolves to your internal custom class wrapper, not the native DOM global
3175
- // If your 'Image' class is a domain wrapper (e.g., CustomImageWrapper), name it distinctly to prevent collision.
3176
- const object = new (Image as any)(this, fabricImage);
3177
-
3178
- this.trackNewObject(object);
3179
- this.selectFabricObject(fabricImage);
3180
- this.syncObjectList();
3181
-
3182
- return object;
3183
- }*/
3184
- /**
3185
- * @override
3186
- * @inheritDoc
3187
- */
3188
- /* public async addImageObject(imageUrl: string): Promise<IImage> {
3189
- //Don't let the image be more than half the canvas in size.
3190
- const maxSizeScale = 2;
3191
- const maxWidth = this.dimensions$.value.widthPx / maxSizeScale;
3192
-
3193
- const options = {crossOrigin: "anonymous"};
3194
- return await new Promise((resolve) => {
3195
- this.fabric.Image.fromURL(imageUrl, options).then((fabricImage: FabricImage) => {
3196
- const id = this.randomId();
3197
-
3198
- let newScale = 1;
3199
-
3200
- const curWidth = newScale * fabricImage.width;
3201
- if (curWidth > maxWidth) {
3202
- newScale = maxWidth / curWidth;
3203
- }
3204
-
3205
- fabricImage.set({
3206
- id: id,
3207
- scaleX: newScale,
3208
- scaleY: newScale,
3209
- originX: "left",
3210
- originY: "top"
3211
- } as any);
3212
-
3213
- this.fabricCanvas.add(fabricImage);
3214
-
3215
- const object = new Image(this, fabricImage);
3216
- this.trackNewObject(object);
3217
- this.selectFabricObject(fabricImage);
3218
-
3219
- this.syncObjectList();
3220
-
3221
- resolve(object);
3222
- });
3223
- });
3224
- }*/
3225
3102
  /**
3226
3103
  * @override
3227
3104
  * @inheritDoc
@@ -3236,6 +3113,7 @@ class AbstractInteractiveCanvas {
3236
3113
  const topPx = Math.min(lowestTextPointPx, this.getDimensions().heightPx - fontSizePx);
3237
3114
  const textOptions = {
3238
3115
  id: id,
3116
+ objectCaching: false,
3239
3117
  top: topPx,
3240
3118
  left: 5,
3241
3119
  width: canvasWidthPx - 10,
@@ -3245,9 +3123,13 @@ class AbstractInteractiveCanvas {
3245
3123
  fontSize: fontSizePx,
3246
3124
  fontFamily: profile.defaultFont,
3247
3125
  textAlign: profile.defaultTextAlignment,
3126
+ hoverCursor: "move",
3248
3127
  multiLine: true,
3249
3128
  lineHeight: profile.defaultLineHeight,
3250
- charSpacing: profile.defaultCharacterSpacing
3129
+ charSpacing: profile.defaultCharacterSpacing,
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.
@@ -3083,8 +3087,6 @@ class AbstractInteractiveCanvas {
3083
3087
  },
3084
3088
  });
3085
3089
  this.fabricCanvas.add(fabricImage);
3086
- const canvasObjectData = new CanvasObjectData(exports.ObjectType.IMAGE, id);
3087
- canvasObjectData.imagePath = imageUrl;
3088
3090
  const object = new Image(this, fabricImage);
3089
3091
  this.trackNewObject(object);
3090
3092
  this.syncObjectList();
@@ -3118,131 +3120,6 @@ class AbstractInteractiveCanvas {
3118
3120
  }
3119
3121
  });
3120
3122
  }
3121
- /* public async addImageObject(imageUrl: string): Promise<IImage> {
3122
- const maxSizeScale = 2;
3123
- const maxWidth = this.dimensions$.value.widthPx / maxSizeScale;
3124
-
3125
- const options = { crossOrigin: "anonymous" };
3126
-
3127
- if (this.headless) {
3128
- const image = await loadImage(imageUrl);
3129
- console.log("image-->",image)
3130
- console.log("Loaded image:", imageUrl, "Width:", image.width, "Height:", image.height);
3131
- return this.createFabricImage(image, maxWidth);
3132
- } else {
3133
- return await new Promise((resolve) => {
3134
- this.fabric.Image.fromURL(imageUrl, options).then((fabricImage: FabricImage) => {
3135
- resolve(this.createFabricImage(fabricImage, maxWidth));
3136
- });
3137
- });
3138
- }
3139
- }
3140
-
3141
- private createFabricImage(image: any, maxWidth: number): IImage {
3142
- const id = this.randomId();
3143
- console.log("image inside createfabricimage-->",image)
3144
- let newScale = 1;
3145
- const curWidth = newScale * image.width;
3146
- if (curWidth > maxWidth) {
3147
- newScale = maxWidth / curWidth;
3148
- }
3149
-
3150
- const fabricImage = new FabricImage(image, {
3151
- id: id,
3152
- scaleX: newScale,
3153
- scaleY: newScale,
3154
- originX: "left",
3155
- originY: "top",
3156
- });
3157
-
3158
- this.fabricCanvas.add(fabricImage);
3159
-
3160
- const object = new Image(this, fabricImage);
3161
- this.trackNewObject(object);
3162
- this.syncObjectList();
3163
-
3164
- return object;
3165
- }*/
3166
- /* public async addImageObject(imageUrl: string): Promise<IImage> {
3167
- const maxSizeScale = 2;
3168
- const maxWidth = this.dimensions$.value.widthPx / maxSizeScale;
3169
-
3170
- // 1. Safe Isomorphic Options: Prevent browser configurations from cracking Server runs
3171
- const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
3172
- const options = isBrowser ? { crossOrigin: "anonymous" } : {};
3173
-
3174
- // 2. Fabric v6 Asynchronous Image Loader
3175
- const fabricImage = await this.fabric.Image.fromURL(imageUrl, options);
3176
-
3177
- const id = this.randomId();
3178
- let newScale = 1;
3179
- const curWidth = newScale * fabricImage.width;
3180
-
3181
- if (curWidth > maxWidth) {
3182
- newScale = maxWidth / curWidth;
3183
- }
3184
-
3185
- fabricImage.set({
3186
- id: id,
3187
- scaleX: newScale,
3188
- scaleY: newScale,
3189
- originX: "left",
3190
- originY: "top"
3191
- } as any);
3192
-
3193
- this.fabricCanvas.add(fabricImage);
3194
-
3195
- // Ensure 'Image' resolves to your internal custom class wrapper, not the native DOM global
3196
- // If your 'Image' class is a domain wrapper (e.g., CustomImageWrapper), name it distinctly to prevent collision.
3197
- const object = new (Image as any)(this, fabricImage);
3198
-
3199
- this.trackNewObject(object);
3200
- this.selectFabricObject(fabricImage);
3201
- this.syncObjectList();
3202
-
3203
- return object;
3204
- }*/
3205
- /**
3206
- * @override
3207
- * @inheritDoc
3208
- */
3209
- /* public async addImageObject(imageUrl: string): Promise<IImage> {
3210
- //Don't let the image be more than half the canvas in size.
3211
- const maxSizeScale = 2;
3212
- const maxWidth = this.dimensions$.value.widthPx / maxSizeScale;
3213
-
3214
- const options = {crossOrigin: "anonymous"};
3215
- return await new Promise((resolve) => {
3216
- this.fabric.Image.fromURL(imageUrl, options).then((fabricImage: FabricImage) => {
3217
- const id = this.randomId();
3218
-
3219
- let newScale = 1;
3220
-
3221
- const curWidth = newScale * fabricImage.width;
3222
- if (curWidth > maxWidth) {
3223
- newScale = maxWidth / curWidth;
3224
- }
3225
-
3226
- fabricImage.set({
3227
- id: id,
3228
- scaleX: newScale,
3229
- scaleY: newScale,
3230
- originX: "left",
3231
- originY: "top"
3232
- } as any);
3233
-
3234
- this.fabricCanvas.add(fabricImage);
3235
-
3236
- const object = new Image(this, fabricImage);
3237
- this.trackNewObject(object);
3238
- this.selectFabricObject(fabricImage);
3239
-
3240
- this.syncObjectList();
3241
-
3242
- resolve(object);
3243
- });
3244
- });
3245
- }*/
3246
3123
  /**
3247
3124
  * @override
3248
3125
  * @inheritDoc
@@ -3257,6 +3134,7 @@ class AbstractInteractiveCanvas {
3257
3134
  const topPx = Math.min(lowestTextPointPx, this.getDimensions().heightPx - fontSizePx);
3258
3135
  const textOptions = {
3259
3136
  id: id,
3137
+ objectCaching: false,
3260
3138
  top: topPx,
3261
3139
  left: 5,
3262
3140
  width: canvasWidthPx - 10,
@@ -3266,9 +3144,13 @@ class AbstractInteractiveCanvas {
3266
3144
  fontSize: fontSizePx,
3267
3145
  fontFamily: profile.defaultFont,
3268
3146
  textAlign: profile.defaultTextAlignment,
3147
+ hoverCursor: "move",
3269
3148
  multiLine: true,
3270
3149
  lineHeight: profile.defaultLineHeight,
3271
- charSpacing: profile.defaultCharacterSpacing
3150
+ charSpacing: profile.defaultCharacterSpacing,
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-4",
3
+ "version": "2.0.24-beta-6",
4
4
  "description": "Leapfrog interactive canvas",
5
5
  "files": [
6
6
  "dist"