@node-projects/web-component-designer 0.0.205 → 0.0.207

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.
@@ -54,7 +54,11 @@ export class CssCurrentPropertiesService extends CommonPropertiesService {
54
54
  setValue(designItems, property, value) {
55
55
  // No selector means local style, styleDeclaration is null means new property
56
56
  if (property.styleRule?.selector !== null && property.styleDeclaration) {
57
- const action = new StylesheetStyleChangeAction(designItems[0].instanceServiceContainer.stylesheetService, property.styleDeclaration, value, property.styleDeclaration.value);
57
+ // styleDeclaration stored Propertygrid is not refreshed after entering a new value, so we need to reload
58
+ // TODO: we do not respect if a same style is found in a media query or another @rule, maybe we need a refresh in the stylesheet parser
59
+ const decls = designItems[0].instanceServiceContainer.stylesheetService?.getDeclarations(designItems[0], property.styleDeclaration.name);
60
+ const currentDecl = decls.find(x => x.parent.selector == property.styleDeclaration.parent.selector && x.parent.stylesheetName == property.styleDeclaration.parent.stylesheetName);
61
+ const action = new StylesheetStyleChangeAction(designItems[0].instanceServiceContainer.stylesheetService, property.styleDeclaration, value, currentDecl.value);
58
62
  designItems[0].instanceServiceContainer.undoService.execute(action);
59
63
  this._notifyChangedProperty(designItems[0], property, value);
60
64
  return;
@@ -35,10 +35,6 @@ export class CssStyleChangeAction {
35
35
  newValue;
36
36
  oldValue;
37
37
  mergeWith(other) {
38
- if (other instanceof CssStyleChangeAction && this.designItem === other.designItem && this.name === other.name) {
39
- this.newValue = other.newValue;
40
- return true;
41
- }
42
38
  return false;
43
39
  }
44
40
  }
@@ -0,0 +1,16 @@
1
+ import { ITransactionItem } from '../ITransactionItem.js';
2
+ import { IDesignItem } from '../../../item/IDesignItem.js';
3
+ export declare class InsertChildAction implements ITransactionItem {
4
+ constructor(designItem: IDesignItem, newParent: IDesignItem, newIndex: number);
5
+ title?: string;
6
+ get affectedItems(): IDesignItem[];
7
+ undo(): void;
8
+ do(): void;
9
+ designItem: IDesignItem;
10
+ newParent: IDesignItem;
11
+ newIndex: number;
12
+ oldParent: IDesignItem;
13
+ oldIndex: number;
14
+ newItem: IDesignItem;
15
+ mergeWith(other: ITransactionItem): boolean;
16
+ }
@@ -0,0 +1,37 @@
1
+ export class InsertChildAction {
2
+ constructor(designItem, newParent, newIndex) {
3
+ this.title = "Move or Insert Item";
4
+ this.designItem = designItem;
5
+ this.newParent = newParent;
6
+ this.newIndex = newIndex;
7
+ }
8
+ title;
9
+ get affectedItems() {
10
+ if (this.oldParent)
11
+ return [this.designItem, this.newParent, this.oldParent];
12
+ return [this.designItem, this.newParent];
13
+ }
14
+ undo() {
15
+ if (this.oldParent)
16
+ this.oldParent._insertChildInternal(this.designItem, this.oldIndex);
17
+ else
18
+ this.designItem.parent._removeChildInternal(this.designItem);
19
+ this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'moved', designItems: [this.designItem] });
20
+ }
21
+ do() {
22
+ this.oldParent = this.designItem.parent;
23
+ if (this.oldParent)
24
+ this.oldIndex = this.designItem.parent.indexOf(this.designItem);
25
+ this.newParent._insertChildInternal(this.designItem, this.newIndex);
26
+ this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'moved', designItems: [this.designItem] });
27
+ }
28
+ designItem;
29
+ newParent;
30
+ newIndex;
31
+ oldParent;
32
+ oldIndex;
33
+ newItem;
34
+ mergeWith(other) {
35
+ return false;
36
+ }
37
+ }
@@ -0,0 +1,12 @@
1
+ import { ITransactionItem } from '../ITransactionItem.js';
2
+ import { IDesignItem } from '../../../item/IDesignItem.js';
3
+ export declare class SetDesignItemsAction implements ITransactionItem {
4
+ constructor(newDesignItems: IDesignItem[], oldDesignItems: IDesignItem[]);
5
+ title?: string;
6
+ get affectedItems(): IDesignItem[];
7
+ undo(): void;
8
+ do(): void;
9
+ newDesignItems: IDesignItem[];
10
+ oldDesignItems: IDesignItem[];
11
+ mergeWith(other: ITransactionItem): boolean;
12
+ }
@@ -0,0 +1,22 @@
1
+ export class SetDesignItemsAction {
2
+ constructor(newDesignItems, oldDesignItems) {
3
+ this.title = "Set all DesignItems";
4
+ this.newDesignItems = newDesignItems;
5
+ this.oldDesignItems = oldDesignItems;
6
+ }
7
+ title;
8
+ get affectedItems() {
9
+ return this.newDesignItems;
10
+ }
11
+ undo() {
12
+ this.newDesignItems[0].instanceServiceContainer.designerCanvas._internalSetDesignItems(this.oldDesignItems);
13
+ }
14
+ do() {
15
+ this.newDesignItems[0].instanceServiceContainer.designerCanvas._internalSetDesignItems(this.newDesignItems);
16
+ }
17
+ newDesignItems;
18
+ oldDesignItems;
19
+ mergeWith(other) {
20
+ return false;
21
+ }
22
+ }
@@ -49,6 +49,8 @@ export interface IDesignerCanvas extends IPlacementView, IUiCommandHandler {
49
49
  elementFromPoint(x: number, y: number): Element;
50
50
  elementsFromPoint(x: number, y: number): Element[];
51
51
  showHoverExtension(element: Element, event: Event): any;
52
+ setDesignItems(designItems: IDesignItem[]): any;
53
+ _internalSetDesignItems(designItems: IDesignItem[]): any;
52
54
  zoomTowardsPoint(point: IPoint, scalechange: number): void;
53
55
  zoomPoint(canvasPoint: IPoint, newZoom: number): void;
54
56
  zoomOntoRectangle(startPoint: IPoint, endPoint: IPoint): void;
@@ -83,6 +83,7 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
83
83
  private _resizeBackgroundGrid;
84
84
  private _updateTransform;
85
85
  setDesignItems(designItems: IDesignItem[]): void;
86
+ _internalSetDesignItems(designItems: IDesignItem[]): void;
86
87
  addDesignItems(designItems: IDesignItem[]): void;
87
88
  _dragOverExtensionItem: IDesignItem;
88
89
  private _onDragEnter;
@@ -19,6 +19,7 @@ import { OverlayLayerView } from './overlayLayerView.js';
19
19
  import { ContextMenu } from '../../helper/contextMenu/ContextMenu.js';
20
20
  import { NodeType } from '../../item/NodeType.js';
21
21
  import { StylesheetChangedAction } from '../../services/undoService/transactionItems/StylesheetChangedAction.js';
22
+ import { SetDesignItemsAction } from '../../services/undoService/transactionItems/SetDesignItemsAction.js';
22
23
  export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
23
24
  // Public Properties
24
25
  serviceContainer;
@@ -523,8 +524,12 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
523
524
  this.snapLines.clearSnaplines();
524
525
  }
525
526
  setDesignItems(designItems) {
527
+ const setItemsAction = new SetDesignItemsAction(designItems, [...this.rootDesignItem.children()]);
528
+ this.instanceServiceContainer.undoService.execute(setItemsAction);
529
+ }
530
+ _internalSetDesignItems(designItems) {
526
531
  this._fillCalculationrects();
527
- this.instanceServiceContainer.undoService.clear();
532
+ //this.instanceServiceContainer.undoService.clear();
528
533
  this.overlayLayer.removeAllOverlays();
529
534
  DomHelper.removeAllChildnodes(this.overlayLayer);
530
535
  for (let i of [...this.rootDesignItem.children()])
@@ -80,10 +80,11 @@ export class EditGridColumnRowSizesExtension extends AbstractExtension {
80
80
  }
81
81
  }
82
82
  _convertCssUnits(pixelSizes, targetUnits, target, percentTarget) {
83
+ let cp = getComputedStyle(target);
83
84
  let bounding = target.getBoundingClientRect();
84
85
  let containerSize = bounding[percentTarget];
85
86
  let amountGaps = percentTarget == "height" ? this.gridInformation.cells.length - 1 : this.gridInformation.cells[0].length - 1;
86
- let gapSize = convertCssUnitToPixel(percentTarget == "width" ? target.style.columnGap : target.style.rowGap, target, percentTarget) ?? 0;
87
+ let gapSize = convertCssUnitToPixel(percentTarget == "width" ? cp.columnGap : cp.rowGap, target, percentTarget) ?? 0;
87
88
  let containerSizeWithoutGaps = containerSize - gapSize * amountGaps;
88
89
  let sizeForFrs = containerSizeWithoutGaps;
89
90
  for (let i = 0; i < pixelSizes.length; i++) {
@@ -96,7 +97,7 @@ export class EditGridColumnRowSizesExtension extends AbstractExtension {
96
97
  result.push(convertCssUnit(pixelSizes[i], target, percentTarget, targetUnits[i]));
97
98
  }
98
99
  else {
99
- result.push((pixelSizes[i] / sizeForFrs).toFixed(2) + 'fr');
100
+ result.push(((pixelSizes[i] / sizeForFrs) * 10).toFixed(2) + 'fr');
100
101
  }
101
102
  }
102
103
  return result;
package/dist/index.d.ts CHANGED
@@ -118,6 +118,7 @@ export * from "./elements/services/undoService/transactionItems/InsertAction.js"
118
118
  export * from "./elements/services/undoService/transactionItems/InsertChildAction.js";
119
119
  export * from "./elements/services/undoService/transactionItems/StylesheetChangedAction.js";
120
120
  export * from "./elements/services/undoService/transactionItems/StylesheetStyleChangeAction.js";
121
+ export * from "./elements/services/undoService/transactionItems/SetDesignItemsAction.js";
121
122
  export * from "./elements/services/BaseServiceContainer.js";
122
123
  export * from "./elements/services/InstanceServiceContainer.js";
123
124
  export type { IService } from "./elements/services/IService.js";
package/dist/index.js CHANGED
@@ -82,6 +82,7 @@ export * from "./elements/services/undoService/transactionItems/InsertAction.js"
82
82
  export * from "./elements/services/undoService/transactionItems/InsertChildAction.js";
83
83
  export * from "./elements/services/undoService/transactionItems/StylesheetChangedAction.js";
84
84
  export * from "./elements/services/undoService/transactionItems/StylesheetStyleChangeAction.js";
85
+ export * from "./elements/services/undoService/transactionItems/SetDesignItemsAction.js";
85
86
  export * from "./elements/services/BaseServiceContainer.js";
86
87
  export * from "./elements/services/InstanceServiceContainer.js";
87
88
  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.205",
4
+ "version": "0.0.207",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",