@node-projects/web-component-designer 0.1.106 → 0.1.107

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 (27) hide show
  1. package/dist/elements/documentContainer.js +3 -1
  2. package/dist/elements/services/propertiesService/PropertyGroupsService.d.ts +4 -0
  3. package/dist/elements/services/propertiesService/PropertyGroupsService.js +10 -1
  4. package/dist/elements/services/propertiesService/services/AttributesPropertiesService.js +1 -1
  5. package/dist/elements/services/propertiesService/services/CommonPropertiesService.js +1 -1
  6. package/dist/elements/services/selectionService/SelectionService.js +4 -3
  7. package/dist/elements/widgets/designerView/designerCanvas.js +5 -7
  8. package/dist/elements/widgets/designerView/extensions/AbstractExtension.js +2 -0
  9. package/dist/elements/widgets/designerView/extensions/EditText/EditTextExtension.d.ts +1 -0
  10. package/dist/elements/widgets/designerView/extensions/EditText/EditTextExtension.js +7 -0
  11. package/dist/elements/widgets/designerView/extensions/ElementDragTitleExtensionProvider.js +1 -1
  12. package/dist/elements/widgets/designerView/extensions/ExtensionManager.d.ts +1 -1
  13. package/dist/elements/widgets/designerView/extensions/ExtensionManager.js +16 -10
  14. package/dist/elements/widgets/designerView/extensions/IExtensionManger.d.ts +1 -1
  15. package/dist/elements/widgets/designerView/extensions/MultipleSelectionRectExtensionProvider.js +1 -1
  16. package/dist/elements/widgets/designerView/extensions/PositionExtensionProvider.js +2 -0
  17. package/dist/elements/widgets/designerView/extensions/ResizeExtensionProvider.js +1 -1
  18. package/dist/elements/widgets/designerView/extensions/RotateExtensionProvider.js +1 -1
  19. package/dist/elements/widgets/designerView/extensions/SelectionDefaultExtensionProvider.js +1 -1
  20. package/dist/elements/widgets/designerView/extensions/TransformOriginExtensionProvider.js +1 -1
  21. package/dist/elements/widgets/designerView/extensions/block/BlockToolbarExtension.js +1 -1
  22. package/dist/elements/widgets/designerView/extensions/flex/FlexToolbarExtension.js +1 -1
  23. package/dist/elements/widgets/designerView/extensions/grid/GridToolbarExtension.js +1 -1
  24. package/dist/elements/widgets/designerView/tools/PointerTool.js +2 -2
  25. package/dist/elements/widgets/designerView/tools/RectangleSelectorTool.js +1 -1
  26. package/dist/elements/widgets/propertyGrid/PropertyGridWithHeader.js +44 -28
  27. package/package.json +1 -1
@@ -3,6 +3,7 @@ import { DesignerTabControl } from './controls/DesignerTabControl.js';
3
3
  import { DesignerView } from './widgets/designerView/designerView.js';
4
4
  import { SimpleSplitView } from './controls/SimpleSplitView.js';
5
5
  import { sleep } from "./helper/Helper.js";
6
+ import { ExtensionType } from "./widgets/designerView/extensions/ExtensionType.js";
6
7
  export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
7
8
  designerView;
8
9
  codeView;
@@ -253,7 +254,8 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
253
254
  return this.designerView.parseHTML(this._content, this._firstLoad);
254
255
  else {
255
256
  this.instanceServiceContainer.undoService.clearTransactionstackIfNotEmpty();
256
- this.designerView.designerCanvas.extensionManager.refreshAllAppliedExtentions();
257
+ this.designerView.designerCanvas.overlayLayer.removeAllOverlays();
258
+ this.designerView.designerCanvas.extensionManager.reapplyAllAppliedExtentions(null, [ExtensionType.Permanent, ExtensionType.Selection, ExtensionType.PrimarySelection, ExtensionType.PrimarySelectionContainer]);
257
259
  }
258
260
  }
259
261
  }
@@ -4,6 +4,10 @@ import { IPropertyGroupsService } from './IPropertyGroupsService.js';
4
4
  import { AttachedPropertiesService } from './services/AttachedPropertiesService.js';
5
5
  export declare class PropertyGroupsService implements IPropertyGroupsService {
6
6
  protected _attachedPropertiesService: AttachedPropertiesService;
7
+ protected _rootPgList: {
8
+ name: string;
9
+ propertiesService: IPropertiesService;
10
+ }[];
7
11
  protected _pgList: {
8
12
  name: string;
9
13
  propertiesService: IPropertiesService;
@@ -7,6 +7,13 @@ import { CssCustomPropertiesService } from './services/CssCustomPropertiesServic
7
7
  import { CssPropertiesService } from './services/CssPropertiesService.js';
8
8
  export class PropertyGroupsService {
9
9
  _attachedPropertiesService = new AttachedPropertiesService();
10
+ _rootPgList = [
11
+ { name: 'styles', propertiesService: new CssCurrentPropertiesService() },
12
+ { name: 'css vars', propertiesService: new CssCustomPropertiesService() },
13
+ { name: 'layout', propertiesService: new CssPropertiesService("layout") },
14
+ { name: 'flex', propertiesService: new CssPropertiesService("flex") },
15
+ { name: 'grid', propertiesService: new CssPropertiesService("grid") },
16
+ ];
10
17
  _pgList = [
11
18
  { name: 'properties', propertiesService: null },
12
19
  { name: 'attached', propertiesService: this._attachedPropertiesService },
@@ -39,6 +46,8 @@ export class PropertyGroupsService {
39
46
  return [];
40
47
  if (designItems[0].nodeType == NodeType.TextNode || designItems[0].nodeType == NodeType.Comment)
41
48
  return [];
49
+ if (designItems[0].isRootItem)
50
+ return this._rootPgList;
42
51
  this._pgList[0].propertiesService = designItems[0].serviceContainer.getLastServiceWhere('propertyService', x => x.isHandledElement(designItems[0]));
43
52
  this._svgPgList[0].propertiesService = designItems[0].serviceContainer.getLastServiceWhere('propertyService', x => x.isHandledElement(designItems[0]));
44
53
  let lst = this._pgList;
@@ -51,6 +60,6 @@ export class PropertyGroupsService {
51
60
  else if (parentStyle.display.includes('flex'))
52
61
  lst = [...lst, this._flexChild[0]];
53
62
  }
54
- return lst;
63
+ return lst; //.filter(x => x.propertiesService.isHandledElement(designItems[0]));
55
64
  }
56
65
  }
@@ -9,7 +9,7 @@ export class AttributesPropertiesService {
9
9
  return RefreshMode.fullOnValueChange;
10
10
  }
11
11
  isHandledElement(designItem) {
12
- return true;
12
+ return !designItem.isRootItem;
13
13
  }
14
14
  getProperty(designItem, name) {
15
15
  return { name: name, type: 'string', service: this, propertyType: PropertyType.attribute };
@@ -38,7 +38,7 @@ export class CommonPropertiesService extends AbstractPropertiesService {
38
38
  ];
39
39
  name = "common";
40
40
  isHandledElement(designItem) {
41
- return true;
41
+ return !designItem.isRootItem;
42
42
  }
43
43
  getProperty(designItem, name) {
44
44
  return this.commonProperties.find(x => x.name == name);
@@ -1,6 +1,5 @@
1
1
  import { TypedEvent } from '@node-projects/base-custom-webcomponent';
2
2
  import { SelectionChangedAction } from '../undoService/transactionItems/SelectionChangedAction.js';
3
- import { arraysEqual } from '../../helper/Helper.js';
4
3
  function findDesignItem(designItem, position) {
5
4
  let usedItem = null;
6
5
  if (designItem.hasChildren) {
@@ -27,8 +26,10 @@ export class SelectionService {
27
26
  this._undoSelectionChanges = undoSelectionChanges;
28
27
  }
29
28
  setSelectedElements(designItems, event) {
29
+ if (designItems === null || designItems.length === 0)
30
+ designItems = [this._designerCanvas.rootDesignItem];
30
31
  if (this.selectedElements != designItems && !(this.selectedElements.length === 0 && (designItems == null || designItems.length === 0))) {
31
- if (arraysEqual(designItems, this.selectedElements)) {
32
+ if (this.selectedElements?.length === 1 && designItems?.length === 1 && designItems[0] === this.selectedElements[0]) {
32
33
  this.onSelectionRefresh.emit({ selectedElements: this.selectedElements, event });
33
34
  return;
34
35
  }
@@ -57,7 +58,7 @@ export class SelectionService {
57
58
  else {
58
59
  let newSelection = [];
59
60
  for (let d of designItems) {
60
- if (d && d != d.instanceServiceContainer.contentService.rootDesignItem)
61
+ if (d && (designItems.length == 1 || d !== d.instanceServiceContainer.contentService.rootDesignItem))
61
62
  newSelection.push(d);
62
63
  }
63
64
  this.selectedElements = newSelection;
@@ -83,7 +83,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
83
83
  }
84
84
  set canvasOffset(value) {
85
85
  this._canvasOffset = value;
86
- this._zoomFactorChanged(false);
86
+ this._zoomFactorChanged();
87
87
  }
88
88
  get canvasOffsetUnzoomed() {
89
89
  return { x: this._canvasOffset.x * this.zoomFactor, y: this._canvasOffset.y * this.zoomFactor };
@@ -657,7 +657,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
657
657
  disconnectedCallback() {
658
658
  this.extensionManager.disconnected();
659
659
  }
660
- _zoomFactorChanged(refreshExtensions = true) {
660
+ _zoomFactorChanged() {
661
661
  //a@ts-ignore
662
662
  //this._canvasContainer.style.zoom = <any>this._zoomFactor;
663
663
  //this._canvasContainer.style.transform = 'scale(' + this._zoomFactor+') translate(' + this._translate.x + ', '+this._translate.y+')';
@@ -667,10 +667,6 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
667
667
  this._updateTransform();
668
668
  this.fillCalculationrects();
669
669
  this.onZoomFactorChanged.emit(this._zoomFactor);
670
- if (refreshExtensions) {
671
- this.extensionManager.refreshAllAppliedExtentions();
672
- setTimeout(() => this.extensionManager.refreshAllAppliedExtentions(), 200);
673
- }
674
670
  if (!this.serviceContainer.options.zoomDesignerBackground)
675
671
  this._resizeBackgroundGrid();
676
672
  }
@@ -853,8 +849,10 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
853
849
  }
854
850
  _onDblClick(event) {
855
851
  event.preventDefault();
856
- if (this.serviceContainer.globalContext.tool == null || this.serviceContainer.globalContext.tool === this.serviceContainer.designerTools.get(NamedTools.Pointer))
852
+ if (this.serviceContainer.globalContext.tool == null || this.serviceContainer.globalContext.tool === this.serviceContainer.designerTools.get(NamedTools.Pointer)) {
853
+ this.extensionManager.removeExtension(this.instanceServiceContainer.selectionService.primarySelection, ExtensionType.PrimarySelectionRefreshed);
857
854
  this.extensionManager.applyExtension(this.instanceServiceContainer.selectionService.primarySelection, ExtensionType.Doubleclick, event);
855
+ }
858
856
  }
859
857
  _searchShowOverlay() {
860
858
  let divElement = this._getDomElement('node-projects-designer-search-container');
@@ -19,6 +19,8 @@ export class AbstractExtension extends AbstractExtensionBase {
19
19
  foreignObject.setAttribute('width', '' + width);
20
20
  foreignObject.setAttribute('height', '' + height);
21
21
  foreignObject.appendChild(element);
22
+ foreignObject.style.scale = '' + 1 / this.designerCanvas.zoomFactor;
23
+ foreignObject.style.transformBox = 'fill-box';
22
24
  this._addOverlay(foreignObject, overlayLayer);
23
25
  foreignObject.updatePosition = (position) => {
24
26
  foreignObject.setAttribute('x', '' + position.x);
@@ -14,6 +14,7 @@ export declare class EditTextExtension extends AbstractExtension implements hand
14
14
  extend(): void;
15
15
  refresh(): void;
16
16
  dispose(): void;
17
+ commitchanges(): void;
17
18
  handlesPointerEvent(designerCanvas: IDesignerCanvas, event: PointerEvent, currentElement: Element): boolean;
18
19
  _formatSelection(type: string, value?: string): void;
19
20
  }
@@ -61,6 +61,8 @@ export class EditTextExtension extends AbstractExtension {
61
61
  this._path.setAttribute('fill-rule', 'evenodd');
62
62
  this._path.style.pointerEvents = 'auto';
63
63
  this._path.onpointerdown = (e) => {
64
+ this.designerCanvas.ignoreEvent(e);
65
+ this.commitchanges();
64
66
  this.extensionManager.removeExtensionInstance(this.extendedItem, this);
65
67
  };
66
68
  this._addOverlay(this._path, OverlayLayer.Background);
@@ -78,6 +80,11 @@ export class EditTextExtension extends AbstractExtension {
78
80
  this._path.setAttribute("d", data);
79
81
  }
80
82
  dispose() {
83
+ this._removeAllOverlays();
84
+ this.extendedItem.element.removeAttribute('contenteditable');
85
+ this.designerCanvas.clickOverlay.style.pointerEvents = 'auto';
86
+ }
87
+ commitchanges() {
81
88
  this._removeAllOverlays();
82
89
  this.extendedItem.element.removeAttribute('contenteditable');
83
90
  this.extendedItem.updateChildrenFromNodesChildren();
@@ -2,7 +2,7 @@ import { ElementDragTitleExtension } from './ElementDragTitleExtension.js';
2
2
  import { css } from "@node-projects/base-custom-webcomponent";
3
3
  export class ElementDragTitleExtensionProvider {
4
4
  shouldExtend(extensionManager, designerView, designItem) {
5
- return true;
5
+ return !designItem.isRootItem;
6
6
  }
7
7
  getExtension(extensionManager, designerView, designItem) {
8
8
  return new ElementDragTitleExtension(extensionManager, designerView, designItem);
@@ -30,6 +30,6 @@ export declare class ExtensionManager implements IExtensionManager {
30
30
  refreshExtensions(designItems: IDesignItem[], extensionType?: ExtensionType, event?: Event, ignoredExtension?: IDesignerExtension, timeout?: number): void;
31
31
  refreshAllExtensions(designItems: IDesignItem[], ignoredExtension?: IDesignerExtension, event?: Event): void;
32
32
  refreshAllAppliedExtentions(event?: Event): void;
33
- reapplyAllAppliedExtentions(filterDesignItems?: IDesignItem[]): void;
33
+ reapplyAllAppliedExtentions(filterDesignItems?: IDesignItem[], enabledExtensionTypes?: ExtensionType[]): void;
34
34
  private static getAllChildElements;
35
35
  }
@@ -22,6 +22,9 @@ export class ExtensionManager {
22
22
  designerCanvas.instanceServiceContainer.selectionService.onSelectionChanged.on(this._selectedElementsChanged.bind(this));
23
23
  designerCanvas.instanceServiceContainer.selectionService.onSelectionRefresh.on(this._selectedElementsRefresh.bind(this));
24
24
  designerCanvas.instanceServiceContainer.contentService.onContentChanged.on(this._contentChanged.bind(this));
25
+ designerCanvas.serviceContainer.globalContext.onToolChanged.on(() => {
26
+ this.removeExtension(designerCanvas.instanceServiceContainer.selectionService.primarySelection, ExtensionType.PrimarySelectionRefreshed);
27
+ });
25
28
  }
26
29
  connected() {
27
30
  if (!this._timeout)
@@ -57,14 +60,14 @@ export class ExtensionManager {
57
60
  _selectedElementsChanged(selectionChangedEvent) {
58
61
  this._lastPrimarySelectionRefreshItem = null;
59
62
  if (selectionChangedEvent.oldSelectedElements && selectionChangedEvent.oldSelectedElements.length) {
63
+ this.removeExtension(selectionChangedEvent.oldSelectedElements[0], ExtensionType.PrimarySelectionRefreshed);
64
+ this.removeExtension(selectionChangedEvent.oldSelectedElements[0], ExtensionType.PrimarySelection);
65
+ this.removeExtension(selectionChangedEvent.oldSelectedElements[0], ExtensionType.PrimarySelectionAndCanBeEntered);
66
+ this.removeExtensions(selectionChangedEvent.oldSelectedElements, false, ExtensionType.Selection);
60
67
  if (selectionChangedEvent.oldSelectedElements[0].parent) {
61
68
  const primaryContainer = DesignItem.GetOrCreateDesignItem(selectionChangedEvent.oldSelectedElements[0].parent.element, selectionChangedEvent.oldSelectedElements[0].parent.element, this.designerCanvas.serviceContainer, this.designerCanvas.instanceServiceContainer);
62
69
  this.removeExtension(primaryContainer, ExtensionType.PrimarySelectionContainer);
63
70
  this.removeExtension(primaryContainer, ExtensionType.PrimarySelectionContainerAndCanBeEntered);
64
- this.removeExtension(selectionChangedEvent.oldSelectedElements[0], ExtensionType.PrimarySelection);
65
- this.removeExtension(selectionChangedEvent.oldSelectedElements[0], ExtensionType.PrimarySelectionRefreshed);
66
- this.removeExtension(selectionChangedEvent.oldSelectedElements[0], ExtensionType.PrimarySelectionAndCanBeEntered);
67
- this.removeExtensions(selectionChangedEvent.oldSelectedElements, false, ExtensionType.Selection);
68
71
  }
69
72
  }
70
73
  if (selectionChangedEvent.selectedElements && selectionChangedEvent.selectedElements.length) {
@@ -72,10 +75,12 @@ export class ExtensionManager {
72
75
  this.applyExtension(selectionChangedEvent.selectedElements[0], ExtensionType.PrimarySelection, selectionChangedEvent.event);
73
76
  if (selectionChangedEvent.selectedElements[0].getPlacementService()?.isEnterableContainer(selectionChangedEvent.selectedElements[0]))
74
77
  this.applyExtension(selectionChangedEvent.selectedElements[0], ExtensionType.PrimarySelectionAndCanBeEntered, selectionChangedEvent.event);
75
- const primaryContainer = DesignItem.GetOrCreateDesignItem(selectionChangedEvent.selectedElements[0].parent.element, selectionChangedEvent.selectedElements[0].parent.element, this.designerCanvas.serviceContainer, this.designerCanvas.instanceServiceContainer);
76
- this.applyExtension(primaryContainer, ExtensionType.PrimarySelectionContainer, selectionChangedEvent.event);
77
- if (primaryContainer.getPlacementService()?.isEnterableContainer(primaryContainer))
78
- this.applyExtension(primaryContainer, ExtensionType.PrimarySelectionContainerAndCanBeEntered, selectionChangedEvent.event);
78
+ if (selectionChangedEvent.selectedElements[0].parent) {
79
+ const primaryContainer = DesignItem.GetOrCreateDesignItem(selectionChangedEvent.selectedElements[0].parent.element, selectionChangedEvent.selectedElements[0].parent.element, this.designerCanvas.serviceContainer, this.designerCanvas.instanceServiceContainer);
80
+ this.applyExtension(primaryContainer, ExtensionType.PrimarySelectionContainer, selectionChangedEvent.event);
81
+ if (primaryContainer.getPlacementService()?.isEnterableContainer(primaryContainer))
82
+ this.applyExtension(primaryContainer, ExtensionType.PrimarySelectionContainerAndCanBeEntered, selectionChangedEvent.event);
83
+ }
79
84
  }
80
85
  }
81
86
  _selectedElementsRefresh(selectionChangedEvent) {
@@ -415,7 +420,7 @@ export class ExtensionManager {
415
420
  }
416
421
  //TODO: does not work with permanant, when not applied... maybe we need to do in another way
417
422
  //maybe store the "shouldAppliedExtensions??"
418
- reapplyAllAppliedExtentions(filterDesignItems) {
423
+ reapplyAllAppliedExtentions(filterDesignItems, enabledExtensionTypes) {
419
424
  this.designerCanvas.overlayLayer.startBatch();
420
425
  for (let d of ExtensionManager.getAllChildElements(this.designerCanvas.rootDesignItem)) {
421
426
  if (!filterDesignItems || filterDesignItems.includes(d)) {
@@ -423,7 +428,8 @@ export class ExtensionManager {
423
428
  for (let t of keys) {
424
429
  const evt = wmGet(d, this._lastApplyEventPerType).get(t);
425
430
  this.removeExtension(d, t);
426
- this.applyExtension(d, t, evt);
431
+ if (enabledExtensionTypes == null || enabledExtensionTypes.includes(t))
432
+ this.applyExtension(d, t, evt);
427
433
  }
428
434
  }
429
435
  }
@@ -12,7 +12,7 @@ export interface IExtensionManager {
12
12
  refreshExtensions(designItems: IDesignItem[], extensionType?: ExtensionType, event?: Event, ignoredExtension?: IDesignerExtension, timeout?: number): any;
13
13
  refreshAllExtensions(designItems: IDesignItem[], ignoredExtension?: IDesignerExtension, event?: Event): any;
14
14
  refreshAllAppliedExtentions(event?: Event): any;
15
- reapplyAllAppliedExtentions(filterDesignItems?: IDesignItem[]): any;
15
+ reapplyAllAppliedExtentions(filterDesignItems?: IDesignItem[], enabledExtensionTypes?: ExtensionType[]): any;
16
16
  connected(): any;
17
17
  disconnected(): any;
18
18
  }
@@ -2,7 +2,7 @@ import { css } from "@node-projects/base-custom-webcomponent";
2
2
  import { MultipleSelectionRectExtension as MultipleSelectionRectExtension } from './MultipleSelectionRectExtension.js';
3
3
  export class MultipleSelectionRectExtensionProvider {
4
4
  shouldExtend(extensionManager, designerView, designItem) {
5
- return true;
5
+ return !designItem.isRootItem;
6
6
  }
7
7
  getExtension(extensionManager, designerView, designItem) {
8
8
  return new MultipleSelectionRectExtension(extensionManager, designerView, designItem);
@@ -2,6 +2,8 @@ import { PositionExtension } from './PositionExtension.js';
2
2
  import { css } from "@node-projects/base-custom-webcomponent";
3
3
  export class PositionExtensionProvider {
4
4
  shouldExtend(extensionManager, designerView, designItem) {
5
+ if (!designItem?.parent)
6
+ return false;
5
7
  const cs = getComputedStyle(designItem.element);
6
8
  if (cs.position === 'relative' || cs.position === 'absolute')
7
9
  return true;
@@ -9,7 +9,7 @@ export class ResizeExtensionProvider {
9
9
  shouldExtend(extensionManager, designerView, designItem) {
10
10
  if (designItem.element instanceof SVGElement)
11
11
  return false;
12
- return designItem.nodeType == NodeType.Element;
12
+ return !designItem.isRootItem && designItem.nodeType == NodeType.Element;
13
13
  }
14
14
  getExtension(extensionManager, designerView, designItem) {
15
15
  return new ResizeExtension(extensionManager, designerView, designItem, this.resizeAllSelected);
@@ -5,7 +5,7 @@ export class RotateExtensionProvider {
5
5
  if (designItem.element instanceof SVGElement) {
6
6
  return false;
7
7
  }
8
- return true;
8
+ return !designItem.isRootItem;
9
9
  }
10
10
  getExtension(extensionManager, designerView, designItem) {
11
11
  return new RotateExtension(extensionManager, designerView, designItem);
@@ -3,7 +3,7 @@ import { css } from "@node-projects/base-custom-webcomponent";
3
3
  import { NodeType } from '../../../item/NodeType.js';
4
4
  export class SelectionDefaultExtensionProvider {
5
5
  shouldExtend(extensionManager, designerView, designItem) {
6
- return designItem.nodeType != NodeType.Comment;
6
+ return !designItem.isRootItem && designItem.nodeType != NodeType.Comment;
7
7
  }
8
8
  getExtension(extensionManager, designerView, designItem) {
9
9
  return new SelectionDefaultExtension(extensionManager, designerView, designItem);
@@ -6,7 +6,7 @@ export class TransformOriginExtensionProvider {
6
6
  this.showOnlyWhenSet = showOnlyWhenSet;
7
7
  }
8
8
  shouldExtend(extensionManager, designerView, designItem) {
9
- if (designItem.node instanceof HTMLElement || (designItem.node instanceof SVGElement && designItem.node.localName === 'svg')) {
9
+ if (!designItem.isRootItem && designItem.node instanceof HTMLElement || (designItem.node instanceof SVGElement && designItem.node.localName === 'svg')) {
10
10
  if (!this.showOnlyWhenSet)
11
11
  return true;
12
12
  if (designItem.hasStyle('transformOrigin'))
@@ -26,7 +26,7 @@ export class BlockToolbarExtension extends AbstractExtension {
26
26
  refresh(cache, event) {
27
27
  if (event) {
28
28
  const pos = this.designerCanvas.getNormalizedEventCoordinates(event);
29
- this._toolbar.updatePosition({ x: (pos.x - 16), y: (pos.y - 44) });
29
+ this._toolbar.updatePosition({ x: (pos.x - (16 / this.designerCanvas.zoomFactor)), y: (pos.y - (44 / this.designerCanvas.zoomFactor)) });
30
30
  }
31
31
  }
32
32
  dispose() {
@@ -26,7 +26,7 @@ export class FlexToolbarExtension extends AbstractExtension {
26
26
  refresh(cache, event) {
27
27
  if (event) {
28
28
  const pos = this.designerCanvas.getNormalizedEventCoordinates(event);
29
- this._toolbar.updatePosition({ x: (pos.x - 16), y: (pos.y - 44) });
29
+ this._toolbar.updatePosition({ x: (pos.x - (16 / this.designerCanvas.zoomFactor)), y: (pos.y - (44 / this.designerCanvas.zoomFactor)) });
30
30
  }
31
31
  }
32
32
  dispose() {
@@ -58,7 +58,7 @@ export class GridToolbarExtension extends AbstractExtension {
58
58
  refresh(cache, event) {
59
59
  if (event) {
60
60
  const pos = this.designerCanvas.getNormalizedEventCoordinates(event);
61
- this._toolbar.updatePosition({ x: (pos.x - 16), y: (pos.y - 44) });
61
+ this._toolbar.updatePosition({ x: (pos.x - (16 / this.designerCanvas.zoomFactor)), y: (pos.y - (44 / this.designerCanvas.zoomFactor)) });
62
62
  }
63
63
  }
64
64
  dispose() {
@@ -110,8 +110,8 @@ export class PointerTool {
110
110
  this._actionType = PointerActionType.Drag;
111
111
  }
112
112
  else if (currentElement === designerCanvas || currentElement === designerCanvas.rootDesignItem.element || currentElement == null) {
113
- if (!event.ctrlKey && !event.shiftKey)
114
- designerCanvas.instanceServiceContainer.selectionService.setSelectedElements(null, event);
113
+ //if (!event.ctrlKey && !event.shiftKey)
114
+ // designerCanvas.instanceServiceContainer.selectionService.setSelectedElements(null, event);
115
115
  this._actionType = PointerActionType.DrawSelection;
116
116
  }
117
117
  else {
@@ -89,7 +89,7 @@ export class RectangleSelectorTool {
89
89
  designerCanvas.overlayLayer.removeOverlay(this._rect);
90
90
  this._rect = null;
91
91
  this._initialPoint = null;
92
- designerCanvas.instanceServiceContainer.selectionService.setSelectedElements(inSelectionElements);
92
+ designerCanvas.instanceServiceContainer.selectionService.setSelectedElements(inSelectionElements, event);
93
93
  designerCanvas.serviceContainer.globalContext.finishedWithTool(this);
94
94
  break;
95
95
  }
@@ -48,10 +48,10 @@ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
48
48
  <span style="grid-column: span 3;" class="desc">Type:</span><input type="text" readonly id="type">
49
49
  <button id="config" style="display: none; grid-column: 5; grid-row: span 3; height: calc(100% - 10px); margin-left: 10px;">config</button>
50
50
  <div title="id" id="idRect" style="grid-column: 1; width: 7px; height: 7px; border: 1px solid white;"></div>
51
- <span style="grid-column: span 2;" class="desc">Id:</span><input type="text" id="id">
51
+ <span id="idSpan" style="grid-column: span 2;" class="desc">Id:</span><input type="text" id="id">
52
52
  <div title="innerHTML" id="innerRect" style="grid-column: 1; width: 7px; height: 7px; border: 1px solid white;"></div>
53
53
  <div title="textContent" id="contentRect" style="width: 7px; height: 7px; border: 1px solid white;"></div>
54
- <span class="desc">Content:</span><input type="text" id="content">
54
+ <span id="contentSpan" class="desc">Content:</span><input type="text" id="content">
55
55
  </div>
56
56
  <node-projects-web-component-designer-property-grid id="pg"></node-projects-web-component-designer-property-grid>`;
57
57
  _type;
@@ -84,15 +84,18 @@ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
84
84
  this._propertiesService = new ContentAndIdPropertiesService();
85
85
  this._idRect.oncontextmenu = (event) => {
86
86
  event.preventDefault();
87
- PropertyGridPropertyList.openContextMenu(event, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService.idProperty);
87
+ if (!this._instanceServiceContainer.selectionService.primarySelection?.isRootItem)
88
+ PropertyGridPropertyList.openContextMenu(event, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService.idProperty);
88
89
  };
89
90
  this._contentRect.oncontextmenu = (event) => {
90
91
  event.preventDefault();
91
- PropertyGridPropertyList.openContextMenu(event, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService.contentProperty);
92
+ if (!this._instanceServiceContainer.selectionService.primarySelection?.isRootItem)
93
+ PropertyGridPropertyList.openContextMenu(event, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService.contentProperty);
92
94
  };
93
95
  this._innerRect.oncontextmenu = (event) => {
94
96
  event.preventDefault();
95
- PropertyGridPropertyList.openContextMenu(event, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService.innerHtmlProperty);
97
+ if (!this._instanceServiceContainer.selectionService.primarySelection?.isRootItem)
98
+ PropertyGridPropertyList.openContextMenu(event, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService.innerHtmlProperty);
96
99
  };
97
100
  this._id.onkeydown = e => {
98
101
  if (e.key == 'Enter')
@@ -137,33 +140,46 @@ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
137
140
  this._selectionChangedHandler = this._instanceServiceContainer.selectionService.onSelectionChanged.on(async (e) => {
138
141
  this._pg.instanceServiceContainer = value;
139
142
  await sleep(20); // delay assignment a little bit, so onblur above could still set the value.
140
- const srv = await this.serviceContainer?.getLastServiceWhereAsync('configUiService', x => x.hasConfigUi(this._instanceServiceContainer.selectionService.primarySelection));
141
- if (srv) {
142
- this._configButton.style.display = 'block';
143
- }
144
- else {
143
+ if (this._instanceServiceContainer.selectionService.primarySelection.isRootItem) {
145
144
  this._configButton.style.display = 'none';
146
- }
147
- if (this._instanceServiceContainer.selectionService.primarySelection?.nodeType == NodeType.Element) {
148
- this._type.value = this._instanceServiceContainer.selectionService.primarySelection?.name ?? '';
145
+ this._id.value = '';
146
+ this._content.value = '';
147
+ this._id.disabled = true;
148
+ this._content.disabled = true;
149
+ this._idRect.style.background = '';
150
+ this._contentRect.style.background = '';
151
+ this._innerRect.style.background = '';
152
+ this._type.value = ":host";
149
153
  }
150
154
  else {
151
- this._type.value = this._instanceServiceContainer.selectionService.primarySelection?.node?.nodeName ?? '';
152
- }
153
- this._type.title = this._type.value;
154
- this._id.blur();
155
- this._id.value = this._instanceServiceContainer.selectionService.primarySelection?.id ?? '';
156
- if (this._instanceServiceContainer.selectionService.primarySelection?.element?.nodeType != NodeType.Element) {
157
- this._content.value = this._instanceServiceContainer.selectionService.primarySelection?.content ?? '';
155
+ const srv = await this.serviceContainer?.getLastServiceWhereAsync('configUiService', x => x.hasConfigUi(this._instanceServiceContainer.selectionService.primarySelection));
156
+ if (srv) {
157
+ this._configButton.style.display = 'block';
158
+ }
159
+ else {
160
+ this._configButton.style.display = 'none';
161
+ }
162
+ if (this._instanceServiceContainer.selectionService.primarySelection?.nodeType == NodeType.Element) {
163
+ this._type.value = this._instanceServiceContainer.selectionService.primarySelection?.name ?? '';
164
+ }
165
+ else {
166
+ this._type.value = this._instanceServiceContainer.selectionService.primarySelection?.node?.nodeName ?? '';
167
+ }
168
+ this._type.title = this._type.value;
169
+ this._id.blur();
170
+ this._id.value = this._instanceServiceContainer.selectionService.primarySelection?.id ?? '';
171
+ if (this._instanceServiceContainer.selectionService.primarySelection?.element?.nodeType != NodeType.Element) {
172
+ this._content.value = this._instanceServiceContainer.selectionService.primarySelection?.content ?? '';
173
+ }
174
+ else if (this._instanceServiceContainer.selectionService.primarySelection?.element?.children?.length <= 0)
175
+ this._content.value = this._instanceServiceContainer.selectionService.primarySelection?.content ?? '';
176
+ else
177
+ this._content.value = '';
178
+ this._content.title = this._content.value;
179
+ PropertyGridPropertyList.refreshIsSetElementAndEditorForDesignItems(this._idRect, this._propertiesService.idProperty, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService);
180
+ PropertyGridPropertyList.refreshIsSetElementAndEditorForDesignItems(this._contentRect, this._propertiesService.contentProperty, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService);
181
+ PropertyGridPropertyList.refreshIsSetElementAndEditorForDesignItems(this._innerRect, this._propertiesService.innerHtmlProperty, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService);
158
182
  }
159
- else if (this._instanceServiceContainer.selectionService.primarySelection?.element?.children?.length <= 0)
160
- this._content.value = this._instanceServiceContainer.selectionService.primarySelection?.content ?? '';
161
- else
162
- this._content.value = '';
163
- this._content.title = this._content.value;
164
- PropertyGridPropertyList.refreshIsSetElementAndEditorForDesignItems(this._idRect, this._propertiesService.idProperty, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService);
165
- PropertyGridPropertyList.refreshIsSetElementAndEditorForDesignItems(this._contentRect, this._propertiesService.contentProperty, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService);
166
- PropertyGridPropertyList.refreshIsSetElementAndEditorForDesignItems(this._innerRect, this._propertiesService.innerHtmlProperty, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService);
167
183
  });
168
184
  this._pg.instanceServiceContainer = value;
169
185
  }
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.1.106",
4
+ "version": "0.1.107",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",