mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-19 18:13:41 -05:00
web/composer: allow autocompleting after newline
This commit is contained in:
parent
72e1bd428e
commit
1e73867b9b
1 changed files with 8 additions and 2 deletions
|
@ -68,7 +68,7 @@ const draftStore = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
set: (roomID: RoomID, data: ComposerState) => localStorage.setItem(`draft-${roomID}`, JSON.stringify(data)),
|
set: (roomID: RoomID, data: ComposerState) => localStorage.setItem(`draft-${roomID}`, JSON.stringify(data)),
|
||||||
clear: (roomID: RoomID)=> localStorage.removeItem(`draft-${roomID}`),
|
clear: (roomID: RoomID) => localStorage.removeItem(`draft-${roomID}`),
|
||||||
}
|
}
|
||||||
|
|
||||||
type CaretEvent<T> = React.MouseEvent<T> | React.KeyboardEvent<T> | React.ChangeEvent<T>
|
type CaretEvent<T> = React.MouseEvent<T> | React.KeyboardEvent<T> | React.ChangeEvent<T>
|
||||||
|
@ -175,7 +175,13 @@ const MessageComposer = () => {
|
||||||
}
|
}
|
||||||
} else if (area.selectionStart === area.selectionEnd) {
|
} else if (area.selectionStart === area.selectionEnd) {
|
||||||
const acType = charToAutocompleteType(newText?.slice(area.selectionStart - 1, area.selectionStart))
|
const acType = charToAutocompleteType(newText?.slice(area.selectionStart - 1, area.selectionStart))
|
||||||
if (acType && (area.selectionStart === 1 || newText?.[area.selectionStart - 2] === " ")) {
|
if (
|
||||||
|
acType && (
|
||||||
|
area.selectionStart === 1
|
||||||
|
|| newText?.[area.selectionStart - 2] === " "
|
||||||
|
|| newText?.[area.selectionStart - 2] === "\n"
|
||||||
|
)
|
||||||
|
) {
|
||||||
setAutocomplete({
|
setAutocomplete({
|
||||||
type: acType,
|
type: acType,
|
||||||
query: "",
|
query: "",
|
||||||
|
|
Loading…
Add table
Reference in a new issue