@mixd-id/web-scaffold 0.1.230406333 → 0.1.230406334
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/package.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
ref="html"
|
|
7
7
|
v-html="html"
|
|
8
8
|
:class="itemClass"
|
|
9
|
+
@keydown="onKeyDown"
|
|
9
10
|
@blur="saveSelection($refs.html)"
|
|
10
11
|
@input="onInput"></p>
|
|
11
12
|
|
|
@@ -137,6 +138,8 @@ export default{
|
|
|
137
138
|
addItem(item){
|
|
138
139
|
this.restoreSelection()
|
|
139
140
|
|
|
141
|
+
console.log(item)
|
|
142
|
+
|
|
140
143
|
const el = document.createElement('span')
|
|
141
144
|
el.setAttribute('contenteditable', 'false')
|
|
142
145
|
el.setAttribute('class', this.$style.tag)
|
|
@@ -169,6 +172,20 @@ export default{
|
|
|
169
172
|
this.addItem(item)
|
|
170
173
|
},
|
|
171
174
|
|
|
175
|
+
onKeyDown(e){
|
|
176
|
+
if (e.key === 'Enter') {
|
|
177
|
+
e.preventDefault();
|
|
178
|
+
document.execCommand('insertLineBreak');
|
|
179
|
+
|
|
180
|
+
const selection = window.getSelection();
|
|
181
|
+
const range = selection.getRangeAt(0);
|
|
182
|
+
range.setStartAfter(range.endContainer);
|
|
183
|
+
range.collapse(true);
|
|
184
|
+
selection.removeAllRanges();
|
|
185
|
+
selection.addRange(range);
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
|
|
172
189
|
remove(e){
|
|
173
190
|
e.target.parentNode.removeChild(e.target)
|
|
174
191
|
},
|
|
@@ -177,14 +194,11 @@ export default{
|
|
|
177
194
|
|
|
178
195
|
const arr = []
|
|
179
196
|
for(let i = 0 ; i < this.$refs.html.childNodes.length ; i++){
|
|
180
|
-
if(this.$refs.html.childNodes[i].nodeType ===
|
|
181
|
-
arr.push(this.$refs.html.childNodes[i].
|
|
182
|
-
}
|
|
183
|
-
else if(this.$refs.html.childNodes[i].nodeType === 3){
|
|
184
|
-
arr.push(this.$refs.html.childNodes[i].textContent)
|
|
197
|
+
if(this.$refs.html.childNodes[i].nodeType === 3){
|
|
198
|
+
arr.push(this.$refs.html.childNodes[i].nodeValue)
|
|
185
199
|
}
|
|
186
|
-
else{
|
|
187
|
-
arr.push(
|
|
200
|
+
else if(this.$refs.html.childNodes[i].nodeType === 1 && this.$refs.html.childNodes[i].classList.contains(this.$style.tag)){
|
|
201
|
+
arr.push(this.$refs.html.childNodes[i].getAttribute('data-value'))
|
|
188
202
|
}
|
|
189
203
|
}
|
|
190
204
|
|