@inweb/markup 25.10.1 → 25.11.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/markup.js CHANGED
@@ -12554,31 +12554,18 @@
12554
12554
  this._konvaStage.height(height);
12555
12555
  };
12556
12556
  this.pan = (event) => {
12557
- const pointer = this._konvaStage.getPointerPosition();
12558
- const pointTo = {
12559
- x: (pointer.x - this._konvaStage.x()) / this._konvaStage.scaleX(),
12560
- y: (pointer.y - this._konvaStage.y()) / this._konvaStage.scaleX(),
12561
- };
12562
12557
  const newPos = {
12563
- x: pointer.x - pointTo.x * this._konvaStage.scale().x + event.dX,
12564
- y: pointer.y - pointTo.y * this._konvaStage.scale().x + event.dY,
12558
+ x: this._konvaStage.x() + event.dX,
12559
+ y: this._konvaStage.y() + event.dY,
12565
12560
  };
12566
12561
  this._konvaStage.position(newPos);
12567
12562
  };
12568
12563
  this.zoomAt = (event) => {
12569
- const oldScale = this._konvaStage.scaleX();
12570
- const pointer = this._konvaStage.getPointerPosition();
12571
- const mousePointTo = {
12572
- x: (pointer.x - this._konvaStage.x()) / oldScale,
12573
- y: (pointer.y - this._konvaStage.y()) / oldScale,
12574
- };
12575
- // how to scale? Zoom in? Or zoom out?
12576
- const direction = event.data > 0 ? 1 : -1;
12577
- const newScale = direction > 0 ? oldScale * event.data : oldScale / event.data;
12564
+ const newScale = this._konvaStage.scaleX() * event.data;
12578
12565
  this._konvaStage.scale({ x: newScale, y: newScale });
12579
12566
  const newPos = {
12580
- x: pointer.x - mousePointTo.x * newScale,
12581
- y: pointer.y - mousePointTo.y * newScale,
12567
+ x: event.x - (event.x - this._konvaStage.x()) * event.data,
12568
+ y: event.y - (event.y - this._konvaStage.y()) * event.data,
12582
12569
  };
12583
12570
  this._konvaStage.position(newPos);
12584
12571
  };
@@ -12611,8 +12598,8 @@
12611
12598
  this._markupContainer.style.position = "absolute";
12612
12599
  this._markupContainer.style.top = "0px";
12613
12600
  this._markupContainer.style.left = "0px";
12614
- // to eliminate grey box during delete elements
12615
- this._markupContainer.style.outline = "0px";
12601
+ this._markupContainer.style.outline = "0px"; // <- to eliminate grey box during delete elements
12602
+ this._markupContainer.style.pointerEvents = "none";
12616
12603
  const parentDiv = this._container.parentElement;
12617
12604
  parentDiv.appendChild(this._markupContainer);
12618
12605
  this._resizeObserver = new ResizeObserver(this.resizeContainer);
@@ -12620,7 +12607,7 @@
12620
12607
  this._markupColor.setColor(255, 0, 0);
12621
12608
  this.initializeKonva();
12622
12609
  if (this._viewer) {
12623
- this._containerEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
12610
+ // this._containerEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
12624
12611
  this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
12625
12612
  this._viewer.addEventListener("pan", this.pan);
12626
12613
  this._viewer.addEventListener("zoomat", this.zoomAt);
@@ -12632,7 +12619,7 @@
12632
12619
  this._viewer.removeEventListener("zoomat", this.zoomAt);
12633
12620
  this._viewer.removeEventListener("pan", this.pan);
12634
12621
  this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
12635
- this._containerEvents.forEach((x) => this._markupContainer.removeEventListener(x, this.redirectToViewer));
12622
+ // this._containerEvents.forEach((x) => this._markupContainer.removeEventListener(x, this.redirectToViewer));
12636
12623
  }
12637
12624
  this.destroyKonva();
12638
12625
  (_a = this._resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
@@ -12656,6 +12643,7 @@
12656
12643
  }
12657
12644
  setMarkupColor(r, g, b) {
12658
12645
  this._markupColor.setColor(r, g, b);
12646
+ this._viewer.emit({ type: "changemarkupcolor", data: { r, g, b } });
12659
12647
  }
12660
12648
  colorizeAllMarkup(r, g, b) {
12661
12649
  const hexColor = new MarkupColor(r, g, b).asHex();
@@ -12709,8 +12697,9 @@
12709
12697
  this.addImage(screenPoint, image.src, image.width, image.height, image.id);
12710
12698
  });
12711
12699
  }
12712
- getViewpoint() {
12713
- const viewpoint = {};
12700
+ getViewpoint(viewpoint) {
12701
+ if (!viewpoint)
12702
+ viewpoint = {};
12714
12703
  viewpoint.lines = this.getMarkupLines();
12715
12704
  viewpoint.texts = this.getMarkupTexts();
12716
12705
  viewpoint.arrows = this.getMarkupArrows();
@@ -12720,7 +12709,6 @@
12720
12709
  viewpoint.rectangles = this.getMarkupRectangles();
12721
12710
  viewpoint.custom_fields = { markup_color: this.getMarkupColor() };
12722
12711
  viewpoint.snapshot = { data: this.combineMarkupWithDrawing() };
12723
- viewpoint.description = new Date().toDateString();
12724
12712
  return viewpoint;
12725
12713
  }
12726
12714
  enableEditMode(mode) {
@@ -12728,10 +12716,12 @@
12728
12716
  this.clearSelected();
12729
12717
  this.removeTextInput();
12730
12718
  this.removeImageInput();
12719
+ this._markupContainer.style.pointerEvents = "none";
12731
12720
  this._markupIsActive = false;
12732
12721
  }
12733
12722
  else {
12734
12723
  this._markupMode = mode;
12724
+ this._markupContainer.style.pointerEvents = "all";
12735
12725
  this._markupIsActive = true;
12736
12726
  }
12737
12727
  return this;