Last active
July 28, 2023 14:48
-
-
Save kyle-aoki/42e2c6ca22b0fe6f8bfd50bbee1272f6 to your computer and use it in GitHub Desktop.
Monaco Text Editor Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const Outer = styled.div` | |
height: 100%; | |
width: 100%; | |
max-height: 100%; | |
max-width: 100%; | |
overflow: hidden; | |
position: relative; | |
`; | |
export const Inner = styled.div` | |
height: 100%; | |
width: 100%; | |
left: 0; | |
top: 0; | |
overflow: hidden; | |
position: absolute; | |
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const TextEditorTsx: FC<{ textEditor: TextEditor }> = ({ textEditor}) => { | |
return ( | |
<> | |
<Outer> | |
<Inner> | |
{Boolean(textEditor.state.openFile) ? ( | |
<Editor | |
onChange={(str) => textEditor.onTextEditorChange(str)} | |
theme="vs-dark" | |
defaultLanguage="json" | |
defaultValue="" | |
value={textEditor.state.openFile?.content || ""} | |
options={{ readOnly: textEditor.state.readOnly }} | |
/> | |
) : ( | |
<></> | |
)} | |
</Inner> | |
</Outer> | |
</> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment