@node-projects/web-component-designer-widgets-wunderbaum 0.1.22 → 0.1.24
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.
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/// <reference types="wunderbaum" />
|
|
1
2
|
import { BaseCustomWebComponentConstructorAppend } from '@node-projects/base-custom-webcomponent';
|
|
2
3
|
import { ITreeView, InstanceServiceContainer, IDesignItem, ContextMenu, ISelectionChangedEvent } from '@node-projects/web-component-designer';
|
|
4
|
+
import { WunderbaumNode } from 'wb_node';
|
|
3
5
|
export declare class TreeViewExtended extends BaseCustomWebComponentConstructorAppend implements ITreeView {
|
|
4
6
|
private _treeDiv;
|
|
5
7
|
private _tree;
|
|
@@ -22,6 +24,7 @@ export declare class TreeViewExtended extends BaseCustomWebComponentConstructorA
|
|
|
22
24
|
ready(): Promise<void>;
|
|
23
25
|
_recomputeRunning: any;
|
|
24
26
|
_recomputeRequestedAgain: any;
|
|
27
|
+
refreshNode(node: WunderbaumNode, item: IDesignItem): Promise<void>;
|
|
25
28
|
createTree(rootItem: IDesignItem): Promise<void>;
|
|
26
29
|
set instanceServiceContainer(value: InstanceServiceContainer);
|
|
27
30
|
selectionChanged(event: ISelectionChangedEvent): void;
|
|
@@ -4,6 +4,7 @@ import { Wunderbaum } from 'wunderbaum';
|
|
|
4
4
|
import { defaultOptions, defaultStyle } from '../WunderbaumOptions.js';
|
|
5
5
|
//@ts-ignore
|
|
6
6
|
import wunderbaumStyle from 'wunderbaum/dist/wunderbaum.css' with { type: 'css' };
|
|
7
|
+
const wbNodeSymbol = Symbol.for('wunderbaumnode');
|
|
7
8
|
export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
|
|
8
9
|
_treeDiv;
|
|
9
10
|
_tree;
|
|
@@ -50,14 +51,23 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
|
|
|
50
51
|
border-radius: 50%;
|
|
51
52
|
width: 10px;
|
|
52
53
|
height: 10px;
|
|
53
|
-
background:
|
|
54
|
+
background: transparent;
|
|
55
|
+
pointer-events: none;
|
|
54
56
|
top: 5px;
|
|
55
57
|
left: 5px;
|
|
56
58
|
position: relative;
|
|
59
|
+
}
|
|
60
|
+
div.isforced {
|
|
61
|
+
background: orange;
|
|
62
|
+
pointer-events: all;
|
|
57
63
|
}`;
|
|
58
64
|
static template = html `
|
|
59
65
|
<div style="height: 100%;">
|
|
60
66
|
<input id="input" style="width: 100%; box-sizing: border-box; height:27px;" placeholder="Filter... (regex)" autocomplete="off">
|
|
67
|
+
<div style="height: 18px; border: solid black 1px; padding-left:2px; background: gray;">
|
|
68
|
+
<svg id="expandAll" style="width: 16px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M64 80a16 16 0 0 0-16 16v320a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V96a16 16 0 0 0-16-16zM0 96a64 64 0 0 1 64-64h320a64 64 0 0 1 64 64v320a64 64 0 0 1-64 64H64a64 64 0 0 1-64-64zm200 248v-64h-64a24 24 0 1 1 0-48h64v-64a24 24 0 1 1 48 0v64h64a24 24 0 1 1 0 48h-64v64a24 24 0 1 1-48 0"></path></svg>
|
|
69
|
+
<svg id="collapseAll" style="width: 16px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M64 80a16 16 0 0 0-16 16v320a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V96a16 16 0 0 0-16-16zM0 96a64 64 0 0 1 64-64h320a64 64 0 0 1 64 64v320a64 64 0 0 1-64 64H64a64 64 0 0 1-64-64zm152 136h144a24 24 0 1 1 0 48H152a24 24 0 1 1 0-48"></path></svg>
|
|
70
|
+
</div>
|
|
61
71
|
<div style="height: calc(100% - 23px);">
|
|
62
72
|
<div id="treetable" class="wb-alternate" style="min-width: 100%; box-sizing: border-box;"></div>
|
|
63
73
|
</div>
|
|
@@ -76,6 +86,22 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
|
|
|
76
86
|
e.style.right = '-' + this._treeDiv.scrollLeft + 'px';
|
|
77
87
|
}
|
|
78
88
|
};
|
|
89
|
+
const expand = this._getDomElement('expandAll');
|
|
90
|
+
expand.onclick = () => {
|
|
91
|
+
this._tree.root
|
|
92
|
+
.visit((node) => {
|
|
93
|
+
if (!node.isExpanded())
|
|
94
|
+
node.setExpanded(true);
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const collapse = this._getDomElement('collapseAll');
|
|
98
|
+
collapse.onclick = () => {
|
|
99
|
+
this._tree.root
|
|
100
|
+
.visit((node) => {
|
|
101
|
+
if (node.isExpanded())
|
|
102
|
+
node.setExpanded(false);
|
|
103
|
+
});
|
|
104
|
+
};
|
|
79
105
|
}
|
|
80
106
|
_filterNodes() {
|
|
81
107
|
let match = this._filter.value;
|
|
@@ -252,16 +278,17 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
|
|
|
252
278
|
imgH.title = 'hide at runtime';
|
|
253
279
|
d.appendChild(imgH);
|
|
254
280
|
rowElem.appendChild(d);
|
|
281
|
+
const f = document.createElement("div");
|
|
282
|
+
f.className = "forced";
|
|
283
|
+
f.title = "has forced style";
|
|
284
|
+
rowElem.appendChild(f);
|
|
285
|
+
f.addEventListener('click', (event) => {
|
|
286
|
+
const items = new ForceCssContextMenu().provideContextMenuItems(event, item.instanceServiceContainer.designerCanvas, item);
|
|
287
|
+
let ctxMenu = new ContextMenu(items, null);
|
|
288
|
+
ctxMenu.display(event);
|
|
289
|
+
});
|
|
255
290
|
if (item.hasForcedCss) {
|
|
256
|
-
|
|
257
|
-
f.className = "forced";
|
|
258
|
-
f.title = "has forced style";
|
|
259
|
-
rowElem.appendChild(f);
|
|
260
|
-
f.addEventListener('click', (event) => {
|
|
261
|
-
const items = new ForceCssContextMenu().provideContextMenuItems(event, item.instanceServiceContainer.designerCanvas, item);
|
|
262
|
-
let ctxMenu = new ContextMenu(items, null);
|
|
263
|
-
ctxMenu.display(event);
|
|
264
|
-
});
|
|
291
|
+
f.className = "forced isforced";
|
|
265
292
|
}
|
|
266
293
|
}
|
|
267
294
|
}
|
|
@@ -271,6 +298,14 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
|
|
|
271
298
|
}
|
|
272
299
|
_recomputeRunning;
|
|
273
300
|
_recomputeRequestedAgain;
|
|
301
|
+
async refreshNode(node, item) {
|
|
302
|
+
const el = node.getColElem(0).parentElement;
|
|
303
|
+
const f = el.querySelector('.forced');
|
|
304
|
+
if (item.hasForcedCss)
|
|
305
|
+
f.classList.add('isforced');
|
|
306
|
+
else
|
|
307
|
+
f.classList.remove('isforced');
|
|
308
|
+
}
|
|
274
309
|
async createTree(rootItem) {
|
|
275
310
|
if (this._tree) {
|
|
276
311
|
if (!this._recomputeRunning) {
|
|
@@ -298,10 +333,17 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
|
|
|
298
333
|
});
|
|
299
334
|
this._contentChangedHandler?.dispose();
|
|
300
335
|
this._contentChangedHandler = this._instanceServiceContainer.contentService.onContentChanged.on(e => {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
336
|
+
if (e.changeType === 'changed') {
|
|
337
|
+
for (const d of e.designItems) {
|
|
338
|
+
this.refreshNode(d[wbNodeSymbol], d);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
this.createTree(value.contentService.rootDesignItem);
|
|
343
|
+
setTimeout(() => {
|
|
344
|
+
this._highlight(this._instanceServiceContainer.selectionService.selectedElements);
|
|
345
|
+
}, 20);
|
|
346
|
+
}
|
|
305
347
|
});
|
|
306
348
|
this.createTree(value.contentService.rootDesignItem);
|
|
307
349
|
}
|
|
@@ -327,6 +369,8 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
|
|
|
327
369
|
title: item.isRootItem ? '-root-' : item.nodeType === NodeType.Element ? item.name + " " + (item.id ? ('#' + item.id) : '') : '<small><small><small>#' + (item.nodeType === NodeType.TextNode ? 'text' : 'comment') + ' </small></small></small> ' + DomConverter.normalizeContentValue(item.content),
|
|
328
370
|
ref: item
|
|
329
371
|
});
|
|
372
|
+
//@ts-ignore
|
|
373
|
+
item[wbNodeSymbol] = newNode;
|
|
330
374
|
for (let i of item.children()) {
|
|
331
375
|
if (!i.isEmptyTextNode) {
|
|
332
376
|
this._getChildren(i, newNode);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "web-component-designer addon: Widgets using wunderbaum",
|
|
3
3
|
"name": "@node-projects/web-component-designer-widgets-wunderbaum",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.24",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "jochen.kuehner@gmx.de",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"tsc": "tsc",
|
|
11
11
|
"build": "tsc",
|
|
12
|
+
"link": "npm link",
|
|
12
13
|
"prepublishOnly": "npm run build"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|