Merge remote-tracking branch 'origin/master' into PAPERPANKS-master

pull/577/head
Alex Dima 7 years ago
commit 290dd05367

@ -1,10 +1,13 @@
# Monaco Editor Change log
## [0.10.1] (16.10.2017)
- Fixes [issue #601](https://github.com/Microsoft/monaco-editor/issues/601): window.opener should be set to null to protect against malicious code
## [0.10.0] (17.08.2017)
### Breaking changes
* Removed `CodeAction`.
* Method `provideCodeActions` in `CodeActionProvider` now returns `Command[] | Thenable<Command[]` instead of `CodeAction[] | Thenable<CodeAction[]>`, which is already removed.
* Method `provideCodeActions` in `CodeActionProvider` now returns `Command[] | Thenable<Command[]>` instead of `CodeAction[] | Thenable<CodeAction[]>`, which is already removed.
### API changes
* added `monaco.editor.getModelMarkers`. Get markers for owner and/or resource.

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2017 Microsoft Corporation
Copyright (c) 2018 Microsoft Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

@ -24,7 +24,7 @@ In IE, the editor must be completely surrounded in the body element, otherwise t
## Installing
```
npm install monaco-editor
$ npm install monaco-editor
```
You will get:

@ -1,21 +1,23 @@
var gulp = require('gulp');
var metadata = require('./metadata');
var es = require('event-stream');
var path = require('path');
var fs = require('fs');
var rimraf = require('rimraf');
var cp = require('child_process');
var httpServer = require('http-server');
var typedoc = require("gulp-typedoc");
var CleanCSS = require('clean-css');
var uncss = require('uncss');
var WEBSITE_GENERATED_PATH = path.join(__dirname, 'website/playground/new-samples');
var MONACO_EDITOR_VERSION = (function() {
var packageJsonPath = path.join(__dirname, 'package.json');
var packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString());
var version = packageJson.version;
const gulp = require('gulp');
const metadata = require('./metadata');
const es = require('event-stream');
const path = require('path');
const fs = require('fs');
const rimraf = require('rimraf');
const cp = require('child_process');
const httpServer = require('http-server');
const typedoc = require("gulp-typedoc");
const CleanCSS = require('clean-css');
const uncss = require('uncss');
const File = require('vinyl');
const ts = require('typescript');
const WEBSITE_GENERATED_PATH = path.join(__dirname, 'website/playground/new-samples');
const MONACO_EDITOR_VERSION = (function() {
const packageJsonPath = path.join(__dirname, 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString());
const version = packageJson.version;
if (!/\d+\.\d+\.\d+/.test(version)) {
console.log('unrecognized package.json version: ' + version);
process.exit(0);
@ -33,6 +35,9 @@ gulp.task('release', ['clean-release'], function() {
// min folder
releaseOne('min'),
// esm folder
ESM_release(),
// package.json
gulp.src('package.json')
.pipe(es.through(function(data) {
@ -62,31 +67,51 @@ gulp.task('release', ['clean-release'], function() {
)
});
/**
* Release to `dev` or `min`.
*/
function releaseOne(type) {
return es.merge(
gulp.src('node_modules/monaco-editor-core/' + type + '/**/*')
.pipe(addPluginContribs())
.pipe(addPluginContribs(type))
.pipe(gulp.dest('release/' + type)),
pluginStreams('release/' + type + '/')
pluginStreams(type, 'release/' + type + '/')
)
}
function pluginStreams(destinationPath) {
/**
* Release plugins to `dev` or `min`.
*/
function pluginStreams(type, destinationPath) {
return es.merge(
metadata.METADATA.PLUGINS.map(function(plugin) {
return pluginStream(plugin, destinationPath);
return pluginStream(plugin, type, destinationPath);
})
);
}
function pluginStream(plugin, destinationPath) {
var contribPath = path.join(plugin.paths.npm, plugin.contrib.substr(plugin.modulePrefix.length)) + '.js';
/**
* Release a plugin to `dev` or `min`.
*/
function pluginStream(plugin, type, destinationPath) {
var pluginPath = plugin.paths[`npm/${type}`]; // npm/dev or npm/min
var contribPath = path.join(pluginPath, plugin.contrib.substr(plugin.modulePrefix.length)) + '.js';
return (
gulp.src([
plugin.paths.npm + '/**/*',
'!' + contribPath,
'!' + plugin.paths.npm + '/**/monaco.d.ts'
pluginPath + '/**/*',
'!' + contribPath
])
.pipe(es.through(function(data) {
if (!/_\.contribution/.test(data.path)) {
this.emit('data', data);
return;
}
let contents = data.contents.toString();
contents = contents.replace('define(["require", "exports"],', 'define(["require", "exports", "vs/editor/editor.api"],');
data.contents = new Buffer(contents);
this.emit('data', data);
}))
.pipe(gulp.dest(destinationPath + plugin.modulePrefix))
);
}
@ -94,10 +119,10 @@ function pluginStream(plugin, destinationPath) {
/**
* Edit editor.main.js:
* - rename the AMD module 'vs/editor/editor.main' to 'vs/editor/edcore.main'
* - append contribs from plugins
* - append monaco.contribution modules from plugins
* - append new AMD module 'vs/editor/editor.main' that stiches things together
*/
function addPluginContribs() {
function addPluginContribs(type) {
return es.through(function(data) {
if (!/editor\.main\.js$/.test(data.path)) {
this.emit('data', data);
@ -113,22 +138,53 @@ function addPluginContribs() {
metadata.METADATA.PLUGINS.forEach(function(plugin) {
allPluginsModuleIds.push(plugin.contrib);
var contribPath = path.join(__dirname, plugin.paths.npm, plugin.contrib.substr(plugin.modulePrefix.length)) + '.js';
var pluginPath = plugin.paths[`npm/${type}`]; // npm/dev or npm/min
var contribPath = path.join(__dirname, pluginPath, plugin.contrib.substr(plugin.modulePrefix.length)) + '.js';
var contribContents = fs.readFileSync(contribPath).toString();
// Check for the anonymous define call case 1
// transform define(function() {...}) to define("moduleId",["require"],function() {...})
var anonymousContribDefineCase1 = contribContents.indexOf('define(function');
if (anonymousContribDefineCase1 >= 0) {
contribContents = (
contribContents.substring(0, anonymousContribDefineCase1)
+ `define("${plugin.contrib}",["require"],function`
+ contribContents.substring(anonymousContribDefineCase1 + 'define(function'.length)
);
}
// Check for the anonymous define call case 2
// transform define([ to define("moduleId",[
var anonymousContribDefineCase2 = contribContents.indexOf('define([');
if (anonymousContribDefineCase2 >= 0) {
contribContents = (
contribContents.substring(0, anonymousContribDefineCase2)
+ `define("${plugin.contrib}",[`
+ contribContents.substring(anonymousContribDefineCase2 + 'define(['.length)
);
}
var contribDefineIndex = contribContents.indexOf('define("' + plugin.contrib);
if (contribDefineIndex === -1) {
console.error('(1) CANNOT DETERMINE AMD define location for contribution', plugin);
process.exit(-1);
contribDefineIndex = contribContents.indexOf('define(\'' + plugin.contrib);
if (contribDefineIndex === -1) {
console.error('(1) CANNOT DETERMINE AMD define location for contribution', pluginPath);
process.exit(-1);
}
}
var depsEndIndex = contribContents.indexOf(']', contribDefineIndex);
if (contribDefineIndex === -1) {
console.error('(2) CANNOT DETERMINE AMD define location for contribution', plugin);
console.error('(2) CANNOT DETERMINE AMD define location for contribution', pluginPath);
process.exit(-1);
}
contribContents = contribContents.substring(0, depsEndIndex) + ',"vs/editor/edcore.main"' + contribContents.substring(depsEndIndex);
contribContents = contribContents.substring(0, depsEndIndex) + ',"vs/editor/editor.api"' + contribContents.substring(depsEndIndex);
contribContents = contribContents.replace(
'define("vs/basic-languages/_.contribution",["require","exports"],',
'define("vs/basic-languages/_.contribution",["require","exports","vs/editor/editor.api"],',
);
extraContent.push(contribContents);
});
@ -145,6 +201,181 @@ function addPluginContribs() {
});
}
function ESM_release() {
return es.merge(
gulp.src('node_modules/monaco-editor-core/esm/**/*')
.pipe(ESM_addImportSuffix())
.pipe(ESM_addPluginContribs('release/esm'))
.pipe(gulp.dest('release/esm')),
ESM_pluginStreams('release/esm/')
)
}
/**
* Release plugins to `esm`.
*/
function ESM_pluginStreams(destinationPath) {
return es.merge(
metadata.METADATA.PLUGINS.map(function(plugin) {
return ESM_pluginStream(plugin, destinationPath);
})
);
}
/**
* Release a plugin to `esm`.
* Adds a dependency to 'vs/editor/editor.api' in contrib files in order for `monaco` to be defined.
* Rewrites imports for 'monaco-editor-core/**'
*/
function ESM_pluginStream(plugin, destinationPath) {
const DESTINATION = path.join(__dirname, destinationPath);
let pluginPath = plugin.paths[`esm`];
return (
gulp.src([
pluginPath + '/**/*'
])
.pipe(es.through(function(data) {
if (!/\.js$/.test(data.path)) {
this.emit('data', data);
return;
}
let contents = data.contents.toString();
const info = ts.preProcessFile(contents);
for (let i = info.importedFiles.length - 1; i >= 0; i--) {
const importText = info.importedFiles[i].fileName;
const pos = info.importedFiles[i].pos;
const end = info.importedFiles[i].end;
if (!/(^\.\/)|(^\.\.\/)/.test(importText)) {
// non-relative import
if (!/^monaco-editor-core/.test(importText)) {
console.error(`Non-relative import for unknown module: ${importText} in ${data.path}`);
process.exit(0);
}
const myFileDestPath = path.join(DESTINATION, plugin.modulePrefix, data.relative);
const importFilePath = path.join(DESTINATION, importText.substr('monaco-editor-core/esm/'.length));
let relativePath = path.relative(path.dirname(myFileDestPath), importFilePath);
if (!/(^\.\/)|(^\.\.\/)/.test(relativePath)) {
relativePath = './' + relativePath;
}
contents = (
contents.substring(0, pos + 1)
+ relativePath
+ contents.substring(end + 1)
);
}
}
data.contents = new Buffer(contents);
this.emit('data', data);
}))
.pipe(es.through(function(data) {
if (!/monaco\.contribution\.js$/.test(data.path)) {
this.emit('data', data);
return;
}
const myFileDestPath = path.join(DESTINATION, plugin.modulePrefix, data.relative);
const apiFilePath = path.join(DESTINATION, 'vs/editor/editor.api');
let relativePath = path.relative(path.dirname(myFileDestPath), apiFilePath);
if (!/(^\.\/)|(^\.\.\/)/.test(relativePath)) {
relativePath = './' + relativePath;
}
let contents = data.contents.toString();
contents = (
`import '${relativePath}';\n` +
contents
);
data.contents = new Buffer(contents);
this.emit('data', data);
}))
.pipe(ESM_addImportSuffix())
.pipe(gulp.dest(destinationPath + plugin.modulePrefix))
);
}
function ESM_addImportSuffix() {
return es.through(function(data) {
if (!/\.js$/.test(data.path)) {
this.emit('data', data);
return;
}
let contents = data.contents.toString();
const info = ts.preProcessFile(contents);
for (let i = info.importedFiles.length - 1; i >= 0; i--) {
const importText = info.importedFiles[i].fileName;
const pos = info.importedFiles[i].pos;
const end = info.importedFiles[i].end;
if (/\.css$/.test(importText)) {
continue;
}
contents = (
contents.substring(0, pos + 1)
+ importText + '.js'
+ contents.substring(end + 1)
);
}
data.contents = new Buffer(contents);
this.emit('data', data);
});
}
/**
* - Rename esm/vs/editor/editor.main.js to esm/vs/editor/edcore.main.js
* - Create esm/vs/editor/editor.main.js that that stiches things together
*/
function ESM_addPluginContribs(dest) {
const DESTINATION = path.join(__dirname, dest);
return es.through(function(data) {
if (!/editor\.main\.js$/.test(data.path)) {
this.emit('data', data);
return;
}
this.emit('data', new File({
path: data.path.replace(/editor\.main/, 'edcore.main'),
base: data.base,
contents: data.contents
}));
const mainFileDestPath = path.join(DESTINATION, 'vs/editor/editor.main.js');
let mainFileImports = [];
metadata.METADATA.PLUGINS.forEach(function(plugin) {
const contribDestPath = path.join(DESTINATION, plugin.contrib);
let relativePath = path.relative(path.dirname(mainFileDestPath), contribDestPath);
if (!/(^\.\/)|(^\.\.\/)/.test(relativePath)) {
relativePath = './' + relativePath;
}
mainFileImports.push(relativePath);
});
let mainFileContents = (
mainFileImports.map((name) => `import '${name}';`).join('\n')
+ `\n\nexport * from './edcore.main';`
);
this.emit('data', new File({
path: data.path,
base: data.base,
contents: new Buffer(mainFileContents)
}));
});
}
/**
* Edit monaco.d.ts:
* - append monaco.d.ts from plugins
@ -159,7 +390,8 @@ function addPluginDTS() {
var extraContent = [];
metadata.METADATA.PLUGINS.forEach(function(plugin) {
var dtsPath = path.join(plugin.paths.npm, 'monaco.d.ts');
var pluginPath = plugin.paths[`npm/min`]; // npm/dev or npm/min
var dtsPath = path.join(pluginPath, '../monaco.d.ts');
try {
extraContent.push(fs.readFileSync(dtsPath).toString());
} catch (err) {

@ -1,60 +1,76 @@
(function() {
(function () {
var METADATA = {
CORE: {
paths: {
npm: 'node_modules/monaco-editor-core/min/vs',
// npm: 'node_modules/monaco-editor-core/dev/vs',
dev: '/vscode/out/vs',
src: '/vscode/out/vs',
'npm/dev': 'node_modules/monaco-editor-core/dev/vs',
'npm/min': 'node_modules/monaco-editor-core/min/vs',
built: '/vscode/out-monaco-editor-core/min/vs',
releaseDev: 'release/dev/vs',
releaseMin: 'release/min/vs',
}
},
PLUGINS: [{
name: 'monaco-typescript',
contrib: 'vs/language/typescript/src/monaco.contribution',
modulePrefix: 'vs/language/typescript',
thirdPartyNotices: 'node_modules/monaco-typescript/ThirdPartyNotices.txt',
paths: {
npm: 'node_modules/monaco-typescript/release',
dev: '/monaco-typescript/out'
}
},{
name: 'monaco-css',
contrib: 'vs/language/css/monaco.contribution',
modulePrefix: 'vs/language/css',
paths: {
npm: 'node_modules/monaco-css/release/min',
dev: '/monaco-css/release/dev'
}
},{
name: 'monaco-json',
contrib: 'vs/language/json/monaco.contribution',
modulePrefix: 'vs/language/json',
paths: {
npm: 'node_modules/monaco-json/release/min',
dev: '/monaco-json/release/dev'
}
},{
name: 'monaco-html',
contrib: 'vs/language/html/monaco.contribution',
modulePrefix: 'vs/language/html',
thirdPartyNotices: 'node_modules/monaco-html/ThirdPartyNotices.txt',
paths: {
npm: 'node_modules/monaco-html/release/min',
dev: '/monaco-html/release/dev'
}
},{
name: 'monaco-languages',
contrib: 'vs/basic-languages/src/monaco.contribution',
modulePrefix: 'vs/basic-languages',
thirdPartyNotices: 'node_modules/monaco-languages/ThirdPartyNotices.txt',
paths: {
npm: 'node_modules/monaco-languages/release',
dev: '/monaco-languages/out'
PLUGINS: [
{
name: 'monaco-typescript',
contrib: 'vs/language/typescript/monaco.contribution',
modulePrefix: 'vs/language/typescript',
thirdPartyNotices: 'node_modules/monaco-typescript/ThirdPartyNotices.txt',
paths: {
src: '/monaco-typescript/release/dev',
'npm/dev': 'node_modules/monaco-typescript/release/dev',
'npm/min': 'node_modules/monaco-typescript/release/min',
esm: 'node_modules/monaco-typescript/release/esm',
}
},
{
name: 'monaco-css',
contrib: 'vs/language/css/monaco.contribution',
modulePrefix: 'vs/language/css',
paths: {
src: '/monaco-css/release/dev',
'npm/dev': 'node_modules/monaco-css/release/dev',
'npm/min': 'node_modules/monaco-css/release/min',
esm: 'node_modules/monaco-css/release/esm',
}
},
{
name: 'monaco-json',
contrib: 'vs/language/json/monaco.contribution',
modulePrefix: 'vs/language/json',
paths: {
src: '/monaco-json/release/dev',
'npm/dev': 'node_modules/monaco-json/release/dev',
'npm/min': 'node_modules/monaco-json/release/min',
esm: 'node_modules/monaco-json/release/esm',
}
},
{
name: 'monaco-html',
contrib: 'vs/language/html/monaco.contribution',
modulePrefix: 'vs/language/html',
thirdPartyNotices: 'node_modules/monaco-html/ThirdPartyNotices.txt',
paths: {
src: '/monaco-html/release/dev',
'npm/dev': 'node_modules/monaco-html/release/dev',
'npm/min': 'node_modules/monaco-html/release/min',
esm: 'node_modules/monaco-html/release/esm',
}
},
{
name: 'monaco-languages',
contrib: 'vs/basic-languages/monaco.contribution',
modulePrefix: 'vs/basic-languages',
thirdPartyNotices: 'node_modules/monaco-languages/ThirdPartyNotices.txt',
paths: {
src: '/monaco-languages/release/dev',
'npm/dev': 'node_modules/monaco-languages/release/dev',
'npm/min': 'node_modules/monaco-languages/release/min',
esm: 'node_modules/monaco-languages/release/esm',
}
}
}]
]
}
if (typeof exports !== 'undefined') {

1484
monaco.d.ts vendored

File diff suppressed because it is too large Load Diff

4296
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,7 +1,7 @@
{
"name": "monaco-editor",
"private": true,
"version": "0.10.0",
"version": "0.10.1",
"description": "A browser based code editor",
"author": "Microsoft Corporation",
"license": "MIT",
@ -11,6 +11,7 @@
"website": "gulp website"
},
"typings": "./monaco.d.ts",
"module": "./esm/vs/editor/editor.main.js",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/monaco-editor"
@ -20,15 +21,17 @@
"event-stream": "^3.3.2",
"gulp": "^3.9.1",
"gulp-typedoc": "^2.0.0",
"http-server": "^0.9.0",
"monaco-css": "1.3.3",
"monaco-editor-core": "0.10.0",
"monaco-html": "1.3.2",
"monaco-json": "1.3.2",
"monaco-languages": "0.9.0",
"monaco-typescript": "2.3.0",
"http-server": "^0.11.1",
"monaco-css": "2.0.1",
"monaco-editor-core": "0.11.3",
"monaco-html": "2.0.2",
"monaco-json": "2.0.1",
"monaco-languages": "1.0.2",
"monaco-typescript": "3.0.0",
"rimraf": "^2.5.2",
"typedoc": "^0.8.0",
"uncss": "^0.14.1"
"typescript": "^2.7.2",
"uncss": "^0.14.1",
"vinyl": "^0.5.3"
}
}

@ -30,9 +30,9 @@
}
var overwrites = parseQueryString();
var result = {};
result['editor'] = overwrites['editor'] || 'npm';
result['editor'] = overwrites['editor'] || 'npm/dev';
METADATA.PLUGINS.map(function(plugin) {
result[plugin.name] = overwrites[plugin.name] || 'npm';
result[plugin.name] = overwrites[plugin.name] || 'npm/dev';
});
return result;
})();
@ -57,7 +57,7 @@
};
Component.prototype.getResolvedPath = function() {
var resolvedPath = this.paths[this.selectedPath];
if (this.selectedPath === 'npm' || this.isRelease()) {
if (this.selectedPath === 'npm/dev' || this.selectedPath === 'npm/min' || this.isRelease()) {
if (IS_FILE_PROTOCOL) {
resolvedPath = DIRNAME + '/../' + resolvedPath;
} else {
@ -76,9 +76,9 @@
Component.prototype.generateUrlForPath = function(pathName) {
var NEW_LOADER_OPTS = {};
Object.keys(LOADER_OPTS).forEach(function(key) {
NEW_LOADER_OPTS[key] = (LOADER_OPTS[key] === 'npm' ? undefined : LOADER_OPTS[key]);
NEW_LOADER_OPTS[key] = (LOADER_OPTS[key] === 'npm/dev' ? undefined : LOADER_OPTS[key]);
});
NEW_LOADER_OPTS[this.name] = (pathName === 'npm' ? undefined : pathName);
NEW_LOADER_OPTS[this.name] = (pathName === 'npm/dev' ? undefined : pathName);
var search = Object.keys(NEW_LOADER_OPTS).map(function(key) {
var value = NEW_LOADER_OPTS[key];

@ -74,6 +74,7 @@ window.setTimeout(function () {
if (location.hash) {
START_SAMPLE = location.hash.replace(/^\#/, '');
START_SAMPLE = decodeURIComponent(START_SAMPLE);
}
samplesData[START_SAMPLE]();

@ -44,7 +44,7 @@ var editor = monaco.editor.create(document.getElementById("container"), {
value: "// First line\nfunction hello() {\n\talert('Hello world!');\n}\n// Last line",
language: "javascript",
lineNumbers: false,
lineNumbers: "off",
roundedSelection: false,
scrollBeyondLastLine: false,
readOnly: false,
@ -52,7 +52,7 @@ var editor = monaco.editor.create(document.getElementById("container"), {
});
setTimeout(function() {
editor.updateOptions({
lineNumbers: true
lineNumbers: "on"
});
}, 2000);

@ -38,9 +38,13 @@ loadEditor(function() {
// Configures two JSON schemas, with references.
var id = "foo.json";
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
validate: true,
schemas: [{
uri: "http://myserver/foo-schema.json",
fileMatch: [id],
schema: {
type: "object",
properties: {
@ -54,6 +58,7 @@ monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
}
},{
uri: "http://myserver/bar-schema.json",
fileMatch: [id],
schema: {
type: "object",
properties: {
@ -68,15 +73,18 @@ monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
var jsonCode = [
'{',
' "$schema": "http://myserver/foo-schema.json"',
' "p1": "v3",',
' "p2": false',
"}"
].join('\n');
var model = monaco.editor.createModel(jsonCode, "json", id);
monaco.editor.create(document.getElementById("container"), {
value: jsonCode,
language: "json"
model: model
});
/*----------------------------------------SAMPLE CSS END*/
});
</script>

@ -154,7 +154,7 @@
<img src="https://opensource.microsoft.com/img/microsoft.png" alt="Microsoft" style="max-height:23px;margin-bottom:12px;">
</a>
<br/>
<small>&copy; 2017 Microsoft</small>
<small>&copy; 2018 Microsoft</small>
</p>
</footer>

@ -4291,7 +4291,7 @@ return {
<footer class="container">
<hr>
<p class="text-center">
<small>&copy; 2017 Microsoft</small>
<small>&copy; 2018 Microsoft</small>
</p>
</footer>

@ -67,7 +67,7 @@
<footer class="container">
<hr>
<p class="text-center">
<small>&copy; 2017 Microsoft</small>
<small>&copy; 2018 Microsoft</small>
</p>
</footer>

File diff suppressed because it is too large Load Diff

@ -6,7 +6,7 @@ var editor = monaco.editor.create(document.getElementById("container"), {
value: "// First line\nfunction hello() {\n\talert('Hello world!');\n}\n// Last line",
language: "javascript",
lineNumbers: false,
lineNumbers: "off",
roundedSelection: false,
scrollBeyondLastLine: false,
readOnly: false,
@ -14,6 +14,6 @@ var editor = monaco.editor.create(document.getElementById("container"), {
});
setTimeout(function() {
editor.updateOptions({
lineNumbers: true
lineNumbers: "on"
});
}, 2000);

@ -28,7 +28,8 @@ monaco.languages.registerCompletionItemProvider('json', {
provideCompletionItems: function(model, position) {
// find out if we are completing a property in the 'dependencies' object.
var textUntilPosition = model.getValueInRange({startLineNumber: 1, startColumn: 1, endLineNumber: position.lineNumber, endColumn: position.column});
var match = textUntilPosition.match(/"dependencies"\s*:\s*{\s*("[^"]*"\s*:\s*"[^"]*"\s*,\s*)*("[^"]*)?$/); if (match) {
var match = textUntilPosition.match(/"dependencies"\s*:\s*{\s*("[^"]*"\s*:\s*"[^"]*"\s*,\s*)*("[^"]*)?$/);
if (match) {
return createDependencyProposals();
}
return [];

@ -1,8 +1,12 @@
// Configures two JSON schemas, with references.
var id = "foo.json";
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
validate: true,
schemas: [{
uri: "http://myserver/foo-schema.json",
fileMatch: [id],
schema: {
type: "object",
properties: {
@ -16,6 +20,7 @@ monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
}
},{
uri: "http://myserver/bar-schema.json",
fileMatch: [id],
schema: {
type: "object",
properties: {
@ -30,11 +35,13 @@ monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
var jsonCode = [
'{',
' "$schema": "http://myserver/foo-schema.json"',
' "p1": "v3",',
' "p2": false',
"}"
].join('\n');
var model = monaco.editor.createModel(jsonCode, "json", id);
monaco.editor.create(document.getElementById("container"), {
value: jsonCode,
language: "json"
});
model: model
});

Loading…
Cancel
Save