@node-projects/web-component-designer 0.0.92 → 0.0.95
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/assets/images/layout/ColorPickerTool.svg +21 -0
- package/assets/images/layout/DrawEllipTool.svg +13 -0
- package/assets/images/layout/DrawLineTool.svg +13 -0
- package/assets/images/layout/DrawPathTool.svg +32 -0
- package/assets/images/layout/DrawRectTool.svg +28 -0
- package/assets/images/layout/MagicWandTool.svg +14 -0
- package/assets/images/layout/PointerTool.svg +10 -0
- package/assets/images/layout/SelectRectTool.svg +9 -0
- package/assets/images/layout/TextBoxTool.svg +8 -0
- package/assets/images/layout/TextTool.svg +7 -0
- package/assets/images/layout/ZoomTool.svg +16 -0
- package/dist/Constants.d.ts +1 -1
- package/dist/Constants.js +4 -1
- package/dist/commandHandling/CommandType.d.ts +2 -0
- package/dist/commandHandling/CommandType.js +2 -0
- package/dist/elements/documentContainer.js +2 -2
- package/dist/elements/helper/contextMenu/ContextMenuHelper.js +2 -4
- package/dist/elements/services/DefaultServiceBootstrap.js +3 -0
- package/dist/elements/services/modelCommandService/DefaultModelCommandService.js +50 -0
- package/dist/elements/services/placementService/DefaultPlacementService.js +2 -2
- package/dist/elements/widgets/bindableObjectsBrowser/bindable-objects-browser.d.ts +0 -1
- package/dist/elements/widgets/bindableObjectsBrowser/bindable-objects-browser.js +1 -2
- package/dist/elements/widgets/designerView/IDesignerCanvas.d.ts +5 -2
- package/dist/elements/widgets/designerView/designerCanvas.d.ts +14 -6
- package/dist/elements/widgets/designerView/designerCanvas.js +85 -127
- package/dist/elements/widgets/designerView/designerView.d.ts +4 -0
- package/dist/elements/widgets/designerView/designerView.js +59 -34
- package/dist/elements/widgets/designerView/extensions/PathExtension.js +0 -1
- package/dist/elements/widgets/designerView/extensions/PathExtensionProvider.js +2 -1
- package/dist/elements/widgets/designerView/extensions/ResizeExtension.js +0 -1
- package/dist/elements/widgets/designerView/extensions/TransformOriginExtension.js +0 -1
- package/dist/elements/widgets/designerView/extensions/TransformOriginExtensionProvider.js +4 -2
- package/dist/elements/widgets/designerView/extensions/contextMenu/ItemsBelowContextMenu.js +1 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/RotateLeftAndRightContextMenu.d.ts +8 -0
- package/dist/elements/widgets/designerView/extensions/contextMenu/RotateLeftAndRightContextMenu.js +12 -0
- package/dist/elements/widgets/designerView/tools/DrawEllipsisTool.js +2 -1
- package/dist/elements/widgets/designerView/tools/DrawLineTool.js +2 -1
- package/dist/elements/widgets/designerView/tools/DrawPathTool.js +5 -2
- package/dist/elements/widgets/designerView/tools/DrawRectTool.js +2 -1
- package/dist/elements/widgets/designerView/tools/MagicWandSelectorTool.js +2 -1
- package/dist/elements/widgets/designerView/tools/NamedTools.d.ts +2 -1
- package/dist/elements/widgets/designerView/tools/NamedTools.js +1 -0
- package/dist/elements/widgets/designerView/tools/PanTool.js +2 -1
- package/dist/elements/widgets/designerView/tools/PointerTool.d.ts +1 -2
- package/dist/elements/widgets/designerView/tools/PointerTool.js +58 -122
- package/dist/elements/widgets/designerView/tools/RectangleSelectorTool.js +2 -1
- package/dist/elements/widgets/designerView/tools/designerToolbarGenerics/designerToolRenderer.d.ts +5 -0
- package/dist/elements/widgets/designerView/tools/designerToolbarGenerics/designerToolRenderer.js +19 -0
- package/dist/elements/widgets/designerView/tools/designerToolbarGenerics/designerToolbarPopup.d.ts +8 -0
- package/dist/elements/widgets/designerView/tools/designerToolbarGenerics/designerToolbarPopup.js +37 -0
- package/dist/elements/widgets/designerView/tools/designerToolbarGenerics/designerToolbarPopupToolSelect.d.ts +12 -0
- package/dist/elements/widgets/designerView/tools/designerToolbarGenerics/designerToolbarPopupToolSelect.js +44 -0
- package/dist/elements/widgets/designerView/tools/designerToolbarGenerics/designerToolsButtons.d.ts +32 -0
- package/dist/elements/widgets/designerView/tools/designerToolbarGenerics/designerToolsButtons.js +96 -0
- package/dist/elements/widgets/designerView/tools/designerToolbarPopups/DrawToolPopup.d.ts +8 -0
- package/dist/elements/widgets/designerView/tools/designerToolbarPopups/DrawToolPopup.js +25 -0
- package/dist/elements/widgets/designerView/tools/designerToolsDock.d.ts +23 -0
- package/dist/elements/widgets/designerView/tools/designerToolsDock.js +115 -0
- package/dist/elements/widgets/miniatureView/html-2-canvas-miniature-view.js +1 -0
- package/dist/elements/widgets/paletteView/paletteTreeView.d.ts +0 -1
- package/dist/elements/widgets/paletteView/paletteTreeView.js +1 -2
- package/dist/elements/widgets/paletteView/paletteView.js +1 -0
- package/dist/elements/widgets/propertyGrid/PropertyGrid.js +1 -0
- package/dist/elements/widgets/propertyGrid/PropertyGridPropertyList.js +1 -0
- package/dist/elements/widgets/propertyGrid/PropertyGridWithHeader.js +1 -0
- package/dist/elements/widgets/treeView/treeView.js +1 -0
- package/dist/elements/widgets/treeView/treeViewExtended.js +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +42 -42
|
@@ -10,6 +10,7 @@ export class MagicWandSelectorTool {
|
|
|
10
10
|
switch (event.type) {
|
|
11
11
|
case EventNames.PointerDown:
|
|
12
12
|
event.target.setPointerCapture(event.pointerId);
|
|
13
|
+
designerCanvas.captureActiveTool(this);
|
|
13
14
|
this._path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
14
15
|
this._path.setAttribute('class', 'svg-selector');
|
|
15
16
|
this._pathD = "M" + currentPoint.x + " " + currentPoint.y;
|
|
@@ -24,7 +25,7 @@ export class MagicWandSelectorTool {
|
|
|
24
25
|
break;
|
|
25
26
|
case EventNames.PointerUp:
|
|
26
27
|
event.target.releasePointerCapture(event.pointerId);
|
|
27
|
-
designerCanvas.
|
|
28
|
+
designerCanvas.releaseActiveTool();
|
|
28
29
|
const elements = designerCanvas.rootDesignItem.element.querySelectorAll('*');
|
|
29
30
|
const inSelectionElements = [];
|
|
30
31
|
let point = designerCanvas.overlayLayer.createPoint();
|
|
@@ -5,6 +5,7 @@ export class PanTool {
|
|
|
5
5
|
switch (event.type) {
|
|
6
6
|
case EventNames.PointerDown:
|
|
7
7
|
event.target.setPointerCapture(event.pointerId);
|
|
8
|
+
designerCanvas.captureActiveTool(this);
|
|
8
9
|
break;
|
|
9
10
|
case EventNames.PointerMove:
|
|
10
11
|
if (event.buttons == 1) {
|
|
@@ -13,7 +14,7 @@ export class PanTool {
|
|
|
13
14
|
break;
|
|
14
15
|
case EventNames.PointerUp:
|
|
15
16
|
event.target.releasePointerCapture(event.pointerId);
|
|
16
|
-
designerCanvas.
|
|
17
|
+
designerCanvas.releaseActiveTool();
|
|
17
18
|
break;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
@@ -8,7 +8,6 @@ export declare class PointerTool implements ITool {
|
|
|
8
8
|
private _actionType?;
|
|
9
9
|
private _actionStartedDesignItem?;
|
|
10
10
|
private _previousEventName;
|
|
11
|
-
private _clickThroughElements;
|
|
12
11
|
private _dragOverExtensionItem;
|
|
13
12
|
private _dragExtensionItem;
|
|
14
13
|
private _moveItemsOffset;
|
|
@@ -18,8 +17,8 @@ export declare class PointerTool implements ITool {
|
|
|
18
17
|
dispose(): void;
|
|
19
18
|
private _showContextMenu;
|
|
20
19
|
pointerEventHandler(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): void;
|
|
20
|
+
private _resetTool;
|
|
21
21
|
private _pointerActionTypeDrawSelection;
|
|
22
|
-
private _resetPointerEventsForClickThrough;
|
|
23
22
|
private _pointerActionTypeDragOrSelect;
|
|
24
23
|
keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent, currentElement: Element): void;
|
|
25
24
|
}
|
|
@@ -3,7 +3,6 @@ import { PointerActionType } from "../../../../enums/PointerActionType";
|
|
|
3
3
|
import { DesignItem } from "../../../item/DesignItem";
|
|
4
4
|
import { ExtensionType } from "../extensions/ExtensionType";
|
|
5
5
|
import { NamedTools } from './NamedTools';
|
|
6
|
-
import { DomHelper } from '@node-projects/base-custom-webcomponent/dist/DomHelper';
|
|
7
6
|
export class PointerTool {
|
|
8
7
|
cursor = 'default';
|
|
9
8
|
_movedSinceStartedAction = false;
|
|
@@ -11,7 +10,6 @@ export class PointerTool {
|
|
|
11
10
|
_actionType;
|
|
12
11
|
_actionStartedDesignItem;
|
|
13
12
|
_previousEventName;
|
|
14
|
-
_clickThroughElements = [];
|
|
15
13
|
_dragOverExtensionItem;
|
|
16
14
|
_dragExtensionItem;
|
|
17
15
|
_moveItemsOffset = { x: 0, y: 0 };
|
|
@@ -25,16 +23,18 @@ export class PointerTool {
|
|
|
25
23
|
_showContextMenu(event, designerCanvas) {
|
|
26
24
|
event.preventDefault();
|
|
27
25
|
if (!event.shiftKey) {
|
|
28
|
-
let items = designerCanvas.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (!designerCanvas.instanceServiceContainer.selectionService.isSelected(designItem)) {
|
|
34
|
-
designerCanvas.instanceServiceContainer.selectionService.setSelectedElements([designItem]);
|
|
26
|
+
let items = designerCanvas.elementsFromPoint(event.x, event.y);
|
|
27
|
+
for (let e of designerCanvas.instanceServiceContainer.selectionService.selectedElements) {
|
|
28
|
+
if (items.indexOf(e.element) >= 0) {
|
|
29
|
+
designerCanvas.showDesignItemContextMenu(designerCanvas.instanceServiceContainer.selectionService.primarySelection, event);
|
|
30
|
+
return;
|
|
35
31
|
}
|
|
36
|
-
designerCanvas.showDesignItemContextMenu(designItem, event);
|
|
37
32
|
}
|
|
33
|
+
const designItem = DesignItem.GetOrCreateDesignItem(event.target, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
34
|
+
if (!designerCanvas.instanceServiceContainer.selectionService.isSelected(designItem)) {
|
|
35
|
+
designerCanvas.instanceServiceContainer.selectionService.setSelectedElements([designItem]);
|
|
36
|
+
}
|
|
37
|
+
designerCanvas.showDesignItemContextMenu(designItem, event);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
pointerEventHandler(designerCanvas, event, currentElement) {
|
|
@@ -52,15 +52,14 @@ export class PointerTool {
|
|
|
52
52
|
switch (event.type) {
|
|
53
53
|
case EventNames.PointerDown:
|
|
54
54
|
event.target.setPointerCapture(event.pointerId);
|
|
55
|
+
designerCanvas.captureActiveTool(this);
|
|
55
56
|
this._movedSinceStartedAction = false;
|
|
56
57
|
break;
|
|
57
58
|
case EventNames.PointerUp:
|
|
58
59
|
event.target.releasePointerCapture(event.pointerId);
|
|
59
|
-
designerCanvas.
|
|
60
|
+
designerCanvas.releaseActiveTool();
|
|
60
61
|
break;
|
|
61
62
|
}
|
|
62
|
-
if (!event.altKey)
|
|
63
|
-
this._resetPointerEventsForClickThrough();
|
|
64
63
|
if (!currentElement)
|
|
65
64
|
return;
|
|
66
65
|
const currentPoint = designerCanvas.getNormalizedEventCoordinates(event);
|
|
@@ -100,39 +99,38 @@ export class PointerTool {
|
|
|
100
99
|
if (currentDesignItem !== designerCanvas.rootDesignItem)
|
|
101
100
|
designerCanvas.instanceServiceContainer.selectionService.setSelectedElements([currentDesignItem]);
|
|
102
101
|
}
|
|
103
|
-
this.
|
|
104
|
-
this._actionStartedDesignItem = null;
|
|
105
|
-
this._movedSinceStartedAction = false;
|
|
106
|
-
this._initialPoint = null;
|
|
102
|
+
this._resetTool();
|
|
107
103
|
}
|
|
108
104
|
this._previousEventName = event.type;
|
|
109
105
|
}
|
|
106
|
+
_resetTool() {
|
|
107
|
+
this._actionType = null;
|
|
108
|
+
this._actionStartedDesignItem = null;
|
|
109
|
+
this._movedSinceStartedAction = false;
|
|
110
|
+
this._initialPoint = null;
|
|
111
|
+
}
|
|
110
112
|
_pointerActionTypeDrawSelection(designerView, event, currentElement) {
|
|
111
113
|
const drawSelectionTool = designerView.serviceContainer.designerTools.get(NamedTools.DrawSelection);
|
|
112
114
|
if (drawSelectionTool) {
|
|
115
|
+
this._resetTool();
|
|
113
116
|
drawSelectionTool.pointerEventHandler(designerView, event, currentElement);
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
|
-
_resetPointerEventsForClickThrough() {
|
|
117
|
-
if (!this._clickThroughElements.length)
|
|
118
|
-
return;
|
|
119
|
-
for (const e of this._clickThroughElements) {
|
|
120
|
-
e[0].element.style.pointerEvents = e[1];
|
|
121
|
-
}
|
|
122
|
-
this._clickThroughElements = [];
|
|
123
|
-
}
|
|
124
119
|
_pointerActionTypeDragOrSelect(designerCanvas, event, currentDesignItem, currentPoint) {
|
|
125
120
|
if (event.altKey) {
|
|
126
121
|
if (event.type == EventNames.PointerDown) {
|
|
127
|
-
|
|
128
|
-
|
|
122
|
+
const currentSelection = designerCanvas.instanceServiceContainer.selectionService.primarySelection;
|
|
123
|
+
if (currentSelection) {
|
|
124
|
+
const elements = designerCanvas.elementsFromPoint(event.x, event.y);
|
|
125
|
+
let idx = elements.indexOf(currentSelection.element);
|
|
126
|
+
if (idx >= 0) {
|
|
127
|
+
idx++;
|
|
128
|
+
}
|
|
129
|
+
let currentElement = elements[idx];
|
|
130
|
+
if (currentElement)
|
|
131
|
+
currentDesignItem = DesignItem.GetOrCreateDesignItem(currentElement, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
132
|
+
}
|
|
129
133
|
}
|
|
130
|
-
let currentElement = designerCanvas.elementFromPoint(event.x, event.y);
|
|
131
|
-
if (DomHelper.getHost(currentElement) !== designerCanvas.overlayLayer)
|
|
132
|
-
currentDesignItem = DesignItem.GetOrCreateDesignItem(currentElement, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
this._resetPointerEventsForClickThrough();
|
|
136
134
|
}
|
|
137
135
|
switch (event.type) {
|
|
138
136
|
case EventNames.PointerDown:
|
|
@@ -183,103 +181,41 @@ export class PointerTool {
|
|
|
183
181
|
let newContainerElementDesignItem = null;
|
|
184
182
|
let newContainerService = null;
|
|
185
183
|
if (canLeave) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
184
|
+
const elementsFromPoint = designerCanvas.elementsFromPoint(event.x, event.y);
|
|
185
|
+
for (let e of elementsFromPoint) {
|
|
186
|
+
if (e == this._actionStartedDesignItem.element) {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
else if (e == this._actionStartedDesignItem.parent.element) {
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
else if (e == designerCanvas.rootDesignItem.element) {
|
|
193
|
+
newContainerElementDesignItem = designerCanvas.rootDesignItem;
|
|
194
|
+
const containerStyle = getComputedStyle(newContainerElementDesignItem.element);
|
|
195
|
+
newContainerService = designerCanvas.serviceContainer.getLastServiceWhere('containerService', x => x.serviceForContainer(newContainerElementDesignItem, containerStyle));
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
else if (false) {
|
|
199
|
+
//check we don't try to move a item over one of its children..
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
newContainerElementDesignItem = DesignItem.GetOrCreateDesignItem(e, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
203
|
+
const containerStyle = getComputedStyle(newContainerElementDesignItem.element);
|
|
204
|
+
newContainerService = designerCanvas.serviceContainer.getLastServiceWhere('containerService', x => x.serviceForContainer(newContainerElementDesignItem, containerStyle));
|
|
205
|
+
if (newContainerService) {
|
|
206
|
+
if (newContainerService.canEnter(newContainerElementDesignItem, [this._actionStartedDesignItem])) {
|
|
209
207
|
break;
|
|
210
208
|
}
|
|
211
|
-
|
|
212
|
-
else if (newContainerElement == this._actionStartedDesignItem.element || newContainerElement == currentDesignItem.element) {
|
|
213
|
-
backupPEventsMap.set(newContainerElement, newContainerElement.style.pointerEvents);
|
|
214
|
-
newContainerElement.style.pointerEvents = 'none';
|
|
215
|
-
const old = newContainerElement;
|
|
216
|
-
newContainerElement = designerCanvas.elementFromPoint(event.x, event.y);
|
|
217
|
-
if (old === newContainerElement) {
|
|
209
|
+
else {
|
|
218
210
|
newContainerElementDesignItem = null;
|
|
219
211
|
newContainerService = null;
|
|
220
|
-
|
|
221
|
-
break;
|
|
212
|
+
continue;
|
|
222
213
|
}
|
|
223
214
|
}
|
|
224
|
-
else {
|
|
225
|
-
//check we don't try to move a item over one of its children...
|
|
226
|
-
let par = newContainerElement.parentElement;
|
|
227
|
-
while (par) {
|
|
228
|
-
if (par == this._actionStartedDesignItem.element) {
|
|
229
|
-
backupPEventsMap.set(newContainerElement, newContainerElement.style.pointerEvents);
|
|
230
|
-
newContainerElement.style.pointerEvents = 'none';
|
|
231
|
-
const old = newContainerElement;
|
|
232
|
-
newContainerElement = designerCanvas.elementFromPoint(event.x, event.y);
|
|
233
|
-
if (old === newContainerElement)
|
|
234
|
-
break;
|
|
235
|
-
continue checkAgain;
|
|
236
|
-
}
|
|
237
|
-
par = par.parentElement;
|
|
238
|
-
}
|
|
239
|
-
//end check
|
|
240
|
-
newContainerElementDesignItem = DesignItem.GetOrCreateDesignItem(newContainerElement, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
241
|
-
const containerStyle = getComputedStyle(newContainerElementDesignItem.element);
|
|
242
|
-
newContainerService = designerCanvas.serviceContainer.getLastServiceWhere('containerService', x => x.serviceForContainer(newContainerElementDesignItem, containerStyle));
|
|
243
|
-
if (newContainerService) {
|
|
244
|
-
if (newContainerService.canEnter(newContainerElementDesignItem, [this._actionStartedDesignItem])) {
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
newContainerElementDesignItem = null;
|
|
249
|
-
newContainerService = null;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
backupPEventsMap.set(newContainerElement, newContainerElement.style.pointerEvents);
|
|
253
|
-
newContainerElement.style.pointerEvents = 'none';
|
|
254
|
-
const newC = designerCanvas.elementFromPoint(event.x, event.y);
|
|
255
|
-
if (newContainerElement === newC) {
|
|
256
|
-
newContainerElement = null;
|
|
257
|
-
break;
|
|
258
|
-
}
|
|
259
|
-
newContainerElement = newC;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
finally {
|
|
264
|
-
for (let e of backupPEventsMap.entries()) {
|
|
265
|
-
e[0].style.pointerEvents = e[1];
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (newContainerElement != null) { //Check if container is in designer canvas....
|
|
269
|
-
let p = newContainerElement;
|
|
270
|
-
while (p != null) {
|
|
271
|
-
if (p === designerCanvas.rootDesignItem.element)
|
|
272
|
-
break;
|
|
273
|
-
p = p.parentElement;
|
|
274
|
-
}
|
|
275
|
-
if (p == null) {
|
|
276
|
-
newContainerService = null;
|
|
277
|
-
newContainerElement = null;
|
|
278
215
|
}
|
|
279
216
|
}
|
|
280
217
|
//if we found a new enterable container create extensions
|
|
281
|
-
if (
|
|
282
|
-
const newContainerElementDesignItem = DesignItem.GetOrCreateDesignItem(newContainerElement, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
218
|
+
if (newContainerElementDesignItem != null) {
|
|
283
219
|
if (this._dragOverExtensionItem != newContainerElementDesignItem) {
|
|
284
220
|
designerCanvas.extensionManager.removeExtension(this._dragOverExtensionItem, ExtensionType.ContainerDragOver);
|
|
285
221
|
designerCanvas.extensionManager.applyExtension(newContainerElementDesignItem, ExtensionType.ContainerDragOver);
|
|
@@ -320,7 +256,7 @@ export class PointerTool {
|
|
|
320
256
|
{
|
|
321
257
|
if (!this._movedSinceStartedAction || this._actionType == PointerActionType.DragOrSelect) {
|
|
322
258
|
if (this._previousEventName == EventNames.PointerDown && !event.shiftKey && !event.ctrlKey)
|
|
323
|
-
designerCanvas.instanceServiceContainer.selectionService.setSelectedElements([
|
|
259
|
+
designerCanvas.instanceServiceContainer.selectionService.setSelectedElements([this._actionStartedDesignItem]);
|
|
324
260
|
return;
|
|
325
261
|
}
|
|
326
262
|
if (this._movedSinceStartedAction) {
|
|
@@ -12,6 +12,7 @@ export class RectangleSelectorTool {
|
|
|
12
12
|
switch (event.type) {
|
|
13
13
|
case EventNames.PointerDown:
|
|
14
14
|
event.target.setPointerCapture(event.pointerId);
|
|
15
|
+
designerCanvas.captureActiveTool(this);
|
|
15
16
|
this._initialPoint = currentPoint;
|
|
16
17
|
if (!this._rect)
|
|
17
18
|
this._rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
@@ -46,7 +47,7 @@ export class RectangleSelectorTool {
|
|
|
46
47
|
break;
|
|
47
48
|
case EventNames.PointerUp:
|
|
48
49
|
event.target.releasePointerCapture(event.pointerId);
|
|
49
|
-
designerCanvas.
|
|
50
|
+
designerCanvas.releaseActiveTool();
|
|
50
51
|
const elements = designerCanvas.rootDesignItem.element.querySelectorAll('*');
|
|
51
52
|
const inSelectionElements = [];
|
|
52
53
|
let point = designerCanvas.overlayLayer.createPoint();
|
package/dist/elements/widgets/designerView/tools/designerToolbarGenerics/designerToolRenderer.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ToolPopupCategoryCollection } from "./designerToolsButtons";
|
|
2
|
+
export declare abstract class DesignerToolRenderer {
|
|
3
|
+
static createToolFromObject(tool: ToolPopupCategoryCollection): ChildNode;
|
|
4
|
+
static createObjectFromTool(tool: HTMLDivElement): ToolPopupCategoryCollection;
|
|
5
|
+
}
|
package/dist/elements/widgets/designerView/tools/designerToolbarGenerics/designerToolRenderer.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//TODO: rename, this is no renderer, it's a static class so more a helper
|
|
2
|
+
export class DesignerToolRenderer {
|
|
3
|
+
static createToolFromObject(tool) {
|
|
4
|
+
let template = document.createElement('template');
|
|
5
|
+
template.innerHTML = "<div class='tool' data-command='setTool' data-command-parameter=" + tool.command_parameter + " popup=" + tool.category + " title=" + tool.title + " style='background-image:" + tool.background_url + ";'></div>";
|
|
6
|
+
return template.content.childNodes[0];
|
|
7
|
+
}
|
|
8
|
+
static createObjectFromTool(tool) {
|
|
9
|
+
let collector = {
|
|
10
|
+
category: tool.getAttribute("popup"),
|
|
11
|
+
command: tool.getAttribute("data-command"),
|
|
12
|
+
command_parameter: tool.getAttribute("data-command-parameter"),
|
|
13
|
+
title: tool.getAttribute("title"),
|
|
14
|
+
tool: tool.getAttribute("data-command-parameter"),
|
|
15
|
+
background_url: tool.style.backgroundImage,
|
|
16
|
+
};
|
|
17
|
+
return collector;
|
|
18
|
+
}
|
|
19
|
+
}
|
package/dist/elements/widgets/designerView/tools/designerToolbarGenerics/designerToolbarPopup.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
export declare abstract class DesignerToolbarPopup extends BaseCustomWebComponentConstructorAppend {
|
|
3
|
+
static readonly style: CSSStyleSheet;
|
|
4
|
+
static readonly template: HTMLTemplateElement;
|
|
5
|
+
ready(): void;
|
|
6
|
+
protected _setTitle(title: string): void;
|
|
7
|
+
protected _setContent(elements: HTMLElement[]): void;
|
|
8
|
+
}
|
package/dist/elements/widgets/designerView/tools/designerToolbarGenerics/designerToolbarPopup.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend, css, html } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
export class DesignerToolbarPopup extends BaseCustomWebComponentConstructorAppend {
|
|
3
|
+
static style = css `
|
|
4
|
+
.container {
|
|
5
|
+
width: 150px;
|
|
6
|
+
min-height: 200px;
|
|
7
|
+
color: white;
|
|
8
|
+
background-color: rgb(64, 64, 64);
|
|
9
|
+
border: 1px solid black;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
header {
|
|
13
|
+
text-align: center;
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
static template = html `
|
|
17
|
+
<div class="container">
|
|
18
|
+
<header><h2 id="title" style="margin: 0;"></h2></header>
|
|
19
|
+
<main id="content-area"></main>
|
|
20
|
+
</div>
|
|
21
|
+
`;
|
|
22
|
+
//TODO: remove this class,
|
|
23
|
+
// i think the popups need no base, okay if they need one the should at least be normal elmeents
|
|
24
|
+
// and also the expicit popup should set the size, not the base class. maybe one needs to be bigger, one smaller...
|
|
25
|
+
ready() {
|
|
26
|
+
this._setTitle(this.getAttribute("title"));
|
|
27
|
+
}
|
|
28
|
+
_setTitle(title) {
|
|
29
|
+
this._getDomElement("title").innerHTML = title;
|
|
30
|
+
}
|
|
31
|
+
_setContent(elements) {
|
|
32
|
+
let contentArea = this._getDomElement("content-area");
|
|
33
|
+
for (let elem of elements) {
|
|
34
|
+
contentArea.appendChild(elem);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend, TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
import { ToolPopupCategoryCollection } from "./designerToolsButtons";
|
|
3
|
+
export declare class DesignerToolbarPopupToolSelect extends BaseCustomWebComponentConstructorAppend {
|
|
4
|
+
static readonly style: CSSStyleSheet;
|
|
5
|
+
static readonly template: HTMLTemplateElement;
|
|
6
|
+
private _popupToolSelected;
|
|
7
|
+
constructor();
|
|
8
|
+
readonly toolActivated: TypedEvent<ToolPopupCategoryCollection>;
|
|
9
|
+
insertToolContent(template: HTMLTemplateElement): Promise<void>;
|
|
10
|
+
private _setupEventHandler;
|
|
11
|
+
private _toolSelected;
|
|
12
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend, css, html, TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
import { DesignerToolRenderer } from "./designerToolRenderer";
|
|
3
|
+
export class DesignerToolbarPopupToolSelect extends BaseCustomWebComponentConstructorAppend {
|
|
4
|
+
static style = css `
|
|
5
|
+
.popup-tool-select {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-wrap: wrap;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.tool {
|
|
11
|
+
height: 32px;
|
|
12
|
+
width: 32px;
|
|
13
|
+
background-color: rgb(255, 255, 255);
|
|
14
|
+
background-size: 65%;
|
|
15
|
+
background-repeat: no-repeat;
|
|
16
|
+
background-position: center center;
|
|
17
|
+
flex-shrink: 0;
|
|
18
|
+
border-bottom: 1px solid black;
|
|
19
|
+
}`;
|
|
20
|
+
static template = html `
|
|
21
|
+
<div id="popup-tool-select" class="popup-tool-select"></div>`;
|
|
22
|
+
_popupToolSelected;
|
|
23
|
+
//TODO: remove this element. it only contains a div, and binds events.
|
|
24
|
+
// this could also be done by the user of this
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
27
|
+
this._popupToolSelected = this._getDomElement("popup-tool-select");
|
|
28
|
+
}
|
|
29
|
+
toolActivated = new TypedEvent();
|
|
30
|
+
async insertToolContent(template) {
|
|
31
|
+
this._popupToolSelected.appendChild(template.content.cloneNode(true));
|
|
32
|
+
await this._waitForChildrenReady();
|
|
33
|
+
this._setupEventHandler();
|
|
34
|
+
}
|
|
35
|
+
_setupEventHandler() {
|
|
36
|
+
for (let tool of [...this._popupToolSelected.querySelectorAll("div.tool")]) {
|
|
37
|
+
tool.addEventListener("click", () => this._toolSelected(tool));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
_toolSelected(tool) {
|
|
41
|
+
this.toolActivated.emit(DesignerToolRenderer.createObjectFromTool(tool));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
customElements.define('node-projects-designer-tools-popup-select', DesignerToolbarPopupToolSelect);
|
package/dist/elements/widgets/designerView/tools/designerToolbarGenerics/designerToolsButtons.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend, TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
import { NamedTools } from "../NamedTools.js";
|
|
3
|
+
export interface ToolTypeAsArg {
|
|
4
|
+
command_parameter: string;
|
|
5
|
+
open_popup?: boolean;
|
|
6
|
+
popup_category?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ToolPopupCategoryCollection {
|
|
9
|
+
category: string;
|
|
10
|
+
command: string;
|
|
11
|
+
command_parameter: string;
|
|
12
|
+
title: string;
|
|
13
|
+
tool: NamedTools;
|
|
14
|
+
background_url: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class DesignerToolsButtons extends BaseCustomWebComponentConstructorAppend {
|
|
17
|
+
static readonly style: CSSStyleSheet;
|
|
18
|
+
static readonly template: HTMLTemplateElement;
|
|
19
|
+
readonly toolActivated: TypedEvent<[ToolPopupCategoryCollection, boolean]>;
|
|
20
|
+
private _toolButtons;
|
|
21
|
+
private _toolCollection;
|
|
22
|
+
private _toolbarhost;
|
|
23
|
+
ready(): void;
|
|
24
|
+
setToolsExternal(tools: ChildNode[]): void;
|
|
25
|
+
private _initToolCategories;
|
|
26
|
+
private _createToolEventListeners;
|
|
27
|
+
private _toolSelected;
|
|
28
|
+
markToolAsSelected(id: string): void;
|
|
29
|
+
private _unselectTools;
|
|
30
|
+
externalToolChange(command_name: string): void;
|
|
31
|
+
get toolCollection(): ToolPopupCategoryCollection[];
|
|
32
|
+
}
|
package/dist/elements/widgets/designerView/tools/designerToolbarGenerics/designerToolsButtons.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend, css, html, TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
import { assetsPath } from "../../../../../Constants.js";
|
|
3
|
+
import { NamedTools } from "../NamedTools.js";
|
|
4
|
+
import { DesignerToolRenderer } from "./designerToolRenderer.js";
|
|
5
|
+
export class DesignerToolsButtons extends BaseCustomWebComponentConstructorAppend {
|
|
6
|
+
static style = css `
|
|
7
|
+
.toolbar-host{
|
|
8
|
+
width: calc(100% - 2px);
|
|
9
|
+
height: calc(100% - 2px);
|
|
10
|
+
border: 1px solid black;
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
justify-content: flex-start;
|
|
14
|
+
align-items: center;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.tool {
|
|
18
|
+
height: 32px;
|
|
19
|
+
width: 32px;
|
|
20
|
+
background-color: rgb(255, 255, 255);
|
|
21
|
+
background-size: 65%;
|
|
22
|
+
background-repeat: no-repeat;
|
|
23
|
+
background-position: center center;
|
|
24
|
+
flex-shrink: 0;
|
|
25
|
+
border-bottom: 1px solid black;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.tool[selected] {
|
|
29
|
+
background-color: rgb(47, 53, 69);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.tool:hover {
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
static template = html `
|
|
37
|
+
<div id="toolbar-host" class="toolbar-host"></div>`;
|
|
38
|
+
toolActivated = new TypedEvent();
|
|
39
|
+
_toolButtons;
|
|
40
|
+
_toolCollection;
|
|
41
|
+
_toolbarhost;
|
|
42
|
+
ready() {
|
|
43
|
+
this._initToolCategories();
|
|
44
|
+
this._toolbarhost = this._getDomElement("toolbar-host");
|
|
45
|
+
}
|
|
46
|
+
setToolsExternal(tools) {
|
|
47
|
+
for (let tool of tools) {
|
|
48
|
+
this._toolbarhost.appendChild(tool);
|
|
49
|
+
}
|
|
50
|
+
this._createToolEventListeners();
|
|
51
|
+
}
|
|
52
|
+
_initToolCategories() {
|
|
53
|
+
let toolCollection = [];
|
|
54
|
+
toolCollection.push({ tool: NamedTools.Pointer, category: "pointer", command: "setTool", command_parameter: NamedTools.Pointer, title: "Pointer Tool", background_url: "url(" + assetsPath + "images/layout/PointerTool.svg)" });
|
|
55
|
+
toolCollection.push({ tool: NamedTools.MagicWandSelector, category: "selector", command: "setTool", command_parameter: NamedTools.MagicWandSelector, title: "Magic Wand Selector", background_url: "url(" + assetsPath + "images/layout/MagicWandTool.svg)" });
|
|
56
|
+
toolCollection.push({ tool: NamedTools.RectangleSelector, category: "selector", command: "setTool", command_parameter: NamedTools.RectangleSelector, title: "Rectangle Selector", background_url: "url(" + assetsPath + "images/layout/SelectRectTool.svg)" });
|
|
57
|
+
toolCollection.push({ tool: NamedTools.DrawLine, category: "draw", command: "setTool", command_parameter: NamedTools.DrawLine, title: "Draw Line", background_url: "url(" + assetsPath + "images/layout/DrawLineTool.svg)" });
|
|
58
|
+
toolCollection.push({ tool: NamedTools.DrawPath, category: "draw", command: "setTool", command_parameter: NamedTools.DrawPath, title: "Draw Path", background_url: "url(" + assetsPath + "images/layout/DrawPathTool.svg)" });
|
|
59
|
+
toolCollection.push({ tool: NamedTools.DrawRect, category: "draw", command: "setTool", command_parameter: NamedTools.DrawRect, title: "Draw Rectangle", background_url: "url(" + assetsPath + "images/layout/DrawRectTool.svg)" });
|
|
60
|
+
toolCollection.push({ tool: NamedTools.DrawEllipsis, category: "draw", command: "setTool", command_parameter: NamedTools.DrawEllipsis, title: "Draw Ellipsis", background_url: "url(" + assetsPath + "images/layout/DrawEllipTool.svg)" });
|
|
61
|
+
toolCollection.push({ tool: NamedTools.Zoom, category: "zoom", command: "setTool", command_parameter: NamedTools.Zoom, title: "Zoom Tool", background_url: "url(" + assetsPath + "images/layout/ZoomTool.svg)" });
|
|
62
|
+
toolCollection.push({ tool: NamedTools.Text, category: "text", command: "setTool", command_parameter: NamedTools.Text, title: "Text Tool", background_url: "url(" + assetsPath + "images/layout/TextTool.svg)" });
|
|
63
|
+
toolCollection.push({ tool: NamedTools.TextBoc, category: "text", command: "setTool", command_parameter: NamedTools.TextBoc, title: "Textbox Tool", background_url: "url(" + assetsPath + "images/layout/TextBoxTool.svg)" });
|
|
64
|
+
toolCollection.push({ tool: NamedTools.PickColor, category: "pick", command: "setTool", command_parameter: NamedTools.PickColor, title: "Color Picker", background_url: "url(" + assetsPath + "images/layout/ColorPickerTool.svg)" });
|
|
65
|
+
this._toolCollection = toolCollection;
|
|
66
|
+
}
|
|
67
|
+
_createToolEventListeners() {
|
|
68
|
+
this._toolButtons = [...this._toolbarhost.querySelectorAll('div.tool')];
|
|
69
|
+
for (let tool of this._toolButtons) {
|
|
70
|
+
tool.addEventListener("click", () => this._toolSelected(tool, false));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
_toolSelected(tool, external) {
|
|
74
|
+
this.toolActivated.emit([DesignerToolRenderer.createObjectFromTool(tool), external]);
|
|
75
|
+
}
|
|
76
|
+
markToolAsSelected(id) {
|
|
77
|
+
this._unselectTools();
|
|
78
|
+
let selectedElement = this._toolButtons.find(t => t.getAttribute("data-command-parameter") == id);
|
|
79
|
+
selectedElement?.setAttribute("selected", "");
|
|
80
|
+
}
|
|
81
|
+
_unselectTools() {
|
|
82
|
+
for (let tool of this._toolButtons) {
|
|
83
|
+
tool.removeAttribute("selected");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
externalToolChange(command_name) {
|
|
87
|
+
let tool = this._toolButtons.find(x => x.getAttribute("data-command-parameter") == command_name);
|
|
88
|
+
if (tool != null) {
|
|
89
|
+
this._toolSelected(tool, true);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
get toolCollection() {
|
|
93
|
+
return this._toolCollection;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
customElements.define('node-projects-designer-tools-buttons', DesignerToolsButtons);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
2
|
+
import { DesignerToolbarPopup } from "../designerToolbarGenerics/designerToolbarPopup";
|
|
3
|
+
import { ToolPopupCategoryCollection } from "../designerToolbarGenerics/designerToolsButtons";
|
|
4
|
+
export declare class DrawToolPopup extends DesignerToolbarPopup {
|
|
5
|
+
private readonly templateToolSelect;
|
|
6
|
+
readonly toolActivated: TypedEvent<ToolPopupCategoryCollection>;
|
|
7
|
+
ready(): void;
|
|
8
|
+
}
|