@dataloop-ai/components 0.18.86 → 0.18.88
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
|
@@ -113,7 +113,8 @@ import {
|
|
|
113
113
|
replaceJSDatesWithStringifiedDates,
|
|
114
114
|
replaceStringifiedDatesWithJSDates,
|
|
115
115
|
setAliases,
|
|
116
|
-
revertAliases
|
|
116
|
+
revertAliases,
|
|
117
|
+
clearPartlyTypedSuggestion
|
|
117
118
|
} from '../utils'
|
|
118
119
|
import { v4 } from 'uuid'
|
|
119
120
|
import {
|
|
@@ -260,14 +261,13 @@ export default defineComponent({
|
|
|
260
261
|
}
|
|
261
262
|
|
|
262
263
|
searchQuery.value = value
|
|
263
|
-
input.value.innerHTML = value
|
|
264
264
|
|
|
265
|
-
|
|
265
|
+
if (value !== input.value.innerText) {
|
|
266
|
+
input.value.innerHTML = value
|
|
267
|
+
}
|
|
268
|
+
|
|
266
269
|
updateEditor(input.value, editorStyle.value)
|
|
267
270
|
setMenuOffset(isEligibleToChange(input.value, expanded.value))
|
|
268
|
-
// resetCursor()
|
|
269
|
-
|
|
270
|
-
setCaret(input.value)
|
|
271
271
|
|
|
272
272
|
if (!expanded.value) {
|
|
273
273
|
isOverflowing.value =
|
|
@@ -330,7 +330,10 @@ export default defineComponent({
|
|
|
330
330
|
stringValue = value + ' '
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
-
setInputValue(
|
|
333
|
+
setInputValue(
|
|
334
|
+
clearPartlyTypedSuggestion(input.value.innerText, stringValue)
|
|
335
|
+
)
|
|
336
|
+
setCaret(input.value)
|
|
334
337
|
}
|
|
335
338
|
|
|
336
339
|
const debouncedSetInputValue = debounce(setInputValue, 300)
|
|
@@ -347,7 +350,12 @@ export default defineComponent({
|
|
|
347
350
|
const setInputFromModel = (value: string) => {
|
|
348
351
|
searchQuery.value = value
|
|
349
352
|
input.value.innerHTML = value
|
|
350
|
-
|
|
353
|
+
|
|
354
|
+
let inputValue = `${value}`
|
|
355
|
+
if (value.length) {
|
|
356
|
+
inputValue += ' '
|
|
357
|
+
}
|
|
358
|
+
setInputValue(inputValue, { noEmit: true })
|
|
351
359
|
}
|
|
352
360
|
|
|
353
361
|
const debouncedSetInputFromModel = debounce(setInputFromModel, 300)
|
|
@@ -52,7 +52,6 @@ export function updateEditor(
|
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
editor.innerHTML = renderText(textContent, colorSchema)
|
|
55
|
-
|
|
56
55
|
restoreSelection(editor, anchorIndex, focusIndex)
|
|
57
56
|
}
|
|
58
57
|
|
|
@@ -120,3 +119,24 @@ export function setCaret(target: HTMLElement) {
|
|
|
120
119
|
sel.addRange(range)
|
|
121
120
|
target.focus()
|
|
122
121
|
}
|
|
122
|
+
|
|
123
|
+
export function clearPartlyTypedSuggestion(oldValue: string, newValue: string) {
|
|
124
|
+
const oldSuggestion = oldValue.split(' ').at(-1)
|
|
125
|
+
const newSuggestion = newValue.split(' ').at(-2)
|
|
126
|
+
if (oldSuggestion && newSuggestion?.includes(oldSuggestion)) {
|
|
127
|
+
newValue = removeOldSuggestion(newValue)
|
|
128
|
+
}
|
|
129
|
+
return newValue
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function removeOldSuggestion(inputString: string) {
|
|
133
|
+
const words = inputString.trim().split(' ')
|
|
134
|
+
|
|
135
|
+
if (words.length >= 2) {
|
|
136
|
+
words.splice(-2, 1)
|
|
137
|
+
const resultString = words.join(' ')
|
|
138
|
+
return resultString + ' '
|
|
139
|
+
} else {
|
|
140
|
+
return inputString
|
|
141
|
+
}
|
|
142
|
+
}
|