diff options
| author | かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> | 2026-01-08 21:08:27 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-08 21:08:27 +0900 |
| commit | ece4efcefedc3ef095f8683db868d64645811893 (patch) | |
| tree | a5b5fe0493a714e8e0b6ccaafcf47fa22676d36a /packages/frontend/src/components/MkPostForm.vue | |
| parent | fix(frontend): 2月29日を誕生日に設定している場合、平年は3... (diff) | |
| download | misskey-ece4efcefedc3ef095f8683db868d64645811893.tar.gz misskey-ece4efcefedc3ef095f8683db868d64645811893.tar.bz2 misskey-ece4efcefedc3ef095f8683db868d64645811893.zip | |
fix(frontend): mfmFunctionPickerを使用して挿入する際のハンドリングを改善 (#17018)
* fix(frontend): mfmFunctionPickerを使用して絵文字を挿入する際のハンドリングを改善
* fix
* Update MkPostForm.vue
* Update Changelog
---------
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Diffstat (limited to 'packages/frontend/src/components/MkPostForm.vue')
| -rw-r--r-- | packages/frontend/src/components/MkPostForm.vue | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index 4b027cf105..9734b51927 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -1166,17 +1166,41 @@ async function insertEmoji(ev: MouseEvent) { }, () => { textAreaReadOnly.value = false; - nextTick(() => focus()); + nextTick(() => { + if (textareaEl.value) { + textareaEl.value.focus(); + textareaEl.value.setSelectionRange(pos, posEnd); + } + }); }, ); } async function insertMfmFunction(ev: MouseEvent) { if (textareaEl.value == null) return; + let pos = textareaEl.value.selectionStart ?? 0; + let posEnd = textareaEl.value.selectionEnd ?? text.value.length; mfmFunctionPicker( ev.currentTarget ?? ev.target, - textareaEl.value, - text, + (tag) => { + if (pos === posEnd) { + text.value = `${text.value.substring(0, pos)}$[${tag} ]${text.value.substring(pos)}`; + pos += tag.length + 3; + posEnd = pos; + } else { + text.value = `${text.value.substring(0, pos)}$[${tag} ${text.value.substring(pos, posEnd)}]${text.value.substring(posEnd)}`; + pos += tag.length + 3; + posEnd = pos; + } + }, + () => { + nextTick(() => { + if (textareaEl.value) { + textareaEl.value.focus(); + textareaEl.value.setSelectionRange(pos, posEnd); + } + }); + }, ); } |