@node-projects/web-component-designer 0.0.243 → 0.0.244

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.
@@ -26,7 +26,7 @@ export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend
26
26
  name: string;
27
27
  newStyle: string;
28
28
  oldStyle: string;
29
- changeSource: 'extern' | 'styleupdate';
29
+ changeSource: 'extern' | 'styleupdate' | 'undo';
30
30
  }>;
31
31
  onContentChanged: TypedEvent<void>;
32
32
  private _serviceContainer;
@@ -32,12 +32,13 @@ export declare abstract class AbstractStylesheetService implements IStylesheetSe
32
32
  abstract insertDeclarationIntoRule(rule: IStyleRule, property: string, value: string, important: boolean): boolean;
33
33
  abstract removeDeclarationFromRule(rule: IStyleRule, property: string): boolean;
34
34
  abstract updateCompleteStylesheet(name: string, newStyle: string): any;
35
+ abstract updateCompleteStylesheetWithoutUndo(name: string, newStyle: string): any;
35
36
  abstract updateDeclarationValueWithoutUndo(declaration: IStyleDeclaration, value: string, important: boolean): any;
36
37
  stylesheetChanged: TypedEvent<{
37
38
  name: string;
38
39
  newStyle: string;
39
40
  oldStyle: string;
40
- changeSource: 'extern' | 'styleupdate';
41
+ changeSource: 'extern' | 'styleupdate' | 'undo';
41
42
  }>;
42
43
  stylesheetsChanged: TypedEvent<void>;
43
44
  protected elementMatchesASelector(designItem: IDesignItem, selectors: string[]): boolean;
@@ -1,6 +1,5 @@
1
1
  import { TypedEvent } from "@node-projects/base-custom-webcomponent";
2
2
  import { DesignerCanvas } from '../../widgets/designerView/designerCanvas.js';
3
- import { StylesheetStyleChangeAction } from "../undoService/transactionItems/StylesheetStyleChangeAction.js";
4
3
  export class AbstractStylesheetService {
5
4
  _stylesheets = new Map();
6
5
  _documentStylesheets = new Map();
@@ -74,13 +73,7 @@ export class AbstractStylesheetService {
74
73
  return stylesheets;
75
74
  }
76
75
  updateDeclarationValue(declaration, value, important) {
77
- if (!declaration.stylesheet.designItem) {
78
- const action = new StylesheetStyleChangeAction(this, declaration, value, declaration.value);
79
- this._instanceServiceContainer.undoService.execute(action);
80
- }
81
- else {
82
- this.updateDeclarationValueWithoutUndo(declaration, value, important);
83
- }
76
+ this.updateDeclarationValueWithoutUndo(declaration, value, important);
84
77
  }
85
78
  stylesheetChanged = new TypedEvent();
86
79
  stylesheetsChanged = new TypedEvent();
@@ -36,5 +36,7 @@ export declare class CssToolsStylesheetService extends AbstractStylesheetService
36
36
  removeDeclarationFromRule(rule: IRuleWithAST, property: string): boolean;
37
37
  private updateStylesheet;
38
38
  updateCompleteStylesheet(name: string, newStyle: string): void;
39
+ updateCompleteStylesheetWithoutUndo(name: string, newStyle: string, noUndo?: boolean): void;
40
+ private updateCompleteStylesheetInternal;
39
41
  }
40
42
  export {};
@@ -57,6 +57,15 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
57
57
  declaration.ast.value = important ? value + ' !important' : value;
58
58
  let ss = this._allStylesheets.get(declaration.parent.stylesheetName);
59
59
  this.updateStylesheet(ss);
60
+ /*
61
+ declaration.ast.value = important ? value + ' !important' : value;
62
+ let ss = declaration.ast;
63
+ while (ss?.parent)
64
+ ss = ss?.parent;
65
+ let obj = { ast: ss, stylesheet: declaration.stylesheet };
66
+ this._allStylesheets.set(declaration.parent.stylesheetName, obj)
67
+ this.updateStylesheet(obj);
68
+ */
60
69
  }
61
70
  insertDeclarationIntoRule(rule, property, value, important) {
62
71
  rule.ast.declarations.push({
@@ -85,6 +94,12 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
85
94
  this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
86
95
  }
87
96
  updateCompleteStylesheet(name, newStyle) {
97
+ this.updateCompleteStylesheetInternal(name, newStyle, 'styleupdate');
98
+ }
99
+ updateCompleteStylesheetWithoutUndo(name, newStyle, noUndo = false) {
100
+ this.updateCompleteStylesheetInternal(name, newStyle, 'undo');
101
+ }
102
+ updateCompleteStylesheetInternal(name, newStyle, changeSource) {
88
103
  const ss = this._allStylesheets.get(name);
89
104
  if (ss.stylesheet.content != newStyle) {
90
105
  const old = ss.stylesheet.content;
@@ -93,7 +108,7 @@ export class CssToolsStylesheetService extends AbstractStylesheetService {
93
108
  ss.stylesheet.designItem.content = ss.stylesheet.content;
94
109
  }
95
110
  else
96
- this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
111
+ this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource });
97
112
  }
98
113
  }
99
114
  }
@@ -45,6 +45,8 @@ export declare class CssTreeStylesheetService extends AbstractStylesheetService
45
45
  insertDeclarationIntoRule(rule: IRuleWithAST, property: string, value: string, important: boolean): boolean;
46
46
  removeDeclarationFromRule(rule: IRuleWithAST, property: string): boolean;
47
47
  updateCompleteStylesheet(name: string, newStyle: string): void;
48
+ updateCompleteStylesheetWithoutUndo(name: string, newStyle: string, noUndo?: boolean): void;
49
+ private updateCompleteStylesheetInternal;
48
50
  private rulesFromAST;
49
51
  private astHasChildren;
50
52
  private buildSelectorString;
@@ -113,6 +113,12 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
113
113
  return true;
114
114
  }
115
115
  updateCompleteStylesheet(name, newStyle) {
116
+ this.updateCompleteStylesheetInternal(name, newStyle, 'styleupdate');
117
+ }
118
+ updateCompleteStylesheetWithoutUndo(name, newStyle, noUndo = false) {
119
+ this.updateCompleteStylesheetInternal(name, newStyle, 'undo');
120
+ }
121
+ updateCompleteStylesheetInternal(name, newStyle, changeSource) {
116
122
  const ss = this._allStylesheets.get(name);
117
123
  if (ss.stylesheet.content != newStyle) {
118
124
  const old = ss.stylesheet.content;
@@ -121,7 +127,7 @@ export class CssTreeStylesheetService extends AbstractStylesheetService {
121
127
  ss.stylesheet.designItem.content = ss.stylesheet.content;
122
128
  }
123
129
  else
124
- this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource: 'styleupdate' });
130
+ this.stylesheetChanged.emit({ name: ss.stylesheet.name, newStyle: ss.stylesheet.content, oldStyle: old, changeSource });
125
131
  }
126
132
  }
127
133
  /* Section covers the internal traversal creation of rules and declarations */
@@ -31,11 +31,12 @@ export interface IStylesheetService {
31
31
  insertDeclarationIntoRule(rule: IStyleRule, property: string, value: string, important: boolean): boolean;
32
32
  removeDeclarationFromRule(rule: IStyleRule, property: string): boolean;
33
33
  updateCompleteStylesheet(name: string, newStyle: string): void;
34
+ updateCompleteStylesheetWithoutUndo(name: string, newStyle: string): void;
34
35
  stylesheetChanged: TypedEvent<{
35
36
  name: string;
36
37
  newStyle: string;
37
38
  oldStyle: string;
38
- changeSource: 'extern' | 'styleupdate';
39
+ changeSource: 'extern' | 'styleupdate' | 'undo';
39
40
  }>;
40
41
  stylesheetsChanged: TypedEvent<void>;
41
42
  }
@@ -12,10 +12,10 @@ export class StylesheetChangedAction {
12
12
  return [];
13
13
  }
14
14
  undo() {
15
- this.stylesheetService.updateCompleteStylesheet(this.name, this.oldValue);
15
+ this.stylesheetService.updateCompleteStylesheetWithoutUndo(this.name, this.oldValue);
16
16
  }
17
17
  do() {
18
- this.stylesheetService.updateCompleteStylesheet(this.name, this.newValue);
18
+ this.stylesheetService.updateCompleteStylesheetWithoutUndo(this.name, this.newValue);
19
19
  }
20
20
  name;
21
21
  newValue;
@@ -544,7 +544,7 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
544
544
  const instance = stylesheetService(this);
545
545
  this.instanceServiceContainer.register("stylesheetService", instance);
546
546
  this.instanceServiceContainer.stylesheetService.stylesheetChanged.on((ss) => {
547
- if (ss.changeSource == 'extern') {
547
+ if (ss.changeSource != 'undo') {
548
548
  const ssca = new StylesheetChangedAction(this.instanceServiceContainer.stylesheetService, ss.name, ss.newStyle, ss.oldStyle);
549
549
  this.instanceServiceContainer.undoService.execute(ssca);
550
550
  }
package/dist/index.d.ts CHANGED
@@ -128,7 +128,6 @@ export * from "./elements/services/undoService/transactionItems/DeleteAction.js"
128
128
  export * from "./elements/services/undoService/transactionItems/InsertAction.js";
129
129
  export * from "./elements/services/undoService/transactionItems/InsertChildAction.js";
130
130
  export * from "./elements/services/undoService/transactionItems/StylesheetChangedAction.js";
131
- export * from "./elements/services/undoService/transactionItems/StylesheetStyleChangeAction.js";
132
131
  export * from "./elements/services/undoService/transactionItems/SetDesignItemsAction.js";
133
132
  export * from "./elements/services/BaseServiceContainer.js";
134
133
  export * from "./elements/services/InstanceServiceContainer.js";
package/dist/index.js CHANGED
@@ -88,7 +88,6 @@ export * from "./elements/services/undoService/transactionItems/DeleteAction.js"
88
88
  export * from "./elements/services/undoService/transactionItems/InsertAction.js";
89
89
  export * from "./elements/services/undoService/transactionItems/InsertChildAction.js";
90
90
  export * from "./elements/services/undoService/transactionItems/StylesheetChangedAction.js";
91
- export * from "./elements/services/undoService/transactionItems/StylesheetStyleChangeAction.js";
92
91
  export * from "./elements/services/undoService/transactionItems/SetDesignItemsAction.js";
93
92
  export * from "./elements/services/BaseServiceContainer.js";
94
93
  export * from "./elements/services/InstanceServiceContainer.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.243",
4
+ "version": "0.0.244",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "",
@@ -13,10 +13,10 @@
13
13
  "prepublishOnly": "npm run build"
14
14
  },
15
15
  "dependencies": {
16
- "@node-projects/base-custom-webcomponent": "^0.11.0"
16
+ "@node-projects/base-custom-webcomponent": "^0.13.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@adobe/css-tools": "4.3.0-beta.1",
19
+ "@adobe/css-tools": "4.3.0-rc.1",
20
20
  "@node-projects/lean-he-esm": "^3.3.0",
21
21
  "@node-projects/node-html-parser-esm": "^6.1.5",
22
22
  "@papyrs/stylo": "^0.0.45",
@@ -24,17 +24,17 @@
24
24
  "@types/css-tree": "^2.3.1",
25
25
  "@types/jquery": "^3.5.16",
26
26
  "@types/jquery.fancytree": "0.0.7",
27
- "@types/node": "^20.3.3",
28
- "ace-builds": "^1.23.1",
27
+ "@types/node": "^20.4.5",
28
+ "ace-builds": "^1.23.4",
29
29
  "codemirror": "^5.0.0",
30
30
  "css-tree": "^2.3.1",
31
31
  "esprima-next": "^5.8.4",
32
32
  "html2canvas": "*",
33
- "jest": "^29.5.0",
33
+ "jest": "^29.6.2",
34
34
  "jquery": "^3.7.0",
35
35
  "jquery.fancytree": "^2.38.3",
36
36
  "mdn-data": "^2.0.32",
37
- "monaco-editor": "^0.39.0",
37
+ "monaco-editor": "^0.40.0",
38
38
  "ts-jest": "^29.1.1",
39
39
  "typescript": "^5.1.6",
40
40
  "typescript-lit-html-plugin": "^0.9.0"