From 90043e0318ea2b9bd7c0008e9fc1fa96b7974cc0 Mon Sep 17 00:00:00 2001 From: Oleg Lobanov Date: Thu, 29 Aug 2024 22:59:25 +0200 Subject: [PATCH] show preview action only for md file --- frontend/src/css/mdPreview.css | 6 +++--- frontend/src/views/files/Editor.vue | 29 +++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/frontend/src/css/mdPreview.css b/frontend/src/css/mdPreview.css index 4c491f35..bf2863f6 100644 --- a/frontend/src/css/mdPreview.css +++ b/frontend/src/css/mdPreview.css @@ -1,5 +1,5 @@ .md_preview { - overflow-y:auto; + overflow-y: auto; max-height: 80vh; padding: 1rem; border: 1px solid #000; @@ -8,6 +8,6 @@ } #preview-container { - overflow: auto; - max-height: 80vh; /* Match the max-height of md_preview for scrolling */ + overflow: auto; + max-height: 80vh; /* Match the max-height of md_preview for scrolling */ } diff --git a/frontend/src/views/files/Editor.vue b/frontend/src/views/files/Editor.vue index c3e2a015..7e4d7a9b 100644 --- a/frontend/src/views/files/Editor.vue +++ b/frontend/src/views/files/Editor.vue @@ -12,13 +12,23 @@ @action="save()" /> - + -
+
@@ -42,7 +52,7 @@ import { inject, onBeforeUnmount, onMounted, ref, watchEffect } from "vue"; import { useRoute, useRouter } from "vue-router"; import { useI18n } from "vue-i18n"; import { getTheme } from "@/utils/theme"; -import { marked } from 'marked'; +import { marked } from "marked"; const $showError = inject("$showError")!; @@ -59,7 +69,9 @@ const editor = ref(null); const isPreview = ref(false); const previewContent = ref(""); -const isMarkdownFile = fileStore.req?.name.endsWith('.md') || fileStore.req?.name.endsWith('.markdown'); +const isMarkdownFile = + fileStore.req?.name.endsWith(".md") || + fileStore.req?.name.endsWith(".markdown"); onMounted(() => { window.addEventListener("keydown", keyEvent); @@ -77,9 +89,11 @@ onMounted(() => { previewContent.value = ""; } - const previewContainer = document.getElementById('preview-container'); + const previewContainer = document.getElementById("preview-container"); if (previewContainer) { - previewContainer.addEventListener("wheel", handleScroll, { capture: true }); + previewContainer.addEventListener("wheel", handleScroll, { + capture: true, + }); } } }); @@ -132,7 +146,7 @@ const keyEvent = (event: KeyboardEvent) => { }; const handleScroll = (event: WheelEvent) => { - const editorContainer = document.getElementById('preview-container'); + const editorContainer = document.getElementById("preview-container"); if (editorContainer) { editorContainer.scrollTop += event.deltaY; } @@ -167,4 +181,3 @@ const preview = () => { isPreview.value = !isPreview.value; }; -