activating basic beautifier of ace-editor

This commit is contained in:
Dooho Yi 2025-01-10 22:55:41 +09:00
parent 129a4fd39d
commit c0b7a04c4a

View file

@ -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<Ace.Editor | null>(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();
if (event.key == "s") {
save();
}
if (event.key == "B") {
beautify.beautify(editor.value?.session);
}
};
const handleScroll = (event: WheelEvent) => {