@cocreate/utils 1.3.19 → 1.4.0
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.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/index.js +18 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.4.0](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.3.19...v1.4.0) (2021-12-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* cssPath and domParser update to support nested contenteditable elements ([a7b700a](https://github.com/CoCreate-app/CoCreate-utils/commit/a7b700add647856071cf2c3bfa0ce95b36144e0a))
|
|
7
|
+
|
|
1
8
|
## [1.3.19](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.3.18...v1.3.19) (2021-12-08)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -17,6 +17,10 @@ export function cssPath(node, container) {
|
|
|
17
17
|
do {
|
|
18
18
|
if (!node || !node.tagName) return false;
|
|
19
19
|
let pathSplit = node.tagName.toLowerCase();
|
|
20
|
+
// if (node.tagName == "DOM-PARSER" || node.hasAttribute('contenteditable')){
|
|
21
|
+
// pathSplit = "[contenteditable]";
|
|
22
|
+
// node = '';
|
|
23
|
+
// }
|
|
20
24
|
if (node.id){
|
|
21
25
|
pathSplit += "#" + node.id;
|
|
22
26
|
node = '';
|
|
@@ -35,17 +39,26 @@ export function cssPath(node, container) {
|
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
if (node.parentNode && node.parentNode.children.length > 1) {
|
|
38
|
-
|
|
42
|
+
// ToDo: improve array logic so ignores javascript generated html??
|
|
43
|
+
let children = []
|
|
44
|
+
for (let child of node.parentNode.children){
|
|
45
|
+
// if (!child.matches('.mirror'))
|
|
46
|
+
// children.push(child);
|
|
47
|
+
if (child.tagName == node.tagName)
|
|
48
|
+
children.push(child);
|
|
49
|
+
}
|
|
39
50
|
let index = Array.prototype.indexOf.call(
|
|
40
|
-
|
|
51
|
+
children,
|
|
41
52
|
node
|
|
42
53
|
);
|
|
43
|
-
|
|
54
|
+
// if (children.length > 1)
|
|
55
|
+
// pathSplit += `:nth-child(${index + 1})`;
|
|
56
|
+
pathSplit += `:nth-of-type(${index + 1})`;
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
// pathSplits.unshift(pathSplit);
|
|
47
60
|
node = node.parentNode;
|
|
48
|
-
if (node == null || node.tagName == "HTML" || node.nodeName == "#document" || node.hasAttribute('contenteditable'))
|
|
61
|
+
if (node == null || node.tagName == "HTML" || node.tagName == "DOM-PARSER" || node.nodeName == "#document" || node.hasAttribute('contenteditable'))
|
|
49
62
|
node = '';
|
|
50
63
|
}
|
|
51
64
|
}
|
|
@@ -73,7 +86,7 @@ export function domParser(str) {
|
|
|
73
86
|
return doc.head;
|
|
74
87
|
|
|
75
88
|
default:
|
|
76
|
-
let con = document.createElement('
|
|
89
|
+
let con = document.createElement('dom-parser');
|
|
77
90
|
con.innerHTML = str;
|
|
78
91
|
return con;
|
|
79
92
|
}
|