@node-projects/web-component-designer 0.1.29 → 0.1.31
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.
- package/dist/elements/helper/ElementHelper.js +3 -0
- package/dist/elements/services/propertiesService/services/CssProperties.json +20 -1
- package/dist/elements/services/refactorService/BindingsRefactorService.d.ts +2 -1
- package/dist/elements/services/refactorService/TextRefactorService.d.ts +2 -1
- package/dist/elements/widgets/designerView/designerCanvas.js +10 -1
- package/dist/elements/widgets/refactorView/refactor-view.d.ts +4 -0
- package/dist/elements/widgets/refactorView/refactor-view.js +46 -3
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NodeType } from '../item/NodeType.js';
|
|
1
2
|
export function inDesigner(element) {
|
|
2
3
|
let node = element.getRootNode();
|
|
3
4
|
if (node?.host?.localName == "node-projects-designer-canvas")
|
|
@@ -136,6 +137,8 @@ export function calculateOuterRect(designItems, designerCanvas) {
|
|
|
136
137
|
let max = { x: Number.MIN_VALUE, y: Number.MIN_VALUE };
|
|
137
138
|
let elementRect;
|
|
138
139
|
for (let s of designItems) {
|
|
140
|
+
if (s.nodeType == NodeType.TextNode || s.nodeType == NodeType.Comment)
|
|
141
|
+
continue;
|
|
139
142
|
elementRect = {
|
|
140
143
|
x: designerCanvas.getNormalizedElementCoordinates(s.element).x,
|
|
141
144
|
y: designerCanvas.getNormalizedElementCoordinates(s.element).y,
|
|
@@ -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": {},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IDesignItem } from "../../item/IDesignItem.js";
|
|
2
|
+
import { IRefactorService } from "./IRefactorService.js";
|
|
2
3
|
import { IRefactoring } from "./IRefactoring.js";
|
|
3
|
-
export declare class BindingsRefactorService {
|
|
4
|
+
export declare class BindingsRefactorService implements IRefactorService {
|
|
4
5
|
getRefactorings(designItems: IDesignItem[]): IRefactoring[];
|
|
5
6
|
refactor(refactoring: IRefactoring, oldValue: string, newValue: string): void;
|
|
6
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IDesignItem } from "../../item/IDesignItem.js";
|
|
2
|
+
import { IRefactorService } from "./IRefactorService.js";
|
|
2
3
|
import { IRefactoring } from "./IRefactoring.js";
|
|
3
|
-
export declare class TextRefactorService {
|
|
4
|
+
export declare class TextRefactorService implements IRefactorService {
|
|
4
5
|
getRefactorings(designItems: IDesignItem[]): IRefactoring[];
|
|
5
6
|
refactor(refactoring: IRefactoring, oldValue: string, newValue: string): void;
|
|
6
7
|
}
|
|
@@ -486,7 +486,16 @@ export class DesignerCanvas extends BaseCustomWebComponentLazyAppend {
|
|
|
486
486
|
}
|
|
487
487
|
/* --- end IUiCommandHandler --- */
|
|
488
488
|
handleSelectAll() {
|
|
489
|
-
|
|
489
|
+
const selection = Array.from(this.rootDesignItem.children());
|
|
490
|
+
const primary = this.instanceServiceContainer.selectionService.primarySelection;
|
|
491
|
+
if (primary) {
|
|
492
|
+
const idx = selection.indexOf(primary);
|
|
493
|
+
if (idx >= 0) {
|
|
494
|
+
selection.splice(idx, 1);
|
|
495
|
+
selection.unshift(primary);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
this.instanceServiceContainer.selectionService.setSelectedElements(selection);
|
|
490
499
|
}
|
|
491
500
|
async handleCopyCommand() {
|
|
492
501
|
this._currentPasteOffset = this.pasteOffset;
|
|
@@ -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
|
-
|
|
80
|
-
|
|
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();
|