@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';
@@ -580,12 +580,74 @@ function setSelectionWithTemporaryElements(board, elements) {
580
580
  });
581
581
  }
582
582
 
583
- function setViewport$1(board, viewport) {
583
+ function setViewport(board, viewport) {
584
584
  const operation = { type: 'set_viewport', properties: board.viewport, newProperties: viewport };
585
585
  board.apply(operation);
586
586
  }
587
587
  const ViewportTransforms = {
588
- setViewport: setViewport$1
588
+ setViewport
589
+ };
590
+
591
+ const CLIP_BOARD_FORMAT_KEY = 'x-plait-fragment';
592
+ const SCROLL_BAR_WIDTH = 20;
593
+ const MAX_RADIUS = 16;
594
+ const POINTER_BUTTON = {
595
+ MAIN: 0,
596
+ WHEEL: 1,
597
+ SECONDARY: 2,
598
+ TOUCH: -1,
599
+ };
600
+
601
+ const NS = 'http://www.w3.org/2000/svg';
602
+ function toPoint(x, y, container) {
603
+ const rect = container.getBoundingClientRect();
604
+ return [x - rect.x, y - rect.y];
605
+ }
606
+ function createG() {
607
+ const newG = document.createElementNS(NS, 'g');
608
+ return newG;
609
+ }
610
+ function createPath() {
611
+ const newG = document.createElementNS(NS, 'path');
612
+ return newG;
613
+ }
614
+ function createSVG() {
615
+ const svg = document.createElementNS(NS, 'svg');
616
+ return svg;
617
+ }
618
+ function createText(x, y, fill, textContent) {
619
+ var text = document.createElementNS(NS, 'text');
620
+ text.setAttribute('x', `${x}`);
621
+ text.setAttribute('y', `${y}`);
622
+ text.setAttribute('fill', fill);
623
+ text.textContent = textContent;
624
+ return text;
625
+ }
626
+ /**
627
+ * Check if a DOM node is an element node.
628
+ */
629
+ const isDOMElement = (value) => {
630
+ return isDOMNode(value) && value.nodeType === 1;
631
+ };
632
+ /**
633
+ * Check if a value is a DOM node.
634
+ */
635
+ const isDOMNode = (value) => {
636
+ return value instanceof window.Node;
637
+ };
638
+ const hasInputOrTextareaTarget = (target) => {
639
+ if (isDOMElement(target)) {
640
+ if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') {
641
+ return true;
642
+ }
643
+ }
644
+ return false;
645
+ };
646
+ const isSecondaryPointer = (event) => {
647
+ return event.button === POINTER_BUTTON.SECONDARY;
648
+ };
649
+ const isMainPointer = (event) => {
650
+ return event.button === POINTER_BUTTON.MAIN;
589
651
  };
590
652
 
591
653
  // https://stackoverflow.com/a/6853926/232122
@@ -636,100 +698,6 @@ function distanceBetweenPointAndRectangle(x, y, rect) {
636
698
  return Math.sqrt(dx * dx + dy * dy);
637
699
  }
638
700
 
639
- function transformPoints(board, points) {
640
- const newPoints = points.map(point => {
641
- return transformPoint(board, point);
642
- });
643
- return newPoints;
644
- }
645
- function transformPoint(board, point) {
646
- const { width, height } = PlaitBoard.getHost(board).getBoundingClientRect();
647
- const viewBox = PlaitBoard.getHost(board).viewBox.baseVal;
648
- const x = (point[0] / width) * viewBox.width + viewBox.x;
649
- const y = (point[1] / height) * viewBox.height + viewBox.y;
650
- const newPoint = [x, y];
651
- return newPoint;
652
- }
653
- function isInPlaitBoard(board, x, y) {
654
- const plaitBoardElement = PlaitBoard.getBoardNativeElement(board);
655
- const plaitBoardRect = plaitBoardElement.getBoundingClientRect();
656
- const distances = distanceBetweenPointAndRectangle(x, y, plaitBoardRect);
657
- return distances === 0;
658
- }
659
-
660
- const NS = 'http://www.w3.org/2000/svg';
661
- function toPoint(x, y, container) {
662
- const rect = container.getBoundingClientRect();
663
- return [x - rect.x, y - rect.y];
664
- }
665
- function createG() {
666
- const newG = document.createElementNS(NS, 'g');
667
- return newG;
668
- }
669
- function createSVG() {
670
- const svg = document.createElementNS(NS, 'svg');
671
- return svg;
672
- }
673
- function createText(x, y, fill, textContent) {
674
- var text = document.createElementNS(NS, 'text');
675
- text.setAttribute('x', `${x}`);
676
- text.setAttribute('y', `${y}`);
677
- text.setAttribute('fill', fill);
678
- text.textContent = textContent;
679
- return text;
680
- }
681
- /**
682
- * Check if a DOM node is an element node.
683
- */
684
- const isDOMElement = (value) => {
685
- return isDOMNode(value) && value.nodeType === 1;
686
- };
687
- /**
688
- * Check if a value is a DOM node.
689
- */
690
- const isDOMNode = (value) => {
691
- return value instanceof window.Node;
692
- };
693
- const hasInputOrTextareaTarget = (target) => {
694
- if (isDOMElement(target)) {
695
- if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA') {
696
- return true;
697
- }
698
- }
699
- return false;
700
- };
701
-
702
- function createForeignObject(x, y, width, height) {
703
- var newForeignObject = document.createElementNS(NS, 'foreignObject');
704
- newForeignObject.setAttribute('x', `${x}`);
705
- newForeignObject.setAttribute('y', `${y}`);
706
- newForeignObject.setAttribute('width', `${width}`);
707
- newForeignObject.setAttribute('height', `${height}`);
708
- return newForeignObject;
709
- }
710
- function updateForeignObject(g, width, height, x, y) {
711
- const foreignObject = g.querySelector('foreignObject');
712
- if (foreignObject) {
713
- foreignObject.setAttribute('width', `${width}`);
714
- foreignObject.setAttribute('height', `${height}`);
715
- foreignObject.setAttribute('x', `${x}`);
716
- foreignObject.setAttribute('y', `${y}`);
717
- }
718
- }
719
-
720
- const IS_IOS = typeof navigator !== 'undefined' &&
721
- typeof window !== 'undefined' &&
722
- /iPad|iPhone|iPod/.test(navigator.userAgent) &&
723
- !window.MSStream;
724
- const IS_APPLE = typeof navigator !== 'undefined' && /Mac OS X/.test(navigator.userAgent);
725
- const IS_FIREFOX = typeof navigator !== 'undefined' && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
726
- const IS_SAFARI = typeof navigator !== 'undefined' && /Version\/[\d\.]+.*Safari/.test(navigator.userAgent);
727
- // "modern" Edge was released at 79.x
728
- const IS_EDGE_LEGACY = typeof navigator !== 'undefined' && /Edge?\/(?:[0-6][0-9]|[0-7][0-8])/i.test(navigator.userAgent);
729
- const IS_CHROME = typeof navigator !== 'undefined' && /Chrome/i.test(navigator.userAgent);
730
- // Native beforeInput events don't work well with react on Chrome 75 and older, Chrome 76+ can use beforeInput
731
- const IS_CHROME_LEGACY = typeof navigator !== 'undefined' && /Chrome?\/(?:[0-7][0-5]|[0-6][0-9])/i.test(navigator.userAgent);
732
-
733
701
  const getHitElements = (board, selection) => {
734
702
  const realSelection = selection || board.selection;
735
703
  const selectedElements = [];
@@ -860,158 +828,66 @@ class PlaitPluginElementComponent {
860
828
  (this.rootG || this.g).remove();
861
829
  }
862
830
  }
863
- PlaitPluginElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitPluginElementComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
864
- PlaitPluginElementComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.2", type: PlaitPluginElementComponent, inputs: { context: "context" }, ngImport: i0 });
865
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitPluginElementComponent, decorators: [{
831
+ PlaitPluginElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitPluginElementComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
832
+ PlaitPluginElementComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: PlaitPluginElementComponent, inputs: { context: "context" }, ngImport: i0 });
833
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitPluginElementComponent, decorators: [{
866
834
  type: Directive
867
835
  }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { context: [{
868
836
  type: Input
869
837
  }] } });
870
838
  const ELEMENT_TO_COMPONENT = new WeakMap();
871
839
 
872
- const PlaitElement = {
873
- isRootElement(value) {
874
- const parent = NODE_TO_PARENT.get(value);
875
- if (parent && PlaitBoard.isBoard(parent)) {
876
- return true;
877
- }
878
- else {
879
- return false;
880
- }
881
- },
882
- getComponent(value) {
883
- return ELEMENT_TO_COMPONENT.get(value);
884
- }
885
- };
886
-
887
- const RectangleClient = {
888
- isHit: (origin, target) => {
889
- const minX = origin.x < target.x ? origin.x : target.x;
890
- const maxX = origin.x + origin.width > target.x + target.width ? origin.x + origin.width : target.x + target.width;
891
- const minY = origin.y < target.y ? origin.y : target.y;
892
- const maxY = origin.y + origin.height > target.y + target.height ? origin.y + origin.height : target.y + target.height;
893
- // float calculate error( eg: 1.4210854715202004e-14 > 0)
894
- if (Math.floor(maxX - minX - origin.width - target.width) <= 0 && Math.floor(maxY - minY - origin.height - target.height) <= 0) {
895
- return true;
896
- }
897
- else {
898
- return false;
899
- }
900
- },
901
- toRectangleClient: (points) => {
902
- const xArray = points.map(ele => ele[0]);
903
- const yArray = points.map(ele => ele[1]);
904
- const xMin = Math.min(...xArray);
905
- const xMax = Math.max(...xArray);
906
- const yMin = Math.min(...yArray);
907
- const yMax = Math.max(...yArray);
908
- const rect = { x: xMin, y: yMin, width: xMax - xMin, height: yMax - yMin };
909
- return rect;
910
- },
911
- getOutlineRectangle: (rectangle, offset) => {
912
- return {
913
- x: rectangle.x + offset,
914
- y: rectangle.y + offset,
915
- width: rectangle.width + Math.abs(offset) * 2,
916
- height: rectangle.height + Math.abs(offset) * 2
917
- };
918
- },
919
- isEqual: (rectangle, otherRectangle) => {
920
- return (rectangle.x === otherRectangle.x &&
921
- rectangle.y === otherRectangle.y &&
922
- rectangle.width === otherRectangle.width &&
923
- rectangle.height === otherRectangle.height);
924
- }
925
- };
926
-
927
- const isSetViewportOperation = (value) => {
928
- return value.type === 'set_viewport';
929
- };
930
- const inverse = (op) => {
931
- switch (op.type) {
932
- case 'insert_node': {
933
- return Object.assign(Object.assign({}, op), { type: 'remove_node' });
934
- }
935
- case 'remove_node': {
936
- return Object.assign(Object.assign({}, op), { type: 'insert_node' });
937
- }
938
- case 'move_node': {
939
- const { newPath, path } = op;
940
- // PERF: in this case the move operation is a no-op anyways.
941
- if (Path.equals(newPath, path)) {
942
- return op;
943
- }
944
- // when operation path is [0,0] -> [0,2], should exec Path.transform to get [0,1] -> [0,0]
945
- // shoud not return [0,2] -> [0,0] #WIK-8981
946
- // if (Path.isSibling(path, newPath)) {
947
- // return { ...op, path: newPath, newPath: path };
948
- // }
949
- // If the move does not happen within a single parent it is possible
950
- // for the move to impact the true path to the location where the node
951
- // was removed from and where it was inserted. We have to adjust for this
952
- // and find the original path. We can accomplish this (only in non-sibling)
953
- // moves by looking at the impact of the move operation on the node
954
- // after the original move path.
955
- const inversePath = Path.transform(path, op);
956
- const inverseNewPath = Path.transform(Path.next(path), op);
957
- return Object.assign(Object.assign({}, op), { path: inversePath, newPath: inverseNewPath });
958
- }
959
- case 'set_node': {
960
- const { properties, newProperties } = op;
961
- return Object.assign(Object.assign({}, op), { properties: newProperties, newProperties: properties });
962
- }
963
- case 'set_selection': {
964
- const { properties, newProperties } = op;
965
- if (properties == null) {
966
- return Object.assign(Object.assign({}, op), { properties: newProperties, newProperties: null });
967
- }
968
- else if (newProperties == null) {
969
- return Object.assign(Object.assign({}, op), { properties: null, newProperties: properties });
970
- }
971
- else {
972
- return Object.assign(Object.assign({}, op), { properties: newProperties, newProperties: properties });
973
- }
974
- }
975
- case 'set_viewport': {
976
- const { properties, newProperties } = op;
977
- if (properties == null) {
978
- return Object.assign(Object.assign({}, op), { properties: newProperties, newProperties: newProperties });
979
- }
980
- else if (newProperties == null) {
981
- return Object.assign(Object.assign({}, op), { properties: properties, newProperties: properties });
982
- }
983
- else {
984
- return Object.assign(Object.assign({}, op), { properties: newProperties, newProperties: properties });
985
- }
986
- }
987
- }
988
- };
989
- const PlaitOperation = {
990
- isSetViewportOperation,
991
- inverse
992
- };
993
-
994
- const Point = {
995
- isEquals(point, otherPoint) {
996
- return point && otherPoint && point[0] === otherPoint[0] && point[1] === otherPoint[1];
997
- }
998
- };
840
+ function transformPoints(board, points) {
841
+ const newPoints = points.map(point => {
842
+ return transformPoint(board, point);
843
+ });
844
+ return newPoints;
845
+ }
846
+ function transformPoint(board, point) {
847
+ const { width, height } = PlaitBoard.getHost(board).getBoundingClientRect();
848
+ const viewBox = PlaitBoard.getHost(board).viewBox.baseVal;
849
+ const x = (point[0] / width) * viewBox.width + viewBox.x;
850
+ const y = (point[1] / height) * viewBox.height + viewBox.y;
851
+ const newPoint = [x, y];
852
+ return newPoint;
853
+ }
854
+ function isInPlaitBoard(board, x, y) {
855
+ const plaitBoardElement = PlaitBoard.getBoardNativeElement(board);
856
+ const plaitBoardRect = plaitBoardElement.getBoundingClientRect();
857
+ const distances = distanceBetweenPointAndRectangle(x, y, plaitBoardRect);
858
+ return distances === 0;
859
+ }
999
860
 
1000
- const SELECTION_BORDER_COLOR = '#6698FF';
1001
- const SELECTION_FILL_COLOR = '#6698FF19'; // 主色 0.1 透明度
1002
- const Selection = {
1003
- isCollapsed(selection) {
1004
- if (selection.anchor[0] == selection.focus[0] && selection.anchor[1] === selection.focus[1]) {
1005
- return true;
1006
- }
1007
- else {
1008
- return false;
1009
- }
861
+ function createForeignObject(x, y, width, height) {
862
+ var newForeignObject = document.createElementNS(NS, 'foreignObject');
863
+ newForeignObject.setAttribute('x', `${x}`);
864
+ newForeignObject.setAttribute('y', `${y}`);
865
+ newForeignObject.setAttribute('width', `${width}`);
866
+ newForeignObject.setAttribute('height', `${height}`);
867
+ return newForeignObject;
868
+ }
869
+ function updateForeignObject(g, width, height, x, y) {
870
+ const foreignObject = g.querySelector('foreignObject');
871
+ if (foreignObject) {
872
+ foreignObject.setAttribute('width', `${width}`);
873
+ foreignObject.setAttribute('height', `${height}`);
874
+ foreignObject.setAttribute('x', `${x}`);
875
+ foreignObject.setAttribute('y', `${y}`);
1010
876
  }
1011
- };
877
+ }
1012
878
 
1013
- const SAVING = new WeakMap();
1014
- const MERGING = new WeakMap();
879
+ const IS_IOS = typeof navigator !== 'undefined' &&
880
+ typeof window !== 'undefined' &&
881
+ /iPad|iPhone|iPod/.test(navigator.userAgent) &&
882
+ !window.MSStream;
883
+ const IS_APPLE = typeof navigator !== 'undefined' && /Mac OS X/.test(navigator.userAgent);
884
+ const IS_FIREFOX = typeof navigator !== 'undefined' && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
885
+ const IS_SAFARI = typeof navigator !== 'undefined' && /Version\/[\d\.]+.*Safari/.test(navigator.userAgent);
886
+ // "modern" Edge was released at 79.x
887
+ const IS_EDGE_LEGACY = typeof navigator !== 'undefined' && /Edge?\/(?:[0-6][0-9]|[0-7][0-8])/i.test(navigator.userAgent);
888
+ const IS_CHROME = typeof navigator !== 'undefined' && /Chrome/i.test(navigator.userAgent);
889
+ // Native beforeInput events don't work well with react on Chrome 75 and older, Chrome 76+ can use beforeInput
890
+ const IS_CHROME_LEGACY = typeof navigator !== 'undefined' && /Chrome?\/(?:[0-7][0-5]|[0-6][0-9])/i.test(navigator.userAgent);
1015
891
 
1016
892
  /**
1017
893
  * Check whether to merge an operation into the previous operation.
@@ -1181,10 +1057,6 @@ function idCreator(length = 5) {
1181
1057
  return key;
1182
1058
  }
1183
1059
 
1184
- const CLIP_BOARD_FORMAT_KEY = 'x-plait-fragment';
1185
- const SCROLL_BAR_WIDTH = 20;
1186
- const MAX_RADIUS = 16;
1187
-
1188
1060
  /**
1189
1061
  * drawRoundRectangle
1190
1062
  */
@@ -1230,54 +1102,269 @@ function drawAbstractRoundRectangle(rs, x1, y1, x2, y2, isHorizontal, options) {
1230
1102
  l0,-${sideLine}
1231
1103
  a${radius},${radius},0,0,1,${radius},-${radius}`, options);
1232
1104
  }
1233
- else {
1234
- const handleSideLine = (height - handleSpace - radius * 2) / 2;
1235
- const sideLine = width - radius * 2;
1236
- return rs.path(`M${x1 + radius},${y1}
1237
- l${sideLine},0
1238
- a${radius},${radius},0,0,1,${radius},${radius}
1239
- l0,${handleSideLine}
1240
- m0,${handleSpace}
1241
- l0,${handleSideLine}
1242
- a${radius},${radius},0,0,1,-${radius},${radius}
1243
- l-${sideLine},0
1244
- a${radius},${radius},0,0,1,-${radius},-${radius}
1245
- l0,-${handleSideLine}
1246
- m0,-${handleSpace}
1247
- l0,-${handleSideLine}
1248
- a${radius},${radius},0,0,1,${radius},-${radius}`, options);
1105
+ else {
1106
+ const handleSideLine = (height - handleSpace - radius * 2) / 2;
1107
+ const sideLine = width - radius * 2;
1108
+ return rs.path(`M${x1 + radius},${y1}
1109
+ l${sideLine},0
1110
+ a${radius},${radius},0,0,1,${radius},${radius}
1111
+ l0,${handleSideLine}
1112
+ m0,${handleSpace}
1113
+ l0,${handleSideLine}
1114
+ a${radius},${radius},0,0,1,-${radius},${radius}
1115
+ l-${sideLine},0
1116
+ a${radius},${radius},0,0,1,-${radius},-${radius}
1117
+ l0,-${handleSideLine}
1118
+ m0,-${handleSpace}
1119
+ l0,-${handleSideLine}
1120
+ a${radius},${radius},0,0,1,${radius},-${radius}`, options);
1121
+ }
1122
+ }
1123
+
1124
+ function arrowPoints(start, end, maxHypotenuseLength = 10, degree = 40) {
1125
+ const width = Math.abs(start[0] - end[0]);
1126
+ const height = Math.abs(start[1] - end[1]);
1127
+ let hypotenuse = Math.hypot(width, height); // 斜边
1128
+ const realRotateLine = hypotenuse > maxHypotenuseLength * 2 ? maxHypotenuseLength : hypotenuse / 2;
1129
+ const rotateWidth = (realRotateLine / hypotenuse) * width;
1130
+ const rotateHeight = (realRotateLine / hypotenuse) * height;
1131
+ const rotatePoint = [
1132
+ end[0] > start[0] ? end[0] - rotateWidth : end[0] + rotateWidth,
1133
+ end[1] > start[1] ? end[1] - rotateHeight : end[1] + rotateHeight
1134
+ ];
1135
+ const pointRight = rotate(rotatePoint[0], rotatePoint[1], end[0], end[1], (degree * Math.PI) / 180);
1136
+ const pointLeft = rotate(rotatePoint[0], rotatePoint[1], end[0], end[1], (-degree * Math.PI) / 180);
1137
+ return { pointLeft, pointRight };
1138
+ }
1139
+ function drawArrow(rs, start, end, options, maxHypotenuseLength = 10, degree = 40) {
1140
+ const { pointLeft, pointRight } = arrowPoints(start, end, maxHypotenuseLength, degree);
1141
+ const arrowLineLeft = rs.linearPath([pointLeft, end], options);
1142
+ const arrowLineRight = rs.linearPath([pointRight, end], options);
1143
+ return [arrowLineLeft, arrowLineRight];
1144
+ }
1145
+
1146
+ function drawCircle(roughSVG, point, diameter, options) {
1147
+ return roughSVG.circle(point[0], point[1], diameter, options);
1148
+ }
1149
+
1150
+ function drawLine(rs, start, end, options) {
1151
+ return rs.linearPath([start, end], options);
1152
+ }
1153
+ function drawLinearPath(points, options) {
1154
+ const g = createG();
1155
+ const path = createPath();
1156
+ let polylinePath = '';
1157
+ points.forEach((point, index) => {
1158
+ if (index === 0) {
1159
+ polylinePath += `M ${point[0]} ${point[1]} `;
1160
+ }
1161
+ else {
1162
+ polylinePath += `L ${point[0]} ${point[1]} `;
1163
+ }
1164
+ });
1165
+ path.setAttribute('d', polylinePath);
1166
+ path.setAttribute('stroke', `${options === null || options === void 0 ? void 0 : options.stroke}`);
1167
+ path.setAttribute('stroke-width', `${options === null || options === void 0 ? void 0 : options.strokeWidth}`);
1168
+ path.setAttribute('fill', `none`);
1169
+ g.appendChild(path);
1170
+ return g;
1171
+ }
1172
+
1173
+ let timerId = null;
1174
+ const throttleRAF = (fn) => {
1175
+ const scheduleFunc = () => {
1176
+ timerId = requestAnimationFrame(() => {
1177
+ timerId = null;
1178
+ fn();
1179
+ });
1180
+ };
1181
+ if (timerId !== null) {
1182
+ cancelAnimationFrame(timerId);
1183
+ timerId = null;
1184
+ }
1185
+ scheduleFunc();
1186
+ };
1187
+ const debounce = (func, wait, options) => {
1188
+ let timerSubscription = null;
1189
+ return () => {
1190
+ if (timerSubscription && !timerSubscription.closed) {
1191
+ timerSubscription.unsubscribe();
1192
+ timerSubscription = timer(wait).subscribe(() => {
1193
+ func();
1194
+ });
1195
+ }
1196
+ else {
1197
+ if (options === null || options === void 0 ? void 0 : options.leading) {
1198
+ func();
1199
+ }
1200
+ timerSubscription = timer(wait).subscribe();
1201
+ }
1202
+ };
1203
+ };
1204
+
1205
+ const getMovingElements = (board) => {
1206
+ return BOARD_TO_MOVING_ELEMENT.get(board) || [];
1207
+ };
1208
+ const addMovingElements = (board, elements) => {
1209
+ const movingElements = getMovingElements(board);
1210
+ const newElements = elements.filter(item => !movingElements.find(movingElement => movingElement.key === item.key));
1211
+ cacheMovingElements(board, [...movingElements, ...newElements]);
1212
+ };
1213
+ const removeMovingElements = (board) => {
1214
+ BOARD_TO_MOVING_ELEMENT.delete(board);
1215
+ };
1216
+ const cacheMovingElements = (board, elements) => {
1217
+ BOARD_TO_MOVING_ELEMENT.set(board, elements);
1218
+ };
1219
+
1220
+ const PlaitElement = {
1221
+ isRootElement(value) {
1222
+ const parent = NODE_TO_PARENT.get(value);
1223
+ if (parent && PlaitBoard.isBoard(parent)) {
1224
+ return true;
1225
+ }
1226
+ else {
1227
+ return false;
1228
+ }
1229
+ },
1230
+ getComponent(value) {
1231
+ return ELEMENT_TO_COMPONENT.get(value);
1232
+ }
1233
+ };
1234
+
1235
+ const RectangleClient = {
1236
+ isHit: (origin, target) => {
1237
+ const minX = origin.x < target.x ? origin.x : target.x;
1238
+ const maxX = origin.x + origin.width > target.x + target.width ? origin.x + origin.width : target.x + target.width;
1239
+ const minY = origin.y < target.y ? origin.y : target.y;
1240
+ const maxY = origin.y + origin.height > target.y + target.height ? origin.y + origin.height : target.y + target.height;
1241
+ // float calculate error( eg: 1.4210854715202004e-14 > 0)
1242
+ if (Math.floor(maxX - minX - origin.width - target.width) <= 0 && Math.floor(maxY - minY - origin.height - target.height) <= 0) {
1243
+ return true;
1244
+ }
1245
+ else {
1246
+ return false;
1247
+ }
1248
+ },
1249
+ toRectangleClient: (points) => {
1250
+ const xArray = points.map(ele => ele[0]);
1251
+ const yArray = points.map(ele => ele[1]);
1252
+ const xMin = Math.min(...xArray);
1253
+ const xMax = Math.max(...xArray);
1254
+ const yMin = Math.min(...yArray);
1255
+ const yMax = Math.max(...yArray);
1256
+ const rect = { x: xMin, y: yMin, width: xMax - xMin, height: yMax - yMin };
1257
+ return rect;
1258
+ },
1259
+ getOutlineRectangle: (rectangle, offset) => {
1260
+ return {
1261
+ x: rectangle.x + offset,
1262
+ y: rectangle.y + offset,
1263
+ width: rectangle.width + Math.abs(offset) * 2,
1264
+ height: rectangle.height + Math.abs(offset) * 2
1265
+ };
1266
+ },
1267
+ isEqual: (rectangle, otherRectangle) => {
1268
+ return (rectangle.x === otherRectangle.x &&
1269
+ rectangle.y === otherRectangle.y &&
1270
+ rectangle.width === otherRectangle.width &&
1271
+ rectangle.height === otherRectangle.height);
1272
+ }
1273
+ };
1274
+
1275
+ const isSetViewportOperation = (value) => {
1276
+ return value.type === 'set_viewport';
1277
+ };
1278
+ const inverse = (op) => {
1279
+ switch (op.type) {
1280
+ case 'insert_node': {
1281
+ return Object.assign(Object.assign({}, op), { type: 'remove_node' });
1282
+ }
1283
+ case 'remove_node': {
1284
+ return Object.assign(Object.assign({}, op), { type: 'insert_node' });
1285
+ }
1286
+ case 'move_node': {
1287
+ const { newPath, path } = op;
1288
+ // PERF: in this case the move operation is a no-op anyways.
1289
+ if (Path.equals(newPath, path)) {
1290
+ return op;
1291
+ }
1292
+ // when operation path is [0,0] -> [0,2], should exec Path.transform to get [0,1] -> [0,0]
1293
+ // shoud not return [0,2] -> [0,0] #WIK-8981
1294
+ // if (Path.isSibling(path, newPath)) {
1295
+ // return { ...op, path: newPath, newPath: path };
1296
+ // }
1297
+ // If the move does not happen within a single parent it is possible
1298
+ // for the move to impact the true path to the location where the node
1299
+ // was removed from and where it was inserted. We have to adjust for this
1300
+ // and find the original path. We can accomplish this (only in non-sibling)
1301
+ // moves by looking at the impact of the move operation on the node
1302
+ // after the original move path.
1303
+ const inversePath = Path.transform(path, op);
1304
+ const inverseNewPath = Path.transform(Path.next(path), op);
1305
+ return Object.assign(Object.assign({}, op), { path: inversePath, newPath: inverseNewPath });
1306
+ }
1307
+ case 'set_node': {
1308
+ const { properties, newProperties } = op;
1309
+ return Object.assign(Object.assign({}, op), { properties: newProperties, newProperties: properties });
1310
+ }
1311
+ case 'set_selection': {
1312
+ const { properties, newProperties } = op;
1313
+ if (properties == null) {
1314
+ return Object.assign(Object.assign({}, op), { properties: newProperties, newProperties: null });
1315
+ }
1316
+ else if (newProperties == null) {
1317
+ return Object.assign(Object.assign({}, op), { properties: null, newProperties: properties });
1318
+ }
1319
+ else {
1320
+ return Object.assign(Object.assign({}, op), { properties: newProperties, newProperties: properties });
1321
+ }
1322
+ }
1323
+ case 'set_viewport': {
1324
+ const { properties, newProperties } = op;
1325
+ if (properties == null) {
1326
+ return Object.assign(Object.assign({}, op), { properties: newProperties, newProperties: newProperties });
1327
+ }
1328
+ else if (newProperties == null) {
1329
+ return Object.assign(Object.assign({}, op), { properties: properties, newProperties: properties });
1330
+ }
1331
+ else {
1332
+ return Object.assign(Object.assign({}, op), { properties: newProperties, newProperties: properties });
1333
+ }
1334
+ }
1335
+ }
1336
+ };
1337
+ const PlaitOperation = {
1338
+ isSetViewportOperation,
1339
+ inverse
1340
+ };
1341
+
1342
+ const Point = {
1343
+ isEquals(point, otherPoint) {
1344
+ return point && otherPoint && point[0] === otherPoint[0] && point[1] === otherPoint[1];
1249
1345
  }
1250
- }
1346
+ };
1251
1347
 
1252
- function arrowPoints(start, end, maxHypotenuseLength = 10, degree = 40) {
1253
- const width = Math.abs(start[0] - end[0]);
1254
- const height = Math.abs(start[1] - end[1]);
1255
- let hypotenuse = Math.hypot(width, height); // 斜边
1256
- const realRotateLine = hypotenuse > maxHypotenuseLength * 2 ? maxHypotenuseLength : hypotenuse / 2;
1257
- const rotateWidth = (realRotateLine / hypotenuse) * width;
1258
- const rotateHeight = (realRotateLine / hypotenuse) * height;
1259
- const rotatePoint = [
1260
- end[0] > start[0] ? end[0] - rotateWidth : end[0] + rotateWidth,
1261
- end[1] > start[1] ? end[1] - rotateHeight : end[1] + rotateHeight
1262
- ];
1263
- const pointRight = rotate(rotatePoint[0], rotatePoint[1], end[0], end[1], (degree * Math.PI) / 180);
1264
- const pointLeft = rotate(rotatePoint[0], rotatePoint[1], end[0], end[1], (-degree * Math.PI) / 180);
1265
- return { pointLeft, pointRight };
1266
- }
1267
- function drawArrow(rs, start, end, options, maxHypotenuseLength = 10, degree = 40) {
1268
- const { pointLeft, pointRight } = arrowPoints(start, end, maxHypotenuseLength, degree);
1269
- const arrowLineLeft = rs.linearPath([pointLeft, end], options);
1270
- const arrowLineRight = rs.linearPath([pointRight, end], options);
1271
- return [arrowLineLeft, arrowLineRight];
1272
- }
1348
+ const SELECTION_BORDER_COLOR = '#6698FF';
1349
+ const SELECTION_FILL_COLOR = '#6698FF19'; // 主色 0.1 透明度
1350
+ const Selection = {
1351
+ isCollapsed(selection) {
1352
+ if (selection.anchor[0] == selection.focus[0] && selection.anchor[1] === selection.focus[1]) {
1353
+ return true;
1354
+ }
1355
+ else {
1356
+ return false;
1357
+ }
1358
+ }
1359
+ };
1273
1360
 
1274
- function drawCircle(roughSVG, point, diameter, options) {
1275
- return roughSVG.circle(point[0], point[1], diameter, options);
1276
- }
1361
+ const SAVING = new WeakMap();
1362
+ const MERGING = new WeakMap();
1277
1363
 
1278
- function drawLine(rs, start, end, options) {
1279
- return rs.linearPath([start, end], options);
1280
- }
1364
+ var PlaitPluginKey;
1365
+ (function (PlaitPluginKey) {
1366
+ PlaitPluginKey["withSelection"] = "withSelection";
1367
+ })(PlaitPluginKey || (PlaitPluginKey = {}));
1281
1368
 
1282
1369
  const IS_FROM_SCROLLING = new WeakMap();
1283
1370
  const IS_FROM_VIEWPORT_CHANGE = new WeakMap();
@@ -1407,15 +1494,49 @@ function initializeViewportOffset(board) {
1407
1494
  }
1408
1495
  updateViewportOffset(board);
1409
1496
  }
1410
- function setViewport(board, origination, zoom) {
1497
+ const updateViewportOrigination = (board, origination) => {
1498
+ BOARD_TO_VIEWPORT_ORIGINATION.set(board, origination);
1499
+ };
1500
+ const clearViewportOrigination = (board) => {
1501
+ BOARD_TO_VIEWPORT_ORIGINATION.delete(board);
1502
+ };
1503
+ const getViewportOrigination = (board) => {
1504
+ const origination = BOARD_TO_VIEWPORT_ORIGINATION.get(board);
1505
+ if (origination) {
1506
+ return origination;
1507
+ }
1508
+ else {
1509
+ return board.viewport.origination;
1510
+ }
1511
+ };
1512
+ const isFromScrolling = (board) => {
1513
+ return !!IS_FROM_SCROLLING.get(board);
1514
+ };
1515
+ const setIsFromScrolling = (board, state) => {
1516
+ IS_FROM_SCROLLING.set(board, state);
1517
+ };
1518
+ const isFromViewportChange = (board) => {
1519
+ return !!IS_FROM_VIEWPORT_CHANGE.get(board);
1520
+ };
1521
+ const setIsFromViewportChange = (board, state) => {
1522
+ IS_FROM_VIEWPORT_CHANGE.set(board, state);
1523
+ };
1524
+ function scrollToRectangle(board, client) { }
1525
+
1526
+ function updateViewport(board, origination, zoom) {
1411
1527
  zoom = zoom !== null && zoom !== void 0 ? zoom : board.viewport.zoom;
1412
- Transforms.setViewport(board, Object.assign(Object.assign({}, board.viewport), { zoom,
1528
+ setViewport(board, Object.assign(Object.assign({}, board.viewport), { zoom,
1413
1529
  origination }));
1414
1530
  clearViewportOrigination(board);
1415
1531
  }
1416
- function changeZoom(board, newZoom, isCenter = true) {
1532
+ const updatePointerType = (board, pointer) => {
1533
+ board.pointer = pointer;
1534
+ const boardComponent = BOARD_TO_COMPONENT.get(board);
1535
+ boardComponent === null || boardComponent === void 0 ? void 0 : boardComponent.markForCheck();
1536
+ };
1537
+ function updateZoom(board, newZoom, isCenter = true) {
1417
1538
  newZoom = clampZoomLevel(newZoom);
1418
- const mousePoint = BOARD_TO_MOVING_POINT.get(board);
1539
+ const mousePoint = PlaitBoard.getMovingPoint(board);
1419
1540
  const nativeElement = PlaitBoard.getBoardNativeElement(board);
1420
1541
  const nativeElementRect = nativeElement.getBoundingClientRect();
1421
1542
  const viewportContainerRect = getViewportContainerRect(board);
@@ -1428,7 +1549,7 @@ function changeZoom(board, newZoom, isCenter = true) {
1428
1549
  const centerX = origination[0] + focusPoint[0] / zoom;
1429
1550
  const centerY = origination[1] + focusPoint[1] / zoom;
1430
1551
  const newOrigination = [centerX - focusPoint[0] / newZoom, centerY - focusPoint[1] / newZoom];
1431
- setViewport(board, newOrigination, newZoom);
1552
+ updateViewport(board, newOrigination, newZoom);
1432
1553
  }
1433
1554
  function fitViewport(board) {
1434
1555
  const nativeElementRect = PlaitBoard.getBoardNativeElement(board).getBoundingClientRect();
@@ -1452,91 +1573,13 @@ function fitViewport(board) {
1452
1573
  centerX - viewportContainerRect.width / 2 / newZoom,
1453
1574
  centerY - viewportContainerRect.height / 2 / newZoom
1454
1575
  ];
1455
- setViewport(board, newOrigination, newZoom);
1576
+ updateViewport(board, newOrigination, newZoom);
1456
1577
  }
1457
- const updateViewportOrigination = (board, origination) => {
1458
- BOARD_TO_VIEWPORT_ORIGINATION.set(board, origination);
1459
- };
1460
- const clearViewportOrigination = (board) => {
1461
- BOARD_TO_VIEWPORT_ORIGINATION.delete(board);
1462
- };
1463
- const getViewportOrigination = (board) => {
1464
- const origination = BOARD_TO_VIEWPORT_ORIGINATION.get(board);
1465
- if (origination) {
1466
- return origination;
1467
- }
1468
- else {
1469
- return board.viewport.origination;
1470
- }
1471
- };
1472
- const isFromScrolling = (board) => {
1473
- return !!IS_FROM_SCROLLING.get(board);
1474
- };
1475
- const setIsFromScrolling = (board, state) => {
1476
- IS_FROM_SCROLLING.set(board, state);
1477
- };
1478
- const isFromViewportChange = (board) => {
1479
- return !!IS_FROM_VIEWPORT_CHANGE.get(board);
1480
- };
1481
- const setIsFromViewportChange = (board, state) => {
1482
- IS_FROM_VIEWPORT_CHANGE.set(board, state);
1483
- };
1484
- function scrollToRectangle(board, client) { }
1485
-
1486
- let timerId = null;
1487
- const throttleRAF = (fn) => {
1488
- const scheduleFunc = () => {
1489
- timerId = requestAnimationFrame(() => {
1490
- timerId = null;
1491
- fn();
1492
- });
1493
- };
1494
- if (timerId !== null) {
1495
- cancelAnimationFrame(timerId);
1496
- timerId = null;
1497
- }
1498
- scheduleFunc();
1499
- };
1500
- const debounce = (func, wait, options) => {
1501
- let timerSubscription = null;
1502
- return () => {
1503
- if (timerSubscription && !timerSubscription.closed) {
1504
- timerSubscription.unsubscribe();
1505
- timerSubscription = timer(wait).subscribe(() => {
1506
- func();
1507
- });
1508
- }
1509
- else {
1510
- if (options === null || options === void 0 ? void 0 : options.leading) {
1511
- func();
1512
- }
1513
- timerSubscription = timer(wait).subscribe();
1514
- }
1515
- };
1516
- };
1517
-
1518
- const getMovingElements = (board) => {
1519
- return BOARD_TO_MOVING_ELEMENT.get(board) || [];
1520
- };
1521
- const addMovingElements = (board, elements) => {
1522
- const movingElements = getMovingElements(board);
1523
- const newElements = elements.filter(item => !movingElements.find(movingElement => movingElement.key === item.key));
1524
- cacheMovingElements(board, [...movingElements, ...newElements]);
1525
- };
1526
- const removeMovingElements = (board) => {
1527
- BOARD_TO_MOVING_ELEMENT.delete(board);
1528
- };
1529
- const cacheMovingElements = (board, elements) => {
1530
- BOARD_TO_MOVING_ELEMENT.set(board, elements);
1531
- };
1532
-
1533
- const updatePointerType = (board, pointer) => {
1534
- board.pointer = pointer;
1535
- const boardComponent = BOARD_TO_COMPONENT.get(board);
1536
- boardComponent === null || boardComponent === void 0 ? void 0 : boardComponent.markForCheck();
1537
- };
1538
1578
  const BoardTransforms = {
1539
- updatePointerType
1579
+ updatePointerType,
1580
+ updateViewport,
1581
+ fitViewport,
1582
+ updateZoom
1540
1583
  };
1541
1584
 
1542
1585
  const Transforms = Object.assign(Object.assign(Object.assign(Object.assign({}, GeneralTransforms), ViewportTransforms), SelectionTransforms), NodeTransforms);
@@ -1743,7 +1786,7 @@ function withHandPointer(board) {
1743
1786
  y: 0
1744
1787
  };
1745
1788
  board.mousedown = (event) => {
1746
- if (board.pointer === PlaitPointerType.hand) {
1789
+ if (PlaitBoard.isPointer(board, PlaitPointerType.hand) && isMainPointer(event)) {
1747
1790
  isMoving = true;
1748
1791
  PlaitBoard.getBoardNativeElement(board).classList.add('viewport-moving');
1749
1792
  plaitBoardMove.x = event.x;
@@ -1752,7 +1795,7 @@ function withHandPointer(board) {
1752
1795
  mousedown(event);
1753
1796
  };
1754
1797
  board.mousemove = (event) => {
1755
- if (board.pointer === PlaitPointerType.hand && board.selection && isMoving) {
1798
+ if (PlaitBoard.isPointer(board, PlaitPointerType.hand) && board.selection && isMoving) {
1756
1799
  const viewportContainer = PlaitBoard.getViewportContainer(board);
1757
1800
  const left = viewportContainer.scrollLeft - (event.x - plaitBoardMove.x);
1758
1801
  const top = viewportContainer.scrollTop - (event.y - plaitBoardMove.y);
@@ -1774,7 +1817,7 @@ function withHandPointer(board) {
1774
1817
  board.keydown = (event) => {
1775
1818
  if (event.code === 'Space') {
1776
1819
  if (!PlaitBoard.isPointer(board, PlaitPointerType.hand)) {
1777
- updatePointerType(board, PlaitPointerType.hand);
1820
+ BoardTransforms.updatePointerType(board, PlaitPointerType.hand);
1778
1821
  }
1779
1822
  event.preventDefault();
1780
1823
  }
@@ -1782,7 +1825,7 @@ function withHandPointer(board) {
1782
1825
  };
1783
1826
  board.keyup = (event) => {
1784
1827
  if (!board.options.readonly && event.code === 'Space') {
1785
- updatePointerType(board, PlaitPointerType.selection);
1828
+ BoardTransforms.updatePointerType(board, PlaitPointerType.selection);
1786
1829
  }
1787
1830
  keyup(event);
1788
1831
  };
@@ -1799,10 +1842,11 @@ function withSelection(board) {
1799
1842
  let selectionOuterG;
1800
1843
  let previousSelectedElements;
1801
1844
  board.mousedown = (event) => {
1802
- if (event.button === 2) {
1845
+ if (!isMainPointer(event)) {
1803
1846
  mousedown(event);
1804
1847
  return;
1805
1848
  }
1849
+ const options = board.getPluginOptions(PlaitPluginKey.withSelection);
1806
1850
  const point = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
1807
1851
  const ranges = [{ anchor: point, focus: point }];
1808
1852
  const selectedElements = getSelectedElements(board);
@@ -1813,7 +1857,8 @@ function withSelection(board) {
1813
1857
  const range = { anchor: point, focus: point };
1814
1858
  if (PlaitBoard.isPointer(board, PlaitPointerType.selection) &&
1815
1859
  PlaitBoard.isFocus(board) &&
1816
- getHitElements(board, { ranges: [range] }).length === 0) {
1860
+ getHitElements(board, { ranges: [range] }).length === 0 &&
1861
+ options.isMultiple) {
1817
1862
  start = point;
1818
1863
  }
1819
1864
  Transforms.setSelection(board, { ranges: ranges });
@@ -1871,7 +1916,11 @@ function withSelection(board) {
1871
1916
  if (board.operations.find(value => value.type === 'set_selection')) {
1872
1917
  selectionOuterG === null || selectionOuterG === void 0 ? void 0 : selectionOuterG.remove();
1873
1918
  const temporaryElements = getTemporaryElements(board);
1874
- const elements = temporaryElements ? temporaryElements : getHitElements(board);
1919
+ let elements = temporaryElements ? temporaryElements : getHitElements(board);
1920
+ const options = board.getPluginOptions(PlaitPluginKey.withSelection);
1921
+ if (!options.isMultiple && elements.length > 1) {
1922
+ elements = [elements[0]];
1923
+ }
1875
1924
  cacheSelectedElements(board, elements);
1876
1925
  previousSelectedElements = elements;
1877
1926
  const { width, height } = getRectangleByElements(board, elements, false);
@@ -1907,6 +1956,7 @@ function withSelection(board) {
1907
1956
  }
1908
1957
  onChange();
1909
1958
  };
1959
+ board.setPluginOptions(PlaitPluginKey.withSelection, { isMultiple: true });
1910
1960
  return board;
1911
1961
  }
1912
1962
  function getTemporaryElements(board) {
@@ -2048,6 +2098,50 @@ function withMoving(board) {
2048
2098
  return board;
2049
2099
  }
2050
2100
 
2101
+ const withOptions = (board) => {
2102
+ const pluginOptions = new Map();
2103
+ const newBoard = board;
2104
+ newBoard.getPluginOptions = key => {
2105
+ return pluginOptions.get(key);
2106
+ };
2107
+ newBoard.setPluginOptions = (key, options) => {
2108
+ const oldOptions = newBoard.getPluginOptions(key) || {};
2109
+ pluginOptions.set(key, Object.assign(Object.assign({}, oldOptions), options));
2110
+ };
2111
+ return newBoard;
2112
+ };
2113
+
2114
+ class PlaitIslandBaseComponent {
2115
+ constructor(cdr) {
2116
+ this.cdr = cdr;
2117
+ }
2118
+ initialize(board) {
2119
+ this.board = board;
2120
+ this.markForCheck();
2121
+ }
2122
+ markForCheck() {
2123
+ this.cdr.markForCheck();
2124
+ }
2125
+ }
2126
+ PlaitIslandBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitIslandBaseComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
2127
+ PlaitIslandBaseComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: PlaitIslandBaseComponent, host: { classAttribute: "plait-island-container" }, ngImport: i0 });
2128
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitIslandBaseComponent, decorators: [{
2129
+ type: Directive,
2130
+ args: [{
2131
+ host: {
2132
+ class: 'plait-island-container'
2133
+ }
2134
+ }]
2135
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; } });
2136
+ const hasOnBoardChange = (value) => {
2137
+ if (value.onBoardChange) {
2138
+ return true;
2139
+ }
2140
+ else {
2141
+ return false;
2142
+ }
2143
+ };
2144
+
2051
2145
  class PlaitElementComponent {
2052
2146
  constructor(renderer2, viewContainerRef) {
2053
2147
  this.renderer2 = renderer2;
@@ -2122,9 +2216,9 @@ class PlaitElementComponent {
2122
2216
  this.board.destroyElement(this.getContext());
2123
2217
  }
2124
2218
  }
2125
- 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 });
2126
- 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 });
2127
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitElementComponent, decorators: [{
2219
+ 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 });
2220
+ 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 });
2221
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitElementComponent, decorators: [{
2128
2222
  type: Component,
2129
2223
  args: [{
2130
2224
  selector: 'plait-element',
@@ -2160,8 +2254,8 @@ class PlaitChildrenElement {
2160
2254
  }
2161
2255
  }
2162
2256
  }
2163
- PlaitChildrenElement.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitChildrenElement, deps: [], target: i0.ɵɵFactoryTarget.Component });
2164
- 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: `
2257
+ PlaitChildrenElement.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitChildrenElement, deps: [], target: i0.ɵɵFactoryTarget.Component });
2258
+ 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: `
2165
2259
  <plait-element
2166
2260
  *ngFor="let item of parent.children; let index = index; trackBy: trackBy"
2167
2261
  [index]="index"
@@ -2172,7 +2266,7 @@ PlaitChildrenElement.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", v
2172
2266
  [parentG]="parentG"
2173
2267
  ></plait-element>
2174
2268
  `, 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"] }] });
2175
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitChildrenElement, decorators: [{
2269
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitChildrenElement, decorators: [{
2176
2270
  type: Component,
2177
2271
  args: [{
2178
2272
  selector: 'plait-children',
@@ -2198,62 +2292,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImpor
2198
2292
  type: Input
2199
2293
  }] } });
2200
2294
 
2201
- class PlaitToolbarComponent {
2202
- constructor() {
2203
- this.PlaitPointerType = PlaitPointerType;
2204
- this.hostClass = `plait-board-toolbar`;
2205
- this.adaptHandle = new EventEmitter();
2206
- this.zoomInHandle = new EventEmitter();
2207
- this.zoomOutHandle = new EventEmitter();
2208
- this.resetZoomHandel = new EventEmitter();
2209
- }
2210
- get zoom() {
2211
- var _a;
2212
- const zoom = ((_a = this.board) === null || _a === void 0 ? void 0 : _a.viewport.zoom) || 1;
2213
- return Number((zoom * 100).toFixed(0));
2214
- }
2215
- get isHand() {
2216
- return this.board.pointer === PlaitPointerType.hand;
2217
- }
2218
- activeHand() {
2219
- updatePointerType(this.board, this.isHand ? PlaitPointerType.selection : PlaitPointerType.hand);
2220
- }
2221
- // 适应画布
2222
- adapt() {
2223
- this.adaptHandle.emit();
2224
- }
2225
- // 放大
2226
- zoomIn() {
2227
- this.zoomInHandle.emit();
2228
- }
2229
- // 缩小
2230
- zoomOut() {
2231
- this.zoomOutHandle.emit();
2232
- }
2233
- resetZoom() {
2234
- this.resetZoomHandel.emit();
2235
- }
2236
- }
2237
- PlaitToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitToolbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2238
- 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 });
2239
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitToolbarComponent, decorators: [{
2240
- type: Component,
2241
- 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" }]
2242
- }], propDecorators: { hostClass: [{
2243
- type: HostBinding,
2244
- args: ['class']
2245
- }], board: [{
2246
- type: Input
2247
- }], adaptHandle: [{
2248
- type: Output
2249
- }], zoomInHandle: [{
2250
- type: Output
2251
- }], zoomOutHandle: [{
2252
- type: Output
2253
- }], resetZoomHandel: [{
2254
- type: Output
2255
- }] } });
2256
-
2257
2295
  const ElementHostClass = 'element-host';
2258
2296
  class PlaitBoardComponent {
2259
2297
  get host() {
@@ -2313,11 +2351,15 @@ class PlaitBoardComponent {
2313
2351
  viewport: this.board.viewport,
2314
2352
  selection: this.board.selection
2315
2353
  };
2354
+ this.updateIslands();
2316
2355
  this.plaitChange.emit(changeEvent);
2317
2356
  });
2318
2357
  });
2319
2358
  this.hasInitialized = true;
2320
2359
  }
2360
+ ngAfterContentInit() {
2361
+ this.initializeIslands();
2362
+ }
2321
2363
  detect() {
2322
2364
  this.effect = {};
2323
2365
  this.cdr.detectChanges();
@@ -2340,7 +2382,7 @@ class PlaitBoardComponent {
2340
2382
  initializeViewportOffset(this.board);
2341
2383
  }
2342
2384
  initializePlugins() {
2343
- let board = withHandPointer(withHistory(withSelection(withMoving(withBoard(withViewport(createBoard(this.plaitValue, this.plaitOptions)))))));
2385
+ let board = withHandPointer(withHistory(withSelection(withMoving(withBoard(withViewport(withOptions(createBoard(this.plaitValue, this.plaitOptions))))))));
2344
2386
  this.plaitPlugins.forEach(plugin => {
2345
2387
  board = plugin(board);
2346
2388
  });
@@ -2382,17 +2424,20 @@ class PlaitBoardComponent {
2382
2424
  this.board.dblclick(event);
2383
2425
  });
2384
2426
  fromEvent(document, 'keydown')
2385
- .pipe(takeUntil(this.destroy$), filter(event => this.isFocused && !PlaitBoard.hasBeenTextEditing(this.board) && !hasInputOrTextareaTarget(event.target)))
2427
+ .pipe(takeUntil(this.destroy$), tap((event) => {
2428
+ if (PlaitBoard.getMovingPoint(this.board)) {
2429
+ if (isHotkey(['mod+=', 'mod++'], { byKey: true })(event)) {
2430
+ event.preventDefault();
2431
+ BoardTransforms.updateZoom(this.board, this.board.viewport.zoom + 0.1, false);
2432
+ }
2433
+ if (isHotkey('mod+-', { byKey: true })(event)) {
2434
+ event.preventDefault();
2435
+ BoardTransforms.updateZoom(this.board, this.board.viewport.zoom - 0.1);
2436
+ }
2437
+ }
2438
+ }), filter(event => this.isFocused && !PlaitBoard.hasBeenTextEditing(this.board) && !hasInputOrTextareaTarget(event.target)))
2386
2439
  .subscribe((event) => {
2387
2440
  var _a;
2388
- if (isHotkey(['mod+=', 'mod++'], { byKey: true })(event)) {
2389
- event.preventDefault();
2390
- this.zoomInHandle(false);
2391
- }
2392
- if (isHotkey('mod+-', { byKey: true })(event)) {
2393
- this.zoomOutHandle();
2394
- event.preventDefault();
2395
- }
2396
2441
  (_a = this.board) === null || _a === void 0 ? void 0 : _a.keydown(event);
2397
2442
  });
2398
2443
  fromEvent(document, 'keyup')
@@ -2445,7 +2490,7 @@ class PlaitBoardComponent {
2445
2490
  if (Point.isEquals(origination, this.board.viewport.origination)) {
2446
2491
  return;
2447
2492
  }
2448
- setViewport(this.board, origination);
2493
+ BoardTransforms.updateViewport(this.board, origination);
2449
2494
  setIsFromScrolling(this.board, true);
2450
2495
  });
2451
2496
  });
@@ -2465,17 +2510,20 @@ class PlaitBoardComponent {
2465
2510
  BOARD_TO_MOVING_POINT.delete(this.board);
2466
2511
  });
2467
2512
  }
2468
- adaptHandle() {
2469
- fitViewport(this.board);
2470
- }
2471
- zoomInHandle(isCenter = true) {
2472
- changeZoom(this.board, this.board.viewport.zoom + 0.1, isCenter);
2473
- }
2474
- zoomOutHandle() {
2475
- changeZoom(this.board, this.board.viewport.zoom - 0.1);
2513
+ initializeIslands() {
2514
+ var _a;
2515
+ (_a = this.islands) === null || _a === void 0 ? void 0 : _a.forEach(island => {
2516
+ island.initialize(this.board);
2517
+ });
2476
2518
  }
2477
- resetZoomHandel() {
2478
- changeZoom(this.board, 1);
2519
+ updateIslands() {
2520
+ var _a;
2521
+ (_a = this.islands) === null || _a === void 0 ? void 0 : _a.forEach(island => {
2522
+ if (hasOnBoardChange(island)) {
2523
+ island.onBoardChange();
2524
+ }
2525
+ island.markForCheck();
2526
+ });
2479
2527
  }
2480
2528
  ngOnDestroy() {
2481
2529
  var _a;
@@ -2491,25 +2539,20 @@ class PlaitBoardComponent {
2491
2539
  }
2492
2540
  markForCheck() {
2493
2541
  this.cdr.markForCheck();
2542
+ this.ngZone.run(() => {
2543
+ this.updateIslands();
2544
+ });
2494
2545
  }
2495
2546
  }
2496
- 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 });
2497
- 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: `
2547
+ 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 });
2548
+ 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: `
2498
2549
  <div class="viewport-container" #viewportContainer>
2499
2550
  <svg #svg width="100%" height="100%" style="position: relative;"><g class="element-host"></g></svg>
2500
2551
  <plait-children [board]="board" [effect]="effect"></plait-children>
2501
2552
  </div>
2502
- <plait-toolbar
2503
- *ngIf="isFocused && !toolbarTemplateRef"
2504
- [board]="board"
2505
- (adaptHandle)="adaptHandle()"
2506
- (zoomInHandle)="zoomInHandle()"
2507
- (zoomOutHandle)="zoomOutHandle()"
2508
- (resetZoomHandel)="resetZoomHandel()"
2509
- ></plait-toolbar>
2510
2553
  <ng-content></ng-content>
2511
- `, 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 });
2512
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitBoardComponent, decorators: [{
2554
+ `, isInline: true, dependencies: [{ kind: "component", type: PlaitChildrenElement, selector: "plait-children", inputs: ["board", "parent", "effect", "parentG"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2555
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitBoardComponent, decorators: [{
2513
2556
  type: Component,
2514
2557
  args: [{
2515
2558
  selector: 'plait-board',
@@ -2518,14 +2561,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImpor
2518
2561
  <svg #svg width="100%" height="100%" style="position: relative;"><g class="element-host"></g></svg>
2519
2562
  <plait-children [board]="board" [effect]="effect"></plait-children>
2520
2563
  </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
2564
  <ng-content></ng-content>
2530
2565
  `,
2531
2566
  changeDetection: ChangeDetectionStrategy.OnPush
@@ -2554,21 +2589,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImpor
2554
2589
  }], svg: [{
2555
2590
  type: ViewChild,
2556
2591
  args: ['svg', { static: true }]
2557
- }], toolbarTemplateRef: [{
2558
- type: ContentChild,
2559
- args: ['plaitToolbar']
2560
2592
  }], viewportContainer: [{
2561
2593
  type: ViewChild,
2562
2594
  args: ['viewportContainer', { read: ElementRef, static: true }]
2595
+ }], islands: [{
2596
+ type: ContentChildren,
2597
+ args: [PlaitIslandBaseComponent, { descendants: true }]
2563
2598
  }] } });
2564
2599
 
2565
- const COMPONENTS = [PlaitBoardComponent, PlaitChildrenElement, PlaitElementComponent, PlaitToolbarComponent];
2600
+ const COMPONENTS = [PlaitBoardComponent, PlaitChildrenElement, PlaitElementComponent];
2566
2601
  class PlaitModule {
2567
2602
  }
2568
- PlaitModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2569
- 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] });
2570
- PlaitModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitModule, imports: [CommonModule] });
2571
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.2", ngImport: i0, type: PlaitModule, decorators: [{
2603
+ PlaitModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2604
+ 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] });
2605
+ PlaitModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, imports: [CommonModule] });
2606
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, decorators: [{
2572
2607
  type: NgModule,
2573
2608
  args: [{
2574
2609
  declarations: [...COMPONENTS],
@@ -2614,5 +2649,5 @@ const clearNodeWeakMap = (object) => {
2614
2649
  * Generated bundle index. Do not edit.
2615
2650
  */
2616
2651
 
2617
- 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 };
2652
+ 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 };
2618
2653
  //# sourceMappingURL=plait-core.mjs.map