From 5aaecdc3442f9934c4d905fae0f645709a610950 Mon Sep 17 00:00:00 2001 From: fly_mc Date: Wed, 23 Oct 2024 00:40:33 +0800 Subject: [PATCH] Revert "tweak mfm cheat sheet style" This reverts commit 4f19ccb040099b143f87e93efba2672902e7e947. --- .../frontend/src/components/MkPostForm.vue | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index b6b80082d..51cf1bcbb 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -90,6 +90,7 @@ SPDX-License-Identifier: AGPL-3.0-only
+
@@ -105,6 +106,7 @@ import * as mfm from 'mfm-js'; import * as Misskey from 'misskey-js'; import insertTextAtCursor from 'insert-text-at-cursor'; import { toASCII } from 'punycode/'; +import autosize from 'autosize'; import { host, url } from '@@/js/config.js'; import MkNoteSimple from '@/components/MkNoteSimple.vue'; import MkNotePreview from '@/components/MkNotePreview.vue'; @@ -152,6 +154,7 @@ const props = withDefaults(defineProps<{ autofocus?: boolean; freezeAfterPosted?: boolean; mock?: boolean; + updateMode?: boolean; }>(), { initialVisibleUsers: () => [], autofocus: true, @@ -372,6 +375,15 @@ function watchForDraft() { watch(reactionAcceptance, () => saveDraft()); } +function MFMWindow() { + const { dispose } = os.popup( + defineAsyncComponent(() => import('@/components/MkMfmWindow.vue')), + {}, + { + closed: () => dispose(), + }); +} + function checkMissingMention() { if (visibility.value === 'specified') { const ast = mfm.parse(text.value); @@ -569,6 +581,8 @@ function clear() { files.value = []; poll.value = null; quoteId.value = null; + + nextTick(() => textareaEl.value && autosize.update(textareaEl.value)); } function onKeydown(ev: KeyboardEvent) { @@ -577,6 +591,8 @@ function onKeydown(ev: KeyboardEvent) { // justEndedComposition.value is for Safari, which keyDown occurs after compositionend. // ev.isComposing is for another browsers. if (ev.key === 'Escape' && !justEndedComposition.value && !ev.isComposing) emit('esc'); + + nextTick(() => textareaEl.value && autosize.update(textareaEl.value)); } function onKeyup(ev: KeyboardEvent) { @@ -585,6 +601,8 @@ function onKeyup(ev: KeyboardEvent) { function onCompositionUpdate(ev: CompositionEvent) { imeText.value = ev.data; + + nextTick(() => textareaEl.value && autosize.update(textareaEl.value)); } function onCompositionEnd(ev: CompositionEvent) { @@ -641,6 +659,8 @@ async function onPaste(ev: ClipboardEvent) { upload(file, `${fileName}.txt`); }); } + + nextTick(() => textareaEl.value && autosize.update(textareaEl.value)); } function onDragover(ev) { @@ -796,6 +816,7 @@ async function post(ev?: MouseEvent) { visibility: visibility.value, visibleUserIds: visibility.value === 'specified' ? visibleUsers.value.map(u => u.id) : undefined, reactionAcceptance: reactionAcceptance.value, + noteId: props.updateMode ? props.initialNote?.id : undefined, }; if (withHashtags.value && hashtags.value && hashtags.value.trim() !== '') { @@ -832,7 +853,7 @@ async function post(ev?: MouseEvent) { } posting.value = true; - misskeyApi('notes/create', postData, token).then(() => { + misskeyApi(props.updateMode ? 'notes/update' : 'notes/create', postData, token).then(() => { if (props.freezeAfterPosted) { posted.value = true; } else { @@ -1048,6 +1069,7 @@ onMounted(() => { } nextTick(() => watchForDraft()); + nextTick(() => textareaEl.value && autosize(textareaEl.value)); }); }); @@ -1064,6 +1086,7 @@ defineExpose({ &.modal { width: 100%; max-width: 520px; + overflow-y: auto; } } @@ -1338,7 +1361,7 @@ html[data-color-scheme=light] .preview { } .footerRight { - flex: 0; + flex: 0.3; margin-left: auto; display: grid; grid-auto-flow: row;