@node-projects/web-component-designer 0.0.117 → 0.0.119

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.
@@ -406,7 +406,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
406
406
  this.instanceServiceContainer.undoService.clear();
407
407
  this.overlayLayer.removeAllOverlays();
408
408
  DomHelper.removeAllChildnodes(this.overlayLayer);
409
- for (let i of this.rootDesignItem.children())
409
+ for (let i of [...this.rootDesignItem.children()])
410
410
  this.rootDesignItem._removeChildInternal(i);
411
411
  this.addDesignItems(designItems);
412
412
  this.instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'parsed' });
@@ -11,6 +11,9 @@ export class AltToEnterContainerExtension extends AbstractExtension {
11
11
  refresh() {
12
12
  let itemRect = this.designerCanvas.getNormalizedElementCoordinates(this.extendedItem.element);
13
13
  this._text = this._drawText("Press ALT to enter container", itemRect.x + 5, itemRect.y + 12, 'svg-text-enter-container', this._text, OverlayLayer.Foregorund);
14
+ this._text.style.fontSize = (14 / this.designerCanvas.scaleFactor) + 'px';
15
+ this._text.setAttribute('x', '' + (itemRect.x + 5 / this.designerCanvas.scaleFactor));
16
+ this._text.setAttribute('y', '' + (itemRect.y + 12 / this.designerCanvas.scaleFactor));
14
17
  }
15
18
  dispose() {
16
19
  this._removeAllOverlays();
@@ -8,6 +8,6 @@ export class AltToEnterContainerExtensionProvider {
8
8
  return new AltToEnterContainerExtension(extensionManager, designerView, designItem);
9
9
  }
10
10
  style = css `
11
- .svg-text-enter-container { stroke: none; fill: black; stroke-width: 1; font-size: 14px; font-weight:800; font-family: monospace; }
11
+ .svg-text-enter-container { stroke: none; fill: black; stroke-width: 1; font-weight:800; font-family: monospace; }
12
12
  `;
13
13
  }
@@ -16,19 +16,26 @@ export class ElementDragTitleExtension extends AbstractExtension {
16
16
  this._rect.addEventListener('pointerdown', (e) => this._pointerEvent(e));
17
17
  this._rect.addEventListener('pointermove', (e) => this._pointerEvent(e));
18
18
  this._rect.addEventListener('pointerup', (e) => this._pointerEvent(e));
19
+ this.refresh();
19
20
  }
20
21
  _drawMoveOverlay(itemRect) {
21
22
  }
22
23
  refresh() {
23
24
  const boundRect = this.extendedItem.element.getBoundingClientRect();
24
25
  const xr = (boundRect.x - this.designerCanvas.containerBoundingRect.x) / this.designerCanvas.scaleFactor;
25
- const yr = (boundRect.y - this.designerCanvas.containerBoundingRect.y) / this.designerCanvas.scaleFactor - 16;
26
+ const h = (15 / this.designerCanvas.scaleFactor);
27
+ const w = (60 / this.designerCanvas.scaleFactor);
28
+ const yr = (boundRect.y - this.designerCanvas.containerBoundingRect.y) / this.designerCanvas.scaleFactor - h;
26
29
  this._rect.setAttribute('x', xr);
27
30
  this._rect.setAttribute('y', yr);
31
+ this._rect.setAttribute('height', '' + h);
32
+ this._rect.setAttribute('width', '' + w);
33
+ this._rect.style.strokeWidth = (1 / this.designerCanvas.scaleFactor).toString();
28
34
  const x = (boundRect.x - this.designerCanvas.containerBoundingRect.x) / this.designerCanvas.scaleFactor;
29
- const y = (boundRect.y - this.designerCanvas.containerBoundingRect.y) / this.designerCanvas.scaleFactor - 5;
35
+ const y = (boundRect.y - this.designerCanvas.containerBoundingRect.y) / this.designerCanvas.scaleFactor - 5 / this.designerCanvas.scaleFactor;
30
36
  this._text.setAttribute('x', x);
31
37
  this._text.setAttribute('y', y);
38
+ this._text.style.fontSize = (10 / this.designerCanvas.scaleFactor) + 'px';
32
39
  }
33
40
  _pointerEvent(event) {
34
41
  event.preventDefault();
@@ -8,6 +8,6 @@ export class ElementDragTitleExtensionProvider {
8
8
  return new ElementDragTitleExtension(extensionManager, designerView, designItem);
9
9
  }
10
10
  style = css `
11
- .svg-text-primary { stroke: none; fill: white; stroke-width: 1; font-size: 10px; font-family: monospace; }
11
+ .svg-text-primary { stroke: none; fill: white; font-family: monospace; }
12
12
  `;
13
13
  }
@@ -26,6 +26,10 @@ export class PathExtension extends AbstractExtension {
26
26
  this._drawPathCircle(p.values[0], p.values[1], p, 0);
27
27
  this._lastPos = { x: p.values[0], y: p.values[1] };
28
28
  break;
29
+ case 'l':
30
+ this._drawPathCircle(p.values[0] + this._lastPos.x, p.values[1] + this._lastPos.y, p, 0);
31
+ this._lastPos = { x: p.values[0] + this._lastPos.x, y: p.values[1] + this._lastPos.y };
32
+ break;
29
33
  case 'H':
30
34
  break;
31
35
  case 'V':
@@ -7,6 +7,10 @@ export declare class PositionExtension extends AbstractExtension {
7
7
  private _line2;
8
8
  private _line3;
9
9
  private _line4;
10
+ private _rectX;
11
+ private _textX;
12
+ private _rectY;
13
+ private _textY;
10
14
  constructor(extensionManager: IExtensionManager, designerView: IDesignerCanvas, extendedItem: IDesignItem);
11
15
  extend(): void;
12
16
  refresh(): void;
@@ -4,6 +4,10 @@ export class PositionExtension extends AbstractExtension {
4
4
  _line2;
5
5
  _line3;
6
6
  _line4;
7
+ _rectX;
8
+ _textX;
9
+ _rectY;
10
+ _textY;
7
11
  constructor(extensionManager, designerView, extendedItem) {
8
12
  super(extensionManager, designerView, extendedItem);
9
13
  }
@@ -11,33 +15,28 @@ export class PositionExtension extends AbstractExtension {
11
15
  this.refresh();
12
16
  }
13
17
  refresh() {
14
- const computedStyle = getComputedStyle(this.extendedItem.element);
15
- let itemRect = this.extendedItem.element.getBoundingClientRect();
16
- const xOffset = itemRect.x - this.designerCanvas.containerBoundingRect.x;
17
- const yOffset = itemRect.y - this.designerCanvas.containerBoundingRect.y;
18
- let left = Number.parseFloat(computedStyle.left.replace('px', ''));
19
- if (isNaN(left))
20
- left = 0;
21
- let top = Number.parseFloat(computedStyle.top.replace('px', ''));
22
- if (isNaN(top))
23
- top = 0;
24
- let right = Number.parseFloat(computedStyle.right.replace('px', ''));
25
- if (isNaN(right))
26
- right = 0;
27
- let bottom = Number.parseFloat(computedStyle.bottom.replace('px', ''));
28
- if (isNaN(bottom))
29
- bottom = 0;
30
- let tx = 0;
31
- let ty = 0;
32
- if (computedStyle.transform !== 'none') {
33
- const transforms = computedStyle.transform.replace('matrix(', '').split(',');
34
- tx = Number.parseFloat(transforms[4]);
35
- ty = Number.parseFloat(transforms[5].replace(')', ''));
36
- }
37
- this._line1 = this._drawLine((xOffset / this.designerCanvas.scaleFactor - left - tx), (yOffset + itemRect.height / 2) / this.designerCanvas.scaleFactor, xOffset / this.designerCanvas.scaleFactor, (yOffset + itemRect.height / 2) / this.designerCanvas.scaleFactor, 'svg-position', this._line1);
38
- this._line2 = this._drawLine((xOffset + itemRect.width / 2) / this.designerCanvas.scaleFactor, (yOffset / this.designerCanvas.scaleFactor) - top - ty, (xOffset + itemRect.width / 2) / this.designerCanvas.scaleFactor, yOffset / this.designerCanvas.scaleFactor, 'svg-position', this._line2);
39
- this._line3 = this._drawLine((xOffset + itemRect.width) / this.designerCanvas.scaleFactor, (yOffset + itemRect.height / 2) / this.designerCanvas.scaleFactor, (xOffset + itemRect.width + right + -1 * tx) / this.designerCanvas.scaleFactor, (yOffset + itemRect.height / 2) / this.designerCanvas.scaleFactor, 'svg-position', this._line3);
40
- this._line4 = this._drawLine((xOffset + itemRect.width / 2) / this.designerCanvas.scaleFactor, (yOffset + itemRect.height) / this.designerCanvas.scaleFactor, (xOffset + itemRect.width / 2) / this.designerCanvas.scaleFactor, (yOffset + itemRect.height + bottom + -1 * ty) / this.designerCanvas.scaleFactor, 'svg-position', this._line4);
18
+ const itemRect = this.designerCanvas.getNormalizedElementCoordinates(this.extendedItem.element);
19
+ const itemParentRect = this.designerCanvas.getNormalizedElementCoordinates(this.extendedItem.element.parentElement);
20
+ this._line1 = this._drawLine(itemParentRect.x, itemRect.y + itemRect.height / 2, itemRect.x, itemRect.y + itemRect.height / 2, 'svg-position', this._line1);
21
+ this._line2 = this._drawLine(itemParentRect.x + itemParentRect.width, itemRect.y + itemRect.height / 2, itemRect.x + itemRect.width, itemRect.y + itemRect.height / 2, 'svg-position', this._line2);
22
+ this._line3 = this._drawLine(itemRect.x + itemRect.width / 2, itemParentRect.y, itemRect.x + itemRect.width / 2, itemRect.y, 'svg-position', this._line3);
23
+ this._line4 = this._drawLine(itemRect.x + itemRect.width / 2, itemParentRect.y + itemParentRect.height, itemRect.x + itemRect.width / 2, itemRect.y + itemRect.height, 'svg-position', this._line4);
24
+ this._line1.style.strokeWidth = '' + (1 / this.designerCanvas.scaleFactor);
25
+ this._line2.style.strokeWidth = '' + (1 / this.designerCanvas.scaleFactor);
26
+ this._line3.style.strokeWidth = '' + (1 / this.designerCanvas.scaleFactor);
27
+ this._line4.style.strokeWidth = '' + (1 / this.designerCanvas.scaleFactor);
28
+ this._line1.style.strokeDasharray = '' + (4 / this.designerCanvas.scaleFactor);
29
+ this._line2.style.strokeDasharray = '' + (4 / this.designerCanvas.scaleFactor);
30
+ this._line3.style.strokeDasharray = '' + (4 / this.designerCanvas.scaleFactor);
31
+ this._line4.style.strokeDasharray = '' + (4 / this.designerCanvas.scaleFactor);
32
+ let x = Math.round(itemRect.x - itemParentRect.x);
33
+ let y = Math.round(itemRect.y - itemParentRect.y);
34
+ this._rectX = this._drawRect(itemParentRect.x + x / 2 - 10, itemRect.y + itemRect.height / 2 - 8, 20, 16, 'svg-position-text-rect', this._rectX);
35
+ this._textX = this._drawText('' + x, itemParentRect.x + x / 2 - 9, itemRect.y + itemRect.height / 2 + 4, null, this._textX);
36
+ this._textX.style.fontSize = '12px';
37
+ this._rectY = this._drawRect(itemRect.x + itemRect.width / 2 - 10, itemParentRect.y + y / 2 - 8, 20, 16, 'svg-position-text-rect', this._rectY);
38
+ this._textY = this._drawText('' + y, itemRect.x + itemRect.width / 2 - 10, itemParentRect.y + y / 2 + 4, null, this._textY);
39
+ this._textY.style.fontSize = '12px';
41
40
  }
42
41
  dispose() {
43
42
  this._removeAllOverlays();
@@ -6,4 +6,5 @@ import { IExtensionManager } from "./IExtensionManger";
6
6
  export declare class PositionExtensionProvider implements IDesignerExtensionProvider {
7
7
  shouldExtend(extensionManager: IExtensionManager, designerView: IDesignerCanvas, designItem: IDesignItem): boolean;
8
8
  getExtension(extensionManager: IExtensionManager, designerView: IDesignerCanvas, designItem: IDesignItem): IDesignerExtension;
9
+ readonly style: CSSStyleSheet;
9
10
  }
@@ -1,4 +1,5 @@
1
1
  import { PositionExtension } from "./PositionExtension";
2
+ import { css } from "@node-projects/base-custom-webcomponent";
2
3
  export class PositionExtensionProvider {
3
4
  shouldExtend(extensionManager, designerView, designItem) {
4
5
  const cs = getComputedStyle(designItem.element);
@@ -9,4 +10,7 @@ export class PositionExtensionProvider {
9
10
  getExtension(extensionManager, designerView, designItem) {
10
11
  return new PositionExtension(extensionManager, designerView, designItem);
11
12
  }
13
+ style = css `
14
+ .svg-position-text-rect { fill: white; }
15
+ `;
12
16
  }
@@ -1,7 +1,7 @@
1
1
  import { CommandType } from "../../../../../commandHandling/CommandType";
2
2
  export class RotateLeftAndRight {
3
3
  shouldProvideContextmenu(event, designerView, designItem, initiator) {
4
- return true;
4
+ return !designItem.isRootItem;
5
5
  }
6
6
  provideContextMenuItems(event, designerView, designItem) {
7
7
  return [
@@ -1,7 +1,7 @@
1
1
  import { CommandType } from "../../../../../commandHandling/CommandType";
2
2
  export class ZMoveContextMenu {
3
3
  shouldProvideContextmenu(event, designerView, designItem, initiator) {
4
- return true;
4
+ return !designItem.isRootItem;
5
5
  }
6
6
  provideContextMenuItems(event, designerView, designItem) {
7
7
  return [
@@ -13,6 +13,8 @@ export class MagicWandSelectorTool {
13
13
  designerCanvas.captureActiveTool(this);
14
14
  this._path = document.createElementNS("http://www.w3.org/2000/svg", "path");
15
15
  this._path.setAttribute('class', 'svg-selector');
16
+ this._path.style.strokeWidth = '' + (1 / designerCanvas.scaleFactor);
17
+ this._path.style.strokeDasharray = '' + (2 / designerCanvas.scaleFactor);
16
18
  this._pathD = "M" + currentPoint.x + " " + currentPoint.y;
17
19
  this._path.setAttribute("D", this._pathD);
18
20
  designerCanvas.overlayLayer.addOverlay(this._path, OverlayLayer.Foregorund);
@@ -31,7 +31,8 @@ export class PointerTool {
31
31
  return;
32
32
  }
33
33
  }
34
- const designItem = DesignItem.GetOrCreateDesignItem(event.target, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
34
+ let newEl = designerCanvas.serviceContainer.elementAtPointService.getElementAtPoint(designerCanvas, { x: event.x, y: event.y });
35
+ const designItem = DesignItem.GetOrCreateDesignItem(newEl, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
35
36
  if (!designerCanvas.instanceServiceContainer.selectionService.isSelected(designItem)) {
36
37
  designerCanvas.instanceServiceContainer.selectionService.setSelectedElements([designItem]);
37
38
  }
@@ -21,6 +21,8 @@ export class RectangleSelectorTool {
21
21
  this._rect.setAttribute('y', (this._initialPoint.y * designerCanvas.scaleFactor));
22
22
  this._rect.setAttribute('width', 0);
23
23
  this._rect.setAttribute('height', 0);
24
+ this._rect.style.strokeWidth = '' + (1 / designerCanvas.scaleFactor);
25
+ this._rect.style.strokeDasharray = '' + (2 / designerCanvas.scaleFactor);
24
26
  designerCanvas.overlayLayer.addOverlay(this._rect, OverlayLayer.Foregorund);
25
27
  break;
26
28
  case EventNames.PointerMove:
@@ -20,6 +20,8 @@ export class ZoomTool {
20
20
  this._rect.setAttribute('y', (this._startPoint.y * designerCanvas.zoomFactor));
21
21
  this._rect.setAttribute('width', 0);
22
22
  this._rect.setAttribute('height', 0);
23
+ this._rect.style.strokeWidth = '' + (1 / designerCanvas.scaleFactor);
24
+ this._rect.style.strokeDasharray = '' + (2 / designerCanvas.scaleFactor);
23
25
  designerCanvas.overlayLayer.addOverlay(this._rect, OverlayLayer.Foregorund);
24
26
  break;
25
27
  case EventNames.PointerMove:
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.117",
4
+ "version": "0.0.119",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",
@@ -19,20 +19,20 @@
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
- "@papyrs/stylo": "^0.0.37",
22
+ "@papyrs/stylo": "^0.0.39",
23
23
  "@types/codemirror": "^5.60.5",
24
24
  "@types/jquery": "^3.5.14",
25
25
  "@types/jquery.fancytree": "0.0.7",
26
- "ace-builds": "^1.9.6",
26
+ "ace-builds": "^1.11.2",
27
27
  "codemirror": "^6.0.1",
28
- "esprima-next": "^5.8.3",
28
+ "esprima-next": "^5.8.4",
29
29
  "html2canvas": "*",
30
- "jest": "^28.0.8",
30
+ "jest": "^29.1.1",
31
31
  "jquery": "^3.6.1",
32
32
  "jquery.fancytree": "^2.38.2",
33
33
  "monaco-editor": "^0.34.0",
34
- "ts-jest": "^28.0.8",
35
- "typescript": "^4.8.2",
34
+ "ts-jest": "^29.0.2",
35
+ "typescript": "^4.8.4",
36
36
  "typescript-lit-html-plugin": "^0.9.0"
37
37
  },
38
38
  "repository": {