@aochuang/client-sdk 1.0.284 → 1.0.286
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.
|
@@ -246,10 +246,10 @@ export default {
|
|
|
246
246
|
if (!nearest) {
|
|
247
247
|
this.closeSuggestions()
|
|
248
248
|
}
|
|
249
|
-
this.loadSuggestions(nearest)
|
|
249
|
+
this.loadSuggestions(nearest, nearsetInfo)
|
|
250
250
|
}, 200)
|
|
251
251
|
},
|
|
252
|
-
loadSuggestions (keyword) {
|
|
252
|
+
loadSuggestions (keyword, nearestInfo) {
|
|
253
253
|
if (!this.fetchSuggestionsMethod) {
|
|
254
254
|
return
|
|
255
255
|
}
|
|
@@ -258,7 +258,9 @@ export default {
|
|
|
258
258
|
this.suggestionsKeyword = keyword
|
|
259
259
|
clearTimeout(this._loadSuggestionsTimer)
|
|
260
260
|
return this.fetchSuggestionsMethod({
|
|
261
|
-
keyword
|
|
261
|
+
keyword,
|
|
262
|
+
nearestInfo,
|
|
263
|
+
isAtContext: !!(nearestInfo && nearestInfo.isAtContext)
|
|
262
264
|
}).then(rs => {
|
|
263
265
|
this.suggestionsData = rs || []
|
|
264
266
|
}).finally(() => {
|
|
@@ -715,6 +717,16 @@ export default {
|
|
|
715
717
|
end
|
|
716
718
|
}
|
|
717
719
|
},
|
|
720
|
+
getMentionReplaceRange () {
|
|
721
|
+
const range = this.cacheInputRange || this.getSelectionTextRange()
|
|
722
|
+
if (!this.suggestionsNearsetInfo || !this.suggestionsNearsetInfo.isAtContext) {
|
|
723
|
+
return {
|
|
724
|
+
start: range.start,
|
|
725
|
+
end: range.end
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return this.getSuggestionsReplaceRange()
|
|
729
|
+
},
|
|
718
730
|
insertInputText (str) {
|
|
719
731
|
if (this.disabled) {
|
|
720
732
|
return
|
|
@@ -745,10 +757,12 @@ export default {
|
|
|
745
757
|
if (!mentionNode) {
|
|
746
758
|
return
|
|
747
759
|
}
|
|
748
|
-
|
|
760
|
+
const replaceRange = this.getMentionReplaceRange()
|
|
761
|
+
const selectedLength = Math.max(0, replaceRange.end - replaceRange.start)
|
|
762
|
+
const nextLength = this.getInputText().length - selectedLength + (mentionNode.textContent || '').length + 1
|
|
763
|
+
if (this.hasMaxlength() && nextLength > this.maxlength) {
|
|
749
764
|
return
|
|
750
765
|
}
|
|
751
|
-
const replaceRange = this.getSuggestionsReplaceRange()
|
|
752
766
|
this.setSelectionByTextRange(replaceRange.start, replaceRange.end)
|
|
753
767
|
this.insertNodesAtSelection([
|
|
754
768
|
mentionNode,
|