forked from mirror/misskey
a6a91fec3a
* add: safeFloatParserを追加
* fix: 欠けていた型を追加
* refactor: pageBlockTypesをjson-schemaに移植
* refactor: components/global内の型エラーが出ている箇所を修正
* lint: fix null check style
* refactor: fix type error
* refactor: fix some type errors
* fix: 翻訳が抜けていた箇所を修正
* refactor: getJsonSchemaで正しいスキーマが返されるように修正
* fix: MkChartの型エラーとbytesオプションが機能していない問題を修正
* fix(misskey-js): `drive`->`folderUpdated`のpayloadの型が間違っていたのを修正
* refactor: fix some type errors
* change: Captcha読み込み中の文言をLoadingに変更
* refactor(backend/misskey-js): MainEventの型を改善
* refactor: chartjs-plugin-gradientが二重でpluginに登録されていたのを修正
* update: misskey-js.api.md
* refactor: fix some type errors
* fix: backendのtypecheckが落ちていたのを修正
* update: misskey-js.api.md
* add: json-schemaのnoteにpollの型定義を追加
* refactor: noteのjson-schemaの型を改善
* refactor: MkPoll
* refactor: fix some type errors
* change: UserLiteにisLockedを持たせるように
* fix: notificationスキーマにroleが含まれていないのを修正
* Revert "change: UserLiteにisLockedを持たせるように"
This reverts commit 1bb0c8e7a9
.
* fix: フォロー通知から鍵垢へのフォローを行うと処理中のまま止まってしまう問題を修正
* refactor: noteスキーマのvisibilityにenumを追加
* change: deepCloneのCloneableTypeにundefinedを追加
* refactor: fix some type errors
* refactor: `allowEmpty: false`を使用していた箇所を`minLength: 1`に置き換え
* enhance: API 'retension' のresponseの型を追加
* fix: Chart関連のtooltipが正しい位置に表示されない問題を修正
* refactor: fix some type errors
* fix: 型情報が不足していたのを修正
* enhance: announcementスキーマにenumを追加
* enhance: ロールポリシーの型定義をRoleServiceからjson-schemaに移植
* refactor: policiesを`ref: RolePolicies`に統一
* fix: API `meta` のレスポンスの型にpoliciesが含まれていないのを修正
* refactor: fix some type errors
* fix: backendのlintが落ちているのを修正
* fix: MkFoldableSectionの開閉時のanimationが適用されていない問題を修正
* fix: backendのtypecheckが落ちているのを修正
* update: run build-misskey-js-with-types
* fix: MkDialogのmount時に文字数制限の判定が行われない問題を修正
* update: CHANGELOG.md
* refactor: MkUserSelectDialogの型を改善
* fix: deepCloneでundefinedはcloneしないように (#9207)
* change: frontendのcloneをbackend側にも反映
* update: CHANGELOG.md
* fix: RoleServiceからPackを通して型RolePoliciesに依存させないように
* Update packages/frontend/src/scripts/get-note-summary.ts
* revert RoleService.ts changes
* change: optional chaining -> non-null assertion
* remove: unused import
* fix: propsで渡されたuserがUserLiteの場合に意図しない動作になってしまうのを修正
* change: fix null check style
* refactor: fix type error
* change: fix null check style
* Update packages/frontend/src/components/MkDrive.vue
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
* refactor: css moduleでglobalを使わないように
* refactor: roleのiconUrlは必ず存在するものとして扱うように
* enhance: MenuButtonのactiveにcomputedを受け付けられるように
* Update packages/frontend/src/components/MkNotePreview.vue
* Update MkWindow.vue
* refactor: notification.noteは必ず存在するものとして扱うように
* Update packages/frontend/src/components/MkNotification.vue
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
* fix: MkSignupDialogでdoneのemit時にresを含んでいなかったのを修正
* Update packages/frontend/src/scripts/clone.ts
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
* refactor: 不要な返り値の型を削除
* refactor: 不要なnullチェックを削除
* update: misskey-js-autogen
* update: clone.ts
* refactor
* Update MkNotification.vue
* Update MkNotification.vue
* ✌️
* Update MkNotification.vue
* Update MkNotification.vue
* Update MkNotification.vue
* Update MkNotifications.vue
* Update MkUserSetupDialog.Profile.vue
* Update MkUserCardMini.vue
* ✌️
* Update MkMenu.vue
---------
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
235 lines
5.1 KiB
Vue
235 lines
5.1 KiB
Vue
<!--
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
-->
|
|
|
|
<template>
|
|
<div>
|
|
<div :class="$style.label" @click="focus"><slot name="label"></slot></div>
|
|
<div :class="{ [$style.disabled]: disabled, [$style.focused]: focused, [$style.tall]: tall, [$style.pre]: pre }" style="position: relative;">
|
|
<textarea
|
|
ref="inputEl"
|
|
v-model="v"
|
|
v-adaptive-border
|
|
:class="[$style.textarea, { _monospace: code }]"
|
|
:disabled="disabled"
|
|
:required="required"
|
|
:readonly="readonly"
|
|
:placeholder="placeholder"
|
|
:pattern="pattern"
|
|
:autocomplete="autocomplete"
|
|
:spellcheck="spellcheck"
|
|
@focus="focused = true"
|
|
@blur="focused = false"
|
|
@keydown="onKeydown($event)"
|
|
@input="onInput"
|
|
></textarea>
|
|
</div>
|
|
<div :class="$style.caption"><slot name="caption"></slot></div>
|
|
<button v-if="mfmPreview" style="font-size: 0.85em;" class="_textButton" type="button" @click="preview = !preview">{{ i18n.ts.preview }}</button>
|
|
<div v-if="mfmPreview" 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>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { onMounted, onUnmounted, nextTick, ref, watch, computed, toRefs, shallowRef } from 'vue';
|
|
import { debounce } from 'throttle-debounce';
|
|
import MkButton from '@/components/MkButton.vue';
|
|
import { i18n } from '@/i18n.js';
|
|
import { Autocomplete, SuggestionType } from '@/scripts/autocomplete.js';
|
|
|
|
const props = defineProps<{
|
|
modelValue: string | null;
|
|
required?: boolean;
|
|
readonly?: boolean;
|
|
disabled?: boolean;
|
|
pattern?: string;
|
|
placeholder?: string;
|
|
autofocus?: boolean;
|
|
autocomplete?: string;
|
|
mfmAutocomplete?: boolean | SuggestionType[],
|
|
mfmPreview?: boolean;
|
|
spellcheck?: boolean;
|
|
debounce?: boolean;
|
|
manualSave?: boolean;
|
|
code?: boolean;
|
|
tall?: boolean;
|
|
pre?: boolean;
|
|
}>();
|
|
|
|
const emit = defineEmits<{
|
|
(ev: 'change', _ev: KeyboardEvent): void;
|
|
(ev: 'keydown', _ev: KeyboardEvent): void;
|
|
(ev: 'enter'): void;
|
|
(ev: 'update:modelValue', value: string): void;
|
|
}>();
|
|
|
|
const { modelValue, autofocus } = toRefs(props);
|
|
const v = ref<string>(modelValue.value ?? '');
|
|
const focused = ref(false);
|
|
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 autocompleteWorker: Autocomplete | null = null;
|
|
|
|
const focus = () => inputEl.value?.focus();
|
|
const onInput = (ev) => {
|
|
changed.value = true;
|
|
emit('change', ev);
|
|
};
|
|
const onKeydown = (ev: KeyboardEvent) => {
|
|
if (ev.isComposing || ev.key === 'Process' || ev.keyCode === 229) return;
|
|
|
|
emit('keydown', ev);
|
|
|
|
if (ev.code === 'Enter') {
|
|
emit('enter');
|
|
}
|
|
|
|
if (props.code && ev.key === 'Tab') {
|
|
const pos = inputEl.value?.selectionStart ?? 0;
|
|
const posEnd = inputEl.value?.selectionEnd ?? v.value.length;
|
|
v.value = v.value.slice(0, pos) + '\t' + v.value.slice(posEnd);
|
|
nextTick(() => {
|
|
inputEl.value?.setSelectionRange(pos + 1, pos + 1);
|
|
});
|
|
ev.preventDefault();
|
|
}
|
|
};
|
|
|
|
const updated = () => {
|
|
changed.value = false;
|
|
emit('update:modelValue', v.value ?? '');
|
|
};
|
|
|
|
const debouncedUpdated = debounce(1000, updated);
|
|
|
|
watch(modelValue, newValue => {
|
|
v.value = newValue ?? '';
|
|
});
|
|
|
|
watch(v, () => {
|
|
if (!props.manualSave) {
|
|
if (props.debounce) {
|
|
debouncedUpdated();
|
|
} else {
|
|
updated();
|
|
}
|
|
}
|
|
|
|
invalid.value = inputEl.value?.validity.badInput ?? true;
|
|
});
|
|
|
|
onMounted(() => {
|
|
nextTick(() => {
|
|
if (autofocus.value) {
|
|
focus();
|
|
}
|
|
});
|
|
|
|
if (props.mfmAutocomplete && inputEl.value) {
|
|
autocompleteWorker = new Autocomplete(inputEl.value, v, props.mfmAutocomplete === true ? undefined : props.mfmAutocomplete);
|
|
}
|
|
});
|
|
|
|
onUnmounted(() => {
|
|
if (autocompleteWorker) {
|
|
autocompleteWorker.detach();
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<style lang="scss" module>
|
|
.label {
|
|
font-size: 0.85em;
|
|
padding: 0 0 8px 0;
|
|
user-select: none;
|
|
|
|
&:empty {
|
|
display: none;
|
|
}
|
|
}
|
|
|
|
.caption {
|
|
font-size: 0.85em;
|
|
padding: 8px 0 0 0;
|
|
color: var(--fgTransparentWeak);
|
|
|
|
&:empty {
|
|
display: none;
|
|
}
|
|
}
|
|
|
|
.textarea {
|
|
appearance: none;
|
|
-webkit-appearance: none;
|
|
display: block;
|
|
width: 100%;
|
|
min-width: 100%;
|
|
max-width: 100%;
|
|
min-height: 130px;
|
|
margin: 0;
|
|
padding: 12px;
|
|
font: inherit;
|
|
font-weight: normal;
|
|
font-size: 1em;
|
|
color: var(--fg);
|
|
background: var(--panel);
|
|
border: solid 1px var(--panel);
|
|
border-radius: 6px;
|
|
outline: none;
|
|
box-shadow: none;
|
|
box-sizing: border-box;
|
|
transition: border-color 0.1s ease-out;
|
|
|
|
&:hover {
|
|
border-color: var(--inputBorderHover) !important;
|
|
}
|
|
}
|
|
|
|
.focused {
|
|
> .textarea {
|
|
border-color: var(--accent) !important;
|
|
}
|
|
}
|
|
|
|
.disabled {
|
|
opacity: 0.7;
|
|
cursor: not-allowed !important;
|
|
|
|
> .textarea {
|
|
cursor: not-allowed !important;
|
|
}
|
|
}
|
|
|
|
.tall {
|
|
> .textarea {
|
|
min-height: 200px;
|
|
}
|
|
}
|
|
|
|
.pre {
|
|
> .textarea {
|
|
white-space: pre;
|
|
}
|
|
}
|
|
|
|
.save {
|
|
margin: 8px 0 0 0;
|
|
}
|
|
|
|
.mfmPreview {
|
|
padding: 12px;
|
|
border-radius: var(--radius);
|
|
box-sizing: border-box;
|
|
min-height: 130px;
|
|
pointer-events: none;
|
|
}
|
|
</style>
|