@node-projects/web-component-designer 0.0.179 → 0.0.181
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.js +9 -8
- package/dist/elements/item/DesignItem.js +4 -0
- package/dist/elements/item/NodeType.d.ts +4 -1
- package/dist/elements/item/NodeType.js +3 -0
- package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService.js +2 -1
- package/dist/elements/widgets/codeView/code-view-monaco.d.ts +1 -1
- package/dist/elements/widgets/codeView/code-view-monaco.js +2 -1
- package/dist/elements/widgets/designerView/designerCanvas.d.ts +1 -0
- package/dist/elements/widgets/designerView/designerCanvas.js +11 -1
- package/dist/elements/widgets/designerView/extensions/ExtensionManager.js +1 -1
- package/dist/elements/widgets/designerView/extensions/SelectionDefaultExtension.js +8 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/RotateLeftAndRightContextMenu.js +2 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/ZMoveContextMenu.js +2 -1
- package/dist/elements/widgets/propertyGrid/PropertyGridWithHeader.js +9 -2
- package/package.json +3 -3
|
@@ -146,10 +146,16 @@ export class ContextMenu {
|
|
|
146
146
|
}
|
|
147
147
|
renderLevel(level) {
|
|
148
148
|
let ul_outer = document.createElement("ul");
|
|
149
|
-
let
|
|
149
|
+
let addDivider = false;
|
|
150
150
|
level.forEach((item) => {
|
|
151
|
-
let li = document.createElement("li");
|
|
152
151
|
if (item.title !== '-') {
|
|
152
|
+
if (addDivider) {
|
|
153
|
+
let li = document.createElement("li");
|
|
154
|
+
li.className = "context_menu_divider";
|
|
155
|
+
addDivider = false;
|
|
156
|
+
ul_outer.appendChild(li);
|
|
157
|
+
}
|
|
158
|
+
let li = document.createElement("li");
|
|
153
159
|
let icon_span = document.createElement("span");
|
|
154
160
|
icon_span.className = 'context_menu_icon_span';
|
|
155
161
|
if ((item.icon ?? '') != '') {
|
|
@@ -190,15 +196,10 @@ export class ContextMenu {
|
|
|
190
196
|
});
|
|
191
197
|
}
|
|
192
198
|
}
|
|
193
|
-
lastWasDivider = false;
|
|
194
199
|
ul_outer.appendChild(li);
|
|
195
200
|
}
|
|
196
201
|
else {
|
|
197
|
-
|
|
198
|
-
li.className = "context_menu_divider";
|
|
199
|
-
lastWasDivider = true;
|
|
200
|
-
ul_outer.appendChild(li);
|
|
201
|
-
}
|
|
202
|
+
addDivider = true;
|
|
202
203
|
}
|
|
203
204
|
});
|
|
204
205
|
return ul_outer;
|
|
@@ -165,12 +165,14 @@ export class DesignItem {
|
|
|
165
165
|
return this.node.textContent;
|
|
166
166
|
}
|
|
167
167
|
set content(value) {
|
|
168
|
+
//undo
|
|
168
169
|
this.node.textContent = value;
|
|
169
170
|
}
|
|
170
171
|
get innerHTML() {
|
|
171
172
|
return this.element.innerHTML;
|
|
172
173
|
}
|
|
173
174
|
set innerHTML(value) {
|
|
175
|
+
//undo
|
|
174
176
|
this.element.innerHTML = value;
|
|
175
177
|
this.updateChildrenFromNodesChildren();
|
|
176
178
|
}
|
|
@@ -354,6 +356,8 @@ export class DesignItem {
|
|
|
354
356
|
return value ?? fallback;
|
|
355
357
|
}
|
|
356
358
|
getAllStyles() {
|
|
359
|
+
if (this.nodeType != NodeType.Element)
|
|
360
|
+
return [];
|
|
357
361
|
const localStyles = [...this._styles.entries()].map(x => ({ name: x[0], value: x[1], important: false, parent: null }));
|
|
358
362
|
if (this.instanceServiceContainer.stylesheetService) {
|
|
359
363
|
const rules = this.instanceServiceContainer.stylesheetService?.getAppliedRules(this);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export var NodeType;
|
|
2
2
|
(function (NodeType) {
|
|
3
3
|
NodeType[NodeType["Element"] = 1] = "Element";
|
|
4
|
+
NodeType[NodeType["Attribute"] = 2] = "Attribute";
|
|
4
5
|
NodeType[NodeType["TextNode"] = 3] = "TextNode";
|
|
5
6
|
NodeType[NodeType["Comment"] = 8] = "Comment";
|
|
7
|
+
NodeType[NodeType["Document"] = 9] = "Document";
|
|
8
|
+
NodeType[NodeType["DocumentFragment"] = 11] = "DocumentFragment";
|
|
6
9
|
})(NodeType || (NodeType = {}));
|
|
@@ -3,6 +3,7 @@ import { RefreshMode } from '../IPropertiesService.js';
|
|
|
3
3
|
import { CommonPropertiesService } from './CommonPropertiesService.js';
|
|
4
4
|
import cssProperties from './CssProperties.json' assert { type: 'json' };
|
|
5
5
|
import { ValueType } from '../ValueType.js';
|
|
6
|
+
import { NodeType } from '../../../item/NodeType.js';
|
|
6
7
|
const localName = '<local>';
|
|
7
8
|
export class CssCurrentPropertiesService extends CommonPropertiesService {
|
|
8
9
|
getRefreshMode(designItem) {
|
|
@@ -19,7 +20,7 @@ export class CssCurrentPropertiesService extends CommonPropertiesService {
|
|
|
19
20
|
return { name: name, type: 'string', service: this, propertyType: PropertyType.cssValue };
|
|
20
21
|
}
|
|
21
22
|
getProperties(designItem) {
|
|
22
|
-
if (!designItem)
|
|
23
|
+
if (!designItem || designItem.nodeType != NodeType.Element)
|
|
23
24
|
return [];
|
|
24
25
|
let styles = designItem.getAllStyles();
|
|
25
26
|
let arr = styles.map(x => ({
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BaseCustomWebComponentLazyAppend, css, html, TypedEvent } from '@node-projects/base-custom-webcomponent';
|
|
2
|
-
import * as monaco from 'monaco-editor';
|
|
3
2
|
import { CommandType } from '../../../commandHandling/CommandType.js';
|
|
4
3
|
export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
5
4
|
dispose() {
|
|
@@ -9,6 +8,7 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
|
9
8
|
elementsToPackages;
|
|
10
9
|
code;
|
|
11
10
|
onTextChanged = new TypedEvent();
|
|
11
|
+
//@ts-ignore
|
|
12
12
|
_monacoEditor;
|
|
13
13
|
_editor;
|
|
14
14
|
static style = css `
|
|
@@ -136,6 +136,7 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
|
|
|
136
136
|
let point1 = model.getPositionAt(position.start);
|
|
137
137
|
let point2 = model.getPositionAt(position.start + position.length);
|
|
138
138
|
this._monacoEditor.setSelection({ startLineNumber: point1.lineNumber, startColumn: point1.column, endLineNumber: point2.lineNumber, endColumn: point2.column });
|
|
139
|
+
//@ts-ignore
|
|
139
140
|
setTimeout(() => this._monacoEditor.revealRangeInCenter(new monaco.Range(point1.lineNumber, point1.column, point2.lineNumber, point2.column), 1));
|
|
140
141
|
}
|
|
141
142
|
}
|
|
@@ -102,6 +102,7 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
|
|
|
102
102
|
* Converts the Event x/y coordinates, to the mouse position in the viewport
|
|
103
103
|
*/
|
|
104
104
|
getViewportCoordinates(event: MouseEvent): IPoint;
|
|
105
|
+
getNormalizedTextNodeCoordinates(element: Text, ignoreScalefactor?: boolean): IRect;
|
|
105
106
|
getNormalizedElementCoordinates(element: Element, ignoreScalefactor?: boolean): IRect;
|
|
106
107
|
getNormalizedElementCoordinatesAndRealSizes(element: Element): IRect & {
|
|
107
108
|
realWidth: number;
|
|
@@ -17,6 +17,7 @@ import { DomHelper } from '@node-projects/base-custom-webcomponent/dist/DomHelpe
|
|
|
17
17
|
import { OverlayLayer } from './extensions/OverlayLayer.js';
|
|
18
18
|
import { OverlayLayerView } from './overlayLayerView.js';
|
|
19
19
|
import { ContextMenu } from '../../helper/contextMenu/ContextMenu.js';
|
|
20
|
+
import { NodeType } from '../../item/NodeType.js';
|
|
20
21
|
export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
21
22
|
// Public Properties
|
|
22
23
|
serviceContainer;
|
|
@@ -391,7 +392,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
391
392
|
let di = designItems[i];
|
|
392
393
|
let pos = positions ? positions[i] : null;
|
|
393
394
|
this.instanceServiceContainer.undoService.execute(new InsertAction(pasteContainer, pasteContainer.childCount, di));
|
|
394
|
-
if (!disableRestoreOfPositions && pos) {
|
|
395
|
+
if (!disableRestoreOfPositions && pos && di.nodeType == NodeType.Element) {
|
|
395
396
|
di.setStyle('left', (pos.x - containerPos.x) + 'px');
|
|
396
397
|
di.setStyle('top', (pos.y - containerPos.y) + 'px');
|
|
397
398
|
}
|
|
@@ -797,7 +798,16 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
797
798
|
y: (event.clientY - this.outerRect.y)
|
|
798
799
|
};
|
|
799
800
|
}
|
|
801
|
+
getNormalizedTextNodeCoordinates(element, ignoreScalefactor) {
|
|
802
|
+
let range = document.createRange();
|
|
803
|
+
range.selectNodeContents(element);
|
|
804
|
+
let targetRect = range.getBoundingClientRect();
|
|
805
|
+
return { x: (targetRect.x - this.containerBoundingRect.x) / (ignoreScalefactor ? 1 : this.scaleFactor), y: (targetRect.y - this.containerBoundingRect.y) / (ignoreScalefactor ? 1 : this.scaleFactor), width: targetRect.width / (ignoreScalefactor ? 1 : this.scaleFactor), height: targetRect.height / (ignoreScalefactor ? 1 : this.scaleFactor) };
|
|
806
|
+
}
|
|
800
807
|
getNormalizedElementCoordinates(element, ignoreScalefactor) {
|
|
808
|
+
if (element.nodeType == NodeType.TextNode) {
|
|
809
|
+
return this.getNormalizedTextNodeCoordinates(element, ignoreScalefactor);
|
|
810
|
+
}
|
|
801
811
|
const targetRect = element.getBoundingClientRect();
|
|
802
812
|
return { x: (targetRect.x - this.containerBoundingRect.x) / (ignoreScalefactor ? 1 : this.scaleFactor), y: (targetRect.y - this.containerBoundingRect.y) / (ignoreScalefactor ? 1 : this.scaleFactor), width: targetRect.width / (ignoreScalefactor ? 1 : this.scaleFactor), height: targetRect.height / (ignoreScalefactor ? 1 : this.scaleFactor) };
|
|
803
813
|
}
|
|
@@ -93,7 +93,7 @@ export class ExtensionManager {
|
|
|
93
93
|
shouldAppE = [];
|
|
94
94
|
shouldAppE.push(e);
|
|
95
95
|
i.shouldAppliedDesignerExtensions.set(extensionType, shouldAppE);
|
|
96
|
-
if (i.nodeType == NodeType.Element
|
|
96
|
+
if ( /*i.nodeType == NodeType.Element &&*/e.shouldExtend(this, this.designerCanvas, i)) {
|
|
97
97
|
let appE = i.appliedDesignerExtensions.get(extensionType);
|
|
98
98
|
if (!appE)
|
|
99
99
|
appE = [];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getDesignerCanvasNormalizedTransformedCornerDOMPoints } from '../../../helper/TransformHelper.js';
|
|
2
|
+
import { NodeType } from '../../../item/NodeType.js';
|
|
2
3
|
import { AbstractExtension } from './AbstractExtension.js';
|
|
3
4
|
export class SelectionDefaultExtension extends AbstractExtension {
|
|
4
5
|
_line1;
|
|
@@ -12,7 +13,13 @@ export class SelectionDefaultExtension extends AbstractExtension {
|
|
|
12
13
|
this.refresh();
|
|
13
14
|
}
|
|
14
15
|
refresh() {
|
|
15
|
-
let transformedCornerPoints
|
|
16
|
+
let transformedCornerPoints;
|
|
17
|
+
if (this.extendedItem.nodeType == NodeType.TextNode) {
|
|
18
|
+
let rect = this.designerCanvas.getNormalizedElementCoordinates(this.extendedItem.element);
|
|
19
|
+
transformedCornerPoints = [{ x: rect.x, y: rect.y }, { x: rect.x + rect.width, y: rect.y }, { x: rect.x, y: rect.y + rect.height }, { x: rect.x + rect.width, y: rect.y + rect.height }];
|
|
20
|
+
}
|
|
21
|
+
else
|
|
22
|
+
transformedCornerPoints = getDesignerCanvasNormalizedTransformedCornerDOMPoints(this.extendedItem.element, null, this.designerCanvas);
|
|
16
23
|
this._line1 = this._drawLine(transformedCornerPoints[0].x, transformedCornerPoints[0].y, transformedCornerPoints[1].x, transformedCornerPoints[1].y, 'svg-selection', this._line1);
|
|
17
24
|
this._line2 = this._drawLine(transformedCornerPoints[0].x, transformedCornerPoints[0].y, transformedCornerPoints[2].x, transformedCornerPoints[2].y, 'svg-selection', this._line2);
|
|
18
25
|
this._line3 = this._drawLine(transformedCornerPoints[1].x, transformedCornerPoints[1].y, transformedCornerPoints[3].x, transformedCornerPoints[3].y, 'svg-selection', this._line3);
|
package/dist/elements/widgets/designerView/extensions/contextMenu/RotateLeftAndRightContextMenu.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CommandType } from '../../../../../commandHandling/CommandType.js';
|
|
2
|
+
import { NodeType } from '../../../../item/NodeType.js';
|
|
2
3
|
export class RotateLeftAndRight {
|
|
3
4
|
shouldProvideContextmenu(event, designerView, designItem, initiator) {
|
|
4
|
-
return !designItem.isRootItem;
|
|
5
|
+
return !designItem.isRootItem && designItem.nodeType == NodeType.Element;
|
|
5
6
|
}
|
|
6
7
|
provideContextMenuItems(event, designerView, designItem) {
|
|
7
8
|
return [
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CommandType } from '../../../../../commandHandling/CommandType.js';
|
|
2
|
+
import { NodeType } from '../../../../item/NodeType.js';
|
|
2
3
|
export class ZMoveContextMenu {
|
|
3
4
|
shouldProvideContextmenu(event, designerView, designItem, initiator) {
|
|
4
|
-
return !designItem.isRootItem;
|
|
5
|
+
return !designItem.isRootItem && designItem.nodeType == NodeType.Element;
|
|
5
6
|
}
|
|
6
7
|
provideContextMenuItems(event, designerView, designItem) {
|
|
7
8
|
return [
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseCustomWebComponentLazyAppend, css, html } from '@node-projects/base-custom-webcomponent';
|
|
2
2
|
import { sleep } from '../../helper/Helper.js';
|
|
3
3
|
import { DesignItem } from '../../item/DesignItem.js';
|
|
4
|
+
import { NodeType } from '../../item/NodeType.js';
|
|
4
5
|
export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
|
|
5
6
|
static style = css `
|
|
6
7
|
:host {
|
|
@@ -103,9 +104,15 @@ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
|
|
|
103
104
|
this._selectionChangedHandler = this._instanceServiceContainer.selectionService.onSelectionChanged.on(async (e) => {
|
|
104
105
|
this._pg.instanceServiceContainer = value;
|
|
105
106
|
await sleep(20); // delay assignment a little bit, so onblur above could still set the value.
|
|
106
|
-
|
|
107
|
+
if (this._instanceServiceContainer.selectionService.primarySelection?.nodeType == NodeType.Element)
|
|
108
|
+
this._type.innerText = this._instanceServiceContainer.selectionService.primarySelection?.name ?? '';
|
|
109
|
+
else
|
|
110
|
+
this._type.innerText = this._instanceServiceContainer.selectionService.primarySelection?.node?.nodeName ?? '';
|
|
107
111
|
this._id.value = this._instanceServiceContainer.selectionService.primarySelection?.id ?? '';
|
|
108
|
-
if (this._instanceServiceContainer.selectionService.primarySelection?.element?.
|
|
112
|
+
if (this._instanceServiceContainer.selectionService.primarySelection?.element?.nodeType != NodeType.Element) {
|
|
113
|
+
this._content.value = this._instanceServiceContainer.selectionService.primarySelection?.element?.textContent ?? '';
|
|
114
|
+
}
|
|
115
|
+
else if (this._instanceServiceContainer.selectionService.primarySelection?.element?.children?.length <= 0)
|
|
109
116
|
this._content.value = this._instanceServiceContainer.selectionService.primarySelection?.element?.textContent ?? '';
|
|
110
117
|
else
|
|
111
118
|
this._content.value = '';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "A UI designer for Polymer apps",
|
|
3
3
|
"name": "@node-projects/web-component-designer",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.181",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"css-tree": "^2.3.1",
|
|
32
32
|
"esprima-next": "^5.8.4",
|
|
33
33
|
"html2canvas": "*",
|
|
34
|
-
"jest": "^29.4.
|
|
34
|
+
"jest": "^29.4.1",
|
|
35
35
|
"jquery": "^3.6.3",
|
|
36
36
|
"jquery.fancytree": "^2.38.2",
|
|
37
37
|
"mdn-data": "^2.0.30",
|
|
38
38
|
"monaco-editor": "^0.34.1",
|
|
39
39
|
"ts-jest": "^29.0.5",
|
|
40
|
-
"typescript": "^4.9.
|
|
40
|
+
"typescript": "^4.9.5",
|
|
41
41
|
"typescript-lit-html-plugin": "^0.9.0"
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|