@node-projects/web-component-designer 0.0.133 → 0.0.134
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/dist/elements/helper/contextMenu/ContextMenu.d.ts +0 -2
- package/dist/elements/helper/contextMenu/ContextMenu.js +4 -10
- package/dist/elements/widgets/designerView/designerCanvas.js +5 -4
- package/dist/elements/widgets/designerView/tools/PointerTool.d.ts +7 -1
- package/dist/elements/widgets/designerView/tools/PointerTool.js +92 -21
- package/dist/elements/widgets/treeView/treeViewExtended.js +18 -3
- package/package.json +1 -1
|
@@ -12,7 +12,6 @@ export declare class ContextMenu {
|
|
|
12
12
|
options: IContextMenuOptions;
|
|
13
13
|
private num;
|
|
14
14
|
private _windowDownBound;
|
|
15
|
-
private _windowUpBound;
|
|
16
15
|
private _windowKeyUpBound;
|
|
17
16
|
private _windowResizeBound;
|
|
18
17
|
private _menuElement;
|
|
@@ -22,7 +21,6 @@ export declare class ContextMenu {
|
|
|
22
21
|
display(event: MouseEvent): void;
|
|
23
22
|
_windowResize(): void;
|
|
24
23
|
_windowDown(e: MouseEvent): void;
|
|
25
|
-
_windowUp(e: MouseEvent): void;
|
|
26
24
|
_windowKeyUp(e: KeyboardEvent): void;
|
|
27
25
|
static show(menu: IContextMenuItem[], event: MouseEvent, options?: IContextMenuOptions): ContextMenu;
|
|
28
26
|
close(): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { css } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
import { sleep } from "../Helper";
|
|
2
3
|
export class ContextMenu {
|
|
3
4
|
static _contextMenuCss = css `
|
|
4
5
|
.context_menu {
|
|
@@ -113,7 +114,6 @@ export class ContextMenu {
|
|
|
113
114
|
options;
|
|
114
115
|
num;
|
|
115
116
|
_windowDownBound;
|
|
116
|
-
_windowUpBound;
|
|
117
117
|
_windowKeyUpBound;
|
|
118
118
|
_windowResizeBound;
|
|
119
119
|
_menuElement;
|
|
@@ -123,7 +123,6 @@ export class ContextMenu {
|
|
|
123
123
|
this.options = options;
|
|
124
124
|
this.reload();
|
|
125
125
|
this._windowDownBound = this._windowDown.bind(this);
|
|
126
|
-
this._windowUpBound = this._windowUp.bind(this);
|
|
127
126
|
this._windowKeyUpBound = this._windowKeyUp.bind(this);
|
|
128
127
|
this._windowResizeBound = this._windowResize.bind(this);
|
|
129
128
|
}
|
|
@@ -231,11 +230,11 @@ export class ContextMenu {
|
|
|
231
230
|
menu.classList.remove("cm_border_bottom");
|
|
232
231
|
}
|
|
233
232
|
menu.classList.add("display");
|
|
233
|
+
event.preventDefault();
|
|
234
234
|
window.addEventListener("keyup", this._windowKeyUpBound);
|
|
235
235
|
window.addEventListener("mousedown", this._windowDownBound);
|
|
236
|
-
window.addEventListener("mouseup", this._windowUpBound);
|
|
237
236
|
window.addEventListener("resize", this._windowResizeBound);
|
|
238
|
-
|
|
237
|
+
sleep(100).then(() => window.addEventListener("contextmenu", this._windowDownBound));
|
|
239
238
|
}
|
|
240
239
|
_windowResize() {
|
|
241
240
|
this.close();
|
|
@@ -245,11 +244,6 @@ export class ContextMenu {
|
|
|
245
244
|
if (p.indexOf(this._menuElement) < 0)
|
|
246
245
|
this.close();
|
|
247
246
|
}
|
|
248
|
-
_windowUp(e) {
|
|
249
|
-
const p = e.composedPath();
|
|
250
|
-
if (p.indexOf(this._menuElement) < 0)
|
|
251
|
-
this.close();
|
|
252
|
-
}
|
|
253
247
|
_windowKeyUp(e) {
|
|
254
248
|
if (e.key === 'Escape') {
|
|
255
249
|
this.close();
|
|
@@ -264,7 +258,7 @@ export class ContextMenu {
|
|
|
264
258
|
this._menuElement.remove();
|
|
265
259
|
window.removeEventListener("keyup", this._windowKeyUpBound);
|
|
266
260
|
window.removeEventListener("mousedown", this._windowDownBound);
|
|
267
|
-
window.removeEventListener("
|
|
261
|
+
window.removeEventListener("contextmenu", this._windowDownBound);
|
|
268
262
|
window.removeEventListener("resize", this._windowResizeBound);
|
|
269
263
|
}
|
|
270
264
|
}
|
|
@@ -57,7 +57,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
57
57
|
}
|
|
58
58
|
set canvasOffset(value) {
|
|
59
59
|
this._canvasOffset = value;
|
|
60
|
-
this._zoomFactorChanged();
|
|
60
|
+
this._zoomFactorChanged(false);
|
|
61
61
|
}
|
|
62
62
|
get canvasOffsetUnzoomed() {
|
|
63
63
|
return { x: this._canvasOffset.x * this.zoomFactor, y: this._canvasOffset.y * this.zoomFactor };
|
|
@@ -452,7 +452,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
452
452
|
this.clickOverlay.addEventListener(EventNames.DblClick, this._onDblClickBound, true);
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
|
-
_zoomFactorChanged() {
|
|
455
|
+
_zoomFactorChanged(refreshExtensions = true) {
|
|
456
456
|
//a@ts-ignore
|
|
457
457
|
//this._canvasContainer.style.zoom = <any>this._zoomFactor;
|
|
458
458
|
//this._canvasContainer.style.transform = 'scale(' + this._zoomFactor+') translate(' + this._translate.x + ', '+this._translate.y+')';
|
|
@@ -462,7 +462,8 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
462
462
|
this._updateTransform();
|
|
463
463
|
this._fillCalculationrects();
|
|
464
464
|
this.onZoomFactorChanged.emit(this._zoomFactor);
|
|
465
|
-
|
|
465
|
+
if (refreshExtensions)
|
|
466
|
+
this.extensionManager.refreshAllAppliedExtentions();
|
|
466
467
|
}
|
|
467
468
|
_updateTransform() {
|
|
468
469
|
this._scaleFactor = this._zoomFactor;
|
|
@@ -851,8 +852,8 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
851
852
|
currentElement = this.instanceServiceContainer.selectionService.primarySelection?.element ?? this._canvas;
|
|
852
853
|
}
|
|
853
854
|
let tool = this.serviceContainer.globalContext.tool ?? this.serviceContainer.designerTools.get(NamedTools.Pointer);
|
|
854
|
-
this._canvas.style.cursor = tool.cursor;
|
|
855
855
|
tool.pointerEventHandler(this, event, currentElement);
|
|
856
|
+
this._canvas.style.cursor = tool.cursor;
|
|
856
857
|
}
|
|
857
858
|
captureActiveTool(tool) {
|
|
858
859
|
this._activeTool = tool;
|
|
@@ -5,17 +5,22 @@ import { IDesignerCanvas } from "../IDesignerCanvas";
|
|
|
5
5
|
import { ITool } from "./ITool";
|
|
6
6
|
import { ServiceContainer } from "../../../services/ServiceContainer.js";
|
|
7
7
|
export declare class PointerTool implements ITool {
|
|
8
|
-
|
|
8
|
+
cursor: string;
|
|
9
9
|
private _movedSinceStartedAction;
|
|
10
10
|
private _initialPoint;
|
|
11
11
|
private _actionType?;
|
|
12
12
|
private _actionStartedDesignItem?;
|
|
13
13
|
private _actionStartedDesignItems?;
|
|
14
|
+
private _clonedItems?;
|
|
15
|
+
private _copiedItemsInserted;
|
|
14
16
|
private _previousEventName;
|
|
15
17
|
private _dragOverExtensionItem;
|
|
16
18
|
private _dragExtensionItem;
|
|
17
19
|
private _moveItemsOffset;
|
|
18
20
|
private _initialOffset;
|
|
21
|
+
private _firstTimeInMove;
|
|
22
|
+
private _secondTimeInMove;
|
|
23
|
+
private _changeGroup;
|
|
19
24
|
constructor();
|
|
20
25
|
activated(serviceContainer: ServiceContainer): void;
|
|
21
26
|
dispose(): void;
|
|
@@ -24,6 +29,7 @@ export declare class PointerTool implements ITool {
|
|
|
24
29
|
private _resetTool;
|
|
25
30
|
private _pointerActionTypeDrawSelection;
|
|
26
31
|
private _pointerActionTypeDragOrSelect;
|
|
32
|
+
private checkSelectElement;
|
|
27
33
|
static FindPossibleContainer(designItem: IDesignItem, designItems: IDesignItem[], event: IPoint): [newContainerElementDesignItem: IDesignItem, newContainerService: IPlacementService];
|
|
28
34
|
keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent, currentElement: Element): void;
|
|
29
35
|
}
|
|
@@ -10,11 +10,16 @@ export class PointerTool {
|
|
|
10
10
|
_actionType;
|
|
11
11
|
_actionStartedDesignItem;
|
|
12
12
|
_actionStartedDesignItems;
|
|
13
|
+
_clonedItems;
|
|
14
|
+
_copiedItemsInserted = false;
|
|
13
15
|
_previousEventName;
|
|
14
16
|
_dragOverExtensionItem;
|
|
15
17
|
_dragExtensionItem;
|
|
16
18
|
_moveItemsOffset = { x: 0, y: 0 };
|
|
17
19
|
_initialOffset;
|
|
20
|
+
_firstTimeInMove;
|
|
21
|
+
_secondTimeInMove;
|
|
22
|
+
_changeGroup;
|
|
18
23
|
constructor() {
|
|
19
24
|
}
|
|
20
25
|
activated(serviceContainer) {
|
|
@@ -40,6 +45,10 @@ export class PointerTool {
|
|
|
40
45
|
}
|
|
41
46
|
}
|
|
42
47
|
pointerEventHandler(designerCanvas, event, currentElement) {
|
|
48
|
+
if (event.ctrlKey)
|
|
49
|
+
this.cursor = 'copy';
|
|
50
|
+
else
|
|
51
|
+
this.cursor = 'default';
|
|
43
52
|
const interactionServices = designerCanvas.serviceContainer.elementInteractionServices;
|
|
44
53
|
if (interactionServices)
|
|
45
54
|
for (let s of interactionServices) {
|
|
@@ -62,10 +71,26 @@ export class PointerTool {
|
|
|
62
71
|
event.target.setPointerCapture(event.pointerId);
|
|
63
72
|
designerCanvas.captureActiveTool(this);
|
|
64
73
|
this._movedSinceStartedAction = false;
|
|
74
|
+
this._copiedItemsInserted = false;
|
|
75
|
+
this._clonedItems = null;
|
|
76
|
+
this._firstTimeInMove = false;
|
|
77
|
+
this._secondTimeInMove = false;
|
|
65
78
|
break;
|
|
66
79
|
case EventNames.PointerUp:
|
|
67
80
|
event.target.releasePointerCapture(event.pointerId);
|
|
68
81
|
designerCanvas.releaseActiveTool();
|
|
82
|
+
this._copiedItemsInserted = false;
|
|
83
|
+
this._clonedItems = null;
|
|
84
|
+
this._firstTimeInMove = false;
|
|
85
|
+
this._secondTimeInMove = false;
|
|
86
|
+
break;
|
|
87
|
+
case EventNames.PointerMove:
|
|
88
|
+
if (this._firstTimeInMove)
|
|
89
|
+
this._secondTimeInMove = true;
|
|
90
|
+
if (this._secondTimeInMove)
|
|
91
|
+
this._firstTimeInMove = false;
|
|
92
|
+
else
|
|
93
|
+
this._firstTimeInMove = true;
|
|
69
94
|
break;
|
|
70
95
|
}
|
|
71
96
|
if (!currentElement)
|
|
@@ -126,7 +151,7 @@ export class PointerTool {
|
|
|
126
151
|
drawSelectionTool.pointerEventHandler(designerView, event, currentElement);
|
|
127
152
|
}
|
|
128
153
|
}
|
|
129
|
-
_pointerActionTypeDragOrSelect(designerCanvas, event, currentDesignItem, currentPoint) {
|
|
154
|
+
async _pointerActionTypeDragOrSelect(designerCanvas, event, currentDesignItem, currentPoint) {
|
|
130
155
|
if (event.altKey) {
|
|
131
156
|
if (event.type == EventNames.PointerDown) {
|
|
132
157
|
const currentSelection = designerCanvas.instanceServiceContainer.selectionService.primarySelection;
|
|
@@ -147,23 +172,6 @@ export class PointerTool {
|
|
|
147
172
|
{
|
|
148
173
|
this._actionStartedDesignItem = currentDesignItem;
|
|
149
174
|
this._moveItemsOffset = { x: 0, y: 0 };
|
|
150
|
-
if (event.shiftKey || event.ctrlKey) {
|
|
151
|
-
const index = designerCanvas.instanceServiceContainer.selectionService.selectedElements.indexOf(currentDesignItem);
|
|
152
|
-
if (index >= 0) {
|
|
153
|
-
let newSelectedList = designerCanvas.instanceServiceContainer.selectionService.selectedElements.slice(0);
|
|
154
|
-
newSelectedList.splice(index, 1);
|
|
155
|
-
designerCanvas.instanceServiceContainer.selectionService.setSelectedElements(newSelectedList);
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
let newSelectedList = designerCanvas.instanceServiceContainer.selectionService.selectedElements.slice(0);
|
|
159
|
-
newSelectedList.push(currentDesignItem);
|
|
160
|
-
designerCanvas.instanceServiceContainer.selectionService.setSelectedElements(newSelectedList);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
if (designerCanvas.instanceServiceContainer.selectionService.selectedElements.indexOf(currentDesignItem) < 0)
|
|
165
|
-
designerCanvas.instanceServiceContainer.selectionService.setSelectedElements([currentDesignItem]);
|
|
166
|
-
}
|
|
167
175
|
this._actionStartedDesignItems = [...designerCanvas.instanceServiceContainer.selectionService.selectedElements];
|
|
168
176
|
if (designerCanvas.alignOnSnap)
|
|
169
177
|
designerCanvas.snapLines.calculateSnaplines(designerCanvas.instanceServiceContainer.selectionService.selectedElements);
|
|
@@ -174,6 +182,40 @@ export class PointerTool {
|
|
|
174
182
|
if (event.buttons == 0) {
|
|
175
183
|
return;
|
|
176
184
|
}
|
|
185
|
+
if (this._firstTimeInMove) {
|
|
186
|
+
if (!currentDesignItem.instanceServiceContainer.selectionService.selectedElements.includes(currentDesignItem)) {
|
|
187
|
+
if (event.ctrlKey || event.shiftKey)
|
|
188
|
+
currentDesignItem.instanceServiceContainer.selectionService.setSelectedElements([...currentDesignItem.instanceServiceContainer.selectionService.selectedElements, currentDesignItem]);
|
|
189
|
+
else
|
|
190
|
+
currentDesignItem.instanceServiceContainer.selectionService.setSelectedElements([currentDesignItem]);
|
|
191
|
+
this._actionStartedDesignItems = [...designerCanvas.instanceServiceContainer.selectionService.selectedElements];
|
|
192
|
+
if (designerCanvas.alignOnSnap)
|
|
193
|
+
designerCanvas.snapLines.calculateSnaplines(designerCanvas.instanceServiceContainer.selectionService.selectedElements);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// *** Copy Items via Ctrl Drag ***
|
|
197
|
+
if (!this._clonedItems) {
|
|
198
|
+
this._clonedItems = [];
|
|
199
|
+
for (let d of this._actionStartedDesignItems) {
|
|
200
|
+
const clone = await d.clone();
|
|
201
|
+
this._clonedItems.push(clone);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (event.ctrlKey && !this._copiedItemsInserted) {
|
|
205
|
+
this._copiedItemsInserted = true;
|
|
206
|
+
if (!this._changeGroup)
|
|
207
|
+
this._changeGroup = designerCanvas.rootDesignItem.openGroup("Copy Elements");
|
|
208
|
+
for (let i = 0; i < this._clonedItems.length; i++) {
|
|
209
|
+
this._actionStartedDesignItems[i].insertAdjacentElement(this._clonedItems[i], 'beforebegin');
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else if (!event.ctrlKey && this._copiedItemsInserted) {
|
|
213
|
+
for (let d of this._clonedItems) {
|
|
214
|
+
d.remove();
|
|
215
|
+
}
|
|
216
|
+
this._copiedItemsInserted = false;
|
|
217
|
+
}
|
|
218
|
+
// *** End Copy Items Part ***
|
|
177
219
|
const elementMoved = currentPoint.x != this._initialPoint.x || currentPoint.y != this._initialPoint.y;
|
|
178
220
|
if (this._actionType != PointerActionType.Drag && elementMoved) {
|
|
179
221
|
this._actionType = PointerActionType.Drag;
|
|
@@ -238,8 +280,12 @@ export class PointerTool {
|
|
|
238
280
|
case EventNames.PointerUp:
|
|
239
281
|
{
|
|
240
282
|
if (!this._movedSinceStartedAction || this._actionType == PointerActionType.DragOrSelect) {
|
|
241
|
-
if (this._previousEventName == EventNames.PointerDown && !event.shiftKey && !event.ctrlKey)
|
|
283
|
+
if (this._previousEventName == EventNames.PointerDown && !event.shiftKey && !event.ctrlKey) {
|
|
242
284
|
designerCanvas.instanceServiceContainer.selectionService.setSelectedElements([this._actionStartedDesignItem]);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
this.checkSelectElement(event, designerCanvas, currentDesignItem);
|
|
288
|
+
}
|
|
243
289
|
return;
|
|
244
290
|
}
|
|
245
291
|
if (this._movedSinceStartedAction) {
|
|
@@ -247,9 +293,11 @@ export class PointerTool {
|
|
|
247
293
|
let containerService = designerCanvas.serviceContainer.getLastServiceWhere('containerService', x => x.serviceForContainer(this._actionStartedDesignItem.parent, containerStyle));
|
|
248
294
|
const cp = { x: currentPoint.x - this._moveItemsOffset.x, y: currentPoint.y - this._moveItemsOffset.y };
|
|
249
295
|
if (containerService) {
|
|
250
|
-
|
|
296
|
+
if (!this._changeGroup)
|
|
297
|
+
this._changeGroup = designerCanvas.rootDesignItem.openGroup("Move Elements");
|
|
251
298
|
containerService.finishPlace(event, designerCanvas, this._actionStartedDesignItem.parent, this._initialPoint, this._initialOffset, cp, designerCanvas.instanceServiceContainer.selectionService.selectedElements);
|
|
252
|
-
|
|
299
|
+
this._changeGroup.commit();
|
|
300
|
+
this._changeGroup = null;
|
|
253
301
|
}
|
|
254
302
|
designerCanvas.extensionManager.removeExtension(this._dragExtensionItem, ExtensionType.ContainerDrag);
|
|
255
303
|
this._dragExtensionItem = null;
|
|
@@ -258,10 +306,33 @@ export class PointerTool {
|
|
|
258
306
|
this._moveItemsOffset = { x: 0, y: 0 };
|
|
259
307
|
}
|
|
260
308
|
designerCanvas.extensionManager.refreshExtensions(designerCanvas.instanceServiceContainer.selectionService.selectedElements);
|
|
309
|
+
if (this._changeGroup) {
|
|
310
|
+
this._changeGroup.abort();
|
|
311
|
+
this._changeGroup = null;
|
|
312
|
+
}
|
|
261
313
|
break;
|
|
262
314
|
}
|
|
263
315
|
}
|
|
264
316
|
}
|
|
317
|
+
checkSelectElement(event, designerCanvas, currentDesignItem) {
|
|
318
|
+
if (event.shiftKey || event.ctrlKey) {
|
|
319
|
+
const index = designerCanvas.instanceServiceContainer.selectionService.selectedElements.indexOf(currentDesignItem);
|
|
320
|
+
if (index >= 0) {
|
|
321
|
+
let newSelectedList = designerCanvas.instanceServiceContainer.selectionService.selectedElements.slice(0);
|
|
322
|
+
newSelectedList.splice(index, 1);
|
|
323
|
+
designerCanvas.instanceServiceContainer.selectionService.setSelectedElements(newSelectedList);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
let newSelectedList = designerCanvas.instanceServiceContainer.selectionService.selectedElements.slice(0);
|
|
327
|
+
newSelectedList.push(currentDesignItem);
|
|
328
|
+
designerCanvas.instanceServiceContainer.selectionService.setSelectedElements(newSelectedList);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
if (designerCanvas.instanceServiceContainer.selectionService.selectedElements.indexOf(currentDesignItem) < 0)
|
|
333
|
+
designerCanvas.instanceServiceContainer.selectionService.setSelectedElements([currentDesignItem]);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
265
336
|
static FindPossibleContainer(designItem, designItems, event) {
|
|
266
337
|
let newContainerElementDesignItem = null;
|
|
267
338
|
let newContainerService = null;
|
|
@@ -174,13 +174,28 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
|
|
|
174
174
|
nodeColumnIdx: 0,
|
|
175
175
|
checkboxColumnIdx: 0, // render the checkboxes into the 1st column
|
|
176
176
|
},
|
|
177
|
-
|
|
177
|
+
click: (event, data) => {
|
|
178
178
|
if (event.originalEvent) { // only for clicked items, not when elements selected via code.
|
|
179
179
|
let node = data.node;
|
|
180
180
|
let designItem = node.data.ref;
|
|
181
|
-
if (designItem)
|
|
182
|
-
|
|
181
|
+
if (designItem) {
|
|
182
|
+
if (event.ctrlKey) {
|
|
183
|
+
const sel = [...designItem.instanceServiceContainer.selectionService.selectedElements];
|
|
184
|
+
const idx = sel.indexOf(designItem);
|
|
185
|
+
if (idx >= 0) {
|
|
186
|
+
sel.splice(idx, 1);
|
|
187
|
+
designItem.instanceServiceContainer.selectionService.setSelectedElements(sel);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
designItem.instanceServiceContainer.selectionService.setSelectedElements([...sel, designItem]);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
designItem.instanceServiceContainer.selectionService.setSelectedElements([designItem]);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
183
197
|
}
|
|
198
|
+
return false;
|
|
184
199
|
},
|
|
185
200
|
createNode: (event, data) => {
|
|
186
201
|
let node = data.node;
|