1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-15 03:25:47 +02:00

fix(frontend): mfmFunctionPickerを使用して挿入する際のハンドリングを改善 (#17018)

* fix(frontend): mfmFunctionPickerを使用して絵文字を挿入する際のハンドリングを改善

* fix

* Update MkPostForm.vue

* Update Changelog

---------

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
かっこかり
2026-01-08 21:08:27 +09:00
committed by GitHub
parent cd973b252a
commit ece4efcefe
4 changed files with 40 additions and 41 deletions

View File

@@ -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);
}
});
},
);
}