mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-09 16:06:21 +02:00
make monaco stylesheet insert just once
This commit is contained in:
@ -181,7 +181,9 @@ export default class CodeEditor extends Component {
|
||||
|
||||
async loadDeps() {
|
||||
if (this.props.type === 'monaco' && !isMonacoDepsLoaded) {
|
||||
loadCss('lib/monaco/monaco.css');
|
||||
if (!$('#monaco-css')) {
|
||||
loadCss({ url: 'lib/monaco/monaco.css', id: 'monaco-css' });
|
||||
}
|
||||
return import(/* webpackChunkName: "monaco" */ '../lib/monaco/monaco.bundle.js').then(
|
||||
() => {
|
||||
isMonacoDepsLoaded = true;
|
||||
|
@ -305,11 +305,14 @@ export function loadJS(src) {
|
||||
return d.promise;
|
||||
}
|
||||
|
||||
export function loadCss(src) {
|
||||
export function loadCss({ url, id }) {
|
||||
var d = deferred();
|
||||
var style = window.document.createElement('link');
|
||||
style.setAttribute('href', src);
|
||||
style.setAttribute('href', url);
|
||||
style.setAttribute('rel', 'stylesheet');
|
||||
if (id) {
|
||||
style.setAttribute('id', id);
|
||||
}
|
||||
document.head.appendChild(style);
|
||||
style.onload = function() {
|
||||
d.resolve();
|
||||
|
Reference in New Issue
Block a user