From e0c1d9ce009a570571c9ad586cad32e277f9d1e0 Mon Sep 17 00:00:00 2001 From: naskya Date: Wed, 22 Nov 2023 22:21:47 +0900 Subject: [PATCH] refactor (minor): update MkPostForm --- packages/client/src/components/MkPostForm.vue | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/client/src/components/MkPostForm.vue b/packages/client/src/components/MkPostForm.vue index 490d75bab..db5ae740a 100644 --- a/packages/client/src/components/MkPostForm.vue +++ b/packages/client/src/components/MkPostForm.vue @@ -344,7 +344,6 @@ const visibleUsers = ref([]); if (props.initialVisibleUsers) { props.initialVisibleUsers.forEach(pushVisibleUser); } -const autocomplete = ref(null); const draghover = ref(false); const quoteId = ref(null); const hasNotSpecifiedMentions = ref(false); @@ -476,11 +475,11 @@ if (props.reply && props.reply.text != null) { ? `@${x.username}` : `@${x.username}@${toASCII(otherHost)}`; - // 自分は除外 + // exclude me if ($i.username === x.username && (x.host == null || x.host === host)) continue; - // 重複は除外 + // remove duplicates if (text.value.includes(`${mention} `)) continue; text.value += `${mention} `; @@ -489,10 +488,10 @@ if (props.reply && props.reply.text != null) { if (props.channel) { visibility.value = "public"; - localOnly.value = true; // TODO: チャンネルが連合するようになった折には消す + localOnly.value = true; // TODO: Delete this once channels get federated } -// 公開以外へのリプライ時は元の公開範囲を引き継ぐ +// Inherit the original visibility if ( props.reply && ["home", "followers", "specified"].includes(props.reply.visibility) @@ -611,10 +610,6 @@ function togglePoll() { } } -function addTag(tag: string) { - insertTextAtCursor(textareaEl.value, ` #${tag} `); -} - function focus() { if (textareaEl.value) { textareaEl.value.focus(); @@ -718,6 +713,8 @@ function clear() { quoteId.value = null; } +// FIXME: ev.which is deprecated +// https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/which function onKeydown(ev: KeyboardEvent) { if ( (ev.which === 10 || ev.which === 13) && @@ -754,7 +751,7 @@ async function onPaste(ev: ClipboardEvent) { } } - const paste = ev.clipboardData.getData("text"); + const paste = ev.clipboardData?.getData("text") ?? ""; if (!props.renote && !quoteId.value && paste.startsWith(url + "/notes/")) { ev.preventDefault(); @@ -769,7 +766,7 @@ async function onPaste(ev: ClipboardEvent) { } quoteId.value = paste - .substr(url.length) + .substring(url.length) .match(/^\/notes\/(.+?)\/?$/)[1]; }); }