beautify using monaco

This commit is contained in:
Olivier Gagnon 2021-10-23 14:40:46 -04:00
parent 148611dd4f
commit a0039d9667
2 changed files with 7 additions and 9 deletions

@ -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",

@ -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<HTMLInputElement>): void {