Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import React from 'react'
import Editor, { monaco } from '@monaco-editor/react'
import { EditorWrapper } from '../../styles/index'
import { inputEditorOptions, outputEditorOptions } from '../../editor'
monaco
.init()
.then(monaco => {
fetch('/solarized-dark.json')
.then(res => res.json())
.then(data => {
monaco.editor.defineTheme('solarized-dark', data)
monaco.editor.setTheme('solarized-dark')
})
})
.catch(error =>
console.error(
'An error occurred during initialization of Monaco: ',
error
)
)
import React from 'react'
import Editor, { monaco } from '@monaco-editor/react'
import { EditorWrapper } from '../../styles/index'
import { inputEditorOptions, outputEditorOptions } from '../../editor'
monaco
.init()
.then(monaco => {
fetch('/solarized-dark.json')
.then(res => res.json())
.then(data => {
monaco.editor.defineTheme('solarized-dark', data)
monaco.editor.setTheme('solarized-dark')
})
})
.catch(error =>
console.error(
'An error occurred during initialization of Monaco: ',
error
)
)
n: [1, 0],
o: [1, 1, 1],
p: [0, 1, 1, 0],
q: [1, 1, 0, 1],
r: [0, 1, 0],
s: [0, 0, 0],
t: [1],
u: [0, 0, 1],
v: [0, 0, 0, 1],
w: [0, 1, 1],
x: [1, 0, 0, 1],
y: [1, 0, 1, 1],
z: [1, 1, 0, 0]
}
monaco
.init()
.then(monaco => {
fetch('/solarized-dark.json')
.then(res => res.json())
.then(data => {
monaco.editor.defineTheme('solarized-dark', data)
monaco.editor.setTheme('solarized-dark')
})
})
.catch(error =>
console.error(
'An error occurred during initialization of Monaco: ',
error
)
)
import React from 'react'
import Editor, { monaco } from '@monaco-editor/react'
import { EditorWrapper } from '../../styles/index'
import { inputEditorOptions, outputEditorOptions } from '../../editor'
monaco
.init()
.then(monaco => {
fetch('/solarized-dark.json')
.then(res => res.json())
.then(data => {
monaco.editor.defineTheme('solarized-dark', data)
monaco.editor.setTheme('solarized-dark')
})
})
.catch(error =>
console.error(
'An error occurred during initialization of Monaco: ',
error
)
)
import React from 'react'
import Editor, { monaco } from '@monaco-editor/react'
import { EditorWrapper } from '../../styles/index'
import { inputEditorOptions, outputEditorOptions } from '../../editor'
monaco
.init()
.then(monaco => {
fetch('/solarized-dark.json')
.then(res => res.json())
.then(data => {
monaco.editor.defineTheme('solarized-dark', data)
monaco.editor.setTheme('solarized-dark')
})
})
.catch(error =>
console.error(
'An error occurred during initialization of Monaco: ',
error
)
)
'10': 'n',
'111': 'o',
'0110': 'p',
'1101': 'q',
'010': 'r',
'000': 's',
'1': 't',
'001': 'u',
'0001': 'v',
'011': 'w',
'1001': 'x',
'1011': 'y',
'1100': 'z'
}
monaco
.init()
.then(monaco => {
fetch('/solarized-dark.json')
.then(res => res.json())
.then(data => {
monaco.editor.defineTheme('solarized-dark', data)
monaco.editor.setTheme('solarized-dark')
})
})
.catch(error =>
console.error(
'An error occurred during initialization of Monaco: ',
error
)
)
import React from 'react'
import Editor, { monaco } from '@monaco-editor/react'
import { EditorWrapper } from '../../styles/index'
import { inputEditorOptions, outputEditorOptions } from '../../editor'
monaco
.init()
.then(monaco => {
fetch('/solarized-dark.json')
.then(res => res.json())
.then(data => {
monaco.editor.defineTheme('solarized-dark', data)
monaco.editor.setTheme('solarized-dark')
})
})
.catch(error =>
console.error(
'An error occurred during initialization of Monaco: ',
error
)
)
React.useEffect(() => {
if (!reactMonaco) {
monaco.init().then(setReactMonaco);
}
}, [reactMonaco]);
const initMonaco = async (value, theme) => {
let model;
if (editorResolved) {
model = (await editor).getModel();
}
freshEditorPromise();
let _monaco;
if (monacoResolved) {
_monaco = await monaco;
} else {
freshMonacoPromise();
try {
_monaco = await monacoReact.init();
resolveMonaco(_monaco);
} catch (err) {
rejectMonaco(err);
rejectEditor(new Error('could not initialize monaco-editor'));
return;
}
}
try {
resolveEditor(_monaco.editor.create(document.getElementById(EDITOR_ID), {
glyphMargin: true,
value,
model
}));
} catch (err) {
rejectEditor(err);
}
import React from 'react';
import PropTypes from 'prop-types';
import FontAwesomeIcon from 'react-fontawesome';
import classNames from 'classnames';
import {SortableContainer, SortableElement} from 'react-sortable-hoc';
import arrayMove from 'array-move';
import {DARK_THEME, LIGHT_THEME} from '../constants';
import {monaco as monacoReact} from '@monaco-editor/react';
monacoReact
.config({
urls: {
monacoLoader: '/vsdir/vsdir/vs/loader.js',
monacoBase: '/vsdir/vsdir/vs'
},
});
const SUPPORTED_LANGUAGES = ['css', 'sol', 'html', 'json'];
const DEFAULT_LANGUAGE = 'javascript';
const EDITOR_ID = 'react-monaco-editor-container';
const GUTTER_GLYPH_MARGIN = 2;
let monacoResolved;
let rejectMonaco;
let resolveMonaco;
let monaco;