Files
transform/components/Monaco.tsx
T
Ritesh Kumar 4ebf5472cd replace monaco editor with compiled version (#290) (#291)
* rename exported functions

* replace monaco editor with compiled version

* fixes

* cancel old API requests
2021-06-27 23:24:08 +05:30

42 lines
754 B
TypeScript

import React from "react";
import Editor from "@monaco-editor/react";
export function processSize(size) {
return !/^\d+$/.test(size) ? size : `${size}px`;
}
interface MonacoProps {
theme?: string;
language?: string;
value?: string;
width?: number | string;
height?: number | string;
options?: any;
defaultValue?: string;
onChange: (value: string) => void;
}
export const Monaco: React.FC<MonacoProps> = ({
language,
value,
defaultValue,
height,
width,
options,
onChange
}) => {
return (
<Editor
defaultLanguage={language}
defaultValue={defaultValue}
value={value}
height={height}
width={width}
options={options}
onChange={onChange}
/>
);
};
export default Monaco;