@cocreate/elements 1.6.0 → 1.6.1
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 +8 -0
- package/demo/get-value.html +3 -1
- package/package.json +1 -1
- package/src/getValue.js +6 -10
- package/src/index.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [1.6.1](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.0...v1.6.1) (2022-01-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add input event listener to valueEl ([ea77493](https://github.com/CoCreate-app/CoCreate-elements/commit/ea77493fed7401b2ccd3d825b73198daf03f836c))
|
|
7
|
+
* check if document_id is a valid id if not return ([220151f](https://github.com/CoCreate-app/CoCreate-elements/commit/220151f9ee0b2c9ff8e4afc06cc24ad5b891b161))
|
|
8
|
+
|
|
1
9
|
# [1.6.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.5.0...v1.6.0) (2022-01-01)
|
|
2
10
|
|
|
3
11
|
|
package/demo/get-value.html
CHANGED
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
<input get-value="#testing1" />
|
|
25
25
|
<input get-value="#testing1" />
|
|
26
26
|
|
|
27
|
+
<script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
|
|
27
28
|
<!--<script src="../dist/CoCreate-form.js"></script>-->
|
|
28
|
-
|
|
29
|
+
<!--<script src="../../../CoCreateJS/dist/CoCreate.js" ></script>-->
|
|
30
|
+
|
|
29
31
|
</body>
|
|
30
32
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Fetch content into any html element by using html5 attributes to query data stored in CoCreate headless CMS. If data is changed it will instantly reflect in html tags as changes are broadcasted in realtime",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"elements",
|
package/src/getValue.js
CHANGED
|
@@ -18,14 +18,11 @@ function initElements(elements) {
|
|
|
18
18
|
function initElement(element) {
|
|
19
19
|
let selector = element.getAttribute('get-value');
|
|
20
20
|
if(!selector) return;
|
|
21
|
+
if(/{{\s*([\w\W]+)\s*}}/g.test(selector)) return;
|
|
21
22
|
|
|
22
23
|
let valueEl = document.querySelector(selector);
|
|
23
24
|
if(!valueEl) return;
|
|
24
|
-
|
|
25
|
-
// let value = getValue(valueEl);
|
|
26
|
-
// if (value)
|
|
27
|
-
// setValue(element, value);
|
|
28
|
-
|
|
25
|
+
|
|
29
26
|
initEvents(valueEl, element);
|
|
30
27
|
|
|
31
28
|
element.dispatchEvent(new Event("input", {
|
|
@@ -35,10 +32,8 @@ function initElement(element) {
|
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
function initEvents(valueEl, element){
|
|
38
|
-
if (!valueEls.has(valueEl))
|
|
35
|
+
if (!valueEls.has(valueEl)) {
|
|
39
36
|
valueEls.set(valueEl, [element]);
|
|
40
|
-
else {
|
|
41
|
-
valueEls.get(valueEl).push(element);
|
|
42
37
|
if (['INPUT', 'TEXTAREA', 'SELECT'].includes(valueEl.tagName) || valueEl.contentEditable)
|
|
43
38
|
valueEl.addEventListener('input', (e) => {
|
|
44
39
|
setValueByFind(e.target);
|
|
@@ -46,8 +41,10 @@ function initEvents(valueEl, element){
|
|
|
46
41
|
|
|
47
42
|
valueEl.addEventListener('updated_by_fetch', (e) => {
|
|
48
43
|
setValueByFind(e.target);
|
|
49
|
-
});
|
|
44
|
+
});
|
|
50
45
|
}
|
|
46
|
+
else
|
|
47
|
+
valueEls.get(valueEl).push(element);
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
function setValueByFind(valueEl) {
|
|
@@ -147,5 +144,4 @@ observer.init({
|
|
|
147
144
|
}
|
|
148
145
|
});
|
|
149
146
|
|
|
150
|
-
// initGetValues();
|
|
151
147
|
export { initGetValues, getValue };
|
package/src/index.js
CHANGED
|
@@ -40,6 +40,7 @@ function initElement(el) {
|
|
|
40
40
|
|
|
41
41
|
const { collection, document_id, name, isRead } = crud.getAttr(el);
|
|
42
42
|
if (!collection || !name) return;
|
|
43
|
+
if (!document_id.match(/^[0-9a-fA-F]{24}$/)) return;
|
|
43
44
|
if (!crud.checkAttrValue(collection) || !crud.checkAttrValue(name)) return;
|
|
44
45
|
|
|
45
46
|
__initEvents(el);
|