mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 15:05:39 +01:00
Load .d.ts in playground
This commit is contained in:
parent
3c8bc9b380
commit
5cee62a7c0
3 changed files with 4846 additions and 21 deletions
|
|
@ -145,6 +145,8 @@ function addPluginDTS() {
|
||||||
|
|
||||||
contents += '\n' + extraContent.join('\n');
|
contents += '\n' + extraContent.join('\n');
|
||||||
data.contents = new Buffer(contents);
|
data.contents = new Buffer(contents);
|
||||||
|
|
||||||
|
fs.writeFileSync('website/playground/samples/editor.d.ts.txt', contents);
|
||||||
this.emit('data', data);
|
this.emit('data', data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1,30 +1,27 @@
|
||||||
|
/// <reference path="../../release/monaco.d.ts" />
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
require(['require', 'vs/editor/editor.main'], function(require) {
|
require(['vs/editor/editor.main'], function() {
|
||||||
|
xhr('playground/samples/editor.d.ts.txt').then(function(response) {
|
||||||
|
monaco.languages.typescript.javascriptDefaults.addExtraLib(response.responseText, 'editor.d.ts');
|
||||||
|
monaco.languages.typescript.javascriptDefaults.addExtraLib([
|
||||||
|
'declare var require: {',
|
||||||
|
' toUrl(path: string): string;',
|
||||||
|
' (moduleName: string): any;',
|
||||||
|
' (dependencies: string[], callback: (...args: any[]) => any, errorback?: (err: any) => void): any;',
|
||||||
|
' config(data: any): any;',
|
||||||
|
' onError: Function;',
|
||||||
|
'};',
|
||||||
|
].join('\n'), 'require.d.ts');
|
||||||
|
|
||||||
// require(['vs/languages/typescript/common/typescript'], function() {
|
var loading = document.getElementById('loading');
|
||||||
// var mode = require('vs/languages/typescript/common/typescript');
|
loading.parentNode.removeChild(loading);
|
||||||
// var winjs = require('vs/base/common/winjs.base');
|
load();
|
||||||
// winjs.xhr({ url: 'playground/samples/editor.d.ts.txt' }).then(function(response) {
|
});
|
||||||
// mode.javaScriptDefaults.addExtraLib(response.responseText, 'editor.d.ts');
|
|
||||||
// mode.javaScriptDefaults.addExtraLib([
|
|
||||||
// 'declare var require: {',
|
|
||||||
// ' toUrl(path: string): string;',
|
|
||||||
// ' (moduleName: string): any;',
|
|
||||||
// ' (dependencies: string[], callback: (...args: any[]) => any, errorback?: (err: any) => void): any;',
|
|
||||||
// ' config(data: any): any;',
|
|
||||||
// ' onError: Function;',
|
|
||||||
// '};',
|
|
||||||
// ].join('\n'), 'require.d.ts');
|
|
||||||
|
|
||||||
var loading = document.getElementById('loading');
|
|
||||||
loading.parentNode.removeChild(loading);
|
|
||||||
load();
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -311,4 +308,33 @@ function doRun(runContainer) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function xhr(url) {
|
||||||
|
var req = null;
|
||||||
|
return new monaco.Promise(function(c,e,p) {
|
||||||
|
req = new XMLHttpRequest();
|
||||||
|
req.onreadystatechange = function () {
|
||||||
|
if (req._canceled) { return; }
|
||||||
|
|
||||||
|
if (req.readyState === 4) {
|
||||||
|
if ((req.status >= 200 && req.status < 300) || req.status === 1223) {
|
||||||
|
c(req);
|
||||||
|
} else {
|
||||||
|
e(req);
|
||||||
|
}
|
||||||
|
req.onreadystatechange = function () { };
|
||||||
|
} else {
|
||||||
|
p(req);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
req.open("GET", url, true );
|
||||||
|
req.responseType = "";
|
||||||
|
|
||||||
|
req.send(null);
|
||||||
|
}, function () {
|
||||||
|
req._canceled = true;
|
||||||
|
req.abort();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
4797
website/playground/samples/editor.d.ts.txt
Normal file
4797
website/playground/samples/editor.d.ts.txt
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue