@node-projects/web-component-designer-htmlparserservice-nodehtmlparser 0.1.1 → 0.1.3

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,6 +1,7 @@
1
1
  import { IHtmlParserService, ServiceContainer, InstanceServiceContainer, IDesignItem } from "@node-projects/web-component-designer";
2
2
  export declare class NodeHtmlParserService implements IHtmlParserService {
3
- constructor();
3
+ _designItemCreatedCallback?: (IDesignItem: any) => void;
4
+ constructor(designItemCreatedCallback?: (IDesignItem: any) => void);
4
5
  parse(html: string, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, parseSnippet: boolean): Promise<IDesignItem[]>;
5
6
  private _parseDiv;
6
7
  _createDesignItemsRecursive(item: any, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, namespace: string, snippet: boolean): IDesignItem;
@@ -3,7 +3,10 @@ import * as parser from "@node-projects/node-html-parser-esm";
3
3
  // Alternative Parser, cause when you use the Browser, it instanciates the CusomElements,
4
4
  // and some Elements remove attributes from their DOM, so you loose Data
5
5
  export class NodeHtmlParserService {
6
- constructor() { }
6
+ _designItemCreatedCallback;
7
+ constructor(designItemCreatedCallback) {
8
+ this._designItemCreatedCallback = designItemCreatedCallback;
9
+ }
7
10
  async parse(html, serviceContainer, instanceServiceContainer, parseSnippet) {
8
11
  const parsed = parser.parse(html, { comment: true });
9
12
  let designItems = [];
@@ -32,6 +35,8 @@ export class NodeHtmlParserService {
32
35
  manualCreatedElement = true;
33
36
  }
34
37
  designItem = DesignItem.GetOrCreateDesignItem(element, item, serviceContainer, instanceServiceContainer);
38
+ if (this._designItemCreatedCallback)
39
+ this._designItemCreatedCallback(designItem);
35
40
  if (!snippet && instanceServiceContainer.designItemDocumentPositionService)
36
41
  instanceServiceContainer.designItemDocumentPositionService.setPosition(designItem, { start: item.range[0], length: item.range[1] - item.range[0] });
37
42
  let style = '';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "web-component-designer addon: Parser Service using the Node HTML Parser",
3
3
  "name": "@node-projects/web-component-designer-htmlparserservice-nodehtmlparser",
4
- "version": "0.1.1",
4
+ "version": "0.1.3",
5
5
  "type": "module",
6
6
  "main": "./dist/service/htmlParserService/NodeHtmlParserService.js",
7
7
  "author": "jochen.kuehner@gmx.de",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@node-projects/node-html-parser-esm": "^6.1.5",
16
- "@node-projects/web-component-designer": "^0.1.0"
16
+ "@node-projects/web-component-designer": "=>0.1.1"
17
17
  },
18
18
  "repository": {
19
19
  "type": "git",