@plait/core 0.13.0 β 0.15.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/constants/index.d.ts +1 -0
- package/core/island/island-base.component.d.ts +18 -1
- package/esm2020/board/board.component.mjs +17 -29
- package/esm2020/constants/index.mjs +2 -1
- package/esm2020/core/island/island-base.component.mjs +38 -2
- package/esm2020/interfaces/board.mjs +13 -4
- package/esm2020/plugins/create-board.mjs +2 -1
- package/esm2020/plugins/with-hotkey.mjs +54 -0
- package/esm2020/transforms/board.mjs +2 -2
- package/esm2020/utils/draw/line.mjs +20 -1
- package/esm2020/utils/weak-maps.mjs +2 -1
- package/fesm2015/plait-core.mjs +182 -79
- package/fesm2015/plait-core.mjs.map +1 -1
- package/fesm2020/plait-core.mjs +182 -79
- package/fesm2020/plait-core.mjs.map +1 -1
- package/interfaces/board.d.ts +3 -1
- package/package.json +1 -1
- package/plugins/with-hotkey.d.ts +2 -0
- package/utils/draw/line.d.ts +1 -0
- package/utils/weak-maps.d.ts +1 -0
package/fesm2020/plait-core.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import rough from 'roughjs/bin/rough';
|
|
|
4
4
|
import { timer, Subject, fromEvent } from 'rxjs';
|
|
5
5
|
import { takeUntil, filter, tap } from 'rxjs/operators';
|
|
6
6
|
import produce, { createDraft, finishDraft, isDraft } from 'immer';
|
|
7
|
-
import { isKeyHotkey, isHotkey } from 'is-hotkey';
|
|
7
|
+
import isHotkey$1, { isKeyHotkey, isHotkey } from 'is-hotkey';
|
|
8
8
|
import * as i1 from '@angular/common';
|
|
9
9
|
import { CommonModule } from '@angular/common';
|
|
10
10
|
|
|
@@ -20,6 +20,7 @@ const BOARD_TO_ROUGH_SVG = new WeakMap();
|
|
|
20
20
|
const BOARD_TO_HOST = new WeakMap();
|
|
21
21
|
const BOARD_TO_ELEMENT_HOST = new WeakMap();
|
|
22
22
|
const BOARD_TO_SELECTED_ELEMENT = new WeakMap();
|
|
23
|
+
const BOARD_TO_MOVING_POINT_IN_BOARD = new WeakMap();
|
|
23
24
|
const BOARD_TO_MOVING_POINT = new WeakMap();
|
|
24
25
|
const BOARD_TO_VIEWPORT_ORIGINATION = new WeakMap();
|
|
25
26
|
const BOARD_TO_IS_SELECTION_MOVING = new WeakMap();
|
|
@@ -133,6 +134,54 @@ const ThemeColors = [
|
|
|
133
134
|
StarryThemeColor
|
|
134
135
|
];
|
|
135
136
|
|
|
137
|
+
// https://stackoverflow.com/a/6853926/232122
|
|
138
|
+
function distanceBetweenPointAndSegment(x, y, x1, y1, x2, y2) {
|
|
139
|
+
const A = x - x1;
|
|
140
|
+
const B = y - y1;
|
|
141
|
+
const C = x2 - x1;
|
|
142
|
+
const D = y2 - y1;
|
|
143
|
+
const dot = A * C + B * D;
|
|
144
|
+
const lenSquare = C * C + D * D;
|
|
145
|
+
let param = -1;
|
|
146
|
+
if (lenSquare !== 0) {
|
|
147
|
+
// in case of 0 length line
|
|
148
|
+
param = dot / lenSquare;
|
|
149
|
+
}
|
|
150
|
+
let xx, yy;
|
|
151
|
+
if (param < 0) {
|
|
152
|
+
xx = x1;
|
|
153
|
+
yy = y1;
|
|
154
|
+
}
|
|
155
|
+
else if (param > 1) {
|
|
156
|
+
xx = x2;
|
|
157
|
+
yy = y2;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
xx = x1 + param * C;
|
|
161
|
+
yy = y1 + param * D;
|
|
162
|
+
}
|
|
163
|
+
const dx = x - xx;
|
|
164
|
+
const dy = y - yy;
|
|
165
|
+
return Math.hypot(dx, dy);
|
|
166
|
+
}
|
|
167
|
+
function rotate(x1, y1, x2, y2, angle) {
|
|
168
|
+
// πβ²π₯=(ππ₯βππ₯)cosπβ(ππ¦βππ¦)sinπ+ππ₯
|
|
169
|
+
// πβ²π¦=(ππ₯βππ₯)sinπ+(ππ¦βππ¦)cosπ+ππ¦.
|
|
170
|
+
// https://math.stackexchange.com/questions/2204520/how-do-i-rotate-a-line-segment-in-a-specific-point-on-the-line
|
|
171
|
+
return [(x1 - x2) * Math.cos(angle) - (y1 - y2) * Math.sin(angle) + x2, (x1 - x2) * Math.sin(angle) + (y1 - y2) * Math.cos(angle) + y2];
|
|
172
|
+
}
|
|
173
|
+
function distanceBetweenPointAndPoint(x1, y1, x2, y2) {
|
|
174
|
+
const dx = x1 - x2;
|
|
175
|
+
const dy = y1 - y2;
|
|
176
|
+
return Math.hypot(dx, dy);
|
|
177
|
+
}
|
|
178
|
+
// https://stackoverflow.com/questions/5254838/calculating-distance-between-a-point-and-a-rectangular-box-nearest-point
|
|
179
|
+
function distanceBetweenPointAndRectangle(x, y, rect) {
|
|
180
|
+
var dx = Math.max(rect.x - x, 0, x - (rect.x + rect.width));
|
|
181
|
+
var dy = Math.max(rect.y - y, 0, y - (rect.y + rect.height));
|
|
182
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
183
|
+
}
|
|
184
|
+
|
|
136
185
|
const PlaitBoard = {
|
|
137
186
|
isBoard(value) {
|
|
138
187
|
const cachedIsBoard = IS_BOARD_CACHE.get(value);
|
|
@@ -201,8 +250,16 @@ const PlaitBoard = {
|
|
|
201
250
|
isPointer(board, pointer) {
|
|
202
251
|
return board.pointer === pointer;
|
|
203
252
|
},
|
|
204
|
-
|
|
205
|
-
return
|
|
253
|
+
getMovingPointInBoard(board) {
|
|
254
|
+
return BOARD_TO_MOVING_POINT_IN_BOARD.get(board);
|
|
255
|
+
},
|
|
256
|
+
isMovingPointInBoard(board) {
|
|
257
|
+
const point = BOARD_TO_MOVING_POINT.get(board);
|
|
258
|
+
const rect = PlaitBoard.getBoardContainer(board).getBoundingClientRect();
|
|
259
|
+
if (point && distanceBetweenPointAndRectangle(point[0], point[1], rect) === 0) {
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
return false;
|
|
206
263
|
},
|
|
207
264
|
getThemeColors(board) {
|
|
208
265
|
return (board.options.themeColors || ThemeColors);
|
|
@@ -786,6 +843,7 @@ const SINGLE_QUOTE = 222;
|
|
|
786
843
|
const MAC_META = 224;
|
|
787
844
|
|
|
788
845
|
const CLIP_BOARD_FORMAT_KEY = 'x-plait-fragment';
|
|
846
|
+
const HOST_CLASS_NAME = 'plait-board-container';
|
|
789
847
|
const SCROLL_BAR_WIDTH = 20;
|
|
790
848
|
const MAX_RADIUS = 16;
|
|
791
849
|
const POINTER_BUTTON = {
|
|
@@ -847,54 +905,6 @@ const isMainPointer = (event) => {
|
|
|
847
905
|
return event.button === POINTER_BUTTON.MAIN;
|
|
848
906
|
};
|
|
849
907
|
|
|
850
|
-
// https://stackoverflow.com/a/6853926/232122
|
|
851
|
-
function distanceBetweenPointAndSegment(x, y, x1, y1, x2, y2) {
|
|
852
|
-
const A = x - x1;
|
|
853
|
-
const B = y - y1;
|
|
854
|
-
const C = x2 - x1;
|
|
855
|
-
const D = y2 - y1;
|
|
856
|
-
const dot = A * C + B * D;
|
|
857
|
-
const lenSquare = C * C + D * D;
|
|
858
|
-
let param = -1;
|
|
859
|
-
if (lenSquare !== 0) {
|
|
860
|
-
// in case of 0 length line
|
|
861
|
-
param = dot / lenSquare;
|
|
862
|
-
}
|
|
863
|
-
let xx, yy;
|
|
864
|
-
if (param < 0) {
|
|
865
|
-
xx = x1;
|
|
866
|
-
yy = y1;
|
|
867
|
-
}
|
|
868
|
-
else if (param > 1) {
|
|
869
|
-
xx = x2;
|
|
870
|
-
yy = y2;
|
|
871
|
-
}
|
|
872
|
-
else {
|
|
873
|
-
xx = x1 + param * C;
|
|
874
|
-
yy = y1 + param * D;
|
|
875
|
-
}
|
|
876
|
-
const dx = x - xx;
|
|
877
|
-
const dy = y - yy;
|
|
878
|
-
return Math.hypot(dx, dy);
|
|
879
|
-
}
|
|
880
|
-
function rotate(x1, y1, x2, y2, angle) {
|
|
881
|
-
// πβ²π₯=(ππ₯βππ₯)cosπβ(ππ¦βππ¦)sinπ+ππ₯
|
|
882
|
-
// πβ²π¦=(ππ₯βππ₯)sinπ+(ππ¦βππ¦)cosπ+ππ¦.
|
|
883
|
-
// https://math.stackexchange.com/questions/2204520/how-do-i-rotate-a-line-segment-in-a-specific-point-on-the-line
|
|
884
|
-
return [(x1 - x2) * Math.cos(angle) - (y1 - y2) * Math.sin(angle) + x2, (x1 - x2) * Math.sin(angle) + (y1 - y2) * Math.cos(angle) + y2];
|
|
885
|
-
}
|
|
886
|
-
function distanceBetweenPointAndPoint(x1, y1, x2, y2) {
|
|
887
|
-
const dx = x1 - x2;
|
|
888
|
-
const dy = y1 - y2;
|
|
889
|
-
return Math.hypot(dx, dy);
|
|
890
|
-
}
|
|
891
|
-
// https://stackoverflow.com/questions/5254838/calculating-distance-between-a-point-and-a-rectangular-box-nearest-point
|
|
892
|
-
function distanceBetweenPointAndRectangle(x, y, rect) {
|
|
893
|
-
var dx = Math.max(rect.x - x, 0, x - (rect.x + rect.width));
|
|
894
|
-
var dy = Math.max(rect.y - y, 0, y - (rect.y + rect.height));
|
|
895
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
896
|
-
}
|
|
897
|
-
|
|
898
908
|
/**
|
|
899
909
|
* Extendable Custom Types Interface
|
|
900
910
|
*/
|
|
@@ -1405,6 +1415,25 @@ function drawLinearPath(points, options) {
|
|
|
1405
1415
|
g.appendChild(path);
|
|
1406
1416
|
return g;
|
|
1407
1417
|
}
|
|
1418
|
+
function drawBezierPath(points, options) {
|
|
1419
|
+
const g = createG();
|
|
1420
|
+
const path = createPath();
|
|
1421
|
+
let polylinePath = '';
|
|
1422
|
+
for (let i = 0; i < points.length - 3; i += 3) {
|
|
1423
|
+
if (i === 0) {
|
|
1424
|
+
polylinePath += `M ${points[0][0]} ${points[0][1]} `;
|
|
1425
|
+
}
|
|
1426
|
+
else {
|
|
1427
|
+
polylinePath += `C ${points[i + 1][0]} ${points[i + 1][1]}, ${points[i + 2][0]} ${points[i + 2][1]}, ${points[i + 3][0]} ${points[i + 3][1]}`;
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
path.setAttribute('d', polylinePath);
|
|
1431
|
+
path.setAttribute('stroke', `${options?.stroke}`);
|
|
1432
|
+
path.setAttribute('stroke-width', `${options?.strokeWidth}`);
|
|
1433
|
+
path.setAttribute('fill', `none`);
|
|
1434
|
+
g.appendChild(path);
|
|
1435
|
+
return g;
|
|
1436
|
+
}
|
|
1408
1437
|
|
|
1409
1438
|
let timerId = null;
|
|
1410
1439
|
const throttleRAF = (fn) => {
|
|
@@ -1893,7 +1922,7 @@ const updatePointerType = (board, pointer) => {
|
|
|
1893
1922
|
};
|
|
1894
1923
|
function updateZoom(board, newZoom, isCenter = true) {
|
|
1895
1924
|
newZoom = clampZoomLevel(newZoom);
|
|
1896
|
-
const mousePoint = PlaitBoard.
|
|
1925
|
+
const mousePoint = PlaitBoard.getMovingPointInBoard(board);
|
|
1897
1926
|
const nativeElement = PlaitBoard.getBoardContainer(board);
|
|
1898
1927
|
const nativeElementRect = nativeElement.getBoundingClientRect();
|
|
1899
1928
|
const boardContainerRect = PlaitBoard.getBoardContainer(board).getBoundingClientRect();
|
|
@@ -2077,6 +2106,7 @@ function createBoard(children, options) {
|
|
|
2077
2106
|
mouseup: (event) => { },
|
|
2078
2107
|
globalMouseup: (event) => { },
|
|
2079
2108
|
keydown: (event) => { },
|
|
2109
|
+
globalKeydown: (event) => { },
|
|
2080
2110
|
keyup: (event) => { },
|
|
2081
2111
|
dblclick: (event) => { },
|
|
2082
2112
|
setFragment: (data) => { },
|
|
@@ -2554,6 +2584,42 @@ i0.Ι΅Ι΅ngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
2554
2584
|
}
|
|
2555
2585
|
}]
|
|
2556
2586
|
}], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; } });
|
|
2587
|
+
class PlaitIslandPopoverBaseComponent {
|
|
2588
|
+
initialize(board) {
|
|
2589
|
+
this.board = board;
|
|
2590
|
+
const onChange = board.onChange;
|
|
2591
|
+
board.onChange = () => {
|
|
2592
|
+
onChange();
|
|
2593
|
+
if (hasOnBoardChange(this)) {
|
|
2594
|
+
this.onBoardChange();
|
|
2595
|
+
}
|
|
2596
|
+
};
|
|
2597
|
+
this.onChange = onChange;
|
|
2598
|
+
}
|
|
2599
|
+
ngOnInit() {
|
|
2600
|
+
if (!this.board) {
|
|
2601
|
+
throw new Error('can not find board instance');
|
|
2602
|
+
}
|
|
2603
|
+
this.initialize(this.board);
|
|
2604
|
+
this.islandOnInit();
|
|
2605
|
+
}
|
|
2606
|
+
ngOnDestroy() {
|
|
2607
|
+
this.board.onChange = this.onChange;
|
|
2608
|
+
this.islandOnDestroy();
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
PlaitIslandPopoverBaseComponent.Ι΅fac = i0.Ι΅Ι΅ngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitIslandPopoverBaseComponent, deps: [], target: i0.Ι΅Ι΅FactoryTarget.Directive });
|
|
2612
|
+
PlaitIslandPopoverBaseComponent.Ι΅dir = i0.Ι΅Ι΅ngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: PlaitIslandPopoverBaseComponent, inputs: { board: "board" }, host: { classAttribute: "plait-island-popover-container" }, ngImport: i0 });
|
|
2613
|
+
i0.Ι΅Ι΅ngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitIslandPopoverBaseComponent, decorators: [{
|
|
2614
|
+
type: Directive,
|
|
2615
|
+
args: [{
|
|
2616
|
+
host: {
|
|
2617
|
+
class: 'plait-island-popover-container'
|
|
2618
|
+
}
|
|
2619
|
+
}]
|
|
2620
|
+
}], propDecorators: { board: [{
|
|
2621
|
+
type: Input
|
|
2622
|
+
}] } });
|
|
2557
2623
|
const hasOnBoardChange = (value) => {
|
|
2558
2624
|
if (value.onBoardChange) {
|
|
2559
2625
|
return true;
|
|
@@ -2563,6 +2629,56 @@ const hasOnBoardChange = (value) => {
|
|
|
2563
2629
|
}
|
|
2564
2630
|
};
|
|
2565
2631
|
|
|
2632
|
+
const withHotkey = (board) => {
|
|
2633
|
+
const { keydown, globalKeydown } = board;
|
|
2634
|
+
board.keydown = (event) => {
|
|
2635
|
+
const options = board.getPluginOptions(PlaitPluginKey.withSelection);
|
|
2636
|
+
if (!PlaitBoard.isReadonly(board) && options.isMultiple && isHotkey$1('mod+a', event)) {
|
|
2637
|
+
event.preventDefault();
|
|
2638
|
+
let elements = [];
|
|
2639
|
+
depthFirstRecursion(board, node => {
|
|
2640
|
+
elements.push(node);
|
|
2641
|
+
}, node => {
|
|
2642
|
+
if (PlaitBoard.isBoard(node) || board.isRecursion(node)) {
|
|
2643
|
+
return true;
|
|
2644
|
+
}
|
|
2645
|
+
else {
|
|
2646
|
+
return false;
|
|
2647
|
+
}
|
|
2648
|
+
}, true);
|
|
2649
|
+
Transforms.setSelectionWithTemporaryElements(board, elements);
|
|
2650
|
+
return;
|
|
2651
|
+
}
|
|
2652
|
+
keydown(event);
|
|
2653
|
+
};
|
|
2654
|
+
board.globalKeydown = (event) => {
|
|
2655
|
+
if (PlaitBoard.getMovingPointInBoard(board) || PlaitBoard.isMovingPointInBoard(board)) {
|
|
2656
|
+
if (isHotkey$1(['mod+=', 'mod++'], { byKey: true })(event)) {
|
|
2657
|
+
event.preventDefault();
|
|
2658
|
+
BoardTransforms.updateZoom(board, board.viewport.zoom + 0.1, false);
|
|
2659
|
+
return;
|
|
2660
|
+
}
|
|
2661
|
+
if (isHotkey$1(['mod+shift+=', 'mod+shift++'], { byKey: true })(event)) {
|
|
2662
|
+
event.preventDefault();
|
|
2663
|
+
BoardTransforms.fitViewport(board);
|
|
2664
|
+
return;
|
|
2665
|
+
}
|
|
2666
|
+
if (isHotkey$1(['mod+-', 'mod+shift+-'])(event)) {
|
|
2667
|
+
event.preventDefault();
|
|
2668
|
+
BoardTransforms.updateZoom(board, board.viewport.zoom - 0.1);
|
|
2669
|
+
return;
|
|
2670
|
+
}
|
|
2671
|
+
if (isHotkey$1(['mod+0', 'mod+shift+0'], { byKey: true })(event)) {
|
|
2672
|
+
event.preventDefault();
|
|
2673
|
+
BoardTransforms.updateZoom(board, 1);
|
|
2674
|
+
return;
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
globalKeydown(event);
|
|
2678
|
+
};
|
|
2679
|
+
return board;
|
|
2680
|
+
};
|
|
2681
|
+
|
|
2566
2682
|
class PlaitElementComponent {
|
|
2567
2683
|
constructor(renderer2, viewContainerRef) {
|
|
2568
2684
|
this.renderer2 = renderer2;
|
|
@@ -2719,7 +2835,7 @@ class PlaitBoardComponent {
|
|
|
2719
2835
|
return this.svg.nativeElement;
|
|
2720
2836
|
}
|
|
2721
2837
|
get hostClass() {
|
|
2722
|
-
return
|
|
2838
|
+
return `${HOST_CLASS_NAME} pointer-${this.board.pointer} theme-${this.board.theme.themeColorMode}`;
|
|
2723
2839
|
}
|
|
2724
2840
|
get readonly() {
|
|
2725
2841
|
return this.board.options.readonly;
|
|
@@ -2760,6 +2876,11 @@ class PlaitBoardComponent {
|
|
|
2760
2876
|
this.initializeHookListener();
|
|
2761
2877
|
this.viewportScrollListener();
|
|
2762
2878
|
this.elementResizeListener();
|
|
2879
|
+
fromEvent(document, 'mouseleave')
|
|
2880
|
+
.pipe(takeUntil(this.destroy$))
|
|
2881
|
+
.subscribe((event) => {
|
|
2882
|
+
BOARD_TO_MOVING_POINT.delete(this.board);
|
|
2883
|
+
});
|
|
2763
2884
|
});
|
|
2764
2885
|
BOARD_TO_COMPONENT.set(this.board, this);
|
|
2765
2886
|
BOARD_TO_ROUGH_SVG.set(this.board, roughSVG);
|
|
@@ -2806,7 +2927,7 @@ class PlaitBoardComponent {
|
|
|
2806
2927
|
initializeViewportOffset(this.board);
|
|
2807
2928
|
}
|
|
2808
2929
|
initializePlugins() {
|
|
2809
|
-
let board = withHandPointer(withHistory(withSelection(withMoving(withBoard(withViewport(withOptions(createBoard(this.plaitValue, this.plaitOptions))))))));
|
|
2930
|
+
let board = withHotkey(withHandPointer(withHistory(withSelection(withMoving(withBoard(withViewport(withOptions(createBoard(this.plaitValue, this.plaitOptions)))))))));
|
|
2810
2931
|
this.plaitPlugins.forEach(plugin => {
|
|
2811
2932
|
board = plugin(board);
|
|
2812
2933
|
});
|
|
@@ -2827,18 +2948,19 @@ class PlaitBoardComponent {
|
|
|
2827
2948
|
fromEvent(this.host, 'mousemove')
|
|
2828
2949
|
.pipe(takeUntil(this.destroy$))
|
|
2829
2950
|
.subscribe((event) => {
|
|
2830
|
-
|
|
2951
|
+
BOARD_TO_MOVING_POINT_IN_BOARD.set(this.board, [event.x, event.y]);
|
|
2831
2952
|
this.board.mousemove(event);
|
|
2832
2953
|
});
|
|
2833
2954
|
fromEvent(this.host, 'mouseleave')
|
|
2834
2955
|
.pipe(takeUntil(this.destroy$))
|
|
2835
2956
|
.subscribe((event) => {
|
|
2836
|
-
|
|
2957
|
+
BOARD_TO_MOVING_POINT_IN_BOARD.delete(this.board);
|
|
2837
2958
|
this.board.mouseleave(event);
|
|
2838
2959
|
});
|
|
2839
2960
|
fromEvent(document, 'mousemove')
|
|
2840
2961
|
.pipe(takeUntil(this.destroy$))
|
|
2841
2962
|
.subscribe((event) => {
|
|
2963
|
+
BOARD_TO_MOVING_POINT.set(this.board, [event.x, event.y]);
|
|
2842
2964
|
this.board.globalMousemove(event);
|
|
2843
2965
|
});
|
|
2844
2966
|
fromEvent(this.host, 'mouseup')
|
|
@@ -2857,27 +2979,8 @@ class PlaitBoardComponent {
|
|
|
2857
2979
|
this.board.dblclick(event);
|
|
2858
2980
|
});
|
|
2859
2981
|
fromEvent(document, 'keydown')
|
|
2860
|
-
.pipe(takeUntil(this.destroy$), tap(
|
|
2861
|
-
|
|
2862
|
-
if (isHotkey(['mod+=', 'mod++'], { byKey: true })(event)) {
|
|
2863
|
-
event.preventDefault();
|
|
2864
|
-
BoardTransforms.updateZoom(this.board, this.board.viewport.zoom + 0.1, false);
|
|
2865
|
-
}
|
|
2866
|
-
if (isHotkey('mod+-', { byKey: true })(event)) {
|
|
2867
|
-
event.preventDefault();
|
|
2868
|
-
BoardTransforms.updateZoom(this.board, this.board.viewport.zoom - 0.1);
|
|
2869
|
-
}
|
|
2870
|
-
if (isHotkey('mod+0', { byKey: true })(event)) {
|
|
2871
|
-
event.preventDefault();
|
|
2872
|
-
BoardTransforms.updateZoom(this.board, 1);
|
|
2873
|
-
return;
|
|
2874
|
-
}
|
|
2875
|
-
if (isHotkey('mod+shift+=', { byKey: true })(event)) {
|
|
2876
|
-
event.preventDefault();
|
|
2877
|
-
BoardTransforms.fitViewport(this.board);
|
|
2878
|
-
return;
|
|
2879
|
-
}
|
|
2880
|
-
}
|
|
2982
|
+
.pipe(takeUntil(this.destroy$), tap(event => {
|
|
2983
|
+
this.board.globalKeydown(event);
|
|
2881
2984
|
}), filter(event => this.isFocused && !PlaitBoard.hasBeenTextEditing(this.board) && !hasInputOrTextareaTarget(event.target)))
|
|
2882
2985
|
.subscribe((event) => {
|
|
2883
2986
|
this.board?.keydown(event);
|
|
@@ -2896,7 +2999,7 @@ class PlaitBoardComponent {
|
|
|
2896
2999
|
fromEvent(document, 'paste')
|
|
2897
3000
|
.pipe(takeUntil(this.destroy$), filter(() => this.isFocused && !PlaitBoard.isReadonly(this.board) && !PlaitBoard.hasBeenTextEditing(this.board)))
|
|
2898
3001
|
.subscribe((clipboardEvent) => {
|
|
2899
|
-
const mousePoint = PlaitBoard.
|
|
3002
|
+
const mousePoint = PlaitBoard.getMovingPointInBoard(this.board);
|
|
2900
3003
|
if (mousePoint) {
|
|
2901
3004
|
const targetPoint = transformPoint(this.board, toPoint(mousePoint[0], mousePoint[1], this.host));
|
|
2902
3005
|
this.board.insertFragment(clipboardEvent.clipboardData, targetPoint);
|
|
@@ -3213,5 +3316,5 @@ function createModModifierKeys() {
|
|
|
3213
3316
|
* Generated bundle index. Do not edit.
|
|
3214
3317
|
*/
|
|
3215
3318
|
|
|
3216
|
-
export { A, ALT, APOSTROPHE, AT_SIGN, B, BACKSLASH, BACKSPACE, 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, C, CAPS_LOCK, CLIP_BOARD_FORMAT_KEY, CLOSE_SQUARE_BRACKET, COMMA, CONTEXT_MENU, CONTROL, ColorfulThemeColor, D, DASH, DELETE, DOWN_ARROW, DarkThemeColor, DefaultThemeColor, E, EIGHT, ELEMENT_TO_COMPONENT, END, ENTER, EQUALS, ESCAPE, F, F1, F10, F11, F12, F2, F3, F4, F5, F6, F7, F8, F9, FF_EQUALS, FF_MINUS, FF_MUTE, FF_SEMICOLON, FF_VOLUME_DOWN, FF_VOLUME_UP, FIRST_MEDIA, FIVE, FLUSHING, FOUR, G, H, HOME, I, INSERT, IS_APPLE, IS_BOARD_CACHE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_FIREFOX, IS_IOS, IS_MAC, IS_SAFARI, IS_TEXT_EDITABLE, J, K, L, LAST_MEDIA, LEFT_ARROW, M, MAC_ENTER, MAC_META, MAC_WK_CMD_LEFT, MAC_WK_CMD_RIGHT, MAX_RADIUS, MERGING, META, MUTE, N, NINE, NODE_TO_INDEX, NODE_TO_PARENT, NS, NUMPAD_DIVIDE, NUMPAD_EIGHT, NUMPAD_FIVE, NUMPAD_FOUR, NUMPAD_MINUS, NUMPAD_MULTIPLY, NUMPAD_NINE, NUMPAD_ONE, NUMPAD_PERIOD, NUMPAD_PLUS, NUMPAD_SEVEN, NUMPAD_SIX, NUMPAD_THREE, NUMPAD_TWO, NUMPAD_ZERO, NUM_CENTER, NUM_LOCK, O, ONE, OPEN_SQUARE_BRACKET, P, PAGE_DOWN, PAGE_UP, PATH_REFS, PAUSE, PERIOD, PLUS_SIGN, POINTER_BUTTON, PRINT_SCREEN, Path, PlaitBoard, PlaitBoardComponent, PlaitChildrenElement, PlaitElement, PlaitElementComponent, PlaitHistoryBoard, PlaitIslandBaseComponent, PlaitModule, PlaitNode, PlaitOperation, PlaitPluginElementComponent, PlaitPluginKey, PlaitPointerType, Point, Q, QUESTION_MARK, R, RIGHT_ARROW, RectangleClient, RetroThemeColor, S, SAVING, SCROLL_BAR_WIDTH, SCROLL_LOCK, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, SEMICOLON, SEVEN, SHIFT, SINGLE_QUOTE, SIX, SLASH, SPACE, Selection, SoftThemeColor, StarryThemeColor, T, TAB, THREE, TILDE, TWO, ThemeColorMode, ThemeColors, Transforms, U, UP_ARROW, V, VOLUME_DOWN, VOLUME_UP, Viewport, W, X, Y, Z, ZERO, addMovingElements, addSelectedElement, arrowPoints, cacheMovingElements, cacheSelectedElements, clampZoomLevel, clearNodeWeakMap, clearSelectedElement, clearSelectionMoving, clearViewportOrigination, createFakeEvent, createForeignObject, createG, createKeyboardEvent, createModModifierKeys, createMouseEvent, createPath, createPointerEvent, createSVG, createSelectionOuterG, createTestingBoard, createText, createTouchEvent, debounce, deleteTemporaryElements, depthFirstRecursion, distanceBetweenPointAndPoint, distanceBetweenPointAndRectangle, distanceBetweenPointAndSegment, downloadImage, drawAbstractRoundRectangle, drawArrow, drawCircle, drawLine, drawLinearPath, drawRoundRectangle, fakeNodeWeakMap, getBoardRectangle, getElementHostBBox, getHitElementOfRoot, getHitElements, getMovingElements, getRealScrollBarWidth, getRectangleByElements, getSelectedElements, getTemporaryElements, getViewBox, getViewBoxCenterPoint, getViewportContainerRect, getViewportOrigination, hasBeforeContextChange, hasInputOrTextareaTarget, hasOnBoardChange, hasOnContextChanged, hotkeys, idCreator, initializeViewBox, initializeViewportContainer, initializeViewportOffset, inverse, isDOMElement, isDOMNode, isFromScrolling, isFromViewportChange, isHitElements, isInPlaitBoard, isMainPointer, isNullOrUndefined, isSecondaryPointer, isSelectedElement, isSelectionMoving, isSetViewportOperation, normalizePoint, removeMovingElements, removeSelectedElement, rotate, scrollToRectangle, setIsFromScrolling, setIsFromViewportChange, setSVGViewBox, setSelectionMoving, shouldClear, shouldMerge, shouldSave, throttleRAF, toImage, toPoint, transformPoint, transformPoints, updateForeignObject, updateViewportContainerScroll, updateViewportOffset, updateViewportOrigination, withMoving, withOptions, withSelection };
|
|
3319
|
+
export { A, ALT, APOSTROPHE, AT_SIGN, B, BACKSLASH, BACKSPACE, 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_MOVING_POINT_IN_BOARD, BOARD_TO_ON_CHANGE, BOARD_TO_ROUGH_SVG, BOARD_TO_SELECTED_ELEMENT, BOARD_TO_TEMPORARY_ELEMENTS, BOARD_TO_VIEWPORT_ORIGINATION, BoardTransforms, C, CAPS_LOCK, CLIP_BOARD_FORMAT_KEY, CLOSE_SQUARE_BRACKET, COMMA, CONTEXT_MENU, CONTROL, ColorfulThemeColor, D, DASH, DELETE, DOWN_ARROW, DarkThemeColor, DefaultThemeColor, E, EIGHT, ELEMENT_TO_COMPONENT, END, ENTER, EQUALS, ESCAPE, F, F1, F10, F11, F12, F2, F3, F4, F5, F6, F7, F8, F9, FF_EQUALS, FF_MINUS, FF_MUTE, FF_SEMICOLON, FF_VOLUME_DOWN, FF_VOLUME_UP, FIRST_MEDIA, FIVE, FLUSHING, FOUR, G, H, HOME, HOST_CLASS_NAME, I, INSERT, IS_APPLE, IS_BOARD_CACHE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_FIREFOX, IS_IOS, IS_MAC, IS_SAFARI, IS_TEXT_EDITABLE, J, K, L, LAST_MEDIA, LEFT_ARROW, M, MAC_ENTER, MAC_META, MAC_WK_CMD_LEFT, MAC_WK_CMD_RIGHT, MAX_RADIUS, MERGING, META, MUTE, N, NINE, NODE_TO_INDEX, NODE_TO_PARENT, NS, NUMPAD_DIVIDE, NUMPAD_EIGHT, NUMPAD_FIVE, NUMPAD_FOUR, NUMPAD_MINUS, NUMPAD_MULTIPLY, NUMPAD_NINE, NUMPAD_ONE, NUMPAD_PERIOD, NUMPAD_PLUS, NUMPAD_SEVEN, NUMPAD_SIX, NUMPAD_THREE, NUMPAD_TWO, NUMPAD_ZERO, NUM_CENTER, NUM_LOCK, O, ONE, OPEN_SQUARE_BRACKET, P, PAGE_DOWN, PAGE_UP, PATH_REFS, PAUSE, PERIOD, PLUS_SIGN, POINTER_BUTTON, PRINT_SCREEN, Path, PlaitBoard, PlaitBoardComponent, PlaitChildrenElement, PlaitElement, PlaitElementComponent, PlaitHistoryBoard, PlaitIslandBaseComponent, PlaitIslandPopoverBaseComponent, PlaitModule, PlaitNode, PlaitOperation, PlaitPluginElementComponent, PlaitPluginKey, PlaitPointerType, Point, Q, QUESTION_MARK, R, RIGHT_ARROW, RectangleClient, RetroThemeColor, S, SAVING, SCROLL_BAR_WIDTH, SCROLL_LOCK, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, SEMICOLON, SEVEN, SHIFT, SINGLE_QUOTE, SIX, SLASH, SPACE, Selection, SoftThemeColor, StarryThemeColor, T, TAB, THREE, TILDE, TWO, ThemeColorMode, ThemeColors, Transforms, U, UP_ARROW, V, VOLUME_DOWN, VOLUME_UP, Viewport, W, X, Y, Z, ZERO, addMovingElements, addSelectedElement, arrowPoints, cacheMovingElements, cacheSelectedElements, clampZoomLevel, clearNodeWeakMap, clearSelectedElement, clearSelectionMoving, clearViewportOrigination, createFakeEvent, createForeignObject, createG, createKeyboardEvent, createModModifierKeys, createMouseEvent, createPath, createPointerEvent, createSVG, createSelectionOuterG, createTestingBoard, createText, createTouchEvent, debounce, deleteTemporaryElements, depthFirstRecursion, distanceBetweenPointAndPoint, distanceBetweenPointAndRectangle, distanceBetweenPointAndSegment, downloadImage, drawAbstractRoundRectangle, drawArrow, drawBezierPath, drawCircle, drawLine, drawLinearPath, drawRoundRectangle, fakeNodeWeakMap, getBoardRectangle, getElementHostBBox, getHitElementOfRoot, getHitElements, getMovingElements, getRealScrollBarWidth, getRectangleByElements, getSelectedElements, getTemporaryElements, getViewBox, getViewBoxCenterPoint, getViewportContainerRect, getViewportOrigination, hasBeforeContextChange, hasInputOrTextareaTarget, hasOnBoardChange, hasOnContextChanged, hotkeys, idCreator, initializeViewBox, initializeViewportContainer, initializeViewportOffset, inverse, isDOMElement, isDOMNode, isFromScrolling, isFromViewportChange, isHitElements, isInPlaitBoard, isMainPointer, isNullOrUndefined, isSecondaryPointer, isSelectedElement, isSelectionMoving, isSetViewportOperation, normalizePoint, removeMovingElements, removeSelectedElement, rotate, scrollToRectangle, setIsFromScrolling, setIsFromViewportChange, setSVGViewBox, setSelectionMoving, shouldClear, shouldMerge, shouldSave, throttleRAF, toImage, toPoint, transformPoint, transformPoints, updateForeignObject, updateViewportContainerScroll, updateViewportOffset, updateViewportOrigination, withMoving, withOptions, withSelection };
|
|
3217
3320
|
//# sourceMappingURL=plait-core.mjs.map
|