@node-projects/web-component-designer 0.0.114 → 0.0.115
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/item/DesignItem.d.ts +1 -1
- package/dist/elements/item/DesignItem.js +12 -13
- package/dist/elements/item/IDesignItem.d.ts +1 -1
- package/dist/elements/services/propertiesService/services/CssPropertiesService.js +1 -1
- package/dist/elements/services/propertiesService/services/UnkownElementPropertiesService.js +1 -1
- package/dist/elements/services/undoService/ChangeGroup.d.ts +2 -2
- package/dist/elements/services/undoService/ChangeGroup.js +11 -3
- package/dist/elements/services/undoService/IUndoService.d.ts +1 -2
- package/dist/elements/services/undoService/UndoService.d.ts +1 -2
- package/dist/elements/services/undoService/UndoService.js +2 -2
- package/dist/elements/services/undoService/transactionItems/DeleteAction.js +1 -1
- package/dist/elements/services/undoService/transactionItems/InsertAction.js +2 -2
- package/dist/elements/services/undoService/transactionItems/InsertChildAction.js +10 -4
- package/dist/elements/widgets/designerView/extensions/ResizeExtension.js +1 -1
- package/dist/elements/widgets/designerView/extensions/RotateExtension.js +1 -1
- package/dist/elements/widgets/designerView/tools/PointerTool.js +1 -1
- package/dist/elements/widgets/propertyGrid/PropertyGridWithHeader.d.ts +1 -0
- package/dist/elements/widgets/propertyGrid/PropertyGridWithHeader.js +20 -0
- package/package.json +1 -1
|
@@ -53,7 +53,7 @@ export declare class DesignItem implements IDesignItem {
|
|
|
53
53
|
static createDesignItemFromInstance(node: Node, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): DesignItem;
|
|
54
54
|
updateChildrenFromNodesChildren(): void;
|
|
55
55
|
constructor(node: Node, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer);
|
|
56
|
-
openGroup(title: string
|
|
56
|
+
openGroup(title: string): ChangeGroup;
|
|
57
57
|
getOrCreateDesignItem(node: Node): IDesignItem;
|
|
58
58
|
static GetOrCreateDesignItem(node: Node, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer): IDesignItem;
|
|
59
59
|
static GetDesignItem(node: Node): IDesignItem;
|
|
@@ -74,18 +74,20 @@ export class DesignItem {
|
|
|
74
74
|
return this._childArray.indexOf(designItem);
|
|
75
75
|
}
|
|
76
76
|
insertAdjacentElement(designItem, where) {
|
|
77
|
+
let action;
|
|
77
78
|
if (where == 'afterbegin') {
|
|
78
|
-
|
|
79
|
+
action = new InsertChildAction(designItem, this, 0);
|
|
79
80
|
}
|
|
80
81
|
else if (where == 'beforeend') {
|
|
81
|
-
this.
|
|
82
|
+
action = new InsertChildAction(designItem, this, this._childArray.length);
|
|
82
83
|
}
|
|
83
84
|
else if (where == 'beforebegin') {
|
|
84
|
-
this.parent
|
|
85
|
+
action = new InsertChildAction(designItem, this.parent, this.parent.indexOf(this));
|
|
85
86
|
}
|
|
86
87
|
else if (where == 'afterend') {
|
|
87
|
-
this.parent
|
|
88
|
+
action = new InsertChildAction(designItem, this.parent, this.parent.indexOf(this));
|
|
88
89
|
}
|
|
90
|
+
this.instanceServiceContainer.undoService.execute(action);
|
|
89
91
|
}
|
|
90
92
|
insertChild(designItem, index) {
|
|
91
93
|
const action = new InsertChildAction(designItem, this, index);
|
|
@@ -96,7 +98,8 @@ export class DesignItem {
|
|
|
96
98
|
this.instanceServiceContainer.undoService.execute(action);
|
|
97
99
|
}
|
|
98
100
|
remove() {
|
|
99
|
-
|
|
101
|
+
const action = new DeleteAction([this]);
|
|
102
|
+
this.instanceServiceContainer.undoService.execute(action);
|
|
100
103
|
}
|
|
101
104
|
clearChildren() {
|
|
102
105
|
for (let i = this._childArray.length - 1; i >= 0; i--) {
|
|
@@ -210,12 +213,8 @@ export class DesignItem {
|
|
|
210
213
|
updateChildrenFromNodesChildren() {
|
|
211
214
|
this._childArray = [];
|
|
212
215
|
if (this.nodeType == NodeType.Element) {
|
|
213
|
-
|
|
214
|
-
this.
|
|
215
|
-
else {
|
|
216
|
-
for (const c of this.element.childNodes)
|
|
217
|
-
this._childArray.push(DesignItem.createDesignItemFromInstance(c, this.serviceContainer, this.instanceServiceContainer));
|
|
218
|
-
}
|
|
216
|
+
for (const c of this.element.childNodes)
|
|
217
|
+
this._childArray.push(DesignItem.createDesignItemFromInstance(c, this.serviceContainer, this.instanceServiceContainer));
|
|
219
218
|
}
|
|
220
219
|
}
|
|
221
220
|
constructor(node, serviceContainer, instanceServiceContainer) {
|
|
@@ -226,8 +225,8 @@ export class DesignItem {
|
|
|
226
225
|
this.styles = new Map();
|
|
227
226
|
DesignItem._designItemMap.set(node, this);
|
|
228
227
|
}
|
|
229
|
-
openGroup(title
|
|
230
|
-
return this.instanceServiceContainer.undoService.openGroup(title
|
|
228
|
+
openGroup(title) {
|
|
229
|
+
return this.instanceServiceContainer.undoService.openGroup(title);
|
|
231
230
|
}
|
|
232
231
|
getOrCreateDesignItem(node) {
|
|
233
232
|
return DesignItem.GetOrCreateDesignItem(node, this.serviceContainer, this.instanceServiceContainer);
|
|
@@ -39,7 +39,7 @@ export interface IDesignItem {
|
|
|
39
39
|
instanceServiceContainer: InstanceServiceContainer;
|
|
40
40
|
appliedDesignerExtensions: Map<ExtensionType, IDesignerExtension[]>;
|
|
41
41
|
getOrCreateDesignItem(node: Node): any;
|
|
42
|
-
openGroup(title: string
|
|
42
|
+
openGroup(title: string): ChangeGroup;
|
|
43
43
|
setStyle(name: string, value?: string | null): any;
|
|
44
44
|
removeStyle(name: string): any;
|
|
45
45
|
setAttribute(name: string, value?: string | null): any;
|
|
@@ -259,7 +259,7 @@ export class CssPropertiesService {
|
|
|
259
259
|
return this[this.name];
|
|
260
260
|
}
|
|
261
261
|
setValue(designItems, property, value) {
|
|
262
|
-
const cg = designItems[0].openGroup("properties changed"
|
|
262
|
+
const cg = designItems[0].openGroup("properties changed");
|
|
263
263
|
for (let d of designItems) {
|
|
264
264
|
d.styles.set(property.name, value);
|
|
265
265
|
d.element.style[property.name] = value;
|
|
@@ -16,7 +16,7 @@ export class UnkownElementPropertiesService {
|
|
|
16
16
|
}
|
|
17
17
|
setValue(designItems, property, value) {
|
|
18
18
|
const attributeName = PropertiesHelper.camelToDashCase(property.name);
|
|
19
|
-
const cg = designItems[0].openGroup("properties changed"
|
|
19
|
+
const cg = designItems[0].openGroup("properties changed");
|
|
20
20
|
try {
|
|
21
21
|
for (let d of designItems) {
|
|
22
22
|
if (property.type === 'object') {
|
|
@@ -2,10 +2,10 @@ import { ITransactionItem } from './ITransactionItem';
|
|
|
2
2
|
import { IDesignItem } from '../../item/IDesignItem';
|
|
3
3
|
export declare class ChangeGroup implements ITransactionItem {
|
|
4
4
|
title: string;
|
|
5
|
-
affectedItems: IDesignItem[];
|
|
5
|
+
get affectedItems(): IDesignItem[];
|
|
6
6
|
private commitHandler;
|
|
7
7
|
private abortHandler;
|
|
8
|
-
constructor(title: string,
|
|
8
|
+
constructor(title: string, commitHandler: (transactionItem: ITransactionItem) => void, abortHandler: (transactionItem: ITransactionItem) => void);
|
|
9
9
|
do(): void;
|
|
10
10
|
undo(): void;
|
|
11
11
|
commit(): void;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
export class ChangeGroup {
|
|
2
2
|
title;
|
|
3
|
-
affectedItems
|
|
3
|
+
get affectedItems() {
|
|
4
|
+
let s = new Set();
|
|
5
|
+
for (let u of this.undoStack)
|
|
6
|
+
for (let i of u.affectedItems)
|
|
7
|
+
s.add(i);
|
|
8
|
+
for (let u of this.redoStack)
|
|
9
|
+
for (let i of u.affectedItems)
|
|
10
|
+
s.add(i);
|
|
11
|
+
return [...s.values()];
|
|
12
|
+
}
|
|
4
13
|
commitHandler;
|
|
5
14
|
abortHandler;
|
|
6
|
-
constructor(title,
|
|
15
|
+
constructor(title, commitHandler, abortHandler) {
|
|
7
16
|
this.title = title;
|
|
8
|
-
this.affectedItems = affectedItems;
|
|
9
17
|
this.commitHandler = commitHandler;
|
|
10
18
|
this.abortHandler = abortHandler;
|
|
11
19
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { IService } from '../IService';
|
|
2
2
|
import { ChangeGroup } from './ChangeGroup';
|
|
3
3
|
import { ITransactionItem } from './ITransactionItem';
|
|
4
|
-
import { IDesignItem } from '../../item/IDesignItem';
|
|
5
4
|
export interface IUndoService extends IService {
|
|
6
|
-
openGroup(title: string
|
|
5
|
+
openGroup(title: string): ChangeGroup;
|
|
7
6
|
execute(item: ITransactionItem): void;
|
|
8
7
|
canUndo(): boolean;
|
|
9
8
|
canRedo(): boolean;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ITransactionItem } from './ITransactionItem.js';
|
|
2
2
|
import { ChangeGroup } from "./ChangeGroup.js";
|
|
3
3
|
import { IUndoService } from './IUndoService.js';
|
|
4
|
-
import { IDesignItem } from '../../item/IDesignItem';
|
|
5
4
|
import { IDesignerCanvas } from '../../widgets/designerView/IDesignerCanvas.js';
|
|
6
5
|
export declare class UndoService implements IUndoService {
|
|
7
6
|
private _undoStack;
|
|
@@ -9,7 +8,7 @@ export declare class UndoService implements IUndoService {
|
|
|
9
8
|
private _transactionStack;
|
|
10
9
|
private _designerCanvas;
|
|
11
10
|
constructor(designerCanvas?: IDesignerCanvas);
|
|
12
|
-
openGroup(title: string
|
|
11
|
+
openGroup(title: string): ChangeGroup;
|
|
13
12
|
private commitTransactionItem;
|
|
14
13
|
private abortTransactionItem;
|
|
15
14
|
execute(item: ITransactionItem): void;
|
|
@@ -10,8 +10,8 @@ export class UndoService {
|
|
|
10
10
|
constructor(designerCanvas) {
|
|
11
11
|
this._designerCanvas = designerCanvas;
|
|
12
12
|
}
|
|
13
|
-
openGroup(title
|
|
14
|
-
let t = new ChangeGroup(title,
|
|
13
|
+
openGroup(title) {
|
|
14
|
+
let t = new ChangeGroup(title, (t) => this.commitTransactionItem(t), (t) => this.abortTransactionItem(t));
|
|
15
15
|
this._transactionStack.push(t);
|
|
16
16
|
return t;
|
|
17
17
|
}
|
|
@@ -22,7 +22,7 @@ export class DeleteAction {
|
|
|
22
22
|
this._parentIndexes.push(DomHelper.nodeIndex(this.deletedItems[n].element));
|
|
23
23
|
}
|
|
24
24
|
for (let n = 0; n < this.deletedItems.length; n++) {
|
|
25
|
-
this.deletedItems[n].
|
|
25
|
+
this.deletedItems[n].parent._removeChildInternal(this.deletedItems[n]);
|
|
26
26
|
}
|
|
27
27
|
this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'removed', designItems: this.deletedItems });
|
|
28
28
|
}
|
|
@@ -7,10 +7,10 @@ export class InsertAction {
|
|
|
7
7
|
}
|
|
8
8
|
title;
|
|
9
9
|
get affectedItems() {
|
|
10
|
-
return [this.designItem];
|
|
10
|
+
return [this.designItem, this.newItem];
|
|
11
11
|
}
|
|
12
12
|
undo() {
|
|
13
|
-
this.newItem.
|
|
13
|
+
this.newItem.parent._removeChildInternal(this.newItem);
|
|
14
14
|
this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'removed', designItems: [this.newItem] });
|
|
15
15
|
}
|
|
16
16
|
do() {
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
export class InsertChildAction {
|
|
2
2
|
constructor(designItem, newParent, newIndex) {
|
|
3
|
-
this.title = "Move Item";
|
|
3
|
+
this.title = "Move or Insert Item";
|
|
4
4
|
this.designItem = designItem;
|
|
5
5
|
this.newParent = newParent;
|
|
6
6
|
this.newIndex = newIndex;
|
|
7
7
|
}
|
|
8
8
|
title;
|
|
9
9
|
get affectedItems() {
|
|
10
|
-
|
|
10
|
+
if (this.oldParent)
|
|
11
|
+
return [this.designItem, this.newParent, this.oldParent];
|
|
12
|
+
return [this.designItem, this.newParent];
|
|
11
13
|
}
|
|
12
14
|
undo() {
|
|
13
|
-
this.oldParent
|
|
15
|
+
if (this.oldParent)
|
|
16
|
+
this.oldParent._insertChildInternal(this.designItem, this.oldIndex);
|
|
17
|
+
else
|
|
18
|
+
this.designItem.parent._removeChildInternal(this.designItem);
|
|
14
19
|
this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'moved', designItems: [this.designItem] });
|
|
15
20
|
}
|
|
16
21
|
do() {
|
|
17
22
|
this.oldParent = this.designItem.parent;
|
|
18
|
-
|
|
23
|
+
if (this.oldParent)
|
|
24
|
+
this.oldIndex = this.designItem.parent.indexOf(this.designItem);
|
|
19
25
|
this.newParent._insertChildInternal(this.designItem, this.newIndex);
|
|
20
26
|
this.affectedItems[0].instanceServiceContainer.contentService.onContentChanged.emit({ changeType: 'moved', designItems: [this.designItem] });
|
|
21
27
|
}
|
|
@@ -138,7 +138,7 @@ export class ResizeExtension extends AbstractExtension {
|
|
|
138
138
|
break;
|
|
139
139
|
case EventNames.PointerUp:
|
|
140
140
|
event.target.releasePointerCapture(event.pointerId);
|
|
141
|
-
let cg = this.extendedItem.openGroup("Resize Elements"
|
|
141
|
+
let cg = this.extendedItem.openGroup("Resize Elements");
|
|
142
142
|
this.extendedItem.setStyle('width', this.extendedItem.element.style.width);
|
|
143
143
|
this.extendedItem.setStyle('height', this.extendedItem.element.style.height);
|
|
144
144
|
if (this.resizeAllSelected) {
|
|
@@ -51,7 +51,7 @@ export class RotateExtension extends AbstractExtension {
|
|
|
51
51
|
this.extensionManager.refreshExtensions(this.designerCanvas.instanceServiceContainer.selectionService.selectedElements);
|
|
52
52
|
break;
|
|
53
53
|
case EventNames.PointerUp:
|
|
54
|
-
let cg = this.extendedItem.openGroup("Rotate Elements"
|
|
54
|
+
let cg = this.extendedItem.openGroup("Rotate Elements");
|
|
55
55
|
/*for (const designItem of this.instanceServiceContainer.selectionService.selectedElements) {
|
|
56
56
|
designItem.setStyle('width', (<HTMLElement>designItem.element).style.width);
|
|
57
57
|
designItem.setStyle('height', (<HTMLElement>designItem.element).style.height);
|
|
@@ -243,7 +243,7 @@ export class PointerTool {
|
|
|
243
243
|
let containerService = designerCanvas.serviceContainer.getLastServiceWhere('containerService', x => x.serviceForContainer(this._actionStartedDesignItem.parent, containerStyle));
|
|
244
244
|
const cp = { x: currentPoint.x - this._moveItemsOffset.x, y: currentPoint.y - this._moveItemsOffset.y };
|
|
245
245
|
if (containerService) {
|
|
246
|
-
let cg = designerCanvas.rootDesignItem.openGroup("Move Elements"
|
|
246
|
+
let cg = designerCanvas.rootDesignItem.openGroup("Move Elements");
|
|
247
247
|
containerService.finishPlace(event, designerCanvas, this._actionStartedDesignItem.parent, this._initialPoint, this._initialOffset, cp, designerCanvas.instanceServiceContainer.selectionService.selectedElements);
|
|
248
248
|
cg.commit();
|
|
249
249
|
}
|
|
@@ -6,6 +6,7 @@ export declare class PropertyGridWithHeader extends BaseCustomWebComponentLazyAp
|
|
|
6
6
|
static readonly template: HTMLTemplateElement;
|
|
7
7
|
private _type;
|
|
8
8
|
private _id;
|
|
9
|
+
private _content;
|
|
9
10
|
private _pg;
|
|
10
11
|
private _selectionChangedHandler;
|
|
11
12
|
private _instanceServiceContainer;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseCustomWebComponentLazyAppend, css, html } from '@node-projects/base-custom-webcomponent';
|
|
2
2
|
import { sleep } from '../../helper/Helper.js';
|
|
3
|
+
import { DesignItem } from '../../item/DesignItem';
|
|
3
4
|
export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
|
|
4
5
|
static style = css `
|
|
5
6
|
:host {
|
|
@@ -43,11 +44,13 @@ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
|
|
|
43
44
|
<div>
|
|
44
45
|
<span class="desc">Type:</span><span id="type"></span>
|
|
45
46
|
<span class="desc">Id:</span><input type="text" id="id">
|
|
47
|
+
<span class="desc">Content:</span><input type="text" id="content">
|
|
46
48
|
</div>
|
|
47
49
|
<node-projects-property-grid id="pg"></node-projects-property-grid>
|
|
48
50
|
`;
|
|
49
51
|
_type;
|
|
50
52
|
_id;
|
|
53
|
+
_content;
|
|
51
54
|
_pg;
|
|
52
55
|
_selectionChangedHandler;
|
|
53
56
|
_instanceServiceContainer;
|
|
@@ -56,6 +59,7 @@ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
|
|
|
56
59
|
this._restoreCachedInititalValues();
|
|
57
60
|
this._type = this._getDomElement('type');
|
|
58
61
|
this._id = this._getDomElement('id');
|
|
62
|
+
this._content = this._getDomElement('content');
|
|
59
63
|
this._pg = this._getDomElement('pg');
|
|
60
64
|
this._id.onkeydown = e => {
|
|
61
65
|
if (e.key == 'Enter')
|
|
@@ -66,6 +70,21 @@ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
|
|
|
66
70
|
e.stopPropagation();
|
|
67
71
|
}
|
|
68
72
|
};
|
|
73
|
+
this._content.onkeydown = e => {
|
|
74
|
+
if (e.key == 'Enter') {
|
|
75
|
+
const grp = this._instanceServiceContainer.selectionService.primarySelection.openGroup('set content');
|
|
76
|
+
this._instanceServiceContainer.selectionService.primarySelection.clearChildren();
|
|
77
|
+
let t = document.createTextNode(this._content.value);
|
|
78
|
+
let di = DesignItem.GetOrCreateDesignItem(t, this._instanceServiceContainer.selectionService.primarySelection.serviceContainer, this._instanceServiceContainer);
|
|
79
|
+
this._instanceServiceContainer.selectionService.primarySelection.insertAdjacentElement(di, 'afterbegin');
|
|
80
|
+
grp.commit();
|
|
81
|
+
}
|
|
82
|
+
else if (e.key == 'Escape') {
|
|
83
|
+
this._content.value = this._instanceServiceContainer.selectionService.primarySelection?.element?.textContent ?? '';
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
e.stopPropagation();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
69
88
|
let pSel;
|
|
70
89
|
this._id.onfocus = e => {
|
|
71
90
|
pSel = this._instanceServiceContainer.selectionService.primarySelection;
|
|
@@ -85,6 +104,7 @@ export class PropertyGridWithHeader extends BaseCustomWebComponentLazyAppend {
|
|
|
85
104
|
await sleep(20); // delay assignment a little bit, so onblur above could still set the value.
|
|
86
105
|
this._type.innerText = this._instanceServiceContainer.selectionService.primarySelection?.name ?? '';
|
|
87
106
|
this._id.value = this._instanceServiceContainer.selectionService.primarySelection?.id ?? '';
|
|
107
|
+
this._content.value = this._instanceServiceContainer.selectionService.primarySelection?.element?.textContent ?? '';
|
|
88
108
|
});
|
|
89
109
|
}
|
|
90
110
|
}
|