@node-projects/web-component-designer-widgets-wunderbaum 0.1.22 → 0.1.23

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,10 +51,15 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
50
51
  border-radius: 50%;
51
52
  width: 10px;
52
53
  height: 10px;
53
- background: orange;
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%;">
@@ -252,16 +258,17 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
252
258
  imgH.title = 'hide at runtime';
253
259
  d.appendChild(imgH);
254
260
  rowElem.appendChild(d);
261
+ const f = document.createElement("div");
262
+ f.className = "forced";
263
+ f.title = "has forced style";
264
+ rowElem.appendChild(f);
265
+ f.addEventListener('click', (event) => {
266
+ const items = new ForceCssContextMenu().provideContextMenuItems(event, item.instanceServiceContainer.designerCanvas, item);
267
+ let ctxMenu = new ContextMenu(items, null);
268
+ ctxMenu.display(event);
269
+ });
255
270
  if (item.hasForcedCss) {
256
- const f = document.createElement("div");
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
- });
271
+ f.className = "forced isforced";
265
272
  }
266
273
  }
267
274
  }
@@ -271,6 +278,14 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
271
278
  }
272
279
  _recomputeRunning;
273
280
  _recomputeRequestedAgain;
281
+ async refreshNode(node, item) {
282
+ const el = node.getColElem(0).parentElement;
283
+ const f = el.querySelector('.forced');
284
+ if (item.hasForcedCss)
285
+ f.classList.add('isforced');
286
+ else
287
+ f.classList.remove('isforced');
288
+ }
274
289
  async createTree(rootItem) {
275
290
  if (this._tree) {
276
291
  if (!this._recomputeRunning) {
@@ -298,10 +313,17 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
298
313
  });
299
314
  this._contentChangedHandler?.dispose();
300
315
  this._contentChangedHandler = this._instanceServiceContainer.contentService.onContentChanged.on(e => {
301
- this.createTree(value.contentService.rootDesignItem);
302
- setTimeout(() => {
303
- this._highlight(this._instanceServiceContainer.selectionService.selectedElements);
304
- }, 20);
316
+ if (e.changeType === 'changed') {
317
+ for (const d of e.designItems) {
318
+ this.refreshNode(d[wbNodeSymbol], d);
319
+ }
320
+ }
321
+ else {
322
+ this.createTree(value.contentService.rootDesignItem);
323
+ setTimeout(() => {
324
+ this._highlight(this._instanceServiceContainer.selectionService.selectedElements);
325
+ }, 20);
326
+ }
305
327
  });
306
328
  this.createTree(value.contentService.rootDesignItem);
307
329
  }
@@ -327,6 +349,8 @@ export class TreeViewExtended extends BaseCustomWebComponentConstructorAppend {
327
349
  title: item.isRootItem ? '-root-' : item.nodeType === NodeType.Element ? item.name + " " + (item.id ? ('#' + item.id) : '') : '<small><small><small>#' + (item.nodeType === NodeType.TextNode ? 'text' : 'comment') + '&nbsp;</small></small></small> ' + DomConverter.normalizeContentValue(item.content),
328
350
  ref: item
329
351
  });
352
+ //@ts-ignore
353
+ item[wbNodeSymbol] = newNode;
330
354
  for (let i of item.children()) {
331
355
  if (!i.isEmptyTextNode) {
332
356
  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.22",
4
+ "version": "0.1.23",
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": {