@node-projects/web-component-designer 0.0.79 → 0.0.83
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/PathDataPolyfill.d.ts +11 -10
- package/dist/elements/helper/PathDataPolyfill.js +36 -1
- package/dist/elements/services/DefaultServiceBootstrap.js +9 -3
- 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 +5 -5
- package/dist/elements/services/htmlWriterService/FormatingHtmlWriterService.js +4 -4
- package/dist/elements/services/htmlWriterService/HtmlWriterService copy.d.ts +4 -14
- package/dist/elements/services/htmlWriterService/HtmlWriterService copy.js +100 -100
- package/dist/elements/services/htmlWriterService/HtmlWriterService.d.ts +6 -6
- package/dist/elements/services/htmlWriterService/HtmlWriterService.js +6 -33
- package/dist/elements/services/htmlWriterService/IHtmlWriterOptions.d.ts +2 -0
- package/dist/elements/services/htmlWriterService/IHtmlWriterOptions.js +5 -3
- package/dist/elements/services/manifestParsers/WebcomponentManifestParserService.js +3 -1
- 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 +7 -4
- package/dist/elements/widgets/designerView/designerCanvas.d.ts +2 -0
- package/dist/elements/widgets/designerView/designerCanvas.js +11 -4
- package/dist/elements/widgets/designerView/designerView.js +25 -7
- package/dist/elements/widgets/designerView/extensions/ExtensionManager.d.ts +5 -4
- package/dist/elements/widgets/designerView/extensions/ExtensionManager.js +41 -15
- package/dist/elements/widgets/designerView/extensions/IExtensionManger.d.ts +2 -2
- package/dist/elements/widgets/designerView/extensions/IframeExtension.d.ts +11 -0
- package/dist/elements/widgets/designerView/extensions/IframeExtension.js +46 -0
- package/dist/elements/widgets/designerView/extensions/IframeExtensionProvider.d.ts +9 -0
- package/dist/elements/widgets/designerView/extensions/IframeExtensionProvider.js +9 -0
- package/dist/elements/widgets/designerView/extensions/InvisibleDivExtension.d.ts +1 -1
- package/dist/elements/widgets/designerView/extensions/InvisibleDivExtension.js +2 -2
- package/dist/elements/widgets/designerView/extensions/InvisibleDivExtensionProvider.d.ts +2 -2
- package/dist/elements/widgets/designerView/extensions/InvisibleDivExtensionProvider.js +3 -3
- package/dist/elements/widgets/designerView/extensions/PathExtension.d.ts +2 -1
- package/dist/elements/widgets/designerView/extensions/PathExtension.js +139 -12
- package/dist/elements/widgets/designerView/extensions/ResizeExtension.js +11 -3
- package/dist/elements/widgets/designerView/extensions/ResizeExtensionProvider.js +2 -1
- 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/tools/DrawElementTool.d.ts +1 -0
- package/dist/elements/widgets/designerView/tools/DrawElementTool.js +1 -0
- package/dist/elements/widgets/designerView/tools/DrawEllipsisTool.d.ts +1 -0
- package/dist/elements/widgets/designerView/tools/DrawEllipsisTool.js +2 -0
- package/dist/elements/widgets/designerView/tools/DrawLineTool.d.ts +1 -0
- package/dist/elements/widgets/designerView/tools/DrawLineTool.js +2 -0
- package/dist/elements/widgets/designerView/tools/DrawPathTool.d.ts +1 -1
- package/dist/elements/widgets/designerView/tools/DrawPathTool.js +18 -9
- package/dist/elements/widgets/designerView/tools/DrawRectTool.d.ts +1 -0
- package/dist/elements/widgets/designerView/tools/DrawRectTool.js +2 -0
- package/dist/elements/widgets/designerView/tools/ITool.d.ts +1 -0
- package/dist/elements/widgets/designerView/tools/MagicWandSelectorTool.d.ts +1 -0
- package/dist/elements/widgets/designerView/tools/MagicWandSelectorTool.js +1 -0
- package/dist/elements/widgets/designerView/tools/PanTool.d.ts +1 -0
- package/dist/elements/widgets/designerView/tools/PanTool.js +1 -0
- package/dist/elements/widgets/designerView/tools/PickColorTool.d.ts +1 -0
- package/dist/elements/widgets/designerView/tools/PickColorTool.js +1 -0
- package/dist/elements/widgets/designerView/tools/PointerTool.d.ts +1 -0
- package/dist/elements/widgets/designerView/tools/PointerTool.js +1 -0
- package/dist/elements/widgets/designerView/tools/RectangleSelectorTool.d.ts +1 -0
- package/dist/elements/widgets/designerView/tools/RectangleSelectorTool.js +1 -0
- package/dist/elements/widgets/designerView/tools/TextTool.d.ts +1 -0
- package/dist/elements/widgets/designerView/tools/TextTool.js +1 -0
- package/dist/elements/widgets/designerView/tools/ZoomTool.d.ts +1 -0
- package/dist/elements/widgets/designerView/tools/ZoomTool.js +1 -0
- package/dist/elements/widgets/treeView/treeViewExtended.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +9 -9
- package/dist/elements/services/htmlWriterService/FormatingHtmlWriterService copy.d.ts +0 -22
- package/dist/elements/services/htmlWriterService/FormatingHtmlWriterService copy.js +0 -125
- package/dist/elements/services/htmlWriterService/LitElementWriterService.d.ts +0 -14
- package/dist/elements/services/htmlWriterService/LitElementWriterService.js +0 -123
- package/dist/elements/services/htmlWriterService/SimpleHtmlWriterService copy.d.ts +0 -22
- package/dist/elements/services/htmlWriterService/SimpleHtmlWriterService copy.js +0 -125
- package/dist/elements/services/initializationService/IIntializationService copy.d.ts +0 -4
- package/dist/elements/services/initializationService/IIntializationService copy.js +0 -1
- 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,25 +120,125 @@ 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
|
-
let circle = this._drawCircle(this._parentRect.x - this.designerCanvas.containerBoundingRect.x + x, this._parentRect.y - this.designerCanvas.containerBoundingRect.y + y,
|
|
128
|
+
let circle = this._drawCircle(this._parentRect.x - this.designerCanvas.containerBoundingRect.x + x, this._parentRect.y - this.designerCanvas.containerBoundingRect.y + y, 5, 'svg-path');
|
|
129
|
+
let circlePos = { x: x, y: y };
|
|
130
|
+
const items = [];
|
|
131
|
+
const pidx = this._pathdata.indexOf(p);
|
|
132
|
+
items.push({
|
|
133
|
+
title: 'delete point', action: () => {
|
|
134
|
+
this._pathdata.splice(pidx, 1);
|
|
135
|
+
if (pidx == 0)
|
|
136
|
+
this._pathdata[0].type = 'M';
|
|
137
|
+
this.extendedItem.setAttribute('d', createPathD(this._pathdata));
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
items.push({
|
|
141
|
+
title: 'insert point after', action: () => {
|
|
142
|
+
const l = { type: 'L', values: [p.values[0], p.values[1]] };
|
|
143
|
+
this._pathdata.splice(pidx + 1, 0, l);
|
|
144
|
+
this.extendedItem.setAttribute('d', createPathD(this._pathdata));
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
if (pidx != 0 && this._checkCircleIndex(p, circlePos)) {
|
|
148
|
+
items.push({
|
|
149
|
+
title: 'convert to quadratic bézier', action: () => {
|
|
150
|
+
let p1x = this._pathdata[pidx - 1].values[0];
|
|
151
|
+
let p1y = this._pathdata[pidx - 1].values[1];
|
|
152
|
+
if (this._pathdata[pidx - 1].type === 'C') {
|
|
153
|
+
p1x = this._pathdata[pidx - 1].values[4];
|
|
154
|
+
p1y = this._pathdata[pidx - 1].values[5];
|
|
155
|
+
}
|
|
156
|
+
else if (this._pathdata[pidx - 1].type === 'Q') {
|
|
157
|
+
p1x = this._pathdata[pidx - 1].values[2];
|
|
158
|
+
p1y = this._pathdata[pidx - 1].values[3];
|
|
159
|
+
}
|
|
160
|
+
const p2x = this._pathdata[pidx].values[0];
|
|
161
|
+
const p2y = this._pathdata[pidx].values[1];
|
|
162
|
+
const mpx = (p2x + p1x) * 0.5;
|
|
163
|
+
const mpy = (p2y + p1y) * 0.5;
|
|
164
|
+
const theta = Math.atan2(p2y - p1y, p2x - p1x) - Math.PI / 2;
|
|
165
|
+
const offset = 50;
|
|
166
|
+
const c1x = mpx + offset * Math.cos(theta);
|
|
167
|
+
const c1y = mpy + offset * Math.sin(theta);
|
|
168
|
+
this._pathdata[pidx].type = 'Q';
|
|
169
|
+
this._pathdata[pidx].values[0] = c1x;
|
|
170
|
+
this._pathdata[pidx].values[1] = c1y;
|
|
171
|
+
this._pathdata[pidx].values[2] = p2x;
|
|
172
|
+
this._pathdata[pidx].values[3] = p2y;
|
|
173
|
+
this.extendedItem.setAttribute('d', createPathD(this._pathdata));
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (pidx != 0 && this._checkCircleIndex(p, circlePos)) {
|
|
178
|
+
items.push({
|
|
179
|
+
title: 'convert to cubic bézier', action: () => {
|
|
180
|
+
let p1x = this._pathdata[pidx - 1].values[0];
|
|
181
|
+
let p1y = this._pathdata[pidx - 1].values[1];
|
|
182
|
+
if (this._pathdata[pidx - 1].type === 'C') {
|
|
183
|
+
p1x = this._pathdata[pidx - 1].values[4];
|
|
184
|
+
p1y = this._pathdata[pidx - 1].values[5];
|
|
185
|
+
}
|
|
186
|
+
else if (this._pathdata[pidx - 1].type === 'Q') {
|
|
187
|
+
p1x = this._pathdata[pidx - 1].values[2];
|
|
188
|
+
p1y = this._pathdata[pidx - 1].values[3];
|
|
189
|
+
}
|
|
190
|
+
const p2x = this._pathdata[pidx].values[0];
|
|
191
|
+
const p2y = this._pathdata[pidx].values[1];
|
|
192
|
+
const mpx = (p2x + p1x) * 0.5;
|
|
193
|
+
const mpy = (p2y + p1y) * 0.5;
|
|
194
|
+
const theta = Math.atan2(p2y - p1y, p2x - p1x) - Math.PI / 2;
|
|
195
|
+
const offset = 50;
|
|
196
|
+
let c1x = mpx + offset * Math.cos(theta);
|
|
197
|
+
let c1y = mpy + offset * Math.sin(theta);
|
|
198
|
+
c1x = p.values[0] + 2 * (p1x - p.values[0]) / 3;
|
|
199
|
+
c1y = p.values[1] + 2 * (p1y - p.values[1]) / 3;
|
|
200
|
+
const c2x = x + 2 * (p1x - x) / 3;
|
|
201
|
+
const c2y = y + 2 * (p1y - y) / 3;
|
|
202
|
+
this._pathdata[pidx].type = 'C';
|
|
203
|
+
this._pathdata[pidx].values[0] = c1x;
|
|
204
|
+
this._pathdata[pidx].values[1] = c1y;
|
|
205
|
+
this._pathdata[pidx].values[2] = c2x;
|
|
206
|
+
this._pathdata[pidx].values[3] = c2y;
|
|
207
|
+
this._pathdata[pidx].values[4] = p2x;
|
|
208
|
+
this._pathdata[pidx].values[5] = p2y;
|
|
209
|
+
this.extendedItem.setAttribute('d', createPathD(this._pathdata));
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
108
213
|
circle.addEventListener(EventNames.PointerDown, event => this.pointerEvent(event, circle, p, index));
|
|
109
214
|
circle.addEventListener(EventNames.PointerMove, event => this.pointerEvent(event, circle, p, index));
|
|
110
215
|
circle.addEventListener(EventNames.PointerUp, event => this.pointerEvent(event, circle, p, index));
|
|
216
|
+
circle.addEventListener(EventNames.ContextMenu, event => {
|
|
217
|
+
event.preventDefault();
|
|
218
|
+
ContextMenuHelper.showContextMenu(null, event, null, items);
|
|
219
|
+
});
|
|
111
220
|
}
|
|
112
221
|
_drawPathLine(x1, y1, x2, y2) {
|
|
113
222
|
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');
|
|
114
223
|
}
|
|
224
|
+
_checkCircleIndex(p, circlePos) {
|
|
225
|
+
switch (p.type) {
|
|
226
|
+
case 'M':
|
|
227
|
+
case 'L':
|
|
228
|
+
if (p.values[0] == circlePos.x && p.values[1] == circlePos.y)
|
|
229
|
+
return true;
|
|
230
|
+
break;
|
|
231
|
+
case 'Q':
|
|
232
|
+
if (p.values[2] == circlePos.x && p.values[3] == circlePos.y)
|
|
233
|
+
return true;
|
|
234
|
+
break;
|
|
235
|
+
case 'C':
|
|
236
|
+
if (p.values[4] == circlePos.x && p.values[5] == circlePos.y)
|
|
237
|
+
return true;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
115
242
|
refresh() {
|
|
116
243
|
this._removeAllOverlays();
|
|
117
244
|
this.extend();
|
|
@@ -19,6 +19,7 @@ export class ResizeExtension extends AbstractExtension {
|
|
|
19
19
|
this.resizeAllSelected = resizeAllSelected;
|
|
20
20
|
}
|
|
21
21
|
extend() {
|
|
22
|
+
this.refresh();
|
|
22
23
|
}
|
|
23
24
|
refresh() {
|
|
24
25
|
const rect = this.extendedItem.element.getBoundingClientRect();
|
|
@@ -69,9 +70,13 @@ export class ResizeExtension extends AbstractExtension {
|
|
|
69
70
|
this._initialPoint = currentPoint;
|
|
70
71
|
this._initialSizes = [];
|
|
71
72
|
this._actionModeStarted = actionMode;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
let rect = this.extendedItem.element.getBoundingClientRect();
|
|
74
|
+
this._initialSizes.push({ width: rect.width / this.designerCanvas.scaleFactor, height: rect.height / this.designerCanvas.scaleFactor });
|
|
75
|
+
if (this.resizeAllSelected) {
|
|
76
|
+
for (const designItem of this.designerCanvas.instanceServiceContainer.selectionService.selectedElements) {
|
|
77
|
+
rect = designItem.element.getBoundingClientRect();
|
|
78
|
+
this._initialSizes.push({ width: rect.width / this.designerCanvas.scaleFactor, height: rect.height / this.designerCanvas.scaleFactor });
|
|
79
|
+
}
|
|
75
80
|
}
|
|
76
81
|
if (this.designerCanvas.alignOnSnap)
|
|
77
82
|
this.designerCanvas.snapLines.calculateSnaplines(this.designerCanvas.instanceServiceContainer.selectionService.selectedElements);
|
|
@@ -90,6 +95,7 @@ export class ResizeExtension extends AbstractExtension {
|
|
|
90
95
|
this.extendedItem.element.style.height = this._initialSizes[i].height + trackY + 'px';
|
|
91
96
|
if (this.resizeAllSelected) {
|
|
92
97
|
for (const designItem of this.designerCanvas.instanceServiceContainer.selectionService.selectedElements) {
|
|
98
|
+
i++;
|
|
93
99
|
if (designItem !== this.extendedItem) {
|
|
94
100
|
designItem.element.style.width = this._initialSizes[i].width + trackX + 'px';
|
|
95
101
|
designItem.element.style.height = this._initialSizes[i].height + trackY + 'px';
|
|
@@ -100,6 +106,7 @@ export class ResizeExtension extends AbstractExtension {
|
|
|
100
106
|
case 's-resize':
|
|
101
107
|
this.extendedItem.element.style.height = this._initialSizes[i].height + trackY + 'px';
|
|
102
108
|
if (this.resizeAllSelected) {
|
|
109
|
+
i++;
|
|
103
110
|
for (const designItem of this.designerCanvas.instanceServiceContainer.selectionService.selectedElements) {
|
|
104
111
|
if (designItem !== this.extendedItem) {
|
|
105
112
|
designItem.element.style.height = this._initialSizes[i].height + trackY + 'px';
|
|
@@ -110,6 +117,7 @@ export class ResizeExtension extends AbstractExtension {
|
|
|
110
117
|
case 'e-resize':
|
|
111
118
|
this.extendedItem.element.style.width = this._initialSizes[i].width + trackX + 'px';
|
|
112
119
|
if (this.resizeAllSelected) {
|
|
120
|
+
i++;
|
|
113
121
|
for (const designItem of this.designerCanvas.instanceServiceContainer.selectionService.selectedElements) {
|
|
114
122
|
if (designItem !== this.extendedItem) {
|
|
115
123
|
designItem.element.style.width = this._initialSizes[i].width + trackX + 'px';
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ResizeExtension } from "./ResizeExtension";
|
|
2
2
|
import { css } from "@node-projects/base-custom-webcomponent";
|
|
3
|
+
import { NodeType } from "../../../item/NodeType.js";
|
|
3
4
|
export class ResizeExtensionProvider {
|
|
4
5
|
resizeAllSelected;
|
|
5
6
|
constructor(resizeAllSelected = false) {
|
|
6
7
|
this.resizeAllSelected = resizeAllSelected;
|
|
7
8
|
}
|
|
8
9
|
shouldExtend(extensionManager, designerView, designItem) {
|
|
9
|
-
return
|
|
10
|
+
return designItem.nodeType == NodeType.Element;
|
|
10
11
|
}
|
|
11
12
|
getExtension(extensionManager, designerView, designItem) {
|
|
12
13
|
return new ResizeExtension(extensionManager, designerView, designItem, this.resizeAllSelected);
|
|
@@ -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
|
+
}
|
|
@@ -12,6 +12,7 @@ export declare class DrawElementTool implements ITool {
|
|
|
12
12
|
activated(serviceContainer: ServiceContainer): void;
|
|
13
13
|
dispose(): void;
|
|
14
14
|
pointerEventHandler(designerView: IDesignerCanvas, event: PointerEvent, currentElement: Element): void;
|
|
15
|
+
keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent, currentElement: Element): void;
|
|
15
16
|
private _onPointerDown;
|
|
16
17
|
private _onPointerMove;
|
|
17
18
|
private _onPointerUp;
|
|
@@ -12,4 +12,5 @@ export declare class DrawEllipsisTool implements ITool {
|
|
|
12
12
|
activated(serviceContainer: ServiceContainer): void;
|
|
13
13
|
dispose(): void;
|
|
14
14
|
pointerEventHandler(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): void;
|
|
15
|
+
keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent, currentElement: Element): void;
|
|
15
16
|
}
|
|
@@ -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));
|
|
@@ -87,4 +88,5 @@ export class DrawEllipsisTool {
|
|
|
87
88
|
break;
|
|
88
89
|
}
|
|
89
90
|
}
|
|
91
|
+
keyboardEventHandler(designerCanvas, event, currentElement) { }
|
|
90
92
|
}
|
|
@@ -10,4 +10,5 @@ export declare class DrawLineTool implements ITool {
|
|
|
10
10
|
activated(serviceContainer: ServiceContainer): void;
|
|
11
11
|
dispose(): void;
|
|
12
12
|
pointerEventHandler(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): void;
|
|
13
|
+
keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent, currentElement: Element): void;
|
|
13
14
|
}
|
|
@@ -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));
|
|
@@ -72,4 +73,5 @@ export class DrawLineTool {
|
|
|
72
73
|
break;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
76
|
+
keyboardEventHandler(designerCanvas, event, currentElement) { }
|
|
75
77
|
}
|
|
@@ -11,10 +11,10 @@ export declare class DrawPathTool implements ITool {
|
|
|
11
11
|
private _pointerMoved;
|
|
12
12
|
private _eventStarted;
|
|
13
13
|
private _lastPoint;
|
|
14
|
-
private _savedPoint;
|
|
15
14
|
private _startPoint;
|
|
16
15
|
constructor();
|
|
17
16
|
activated(serviceContainer: ServiceContainer): void;
|
|
18
17
|
dispose(): void;
|
|
19
18
|
pointerEventHandler(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): void;
|
|
19
|
+
keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent, currentElement: Element): void;
|
|
20
20
|
}
|
|
@@ -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);
|
|
@@ -112,4 +120,5 @@ export class DrawPathTool {
|
|
|
112
120
|
break;
|
|
113
121
|
}
|
|
114
122
|
}
|
|
123
|
+
keyboardEventHandler(designerCanvas, event, currentElement) { }
|
|
115
124
|
}
|
|
@@ -15,4 +15,5 @@ export declare class DrawRectTool implements ITool {
|
|
|
15
15
|
activated(serviceContainer: ServiceContainer): void;
|
|
16
16
|
dispose(): void;
|
|
17
17
|
pointerEventHandler(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): void;
|
|
18
|
+
keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent, currentElement: Element): void;
|
|
18
19
|
}
|
|
@@ -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));
|
|
@@ -102,4 +103,5 @@ export class DrawRectTool {
|
|
|
102
103
|
break;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
106
|
+
keyboardEventHandler(designerCanvas, event, currentElement) { }
|
|
105
107
|
}
|
|
@@ -5,4 +5,5 @@ export interface ITool extends IDisposable {
|
|
|
5
5
|
readonly cursor: string;
|
|
6
6
|
activated(serviceContainer: ServiceContainer): any;
|
|
7
7
|
pointerEventHandler(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): any;
|
|
8
|
+
keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent, currentElement: Element): any;
|
|
8
9
|
}
|
|
@@ -6,6 +6,7 @@ export declare class MagicWandSelectorTool implements ITool {
|
|
|
6
6
|
private _pathD;
|
|
7
7
|
private _path;
|
|
8
8
|
pointerEventHandler(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): void;
|
|
9
|
+
keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent, currentElement: Element): void;
|
|
9
10
|
activated(serviceContainer: ServiceContainer): void;
|
|
10
11
|
dispose(): void;
|
|
11
12
|
}
|
|
@@ -4,6 +4,7 @@ import { ITool } from './ITool';
|
|
|
4
4
|
export declare class PanTool implements ITool {
|
|
5
5
|
readonly cursor: string;
|
|
6
6
|
pointerEventHandler(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): void;
|
|
7
|
+
keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent, currentElement: Element): void;
|
|
7
8
|
activated(serviceContainer: ServiceContainer): void;
|
|
8
9
|
dispose(): void;
|
|
9
10
|
}
|
|
@@ -5,5 +5,6 @@ export declare class PickColorTool implements ITool {
|
|
|
5
5
|
readonly cursor = "crosshair";
|
|
6
6
|
activated(serviceContainer: ServiceContainer): Promise<void>;
|
|
7
7
|
pointerEventHandler(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): Promise<void>;
|
|
8
|
+
keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent, currentElement: Element): void;
|
|
8
9
|
dispose(): void;
|
|
9
10
|
}
|
|
@@ -20,4 +20,5 @@ export declare class PointerTool implements ITool {
|
|
|
20
20
|
private _pointerActionTypeDrawSelection;
|
|
21
21
|
private _resetPointerEventsForClickThrough;
|
|
22
22
|
private _pointerActionTypeDragOrSelect;
|
|
23
|
+
keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent, currentElement: Element): void;
|
|
23
24
|
}
|
|
@@ -7,5 +7,6 @@ export declare class RectangleSelectorTool implements ITool {
|
|
|
7
7
|
private _initialPoint;
|
|
8
8
|
activated(serviceContainer: ServiceContainer): void;
|
|
9
9
|
pointerEventHandler(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): void;
|
|
10
|
+
keyboardEventHandler(designerCanvas: IDesignerCanvas, event: KeyboardEvent, currentElement: Element): void;
|
|
10
11
|
dispose(): void;
|
|
11
12
|
}
|