@node-projects/web-component-designer 0.1.29 → 0.1.30

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.
@@ -661,7 +661,26 @@
661
661
  "system": {},
662
662
  "tabSize": {},
663
663
  "tableLayout": {},
664
- "textAlign": {},
664
+ "textAlign": {
665
+ "type": "list",
666
+ "values": [
667
+ "start",
668
+ "end",
669
+ "left",
670
+ "right",
671
+ "center",
672
+ "justify",
673
+ "justify-all",
674
+ "match-parent",
675
+ "\".\"",
676
+ "\".\" center",
677
+ "inherit",
678
+ "initial",
679
+ "revert",
680
+ "revert-layer",
681
+ "unset"
682
+ ]
683
+ },
665
684
  "textAlignLast": {},
666
685
  "textAnchor": {},
667
686
  "textCombineUpright": {},
@@ -10,11 +10,15 @@ export declare class RefactorView extends BaseCustomWebComponentConstructorAppen
10
10
  private _instanceServiceContainer;
11
11
  private _selectionChangedHandler;
12
12
  private _selectedItems;
13
+ searchText: string;
14
+ replaceText: string;
13
15
  refactorings: Map<string, IRefactoring[]>;
14
16
  ready(): void;
15
17
  set instanceServiceContainer(value: InstanceServiceContainer);
16
18
  get selectedItems(): IDesignItem[];
17
19
  set selectedItems(items: IDesignItem[]);
20
+ replace(): void;
18
21
  _refactor(refactoring: [string, IRefactoring[]], event: KeyboardEvent): void;
22
+ applyRefactoring(refactoring: [string, IRefactoring[]], newValue: string): void;
19
23
  updateRefactorlist(designItems: IDesignItem[]): void;
20
24
  }
@@ -2,6 +2,14 @@ import { BaseCustomWebComponentConstructorAppend, css, html } from '@node-projec
2
2
  export class RefactorView extends BaseCustomWebComponentConstructorAppend {
3
3
  static template = html `
4
4
  <div id="root">
5
+ <div class="search">
6
+ <span>search</span>
7
+ <input style="flex-grow: 1; min-width: 0" value="{{this.searchText}}">
8
+ <span>replace</span>
9
+ <input style="flex-grow: 1; min-width: 0"value="{{this.replaceText}}">
10
+ <button @click="[[this.replace()]]" style="grid-column: 2;">replace</button>
11
+ </div>
12
+ <hr>
5
13
  <template repeat:item="[[this.refactorings]]">
6
14
  <details open>
7
15
  <summary>
@@ -25,6 +33,16 @@ export class RefactorView extends BaseCustomWebComponentConstructorAppend {
25
33
  overflow: hidden;
26
34
  }
27
35
 
36
+ .search {
37
+ display: grid;
38
+ grid-template-columns: 40px 1fr;
39
+ align-items: center;
40
+ }
41
+
42
+ span {
43
+ font-size: 10px;
44
+ }
45
+
28
46
  summary {
29
47
  cursor: pointer;
30
48
  font-size: 10px;
@@ -51,6 +69,8 @@ export class RefactorView extends BaseCustomWebComponentConstructorAppend {
51
69
  _instanceServiceContainer;
52
70
  _selectionChangedHandler;
53
71
  _selectedItems;
72
+ searchText = "(.*)";
73
+ replaceText = "$1";
54
74
  refactorings = new Map();
55
75
  ;
56
76
  ready() {
@@ -73,13 +93,36 @@ export class RefactorView extends BaseCustomWebComponentConstructorAppend {
73
93
  this.updateRefactorlist(this._selectedItems);
74
94
  }
75
95
  }
96
+ replace() {
97
+ let grp = null;
98
+ for (let r of this.refactorings) {
99
+ let n = r[1][0].name;
100
+ const regex = new RegExp(this.searchText);
101
+ const found = n.match(regex);
102
+ if (found) {
103
+ if (!grp)
104
+ grp = r[1][0].designItem.openGroup('refactor with regex ' + this.searchText + " -> " + this.replaceText);
105
+ const newText = n.replace(regex, this.replaceText);
106
+ if (newText != n) {
107
+ this.applyRefactoring(r, newText);
108
+ }
109
+ }
110
+ }
111
+ if (!grp)
112
+ grp.commit();
113
+ }
76
114
  _refactor(refactoring, event) {
77
115
  const ip = event.target;
78
116
  if (event.key == 'Enter') {
79
- for (let r of refactoring[1]) {
80
- r.service.refactor(r, r.name, ip.value);
81
- }
117
+ this.applyRefactoring(refactoring, ip.value);
118
+ }
119
+ }
120
+ applyRefactoring(refactoring, newValue) {
121
+ const grp = refactoring[1][0].designItem.openGroup('refactor ' + refactoring[1][0].name + ' to ' + newValue);
122
+ for (let r of refactoring[1]) {
123
+ r.service.refactor(r, r.name, newValue);
82
124
  }
125
+ grp.commit();
83
126
  }
84
127
  updateRefactorlist(designItems) {
85
128
  this.refactorings.clear();
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.1.29",
4
+ "version": "0.1.30",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",