@node-projects/web-component-designer 0.0.43 → 0.0.47

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 (24) hide show
  1. package/dist/elements/item/DesignItem.js +11 -0
  2. package/dist/elements/item/IDesignItem.d.ts +1 -1
  3. package/dist/elements/services/InstanceServiceContainer.d.ts +3 -0
  4. package/dist/elements/services/InstanceServiceContainer.js +5 -0
  5. package/dist/elements/services/contentService/IContentChanged.d.ts +3 -3
  6. package/dist/elements/services/undoService/transactionItems/DeleteAction.js +2 -0
  7. package/dist/elements/services/undoService/transactionItems/InsertAction.js +2 -0
  8. package/dist/elements/services/undoService/transactionItems/MoveElementInDomAction.js +2 -0
  9. package/dist/elements/widgets/designerView/designerCanvas.js +14 -7
  10. package/dist/elements/widgets/designerView/tools/PointerTool.js +4 -2
  11. package/dist/elements/widgets/designerView/tools/RectangleSelectorTool.js +0 -1
  12. package/dist/elements/widgets/propertyGrid/PropertyGrid copy.d.ts +17 -0
  13. package/dist/elements/widgets/propertyGrid/PropertyGrid copy.js +143 -0
  14. package/dist/elements/widgets/propertyGrid/PropertyGrid.d.ts +4 -0
  15. package/dist/elements/widgets/propertyGrid/PropertyGrid.js +10 -15
  16. package/dist/elements/widgets/propertyGrid/PropertyGridWithHeader.d.ts +15 -0
  17. package/dist/elements/widgets/propertyGrid/PropertyGridWithHeader.js +86 -0
  18. package/dist/elements/widgets/treeView/treeView.d.ts +5 -0
  19. package/dist/elements/widgets/treeView/treeView.js +15 -0
  20. package/dist/elements/widgets/treeView/treeViewExtended.d.ts +5 -0
  21. package/dist/elements/widgets/treeView/treeViewExtended.js +39 -37
  22. package/dist/index.d.ts +3 -0
  23. package/dist/index.js +2 -0
  24. package/package.json +1 -1
@@ -1,6 +1,8 @@
1
1
  import { CssStyleChangeAction } from '../services/undoService/transactionItems/CssStyleChangeAction';
2
2
  import { NodeType } from './NodeType';
3
3
  import { AttributeChangeAction } from '../services/undoService/transactionItems/AttributeChangeAction';
4
+ //import { PropertyChangeAction } from '../services/undoService/transactionItems/PropertyChangeAction';
5
+ import { ExtensionType } from '../widgets/designerView/extensions/ExtensionType';
4
6
  import { DomHelper } from '@node-projects/base-custom-webcomponent/dist/DomHelper';
5
7
  import { CssAttributeParser } from '../helper/CssAttributeParser.js';
6
8
  const hideAtDesignTimeAttributeName = 'node-projects-hide-at-design-time';
@@ -43,6 +45,7 @@ export class DesignItem {
43
45
  }
44
46
  set id(value) {
45
47
  this.element.id = value;
48
+ this.setAttribute("id", value);
46
49
  }
47
50
  get isRootItem() {
48
51
  return this.instanceServiceContainer.contentService.rootDesignItem === this;
@@ -66,6 +69,9 @@ export class DesignItem {
66
69
  return this.getOrCreateDesignItem(this.element.parentNode);
67
70
  }
68
71
  insertChild(designItem, index) {
72
+ //todo... via undoredo system....
73
+ if (designItem.parent && this.instanceServiceContainer.selectionService.primarySelection == designItem)
74
+ designItem.instanceServiceContainer.designerCanvas.extensionManager.removeExtension(designItem.parent, ExtensionType.PrimarySelectionContainer);
69
75
  if (designItem.parent) {
70
76
  designItem.parent.removeChild(designItem);
71
77
  }
@@ -79,8 +85,13 @@ export class DesignItem {
79
85
  this.node.insertBefore(designItem.node, el.element);
80
86
  this._childArray.splice(index, 0, designItem);
81
87
  }
88
+ if (this.instanceServiceContainer.selectionService.primarySelection == designItem)
89
+ designItem.instanceServiceContainer.designerCanvas.extensionManager.applyExtension(designItem.parent, ExtensionType.PrimarySelectionContainer);
82
90
  }
83
91
  removeChild(designItem) {
92
+ //todo... via undoredo system....
93
+ if (designItem.parent && this.instanceServiceContainer.selectionService.primarySelection == designItem)
94
+ designItem.instanceServiceContainer.designerCanvas.extensionManager.removeExtension(designItem.parent, ExtensionType.PrimarySelectionContainer);
84
95
  const index = this._childArray.indexOf(designItem);
85
96
  if (index > -1) {
86
97
  this._childArray.splice(index, 1);
@@ -8,7 +8,7 @@ export interface IDesignItem {
8
8
  replaceNode(newNode: Node): any;
9
9
  readonly nodeType: NodeType;
10
10
  readonly name: string;
11
- readonly id: string;
11
+ id: string;
12
12
  readonly isRootItem: boolean;
13
13
  readonly hasAttributes: boolean;
14
14
  readonly attributes: Map<string, string>;
@@ -3,6 +3,7 @@ import { IUndoService } from './undoService/IUndoService';
3
3
  import { BaseServiceContainer } from './BaseServiceContainer';
4
4
  import { IContentService } from './contentService/IContentService';
5
5
  import { IDesignContext } from '../widgets/designerView/IDesignContext';
6
+ import { IDesignerCanvas } from '../widgets/designerView/IDesignerCanvas.js';
6
7
  interface InstanceServiceNameMap {
7
8
  "undoService": IUndoService;
8
9
  "selectionService": ISelectionService;
@@ -10,6 +11,8 @@ interface InstanceServiceNameMap {
10
11
  }
11
12
  export declare class InstanceServiceContainer extends BaseServiceContainer<InstanceServiceNameMap> {
12
13
  designContext: IDesignContext;
14
+ readonly designerCanvas: IDesignerCanvas;
15
+ constructor(designerCanvas: IDesignerCanvas);
13
16
  get undoService(): IUndoService;
14
17
  get selectionService(): ISelectionService;
15
18
  get contentService(): IContentService;
@@ -2,6 +2,11 @@ import { BaseServiceContainer } from './BaseServiceContainer';
2
2
  import { DesignContext } from '../widgets/designerView/DesignContext';
3
3
  export class InstanceServiceContainer extends BaseServiceContainer {
4
4
  designContext = new DesignContext();
5
+ designerCanvas;
6
+ constructor(designerCanvas) {
7
+ super();
8
+ this.designerCanvas = designerCanvas;
9
+ }
5
10
  get undoService() {
6
11
  return this.getLastService('undoService');
7
12
  }
@@ -1,5 +1,5 @@
1
+ import { IDesignItem } from "../../item/IDesignItem.js";
1
2
  export interface IContentChanged {
2
- changeType: "added" | "removed" | "moved";
3
- element: HTMLElement;
4
- parent: HTMLElement;
3
+ changeType: "added" | "removed" | "moved" | 'parsed';
4
+ designItems?: IDesignItem[];
5
5
  }
@@ -13,6 +13,7 @@ export class DeleteAction {
13
13
  for (let n = 0; n < this.deletedItems.length; n++) {
14
14
  this._parentItems[n].insertChild(this.deletedItems[n], this._parentIndexes[n]);
15
15
  }
16
+ this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'added', designItems: this.deletedItems });
16
17
  }
17
18
  do() {
18
19
  this._parentItems = [];
@@ -25,6 +26,7 @@ export class DeleteAction {
25
26
  this.deletedItems[n].remove();
26
27
  }
27
28
  this.extensionManager.removeExtensions(this.deletedItems);
29
+ this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'removed', designItems: this.deletedItems });
28
30
  }
29
31
  deletedItems;
30
32
  extensionManager;
@@ -11,12 +11,14 @@ export class InsertAction {
11
11
  }
12
12
  undo() {
13
13
  this.newItem.element.remove();
14
+ this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'removed', designItems: [this.newItem] });
14
15
  }
15
16
  do() {
16
17
  this.designItem.insertChild(this.newItem, this.index);
17
18
  const prepService = this.designItem.serviceContainer.prepareElementsForDesignerService;
18
19
  if (prepService)
19
20
  requestAnimationFrame(() => prepService.prepareElementsForDesigner(this.newItem));
21
+ this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'added', designItems: [this.newItem] });
20
22
  }
21
23
  designItem;
22
24
  index;
@@ -13,9 +13,11 @@ export class MoveElementInDomAction {
13
13
  }
14
14
  undo() {
15
15
  this.oldTarget.element.insertAdjacentElement(this.oldPosition, this.designItem.element);
16
+ this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'moved', designItems: [this.designItem] });
16
17
  }
17
18
  do() {
18
19
  this.newTarget.element.insertAdjacentElement(this.newPosition, this.designItem.element);
20
+ this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'moved', designItems: [this.designItem] });
19
21
  }
20
22
  designItem;
21
23
  newTarget;
@@ -115,7 +115,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
115
115
  this._canvas = this._getDomElement('node-projects-designer-canvas-canvas');
116
116
  this._canvasContainer = this._getDomElement('node-projects-designer-canvas-canvasContainer');
117
117
  this._outercanvas2 = this._getDomElement('node-projects-designer-canvas-outercanvas2');
118
- this.instanceServiceContainer = new InstanceServiceContainer();
118
+ this.instanceServiceContainer = new InstanceServiceContainer(this);
119
119
  this.instanceServiceContainer.register("undoService", new UndoService(this));
120
120
  this.instanceServiceContainer.register("selectionService", new SelectionService);
121
121
  this.extensionManager = new ExtensionManager(this);
@@ -161,9 +161,12 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
161
161
  }
162
162
  /* --- start IUiCommandHandler --- */
163
163
  async executeCommand(command) {
164
- let handeled = this.serviceContainer.modelCommandService.executeCommand(this, command);
165
- if (handeled != null)
166
- return;
164
+ const modelCommandService = this.serviceContainer.modelCommandService;
165
+ if (modelCommandService) {
166
+ let handeled = await modelCommandService.executeCommand(this, command);
167
+ if (handeled != null)
168
+ return;
169
+ }
167
170
  switch (command.type) {
168
171
  case CommandType.screenshot:
169
172
  {
@@ -212,9 +215,12 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
212
215
  }
213
216
  }
214
217
  canExecuteCommand(command) {
215
- let handeled = this.serviceContainer.modelCommandService.canExecuteCommand(this, command);
216
- if (handeled !== null)
217
- return handeled;
218
+ const modelCommandService = this.serviceContainer.modelCommandService;
219
+ if (modelCommandService) {
220
+ let handeled = modelCommandService.canExecuteCommand(this, command);
221
+ if (handeled !== null)
222
+ return handeled;
223
+ }
218
224
  if (command.type === CommandType.undo) {
219
225
  return this.instanceServiceContainer.undoService.canUndo();
220
226
  }
@@ -312,6 +318,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
312
318
  DomHelper.removeAllChildnodes(this.overlayLayer);
313
319
  this.rootDesignItem.clearChildren();
314
320
  this.addDesignItems(designItems);
321
+ this.instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'parsed' });
315
322
  }
316
323
  addDesignItems(designItems) {
317
324
  if (designItems) {
@@ -221,8 +221,10 @@ export class PointerTool {
221
221
  backupPEventsMap.set(newContainerElement, newContainerElement.style.pointerEvents);
222
222
  newContainerElement.style.pointerEvents = 'none';
223
223
  const newC = designerCanvas.elementFromPoint(event.x, event.y);
224
- if (newContainerElement === newC)
224
+ if (newContainerElement === newC) {
225
+ newContainerElement = null;
225
226
  break;
227
+ }
226
228
  newContainerElement = newC;
227
229
  }
228
230
  }
@@ -232,7 +234,7 @@ export class PointerTool {
232
234
  e[0].style.pointerEvents = e[1];
233
235
  }
234
236
  }
235
- if (newContainerElement != null) {
237
+ if (newContainerElement != null) { //Check if container is in designer canvas....
236
238
  let p = newContainerElement;
237
239
  while (p != null) {
238
240
  if (p === designerCanvas.rootDesignItem.element)
@@ -24,7 +24,6 @@ export class RectangleSelectorTool {
24
24
  break;
25
25
  case EventNames.PointerMove:
26
26
  if (this._initialPoint) {
27
- console.warn(currentPoint);
28
27
  let w = currentPoint.x - this._initialPoint.x;
29
28
  let h = currentPoint.y - this._initialPoint.y;
30
29
  if (w >= 0) {
@@ -0,0 +1,17 @@
1
+ import { ServiceContainer } from '../../services/ServiceContainer';
2
+ import { IDesignItem } from '../../item/IDesignItem';
3
+ import { BaseCustomWebComponentLazyAppend } from '@node-projects/base-custom-webcomponent';
4
+ export declare class PropertyGrid extends BaseCustomWebComponentLazyAppend {
5
+ private _serviceContainer;
6
+ private _designerTabControl;
7
+ private _selectedItems;
8
+ private _propertyGridPropertyLists;
9
+ private _itemsObserver;
10
+ static readonly style: CSSStyleSheet;
11
+ constructor();
12
+ set serviceContainer(value: ServiceContainer);
13
+ get serviceContainer(): ServiceContainer;
14
+ get selectedItems(): IDesignItem[];
15
+ set selectedItems(items: IDesignItem[]);
16
+ private _observeItems;
17
+ }
@@ -0,0 +1,143 @@
1
+ import { PropertyGridPropertyList } from './PropertyGridPropertyList';
2
+ import { DesignerTabControl } from '../../controls/DesignerTabControl';
3
+ import { BaseCustomWebComponentLazyAppend, css } from '@node-projects/base-custom-webcomponent';
4
+ import { CssPropertiesService } from '../../services/propertiesService/services/CssPropertiesService';
5
+ import { CommonPropertiesService } from '../../services/propertiesService/services/CommonPropertiesService';
6
+ import { AttributesPropertiesService } from '../../services/propertiesService/services/AttributesPropertiesService';
7
+ export class PropertyGrid extends BaseCustomWebComponentLazyAppend {
8
+ _serviceContainer;
9
+ _designerTabControl;
10
+ _selectedItems;
11
+ _propertyGridPropertyLists;
12
+ _itemsObserver;
13
+ static style = css `
14
+ :host {
15
+ display: block;
16
+ height: 100%;
17
+ user-select: none;
18
+ }
19
+ iron-pages {
20
+ overflow: hidden;
21
+ height: 250px;
22
+ background: var(--medium-grey, #2f3545);
23
+ color: white;
24
+ }
25
+ button:hover {
26
+ box-shadow: inset 0 3px 0 var(--light-grey);
27
+ }
28
+ button:focus {
29
+ box-shadow: inset 0 3px 0 var(--highlight-pink, #e91e63);
30
+ }
31
+ `;
32
+ constructor() {
33
+ super();
34
+ this._designerTabControl = new DesignerTabControl();
35
+ this.shadowRoot.appendChild(this._designerTabControl);
36
+ this.addEventListener('contextmenu', (e) => {
37
+ if (e.composedPath()[0].localName != 'input')
38
+ e.preventDefault();
39
+ });
40
+ this._itemsObserver = new MutationObserver((m) => {
41
+ for (const a of this._propertyGridPropertyLists) {
42
+ a.refreshForDesignItems(this._selectedItems);
43
+ }
44
+ });
45
+ }
46
+ set serviceContainer(value) {
47
+ this._serviceContainer = value;
48
+ this._propertyGridPropertyLists = [];
49
+ let elementPropertyEditorAttributeList = new PropertyGridPropertyList(value);
50
+ elementPropertyEditorAttributeList.setPropertiesService(new CssPropertiesService("styles")); //This is replace in selectedItems
51
+ elementPropertyEditorAttributeList.title = "properties";
52
+ this._designerTabControl.appendChild(elementPropertyEditorAttributeList);
53
+ this._propertyGridPropertyLists.push(elementPropertyEditorAttributeList);
54
+ let attributeEditorAttributeList = new PropertyGridPropertyList(value);
55
+ attributeEditorAttributeList.setPropertiesService(new AttributesPropertiesService());
56
+ attributeEditorAttributeList.createElements(null);
57
+ attributeEditorAttributeList.title = "attributes";
58
+ this._designerTabControl.appendChild(attributeEditorAttributeList);
59
+ this._propertyGridPropertyLists.push(attributeEditorAttributeList);
60
+ attributeEditorAttributeList = new PropertyGridPropertyList(value);
61
+ attributeEditorAttributeList.setPropertiesService(new CommonPropertiesService());
62
+ attributeEditorAttributeList.createElements(null);
63
+ attributeEditorAttributeList.title = "common";
64
+ this._designerTabControl.appendChild(attributeEditorAttributeList);
65
+ this._propertyGridPropertyLists.push(attributeEditorAttributeList);
66
+ attributeEditorAttributeList = new PropertyGridPropertyList(value);
67
+ attributeEditorAttributeList.setPropertiesService(new CssPropertiesService("set-styles"));
68
+ attributeEditorAttributeList.createElements(null);
69
+ attributeEditorAttributeList.title = "set-styles";
70
+ this._designerTabControl.appendChild(attributeEditorAttributeList);
71
+ this._propertyGridPropertyLists.push(attributeEditorAttributeList);
72
+ attributeEditorAttributeList = new PropertyGridPropertyList(value);
73
+ attributeEditorAttributeList.setPropertiesService(new CssPropertiesService("styles"));
74
+ attributeEditorAttributeList.createElements(null);
75
+ attributeEditorAttributeList.title = "styles";
76
+ this._designerTabControl.appendChild(attributeEditorAttributeList);
77
+ this._propertyGridPropertyLists.push(attributeEditorAttributeList);
78
+ attributeEditorAttributeList = new PropertyGridPropertyList(value);
79
+ attributeEditorAttributeList.setPropertiesService(new CssPropertiesService("alignment"));
80
+ attributeEditorAttributeList.createElements(null);
81
+ attributeEditorAttributeList.title = "alignment";
82
+ this._designerTabControl.appendChild(attributeEditorAttributeList);
83
+ this._propertyGridPropertyLists.push(attributeEditorAttributeList);
84
+ attributeEditorAttributeList = new PropertyGridPropertyList(value);
85
+ attributeEditorAttributeList.setPropertiesService(new CssPropertiesService("grid"));
86
+ attributeEditorAttributeList.createElements(null);
87
+ attributeEditorAttributeList.title = "grid";
88
+ this._designerTabControl.appendChild(attributeEditorAttributeList);
89
+ this._propertyGridPropertyLists.push(attributeEditorAttributeList);
90
+ attributeEditorAttributeList = new PropertyGridPropertyList(value);
91
+ attributeEditorAttributeList.setPropertiesService(new CssPropertiesService("flex"));
92
+ attributeEditorAttributeList.createElements(null);
93
+ attributeEditorAttributeList.title = "flex";
94
+ this._designerTabControl.appendChild(attributeEditorAttributeList);
95
+ this._propertyGridPropertyLists.push(attributeEditorAttributeList);
96
+ this._designerTabControl.selectedIndex = 0;
97
+ }
98
+ get serviceContainer() {
99
+ return this._serviceContainer;
100
+ }
101
+ get selectedItems() {
102
+ return this._selectedItems;
103
+ }
104
+ set selectedItems(items) {
105
+ this._selectedItems = items;
106
+ if (this.selectedItems && this.selectedItems.length > 0) {
107
+ const propService = this._serviceContainer.getLastServiceWhere('propertyService', x => x.isHandledElement(this.selectedItems[0]));
108
+ this._propertyGridPropertyLists[0].setPropertiesService(propService);
109
+ this._propertyGridPropertyLists[0].createElements(this.selectedItems[0]);
110
+ this._propertyGridPropertyLists[1].createElements(this.selectedItems[0]);
111
+ this._propertyGridPropertyLists[3].createElements(this.selectedItems[0]);
112
+ }
113
+ for (const a of this._propertyGridPropertyLists) {
114
+ a.designItemsChanged(items);
115
+ }
116
+ if (items) {
117
+ if (items.length == 1) {
118
+ for (const a of this._propertyGridPropertyLists) {
119
+ a.designItemsChanged(items);
120
+ a.refreshForDesignItems(items);
121
+ }
122
+ this._observeItems();
123
+ /*let properties = serviceContainer.forSomeServicesTillResult("propertyService", x => x.getProperties(element));
124
+
125
+ if (properties) {
126
+ let attributeEditorAttributeList = new PropertyGridPropertyList();
127
+ attributeEditorAttributeList.serviceContainer = this.serviceContainer;
128
+ // attributeEditorAttributeList.title =
129
+ attributeEditorAttributeList.createElements(properties);
130
+ this._designerTabControl.appendChild(attributeEditorAttributeList);
131
+ }*/
132
+ }
133
+ }
134
+ else {
135
+ this._itemsObserver.disconnect();
136
+ }
137
+ }
138
+ _observeItems() {
139
+ this._itemsObserver.disconnect();
140
+ this._itemsObserver.observe(this._selectedItems[0].element, { attributes: true, childList: false, characterData: false });
141
+ }
142
+ }
143
+ customElements.define('node-projects-property-grid', PropertyGrid);
@@ -1,16 +1,20 @@
1
1
  import { ServiceContainer } from '../../services/ServiceContainer';
2
2
  import { IDesignItem } from '../../item/IDesignItem';
3
3
  import { BaseCustomWebComponentLazyAppend } from '@node-projects/base-custom-webcomponent';
4
+ import { InstanceServiceContainer } from '../../services/InstanceServiceContainer.js';
4
5
  export declare class PropertyGrid extends BaseCustomWebComponentLazyAppend {
5
6
  private _serviceContainer;
6
7
  private _designerTabControl;
7
8
  private _selectedItems;
8
9
  private _propertyGridPropertyLists;
9
10
  private _itemsObserver;
11
+ private _instanceServiceContainer;
12
+ private _selectionChangedHandler;
10
13
  static readonly style: CSSStyleSheet;
11
14
  constructor();
12
15
  set serviceContainer(value: ServiceContainer);
13
16
  get serviceContainer(): ServiceContainer;
17
+ set instanceServiceContainer(value: InstanceServiceContainer);
14
18
  get selectedItems(): IDesignItem[];
15
19
  set selectedItems(items: IDesignItem[]);
16
20
  private _observeItems;
@@ -10,18 +10,14 @@ export class PropertyGrid extends BaseCustomWebComponentLazyAppend {
10
10
  _selectedItems;
11
11
  _propertyGridPropertyLists;
12
12
  _itemsObserver;
13
+ _instanceServiceContainer;
14
+ _selectionChangedHandler;
13
15
  static style = css `
14
16
  :host {
15
17
  display: block;
16
18
  height: 100%;
17
19
  user-select: none;
18
20
  }
19
- iron-pages {
20
- overflow: hidden;
21
- height: 250px;
22
- background: var(--medium-grey, #2f3545);
23
- color: white;
24
- }
25
21
  button:hover {
26
22
  box-shadow: inset 0 3px 0 var(--light-grey);
27
23
  }
@@ -98,6 +94,14 @@ export class PropertyGrid extends BaseCustomWebComponentLazyAppend {
98
94
  get serviceContainer() {
99
95
  return this._serviceContainer;
100
96
  }
97
+ set instanceServiceContainer(value) {
98
+ this._instanceServiceContainer = value;
99
+ this._selectionChangedHandler?.dispose();
100
+ this._selectionChangedHandler = this._instanceServiceContainer.selectionService.onSelectionChanged.on(e => {
101
+ this.selectedItems = e.selectedElements;
102
+ });
103
+ this.selectedItems = this._instanceServiceContainer.selectionService.selectedElements;
104
+ }
101
105
  get selectedItems() {
102
106
  return this._selectedItems;
103
107
  }
@@ -120,15 +124,6 @@ export class PropertyGrid extends BaseCustomWebComponentLazyAppend {
120
124
  a.refreshForDesignItems(items);
121
125
  }
122
126
  this._observeItems();
123
- /*let properties = serviceContainer.forSomeServicesTillResult("propertyService", x => x.getProperties(element));
124
-
125
- if (properties) {
126
- let attributeEditorAttributeList = new PropertyGridPropertyList();
127
- attributeEditorAttributeList.serviceContainer = this.serviceContainer;
128
- // attributeEditorAttributeList.title =
129
- attributeEditorAttributeList.createElements(properties);
130
- this._designerTabControl.appendChild(attributeEditorAttributeList);
131
- }*/
132
127
  }
133
128
  }
134
129
  else {
@@ -0,0 +1,15 @@
1
+ import { ServiceContainer } from '../../services/ServiceContainer';
2
+ import { BaseCustomWebComponentLazyAppend } from '@node-projects/base-custom-webcomponent';
3
+ import { InstanceServiceContainer } from '../../services/InstanceServiceContainer';
4
+ export declare class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
5
+ static readonly style: CSSStyleSheet;
6
+ static readonly template: HTMLTemplateElement;
7
+ private _type;
8
+ private _id;
9
+ private _pg;
10
+ private _selectionChangedHandler;
11
+ private _instanceServiceContainer;
12
+ constructor();
13
+ set serviceContainer(value: ServiceContainer);
14
+ set instanceServiceContainer(value: InstanceServiceContainer);
15
+ }
@@ -0,0 +1,86 @@
1
+ import { BaseCustomWebComponentLazyAppend, css, html } from '@node-projects/base-custom-webcomponent';
2
+ import { sleep } from '../../helper/Helper.js';
3
+ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
4
+ static style = css `
5
+ :host {
6
+ display: block;
7
+ height: 100%;
8
+ user-select: none;
9
+ background: var(--medium-grey, #2f3545);
10
+ color: white;
11
+ }
12
+ div {
13
+ display: grid;
14
+ grid-template-columns: auto 1fr;
15
+ padding: 6px;
16
+ font-family: monospace;
17
+ align-items: center;
18
+ }
19
+ .desc {
20
+ font-weight: 700;
21
+ font-size: 10px;
22
+ margin-right: 5px;
23
+ }
24
+ input {
25
+ background: var(--medium-grey, #2f3545);
26
+ border: solid 1px gray;
27
+ color: white;
28
+ width: calc(100% - 6px);
29
+ }
30
+ #type {
31
+ color: wheat;
32
+ white-space: nowrap;
33
+ overflow: hidden;
34
+ font-size: 12px;
35
+ height: 20px;
36
+ }
37
+ `;
38
+ static template = html `
39
+ <div>
40
+ <span class="desc">Type:</span><span id="type"></span>
41
+ <span class="desc">Id:</span><input type="text" id="id">
42
+ </div>
43
+ <node-projects-property-grid id="pg"></node-projects-property-grid>
44
+ `;
45
+ _type;
46
+ _id;
47
+ _pg;
48
+ _selectionChangedHandler;
49
+ _instanceServiceContainer;
50
+ constructor() {
51
+ super();
52
+ this._type = this._getDomElement('type');
53
+ this._id = this._getDomElement('id');
54
+ this._pg = this._getDomElement('pg');
55
+ this._id.onkeydown = e => {
56
+ if (e.key == 'Enter')
57
+ this._instanceServiceContainer.selectionService.primarySelection.id = this._id.value;
58
+ else if (e.key == 'Escape') {
59
+ this._id.value = this._instanceServiceContainer.selectionService.primarySelection?.id ?? '';
60
+ e.preventDefault();
61
+ e.stopPropagation();
62
+ }
63
+ };
64
+ let pSel;
65
+ this._id.onfocus = e => {
66
+ pSel = this._instanceServiceContainer.selectionService.primarySelection;
67
+ };
68
+ this._id.onblur = e => {
69
+ pSel.id = this._id.value;
70
+ };
71
+ }
72
+ set serviceContainer(value) {
73
+ this._pg.serviceContainer = value;
74
+ }
75
+ set instanceServiceContainer(value) {
76
+ this._instanceServiceContainer = value;
77
+ this._selectionChangedHandler?.dispose();
78
+ this._selectionChangedHandler = this._instanceServiceContainer.selectionService.onSelectionChanged.on(async (e) => {
79
+ this._pg.instanceServiceContainer = value;
80
+ await sleep(20); // delay assignment a little bit, so onblur above could still set the value.
81
+ this._type.innerText = this._instanceServiceContainer.selectionService.primarySelection?.name ?? '';
82
+ this._id.value = this._instanceServiceContainer.selectionService.primarySelection?.id ?? '';
83
+ });
84
+ }
85
+ }
86
+ customElements.define('node-projects-property-grid-with-header', PropertyGridWithHeader);
@@ -2,16 +2,21 @@ import { BaseCustomWebComponentLazyAppend } from '@node-projects/base-custom-web
2
2
  import { ISelectionChangedEvent } from '../../services/selectionService/ISelectionChangedEvent';
3
3
  import { IDesignItem } from '../../item/IDesignItem';
4
4
  import { ITreeView } from './ITreeView';
5
+ import { InstanceServiceContainer } from '../../services/InstanceServiceContainer.js';
5
6
  export declare class TreeView extends BaseCustomWebComponentLazyAppend implements ITreeView {
6
7
  private _items;
7
8
  private _index;
8
9
  private _previouslySelected;
9
10
  private _treeDiv;
11
+ private _instanceServiceContainer;
12
+ private _selectionChangedHandler;
13
+ private _contentChangedHandler;
10
14
  private _mapElementTreeitem;
11
15
  private _rootItem;
12
16
  static readonly style: CSSStyleSheet;
13
17
  constructor();
14
18
  createTree(rootItem: IDesignItem): void;
19
+ set instanceServiceContainer(value: InstanceServiceContainer);
15
20
  selectionChanged(event: ISelectionChangedEvent): void;
16
21
  private _recomputeTree;
17
22
  private _makeButton;
@@ -5,6 +5,9 @@ export class TreeView extends BaseCustomWebComponentLazyAppend {
5
5
  _index;
6
6
  _previouslySelected;
7
7
  _treeDiv;
8
+ _instanceServiceContainer;
9
+ _selectionChangedHandler;
10
+ _contentChangedHandler;
8
11
  _mapElementTreeitem;
9
12
  _rootItem;
10
13
  //TODO, buuton so key events can be transfered to designer Cnvas (so you can move controls with keys)
@@ -115,6 +118,18 @@ export class TreeView extends BaseCustomWebComponentLazyAppend {
115
118
  this._recomputeTree(rootItem.element, null /*, activeElement */);
116
119
  }
117
120
  // this.instanceServiceContainer.selectionService.setSelectedElements(null);
121
+ set instanceServiceContainer(value) {
122
+ this._instanceServiceContainer = value;
123
+ this._selectionChangedHandler?.dispose();
124
+ this._selectionChangedHandler = this._instanceServiceContainer.selectionService.onSelectionChanged.on(e => {
125
+ this.selectionChanged(e);
126
+ });
127
+ this._contentChangedHandler?.dispose();
128
+ this._contentChangedHandler = this._instanceServiceContainer.contentService.onContentChanged.on(e => {
129
+ this.createTree(value.contentService.rootDesignItem);
130
+ });
131
+ this.createTree(value.contentService.rootDesignItem);
132
+ }
118
133
  selectionChanged(event) {
119
134
  if (event.selectedElements.length > 0) {
120
135
  this._selectTreeElements(event.selectedElements.map(x => this._mapElementTreeitem.get(x.element)));
@@ -2,10 +2,14 @@ import { BaseCustomWebComponentConstructorAppend } from '@node-projects/base-cus
2
2
  import { ITreeView } from './ITreeView';
3
3
  import { IDesignItem } from '../../item/IDesignItem';
4
4
  import { ISelectionChangedEvent } from '../../services/selectionService/ISelectionChangedEvent';
5
+ import { InstanceServiceContainer } from '../../services/InstanceServiceContainer.js';
5
6
  export declare class TreeViewExtended extends BaseCustomWebComponentConstructorAppend implements ITreeView {
6
7
  private _treeDiv;
7
8
  private _tree;
8
9
  private _filter;
10
+ private _instanceServiceContainer;
11
+ private _selectionChangedHandler;
12
+ private _contentChangedHandler;
9
13
  static readonly style: CSSStyleSheet;
10
14
  static readonly template: HTMLTemplateElement;
11
15
  constructor();
@@ -17,6 +21,7 @@ export declare class TreeViewExtended extends BaseCustomWebComponentConstructorA
17
21
  _switchHideAtRunTimeState(img: HTMLImageElement, designItem: IDesignItem): void;
18
22
  ready(): Promise<void>;
19
23
  createTree(rootItem: IDesignItem): void;
24
+ set instanceServiceContainer(value: InstanceServiceContainer);
20
25
  selectionChanged(event: ISelectionChangedEvent): void;
21
26
  private _recomputeTree;
22
27
  private _getChildren;
@@ -5,6 +5,9 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
5
5
  _treeDiv;
6
6
  _tree;
7
7
  _filter;
8
+ _instanceServiceContainer;
9
+ _selectionChangedHandler;
10
+ _contentChangedHandler;
8
11
  static style = css `
9
12
  * {
10
13
  touch-action: none;
@@ -39,14 +42,20 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
39
42
  }
40
43
  td {
41
44
  white-space: nowrap;
42
- }
43
- td:nth-child(n+2) {
44
- text-align: center;
45
+ display: flex;
45
46
  }
46
47
  td > img {
47
48
  vertical-align: middle;
48
49
  }
49
50
 
51
+ .cmd {
52
+ display: flex;
53
+ position: sticky;
54
+ right: 4px;
55
+ align-items: center;
56
+ gap: 2px;
57
+ }
58
+
50
59
  table.fancytree-ext-table tbody tr.fancytree-selected {
51
60
  background-color: #bebebe;
52
61
  }
@@ -58,16 +67,16 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
58
67
  <table id="treetable" style="min-width: 100%;">
59
68
  <colgroup>
60
69
  <col width="*">
70
+ <!--<col width="25px">
61
71
  <col width="25px">
62
- <col width="25px">
63
- <col width="25px">
72
+ <col width="25px">-->
64
73
  </colgroup>
65
74
  <thead style="display: none;">
66
75
  <tr>
67
76
  <th></th>
77
+ <!--<th></th>
68
78
  <th></th>
69
- <th></th>
70
- <th></th>
79
+ <th></th>-->
71
80
  </tr>
72
81
  </thead>
73
82
  </table>
@@ -142,46 +151,27 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
142
151
  },
143
152
  createNode: (event, data) => {
144
153
  let node = data.node;
145
- if (node.tr.children[1]) {
154
+ if (node.tr.children[0]) {
146
155
  let designItem = node.data.ref;
147
- if (designItem.nodeType === NodeType.Element && designItem !== designItem.instanceServiceContainer.contentService.rootDesignItem) {
148
- /*
149
- let toolTipImg: HTMLImageElement;
150
- (<HTMLElement>node.tr.children[0]).onmouseenter = (e) => {
151
- toolTipImg = document.createElement("img");
152
- Screenshot.takeScreenshot(designItem.element).then(x => { if (toolTipImg) toolTipImg.src = x; });
153
- toolTipImg.style.position = 'absolute';
154
- let r = node.tr.children[0].getBoundingClientRect();
155
- toolTipImg.style.left = (e.x + 5 - r.left) + 'px';
156
- toolTipImg.style.top = (e.y + 5 - r.top) + 'px';
157
- (<HTMLElement>node.tr.children[0]).appendChild(toolTipImg);
158
- }
159
- (<HTMLElement>node.tr.children[0]).onmousemove = (e) => {
160
- if (toolTipImg) {
161
- let r = node.tr.children[0].getBoundingClientRect();
162
- toolTipImg.style.left = (e.x + 5 - r.left) + 'px';
163
- toolTipImg.style.top = (e.y + 5 - r.top) + 'px';
164
- }
165
- }
166
- (<HTMLElement>node.tr.children[0]).onmouseout = (e) => {
167
- if (toolTipImg) {
168
- toolTipImg.parentNode?.removeChild(toolTipImg);
169
- toolTipImg = null;
170
- }
171
- }
172
- */
156
+ if (designItem && designItem.nodeType === NodeType.Element && designItem !== designItem.instanceServiceContainer.contentService.rootDesignItem) {
157
+ let d = document.createElement("div");
158
+ d.className = "cmd";
173
159
  let img = document.createElement('img');
174
160
  this._showHideAtDesignTimeState(img, designItem);
175
161
  img.onclick = () => this._switchHideAtDesignTimeState(img, designItem);
176
- node.tr.children[1].appendChild(img);
162
+ img.title = 'hide in designer';
163
+ d.appendChild(img);
177
164
  let imgL = document.createElement('img');
178
165
  this._showLockAtDesignTimeState(imgL, designItem);
179
166
  imgL.onclick = () => this._switchLockAtDesignTimeState(imgL, designItem);
180
- node.tr.children[2].appendChild(imgL);
167
+ imgL.title = 'lock';
168
+ d.appendChild(imgL);
181
169
  let imgH = document.createElement('img');
182
170
  this._showHideAtRunTimeState(imgH, designItem);
183
171
  imgH.onclick = () => this._switchHideAtRunTimeState(imgH, designItem);
184
- node.tr.children[3].appendChild(imgH);
172
+ imgH.title = 'hide at runtime';
173
+ d.appendChild(imgH);
174
+ node.tr.children[0].appendChild(d);
185
175
  }
186
176
  }
187
177
  },
@@ -318,6 +308,18 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
318
308
  this._recomputeTree(rootItem);
319
309
  }
320
310
  }
311
+ set instanceServiceContainer(value) {
312
+ this._instanceServiceContainer = value;
313
+ this._selectionChangedHandler?.dispose();
314
+ this._selectionChangedHandler = this._instanceServiceContainer.selectionService.onSelectionChanged.on(e => {
315
+ this.selectionChanged(e);
316
+ });
317
+ this._contentChangedHandler?.dispose();
318
+ this._contentChangedHandler = this._instanceServiceContainer.contentService.onContentChanged.on(e => {
319
+ this.createTree(value.contentService.rootDesignItem);
320
+ });
321
+ this.createTree(value.contentService.rootDesignItem);
322
+ }
321
323
  selectionChanged(event) {
322
324
  if (event.selectedElements.length > 0) {
323
325
  this._highlight(event.selectedElements);
package/dist/index.d.ts CHANGED
@@ -49,6 +49,8 @@ export * from "./elements/services/instanceService/DefaultInstanceService.js";
49
49
  export type { IInstanceService } from "./elements/services/instanceService/IInstanceService.js";
50
50
  export * from "./elements/services/instanceService/PrepareElementsForDesignerService.js";
51
51
  export type { IPrepareElementsForDesignerService } from "./elements/services/instanceService/IPrepareElementsForDesignerService.js";
52
+ export type { IModelCommandService } from "./elements/services/modelCommandService/IModelCommandService.js";
53
+ export * from "./elements/services/modelCommandService/DefaultModelCommandService.js";
52
54
  export * from "./elements/services/propertiesService/DefaultEditorTypesService.js";
53
55
  export type { IEditorTypesService } from "./elements/services/propertiesService/IEditorTypesService.js";
54
56
  export type { IPropertiesService } from "./elements/services/propertiesService/IPropertiesService.js";
@@ -82,6 +84,7 @@ export type { IServiceContainer } from "./elements/services/IServiceContainer.js
82
84
  export * from "./elements/services/ServiceContainer.js";
83
85
  export * from "./elements/widgets/propertyGrid/PropertyGrid.js";
84
86
  export * from "./elements/widgets/propertyGrid/PropertyGridPropertyList.js";
87
+ export * from "./elements/widgets/propertyGrid/PropertyGridWithHeader.js";
85
88
  export type { IDesignerCanvas } from "./elements/widgets/designerView/IDesignerCanvas.js";
86
89
  export type { IPlacementView } from "./elements/widgets/designerView/IPlacementView.js";
87
90
  export * from "./elements/widgets/designerView/designerView.js";
package/dist/index.js CHANGED
@@ -28,6 +28,7 @@ export * from "./elements/services/htmlParserService/DefaultHtmlParserService.js
28
28
  export * from "./elements/services/htmlParserService/NodeHtmlParserService.js";
29
29
  export * from "./elements/services/instanceService/DefaultInstanceService.js";
30
30
  export * from "./elements/services/instanceService/PrepareElementsForDesignerService.js";
31
+ export * from "./elements/services/modelCommandService/DefaultModelCommandService.js";
31
32
  export * from "./elements/services/propertiesService/DefaultEditorTypesService.js";
32
33
  export * from "./elements/services/propertiesService/services/BaseCustomWebComponentPropertiesService.js";
33
34
  export * from "./elements/services/propertiesService/services/CommonPropertiesService.js";
@@ -52,6 +53,7 @@ export * from "./elements/services/InstanceServiceContainer.js";
52
53
  export * from "./elements/services/ServiceContainer.js";
53
54
  export * from "./elements/widgets/propertyGrid/PropertyGrid.js";
54
55
  export * from "./elements/widgets/propertyGrid/PropertyGridPropertyList.js";
56
+ export * from "./elements/widgets/propertyGrid/PropertyGridWithHeader.js";
55
57
  export * from "./elements/widgets/designerView/designerView.js";
56
58
  export * from "./elements/widgets/designerView/overlayLayerView.js";
57
59
  export * from "./elements/widgets/designerView/defaultConfiguredDesignerView.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.43",
4
+ "version": "0.0.47",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",