2024-01-18 03:49:12 +03:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'
|
|
|
|
import { ref, onMounted } from 'vue'
|
|
|
|
import { FilesManager } from '~/composables/files-manager';
|
|
|
|
import { iFile } from '~/composables/worker/7zip-manager';
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
file: iFile,
|
|
|
|
filesManager: FilesManager
|
|
|
|
}
|
|
|
|
|
|
|
|
const editor = ref()
|
|
|
|
|
|
|
|
let { file, filesManager } = defineProps<Props>()
|
|
|
|
|
|
|
|
// files manager
|
|
|
|
onMounted(async () => {
|
|
|
|
const darkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
|
|
|
2024-11-04 13:07:23 +03:00
|
|
|
if(!file) return;
|
2024-01-18 03:49:12 +03:00
|
|
|
let fileContent = await filesManager.getFileContent(file.path);
|
|
|
|
monaco.editor.create(editor.value, {
|
|
|
|
value: fileContent?.toString()!,
|
|
|
|
language: file.extension,
|
|
|
|
readOnly: true,
|
|
|
|
theme: darkMode ? 'vs-dark' : 'vs-light'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div id="editor" ref="editor"></div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
#editor {
|
|
|
|
width: 100vw;
|
2024-11-04 09:44:01 +03:00
|
|
|
height: calc(100vh - 120px);
|
2024-01-18 03:49:12 +03:00
|
|
|
}
|
|
|
|
</style>
|