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/material": "^5.0.3",
"@mui/styles": "^5.0.1", "@mui/styles": "^5.0.1",
"@types/escodegen": "^0.0.7", "@types/escodegen": "^0.0.7",
"@types/js-beautify": "^1.13.2",
"@types/numeral": "0.0.25", "@types/numeral": "0.0.25",
"@types/react": "^17.0.21", "@types/react": "^17.0.21",
"@types/react-dom": "^17.0.9", "@types/react-dom": "^17.0.9",
@ -64,7 +63,6 @@
"html-webpack-plugin": "^3.2.0", "html-webpack-plugin": "^3.2.0",
"http-server": "^13.0.1", "http-server": "^13.0.1",
"jest": "^27.1.0", "jest": "^27.1.0",
"js-beautify": "^1.5.10",
"jsdom": "^15.0.0", "jsdom": "^15.0.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"mini-css-extract-plugin": "^0.4.1", "mini-css-extract-plugin": "^0.4.1",

@ -4,7 +4,6 @@ import * as monaco from "monaco-editor";
type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor; type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor;
import { OptionsModal } from "./OptionsModal"; import { OptionsModal } from "./OptionsModal";
import { Options } from "./Options"; import { Options } from "./Options";
import { js_beautify as beautifyCode } from "js-beautify";
import { isValidFilePath } from "../../Terminal/DirectoryHelpers"; import { isValidFilePath } from "../../Terminal/DirectoryHelpers";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { IRouter } from "../../ui/Router"; import { IRouter } from "../../ui/Router";
@ -217,12 +216,13 @@ export function Root(props: IProps): React.ReactElement {
function beautify(): void { function beautify(): void {
if (editorRef.current === null) return; if (editorRef.current === null) return;
const pretty = beautifyCode(code, { editorRef.current.getAction("editor.action.formatDocument").run();
indent_with_tabs: !options.insertSpaces, // const pretty = beautifyCode(code, {
indent_size: 4, // indent_with_tabs: !options.insertSpaces,
brace_style: "preserve-inline", // indent_size: 4,
}); // brace_style: "preserve-inline",
editorRef.current.setValue(pretty); // });
// editorRef.current.setValue(pretty);
} }
function onFilenameChange(event: React.ChangeEvent<HTMLInputElement>): void { function onFilenameChange(event: React.ChangeEvent<HTMLInputElement>): void {