@inweb/markup 25.8.11 → 25.8.12

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
@@ -11603,7 +11603,7 @@
11603
11603
  this._ref.draggable(value);
11604
11604
  }
11605
11605
  type() {
11606
- return "line";
11606
+ return "Line";
11607
11607
  }
11608
11608
  getColor() {
11609
11609
  return this._ref.stroke();
@@ -11725,7 +11725,7 @@
11725
11725
  this._ref.draggable(value);
11726
11726
  }
11727
11727
  type() {
11728
- return "text";
11728
+ return "Text";
11729
11729
  }
11730
11730
  getColor() {
11731
11731
  return this._ref.fill();
@@ -11847,7 +11847,7 @@
11847
11847
  this._ref.draggable(value);
11848
11848
  }
11849
11849
  type() {
11850
- return "rectangle";
11850
+ return "Rectangle";
11851
11851
  }
11852
11852
  getColor() {
11853
11853
  return this._ref.stroke();
@@ -11968,7 +11968,7 @@
11968
11968
  this._ref.draggable(value);
11969
11969
  }
11970
11970
  type() {
11971
- return "ellipse";
11971
+ return "Ellipse";
11972
11972
  }
11973
11973
  getColor() {
11974
11974
  return this._ref.stroke();
@@ -12032,7 +12032,7 @@
12032
12032
  this._ref.draggable(value);
12033
12033
  }
12034
12034
  type() {
12035
- return "arrow";
12035
+ return "Arrow";
12036
12036
  }
12037
12037
  getColor() {
12038
12038
  return this._ref.stroke();
@@ -12182,7 +12182,7 @@
12182
12182
  this._ref.draggable(value);
12183
12183
  }
12184
12184
  type() {
12185
- return "image";
12185
+ return "Image";
12186
12186
  }
12187
12187
  getRotation() {
12188
12188
  return this._ref.rotation();
@@ -12323,7 +12323,7 @@
12323
12323
  this._ref.draggable(value);
12324
12324
  }
12325
12325
  type() {
12326
- return "cloud";
12326
+ return "Cloud";
12327
12327
  }
12328
12328
  getColor() {
12329
12329
  return this._ref.stroke();
@@ -12382,7 +12382,6 @@
12382
12382
  Line: {
12383
12383
  name: "Line",
12384
12384
  initializer: (ref, params = null) => new KonvaLine(params, ref),
12385
- zIndex: 1,
12386
12385
  },
12387
12386
  Text: {
12388
12387
  name: "Text",
@@ -12391,27 +12390,22 @@
12391
12390
  Rectangle: {
12392
12391
  name: "Rect",
12393
12392
  initializer: (ref, params = null) => new KonvaRectangle(params, ref),
12394
- zIndex: 1,
12395
12393
  },
12396
12394
  Ellipse: {
12397
12395
  name: "Ellipse",
12398
12396
  initializer: (ref, params = null) => new KonvaEllipse(params, ref),
12399
- zIndex: 1,
12400
12397
  },
12401
12398
  Arrow: {
12402
12399
  name: "Arrow",
12403
12400
  initializer: (ref, params = null) => new KonvaArrow(params, ref),
12404
- zIndex: 1,
12405
12401
  },
12406
12402
  Image: {
12407
12403
  name: "Image",
12408
12404
  initializer: (ref, params = null) => new KonvaImage(params, ref),
12409
- zIndex: 0,
12410
12405
  },
12411
12406
  Cloud: {
12412
12407
  name: "Cloud",
12413
12408
  initializer: (ref, params = null) => new KonvaCloud(params, ref),
12414
- zIndex: 1,
12415
12409
  },
12416
12410
  };
12417
12411
  /**
@@ -12422,7 +12416,6 @@
12422
12416
  this._pointerEvents = [];
12423
12417
  this._markupIsActive = false;
12424
12418
  this._markupColor = new MarkupColor(255, 0, 0);
12425
- this._zIndex = 1;
12426
12419
  this.lineWidth = 4;
12427
12420
  this.lineType = "solid";
12428
12421
  this.fontSize = 34;
@@ -12523,6 +12516,9 @@
12523
12516
  }
12524
12517
  setViewpoint(viewpoint) {
12525
12518
  var _a, _b, _c, _d, _e, _f, _g, _h;
12519
+ this.clearSelected();
12520
+ this.removeTextInput();
12521
+ this.removeImageInput();
12526
12522
  const markupColor = ((_a = viewpoint.custom_fields) === null || _a === void 0 ? void 0 : _a.markup_color) || { r: 255, g: 0, b: 0 };
12527
12523
  this.setMarkupColor(markupColor.r, markupColor.g, markupColor.b);
12528
12524
  (_b = viewpoint.lines) === null || _b === void 0 ? void 0 : _b.forEach((line) => {
@@ -12577,6 +12573,8 @@
12577
12573
  enableEditMode(mode) {
12578
12574
  if (!mode || !MarkupMode2Konva[mode]) {
12579
12575
  this.clearSelected();
12576
+ this.removeTextInput();
12577
+ this.removeImageInput();
12580
12578
  this._markupIsActive = false;
12581
12579
  }
12582
12580
  else {
@@ -12586,16 +12584,11 @@
12586
12584
  return this;
12587
12585
  }
12588
12586
  createObject(type, params) {
12589
- var _a;
12590
12587
  const konvaShape = MarkupMode2Konva[type];
12591
12588
  if (!konvaShape || !konvaShape.initializer)
12592
12589
  throw new Error(`Markup CreateObject - unsupported markup type ${type}`);
12593
12590
  const object = konvaShape.initializer(null, params);
12594
12591
  this.addObject(object);
12595
- // Set zIndex only when shape has been added to Layer else we will get
12596
- // "Konva warning: Node has no parent. zIndex parameter is ignored."
12597
- object.setZIndex((_a = konvaShape.zIndex) !== null && _a !== void 0 ? _a : this._zIndex);
12598
- this._zIndex++;
12599
12592
  return object;
12600
12593
  }
12601
12594
  getObjects() {
@@ -12629,8 +12622,12 @@
12629
12622
  this._konvaTransformer.nodes([]);
12630
12623
  }
12631
12624
  addObject(object) {
12632
- if (this._konvaLayer)
12633
- this._konvaLayer.add(object.ref());
12625
+ if (object.type() === "Image")
12626
+ this._groupImages.add(object.ref());
12627
+ else if (object.type() === "Text")
12628
+ this._groupTexts.add(object.ref());
12629
+ else
12630
+ this._groupGeometry.add(object.ref());
12634
12631
  }
12635
12632
  konvaLayerFind(type) {
12636
12633
  if (!this._konvaLayer)
@@ -12639,7 +12636,12 @@
12639
12636
  if (!konvaShape || !konvaShape.initializer)
12640
12637
  return [];
12641
12638
  // for "draggable" Konva uses Rectangles in Transformer. We need only Shapes from layer.
12642
- return this._konvaLayer.find(konvaShape.name).filter((ref) => ref.parent === this._konvaLayer);
12639
+ return this._konvaLayer
12640
+ .find(konvaShape.name)
12641
+ .filter((ref) => ref.parent === this._konvaLayer ||
12642
+ ref.parent === this._groupImages ||
12643
+ ref.parent === this._groupGeometry ||
12644
+ ref.parent === this._groupTexts);
12643
12645
  }
12644
12646
  initializeKonva() {
12645
12647
  // first we need Konva core things: stage and layer
@@ -12651,6 +12653,12 @@
12651
12653
  this._konvaStage = stage;
12652
12654
  const layer = new Konva.Layer({ pixelRation: window.devicePixelRatio });
12653
12655
  stage.add(layer);
12656
+ this._groupImages = new Konva.Group();
12657
+ layer.add(this._groupImages);
12658
+ this._groupGeometry = new Konva.Group();
12659
+ layer.add(this._groupGeometry);
12660
+ this._groupTexts = new Konva.Group();
12661
+ layer.add(this._groupTexts);
12654
12662
  this._konvaLayer = layer;
12655
12663
  const transformer = new Konva.Transformer({
12656
12664
  shouldOverdrawWholeArea: false,
@@ -12807,7 +12815,9 @@
12807
12815
  this.removeImageInput();
12808
12816
  }
12809
12817
  }
12810
- if (transformer.nodes().filter((x) => x.className === "Cloud").length > 0 || e.target.className === "Cloud") {
12818
+ if (transformer.nodes().filter((x) => x.className === "Cloud" || x.className === "Image").length > 0 ||
12819
+ e.target.className === "Cloud" ||
12820
+ e.target.className === "Image") {
12811
12821
  transformer.rotateEnabled(false);
12812
12822
  }
12813
12823
  else {
@@ -12853,8 +12863,13 @@
12853
12863
  }
12854
12864
  destroyKonva() {
12855
12865
  var _a;
12866
+ this.removeTextInput();
12867
+ this.removeImageInput();
12856
12868
  this.clearOverlay();
12857
12869
  (_a = this._konvaStage) === null || _a === void 0 ? void 0 : _a.destroy();
12870
+ this._groupImages = undefined;
12871
+ this._groupGeometry = undefined;
12872
+ this._groupTexts = undefined;
12858
12873
  this._konvaLayer = undefined;
12859
12874
  this._konvaTransformer = undefined;
12860
12875
  this._konvaStage = undefined;
@@ -13037,6 +13052,9 @@
13037
13052
  this._textInputRef.style.display = "block";
13038
13053
  this._textInputRef.style.top = inputY + "px";
13039
13054
  this._textInputRef.style.left = inputX + "px";
13055
+ this._textInputRef.style.fontSize = `${this.fontSize}px`;
13056
+ this._textInputRef.style.color = `${this._markupColor.HexColor}`;
13057
+ this._textInputRef.style.fontFamily = "Calibri";
13040
13058
  this._textInputRef.onkeydown = (event) => {
13041
13059
  if (event.key === "Enter" && !event.shiftKey) {
13042
13060
  event.preventDefault();