@cocreate/utils 1.5.1 → 1.6.3

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.6.3](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.6.2...v1.6.3) (2022-02-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * bump dependency versions ([849f540](https://github.com/CoCreate-app/CoCreate-utils/commit/849f5409d140a475701f7c392ab99eeeb7001c6e))
7
+
8
+ ## [1.6.2](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.6.1...v1.6.2) (2022-02-07)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * if eid contains {{...}} continue with cssPath ([34e142c](https://github.com/CoCreate-app/CoCreate-utils/commit/34e142ce50e82da94c603c431244727f479bd333))
14
+
15
+ ## [1.6.1](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.6.0...v1.6.1) (2022-02-03)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * replaced show and hide class hidden with attribute hidden ([f1ad793](https://github.com/CoCreate-app/CoCreate-utils/commit/f1ad793841db4abe67032a24625e8a46f7560bbf))
21
+
22
+ # [1.6.0](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.5.1...v1.6.0) (2022-02-03)
23
+
24
+
25
+ ### Features
26
+
27
+ * 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))
28
+
1
29
  ## [1.5.1](https://github.com/CoCreate-app/CoCreate-utils/compare/v1.5.0...v1.5.1) (2022-02-01)
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 hidden" id="preview" show="#code, #view" hide="#preview"><i class="fas fa-code"></i></a>
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.5.1",
3
+ "version": "1.6.3",
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.65"
64
+ "@cocreate/docs": "^1.2.67"
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 queryFrameSelector(selector) {
117
- if(selector.indexOf(';') !== -1) {
118
- let [frameSelector, target] = selector.split(';');
119
- let frame = document.querySelector(frameSelector);
120
- if (frame) {
121
- let Document = frame.contentDocument;
122
- let elements = Document.querySelectorAll(target);
123
- return elements;
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
- if(selector.indexOf(';') !== -1) {
130
- let [frameSelector, target] = selector.split(';');
131
- let frame = document.querySelector(frameSelector);
132
- if (frame) {
133
- let Document = frame.contentDocument;
134
- let element = Document.querySelector(target);
135
- return element;
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
  };