@node-projects/web-component-designer 0.1.144 → 0.1.146

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 (28) hide show
  1. package/dist/elements/documentContainer.d.ts +2 -0
  2. package/dist/elements/documentContainer.js +22 -0
  3. package/dist/elements/services/InstanceServiceContainer.d.ts +2 -0
  4. package/dist/elements/services/InstanceServiceContainer.js +1 -0
  5. package/dist/elements/services/propertiesService/IPropertiesService.d.ts +2 -0
  6. package/dist/elements/services/propertiesService/services/AbstractCssPropertiesService.d.ts +7 -0
  7. package/dist/elements/services/propertiesService/services/AbstractCssPropertiesService.js +10 -0
  8. package/dist/elements/services/propertiesService/services/AbstractPropertiesService.d.ts +2 -0
  9. package/dist/elements/services/propertiesService/services/AbstractPropertiesService.js +43 -0
  10. package/dist/elements/services/propertiesService/services/AttributesPropertiesService.d.ts +3 -2
  11. package/dist/elements/services/propertiesService/services/AttributesPropertiesService.js +1 -1
  12. package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService.d.ts +2 -2
  13. package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService.js +4 -4
  14. package/dist/elements/services/propertiesService/services/CssCustomPropertiesService.d.ts +2 -2
  15. package/dist/elements/services/propertiesService/services/CssCustomPropertiesService.js +3 -3
  16. package/dist/elements/services/propertiesService/services/CssPropertiesService copy.d.ts +25 -0
  17. package/dist/elements/services/propertiesService/services/CssPropertiesService copy.js +126 -0
  18. package/dist/elements/services/propertiesService/services/CssPropertiesService.d.ts +2 -2
  19. package/dist/elements/services/propertiesService/services/CssPropertiesService.js +3 -3
  20. package/dist/elements/widgets/propertyGrid/PropertyGrid.d.ts +5 -0
  21. package/dist/elements/widgets/propertyGrid/PropertyGrid.js +5 -1
  22. package/dist/elements/widgets/propertyGrid/PropertyGridPropertyList.d.ts +2 -1
  23. package/dist/elements/widgets/propertyGrid/PropertyGridPropertyList.js +6 -43
  24. package/dist/elements/widgets/propertyGrid/PropertyGridWithHeader.d.ts +3 -1
  25. package/dist/elements/widgets/propertyGrid/PropertyGridWithHeader.js +17 -8
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.js +1 -0
  28. package/package.json +1 -1
@@ -42,6 +42,8 @@ export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend
42
42
  static get style(): CSSStyleSheet;
43
43
  constructor(serviceContainer: ServiceContainer, content?: string);
44
44
  refreshInSplitView(): Promise<void>;
45
+ get currentView(): 'designer' | 'split' | 'code' | 'preview';
46
+ set currentView(view: 'designer' | 'split' | 'code' | 'preview');
45
47
  designerSelectionChanged(e: ISelectionChangedEvent): void;
46
48
  designerContentChanged(): void;
47
49
  dispose(): void;
@@ -85,6 +85,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
85
85
  this._designerDiv.title = 'Designer';
86
86
  this._designerDiv.appendChild(this.designerView);
87
87
  this.designerView.initialize(this._serviceContainer);
88
+ this.designerView.instanceServiceContainer.documentContainer = this;
88
89
  this.designerView.instanceServiceContainer.selectionService.onSelectionChanged.on(e => this.designerSelectionChanged(e));
89
90
  this.designerView.designerCanvas.onContentChanged.on(() => this.designerContentChanged());
90
91
  this.codeView = new serviceContainer.config.codeViewWidget();
@@ -125,6 +126,27 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
125
126
  }
126
127
  this._disableChangeNotificationEditor = false;
127
128
  }
129
+ get currentView() {
130
+ if (this._tabControl.selectedIndex == tabIndex.designer)
131
+ return 'designer';
132
+ if (this._tabControl.selectedIndex == tabIndex.split)
133
+ return 'split';
134
+ if (this._tabControl.selectedIndex == tabIndex.code)
135
+ return 'code';
136
+ if (this._tabControl.selectedIndex == tabIndex.preview)
137
+ return 'preview';
138
+ return null;
139
+ }
140
+ set currentView(view) {
141
+ if (view == 'designer')
142
+ this._tabControl.selectedIndex = tabIndex.designer;
143
+ if (view == 'split')
144
+ this._tabControl.selectedIndex = tabIndex.split;
145
+ if (view == 'code')
146
+ this._tabControl.selectedIndex = tabIndex.code;
147
+ if (view == 'preview')
148
+ this._tabControl.selectedIndex = tabIndex.preview;
149
+ }
128
150
  designerSelectionChanged(e) {
129
151
  if (this._tabControl.selectedIndex === tabIndex.split) {
130
152
  let primarySelection = this.instanceServiceContainer.selectionService.primarySelection;
@@ -6,6 +6,7 @@ import { IDesignContext } from '../widgets/designerView/IDesignContext.js';
6
6
  import { IDesignerCanvas } from '../widgets/designerView/IDesignerCanvas.js';
7
7
  import { IStylesheetService } from './stylesheetService/IStylesheetService.js';
8
8
  import { IDesignItemDocumentPositionService } from './designItemDocumentPositionService/IDesignItemDocumentPositionService.js';
9
+ import { DocumentContainer } from '../documentContainer.js';
9
10
  interface InstanceServiceNameMap {
10
11
  "undoService": IUndoService;
11
12
  "selectionService": ISelectionService;
@@ -17,6 +18,7 @@ export declare class InstanceServiceContainer extends BaseServiceContainer<Insta
17
18
  designContext: IDesignContext;
18
19
  readonly designerCanvas: IDesignerCanvas;
19
20
  designer: any;
21
+ documentContainer: DocumentContainer;
20
22
  constructor(designerCanvas: IDesignerCanvas);
21
23
  get undoService(): IUndoService;
22
24
  get selectionService(): ISelectionService;
@@ -4,6 +4,7 @@ export class InstanceServiceContainer extends BaseServiceContainer {
4
4
  designContext = new DesignContext();
5
5
  designerCanvas;
6
6
  designer; //usable to assign designer from outside
7
+ documentContainer; //usable to assign designer from outside
7
8
  constructor(designerCanvas) {
8
9
  super();
9
10
  this.designerCanvas = designerCanvas;
@@ -5,6 +5,7 @@ import { ValueType } from './ValueType.js';
5
5
  import { BindingTarget } from '../../item/BindingTarget.js';
6
6
  import { IBinding } from '../../item/IBinding.js';
7
7
  import { IPropertyGroup } from './IPropertyGroup.js';
8
+ import { IContextMenuItem } from '../../helper/contextMenu/IContextMenuItem.js';
8
9
  export declare enum RefreshMode {
9
10
  none = 0,
10
11
  full = 1,
@@ -22,4 +23,5 @@ export interface IPropertiesService extends IService {
22
23
  isSet(designItems: IDesignItem[], property: IProperty): ValueType;
23
24
  getValue(designItems: IDesignItem[], property: IProperty): any;
24
25
  getUnsetValue(designItems: IDesignItem[], property: IProperty): any;
26
+ getContextMenu(designItems: IDesignItem[], property: IProperty): IContextMenuItem[];
25
27
  }
@@ -0,0 +1,7 @@
1
+ import { IDesignItem } from '../../../item/IDesignItem.js';
2
+ import { CommonPropertiesService } from './CommonPropertiesService.js';
3
+ import { RefreshMode } from '../IPropertiesService.js';
4
+ export declare abstract class AbstractCssPropertiesService extends CommonPropertiesService {
5
+ getRefreshMode(designItem: IDesignItem): RefreshMode;
6
+ constructor();
7
+ }
@@ -0,0 +1,10 @@
1
+ import { CommonPropertiesService } from './CommonPropertiesService.js';
2
+ import { RefreshMode } from '../IPropertiesService.js';
3
+ export class AbstractCssPropertiesService extends CommonPropertiesService {
4
+ getRefreshMode(designItem) {
5
+ return RefreshMode.none;
6
+ }
7
+ constructor() {
8
+ super(false);
9
+ }
10
+ }
@@ -5,6 +5,7 @@ import { ValueType } from '../ValueType.js';
5
5
  import { BindingTarget } from '../../../item/BindingTarget.js';
6
6
  import { IBinding } from '../../../item/IBinding.js';
7
7
  import { IPropertyGroup } from '../IPropertyGroup.js';
8
+ import { IContextMenuItem } from '../../../helper/contextMenu/IContextMenuItem.js';
8
9
  export declare abstract class AbstractPropertiesService implements IPropertiesService {
9
10
  constructor(recreateElementsOnPropertyChange?: boolean);
10
11
  protected _recreateElementsOnPropertyChange: boolean;
@@ -26,4 +27,5 @@ export declare abstract class AbstractPropertiesService implements IPropertiesSe
26
27
  getBinding(designItems: IDesignItem[], property: IProperty): IBinding;
27
28
  getUnsetValue(designItems: IDesignItem[], property: IProperty): any;
28
29
  protected static recreateElements(service: IPropertiesService, designItems: IDesignItem[]): void;
30
+ getContextMenu(designItems: IDesignItem[], property: IProperty): IContextMenuItem[];
29
31
  }
@@ -271,4 +271,47 @@ export class AbstractPropertiesService {
271
271
  d.replaceNode(element);
272
272
  }
273
273
  }
274
+ getContextMenu(designItems, property) {
275
+ const ctxMenuItems = [
276
+ {
277
+ title: 'clear', action: (e) => {
278
+ property.service.clearValue(designItems, property, 'value');
279
+ designItems[0].instanceServiceContainer.designerCanvas.extensionManager.refreshAllExtensions(designItems);
280
+ }
281
+ },
282
+ {
283
+ title: 'edit as text', action: (e, _1, _2, menu) => {
284
+ menu.close();
285
+ setTimeout(() => {
286
+ const oldValue = property.service.getValue(designItems, property);
287
+ let value = prompt(`edit value of '${property.name}' as string:`, oldValue);
288
+ if (value && value != oldValue) {
289
+ property.service.setValue(designItems, property, value);
290
+ }
291
+ designItems[0].instanceServiceContainer.designerCanvas.extensionManager.refreshAllExtensions(designItems);
292
+ }, 10);
293
+ }
294
+ },
295
+ ];
296
+ if (designItems[0].serviceContainer.config.openBindingsEditor) {
297
+ ctxMenuItems.push(...[
298
+ { title: '-' },
299
+ {
300
+ title: 'edit binding', action: () => {
301
+ let target = property.service.getPropertyTarget(designItems[0], property);
302
+ let binding = property.service.getBinding(designItems, property);
303
+ designItems[0].serviceContainer.config.openBindingsEditor(property, designItems, binding, target);
304
+ }
305
+ },
306
+ {
307
+ title: 'clear binding', action: () => {
308
+ property.service.clearValue(designItems, property, 'binding');
309
+ designItems[0].instanceServiceContainer.designerCanvas.extensionManager.refreshAllExtensions(designItems);
310
+ }
311
+ }
312
+ ]);
313
+ }
314
+ ;
315
+ return ctxMenuItems;
316
+ }
274
317
  }
@@ -1,11 +1,12 @@
1
- import { IPropertiesService, RefreshMode } from '../IPropertiesService.js';
1
+ import { RefreshMode } from '../IPropertiesService.js';
2
2
  import { IProperty } from '../IProperty.js';
3
3
  import { IDesignItem } from '../../../item/IDesignItem.js';
4
4
  import { ValueType } from '../ValueType.js';
5
5
  import { IBinding } from "../../../item/IBinding.js";
6
6
  import { BindingTarget } from '../../../item/BindingTarget.js';
7
7
  import { IPropertyGroup } from '../IPropertyGroup.js';
8
- export declare class AttributesPropertiesService implements IPropertiesService {
8
+ import { AbstractPropertiesService } from './AbstractPropertiesService.js';
9
+ export declare class AttributesPropertiesService extends AbstractPropertiesService {
9
10
  name: string;
10
11
  getRefreshMode(designItem: IDesignItem): RefreshMode;
11
12
  isHandledElement(designItem: IDesignItem): boolean;
@@ -4,7 +4,7 @@ import { BindingTarget } from '../../../item/BindingTarget.js';
4
4
  import { PropertyType } from '../PropertyType.js';
5
5
  import { PropertiesHelper } from './PropertiesHelper.js';
6
6
  import { AbstractPropertiesService } from './AbstractPropertiesService.js';
7
- export class AttributesPropertiesService {
7
+ export class AttributesPropertiesService extends AbstractPropertiesService {
8
8
  name = "attributes";
9
9
  getRefreshMode(designItem) {
10
10
  return RefreshMode.fullOnValueChange;
@@ -3,10 +3,10 @@ import { IDesignItem } from '../../../item/IDesignItem.js';
3
3
  import { RefreshMode } from '../IPropertiesService.js';
4
4
  import { IPropertyGroup } from '../IPropertyGroup.js';
5
5
  import { IStyleDeclaration, IStyleRule } from '../../stylesheetService/IStylesheetService.js';
6
- import { CommonPropertiesService } from './CommonPropertiesService.js';
7
6
  import { ValueType } from '../ValueType.js';
8
7
  import { BindingTarget } from '../../../item/BindingTarget.js';
9
- export declare class CssCurrentPropertiesService extends CommonPropertiesService {
8
+ import { AbstractCssPropertiesService } from './AbstractCssPropertiesService.js';
9
+ export declare class CssCurrentPropertiesService extends AbstractCssPropertiesService {
10
10
  getRefreshMode(designItem: IDesignItem): RefreshMode;
11
11
  constructor();
12
12
  isHandledElement(designItem: IDesignItem): boolean;
@@ -1,17 +1,17 @@
1
1
  import { PropertyType } from '../PropertyType.js';
2
2
  import { RefreshMode } from '../IPropertiesService.js';
3
- import { CommonPropertiesService } from './CommonPropertiesService.js';
4
3
  import { ValueType } from '../ValueType.js';
5
4
  import { NodeType } from '../../../item/NodeType.js';
6
5
  import cssProperties from "./CssProperties.json" with { type: 'json' };
7
6
  import { BindingTarget } from '../../../item/BindingTarget.js';
7
+ import { AbstractCssPropertiesService } from './AbstractCssPropertiesService.js';
8
8
  const localName = '&lt;local&gt;';
9
- export class CssCurrentPropertiesService extends CommonPropertiesService {
9
+ export class CssCurrentPropertiesService extends AbstractCssPropertiesService {
10
10
  getRefreshMode(designItem) {
11
11
  return RefreshMode.fullOnValueChange;
12
12
  }
13
13
  constructor() {
14
- super(false);
14
+ super();
15
15
  this.name = 'styles';
16
16
  }
17
17
  isHandledElement(designItem) {
@@ -87,7 +87,7 @@ export class CssCurrentPropertiesService extends CommonPropertiesService {
87
87
  if (designItems[0].hasStyle(property.name))
88
88
  return ValueType.none;
89
89
  //TODO: we need to check if this is the dec. with the highest specifity
90
- return ValueType.all;
90
+ return ValueType.fromStylesheet;
91
91
  }
92
92
  return super.isSet(designItems, property);
93
93
  }
@@ -2,10 +2,10 @@ import { IProperty } from '../IProperty.js';
2
2
  import { IDesignItem } from '../../../item/IDesignItem.js';
3
3
  import { RefreshMode } from '../IPropertiesService.js';
4
4
  import { IPropertyGroup } from '../IPropertyGroup.js';
5
- import { CommonPropertiesService } from './CommonPropertiesService.js';
6
5
  import { ValueType } from '../ValueType.js';
7
6
  import { BindingTarget } from '../../../item/BindingTarget.js';
8
- export declare class CssCustomPropertiesService extends CommonPropertiesService {
7
+ import { AbstractCssPropertiesService } from './AbstractCssPropertiesService.js';
8
+ export declare class CssCustomPropertiesService extends AbstractCssPropertiesService {
9
9
  removeInheritedCustomProperties: boolean;
10
10
  constructor(removeInheritedCustomProperties?: boolean);
11
11
  getRefreshMode(designItem: IDesignItem): RefreshMode;
@@ -1,12 +1,12 @@
1
1
  import { PropertyType } from '../PropertyType.js';
2
2
  import { RefreshMode } from '../IPropertiesService.js';
3
- import { CommonPropertiesService } from './CommonPropertiesService.js';
4
3
  import { ValueType } from '../ValueType.js';
5
4
  import { BindingTarget } from '../../../item/BindingTarget.js';
6
- export class CssCustomPropertiesService extends CommonPropertiesService {
5
+ import { AbstractCssPropertiesService } from './AbstractCssPropertiesService.js';
6
+ export class CssCustomPropertiesService extends AbstractCssPropertiesService {
7
7
  removeInheritedCustomProperties;
8
8
  constructor(removeInheritedCustomProperties = true) {
9
- super(false);
9
+ super();
10
10
  this.name = 'customProperties';
11
11
  this.removeInheritedCustomProperties = removeInheritedCustomProperties;
12
12
  }
@@ -0,0 +1,25 @@
1
+ import { IProperty } from '../IProperty.js';
2
+ import { IDesignItem } from '../../../item/IDesignItem.js';
3
+ import { BindingTarget } from '../../../item/BindingTarget.js';
4
+ import { CommonPropertiesService } from './CommonPropertiesService.js';
5
+ import { RefreshMode } from '../IPropertiesService.js';
6
+ import { IPropertyGroup } from '../IPropertyGroup.js';
7
+ export declare class CssPropertiesService extends CommonPropertiesService {
8
+ getRefreshMode(designItem: IDesignItem): RefreshMode;
9
+ layout: {
10
+ common: string[];
11
+ font: string[];
12
+ layout: string[];
13
+ };
14
+ grid: string[];
15
+ gridChild: string[];
16
+ flex: string[];
17
+ flexChild: string[];
18
+ svg: string[];
19
+ constructor(name: 'layout' | 'grid' | 'gridChild' | 'flex' | 'flexChild' | 'svg');
20
+ isHandledElement(designItem: IDesignItem): boolean;
21
+ getProperty(designItem: IDesignItem, name: string): IProperty;
22
+ getProperties(designItem: IDesignItem): IProperty[] | IPropertyGroup[];
23
+ _getPropertyDef(name: string): IProperty;
24
+ getPropertyTarget(designItem: IDesignItem, property: IProperty): BindingTarget;
25
+ }
@@ -0,0 +1,126 @@
1
+ import { BindingTarget } from '../../../item/BindingTarget.js';
2
+ import { PropertyType } from '../PropertyType.js';
3
+ import { CommonPropertiesService } from './CommonPropertiesService.js';
4
+ import { RefreshMode } from '../IPropertiesService.js';
5
+ import { PropertiesHelper } from './PropertiesHelper.js';
6
+ import { GridAssignedRowColumnPropertyEditor } from '../propertyEditors/special/GridAssignedRowColumnPropertyEditor.js';
7
+ import { MetricsPropertyEditor } from '../propertyEditors/special/MetricsPropertyEditor.js';
8
+ import cssProperties from "./CssProperties.json" with { type: 'json' };
9
+ export class CssPropertiesService extends CommonPropertiesService {
10
+ getRefreshMode(designItem) {
11
+ return RefreshMode.none;
12
+ }
13
+ //metrics
14
+ layout = {
15
+ "common": [
16
+ "display",
17
+ "color",
18
+ "background-color",
19
+ "box-sizing",
20
+ "border",
21
+ "box-shadow",
22
+ "opacity",
23
+ "position",
24
+ ],
25
+ "font": [
26
+ "font-family",
27
+ "font-size",
28
+ "font-weight",
29
+ ],
30
+ "layout": [
31
+ "inset",
32
+ "margin",
33
+ "border",
34
+ "padding",
35
+ "overflow",
36
+ "metrics"
37
+ ]
38
+ };
39
+ grid = [
40
+ "display",
41
+ "position",
42
+ "grid-template-columns",
43
+ "grid-template-rows",
44
+ "column-gap",
45
+ "row-gap",
46
+ "align-content",
47
+ "justify-content",
48
+ "align-items",
49
+ "justify-items",
50
+ ];
51
+ gridChild = [
52
+ "grid-row",
53
+ "grid-column",
54
+ "assigned-row-column",
55
+ "align-self",
56
+ "justify-self"
57
+ ];
58
+ flex = [
59
+ "display",
60
+ "position",
61
+ "flex-direction",
62
+ "flex-wrap",
63
+ "align-content",
64
+ "justify-content",
65
+ "align-items"
66
+ ];
67
+ flexChild = [
68
+ "align-self",
69
+ "justify-self"
70
+ ];
71
+ svg = [
72
+ "fill",
73
+ "fill-rule",
74
+ "fill-opacity",
75
+ "stroke",
76
+ "stroke-width",
77
+ "stroke-dasharray",
78
+ "stroke-dashoffset",
79
+ "stroke-opacity"
80
+ ];
81
+ constructor(name) {
82
+ super(false);
83
+ this.name = name;
84
+ }
85
+ isHandledElement(designItem) {
86
+ return true;
87
+ }
88
+ getProperty(designItem, name) {
89
+ return this._getPropertyDef(name);
90
+ }
91
+ getProperties(designItem) {
92
+ const propNames = this[this.name];
93
+ if (Array.isArray(propNames)) {
94
+ const propertiesList = propNames.map(x => this._getPropertyDef(x));
95
+ return propertiesList;
96
+ }
97
+ else {
98
+ let grps = [];
99
+ for (let g in propNames) {
100
+ let grp = { name: g, properties: propNames[g].map(x => this._getPropertyDef(x)) };
101
+ grps.push(grp);
102
+ }
103
+ return grps;
104
+ }
105
+ }
106
+ _getPropertyDef(name) {
107
+ const camelName = PropertiesHelper.dashToCamelCase(name);
108
+ switch (camelName) {
109
+ case 'assignedRowColumn':
110
+ return { name, service: this, propertyType: PropertyType.complex, createEditor: (p) => new GridAssignedRowColumnPropertyEditor(p) };
111
+ case 'metrics':
112
+ return { name, service: this, propertyType: PropertyType.complex, createEditor: (p) => new MetricsPropertyEditor(p) };
113
+ default:
114
+ return {
115
+ name,
116
+ type: cssProperties[camelName]?.type ?? 'string',
117
+ values: cssProperties[camelName]?.values ? [...cssProperties[camelName]?.values, 'initial', 'inherit', 'unset'] : ['initial', 'inherit', 'unset'],
118
+ service: this,
119
+ propertyType: PropertyType.cssValue
120
+ };
121
+ }
122
+ }
123
+ getPropertyTarget(designItem, property) {
124
+ return BindingTarget.css;
125
+ }
126
+ }
@@ -1,10 +1,10 @@
1
1
  import { IProperty } from '../IProperty.js';
2
2
  import { IDesignItem } from '../../../item/IDesignItem.js';
3
3
  import { BindingTarget } from '../../../item/BindingTarget.js';
4
- import { CommonPropertiesService } from './CommonPropertiesService.js';
5
4
  import { RefreshMode } from '../IPropertiesService.js';
6
5
  import { IPropertyGroup } from '../IPropertyGroup.js';
7
- export declare class CssPropertiesService extends CommonPropertiesService {
6
+ import { AbstractCssPropertiesService } from './AbstractCssPropertiesService.js';
7
+ export declare class CssPropertiesService extends AbstractCssPropertiesService {
8
8
  getRefreshMode(designItem: IDesignItem): RefreshMode;
9
9
  layout: {
10
10
  common: string[];
@@ -1,12 +1,12 @@
1
1
  import { BindingTarget } from '../../../item/BindingTarget.js';
2
2
  import { PropertyType } from '../PropertyType.js';
3
- import { CommonPropertiesService } from './CommonPropertiesService.js';
4
3
  import { RefreshMode } from '../IPropertiesService.js';
5
4
  import { PropertiesHelper } from './PropertiesHelper.js';
6
5
  import { GridAssignedRowColumnPropertyEditor } from '../propertyEditors/special/GridAssignedRowColumnPropertyEditor.js';
7
6
  import { MetricsPropertyEditor } from '../propertyEditors/special/MetricsPropertyEditor.js';
8
7
  import cssProperties from "./CssProperties.json" with { type: 'json' };
9
- export class CssPropertiesService extends CommonPropertiesService {
8
+ import { AbstractCssPropertiesService } from './AbstractCssPropertiesService.js';
9
+ export class CssPropertiesService extends AbstractCssPropertiesService {
10
10
  getRefreshMode(designItem) {
11
11
  return RefreshMode.none;
12
12
  }
@@ -79,7 +79,7 @@ export class CssPropertiesService extends CommonPropertiesService {
79
79
  "stroke-opacity"
80
80
  ];
81
81
  constructor(name) {
82
- super(false);
82
+ super();
83
83
  this.name = name;
84
84
  }
85
85
  isHandledElement(designItem) {
@@ -3,6 +3,8 @@ import { IDesignItem } from '../../item/IDesignItem.js';
3
3
  import { BaseCustomWebComponentLazyAppend } from '@node-projects/base-custom-webcomponent';
4
4
  import { InstanceServiceContainer } from '../../services/InstanceServiceContainer.js';
5
5
  import { IPropertyGroup } from '../../services/propertiesService/IPropertyGroup.js';
6
+ import { IProperty } from '../../services/propertiesService/IProperty.js';
7
+ import { IContextMenuItem } from '../../helper/contextMenu/IContextMenuItem.js';
6
8
  export declare class PropertyGrid extends BaseCustomWebComponentLazyAppend {
7
9
  private _serviceContainer;
8
10
  private _designerTabControl;
@@ -15,11 +17,14 @@ export declare class PropertyGrid extends BaseCustomWebComponentLazyAppend {
15
17
  private _selectionChangedHandler;
16
18
  propertyGroupHover: (group: IPropertyGroup, part: 'name' | 'desc') => boolean;
17
19
  propertyGroupClick: (group: IPropertyGroup, part: 'name' | 'desc') => void;
20
+ propertyContextMenuProvider: (designItems: IDesignItem[], property: IProperty) => IContextMenuItem[];
18
21
  static readonly style: CSSStyleSheet;
19
22
  static readonly properties: {
20
23
  serviceContainer: ObjectConstructor;
21
24
  instanceServiceContainer: ObjectConstructor;
22
25
  selectedItems: ArrayConstructor;
26
+ propertyGroupHover: FunctionConstructor;
27
+ propertyGroupClick: FunctionConstructor;
23
28
  };
24
29
  constructor();
25
30
  set serviceContainer(value: ServiceContainer);
@@ -14,6 +14,7 @@ export class PropertyGrid extends BaseCustomWebComponentLazyAppend {
14
14
  _selectionChangedHandler;
15
15
  propertyGroupHover;
16
16
  propertyGroupClick;
17
+ propertyContextMenuProvider;
17
18
  static style = css `
18
19
  :host {
19
20
  display: block;
@@ -31,7 +32,9 @@ export class PropertyGrid extends BaseCustomWebComponentLazyAppend {
31
32
  static properties = {
32
33
  serviceContainer: Object,
33
34
  instanceServiceContainer: Object,
34
- selectedItems: Array
35
+ selectedItems: Array,
36
+ propertyGroupHover: Function,
37
+ propertyGroupClick: Function
35
38
  };
36
39
  constructor() {
37
40
  super();
@@ -75,6 +78,7 @@ export class PropertyGrid extends BaseCustomWebComponentLazyAppend {
75
78
  lst.title = p.name;
76
79
  lst.propertyGroupHover = this.propertyGroupHover;
77
80
  lst.propertyGroupClick = this.propertyGroupClick;
81
+ lst.propertyContextMenuProvider = this.propertyContextMenuProvider;
78
82
  this._designerTabControl.appendChild(lst);
79
83
  this._propertyGridPropertyLists.push(lst);
80
84
  this._propertyGridPropertyListsDict[p.name] = lst;
@@ -5,6 +5,7 @@ import { IPropertyEditor } from '../../services/propertiesService/IPropertyEdito
5
5
  import { IDesignItem } from '../../item/IDesignItem.js';
6
6
  import { IPropertiesService } from '../../services/propertiesService/IPropertiesService.js';
7
7
  import { IPropertyGroup } from '../../services/propertiesService/IPropertyGroup.js';
8
+ import { IContextMenuItem } from '../../helper/contextMenu/IContextMenuItem.js';
8
9
  export declare class PropertyGridPropertyList extends BaseCustomWebComponentLazyAppend {
9
10
  private _div;
10
11
  private _propertyMap;
@@ -13,6 +14,7 @@ export declare class PropertyGridPropertyList extends BaseCustomWebComponentLazy
13
14
  private _designItems;
14
15
  propertyGroupHover: (group: IPropertyGroup, part: 'name' | 'desc') => boolean;
15
16
  propertyGroupClick: (group: IPropertyGroup, part: 'name' | 'desc') => void;
17
+ propertyContextMenuProvider: (designItems: IDesignItem[], property: IProperty) => IContextMenuItem[];
16
18
  get propertiesService(): IPropertiesService;
17
19
  static get style(): CSSStyleSheet;
18
20
  constructor(serviceContainer: ServiceContainer);
@@ -24,7 +26,6 @@ export declare class PropertyGridPropertyList extends BaseCustomWebComponentLazy
24
26
  private _onDragOver;
25
27
  private _onDrop;
26
28
  openContextMenu(event: MouseEvent, property: IProperty): void;
27
- static openContextMenu(event: MouseEvent, designItems: IDesignItem[], property: IProperty): void;
28
29
  designItemsChanged(designItems: IDesignItem[]): void;
29
30
  refreshForDesignItems(items: IDesignItem[]): void;
30
31
  static refreshIsSetElementAndEditorForDesignItems(isSetElement: HTMLElement, property: IProperty, items: IDesignItem[], propertiesService: IPropertiesService, editor?: IPropertyEditor): void;
@@ -12,6 +12,7 @@ export class PropertyGridPropertyList extends BaseCustomWebComponentLazyAppend {
12
12
  _designItems;
13
13
  propertyGroupHover;
14
14
  propertyGroupClick;
15
+ propertyContextMenuProvider;
15
16
  get propertiesService() {
16
17
  return this._propertiesService;
17
18
  }
@@ -312,49 +313,11 @@ export class PropertyGridPropertyList extends BaseCustomWebComponentLazyAppend {
312
313
  }
313
314
  }
314
315
  openContextMenu(event, property) {
315
- PropertyGridPropertyList.openContextMenu(event, this._designItems, property);
316
- }
317
- static openContextMenu(event, designItems, property) {
318
- const ctxMenuItems = [
319
- {
320
- title: 'clear', action: (e) => {
321
- property.service.clearValue(designItems, property, 'value');
322
- designItems[0].instanceServiceContainer.designerCanvas.extensionManager.refreshAllExtensions(designItems);
323
- }
324
- },
325
- {
326
- title: 'edit as text', action: (e, _1, _2, menu) => {
327
- menu.close();
328
- setTimeout(() => {
329
- const oldValue = property.service.getValue(designItems, property);
330
- let value = prompt(`edit value of '${property.name}' as string:`, oldValue);
331
- if (value && value != oldValue) {
332
- property.service.setValue(designItems, property, value);
333
- }
334
- designItems[0].instanceServiceContainer.designerCanvas.extensionManager.refreshAllExtensions(designItems);
335
- }, 10);
336
- }
337
- },
338
- ];
339
- if (designItems[0].serviceContainer.config.openBindingsEditor) {
340
- ctxMenuItems.push(...[
341
- { title: '-' },
342
- {
343
- title: 'edit binding', action: () => {
344
- let target = property.service.getPropertyTarget(designItems[0], property);
345
- let binding = property.service.getBinding(designItems, property);
346
- designItems[0].serviceContainer.config.openBindingsEditor(property, designItems, binding, target);
347
- }
348
- },
349
- {
350
- title: 'clear binding', action: () => {
351
- property.service.clearValue(designItems, property, 'binding');
352
- designItems[0].instanceServiceContainer.designerCanvas.extensionManager.refreshAllExtensions(designItems);
353
- }
354
- }
355
- ]);
356
- }
357
- ;
316
+ let ctxMenuItems;
317
+ if (this.propertyContextMenuProvider)
318
+ ctxMenuItems = this.propertyContextMenuProvider(this._designItems, property);
319
+ if (!ctxMenuItems)
320
+ ctxMenuItems = property.service.getContextMenu(this._designItems, property);
358
321
  ContextMenu.show(ctxMenuItems, event);
359
322
  }
360
323
  designItemsChanged(designItems) {
@@ -1,13 +1,14 @@
1
1
  import { ServiceContainer } from '../../services/ServiceContainer.js';
2
2
  import { BaseCustomWebComponentLazyAppend } from '@node-projects/base-custom-webcomponent';
3
+ import { PropertyGrid } from './PropertyGrid.js';
3
4
  import { InstanceServiceContainer } from '../../services/InstanceServiceContainer.js';
4
5
  export declare class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
5
6
  static readonly style: CSSStyleSheet;
6
7
  static readonly template: HTMLTemplateElement;
8
+ propertyGrid: PropertyGrid;
7
9
  private _type;
8
10
  private _id;
9
11
  private _content;
10
- private _pg;
11
12
  private _selectionChangedHandler;
12
13
  private _instanceServiceContainer;
13
14
  private _idRect;
@@ -18,4 +19,5 @@ export declare class PropertyGridWithHeader extends BaseCustomWebComponentLazyAp
18
19
  constructor();
19
20
  set serviceContainer(value: ServiceContainer);
20
21
  set instanceServiceContainer(value: InstanceServiceContainer);
22
+ private _openContextMenu;
21
23
  }
@@ -3,6 +3,7 @@ import { sleep } from '../../helper/Helper.js';
3
3
  import { NodeType } from '../../item/NodeType.js';
4
4
  import { PropertyGridPropertyList } from './PropertyGridPropertyList.js';
5
5
  import { ContentAndIdPropertiesService } from '../../services/propertiesService/services/ContentAndIdPropertiesService.js';
6
+ import { ContextMenu } from '../../helper/contextMenu/ContextMenu.js';
6
7
  export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
7
8
  static style = css `
8
9
  :host {
@@ -54,10 +55,10 @@ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
54
55
  <span id="contentSpan" class="desc">Content:</span><input type="text" id="content">
55
56
  </div>
56
57
  <node-projects-web-component-designer-property-grid id="pg"></node-projects-web-component-designer-property-grid>`;
58
+ propertyGrid;
57
59
  _type;
58
60
  _id;
59
61
  _content;
60
- _pg;
61
62
  _selectionChangedHandler;
62
63
  _instanceServiceContainer;
63
64
  _idRect;
@@ -71,7 +72,7 @@ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
71
72
  this._type = this._getDomElement('type');
72
73
  this._id = this._getDomElement('id');
73
74
  this._content = this._getDomElement('content');
74
- this._pg = this._getDomElement('pg');
75
+ this.propertyGrid = this._getDomElement('pg');
75
76
  this._idRect = this._getDomElement('idRect');
76
77
  this._contentRect = this._getDomElement('contentRect');
77
78
  this._innerRect = this._getDomElement('innerRect');
@@ -85,17 +86,17 @@ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
85
86
  this._idRect.oncontextmenu = (event) => {
86
87
  event.preventDefault();
87
88
  if (!this._instanceServiceContainer.selectionService.primarySelection?.isRootItem)
88
- PropertyGridPropertyList.openContextMenu(event, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService.idProperty);
89
+ this._openContextMenu(event, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService.idProperty);
89
90
  };
90
91
  this._contentRect.oncontextmenu = (event) => {
91
92
  event.preventDefault();
92
93
  if (!this._instanceServiceContainer.selectionService.primarySelection?.isRootItem)
93
- PropertyGridPropertyList.openContextMenu(event, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService.contentProperty);
94
+ this._openContextMenu(event, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService.contentProperty);
94
95
  };
95
96
  this._innerRect.oncontextmenu = (event) => {
96
97
  event.preventDefault();
97
98
  if (!this._instanceServiceContainer.selectionService.primarySelection?.isRootItem)
98
- PropertyGridPropertyList.openContextMenu(event, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService.innerHtmlProperty);
99
+ this._openContextMenu(event, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService.innerHtmlProperty);
99
100
  };
100
101
  this._id.onkeydown = e => {
101
102
  if (e.key == 'Enter')
@@ -132,13 +133,13 @@ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
132
133
  };
133
134
  }
134
135
  set serviceContainer(value) {
135
- this._pg.serviceContainer = value;
136
+ this.propertyGrid.serviceContainer = value;
136
137
  }
137
138
  set instanceServiceContainer(value) {
138
139
  this._instanceServiceContainer = value;
139
140
  this._selectionChangedHandler?.dispose();
140
141
  this._selectionChangedHandler = this._instanceServiceContainer.selectionService.onSelectionChanged.on(async (e) => {
141
- this._pg.instanceServiceContainer = value;
142
+ this.propertyGrid.instanceServiceContainer = value;
142
143
  await sleep(20); // delay assignment a little bit, so onblur above could still set the value.
143
144
  if (this._instanceServiceContainer.selectionService?.primarySelection?.isRootItem) {
144
145
  this._configButton.style.display = 'none';
@@ -183,7 +184,15 @@ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
183
184
  PropertyGridPropertyList.refreshIsSetElementAndEditorForDesignItems(this._innerRect, this._propertiesService.innerHtmlProperty, this._instanceServiceContainer.selectionService.selectedElements, this._propertiesService);
184
185
  }
185
186
  });
186
- this._pg.instanceServiceContainer = value;
187
+ this.propertyGrid.instanceServiceContainer = value;
188
+ }
189
+ _openContextMenu(event, designItems, property) {
190
+ let ctxMenuItems;
191
+ if (this.propertyGrid.propertyContextMenuProvider)
192
+ ctxMenuItems = this.propertyGrid.propertyContextMenuProvider(designItems, property);
193
+ if (!ctxMenuItems)
194
+ ctxMenuItems = property.service.getContextMenu(designItems, property);
195
+ ContextMenu.show(ctxMenuItems, event);
187
196
  }
188
197
  }
189
198
  customElements.define('node-projects-web-component-designer-property-grid-with-header', PropertyGridWithHeader);
package/dist/index.d.ts CHANGED
@@ -109,6 +109,7 @@ export * from "./elements/services/propertiesService/propertyEditors/special/Met
109
109
  export * from "./elements/services/propertiesService/propertyEditors/special/GridAssignedRowColumnPropertyEditor.js";
110
110
  export * from "./elements/services/propertiesService/services/PropertiesHelper.js";
111
111
  export * from "./elements/services/propertiesService/services/AttachedPropertiesService.js";
112
+ export * from "./elements/services/propertiesService/services/AbstractCssPropertiesService.js";
112
113
  export * from "./elements/services/propertiesService/services/BaseCustomWebComponentPropertiesService.js";
113
114
  export * from "./elements/services/propertiesService/services/BasicWebcomponentPropertiesService.js";
114
115
  export * from "./elements/services/propertiesService/services/CommonPropertiesService.js";
package/dist/index.js CHANGED
@@ -68,6 +68,7 @@ export * from "./elements/services/propertiesService/propertyEditors/special/Met
68
68
  export * from "./elements/services/propertiesService/propertyEditors/special/GridAssignedRowColumnPropertyEditor.js";
69
69
  export * from "./elements/services/propertiesService/services/PropertiesHelper.js";
70
70
  export * from "./elements/services/propertiesService/services/AttachedPropertiesService.js";
71
+ export * from "./elements/services/propertiesService/services/AbstractCssPropertiesService.js";
71
72
  export * from "./elements/services/propertiesService/services/BaseCustomWebComponentPropertiesService.js";
72
73
  export * from "./elements/services/propertiesService/services/BasicWebcomponentPropertiesService.js";
73
74
  export * from "./elements/services/propertiesService/services/CommonPropertiesService.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "A WYSIWYG designer webcomponent for html components",
3
3
  "name": "@node-projects/web-component-designer",
4
- "version": "0.1.144",
4
+ "version": "0.1.146",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",