1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/didiopensource-KnowStreaming

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Это зеркальный репозиторий, синхронизируется ежедневно с исходного репозитория.
Клонировать/Скачать
index.tsx 1.3 КБ
Копировать Редактировать Исходные данные Просмотреть построчно История
zengqiao Отправлено 4 лет назад 447a575
import * as React from 'react';
import * as monaco from 'monaco-editor';
import './index.less';
export interface IEditorProps {
style?: React.CSSProperties;
options: monaco.editor.IStandaloneEditorConstructionOptions;
uri?: monaco.Uri;
autoUnmount?: boolean;
customMount?: (editor: monaco.editor.IStandaloneCodeEditor, monaco: any) => any;
placeholder?: string;
}
export class EditorCom extends React.Component<IEditorProps> {
public ref: HTMLElement = null;
public editor: monaco.editor.IStandaloneCodeEditor;
public state = {
placeholder: this.props.placeholder ?? '',
};
public componentWillUnmount() {
if (this.props.autoUnmount === false) return;
const model = this.editor.getModel();
model.dispose();
this.editor.dispose();
}
public componentDidMount() {
const { customMount, options, uri } = this.props;
const { value, language } = options;
if (uri) {
options.model = monaco.editor.createModel(value, language, uri);
}
this.editor = monaco.editor.create(this.ref,
options,
);
if (customMount) customMount(this.editor, monaco);
}
public render() {
const { style } = this.props;
return (
<>
<div style={style} className="editor" ref={(id) => { this.ref = id; }} />
</>
);
}
}

Комментарий ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/didiopensource-KnowStreaming.git
git@gitlife.ru:oschina-mirror/didiopensource-KnowStreaming.git
oschina-mirror
didiopensource-KnowStreaming
didiopensource-KnowStreaming
v2.1.0