CWと本文を入れ替えるボタン

This commit is contained in:
FruitRiin 2024-09-21 21:49:20 +09:00
parent f25fc5215b
commit 29665f9f83
1 changed files with 31 additions and 1 deletions

View File

@ -65,7 +65,19 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
</div>
<MkInfo v-if="hasNotSpecifiedMentions" warn :class="$style.hasNotSpecifiedMentions">{{ i18n.ts.notSpecifiedMentionWarning }} - <button class="_textButton" @click="addMissingMention()">{{ i18n.ts.add }}</button></MkInfo>
<input v-show="useCw" ref="cwInputEl" v-model="cw" :class="$style.cw" :placeholder="i18n.ts.annotation" @keydown="onKeydown" @keyup="onKeyup" @compositionend="onCompositionEnd">
<div v-show="useCw" style="display: flex">
<input
ref="cwInputEl"
v-model="cw"
:class="$style.cw"
:placeholder="i18n.ts.annotation"
@keydown="onKeydown"
@compositionend="onCompositionEnd"
/>
<button class="_button" :class="$style.cwSwapButton" @click="swapCwText">
<i class="ti ti-switch-vertical"></i>
</button>
</div>
<div :class="[$style.textOuter, { [$style.withCw]: useCw }]">
<div v-if="channel" :class="$style.colorBar" :style="{ background: channel.color }"></div>
<textarea ref="textareaEl" v-model="text" :class="[$style.text]" :disabled="posting || posted" :readonly="textAreaReadOnly" :placeholder="placeholder" data-cy-post-form-text @keydown="onKeydown" @keyup="onKeyup" @paste="onPaste" @compositionupdate="onCompositionUpdate" @compositionend="onCompositionEnd"/>
@ -386,6 +398,15 @@ function addMissingMention() {
}
}
function swapCwText() {
if (useCw.value) {
// text
const temp = text.value.split(/\r?\n/).join(" ");
text.value = cw.value ?? "";
cw.value = temp;
}
}
function togglePoll() {
if (poll.value) {
poll.value = null;
@ -1192,6 +1213,15 @@ defineExpose({
}
//#endregion
.cwSwapButton {
margin-left: 8px;
padding: 8px;
border-radius: 6px;
&:hover {
background: var(--X4);
}
}
.preview {
padding: 16px 20px 0 20px;
min-height: 75px;