@node-projects/web-component-designer 0.0.128 → 0.0.130
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/.vscode/settings.json +1 -1
- package/dist/elements/services/selectionService/SelectionService.js +1 -4
- package/dist/elements/widgets/designerView/extensions/ExtensionManager.js +3 -2
- package/dist/elements/widgets/designerView/extensions/contextMenu/MultipleItemsSelectedContextMenu.d.ts +2 -2
- package/dist/elements/widgets/designerView/extensions/contextMenu/MultipleItemsSelectedContextMenu.js +40 -3
- package/package.json +1 -1
package/.vscode/settings.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
|
-
import { NodeType } from '../../item/NodeType';
|
|
3
2
|
export class SelectionService {
|
|
4
3
|
primarySelection;
|
|
5
4
|
selectedElements = [];
|
|
@@ -12,9 +11,7 @@ export class SelectionService {
|
|
|
12
11
|
else {
|
|
13
12
|
let newSelection = [];
|
|
14
13
|
for (let d of designItems) {
|
|
15
|
-
|
|
16
|
-
d = d.parent;
|
|
17
|
-
if (d && d.nodeType == NodeType.Element && d != d.instanceServiceContainer.contentService.rootDesignItem)
|
|
14
|
+
if (d && d != d.instanceServiceContainer.contentService.rootDesignItem)
|
|
18
15
|
newSelection.push(d);
|
|
19
16
|
}
|
|
20
17
|
this.selectedElements = newSelection;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DesignItem } from "../../../item/DesignItem";
|
|
2
|
+
import { NodeType } from "../../../item/NodeType.js";
|
|
2
3
|
import { ExtensionType } from './ExtensionType';
|
|
3
4
|
export class ExtensionManager {
|
|
4
5
|
designerCanvas;
|
|
@@ -44,7 +45,7 @@ export class ExtensionManager {
|
|
|
44
45
|
this.refreshExtensions(selectionChangedEvent.selectedElements);
|
|
45
46
|
}
|
|
46
47
|
applyExtension(designItem, extensionType, recursive = false) {
|
|
47
|
-
if (designItem) {
|
|
48
|
+
if (designItem && designItem.nodeType == NodeType.Element) {
|
|
48
49
|
const extProv = this.designerCanvas.serviceContainer.designerExtensions.get(extensionType);
|
|
49
50
|
if (extProv) {
|
|
50
51
|
for (let e of extProv) {
|
|
@@ -78,7 +79,7 @@ export class ExtensionManager {
|
|
|
78
79
|
if (extProv) {
|
|
79
80
|
for (let e of extProv) {
|
|
80
81
|
for (let i of designItems) {
|
|
81
|
-
if (e.shouldExtend(this, this.designerCanvas, i)) {
|
|
82
|
+
if (i.nodeType == NodeType.Element && e.shouldExtend(this, this.designerCanvas, i)) {
|
|
82
83
|
let appE = i.appliedDesignerExtensions.get(extensionType);
|
|
83
84
|
if (!appE)
|
|
84
85
|
appE = [];
|
|
@@ -4,6 +4,6 @@ import { IDesignerCanvas } from "../../IDesignerCanvas";
|
|
|
4
4
|
import { ContextmenuInitiator, IContextMenuExtension } from "./IContextMenuExtension";
|
|
5
5
|
export declare class MultipleItemsSelectedContextMenu implements IContextMenuExtension {
|
|
6
6
|
orderIndex: number;
|
|
7
|
-
shouldProvideContextmenu(event: MouseEvent,
|
|
8
|
-
provideContextMenuItems(event: MouseEvent,
|
|
7
|
+
shouldProvideContextmenu(event: MouseEvent, designerCanvas: IDesignerCanvas, designItem: IDesignItem, initiator: ContextmenuInitiator): boolean;
|
|
8
|
+
provideContextMenuItems(event: MouseEvent, designerCanvas: IDesignerCanvas, designItem: IDesignItem): IContextMenuItem[];
|
|
9
9
|
}
|
|
@@ -1,19 +1,56 @@
|
|
|
1
|
+
import { DesignItem } from "../../../../item/DesignItem";
|
|
1
2
|
export class MultipleItemsSelectedContextMenu {
|
|
2
3
|
orderIndex = 60;
|
|
3
|
-
shouldProvideContextmenu(event,
|
|
4
|
+
shouldProvideContextmenu(event, designerCanvas, designItem, initiator) {
|
|
4
5
|
if (designItem.instanceServiceContainer.selectionService.selectedElements.length > 1) {
|
|
5
6
|
return true;
|
|
6
7
|
}
|
|
7
8
|
return false;
|
|
8
9
|
}
|
|
9
|
-
provideContextMenuItems(event,
|
|
10
|
+
provideContextMenuItems(event, designerCanvas, designItem) {
|
|
10
11
|
return [
|
|
11
12
|
{
|
|
12
13
|
title: 'wrap in',
|
|
13
14
|
children: [
|
|
14
15
|
{
|
|
15
16
|
title: 'div',
|
|
16
|
-
action: () => {
|
|
17
|
+
action: () => {
|
|
18
|
+
const grp = designItem.openGroup("wrap in Div");
|
|
19
|
+
let elements = designItem.instanceServiceContainer.selectionService.selectedElements;
|
|
20
|
+
let div = document.createElement('div');
|
|
21
|
+
const divDesignItem = DesignItem.createDesignItemFromInstance(div, designItem.serviceContainer, designItem.instanceServiceContainer);
|
|
22
|
+
designItem.insertAdjacentElement(divDesignItem, 'beforebegin');
|
|
23
|
+
let offset = 10;
|
|
24
|
+
let minX = Number.MAX_VALUE;
|
|
25
|
+
let minY = Number.MAX_VALUE;
|
|
26
|
+
let maxX = 0;
|
|
27
|
+
let maxY = 0;
|
|
28
|
+
for (let e of elements) {
|
|
29
|
+
let rect = designerCanvas.getNormalizedElementCoordinates(e.element);
|
|
30
|
+
if (rect.x < minX)
|
|
31
|
+
minX = rect.x;
|
|
32
|
+
if (rect.y < minY)
|
|
33
|
+
minY = rect.y;
|
|
34
|
+
if (rect.x + rect.width > maxX)
|
|
35
|
+
maxX = rect.x + rect.width;
|
|
36
|
+
if (rect.y + rect.height > maxY)
|
|
37
|
+
maxY = rect.y + rect.height;
|
|
38
|
+
}
|
|
39
|
+
for (let e of elements) {
|
|
40
|
+
let rect = designerCanvas.getNormalizedElementCoordinates(e.element);
|
|
41
|
+
e.remove();
|
|
42
|
+
e.setStyle('left', (rect.x - minX + offset).toString() + 'px');
|
|
43
|
+
e.setStyle('top', (rect.y - minY + offset).toString() + 'px');
|
|
44
|
+
divDesignItem.insertChild(e);
|
|
45
|
+
}
|
|
46
|
+
divDesignItem.setStyle('position', 'absolute');
|
|
47
|
+
divDesignItem.setStyle('left', (minX - offset).toString() + 'px');
|
|
48
|
+
divDesignItem.setStyle('top', (minY - offset).toString() + 'px');
|
|
49
|
+
divDesignItem.setStyle('width', (maxX - minX + 2 * offset).toString() + 'px');
|
|
50
|
+
divDesignItem.setStyle('height', (maxY - minY + 2 * offset).toString() + 'px');
|
|
51
|
+
grp.commit();
|
|
52
|
+
designItem.instanceServiceContainer.selectionService.setSelectedElements([divDesignItem]);
|
|
53
|
+
}
|
|
17
54
|
}
|
|
18
55
|
]
|
|
19
56
|
}
|