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

This commit is contained in:
FruitRiin 2024-09-21 21:49:20 +09:00
parent dac3b1f405
commit 61f1740b19

View file

@ -65,7 +65,19 @@ SPDX-License-Identifier: AGPL-3.0-only
</div> </div>
</div> </div>
<MkInfo v-if="hasNotSpecifiedMentions" warn :class="$style.hasNotSpecifiedMentions">{{ i18n.ts.notSpecifiedMentionWarning }} - <button class="_textButton" @click="addMissingMention()">{{ i18n.ts.add }}</button></MkInfo> <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 :class="[$style.textOuter, { [$style.withCw]: useCw }]">
<div v-if="channel" :class="$style.colorBar" :style="{ background: channel.color }"></div> <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"/> <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() { function togglePoll() {
if (poll.value) { if (poll.value) {
poll.value = null; poll.value = null;
@ -1192,6 +1213,15 @@ defineExpose({
} }
//#endregion //#endregion
.cwSwapButton {
margin-left: 8px;
padding: 8px;
border-radius: 6px;
&:hover {
background: var(--X4);
}
}
.preview { .preview {
padding: 16px 20px 0 20px; padding: 16px 20px 0 20px;
min-height: 75px; min-height: 75px;