@cocreate/elements 1.9.0 → 1.10.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 +7 -0
- package/package.json +1 -1
- package/src/index.js +3 -3
- package/src/setValue.js +10 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.10.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.9.0...v1.10.0) (2022-07-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* value-type support and if element name attribute = _id do not save ([164d12f](https://github.com/CoCreate-app/CoCreate-elements/commit/164d12f40a84d85d4114df3b8efe51b9cf6a4e11))
|
|
7
|
+
|
|
1
8
|
# [1.9.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.8.4...v1.9.0) (2022-07-03)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
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/index.js
CHANGED
|
@@ -95,7 +95,7 @@ function setData(elements, data) {
|
|
|
95
95
|
// if (name == 'data')
|
|
96
96
|
// value = JSON.stringify(data[name])
|
|
97
97
|
// else
|
|
98
|
-
|
|
98
|
+
value = JSON.stringify(data.data[name])
|
|
99
99
|
value = decodeURIComponent(value)
|
|
100
100
|
} else
|
|
101
101
|
value = encodeData[name];
|
|
@@ -139,8 +139,8 @@ function __initEvents(el) {
|
|
|
139
139
|
if (!elementEvents.has(el)) {
|
|
140
140
|
if (el.tagName == 'INPUT' || el.tagName == 'TEXTAREA' || el.tagName == 'SELECT' || el.hasAttribute('contenteditable')) {
|
|
141
141
|
el.addEventListener('input', function(e) {
|
|
142
|
-
const {document_id, isRealtime, isCrdt} = crud.getAttr(el);
|
|
143
|
-
if (isCrdt == "true" && document_id || isRealtime == "false") return;
|
|
142
|
+
const {document_id, name, isRealtime, isCrdt} = crud.getAttr(el);
|
|
143
|
+
if (isCrdt == "true" && document_id || isRealtime == "false" || name == "_id") return;
|
|
144
144
|
if (document_id && e.detail && e.detail.skip == true) return;
|
|
145
145
|
save(el);
|
|
146
146
|
});
|
package/src/setValue.js
CHANGED
|
@@ -73,7 +73,8 @@ function setValueByFind(element){
|
|
|
73
73
|
|
|
74
74
|
var setValue = (el, value) => {
|
|
75
75
|
if (value === null || value === undefined) return;
|
|
76
|
-
|
|
76
|
+
let valueType = el.getAttribute('value-type');
|
|
77
|
+
|
|
77
78
|
if (el.tagName == 'INPUT' || el.tagName == 'TEXTAREA' || el.tagName == 'SELECT') {
|
|
78
79
|
const {isCrdt} = crud.getAttr(el);
|
|
79
80
|
if (isCrdt == "true" || el.type === 'file') return;
|
|
@@ -130,7 +131,10 @@ var setValue = (el, value) => {
|
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
else {
|
|
133
|
-
|
|
134
|
+
if (valueType == 'string' || valueType == 'text')
|
|
135
|
+
el.textContent = value;
|
|
136
|
+
else
|
|
137
|
+
el.innerHTML = value;
|
|
134
138
|
}
|
|
135
139
|
}
|
|
136
140
|
}
|
|
@@ -140,8 +144,10 @@ var setValue = (el, value) => {
|
|
|
140
144
|
}
|
|
141
145
|
else {
|
|
142
146
|
if (el.hasAttribute('contenteditable') && el == document.activeElement) return;
|
|
143
|
-
|
|
144
|
-
|
|
147
|
+
if (valueType == 'string' || valueType == 'text')
|
|
148
|
+
el.textContent = value;
|
|
149
|
+
else
|
|
150
|
+
el.innerHTML = value;
|
|
145
151
|
if (el.hasAttribute("value")) {
|
|
146
152
|
el.setAttribute("value", value);
|
|
147
153
|
}
|