From c0b7a04c4ac418d46790870e8ac9049b35ab452f Mon Sep 17 00:00:00 2001 From: Dooho Yi Date: Fri, 10 Jan 2025 22:55:41 +0900 Subject: [PATCH] activating basic beautifier of ace-editor --- frontend/src/views/files/Editor.vue | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/files/Editor.vue b/frontend/src/views/files/Editor.vue index 7e4d7a9b..1ecbe53b 100644 --- a/frontend/src/views/files/Editor.vue +++ b/frontend/src/views/files/Editor.vue @@ -41,6 +41,7 @@ import url from "@/utils/url"; import ace, { Ace, version as ace_version } from "ace-builds"; import modelist from "ace-builds/src-noconflict/ext-modelist"; import "ace-builds/src-noconflict/ext-language_tools"; +import "ace-builds/src-noconflict/ext-beautify"; import HeaderBar from "@/components/header/HeaderBar.vue"; import Action from "@/components/header/Action.vue"; @@ -66,6 +67,7 @@ const route = useRoute(); const router = useRouter(); const editor = ref(null); +const beautify = ace.require("ace/ext/beautify"); const isPreview = ref(false); const previewContent = ref(""); @@ -137,12 +139,19 @@ const keyEvent = (event: KeyboardEvent) => { return; } - if (event.key !== "s") { + if (event.key !== "s" && event.key !== "B") { return; } event.preventDefault(); - save(); + + if (event.key == "s") { + save(); + } + + if (event.key == "B") { + beautify.beautify(editor.value?.session); + } }; const handleScroll = (event: WheelEvent) => {