Skip to content

Instantly share code, notes, and snippets.

@kyle-aoki
Last active July 28, 2023 14:48
Show Gist options
  • Save kyle-aoki/42e2c6ca22b0fe6f8bfd50bbee1272f6 to your computer and use it in GitHub Desktop.
Save kyle-aoki/42e2c6ca22b0fe6f8bfd50bbee1272f6 to your computer and use it in GitHub Desktop.
Monaco Text Editor Setup
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;
`;
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