mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 22:02:55 +01:00
Merge pull request #2112 from KapitanOczywisty/javascriptDefaults
Update example: allow peek definition
This commit is contained in:
commit
45279f68e2
3 changed files with 30 additions and 18 deletions
|
|
@ -816,6 +816,8 @@ function createSimpleServer(rootDir, port) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gulp.task('generate-test-samples', taskSeries(generateTestSamplesTask));
|
||||||
|
|
||||||
gulp.task('simpleserver', taskSeries(generateTestSamplesTask, function() {
|
gulp.task('simpleserver', taskSeries(generateTestSamplesTask, function() {
|
||||||
const SERVER_ROOT = path.normalize(path.join(__dirname, '../'));
|
const SERVER_ROOT = path.normalize(path.join(__dirname, '../'));
|
||||||
createSimpleServer(SERVER_ROOT, 8080);
|
createSimpleServer(SERVER_ROOT, 8080);
|
||||||
|
|
|
||||||
|
|
@ -53,28 +53,33 @@ monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
||||||
});
|
});
|
||||||
|
|
||||||
// extra libraries
|
// extra libraries
|
||||||
monaco.languages.typescript.javascriptDefaults.addExtraLib([
|
var libSource = [
|
||||||
'declare class Facts {',
|
'declare class Facts {',
|
||||||
' /**',
|
' /**',
|
||||||
' * Returns the next fact',
|
' * Returns the next fact',
|
||||||
' */',
|
' */',
|
||||||
' static next():string',
|
' static next():string',
|
||||||
'}',
|
'}',
|
||||||
].join('\n'), 'ts:filename/facts.d.ts');
|
].join('\n');
|
||||||
|
var libUri = 'ts:filename/facts.d.ts';
|
||||||
|
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
|
||||||
|
// When resolving definitions and references, the editor will try to use created models.
|
||||||
|
// Creating a model for the library allows "peek definition/references" commands to work with the library.
|
||||||
|
monaco.editor.createModel(libSource, 'typescript', monaco.Uri.parse(libUri));
|
||||||
|
|
||||||
var jsCode = [
|
var jsCode = [
|
||||||
'"use strict";',
|
'"use strict";',
|
||||||
'',
|
'',
|
||||||
"class Chuck {",
|
'class Chuck {',
|
||||||
" greet() {",
|
' greet() {',
|
||||||
" return Facts.next();",
|
' return Facts.next();',
|
||||||
" }",
|
' }',
|
||||||
"}"
|
'}'
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
|
||||||
monaco.editor.create(document.getElementById("container"), {
|
monaco.editor.create(document.getElementById('container'), {
|
||||||
value: jsCode,
|
value: jsCode,
|
||||||
language: "javascript"
|
language: 'javascript'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,26 +16,31 @@ monaco.languages.typescript.javascriptDefaults.setCompilerOptions({
|
||||||
});
|
});
|
||||||
|
|
||||||
// extra libraries
|
// extra libraries
|
||||||
monaco.languages.typescript.javascriptDefaults.addExtraLib([
|
var libSource = [
|
||||||
'declare class Facts {',
|
'declare class Facts {',
|
||||||
' /**',
|
' /**',
|
||||||
' * Returns the next fact',
|
' * Returns the next fact',
|
||||||
' */',
|
' */',
|
||||||
' static next():string',
|
' static next():string',
|
||||||
'}',
|
'}',
|
||||||
].join('\n'), 'ts:filename/facts.d.ts');
|
].join('\n');
|
||||||
|
var libUri = 'ts:filename/facts.d.ts';
|
||||||
|
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
|
||||||
|
// When resolving definitions and references, the editor will try to use created models.
|
||||||
|
// Creating a model for the library allows "peek definition/references" commands to work with the library.
|
||||||
|
monaco.editor.createModel(libSource, 'typescript', monaco.Uri.parse(libUri));
|
||||||
|
|
||||||
var jsCode = [
|
var jsCode = [
|
||||||
'"use strict";',
|
'"use strict";',
|
||||||
'',
|
'',
|
||||||
"class Chuck {",
|
'class Chuck {',
|
||||||
" greet() {",
|
' greet() {',
|
||||||
" return Facts.next();",
|
' return Facts.next();',
|
||||||
" }",
|
' }',
|
||||||
"}"
|
'}'
|
||||||
].join('\n');
|
].join('\n');
|
||||||
|
|
||||||
monaco.editor.create(document.getElementById("container"), {
|
monaco.editor.create(document.getElementById('container'), {
|
||||||
value: jsCode,
|
value: jsCode,
|
||||||
language: "javascript"
|
language: 'javascript'
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue