@cocreate/element-prototype 1.3.0 → 1.4.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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.4.1](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.4.0...v1.4.1) (2023-01-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * bump dependencies ([daea982](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/daea9825b670529595d5af53c9ef617a3029a644))
7
+
8
+ # [1.4.0](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.3.0...v1.4.0) (2023-01-10)
9
+
10
+
11
+ ### Features
12
+
13
+ * run CoCReate,pass on elementsprior t inserting. merge domEditor and alements together ([d39f8ff](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/d39f8ffd287ed82754314a401b7c33e7bf902450))
14
+
1
15
  # [1.3.0](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.2.28...v1.3.0) (2023-01-09)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/element-prototype",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "description": "A simple element-prototype component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "element-prototype",
@@ -60,8 +60,8 @@
60
60
  "webpack-log": "^3.0.1"
61
61
  },
62
62
  "dependencies": {
63
- "@cocreate/docs": "^1.5.5",
64
- "@cocreate/hosting": "^1.7.5",
65
- "@cocreate/utils": "^1.17.18"
63
+ "@cocreate/docs": "^1.5.6",
64
+ "@cocreate/hosting": "^1.7.6",
65
+ "@cocreate/utils": "^1.17.19"
66
66
  }
67
67
  }
package/src/setValue.js CHANGED
@@ -61,15 +61,36 @@ const setValue = (el, value) => {
61
61
  else if (el.tagName === 'IFRAME')
62
62
  el.srcdoc = value;
63
63
 
64
- else if (el.tagName === 'DIV') {
65
- if (el.hasAttribute("value")) {
66
- el.setAttribute("value", value);
64
+ else if (el.tagName === 'SCRIPT')
65
+ setScript(el, value);
66
+
67
+ else {
68
+ if (el.hasAttribute('contenteditable') && el == document.activeElement) return;
69
+ if (el.tagName === 'DIV') {
70
+ if (!el.classList.contains('domEditor') || !el.hasAttribute('get-value') || !el.hasAttribute('get-value-closest'))
71
+ return
67
72
  }
68
73
 
69
- if (el.classList.contains('domEditor') || el.hasAttribute('get-value') || el.hasAttribute('get-value-closest')) {
70
- if (el.getAttribute('data-domEditor') == "replace") {
71
- let newElement = document.createElement("div");
72
- newElement.innerHTML = value;
74
+ if (valueType == 'string' || valueType == 'text')
75
+ el.textContent = value;
76
+ else {
77
+ let newElement = document.createElement("div");
78
+ newElement.innerHTML = value;
79
+ setPass(newElement)
80
+
81
+ let CoCreateJS = newElement.querySelector('script[src*="CoCreate.js"], script[src*="CoCreate.min.js"]')
82
+ if (CoCreateJS)
83
+ CoCreateJS.remove()
84
+
85
+ let CoCreateCSS = newElement.querySelector('link[href*="CoCreate.css"], link[href*="CoCreate.min.css"]')
86
+ if (CoCreateCSS)
87
+ CoCreateCSS.remove()
88
+
89
+ let css = newElement.querySelector('link[collection], link[document]')
90
+ if (css)
91
+ css.remove()
92
+
93
+ if (el.getAttribute('domEditor') == "replace") {
73
94
  let parentNode = el.parentNode;
74
95
  if (parentNode) {
75
96
  if (newElement.children[0]) {
@@ -79,29 +100,16 @@ const setValue = (el, value) => {
79
100
  parentNode.replaceChild(newElement, el);
80
101
  }
81
102
  }
82
- }
83
- else {
84
- if (valueType == 'string' || valueType == 'text')
85
- el.textContent = value;
86
- else
87
- el.innerHTML = value;
103
+ } else {
104
+ el.innerHTML = newElement.innerHTML;
88
105
  }
89
106
  }
90
- }
91
107
 
92
- else if (el.tagName === 'SCRIPT'){
93
- setScript(el, value);
94
- }
95
- else {
96
- if (el.hasAttribute('contenteditable') && el == document.activeElement) return;
97
- if (valueType == 'string' || valueType == 'text')
98
- el.textContent = value;
99
- else
100
- el.innerHTML = value;
101
108
  if (el.hasAttribute("value")) {
102
109
  el.setAttribute("value", value);
103
110
  }
104
111
  }
112
+
105
113
  if (el.getAttribute('contenteditable'))
106
114
  dispatchEvents(el);
107
115
 
@@ -117,6 +125,14 @@ const setValue = (el, value) => {
117
125
  }
118
126
  };
119
127
 
128
+ function setPass(el) {
129
+ if (CoCreate.pass) {
130
+ let passElements = el.querySelectorAll('[pass_id]');
131
+ if (passElements)
132
+ CoCreate.pass.initElements(passElements)
133
+ }
134
+ }
135
+
120
136
  function setScript(script, value) {
121
137
  let newScript = document.createElement('script');
122
138
  newScript.attributes = script.attributes;