@cocreate/utils 1.3.18 → 1.4.2

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 CHANGED
@@ -1,3 +1,31 @@
1
+ ## [1.4.2](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.4.1...v1.4.2) (2021-12-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * comment cssPath class parser. path could not resolve element ([1a00794](https://github.com/CoCreate-app/CoCreate-utils/commit/1a00794a0ee96699379e8efd0e75000efe93cded))
7
+
8
+ ## [1.4.1](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.4.0...v1.4.1) (2021-12-15)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * update dependencies ([a36e4a6](https://github.com/CoCreate-app/CoCreate-utils/commit/a36e4a6356fdf7e25351895c9897e0f31341a9e1))
14
+
15
+ # [1.4.0](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.3.19...v1.4.0) (2021-12-14)
16
+
17
+
18
+ ### Features
19
+
20
+ * cssPath and domParser update to support nested contenteditable elements ([a7b700a](https://github.com/CoCreate-app/CoCreate-utils/commit/a7b700add647856071cf2c3bfa0ce95b36144e0a))
21
+
22
+ ## [1.3.19](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.3.18...v1.3.19) (2021-12-08)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * cssPath nth-child if childern > 1 ([caa0f54](https://github.com/CoCreate-app/CoCreate-utils/commit/caa0f5480c58a3f5a5e8e117133ccad9f4acde66))
28
+
1
29
  ## [1.3.18](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.3.17...v1.3.18) (2021-12-08)
2
30
 
3
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/utils",
3
- "version": "1.3.18",
3
+ "version": "1.4.2",
4
4
  "description": "A simple utils component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "utils",
@@ -61,6 +61,6 @@
61
61
  "webpack-log": "^3.0.1"
62
62
  },
63
63
  "dependencies": {
64
- "@cocreate/docs": "^1.2.60"
64
+ "@cocreate/docs": "^1.2.62"
65
65
  }
66
66
  }
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 = '';
@@ -28,23 +32,33 @@ export function cssPath(node, container) {
28
32
  node = '';
29
33
  }
30
34
  else {
31
- if (node.classList.length) {
32
- node.classList.forEach((item) => {
33
- if (item.indexOf(":") === -1) pathSplit += "." + item;
34
- });
35
- }
35
+ // if (node.classList.length) {
36
+ // node.classList.forEach((item) => {
37
+ // if (item.indexOf(":") === -1) pathSplit += "." + item;
38
+ // });
39
+ // }
36
40
 
37
- if (node.parentNode) {
41
+ if (node.parentNode && node.parentNode.children.length > 1) {
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
+ }
38
50
  let index = Array.prototype.indexOf.call(
39
- node.parentNode.children,
51
+ children,
40
52
  node
41
53
  );
42
- pathSplit += `:nth-child(${index + 1})`;
54
+ // if (children.length > 1)
55
+ // pathSplit += `:nth-child(${index + 1})`;
56
+ pathSplit += `:nth-of-type(${index + 1})`;
43
57
  }
44
58
 
45
59
  // pathSplits.unshift(pathSplit);
46
60
  node = node.parentNode;
47
- 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'))
48
62
  node = '';
49
63
  }
50
64
  }
@@ -72,7 +86,7 @@ export function domParser(str) {
72
86
  return doc.head;
73
87
 
74
88
  default:
75
- let con = document.createElement('div');
89
+ let con = document.createElement('dom-parser');
76
90
  con.innerHTML = str;
77
91
  return con;
78
92
  }
package/src/index.old.js CHANGED
@@ -345,6 +345,17 @@ async function complexSelector(comSelector, callback) {
345
345
  return callback(canvas.contentWindow.document, selector);
346
346
  }
347
347
 
348
+ // function eid(html){
349
+ // let dom = domParser(html);
350
+ // let elements = dom.querySelectorAll('*');
351
+ // for (let element of elements){
352
+ // if (!element.getAttribute('eid')){
353
+ // element.setAttribute(eid, uuid(8))
354
+ // }
355
+ // }
356
+ // return dom.outterHTML
357
+ // }
358
+
348
359
 
349
360
  // export function computeStyles(el, properties) {
350
361
  // let computed = window.getComputedStyle(el);