@aochuang/client-sdk 1.0.282 → 1.0.284
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.
|
@@ -20,8 +20,10 @@
|
|
|
20
20
|
@paste="handleInputPaste"
|
|
21
21
|
@keydown="handleInputKeydown"
|
|
22
22
|
@keyup="handleInputKeyup"
|
|
23
|
+
@mouseup="handleInputMouseup"
|
|
23
24
|
@input="handleInputValueChange"
|
|
24
25
|
@focus="handleInputFocus"
|
|
26
|
+
@blur="handleInputBlur"
|
|
25
27
|
></div>
|
|
26
28
|
</div>
|
|
27
29
|
<template v-if="$slots.addon">
|
|
@@ -147,7 +149,7 @@ export default {
|
|
|
147
149
|
if (this.disabled) {
|
|
148
150
|
return
|
|
149
151
|
}
|
|
150
|
-
this.
|
|
152
|
+
this.cacheCurrentInputRange()
|
|
151
153
|
},
|
|
152
154
|
handleBeforeInput (evt) {
|
|
153
155
|
if (this.disabled) {
|
|
@@ -199,7 +201,19 @@ export default {
|
|
|
199
201
|
if (this.disabled) {
|
|
200
202
|
return
|
|
201
203
|
}
|
|
202
|
-
this.
|
|
204
|
+
this.cacheCurrentInputRange()
|
|
205
|
+
},
|
|
206
|
+
handleInputMouseup () {
|
|
207
|
+
if (this.disabled) {
|
|
208
|
+
return
|
|
209
|
+
}
|
|
210
|
+
this.cacheCurrentInputRange()
|
|
211
|
+
},
|
|
212
|
+
handleInputBlur () {
|
|
213
|
+
if (this.disabled) {
|
|
214
|
+
return
|
|
215
|
+
}
|
|
216
|
+
this.cacheCurrentInputRange()
|
|
203
217
|
},
|
|
204
218
|
handleInputPaste (evt) {
|
|
205
219
|
if (this.disabled) {
|
|
@@ -268,7 +282,7 @@ export default {
|
|
|
268
282
|
if (!this.hasMaxlength()) {
|
|
269
283
|
return Infinity
|
|
270
284
|
}
|
|
271
|
-
const range = this.getSelectionTextRange()
|
|
285
|
+
const range = this.getSafeRange() ? this.getSelectionTextRange() : (this.cacheInputRange || this.getSelectionTextRange())
|
|
272
286
|
const selectedLength = Math.max(0, range.end - range.start)
|
|
273
287
|
return Math.max(0, this.maxlength - (this.getInputText().length - selectedLength))
|
|
274
288
|
},
|
|
@@ -408,12 +422,23 @@ export default {
|
|
|
408
422
|
}
|
|
409
423
|
return range
|
|
410
424
|
},
|
|
411
|
-
|
|
425
|
+
cacheCurrentInputRange () {
|
|
426
|
+
const range = this.getSafeRange()
|
|
427
|
+
if (!range) {
|
|
428
|
+
return false
|
|
429
|
+
}
|
|
430
|
+
this.cacheInputRange = {
|
|
431
|
+
start: this.getTextOffsetByDomPoint(range.startContainer, range.startOffset),
|
|
432
|
+
end: this.getTextOffsetByDomPoint(range.endContainer, range.endOffset)
|
|
433
|
+
}
|
|
434
|
+
return true
|
|
435
|
+
},
|
|
436
|
+
focus (options = {}) {
|
|
412
437
|
if (!this.$refs.input || this.disabled) {
|
|
413
438
|
return
|
|
414
439
|
}
|
|
415
440
|
this.$refs.input.focus()
|
|
416
|
-
if (!this.getSafeRange()) {
|
|
441
|
+
if (options.resetCursor || !this.getSafeRange()) {
|
|
417
442
|
this.setCursorByTextOffset(this.getInputText().length)
|
|
418
443
|
}
|
|
419
444
|
},
|
|
@@ -626,7 +651,12 @@ export default {
|
|
|
626
651
|
return ['DIV', 'P', 'LI'].includes(node.tagName)
|
|
627
652
|
},
|
|
628
653
|
insertNodesAtSelection (nodes) {
|
|
654
|
+
const cachedRange = this.cacheInputRange ? Object.assign({}, this.cacheInputRange) : null
|
|
655
|
+
const shouldRestoreCachedRange = !this.getSafeRange() && cachedRange
|
|
629
656
|
this.focus()
|
|
657
|
+
if (shouldRestoreCachedRange) {
|
|
658
|
+
this.setSelectionByTextRange(cachedRange.start, cachedRange.end)
|
|
659
|
+
}
|
|
630
660
|
let range = this.getSafeRange()
|
|
631
661
|
if (!range) {
|
|
632
662
|
this.setCursorByTextOffset(this.getInputText().length)
|
|
@@ -644,6 +674,7 @@ export default {
|
|
|
644
674
|
})
|
|
645
675
|
if (lastNode) {
|
|
646
676
|
this.setCursorAfterNode(lastNode)
|
|
677
|
+
this.cacheCurrentInputRange()
|
|
647
678
|
}
|
|
648
679
|
},
|
|
649
680
|
insertFragmentAtSelection (fragment) {
|
|
@@ -787,7 +818,7 @@ export default {
|
|
|
787
818
|
this.setInputText(this.inputValue.slice(0, this.maxlength))
|
|
788
819
|
this.setCursorByTextOffset(this.inputValue.length)
|
|
789
820
|
}
|
|
790
|
-
this.
|
|
821
|
+
this.cacheCurrentInputRange()
|
|
791
822
|
if (this._skipNextSuggestionsLoad) {
|
|
792
823
|
this._skipNextSuggestionsLoad = false
|
|
793
824
|
} else {
|
|
@@ -104,7 +104,6 @@ export default {
|
|
|
104
104
|
data () {
|
|
105
105
|
return {
|
|
106
106
|
pageSize: 40,
|
|
107
|
-
tuckReady: false,
|
|
108
107
|
allowTuck: false,
|
|
109
108
|
loading: false
|
|
110
109
|
}
|
|
@@ -190,17 +189,24 @@ export default {
|
|
|
190
189
|
},
|
|
191
190
|
watch: {
|
|
192
191
|
lastStickyOnTopSession () {
|
|
193
|
-
this.
|
|
192
|
+
this.checkAllowTuckAfterRender()
|
|
193
|
+
},
|
|
194
|
+
tucked () {
|
|
195
|
+
this.checkAllowTuckAfterRender()
|
|
196
|
+
},
|
|
197
|
+
sessionListData () {
|
|
198
|
+
this.checkAllowTuckAfterRender()
|
|
194
199
|
}
|
|
195
200
|
},
|
|
196
201
|
mounted () {
|
|
197
|
-
this.resizeObserver = new ResizeObserver(
|
|
202
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
198
203
|
this.delayCheckAllowTuck()
|
|
199
204
|
})
|
|
200
|
-
this.
|
|
205
|
+
this.observeTuckTarget()
|
|
201
206
|
if (this.autoLoad) {
|
|
202
207
|
this.$refs.loadMore.reload()
|
|
203
208
|
}
|
|
209
|
+
this.checkAllowTuckAfterRender()
|
|
204
210
|
},
|
|
205
211
|
methods: {
|
|
206
212
|
reload () {
|
|
@@ -208,7 +214,6 @@ export default {
|
|
|
208
214
|
return
|
|
209
215
|
}
|
|
210
216
|
return this.$refs.loadMore.reload().then(() => {
|
|
211
|
-
this.tuckReady = true
|
|
212
217
|
this.delayCheckAllowTuck()
|
|
213
218
|
})
|
|
214
219
|
},
|
|
@@ -221,13 +226,33 @@ export default {
|
|
|
221
226
|
scrollTop (top) {
|
|
222
227
|
this.$refs.loadMore.scrollTop(top)
|
|
223
228
|
},
|
|
224
|
-
|
|
225
|
-
if (!this.
|
|
229
|
+
observeTuckTarget () {
|
|
230
|
+
if (!this.resizeObserver || !this.$el) {
|
|
226
231
|
return
|
|
227
232
|
}
|
|
233
|
+
this.resizeObserver.disconnect()
|
|
234
|
+
this.resizeObserver.observe(this.$el)
|
|
235
|
+
if (this.$refs.loadMore && this.$refs.loadMore.$el && this.$refs.loadMore.$el !== this.$el) {
|
|
236
|
+
this.resizeObserver.observe(this.$refs.loadMore.$el)
|
|
237
|
+
}
|
|
238
|
+
if (this.lastStickyOnTopSession) {
|
|
239
|
+
const $lastStickyOnTopEls = this.$refs['item-' + this.lastStickyOnTopSession[this.idField]]
|
|
240
|
+
if ($lastStickyOnTopEls && $lastStickyOnTopEls.length) {
|
|
241
|
+
this.resizeObserver.observe($lastStickyOnTopEls[0])
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
checkAllowTuckAfterRender () {
|
|
246
|
+
this.$nextTick(() => {
|
|
247
|
+
this.observeTuckTarget()
|
|
248
|
+
this.delayCheckAllowTuck()
|
|
249
|
+
})
|
|
250
|
+
},
|
|
251
|
+
delayCheckAllowTuck () {
|
|
228
252
|
clearTimeout(this._checkTimer)
|
|
229
253
|
this._checkTimer = setTimeout(() => {
|
|
230
|
-
if (!this.tuckable) {
|
|
254
|
+
if (!this.tuckable || !this.$el) {
|
|
255
|
+
this.allowTuck = false
|
|
231
256
|
return
|
|
232
257
|
}
|
|
233
258
|
if (this.tucked) {
|
|
@@ -298,7 +323,9 @@ export default {
|
|
|
298
323
|
}
|
|
299
324
|
},
|
|
300
325
|
beforeDestroy () {
|
|
301
|
-
this.
|
|
326
|
+
clearTimeout(this._checkTimer)
|
|
327
|
+
this.resizeObserver && this.resizeObserver.disconnect()
|
|
328
|
+
this.resizeObserver = null
|
|
302
329
|
}
|
|
303
330
|
}
|
|
304
331
|
</script>
|
|
@@ -321,6 +348,7 @@ export default {
|
|
|
321
348
|
align-items: center;
|
|
322
349
|
transition: background-color .25s;
|
|
323
350
|
cursor: pointer;
|
|
351
|
+
z-index: 3;
|
|
324
352
|
&:hover {
|
|
325
353
|
&:not(.is-loading) {
|
|
326
354
|
background-color: #ddd;
|