Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
case 'typescript':
case 'javascript':
/* $FlowFixMe */
MonacoWorker = require('worker-loader!monaco-editor/esm/vs/language/typescript/ts.worker');
break;
default:
/* $FlowFixMe */
MonacoWorker = require('worker-loader!monaco-editor/esm/vs/editor/editor.worker');
}
return new MonacoWorker();
},
};
monaco.editor.defineTheme('ayu-light', light);
monaco.editor.defineTheme('ayu-dark', dark);
/**
* Disable typescript's diagnostics for JavaScript files.
* This suppresses errors when using Flow syntax.
* It's also unnecessary since we use ESLint for error checking.
*/
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
noSemanticValidation: true,
noSyntaxValidation: true,
});
/**
* Use prettier to format JavaScript code.
* This will replace the default formatter.
*/
monaco.languages.registerDocumentFormattingEditProvider('javascript', {
break;
case 'typescript':
case 'javascript':
/* $FlowFixMe */
MonacoWorker = require('worker-loader!monaco-editor/esm/vs/language/typescript/ts.worker');
break;
default:
/* $FlowFixMe */
MonacoWorker = require('worker-loader!monaco-editor/esm/vs/editor/editor.worker');
}
return new MonacoWorker();
},
};
monaco.editor.defineTheme('ayu-light', light);
monaco.editor.defineTheme('ayu-dark', dark);
/**
* Disable typescript's diagnostics for JavaScript files.
* This suppresses errors when using Flow syntax.
* It's also unnecessary since we use ESLint for error checking.
*/
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
noSemanticValidation: true,
noSyntaxValidation: true,
});
/**
* Use prettier to format JavaScript code.
* This will replace the default formatter.
*/
break;
case 'typescript':
case 'javascript':
/* $FlowFixMe */
MonacoWorker = require('worker-loader!monaco-editor/esm/vs/language/typescript/ts.worker');
break;
default:
/* $FlowFixMe */
MonacoWorker = require('worker-loader!monaco-editor/esm/vs/editor/editor.worker');
}
return new MonacoWorker();
},
};
monaco.editor.defineTheme('light', light);
monaco.editor.defineTheme('dark', dark);
/**
* Disable typescript's diagnostics for JavaScript files.
* This suppresses errors when using Flow syntax.
* It's also unnecessary since we use ESLint for error checking.
*/
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
noSemanticValidation: true,
noSyntaxValidation: true,
});
/**
* Use prettier to format JavaScript code.
* This will replace the default formatter.
*/
componentDidMount() {
// Spawn a worker to fetch type definitions for dependencies
/* $FlowFixMe */
this._typingsWorker = new TypingsWorker();
this._typingsWorker.addEventListener('message', ({ data }: any) => this._addTypings(data));
const { path, value, annotations, autoFocus, ...rest } = this.props;
this._editor = monaco.editor.create(this._node, rest, {
codeEditorService: {
addCodeEditor: () => {},
removeCodeEditor: () => {},
listCodeEditors: () => [this._editor],
getFocusedCodeEditor: () => this._editor,
registerDecorationType: () => {},
removeDecorationType: () => {},
resolveDecorationOptions: () => {},
setTransientModelProperty: () => {},
getTransientModelProperty: () => {},
getActiveCodeEditor: () => this._editor,
openCodeEditor: async ({ resource, options }, editor) => {
const findModel = (path: string) =>
monaco.editor.getModels().find(model => model.uri.path === `/${path}`);
SimpleEditorModelResolverService.prototype.findModel = function(_: any, resource: any) {
return monaco.editor.getModels().find(model => model.uri.toString() === resource.toString());
};