@node-projects/web-component-designer 0.0.77 → 0.0.81

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.
Files changed (63) hide show
  1. package/.github/FUNDING.yml +1 -0
  2. package/dist/elements/documentContainer.js +2 -2
  3. package/dist/elements/helper/ElementHelper.d.ts +6 -0
  4. package/dist/elements/helper/ElementHelper.js +10 -0
  5. package/dist/elements/helper/PathDataPolyfill.d.ts +11 -10
  6. package/dist/elements/helper/PathDataPolyfill.js +36 -1
  7. package/dist/elements/services/DefaultServiceBootstrap.js +6 -2
  8. package/dist/elements/services/ServiceContainer.d.ts +1 -1
  9. package/dist/elements/services/ServiceContainer.js +2 -2
  10. package/dist/elements/services/demoProviderService/DemoProviderService.d.ts +1 -1
  11. package/dist/elements/services/demoProviderService/DemoProviderService.js +2 -1
  12. package/dist/elements/services/demoProviderService/IDemoProviderService.d.ts +1 -1
  13. package/dist/elements/services/htmlWriterService/AbstractHtmlWriterService.d.ts +10 -0
  14. package/dist/elements/services/htmlWriterService/AbstractHtmlWriterService.js +62 -0
  15. package/dist/elements/services/htmlWriterService/FormatingHtmlWriterService.d.ts +22 -0
  16. package/dist/elements/services/htmlWriterService/FormatingHtmlWriterService.js +133 -0
  17. package/dist/elements/services/htmlWriterService/HtmlWriterService copy.d.ts +2 -2
  18. package/dist/elements/services/htmlWriterService/HtmlWriterService copy.js +34 -19
  19. package/dist/elements/services/htmlWriterService/HtmlWriterService.d.ts +8 -8
  20. package/dist/elements/services/htmlWriterService/HtmlWriterService.js +13 -42
  21. package/dist/elements/services/htmlWriterService/IHtmlWriterOptions.d.ts +2 -0
  22. package/dist/elements/services/htmlWriterService/IHtmlWriterOptions.js +5 -3
  23. package/dist/elements/services/htmlWriterService/IHtmlWriterService.d.ts +5 -6
  24. package/dist/elements/services/htmlWriterService/LitTsElementWriterService.d.ts +9 -0
  25. package/dist/elements/services/htmlWriterService/LitTsElementWriterService.js +43 -0
  26. package/dist/elements/services/htmlWriterService/SimpleHtmlWriterService.d.ts +27 -0
  27. package/dist/elements/services/htmlWriterService/SimpleHtmlWriterService.js +93 -0
  28. package/dist/elements/services/initializationService/DefaultIntializationService.d.ts +6 -0
  29. package/dist/elements/services/initializationService/DefaultIntializationService.js +22 -0
  30. package/dist/elements/services/manifestParsers/WebcomponentManifestParserService.d.ts +3 -1
  31. package/dist/elements/services/manifestParsers/WebcomponentManifestParserService.js +42 -28
  32. package/dist/elements/widgets/codeView/code-view-ace.js +1 -1
  33. package/dist/elements/widgets/codeView/code-view-code-mirror.js +1 -1
  34. package/dist/elements/widgets/demoView/IDemoView.d.ts +1 -1
  35. package/dist/elements/widgets/demoView/demoView.d.ts +1 -1
  36. package/dist/elements/widgets/demoView/demoView.js +2 -2
  37. package/dist/elements/widgets/designerView/DomConverter.d.ts +3 -3
  38. package/dist/elements/widgets/designerView/DomConverter.js +8 -11
  39. package/dist/elements/widgets/designerView/extensions/PathExtension.d.ts +0 -1
  40. package/dist/elements/widgets/designerView/extensions/PathExtension.js +100 -12
  41. package/dist/elements/widgets/designerView/extensions/contextMenu/CopyPasteContextMenu.js +0 -1
  42. package/dist/elements/widgets/designerView/extensions/contextMenu/PathContextMenu.d.ts +8 -0
  43. package/dist/elements/widgets/designerView/extensions/contextMenu/PathContextMenu.js +31 -0
  44. package/dist/elements/widgets/designerView/extensions/contextMenu/RectContextMenu.d.ts +8 -0
  45. package/dist/elements/widgets/designerView/extensions/contextMenu/RectContextMenu.js +34 -0
  46. package/dist/elements/widgets/designerView/overlayLayerView.js +1 -2
  47. package/dist/elements/widgets/designerView/tools/DrawEllipsisTool.js +1 -0
  48. package/dist/elements/widgets/designerView/tools/DrawLineTool.js +1 -0
  49. package/dist/elements/widgets/designerView/tools/DrawPathTool.d.ts +0 -1
  50. package/dist/elements/widgets/designerView/tools/DrawPathTool.js +17 -9
  51. package/dist/elements/widgets/designerView/tools/DrawRectTool.js +1 -0
  52. package/dist/elements/widgets/treeView/treeViewExtended.js +1 -0
  53. package/dist/index.d.ts +4 -0
  54. package/dist/index.js +4 -0
  55. package/package.json +7 -7
  56. package/dist/elements/services/htmlWriterService/LitElementWriterService.d.ts +0 -12
  57. package/dist/elements/services/htmlWriterService/LitElementWriterService.js +0 -107
  58. package/dist/elements/services/manifestLoaders/WebcomponentManifestParserService.d.ts +0 -26
  59. package/dist/elements/services/manifestLoaders/WebcomponentManifestParserService.js +0 -69
  60. package/dist/elements/services/webcomponentManifestParserService/WebcomponentManifestParserService.1.d.ts +0 -0
  61. package/dist/elements/services/webcomponentManifestParserService/WebcomponentManifestParserService.1.js +0 -1
  62. package/dist/elements/services/webcomponentManifestParserService/webcomponentManifestParserService.d.ts +0 -26
  63. 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: true });
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;
@@ -56,6 +59,8 @@ export class PathExtension extends AbstractExtension {
56
59
  case 'Q':
57
60
  this._drawPathCircle(p.values[0], p.values[1], p, 0);
58
61
  this._drawPathCircle(p.values[2], p.values[3], p, 2);
62
+ this._drawPathLine(this._lastPos.x, this._lastPos.y, p.values[0], p.values[1]);
63
+ this._drawPathLine(p.values[0], p.values[1], p.values[2], p.values[3]);
59
64
  break;
60
65
  case 'T':
61
66
  this._drawPathCircle(p.values[0], p.values[1], p, 0);
@@ -83,9 +88,27 @@ export class PathExtension extends AbstractExtension {
83
88
  const cy = event.y - this._lastPos.y + this._circlePos.y;
84
89
  const dx = cx - this._circlePos.x;
85
90
  const dy = cy - this._circlePos.y;
86
- p.values[index] = this._originalPathPoint.x + dx;
87
- p.values[index + 1] = this._originalPathPoint.y + dy;
88
- this._drawPath(this._pathdata, index);
91
+ if (event.shiftKey) {
92
+ if (Math.abs(dx) >= Math.abs(dy)) {
93
+ p.values[index] = this._originalPathPoint.x + dx;
94
+ circle.setAttribute("cx", (this._circlePos.x + dx).toString());
95
+ p.values[index + 1] = this._originalPathPoint.y;
96
+ circle.setAttribute("cy", (this._circlePos.y).toString());
97
+ }
98
+ else {
99
+ p.values[index] = this._originalPathPoint.x;
100
+ circle.setAttribute("cx", (this._circlePos.x).toString());
101
+ p.values[index + 1] = this._originalPathPoint.y + dy;
102
+ circle.setAttribute("cy", (this._circlePos.y + dy).toString());
103
+ }
104
+ }
105
+ else {
106
+ p.values[index] = this._originalPathPoint.x + dx;
107
+ p.values[index + 1] = this._originalPathPoint.y + dy;
108
+ circle.setAttribute("cx", (this._circlePos.x + dx).toString());
109
+ circle.setAttribute("cy", (this._circlePos.y + dy).toString());
110
+ }
111
+ this.extendedItem.element.setAttribute("d", createPathD(this._pathdata));
89
112
  }
90
113
  break;
91
114
  case EventNames.PointerUp:
@@ -93,21 +116,86 @@ export class PathExtension extends AbstractExtension {
93
116
  this._startPos = null;
94
117
  this._circlePos = null;
95
118
  this._lastPos = null;
119
+ this.extendedItem.setAttribute('d', createPathD(this._pathdata));
96
120
  break;
97
121
  }
98
122
  }
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
123
  _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, 3, 'svg-path');
124
+ const items = [];
125
+ const pidx = this._pathdata.indexOf(p);
126
+ items.push({
127
+ title: 'delete point', action: () => {
128
+ this._pathdata.splice(pidx, 1);
129
+ if (pidx == 0)
130
+ this._pathdata[0].type = 'M';
131
+ this.extendedItem.setAttribute('d', createPathD(this._pathdata));
132
+ }
133
+ });
134
+ items.push({
135
+ title: 'insert point after', action: () => {
136
+ const l = { type: 'L', values: [p.values[0], p.values[1]] };
137
+ this._pathdata.splice(pidx + 1, 0, l);
138
+ this.extendedItem.setAttribute('d', createPathD(this._pathdata));
139
+ }
140
+ });
141
+ if (pidx != 0) {
142
+ items.push({
143
+ title: 'convert to quadratic bézier', action: () => {
144
+ const p1x = this._pathdata[pidx - 1].values[0];
145
+ const p1y = this._pathdata[pidx - 1].values[1];
146
+ const p2x = this._pathdata[pidx].values[0];
147
+ const p2y = this._pathdata[pidx].values[1];
148
+ const mpx = (p2x + p1x) * 0.5;
149
+ const mpy = (p2y + p1y) * 0.5;
150
+ const theta = Math.atan2(p2y - p1y, p2x - p1x) - Math.PI / 2;
151
+ const offset = 50;
152
+ const c1x = mpx + offset * Math.cos(theta);
153
+ const c1y = mpy + offset * Math.sin(theta);
154
+ this._pathdata[pidx].type = 'Q';
155
+ this._pathdata[pidx].values[0] = c1x;
156
+ this._pathdata[pidx].values[1] = c1y;
157
+ this._pathdata[pidx].values[2] = p2x;
158
+ this._pathdata[pidx].values[3] = p2y;
159
+ this.extendedItem.setAttribute('d', createPathD(this._pathdata));
160
+ }
161
+ });
162
+ }
163
+ if (pidx != 0) {
164
+ items.push({
165
+ title: 'convert to cubic bézier', action: () => {
166
+ const p1x = this._pathdata[pidx - 1].values[0];
167
+ const p1y = this._pathdata[pidx - 1].values[1];
168
+ const p2x = this._pathdata[pidx].values[0];
169
+ const p2y = this._pathdata[pidx].values[1];
170
+ const mpx = (p2x + p1x) * 0.5;
171
+ const mpy = (p2y + p1y) * 0.5;
172
+ const theta = Math.atan2(p2y - p1y, p2x - p1x) - Math.PI / 2;
173
+ const offset = 50;
174
+ let c1x = mpx + offset * Math.cos(theta);
175
+ let c1y = mpy + offset * Math.sin(theta);
176
+ c1x = p.values[0] + 2 * (p1x - p.values[0]) / 3;
177
+ c1y = p.values[1] + 2 * (p1y - p.values[1]) / 3;
178
+ const c2x = x + 2 * (p1x - x) / 3;
179
+ const c2y = y + 2 * (p1y - y) / 3;
180
+ this._pathdata[pidx].type = 'C';
181
+ this._pathdata[pidx].values[0] = c1x;
182
+ this._pathdata[pidx].values[1] = c1y;
183
+ this._pathdata[pidx].values[2] = c2x;
184
+ this._pathdata[pidx].values[3] = c2y;
185
+ this._pathdata[pidx].values[4] = p2x;
186
+ this._pathdata[pidx].values[5] = p2y;
187
+ this.extendedItem.setAttribute('d', createPathD(this._pathdata));
188
+ }
189
+ });
190
+ }
191
+ let circle = this._drawCircle(this._parentRect.x - this.designerCanvas.containerBoundingRect.x + x, this._parentRect.y - this.designerCanvas.containerBoundingRect.y + y, 5, 'svg-path');
108
192
  circle.addEventListener(EventNames.PointerDown, event => this.pointerEvent(event, circle, p, index));
109
193
  circle.addEventListener(EventNames.PointerMove, event => this.pointerEvent(event, circle, p, index));
110
194
  circle.addEventListener(EventNames.PointerUp, event => this.pointerEvent(event, circle, p, index));
195
+ circle.addEventListener(EventNames.ContextMenu, event => {
196
+ event.preventDefault();
197
+ ContextMenuHelper.showContextMenu(null, event, null, items);
198
+ });
111
199
  }
112
200
  _drawPathLine(x1, y1, x2, y2) {
113
201
  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
- if (element)
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));
@@ -11,7 +11,6 @@ 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;
@@ -12,9 +12,8 @@ export class DrawPathTool {
12
12
  _dragMode = false;
13
13
  _pointerMoved = false;
14
14
  _eventStarted = false;
15
- _lastPoint = { x: 0, y: 0 };
16
- _savedPoint = { x: 0, y: 0 };
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 = currentPoint;
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._savedPoint, currentPoint);
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._savedPoint, currentPoint);
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));
@@ -59,6 +59,7 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
59
59
  background: #ffffffc9;
60
60
  width: 70px;
61
61
  justify-content: flex-end;
62
+ background: white;
62
63
  }
63
64
 
64
65
  table.fancytree-ext-table tbody tr.fancytree-selected {
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.77",
4
+ "version": "0.0.81",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",
@@ -13,25 +13,25 @@
13
13
  "prepublishOnly": "npm run build"
14
14
  },
15
15
  "dependencies": {
16
- "@node-projects/base-custom-webcomponent": "^0.4.0",
16
+ "@node-projects/base-custom-webcomponent": "^0.4.1",
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.11",
23
+ "@types/jquery": "^3.5.13",
24
24
  "@types/jquery.fancytree": "0.0.7",
25
25
  "ace-builds": "^1.4.13",
26
26
  "codemirror": "^5.65.0",
27
27
  "custom-elements-manifest": "^1.0.0",
28
- "esprima-next": "^5.7.0",
28
+ "esprima-next": "^5.8.1",
29
29
  "html2canvas": "*",
30
- "jest": "^27.4.5",
30
+ "jest": "^27.4.7",
31
31
  "jquery": "^3.6.0",
32
- "jquery.fancytree": "^2.38.0",
32
+ "jquery.fancytree": "^2.38.1",
33
33
  "monaco-editor": "^0.31.1",
34
- "ts-jest": "^27.1.2",
34
+ "ts-jest": "^27.1.3",
35
35
  "typescript": "^4.5.4",
36
36
  "typescript-lit-html-plugin": "^0.9.0"
37
37
  },
@@ -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
- }