2023-07-27 05:31:52 +00:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2019-01-27 05:34:52 +00:00
|
|
|
<template>
|
2023-12-03 01:58:42 +00:00
|
|
|
<Suspense>
|
|
|
|
<template #fallback>
|
|
|
|
<MkLoading v-if="!inline ?? true"/>
|
|
|
|
</template>
|
|
|
|
<code v-if="inline" :class="$style.codeInlineRoot">{{ code }}</code>
|
|
|
|
<XCode v-else-if="show" :code="code" :lang="lang"/>
|
|
|
|
<button v-else :class="$style.codePlaceholderRoot" @click="show = true">
|
|
|
|
<div :class="$style.codePlaceholderContainer">
|
|
|
|
<div><i class="ti ti-code"></i> {{ i18n.ts.code }}</div>
|
|
|
|
<div>{{ i18n.ts.clickToShow }}</div>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
</Suspense>
|
2019-01-27 05:34:52 +00:00
|
|
|
</template>
|
|
|
|
|
2022-01-10 15:05:18 +00:00
|
|
|
<script lang="ts" setup>
|
2023-12-03 01:58:42 +00:00
|
|
|
import { defineAsyncComponent, ref } from 'vue';
|
2023-10-29 05:12:40 +00:00
|
|
|
import MkLoading from '@/components/global/MkLoading.vue';
|
2023-12-03 01:58:42 +00:00
|
|
|
import { defaultStore } from '@/store.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2022-01-10 15:05:18 +00:00
|
|
|
defineProps<{
|
|
|
|
code: string;
|
|
|
|
lang?: string;
|
|
|
|
inline?: boolean;
|
|
|
|
}>();
|
|
|
|
|
2023-12-03 01:58:42 +00:00
|
|
|
const show = ref(!defaultStore.state.dataSaver.code);
|
|
|
|
|
2022-08-30 15:24:33 +00:00
|
|
|
const XCode = defineAsyncComponent(() => import('@/components/MkCode.core.vue'));
|
2019-01-27 05:34:52 +00:00
|
|
|
</script>
|
2023-10-29 05:12:40 +00:00
|
|
|
|
|
|
|
<style module lang="scss">
|
|
|
|
.codeInlineRoot {
|
|
|
|
display: inline-block;
|
|
|
|
font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;
|
|
|
|
overflow-wrap: anywhere;
|
|
|
|
color: #D4D4D4;
|
|
|
|
background: #1E1E1E;
|
|
|
|
padding: .1em;
|
|
|
|
border-radius: .3em;
|
|
|
|
}
|
2023-12-03 01:58:42 +00:00
|
|
|
|
|
|
|
.codePlaceholderRoot {
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
background: none;
|
|
|
|
border: none;
|
|
|
|
outline: none;
|
|
|
|
font: inherit;
|
|
|
|
color: inherit;
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
border-radius: 8px;
|
|
|
|
padding: 24px;
|
|
|
|
margin-top: 4px;
|
|
|
|
color: #D4D4D4;
|
|
|
|
background: #1E1E1E;
|
|
|
|
}
|
|
|
|
|
|
|
|
.codePlaceholderContainer {
|
|
|
|
text-align: center;
|
|
|
|
font-size: 0.8em;
|
|
|
|
}
|
2023-10-29 05:12:40 +00:00
|
|
|
</style>
|