-
Notifications
You must be signed in to change notification settings - Fork 937
feat(site): refactor template version editor layout #10912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
90c68a3
5c15516
ec90ce1
b2f0054
3c4c0f5
2735d25
bbe7894
9ed1474
46a1944
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { useTheme } from "@emotion/react"; | ||
import Editor, { loader } from "@monaco-editor/react"; | ||
import * as monaco from "monaco-editor"; | ||
import { FC, useLayoutEffect, useMemo, useState } from "react"; | ||
import { FC, useMemo } from "react"; | ||
import { MONOSPACE_FONT_FAMILY } from "theme/constants"; | ||
import type { editor } from "monaco-editor"; | ||
|
||
loader.config({ monaco }); | ||
|
||
|
@@ -13,22 +12,6 @@ export const MonacoEditor: FC<{ | |
onChange?: (value: string) => void; | ||
}> = ({ onChange, value, path }) => { | ||
const theme = useTheme(); | ||
const [editor, setEditor] = useState<editor.IStandaloneCodeEditor>(); | ||
useLayoutEffect(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious: do you know why we needed the resize listeners originally? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To resize the editor when the bottom panel was open/closed but Idk why we were using it since the autoLayout prop was set to true 🤔 maybe someone faced a bug and used the listener? I tested both cases and they worked without it tho |
||
if (!editor) { | ||
return; | ||
} | ||
const resizeListener = () => { | ||
editor.layout({ | ||
height: 0, | ||
width: 0, | ||
}); | ||
}; | ||
window.addEventListener("resize", resizeListener); | ||
return () => { | ||
window.removeEventListener("resize", resizeListener); | ||
}; | ||
}, [editor]); | ||
|
||
const language = useMemo(() => { | ||
if (path?.endsWith(".tf")) { | ||
|
@@ -56,7 +39,7 @@ export const MonacoEditor: FC<{ | |
options={{ | ||
automaticLayout: true, | ||
fontFamily: MONOSPACE_FONT_FAMILY, | ||
fontSize: 16, | ||
fontSize: 14, | ||
wordWrap: "on", | ||
padding: { | ||
top: 16, | ||
|
@@ -81,8 +64,6 @@ export const MonacoEditor: FC<{ | |
}, | ||
); | ||
|
||
setEditor(editor); | ||
|
||
document.fonts.ready | ||
.then(() => { | ||
// Ensures that all text is measured properly. | ||
|
@@ -124,7 +105,7 @@ export const MonacoEditor: FC<{ | |
], | ||
colors: { | ||
"editor.foreground": theme.palette.text.primary, | ||
"editor.background": theme.palette.background.default, | ||
"editor.background": theme.palette.background.paper, | ||
}, | ||
}); | ||
editor.updateOptions({ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot the details for when something can and can't support the
css
, but I'm thinking that this could be consolidated into a singlecss
prop