@plait/core 0.1.9 → 0.2.0-next.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.
- package/board/board.component.d.ts +4 -3
- package/core/children/children.component.d.ts +17 -0
- package/core/children/effect.d.ts +2 -0
- package/core/element/context-change.d.ts +10 -0
- package/core/element/context.d.ts +4 -2
- package/core/element/element.component.d.ts +10 -13
- package/core/element/plugin-element.d.ts +5 -4
- package/esm2020/board/board.component.mjs +15 -23
- package/esm2020/core/children/children.component.mjs +58 -0
- package/esm2020/core/children/effect.mjs +2 -0
- package/esm2020/core/element/context-change.mjs +13 -0
- package/esm2020/core/element/context.mjs +1 -1
- package/esm2020/core/element/element.component.mjs +47 -37
- package/esm2020/core/element/plugin-element.mjs +36 -27
- package/esm2020/interfaces/board.mjs +33 -2
- package/esm2020/interfaces/element.mjs +15 -4
- package/esm2020/interfaces/node.mjs +23 -3
- package/esm2020/interfaces/operation.mjs +1 -1
- package/esm2020/interfaces/path.mjs +36 -1
- package/esm2020/interfaces/rectangle-client.mjs +9 -1
- package/esm2020/plait.module.mjs +4 -3
- package/esm2020/plugins/create-board.mjs +2 -1
- package/esm2020/plugins/with-moving.mjs +4 -4
- package/esm2020/plugins/with-selection.mjs +4 -4
- package/esm2020/public-api.mjs +3 -3
- package/esm2020/utils/draw/circle.mjs +4 -0
- package/esm2020/utils/draw/line.mjs +4 -0
- package/esm2020/utils/draw/rectangle.mjs +43 -1
- package/esm2020/utils/element.mjs +2 -2
- package/esm2020/utils/index.mjs +3 -1
- package/esm2020/utils/selected-element.mjs +11 -4
- package/esm2020/utils/tree.mjs +7 -5
- package/esm2020/utils/weak-maps.mjs +4 -1
- package/fesm2015/plait-core.mjs +417 -187
- package/fesm2015/plait-core.mjs.map +1 -1
- package/fesm2020/plait-core.mjs +416 -185
- package/fesm2020/plait-core.mjs.map +1 -1
- package/interfaces/board.d.ts +5 -0
- package/interfaces/element.d.ts +6 -3
- package/interfaces/node.d.ts +17 -9
- package/interfaces/operation.d.ts +1 -1
- package/interfaces/path.d.ts +18 -0
- package/interfaces/rectangle-client.d.ts +6 -0
- package/package.json +1 -1
- package/plait.module.d.ts +5 -4
- package/public-api.d.ts +2 -2
- package/styles/styles.scss +4 -0
- package/utils/draw/circle.d.ts +4 -0
- package/utils/draw/line.d.ts +4 -0
- package/utils/draw/rectangle.d.ts +1 -0
- package/utils/index.d.ts +2 -0
- package/utils/selected-element.d.ts +2 -2
- package/utils/tree.d.ts +1 -1
- package/utils/weak-maps.d.ts +4 -0
- package/core/base/detector.d.ts +0 -7
- package/core/element/before-context-change.d.ts +0 -6
- package/esm2020/core/base/detector.mjs +0 -2
- package/esm2020/core/element/before-context-change.mjs +0 -7
package/fesm2015/plait-core.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, ChangeDetectionStrategy,
|
|
2
|
+
import { Directive, Input, Component, ChangeDetectionStrategy, EventEmitter, HostBinding, Output, ElementRef, ViewChild, ContentChild, NgModule } from '@angular/core';
|
|
3
3
|
import rough from 'roughjs/bin/rough';
|
|
4
4
|
import { timer, Subject, fromEvent } from 'rxjs';
|
|
5
5
|
import { takeUntil, filter } from 'rxjs/operators';
|
|
@@ -9,7 +9,10 @@ import * as i1 from '@angular/common';
|
|
|
9
9
|
import { BrowserModule } from '@angular/platform-browser';
|
|
10
10
|
|
|
11
11
|
// record richtext type status
|
|
12
|
+
const IS_BOARD_CACHE = new WeakMap();
|
|
12
13
|
const FLUSHING = new WeakMap();
|
|
14
|
+
const NODE_TO_INDEX = new WeakMap();
|
|
15
|
+
const NODE_TO_PARENT = new WeakMap();
|
|
13
16
|
const IS_TEXT_EDITABLE = new WeakMap();
|
|
14
17
|
const BOARD_TO_ON_CHANGE = new WeakMap();
|
|
15
18
|
const BOARD_TO_COMPONENT = new WeakMap();
|
|
@@ -24,11 +27,13 @@ const BOARD_TO_IS_SELECTION_MOVING = new WeakMap();
|
|
|
24
27
|
const BOARD_TO_TEMPORARY_ELEMENTS = new WeakMap();
|
|
25
28
|
const BOARD_TO_MOVING_ELEMENT = new WeakMap();
|
|
26
29
|
|
|
27
|
-
function depthFirstRecursion(node, callback) {
|
|
30
|
+
function depthFirstRecursion(node, callback, recursion) {
|
|
28
31
|
var _a;
|
|
29
|
-
(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
if (!recursion || recursion(node)) {
|
|
33
|
+
(_a = node.children) === null || _a === void 0 ? void 0 : _a.forEach(child => {
|
|
34
|
+
depthFirstRecursion(child, callback, recursion);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
32
37
|
callback(node);
|
|
33
38
|
}
|
|
34
39
|
|
|
@@ -50,7 +55,7 @@ function getRectangleByElements(board, elements, recursion) {
|
|
|
50
55
|
};
|
|
51
56
|
elements.forEach(element => {
|
|
52
57
|
if (recursion) {
|
|
53
|
-
depthFirstRecursion(element, node => calcRectangleClient(node));
|
|
58
|
+
depthFirstRecursion(element, node => calcRectangleClient(node), node => board.isRecursion(node));
|
|
54
59
|
}
|
|
55
60
|
else {
|
|
56
61
|
calcRectangleClient(element);
|
|
@@ -68,6 +73,37 @@ function getBoardRectangle(board) {
|
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
const PlaitBoard = {
|
|
76
|
+
isBoard(value) {
|
|
77
|
+
const cachedIsBoard = IS_BOARD_CACHE.get(value);
|
|
78
|
+
if (cachedIsBoard !== undefined) {
|
|
79
|
+
return cachedIsBoard;
|
|
80
|
+
}
|
|
81
|
+
const isBoard = typeof value.onChange === 'function' && typeof value.apply === 'function';
|
|
82
|
+
IS_BOARD_CACHE.set(value, isBoard);
|
|
83
|
+
return isBoard;
|
|
84
|
+
},
|
|
85
|
+
findPath(board, node) {
|
|
86
|
+
const path = [];
|
|
87
|
+
let child = node;
|
|
88
|
+
while (true) {
|
|
89
|
+
const parent = NODE_TO_PARENT.get(child);
|
|
90
|
+
if (parent == null) {
|
|
91
|
+
if (PlaitBoard.isBoard(child)) {
|
|
92
|
+
return path;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const i = NODE_TO_INDEX.get(child);
|
|
99
|
+
if (i == null) {
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
path.unshift(i);
|
|
103
|
+
child = parent;
|
|
104
|
+
}
|
|
105
|
+
throw new Error(`Unable to find the path for Plait node: ${JSON.stringify(node)}`);
|
|
106
|
+
},
|
|
71
107
|
getHost(board) {
|
|
72
108
|
return BOARD_TO_HOST.get(board);
|
|
73
109
|
},
|
|
@@ -130,6 +166,41 @@ const Viewport = {
|
|
|
130
166
|
};
|
|
131
167
|
|
|
132
168
|
const Path = {
|
|
169
|
+
/**
|
|
170
|
+
* Get a list of ancestor paths for a given path.
|
|
171
|
+
*
|
|
172
|
+
* The paths are sorted from shallowest to deepest ancestor. However, if the
|
|
173
|
+
* `reverse: true` option is passed, they are reversed.
|
|
174
|
+
*/
|
|
175
|
+
ancestors(path, options = {}) {
|
|
176
|
+
const { reverse = false } = options;
|
|
177
|
+
let paths = Path.levels(path, options);
|
|
178
|
+
if (reverse) {
|
|
179
|
+
paths = paths.slice(1);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
paths = paths.slice(0, -1);
|
|
183
|
+
}
|
|
184
|
+
return paths;
|
|
185
|
+
},
|
|
186
|
+
/**
|
|
187
|
+
* Get a list of paths at every level down to a path. Note: this is the same
|
|
188
|
+
* as `Path.ancestors`, but including the path itself.
|
|
189
|
+
*
|
|
190
|
+
* The paths are sorted from shallowest to deepest. However, if the `reverse:
|
|
191
|
+
* true` option is passed, they are reversed.
|
|
192
|
+
*/
|
|
193
|
+
levels(path, options = {}) {
|
|
194
|
+
const { reverse = false } = options;
|
|
195
|
+
const list = [];
|
|
196
|
+
for (let i = 0; i <= path.length; i++) {
|
|
197
|
+
list.push(path.slice(0, i));
|
|
198
|
+
}
|
|
199
|
+
if (reverse) {
|
|
200
|
+
list.reverse();
|
|
201
|
+
}
|
|
202
|
+
return list;
|
|
203
|
+
},
|
|
133
204
|
parent(path) {
|
|
134
205
|
if (path.length === 0) {
|
|
135
206
|
throw new Error(`Cannot get the parent path of the root path [${path}].`);
|
|
@@ -273,8 +344,20 @@ const PlaitNode = {
|
|
|
273
344
|
const p = PlaitNode.get(board, parentPath);
|
|
274
345
|
return p;
|
|
275
346
|
},
|
|
276
|
-
|
|
277
|
-
|
|
347
|
+
/**
|
|
348
|
+
* Return a generator of all the ancestor nodes above a specific path.
|
|
349
|
+
*
|
|
350
|
+
* By default the order is top-down, from highest to lowest ancestor in
|
|
351
|
+
* the tree, but you can pass the `reverse: true` option to go bottom-up.
|
|
352
|
+
*/
|
|
353
|
+
*parents(root, path, options = {}) {
|
|
354
|
+
for (const p of Path.ancestors(path, options)) {
|
|
355
|
+
const n = PlaitNode.get(root, p);
|
|
356
|
+
yield n;
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
get(root, path) {
|
|
360
|
+
let node = root;
|
|
278
361
|
for (let i = 0; i < path.length; i++) {
|
|
279
362
|
const p = path[i];
|
|
280
363
|
if (!node || !node.children || !node.children[p]) {
|
|
@@ -283,6 +366,14 @@ const PlaitNode = {
|
|
|
283
366
|
node = node.children[p];
|
|
284
367
|
}
|
|
285
368
|
return node;
|
|
369
|
+
},
|
|
370
|
+
last(board, path) {
|
|
371
|
+
let n = PlaitNode.get(board, path);
|
|
372
|
+
while (n && n.children) {
|
|
373
|
+
const i = n.children.length - 1;
|
|
374
|
+
n = n.children[i];
|
|
375
|
+
}
|
|
376
|
+
return n;
|
|
286
377
|
}
|
|
287
378
|
};
|
|
288
379
|
|
|
@@ -584,10 +675,153 @@ const IS_CHROME = typeof navigator !== 'undefined' && /Chrome/i.test(navigator.u
|
|
|
584
675
|
// Native beforeInput events don't work well with react on Chrome 75 and older, Chrome 76+ can use beforeInput
|
|
585
676
|
const IS_CHROME_LEGACY = typeof navigator !== 'undefined' && /Chrome?\/(?:[0-7][0-5]|[0-6][0-9])/i.test(navigator.userAgent);
|
|
586
677
|
|
|
678
|
+
const getHitElements = (board) => {
|
|
679
|
+
const selectedElements = [];
|
|
680
|
+
depthFirstRecursion(board, node => {
|
|
681
|
+
var _a;
|
|
682
|
+
if (!PlaitBoard.isBoard(node) &&
|
|
683
|
+
((_a = board.selection) === null || _a === void 0 ? void 0 : _a.ranges.some(range => {
|
|
684
|
+
return board.isHitSelection(node, range);
|
|
685
|
+
}))) {
|
|
686
|
+
selectedElements.push(node);
|
|
687
|
+
}
|
|
688
|
+
}, node => {
|
|
689
|
+
if (PlaitBoard.isBoard(node) || board.isRecursion(node)) {
|
|
690
|
+
return true;
|
|
691
|
+
}
|
|
692
|
+
else {
|
|
693
|
+
return false;
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
return selectedElements;
|
|
697
|
+
};
|
|
698
|
+
const isIntersectionElements = (board, elements, ranges) => {
|
|
699
|
+
let isIntersectionElements = false;
|
|
700
|
+
if (elements.length) {
|
|
701
|
+
elements.map(item => {
|
|
702
|
+
if (!isIntersectionElements) {
|
|
703
|
+
isIntersectionElements = ranges.some(range => {
|
|
704
|
+
return board.isHitSelection(item, range);
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
return isIntersectionElements;
|
|
710
|
+
};
|
|
711
|
+
const cacheSelectedElements = (board, selectedElements) => {
|
|
712
|
+
BOARD_TO_SELECTED_ELEMENT.set(board, selectedElements);
|
|
713
|
+
};
|
|
714
|
+
const getSelectedElements = (board) => {
|
|
715
|
+
return BOARD_TO_SELECTED_ELEMENT.get(board) || [];
|
|
716
|
+
};
|
|
717
|
+
const addSelectedElement = (board, element) => {
|
|
718
|
+
const selectedElements = getSelectedElements(board);
|
|
719
|
+
cacheSelectedElements(board, [...selectedElements, element]);
|
|
720
|
+
};
|
|
721
|
+
const removeSelectedElement = (board, element) => {
|
|
722
|
+
const selectedElements = getSelectedElements(board);
|
|
723
|
+
const newSelectedElements = selectedElements.filter(value => value !== element);
|
|
724
|
+
cacheSelectedElements(board, newSelectedElements);
|
|
725
|
+
};
|
|
726
|
+
const isSelectedElement = (board, element) => {
|
|
727
|
+
const selectedElements = getSelectedElements(board);
|
|
728
|
+
return !!selectedElements.find(value => value === element);
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
function hasBeforeContextChange(value) {
|
|
732
|
+
if (value.beforeContextChange) {
|
|
733
|
+
return true;
|
|
734
|
+
}
|
|
735
|
+
return false;
|
|
736
|
+
}
|
|
737
|
+
function hasOnContextChanged(value) {
|
|
738
|
+
if (value.onContextChanged) {
|
|
739
|
+
return true;
|
|
740
|
+
}
|
|
741
|
+
return false;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
class PlaitPluginElementComponent {
|
|
745
|
+
set context(value) {
|
|
746
|
+
if (hasBeforeContextChange(this)) {
|
|
747
|
+
this.beforeContextChange(value);
|
|
748
|
+
}
|
|
749
|
+
const previousContext = this._context;
|
|
750
|
+
this._context = value;
|
|
751
|
+
if (this.element) {
|
|
752
|
+
ELEMENT_TO_COMPONENT.set(this.element, this);
|
|
753
|
+
}
|
|
754
|
+
if (this.initialized) {
|
|
755
|
+
this.cdr.markForCheck();
|
|
756
|
+
if (hasOnContextChanged(this)) {
|
|
757
|
+
this.onContextChanged(value, previousContext);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
else {
|
|
761
|
+
if (PlaitElement.isRootElement(this.element) && this.element.children && this.element.children.length > 0) {
|
|
762
|
+
this.g = createG();
|
|
763
|
+
this.rootG = createG();
|
|
764
|
+
this.rootG.append(this.g);
|
|
765
|
+
}
|
|
766
|
+
else {
|
|
767
|
+
this.g = createG();
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
get context() {
|
|
772
|
+
return this._context;
|
|
773
|
+
}
|
|
774
|
+
get element() {
|
|
775
|
+
return this.context && this.context.element;
|
|
776
|
+
}
|
|
777
|
+
get board() {
|
|
778
|
+
return this.context && this.context.board;
|
|
779
|
+
}
|
|
780
|
+
get selected() {
|
|
781
|
+
return this.context && this.context.selected;
|
|
782
|
+
}
|
|
783
|
+
get effect() {
|
|
784
|
+
return this.context && this.context.effect;
|
|
785
|
+
}
|
|
786
|
+
constructor(cdr) {
|
|
787
|
+
this.cdr = cdr;
|
|
788
|
+
this.initialized = false;
|
|
789
|
+
}
|
|
790
|
+
ngOnInit() {
|
|
791
|
+
if (this.element.type) {
|
|
792
|
+
(this.rootG || this.g).setAttribute(`plait-${this.element.type}`, 'true');
|
|
793
|
+
}
|
|
794
|
+
this.initialized = true;
|
|
795
|
+
}
|
|
796
|
+
ngOnDestroy() {
|
|
797
|
+
if (ELEMENT_TO_COMPONENT.get(this.element) === this) {
|
|
798
|
+
ELEMENT_TO_COMPONENT.delete(this.element);
|
|
799
|
+
}
|
|
800
|
+
removeSelectedElement(this.board, this.element);
|
|
801
|
+
(this.rootG || this.g).remove();
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
PlaitPluginElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitPluginElementComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
805
|
+
PlaitPluginElementComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: PlaitPluginElementComponent, inputs: { context: "context" }, ngImport: i0 });
|
|
806
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitPluginElementComponent, decorators: [{
|
|
807
|
+
type: Directive
|
|
808
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { context: [{
|
|
809
|
+
type: Input
|
|
810
|
+
}] } });
|
|
811
|
+
const ELEMENT_TO_COMPONENT = new WeakMap();
|
|
812
|
+
|
|
587
813
|
const PlaitElement = {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
814
|
+
isRootElement(value) {
|
|
815
|
+
const parent = NODE_TO_PARENT.get(value);
|
|
816
|
+
if (parent && PlaitBoard.isBoard(parent)) {
|
|
817
|
+
return true;
|
|
818
|
+
}
|
|
819
|
+
else {
|
|
820
|
+
return false;
|
|
821
|
+
}
|
|
822
|
+
},
|
|
823
|
+
getComponent(value) {
|
|
824
|
+
return ELEMENT_TO_COMPONENT.get(value);
|
|
591
825
|
}
|
|
592
826
|
};
|
|
593
827
|
|
|
@@ -613,6 +847,14 @@ const RectangleClient = {
|
|
|
613
847
|
const yMax = Math.max(...yArray);
|
|
614
848
|
const rect = { x: xMin, y: yMin, width: xMax - xMin, height: yMax - yMin };
|
|
615
849
|
return rect;
|
|
850
|
+
},
|
|
851
|
+
getOutlineRectangle: (rectangle, offset) => {
|
|
852
|
+
return {
|
|
853
|
+
x: rectangle.x + offset,
|
|
854
|
+
y: rectangle.y + offset,
|
|
855
|
+
width: rectangle.width + Math.abs(offset) * 2,
|
|
856
|
+
height: rectangle.height + Math.abs(offset) * 2
|
|
857
|
+
};
|
|
616
858
|
}
|
|
617
859
|
};
|
|
618
860
|
|
|
@@ -873,52 +1115,6 @@ function idCreator(length = 5) {
|
|
|
873
1115
|
return key;
|
|
874
1116
|
}
|
|
875
1117
|
|
|
876
|
-
const calcElementIntersectionSelection = (board) => {
|
|
877
|
-
const selectedElements = [];
|
|
878
|
-
depthFirstRecursion(board, node => {
|
|
879
|
-
var _a;
|
|
880
|
-
if (PlaitElement.isElement(node) &&
|
|
881
|
-
((_a = board.selection) === null || _a === void 0 ? void 0 : _a.ranges.some(range => {
|
|
882
|
-
return board.isHitSelection(node, range);
|
|
883
|
-
}))) {
|
|
884
|
-
selectedElements.push(node);
|
|
885
|
-
}
|
|
886
|
-
});
|
|
887
|
-
return selectedElements;
|
|
888
|
-
};
|
|
889
|
-
const isIntersectionElements = (board, elements, ranges) => {
|
|
890
|
-
let isIntersectionElements = false;
|
|
891
|
-
if (elements.length) {
|
|
892
|
-
elements.map(item => {
|
|
893
|
-
if (!isIntersectionElements) {
|
|
894
|
-
isIntersectionElements = ranges.some(range => {
|
|
895
|
-
return board.isHitSelection(item, range);
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
|
-
});
|
|
899
|
-
}
|
|
900
|
-
return isIntersectionElements;
|
|
901
|
-
};
|
|
902
|
-
const cacheSelectedElements = (board, selectedElements) => {
|
|
903
|
-
BOARD_TO_SELECTED_ELEMENT.set(board, selectedElements);
|
|
904
|
-
};
|
|
905
|
-
const getSelectedElements = (board) => {
|
|
906
|
-
return BOARD_TO_SELECTED_ELEMENT.get(board) || [];
|
|
907
|
-
};
|
|
908
|
-
const addSelectedElement = (board, element) => {
|
|
909
|
-
const selectedElements = getSelectedElements(board);
|
|
910
|
-
cacheSelectedElements(board, [...selectedElements, element]);
|
|
911
|
-
};
|
|
912
|
-
const removeSelectedElement = (board, element) => {
|
|
913
|
-
const selectedElements = getSelectedElements(board);
|
|
914
|
-
const newSelectedElements = selectedElements.filter(value => value !== element);
|
|
915
|
-
cacheSelectedElements(board, newSelectedElements);
|
|
916
|
-
};
|
|
917
|
-
const isSelectedElement = (board, element) => {
|
|
918
|
-
const selectedElements = getSelectedElements(board);
|
|
919
|
-
return !!selectedElements.find(value => value === element);
|
|
920
|
-
};
|
|
921
|
-
|
|
922
1118
|
const CLIP_BOARD_FORMAT_KEY = 'x-plait-fragment';
|
|
923
1119
|
const SCROLL_BAR_WIDTH = 20;
|
|
924
1120
|
const MAX_RADIUS = 16;
|
|
@@ -944,6 +1140,48 @@ function drawRoundRectangle(rs, x1, y1, x2, y2, options, outline = false, border
|
|
|
944
1140
|
const point8 = [x1, y1 + radius];
|
|
945
1141
|
return rs.path(`M${point2[0]} ${point2[1]} A ${radius} ${radius}, 0, 0, 1, ${point3[0]} ${point3[1]} L ${point4[0]} ${point4[1]} A ${radius} ${radius}, 0, 0, 1, ${point5[0]} ${point5[1]} L ${point6[0]} ${point6[1]} A ${radius} ${radius}, 0, 0, 1, ${point7[0]} ${point7[1]} L ${point8[0]} ${point8[1]} A ${radius} ${radius}, 0, 0, 1, ${point1[0]} ${point1[1]} Z`, options);
|
|
946
1142
|
}
|
|
1143
|
+
function drawAbstractRoundRectangle(rs, x1, y1, x2, y2, isHorizontal, options) {
|
|
1144
|
+
const width = Math.abs(x1 - x2);
|
|
1145
|
+
const height = Math.abs(y1 - y2);
|
|
1146
|
+
const radius = 3;
|
|
1147
|
+
const handleGap = 4;
|
|
1148
|
+
const handleLength = 10;
|
|
1149
|
+
const handleSpace = handleLength + handleGap * 2;
|
|
1150
|
+
if (isHorizontal) {
|
|
1151
|
+
const handleSideLine = (width - handleSpace - radius * 2) / 2;
|
|
1152
|
+
const sideLine = height - radius * 2;
|
|
1153
|
+
return rs.path(`M${x1 + radius},${y1}
|
|
1154
|
+
l${handleSideLine},0
|
|
1155
|
+
m${handleSpace},0
|
|
1156
|
+
l${handleSideLine},0
|
|
1157
|
+
a${radius},${radius},0,0,1,${radius},${radius}
|
|
1158
|
+
l0,${sideLine}
|
|
1159
|
+
a${radius},${radius},0,0,1,-${radius},${radius}
|
|
1160
|
+
l-${handleSideLine},0
|
|
1161
|
+
m-${handleSpace},0
|
|
1162
|
+
l-${handleSideLine},0
|
|
1163
|
+
a${radius},${radius},0,0,1,-${radius},-${radius}
|
|
1164
|
+
l0,-${sideLine}
|
|
1165
|
+
a${radius},${radius},0,0,1,${radius},-${radius}`, options);
|
|
1166
|
+
}
|
|
1167
|
+
else {
|
|
1168
|
+
const handleSideLine = (height - handleSpace - radius * 2) / 2;
|
|
1169
|
+
const sideLine = width - radius * 2;
|
|
1170
|
+
return rs.path(`M${x1 + radius},${y1}
|
|
1171
|
+
l${sideLine},0
|
|
1172
|
+
a${radius},${radius},0,0,1,${radius},${radius}
|
|
1173
|
+
l0,${handleSideLine}
|
|
1174
|
+
m0,${handleSpace}
|
|
1175
|
+
l0,${handleSideLine}
|
|
1176
|
+
a${radius},${radius},0,0,1,-${radius},${radius}
|
|
1177
|
+
l-${sideLine},0
|
|
1178
|
+
a${radius},${radius},0,0,1,-${radius},-${radius}
|
|
1179
|
+
l0,-${handleSideLine}
|
|
1180
|
+
m0,-${handleSpace}
|
|
1181
|
+
l0,-${handleSideLine}
|
|
1182
|
+
a${radius},${radius},0,0,1,${radius},-${radius}`, options);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
947
1185
|
|
|
948
1186
|
function arrowPoints(start, end, maxHypotenuseLength = 10, degree = 40) {
|
|
949
1187
|
const width = Math.abs(start[0] - end[0]);
|
|
@@ -967,6 +1205,14 @@ function drawArrow(rs, start, end, options, maxHypotenuseLength = 10, degree = 4
|
|
|
967
1205
|
return [arrowLineLeft, arrowLineRight];
|
|
968
1206
|
}
|
|
969
1207
|
|
|
1208
|
+
function drawCircle(roughSVG, point, diameter, options) {
|
|
1209
|
+
return roughSVG.circle(point[0], point[1], diameter, options);
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
function drawLine(rs, start, end, options) {
|
|
1213
|
+
return rs.linearPath([start, end], options);
|
|
1214
|
+
}
|
|
1215
|
+
|
|
970
1216
|
const IS_FROM_SCROLLING = new WeakMap();
|
|
971
1217
|
const IS_FROM_VIEWPORT_CHANGE = new WeakMap();
|
|
972
1218
|
function getViewportContainerRect(board) {
|
|
@@ -1278,6 +1524,7 @@ function createBoard(children, options) {
|
|
|
1278
1524
|
destroyElement: (context) => { },
|
|
1279
1525
|
isWithinSelection: element => false,
|
|
1280
1526
|
isHitSelection: element => false,
|
|
1527
|
+
isRecursion: element => true,
|
|
1281
1528
|
isMovable: element => false,
|
|
1282
1529
|
getRectangle: element => null
|
|
1283
1530
|
};
|
|
@@ -1462,7 +1709,7 @@ function withSelection(board) {
|
|
|
1462
1709
|
return;
|
|
1463
1710
|
}
|
|
1464
1711
|
Transforms.setSelection(board, { ranges: ranges });
|
|
1465
|
-
if (
|
|
1712
|
+
if (getHitElements(board).length || board.pointer === PlaitPointerType.hand) {
|
|
1466
1713
|
start = null;
|
|
1467
1714
|
}
|
|
1468
1715
|
}
|
|
@@ -1516,7 +1763,7 @@ function withSelection(board) {
|
|
|
1516
1763
|
if (board.operations.find(value => value.type === 'set_selection')) {
|
|
1517
1764
|
selectionOuterG === null || selectionOuterG === void 0 ? void 0 : selectionOuterG.remove();
|
|
1518
1765
|
const temporaryElements = getTemporaryElements(board);
|
|
1519
|
-
const elements = temporaryElements ? temporaryElements :
|
|
1766
|
+
const elements = temporaryElements ? temporaryElements : getHitElements(board);
|
|
1520
1767
|
cacheSelectedElements(board, elements);
|
|
1521
1768
|
previousSelectedElements = elements;
|
|
1522
1769
|
const { width, height } = getRectangleByElements(board, elements, false);
|
|
@@ -1620,7 +1867,7 @@ function withMoving(board) {
|
|
|
1620
1867
|
const host = BOARD_TO_HOST.get(board);
|
|
1621
1868
|
const point = transformPoint(board, toPoint(event.x, event.y, host));
|
|
1622
1869
|
const ranges = [{ anchor: point, focus: point }];
|
|
1623
|
-
let movableElements = board.children.filter(item =>
|
|
1870
|
+
let movableElements = board.children.filter(item => board.isMovable(item));
|
|
1624
1871
|
if (movableElements.length) {
|
|
1625
1872
|
startPoint = point;
|
|
1626
1873
|
const selectedRootElements = getSelectedElements(board).filter(item => movableElements.includes(item));
|
|
@@ -1698,71 +1945,76 @@ class PlaitElementComponent {
|
|
|
1698
1945
|
this.renderer2 = renderer2;
|
|
1699
1946
|
this.viewContainerRef = viewContainerRef;
|
|
1700
1947
|
this.initialized = false;
|
|
1701
|
-
this.selection = null;
|
|
1702
1948
|
}
|
|
1703
1949
|
ngOnInit() {
|
|
1704
1950
|
this.initialize();
|
|
1705
1951
|
this.drawElement();
|
|
1706
1952
|
}
|
|
1707
1953
|
initialize() {
|
|
1954
|
+
NODE_TO_INDEX.set(this.element, this.index);
|
|
1955
|
+
NODE_TO_PARENT.set(this.element, this.parent);
|
|
1708
1956
|
this.initialized = true;
|
|
1709
|
-
this.gGroup = createG();
|
|
1710
|
-
this.renderer2.setAttribute(this.gGroup, 'plait-element-group', this.index.toString());
|
|
1711
|
-
PlaitBoard.getElementHost(this.board).append(this.gGroup);
|
|
1712
1957
|
}
|
|
1713
1958
|
drawElement() {
|
|
1714
1959
|
const context = this.getContext();
|
|
1715
|
-
const result = this.board.drawElement(context
|
|
1960
|
+
const result = this.board.drawElement(context);
|
|
1716
1961
|
if (Array.isArray(result)) {
|
|
1717
|
-
result.forEach(g => {
|
|
1718
|
-
this.gGroup.appendChild(g);
|
|
1719
|
-
});
|
|
1720
1962
|
}
|
|
1721
1963
|
else {
|
|
1722
1964
|
const componentRef = this.viewContainerRef.createComponent(result);
|
|
1723
1965
|
const instance = componentRef.instance;
|
|
1724
|
-
instance.context = context
|
|
1725
|
-
this.
|
|
1966
|
+
instance.context = context;
|
|
1967
|
+
this.insertG(instance.rootG ? instance.rootG : instance.g);
|
|
1726
1968
|
this.instance = instance;
|
|
1727
1969
|
}
|
|
1728
1970
|
}
|
|
1729
|
-
|
|
1971
|
+
insertG(g) {
|
|
1972
|
+
if (PlaitBoard.isBoard(this.parent)) {
|
|
1973
|
+
this.parentG.prepend(g);
|
|
1974
|
+
}
|
|
1975
|
+
else {
|
|
1976
|
+
let siblingG = PlaitElement.getComponent(this.parent).g;
|
|
1977
|
+
if (this.index > 0) {
|
|
1978
|
+
const brotherElement = this.parent.children[this.index - 1];
|
|
1979
|
+
const lastElement = PlaitNode.last(this.board, PlaitBoard.findPath(this.board, brotherElement));
|
|
1980
|
+
const siblingElement = lastElement || brotherElement;
|
|
1981
|
+
siblingG = PlaitElement.getComponent(siblingElement).g;
|
|
1982
|
+
}
|
|
1983
|
+
this.parentG.insertBefore(g, siblingG);
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
ngOnChanges(simpleChanges) {
|
|
1730
1987
|
if (this.initialized) {
|
|
1988
|
+
NODE_TO_INDEX.set(this.element, this.index);
|
|
1989
|
+
NODE_TO_PARENT.set(this.element, this.parent);
|
|
1990
|
+
const elementChanged = simpleChanges['element'];
|
|
1731
1991
|
const context = this.getContext();
|
|
1732
|
-
if (this.
|
|
1733
|
-
|
|
1992
|
+
if (elementChanged && isSelectedElement(this.board, elementChanged.previousValue)) {
|
|
1993
|
+
context.selected = true;
|
|
1994
|
+
removeSelectedElement(this.board, elementChanged.previousValue);
|
|
1995
|
+
addSelectedElement(this.board, this.element);
|
|
1734
1996
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
this.gGroup.childNodes.forEach(g => g.remove());
|
|
1738
|
-
result.forEach(g => {
|
|
1739
|
-
this.gGroup.appendChild(g);
|
|
1740
|
-
});
|
|
1997
|
+
if (this.instance) {
|
|
1998
|
+
this.instance.context = context;
|
|
1741
1999
|
}
|
|
1742
2000
|
}
|
|
1743
2001
|
}
|
|
1744
2002
|
getContext() {
|
|
1745
|
-
const
|
|
2003
|
+
const isSelected = isSelectedElement(this.board, this.element);
|
|
2004
|
+
const context = {
|
|
1746
2005
|
element: this.element,
|
|
1747
|
-
|
|
1748
|
-
|
|
2006
|
+
board: this.board,
|
|
2007
|
+
selected: isSelected,
|
|
2008
|
+
effect: this.effect
|
|
1749
2009
|
};
|
|
1750
|
-
|
|
1751
|
-
const previous = Object.assign({}, this.context);
|
|
1752
|
-
this.context = current;
|
|
1753
|
-
return { current, previous };
|
|
1754
|
-
}
|
|
1755
|
-
else {
|
|
1756
|
-
return { current };
|
|
1757
|
-
}
|
|
2010
|
+
return context;
|
|
1758
2011
|
}
|
|
1759
2012
|
ngOnDestroy() {
|
|
1760
|
-
this.
|
|
1761
|
-
this.board.destroyElement(this.getContext().current);
|
|
2013
|
+
this.board.destroyElement(this.getContext());
|
|
1762
2014
|
}
|
|
1763
2015
|
}
|
|
1764
2016
|
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 });
|
|
1765
|
-
PlaitElementComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: PlaitElementComponent, selector: "plait-element", inputs: { index: "index", element: "element", board: "board",
|
|
2017
|
+
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 });
|
|
1766
2018
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitElementComponent, decorators: [{
|
|
1767
2019
|
type: Component,
|
|
1768
2020
|
args: [{
|
|
@@ -1774,11 +2026,66 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
1774
2026
|
type: Input
|
|
1775
2027
|
}], element: [{
|
|
1776
2028
|
type: Input
|
|
2029
|
+
}], parent: [{
|
|
2030
|
+
type: Input
|
|
1777
2031
|
}], board: [{
|
|
1778
2032
|
type: Input
|
|
1779
|
-
}],
|
|
2033
|
+
}], effect: [{
|
|
2034
|
+
type: Input
|
|
2035
|
+
}], parentG: [{
|
|
2036
|
+
type: Input
|
|
2037
|
+
}] } });
|
|
2038
|
+
|
|
2039
|
+
class PlaitChildrenElement {
|
|
2040
|
+
constructor() {
|
|
2041
|
+
this.trackBy = (index, element) => {
|
|
2042
|
+
return element.id;
|
|
2043
|
+
};
|
|
2044
|
+
}
|
|
2045
|
+
ngOnInit() {
|
|
2046
|
+
if (!this.parent) {
|
|
2047
|
+
this.parent = this.board;
|
|
2048
|
+
}
|
|
2049
|
+
if (!this.parentG) {
|
|
2050
|
+
this.parentG = PlaitBoard.getElementHost(this.board);
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
PlaitChildrenElement.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitChildrenElement, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2055
|
+
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: `
|
|
2056
|
+
<plait-element
|
|
2057
|
+
*ngFor="let item of parent.children; let index = index; trackBy: trackBy"
|
|
2058
|
+
[index]="index"
|
|
2059
|
+
[element]="item"
|
|
2060
|
+
[parent]="parent"
|
|
2061
|
+
[board]="board"
|
|
2062
|
+
[effect]="effect"
|
|
2063
|
+
[parentG]="parentG"
|
|
2064
|
+
></plait-element>
|
|
2065
|
+
`, 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"] }] });
|
|
2066
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitChildrenElement, decorators: [{
|
|
2067
|
+
type: Component,
|
|
2068
|
+
args: [{
|
|
2069
|
+
selector: 'plait-children',
|
|
2070
|
+
template: `
|
|
2071
|
+
<plait-element
|
|
2072
|
+
*ngFor="let item of parent.children; let index = index; trackBy: trackBy"
|
|
2073
|
+
[index]="index"
|
|
2074
|
+
[element]="item"
|
|
2075
|
+
[parent]="parent"
|
|
2076
|
+
[board]="board"
|
|
2077
|
+
[effect]="effect"
|
|
2078
|
+
[parentG]="parentG"
|
|
2079
|
+
></plait-element>
|
|
2080
|
+
`
|
|
2081
|
+
}]
|
|
2082
|
+
}], ctorParameters: function () { return []; }, propDecorators: { board: [{
|
|
2083
|
+
type: Input
|
|
2084
|
+
}], parent: [{
|
|
2085
|
+
type: Input
|
|
2086
|
+
}], effect: [{
|
|
1780
2087
|
type: Input
|
|
1781
|
-
}],
|
|
2088
|
+
}], parentG: [{
|
|
1782
2089
|
type: Input
|
|
1783
2090
|
}] } });
|
|
1784
2091
|
|
|
@@ -1855,12 +2162,12 @@ class PlaitBoardComponent {
|
|
|
1855
2162
|
get nativeElement() {
|
|
1856
2163
|
return this.elementRef.nativeElement;
|
|
1857
2164
|
}
|
|
1858
|
-
constructor(cdr,
|
|
2165
|
+
constructor(cdr, elementRef, ngZone) {
|
|
1859
2166
|
this.cdr = cdr;
|
|
1860
|
-
this.renderer2 = renderer2;
|
|
1861
2167
|
this.elementRef = elementRef;
|
|
1862
2168
|
this.ngZone = ngZone;
|
|
1863
2169
|
this.hasInitialized = false;
|
|
2170
|
+
this.effect = {};
|
|
1864
2171
|
this.destroy$ = new Subject();
|
|
1865
2172
|
this.plaitValue = [];
|
|
1866
2173
|
this.plaitPlugins = [];
|
|
@@ -1886,7 +2193,7 @@ class PlaitBoardComponent {
|
|
|
1886
2193
|
BOARD_TO_HOST.set(this.board, this.host);
|
|
1887
2194
|
BOARD_TO_ELEMENT_HOST.set(this.board, elementHost);
|
|
1888
2195
|
BOARD_TO_ON_CHANGE.set(this.board, () => {
|
|
1889
|
-
this.
|
|
2196
|
+
this.detect();
|
|
1890
2197
|
const changeEvent = {
|
|
1891
2198
|
children: this.board.children,
|
|
1892
2199
|
operations: this.board.operations,
|
|
@@ -1897,6 +2204,10 @@ class PlaitBoardComponent {
|
|
|
1897
2204
|
});
|
|
1898
2205
|
this.hasInitialized = true;
|
|
1899
2206
|
}
|
|
2207
|
+
detect() {
|
|
2208
|
+
this.effect = {};
|
|
2209
|
+
this.cdr.detectChanges();
|
|
2210
|
+
}
|
|
1900
2211
|
mouseLeaveListener() {
|
|
1901
2212
|
fromEvent(this.host, 'mouseleave')
|
|
1902
2213
|
.pipe(takeUntil(this.destroy$))
|
|
@@ -2068,17 +2379,11 @@ class PlaitBoardComponent {
|
|
|
2068
2379
|
this.cdr.markForCheck();
|
|
2069
2380
|
}
|
|
2070
2381
|
}
|
|
2071
|
-
PlaitBoardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitBoardComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.
|
|
2382
|
+
PlaitBoardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitBoardComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
2072
2383
|
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: "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: `
|
|
2073
2384
|
<div class="viewport-container" #viewportContainer>
|
|
2074
2385
|
<svg #svg width="100%" height="100%" style="position: relative;"><g class="element-host"></g></svg>
|
|
2075
|
-
<plait-
|
|
2076
|
-
*ngFor="let item of board.children; let index = index; trackBy: trackBy"
|
|
2077
|
-
[index]="index"
|
|
2078
|
-
[element]="item"
|
|
2079
|
-
[board]="board"
|
|
2080
|
-
[selection]="board.selection"
|
|
2081
|
-
></plait-element>
|
|
2386
|
+
<plait-children [board]="board" [effect]="effect"></plait-children>
|
|
2082
2387
|
</div>
|
|
2083
2388
|
<plait-toolbar
|
|
2084
2389
|
*ngIf="isFocused && !toolbarTemplateRef"
|
|
@@ -2089,7 +2394,7 @@ PlaitBoardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", ve
|
|
|
2089
2394
|
(resetZoomHandel)="resetZoomHandel()"
|
|
2090
2395
|
></plait-toolbar>
|
|
2091
2396
|
<ng-content></ng-content>
|
|
2092
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: i1.
|
|
2397
|
+
`, 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 });
|
|
2093
2398
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitBoardComponent, decorators: [{
|
|
2094
2399
|
type: Component,
|
|
2095
2400
|
args: [{
|
|
@@ -2097,13 +2402,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
2097
2402
|
template: `
|
|
2098
2403
|
<div class="viewport-container" #viewportContainer>
|
|
2099
2404
|
<svg #svg width="100%" height="100%" style="position: relative;"><g class="element-host"></g></svg>
|
|
2100
|
-
<plait-
|
|
2101
|
-
*ngFor="let item of board.children; let index = index; trackBy: trackBy"
|
|
2102
|
-
[index]="index"
|
|
2103
|
-
[element]="item"
|
|
2104
|
-
[board]="board"
|
|
2105
|
-
[selection]="board.selection"
|
|
2106
|
-
></plait-element>
|
|
2405
|
+
<plait-children [board]="board" [effect]="effect"></plait-children>
|
|
2107
2406
|
</div>
|
|
2108
2407
|
<plait-toolbar
|
|
2109
2408
|
*ngIf="isFocused && !toolbarTemplateRef"
|
|
@@ -2117,7 +2416,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
2117
2416
|
`,
|
|
2118
2417
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
2119
2418
|
}]
|
|
2120
|
-
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.
|
|
2419
|
+
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { plaitValue: [{
|
|
2121
2420
|
type: Input
|
|
2122
2421
|
}], plaitViewport: [{
|
|
2123
2422
|
type: Input
|
|
@@ -2149,80 +2448,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
2149
2448
|
args: ['viewportContainer', { read: ElementRef, static: true }]
|
|
2150
2449
|
}] } });
|
|
2151
2450
|
|
|
2152
|
-
|
|
2153
|
-
if (value.beforeContextChange) {
|
|
2154
|
-
return true;
|
|
2155
|
-
}
|
|
2156
|
-
return false;
|
|
2157
|
-
}
|
|
2158
|
-
|
|
2159
|
-
class PlaitPluginElementComponent {
|
|
2160
|
-
set context(value) {
|
|
2161
|
-
if (hasBeforeContextChange(this)) {
|
|
2162
|
-
this.beforeContextChange(value);
|
|
2163
|
-
}
|
|
2164
|
-
const elementChanged = this.element && this.element !== value.element;
|
|
2165
|
-
if (elementChanged) {
|
|
2166
|
-
if (isSelectedElement(this.board, this.element)) {
|
|
2167
|
-
removeSelectedElement(this.board, this.element);
|
|
2168
|
-
addSelectedElement(this.board, value.element);
|
|
2169
|
-
}
|
|
2170
|
-
}
|
|
2171
|
-
this._context = value;
|
|
2172
|
-
if (this.element) {
|
|
2173
|
-
ELEMENT_TO_PLUGIN_COMPONENT.set(this.element, this);
|
|
2174
|
-
}
|
|
2175
|
-
this.onContextChange();
|
|
2176
|
-
}
|
|
2177
|
-
get context() {
|
|
2178
|
-
return this._context;
|
|
2179
|
-
}
|
|
2180
|
-
get element() {
|
|
2181
|
-
return this.context && this.context.element;
|
|
2182
|
-
}
|
|
2183
|
-
get selection() {
|
|
2184
|
-
return this.context && this.context.selection;
|
|
2185
|
-
}
|
|
2186
|
-
get board() {
|
|
2187
|
-
return this.context && this.context.board;
|
|
2188
|
-
}
|
|
2189
|
-
constructor(cdr) {
|
|
2190
|
-
this.cdr = cdr;
|
|
2191
|
-
this.initialized = false;
|
|
2192
|
-
this.g = createG();
|
|
2193
|
-
}
|
|
2194
|
-
onContextChange() {
|
|
2195
|
-
if (!this.initialized) {
|
|
2196
|
-
return;
|
|
2197
|
-
}
|
|
2198
|
-
this.cdr.markForCheck();
|
|
2199
|
-
}
|
|
2200
|
-
ngOnInit() {
|
|
2201
|
-
var _a;
|
|
2202
|
-
const type = ((_a = this.element) === null || _a === void 0 ? void 0 : _a.type) || 'default-plugin-element';
|
|
2203
|
-
this.g.setAttribute(`plait-${type}`, 'true');
|
|
2204
|
-
this.initialized = true;
|
|
2205
|
-
}
|
|
2206
|
-
ngOnDestroy() {
|
|
2207
|
-
ELEMENT_TO_PLUGIN_COMPONENT.delete(this.element);
|
|
2208
|
-
removeSelectedElement(this.board, this.element);
|
|
2209
|
-
this.g.remove();
|
|
2210
|
-
}
|
|
2211
|
-
}
|
|
2212
|
-
PlaitPluginElementComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitPluginElementComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
2213
|
-
PlaitPluginElementComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: PlaitPluginElementComponent, inputs: { context: "context" }, ngImport: i0 });
|
|
2214
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitPluginElementComponent, decorators: [{
|
|
2215
|
-
type: Directive
|
|
2216
|
-
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { context: [{
|
|
2217
|
-
type: Input
|
|
2218
|
-
}] } });
|
|
2219
|
-
const ELEMENT_TO_PLUGIN_COMPONENT = new WeakMap();
|
|
2220
|
-
|
|
2221
|
-
const COMPONENTS = [PlaitBoardComponent, PlaitElementComponent, PlaitToolbarComponent];
|
|
2451
|
+
const COMPONENTS = [PlaitBoardComponent, PlaitChildrenElement, PlaitElementComponent, PlaitToolbarComponent];
|
|
2222
2452
|
class PlaitModule {
|
|
2223
2453
|
}
|
|
2224
2454
|
PlaitModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2225
|
-
PlaitModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, declarations: [PlaitBoardComponent, PlaitElementComponent, PlaitToolbarComponent], imports: [BrowserModule], exports: [PlaitBoardComponent, PlaitElementComponent, PlaitToolbarComponent] });
|
|
2455
|
+
PlaitModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, declarations: [PlaitBoardComponent, PlaitChildrenElement, PlaitElementComponent, PlaitToolbarComponent], imports: [BrowserModule], exports: [PlaitBoardComponent, PlaitChildrenElement, PlaitElementComponent, PlaitToolbarComponent] });
|
|
2226
2456
|
PlaitModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, imports: [BrowserModule] });
|
|
2227
2457
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitModule, decorators: [{
|
|
2228
2458
|
type: NgModule,
|
|
@@ -2241,5 +2471,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
2241
2471
|
* Generated bundle index. Do not edit.
|
|
2242
2472
|
*/
|
|
2243
2473
|
|
|
2244
|
-
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,
|
|
2474
|
+
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, 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, clearSelectionMoving, clearViewportOrigination, createG, createSVG, createSelectionOuterG, createText, debounce, deleteTemporaryElements, depthFirstRecursion, distanceBetweenPointAndPoint, distanceBetweenPointAndRectangle, distanceBetweenPointAndSegment, drawAbstractRoundRectangle, drawArrow, drawCircle, drawLine, drawRoundRectangle, fitViewport, getBoardRectangle, getElementHostBBox, getHitElements, getMovingElements, getRectangleByElements, getSelectedElements, getTemporaryElements, getViewBox, getViewportContainerRect, getViewportOrigination, hasBeforeContextChange, hasOnContextChanged, hotkeys, idCreator, initializeViewBox, initializeViewportContainer, initializeViewportOffset, inverse, 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, updateViewportContainerScroll, updateViewportOffset, updateViewportOrigination, withMoving, withSelection };
|
|
2245
2475
|
//# sourceMappingURL=plait-core.mjs.map
|