@node-projects/web-component-designer-htmlparserservice-nodehtmlparser 0.1.10 → 0.1.11
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.
|
@@ -3,6 +3,5 @@ export declare class NodeHtmlParserService implements IHtmlParserService {
|
|
|
3
3
|
_designItemCreatedCallback?: (IDesignItem: any) => void;
|
|
4
4
|
constructor(designItemCreatedCallback?: (IDesignItem: any) => void);
|
|
5
5
|
parse(html: string, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, parseSnippet: boolean, positionOffset?: number): Promise<IDesignItem[]>;
|
|
6
|
-
private _parseDiv;
|
|
7
6
|
_createDesignItemsRecursive(item: any, serviceContainer: ServiceContainer, instanceServiceContainer: InstanceServiceContainer, namespace: string, snippet: boolean, positionOffset?: number): IDesignItem;
|
|
8
7
|
}
|
|
@@ -19,19 +19,18 @@ export class NodeHtmlParserService {
|
|
|
19
19
|
}
|
|
20
20
|
return designItems;
|
|
21
21
|
}
|
|
22
|
-
_parseDiv = document.createElement("div");
|
|
23
22
|
_createDesignItemsRecursive(item, serviceContainer, instanceServiceContainer, namespace, snippet, positionOffset = 0) {
|
|
24
23
|
let designItem = null;
|
|
25
24
|
if (item.nodeType == 1) {
|
|
26
25
|
let element;
|
|
27
26
|
let manualCreatedElement = false;
|
|
28
27
|
if (!namespace)
|
|
29
|
-
element = newElementFromString('<' + item.rawTagName + ' ' + item.rawAttrs + '></' + item.rawTagName + '>'); // some custom elements only parse attributes during constructor call
|
|
28
|
+
element = newElementFromString('<' + item.rawTagName + ' ' + item.rawAttrs + '></' + item.rawTagName + '>', instanceServiceContainer.designerCanvas.rootDesignItem.document); // some custom elements only parse attributes during constructor call
|
|
30
29
|
if (!element) {
|
|
31
30
|
if (namespace)
|
|
32
|
-
element = document.createElementNS(namespace, item.rawTagName);
|
|
31
|
+
element = instanceServiceContainer.designerCanvas.rootDesignItem.document.createElementNS(namespace, item.rawTagName);
|
|
33
32
|
else
|
|
34
|
-
element = document.createElement(item.rawTagName);
|
|
33
|
+
element = instanceServiceContainer.designerCanvas.rootDesignItem.document.createElement(item.rawTagName);
|
|
35
34
|
manualCreatedElement = true;
|
|
36
35
|
}
|
|
37
36
|
designItem = DesignItem.GetOrCreateDesignItem(element, item, serviceContainer, instanceServiceContainer);
|
|
@@ -87,8 +86,9 @@ export class NodeHtmlParserService {
|
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
else if (item.nodeType == 3) {
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
const parseDiv = instanceServiceContainer.designerCanvas.rootDesignItem.document.createElement("div");
|
|
90
|
+
parseDiv.innerHTML = item.rawText;
|
|
91
|
+
let element = parseDiv.childNodes[0];
|
|
92
92
|
designItem = DesignItem.GetOrCreateDesignItem(element, item, serviceContainer, instanceServiceContainer);
|
|
93
93
|
if (!snippet && instanceServiceContainer.designItemDocumentPositionService)
|
|
94
94
|
instanceServiceContainer.designItemDocumentPositionService.setPosition(designItem, { start: item.range[0] + positionOffset, length: item.range[1] - item.range[0] });
|
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.
|
|
4
|
+
"version": "0.1.11",
|
|
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.
|
|
16
|
+
"@node-projects/web-component-designer": ">=0.1.161"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|