@plait/core 0.0.39 → 0.0.40
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/fesm2020/plait-core.mjs
CHANGED
|
@@ -1082,6 +1082,7 @@ class PlaitBoardComponent {
|
|
|
1082
1082
|
this.cdr = cdr;
|
|
1083
1083
|
this.elementRef = elementRef;
|
|
1084
1084
|
this.renderer2 = renderer2;
|
|
1085
|
+
this.hasInitialized = false;
|
|
1085
1086
|
this.destroy$ = new Subject();
|
|
1086
1087
|
this._viewZoom = 100;
|
|
1087
1088
|
this.plaitBoardMove = {
|
|
@@ -1116,11 +1117,11 @@ class PlaitBoardComponent {
|
|
|
1116
1117
|
return this.svg.nativeElement;
|
|
1117
1118
|
}
|
|
1118
1119
|
get isFocused() {
|
|
1119
|
-
if (!this.board?.selection && this.board.cursor === BaseCursorStatus.move) {
|
|
1120
|
-
this.changeMoveMode(BaseCursorStatus.select);
|
|
1121
|
-
}
|
|
1122
1120
|
return this.board?.selection;
|
|
1123
1121
|
}
|
|
1122
|
+
get readonly() {
|
|
1123
|
+
return this.plaitReadonly;
|
|
1124
|
+
}
|
|
1124
1125
|
get focused() {
|
|
1125
1126
|
return this.isFocused;
|
|
1126
1127
|
}
|
|
@@ -1144,6 +1145,14 @@ class PlaitBoardComponent {
|
|
|
1144
1145
|
}
|
|
1145
1146
|
this.plaitChange.emit(changeEvent);
|
|
1146
1147
|
});
|
|
1148
|
+
this.hasInitialized = true;
|
|
1149
|
+
}
|
|
1150
|
+
ngOnChanges(changes) {
|
|
1151
|
+
const valueChange = changes['plaitValue'];
|
|
1152
|
+
if (valueChange && this.hasInitialized) {
|
|
1153
|
+
this.board.children = valueChange.currentValue;
|
|
1154
|
+
this.cdr.markForCheck();
|
|
1155
|
+
}
|
|
1147
1156
|
}
|
|
1148
1157
|
ngAfterViewInit() {
|
|
1149
1158
|
this.plaitBoardInitialized.emit(this.board);
|
|
@@ -1164,6 +1173,7 @@ class PlaitBoardComponent {
|
|
|
1164
1173
|
.pipe(takeUntil(this.destroy$))
|
|
1165
1174
|
.subscribe((event) => {
|
|
1166
1175
|
this.board.mousedown(event);
|
|
1176
|
+
this.setCursorStatus();
|
|
1167
1177
|
this.isFocused && this.isMoveMode && this.initMove(event);
|
|
1168
1178
|
});
|
|
1169
1179
|
fromEvent(this.host, 'mousemove')
|
|
@@ -1213,7 +1223,7 @@ class PlaitBoardComponent {
|
|
|
1213
1223
|
}))
|
|
1214
1224
|
.subscribe((event) => {
|
|
1215
1225
|
this.board?.keyup(event);
|
|
1216
|
-
this.isFocused && event.code === 'Space' && this.changeMoveMode(BaseCursorStatus.select);
|
|
1226
|
+
this.isFocused && !this.plaitReadonly && event.code === 'Space' && this.changeMoveMode(BaseCursorStatus.select);
|
|
1217
1227
|
});
|
|
1218
1228
|
fromEvent(document, 'copy')
|
|
1219
1229
|
.pipe(takeUntil(this.destroy$), filter(() => {
|
|
@@ -1252,6 +1262,14 @@ class PlaitBoardComponent {
|
|
|
1252
1262
|
const viewBox = getViewBox(this.board);
|
|
1253
1263
|
this.renderer2.setAttribute(this.host, 'viewBox', `${viewBox.minX}, ${viewBox.minY}, ${viewBox.width}, ${viewBox.height}`);
|
|
1254
1264
|
}
|
|
1265
|
+
setCursorStatus() {
|
|
1266
|
+
if (this.plaitReadonly) {
|
|
1267
|
+
this.changeMoveMode(BaseCursorStatus.move);
|
|
1268
|
+
}
|
|
1269
|
+
else if (!this.isFocused) {
|
|
1270
|
+
this.changeMoveMode(BaseCursorStatus.select);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1255
1273
|
initMove(e) {
|
|
1256
1274
|
this.plaitBoardMove.isMoving = true;
|
|
1257
1275
|
this.plaitBoardMove.x = e.x;
|
|
@@ -1322,7 +1340,7 @@ class PlaitBoardComponent {
|
|
|
1322
1340
|
}
|
|
1323
1341
|
}
|
|
1324
1342
|
PlaitBoardComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: PlaitBoardComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
|
|
1325
|
-
PlaitBoardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: PlaitBoardComponent, selector: "plait-board", inputs: { plaitValue: "plaitValue", plaitViewport: "plaitViewport", plaitPlugins: "plaitPlugins", plaitReadonly: "plaitReadonly", plaitAllowClearBoard: "plaitAllowClearBoard" }, outputs: { plaitChange: "plaitChange", plaitBoardInitialized: "plaitBoardInitialized" }, host: { properties: { "class": "this.hostClass", "class.focused": "this.focused" } }, queries: [{ propertyName: "toolbarTemplateRef", first: true, predicate: ["plaitToolbar"], descendants: true }], viewQueries: [{ propertyName: "svg", first: true, predicate: ["svg"], descendants: true, static: true }], ngImport: i0, template: `
|
|
1343
|
+
PlaitBoardComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: PlaitBoardComponent, selector: "plait-board", inputs: { plaitValue: "plaitValue", plaitViewport: "plaitViewport", plaitPlugins: "plaitPlugins", plaitReadonly: "plaitReadonly", plaitAllowClearBoard: "plaitAllowClearBoard" }, outputs: { plaitChange: "plaitChange", plaitBoardInitialized: "plaitBoardInitialized" }, host: { properties: { "class": "this.hostClass", "class.readonly": "this.readonly", "class.focused": "this.focused" } }, queries: [{ propertyName: "toolbarTemplateRef", first: true, predicate: ["plaitToolbar"], descendants: true }], viewQueries: [{ propertyName: "svg", first: true, predicate: ["svg"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
1326
1344
|
<svg
|
|
1327
1345
|
#svg
|
|
1328
1346
|
width="100%"
|
|
@@ -1409,6 +1427,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
|
|
|
1409
1427
|
type: Output
|
|
1410
1428
|
}], plaitBoardInitialized: [{
|
|
1411
1429
|
type: Output
|
|
1430
|
+
}], readonly: [{
|
|
1431
|
+
type: HostBinding,
|
|
1432
|
+
args: ['class.readonly']
|
|
1412
1433
|
}], focused: [{
|
|
1413
1434
|
type: HostBinding,
|
|
1414
1435
|
args: ['class.focused']
|