@cocreate/utils 1.4.0 → 1.5.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 +28 -0
- package/docs/index.html +1 -1
- package/package.json +2 -2
- package/src/index.js +28 -5
- package/src/index.old.js +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
# [1.5.0](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.4.3...v1.5.0) (2022-01-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* function to add click event to all documents in order to apply clickedElement to document dom object. this provides a refrence to the element that was actively clicked ([537003d](https://github.com/CoCreate-app/CoCreate-utils/commit/537003de6aa749a8dc215e70926dfc3dd2b830fb))
|
|
7
|
+
|
|
8
|
+
## [1.4.3](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.4.2...v1.4.3) (2022-01-01)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* get-value attribute value now supports a selector added # to all values currently in get-value attributes ([d48bcd5](https://github.com/CoCreate-app/CoCreate-utils/commit/d48bcd5bdbc715b3aacb8db3b99cd8aa581b72ce))
|
|
14
|
+
|
|
15
|
+
## [1.4.2](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.4.1...v1.4.2) (2021-12-25)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* comment cssPath class parser. path could not resolve element ([1a00794](https://github.com/CoCreate-app/CoCreate-utils/commit/1a00794a0ee96699379e8efd0e75000efe93cded))
|
|
21
|
+
|
|
22
|
+
## [1.4.1](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.4.0...v1.4.1) (2021-12-15)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* update dependencies ([a36e4a6](https://github.com/CoCreate-app/CoCreate-utils/commit/a36e4a6356fdf7e25351895c9897e0f31341a9e1))
|
|
28
|
+
|
|
1
29
|
# [1.4.0](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.3.19...v1.4.0) (2021-12-14)
|
|
2
30
|
|
|
3
31
|
|
package/docs/index.html
CHANGED
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
<div class="svSplitter svHorizontal"> </div>
|
|
118
118
|
|
|
119
119
|
<div class="svPanel">
|
|
120
|
-
<iframe get-value="demo" frameBorder="0" height="100%" width="100%" class="min-width:300px"></iframe>
|
|
120
|
+
<iframe get-value="#demo" frameBorder="0" height="100%" width="100%" class="min-width:300px"></iframe>
|
|
121
121
|
</div>
|
|
122
122
|
|
|
123
123
|
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
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.
|
|
64
|
+
"@cocreate/docs": "^1.2.62"
|
|
65
65
|
}
|
|
66
66
|
}
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
/*globals DOMParser*/
|
|
2
|
+
function clickedElement() {
|
|
3
|
+
document.addEventListener('click', e => {
|
|
4
|
+
document.clickedElement = e.target;
|
|
5
|
+
});
|
|
6
|
+
let frameDocuments = window.top.frameDocuments;
|
|
7
|
+
if (!frameDocuments){
|
|
8
|
+
window.top.frameDocuments = new Map();
|
|
9
|
+
frameDocuments = window.top.frameDocuments;
|
|
10
|
+
}
|
|
11
|
+
let frames = document.querySelectorAll('iframe');
|
|
12
|
+
for (let frame of frames){
|
|
13
|
+
let frameDocument = frame.contentDocument;
|
|
14
|
+
if (!frameDocuments.has(frameDocument)){
|
|
15
|
+
frameDocuments.set(frameDocument, '')
|
|
16
|
+
frameDocument.addEventListener('click', e => {
|
|
17
|
+
frameDocument.clickedElement = e.target;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
2
23
|
export function getAttributes(element) {
|
|
3
24
|
return element.getAttributeNames().reduce((attrMap, name) => {
|
|
4
25
|
attrMap[name] = element.getAttribute(name);
|
|
@@ -32,11 +53,11 @@ export function cssPath(node, container) {
|
|
|
32
53
|
node = '';
|
|
33
54
|
}
|
|
34
55
|
else {
|
|
35
|
-
if (node.classList.length) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
56
|
+
// if (node.classList.length) {
|
|
57
|
+
// node.classList.forEach((item) => {
|
|
58
|
+
// if (item.indexOf(":") === -1) pathSplit += "." + item;
|
|
59
|
+
// });
|
|
60
|
+
// }
|
|
40
61
|
|
|
41
62
|
if (node.parentNode && node.parentNode.children.length > 1) {
|
|
42
63
|
// ToDo: improve array logic so ignores javascript generated html??
|
|
@@ -136,6 +157,8 @@ export function queryFrameSelectorAll(selector) {
|
|
|
136
157
|
// } while (parentElement);
|
|
137
158
|
// }
|
|
138
159
|
|
|
160
|
+
clickedElement();
|
|
161
|
+
|
|
139
162
|
export default {
|
|
140
163
|
parseTextToHtml,
|
|
141
164
|
getAttributes,
|
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);
|
|
@@ -355,6 +366,11 @@ async function complexSelector(comSelector, callback) {
|
|
|
355
366
|
// return result;
|
|
356
367
|
// }
|
|
357
368
|
|
|
369
|
+
function isObjectEmpty(obj) {
|
|
370
|
+
for (var x in obj) { return false; }
|
|
371
|
+
return true;
|
|
372
|
+
}
|
|
373
|
+
|
|
358
374
|
|
|
359
375
|
export default {
|
|
360
376
|
getElementPath,
|