Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed Dec 14, 2023
1 parent 825f6c1 commit 68ed400
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 149 deletions.
7 changes: 1 addition & 6 deletions packages/frontend/src/components/MkFormDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,10 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #label><span v-text="form[item].label || item"></span><span v-if="form[item].required === false"> ({{ i18n.ts.optional }})</span></template>
<template v-if="form[item].description" #caption>{{ form[item].description }}</template>
</MkInput>
<MkTextarea v-else-if="form[item].type === 'string' && form[item].multiline && !form[item].isMfmAvailable" v-model="values[item]">
<MkTextarea v-else-if="form[item].type === 'string' && form[item].multiline" v-model="values[item]" mfmAutocomplete :mfmPreview="form[item].isMfmAvailable">
<template #label><span v-text="form[item].label || item"></span><span v-if="form[item].required === false"> ({{ i18n.ts.optional }})</span></template>
<template v-if="form[item].description" #caption>{{ form[item].description }}</template>
</MkTextarea>
<MkTextareaWithMfmPreview v-else-if="form[item].type === 'string' && form[item].multiline && form[item].isMfmAvailable" v-model="values[item]">
<template #label><span v-text="form[item].label || item"></span><span v-if="form[item].required === false"> ({{ i18n.ts.optional }})</span></template>
<template v-if="form[item].description" #caption>{{ form[item].description }}</template>
</MkTextareaWithMfmPreview>
<MkSwitch v-else-if="form[item].type === 'boolean'" v-model="values[item]">
<span v-text="form[item].label || item"></span>
<template v-if="form[item].description" #caption>{{ form[item].description }}</template>
Expand Down Expand Up @@ -73,7 +69,6 @@ import MkRange from './MkRange.vue';
import MkButton from './MkButton.vue';
import MkRadios from './MkRadios.vue';
import MkModalWindow from '@/components/MkModalWindow.vue';
import MkTextareaWithMfmPreview from './MkTextareaWithMfmPreview.vue';
import { i18n } from '@/i18n.js';

const props = defineProps<{
Expand Down
14 changes: 14 additions & 0 deletions packages/frontend/src/components/MkTextarea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ SPDX-License-Identifier: AGPL-3.0-only
></textarea>
</div>
<div :class="$style.caption"><slot name="caption"></slot></div>
<button style="font-size: 0.85em;" class="_textButton" type="button" @click="preview = !preview">{{ i18n.ts.preview }}</button>
<div v-show="preview" v-panel :class="$style.mfmPreview">
<Mfm :text="v"/>
</div>

<MkButton v-if="manualSave && changed" primary :class="$style.save" @click="updated"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
</div>
Expand All @@ -48,6 +52,7 @@ const props = defineProps<{
autofocus?: boolean;
autocomplete?: string;
mfmAutocomplete?: boolean | SuggestionType[],
mfmPreview?: boolean;
spellcheck?: boolean;
debounce?: boolean;
manualSave?: boolean;
Expand All @@ -70,6 +75,7 @@ const changed = ref(false);
const invalid = ref(false);
const filled = computed(() => v.value !== '' && v.value != null);
const inputEl = shallowRef<HTMLTextAreaElement>();
const preview = ref(false);
let autocomplete: Autocomplete;

const focus = () => inputEl.value.focus();
Expand Down Expand Up @@ -207,4 +213,12 @@ onUnmounted(() => {
.save {
margin: 8px 0 0 0;
}

.mfmPreview {
padding: 12px;
border-radius: var(--radius);
box-sizing: border-box;
min-height: 130px;
pointer-events: none;
}
</style>
133 changes: 0 additions & 133 deletions packages/frontend/src/components/MkTextareaWithMfmPreview.vue

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type MfmProps = {
isNote?: boolean;
emojiUrls?: string[];
rootScale?: number;
nyaize: boolean | 'respect';
nyaize?: boolean | 'respect';
parsedNodes?: mfm.MfmNode[] | null;
enableEmojiMenu?: boolean;
enableEmojiMenuReaction?: boolean;
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/pages/admin/announcements.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkInput v-model="announcement.title">
<template #label>{{ i18n.ts.title }}</template>
</MkInput>
<MkTextareaWithMfmPreview v-model="announcement.text">
<MkTextarea v-model="announcement.text" mfmAutocomplete :mfmPreview="true">
<template #label>{{ i18n.ts.text }}</template>
</MkTextareaWithMfmPreview>
</MkTextarea>
<MkInput v-model="announcement.imageUrl" type="url">
<template #label>{{ i18n.ts.imageUrl }}</template>
</MkInput>
Expand Down Expand Up @@ -75,14 +75,14 @@ import { ref, computed } from 'vue';
import XHeader from './_header_.vue';
import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue';
import MkTextareaWithMfmPreview from '@/components/MkTextareaWithMfmPreview.vue';
import MkSwitch from '@/components/MkSwitch.vue';
import MkRadios from '@/components/MkRadios.vue';
import MkInfo from '@/components/MkInfo.vue';
import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import MkFolder from '@/components/MkFolder.vue';
import MkTextarea from '@/components/MkTextarea.vue';

const announcements = ref<any[]>([]);

Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/pages/channel-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #label>{{ i18n.ts.name }}</template>
</MkInput>

<MkTextareaWithMfmPreview v-model="description">
<MkTextarea v-model="description" mfmAutocomplete :mfmPreview="true">
<template #label>{{ i18n.ts.description }}</template>
</MkTextareaWithMfmPreview>
</MkTextarea>

<MkColorInput v-model="color">
<template #label>{{ i18n.ts.color }}</template>
Expand Down Expand Up @@ -80,7 +80,7 @@ import { definePageMetadata } from '@/scripts/page-metadata.js';
import { i18n } from '@/i18n.js';
import MkFolder from '@/components/MkFolder.vue';
import MkSwitch from '@/components/MkSwitch.vue';
import MkTextareaWithMfmPreview from '@/components/MkTextareaWithMfmPreview.vue';
import MkTextarea from '@/components/MkTextarea.vue';

const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default));

Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/pages/settings/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #label>{{ i18n.ts._profile.name }}</template>
</MkInput>

<MkTextareaWithMfmPreview v-model="profile.description" :max="500" tall manualSave :nyaize="$i?.isCat ? 'respect' : undefined" :author="($i as Misskey.entities.UserLite)">
<MkTextarea v-model="profile.description" :max="500" tall manualSave mfmAutocomplete :mfmPreview="true" :nyaize="$i?.isCat ? 'respect' : undefined" :author="($i as Misskey.entities.UserLite)">
<template #label>{{ i18n.ts._profile.description }}</template>
<template #caption>{{ i18n.ts._profile.youCanIncludeHashtags }}</template>
</MkTextareaWithMfmPreview>
</MkTextarea>

<MkInput v-model="profile.location" manualSave>
<template #label>{{ i18n.ts.location }}</template>
Expand Down Expand Up @@ -130,7 +130,7 @@ import { definePageMetadata } from '@/scripts/page-metadata.js';
import { claimAchievement } from '@/scripts/achievements.js';
import { defaultStore } from '@/store.js';
import MkInfo from '@/components/MkInfo.vue';
import MkTextareaWithMfmPreview from '@/components/MkTextareaWithMfmPreview.vue';
import MkTextarea from '@/components/MkTextarea.vue';

const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.default));

Expand Down

0 comments on commit 68ed400

Please sign in to comment.