@node-projects/web-component-designer 0.0.170 → 0.0.172

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 (32) hide show
  1. package/dist/elements/helper/CssUnitConverter.d.ts +2 -2
  2. package/dist/elements/helper/CssUnitConverter.js +3 -3
  3. package/dist/elements/helper/GridHelper.d.ts +2 -0
  4. package/dist/elements/helper/GridHelper.js +16 -1
  5. package/dist/elements/item/DesignItem.d.ts +1 -0
  6. package/dist/elements/item/DesignItem.js +19 -7
  7. package/dist/elements/item/IDesignItem.d.ts +1 -0
  8. package/dist/elements/services/copyPasteService/CopyPasteService.js +2 -2
  9. package/dist/elements/services/propertiesService/PropertyGroupsService.d.ts +2 -2
  10. package/dist/elements/services/propertiesService/services/AbstractPropertiesService.js +2 -2
  11. package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService.d.ts +6 -2
  12. package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService.js +31 -7
  13. package/dist/elements/services/propertiesService/services/CssProperties.json +541 -0
  14. package/dist/elements/services/propertiesService/services/CssPropertiesService.d.ts +4 -4
  15. package/dist/elements/services/propertiesService/services/CssPropertiesService.js +42 -167
  16. package/dist/elements/services/propertiesService/services/NativeElementsPropertiesService.js +6 -0
  17. package/dist/elements/services/stylesheetService/CssToolsStylesheetService.d.ts +17 -0
  18. package/dist/elements/services/stylesheetService/CssToolsStylesheetService.js +45 -0
  19. package/dist/elements/services/stylesheetService/CssTreeStylesheetService copy.d.ts +48 -0
  20. package/dist/elements/services/stylesheetService/CssTreeStylesheetService copy.js +185 -0
  21. package/dist/elements/services/stylesheetService/CssTreeStylesheetService.d.ts +3 -3
  22. package/dist/elements/services/stylesheetService/CssTreeStylesheetService.js +41 -22
  23. package/dist/elements/services/stylesheetService/IStylesheetService.d.ts +5 -5
  24. package/dist/elements/widgets/designerView/designerCanvas.d.ts +1 -0
  25. package/dist/elements/widgets/designerView/designerCanvas.js +9 -3
  26. package/dist/elements/widgets/designerView/extensions/GridExtension.d.ts +35 -4
  27. package/dist/elements/widgets/designerView/extensions/GridExtension.js +277 -90
  28. package/dist/elements/widgets/designerView/extensions/GridExtensionProvider.js +3 -1
  29. package/dist/elements/widgets/designerView/extensions/TransformOriginExtension.js +7 -6
  30. package/dist/index.d.ts +1 -0
  31. package/dist/index.js +1 -0
  32. package/package.json +2 -1
@@ -11,7 +11,7 @@ export class CssTreeStylesheetService {
11
11
  for (let stylesheet of stylesheets) {
12
12
  this._stylesheets.set(stylesheet.name, {
13
13
  stylesheet: stylesheet,
14
- ast: window.csstree.toPlainObject((window.csstree.parse(stylesheet.stylesheet, { positions: true, parseValue: false })))
14
+ ast: window.csstree.toPlainObject((window.csstree.parse(stylesheet.content, { positions: true, parseValue: false })))
15
15
  });
16
16
  }
17
17
  this.stylesheetsChanged.emit();
@@ -33,8 +33,8 @@ export class CssTreeStylesheetService {
33
33
  let styles = [];
34
34
  for (let item of this._stylesheets) {
35
35
  if (!item[1].ast || !this.astHasChildren(item[1].ast))
36
- break;
37
- styles = styles.concat(Array.from(this.rulesFromAST(item[1].ast, item[1].stylesheet.stylesheet, item[0], designItem)));
36
+ continue;
37
+ styles = styles.concat(Array.from(this.rulesFromAST(item[1].ast, item[1].stylesheet.content, item[0], designItem)));
38
38
  }
39
39
  ;
40
40
  return styles;
@@ -61,19 +61,19 @@ export class CssTreeStylesheetService {
61
61
  }
62
62
  return retCollection;
63
63
  }
64
- getDeclarationInternal(designItem, prop) {
64
+ getDeclarationInternal(designItem, styleName) {
65
65
  let rules = this.getAppliedRulesInternal(designItem);
66
66
  if (!rules)
67
67
  return null;
68
68
  let declarations = [];
69
69
  for (let rule of rules) {
70
- let declaration = this.findDeclarationInRule(rule.ast, prop);
70
+ let declaration = this.findDeclarationInRule(rule.ast, styleName);
71
71
  if (!declaration)
72
72
  continue;
73
73
  declarations.push({
74
74
  ast: declaration,
75
75
  parent: rule,
76
- name: prop.name,
76
+ name: styleName,
77
77
  value: declaration.value.value,
78
78
  important: declaration.important == true,
79
79
  });
@@ -81,25 +81,39 @@ export class CssTreeStylesheetService {
81
81
  ;
82
82
  return declarations;
83
83
  }
84
- getDeclarations(designItem, prop) {
85
- let declarations = this.getDeclarationInternal(designItem, prop);
84
+ getDeclarations(designItem, stlyeName) {
85
+ let declarations = this.getDeclarationInternal(designItem, stlyeName);
86
86
  if (!declarations)
87
87
  return null;
88
88
  return this.sortDeclarations(declarations);
89
89
  }
90
90
  /* Section covers the update of rules and declarations */
91
- updateDeclarationWithProperty(designItem, property, value, important) {
92
- let sortedDecl = this.sortDeclarations(this.getDeclarationInternal(designItem, property));
93
- if (!sortedDecl) {
94
- // no declaration of property yet
95
- return false;
96
- }
97
- return false;
98
- }
99
91
  updateDeclarationWithDeclaration(declaration, value, important) {
100
- declaration.ast.value = window.csstree.toPlainObject(window.csstree.parse(declaration.name + ": " + value, { context: 'declaration', parseValue: false })).value;
101
- this._stylesheets.get(declaration.parent.stylesheetName).stylesheet.stylesheet = window.csstree.generate(window.csstree.fromPlainObject(this._stylesheets.get(declaration.parent.stylesheetName).ast));
102
- this.stylesheetChanged.emit({ stylesheet: this._stylesheets.get(declaration.parent.stylesheetName).stylesheet });
92
+ let sourceNode = this._stylesheets.get(declaration.parent.stylesheetName);
93
+ declaration.ast.value = window.csstree.toPlainObject(window.csstree.parse(declaration.name + ": " + value + (important ? " !important" : ""), { context: 'declaration', parseValue: false })).value;
94
+ sourceNode.stylesheet.content = window.csstree.generate(window.csstree.fromPlainObject(sourceNode.ast));
95
+ // After generating the stylesheet, the AST has to be transformed back into a plain object
96
+ sourceNode.ast = window.csstree.toPlainObject(sourceNode.ast);
97
+ this.stylesheetChanged.emit({ stylesheet: sourceNode.stylesheet });
98
+ return true;
99
+ }
100
+ insertDeclarationIntoRule(rule, declaration, important) {
101
+ let sourceNode = this._stylesheets.get(rule.stylesheetName);
102
+ rule.ast.block.children.push(window.csstree.toPlainObject(window.csstree.parse(declaration.name + ": " + declaration.value + (declaration.important ? " !important" : ""), { context: 'declaration', parseValue: false })));
103
+ sourceNode.stylesheet.content = window.csstree.generate(window.csstree.fromPlainObject(sourceNode.ast));
104
+ // After generating the stylesheet, the AST has to be transformed back into a plain object
105
+ sourceNode.ast = window.csstree.toPlainObject(sourceNode.ast);
106
+ this.stylesheetChanged.emit({ stylesheet: sourceNode.stylesheet });
107
+ return true;
108
+ }
109
+ removeDeclarationFromRule(rule, declaration) {
110
+ let index = rule.ast.block.children.indexOf(declaration.ast);
111
+ if (index == -1)
112
+ return false;
113
+ rule.ast.block.children.splice(index, 1);
114
+ this._stylesheets.get(rule.stylesheetName).stylesheet.content = window.csstree.generate(window.csstree.fromPlainObject(this._stylesheets.get(rule.stylesheetName).ast));
115
+ this._stylesheets.get(rule.stylesheetName).ast = window.csstree.toPlainObject(window.csstree.fromPlainObject(this._stylesheets.get(rule.stylesheetName).ast));
116
+ this.stylesheetChanged.emit({ stylesheet: this._stylesheets.get(rule.stylesheetName).stylesheet });
103
117
  return true;
104
118
  }
105
119
  /* Section covers the internal traversal creation of rules and declarations */
@@ -145,7 +159,12 @@ export class CssTreeStylesheetService {
145
159
  for (let selector of selectorsAST.children) {
146
160
  let sel = "";
147
161
  for (let fraction of selector.children) {
148
- sel += fraction.name;
162
+ if (fraction.type == "IdSelector")
163
+ sel += "#" + fraction.name;
164
+ else if (fraction.type == "ClassSelector")
165
+ sel += "." + fraction.name;
166
+ else
167
+ sel += fraction.name;
149
168
  }
150
169
  selectors.push(sel);
151
170
  }
@@ -158,8 +177,8 @@ export class CssTreeStylesheetService {
158
177
  specificities.forEach(specificity => sum += specificity.a * 10000 + specificity.b * 100 + specificity.c);
159
178
  return sum;
160
179
  }
161
- findDeclarationInRule(rule, property) {
162
- return rule.block.children.find(declaration => declaration.property == property.name);
180
+ findDeclarationInRule(rule, styleName) {
181
+ return rule.block.children.find(declaration => declaration.property == styleName);
163
182
  }
164
183
  elementMatchesASelector(designItem, selectors) {
165
184
  for (const selector of selectors)
@@ -1,6 +1,5 @@
1
1
  import { TypedEvent } from "@node-projects/base-custom-webcomponent";
2
2
  import { IDesignItem } from "../../item/IDesignItem.js";
3
- import { IProperty } from "../propertiesService/IProperty.js";
4
3
  export interface IStyleRule {
5
4
  selector: string;
6
5
  declarations: IStyleDeclaration[];
@@ -13,16 +12,17 @@ export interface IStyleDeclaration {
13
12
  important: boolean;
14
13
  }
15
14
  export interface IStylesheet {
16
- stylesheet: string;
15
+ content: string;
17
16
  name: string;
18
17
  }
19
18
  export interface IStylesheetService {
20
- setStylesheets(stylesheets: IStylesheet[]): any;
19
+ setStylesheets(stylesheets: IStylesheet[]): void;
21
20
  getStylesheets(): IStylesheet[];
22
21
  getAppliedRules(designItem: IDesignItem): IStyleRule[];
23
- getDeclarations(designItem: IDesignItem, property: IProperty): IStyleDeclaration[];
24
- updateDeclarationWithProperty(designItem: IDesignItem, property: IProperty, value: string, important: boolean): boolean;
22
+ getDeclarations(designItem: IDesignItem, styleName: string): IStyleDeclaration[];
25
23
  updateDeclarationWithDeclaration(declaration: IStyleDeclaration, value: string, important: boolean): boolean;
24
+ insertDeclarationIntoRule(rule: IStyleRule, declaration: IStyleDeclaration, important: boolean): boolean;
25
+ removeDeclarationFromRule(rule: IStyleRule, declaration: IStyleDeclaration): boolean;
26
26
  stylesheetChanged: TypedEvent<{
27
27
  stylesheet: IStylesheet;
28
28
  }>;
@@ -59,6 +59,7 @@ export declare class DesignerCanvas extends BaseCustomWebComponentLazyAppend imp
59
59
  extensionManager: IExtensionManager;
60
60
  private _pointerextensions;
61
61
  private _onDblClickBound;
62
+ private _lastCopiedPrimaryItem;
62
63
  constructor();
63
64
  get designerWidth(): string;
64
65
  set designerWidth(value: string);
@@ -163,6 +163,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
163
163
  extensionManager;
164
164
  _pointerextensions;
165
165
  _onDblClickBound;
166
+ _lastCopiedPrimaryItem;
166
167
  constructor() {
167
168
  super();
168
169
  this._restoreCachedInititalValues();
@@ -219,7 +220,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
219
220
  if (this.instanceServiceContainer.stylesheetService) {
220
221
  styles.push(...this.instanceServiceContainer.stylesheetService
221
222
  .getStylesheets()
222
- .map(x => cssFromString(this.buildPatchedStyleSheet([cssFromString(x.stylesheet)]))));
223
+ .map(x => cssFromString(this.buildPatchedStyleSheet([cssFromString(x.content)]))));
223
224
  }
224
225
  this.shadowRoot.adoptedStyleSheets = styles;
225
226
  }
@@ -365,13 +366,14 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
365
366
  this.instanceServiceContainer.selectionService.setSelectedElements(Array.from(this.rootDesignItem.children()));
366
367
  }
367
368
  async handleCopyCommand() {
369
+ this._lastCopiedPrimaryItem = this.instanceServiceContainer.selectionService.primarySelection;
368
370
  await this.serviceContainer.copyPasteService.copyItems(this.instanceServiceContainer.selectionService.selectedElements);
369
371
  }
370
372
  async handlePasteCommand(disableRestoreOfPositions) {
371
373
  const [designItems, positions] = await this.serviceContainer.copyPasteService.getPasteItems(this.serviceContainer, this.instanceServiceContainer);
372
374
  let grp = this.rootDesignItem.openGroup("Insert");
373
375
  let pasteContainer = this.rootDesignItem;
374
- let pCon = this.instanceServiceContainer.selectionService.primarySelection;
376
+ let pCon = this._lastCopiedPrimaryItem?.parent ?? this.instanceServiceContainer.selectionService.primarySelection;
375
377
  while (pCon != null) {
376
378
  const containerStyle = getComputedStyle(pCon.element);
377
379
  let newContainerService;
@@ -420,8 +422,12 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
420
422
  if (undoService)
421
423
  this.instanceServiceContainer.register("undoService", undoService(this));
422
424
  const selectionService = this.serviceContainer.getLastService('selectionService');
423
- if (selectionService)
425
+ if (selectionService) {
424
426
  this.instanceServiceContainer.register("selectionService", selectionService(this));
427
+ this.instanceServiceContainer.selectionService.onSelectionChanged.on(() => {
428
+ this._lastCopiedPrimaryItem = null;
429
+ });
430
+ }
425
431
  this.rootDesignItem = DesignItem.GetOrCreateDesignItem(this._canvas, this.serviceContainer, this.instanceServiceContainer);
426
432
  const contentService = this.serviceContainer.getLastService('contentService');
427
433
  if (contentService)
@@ -5,16 +5,47 @@ import { IExtensionManager } from './IExtensionManger.js';
5
5
  export declare class GridExtension extends AbstractExtension {
6
6
  private _initialPoint;
7
7
  private _initialSizes;
8
- private _rects;
8
+ private _cells;
9
9
  private _gaps;
10
+ private _headers;
11
+ private _headerTexts;
12
+ private _plusCircles;
10
13
  private _resizeCircles;
11
14
  private minPixelSize;
15
+ private gridInformation;
16
+ private defaultHeaderSize;
17
+ private defaultPlusSize;
18
+ private defaultDistanceToBox;
19
+ private defaultDistanceBetweenHeaders;
20
+ private defaultSizeOfNewRowOrColumn;
12
21
  constructor(extensionManager: IExtensionManager, designerView: IDesignerCanvas, extendedItem: IDesignItem);
13
22
  extend(): void;
14
23
  refresh(): void;
15
24
  dispose(): void;
16
- _drawResizeCircles(gap: any, oldCircle?: SVGCircleElement): SVGCircleElement;
25
+ _initSVGArrays(): void;
26
+ _drawResizeCircle(gap: any, oldCircle?: SVGCircleElement): SVGCircleElement;
27
+ _drawHeader(cell: any, oldHeader: any, index: any, alignment: "vertical" | "horizontal"): SVGRectElement;
28
+ _drawHeaderText(cell: any, oldHeaderText: any, alignment: "vertical" | "horizontal"): SVGTextElement;
29
+ _drawPlusCircle(x: any, y: any, oldPlusElement: {
30
+ circle: SVGCircleElement;
31
+ verticalLine: SVGLineElement;
32
+ horizontalLine: SVGLineElement;
33
+ }, index: any, alignment: "vertical" | "horizontal", final?: boolean): {
34
+ circle: any;
35
+ verticalLine: any;
36
+ horizontalLine: any;
37
+ };
38
+ _getHeaderText(size: number, unit: string, percentTarget: "width" | "height"): string;
39
+ _getInitialSizes(): {
40
+ x: any[];
41
+ xUnit: any[];
42
+ y: any[];
43
+ yUnit: any[];
44
+ };
17
45
  _pointerActionTypeResize(event: PointerEvent, circle: SVGCircleElement, gapColumn: any, gapRow: any): void;
18
- _calculateNewSize(iSizes: any, diff: any, gapIndex: any, percentTarget: 'width' | 'heigth'): string;
19
- _getCssUnit(cssValue: string): string;
46
+ _calculateNewSize(iSizes: number[], iUnits: string[], diff: any, gapIndex: any, percentTarget: 'width' | 'height', pointerUp?: boolean): string;
47
+ _editGrid(pos: number, alignment: "vertical" | "horizontal", task: "add" | "del"): void;
48
+ _calculateNewElementSize(elementTarget: "width" | "height"): string;
49
+ _toggleDisplayPlusCircles(index: any, alignment: "vertical" | "horizontal", double?: boolean): void;
50
+ _convertCssUnit(cssValue: string | number, target: HTMLElement, percentTarget: 'width' | 'height', unit: string): string | number;
20
51
  }