@node-projects/web-component-designer 0.0.204 → 0.0.206

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 (30) hide show
  1. package/dist/elements/documentContainer.d.ts +4 -1
  2. package/dist/elements/documentContainer.js +1 -1
  3. package/dist/elements/item/DesignItem.js +5 -4
  4. package/dist/elements/services/placementService/GridPlacementService.js +4 -0
  5. package/dist/elements/services/propertiesService/services/CssCurrentPropertiesService.js +3 -1
  6. package/dist/elements/services/stylesheetService/AbstractStylesheetService.d.ts +5 -1
  7. package/dist/elements/services/stylesheetService/CssToolsStylesheetService.d.ts +1 -0
  8. package/dist/elements/services/stylesheetService/CssToolsStylesheetService.js +29 -2
  9. package/dist/elements/services/stylesheetService/CssTreeStylesheetService.d.ts +1 -0
  10. package/dist/elements/services/stylesheetService/CssTreeStylesheetService.js +17 -5
  11. package/dist/elements/services/stylesheetService/IStylesheetService.d.ts +5 -1
  12. package/dist/elements/services/undoService/transactionItems/CssStyleChangeAction copy.d.ts +14 -0
  13. package/dist/elements/services/undoService/transactionItems/CssStyleChangeAction copy.js +44 -0
  14. package/dist/elements/services/undoService/transactionItems/CssStyleChangeAction.js +0 -4
  15. package/dist/elements/services/undoService/transactionItems/InsertChildAction copy.d.ts +16 -0
  16. package/dist/elements/services/undoService/transactionItems/InsertChildAction copy.js +37 -0
  17. package/dist/elements/services/undoService/transactionItems/SetDesignItemsAction.d.ts +12 -0
  18. package/dist/elements/services/undoService/transactionItems/SetDesignItemsAction.js +22 -0
  19. package/dist/elements/services/undoService/transactionItems/StylesheetChangedAction.d.ts +14 -0
  20. package/dist/elements/services/undoService/transactionItems/StylesheetChangedAction.js +24 -0
  21. package/dist/elements/services/undoService/transactionItems/StylesheetStyleChangeAction.d.ts +17 -0
  22. package/dist/elements/services/undoService/transactionItems/StylesheetStyleChangeAction.js +28 -0
  23. package/dist/elements/widgets/codeView/code-view-ace.js +1 -1
  24. package/dist/elements/widgets/codeView/code-view-monaco.js +1 -1
  25. package/dist/elements/widgets/designerView/IDesignerCanvas.d.ts +2 -0
  26. package/dist/elements/widgets/designerView/designerCanvas.d.ts +1 -0
  27. package/dist/elements/widgets/designerView/designerCanvas.js +17 -3
  28. package/dist/index.d.ts +3 -0
  29. package/dist/index.js +3 -0
  30. package/package.json +3 -3
@@ -21,7 +21,10 @@ export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend
21
21
  set additionalStylesheets(stylesheets: IStylesheet[]);
22
22
  get additionalStylesheets(): IStylesheet[];
23
23
  additionalStylesheetChanged: TypedEvent<{
24
- stylesheet: IStylesheet;
24
+ name: string;
25
+ newStyle: string;
26
+ oldStyle: string;
27
+ changeSource: 'extern' | 'styleupdate';
25
28
  }>;
26
29
  onContentChanged: TypedEvent<void>;
27
30
  private _serviceContainer;
@@ -25,7 +25,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
25
25
  if (stylesheetService) {
26
26
  const instance = stylesheetService(this.designerView.designerCanvas);
27
27
  this.instanceServiceContainer.register("stylesheetService", instance);
28
- instance.stylesheetChanged.on(s => this.additionalStylesheetChanged.emit(s));
28
+ instance.stylesheetChanged.on(e => this.additionalStylesheetChanged.emit({ name: e.name, newStyle: e.newStyle, oldStyle: e.oldStyle, changeSource: e.changeSource }));
29
29
  }
30
30
  else {
31
31
  console.warn("no Stylesheet-Service registered, but additionalStylesheets are used.");
@@ -8,6 +8,7 @@ import { InsertChildAction } from '../services/undoService/transactionItems/Inse
8
8
  import { DomConverter } from '../widgets/designerView/DomConverter.js';
9
9
  import { DeleteAction } from '../services/undoService/transactionItems/DeleteAction.js';
10
10
  import { enableStylesheetService } from '../widgets/designerView/extensions/buttons/StylesheetServiceDesignViewConfigButtons.js';
11
+ import { StylesheetStyleChangeAction } from '../services/undoService/transactionItems/StylesheetStyleChangeAction.js';
11
12
  const hideAtDesignTimeAttributeName = 'node-projects-hide-at-design-time';
12
13
  const hideAtRunTimeAttributeName = 'node-projects-hide-at-run-time';
13
14
  const lockAtDesignTimeAttributeName = 'node-projects-lock-at-design-time';
@@ -328,8 +329,8 @@ export class DesignItem {
328
329
  updateStyleInSheetOrLocal(name, value, important) {
329
330
  let nm = PropertiesHelper.camelToDashCase(name);
330
331
  // Pre-sorted by specificity
331
- let declerations = this.instanceServiceContainer.stylesheetService?.getDeclarations(this, nm);
332
- if (this.hasStyle(name) || this.instanceServiceContainer.designContext.extensionOptions[enableStylesheetService] === false || !declerations?.length) {
332
+ let declarations = this.instanceServiceContainer.stylesheetService?.getDeclarations(this, nm);
333
+ if (this.hasStyle(name) || this.instanceServiceContainer.designContext.extensionOptions[enableStylesheetService] === false || !declarations?.length) {
333
334
  // Set style locally
334
335
  if (this.getStyle(nm) != value) {
335
336
  this.setStyle(nm, value);
@@ -339,8 +340,8 @@ export class DesignItem {
339
340
  }
340
341
  }
341
342
  else {
342
- // Set style in sheet
343
- this.instanceServiceContainer.stylesheetService.updateDeclarationValue(declerations[0], value, important);
343
+ const action = new StylesheetStyleChangeAction(this.instanceServiceContainer.stylesheetService, declarations[0], value, declarations[0].value);
344
+ this.instanceServiceContainer.undoService.execute(action);
344
345
  }
345
346
  }
346
347
  getStyleFromSheetOrLocal(name, fallback = null) {
@@ -84,12 +84,16 @@ export class GridPlacementService {
84
84
  column = 0;
85
85
  for (let cell of cellRow) {
86
86
  if (pointInRect(pos, cell)) {
87
+ //Grid Area is shorthand for grid row/column, to make undo work correctly we need to set befor and after clear
87
88
  if (cell.name) {
89
+ items[0].setStyle('grid-area', cell.name);
88
90
  items[0].removeStyle('grid-column');
89
91
  items[0].removeStyle('grid-row');
90
92
  items[0].setStyle('grid-area', cell.name);
91
93
  }
92
94
  else {
95
+ items[0].setStyle('grid-column', column + 1);
96
+ items[0].setStyle('grid-row', row + 1);
93
97
  items[0].removeStyle('grid-area');
94
98
  items[0].setStyle('grid-column', column + 1);
95
99
  items[0].setStyle('grid-row', row + 1);
@@ -3,6 +3,7 @@ import { RefreshMode } from '../IPropertiesService.js';
3
3
  import { CommonPropertiesService } from './CommonPropertiesService.js';
4
4
  import { ValueType } from '../ValueType.js';
5
5
  import { NodeType } from '../../../item/NodeType.js';
6
+ import { StylesheetStyleChangeAction } from '../../undoService/transactionItems/StylesheetStyleChangeAction.js';
6
7
  //TODO: remove this code when import asserts are supported
7
8
  let cssProperties;
8
9
  //@ts-ignore
@@ -53,7 +54,8 @@ export class CssCurrentPropertiesService extends CommonPropertiesService {
53
54
  setValue(designItems, property, value) {
54
55
  // No selector means local style, styleDeclaration is null means new property
55
56
  if (property.styleRule?.selector !== null && property.styleDeclaration) {
56
- designItems[0].instanceServiceContainer.stylesheetService.updateDeclarationValue(property.styleDeclaration, value, false);
57
+ const action = new StylesheetStyleChangeAction(designItems[0].instanceServiceContainer.stylesheetService, property.styleDeclaration, value, property.styleDeclaration.value);
58
+ designItems[0].instanceServiceContainer.undoService.execute(action);
57
59
  this._notifyChangedProperty(designItems[0], property, value);
58
60
  return;
59
61
  }
@@ -9,8 +9,12 @@ export declare abstract class AbstractStylesheetService implements IStylesheetSe
9
9
  abstract updateDeclarationValue(declaration: IStyleDeclaration, value: string, important: boolean): boolean;
10
10
  abstract insertDeclarationIntoRule(rule: IStyleRule, property: string, value: string, important: boolean): boolean;
11
11
  abstract removeDeclarationFromRule(rule: IStyleRule, property: string): boolean;
12
+ abstract updateCompleteStylesheet(name: string, newStyle: string): any;
12
13
  stylesheetChanged: TypedEvent<{
13
- stylesheet: IStylesheet;
14
+ name: string;
15
+ newStyle: string;
16
+ oldStyle: string;
17
+ changeSource: 'extern' | 'styleupdate';
14
18
  }>;
15
19
  stylesheetsChanged: TypedEvent<void>;
16
20
  protected elementMatchesASelector(designItem: IDesignItem, selectors: string[]): boolean;
@@ -33,5 +33,6 @@ export declare class CssToolsStylesheetService extends AbstractStylesheetService
33
33
  insertDeclarationIntoRule(rule: IRuleWithAST, property: string, value: string, important: boolean): boolean;
34
34
  removeDeclarationFromRule(rule: IRuleWithAST, property: string): boolean;
35
35
  private updateStylesheet;
36
+ updateCompleteStylesheet(name: string, newStyle: string): void;
36
37
  }
37
38
  export {};
@@ -3,8 +3,26 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
3
3
  _stylesheets = new Map();
4
4
  _tools;
5
5
  async setStylesheets(stylesheets) {
6
- if (stylesheets != null) {
6
+ if (!this._tools)
7
7
  this._tools = await import('@adobe/css-tools');
8
+ if (this._stylesheets != null && stylesheets != null && this._stylesheets.size == stylesheets.length && stylesheets.every(x => this._stylesheets.has(x.name))) {
9
+ for (let stylesheet of stylesheets) {
10
+ const old = this._stylesheets.get(stylesheet.name);
11
+ if (old.stylesheet.content != stylesheet.content) {
12
+ try {
13
+ this._stylesheets.set(stylesheet.name, {
14
+ stylesheet: stylesheet,
15
+ ast: this._tools.parse(stylesheet.content)
16
+ });
17
+ }
18
+ catch (err) {
19
+ console.warn("error parsing stylesheet", stylesheet, err);
20
+ }
21
+ this.stylesheetChanged.emit({ name: stylesheet.name, newStyle: stylesheet.content, oldStyle: old.stylesheet.content, changeSource: 'extern' });
22
+ }
23
+ }
24
+ }
25
+ else if (stylesheets != null) {
8
26
  this._stylesheets = new Map();
9
27
  for (let stylesheet of stylesheets) {
10
28
  try {
@@ -98,7 +116,16 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
98
116
  return true;
99
117
  }
100
118
  updateStylesheet(ss) {
119
+ const old = ss.stylesheet.content;
101
120
  ss.stylesheet.content = this._tools.stringify(ss.ast, { indent: ' ', compress: false, emptyDeclarations: true });
102
- this.stylesheetChanged.emit({ stylesheet: ss.stylesheet });
121
+ this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
122
+ }
123
+ updateCompleteStylesheet(name, newStyle) {
124
+ const ss = this._stylesheets.get(name);
125
+ if (ss.stylesheet.content != newStyle) {
126
+ const old = ss.stylesheet.content;
127
+ ss.stylesheet.content = newStyle;
128
+ this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
129
+ }
103
130
  }
104
131
  }
@@ -43,6 +43,7 @@ export declare class CssTreeStylesheetService extends AbstractStylesheetService
43
43
  updateDeclarationValue(declaration: IDeclarationWithAST, value: string, important: boolean): boolean;
44
44
  insertDeclarationIntoRule(rule: IRuleWithAST, property: string, value: string, important: boolean): boolean;
45
45
  removeDeclarationFromRule(rule: IRuleWithAST, property: string): boolean;
46
+ updateCompleteStylesheet(name: string, newStyle: string): void;
46
47
  private rulesFromAST;
47
48
  private astHasChildren;
48
49
  private buildSelectorString;
@@ -93,19 +93,21 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
93
93
  updateDeclarationValue(declaration, value, important) {
94
94
  let sourceNode = this._stylesheets.get(declaration.parent.stylesheetName);
95
95
  declaration.ast.value = window.csstree.toPlainObject(window.csstree.parse(declaration.name + ": " + value + (important ? " !important" : ""), { context: 'declaration', parseValue: false })).value;
96
+ const old = sourceNode.stylesheet.content;
96
97
  sourceNode.stylesheet.content = window.csstree.generate(window.csstree.fromPlainObject(sourceNode.ast));
97
98
  // After generating the stylesheet, parse again (so line numbers are correct)
98
99
  sourceNode.ast = window.csstree.toPlainObject((window.csstree.parse(sourceNode.stylesheet.content, { positions: true, parseValue: false })));
99
- this.stylesheetChanged.emit({ stylesheet: sourceNode.stylesheet });
100
+ this.stylesheetChanged.emit({ name: sourceNode.stylesheet.name, newStyle: sourceNode.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
100
101
  return true;
101
102
  }
102
103
  insertDeclarationIntoRule(rule, property, value, important) {
103
104
  let sourceNode = this._stylesheets.get(rule.stylesheetName);
104
105
  rule.ast.block.children.push(window.csstree.toPlainObject(window.csstree.parse(property + ": " + value + (important ? " !important" : ""), { context: 'declaration', parseValue: false })));
106
+ const old = sourceNode.stylesheet.content;
105
107
  sourceNode.stylesheet.content = window.csstree.generate(window.csstree.fromPlainObject(sourceNode.ast));
106
108
  // After generating the stylesheet, parse again (so line numbers are correct)
107
109
  sourceNode.ast = window.csstree.toPlainObject((window.csstree.parse(sourceNode.stylesheet.content, { positions: true, parseValue: false })));
108
- this.stylesheetChanged.emit({ stylesheet: sourceNode.stylesheet });
110
+ this.stylesheetChanged.emit({ name: sourceNode.stylesheet.name, newStyle: sourceNode.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
109
111
  return true;
110
112
  }
111
113
  removeDeclarationFromRule(rule, property) {
@@ -113,12 +115,22 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
113
115
  if (index == -1)
114
116
  return false;
115
117
  rule.ast.block.children.splice(index, 1);
116
- this._stylesheets.get(rule.stylesheetName).stylesheet.content = window.csstree.generate(window.csstree.fromPlainObject(this._stylesheets.get(rule.stylesheetName).ast));
118
+ const ss = this._stylesheets.get(rule.stylesheetName);
119
+ const old = ss.stylesheet.content;
120
+ ss.stylesheet.content = window.csstree.generate(window.csstree.fromPlainObject(this._stylesheets.get(rule.stylesheetName).ast));
117
121
  // After generating the stylesheet, parse again (so line numbers are correct)
118
- this._stylesheets.get(rule.stylesheetName).ast = window.csstree.toPlainObject((window.csstree.parse(this._stylesheets.get(rule.stylesheetName).stylesheet.content, { positions: true, parseValue: false })));
119
- this.stylesheetChanged.emit({ stylesheet: this._stylesheets.get(rule.stylesheetName).stylesheet });
122
+ ss.ast = window.csstree.toPlainObject((window.csstree.parse(this._stylesheets.get(rule.stylesheetName).stylesheet.content, { positions: true, parseValue: false })));
123
+ this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
120
124
  return true;
121
125
  }
126
+ updateCompleteStylesheet(name, newStyle) {
127
+ const ss = this._stylesheets.get(name);
128
+ if (ss.stylesheet.content != newStyle) {
129
+ const old = ss.stylesheet.content;
130
+ ss.stylesheet.content = newStyle;
131
+ this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
132
+ }
133
+ }
122
134
  /* Section covers the internal traversal creation of rules and declarations */
123
135
  *rulesFromAST(ast, stylesheet, source, designItem, previousCheck = '') {
124
136
  let parent = ast["children"] != null ? ast : ast.block;
@@ -24,8 +24,12 @@ export interface IStylesheetService {
24
24
  updateDeclarationValue(declaration: IStyleDeclaration, value: string, important: boolean): boolean;
25
25
  insertDeclarationIntoRule(rule: IStyleRule, property: string, value: string, important: boolean): boolean;
26
26
  removeDeclarationFromRule(rule: IStyleRule, property: string): boolean;
27
+ updateCompleteStylesheet(name: string, newStyle: string): void;
27
28
  stylesheetChanged: TypedEvent<{
28
- stylesheet: IStylesheet;
29
+ name: string;
30
+ newStyle: string;
31
+ oldStyle: string;
32
+ changeSource: 'extern' | 'styleupdate';
29
33
  }>;
30
34
  stylesheetsChanged: TypedEvent<void>;
31
35
  }
@@ -0,0 +1,14 @@
1
+ import { ITransactionItem } from '../ITransactionItem.js';
2
+ import { IDesignItem } from '../../../item/IDesignItem.js';
3
+ export declare class CssStyleChangeAction implements ITransactionItem {
4
+ constructor(designItem: IDesignItem, name: string, newValue: any, oldValue: any);
5
+ title?: string;
6
+ get affectedItems(): IDesignItem[];
7
+ undo(): void;
8
+ do(): void;
9
+ designItem: IDesignItem;
10
+ name: string;
11
+ newValue: any;
12
+ oldValue: any;
13
+ mergeWith(other: ITransactionItem): boolean;
14
+ }
@@ -0,0 +1,44 @@
1
+ export class CssStyleChangeAction {
2
+ constructor(designItem, name, newValue, oldValue) {
3
+ this.title = "Change Css Style " + name + " of &lt;" + designItem.name + "&gt;";
4
+ this.designItem = designItem;
5
+ this.name = name;
6
+ this.newValue = newValue;
7
+ this.oldValue = oldValue;
8
+ }
9
+ title;
10
+ get affectedItems() {
11
+ return [this.designItem];
12
+ }
13
+ undo() {
14
+ if (this.oldValue === '' || this.oldValue == null) {
15
+ this.designItem._withoutUndoRemoveStyle(this.name);
16
+ this.designItem.element.style[this.name] = '';
17
+ }
18
+ else {
19
+ this.designItem._withoutUndoSetStyle(this.name, this.oldValue);
20
+ this.designItem.element.style[this.name] = this.oldValue;
21
+ }
22
+ }
23
+ do() {
24
+ if (this.newValue === '' || this.newValue == null) {
25
+ this.designItem._withoutUndoRemoveStyle(this.name);
26
+ this.designItem.element.style[this.name] = '';
27
+ }
28
+ else {
29
+ this.designItem._withoutUndoSetStyle(this.name, this.newValue);
30
+ this.designItem.element.style[this.name] = this.newValue;
31
+ }
32
+ }
33
+ designItem;
34
+ name;
35
+ newValue;
36
+ oldValue;
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
+ return false;
43
+ }
44
+ }
@@ -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
+ }
@@ -0,0 +1,14 @@
1
+ import { IStylesheetService } from '../../stylesheetService/IStylesheetService.js';
2
+ import { ITransactionItem } from '../ITransactionItem.js';
3
+ export declare class StylesheetChangedAction implements ITransactionItem {
4
+ private stylesheetService;
5
+ constructor(stylesheetService: IStylesheetService, name: string, newValue: string, oldValue: string);
6
+ title?: string;
7
+ get affectedItems(): any[];
8
+ undo(): void;
9
+ do(): void;
10
+ name: string;
11
+ newValue: string;
12
+ oldValue: string;
13
+ mergeWith(other: ITransactionItem): boolean;
14
+ }
@@ -0,0 +1,24 @@
1
+ export class StylesheetChangedAction {
2
+ stylesheetService;
3
+ constructor(stylesheetService, name, newValue, oldValue) {
4
+ this.title = "Changed Css Stylesheet: " + name;
5
+ this.stylesheetService = stylesheetService;
6
+ this.name = name;
7
+ this.newValue = newValue;
8
+ this.oldValue = oldValue;
9
+ }
10
+ title;
11
+ get affectedItems() {
12
+ return [];
13
+ }
14
+ undo() {
15
+ this.stylesheetService.updateCompleteStylesheet(this.name, this.oldValue);
16
+ }
17
+ do() {
18
+ this.stylesheetService.updateCompleteStylesheet(this.name, this.newValue);
19
+ }
20
+ name;
21
+ newValue;
22
+ oldValue;
23
+ mergeWith(other) { return false; }
24
+ }
@@ -0,0 +1,17 @@
1
+ import { ITransactionItem } from '../ITransactionItem.js';
2
+ import { IDesignItem } from '../../../item/IDesignItem.js';
3
+ import { IStyleDeclaration, IStylesheetService } from '../../stylesheetService/IStylesheetService.js';
4
+ export declare class StylesheetStyleChangeAction implements ITransactionItem {
5
+ private stylesheetService;
6
+ private declaration;
7
+ constructor(stylesheetService: IStylesheetService, declaration: IStyleDeclaration, newValue: any, oldValue: any);
8
+ title?: string;
9
+ get affectedItems(): any[];
10
+ undo(): void;
11
+ do(): void;
12
+ designItem: IDesignItem;
13
+ name: string;
14
+ newValue: any;
15
+ oldValue: any;
16
+ mergeWith(other: ITransactionItem): boolean;
17
+ }
@@ -0,0 +1,28 @@
1
+ export class StylesheetStyleChangeAction {
2
+ stylesheetService;
3
+ declaration;
4
+ constructor(stylesheetService, declaration, newValue, oldValue) {
5
+ this.title = "Change Css Style " + declaration.name + " to " + newValue;
6
+ this.stylesheetService = stylesheetService;
7
+ this.declaration = declaration;
8
+ this.newValue = newValue;
9
+ this.oldValue = oldValue;
10
+ }
11
+ title;
12
+ get affectedItems() {
13
+ return [];
14
+ }
15
+ undo() {
16
+ this.stylesheetService.updateDeclarationValue(this.declaration, this.oldValue, false);
17
+ }
18
+ do() {
19
+ this.stylesheetService.updateDeclarationValue(this.declaration, this.newValue, false);
20
+ }
21
+ designItem;
22
+ name;
23
+ newValue;
24
+ oldValue;
25
+ mergeWith(other) {
26
+ return false;
27
+ }
28
+ }
@@ -37,7 +37,7 @@ export class CodeViewAce extends BaseCustomWebComponentLazyAppend {
37
37
  this.shadowRoot.appendChild(this._editor);
38
38
  }
39
39
  dispose() {
40
- this._aceEditor.destroy();
40
+ this._aceEditor?.destroy();
41
41
  }
42
42
  executeCommand(command) {
43
43
  switch (command.type) {
@@ -3,7 +3,7 @@ import { CommandType } from '../../../commandHandling/CommandType.js';
3
3
  export class CodeViewMonaco extends BaseCustomWebComponentLazyAppend {
4
4
  static _initalized;
5
5
  dispose() {
6
- this._monacoEditor.dispose();
6
+ this._monacoEditor?.dispose();
7
7
  }
8
8
  canvasElement;
9
9
  elementsToPackages;
@@ -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;
@@ -18,6 +18,8 @@ import { OverlayLayer } from './extensions/OverlayLayer.js';
18
18
  import { OverlayLayerView } from './overlayLayerView.js';
19
19
  import { ContextMenu } from '../../helper/contextMenu/ContextMenu.js';
20
20
  import { NodeType } from '../../item/NodeType.js';
21
+ import { StylesheetChangedAction } from '../../services/undoService/transactionItems/StylesheetChangedAction.js';
22
+ import { SetDesignItemsAction } from '../../services/undoService/transactionItems/SetDesignItemsAction.js';
21
23
  export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
22
24
  // Public Properties
23
25
  serviceContainer;
@@ -433,8 +435,16 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
433
435
  this.instanceServiceContainer.servicesChanged.on(e => {
434
436
  if (e.serviceName == 'stylesheetService') {
435
437
  this.applyAllStyles();
436
- this.instanceServiceContainer.stylesheetService.stylesheetChanged.on(() => this.applyAllStyles());
437
- this.instanceServiceContainer.stylesheetService.stylesheetsChanged.on(() => this.applyAllStyles());
438
+ this.instanceServiceContainer.stylesheetService.stylesheetChanged.on((ss) => {
439
+ if (ss.changeSource == 'extern') {
440
+ const ssca = new StylesheetChangedAction(this.instanceServiceContainer.stylesheetService, ss.name, ss.newStyle, ss.oldStyle);
441
+ this.instanceServiceContainer.undoService.execute(ssca);
442
+ }
443
+ this.applyAllStyles();
444
+ });
445
+ this.instanceServiceContainer.stylesheetService.stylesheetsChanged.on(() => {
446
+ this.applyAllStyles();
447
+ });
438
448
  }
439
449
  });
440
450
  this.extensionManager = new ExtensionManager(this);
@@ -514,8 +524,12 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
514
524
  this.snapLines.clearSnaplines();
515
525
  }
516
526
  setDesignItems(designItems) {
527
+ const setItemsAction = new SetDesignItemsAction(designItems, [...this.rootDesignItem.children()]);
528
+ this.instanceServiceContainer.undoService.execute(setItemsAction);
529
+ }
530
+ _internalSetDesignItems(designItems) {
517
531
  this._fillCalculationrects();
518
- this.instanceServiceContainer.undoService.clear();
532
+ //this.instanceServiceContainer.undoService.clear();
519
533
  this.overlayLayer.removeAllOverlays();
520
534
  DomHelper.removeAllChildnodes(this.overlayLayer);
521
535
  for (let i of [...this.rootDesignItem.children()])
package/dist/index.d.ts CHANGED
@@ -116,6 +116,9 @@ export * from "./elements/services/undoService/transactionItems/CssStyleChangeAc
116
116
  export * from "./elements/services/undoService/transactionItems/DeleteAction.js";
117
117
  export * from "./elements/services/undoService/transactionItems/InsertAction.js";
118
118
  export * from "./elements/services/undoService/transactionItems/InsertChildAction.js";
119
+ export * from "./elements/services/undoService/transactionItems/StylesheetChangedAction.js";
120
+ export * from "./elements/services/undoService/transactionItems/StylesheetStyleChangeAction.js";
121
+ export * from "./elements/services/undoService/transactionItems/SetDesignItemsAction.js";
119
122
  export * from "./elements/services/BaseServiceContainer.js";
120
123
  export * from "./elements/services/InstanceServiceContainer.js";
121
124
  export type { IService } from "./elements/services/IService.js";
package/dist/index.js CHANGED
@@ -80,6 +80,9 @@ export * from "./elements/services/undoService/transactionItems/CssStyleChangeAc
80
80
  export * from "./elements/services/undoService/transactionItems/DeleteAction.js";
81
81
  export * from "./elements/services/undoService/transactionItems/InsertAction.js";
82
82
  export * from "./elements/services/undoService/transactionItems/InsertChildAction.js";
83
+ export * from "./elements/services/undoService/transactionItems/StylesheetChangedAction.js";
84
+ export * from "./elements/services/undoService/transactionItems/StylesheetStyleChangeAction.js";
85
+ export * from "./elements/services/undoService/transactionItems/SetDesignItemsAction.js";
83
86
  export * from "./elements/services/BaseServiceContainer.js";
84
87
  export * from "./elements/services/InstanceServiceContainer.js";
85
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.204",
4
+ "version": "0.0.206",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",
@@ -25,7 +25,7 @@
25
25
  "@types/css-tree": "^2.3.1",
26
26
  "@types/jquery": "^3.5.16",
27
27
  "@types/jquery.fancytree": "0.0.7",
28
- "@types/node": "^18.14.0",
28
+ "@types/node": "^18.14.2",
29
29
  "ace-builds": "^1.15.2",
30
30
  "codemirror": "^6.0.1",
31
31
  "css-tree": "^2.3.1",
@@ -35,7 +35,7 @@
35
35
  "jquery": "^3.6.3",
36
36
  "jquery.fancytree": "^2.38.3",
37
37
  "mdn-data": "^2.0.31",
38
- "monaco-editor": "^0.35.0",
38
+ "monaco-editor": "^0.36.1",
39
39
  "ts-jest": "^29.0.5",
40
40
  "typescript": "^4.9.5",
41
41
  "typescript-lit-html-plugin": "^0.9.0"