@plait/core 0.3.0 → 0.4.0

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.
Files changed (39) hide show
  1. package/board/board.component.d.ts +8 -8
  2. package/constants/index.d.ts +6 -0
  3. package/core/island/island-base.component.d.ts +16 -0
  4. package/esm2020/board/board.component.interface.mjs +1 -1
  5. package/esm2020/board/board.component.mjs +47 -51
  6. package/esm2020/constants/index.mjs +7 -1
  7. package/esm2020/core/children/children.component.mjs +3 -3
  8. package/esm2020/core/element/element.component.mjs +3 -3
  9. package/esm2020/core/element/plugin-element.mjs +3 -3
  10. package/esm2020/core/island/island-base.component.mjs +33 -0
  11. package/esm2020/interfaces/index.mjs +2 -1
  12. package/esm2020/interfaces/plugin-key.mjs +5 -0
  13. package/esm2020/plait.module.mjs +6 -7
  14. package/esm2020/plugins/with-hand.mjs +7 -6
  15. package/esm2020/plugins/with-options.mjs +13 -0
  16. package/esm2020/plugins/with-selection.mjs +13 -5
  17. package/esm2020/public-api.mjs +3 -2
  18. package/esm2020/transforms/board.mjs +63 -4
  19. package/esm2020/utils/dom/common.mjs +12 -1
  20. package/esm2020/utils/draw/line.mjs +21 -1
  21. package/esm2020/utils/viewport.mjs +2 -55
  22. package/fesm2015/plait-core.mjs +531 -496
  23. package/fesm2015/plait-core.mjs.map +1 -1
  24. package/fesm2020/plait-core.mjs +546 -512
  25. package/fesm2020/plait-core.mjs.map +1 -1
  26. package/interfaces/index.d.ts +1 -0
  27. package/interfaces/plugin-key.d.ts +3 -0
  28. package/package.json +1 -1
  29. package/plait.module.d.ts +2 -3
  30. package/plugins/with-options.d.ts +9 -0
  31. package/plugins/with-selection.d.ts +4 -0
  32. package/public-api.d.ts +2 -1
  33. package/styles/styles.scss +0 -73
  34. package/transforms/board.d.ts +8 -1
  35. package/utils/dom/common.d.ts +3 -0
  36. package/utils/draw/line.d.ts +1 -0
  37. package/utils/viewport.d.ts +0 -3
  38. package/core/toolbar/toolbar.component.d.ts +0 -21
  39. package/esm2020/core/toolbar/toolbar.component.mjs +0 -60
@@ -1,8 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Directive, Input, Component, ChangeDetectionStrategy, EventEmitter, HostBinding, Output, ElementRef, ViewChild, ContentChild, NgModule } from '@angular/core';
2
+ import { Directive, Input, Component, ChangeDetectionStrategy, EventEmitter, ElementRef, Output, HostBinding, ViewChild, ContentChildren, NgModule } from '@angular/core';
3
3
  import rough from 'roughjs/bin/rough';
4
4
  import { timer, Subject, fromEvent } from 'rxjs';
5
- import { takeUntil, filter } from 'rxjs/operators';
5
+ import { takeUntil, filter, tap } from 'rxjs/operators';
6
6
  import produce, { createDraft, finishDraft, isDraft } from 'immer';
7
7
  import { isKeyHotkey, isHotkey } from 'is-hotkey';
8
8
  import * as i1 from '@angular/common';
@@ -578,12 +578,74 @@ function setSelectionWithTemporaryElements(board, elements) {
578
578
  });
579
579
  }
580
580
 
581
- function setViewport$1(board, viewport) {
581
+ function setViewport(board, viewport) {
582
582
  const operation = { type: 'set_viewport', properties: board.viewport, newProperties: viewport };
583
583
  board.apply(operation);
584
584
  }
585
585
  const ViewportTransforms = {
586
- setViewport: setViewport$1
586
+ setViewport
587
+ };
588
+
589
+ const CLIP_BOARD_FORMAT_KEY = 'x-plait-fragment';
590
+ const SCROLL_BAR_WIDTH = 20;
591
+ const MAX_RADIUS = 16;
592
+ const POINTER_BUTTON = {
593
+ MAIN: 0,
594
+ WHEEL: 1,
595
+ SECONDARY: 2,
596
+ TOUCH: -1,
597
+ };
598
+
599
+ const NS = 'http://www.w3.org/2000/svg';
600
+ function toPoint(x, y, container) {
601
+ const rect = container.getBoundingClientRect();
602
+ return [x - rect.x, y - rect.y];
603
+ }
604
+ function createG() {
605
+ const newG = document.createElementNS(NS, 'g');
606
+ return newG;
607
+ }
608
+ function createPath() {
609
+ const newG = document.createElementNS(NS, 'path');
610
+ return newG;
611
+ }
612
+ function createSVG() {
613
+ const svg = document.createElementNS(NS, 'svg');
614
+ return svg;
615
+ }
616
+ function createText(x, y, fill, textContent) {
617
+ var text = document.createElementNS(NS, 'text');
618
+ text.setAttribute('x', `${x}`);
619
+ text.setAttribute('y', `${y}`);
620
+ text.setAttribute('fill', fill);
621
+ text.textContent = textContent;
622
+ return text;
623
+ }
624
+ /**
625
+ * Check if a DOM node is an element node.
626
+ */
627
+ const isDOMElement = (value) => {
628
+ return isDOMNode(value) && value.nodeType === 1;
629
+ };
630
+ /**
631
+ * Check if a value is a DOM node.
632
+ */
633
+ const isDOMNode = (value) => {
634
+ return value instanceof window.Node;
635
+ };
636
+ const hasInputOrTextareaTarget = (target) => {
637
+ if (isDOMElement(target)) {
638
+ if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') {
639
+ return true;
640
+ }
641
+ }
642
+ return false;
643
+ };
644
+ const isSecondaryPointer = (event) => {
645
+ return event.button === POINTER_BUTTON.SECONDARY;
646
+ };
647
+ const isMainPointer = (event) => {
648
+ return event.button === POINTER_BUTTON.MAIN;
587
649
  };
588
650
 
589
651
  // https://stackoverflow.com/a/6853926/232122
@@ -634,100 +696,6 @@ function distanceBetweenPointAndRectangle(x, y, rect) {
634
696
  return Math.sqrt(dx * dx + dy * dy);
635
697
  }
636
698
 
637
- function transformPoints(board, points) {
638
- const newPoints = points.map(point => {
639
- return transformPoint(board, point);
640
- });
641
- return newPoints;
642
- }
643
- function transformPoint(board, point) {
644
- const { width, height } = PlaitBoard.getHost(board).getBoundingClientRect();
645
- const viewBox = PlaitBoard.getHost(board).viewBox.baseVal;
646
- const x = (point[0] / width) * viewBox.width + viewBox.x;
647
- const y = (point[1] / height) * viewBox.height + viewBox.y;
648
- const newPoint = [x, y];
649
- return newPoint;
650
- }
651
- function isInPlaitBoard(board, x, y) {
652
- const plaitBoardElement = PlaitBoard.getBoardNativeElement(board);
653
- const plaitBoardRect = plaitBoardElement.getBoundingClientRect();
654
- const distances = distanceBetweenPointAndRectangle(x, y, plaitBoardRect);
655
- return distances === 0;
656
- }
657
-
658
- const NS = 'http://www.w3.org/2000/svg';
659
- function toPoint(x, y, container) {
660
- const rect = container.getBoundingClientRect();
661
- return [x - rect.x, y - rect.y];
662
- }
663
- function createG() {
664
- const newG = document.createElementNS(NS, 'g');
665
- return newG;
666
- }
667
- function createSVG() {
668
- const svg = document.createElementNS(NS, 'svg');
669
- return svg;
670
- }
671
- function createText(x, y, fill, textContent) {
672
- var text = document.createElementNS(NS, 'text');
673
- text.setAttribute('x', `${x}`);
674
- text.setAttribute('y', `${y}`);
675
- text.setAttribute('fill', fill);
676
- text.textContent = textContent;
677
- return text;
678
- }
679
- /**
680
- * Check if a DOM node is an element node.
681
- */
682
- const isDOMElement = (value) => {
683
- return isDOMNode(value) && value.nodeType === 1;
684
- };
685
- /**
686
- * Check if a value is a DOM node.
687
- */
688
- const isDOMNode = (value) => {
689
- return value instanceof window.Node;
690
- };
691
- const hasInputOrTextareaTarget = (target) => {
692
- if (isDOMElement(target)) {
693
- if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') {
694
- return true;
695
- }
696
- }
697
- return false;
698
- };
699
-
700
- function createForeignObject(x, y, width, height) {
701
- var newForeignObject = document.createElementNS(NS, 'foreignObject');
702
- newForeignObject.setAttribute('x', `${x}`);
703
- newForeignObject.setAttribute('y', `${y}`);
704
- newForeignObject.setAttribute('width', `${width}`);
705
- newForeignObject.setAttribute('height', `${height}`);
706
- return newForeignObject;
707
- }
708
- function updateForeignObject(g, width, height, x, y) {
709
- const foreignObject = g.querySelector('foreignObject');
710
- if (foreignObject) {
711
- foreignObject.setAttribute('width', `${width}`);
712
- foreignObject.setAttribute('height', `${height}`);
713
- foreignObject.setAttribute('x', `${x}`);
714
- foreignObject.setAttribute('y', `${y}`);
715
- }
716
- }
717
-
718
- const IS_IOS = typeof navigator !== 'undefined' &&
719
- typeof window !== 'undefined' &&
720
- /iPad|iPhone|iPod/.test(navigator.userAgent) &&
721
- !window.MSStream;
722
- const IS_APPLE = typeof navigator !== 'undefined' && /Mac OS X/.test(navigator.userAgent);
723
- const IS_FIREFOX = typeof navigator !== 'undefined' && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
724
- const IS_SAFARI = typeof navigator !== 'undefined' && /Version\/[\d\.]+.*Safari/.test(navigator.userAgent);
725
- // "modern" Edge was released at 79.x
726
- const IS_EDGE_LEGACY = typeof navigator !== 'undefined' && /Edge?\/(?:[0-6][0-9]|[0-7][0-8])/i.test(navigator.userAgent);
727
- const IS_CHROME = typeof navigator !== 'undefined' && /Chrome/i.test(navigator.userAgent);
728
- // Native beforeInput events don't work well with react on Chrome 75 and older, Chrome 76+ can use beforeInput
729
- const IS_CHROME_LEGACY = typeof navigator !== 'undefined' && /Chrome?\/(?:[0-7][0-5]|[0-6][0-9])/i.test(navigator.userAgent);
730
-
731
699
  /**
732
700
  * Extendable Custom Types Interface
733
701
  */
@@ -862,174 +830,66 @@ class PlaitPluginElementComponent {
862
830
  (this.rootG || this.g).remove();
863
831
  }
864
832
  }
865
- PlaitPluginElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitPluginElementComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
866
- PlaitPluginElementComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.2", type: PlaitPluginElementComponent, inputs: { context: "context" }, ngImport: i0 });
867
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitPluginElementComponent, decorators: [{
833
+ PlaitPluginElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitPluginElementComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
834
+ PlaitPluginElementComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: PlaitPluginElementComponent, inputs: { context: "context" }, ngImport: i0 });
835
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitPluginElementComponent, decorators: [{
868
836
  type: Directive
869
837
  }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { context: [{
870
838
  type: Input
871
839
  }] } });
872
840
  const ELEMENT_TO_COMPONENT = new WeakMap();
873
841
 
874
- const PlaitElement = {
875
- isRootElement(value) {
876
- const parent = NODE_TO_PARENT.get(value);
877
- if (parent && PlaitBoard.isBoard(parent)) {
878
- return true;
879
- }
880
- else {
881
- return false;
882
- }
883
- },
884
- getComponent(value) {
885
- return ELEMENT_TO_COMPONENT.get(value);
886
- }
887
- };
888
-
889
- const RectangleClient = {
890
- isHit: (origin, target) => {
891
- const minX = origin.x < target.x ? origin.x : target.x;
892
- const maxX = origin.x + origin.width > target.x + target.width ? origin.x + origin.width : target.x + target.width;
893
- const minY = origin.y < target.y ? origin.y : target.y;
894
- const maxY = origin.y + origin.height > target.y + target.height ? origin.y + origin.height : target.y + target.height;
895
- // float calculate error( eg: 1.4210854715202004e-14 > 0)
896
- if (Math.floor(maxX - minX - origin.width - target.width) <= 0 && Math.floor(maxY - minY - origin.height - target.height) <= 0) {
897
- return true;
898
- }
899
- else {
900
- return false;
901
- }
902
- },
903
- toRectangleClient: (points) => {
904
- const xArray = points.map(ele => ele[0]);
905
- const yArray = points.map(ele => ele[1]);
906
- const xMin = Math.min(...xArray);
907
- const xMax = Math.max(...xArray);
908
- const yMin = Math.min(...yArray);
909
- const yMax = Math.max(...yArray);
910
- const rect = { x: xMin, y: yMin, width: xMax - xMin, height: yMax - yMin };
911
- return rect;
912
- },
913
- getOutlineRectangle: (rectangle, offset) => {
914
- return {
915
- x: rectangle.x + offset,
916
- y: rectangle.y + offset,
917
- width: rectangle.width + Math.abs(offset) * 2,
918
- height: rectangle.height + Math.abs(offset) * 2
919
- };
920
- },
921
- isEqual: (rectangle, otherRectangle) => {
922
- return (rectangle.x === otherRectangle.x &&
923
- rectangle.y === otherRectangle.y &&
924
- rectangle.width === otherRectangle.width &&
925
- rectangle.height === otherRectangle.height);
926
- }
927
- };
928
-
929
- const isSetViewportOperation = (value) => {
930
- return value.type === 'set_viewport';
931
- };
932
- const inverse = (op) => {
933
- switch (op.type) {
934
- case 'insert_node': {
935
- return { ...op, type: 'remove_node' };
936
- }
937
- case 'remove_node': {
938
- return { ...op, type: 'insert_node' };
939
- }
940
- case 'move_node': {
941
- const { newPath, path } = op;
942
- // PERF: in this case the move operation is a no-op anyways.
943
- if (Path.equals(newPath, path)) {
944
- return op;
945
- }
946
- // when operation path is [0,0] -> [0,2], should exec Path.transform to get [0,1] -> [0,0]
947
- // shoud not return [0,2] -> [0,0] #WIK-8981
948
- // if (Path.isSibling(path, newPath)) {
949
- // return { ...op, path: newPath, newPath: path };
950
- // }
951
- // If the move does not happen within a single parent it is possible
952
- // for the move to impact the true path to the location where the node
953
- // was removed from and where it was inserted. We have to adjust for this
954
- // and find the original path. We can accomplish this (only in non-sibling)
955
- // moves by looking at the impact of the move operation on the node
956
- // after the original move path.
957
- const inversePath = Path.transform(path, op);
958
- const inverseNewPath = Path.transform(Path.next(path), op);
959
- return { ...op, path: inversePath, newPath: inverseNewPath };
960
- }
961
- case 'set_node': {
962
- const { properties, newProperties } = op;
963
- return { ...op, properties: newProperties, newProperties: properties };
964
- }
965
- case 'set_selection': {
966
- const { properties, newProperties } = op;
967
- if (properties == null) {
968
- return {
969
- ...op,
970
- properties: newProperties,
971
- newProperties: null
972
- };
973
- }
974
- else if (newProperties == null) {
975
- return {
976
- ...op,
977
- properties: null,
978
- newProperties: properties
979
- };
980
- }
981
- else {
982
- return { ...op, properties: newProperties, newProperties: properties };
983
- }
984
- }
985
- case 'set_viewport': {
986
- const { properties, newProperties } = op;
987
- if (properties == null) {
988
- return {
989
- ...op,
990
- properties: newProperties,
991
- newProperties: newProperties
992
- };
993
- }
994
- else if (newProperties == null) {
995
- return {
996
- ...op,
997
- properties: properties,
998
- newProperties: properties
999
- };
1000
- }
1001
- else {
1002
- return { ...op, properties: newProperties, newProperties: properties };
1003
- }
1004
- }
1005
- }
1006
- };
1007
- const PlaitOperation = {
1008
- isSetViewportOperation,
1009
- inverse
1010
- };
1011
-
1012
- const Point = {
1013
- isEquals(point, otherPoint) {
1014
- return point && otherPoint && point[0] === otherPoint[0] && point[1] === otherPoint[1];
1015
- }
1016
- };
1017
-
1018
- const SELECTION_BORDER_COLOR = '#6698FF';
1019
- const SELECTION_FILL_COLOR = '#6698FF19'; // 主色 0.1 透明度
1020
- const Selection = {
1021
- isCollapsed(selection) {
1022
- if (selection.anchor[0] == selection.focus[0] && selection.anchor[1] === selection.focus[1]) {
1023
- return true;
1024
- }
1025
- else {
1026
- return false;
1027
- }
842
+ function transformPoints(board, points) {
843
+ const newPoints = points.map(point => {
844
+ return transformPoint(board, point);
845
+ });
846
+ return newPoints;
847
+ }
848
+ function transformPoint(board, point) {
849
+ const { width, height } = PlaitBoard.getHost(board).getBoundingClientRect();
850
+ const viewBox = PlaitBoard.getHost(board).viewBox.baseVal;
851
+ const x = (point[0] / width) * viewBox.width + viewBox.x;
852
+ const y = (point[1] / height) * viewBox.height + viewBox.y;
853
+ const newPoint = [x, y];
854
+ return newPoint;
855
+ }
856
+ function isInPlaitBoard(board, x, y) {
857
+ const plaitBoardElement = PlaitBoard.getBoardNativeElement(board);
858
+ const plaitBoardRect = plaitBoardElement.getBoundingClientRect();
859
+ const distances = distanceBetweenPointAndRectangle(x, y, plaitBoardRect);
860
+ return distances === 0;
861
+ }
862
+
863
+ function createForeignObject(x, y, width, height) {
864
+ var newForeignObject = document.createElementNS(NS, 'foreignObject');
865
+ newForeignObject.setAttribute('x', `${x}`);
866
+ newForeignObject.setAttribute('y', `${y}`);
867
+ newForeignObject.setAttribute('width', `${width}`);
868
+ newForeignObject.setAttribute('height', `${height}`);
869
+ return newForeignObject;
870
+ }
871
+ function updateForeignObject(g, width, height, x, y) {
872
+ const foreignObject = g.querySelector('foreignObject');
873
+ if (foreignObject) {
874
+ foreignObject.setAttribute('width', `${width}`);
875
+ foreignObject.setAttribute('height', `${height}`);
876
+ foreignObject.setAttribute('x', `${x}`);
877
+ foreignObject.setAttribute('y', `${y}`);
1028
878
  }
1029
- };
879
+ }
1030
880
 
1031
- const SAVING = new WeakMap();
1032
- const MERGING = new WeakMap();
881
+ const IS_IOS = typeof navigator !== 'undefined' &&
882
+ typeof window !== 'undefined' &&
883
+ /iPad|iPhone|iPod/.test(navigator.userAgent) &&
884
+ !window.MSStream;
885
+ const IS_APPLE = typeof navigator !== 'undefined' && /Mac OS X/.test(navigator.userAgent);
886
+ const IS_FIREFOX = typeof navigator !== 'undefined' && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
887
+ const IS_SAFARI = typeof navigator !== 'undefined' && /Version\/[\d\.]+.*Safari/.test(navigator.userAgent);
888
+ // "modern" Edge was released at 79.x
889
+ const IS_EDGE_LEGACY = typeof navigator !== 'undefined' && /Edge?\/(?:[0-6][0-9]|[0-7][0-8])/i.test(navigator.userAgent);
890
+ const IS_CHROME = typeof navigator !== 'undefined' && /Chrome/i.test(navigator.userAgent);
891
+ // Native beforeInput events don't work well with react on Chrome 75 and older, Chrome 76+ can use beforeInput
892
+ const IS_CHROME_LEGACY = typeof navigator !== 'undefined' && /Chrome?\/(?:[0-7][0-5]|[0-6][0-9])/i.test(navigator.userAgent);
1033
893
 
1034
894
  /**
1035
895
  * Check whether to merge an operation into the previous operation.
@@ -1199,10 +1059,6 @@ function idCreator(length = 5) {
1199
1059
  return key;
1200
1060
  }
1201
1061
 
1202
- const CLIP_BOARD_FORMAT_KEY = 'x-plait-fragment';
1203
- const SCROLL_BAR_WIDTH = 20;
1204
- const MAX_RADIUS = 16;
1205
-
1206
1062
  /**
1207
1063
  * drawRoundRectangle
1208
1064
  */
@@ -1248,54 +1104,285 @@ function drawAbstractRoundRectangle(rs, x1, y1, x2, y2, isHorizontal, options) {
1248
1104
  l0,-${sideLine}
1249
1105
  a${radius},${radius},0,0,1,${radius},-${radius}`, options);
1250
1106
  }
1251
- else {
1252
- const handleSideLine = (height - handleSpace - radius * 2) / 2;
1253
- const sideLine = width - radius * 2;
1254
- return rs.path(`M${x1 + radius},${y1}
1255
- l${sideLine},0
1256
- a${radius},${radius},0,0,1,${radius},${radius}
1257
- l0,${handleSideLine}
1258
- m0,${handleSpace}
1259
- l0,${handleSideLine}
1260
- a${radius},${radius},0,0,1,-${radius},${radius}
1261
- l-${sideLine},0
1262
- a${radius},${radius},0,0,1,-${radius},-${radius}
1263
- l0,-${handleSideLine}
1264
- m0,-${handleSpace}
1265
- l0,-${handleSideLine}
1266
- a${radius},${radius},0,0,1,${radius},-${radius}`, options);
1107
+ else {
1108
+ const handleSideLine = (height - handleSpace - radius * 2) / 2;
1109
+ const sideLine = width - radius * 2;
1110
+ return rs.path(`M${x1 + radius},${y1}
1111
+ l${sideLine},0
1112
+ a${radius},${radius},0,0,1,${radius},${radius}
1113
+ l0,${handleSideLine}
1114
+ m0,${handleSpace}
1115
+ l0,${handleSideLine}
1116
+ a${radius},${radius},0,0,1,-${radius},${radius}
1117
+ l-${sideLine},0
1118
+ a${radius},${radius},0,0,1,-${radius},-${radius}
1119
+ l0,-${handleSideLine}
1120
+ m0,-${handleSpace}
1121
+ l0,-${handleSideLine}
1122
+ a${radius},${radius},0,0,1,${radius},-${radius}`, options);
1123
+ }
1124
+ }
1125
+
1126
+ function arrowPoints(start, end, maxHypotenuseLength = 10, degree = 40) {
1127
+ const width = Math.abs(start[0] - end[0]);
1128
+ const height = Math.abs(start[1] - end[1]);
1129
+ let hypotenuse = Math.hypot(width, height); // 斜边
1130
+ const realRotateLine = hypotenuse > maxHypotenuseLength * 2 ? maxHypotenuseLength : hypotenuse / 2;
1131
+ const rotateWidth = (realRotateLine / hypotenuse) * width;
1132
+ const rotateHeight = (realRotateLine / hypotenuse) * height;
1133
+ const rotatePoint = [
1134
+ end[0] > start[0] ? end[0] - rotateWidth : end[0] + rotateWidth,
1135
+ end[1] > start[1] ? end[1] - rotateHeight : end[1] + rotateHeight
1136
+ ];
1137
+ const pointRight = rotate(rotatePoint[0], rotatePoint[1], end[0], end[1], (degree * Math.PI) / 180);
1138
+ const pointLeft = rotate(rotatePoint[0], rotatePoint[1], end[0], end[1], (-degree * Math.PI) / 180);
1139
+ return { pointLeft, pointRight };
1140
+ }
1141
+ function drawArrow(rs, start, end, options, maxHypotenuseLength = 10, degree = 40) {
1142
+ const { pointLeft, pointRight } = arrowPoints(start, end, maxHypotenuseLength, degree);
1143
+ const arrowLineLeft = rs.linearPath([pointLeft, end], options);
1144
+ const arrowLineRight = rs.linearPath([pointRight, end], options);
1145
+ return [arrowLineLeft, arrowLineRight];
1146
+ }
1147
+
1148
+ function drawCircle(roughSVG, point, diameter, options) {
1149
+ return roughSVG.circle(point[0], point[1], diameter, options);
1150
+ }
1151
+
1152
+ function drawLine(rs, start, end, options) {
1153
+ return rs.linearPath([start, end], options);
1154
+ }
1155
+ function drawLinearPath(points, options) {
1156
+ const g = createG();
1157
+ const path = createPath();
1158
+ let polylinePath = '';
1159
+ points.forEach((point, index) => {
1160
+ if (index === 0) {
1161
+ polylinePath += `M ${point[0]} ${point[1]} `;
1162
+ }
1163
+ else {
1164
+ polylinePath += `L ${point[0]} ${point[1]} `;
1165
+ }
1166
+ });
1167
+ path.setAttribute('d', polylinePath);
1168
+ path.setAttribute('stroke', `${options?.stroke}`);
1169
+ path.setAttribute('stroke-width', `${options?.strokeWidth}`);
1170
+ path.setAttribute('fill', `none`);
1171
+ g.appendChild(path);
1172
+ return g;
1173
+ }
1174
+
1175
+ let timerId = null;
1176
+ const throttleRAF = (fn) => {
1177
+ const scheduleFunc = () => {
1178
+ timerId = requestAnimationFrame(() => {
1179
+ timerId = null;
1180
+ fn();
1181
+ });
1182
+ };
1183
+ if (timerId !== null) {
1184
+ cancelAnimationFrame(timerId);
1185
+ timerId = null;
1186
+ }
1187
+ scheduleFunc();
1188
+ };
1189
+ const debounce = (func, wait, options) => {
1190
+ let timerSubscription = null;
1191
+ return () => {
1192
+ if (timerSubscription && !timerSubscription.closed) {
1193
+ timerSubscription.unsubscribe();
1194
+ timerSubscription = timer(wait).subscribe(() => {
1195
+ func();
1196
+ });
1197
+ }
1198
+ else {
1199
+ if (options?.leading) {
1200
+ func();
1201
+ }
1202
+ timerSubscription = timer(wait).subscribe();
1203
+ }
1204
+ };
1205
+ };
1206
+
1207
+ const getMovingElements = (board) => {
1208
+ return BOARD_TO_MOVING_ELEMENT.get(board) || [];
1209
+ };
1210
+ const addMovingElements = (board, elements) => {
1211
+ const movingElements = getMovingElements(board);
1212
+ const newElements = elements.filter(item => !movingElements.find(movingElement => movingElement.key === item.key));
1213
+ cacheMovingElements(board, [...movingElements, ...newElements]);
1214
+ };
1215
+ const removeMovingElements = (board) => {
1216
+ BOARD_TO_MOVING_ELEMENT.delete(board);
1217
+ };
1218
+ const cacheMovingElements = (board, elements) => {
1219
+ BOARD_TO_MOVING_ELEMENT.set(board, elements);
1220
+ };
1221
+
1222
+ const PlaitElement = {
1223
+ isRootElement(value) {
1224
+ const parent = NODE_TO_PARENT.get(value);
1225
+ if (parent && PlaitBoard.isBoard(parent)) {
1226
+ return true;
1227
+ }
1228
+ else {
1229
+ return false;
1230
+ }
1231
+ },
1232
+ getComponent(value) {
1233
+ return ELEMENT_TO_COMPONENT.get(value);
1234
+ }
1235
+ };
1236
+
1237
+ const RectangleClient = {
1238
+ isHit: (origin, target) => {
1239
+ const minX = origin.x < target.x ? origin.x : target.x;
1240
+ const maxX = origin.x + origin.width > target.x + target.width ? origin.x + origin.width : target.x + target.width;
1241
+ const minY = origin.y < target.y ? origin.y : target.y;
1242
+ const maxY = origin.y + origin.height > target.y + target.height ? origin.y + origin.height : target.y + target.height;
1243
+ // float calculate error( eg: 1.4210854715202004e-14 > 0)
1244
+ if (Math.floor(maxX - minX - origin.width - target.width) <= 0 && Math.floor(maxY - minY - origin.height - target.height) <= 0) {
1245
+ return true;
1246
+ }
1247
+ else {
1248
+ return false;
1249
+ }
1250
+ },
1251
+ toRectangleClient: (points) => {
1252
+ const xArray = points.map(ele => ele[0]);
1253
+ const yArray = points.map(ele => ele[1]);
1254
+ const xMin = Math.min(...xArray);
1255
+ const xMax = Math.max(...xArray);
1256
+ const yMin = Math.min(...yArray);
1257
+ const yMax = Math.max(...yArray);
1258
+ const rect = { x: xMin, y: yMin, width: xMax - xMin, height: yMax - yMin };
1259
+ return rect;
1260
+ },
1261
+ getOutlineRectangle: (rectangle, offset) => {
1262
+ return {
1263
+ x: rectangle.x + offset,
1264
+ y: rectangle.y + offset,
1265
+ width: rectangle.width + Math.abs(offset) * 2,
1266
+ height: rectangle.height + Math.abs(offset) * 2
1267
+ };
1268
+ },
1269
+ isEqual: (rectangle, otherRectangle) => {
1270
+ return (rectangle.x === otherRectangle.x &&
1271
+ rectangle.y === otherRectangle.y &&
1272
+ rectangle.width === otherRectangle.width &&
1273
+ rectangle.height === otherRectangle.height);
1274
+ }
1275
+ };
1276
+
1277
+ const isSetViewportOperation = (value) => {
1278
+ return value.type === 'set_viewport';
1279
+ };
1280
+ const inverse = (op) => {
1281
+ switch (op.type) {
1282
+ case 'insert_node': {
1283
+ return { ...op, type: 'remove_node' };
1284
+ }
1285
+ case 'remove_node': {
1286
+ return { ...op, type: 'insert_node' };
1287
+ }
1288
+ case 'move_node': {
1289
+ const { newPath, path } = op;
1290
+ // PERF: in this case the move operation is a no-op anyways.
1291
+ if (Path.equals(newPath, path)) {
1292
+ return op;
1293
+ }
1294
+ // when operation path is [0,0] -> [0,2], should exec Path.transform to get [0,1] -> [0,0]
1295
+ // shoud not return [0,2] -> [0,0] #WIK-8981
1296
+ // if (Path.isSibling(path, newPath)) {
1297
+ // return { ...op, path: newPath, newPath: path };
1298
+ // }
1299
+ // If the move does not happen within a single parent it is possible
1300
+ // for the move to impact the true path to the location where the node
1301
+ // was removed from and where it was inserted. We have to adjust for this
1302
+ // and find the original path. We can accomplish this (only in non-sibling)
1303
+ // moves by looking at the impact of the move operation on the node
1304
+ // after the original move path.
1305
+ const inversePath = Path.transform(path, op);
1306
+ const inverseNewPath = Path.transform(Path.next(path), op);
1307
+ return { ...op, path: inversePath, newPath: inverseNewPath };
1308
+ }
1309
+ case 'set_node': {
1310
+ const { properties, newProperties } = op;
1311
+ return { ...op, properties: newProperties, newProperties: properties };
1312
+ }
1313
+ case 'set_selection': {
1314
+ const { properties, newProperties } = op;
1315
+ if (properties == null) {
1316
+ return {
1317
+ ...op,
1318
+ properties: newProperties,
1319
+ newProperties: null
1320
+ };
1321
+ }
1322
+ else if (newProperties == null) {
1323
+ return {
1324
+ ...op,
1325
+ properties: null,
1326
+ newProperties: properties
1327
+ };
1328
+ }
1329
+ else {
1330
+ return { ...op, properties: newProperties, newProperties: properties };
1331
+ }
1332
+ }
1333
+ case 'set_viewport': {
1334
+ const { properties, newProperties } = op;
1335
+ if (properties == null) {
1336
+ return {
1337
+ ...op,
1338
+ properties: newProperties,
1339
+ newProperties: newProperties
1340
+ };
1341
+ }
1342
+ else if (newProperties == null) {
1343
+ return {
1344
+ ...op,
1345
+ properties: properties,
1346
+ newProperties: properties
1347
+ };
1348
+ }
1349
+ else {
1350
+ return { ...op, properties: newProperties, newProperties: properties };
1351
+ }
1352
+ }
1353
+ }
1354
+ };
1355
+ const PlaitOperation = {
1356
+ isSetViewportOperation,
1357
+ inverse
1358
+ };
1359
+
1360
+ const Point = {
1361
+ isEquals(point, otherPoint) {
1362
+ return point && otherPoint && point[0] === otherPoint[0] && point[1] === otherPoint[1];
1267
1363
  }
1268
- }
1364
+ };
1269
1365
 
1270
- function arrowPoints(start, end, maxHypotenuseLength = 10, degree = 40) {
1271
- const width = Math.abs(start[0] - end[0]);
1272
- const height = Math.abs(start[1] - end[1]);
1273
- let hypotenuse = Math.hypot(width, height); // 斜边
1274
- const realRotateLine = hypotenuse > maxHypotenuseLength * 2 ? maxHypotenuseLength : hypotenuse / 2;
1275
- const rotateWidth = (realRotateLine / hypotenuse) * width;
1276
- const rotateHeight = (realRotateLine / hypotenuse) * height;
1277
- const rotatePoint = [
1278
- end[0] > start[0] ? end[0] - rotateWidth : end[0] + rotateWidth,
1279
- end[1] > start[1] ? end[1] - rotateHeight : end[1] + rotateHeight
1280
- ];
1281
- const pointRight = rotate(rotatePoint[0], rotatePoint[1], end[0], end[1], (degree * Math.PI) / 180);
1282
- const pointLeft = rotate(rotatePoint[0], rotatePoint[1], end[0], end[1], (-degree * Math.PI) / 180);
1283
- return { pointLeft, pointRight };
1284
- }
1285
- function drawArrow(rs, start, end, options, maxHypotenuseLength = 10, degree = 40) {
1286
- const { pointLeft, pointRight } = arrowPoints(start, end, maxHypotenuseLength, degree);
1287
- const arrowLineLeft = rs.linearPath([pointLeft, end], options);
1288
- const arrowLineRight = rs.linearPath([pointRight, end], options);
1289
- return [arrowLineLeft, arrowLineRight];
1290
- }
1366
+ const SELECTION_BORDER_COLOR = '#6698FF';
1367
+ const SELECTION_FILL_COLOR = '#6698FF19'; // 主色 0.1 透明度
1368
+ const Selection = {
1369
+ isCollapsed(selection) {
1370
+ if (selection.anchor[0] == selection.focus[0] && selection.anchor[1] === selection.focus[1]) {
1371
+ return true;
1372
+ }
1373
+ else {
1374
+ return false;
1375
+ }
1376
+ }
1377
+ };
1291
1378
 
1292
- function drawCircle(roughSVG, point, diameter, options) {
1293
- return roughSVG.circle(point[0], point[1], diameter, options);
1294
- }
1379
+ const SAVING = new WeakMap();
1380
+ const MERGING = new WeakMap();
1295
1381
 
1296
- function drawLine(rs, start, end, options) {
1297
- return rs.linearPath([start, end], options);
1298
- }
1382
+ var PlaitPluginKey;
1383
+ (function (PlaitPluginKey) {
1384
+ PlaitPluginKey["withSelection"] = "withSelection";
1385
+ })(PlaitPluginKey || (PlaitPluginKey = {}));
1299
1386
 
1300
1387
  const IS_FROM_SCROLLING = new WeakMap();
1301
1388
  const IS_FROM_VIEWPORT_CHANGE = new WeakMap();
@@ -1424,18 +1511,52 @@ function initializeViewportOffset(board) {
1424
1511
  }
1425
1512
  updateViewportOffset(board);
1426
1513
  }
1427
- function setViewport(board, origination, zoom) {
1514
+ const updateViewportOrigination = (board, origination) => {
1515
+ BOARD_TO_VIEWPORT_ORIGINATION.set(board, origination);
1516
+ };
1517
+ const clearViewportOrigination = (board) => {
1518
+ BOARD_TO_VIEWPORT_ORIGINATION.delete(board);
1519
+ };
1520
+ const getViewportOrigination = (board) => {
1521
+ const origination = BOARD_TO_VIEWPORT_ORIGINATION.get(board);
1522
+ if (origination) {
1523
+ return origination;
1524
+ }
1525
+ else {
1526
+ return board.viewport.origination;
1527
+ }
1528
+ };
1529
+ const isFromScrolling = (board) => {
1530
+ return !!IS_FROM_SCROLLING.get(board);
1531
+ };
1532
+ const setIsFromScrolling = (board, state) => {
1533
+ IS_FROM_SCROLLING.set(board, state);
1534
+ };
1535
+ const isFromViewportChange = (board) => {
1536
+ return !!IS_FROM_VIEWPORT_CHANGE.get(board);
1537
+ };
1538
+ const setIsFromViewportChange = (board, state) => {
1539
+ IS_FROM_VIEWPORT_CHANGE.set(board, state);
1540
+ };
1541
+ function scrollToRectangle(board, client) { }
1542
+
1543
+ function updateViewport(board, origination, zoom) {
1428
1544
  zoom = zoom ?? board.viewport.zoom;
1429
- Transforms.setViewport(board, {
1545
+ setViewport(board, {
1430
1546
  ...board.viewport,
1431
1547
  zoom,
1432
1548
  origination
1433
1549
  });
1434
1550
  clearViewportOrigination(board);
1435
1551
  }
1436
- function changeZoom(board, newZoom, isCenter = true) {
1552
+ const updatePointerType = (board, pointer) => {
1553
+ board.pointer = pointer;
1554
+ const boardComponent = BOARD_TO_COMPONENT.get(board);
1555
+ boardComponent?.markForCheck();
1556
+ };
1557
+ function updateZoom(board, newZoom, isCenter = true) {
1437
1558
  newZoom = clampZoomLevel(newZoom);
1438
- const mousePoint = BOARD_TO_MOVING_POINT.get(board);
1559
+ const mousePoint = PlaitBoard.getMovingPoint(board);
1439
1560
  const nativeElement = PlaitBoard.getBoardNativeElement(board);
1440
1561
  const nativeElementRect = nativeElement.getBoundingClientRect();
1441
1562
  const viewportContainerRect = getViewportContainerRect(board);
@@ -1448,7 +1569,7 @@ function changeZoom(board, newZoom, isCenter = true) {
1448
1569
  const centerX = origination[0] + focusPoint[0] / zoom;
1449
1570
  const centerY = origination[1] + focusPoint[1] / zoom;
1450
1571
  const newOrigination = [centerX - focusPoint[0] / newZoom, centerY - focusPoint[1] / newZoom];
1451
- setViewport(board, newOrigination, newZoom);
1572
+ updateViewport(board, newOrigination, newZoom);
1452
1573
  }
1453
1574
  function fitViewport(board) {
1454
1575
  const nativeElementRect = PlaitBoard.getBoardNativeElement(board).getBoundingClientRect();
@@ -1472,91 +1593,13 @@ function fitViewport(board) {
1472
1593
  centerX - viewportContainerRect.width / 2 / newZoom,
1473
1594
  centerY - viewportContainerRect.height / 2 / newZoom
1474
1595
  ];
1475
- setViewport(board, newOrigination, newZoom);
1596
+ updateViewport(board, newOrigination, newZoom);
1476
1597
  }
1477
- const updateViewportOrigination = (board, origination) => {
1478
- BOARD_TO_VIEWPORT_ORIGINATION.set(board, origination);
1479
- };
1480
- const clearViewportOrigination = (board) => {
1481
- BOARD_TO_VIEWPORT_ORIGINATION.delete(board);
1482
- };
1483
- const getViewportOrigination = (board) => {
1484
- const origination = BOARD_TO_VIEWPORT_ORIGINATION.get(board);
1485
- if (origination) {
1486
- return origination;
1487
- }
1488
- else {
1489
- return board.viewport.origination;
1490
- }
1491
- };
1492
- const isFromScrolling = (board) => {
1493
- return !!IS_FROM_SCROLLING.get(board);
1494
- };
1495
- const setIsFromScrolling = (board, state) => {
1496
- IS_FROM_SCROLLING.set(board, state);
1497
- };
1498
- const isFromViewportChange = (board) => {
1499
- return !!IS_FROM_VIEWPORT_CHANGE.get(board);
1500
- };
1501
- const setIsFromViewportChange = (board, state) => {
1502
- IS_FROM_VIEWPORT_CHANGE.set(board, state);
1503
- };
1504
- function scrollToRectangle(board, client) { }
1505
-
1506
- let timerId = null;
1507
- const throttleRAF = (fn) => {
1508
- const scheduleFunc = () => {
1509
- timerId = requestAnimationFrame(() => {
1510
- timerId = null;
1511
- fn();
1512
- });
1513
- };
1514
- if (timerId !== null) {
1515
- cancelAnimationFrame(timerId);
1516
- timerId = null;
1517
- }
1518
- scheduleFunc();
1519
- };
1520
- const debounce = (func, wait, options) => {
1521
- let timerSubscription = null;
1522
- return () => {
1523
- if (timerSubscription && !timerSubscription.closed) {
1524
- timerSubscription.unsubscribe();
1525
- timerSubscription = timer(wait).subscribe(() => {
1526
- func();
1527
- });
1528
- }
1529
- else {
1530
- if (options?.leading) {
1531
- func();
1532
- }
1533
- timerSubscription = timer(wait).subscribe();
1534
- }
1535
- };
1536
- };
1537
-
1538
- const getMovingElements = (board) => {
1539
- return BOARD_TO_MOVING_ELEMENT.get(board) || [];
1540
- };
1541
- const addMovingElements = (board, elements) => {
1542
- const movingElements = getMovingElements(board);
1543
- const newElements = elements.filter(item => !movingElements.find(movingElement => movingElement.key === item.key));
1544
- cacheMovingElements(board, [...movingElements, ...newElements]);
1545
- };
1546
- const removeMovingElements = (board) => {
1547
- BOARD_TO_MOVING_ELEMENT.delete(board);
1548
- };
1549
- const cacheMovingElements = (board, elements) => {
1550
- BOARD_TO_MOVING_ELEMENT.set(board, elements);
1551
- };
1552
-
1553
- const updatePointerType = (board, pointer) => {
1554
- board.pointer = pointer;
1555
- const boardComponent = BOARD_TO_COMPONENT.get(board);
1556
- boardComponent?.markForCheck();
1557
- };
1558
1598
  const BoardTransforms = {
1559
- updatePointerType
1599
+ updatePointerType,
1600
+ updateViewport,
1601
+ fitViewport,
1602
+ updateZoom
1560
1603
  };
1561
1604
 
1562
1605
  const Transforms = {
@@ -1768,7 +1811,7 @@ function withHandPointer(board) {
1768
1811
  y: 0
1769
1812
  };
1770
1813
  board.mousedown = (event) => {
1771
- if (board.pointer === PlaitPointerType.hand) {
1814
+ if (PlaitBoard.isPointer(board, PlaitPointerType.hand) && isMainPointer(event)) {
1772
1815
  isMoving = true;
1773
1816
  PlaitBoard.getBoardNativeElement(board).classList.add('viewport-moving');
1774
1817
  plaitBoardMove.x = event.x;
@@ -1777,7 +1820,7 @@ function withHandPointer(board) {
1777
1820
  mousedown(event);
1778
1821
  };
1779
1822
  board.mousemove = (event) => {
1780
- if (board.pointer === PlaitPointerType.hand && board.selection && isMoving) {
1823
+ if (PlaitBoard.isPointer(board, PlaitPointerType.hand) && board.selection && isMoving) {
1781
1824
  const viewportContainer = PlaitBoard.getViewportContainer(board);
1782
1825
  const left = viewportContainer.scrollLeft - (event.x - plaitBoardMove.x);
1783
1826
  const top = viewportContainer.scrollTop - (event.y - plaitBoardMove.y);
@@ -1799,7 +1842,7 @@ function withHandPointer(board) {
1799
1842
  board.keydown = (event) => {
1800
1843
  if (event.code === 'Space') {
1801
1844
  if (!PlaitBoard.isPointer(board, PlaitPointerType.hand)) {
1802
- updatePointerType(board, PlaitPointerType.hand);
1845
+ BoardTransforms.updatePointerType(board, PlaitPointerType.hand);
1803
1846
  }
1804
1847
  event.preventDefault();
1805
1848
  }
@@ -1807,7 +1850,7 @@ function withHandPointer(board) {
1807
1850
  };
1808
1851
  board.keyup = (event) => {
1809
1852
  if (!board.options.readonly && event.code === 'Space') {
1810
- updatePointerType(board, PlaitPointerType.selection);
1853
+ BoardTransforms.updatePointerType(board, PlaitPointerType.selection);
1811
1854
  }
1812
1855
  keyup(event);
1813
1856
  };
@@ -1824,10 +1867,11 @@ function withSelection(board) {
1824
1867
  let selectionOuterG;
1825
1868
  let previousSelectedElements;
1826
1869
  board.mousedown = (event) => {
1827
- if (event.button === 2) {
1870
+ if (!isMainPointer(event)) {
1828
1871
  mousedown(event);
1829
1872
  return;
1830
1873
  }
1874
+ const options = board.getPluginOptions(PlaitPluginKey.withSelection);
1831
1875
  const point = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
1832
1876
  const ranges = [{ anchor: point, focus: point }];
1833
1877
  const selectedElements = getSelectedElements(board);
@@ -1838,7 +1882,8 @@ function withSelection(board) {
1838
1882
  const range = { anchor: point, focus: point };
1839
1883
  if (PlaitBoard.isPointer(board, PlaitPointerType.selection) &&
1840
1884
  PlaitBoard.isFocus(board) &&
1841
- getHitElements(board, { ranges: [range] }).length === 0) {
1885
+ getHitElements(board, { ranges: [range] }).length === 0 &&
1886
+ options.isMultiple) {
1842
1887
  start = point;
1843
1888
  }
1844
1889
  Transforms.setSelection(board, { ranges: ranges });
@@ -1896,7 +1941,11 @@ function withSelection(board) {
1896
1941
  if (board.operations.find(value => value.type === 'set_selection')) {
1897
1942
  selectionOuterG?.remove();
1898
1943
  const temporaryElements = getTemporaryElements(board);
1899
- const elements = temporaryElements ? temporaryElements : getHitElements(board);
1944
+ let elements = temporaryElements ? temporaryElements : getHitElements(board);
1945
+ const options = board.getPluginOptions(PlaitPluginKey.withSelection);
1946
+ if (!options.isMultiple && elements.length > 1) {
1947
+ elements = [elements[0]];
1948
+ }
1900
1949
  cacheSelectedElements(board, elements);
1901
1950
  previousSelectedElements = elements;
1902
1951
  const { width, height } = getRectangleByElements(board, elements, false);
@@ -1932,6 +1981,7 @@ function withSelection(board) {
1932
1981
  }
1933
1982
  onChange();
1934
1983
  };
1984
+ board.setPluginOptions(PlaitPluginKey.withSelection, { isMultiple: true });
1935
1985
  return board;
1936
1986
  }
1937
1987
  function getTemporaryElements(board) {
@@ -2073,6 +2123,50 @@ function withMoving(board) {
2073
2123
  return board;
2074
2124
  }
2075
2125
 
2126
+ const withOptions = (board) => {
2127
+ const pluginOptions = new Map();
2128
+ const newBoard = board;
2129
+ newBoard.getPluginOptions = key => {
2130
+ return pluginOptions.get(key);
2131
+ };
2132
+ newBoard.setPluginOptions = (key, options) => {
2133
+ const oldOptions = newBoard.getPluginOptions(key) || {};
2134
+ pluginOptions.set(key, { ...oldOptions, ...options });
2135
+ };
2136
+ return newBoard;
2137
+ };
2138
+
2139
+ class PlaitIslandBaseComponent {
2140
+ constructor(cdr) {
2141
+ this.cdr = cdr;
2142
+ }
2143
+ initialize(board) {
2144
+ this.board = board;
2145
+ this.markForCheck();
2146
+ }
2147
+ markForCheck() {
2148
+ this.cdr.markForCheck();
2149
+ }
2150
+ }
2151
+ PlaitIslandBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitIslandBaseComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
2152
+ PlaitIslandBaseComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: PlaitIslandBaseComponent, host: { classAttribute: "plait-island-container" }, ngImport: i0 });
2153
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitIslandBaseComponent, decorators: [{
2154
+ type: Directive,
2155
+ args: [{
2156
+ host: {
2157
+ class: 'plait-island-container'
2158
+ }
2159
+ }]
2160
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; } });
2161
+ const hasOnBoardChange = (value) => {
2162
+ if (value.onBoardChange) {
2163
+ return true;
2164
+ }
2165
+ else {
2166
+ return false;
2167
+ }
2168
+ };
2169
+
2076
2170
  class PlaitElementComponent {
2077
2171
  constructor(renderer2, viewContainerRef) {
2078
2172
  this.renderer2 = renderer2;
@@ -2147,9 +2241,9 @@ class PlaitElementComponent {
2147
2241
  this.board.destroyElement(this.getContext());
2148
2242
  }
2149
2243
  }
2150
- PlaitElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitElementComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
2151
- PlaitElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.2", type: PlaitElementComponent, selector: "plait-element", inputs: { index: "index", element: "element", parent: "parent", board: "board", effect: "effect", parentG: "parentG" }, usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
2152
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitElementComponent, decorators: [{
2244
+ PlaitElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitElementComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
2245
+ PlaitElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: PlaitElementComponent, selector: "plait-element", inputs: { index: "index", element: "element", parent: "parent", board: "board", effect: "effect", parentG: "parentG" }, usesOnChanges: true, ngImport: i0, template: '', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
2246
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitElementComponent, decorators: [{
2153
2247
  type: Component,
2154
2248
  args: [{
2155
2249
  selector: 'plait-element',
@@ -2185,8 +2279,8 @@ class PlaitChildrenElement {
2185
2279
  }
2186
2280
  }
2187
2281
  }
2188
- PlaitChildrenElement.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitChildrenElement, deps: [], target: i0.ɵɵFactoryTarget.Component });
2189
- PlaitChildrenElement.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.2", type: PlaitChildrenElement, selector: "plait-children", inputs: { board: "board", parent: "parent", effect: "effect", parentG: "parentG" }, ngImport: i0, template: `
2282
+ PlaitChildrenElement.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitChildrenElement, deps: [], target: i0.ɵɵFactoryTarget.Component });
2283
+ PlaitChildrenElement.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: PlaitChildrenElement, selector: "plait-children", inputs: { board: "board", parent: "parent", effect: "effect", parentG: "parentG" }, ngImport: i0, template: `
2190
2284
  <plait-element
2191
2285
  *ngFor="let item of parent.children; let index = index; trackBy: trackBy"
2192
2286
  [index]="index"
@@ -2197,7 +2291,7 @@ PlaitChildrenElement.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", v
2197
2291
  [parentG]="parentG"
2198
2292
  ></plait-element>
2199
2293
  `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: PlaitElementComponent, selector: "plait-element", inputs: ["index", "element", "parent", "board", "effect", "parentG"] }] });
2200
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitChildrenElement, decorators: [{
2294
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitChildrenElement, decorators: [{
2201
2295
  type: Component,
2202
2296
  args: [{
2203
2297
  selector: 'plait-children',
@@ -2223,61 +2317,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImpor
2223
2317
  type: Input
2224
2318
  }] } });
2225
2319
 
2226
- class PlaitToolbarComponent {
2227
- constructor() {
2228
- this.PlaitPointerType = PlaitPointerType;
2229
- this.hostClass = `plait-board-toolbar`;
2230
- this.adaptHandle = new EventEmitter();
2231
- this.zoomInHandle = new EventEmitter();
2232
- this.zoomOutHandle = new EventEmitter();
2233
- this.resetZoomHandel = new EventEmitter();
2234
- }
2235
- get zoom() {
2236
- const zoom = this.board?.viewport.zoom || 1;
2237
- return Number((zoom * 100).toFixed(0));
2238
- }
2239
- get isHand() {
2240
- return this.board.pointer === PlaitPointerType.hand;
2241
- }
2242
- activeHand() {
2243
- updatePointerType(this.board, this.isHand ? PlaitPointerType.selection : PlaitPointerType.hand);
2244
- }
2245
- // 适应画布
2246
- adapt() {
2247
- this.adaptHandle.emit();
2248
- }
2249
- // 放大
2250
- zoomIn() {
2251
- this.zoomInHandle.emit();
2252
- }
2253
- // 缩小
2254
- zoomOut() {
2255
- this.zoomOutHandle.emit();
2256
- }
2257
- resetZoom() {
2258
- this.resetZoomHandel.emit();
2259
- }
2260
- }
2261
- PlaitToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitToolbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2262
- PlaitToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.2", type: PlaitToolbarComponent, selector: "plait-toolbar", inputs: { board: "board" }, outputs: { adaptHandle: "adaptHandle", zoomInHandle: "zoomInHandle", zoomOutHandle: "zoomOutHandle", resetZoomHandel: "resetZoomHandel" }, host: { properties: { "class": "this.hostClass" } }, ngImport: i0, template: "<div class=\"zoom-toolbar island plait-board-attached\">\n <a class=\"toolbar-item plait-action-icon\" [ngClass]=\"{ 'icon-active': isHand }\" (click)=\"activeHand()\">\n <ng-template [ngTemplateOutlet]=\"dragMoveTemplate\"></ng-template>\n </a>\n <div class=\"divider\"></div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"adapt()\">\n <ng-template [ngTemplateOutlet]=\"adaptTemplate\"></ng-template>\n </a>\n <div class=\"divider\"></div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"zoomOut()\">\n <ng-template [ngTemplateOutlet]=\"zoomOutTemplate\"></ng-template>\n </a>\n <div class=\"toolbar-item zoom-value\" (mousedown)=\"resetZoom()\">{{ zoom }}%</div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"zoomIn()\">\n <ng-template [ngTemplateOutlet]=\"zoomInTemplate\"></ng-template>\n </a>\n</div>\n\n<ng-template #dragMoveTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/hand</title>\n <g id=\"1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/hand\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M8.44583468,0.500225887 C9.07406934,0.510185679 9.54739531,0.839591366 9.86192311,1.34305279 C9.89696656,1.39914649 9.92878401,1.45492964 9.9576026,1.50991157 L9.9576026,1.50991157 L10.0210033,1.64201027 L10.061978,1.62350755 C10.1972891,1.56834247 10.3444107,1.53218464 10.5027907,1.51755353 L10.5027907,1.51755353 L10.6649031,1.51019133 C11.4883708,1.51019133 12.0208782,1.99343346 12.3023042,2.66393278 C12.3903714,2.87392911 12.4344191,3.10047818 12.4339446,3.3257952 L12.4339446,3.3257952 L12.4360033,3.80501027 L12.5160535,3.78341501 C12.6124478,3.76124046 12.7138812,3.74739854 12.820201,3.74250274 L12.820201,3.74250274 L12.9833264,3.74194533 C13.6121166,3.7657478 14.0645887,4.0801724 14.3087062,4.56112689 C14.4521117,4.8436609 14.4987984,5.11349437 14.4999262,5.33449618 L14.4999262,5.33449618 L14.3922653,12.049414 C14.3784752,12.909177 14.0717787,13.7360948 13.5212406,14.3825228 C13.4055676,14.5183496 13.2843697,14.643961 13.1582361,14.7596335 C12.4634771,15.3967716 11.755103,15.6538706 11.1897396,15.7000055 L11.1897396,15.7000055 L7.4723083,15.6798158 C7.14276373,15.634268 6.81580098,15.5154267 6.49455235,15.3472501 C6.25643701,15.2225944 6.06881706,15.0975452 5.88705731,14.9494308 L5.88705731,14.9494308 L2.55198782,11.500873 C2.39559475,11.3769079 2.17626793,11.1748532 1.9548636,10.9139403 C1.57867502,10.4706225 1.33501976,10.0139923 1.30330257,9.52833025 C1.28093191,9.18578476 1.37200912,8.85641102 1.5826788,8.56872564 C1.82538833,8.23725279 2.12881965,8.02107162 2.47470569,7.92957033 C2.95807982,7.80169771 3.42705723,7.92468989 3.86509644,8.18731167 C4.04431391,8.29475961 4.1816109,8.40304483 4.26225571,8.47866867 L4.26225571,8.47866867 L4.61400328,8.79701027 L4.57247249,3.59275349 L4.57628524,3.46204923 C4.5897691,3.23444442 4.64087578,2.95701848 4.75937106,2.66961597 C5.01017272,2.06131302 5.49670227,1.64692543 6.21363856,1.60818786 C6.44223508,1.59583681 6.65042099,1.62176802 6.83696985,1.68057551 L6.83696985,1.68057551 L6.86400328,1.69001027 C6.88501862,1.63593052 6.90764242,1.58175442 6.9331867,1.52672633 L6.9331867,1.52672633 L7.01883595,1.35955614 C7.31549194,0.832047939 7.79476072,0.48993549 8.44583468,0.500225887 Z M8.42684173,1.70001476 C8.26825412,1.69756905 8.16339456,1.77242008 8.06478367,1.94776814 C8.03967773,1.99241107 8.01831703,2.03811495 8.00083464,2.07855067 L8.00083464,2.07855067 L7.94879157,2.2035905 L7.94354455,2.20731401 L7.943,3.161 L7.97170661,3.16123746 L7.97170661,7.60991883 L6.77170661,7.60991883 L6.771,3.338 L6.74362358,3.33880359 C6.74284189,3.29064626 6.73014163,3.20282206 6.7002616,3.11094408 L6.66446012,3.01903385 C6.58982025,2.85766739 6.49843292,2.79455071 6.27838133,2.80644008 C6.07001018,2.81769881 5.95642108,2.91444507 5.86877664,3.12702089 C5.79792279,3.29887224 5.77228127,3.48655908 5.77246879,3.58977183 L5.77246879,3.58977183 L5.83613619,11.5252021 L3.41863956,9.33477657 L3.31637296,9.25979571 L3.24805011,9.21651224 C3.06096922,9.10434987 2.89279975,9.06024641 2.78159879,9.0896637 C2.71007735,9.10858411 2.63607367,9.1613084 2.55086305,9.27768211 C2.51020424,9.33320478 2.49638061,9.38319687 2.50075171,9.4501283 C2.51206889,9.62341997 2.64503022,9.87260054 2.86983366,10.1375191 C3.03268834,10.3294345 3.19762053,10.4813781 3.35554956,10.6131022 L3.35554956,10.6131022 L6.68454317,14.0569073 C6.71106575,14.0773808 6.74806086,14.1037158 6.79369091,14.1335929 L6.79369091,14.1335929 L6.95464838,14.2315311 L7.05111031,14.2841211 C7.25978123,14.3933622 7.46253523,14.4670573 7.55685495,14.4854708 L7.55685495,14.4854708 L11.1407985,14.5022108 C11.1503576,14.5013899 11.1627905,14.4997539 11.1779002,14.4971772 L11.1779002,14.4971772 L11.2991076,14.4694224 C11.3491682,14.4557375 11.4083624,14.437284 11.4751158,14.4130563 C11.769383,14.3062543 12.066676,14.1324596 12.3471758,13.8752234 C12.4371203,13.7927386 12.5240597,13.7026333 12.607654,13.6044743 C12.9760464,13.1719172 13.183059,12.6137678 13.1924195,12.030173 L13.1924195,12.030173 L13.3000132,5.32832551 C13.2997939,5.29016685 13.2826117,5.19085946 13.2386527,5.10425262 C13.1843838,4.99733326 13.1129774,4.94771265 12.9379578,4.94108739 C12.6814739,4.93138871 12.534132,5.11189595 12.4756792,5.39480062 L12.4768718,7.52734922 L11.2768718,7.52734922 L11.276,5.688 L11.2462883,5.6883208 L11.2339541,3.32771285 C11.2341,3.2560396 11.2209054,3.18817621 11.1957482,3.12818892 C11.0820579,2.85732094 10.9199288,2.71019133 10.6649031,2.71019133 C10.456829,2.71019133 10.3197487,2.87378067 10.2524297,3.11264939 L10.2530225,7.512783 L9.05302254,7.512783 L9.053,3.288 L9.01554331,3.28724203 L8.98800328,2.29901027 L8.9629175,2.22263368 C8.94515567,2.17417174 8.92167756,2.11937748 8.8924232,2.06330056 L8.8924232,2.06330056 L8.84420197,1.9788544 C8.72758855,1.79219249 8.59915015,1.70280728 8.42684173,1.70001476 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n\n<ng-template #adaptTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/Fit canvas</title>\n <g id=\"1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/Fit-canvas\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M14.9971494,10.4 L14.9971494,13.4020516 C14.9971494,14.2366152 14.3581879,14.9219414 13.542782,14.9955129 L13.3971494,15.0020516 L10.4,15.0020516 L10.4,13.8020516 L13.3971494,13.8020516 C13.590449,13.8020516 13.7517243,13.6649388 13.7890228,13.4826656 L13.7971494,13.4020516 L13.7971494,10.4 L14.9971494,10.4 Z M2.2,10.4 L2.2,13.3971494 C2.2,13.590449 2.3371128,13.7517243 2.51938605,13.7890228 L2.6,13.7971494 L5.60205161,13.7971494 L5.60205161,14.9971494 L2.6,14.9971494 C1.76543638,14.9971494 1.08011021,14.3581879 1.00653868,13.542782 L1,13.3971494 L1,10.4 L2.2,10.4 Z M10.5024511,4.9 C11.3861067,4.9 12.1024511,5.6163444 12.1024511,6.5 L12.1024511,6.5 L12.1024511,9.5 C12.1024511,10.3836556 11.3861067,11.1 10.5024511,11.1 L10.5024511,11.1 L5.50245112,11.1 C4.61879552,11.1 3.90245112,10.3836556 3.90245112,9.5 L3.90245112,9.5 L3.90245112,6.5 C3.90245112,5.6163444 4.61879552,4.9 5.50245112,4.9 L5.50245112,4.9 Z M10.5024511,6.1 L5.50245112,6.1 C5.28153722,6.1 5.10245112,6.2790861 5.10245112,6.5 L5.10245112,6.5 L5.10245112,9.5 C5.10245112,9.7209139 5.28153722,9.9 5.50245112,9.9 L5.50245112,9.9 L10.5024511,9.9 C10.723365,9.9 10.9024511,9.7209139 10.9024511,9.5 L10.9024511,9.5 L10.9024511,6.5 C10.9024511,6.2790861 10.723365,6.1 10.5024511,6.1 L10.5024511,6.1 Z M5.59714938,1 L5.59714938,2.2 L2.6,2.2 C2.40670034,2.2 2.24542508,2.3371128 2.20812658,2.51938605 L2.2,2.6 L2.2,5.60205161 L1,5.60205161 L1,2.6 C1,1.76543638 1.63896152,1.08011021 2.45436739,1.00653868 L2.6,1 L5.59714938,1 Z M13.3971494,1 L13.542782,1.00653868 C14.3581879,1.08011021 14.9971494,1.76543638 14.9971494,2.6 L14.9971494,2.6 L14.9971494,5.60205161 L13.7971494,5.60205161 L13.7971494,2.6 L13.7890228,2.51938605 C13.7517243,2.3371128 13.590449,2.2 13.3971494,2.2 L13.3971494,2.2 L10.4,2.2 L10.4,1 L13.3971494,1 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n<ng-template #zoomOutTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>action/zoom-out</title>\n <desc>Created with Sketch.</desc>\n <g id=\"action/zoom-out\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M6.85,2.73225886e-13 C10.6331505,2.73225886e-13 13.7,3.06684946 13.7,6.85 C13.7,8.54194045 13.0865836,10.0906098 12.0700142,11.2857448 L15.4201976,14.5717081 C15.6567367,14.8037768 15.6603607,15.1836585 15.4282919,15.4201976 C15.1962232,15.6567367 14.8163415,15.6603607 14.5798024,15.4282919 L14.5798024,15.4282919 L11.2163456,12.128262 C10.0309427,13.1099691 8.50937591,13.7 6.85,13.7 C3.06684946,13.7 4.58522109e-14,10.6331505 4.58522109e-14,6.85 C4.58522109e-14,3.06684946 3.06684946,2.73225886e-13 6.85,2.73225886e-13 Z M6.85,1.2 C3.72959116,1.2 1.2,3.72959116 1.2,6.85 C1.2,9.97040884 3.72959116,12.5 6.85,12.5 C8.31753357,12.5 9.65438791,11.9404957 10.6588859,11.0231643 C10.6855412,10.9625408 10.7245275,10.9050898 10.7743982,10.8542584 C10.8288931,10.7987137 10.8915387,10.7560124 10.9585649,10.7261903 C11.9144009,9.71595758 12.5,8.35136579 12.5,6.85 C12.5,3.72959116 9.97040884,1.2 6.85,1.2 Z M4.6,6.2 L9.12944565,6.2 C9.4608165,6.2 9.72944565,6.46862915 9.72944565,6.8 C9.72944565,7.09823376 9.51185604,7.34564675 9.22676876,7.39214701 L9.12944565,7.4 L4.6,7.4 C4.26862915,7.4 4,7.13137085 4,6.8 C4,6.50176624 4.21758961,6.25435325 4.50267688,6.20785299 L4.6,6.2 L9.12944565,6.2 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n\n<ng-template #zoomInTemplate\n ><svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>action/zoom-in</title>\n <desc>Created with Sketch.</desc>\n <g id=\"action/zoom-in\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M6.85,-1.81188398e-13 C10.6331505,-1.81188398e-13 13.7,3.06684946 13.7,6.85 C13.7,8.54194045 13.0865836,10.0906098 12.0700142,11.2857448 L15.4201976,14.5717081 C15.6567367,14.8037768 15.6603607,15.1836585 15.4282919,15.4201976 C15.1962232,15.6567367 14.8163415,15.6603607 14.5798024,15.4282919 L14.5798024,15.4282919 L11.2163456,12.128262 C10.0309427,13.1099691 8.50937591,13.7 6.85,13.7 C3.06684946,13.7 4.61852778e-14,10.6331505 4.61852778e-14,6.85 C4.61852778e-14,3.06684946 3.06684946,-1.81188398e-13 6.85,-1.81188398e-13 Z M6.85,1.2 C3.72959116,1.2 1.2,3.72959116 1.2,6.85 C1.2,9.97040884 3.72959116,12.5 6.85,12.5 C8.31753357,12.5 9.65438791,11.9404957 10.6588859,11.0231643 C10.6855412,10.9625408 10.7245275,10.9050898 10.7743982,10.8542584 C10.8288931,10.7987137 10.8915387,10.7560124 10.9585649,10.7261903 C11.9144009,9.71595758 12.5,8.35136579 12.5,6.85 C12.5,3.72959116 9.97040884,1.2 6.85,1.2 Z M6.86472282,3.93527718 C7.16295659,3.93527718 7.41036958,4.15286679 7.45686984,4.43795406 L7.46472282,4.53527718 L7.464,6.19927718 L9.12944565,6.2 C9.42767941,6.2 9.6750924,6.41758961 9.72159266,6.70267688 L9.72944565,6.8 C9.72944565,7.09823376 9.51185604,7.34564675 9.22676876,7.39214701 L9.12944565,7.4 L7.464,7.39927718 L7.46472282,9.06472282 C7.46472282,9.36295659 7.24713321,9.61036958 6.96204594,9.65686984 L6.86472282,9.66472282 C6.56648906,9.66472282 6.31907607,9.44713321 6.27257581,9.16204594 L6.26472282,9.06472282 L6.264,7.39927718 L4.6,7.4 C4.30176624,7.4 4.05435325,7.18241039 4.00785299,6.89732312 L4,6.8 C4,6.50176624 4.21758961,6.25435325 4.50267688,6.20785299 L4.6,6.2 L6.264,6.19927718 L6.26472282,4.53527718 C6.26472282,4.2701805 6.43664548,4.0452385 6.67507642,3.96586557 L6.76739971,3.94313016 L6.86472282,3.93527718 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2263
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitToolbarComponent, decorators: [{
2264
- type: Component,
2265
- args: [{ selector: 'plait-toolbar', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"zoom-toolbar island plait-board-attached\">\n <a class=\"toolbar-item plait-action-icon\" [ngClass]=\"{ 'icon-active': isHand }\" (click)=\"activeHand()\">\n <ng-template [ngTemplateOutlet]=\"dragMoveTemplate\"></ng-template>\n </a>\n <div class=\"divider\"></div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"adapt()\">\n <ng-template [ngTemplateOutlet]=\"adaptTemplate\"></ng-template>\n </a>\n <div class=\"divider\"></div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"zoomOut()\">\n <ng-template [ngTemplateOutlet]=\"zoomOutTemplate\"></ng-template>\n </a>\n <div class=\"toolbar-item zoom-value\" (mousedown)=\"resetZoom()\">{{ zoom }}%</div>\n <a class=\"toolbar-item plait-action-icon\" (mousedown)=\"zoomIn()\">\n <ng-template [ngTemplateOutlet]=\"zoomInTemplate\"></ng-template>\n </a>\n</div>\n\n<ng-template #dragMoveTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/hand</title>\n <g id=\"1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/hand\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M8.44583468,0.500225887 C9.07406934,0.510185679 9.54739531,0.839591366 9.86192311,1.34305279 C9.89696656,1.39914649 9.92878401,1.45492964 9.9576026,1.50991157 L9.9576026,1.50991157 L10.0210033,1.64201027 L10.061978,1.62350755 C10.1972891,1.56834247 10.3444107,1.53218464 10.5027907,1.51755353 L10.5027907,1.51755353 L10.6649031,1.51019133 C11.4883708,1.51019133 12.0208782,1.99343346 12.3023042,2.66393278 C12.3903714,2.87392911 12.4344191,3.10047818 12.4339446,3.3257952 L12.4339446,3.3257952 L12.4360033,3.80501027 L12.5160535,3.78341501 C12.6124478,3.76124046 12.7138812,3.74739854 12.820201,3.74250274 L12.820201,3.74250274 L12.9833264,3.74194533 C13.6121166,3.7657478 14.0645887,4.0801724 14.3087062,4.56112689 C14.4521117,4.8436609 14.4987984,5.11349437 14.4999262,5.33449618 L14.4999262,5.33449618 L14.3922653,12.049414 C14.3784752,12.909177 14.0717787,13.7360948 13.5212406,14.3825228 C13.4055676,14.5183496 13.2843697,14.643961 13.1582361,14.7596335 C12.4634771,15.3967716 11.755103,15.6538706 11.1897396,15.7000055 L11.1897396,15.7000055 L7.4723083,15.6798158 C7.14276373,15.634268 6.81580098,15.5154267 6.49455235,15.3472501 C6.25643701,15.2225944 6.06881706,15.0975452 5.88705731,14.9494308 L5.88705731,14.9494308 L2.55198782,11.500873 C2.39559475,11.3769079 2.17626793,11.1748532 1.9548636,10.9139403 C1.57867502,10.4706225 1.33501976,10.0139923 1.30330257,9.52833025 C1.28093191,9.18578476 1.37200912,8.85641102 1.5826788,8.56872564 C1.82538833,8.23725279 2.12881965,8.02107162 2.47470569,7.92957033 C2.95807982,7.80169771 3.42705723,7.92468989 3.86509644,8.18731167 C4.04431391,8.29475961 4.1816109,8.40304483 4.26225571,8.47866867 L4.26225571,8.47866867 L4.61400328,8.79701027 L4.57247249,3.59275349 L4.57628524,3.46204923 C4.5897691,3.23444442 4.64087578,2.95701848 4.75937106,2.66961597 C5.01017272,2.06131302 5.49670227,1.64692543 6.21363856,1.60818786 C6.44223508,1.59583681 6.65042099,1.62176802 6.83696985,1.68057551 L6.83696985,1.68057551 L6.86400328,1.69001027 C6.88501862,1.63593052 6.90764242,1.58175442 6.9331867,1.52672633 L6.9331867,1.52672633 L7.01883595,1.35955614 C7.31549194,0.832047939 7.79476072,0.48993549 8.44583468,0.500225887 Z M8.42684173,1.70001476 C8.26825412,1.69756905 8.16339456,1.77242008 8.06478367,1.94776814 C8.03967773,1.99241107 8.01831703,2.03811495 8.00083464,2.07855067 L8.00083464,2.07855067 L7.94879157,2.2035905 L7.94354455,2.20731401 L7.943,3.161 L7.97170661,3.16123746 L7.97170661,7.60991883 L6.77170661,7.60991883 L6.771,3.338 L6.74362358,3.33880359 C6.74284189,3.29064626 6.73014163,3.20282206 6.7002616,3.11094408 L6.66446012,3.01903385 C6.58982025,2.85766739 6.49843292,2.79455071 6.27838133,2.80644008 C6.07001018,2.81769881 5.95642108,2.91444507 5.86877664,3.12702089 C5.79792279,3.29887224 5.77228127,3.48655908 5.77246879,3.58977183 L5.77246879,3.58977183 L5.83613619,11.5252021 L3.41863956,9.33477657 L3.31637296,9.25979571 L3.24805011,9.21651224 C3.06096922,9.10434987 2.89279975,9.06024641 2.78159879,9.0896637 C2.71007735,9.10858411 2.63607367,9.1613084 2.55086305,9.27768211 C2.51020424,9.33320478 2.49638061,9.38319687 2.50075171,9.4501283 C2.51206889,9.62341997 2.64503022,9.87260054 2.86983366,10.1375191 C3.03268834,10.3294345 3.19762053,10.4813781 3.35554956,10.6131022 L3.35554956,10.6131022 L6.68454317,14.0569073 C6.71106575,14.0773808 6.74806086,14.1037158 6.79369091,14.1335929 L6.79369091,14.1335929 L6.95464838,14.2315311 L7.05111031,14.2841211 C7.25978123,14.3933622 7.46253523,14.4670573 7.55685495,14.4854708 L7.55685495,14.4854708 L11.1407985,14.5022108 C11.1503576,14.5013899 11.1627905,14.4997539 11.1779002,14.4971772 L11.1779002,14.4971772 L11.2991076,14.4694224 C11.3491682,14.4557375 11.4083624,14.437284 11.4751158,14.4130563 C11.769383,14.3062543 12.066676,14.1324596 12.3471758,13.8752234 C12.4371203,13.7927386 12.5240597,13.7026333 12.607654,13.6044743 C12.9760464,13.1719172 13.183059,12.6137678 13.1924195,12.030173 L13.1924195,12.030173 L13.3000132,5.32832551 C13.2997939,5.29016685 13.2826117,5.19085946 13.2386527,5.10425262 C13.1843838,4.99733326 13.1129774,4.94771265 12.9379578,4.94108739 C12.6814739,4.93138871 12.534132,5.11189595 12.4756792,5.39480062 L12.4768718,7.52734922 L11.2768718,7.52734922 L11.276,5.688 L11.2462883,5.6883208 L11.2339541,3.32771285 C11.2341,3.2560396 11.2209054,3.18817621 11.1957482,3.12818892 C11.0820579,2.85732094 10.9199288,2.71019133 10.6649031,2.71019133 C10.456829,2.71019133 10.3197487,2.87378067 10.2524297,3.11264939 L10.2530225,7.512783 L9.05302254,7.512783 L9.053,3.288 L9.01554331,3.28724203 L8.98800328,2.29901027 L8.9629175,2.22263368 C8.94515567,2.17417174 8.92167756,2.11937748 8.8924232,2.06330056 L8.8924232,2.06330056 L8.84420197,1.9788544 C8.72758855,1.79219249 8.59915015,1.70280728 8.42684173,1.70001476 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n\n<ng-template #adaptTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/Fit canvas</title>\n <g id=\"1.Base\u57FA\u7840/1.icon\u56FE\u6807/2.normal/Fit-canvas\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M14.9971494,10.4 L14.9971494,13.4020516 C14.9971494,14.2366152 14.3581879,14.9219414 13.542782,14.9955129 L13.3971494,15.0020516 L10.4,15.0020516 L10.4,13.8020516 L13.3971494,13.8020516 C13.590449,13.8020516 13.7517243,13.6649388 13.7890228,13.4826656 L13.7971494,13.4020516 L13.7971494,10.4 L14.9971494,10.4 Z M2.2,10.4 L2.2,13.3971494 C2.2,13.590449 2.3371128,13.7517243 2.51938605,13.7890228 L2.6,13.7971494 L5.60205161,13.7971494 L5.60205161,14.9971494 L2.6,14.9971494 C1.76543638,14.9971494 1.08011021,14.3581879 1.00653868,13.542782 L1,13.3971494 L1,10.4 L2.2,10.4 Z M10.5024511,4.9 C11.3861067,4.9 12.1024511,5.6163444 12.1024511,6.5 L12.1024511,6.5 L12.1024511,9.5 C12.1024511,10.3836556 11.3861067,11.1 10.5024511,11.1 L10.5024511,11.1 L5.50245112,11.1 C4.61879552,11.1 3.90245112,10.3836556 3.90245112,9.5 L3.90245112,9.5 L3.90245112,6.5 C3.90245112,5.6163444 4.61879552,4.9 5.50245112,4.9 L5.50245112,4.9 Z M10.5024511,6.1 L5.50245112,6.1 C5.28153722,6.1 5.10245112,6.2790861 5.10245112,6.5 L5.10245112,6.5 L5.10245112,9.5 C5.10245112,9.7209139 5.28153722,9.9 5.50245112,9.9 L5.50245112,9.9 L10.5024511,9.9 C10.723365,9.9 10.9024511,9.7209139 10.9024511,9.5 L10.9024511,9.5 L10.9024511,6.5 C10.9024511,6.2790861 10.723365,6.1 10.5024511,6.1 L10.5024511,6.1 Z M5.59714938,1 L5.59714938,2.2 L2.6,2.2 C2.40670034,2.2 2.24542508,2.3371128 2.20812658,2.51938605 L2.2,2.6 L2.2,5.60205161 L1,5.60205161 L1,2.6 C1,1.76543638 1.63896152,1.08011021 2.45436739,1.00653868 L2.6,1 L5.59714938,1 Z M13.3971494,1 L13.542782,1.00653868 C14.3581879,1.08011021 14.9971494,1.76543638 14.9971494,2.6 L14.9971494,2.6 L14.9971494,5.60205161 L13.7971494,5.60205161 L13.7971494,2.6 L13.7890228,2.51938605 C13.7517243,2.3371128 13.590449,2.2 13.3971494,2.2 L13.3971494,2.2 L10.4,2.2 L10.4,1 L13.3971494,1 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n<ng-template #zoomOutTemplate>\n <svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>action/zoom-out</title>\n <desc>Created with Sketch.</desc>\n <g id=\"action/zoom-out\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M6.85,2.73225886e-13 C10.6331505,2.73225886e-13 13.7,3.06684946 13.7,6.85 C13.7,8.54194045 13.0865836,10.0906098 12.0700142,11.2857448 L15.4201976,14.5717081 C15.6567367,14.8037768 15.6603607,15.1836585 15.4282919,15.4201976 C15.1962232,15.6567367 14.8163415,15.6603607 14.5798024,15.4282919 L14.5798024,15.4282919 L11.2163456,12.128262 C10.0309427,13.1099691 8.50937591,13.7 6.85,13.7 C3.06684946,13.7 4.58522109e-14,10.6331505 4.58522109e-14,6.85 C4.58522109e-14,3.06684946 3.06684946,2.73225886e-13 6.85,2.73225886e-13 Z M6.85,1.2 C3.72959116,1.2 1.2,3.72959116 1.2,6.85 C1.2,9.97040884 3.72959116,12.5 6.85,12.5 C8.31753357,12.5 9.65438791,11.9404957 10.6588859,11.0231643 C10.6855412,10.9625408 10.7245275,10.9050898 10.7743982,10.8542584 C10.8288931,10.7987137 10.8915387,10.7560124 10.9585649,10.7261903 C11.9144009,9.71595758 12.5,8.35136579 12.5,6.85 C12.5,3.72959116 9.97040884,1.2 6.85,1.2 Z M4.6,6.2 L9.12944565,6.2 C9.4608165,6.2 9.72944565,6.46862915 9.72944565,6.8 C9.72944565,7.09823376 9.51185604,7.34564675 9.22676876,7.39214701 L9.12944565,7.4 L4.6,7.4 C4.26862915,7.4 4,7.13137085 4,6.8 C4,6.50176624 4.21758961,6.25435325 4.50267688,6.20785299 L4.6,6.2 L9.12944565,6.2 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n\n<ng-template #zoomInTemplate\n ><svg\n width=\"16px\"\n height=\"16px\"\n viewBox=\"0 0 16 16\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n >\n <title>action/zoom-in</title>\n <desc>Created with Sketch.</desc>\n <g id=\"action/zoom-in\" stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n d=\"M6.85,-1.81188398e-13 C10.6331505,-1.81188398e-13 13.7,3.06684946 13.7,6.85 C13.7,8.54194045 13.0865836,10.0906098 12.0700142,11.2857448 L15.4201976,14.5717081 C15.6567367,14.8037768 15.6603607,15.1836585 15.4282919,15.4201976 C15.1962232,15.6567367 14.8163415,15.6603607 14.5798024,15.4282919 L14.5798024,15.4282919 L11.2163456,12.128262 C10.0309427,13.1099691 8.50937591,13.7 6.85,13.7 C3.06684946,13.7 4.61852778e-14,10.6331505 4.61852778e-14,6.85 C4.61852778e-14,3.06684946 3.06684946,-1.81188398e-13 6.85,-1.81188398e-13 Z M6.85,1.2 C3.72959116,1.2 1.2,3.72959116 1.2,6.85 C1.2,9.97040884 3.72959116,12.5 6.85,12.5 C8.31753357,12.5 9.65438791,11.9404957 10.6588859,11.0231643 C10.6855412,10.9625408 10.7245275,10.9050898 10.7743982,10.8542584 C10.8288931,10.7987137 10.8915387,10.7560124 10.9585649,10.7261903 C11.9144009,9.71595758 12.5,8.35136579 12.5,6.85 C12.5,3.72959116 9.97040884,1.2 6.85,1.2 Z M6.86472282,3.93527718 C7.16295659,3.93527718 7.41036958,4.15286679 7.45686984,4.43795406 L7.46472282,4.53527718 L7.464,6.19927718 L9.12944565,6.2 C9.42767941,6.2 9.6750924,6.41758961 9.72159266,6.70267688 L9.72944565,6.8 C9.72944565,7.09823376 9.51185604,7.34564675 9.22676876,7.39214701 L9.12944565,7.4 L7.464,7.39927718 L7.46472282,9.06472282 C7.46472282,9.36295659 7.24713321,9.61036958 6.96204594,9.65686984 L6.86472282,9.66472282 C6.56648906,9.66472282 6.31907607,9.44713321 6.27257581,9.16204594 L6.26472282,9.06472282 L6.264,7.39927718 L4.6,7.4 C4.30176624,7.4 4.05435325,7.18241039 4.00785299,6.89732312 L4,6.8 C4,6.50176624 4.21758961,6.25435325 4.50267688,6.20785299 L4.6,6.2 L6.264,6.19927718 L6.26472282,4.53527718 C6.26472282,4.2701805 6.43664548,4.0452385 6.67507642,3.96586557 L6.76739971,3.94313016 L6.86472282,3.93527718 Z\"\n id=\"\u5F62\u72B6\u7ED3\u5408\"\n fill-rule=\"nonzero\"\n ></path>\n </g>\n </svg>\n</ng-template>\n" }]
2266
- }], propDecorators: { hostClass: [{
2267
- type: HostBinding,
2268
- args: ['class']
2269
- }], board: [{
2270
- type: Input
2271
- }], adaptHandle: [{
2272
- type: Output
2273
- }], zoomInHandle: [{
2274
- type: Output
2275
- }], zoomOutHandle: [{
2276
- type: Output
2277
- }], resetZoomHandel: [{
2278
- type: Output
2279
- }] } });
2280
-
2281
2320
  const ElementHostClass = 'element-host';
2282
2321
  class PlaitBoardComponent {
2283
2322
  get host() {
@@ -2337,11 +2376,15 @@ class PlaitBoardComponent {
2337
2376
  viewport: this.board.viewport,
2338
2377
  selection: this.board.selection
2339
2378
  };
2379
+ this.updateIslands();
2340
2380
  this.plaitChange.emit(changeEvent);
2341
2381
  });
2342
2382
  });
2343
2383
  this.hasInitialized = true;
2344
2384
  }
2385
+ ngAfterContentInit() {
2386
+ this.initializeIslands();
2387
+ }
2345
2388
  detect() {
2346
2389
  this.effect = {};
2347
2390
  this.cdr.detectChanges();
@@ -2364,7 +2407,7 @@ class PlaitBoardComponent {
2364
2407
  initializeViewportOffset(this.board);
2365
2408
  }
2366
2409
  initializePlugins() {
2367
- let board = withHandPointer(withHistory(withSelection(withMoving(withBoard(withViewport(createBoard(this.plaitValue, this.plaitOptions)))))));
2410
+ let board = withHandPointer(withHistory(withSelection(withMoving(withBoard(withViewport(withOptions(createBoard(this.plaitValue, this.plaitOptions))))))));
2368
2411
  this.plaitPlugins.forEach(plugin => {
2369
2412
  board = plugin(board);
2370
2413
  });
@@ -2406,16 +2449,19 @@ class PlaitBoardComponent {
2406
2449
  this.board.dblclick(event);
2407
2450
  });
2408
2451
  fromEvent(document, 'keydown')
2409
- .pipe(takeUntil(this.destroy$), filter(event => this.isFocused && !PlaitBoard.hasBeenTextEditing(this.board) && !hasInputOrTextareaTarget(event.target)))
2410
- .subscribe((event) => {
2411
- if (isHotkey(['mod+=', 'mod++'], { byKey: true })(event)) {
2412
- event.preventDefault();
2413
- this.zoomInHandle(false);
2414
- }
2415
- if (isHotkey('mod+-', { byKey: true })(event)) {
2416
- this.zoomOutHandle();
2417
- event.preventDefault();
2452
+ .pipe(takeUntil(this.destroy$), tap((event) => {
2453
+ if (PlaitBoard.getMovingPoint(this.board)) {
2454
+ if (isHotkey(['mod+=', 'mod++'], { byKey: true })(event)) {
2455
+ event.preventDefault();
2456
+ BoardTransforms.updateZoom(this.board, this.board.viewport.zoom + 0.1, false);
2457
+ }
2458
+ if (isHotkey('mod+-', { byKey: true })(event)) {
2459
+ event.preventDefault();
2460
+ BoardTransforms.updateZoom(this.board, this.board.viewport.zoom - 0.1);
2461
+ }
2418
2462
  }
2463
+ }), filter(event => this.isFocused && !PlaitBoard.hasBeenTextEditing(this.board) && !hasInputOrTextareaTarget(event.target)))
2464
+ .subscribe((event) => {
2419
2465
  this.board?.keydown(event);
2420
2466
  });
2421
2467
  fromEvent(document, 'keyup')
@@ -2465,7 +2511,7 @@ class PlaitBoardComponent {
2465
2511
  if (Point.isEquals(origination, this.board.viewport.origination)) {
2466
2512
  return;
2467
2513
  }
2468
- setViewport(this.board, origination);
2514
+ BoardTransforms.updateViewport(this.board, origination);
2469
2515
  setIsFromScrolling(this.board, true);
2470
2516
  });
2471
2517
  });
@@ -2485,17 +2531,18 @@ class PlaitBoardComponent {
2485
2531
  BOARD_TO_MOVING_POINT.delete(this.board);
2486
2532
  });
2487
2533
  }
2488
- adaptHandle() {
2489
- fitViewport(this.board);
2490
- }
2491
- zoomInHandle(isCenter = true) {
2492
- changeZoom(this.board, this.board.viewport.zoom + 0.1, isCenter);
2493
- }
2494
- zoomOutHandle() {
2495
- changeZoom(this.board, this.board.viewport.zoom - 0.1);
2534
+ initializeIslands() {
2535
+ this.islands?.forEach(island => {
2536
+ island.initialize(this.board);
2537
+ });
2496
2538
  }
2497
- resetZoomHandel() {
2498
- changeZoom(this.board, 1);
2539
+ updateIslands() {
2540
+ this.islands?.forEach(island => {
2541
+ if (hasOnBoardChange(island)) {
2542
+ island.onBoardChange();
2543
+ }
2544
+ island.markForCheck();
2545
+ });
2499
2546
  }
2500
2547
  ngOnDestroy() {
2501
2548
  this.destroy$.next();
@@ -2510,25 +2557,20 @@ class PlaitBoardComponent {
2510
2557
  }
2511
2558
  markForCheck() {
2512
2559
  this.cdr.markForCheck();
2560
+ this.ngZone.run(() => {
2561
+ this.updateIslands();
2562
+ });
2513
2563
  }
2514
2564
  }
2515
- PlaitBoardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitBoardComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ViewContainerRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
2516
- PlaitBoardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.2", type: PlaitBoardComponent, selector: "plait-board", inputs: { plaitValue: "plaitValue", plaitViewport: "plaitViewport", plaitPlugins: "plaitPlugins", plaitOptions: "plaitOptions" }, outputs: { plaitChange: "plaitChange", plaitBoardInitialized: "plaitBoardInitialized" }, host: { properties: { "class": "this.hostClass", "class.readonly": "this.readonly", "class.focused": "this.isFocused" } }, queries: [{ propertyName: "toolbarTemplateRef", first: true, predicate: ["plaitToolbar"], descendants: true }], viewQueries: [{ propertyName: "svg", first: true, predicate: ["svg"], descendants: true, static: true }, { propertyName: "viewportContainer", first: true, predicate: ["viewportContainer"], descendants: true, read: ElementRef, static: true }], usesOnChanges: true, ngImport: i0, template: `
2565
+ PlaitBoardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitBoardComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ViewContainerRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
2566
+ PlaitBoardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: PlaitBoardComponent, selector: "plait-board", inputs: { plaitValue: "plaitValue", plaitViewport: "plaitViewport", plaitPlugins: "plaitPlugins", plaitOptions: "plaitOptions" }, outputs: { plaitChange: "plaitChange", plaitBoardInitialized: "plaitBoardInitialized" }, host: { properties: { "class": "this.hostClass", "class.readonly": "this.readonly", "class.focused": "this.isFocused" } }, queries: [{ propertyName: "islands", predicate: PlaitIslandBaseComponent, descendants: true }], viewQueries: [{ propertyName: "svg", first: true, predicate: ["svg"], descendants: true, static: true }, { propertyName: "viewportContainer", first: true, predicate: ["viewportContainer"], descendants: true, read: ElementRef, static: true }], usesOnChanges: true, ngImport: i0, template: `
2517
2567
  <div class="viewport-container" #viewportContainer>
2518
2568
  <svg #svg width="100%" height="100%" style="position: relative;"><g class="element-host"></g></svg>
2519
2569
  <plait-children [board]="board" [effect]="effect"></plait-children>
2520
2570
  </div>
2521
- <plait-toolbar
2522
- *ngIf="isFocused && !toolbarTemplateRef"
2523
- [board]="board"
2524
- (adaptHandle)="adaptHandle()"
2525
- (zoomInHandle)="zoomInHandle()"
2526
- (zoomOutHandle)="zoomOutHandle()"
2527
- (resetZoomHandel)="resetZoomHandel()"
2528
- ></plait-toolbar>
2529
2571
  <ng-content></ng-content>
2530
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: PlaitChildrenElement, selector: "plait-children", inputs: ["board", "parent", "effect", "parentG"] }, { kind: "component", type: PlaitToolbarComponent, selector: "plait-toolbar", inputs: ["board"], outputs: ["adaptHandle", "zoomInHandle", "zoomOutHandle", "resetZoomHandel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2531
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitBoardComponent, decorators: [{
2572
+ `, isInline: true, dependencies: [{ kind: "component", type: PlaitChildrenElement, selector: "plait-children", inputs: ["board", "parent", "effect", "parentG"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2573
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitBoardComponent, decorators: [{
2532
2574
  type: Component,
2533
2575
  args: [{
2534
2576
  selector: 'plait-board',
@@ -2537,14 +2579,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImpor
2537
2579
  <svg #svg width="100%" height="100%" style="position: relative;"><g class="element-host"></g></svg>
2538
2580
  <plait-children [board]="board" [effect]="effect"></plait-children>
2539
2581
  </div>
2540
- <plait-toolbar
2541
- *ngIf="isFocused && !toolbarTemplateRef"
2542
- [board]="board"
2543
- (adaptHandle)="adaptHandle()"
2544
- (zoomInHandle)="zoomInHandle()"
2545
- (zoomOutHandle)="zoomOutHandle()"
2546
- (resetZoomHandel)="resetZoomHandel()"
2547
- ></plait-toolbar>
2548
2582
  <ng-content></ng-content>
2549
2583
  `,
2550
2584
  changeDetection: ChangeDetectionStrategy.OnPush
@@ -2573,21 +2607,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImpor
2573
2607
  }], svg: [{
2574
2608
  type: ViewChild,
2575
2609
  args: ['svg', { static: true }]
2576
- }], toolbarTemplateRef: [{
2577
- type: ContentChild,
2578
- args: ['plaitToolbar']
2579
2610
  }], viewportContainer: [{
2580
2611
  type: ViewChild,
2581
2612
  args: ['viewportContainer', { read: ElementRef, static: true }]
2613
+ }], islands: [{
2614
+ type: ContentChildren,
2615
+ args: [PlaitIslandBaseComponent, { descendants: true }]
2582
2616
  }] } });
2583
2617
 
2584
- const COMPONENTS = [PlaitBoardComponent, PlaitChildrenElement, PlaitElementComponent, PlaitToolbarComponent];
2618
+ const COMPONENTS = [PlaitBoardComponent, PlaitChildrenElement, PlaitElementComponent];
2585
2619
  class PlaitModule {
2586
2620
  }
2587
- PlaitModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2588
- PlaitModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.2", ngImport: i0, type: PlaitModule, declarations: [PlaitBoardComponent, PlaitChildrenElement, PlaitElementComponent, PlaitToolbarComponent], imports: [CommonModule], exports: [PlaitBoardComponent, PlaitChildrenElement, PlaitElementComponent, PlaitToolbarComponent] });
2589
- PlaitModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitModule, imports: [CommonModule] });
2590
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitModule, decorators: [{
2621
+ PlaitModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2622
+ PlaitModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, declarations: [PlaitBoardComponent, PlaitChildrenElement, PlaitElementComponent], imports: [CommonModule], exports: [PlaitBoardComponent, PlaitChildrenElement, PlaitElementComponent] });
2623
+ PlaitModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, imports: [CommonModule] });
2624
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, decorators: [{
2591
2625
  type: NgModule,
2592
2626
  args: [{
2593
2627
  declarations: [...COMPONENTS],
@@ -2633,5 +2667,5 @@ const clearNodeWeakMap = (object) => {
2633
2667
  * Generated bundle index. Do not edit.
2634
2668
  */
2635
2669
 
2636
- export { BOARD_TO_COMPONENT, BOARD_TO_ELEMENT_HOST, BOARD_TO_HOST, BOARD_TO_IS_SELECTION_MOVING, BOARD_TO_MOVING_ELEMENT, BOARD_TO_MOVING_POINT, BOARD_TO_ON_CHANGE, BOARD_TO_ROUGH_SVG, BOARD_TO_SELECTED_ELEMENT, BOARD_TO_TEMPORARY_ELEMENTS, BOARD_TO_VIEWPORT_ORIGINATION, BoardTransforms, CLIP_BOARD_FORMAT_KEY, ELEMENT_TO_COMPONENT, FLUSHING, IS_APPLE, IS_BOARD_CACHE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_FIREFOX, IS_IOS, IS_SAFARI, IS_TEXT_EDITABLE, MAX_RADIUS, MERGING, NODE_TO_INDEX, NODE_TO_PARENT, NS, PATH_REFS, Path, PlaitBoard, PlaitBoardComponent, PlaitChildrenElement, PlaitElement, PlaitElementComponent, PlaitHistoryBoard, PlaitModule, PlaitNode, PlaitOperation, PlaitPluginElementComponent, PlaitPointerType, PlaitToolbarComponent, Point, RectangleClient, SAVING, SCROLL_BAR_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, Selection, Transforms, Viewport, addMovingElements, addSelectedElement, arrowPoints, cacheMovingElements, cacheSelectedElements, changeZoom, clampZoomLevel, clearNodeWeakMap, clearSelectedElement, clearSelectionMoving, clearViewportOrigination, createForeignObject, createG, createSVG, createSelectionOuterG, createTestingBoard, createText, debounce, deleteTemporaryElements, depthFirstRecursion, distanceBetweenPointAndPoint, distanceBetweenPointAndRectangle, distanceBetweenPointAndSegment, drawAbstractRoundRectangle, drawArrow, drawCircle, drawLine, drawRoundRectangle, fakeNodeWeakMap, fitViewport, getBoardRectangle, getElementHostBBox, getHitElements, getMovingElements, getRectangleByElements, getSelectedElements, getTemporaryElements, getViewBox, getViewportContainerRect, getViewportOrigination, hasBeforeContextChange, hasInputOrTextareaTarget, hasOnContextChanged, hotkeys, idCreator, initializeViewBox, initializeViewportContainer, initializeViewportOffset, inverse, isDOMElement, isDOMNode, isFromScrolling, isFromViewportChange, isInPlaitBoard, isIntersectionElements, isNullOrUndefined, isSelectedElement, isSelectionMoving, isSetViewportOperation, normalizePoint, removeMovingElements, removeSelectedElement, rotate, scrollToRectangle, setIsFromScrolling, setIsFromViewportChange, setSVGViewBox, setSelectionMoving, setViewport, shouldClear, shouldMerge, shouldSave, throttleRAF, toPoint, transformPoint, transformPoints, updateForeignObject, updateViewportContainerScroll, updateViewportOffset, updateViewportOrigination, withMoving, withSelection };
2670
+ export { BOARD_TO_COMPONENT, BOARD_TO_ELEMENT_HOST, BOARD_TO_HOST, BOARD_TO_IS_SELECTION_MOVING, BOARD_TO_MOVING_ELEMENT, BOARD_TO_MOVING_POINT, BOARD_TO_ON_CHANGE, BOARD_TO_ROUGH_SVG, BOARD_TO_SELECTED_ELEMENT, BOARD_TO_TEMPORARY_ELEMENTS, BOARD_TO_VIEWPORT_ORIGINATION, BoardTransforms, CLIP_BOARD_FORMAT_KEY, ELEMENT_TO_COMPONENT, FLUSHING, IS_APPLE, IS_BOARD_CACHE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_FIREFOX, IS_IOS, IS_SAFARI, IS_TEXT_EDITABLE, MAX_RADIUS, MERGING, NODE_TO_INDEX, NODE_TO_PARENT, NS, PATH_REFS, POINTER_BUTTON, Path, PlaitBoard, PlaitBoardComponent, PlaitChildrenElement, PlaitElement, PlaitElementComponent, PlaitHistoryBoard, PlaitIslandBaseComponent, PlaitModule, PlaitNode, PlaitOperation, PlaitPluginElementComponent, PlaitPluginKey, PlaitPointerType, Point, RectangleClient, SAVING, SCROLL_BAR_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, Selection, Transforms, Viewport, addMovingElements, addSelectedElement, arrowPoints, cacheMovingElements, cacheSelectedElements, clampZoomLevel, clearNodeWeakMap, clearSelectedElement, clearSelectionMoving, clearViewportOrigination, createForeignObject, createG, createPath, createSVG, createSelectionOuterG, createTestingBoard, createText, debounce, deleteTemporaryElements, depthFirstRecursion, distanceBetweenPointAndPoint, distanceBetweenPointAndRectangle, distanceBetweenPointAndSegment, drawAbstractRoundRectangle, drawArrow, drawCircle, drawLine, drawLinearPath, drawRoundRectangle, fakeNodeWeakMap, getBoardRectangle, getElementHostBBox, getHitElements, getMovingElements, getRectangleByElements, getSelectedElements, getTemporaryElements, getViewBox, getViewportContainerRect, getViewportOrigination, hasBeforeContextChange, hasInputOrTextareaTarget, hasOnBoardChange, hasOnContextChanged, hotkeys, idCreator, initializeViewBox, initializeViewportContainer, initializeViewportOffset, inverse, isDOMElement, isDOMNode, isFromScrolling, isFromViewportChange, isInPlaitBoard, isIntersectionElements, isMainPointer, isNullOrUndefined, isSecondaryPointer, isSelectedElement, isSelectionMoving, isSetViewportOperation, normalizePoint, removeMovingElements, removeSelectedElement, rotate, scrollToRectangle, setIsFromScrolling, setIsFromViewportChange, setSVGViewBox, setSelectionMoving, shouldClear, shouldMerge, shouldSave, throttleRAF, toPoint, transformPoint, transformPoints, updateForeignObject, updateViewportContainerScroll, updateViewportOffset, updateViewportOrigination, withMoving, withOptions, withSelection };
2637
2671
  //# sourceMappingURL=plait-core.mjs.map