@wener/ui
Version:
93 lines • 2.86 kB
JavaScript
"use strict";
// import React, { useRef, useState } from 'react';
// import MonacoEditor from 'react-monaco-editor';
// import type MonacoEditorApi from 'monaco-editor/esm/vs/editor/editor.api';
// import 'monaco-editor/min/vs/editor/editor.main.nls.js'
// export default {
// title: 'editors/monaco/demo',
// };
//
// // require.config({ paths: { 'vs': '../node_modules/monaco-editor/min/vs' }});
// // require.config({
// // 'vs/nls' : {
// // availableLanguages: {
// // '*': 'zh-cn'
// // }
// // }
// // });
//
// const DemoMonaco: React.FC = () => {
// const [value, setValue] = useState('{"name":"wener"}');
// const ref = useRef<[MonacoEditorApi.editor.IStandaloneCodeEditor, typeof MonacoEditorApi]>();
// const onEditorMount = (editor: MonacoEditorApi.editor.IStandaloneCodeEditor, monaco: typeof MonacoEditorApi) => {
// ref.current = [editor, monaco];
// editor.focus();
// };
// return (
// <MonacoEditor
// width="800"
// height="600"
// language="json"
// theme="vs-dark"
// value={value}
// options={{}}
// onChange={(v) => setValue(v)}
// editorDidMount={onEditorMount}
// />
// );
// };
//
// export const FirstDemo = () => {
// return <DemoMonaco />;
// };
//
// // class App extends React.Component<any,any> {
// // constructor(props) {
// // super(props);
// // this.state = {
// // code: '// type your code...',
// // }
// // }
// // editorDidMount(editor, monaco) {
// // console.log('editorDidMount', editor);
// // editor.focus();
// // }
// // onChange(newValue, e) {
// // console.log('onChange', newValue, e);
// // }
// // render() {
// // const code = this.state.code;
// // const options = {
// // selectOnLineNumbers: true
// // };
// // return (
// // <MonacoEditor
// // width="800"
// // height="600"
// // language="javascript"
// // theme="vs-dark"
// // value={code}
// // options={options}
// // onChange={::this.onChange}
// // editorDidMount={::this.editorDidMount}
// // />
// // );
// // }
// // }
//
// // override worker in ssr
// /*
// <MonacoEditor
// editorDidMount={() => {
// window.MonacoEnvironment.getWorkerUrl = (_moduleId: string, label: string) => {
// if (label === 'json') return 'static/monaco/json.worker.js';
// if (label === 'css') return 'static/monaco/css.worker.js';
// if (label === 'html') return 'static/monaco/html.worker.js';
// if (label === 'typescript' || label === 'javascript')
// return 'static/monaco/ts.worker.js';
// return 'static/monaco/editor.worker.js';
// };
// }}
// */
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=monaco-demo.stories.js.map