mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-24 18:46:43 -06:00
fix(frontend): emojiPickerを使用して絵文字を挿入する際、refに直接挿入するように (#14282)
* fix(frontend): emojiPickerを使用して絵文字を挿入する際、refに直接挿入するように * add comment
This commit is contained in:
parent
3548ffba26
commit
9181eb277e
1 changed files with 14 additions and 1 deletions
|
@ -906,10 +906,23 @@ async function insertEmoji(ev: MouseEvent) {
|
||||||
textAreaReadOnly.value = true;
|
textAreaReadOnly.value = true;
|
||||||
const target = ev.currentTarget ?? ev.target;
|
const target = ev.currentTarget ?? ev.target;
|
||||||
if (target == null) return;
|
if (target == null) return;
|
||||||
|
|
||||||
|
// emojiPickerはダイアログが閉じずにtextareaとやりとりするので、
|
||||||
|
// focustrapをかけているとinsertTextAtCursorが効かない
|
||||||
|
// そのため、投稿フォームのテキストに直接注入する
|
||||||
|
// See: https://github.com/misskey-dev/misskey/pull/14282
|
||||||
|
// https://github.com/misskey-dev/misskey/issues/14274
|
||||||
|
|
||||||
|
let pos = textareaEl.value?.selectionStart ?? 0;
|
||||||
|
let posEnd = textareaEl.value?.selectionEnd ?? text.value.length;
|
||||||
emojiPicker.show(
|
emojiPicker.show(
|
||||||
target as HTMLElement,
|
target as HTMLElement,
|
||||||
emoji => {
|
emoji => {
|
||||||
insertTextAtCursor(textareaEl.value, emoji);
|
const textBefore = text.value.substring(0, pos);
|
||||||
|
const textAfter = text.value.substring(posEnd);
|
||||||
|
text.value = textBefore + emoji + textAfter;
|
||||||
|
pos += emoji.length;
|
||||||
|
posEnd += emoji.length;
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
textAreaReadOnly.value = false;
|
textAreaReadOnly.value = false;
|
||||||
|
|
Loading…
Reference in a new issue