@cocreate/utils 1.5.0 → 1.6.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 +28 -0
- package/docs/index.html +1 -1
- package/package.json +2 -2
- package/src/index.js +52 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [1.6.2](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.6.1...v1.6.2) (2022-02-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* if eid contains {{...}} continue with cssPath ([34e142c](https://github.com/CoCreate-app/CoCreate-utils/commit/34e142ce50e82da94c603c431244727f479bd333))
|
|
7
|
+
|
|
8
|
+
## [1.6.1](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.6.0...v1.6.1) (2022-02-03)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* replaced show and hide class hidden with attribute hidden ([f1ad793](https://github.com/CoCreate-app/CoCreate-utils/commit/f1ad793841db4abe67032a24625e8a46f7560bbf))
|
|
14
|
+
|
|
15
|
+
# [1.6.0](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.5.1...v1.6.0) (2022-02-03)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* queryFrameSelectorAll to return elements from other documents, getFrameSelector to pase a selector and return document and selector ([c3b8c27](https://github.com/CoCreate-app/CoCreate-utils/commit/c3b8c27fc1f452b7eac0ac801770e3c0809295f8))
|
|
21
|
+
|
|
22
|
+
## [1.5.1](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.5.0...v1.5.1) (2022-02-01)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* update dependency versions ([f85b89a](https://github.com/CoCreate-app/CoCreate-utils/commit/f85b89a8b27e0a92153739e89345c753917b350f))
|
|
28
|
+
|
|
1
29
|
# [1.5.0](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.4.3...v1.5.0) (2022-01-29)
|
|
2
30
|
|
|
3
31
|
|
package/docs/index.html
CHANGED
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
<div class="container svColumn overflow:hidden card position:relative border-radius:2px width:auto height:100%" id="sandbox">
|
|
105
105
|
<div class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
|
|
106
106
|
<a class="margin-right:10px" id="code" show="#preview" hide="#code, #view"><i class="far fa-eye"></i></a>
|
|
107
|
-
<a class="margin-right:10px
|
|
107
|
+
<a class="margin-right:10px" id="preview" show="#code, #view" hide="#preview" hidden><i class="fas fa-code"></i></a>
|
|
108
108
|
<a class="margin-right:5px" fullscreen target="#playground"><i class="fas fa-expand"></i></a>
|
|
109
109
|
</div>
|
|
110
110
|
<div class="svRow">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.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.
|
|
64
|
+
"@cocreate/docs": "^1.2.65"
|
|
65
65
|
}
|
|
66
66
|
}
|
package/src/index.js
CHANGED
|
@@ -48,6 +48,9 @@ export function cssPath(node, container) {
|
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
50
|
let eid = node.getAttribute('eid');
|
|
51
|
+
if(/{{\s*([\w\W]+)\s*}}/g.test(eid)) {
|
|
52
|
+
eid = false;
|
|
53
|
+
}
|
|
51
54
|
if (eid) {
|
|
52
55
|
pathSplit += `[eid="${eid}"]`;
|
|
53
56
|
node = '';
|
|
@@ -113,29 +116,61 @@ export function domParser(str) {
|
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
|
|
116
|
-
export function
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
export function getFrameSelector(selector) {
|
|
120
|
+
let selectorArray = [];
|
|
121
|
+
if (selector) {
|
|
122
|
+
let selectors = [selector];
|
|
123
|
+
if(selector.indexOf(',') !== -1){
|
|
124
|
+
selectors = selector.split(',');
|
|
125
|
+
}
|
|
126
|
+
for (let selector of selectors){
|
|
127
|
+
let els;
|
|
128
|
+
if(selector.indexOf(';') !== -1) {
|
|
129
|
+
let [documentSelector, targetSelector] = selector.split(';');
|
|
130
|
+
let frame = document.querySelector(documentSelector);
|
|
131
|
+
if (frame)
|
|
132
|
+
selectorArray.push({Document: frame.contentDocument, selector: targetSelector});
|
|
124
133
|
}
|
|
134
|
+
else
|
|
135
|
+
selectorArray.push({Document: document, selector: selector});
|
|
125
136
|
}
|
|
137
|
+
return selectorArray;
|
|
138
|
+
}
|
|
126
139
|
}
|
|
127
140
|
|
|
128
141
|
export function queryFrameSelectorAll(selector) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
142
|
+
let elements = [];
|
|
143
|
+
|
|
144
|
+
if (selector) {
|
|
145
|
+
let selectors = [selector];
|
|
146
|
+
if(selector.indexOf(',') !== -1){
|
|
147
|
+
selectors = selector.split(',');
|
|
148
|
+
}
|
|
149
|
+
for (let selector of selectors){
|
|
150
|
+
let els;
|
|
151
|
+
if(selector.indexOf(';') !== -1) {
|
|
152
|
+
let [documentSelector, targetSelector] = selector.split(';');
|
|
153
|
+
let frame = document.querySelector(documentSelector);
|
|
154
|
+
if (frame) {
|
|
155
|
+
let targetDocument = frame.contentDocument;
|
|
156
|
+
if (targetSelector)
|
|
157
|
+
els = targetDocument.querySelectorAll(targetSelector);
|
|
158
|
+
else
|
|
159
|
+
if (targetDocument.clickedElement)
|
|
160
|
+
els = [targetDocument.clickedElement];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else
|
|
164
|
+
els = document.querySelectorAll(selector);
|
|
165
|
+
if (els){
|
|
166
|
+
els = Array.prototype.slice.call(els);
|
|
167
|
+
elements = elements.concat(els);
|
|
136
168
|
}
|
|
137
169
|
}
|
|
170
|
+
return elements;
|
|
171
|
+
}
|
|
138
172
|
}
|
|
173
|
+
|
|
139
174
|
// export function computeStyles(el, properties) {
|
|
140
175
|
// let computed = window.getComputedStyle(el);
|
|
141
176
|
// let result = {};
|
|
@@ -163,5 +198,6 @@ export default {
|
|
|
163
198
|
parseTextToHtml,
|
|
164
199
|
getAttributes,
|
|
165
200
|
cssPath,
|
|
166
|
-
domParser
|
|
201
|
+
domParser,
|
|
202
|
+
queryFrameSelectorAll
|
|
167
203
|
};
|