@node-projects/web-component-designer 0.0.78 → 0.0.82
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/.github/FUNDING.yml +1 -0
- package/dist/elements/helper/ElementHelper.d.ts +6 -0
- package/dist/elements/helper/ElementHelper.js +10 -0
- package/dist/elements/helper/PathDataPolyfill.d.ts +11 -10
- package/dist/elements/helper/PathDataPolyfill.js +36 -1
- package/dist/elements/services/DefaultServiceBootstrap.js +6 -2
- package/dist/elements/services/ServiceContainer.d.ts +1 -1
- package/dist/elements/services/ServiceContainer.js +2 -2
- package/dist/elements/services/htmlWriterService/AbstractHtmlWriterService.d.ts +10 -0
- package/dist/elements/services/htmlWriterService/AbstractHtmlWriterService.js +62 -0
- package/dist/elements/services/htmlWriterService/FormatingHtmlWriterService.d.ts +22 -0
- package/dist/elements/services/htmlWriterService/FormatingHtmlWriterService.js +133 -0
- package/dist/elements/services/htmlWriterService/HtmlWriterService copy.d.ts +2 -2
- package/dist/elements/services/htmlWriterService/HtmlWriterService copy.js +34 -19
- package/dist/elements/services/htmlWriterService/HtmlWriterService.d.ts +8 -8
- package/dist/elements/services/htmlWriterService/HtmlWriterService.js +13 -42
- package/dist/elements/services/htmlWriterService/IHtmlWriterOptions.d.ts +2 -0
- package/dist/elements/services/htmlWriterService/IHtmlWriterOptions.js +5 -3
- package/dist/elements/services/htmlWriterService/IHtmlWriterService.d.ts +5 -6
- package/dist/elements/services/htmlWriterService/LitTsElementWriterService.d.ts +9 -0
- package/dist/elements/services/htmlWriterService/LitTsElementWriterService.js +43 -0
- package/dist/elements/services/htmlWriterService/SimpleHtmlWriterService.d.ts +27 -0
- package/dist/elements/services/htmlWriterService/SimpleHtmlWriterService.js +93 -0
- package/dist/elements/services/initializationService/DefaultIntializationService.d.ts +6 -0
- package/dist/elements/services/initializationService/DefaultIntializationService.js +22 -0
- package/dist/elements/services/manifestParsers/WebcomponentManifestParserService.d.ts +3 -1
- package/dist/elements/services/manifestParsers/WebcomponentManifestParserService.js +42 -28
- package/dist/elements/widgets/codeView/code-view-ace.js +1 -1
- package/dist/elements/widgets/codeView/code-view-code-mirror.js +1 -1
- package/dist/elements/widgets/designerView/DomConverter.d.ts +3 -3
- package/dist/elements/widgets/designerView/DomConverter.js +8 -11
- package/dist/elements/widgets/designerView/designerCanvas.d.ts +2 -0
- package/dist/elements/widgets/designerView/designerCanvas.js +6 -0
- package/dist/elements/widgets/designerView/designerView.js +21 -6
- package/dist/elements/widgets/designerView/extensions/PathExtension.d.ts +0 -1
- package/dist/elements/widgets/designerView/extensions/PathExtension.js +104 -12
- package/dist/elements/widgets/designerView/extensions/contextMenu/CopyPasteContextMenu.js +0 -1
- package/dist/elements/widgets/designerView/extensions/contextMenu/PathContextMenu.d.ts +8 -0
- package/dist/elements/widgets/designerView/extensions/contextMenu/PathContextMenu.js +31 -0
- package/dist/elements/widgets/designerView/extensions/contextMenu/RectContextMenu.d.ts +8 -0
- package/dist/elements/widgets/designerView/extensions/contextMenu/RectContextMenu.js +34 -0
- package/dist/elements/widgets/designerView/overlayLayerView.js +1 -2
- package/dist/elements/widgets/designerView/tools/DrawEllipsisTool.js +1 -0
- package/dist/elements/widgets/designerView/tools/DrawLineTool.js +1 -0
- package/dist/elements/widgets/designerView/tools/DrawPathTool.d.ts +0 -1
- package/dist/elements/widgets/designerView/tools/DrawPathTool.js +17 -9
- package/dist/elements/widgets/designerView/tools/DrawRectTool.js +1 -0
- package/dist/elements/widgets/treeView/treeViewExtended.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/package.json +9 -9
- package/dist/elements/services/htmlWriterService/LitElementWriterService.d.ts +0 -12
- package/dist/elements/services/htmlWriterService/LitElementWriterService.js +0 -107
- package/dist/elements/services/manifestLoaders/WebcomponentManifestParserService.d.ts +0 -26
- package/dist/elements/services/manifestLoaders/WebcomponentManifestParserService.js +0 -69
- package/dist/elements/services/webcomponentManifestParserService/WebcomponentManifestParserService.1.d.ts +0 -0
- package/dist/elements/services/webcomponentManifestParserService/WebcomponentManifestParserService.1.js +0 -1
- package/dist/elements/services/webcomponentManifestParserService/webcomponentManifestParserService.d.ts +0 -26
- package/dist/elements/services/webcomponentManifestParserService/webcomponentManifestParserService.js +0 -69
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AbstractExtension } from "./AbstractExtension";
|
|
2
2
|
import "../../../helper/PathDataPolyfill";
|
|
3
3
|
import { EventNames } from "../../../../enums/EventNames";
|
|
4
|
+
import { createPathD } from "../../../helper/PathDataPolyfill";
|
|
5
|
+
import { ContextMenuHelper } from "../../../helper/contextMenu/ContextMenuHelper";
|
|
4
6
|
export class PathExtension extends AbstractExtension {
|
|
5
7
|
//private _itemRect: DOMRect;
|
|
6
8
|
//private _svgRect: DOMRect;
|
|
@@ -17,7 +19,7 @@ export class PathExtension extends AbstractExtension {
|
|
|
17
19
|
//this._itemRect = this.extendedItem.element.getBoundingClientRect();
|
|
18
20
|
//this._svgRect = (<SVGGeometryElement>this.extendedItem.element).ownerSVGElement.getBoundingClientRect();
|
|
19
21
|
this._parentRect = this.extendedItem.element.parentElement.getBoundingClientRect();
|
|
20
|
-
this._pathdata = this.extendedItem.node.getPathData({ normalize:
|
|
22
|
+
this._pathdata = this.extendedItem.node.getPathData({ normalize: false });
|
|
21
23
|
for (let p of this._pathdata) {
|
|
22
24
|
switch (p.type) {
|
|
23
25
|
case 'M':
|
|
@@ -26,6 +28,7 @@ export class PathExtension extends AbstractExtension {
|
|
|
26
28
|
break;
|
|
27
29
|
case 'L':
|
|
28
30
|
this._drawPathCircle(p.values[0], p.values[1], p, 0);
|
|
31
|
+
this._lastPos = { x: p.values[0], y: p.values[1] };
|
|
29
32
|
break;
|
|
30
33
|
case 'H':
|
|
31
34
|
break;
|
|
@@ -52,17 +55,23 @@ export class PathExtension extends AbstractExtension {
|
|
|
52
55
|
case 'S':
|
|
53
56
|
this._drawPathCircle(p.values[0], p.values[1], p, 0);
|
|
54
57
|
this._drawPathCircle(p.values[2], p.values[3], p, 2);
|
|
58
|
+
this._lastPos = { x: p.values[2], y: p.values[3] };
|
|
55
59
|
break;
|
|
56
60
|
case 'Q':
|
|
61
|
+
this._drawPathLine(this._lastPos.x, this._lastPos.y, p.values[0], p.values[1]);
|
|
62
|
+
this._drawPathLine(p.values[0], p.values[1], p.values[2], p.values[3]);
|
|
57
63
|
this._drawPathCircle(p.values[0], p.values[1], p, 0);
|
|
58
64
|
this._drawPathCircle(p.values[2], p.values[3], p, 2);
|
|
65
|
+
this._lastPos = { x: p.values[2], y: p.values[3] };
|
|
59
66
|
break;
|
|
60
67
|
case 'T':
|
|
61
68
|
this._drawPathCircle(p.values[0], p.values[1], p, 0);
|
|
69
|
+
this._lastPos = { x: p.values[0], y: p.values[1] };
|
|
62
70
|
break;
|
|
63
71
|
case 'A':
|
|
64
72
|
this._drawPathCircle(p.values[0], p.values[1], p, 0);
|
|
65
73
|
this._drawPathCircle(p.values[5], p.values[6], p, 5);
|
|
74
|
+
this._lastPos = { x: p.values[0], y: p.values[1] };
|
|
66
75
|
break;
|
|
67
76
|
}
|
|
68
77
|
}
|
|
@@ -83,9 +92,27 @@ export class PathExtension extends AbstractExtension {
|
|
|
83
92
|
const cy = event.y - this._lastPos.y + this._circlePos.y;
|
|
84
93
|
const dx = cx - this._circlePos.x;
|
|
85
94
|
const dy = cy - this._circlePos.y;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
if (event.shiftKey) {
|
|
96
|
+
if (Math.abs(dx) >= Math.abs(dy)) {
|
|
97
|
+
p.values[index] = this._originalPathPoint.x + dx;
|
|
98
|
+
circle.setAttribute("cx", (this._circlePos.x + dx).toString());
|
|
99
|
+
p.values[index + 1] = this._originalPathPoint.y;
|
|
100
|
+
circle.setAttribute("cy", (this._circlePos.y).toString());
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
p.values[index] = this._originalPathPoint.x;
|
|
104
|
+
circle.setAttribute("cx", (this._circlePos.x).toString());
|
|
105
|
+
p.values[index + 1] = this._originalPathPoint.y + dy;
|
|
106
|
+
circle.setAttribute("cy", (this._circlePos.y + dy).toString());
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
p.values[index] = this._originalPathPoint.x + dx;
|
|
111
|
+
p.values[index + 1] = this._originalPathPoint.y + dy;
|
|
112
|
+
circle.setAttribute("cx", (this._circlePos.x + dx).toString());
|
|
113
|
+
circle.setAttribute("cy", (this._circlePos.y + dy).toString());
|
|
114
|
+
}
|
|
115
|
+
this.extendedItem.element.setAttribute("d", createPathD(this._pathdata));
|
|
89
116
|
}
|
|
90
117
|
break;
|
|
91
118
|
case EventNames.PointerUp:
|
|
@@ -93,21 +120,86 @@ export class PathExtension extends AbstractExtension {
|
|
|
93
120
|
this._startPos = null;
|
|
94
121
|
this._circlePos = null;
|
|
95
122
|
this._lastPos = null;
|
|
123
|
+
this.extendedItem.setAttribute('d', createPathD(this._pathdata));
|
|
96
124
|
break;
|
|
97
125
|
}
|
|
98
126
|
}
|
|
99
|
-
_drawPath(path, index) {
|
|
100
|
-
let pathD = "";
|
|
101
|
-
for (let p of path) {
|
|
102
|
-
pathD += p.type + p.values[index] + " " + p.values[index + 1];
|
|
103
|
-
}
|
|
104
|
-
this.extendedItem.setAttribute("d", pathD);
|
|
105
|
-
}
|
|
106
127
|
_drawPathCircle(x, y, p, index) {
|
|
107
|
-
|
|
128
|
+
const items = [];
|
|
129
|
+
const pidx = this._pathdata.indexOf(p);
|
|
130
|
+
items.push({
|
|
131
|
+
title: 'delete point', action: () => {
|
|
132
|
+
this._pathdata.splice(pidx, 1);
|
|
133
|
+
if (pidx == 0)
|
|
134
|
+
this._pathdata[0].type = 'M';
|
|
135
|
+
this.extendedItem.setAttribute('d', createPathD(this._pathdata));
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
items.push({
|
|
139
|
+
title: 'insert point after', action: () => {
|
|
140
|
+
const l = { type: 'L', values: [p.values[0], p.values[1]] };
|
|
141
|
+
this._pathdata.splice(pidx + 1, 0, l);
|
|
142
|
+
this.extendedItem.setAttribute('d', createPathD(this._pathdata));
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
if (pidx != 0) {
|
|
146
|
+
items.push({
|
|
147
|
+
title: 'convert to quadratic bézier', action: () => {
|
|
148
|
+
const p1x = this._pathdata[pidx - 1].values[0];
|
|
149
|
+
const p1y = this._pathdata[pidx - 1].values[1];
|
|
150
|
+
const p2x = this._pathdata[pidx].values[0];
|
|
151
|
+
const p2y = this._pathdata[pidx].values[1];
|
|
152
|
+
const mpx = (p2x + p1x) * 0.5;
|
|
153
|
+
const mpy = (p2y + p1y) * 0.5;
|
|
154
|
+
const theta = Math.atan2(p2y - p1y, p2x - p1x) - Math.PI / 2;
|
|
155
|
+
const offset = 50;
|
|
156
|
+
const c1x = mpx + offset * Math.cos(theta);
|
|
157
|
+
const c1y = mpy + offset * Math.sin(theta);
|
|
158
|
+
this._pathdata[pidx].type = 'Q';
|
|
159
|
+
this._pathdata[pidx].values[0] = c1x;
|
|
160
|
+
this._pathdata[pidx].values[1] = c1y;
|
|
161
|
+
this._pathdata[pidx].values[2] = p2x;
|
|
162
|
+
this._pathdata[pidx].values[3] = p2y;
|
|
163
|
+
this.extendedItem.setAttribute('d', createPathD(this._pathdata));
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
if (pidx != 0) {
|
|
168
|
+
items.push({
|
|
169
|
+
title: 'convert to cubic bézier', action: () => {
|
|
170
|
+
const p1x = this._pathdata[pidx - 1].values[0];
|
|
171
|
+
const p1y = this._pathdata[pidx - 1].values[1];
|
|
172
|
+
const p2x = this._pathdata[pidx].values[0];
|
|
173
|
+
const p2y = this._pathdata[pidx].values[1];
|
|
174
|
+
const mpx = (p2x + p1x) * 0.5;
|
|
175
|
+
const mpy = (p2y + p1y) * 0.5;
|
|
176
|
+
const theta = Math.atan2(p2y - p1y, p2x - p1x) - Math.PI / 2;
|
|
177
|
+
const offset = 50;
|
|
178
|
+
let c1x = mpx + offset * Math.cos(theta);
|
|
179
|
+
let c1y = mpy + offset * Math.sin(theta);
|
|
180
|
+
c1x = p.values[0] + 2 * (p1x - p.values[0]) / 3;
|
|
181
|
+
c1y = p.values[1] + 2 * (p1y - p.values[1]) / 3;
|
|
182
|
+
const c2x = x + 2 * (p1x - x) / 3;
|
|
183
|
+
const c2y = y + 2 * (p1y - y) / 3;
|
|
184
|
+
this._pathdata[pidx].type = 'C';
|
|
185
|
+
this._pathdata[pidx].values[0] = c1x;
|
|
186
|
+
this._pathdata[pidx].values[1] = c1y;
|
|
187
|
+
this._pathdata[pidx].values[2] = c2x;
|
|
188
|
+
this._pathdata[pidx].values[3] = c2y;
|
|
189
|
+
this._pathdata[pidx].values[4] = p2x;
|
|
190
|
+
this._pathdata[pidx].values[5] = p2y;
|
|
191
|
+
this.extendedItem.setAttribute('d', createPathD(this._pathdata));
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
let circle = this._drawCircle(this._parentRect.x - this.designerCanvas.containerBoundingRect.x + x, this._parentRect.y - this.designerCanvas.containerBoundingRect.y + y, 5, 'svg-path');
|
|
108
196
|
circle.addEventListener(EventNames.PointerDown, event => this.pointerEvent(event, circle, p, index));
|
|
109
197
|
circle.addEventListener(EventNames.PointerMove, event => this.pointerEvent(event, circle, p, index));
|
|
110
198
|
circle.addEventListener(EventNames.PointerUp, event => this.pointerEvent(event, circle, p, index));
|
|
199
|
+
circle.addEventListener(EventNames.ContextMenu, event => {
|
|
200
|
+
event.preventDefault();
|
|
201
|
+
ContextMenuHelper.showContextMenu(null, event, null, items);
|
|
202
|
+
});
|
|
111
203
|
}
|
|
112
204
|
_drawPathLine(x1, y1, x2, y2) {
|
|
113
205
|
this._drawLine(this._parentRect.x - this.designerCanvas.containerBoundingRect.x + x1, this._parentRect.y - this.designerCanvas.containerBoundingRect.y + y1, this._parentRect.x - this.designerCanvas.containerBoundingRect.x + x2, this._parentRect.y - this.designerCanvas.containerBoundingRect.y + y2, 'svg-path-line');
|
|
@@ -8,7 +8,6 @@ export class CopyPasteContextMenu {
|
|
|
8
8
|
{ title: 'copy', action: () => { designerView.executeCommand({ type: CommandType.copy }); } },
|
|
9
9
|
{ title: 'cut', action: () => { designerView.executeCommand({ type: CommandType.cut }); } },
|
|
10
10
|
{ title: 'paste', action: () => { designerView.executeCommand({ type: CommandType.paste }); } },
|
|
11
|
-
{ title: '-' },
|
|
12
11
|
{ title: 'delete', action: () => { designerView.executeCommand({ type: CommandType.delete }); } },
|
|
13
12
|
{ title: '-' }
|
|
14
13
|
];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IContextMenuItem } from "../../../../helper/contextMenu/IContextmenuItem";
|
|
2
|
+
import { IDesignItem } from "../../../../item/IDesignItem";
|
|
3
|
+
import { IDesignerCanvas } from "../../IDesignerCanvas";
|
|
4
|
+
import { ContextmenuInitiator, IContextMenuExtension } from "./IContextMenuExtension";
|
|
5
|
+
export declare class PathContextMenu implements IContextMenuExtension {
|
|
6
|
+
shouldProvideContextmenu(event: MouseEvent, designerView: IDesignerCanvas, designItem: IDesignItem, initiator: ContextmenuInitiator): boolean;
|
|
7
|
+
provideContextMenuItems(event: MouseEvent, designerCanvas: IDesignerCanvas, designItem: IDesignItem): IContextMenuItem[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createPathD } from "../../../../helper/PathDataPolyfill";
|
|
2
|
+
export class PathContextMenu {
|
|
3
|
+
shouldProvideContextmenu(event, designerView, designItem, initiator) {
|
|
4
|
+
if (designItem.element instanceof SVGPathElement)
|
|
5
|
+
return true;
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
provideContextMenuItems(event, designerCanvas, designItem) {
|
|
9
|
+
const pathdata = designItem.node.getPathData({ normalize: true });
|
|
10
|
+
const items = [];
|
|
11
|
+
const lastType = pathdata[pathdata.length - 1].type;
|
|
12
|
+
items.push({ title: '-' });
|
|
13
|
+
if (lastType == 'z' || lastType == 'Z') {
|
|
14
|
+
items.push({
|
|
15
|
+
title: 'open path ', action: () => {
|
|
16
|
+
pathdata.splice(pathdata.length - 1, 1);
|
|
17
|
+
designItem.setAttribute('d', createPathD(pathdata));
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
items.push({
|
|
23
|
+
title: 'close path ', action: () => {
|
|
24
|
+
pathdata.push({ type: 'Z' });
|
|
25
|
+
designItem.setAttribute('d', createPathD(pathdata));
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return items;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IContextMenuItem } from "../../../../helper/contextMenu/IContextmenuItem";
|
|
2
|
+
import { IDesignItem } from "../../../../item/IDesignItem";
|
|
3
|
+
import { IDesignerCanvas } from "../../IDesignerCanvas";
|
|
4
|
+
import { ContextmenuInitiator, IContextMenuExtension } from "./IContextMenuExtension";
|
|
5
|
+
export declare class RectContextMenu implements IContextMenuExtension {
|
|
6
|
+
shouldProvideContextmenu(event: MouseEvent, designerView: IDesignerCanvas, designItem: IDesignItem, initiator: ContextmenuInitiator): boolean;
|
|
7
|
+
provideContextMenuItems(event: MouseEvent, designerCanvas: IDesignerCanvas, designItem: IDesignItem): IContextMenuItem[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DeleteAction } from "../../../../..";
|
|
2
|
+
import { DesignItem } from "../../../../item/DesignItem";
|
|
3
|
+
import { InsertAction } from "../../../../services/undoService/transactionItems/InsertAction";
|
|
4
|
+
export class RectContextMenu {
|
|
5
|
+
shouldProvideContextmenu(event, designerView, designItem, initiator) {
|
|
6
|
+
if (designItem.element instanceof SVGRectElement)
|
|
7
|
+
return true;
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
provideContextMenuItems(event, designerCanvas, designItem) {
|
|
11
|
+
return [
|
|
12
|
+
{ title: '-' },
|
|
13
|
+
{
|
|
14
|
+
title: 'convert to path', action: () => {
|
|
15
|
+
let rect = designItem.element;
|
|
16
|
+
let pathD = "";
|
|
17
|
+
pathD += "M" + rect.x.baseVal.value + " " + rect.y.baseVal.value +
|
|
18
|
+
"L" + (rect.x.baseVal.value + rect.width.baseVal.value) + " " + rect.y.baseVal.value +
|
|
19
|
+
"L" + (rect.x.baseVal.value + rect.width.baseVal.value) + " " + (rect.y.baseVal.value + rect.height.baseVal.value) +
|
|
20
|
+
"L" + rect.x.baseVal.value + " " + (rect.y.baseVal.value + rect.height.baseVal.value) +
|
|
21
|
+
"Z";
|
|
22
|
+
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
23
|
+
path.setAttribute("d", pathD);
|
|
24
|
+
path.setAttribute("stroke", rect.getAttribute("stroke"));
|
|
25
|
+
path.setAttribute("fill", rect.getAttribute("fill"));
|
|
26
|
+
path.setAttribute("stroke-width", rect.getAttribute("stroke-width"));
|
|
27
|
+
const di = DesignItem.createDesignItemFromInstance(path, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
28
|
+
designerCanvas.instanceServiceContainer.undoService.execute(new InsertAction(designItem.parent, designItem.childCount, di));
|
|
29
|
+
designerCanvas.instanceServiceContainer.undoService.execute(new DeleteAction([designItem]));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -67,8 +67,7 @@ export class OverlayLayerView extends BaseCustomWebComponentConstructorAppend {
|
|
|
67
67
|
}
|
|
68
68
|
removeOverlay(element) {
|
|
69
69
|
try {
|
|
70
|
-
|
|
71
|
-
element.parentElement.removeChild(element);
|
|
70
|
+
element?.parentElement?.removeChild(element);
|
|
72
71
|
}
|
|
73
72
|
catch (err) {
|
|
74
73
|
console.error(err);
|
|
@@ -80,6 +80,7 @@ export class DrawEllipsisTool {
|
|
|
80
80
|
svg.style.position = 'absolute';
|
|
81
81
|
svg.style.width = (rect.width + 2 * offset) + 'px';
|
|
82
82
|
svg.style.height = (rect.height + 2 * offset) + 'px';
|
|
83
|
+
svg.style.overflow = 'visible';
|
|
83
84
|
this._path = null;
|
|
84
85
|
const di = DesignItem.createDesignItemFromInstance(svg, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
85
86
|
designerCanvas.instanceServiceContainer.undoService.execute(new InsertAction(designerCanvas.rootDesignItem, designerCanvas.rootDesignItem.childCount, di));
|
|
@@ -65,6 +65,7 @@ export class DrawLineTool {
|
|
|
65
65
|
svg.style.position = 'absolute';
|
|
66
66
|
svg.style.width = (rect.width + 2 * offset) + 'px';
|
|
67
67
|
svg.style.height = (rect.height + 2 * offset) + 'px';
|
|
68
|
+
svg.style.overflow = 'visible';
|
|
68
69
|
this._path = null;
|
|
69
70
|
const di = DesignItem.createDesignItemFromInstance(svg, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
70
71
|
designerCanvas.instanceServiceContainer.undoService.execute(new InsertAction(designerCanvas.rootDesignItem, designerCanvas.rootDesignItem.childCount, di));
|
|
@@ -12,9 +12,8 @@ export class DrawPathTool {
|
|
|
12
12
|
_dragMode = false;
|
|
13
13
|
_pointerMoved = false;
|
|
14
14
|
_eventStarted = false;
|
|
15
|
-
_lastPoint
|
|
16
|
-
|
|
17
|
-
_startPoint = { x: 0, y: 0 };
|
|
15
|
+
_lastPoint;
|
|
16
|
+
_startPoint;
|
|
18
17
|
constructor() {
|
|
19
18
|
}
|
|
20
19
|
activated(serviceContainer) {
|
|
@@ -38,10 +37,15 @@ export class DrawPathTool {
|
|
|
38
37
|
designerCanvas.overlayLayer.addOverlay(this._path, OverlayLayer.Foregorund);
|
|
39
38
|
this._startPoint = currentPoint;
|
|
40
39
|
}
|
|
41
|
-
if (this._lastPoint.x === currentPoint.x && this._lastPoint.y === currentPoint.y && !this._samePoint) {
|
|
40
|
+
if (this._lastPoint != null && this._lastPoint.x === currentPoint.x && this._lastPoint.y === currentPoint.y && !this._samePoint) {
|
|
42
41
|
this._samePoint = true;
|
|
43
42
|
}
|
|
44
|
-
this._lastPoint
|
|
43
|
+
if (this._lastPoint == null) {
|
|
44
|
+
this._lastPoint = currentPoint;
|
|
45
|
+
}
|
|
46
|
+
if (this._startPoint == null) {
|
|
47
|
+
this._startPoint = currentPoint;
|
|
48
|
+
}
|
|
45
49
|
break;
|
|
46
50
|
case EventNames.PointerMove:
|
|
47
51
|
if (this._eventStarted) {
|
|
@@ -57,8 +61,9 @@ export class DrawPathTool {
|
|
|
57
61
|
else { // shows line preview
|
|
58
62
|
if (this._path) {
|
|
59
63
|
let straightLine = currentPoint;
|
|
60
|
-
if (event.shiftKey)
|
|
61
|
-
straightLine = straightenLine(this.
|
|
64
|
+
if (event.shiftKey) {
|
|
65
|
+
straightLine = straightenLine(this._lastPoint, currentPoint);
|
|
66
|
+
}
|
|
62
67
|
this._path.setAttribute("d", this._pathD + "L" + straightLine.x + " " + straightLine.y);
|
|
63
68
|
}
|
|
64
69
|
}
|
|
@@ -71,15 +76,16 @@ export class DrawPathTool {
|
|
|
71
76
|
if (this._p2pMode && !this._samePoint && this._startPoint.x != currentPoint.x && this._startPoint.y != currentPoint.y) {
|
|
72
77
|
if (this._path) {
|
|
73
78
|
if (event.shiftKey) {
|
|
74
|
-
let straightLine = straightenLine(this.
|
|
79
|
+
let straightLine = straightenLine(this._lastPoint, currentPoint);
|
|
75
80
|
this._pathD += "L" + straightLine.x + " " + straightLine.y;
|
|
76
81
|
this._path.setAttribute("d", this._pathD);
|
|
82
|
+
this._lastPoint = straightLine;
|
|
77
83
|
}
|
|
78
84
|
else {
|
|
79
85
|
this._pathD += "L" + currentPoint.x + " " + currentPoint.y;
|
|
80
86
|
this._path.setAttribute("d", this._pathD);
|
|
87
|
+
this._lastPoint = currentPoint;
|
|
81
88
|
}
|
|
82
|
-
this._savedPoint = currentPoint;
|
|
83
89
|
}
|
|
84
90
|
}
|
|
85
91
|
if (this._samePoint && this._p2pMode || this._dragMode && !this._p2pMode) {
|
|
@@ -101,9 +107,11 @@ export class DrawPathTool {
|
|
|
101
107
|
svg.style.position = 'absolute';
|
|
102
108
|
svg.style.width = (rect.width + 2 * offset) + 'px';
|
|
103
109
|
svg.style.height = (rect.height + 2 * offset) + 'px';
|
|
110
|
+
svg.style.overflow = 'visible';
|
|
104
111
|
//designerView.rootDesignItem.element.appendChild(svg);
|
|
105
112
|
this._path = null;
|
|
106
113
|
this._pathD = null;
|
|
114
|
+
this._lastPoint = null;
|
|
107
115
|
const di = DesignItem.createDesignItemFromInstance(svg, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
108
116
|
designerCanvas.instanceServiceContainer.undoService.execute(new InsertAction(designerCanvas.rootDesignItem, designerCanvas.rootDesignItem.childCount, di));
|
|
109
117
|
designerCanvas.serviceContainer.globalContext.finishedWithTool(this);
|
|
@@ -95,6 +95,7 @@ export class DrawRectTool {
|
|
|
95
95
|
svg.style.position = 'absolute';
|
|
96
96
|
svg.style.width = (rect.width + 2 * offset) + 'px';
|
|
97
97
|
svg.style.height = (rect.height + 2 * offset) + 'px';
|
|
98
|
+
svg.style.overflow = 'visible';
|
|
98
99
|
this._path = null;
|
|
99
100
|
const di = DesignItem.createDesignItemFromInstance(svg, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
100
101
|
designerCanvas.instanceServiceContainer.undoService.execute(new InsertAction(designerCanvas.rootDesignItem, designerCanvas.rootDesignItem.childCount, di));
|
package/dist/index.d.ts
CHANGED
|
@@ -45,7 +45,10 @@ export * from "./elements/services/elementsService/JsonFileElementsService.js";
|
|
|
45
45
|
export * from "./elements/services/elementsService/PreDefinedElementsService.js";
|
|
46
46
|
export type { IHtmlWriterService } from "./elements/services/htmlWriterService/IHtmlWriterService.js";
|
|
47
47
|
export type { IHtmlWriterOptions } from "./elements/services/htmlWriterService/IHtmlWriterOptions.js";
|
|
48
|
+
export * from "./elements/services/htmlWriterService/AbstractHtmlWriterService.js";
|
|
49
|
+
export * from "./elements/services/htmlWriterService/FormatingHtmlWriterService.js";
|
|
48
50
|
export * from "./elements/services/htmlWriterService/HtmlWriterService.js";
|
|
51
|
+
export * from "./elements/services/htmlWriterService/LitTsElementWriterService.js";
|
|
49
52
|
export * from "./elements/services/htmlParserService/DefaultHtmlParserService.js";
|
|
50
53
|
export * from "./elements/services/htmlParserService/NodeHtmlParserService.js";
|
|
51
54
|
export type { IHtmlParserService } from "./elements/services/htmlParserService/IHtmlParserService.js";
|
|
@@ -177,3 +180,4 @@ export type { IPoint } from "./interfaces/IPoint.js";
|
|
|
177
180
|
export type { IRect } from "./interfaces/IRect.js";
|
|
178
181
|
export type { ISize } from "./interfaces/ISize.js";
|
|
179
182
|
export type { ICommandHandler } from "./interfaces/ICommandHandler.js";
|
|
183
|
+
export * from './Constants.js';
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,10 @@ export * from "./elements/services/demoProviderService/DemoProviderService.js";
|
|
|
26
26
|
export * from "./elements/services/dragDropService/DragDropService.js";
|
|
27
27
|
export * from "./elements/services/elementsService/JsonFileElementsService.js";
|
|
28
28
|
export * from "./elements/services/elementsService/PreDefinedElementsService.js";
|
|
29
|
+
export * from "./elements/services/htmlWriterService/AbstractHtmlWriterService.js";
|
|
30
|
+
export * from "./elements/services/htmlWriterService/FormatingHtmlWriterService.js";
|
|
29
31
|
export * from "./elements/services/htmlWriterService/HtmlWriterService.js";
|
|
32
|
+
export * from "./elements/services/htmlWriterService/LitTsElementWriterService.js";
|
|
30
33
|
export * from "./elements/services/htmlParserService/DefaultHtmlParserService.js";
|
|
31
34
|
export * from "./elements/services/htmlParserService/NodeHtmlParserService.js";
|
|
32
35
|
export * from "./elements/services/instanceService/DefaultInstanceService.js";
|
|
@@ -126,3 +129,4 @@ export * from "./elements/widgets/codeView/code-view-code-mirror.js";
|
|
|
126
129
|
export * from "./elements/documentContainer.js";
|
|
127
130
|
export * from "./enums/EventNames.js";
|
|
128
131
|
export * from "./enums/PointerActionType.js";
|
|
132
|
+
export * from './Constants.js';
|
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.82",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "",
|
|
@@ -13,26 +13,26 @@
|
|
|
13
13
|
"prepublishOnly": "npm run build"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@node-projects/base-custom-webcomponent": "^0.
|
|
16
|
+
"@node-projects/base-custom-webcomponent": "^0.5.0",
|
|
17
17
|
"construct-style-sheets-polyfill": "^3.0.5"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@node-projects/lean-he-esm": "^3.3.0",
|
|
21
21
|
"@node-projects/node-html-parser-esm": "^2.4.1",
|
|
22
22
|
"@types/codemirror": "^5.60.5",
|
|
23
|
-
"@types/jquery": "^3.5.
|
|
23
|
+
"@types/jquery": "^3.5.13",
|
|
24
24
|
"@types/jquery.fancytree": "0.0.7",
|
|
25
25
|
"ace-builds": "^1.4.13",
|
|
26
|
-
"codemirror": "^5.65.
|
|
26
|
+
"codemirror": "^5.65.1",
|
|
27
27
|
"custom-elements-manifest": "^1.0.0",
|
|
28
|
-
"esprima-next": "^5.
|
|
28
|
+
"esprima-next": "^5.8.1",
|
|
29
29
|
"html2canvas": "*",
|
|
30
|
-
"jest": "^27.4.
|
|
30
|
+
"jest": "^27.4.7",
|
|
31
31
|
"jquery": "^3.6.0",
|
|
32
|
-
"jquery.fancytree": "^2.38.
|
|
32
|
+
"jquery.fancytree": "^2.38.1",
|
|
33
33
|
"monaco-editor": "^0.31.1",
|
|
34
|
-
"ts-jest": "^27.1.
|
|
35
|
-
"typescript": "^4.5.
|
|
34
|
+
"ts-jest": "^27.1.3",
|
|
35
|
+
"typescript": "^4.5.5",
|
|
36
36
|
"typescript-lit-html-plugin": "^0.9.0"
|
|
37
37
|
},
|
|
38
38
|
"repository": {
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { IDesignItem } from '../../item/IDesignItem';
|
|
2
|
-
import { IHtmlWriterService } from './IHtmlWriterService';
|
|
3
|
-
import { IHtmlWriterOptions } from './IHtmlWriterOptions';
|
|
4
|
-
import { IndentedTextWriter } from '../../helper/IndentedTextWriter';
|
|
5
|
-
import { IStringPosition } from './IStringPosition';
|
|
6
|
-
export declare class HtmlWriterService implements IHtmlWriterService {
|
|
7
|
-
canWrite(designItem: IDesignItem): boolean;
|
|
8
|
-
private _conditionalyWriteIndent;
|
|
9
|
-
private _conditionalyWriteNewline;
|
|
10
|
-
write(indentedTextWriter: IndentedTextWriter, designItem: IDesignItem, options: IHtmlWriterOptions, designItemsAssignmentList?: Map<IDesignItem, IStringPosition>): void;
|
|
11
|
-
private writeTextNode;
|
|
12
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { DomConverter } from '../../widgets/designerView/DomConverter';
|
|
2
|
-
import { CssCombiner } from '../../helper/CssCombiner';
|
|
3
|
-
import { NodeType } from '../../item/NodeType';
|
|
4
|
-
import { PropertiesHelper } from '../propertiesService/services/PropertiesHelper';
|
|
5
|
-
import { isInline } from '../../helper/ElementHelper.js';
|
|
6
|
-
//todo :
|
|
7
|
-
//write style...
|
|
8
|
-
//needs InternalBindinsgStorrageService -> keeps bindings
|
|
9
|
-
export class HtmlWriterService {
|
|
10
|
-
canWrite(designItem) {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
_conditionalyWriteIndent(indentedTextWriter, designItem) {
|
|
14
|
-
if ((designItem.element instanceof HTMLElement && !isInline(designItem.element)) ||
|
|
15
|
-
(designItem.element.previousElementSibling instanceof HTMLElement && !isInline(designItem.element.previousElementSibling)))
|
|
16
|
-
indentedTextWriter.writeIndent();
|
|
17
|
-
}
|
|
18
|
-
_conditionalyWriteNewline(indentedTextWriter, designItem) {
|
|
19
|
-
if ((designItem.element instanceof HTMLElement && !isInline(designItem.element)) ||
|
|
20
|
-
(designItem.element.nextElementSibling instanceof HTMLElement && !isInline(designItem.element.nextElementSibling)))
|
|
21
|
-
indentedTextWriter.writeNewline();
|
|
22
|
-
}
|
|
23
|
-
write(indentedTextWriter, designItem, options, designItemsAssignmentList) {
|
|
24
|
-
let start = indentedTextWriter.position;
|
|
25
|
-
if (designItem.nodeType == NodeType.TextNode) {
|
|
26
|
-
this._conditionalyWriteIndent(indentedTextWriter, designItem);
|
|
27
|
-
this.writeTextNode(indentedTextWriter, designItem, true);
|
|
28
|
-
}
|
|
29
|
-
else if (designItem.nodeType == NodeType.Comment) {
|
|
30
|
-
this._conditionalyWriteIndent(indentedTextWriter, designItem);
|
|
31
|
-
indentedTextWriter.write('<!--' + designItem.content + '-->');
|
|
32
|
-
this._conditionalyWriteNewline(indentedTextWriter, designItem);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
this._conditionalyWriteIndent(indentedTextWriter, designItem);
|
|
36
|
-
indentedTextWriter.write('<' + designItem.name);
|
|
37
|
-
if (designItem.hasAttributes) {
|
|
38
|
-
for (const a of designItem.attributes) {
|
|
39
|
-
indentedTextWriter.write(' ');
|
|
40
|
-
if (typeof a[1] === 'string') {
|
|
41
|
-
if (a[1] === "")
|
|
42
|
-
indentedTextWriter.write(a[0]);
|
|
43
|
-
else
|
|
44
|
-
indentedTextWriter.write(a[0] + '="' + DomConverter.normalizeAttributeValue(a[1]) + '"');
|
|
45
|
-
}
|
|
46
|
-
else if (!a[1])
|
|
47
|
-
indentedTextWriter.write(a[0]);
|
|
48
|
-
else {
|
|
49
|
-
//TODO: writing of bindings
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (designItem.hasStyles) {
|
|
54
|
-
indentedTextWriter.write(' style="');
|
|
55
|
-
let styles = designItem.styles;
|
|
56
|
-
if (options.compressCssToShorthandProperties)
|
|
57
|
-
styles = CssCombiner.combine(styles);
|
|
58
|
-
for (const s of styles) {
|
|
59
|
-
if (s[0]) {
|
|
60
|
-
indentedTextWriter.write(PropertiesHelper.camelToDashCase(s[0]) + ':' + DomConverter.normalizeAttributeValue(s[1]) + ';');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
indentedTextWriter.write('"');
|
|
64
|
-
}
|
|
65
|
-
indentedTextWriter.write('>');
|
|
66
|
-
if (designItem.hasChildren) {
|
|
67
|
-
const children = designItem.children();
|
|
68
|
-
const singleTextNode = designItem.childCount === 1 && designItem.firstChild.nodeType === NodeType.TextNode;
|
|
69
|
-
if (singleTextNode) {
|
|
70
|
-
this.writeTextNode(indentedTextWriter, designItem, false);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
indentedTextWriter.writeNewline();
|
|
74
|
-
indentedTextWriter.levelRaise();
|
|
75
|
-
for (const c of children) {
|
|
76
|
-
c.serviceContainer.forSomeServicesTillResult('htmlWriterService', (s) => {
|
|
77
|
-
if (s.canWrite(c)) {
|
|
78
|
-
s.write(indentedTextWriter, c, options, designItemsAssignmentList);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
indentedTextWriter.levelShrink();
|
|
83
|
-
indentedTextWriter.writeIndent();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else if (designItem.hasContent) {
|
|
87
|
-
indentedTextWriter.write(DomConverter.normalizeContentValue(designItem.content));
|
|
88
|
-
}
|
|
89
|
-
if (!DomConverter.IsSelfClosingElement(designItem.name))
|
|
90
|
-
indentedTextWriter.write('</' + designItem.name + '>');
|
|
91
|
-
this._conditionalyWriteNewline(indentedTextWriter, designItem);
|
|
92
|
-
}
|
|
93
|
-
if (designItemsAssignmentList) {
|
|
94
|
-
designItemsAssignmentList.set(designItem, { start: start, length: indentedTextWriter.position - start - 1 });
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
writeTextNode(indentedTextWriter, designItem, indentAndNewline) {
|
|
98
|
-
let content = DomConverter.normalizeContentValue(designItem.content).trim();
|
|
99
|
-
if (content) {
|
|
100
|
-
if (indentAndNewline)
|
|
101
|
-
this._conditionalyWriteIndent(indentedTextWriter, designItem);
|
|
102
|
-
indentedTextWriter.write(content);
|
|
103
|
-
if (indentAndNewline)
|
|
104
|
-
this._conditionalyWriteNewline(indentedTextWriter, designItem);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { IDesignItem } from "../../..";
|
|
2
|
-
import { BindingTarget } from "../../item/BindingTarget";
|
|
3
|
-
import { IElementDefinition } from "../elementsService/IElementDefinition";
|
|
4
|
-
import { IElementsService } from "../elementsService/IElementsService";
|
|
5
|
-
import { IPropertiesService } from "../propertiesService/IPropertiesService";
|
|
6
|
-
import { IProperty } from "../propertiesService/IProperty";
|
|
7
|
-
import { ValueType } from "../propertiesService/ValueType";
|
|
8
|
-
export declare class WebcomponentManifestParserService implements IElementsService, IPropertiesService {
|
|
9
|
-
private _name;
|
|
10
|
-
get name(): string;
|
|
11
|
-
private _packageData;
|
|
12
|
-
private _elementList;
|
|
13
|
-
private _resolveStored;
|
|
14
|
-
private _rejectStored;
|
|
15
|
-
constructor(name: string, file: string);
|
|
16
|
-
getElements(): Promise<IElementDefinition[]>;
|
|
17
|
-
isHandledElement(designItem: IDesignItem): boolean;
|
|
18
|
-
getProperties(designItem: IDesignItem): IProperty[];
|
|
19
|
-
getProperty(designItem: IDesignItem, name: string): IProperty;
|
|
20
|
-
getPropertyTarget(designItem: IDesignItem, property: IProperty): BindingTarget;
|
|
21
|
-
setValue(designItems: IDesignItem[], property: IProperty, value: any): void;
|
|
22
|
-
clearValue(designItems: IDesignItem[], property: IProperty): void;
|
|
23
|
-
isSet(designItems: IDesignItem[], property: IProperty): ValueType;
|
|
24
|
-
getValue(designItems: IDesignItem[], property: IProperty): void;
|
|
25
|
-
getUnsetValue(designItems: IDesignItem[], property: IProperty): void;
|
|
26
|
-
}
|