From a0039d966773f85ec03bee0909306aec0e810c38 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Sat, 23 Oct 2021 14:40:46 -0400 Subject: [PATCH] beautify using monaco --- package.json | 2 -- src/ScriptEditor/ui/ScriptEditorRoot.tsx | 14 +++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 0a0d5fb84..090a5d1c5 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "@mui/material": "^5.0.3", "@mui/styles": "^5.0.1", "@types/escodegen": "^0.0.7", - "@types/js-beautify": "^1.13.2", "@types/numeral": "0.0.25", "@types/react": "^17.0.21", "@types/react-dom": "^17.0.9", @@ -64,7 +63,6 @@ "html-webpack-plugin": "^3.2.0", "http-server": "^13.0.1", "jest": "^27.1.0", - "js-beautify": "^1.5.10", "jsdom": "^15.0.0", "lodash": "^4.17.21", "mini-css-extract-plugin": "^0.4.1", diff --git a/src/ScriptEditor/ui/ScriptEditorRoot.tsx b/src/ScriptEditor/ui/ScriptEditorRoot.tsx index 6558f9588..e1b5fa4a1 100644 --- a/src/ScriptEditor/ui/ScriptEditorRoot.tsx +++ b/src/ScriptEditor/ui/ScriptEditorRoot.tsx @@ -4,7 +4,6 @@ import * as monaco from "monaco-editor"; type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor; import { OptionsModal } from "./OptionsModal"; import { Options } from "./Options"; -import { js_beautify as beautifyCode } from "js-beautify"; import { isValidFilePath } from "../../Terminal/DirectoryHelpers"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { IRouter } from "../../ui/Router"; @@ -217,12 +216,13 @@ export function Root(props: IProps): React.ReactElement { function beautify(): void { if (editorRef.current === null) return; - const pretty = beautifyCode(code, { - indent_with_tabs: !options.insertSpaces, - indent_size: 4, - brace_style: "preserve-inline", - }); - editorRef.current.setValue(pretty); + editorRef.current.getAction("editor.action.formatDocument").run(); + // const pretty = beautifyCode(code, { + // indent_with_tabs: !options.insertSpaces, + // indent_size: 4, + // brace_style: "preserve-inline", + // }); + // editorRef.current.setValue(pretty); } function onFilenameChange(event: React.ChangeEvent): void {