mirror of
https://github.com/ritz078/transform.git
synced 2026-12-01 13:02:08 +03:00
* rename exported functions * replace monaco editor with compiled version * fixes * cancel old API requests
42 lines
754 B
TypeScript
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;
|