@node-projects/web-component-designer 0.1.102 → 0.1.103

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.
@@ -50,5 +50,6 @@ export declare class DocumentContainer extends BaseCustomWebComponentLazyAppend
50
50
  set content(value: string);
51
51
  get content(): string;
52
52
  ready(): void;
53
+ private updateDesignerHtml;
53
54
  get instanceServiceContainer(): InstanceServiceContainer;
54
55
  }
@@ -109,7 +109,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
109
109
  });
110
110
  }
111
111
  async refreshInSplitView() {
112
- await this.designerView.parseHTML(this._content);
112
+ await this.updateDesignerHtml();
113
113
  this._disableChangeNotificationEditor = false;
114
114
  }
115
115
  designerSelectionChanged(e) {
@@ -177,7 +177,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
177
177
  this._content = value;
178
178
  if (this._tabControl) {
179
179
  if (this._tabControl.selectedIndex === 0)
180
- this.designerView.parseHTML(this._content, this._firstLoad);
180
+ this.updateDesignerHtml();
181
181
  else if (this._tabControl.selectedIndex === 1)
182
182
  this.codeView.update(this._content, this.designerView.instanceServiceContainer);
183
183
  else if (this._tabControl.selectedIndex === 2) {
@@ -213,7 +213,7 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
213
213
  this._codeDiv.appendChild(this.codeView);
214
214
  }
215
215
  if (i.newIndex === 0 || i.newIndex === 2)
216
- this.designerView.parseHTML(this._content, this._firstLoad);
216
+ this.updateDesignerHtml();
217
217
  if (i.newIndex === 1 || i.newIndex === 2) {
218
218
  this.codeView.update(this._content, this.designerView.instanceServiceContainer);
219
219
  if (this._selectionPosition) {
@@ -244,6 +244,19 @@ export class DocumentContainer extends BaseCustomWebComponentLazyAppend {
244
244
  this._firstLoad = false;
245
245
  }
246
246
  }
247
+ async updateDesignerHtml() {
248
+ if (this._firstLoad)
249
+ return this.designerView.parseHTML(this._content, this._firstLoad);
250
+ else {
251
+ const html = this.designerView.getHTML();
252
+ if (html != this._content)
253
+ return this.designerView.parseHTML(this._content, this._firstLoad);
254
+ else {
255
+ this.instanceServiceContainer.undoService.clearTransactionstackIfNotEmpty();
256
+ this.designerView.designerCanvas.extensionManager.refreshAllAppliedExtentions();
257
+ }
258
+ }
259
+ }
247
260
  get instanceServiceContainer() {
248
261
  return this.designerView.instanceServiceContainer;
249
262
  }
@@ -2,8 +2,11 @@ import { DesignItem } from '../../item/DesignItem.js';
2
2
  export class DefaultHtmlParserService {
3
3
  async parse(html, serviceContainer, instanceServiceContainer, parseSnippet) {
4
4
  const parser = new DOMParser();
5
- const doc = parser.parseFromString(html, 'text/html');
6
- return this.createDesignItems(doc.body.childNodes, serviceContainer, instanceServiceContainer);
5
+ //@ts-ignore
6
+ const doc = parser.parseFromString(html, 'text/html', { includeShadowRoots: true });
7
+ const headNodes = this.createDesignItems(doc.head.childNodes, serviceContainer, instanceServiceContainer);
8
+ const bodyNodes = this.createDesignItems(doc.body.childNodes, serviceContainer, instanceServiceContainer);
9
+ return [...headNodes, ...bodyNodes];
7
10
  }
8
11
  createDesignItems(elements, serviceContainer, instanceServiceContainer) {
9
12
  let res = [];
@@ -58,7 +58,11 @@ export class DefaultInstanceService {
58
58
  }
59
59
  if (definition.defaultContent) {
60
60
  if (typeof definition.defaultContent === "string") {
61
- element.innerHTML = definition.defaultContent;
61
+ const parser = new DOMParser();
62
+ //@ts-ignore
63
+ const doc = parser.parseFromString(definition.defaultContent, 'text/html', { includeShadowRoots: true });
64
+ element.append(...doc.head.childNodes);
65
+ element.append(...doc.body.childNodes);
62
66
  }
63
67
  else {
64
68
  element.appendChild(definition.defaultContent);
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.102",
4
+ "version": "0.1.103",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",