@node-projects/web-component-designer 0.0.36 → 0.0.37

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.
@@ -1 +1,82 @@
1
- <svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 13 13"><g clip-path="url(#clip0)"><rect x="2" y="2.816" width="4.607" height="2.738" rx=".5" stroke="#000"/><rect x="1.5" y="6.989" width="5.607" height="3.738" rx="1" fill="#000"/><path d="M9.461 1.5v7.63H8L10.002 12 12 9.13h-1.458V1.5h-1.08z" fill="#000"/></g><defs><clipPath id="clip0"><path fill="#fff" d="M0 0h13v13H0z"/></clipPath></defs></svg>
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
4
+ xmlns:cc="http://creativecommons.org/ns#"
5
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6
+ xmlns:svg="http://www.w3.org/2000/svg"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10
+ fill="none"
11
+ viewBox="0 0 13 13"
12
+ version="1.1"
13
+ id="svg15"
14
+ sodipodi:docname="flex-direction-row-icon.svg"
15
+ inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
16
+ <metadata
17
+ id="metadata19">
18
+ <rdf:RDF>
19
+ <cc:Work
20
+ rdf:about="">
21
+ <dc:format>image/svg+xml</dc:format>
22
+ <dc:type
23
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
24
+ </cc:Work>
25
+ </rdf:RDF>
26
+ </metadata>
27
+ <sodipodi:namedview
28
+ pagecolor="#ffffff"
29
+ bordercolor="#666666"
30
+ borderopacity="1"
31
+ objecttolerance="10"
32
+ gridtolerance="10"
33
+ guidetolerance="10"
34
+ inkscape:pageopacity="0"
35
+ inkscape:pageshadow="2"
36
+ inkscape:window-width="1680"
37
+ inkscape:window-height="987"
38
+ id="namedview17"
39
+ showgrid="false"
40
+ inkscape:zoom="63.076923"
41
+ inkscape:cx="6.5"
42
+ inkscape:cy="6.5"
43
+ inkscape:window-x="-8"
44
+ inkscape:window-y="-8"
45
+ inkscape:window-maximized="1"
46
+ inkscape:current-layer="svg15" />
47
+ <g
48
+ clip-path="url(#clip0)"
49
+ id="g8"
50
+ transform="matrix(0,1,1,0,0,0)">
51
+ <rect
52
+ x="2"
53
+ y="2.816"
54
+ width="4.6069999"
55
+ height="2.7379999"
56
+ rx="0.5"
57
+ stroke="#000000"
58
+ id="rect2" />
59
+ <rect
60
+ x="1.5"
61
+ y="6.9889998"
62
+ width="5.6069999"
63
+ height="3.7379999"
64
+ rx="1"
65
+ fill="#000000"
66
+ id="rect4" />
67
+ <path
68
+ d="M 9.461,1.5 V 9.13 H 8 L 10.002,12 12,9.13 H 10.542 V 1.5 h -1.08 z"
69
+ fill="#000000"
70
+ id="path6" />
71
+ </g>
72
+ <defs
73
+ id="defs13">
74
+ <clipPath
75
+ id="clip0">
76
+ <path
77
+ fill="#fff"
78
+ d="M0 0h13v13H0z"
79
+ id="path10" />
80
+ </clipPath>
81
+ </defs>
82
+ </svg>
@@ -21,6 +21,7 @@ export declare class DesignItem implements IDesignItem {
21
21
  get name(): string;
22
22
  get id(): string;
23
23
  set id(value: string);
24
+ get isRootItem(): boolean;
24
25
  private _childArray;
25
26
  get hasChildren(): boolean;
26
27
  children(): IterableIterator<IDesignItem>;
@@ -44,6 +44,9 @@ export class DesignItem {
44
44
  set id(value) {
45
45
  this.element.id = value;
46
46
  }
47
+ get isRootItem() {
48
+ return this.instanceServiceContainer.contentService.rootDesignItem === this;
49
+ }
47
50
  _childArray = [];
48
51
  get hasChildren() {
49
52
  return this._childArray.length > 0;
@@ -9,6 +9,7 @@ export interface IDesignItem {
9
9
  readonly nodeType: NodeType;
10
10
  readonly name: string;
11
11
  readonly id: string;
12
+ readonly isRootItem: boolean;
12
13
  readonly hasAttributes: boolean;
13
14
  readonly attributes: Map<string, string>;
14
15
  readonly hasStyles: boolean;
@@ -11,6 +11,6 @@ export class NumberPropertyEditor extends BasePropertyEditor {
11
11
  this.element = element;
12
12
  }
13
13
  refreshValue(valueType, value) {
14
- this.element.value = value;
14
+ this.element.value = value === undefined ? null : value;
15
15
  }
16
16
  }
@@ -115,6 +115,11 @@ export class CssPropertiesService {
115
115
  type: "list",
116
116
  values: ["block", "inline-block", "flex", "contents", "grid", "inherit", "initial", "none"],
117
117
  service: this
118
+ }, {
119
+ name: "position",
120
+ type: "list",
121
+ values: ["static", "relative", "absolute"],
122
+ service: this
118
123
  }, {
119
124
  name: "grid-template-columns",
120
125
  type: "string",
@@ -160,6 +165,11 @@ export class CssPropertiesService {
160
165
  type: "list",
161
166
  values: ["block", "inline-block", "flex", "contents", "grid", "inherit", "initial", "none"],
162
167
  service: this
168
+ }, {
169
+ name: "position",
170
+ type: "list",
171
+ values: ["static", "relative", "absolute"],
172
+ service: this
163
173
  }, {
164
174
  name: "flex-direction",
165
175
  type: "img-list",
@@ -22,6 +22,7 @@ export interface IDesignerCanvas extends IPlacementView, IUiCommandHandler {
22
22
  eatEvents: Element;
23
23
  initialize(serviceContainer: ServiceContainer): any;
24
24
  getNormalizedEventCoordinates(event: MouseEvent): IPoint;
25
+ getNormalizedOffsetInElement(event: MouseEvent, element: Element): IPoint;
25
26
  getElementAtPoint(point: IPoint, ignoreElementCallback?: (element: HTMLElement) => boolean): any;
26
27
  elementFromPoint(x: number, y: number): Element;
27
28
  }
@@ -70,6 +70,8 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
70
70
  private onKeyUp;
71
71
  private onKeyDown;
72
72
  getNormalizedEventCoordinates(event: MouseEvent): IPoint;
73
+ getNormalizedElementCoordinates(element: Element): IPoint;
74
+ getNormalizedOffsetInElement(event: MouseEvent, element: Element): IPoint;
73
75
  static getHost(node: Node): Element;
74
76
  getElementAtPoint(point: IPoint, ignoreElementCallback?: (element: HTMLElement) => boolean): HTMLElement;
75
77
  _rect: SVGRectElement;
@@ -486,6 +486,15 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
486
486
  y: offsetOfOuterY - offsetOfCanvasY
487
487
  };
488
488
  }
489
+ getNormalizedElementCoordinates(element) {
490
+ const targetRect = element.getBoundingClientRect();
491
+ return { x: targetRect.x - this.containerBoundingRect.x, y: targetRect.y - this.containerBoundingRect.y };
492
+ }
493
+ getNormalizedOffsetInElement(event, element) {
494
+ const normEvt = this.getNormalizedEventCoordinates(event);
495
+ const normEl = this.getNormalizedElementCoordinates(element);
496
+ return { x: normEvt.x - normEl.x, y: normEvt.y - normEl.y };
497
+ }
489
498
  //todo remove, is in base custom webcomp domhelper
490
499
  static getHost(node) {
491
500
  while (node.parentElement)
@@ -40,11 +40,7 @@ export class PointerTool {
40
40
  const currentDesignItem = DesignItem.GetOrCreateDesignItem(currentElement, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
41
41
  if (this._actionType == null) {
42
42
  this._initialPoint = currentPoint;
43
- const targetRect = currentElement.getBoundingClientRect();
44
- this._initialOffset = {
45
- x: event.x - targetRect.x,
46
- y: event.y - targetRect.y
47
- };
43
+ this._initialOffset = designerCanvas.getNormalizedOffsetInElement(event, currentElement);
48
44
  if (event.type == EventNames.PointerDown) {
49
45
  this._actionStartedDesignItem = currentDesignItem;
50
46
  designerCanvas.snapLines.clearSnaplines();
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.36",
4
+ "version": "0.0.37",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",