@node-projects/web-component-designer 0.0.155 → 0.0.156

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 (46) hide show
  1. package/dist/elements/helper/ElementHelper.js +14 -4
  2. package/dist/elements/helper/SvgHelper.d.ts +1 -0
  3. package/dist/elements/helper/SvgHelper.js +13 -0
  4. package/dist/elements/helper/TransformHelper.js +9 -4
  5. package/dist/elements/item/DesignItem.d.ts +12 -2
  6. package/dist/elements/item/DesignItem.js +55 -20
  7. package/dist/elements/item/IDesignItem.d.ts +10 -2
  8. package/dist/elements/services/bindingsService/BaseCustomWebcomponentBindingsService.js +1 -1
  9. package/dist/elements/services/htmlParserService/DefaultHtmlParserService.d.ts +1 -1
  10. package/dist/elements/services/htmlParserService/DefaultHtmlParserService.js +3 -3
  11. package/dist/elements/services/htmlParserService/LitElementParserService.js +2 -2
  12. package/dist/elements/services/htmlParserService/NodeHtmlParserService.js +2 -2
  13. package/dist/elements/services/htmlWriterService/AbstractHtmlWriterService.js +3 -3
  14. package/dist/elements/services/htmlWriterService/FormatingHtmlWriterService.js +3 -3
  15. package/dist/elements/services/htmlWriterService/SimpleHtmlWriterService.js +3 -3
  16. package/dist/elements/services/modelCommandService/DefaultModelCommandService.js +4 -4
  17. package/dist/elements/services/placementService/DefaultPlacementService.js +5 -5
  18. package/dist/elements/services/propertiesService/IProperty.d.ts +1 -0
  19. package/dist/elements/services/propertiesService/propertyEditors/BasePropertyEditor.js +4 -4
  20. package/dist/elements/services/propertiesService/services/AbstractPropertiesService.d.ts +1 -1
  21. package/dist/elements/services/propertiesService/services/AbstractPropertiesService.js +13 -20
  22. package/dist/elements/services/propertiesService/services/AttributesPropertiesService.d.ts +1 -1
  23. package/dist/elements/services/propertiesService/services/AttributesPropertiesService.js +7 -9
  24. package/dist/elements/services/propertiesService/services/CssPropertiesService.js +1 -1
  25. package/dist/elements/services/selectionService/SelectionService.d.ts +4 -0
  26. package/dist/elements/services/selectionService/SelectionService.js +11 -0
  27. package/dist/elements/services/undoService/UndoService.d.ts +1 -1
  28. package/dist/elements/services/undoService/transactionItems/AttributeChangeAction.js +4 -4
  29. package/dist/elements/services/undoService/transactionItems/CssStyleChangeAction.js +4 -4
  30. package/dist/elements/services/undoService/transactionItems/InsertAction.d.ts +2 -2
  31. package/dist/elements/services/undoService/transactionItems/InsertAction.js +5 -5
  32. package/dist/elements/services/undoService/transactionItems/SelectionChangedAction.d.ts +14 -0
  33. package/dist/elements/services/undoService/transactionItems/SelectionChangedAction.js +28 -0
  34. package/dist/elements/widgets/codeView/code-view-monaco.js +21 -1
  35. package/dist/elements/widgets/designerView/designerCanvas.js +6 -4
  36. package/dist/elements/widgets/designerView/extensions/ResizeExtension.js +3 -3
  37. package/dist/elements/widgets/designerView/extensions/RotateExtensionProvider.js +3 -0
  38. package/dist/elements/widgets/designerView/extensions/TransformOriginExtension.js +2 -2
  39. package/dist/elements/widgets/designerView/extensions/svg/EllipsisExtensionProvider.js +2 -1
  40. package/dist/elements/widgets/designerView/extensions/svg/LineExtensionProvider.js +3 -1
  41. package/dist/elements/widgets/designerView/extensions/svg/PathExtensionProvider.js +3 -1
  42. package/dist/elements/widgets/designerView/extensions/svg/RectExtensionProvider.js +3 -1
  43. package/dist/elements/widgets/propertyGrid/PropertyGridPropertyList.js +29 -6
  44. package/dist/index.d.ts +0 -1
  45. package/dist/index.js +0 -1
  46. package/package.json +4 -4
@@ -11,12 +11,18 @@ export var ElementDisplayType;
11
11
  ElementDisplayType[ElementDisplayType["block"] = 2] = "block";
12
12
  })(ElementDisplayType || (ElementDisplayType = {}));
13
13
  export function isInline(element) {
14
+ if (element instanceof SVGElement)
15
+ return false;
14
16
  return element != null && window.getComputedStyle(element).display.startsWith('inline');
15
17
  }
16
18
  export function isInlineAfter(element) {
17
- return element != null && window.getComputedStyle(element).display == 'inline';
19
+ if (element instanceof SVGElement)
20
+ return false;
21
+ return element != null && window.getComputedStyle(element).display.startsWith('inline');
18
22
  }
19
23
  export function getElementDisplaytype(element) {
24
+ if (element instanceof SVGElement)
25
+ return ElementDisplayType.block;
20
26
  const display = window.getComputedStyle(element).display;
21
27
  return display == 'none' ? ElementDisplayType.none : display.startsWith('inline') ? ElementDisplayType.inline : ElementDisplayType.block;
22
28
  }
@@ -44,12 +50,16 @@ export function getParentElementIncludingSlots(element) {
44
50
  return element.parentElement;
45
51
  }
46
52
  export function getElementsWindowOffsetWithoutSelfAndParentTransformations(element) {
47
- var offsetLeft = 0;
48
- var offsetTop = 0;
53
+ let offsetLeft = 0;
54
+ let offsetTop = 0;
49
55
  while (element) {
50
56
  if (element instanceof SVGSVGElement) {
57
+ //todo - fix without transformation
58
+ let t = element.style.transform;
59
+ element.style.transform = '';
51
60
  const bcEl = element.getBoundingClientRect();
52
61
  const bcPar = element.parentElement.getBoundingClientRect();
62
+ element.style.transform = t;
53
63
  offsetLeft += bcEl.left - bcPar.left;
54
64
  offsetTop += bcEl.top - bcPar.top;
55
65
  element = element.parentElement;
@@ -58,7 +68,7 @@ export function getElementsWindowOffsetWithoutSelfAndParentTransformations(eleme
58
68
  let bbox = element.getBBox();
59
69
  offsetLeft += bbox.x;
60
70
  offsetTop += bbox.y;
61
- element = element.parentElement;
71
+ element = element.ownerSVGElement;
62
72
  }
63
73
  else {
64
74
  offsetLeft += element.offsetLeft;
@@ -0,0 +1 @@
1
+ export declare function isVisualSvgElement(element: SVGElement): boolean;
@@ -0,0 +1,13 @@
1
+ export function isVisualSvgElement(element) {
2
+ let el = element;
3
+ while (el) {
4
+ if (el instanceof SVGSVGElement)
5
+ return true;
6
+ if (el instanceof SVGDefsElement)
7
+ return false;
8
+ if (el instanceof SVGMetadataElement)
9
+ return false;
10
+ el = el.parentElement;
11
+ }
12
+ return true;
13
+ }
@@ -96,15 +96,18 @@ export function getDesignerCanvasNormalizedTransformedOriginWithoutParentTransfo
96
96
  export function getResultingTransformationBetweenElementAndAllAncestors(element, ancestor, excludeAncestor) {
97
97
  let actualElement = element;
98
98
  let actualElementMatrix;
99
+ let newElementMatrix;
99
100
  let originalElementAndAllParentsMultipliedMatrix;
100
101
  while (actualElement != ancestor) {
101
102
  const newElement = getParentElementIncludingSlots(actualElement);
102
103
  actualElementMatrix = new DOMMatrix(getComputedStyle(actualElement).transform);
104
+ newElementMatrix = new DOMMatrix(getComputedStyle(newElement).transform);
105
+ newElementMatrix.m41 = newElementMatrix.m42 = 0;
103
106
  if (actualElement == element) {
104
- originalElementAndAllParentsMultipliedMatrix = actualElementMatrix.multiply(new DOMMatrix(getComputedStyle(newElement).transform));
107
+ originalElementAndAllParentsMultipliedMatrix = actualElementMatrix.multiply(newElementMatrix);
105
108
  }
106
109
  else if (newElement != ancestor || !excludeAncestor) {
107
- originalElementAndAllParentsMultipliedMatrix = originalElementAndAllParentsMultipliedMatrix.multiply(new DOMMatrix(getComputedStyle(newElement).transform));
110
+ originalElementAndAllParentsMultipliedMatrix = originalElementAndAllParentsMultipliedMatrix.multiply(newElementMatrix);
108
111
  }
109
112
  actualElement = newElement;
110
113
  }
@@ -118,8 +121,10 @@ export function getByParentsTransformedPointRelatedToCanvas(element, point, desi
118
121
  while (actualElement != canvas) {
119
122
  const parentElement = getParentElementIncludingSlots(actualElement);
120
123
  const parentElementTransformOrigin = new DOMPoint(getElementsWindowOffsetWithoutSelfAndParentTransformations(parentElement).offsetLeft - designerCanvas.outerRect.x + parseFloat(getComputedStyle(parentElement).transformOrigin.split(' ')[0]), getElementsWindowOffsetWithoutSelfAndParentTransformations(parentElement).offsetTop - designerCanvas.outerRect.y + parseFloat(getComputedStyle(parentElement).transformOrigin.split(' ')[1]));
121
- parentElementTransformOrigin.x -= extractTranslationFromDOMMatrix(new DOMMatrix(element.style.transform)).x;
122
- parentElementTransformOrigin.y -= extractTranslationFromDOMMatrix(new DOMMatrix(element.style.transform)).y;
124
+ if (actualElement == element) {
125
+ parentElementTransformOrigin.x -= extractTranslationFromDOMMatrix(new DOMMatrix(element.style.transform)).x;
126
+ parentElementTransformOrigin.y -= extractTranslationFromDOMMatrix(new DOMMatrix(element.style.transform)).y;
127
+ }
123
128
  const parentElementTransformOriginToPointVector = new DOMPointReadOnly(-parentElementTransformOrigin.x + (element == actualElement ? point.x : byParentTransformedPointRelatedToCanvas.x), -parentElementTransformOrigin.y + (element == actualElement ? point.y : byParentTransformedPointRelatedToCanvas.y));
124
129
  parentElementTransformOriginToPointVectorTransformed = parentElementTransformOriginToPointVector.matrixTransform(new DOMMatrix(getComputedStyle(parentElement).transform));
125
130
  byParentTransformedPointRelatedToCanvas = new DOMPoint(parentElementTransformOrigin.x + parentElementTransformOriginToPointVectorTransformed.x, parentElementTransformOrigin.y + parentElementTransformOriginToPointVectorTransformed.y);
@@ -15,10 +15,20 @@ export declare class DesignItem implements IDesignItem {
15
15
  clone(): Promise<IDesignItem>;
16
16
  replaceNode(newNode: Node): void;
17
17
  get nodeType(): NodeType;
18
+ private _attributes;
18
19
  get hasAttributes(): boolean;
19
- attributes: Map<string, string>;
20
+ hasAttribute(name: string): boolean;
21
+ getAttribute(name: string): string;
22
+ attributes(): Generator<[string, string], void, unknown>;
23
+ _withoutUndoSetAttribute(name: string, value: string): void;
24
+ _withoutUndoRemoveAttribute(name: string): void;
25
+ private _styles;
20
26
  get hasStyles(): boolean;
21
- styles: Map<string, string>;
27
+ hasStyle(name: string): boolean;
28
+ getStyle(name: string): string;
29
+ styles(): Generator<[string, string], void, unknown>;
30
+ _withoutUndoSetStyle(name: string, value: string): void;
31
+ _withoutUndoRemoveStyle(name: string): void;
22
32
  private static _designItemMap;
23
33
  get element(): Element;
24
34
  get name(): string;
@@ -33,14 +33,48 @@ export class DesignItem {
33
33
  return NodeType.TextNode;
34
34
  return NodeType.Element;
35
35
  }
36
+ _attributes;
36
37
  get hasAttributes() {
37
- return this.attributes.size > 0;
38
+ return this._attributes.size > 0;
38
39
  }
39
- attributes;
40
+ hasAttribute(name) {
41
+ return this._attributes.has(name);
42
+ }
43
+ getAttribute(name) {
44
+ return this._attributes.get(name);
45
+ }
46
+ *attributes() {
47
+ for (let s of this._attributes) {
48
+ yield s;
49
+ }
50
+ }
51
+ _withoutUndoSetAttribute(name, value) {
52
+ this._attributes.set(name, value);
53
+ }
54
+ _withoutUndoRemoveAttribute(name) {
55
+ this._attributes.delete(name);
56
+ }
57
+ _styles;
40
58
  get hasStyles() {
41
- return this.styles.size > 0;
59
+ return this._styles.size > 0;
60
+ }
61
+ hasStyle(name) {
62
+ return this._styles.has(name);
63
+ }
64
+ getStyle(name) {
65
+ return this._styles.get(name);
66
+ }
67
+ *styles() {
68
+ for (let s of this._styles) {
69
+ yield s;
70
+ }
71
+ }
72
+ _withoutUndoSetStyle(name, value) {
73
+ this._styles.set(name, value);
74
+ }
75
+ _withoutUndoRemoveStyle(name) {
76
+ this._styles.delete(name);
42
77
  }
43
- styles;
44
78
  static _designItemMap = new WeakMap();
45
79
  get element() {
46
80
  return this.node;
@@ -140,12 +174,12 @@ export class DesignItem {
140
174
  set hideAtDesignTime(value) {
141
175
  this._hideAtDesignTime = value;
142
176
  if (value)
143
- this.attributes.set(hideAtDesignTimeAttributeName, "");
177
+ this._attributes.set(hideAtDesignTimeAttributeName, "");
144
178
  else
145
- this.attributes.delete(hideAtDesignTimeAttributeName);
179
+ this._attributes.delete(hideAtDesignTimeAttributeName);
146
180
  if (this.element instanceof HTMLElement || this.element instanceof SVGElement) {
147
181
  if (!value)
148
- this.element.style.display = this.styles.get('display') ?? "";
182
+ this.element.style.display = this._styles.get('display') ?? "";
149
183
  else
150
184
  this.element.style.display = 'none';
151
185
  }
@@ -157,12 +191,12 @@ export class DesignItem {
157
191
  set hideAtRunTime(value) {
158
192
  this._hideAtRunTime = value;
159
193
  if (value)
160
- this.attributes.set(hideAtRunTimeAttributeName, "");
194
+ this._attributes.set(hideAtRunTimeAttributeName, "");
161
195
  else
162
- this.attributes.delete(hideAtRunTimeAttributeName);
196
+ this._attributes.delete(hideAtRunTimeAttributeName);
163
197
  if (this.element instanceof HTMLElement || this.element instanceof SVGElement) {
164
198
  if (!value)
165
- this.element.style.opacity = this.styles.get('opacity') ?? "";
199
+ this.element.style.opacity = this._styles.get('opacity') ?? "";
166
200
  else
167
201
  this.element.style.opacity = '0.3';
168
202
  }
@@ -174,9 +208,9 @@ export class DesignItem {
174
208
  set lockAtDesignTime(value) {
175
209
  this._lockAtDesignTime = value;
176
210
  if (value)
177
- this.attributes.set(lockAtDesignTimeAttributeName, "");
211
+ this._attributes.set(lockAtDesignTimeAttributeName, "");
178
212
  else
179
- this.attributes.delete(lockAtDesignTimeAttributeName);
213
+ this._attributes.delete(lockAtDesignTimeAttributeName);
180
214
  if (this.element instanceof HTMLElement || this.element instanceof SVGElement) {
181
215
  if (!value)
182
216
  this.element.style.pointerEvents = 'auto';
@@ -189,7 +223,7 @@ export class DesignItem {
189
223
  if (designItem.nodeType == NodeType.Element) {
190
224
  for (let a of designItem.element.attributes) {
191
225
  if (a.name !== 'style') {
192
- designItem.attributes.set(a.name, a.value);
226
+ designItem._attributes.set(a.name, a.value);
193
227
  if (a.name === hideAtDesignTimeAttributeName)
194
228
  designItem._hideAtDesignTime = true;
195
229
  if (a.name === hideAtRunTimeAttributeName)
@@ -204,7 +238,7 @@ export class DesignItem {
204
238
  if (st) {
205
239
  cssParser.parse(st);
206
240
  for (let e of cssParser.entries) {
207
- designItem.styles.set(e.name, e.value);
241
+ designItem._styles.set(e.name, e.value);
208
242
  }
209
243
  }
210
244
  if (!designItem._lockAtDesignTime) {
@@ -230,8 +264,8 @@ export class DesignItem {
230
264
  this.node = node;
231
265
  this.serviceContainer = serviceContainer;
232
266
  this.instanceServiceContainer = instanceServiceContainer;
233
- this.attributes = new Map();
234
- this.styles = new Map();
267
+ this._attributes = new Map();
268
+ this._styles = new Map();
235
269
  DesignItem._designItemMap.set(node, this);
236
270
  }
237
271
  openGroup(title) {
@@ -257,20 +291,20 @@ export class DesignItem {
257
291
  }
258
292
  setStyle(name, value) {
259
293
  let nm = PropertiesHelper.camelToDashCase(name);
260
- const action = new CssStyleChangeAction(this, nm, value, this.styles.get(nm));
294
+ const action = new CssStyleChangeAction(this, nm, value, this._styles.get(nm));
261
295
  this.instanceServiceContainer.undoService.execute(action);
262
296
  }
263
297
  removeStyle(name) {
264
298
  let nm = PropertiesHelper.camelToDashCase(name);
265
- const action = new CssStyleChangeAction(this, nm, '', this.styles.get(nm));
299
+ const action = new CssStyleChangeAction(this, nm, '', this._styles.get(nm));
266
300
  this.instanceServiceContainer.undoService.execute(action);
267
301
  }
268
302
  setAttribute(name, value) {
269
- const action = new AttributeChangeAction(this, name, value, this.attributes.get(name));
303
+ const action = new AttributeChangeAction(this, name, value, this._attributes.get(name));
270
304
  this.instanceServiceContainer.undoService.execute(action);
271
305
  }
272
306
  removeAttribute(name) {
273
- const action = new AttributeChangeAction(this, name, null, this.attributes.get(name));
307
+ const action = new AttributeChangeAction(this, name, null, this._attributes.get(name));
274
308
  this.instanceServiceContainer.undoService.execute(action);
275
309
  }
276
310
  // Internal implementations wich don't use undo/redo
@@ -289,6 +323,7 @@ export class DesignItem {
289
323
  this.node.insertBefore(designItem.node, el.element);
290
324
  this._childArray.splice(index, 0, designItem);
291
325
  }
326
+ //todo: is this still needed???
292
327
  if (this.instanceServiceContainer.selectionService.primarySelection == designItem)
293
328
  designItem.instanceServiceContainer.designerCanvas.extensionManager.applyExtension(designItem.parent, ExtensionType.PrimarySelectionContainer);
294
329
  }
@@ -14,9 +14,7 @@ export interface IDesignItem {
14
14
  id: string;
15
15
  readonly isRootItem: boolean;
16
16
  readonly hasAttributes: boolean;
17
- readonly attributes: Map<string, string>;
18
17
  readonly hasStyles: boolean;
19
- readonly styles: Map<string, string>;
20
18
  readonly hasChildren: boolean;
21
19
  children(): IterableIterator<IDesignItem>;
22
20
  readonly childCount: number;
@@ -24,6 +22,10 @@ export interface IDesignItem {
24
22
  readonly parent: IDesignItem;
25
23
  _insertChildInternal(designItem: IDesignItem, index?: number): any;
26
24
  _removeChildInternal(designItem: IDesignItem): any;
25
+ _withoutUndoSetStyle(name: string, value: string): any;
26
+ _withoutUndoRemoveStyle(name: string): any;
27
+ _withoutUndoSetAttribute(name: string, value: string): any;
28
+ _withoutUndoRemoveAttribute(name: string): any;
27
29
  indexOf(designItem: IDesignItem): number;
28
30
  insertAdjacentElement(designItem: IDesignItem, where: InsertPosition): any;
29
31
  insertChild(designItem: IDesignItem, index?: number): any;
@@ -42,8 +44,14 @@ export interface IDesignItem {
42
44
  appliedDesignerExtensions: Map<ExtensionType, IDesignerExtension[]>;
43
45
  getOrCreateDesignItem(node: Node): any;
44
46
  openGroup(title: string): ChangeGroup;
47
+ styles(): Iterable<[name: string, value: string]>;
48
+ getStyle(name: string): any;
49
+ hasStyle(name: string): any;
45
50
  setStyle(name: string, value?: string | null): any;
46
51
  removeStyle(name: string): any;
52
+ attributes(): Iterable<[name: string, value: string]>;
53
+ getAttribute(name: string): any;
54
+ hasAttribute(name: string): any;
47
55
  setAttribute(name: string, value?: string | null): any;
48
56
  removeAttribute(name: string): any;
49
57
  hideAtDesignTime: boolean;
@@ -5,7 +5,7 @@ export class BaseCustomWebcomponentBindingsService {
5
5
  static type = 'base-custom-webcomponent-binding';
6
6
  getBindings(designItem) {
7
7
  let bindings = null;
8
- for (let a of designItem.attributes) {
8
+ for (let a of designItem.attributes()) {
9
9
  const name = a[0];
10
10
  const value = a[1];
11
11
  if ((value.startsWith('[[') || value.startsWith('{{')) && (value.endsWith('}}') || value.endsWith(']]'))) {
@@ -4,6 +4,6 @@ import { ServiceContainer } from "../ServiceContainer";
4
4
  import { IHtmlParserService } from "./IHtmlParserService";
5
5
  export declare class DefaultHtmlParserService implements IHtmlParserService {
6
6
  parse(html: string, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): Promise<IDesignItem[]>;
7
- createDesignItems(elements: HTMLCollection | HTMLElement[], serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): IDesignItem[];
7
+ createDesignItems(elements: NodeListOf<ChildNode> | Node[] | HTMLCollection | HTMLElement[], serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): IDesignItem[];
8
8
  private _createDesignItemsRecursive;
9
9
  }
@@ -3,7 +3,7 @@ export class DefaultHtmlParserService {
3
3
  async parse(html, serviceContainer, instanceServiceContainer) {
4
4
  const parser = new DOMParser();
5
5
  const doc = parser.parseFromString(html, 'text/html');
6
- return this.createDesignItems(doc.body.children, serviceContainer, instanceServiceContainer);
6
+ return this.createDesignItems(doc.body.childNodes, serviceContainer, instanceServiceContainer);
7
7
  }
8
8
  createDesignItems(elements, serviceContainer, instanceServiceContainer) {
9
9
  let res = [];
@@ -12,7 +12,7 @@ export class DefaultHtmlParserService {
12
12
  }
13
13
  return res;
14
14
  }
15
- _createDesignItemsRecursive(element, serviceContainer, instanceServiceContainer) {
16
- return DesignItem.createDesignItemFromInstance(element, serviceContainer, instanceServiceContainer);
15
+ _createDesignItemsRecursive(node, serviceContainer, instanceServiceContainer) {
16
+ return DesignItem.createDesignItemFromInstance(node, serviceContainer, instanceServiceContainer);
17
17
  }
18
18
  }
@@ -55,7 +55,7 @@ export class LitElementParserService {
55
55
  let attr = item.attributes;
56
56
  for (let a in attr) {
57
57
  if (a !== 'style') {
58
- designItem.attributes.set(a, attr[a]);
58
+ designItem._withoutUndoSetAttribute(a, attr[a]);
59
59
  if (manualCreatedElement) {
60
60
  element.setAttribute(a, attr[a]);
61
61
  }
@@ -74,7 +74,7 @@ export class LitElementParserService {
74
74
  let styleParser = new CssAttributeParser();
75
75
  styleParser.parse(style);
76
76
  for (let s of styleParser.entries) {
77
- designItem.styles.set(s.name, s.value);
77
+ designItem._withoutUndoSetStyle(s.name, s.value);
78
78
  if (manualCreatedElement) {
79
79
  element.style[s.name] = s.value;
80
80
  }
@@ -45,7 +45,7 @@ export class NodeHtmlParserService {
45
45
  let attr = item.attributes;
46
46
  for (let a in attr) {
47
47
  if (a !== 'style') {
48
- designItem.attributes.set(a, attr[a]);
48
+ designItem._withoutUndoSetAttribute(a, attr[a]);
49
49
  if (manualCreatedElement) {
50
50
  element.setAttribute(a, attr[a]);
51
51
  }
@@ -64,7 +64,7 @@ export class NodeHtmlParserService {
64
64
  let styleParser = new CssAttributeParser();
65
65
  styleParser.parse(style);
66
66
  for (let s of styleParser.entries) {
67
- designItem.styles.set(s.name, s.value);
67
+ designItem._withoutUndoSetStyle(s.name, s.value);
68
68
  if (manualCreatedElement) {
69
69
  element.style[s.name] = s.value;
70
70
  }
@@ -4,7 +4,7 @@ import { PropertiesHelper } from '../propertiesService/services/PropertiesHelper
4
4
  export class AbstractHtmlWriterService {
5
5
  writeAttributes(indentedTextWriter, designItem, options) {
6
6
  if (designItem.hasAttributes) {
7
- for (const a of designItem.attributes) {
7
+ for (const a of designItem.attributes()) {
8
8
  indentedTextWriter.write(' ');
9
9
  if (typeof a[1] === 'string') {
10
10
  if (a[1] === "")
@@ -48,9 +48,9 @@ export class AbstractHtmlWriterService {
48
48
  writeStyles(indentedTextWriter, designItem, options) {
49
49
  if (designItem.hasStyles) {
50
50
  indentedTextWriter.write(' style="');
51
- let styles = designItem.styles;
51
+ let styles = designItem.styles();
52
52
  if (options.compressCssToShorthandProperties)
53
- styles = CssCombiner.combine(styles);
53
+ styles = CssCombiner.combine(new Map(styles));
54
54
  for (const s of styles) {
55
55
  if (s[0]) {
56
56
  indentedTextWriter.write(PropertiesHelper.camelToDashCase(s[0]) + ':' + DomConverter.normalizeAttributeValue(s[1]) + ';');
@@ -12,7 +12,7 @@ var ElementContainerType;
12
12
  export class FormatingHtmlWriterService {
13
13
  writeAttributes(writeContext, designItem) {
14
14
  if (designItem.hasAttributes) {
15
- for (const a of designItem.attributes) {
15
+ for (const a of designItem.attributes()) {
16
16
  writeContext.indentedTextWriter.write(' ');
17
17
  if (typeof a[1] === 'string') {
18
18
  if (a[1] === "")
@@ -30,9 +30,9 @@ export class FormatingHtmlWriterService {
30
30
  writeStyles(writeContext, designItem) {
31
31
  if (designItem.hasStyles) {
32
32
  writeContext.indentedTextWriter.write(' style="');
33
- let styles = designItem.styles;
33
+ let styles = designItem.styles();
34
34
  if (writeContext.options.compressCssToShorthandProperties)
35
- styles = CssCombiner.combine(styles);
35
+ styles = CssCombiner.combine(new Map(styles));
36
36
  for (const s of styles) {
37
37
  if (s[0]) {
38
38
  writeContext.indentedTextWriter.write(PropertiesHelper.camelToDashCase(s[0]) + ':' + DomConverter.normalizeAttributeValue(s[1]) + ';');
@@ -11,7 +11,7 @@ export var ElementContainerType;
11
11
  export class SimpleHtmlWriterService {
12
12
  writeAttributes(writeContext, designItem) {
13
13
  if (designItem.hasAttributes) {
14
- for (const a of designItem.attributes) {
14
+ for (const a of designItem.attributes()) {
15
15
  writeContext.indentedTextWriter.write(' ');
16
16
  if (typeof a[1] === 'string') {
17
17
  if (a[1] === "")
@@ -29,9 +29,9 @@ export class SimpleHtmlWriterService {
29
29
  writeStyles(writeContext, designItem) {
30
30
  if (designItem.hasStyles) {
31
31
  writeContext.indentedTextWriter.write(' style="');
32
- let styles = designItem.styles;
32
+ let styles = designItem.styles();
33
33
  if (writeContext.options.compressCssToShorthandProperties)
34
- styles = CssCombiner.combine(styles);
34
+ styles = CssCombiner.combine(new Map(styles));
35
35
  for (const s of styles) {
36
36
  if (s[0]) {
37
37
  writeContext.indentedTextWriter.write(PropertiesHelper.camelToDashCase(s[0]) + ':' + DomConverter.normalizeAttributeValue(s[1]) + ';');
@@ -56,7 +56,7 @@ export class DefaultModelCommandService {
56
56
  }
57
57
  else if (command.type == CommandType.unifyHeight) {
58
58
  const grp = designerCanvas.instanceServiceContainer.selectionService.primarySelection.openGroup('unifyHeight');
59
- const height = designerCanvas.instanceServiceContainer.selectionService.primarySelection.styles.get('height');
59
+ const height = designerCanvas.instanceServiceContainer.selectionService.primarySelection.getStyle('height');
60
60
  for (let s of designerCanvas.instanceServiceContainer.selectionService.selectedElements) {
61
61
  s.setStyle('height', height);
62
62
  }
@@ -64,7 +64,7 @@ export class DefaultModelCommandService {
64
64
  }
65
65
  else if (command.type == CommandType.unifyWidth) {
66
66
  const grp = designerCanvas.instanceServiceContainer.selectionService.primarySelection.openGroup('unifyWidth');
67
- const width = designerCanvas.instanceServiceContainer.selectionService.primarySelection.styles.get('width');
67
+ const width = designerCanvas.instanceServiceContainer.selectionService.primarySelection.getStyle('width');
68
68
  for (let s of designerCanvas.instanceServiceContainer.selectionService.selectedElements) {
69
69
  s.setStyle('width', width);
70
70
  }
@@ -72,7 +72,7 @@ export class DefaultModelCommandService {
72
72
  }
73
73
  else if (command.type == CommandType.rotateCounterClockwise) {
74
74
  const grp = designerCanvas.instanceServiceContainer.selectionService.primarySelection.openGroup('rotateCounterClockwise');
75
- var trf = designerCanvas.instanceServiceContainer.selectionService.primarySelection.styles.get('transform');
75
+ var trf = designerCanvas.instanceServiceContainer.selectionService.primarySelection.getStyle('transform');
76
76
  let degree = 0;
77
77
  let rotation = "";
78
78
  if (trf != null) {
@@ -97,7 +97,7 @@ export class DefaultModelCommandService {
97
97
  }
98
98
  else if (command.type == CommandType.rotateClockwise) {
99
99
  const grp = designerCanvas.instanceServiceContainer.selectionService.primarySelection.openGroup('rotateClockwise');
100
- var trf = designerCanvas.instanceServiceContainer.selectionService.primarySelection.styles.get('transform');
100
+ var trf = designerCanvas.instanceServiceContainer.selectionService.primarySelection.getStyle('transform');
101
101
  let degree = 0;
102
102
  let rotation = "";
103
103
  if (trf != null) {
@@ -102,16 +102,16 @@ export class DefaultPlacementService {
102
102
  transformMatrixParentTransformsCompensated = new DOMPoint(track.x, track.y, 0, 0);
103
103
  }
104
104
  const translationMatrix = new DOMMatrix().translate(transformMatrixParentTransformsCompensated.x, transformMatrixParentTransformsCompensated.y);
105
- combineTransforms(designItem.element, designItem.styles.get('transform'), translationMatrix.toString());
105
+ combineTransforms(designItem.element, designItem.getStyle('transform'), translationMatrix.toString());
106
106
  }
107
107
  }
108
108
  enterContainer(container, items) {
109
109
  let filterdItems = filterChildPlaceItems(items);
110
110
  for (let i of filterdItems) {
111
111
  if (i.lastContainerSize) {
112
- if (!i.styles.has('width'))
112
+ if (!i.hasStyle('width'))
113
113
  i.setStyle('width', i.lastContainerSize.width + 'px');
114
- if (!i.styles.has('height'))
114
+ if (!i.hasStyle('height'))
115
115
  i.setStyle('height', i.lastContainerSize.height + 'px');
116
116
  }
117
117
  }
@@ -122,8 +122,8 @@ export class DefaultPlacementService {
122
122
  let filterdItems = filterChildPlaceItems(items);
123
123
  for (const designItem of filterdItems) {
124
124
  let translation = extractTranslationFromDOMMatrix(new DOMMatrix(designItem.element.style.transform));
125
- const stylesMapOffset = extractTranslationFromDOMMatrix(new DOMMatrix(designItem.styles.get('transform') ?? ''));
126
- designItem.element.style.transform = designItem.styles.get('transform') ?? '';
125
+ const stylesMapOffset = extractTranslationFromDOMMatrix(new DOMMatrix(designItem.getStyle('transform') ?? ''));
126
+ designItem.element.style.transform = designItem.getStyle('transform') ?? '';
127
127
  let track = { x: translation.x, y: translation.y };
128
128
  placeDesignItem(container, designItem, { x: track.x - stylesMapOffset.x, y: track.y - stylesMapOffset.y }, 'position');
129
129
  }
@@ -3,6 +3,7 @@ import { IPropertyEditor } from './IPropertyEditor';
3
3
  import { PropertyType } from './PropertyType';
4
4
  export interface IProperty {
5
5
  name: string;
6
+ renamable?: boolean;
6
7
  propertyName?: string;
7
8
  attributeName?: string;
8
9
  description?: string;
@@ -1,5 +1,4 @@
1
1
  import { ValueType } from '../ValueType';
2
- import { PropertyChangeAction } from "../../undoService/transactionItems/PropertyChangeAction";
3
2
  export class BasePropertyEditor {
4
3
  element;
5
4
  property;
@@ -13,9 +12,10 @@ export class BasePropertyEditor {
13
12
  if (this.designItems && this.designItems.length) {
14
13
  const cg = this.designItems[0].openGroup("set property: " + this.property.name);
15
14
  for (let d of this.designItems) {
16
- const oldValue = this.property.service.getValue([d], this.property);
17
- const action = new PropertyChangeAction(d, this.property, newValue, oldValue);
18
- d.instanceServiceContainer.undoService.execute(action);
15
+ if (newValue == null)
16
+ this.property.service.clearValue([d], this.property);
17
+ else
18
+ this.property.service.setValue([d], this.property, newValue);
19
19
  }
20
20
  cg.commit();
21
21
  }
@@ -14,7 +14,7 @@ export declare abstract class AbstractPropertiesService implements IPropertiesSe
14
14
  getPropertyTarget(designItem: IDesignItem, property: IProperty): BindingTarget;
15
15
  clearValue(designItems: IDesignItem[], property: IProperty): void;
16
16
  isSet(designItems: IDesignItem[], property: IProperty): ValueType;
17
- getValue(designItems: IDesignItem[], property: IProperty): string | boolean;
17
+ getValue(designItems: IDesignItem[], property: IProperty): any;
18
18
  getBinding(designItems: IDesignItem[], property: IProperty): IBinding;
19
19
  getUnsetValue(designItems: IDesignItem[], property: IProperty): any;
20
20
  }
@@ -13,8 +13,7 @@ export class AbstractPropertiesService {
13
13
  const cg = designItems[0].openGroup("properties changed");
14
14
  for (let d of designItems) {
15
15
  if (property.propertyType == PropertyType.cssValue) {
16
- d.styles.set(property.name, value);
17
- d.element.style[property.name] = value;
16
+ d.setStyle(property.name, value);
18
17
  //unkown css property names do not trigger the mutation observer of property grid,
19
18
  //fixed by assinging stle again to the attribute
20
19
  d.element.setAttribute('style', d.element.getAttribute('style'));
@@ -25,20 +24,16 @@ export class AbstractPropertiesService {
25
24
  attributeName = PropertiesHelper.camelToDashCase(property.name);
26
25
  if (property.type === 'object') {
27
26
  const json = JSON.stringify(value);
28
- d.attributes.set(attributeName, json);
29
- d.element.setAttribute(attributeName, json);
27
+ d.setAttribute(attributeName, json);
30
28
  }
31
29
  else if (property.type == 'boolean' && !value) {
32
- d.attributes.delete(attributeName);
33
- d.element.removeAttribute(attributeName);
30
+ d.removeAttribute(attributeName);
34
31
  }
35
32
  else if (property.type == 'boolean' && value) {
36
- d.attributes.set(attributeName, "");
37
- d.element.setAttribute(attributeName, "");
33
+ d.setAttribute(attributeName, "");
38
34
  }
39
35
  else {
40
- d.attributes.set(attributeName, value);
41
- d.element.setAttribute(attributeName, value);
36
+ d.setAttribute(attributeName, value);
42
37
  }
43
38
  }
44
39
  this._notifyChangedProperty(d, property, value);
@@ -52,15 +47,13 @@ export class AbstractPropertiesService {
52
47
  const cg = designItems[0].openGroup("properties cleared");
53
48
  for (let d of designItems) {
54
49
  if (property.propertyType == PropertyType.cssValue) {
55
- d.styles.delete(property.name);
56
- d.element.style[property.name] = '';
50
+ d.removeStyle(property.name);
57
51
  }
58
52
  else {
59
53
  let attributeName = property.attributeName;
60
54
  if (!attributeName)
61
55
  attributeName = PropertiesHelper.camelToDashCase(property.name);
62
- d.attributes.delete(attributeName);
63
- d.element.removeAttribute(attributeName);
56
+ d.removeAttribute(attributeName);
64
57
  }
65
58
  d.serviceContainer.forSomeServicesTillResult('bindingService', (s) => {
66
59
  return s.clearBinding(d, property.name, this.getPropertyTarget(d, property));
@@ -79,9 +72,9 @@ export class AbstractPropertiesService {
79
72
  designItems.forEach((x) => {
80
73
  let has = false;
81
74
  if (property.propertyType == PropertyType.cssValue)
82
- has = x.styles.has(property.name);
75
+ has = x.hasStyle(property.name);
83
76
  else
84
- has = x.attributes.has(attributeName);
77
+ has = x.hasAttribute(attributeName);
85
78
  all = all && has;
86
79
  some = some || has;
87
80
  });
@@ -105,9 +98,9 @@ export class AbstractPropertiesService {
105
98
  getValue(designItems, property) {
106
99
  if (designItems != null && designItems.length !== 0) {
107
100
  if (property.propertyType == PropertyType.cssValue) {
108
- let lastValue = designItems[0].styles.get(property.name);
101
+ let lastValue = designItems[0].getStyle(property.name);
109
102
  for (const x of designItems) {
110
- let value = x.styles.get(property.name);
103
+ let value = x.getStyle(property.name);
111
104
  if (value != lastValue) {
112
105
  lastValue = null;
113
106
  break;
@@ -120,8 +113,8 @@ export class AbstractPropertiesService {
120
113
  if (!attributeName)
121
114
  attributeName = PropertiesHelper.camelToDashCase(property.name);
122
115
  if (property.type == 'boolean')
123
- return designItems[0].attributes.has(attributeName);
124
- let lastValue = designItems[0].attributes.get(attributeName);
116
+ return designItems[0].hasAttribute(attributeName);
117
+ let lastValue = designItems[0].getAttribute(attributeName);
125
118
  /*
126
119
  for (const x of designItems) {
127
120
  let value = x.attributes.get(attributeName);
@@ -14,7 +14,7 @@ export declare class AttributesPropertiesService implements IPropertiesService {
14
14
  getPropertyTarget(designItem: IDesignItem, property: IProperty): BindingTarget;
15
15
  clearValue(designItems: IDesignItem[], property: IProperty): void;
16
16
  isSet(designItems: IDesignItem[], property: IProperty): ValueType;
17
- getValue(designItems: IDesignItem[], property: IProperty): string;
17
+ getValue(designItems: IDesignItem[], property: IProperty): any;
18
18
  getBinding(designItems: IDesignItem[], property: IProperty): IBinding;
19
19
  getUnsetValue(designItems: IDesignItem[], property: IProperty): any;
20
20
  }
@@ -16,8 +16,8 @@ export class AttributesPropertiesService {
16
16
  getProperties(designItem) {
17
17
  if (designItem) {
18
18
  let p = [];
19
- for (let a of designItem.attributes.keys()) {
20
- p.push({ name: a, type: 'string', service: this, propertyType: PropertyType.propertyAndAttribute });
19
+ for (let a of designItem.attributes()) {
20
+ p.push({ name: a[0], renamable: true, type: 'string', service: this, propertyType: PropertyType.propertyAndAttribute });
21
21
  }
22
22
  p.push({ name: '', type: 'addNew', service: this, propertyType: PropertyType.complex });
23
23
  return p;
@@ -27,8 +27,7 @@ export class AttributesPropertiesService {
27
27
  setValue(designItems, property, value) {
28
28
  const cg = designItems[0].openGroup("properties changed");
29
29
  for (let d of designItems) {
30
- d.attributes.set(property.name, value);
31
- d.element.setAttribute(property.name, value);
30
+ d.setAttribute(property.name, value);
32
31
  }
33
32
  cg.commit();
34
33
  }
@@ -37,8 +36,7 @@ export class AttributesPropertiesService {
37
36
  }
38
37
  clearValue(designItems, property) {
39
38
  for (let d of designItems) {
40
- d.attributes.delete(property.name);
41
- d.element.removeAttribute(property.name);
39
+ d.removeAttribute(property.name);
42
40
  d.serviceContainer.forSomeServicesTillResult('bindingService', (s) => {
43
41
  return s.clearBinding(d, property.name, this.getPropertyTarget(d, property));
44
42
  });
@@ -48,11 +46,11 @@ export class AttributesPropertiesService {
48
46
  let all = true;
49
47
  let some = false;
50
48
  if (designItems != null && designItems.length !== 0) {
51
- if (designItems.length == 1 && typeof designItems[0].attributes.get(property.name) == 'object')
49
+ if (designItems.length == 1 && typeof designItems[0].getAttribute(property.name) == 'object')
52
50
  return ValueType.bound;
53
51
  let attributeName = property.name;
54
52
  designItems.forEach((x) => {
55
- let has = x.attributes.has(attributeName);
53
+ let has = x.hasAttribute(attributeName);
56
54
  all = all && has;
57
55
  some = some || has;
58
56
  });
@@ -64,7 +62,7 @@ export class AttributesPropertiesService {
64
62
  getValue(designItems, property) {
65
63
  if (designItems != null && designItems.length !== 0) {
66
64
  let attributeName = property.name;
67
- let lastValue = designItems[0].attributes.get(attributeName);
65
+ let lastValue = designItems[0].getAttribute(attributeName);
68
66
  if (typeof lastValue === 'object')
69
67
  return lastValue.rawValue;
70
68
  /*
@@ -195,7 +195,7 @@ export class CssPropertiesService extends CommonPropertiesService {
195
195
  if (this.name == 'styles') {
196
196
  if (!designItem)
197
197
  return [];
198
- let arr = Array.from(designItem.styles.keys(), x => ({ name: x, type: 'string', service: this, propertyType: PropertyType.cssValue }));
198
+ let arr = Array.from(designItem.styles(), ([key, value]) => ({ name: key, renamable: true, type: 'string', service: this, propertyType: PropertyType.cssValue }));
199
199
  arr.push({ name: '', type: 'addNew', service: this, propertyType: PropertyType.complex });
200
200
  return arr;
201
201
  }
@@ -2,10 +2,14 @@ import { ISelectionService } from './ISelectionService';
2
2
  import { IDesignItem } from '../../item/IDesignItem';
3
3
  import { ISelectionChangedEvent } from './ISelectionChangedEvent';
4
4
  import { TypedEvent } from '@node-projects/base-custom-webcomponent';
5
+ import { IDesignerCanvas } from '../../widgets/designerView/IDesignerCanvas';
5
6
  export declare class SelectionService implements ISelectionService {
6
7
  primarySelection: IDesignItem;
7
8
  selectedElements: IDesignItem[];
9
+ _designerCanvas: IDesignerCanvas;
10
+ constructor(designerCanvas: IDesignerCanvas);
8
11
  setSelectedElements(designItems: IDesignItem[]): void;
12
+ _withoutUndoSetSelectedElements(designItems: IDesignItem[]): void;
9
13
  clearSelectedElements(): void;
10
14
  isSelected(designItem: IDesignItem): boolean;
11
15
  readonly onSelectionChanged: TypedEvent<ISelectionChangedEvent>;
@@ -1,8 +1,19 @@
1
1
  import { TypedEvent } from '@node-projects/base-custom-webcomponent';
2
+ import { SelectionChangedAction } from '../undoService/transactionItems/SelectionChangedAction';
2
3
  export class SelectionService {
3
4
  primarySelection;
4
5
  selectedElements = [];
6
+ _designerCanvas;
7
+ constructor(designerCanvas) {
8
+ this._designerCanvas = designerCanvas;
9
+ }
5
10
  setSelectedElements(designItems) {
11
+ if (this.selectedElements != designItems) {
12
+ const action = new SelectionChangedAction(this.selectedElements, designItems, this);
13
+ this._designerCanvas.instanceServiceContainer.undoService.execute(action);
14
+ }
15
+ }
16
+ _withoutUndoSetSelectedElements(designItems) {
6
17
  let oldSelectedElements = this.selectedElements;
7
18
  if (!designItems) {
8
19
  this.selectedElements = [];
@@ -7,7 +7,7 @@ export declare class UndoService implements IUndoService {
7
7
  private _redoStack;
8
8
  private _transactionStack;
9
9
  private _designerCanvas;
10
- constructor(designerCanvas?: IDesignerCanvas);
10
+ constructor(designerCanvas: IDesignerCanvas);
11
11
  openGroup(title: string): ChangeGroup;
12
12
  private commitTransactionItem;
13
13
  private abortTransactionItem;
@@ -12,7 +12,7 @@ export class AttributeChangeAction {
12
12
  }
13
13
  undo() {
14
14
  if (this.oldValue == null) {
15
- this.designItem.attributes.delete(this.name);
15
+ this.designItem._withoutUndoRemoveAttribute(this.name);
16
16
  try {
17
17
  this.designItem.element.removeAttribute(this.name);
18
18
  }
@@ -21,7 +21,7 @@ export class AttributeChangeAction {
21
21
  }
22
22
  }
23
23
  else {
24
- this.designItem.attributes.set(this.name, this.oldValue);
24
+ this.designItem._withoutUndoSetAttribute(this.name, this.oldValue);
25
25
  if (this.name != "draggable") {
26
26
  try {
27
27
  if (typeof this.oldValue === 'string')
@@ -35,7 +35,7 @@ export class AttributeChangeAction {
35
35
  }
36
36
  do() {
37
37
  if (this.newValue == null) {
38
- this.designItem.attributes.delete(this.name);
38
+ this.designItem._withoutUndoRemoveAttribute(this.name);
39
39
  try {
40
40
  this.designItem.element.removeAttribute(this.name);
41
41
  }
@@ -44,7 +44,7 @@ export class AttributeChangeAction {
44
44
  }
45
45
  }
46
46
  else {
47
- this.designItem.attributes.set(this.name, this.newValue);
47
+ this.designItem._withoutUndoSetAttribute(this.name, this.newValue);
48
48
  if (this.name != "draggable") {
49
49
  try {
50
50
  if (typeof this.newValue === 'string')
@@ -12,21 +12,21 @@ export class CssStyleChangeAction {
12
12
  }
13
13
  undo() {
14
14
  if (this.oldValue === '' || this.oldValue == null) {
15
- this.designItem.styles.delete(this.name);
15
+ this.designItem._withoutUndoRemoveStyle(this.name);
16
16
  this.designItem.element.style[this.name] = '';
17
17
  }
18
18
  else {
19
- this.designItem.styles.set(this.name, this.oldValue);
19
+ this.designItem._withoutUndoSetStyle(this.name, this.oldValue);
20
20
  this.designItem.element.style[this.name] = this.oldValue;
21
21
  }
22
22
  }
23
23
  do() {
24
24
  if (this.newValue === '' || this.newValue == null) {
25
- this.designItem.styles.delete(this.name);
25
+ this.designItem._withoutUndoRemoveStyle(this.name);
26
26
  this.designItem.element.style[this.name] = '';
27
27
  }
28
28
  else {
29
- this.designItem.styles.set(this.name, this.newValue);
29
+ this.designItem._withoutUndoSetStyle(this.name, this.newValue);
30
30
  this.designItem.element.style[this.name] = this.newValue;
31
31
  }
32
32
  }
@@ -1,12 +1,12 @@
1
1
  import { ITransactionItem } from '../ITransactionItem';
2
2
  import { IDesignItem } from '../../../item/IDesignItem';
3
3
  export declare class InsertAction implements ITransactionItem {
4
- constructor(designItem: IDesignItem, index: number, newItem: IDesignItem);
4
+ constructor(containerItem: IDesignItem, index: number, newItem: IDesignItem);
5
5
  title?: string;
6
6
  get affectedItems(): IDesignItem[];
7
7
  undo(): void;
8
8
  do(): void;
9
- designItem: IDesignItem;
9
+ containerItem: IDesignItem;
10
10
  index: number;
11
11
  newItem: IDesignItem;
12
12
  mergeWith(other: ITransactionItem): boolean;
@@ -1,23 +1,23 @@
1
1
  export class InsertAction {
2
- constructor(designItem, index, newItem) {
2
+ constructor(containerItem, index, newItem) {
3
3
  this.title = "Insert Item";
4
- this.designItem = designItem;
4
+ this.containerItem = containerItem;
5
5
  this.index = index;
6
6
  this.newItem = newItem;
7
7
  }
8
8
  title;
9
9
  get affectedItems() {
10
- return [this.designItem, this.newItem];
10
+ return [this.containerItem, this.newItem];
11
11
  }
12
12
  undo() {
13
13
  this.newItem.parent._removeChildInternal(this.newItem);
14
14
  this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'removed', designItems: [this.newItem] });
15
15
  }
16
16
  do() {
17
- this.designItem._insertChildInternal(this.newItem, this.index);
17
+ this.containerItem._insertChildInternal(this.newItem, this.index);
18
18
  this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'added', designItems: [this.newItem] });
19
19
  }
20
- designItem;
20
+ containerItem;
21
21
  index;
22
22
  newItem;
23
23
  mergeWith(other) {
@@ -0,0 +1,14 @@
1
+ import { ITransactionItem } from '../ITransactionItem';
2
+ import { IDesignItem } from '../../../item/IDesignItem';
3
+ import { ISelectionService } from '../../selectionService/ISelectionService';
4
+ export declare class SelectionChangedAction implements ITransactionItem {
5
+ constructor(oldSelection: IDesignItem[], newSelection: IDesignItem[], selectionService: ISelectionService);
6
+ title?: string;
7
+ get affectedItems(): IDesignItem[];
8
+ undo(): void;
9
+ do(): void;
10
+ oldSelection: IDesignItem[];
11
+ newSelection: IDesignItem[];
12
+ selectionService: ISelectionService;
13
+ mergeWith(other: ITransactionItem): boolean;
14
+ }
@@ -0,0 +1,28 @@
1
+ export class SelectionChangedAction {
2
+ constructor(oldSelection, newSelection, selectionService) {
3
+ this.title = "Change Selection";
4
+ this.oldSelection = oldSelection;
5
+ this.newSelection = newSelection;
6
+ this.selectionService = selectionService;
7
+ }
8
+ title;
9
+ get affectedItems() {
10
+ if (this.oldSelection && this.newSelection)
11
+ return [...this.oldSelection, ...this.newSelection];
12
+ if (this.oldSelection)
13
+ return [...this.oldSelection];
14
+ return [...this.newSelection];
15
+ }
16
+ undo() {
17
+ this.selectionService._withoutUndoSetSelectedElements(this.oldSelection);
18
+ }
19
+ do() {
20
+ this.selectionService._withoutUndoSetSelectedElements(this.newSelection);
21
+ }
22
+ oldSelection;
23
+ newSelection;
24
+ selectionService;
25
+ mergeWith(other) {
26
+ return false;
27
+ }
28
+ }
@@ -75,8 +75,28 @@ export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
75
75
  minimap: {
76
76
  size: 'fill'
77
77
  },
78
- fixedOverflowWidgets: true
78
+ fixedOverflowWidgets: true,
79
+ scrollbar: {
80
+ useShadows: false,
81
+ verticalHasArrows: true,
82
+ horizontalHasArrows: true,
83
+ vertical: 'visible',
84
+ horizontal: 'visible'
85
+ }
79
86
  });
87
+ //@ts-ignore
88
+ monaco.editor.defineTheme('myTheme', {
89
+ base: 'vs',
90
+ inherit: true,
91
+ //@ts-ignore
92
+ rules: [{ background: 'EDF9FA' }],
93
+ colors: {
94
+ 'editor.selectionBackground': '#add6ff',
95
+ 'editor.inactiveSelectionBackground': '#add6ff'
96
+ }
97
+ });
98
+ //@ts-ignore
99
+ monaco.editor.setTheme('myTheme');
80
100
  this._monacoEditor.layout();
81
101
  let changeContentListener = this._monacoEditor.getModel().onDidChangeContent(e => {
82
102
  this.onTextChanged.emit(this._monacoEditor.getValue());
@@ -427,7 +427,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
427
427
  this.serviceContainer = serviceContainer;
428
428
  this.instanceServiceContainer = new InstanceServiceContainer(this);
429
429
  this.instanceServiceContainer.register("undoService", new UndoService(this));
430
- this.instanceServiceContainer.register("selectionService", new SelectionService);
430
+ this.instanceServiceContainer.register("selectionService", new SelectionService(this));
431
431
  this.rootDesignItem = DesignItem.GetOrCreateDesignItem(this._canvas, this.serviceContainer, this.instanceServiceContainer);
432
432
  this.instanceServiceContainer.register("contentService", new ContentService(this.rootDesignItem));
433
433
  this.extensionManager = new ExtensionManager(this);
@@ -498,7 +498,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
498
498
  this.rootDesignItem._removeChildInternal(i);
499
499
  this.addDesignItems(designItems);
500
500
  this.instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'parsed' });
501
- this.instanceServiceContainer.selectionService.setSelectedElements(null);
501
+ this.instanceServiceContainer.selectionService._withoutUndoSetSelectedElements(null);
502
502
  }
503
503
  addDesignItems(designItems) {
504
504
  if (designItems) {
@@ -666,8 +666,10 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
666
666
  const containerService = this.serviceContainer.getLastServiceWhere('containerService', x => x.serviceForContainer(newContainer, getComputedStyle(newContainer.element)));
667
667
  containerService.enterContainer(newContainer, [di]);
668
668
  this.instanceServiceContainer.undoService.execute(new InsertAction(newContainer, newContainer.childCount, di));
669
- grp.commit();
670
- requestAnimationFrame(() => this.instanceServiceContainer.selectionService.setSelectedElements([di]));
669
+ requestAnimationFrame(() => {
670
+ this.instanceServiceContainer.selectionService.setSelectedElements([di]);
671
+ grp.commit();
672
+ });
671
673
  }
672
674
  }
673
675
  }
@@ -70,7 +70,7 @@ export class ResizeExtension extends AbstractExtension {
70
70
  //#endregion Calc element's dimension
71
71
  this._initialSizes.push({ width: rect.width / this.designerCanvas.scaleFactor, height: rect.height / this.designerCanvas.scaleFactor });
72
72
  this.extendedItem.element.style.width = this._initialSizes[0].width + 'px';
73
- const toArr = getComputedStyle(this.extendedItem.element).transformOrigin.split(' ').map(x => parseInt(x.replace('px', '')));
73
+ const toArr = getComputedStyle(this.extendedItem.element).transformOrigin.split(' ').map(x => parseFloat(x.replace('px', '')));
74
74
  const transformOrigin = new DOMPoint(toArr[0], toArr[1]);
75
75
  this._initialComputedTransformOrigins.push(transformOrigin);
76
76
  this._initialTransformOrigins.push(this.extendedItem.element.style.transformOrigin);
@@ -291,9 +291,9 @@ export class ResizeExtension extends AbstractExtension {
291
291
  this.extendedItem.setStyle('height', this.extendedItem.element.style.height);
292
292
  this.extendedItem.setStyle('left', normalizeToAbsolutePosition(this.extendedItem.element, 'left'));
293
293
  this.extendedItem.setStyle('top', normalizeToAbsolutePosition(this.extendedItem.element, 'top'));
294
- let p3Abs = new DOMPoint(this.extendedItem.element.offsetLeft + parseInt(getComputedStyle(this.extendedItem.element).transformOrigin.split(' ')[0].replace('px', '')), this.extendedItem.element.offsetTop + parseInt(getComputedStyle(this.extendedItem.element).transformOrigin.split(' ')[1].replace('px', '')));
294
+ let p3Abs = new DOMPoint(this.extendedItem.element.offsetLeft + parseFloat(getComputedStyle(this.extendedItem.element).transformOrigin.split(' ')[0].replace('px', '')), this.extendedItem.element.offsetTop + parseFloat(getComputedStyle(this.extendedItem.element).transformOrigin.split(' ')[1].replace('px', '')));
295
295
  this.extendedItem.element.style.transformOrigin = this._initialTransformOrigins[0];
296
- let p1Abs = new DOMPoint(this.extendedItem.element.offsetLeft + parseInt(getComputedStyle(this.extendedItem.element).transformOrigin.split(' ')[0].replace('px', '')), this.extendedItem.element.offsetTop + parseInt(getComputedStyle(this.extendedItem.element).transformOrigin.split(' ')[1].replace('px', '')));
296
+ let p1Abs = new DOMPoint(this.extendedItem.element.offsetLeft + parseFloat(getComputedStyle(this.extendedItem.element).transformOrigin.split(' ')[0].replace('px', '')), this.extendedItem.element.offsetTop + parseFloat(getComputedStyle(this.extendedItem.element).transformOrigin.split(' ')[1].replace('px', '')));
297
297
  let p1 = new DOMPoint(p1Abs.x - p3Abs.x, -(p1Abs.y - p3Abs.y));
298
298
  let matrix = new DOMMatrix(getComputedStyle(this.extendedItem.element).transform);
299
299
  let deltaX = 0;
@@ -2,6 +2,9 @@ import { RotateExtension } from "./RotateExtension";
2
2
  import { css } from "@node-projects/base-custom-webcomponent";
3
3
  export class RotateExtensionProvider {
4
4
  shouldExtend(extensionManager, designerView, designItem) {
5
+ if (designItem.element instanceof SVGElement) {
6
+ return false;
7
+ }
5
8
  return true;
6
9
  }
7
10
  getExtension(extensionManager, designerView, designItem) {
@@ -23,8 +23,8 @@ export class TransformOriginExtension extends AbstractExtension {
23
23
  this._circle.addEventListener(EventNames.PointerDown, event => this.pointerEvent(event));
24
24
  this._circle.addEventListener(EventNames.PointerMove, event => this.pointerEvent(event));
25
25
  this._circle.addEventListener(EventNames.PointerUp, event => this.pointerEvent(event)); //TODO: -> assign to window
26
- if (this.extendedItem.styles.get('transform-origin')) {
27
- this._oldValue = this.extendedItem.styles.get('transform-origin');
26
+ if (this.extendedItem.getStyle('transform-origin')) {
27
+ this._oldValue = this.extendedItem.getStyle('transform-origin');
28
28
  }
29
29
  }
30
30
  pointerEvent(event) {
@@ -1,8 +1,9 @@
1
1
  import { EllipsisExtension } from "./EllipsisExtension";
2
+ import { isVisualSvgElement } from "../../../../helper/SvgHelper";
2
3
  export class EllipsisExtensionProvider {
3
4
  shouldExtend(extensionManager, designerView, designItem) {
4
5
  if (designItem.node instanceof SVGEllipseElement) {
5
- return true;
6
+ return isVisualSvgElement(designItem.node);
6
7
  }
7
8
  return false;
8
9
  }
@@ -1,8 +1,10 @@
1
1
  import { LineExtension } from "./LineExtension";
2
+ import { isVisualSvgElement } from "../../../../helper/SvgHelper";
2
3
  export class LineExtensionProvider {
3
4
  shouldExtend(extensionManager, designerView, designItem) {
4
5
  if (designItem.node instanceof SVGLineElement) {
5
- return true;
6
+ return isVisualSvgElement(designItem.node);
7
+ ;
6
8
  }
7
9
  return false;
8
10
  }
@@ -1,8 +1,10 @@
1
1
  import { PathExtension } from "./PathExtension";
2
+ import { isVisualSvgElement } from "../../../../helper/SvgHelper";
2
3
  export class PathExtensionProvider {
3
4
  shouldExtend(extensionManager, designerView, designItem) {
4
5
  if (designItem.node instanceof SVGPathElement) {
5
- return true;
6
+ return isVisualSvgElement(designItem.node);
7
+ ;
6
8
  }
7
9
  return false;
8
10
  }
@@ -1,8 +1,10 @@
1
1
  import { RectExtension } from "./RectExtension";
2
+ import { isVisualSvgElement } from "../../../../helper/SvgHelper";
2
3
  export class RectExtentionProvider {
3
4
  shouldExtend(extensionManager, designerView, designItem) {
4
5
  if (designItem.node instanceof SVGRectElement) {
5
- return true;
6
+ return isVisualSvgElement(designItem.node);
7
+ ;
6
8
  }
7
9
  return false;
8
10
  }
@@ -143,11 +143,29 @@ export class PropertyGridPropertyList extends BaseCustomWebComponentLazyAppend {
143
143
  this._div.appendChild(label);
144
144
  }
145
145
  else {
146
- let label = document.createElement("label");
147
- label.htmlFor = p.name;
148
- label.textContent = p.name;
149
- label.title = p.name;
150
- this._div.appendChild(label);
146
+ if (!p.renamable) {
147
+ let label = document.createElement("label");
148
+ label.htmlFor = p.name;
149
+ label.textContent = p.name;
150
+ label.title = p.name;
151
+ this._div.appendChild(label);
152
+ }
153
+ else {
154
+ let label = document.createElement("input");
155
+ let input = editor.element;
156
+ label.value = p.name;
157
+ label.onkeyup = e => {
158
+ if (e.key == 'Enter' && label.value) {
159
+ const pg = this._designItems[0].openGroup("rename property name from '" + p.name + "' to '" + label.value + "'");
160
+ p.service.clearValue(this._designItems, p);
161
+ p.name = label.value;
162
+ p.service.setValue(this._designItems, p, input.value);
163
+ pg.commit();
164
+ this._designItems[0].instanceServiceContainer.designerCanvas.extensionManager.refreshAllExtensions(this._designItems);
165
+ }
166
+ };
167
+ this._div.appendChild(label);
168
+ }
151
169
  }
152
170
  editor.element.id = p.name;
153
171
  this._div.appendChild(editor.element);
@@ -160,7 +178,12 @@ export class PropertyGridPropertyList extends BaseCustomWebComponentLazyAppend {
160
178
  }
161
179
  openContextMenu(event, property) {
162
180
  const ctxMenu = [
163
- { title: 'clear', action: (e) => property.service.clearValue(this._designItems, property) },
181
+ {
182
+ title: 'clear', action: (e) => {
183
+ property.service.clearValue(this._designItems, property);
184
+ this._designItems[0].instanceServiceContainer.designerCanvas.extensionManager.refreshAllExtensions(this._designItems);
185
+ }
186
+ },
164
187
  ];
165
188
  if (this._serviceContainer.config.openBindingsEditor) {
166
189
  ctxMenu.push(...[
package/dist/index.d.ts CHANGED
@@ -107,7 +107,6 @@ export * from "./elements/services/undoService/transactionItems/CssStyleChangeAc
107
107
  export * from "./elements/services/undoService/transactionItems/DeleteAction.js";
108
108
  export * from "./elements/services/undoService/transactionItems/InsertAction.js";
109
109
  export * from "./elements/services/undoService/transactionItems/InsertChildAction.js";
110
- export * from "./elements/services/undoService/transactionItems/PropertyChangeAction.js";
111
110
  export * from "./elements/services/BaseServiceContainer.js";
112
111
  export * from "./elements/services/InstanceServiceContainer.js";
113
112
  export type { IService } from "./elements/services/IService.js";
package/dist/index.js CHANGED
@@ -74,7 +74,6 @@ export * from "./elements/services/undoService/transactionItems/CssStyleChangeAc
74
74
  export * from "./elements/services/undoService/transactionItems/DeleteAction.js";
75
75
  export * from "./elements/services/undoService/transactionItems/InsertAction.js";
76
76
  export * from "./elements/services/undoService/transactionItems/InsertChildAction.js";
77
- export * from "./elements/services/undoService/transactionItems/PropertyChangeAction.js";
78
77
  export * from "./elements/services/BaseServiceContainer.js";
79
78
  export * from "./elements/services/InstanceServiceContainer.js";
80
79
  export * from "./elements/services/ServiceContainer.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.155",
4
+ "version": "0.0.156",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",
@@ -13,8 +13,8 @@
13
13
  "prepublishOnly": "npm run build"
14
14
  },
15
15
  "dependencies": {
16
- "@node-projects/base-custom-webcomponent": "^0.10.3",
17
- "@types/node": "^18.11.9",
16
+ "@node-projects/base-custom-webcomponent": "^0.10.5",
17
+ "@types/node": "^18.11.11",
18
18
  "construct-style-sheets-polyfill": "^3.1.0"
19
19
  },
20
20
  "devDependencies": {
@@ -24,7 +24,7 @@
24
24
  "@types/codemirror": "^5.60.5",
25
25
  "@types/jquery": "^3.5.14",
26
26
  "@types/jquery.fancytree": "0.0.7",
27
- "ace-builds": "^1.13.1",
27
+ "ace-builds": "^1.13.2",
28
28
  "codemirror": "^6.0.1",
29
29
  "esprima-next": "^5.8.4",
30
30
  "html2canvas": "*",