diff --git a/routes/_actions/compose.js b/routes/_actions/compose.js index aadd5a6f..c0c356bc 100644 --- a/routes/_actions/compose.js +++ b/routes/_actions/compose.js @@ -47,3 +47,21 @@ export async function postStatus (realm, text, inReplyToId, mediaIds, store.set({postingStatus: false}) } } + +export async function insertUsername (realm, username, startIndex, endIndex) { + let oldText = store.getComposeData(realm, 'text') + let pre = oldText.substring(0, startIndex) + let post = oldText.substring(endIndex) + let newText = `${pre}@${username} ${post}` + store.setComposeData(realm, {text: newText}) +} + +export async function clickSelectedAutosuggestionUsername (realm) { + let selectionStart = store.get('composeSelectionStart') + let searchText = store.get('composeAutosuggestionSearchText') + let selection = store.get('composeAutosuggestionSelected') || 0 + let account = store.get('composeAutosuggestionSearchResults')[selection] + let startIndex = selectionStart - searchText.length + let endIndex = selectionStart + await insertUsername(realm, account.acct, startIndex, endIndex) +} diff --git a/routes/_components/compose/ComposeAutosuggest.html b/routes/_components/compose/ComposeAutosuggest.html new file mode 100644 index 00000000..88833e60 --- /dev/null +++ b/routes/_components/compose/ComposeAutosuggest.html @@ -0,0 +1,128 @@ +
+ + \ No newline at end of file diff --git a/routes/_components/compose/ComposeAutosuggestionList.html b/routes/_components/compose/ComposeAutosuggestionList.html new file mode 100644 index 00000000..68978d8b --- /dev/null +++ b/routes/_components/compose/ComposeAutosuggestionList.html @@ -0,0 +1,90 @@ +