@mixd-id/web-scaffold 0.1.230406333 → 0.1.230406335

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.230406333",
4
+ "version": "0.1.230406335",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -2,10 +2,11 @@
2
2
  <div :class="$style.comp">
3
3
 
4
4
  <div class="flex flex-row items-start">
5
- <p contenteditable="true" spellcheck="false" class="flex-1 whitespace-pre-line"
5
+ <p contenteditable="true" spellcheck="false" class="flex-1 whitespace-pre-wrap"
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
 
@@ -14,7 +15,7 @@
14
15
  </button>
15
16
  </div>
16
17
 
17
- <div v-if="variant !== 'minimal'" class="flex flex-row bg-base-300">
18
+ <div v-if="variant !== 'minimal'" class="flex flex-row bg-base-300" @dblclick.alt="log(JSON.stringify(modelValue))">
18
19
  <div class="flex-1 flex flex-row gap-2 overflow-x-auto p-1" :class="$style.noScrollbar">
19
20
  <button type="button" v-for="item in viewedItems" :class="$style.tag2" class="text-xs" @click="add(item)">{{ item.text ?? item.value }}</button>
20
21
  </div>
@@ -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,18 +194,15 @@ 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 === 1 && this.$refs.html.childNodes[i].classList.contains(this.$style.tag)){
181
- arr.push(this.$refs.html.childNodes[i].getAttribute('data-value'))
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((arr.length > 0 ? "\n\n" : '') + this.$refs.html.childNodes[i].innerText)
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
 
191
- const text = arr.filter(_ => _).join('')
205
+ const text = arr.filter(_ => _).join('').trim()
192
206
 
193
207
  this.$emit('update:modelValue', text)
194
208