diff --git a/routes/_actions/compose.js b/routes/_actions/compose.js index aadd5a6..c0c356b 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 0000000..88833e6 --- /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 0000000..68978d8 --- /dev/null +++ b/routes/_components/compose/ComposeAutosuggestionList.html @@ -0,0 +1,90 @@ + + + \ No newline at end of file diff --git a/routes/_components/compose/ComposeBox.html b/routes/_components/compose/ComposeBox.html index 8135bb2..d02d107 100644 --- a/routes/_components/compose/ComposeBox.html +++ b/routes/_components/compose/ComposeBox.html @@ -8,7 +8,7 @@ {{/if}} - + diff --git a/routes/_components/compose/ComposeInput.html b/routes/_components/compose/ComposeInput.html index 9acfbac..ee8a61a 100644 --- a/routes/_components/compose/ComposeInput.html +++ b/routes/_components/compose/ComposeInput.html @@ -4,6 +4,9 @@ ref:textarea bind:value=rawText on:blur="onBlur()" + on:focus="onFocus()" + on:selectionChange="onSelectionChange(event)" + on:keydown="onKeydown(event)" >