2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
2024-02-13 16:59:27 +01:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 07:31:52 +02:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
-->
|
|
|
|
|
|
2019-04-29 02:11:57 +02:00
|
|
|
<template>
|
2021-11-18 15:32:43 +01:00
|
|
|
<!-- eslint-disable vue/no-mutating-props -->
|
2024-10-31 05:50:50 +01:00
|
|
|
<XContainer :draggable="true" @remove="() => emit('remove')">
|
2023-04-01 07:01:57 +02:00
|
|
|
<template #header><i class="ti ti-align-left"></i> {{ i18n.ts._pages.blocks.text }}</template>
|
2019-04-29 02:11:57 +02:00
|
|
|
|
2023-05-14 03:21:56 +02:00
|
|
|
<section>
|
2023-12-14 05:11:23 +01:00
|
|
|
<textarea ref="inputEl" v-model="text" :class="$style.textarea"></textarea>
|
2019-04-29 02:11:57 +02:00
|
|
|
</section>
|
2020-10-17 13:12:00 +02:00
|
|
|
</XContainer>
|
2019-04-29 02:11:57 +02:00
|
|
|
</template>
|
|
|
|
|
|
2022-06-18 11:39:04 +02:00
|
|
|
<script lang="ts" setup>
|
2024-10-31 05:50:50 +01:00
|
|
|
|
2023-12-14 05:11:23 +01:00
|
|
|
import { watch, ref, shallowRef, onMounted, onUnmounted } from 'vue';
|
2024-10-31 05:46:42 +01:00
|
|
|
import * as Misskey from 'misskey-js';
|
2019-04-29 23:40:02 +02:00
|
|
|
import XContainer from '../page-editor.container.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { i18n } from '@/i18n.js';
|
2023-12-14 05:11:23 +01:00
|
|
|
import { Autocomplete } from '@/scripts/autocomplete.js';
|
2019-04-29 02:11:57 +02:00
|
|
|
|
2022-12-24 03:57:06 +01:00
|
|
|
const props = defineProps<{
|
2024-10-31 05:46:42 +01:00
|
|
|
modelValue: Misskey.entities.PageBlock & { type: 'text' }
|
2022-12-24 03:57:06 +01:00
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
2024-10-31 05:46:42 +01:00
|
|
|
(ev: 'update:modelValue', value: Misskey.entities.PageBlock & { type: 'text' }): void;
|
2022-12-24 03:57:06 +01:00
|
|
|
}>();
|
|
|
|
|
|
2023-12-14 05:11:23 +01:00
|
|
|
let autocomplete: Autocomplete;
|
|
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const text = ref(props.modelValue.text ?? '');
|
2023-12-14 05:11:23 +01:00
|
|
|
const inputEl = shallowRef<HTMLTextAreaElement | null>(null);
|
2022-12-24 03:57:06 +01:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
watch(text, () => {
|
2022-12-24 03:57:06 +01:00
|
|
|
emit('update:modelValue', {
|
|
|
|
|
...props.modelValue,
|
2023-12-07 06:42:09 +01:00
|
|
|
text: text.value,
|
2022-12-24 03:57:06 +01:00
|
|
|
});
|
2019-04-29 02:11:57 +02:00
|
|
|
});
|
2023-12-14 05:11:23 +01:00
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
autocomplete = new Autocomplete(inputEl.value, text);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
autocomplete.detach();
|
|
|
|
|
});
|
2019-04-29 02:11:57 +02:00
|
|
|
</script>
|
|
|
|
|
|
2023-05-14 03:21:56 +02:00
|
|
|
<style lang="scss" module>
|
|
|
|
|
.textarea {
|
|
|
|
|
display: block;
|
|
|
|
|
-webkit-appearance: none;
|
|
|
|
|
-moz-appearance: none;
|
|
|
|
|
appearance: none;
|
|
|
|
|
width: 100%;
|
|
|
|
|
min-width: 100%;
|
|
|
|
|
min-height: 150px;
|
|
|
|
|
border: none;
|
|
|
|
|
box-shadow: none;
|
|
|
|
|
padding: 16px;
|
|
|
|
|
background: transparent;
|
2024-10-09 11:08:14 +02:00
|
|
|
color: var(--MI_THEME-fg);
|
2023-05-14 03:21:56 +02:00
|
|
|
font-size: 14px;
|
|
|
|
|
box-sizing: border-box;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
2019-04-29 02:11:57 +02:00
|
|
|
</style>
|