@inditextech/weave-sdk 3.2.0-SNAPSHOT.112.1 → 3.2.0-SNAPSHOT.114.1

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.
package/dist/sdk.js CHANGED
@@ -21957,7 +21957,7 @@ var WeaveRegisterManager = class {
21957
21957
 
21958
21958
  //#endregion
21959
21959
  //#region package.json
21960
- var version = "3.2.0-SNAPSHOT.112.1";
21960
+ var version = "3.2.0-SNAPSHOT.114.1";
21961
21961
 
21962
21962
  //#endregion
21963
21963
  //#region src/managers/setup.ts
@@ -25697,6 +25697,57 @@ var WeaveImageCrop = class WeaveImageCrop {
25697
25697
  }
25698
25698
  };
25699
25699
 
25700
+ //#endregion
25701
+ //#region src/nodes/image/utils.ts
25702
+ const extractCursorUrl = (cursor, fallback) => {
25703
+ const lower = cursor.toLowerCase();
25704
+ const start = lower.indexOf("url(");
25705
+ if (start === -1) return {
25706
+ preload: false,
25707
+ cursor
25708
+ };
25709
+ let i = start + 4;
25710
+ const len = cursor.length;
25711
+ while (i < len && /\s/.test(cursor[i])) i++;
25712
+ let quote = null;
25713
+ if (cursor[i] === "\"" || cursor[i] === "'") {
25714
+ quote = cursor[i];
25715
+ i++;
25716
+ }
25717
+ let buf = "";
25718
+ for (; i < len; i++) {
25719
+ const ch = cursor[i];
25720
+ if (quote) {
25721
+ if (ch === quote) {
25722
+ i++;
25723
+ break;
25724
+ }
25725
+ buf += ch;
25726
+ } else {
25727
+ if (ch === ")") break;
25728
+ buf += ch;
25729
+ }
25730
+ }
25731
+ const url = buf.trim();
25732
+ if (!url) return {
25733
+ preload: false,
25734
+ cursor: fallback
25735
+ };
25736
+ if (!isAllowedUrl(url)) return {
25737
+ preload: false,
25738
+ cursor: fallback
25739
+ };
25740
+ return {
25741
+ preload: true,
25742
+ cursor: url
25743
+ };
25744
+ };
25745
+ const isAllowedUrl = (value) => {
25746
+ if (/^https?:\/\//i.test(value)) return true;
25747
+ if (/^(javascript|data|blob|ftp):/i.test(value)) return false;
25748
+ return true;
25749
+ };
25750
+
25700
25751
  //#endregion
25701
25752
  //#region src/nodes/image/image.ts
25702
25753
  var WeaveImageNode = class extends WeaveNode {
@@ -25732,7 +25783,7 @@ var WeaveImageNode = class extends WeaveNode {
25732
25783
  const cursorFallback = { loading: "wait" };
25733
25784
  for (const cursorKey of cursors) {
25734
25785
  const cursorValue = this.config.style.cursor[cursorKey];
25735
- const { preload, cursor } = this.extractCursorUrl(cursorValue, cursorFallback[cursorKey]);
25786
+ const { preload, cursor } = extractCursorUrl(cursorValue, cursorFallback[cursorKey]);
25736
25787
  if (preload) cursorUrls.push({ src: cursor });
25737
25788
  }
25738
25789
  if (cursorUrls.length > 0) {
@@ -26552,54 +26603,6 @@ var WeaveImageNode = class extends WeaveNode {
26552
26603
  delete this.imageFallback[nodeId];
26553
26604
  nodeInstance.destroy();
26554
26605
  }
26555
- extractCursorUrl(cursor, fallback) {
26556
- const lower = cursor.toLowerCase();
26557
- const start = lower.indexOf("url(");
26558
- if (start === -1) return {
26559
- preload: false,
26560
- cursor
26561
- };
26562
- let i = start + 4;
26563
- const len = cursor.length;
26564
- while (i < len && /\s/.test(cursor[i])) i++;
26565
- let quote = null;
26566
- if (cursor[i] === "\"" || cursor[i] === "'") {
26567
- quote = cursor[i];
26568
- i++;
26569
- }
26570
- let buf = "";
26571
- for (; i < len; i++) {
26572
- const ch = cursor[i];
26573
- if (quote) {
26574
- if (ch === quote) {
26575
- i++;
26576
- break;
26577
- }
26578
- buf += ch;
26579
- } else {
26580
- if (ch === ")") break;
26581
- buf += ch;
26582
- }
26583
- }
26584
- const url = buf.trim();
26585
- if (!url) return {
26586
- preload: false,
26587
- cursor: fallback
26588
- };
26589
- if (!this.isAllowedUrl(url)) return {
26590
- preload: false,
26591
- cursor: fallback
26592
- };
26593
- return {
26594
- preload: true,
26595
- cursor: url
26596
- };
26597
- }
26598
- isAllowedUrl(value) {
26599
- if (/^https?:\/\//i.test(value)) return true;
26600
- if (/^(javascript|data|blob|ftp):/i.test(value)) return false;
26601
- return true;
26602
- }
26603
26606
  };
26604
26607
 
26605
26608
  //#endregion
@@ -31973,7 +31976,7 @@ var WeaveZoomOutToolAction = class extends WeaveAction {
31973
31976
  }
31974
31977
  cleanup() {
31975
31978
  const stage = this.instance.getStage();
31976
- this.instance.triggerAction(this.previousAction);
31979
+ if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
31977
31980
  stage.container().style.cursor = "default";
31978
31981
  }
31979
31982
  };
@@ -32007,7 +32010,7 @@ var WeaveZoomInToolAction = class extends WeaveAction {
32007
32010
  }
32008
32011
  cleanup() {
32009
32012
  const stage = this.instance.getStage();
32010
- this.instance.triggerAction(this.previousAction);
32013
+ if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32011
32014
  stage.container().style.cursor = "default";
32012
32015
  }
32013
32016
  };
@@ -32040,7 +32043,7 @@ var WeaveFitToScreenToolAction = class extends WeaveAction {
32040
32043
  }
32041
32044
  cleanup() {
32042
32045
  const stage = this.instance.getStage();
32043
- this.instance.triggerAction(this.previousAction);
32046
+ if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32044
32047
  stage.container().style.cursor = "default";
32045
32048
  }
32046
32049
  };
@@ -32082,7 +32085,7 @@ var WeaveFitToSelectionToolAction = class extends WeaveAction {
32082
32085
  }
32083
32086
  cleanup() {
32084
32087
  const stage = this.instance.getStage();
32085
- if (this.previousAction) this.instance.triggerAction(this.previousAction);
32088
+ if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32086
32089
  stage.container().style.cursor = "default";
32087
32090
  }
32088
32091
  };
@@ -33939,6 +33942,7 @@ var WeaveImageToolAction = class extends WeaveAction {
33939
33942
  height: imageHeight
33940
33943
  }
33941
33944
  });
33945
+ console.log("add image", node);
33942
33946
  this.instance.addNode(node, this.forceMainContainer ? this.instance.getMainLayer()?.getAttrs().id : this.container?.getAttrs().id);
33943
33947
  this.instance.emitEvent("onAddedImage", { nodeId: this.imageId });
33944
33948
  if (this.uploadType === WEAVE_IMAGE_TOOL_UPLOAD_TYPE.FILE) {
@@ -33974,6 +33978,7 @@ var WeaveImageToolAction = class extends WeaveAction {
33974
33978
  this.imageFile = null;
33975
33979
  this.imageURL = null;
33976
33980
  this.imageId = v4_default();
33981
+ console.log("add image", { id: this.imageId });
33977
33982
  this.props = this.initProps();
33978
33983
  if (params?.imageId) this.updateProps({ imageId: params.imageId });
33979
33984
  if (this.forceExecution) {
@@ -34245,9 +34250,9 @@ var WeaveImagesToolAction = class extends WeaveAction {
34245
34250
  const shadowBlur = this.config.style.cursor.imageThumbnails.shadowBlur;
34246
34251
  const shadowOffset = this.config.style.cursor.imageThumbnails.shadowOffset;
34247
34252
  const shadowOpacity = this.config.style.cursor.imageThumbnails.shadowOpacity;
34248
- const aspectRatio = imageSource.width / imageSource.height || 1;
34249
- const imageWidth = maxImageWidth * aspectRatio * (1 / stage.scaleX());
34250
- const imageHeight = maxImageHeight * (1 / stage.scaleY());
34253
+ const scale = Math.min(maxImageWidth / imageSource.width, maxImageHeight / imageSource.height);
34254
+ const imageWidth = imageSource.width * scale * (1 / stage.scaleX());
34255
+ const imageHeight = imageSource.height * scale * (1 / stage.scaleY());
34251
34256
  const imageNode = new Konva.Image({
34252
34257
  x: position$1.x,
34253
34258
  y: position$1.y,
@@ -34265,7 +34270,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
34265
34270
  shadowOffset,
34266
34271
  shadowOpacity
34267
34272
  });
34268
- maxWidth = position$1.x + imageWidth;
34273
+ maxWidth = Math.max(maxWidth, position$1.x + imageWidth);
34269
34274
  maxHeight = Math.max(maxHeight, position$1.y + imageHeight);
34270
34275
  position$1 = {
34271
34276
  x: position$1.x + imageThumbnailsPadding / stage.scaleX(),
@@ -34364,7 +34369,6 @@ var WeaveImagesToolAction = class extends WeaveAction {
34364
34369
  },
34365
34370
  forceMainContainer: this.forceMainContainer
34366
34371
  }, true);
34367
- this.nodesIds.push(nodeId);
34368
34372
  maxHeight = Math.max(maxHeight, height);
34369
34373
  imagePositionX += imagesPadding + width;
34370
34374
  if ((i + 1) % layoutColumns === 0) {
@@ -34372,6 +34376,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
34372
34376
  imagePositionY = imagePositionY + maxHeight + imagesPadding;
34373
34377
  maxHeight = 0;
34374
34378
  }
34379
+ this.nodesIds.push(nodeId);
34375
34380
  while (imageToolActionHandler.getActualState() !== WEAVE_IMAGES_TOOL_STATE.IDLE) await sleep(10);
34376
34381
  }
34377
34382
  this.instance.emitEvent("onAddedImages", { nodesIds: this.nodesIds });
package/dist/sdk.node.js CHANGED
@@ -21956,7 +21956,7 @@ var WeaveRegisterManager = class {
21956
21956
 
21957
21957
  //#endregion
21958
21958
  //#region package.json
21959
- var version = "3.2.0-SNAPSHOT.112.1";
21959
+ var version = "3.2.0-SNAPSHOT.114.1";
21960
21960
 
21961
21961
  //#endregion
21962
21962
  //#region src/managers/setup.ts
@@ -25696,6 +25696,57 @@ var WeaveImageCrop = class WeaveImageCrop {
25696
25696
  }
25697
25697
  };
25698
25698
 
25699
+ //#endregion
25700
+ //#region src/nodes/image/utils.ts
25701
+ const extractCursorUrl = (cursor, fallback) => {
25702
+ const lower = cursor.toLowerCase();
25703
+ const start = lower.indexOf("url(");
25704
+ if (start === -1) return {
25705
+ preload: false,
25706
+ cursor
25707
+ };
25708
+ let i = start + 4;
25709
+ const len = cursor.length;
25710
+ while (i < len && /\s/.test(cursor[i])) i++;
25711
+ let quote = null;
25712
+ if (cursor[i] === "\"" || cursor[i] === "'") {
25713
+ quote = cursor[i];
25714
+ i++;
25715
+ }
25716
+ let buf = "";
25717
+ for (; i < len; i++) {
25718
+ const ch = cursor[i];
25719
+ if (quote) {
25720
+ if (ch === quote) {
25721
+ i++;
25722
+ break;
25723
+ }
25724
+ buf += ch;
25725
+ } else {
25726
+ if (ch === ")") break;
25727
+ buf += ch;
25728
+ }
25729
+ }
25730
+ const url = buf.trim();
25731
+ if (!url) return {
25732
+ preload: false,
25733
+ cursor: fallback
25734
+ };
25735
+ if (!isAllowedUrl(url)) return {
25736
+ preload: false,
25737
+ cursor: fallback
25738
+ };
25739
+ return {
25740
+ preload: true,
25741
+ cursor: url
25742
+ };
25743
+ };
25744
+ const isAllowedUrl = (value) => {
25745
+ if (/^https?:\/\//i.test(value)) return true;
25746
+ if (/^(javascript|data|blob|ftp):/i.test(value)) return false;
25747
+ return true;
25748
+ };
25749
+
25699
25750
  //#endregion
25700
25751
  //#region src/nodes/image/image.ts
25701
25752
  var WeaveImageNode = class extends WeaveNode {
@@ -25731,7 +25782,7 @@ var WeaveImageNode = class extends WeaveNode {
25731
25782
  const cursorFallback = { loading: "wait" };
25732
25783
  for (const cursorKey of cursors) {
25733
25784
  const cursorValue = this.config.style.cursor[cursorKey];
25734
- const { preload, cursor } = this.extractCursorUrl(cursorValue, cursorFallback[cursorKey]);
25785
+ const { preload, cursor } = extractCursorUrl(cursorValue, cursorFallback[cursorKey]);
25735
25786
  if (preload) cursorUrls.push({ src: cursor });
25736
25787
  }
25737
25788
  if (cursorUrls.length > 0) {
@@ -26551,54 +26602,6 @@ var WeaveImageNode = class extends WeaveNode {
26551
26602
  delete this.imageFallback[nodeId];
26552
26603
  nodeInstance.destroy();
26553
26604
  }
26554
- extractCursorUrl(cursor, fallback) {
26555
- const lower = cursor.toLowerCase();
26556
- const start = lower.indexOf("url(");
26557
- if (start === -1) return {
26558
- preload: false,
26559
- cursor
26560
- };
26561
- let i = start + 4;
26562
- const len = cursor.length;
26563
- while (i < len && /\s/.test(cursor[i])) i++;
26564
- let quote = null;
26565
- if (cursor[i] === "\"" || cursor[i] === "'") {
26566
- quote = cursor[i];
26567
- i++;
26568
- }
26569
- let buf = "";
26570
- for (; i < len; i++) {
26571
- const ch = cursor[i];
26572
- if (quote) {
26573
- if (ch === quote) {
26574
- i++;
26575
- break;
26576
- }
26577
- buf += ch;
26578
- } else {
26579
- if (ch === ")") break;
26580
- buf += ch;
26581
- }
26582
- }
26583
- const url = buf.trim();
26584
- if (!url) return {
26585
- preload: false,
26586
- cursor: fallback
26587
- };
26588
- if (!this.isAllowedUrl(url)) return {
26589
- preload: false,
26590
- cursor: fallback
26591
- };
26592
- return {
26593
- preload: true,
26594
- cursor: url
26595
- };
26596
- }
26597
- isAllowedUrl(value) {
26598
- if (/^https?:\/\//i.test(value)) return true;
26599
- if (/^(javascript|data|blob|ftp):/i.test(value)) return false;
26600
- return true;
26601
- }
26602
26605
  };
26603
26606
 
26604
26607
  //#endregion
@@ -31972,7 +31975,7 @@ var WeaveZoomOutToolAction = class extends WeaveAction {
31972
31975
  }
31973
31976
  cleanup() {
31974
31977
  const stage = this.instance.getStage();
31975
- this.instance.triggerAction(this.previousAction);
31978
+ if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
31976
31979
  stage.container().style.cursor = "default";
31977
31980
  }
31978
31981
  };
@@ -32006,7 +32009,7 @@ var WeaveZoomInToolAction = class extends WeaveAction {
32006
32009
  }
32007
32010
  cleanup() {
32008
32011
  const stage = this.instance.getStage();
32009
- this.instance.triggerAction(this.previousAction);
32012
+ if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32010
32013
  stage.container().style.cursor = "default";
32011
32014
  }
32012
32015
  };
@@ -32039,7 +32042,7 @@ var WeaveFitToScreenToolAction = class extends WeaveAction {
32039
32042
  }
32040
32043
  cleanup() {
32041
32044
  const stage = this.instance.getStage();
32042
- this.instance.triggerAction(this.previousAction);
32045
+ if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32043
32046
  stage.container().style.cursor = "default";
32044
32047
  }
32045
32048
  };
@@ -32081,7 +32084,7 @@ var WeaveFitToSelectionToolAction = class extends WeaveAction {
32081
32084
  }
32082
32085
  cleanup() {
32083
32086
  const stage = this.instance.getStage();
32084
- if (this.previousAction) this.instance.triggerAction(this.previousAction);
32087
+ if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32085
32088
  stage.container().style.cursor = "default";
32086
32089
  }
32087
32090
  };
@@ -33938,6 +33941,7 @@ var WeaveImageToolAction = class extends WeaveAction {
33938
33941
  height: imageHeight
33939
33942
  }
33940
33943
  });
33944
+ console.log("add image", node);
33941
33945
  this.instance.addNode(node, this.forceMainContainer ? this.instance.getMainLayer()?.getAttrs().id : this.container?.getAttrs().id);
33942
33946
  this.instance.emitEvent("onAddedImage", { nodeId: this.imageId });
33943
33947
  if (this.uploadType === WEAVE_IMAGE_TOOL_UPLOAD_TYPE.FILE) {
@@ -33973,6 +33977,7 @@ var WeaveImageToolAction = class extends WeaveAction {
33973
33977
  this.imageFile = null;
33974
33978
  this.imageURL = null;
33975
33979
  this.imageId = v4_default();
33980
+ console.log("add image", { id: this.imageId });
33976
33981
  this.props = this.initProps();
33977
33982
  if (params?.imageId) this.updateProps({ imageId: params.imageId });
33978
33983
  if (this.forceExecution) {
@@ -34244,9 +34249,9 @@ var WeaveImagesToolAction = class extends WeaveAction {
34244
34249
  const shadowBlur = this.config.style.cursor.imageThumbnails.shadowBlur;
34245
34250
  const shadowOffset = this.config.style.cursor.imageThumbnails.shadowOffset;
34246
34251
  const shadowOpacity = this.config.style.cursor.imageThumbnails.shadowOpacity;
34247
- const aspectRatio = imageSource.width / imageSource.height || 1;
34248
- const imageWidth = maxImageWidth * aspectRatio * (1 / stage.scaleX());
34249
- const imageHeight = maxImageHeight * (1 / stage.scaleY());
34252
+ const scale = Math.min(maxImageWidth / imageSource.width, maxImageHeight / imageSource.height);
34253
+ const imageWidth = imageSource.width * scale * (1 / stage.scaleX());
34254
+ const imageHeight = imageSource.height * scale * (1 / stage.scaleY());
34250
34255
  const imageNode = new Konva.Image({
34251
34256
  x: position$1.x,
34252
34257
  y: position$1.y,
@@ -34264,7 +34269,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
34264
34269
  shadowOffset,
34265
34270
  shadowOpacity
34266
34271
  });
34267
- maxWidth = position$1.x + imageWidth;
34272
+ maxWidth = Math.max(maxWidth, position$1.x + imageWidth);
34268
34273
  maxHeight = Math.max(maxHeight, position$1.y + imageHeight);
34269
34274
  position$1 = {
34270
34275
  x: position$1.x + imageThumbnailsPadding / stage.scaleX(),
@@ -34363,7 +34368,6 @@ var WeaveImagesToolAction = class extends WeaveAction {
34363
34368
  },
34364
34369
  forceMainContainer: this.forceMainContainer
34365
34370
  }, true);
34366
- this.nodesIds.push(nodeId);
34367
34371
  maxHeight = Math.max(maxHeight, height);
34368
34372
  imagePositionX += imagesPadding + width;
34369
34373
  if ((i + 1) % layoutColumns === 0) {
@@ -34371,6 +34375,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
34371
34375
  imagePositionY = imagePositionY + maxHeight + imagesPadding;
34372
34376
  maxHeight = 0;
34373
34377
  }
34378
+ this.nodesIds.push(nodeId);
34374
34379
  while (imageToolActionHandler.getActualState() !== WEAVE_IMAGES_TOOL_STATE.IDLE) await sleep(10);
34375
34380
  }
34376
34381
  this.instance.emitEvent("onAddedImages", { nodesIds: this.nodesIds });
package/dist/types.d.ts CHANGED
@@ -1866,11 +1866,6 @@ declare class WeaveImageNode extends WeaveNode {
1866
1866
  getIsAsync(): boolean;
1867
1867
  forceLoadImage(nodeInstance: WeaveElementInstance): void;
1868
1868
  onDestroy(nodeInstance: WeaveElementInstance): void;
1869
- extractCursorUrl(cursor: string, fallback: string): {
1870
- preload: boolean;
1871
- cursor: string;
1872
- };
1873
- isAllowedUrl(value: string): boolean;
1874
1869
  }
1875
1870
 
1876
1871
  //#endregion