Adopt core & plugins for 0.5.0

This commit is contained in:
Alex Dima 2016-06-24 21:17:11 +02:00
parent e61cf2c079
commit 18f953b747
10 changed files with 161 additions and 155 deletions

16
CHANGELOG.md Normal file
View file

@ -0,0 +1,16 @@
# Monaco Editor Change log
## [0.5.0]
### Breaking changes
- `monaco.editor.createWebWorker` now loads the AMD module and calls `create` and passes in as first argument a context of type `monaco.worker.IWorkerContext` and as second argument the `initData`. This breaking change was needed to allow handling the case of misconfigured web workers (running on a file protocol or the cross-domain case)
- the `CodeActionProvider.provideCodeActions` now gets passed in a `CodeActionContext` that contains the markers at the relevant range.
- the `hoverMessage` of a decoration is now a `MarkedString | MarkedString[]`
- the `contents` of a `Hover` returned by a `HoverProvider` is now a `MarkedString | MarkedString[]`
- removed deprecated `IEditor.onDidChangeModelRawContent`, `IModel.onDidChangeRawContent`
### Notable fixes
- Broken configurations (loading from `file://` or misconfigured cross-domain loading) now load the web worker code in the UI thread. This caused a breaking change in the behaviour of `monaco.editor.createWebWorker`
- The right-pointing mouse pointer is oversized in high DPI - [issue](https://github.com/Microsoft/monaco-editor/issues/5)
- The editor functions now correctly when hosted inside a `position:fixed` element.
- Cross origin configuration is now picked up (as advertised in documentation from MonacoEnvironment)

View file

@ -9,9 +9,10 @@ The Monaco Editor is the code editor that powers [VS Code](https://github.com/Mi
Please mention the version of the editor when creating issues and the browser you're having trouble in. Please mention the version of the editor when creating issues and the browser you're having trouble in.
This repository contains only the scripts to glue things together, please create issues against the actual repositories where the source code lives: This repository contains only the scripts to glue things together, please create issues against the actual repositories where the source code lives:
* monaco-editor-core: [Issues](https://github.com/Microsoft/vscode) -- [npm module](https://www.npmjs.com/package/monaco-editor-core) (Issues with the editor itself) * [monaco-editor-core](https://github.com/Microsoft/vscode) -- (the editor itself)
* monaco-typescript: [Issues](https://github.com/Microsoft/monaco-typescript) -- [npm module](https://www.npmjs.com/package/monaco-typescript) (Issues with JavaScript or TypeScript language support) * [monaco-typescript](https://github.com/Microsoft/monaco-typescript) -- (JavaScript or TypeScript language support)
* monaco-languages: [Issues](https://github.com/Microsoft/monaco-languages) -- [npm module](https://www.npmjs.com/package/monaco-languages) (Issues with bat, coffee script, cpp, csharp, fsharp, go, ini, jade, lua, objective-c, powershell, python, r, ruby, sql, swift, vb or xml) * [monaco-css](https://github.com/Microsoft/monaco-css) -- (CSS, LESS or SCSS advanced language support)
* [monaco-languages](https://github.com/Microsoft/monaco-languages) -- (bat, coffee script, cpp, csharp, fsharp, go, ini, jade, lua, objective-c, powershell, python, r, ruby, sql, swift, vb or xml colorizers)
## Known issues ## Known issues
In IE, the editor must be completely surrounded in the body element, otherwise the hit testing we do for mouse operations does not work. You can inspect this using F12 and clicking on the body element and confirm that visually it surrounds the editor. In IE, the editor must be completely surrounded in the body element, otherwise the hit testing we do for mouse operations does not work. You can inspect this using F12 and clicking on the body element and confirm that visually it surrounds the editor.
@ -152,16 +153,14 @@ Create a Monarch tokenizer [here](https://microsoft.github.io/monaco-editor/mona
* clone https://github.com/Microsoft/vscode in `$/src/vscode/` (next to this repo) * clone https://github.com/Microsoft/vscode in `$/src/vscode/` (next to this repo)
* run `$/src/vscode> gulp watch` * run `$/src/vscode> gulp watch`
* run `$/src/monaco-editor> npm run simpleserver` * run `$/src/monaco-editor> npm run simpleserver`
* edit `$/src/monaco-editor/test/index.html` and set `var RUN_EDITOR_FROM_SOURCE = true;` * open http://localhost:8080/monaco-editor/test/?editor=dev
* open http://localhost:8080/monaco-editor/test/
### Running a plugin (e.g. monaco-typescript) from source ### Running a plugin (e.g. monaco-typescript) from source
* clone https://github.com/Microsoft/monaco-typescript in `$/src/monaco-typescript` (next to this repo) * clone https://github.com/Microsoft/monaco-typescript in `$/src/monaco-typescript` (next to this repo)
* run `$/src/monaco-typescript> npm run watch` * run `$/src/monaco-typescript> npm run watch`
* run `$/src/monaco-editor> npm run simpleserver` * run `$/src/monaco-editor> npm run simpleserver`
* edit `$/src/monaco-editor/test/index.html` and set `RUN_PLUGINS_FROM_SOURCE['monaco-typescript'] = true;` * open http://localhost:8080/monaco-editor/test/?editor=dev&monaco-typescript=dev
* open http://localhost:8080/monaco-editor/test/
--- ---
@ -177,11 +176,13 @@ Create a Monarch tokenizer [here](https://microsoft.github.io/monaco-editor/mona
#### Adopt new `monaco-editor-core` in plugins (if necessary) #### Adopt new `monaco-editor-core` in plugins (if necessary)
* https://github.com/Microsoft/monaco-typescript * https://github.com/Microsoft/monaco-typescript
* https://github.com/Microsoft/monaco-languages * https://github.com/Microsoft/monaco-languages
* https://github.com/Microsoft/monaco-css
#### Adopt new `monaco-editor-core` #### Adopt new `monaco-editor-core`
* edit `$/src/monaco-editor/package.json` and update the version for (as necessary): * edit `$/src/monaco-editor/package.json` and update the version for (as necessary):
* `monaco-editor-core` * `monaco-editor-core`
* `monaco-typescript` * `monaco-typescript`
* `monaco-css`
* `monaco-languages` * `monaco-languages`
* update the version in `$/src/monaco-editor/package.json` * update the version in `$/src/monaco-editor/package.json`
* I try to keep it similar to `monaco-editor-core`, maybe just vary the patch version. * I try to keep it similar to `monaco-editor-core`, maybe just vary the patch version.

View file

@ -37,10 +37,20 @@ gulp.task('release', ['clean-release'], function() {
// other files // other files
gulp.src([ gulp.src([
'node_modules/monaco-editor-core/LICENSE', 'node_modules/monaco-editor-core/LICENSE',
'node_modules/monaco-editor-core/CHANGELOG.md',
'node_modules/monaco-editor-core/monaco.d.ts', 'node_modules/monaco-editor-core/monaco.d.ts',
'node_modules/monaco-editor-core/ThirdPartyNotices.txt', 'node_modules/monaco-editor-core/ThirdPartyNotices.txt',
'README.md' 'README.md'
]).pipe(addPluginDTS()).pipe(gulp.dest('release')) ])
.pipe(es.through(function(data) {
if (/CHANGELOG\.md$/.test(data.path)) {
fs.writeFileSync('CHANGELOG.md', data.contents);
}
this.emit('data', data);
}))
.pipe(addPluginDTS())
.pipe(addPluginThirdPartyNotices())
.pipe(gulp.dest('release'))
) )
}); });
@ -66,7 +76,8 @@ function pluginStream(plugin, destinationPath) {
return ( return (
gulp.src([ gulp.src([
plugin.path + '/**/*', plugin.path + '/**/*',
'!' + contribPath '!' + contribPath,
'!' + plugin.path + '/**/monaco.d.ts'
]) ])
.pipe(gulp.dest(destinationPath + plugin.modulePrefix)) .pipe(gulp.dest(destinationPath + plugin.modulePrefix))
); );
@ -156,6 +167,37 @@ function addPluginDTS() {
}); });
} }
/**
* Edit ThirdPartyNotices.txt:
* - append ThirdPartyNotices.txt from plugins
*/
function addPluginThirdPartyNotices() {
return es.through(function(data) {
if (!/ThirdPartyNotices\.txt$/.test(data.path)) {
this.emit('data', data);
return;
}
var contents = data.contents.toString();
var extraContent = [];
metadata.METADATA.PLUGINS.forEach(function(plugin) {
var thirdPartyNoticePath = path.join(path.dirname(plugin.path), 'ThirdPartyNotices.txt');
try {
var thirdPartyNoticeContent = fs.readFileSync(thirdPartyNoticePath).toString();
thirdPartyNoticeContent = thirdPartyNoticeContent.split('\n').slice(8).join('\n');
extraContent.push(thirdPartyNoticeContent);
} catch (err) {
return;
}
});
contents += '\n' + extraContent.join('\n');
data.contents = new Buffer(contents);
this.emit('data', data);
});
}
// --- website // --- website
@ -276,7 +318,7 @@ gulp.task('playground-samples', ['clean-playground-samples'], function() {
sampleId: sampleId sampleId: sampleId
}); });
var content = var content =
`// This is a generated file. Please do not edit directly. `// This is a generated file. Please do not edit directly.
var SAMPLES = this.SAMPLES || []; var SAMPLES = this.SAMPLES || [];
SAMPLES.push(${JSON.stringify(sampleOut)}); SAMPLES.push(${JSON.stringify(sampleOut)});

View file

@ -18,10 +18,10 @@
"event-stream": "^3.3.2", "event-stream": "^3.3.2",
"gulp": "^3.9.1", "gulp": "^3.9.1",
"http-server": "^0.9.0", "http-server": "^0.9.0",
"monaco-editor-core": "0.4.2", "monaco-editor-core": "0.5.1",
"monaco-languages": "0.2.1", "monaco-languages": "0.3.0",
"monaco-typescript": "0.2.1", "monaco-typescript": "0.5.0",
"monaco-css": "1.0.0", "monaco-css": "1.1.0",
"rimraf": "^2.5.2" "rimraf": "^2.5.2"
} }
} }

View file

@ -19,7 +19,7 @@
loadEditor(function() { loadEditor(function() {
monaco.editor.create(document.getElementById('container'), { monaco.editor.create(document.getElementById('container'), {
value: document.documentElement.innerHTML, value: document.documentElement.innerHTML,
language: 'xml' language: 'css'
}); });
}, 'http://localhost:8088'); }, 'http://localhost:8088');
</script> </script>

View file

@ -15,7 +15,7 @@
<script src="../metadata.js"></script> <script src="../metadata.js"></script>
<script src="dev-setup.js"></script> <script src="dev-setup.js"></script>
<script> <script>
window.GlobalEnvironment = { window.MonacoEnvironment = {
getWorkerUrl: function() { getWorkerUrl: function() {
return loadDevEditor() ? 'cross-origin-worker-proxy-dev.js' : 'cross-origin-worker-proxy.js'; return loadDevEditor() ? 'cross-origin-worker-proxy-dev.js' : 'cross-origin-worker-proxy.js';
} }
@ -26,7 +26,7 @@
loadEditor(function() { loadEditor(function() {
monaco.editor.create(document.getElementById('container'), { monaco.editor.create(document.getElementById('container'), {
value: document.documentElement.innerHTML, value: document.documentElement.innerHTML,
language: 'xml' language: 'css'
}); });
}, 'http://localhost:8088'); }, 'http://localhost:8088');
</script> </script>

View file

@ -1,4 +1,4 @@
self.GlobalEnvironment = { self.MonacoEnvironment = {
baseUrl: 'http://localhost:8088/vscode/out/' baseUrl: 'http://localhost:8088/vscode/out/'
}; };
importScripts('http://localhost:8088/vscode/out/vs/base/worker/workerMain.js'); importScripts('http://localhost:8088/vscode/out/vs/base/worker/workerMain.js');

View file

@ -1,4 +1,4 @@
self.GlobalEnvironment = { self.MonacoEnvironment = {
baseUrl: 'http://localhost:8088/monaco-editor/node_modules/monaco-editor-core/min/' baseUrl: 'http://localhost:8088/monaco-editor/node_modules/monaco-editor-core/min/'
}; };
importScripts('http://localhost:8088/monaco-editor/node_modules/monaco-editor-core/min/vs/base/worker/workerMain.js'); importScripts('http://localhost:8088/monaco-editor/node_modules/monaco-editor-core/min/vs/base/worker/workerMain.js');

1
website/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
node_modules/monaco-editor/dev

View file

@ -347,37 +347,24 @@ declare module monaco {
static WinCtrl: number; static WinCtrl: number;
static chord(firstPart: number, secondPart: number): number; static chord(firstPart: number, secondPart: number): number;
} }
export interface IHTMLContentElementCode { /**
* MarkedString can be used to render human readable text. It is either a markdown string
* or a code-block that provides a language and a code snippet. Note that
* markdown strings will be sanitized - that means html will be escaped.
*/
export type MarkedString = string | {
language: string; language: string;
value: string; value: string;
} };
export interface IHTMLContentElement {
/**
* supports **bold**, __italics__, and [[actions]]
*/
formattedText?: string;
text?: string;
className?: string;
style?: string;
customStyle?: any;
tagName?: string;
children?: IHTMLContentElement[];
isText?: boolean;
role?: string;
markdown?: string;
code?: IHTMLContentElementCode;
}
export interface IKeyboardEvent { export interface IKeyboardEvent {
browserEvent: Event; browserEvent: KeyboardEvent;
target: HTMLElement; target: HTMLElement;
ctrlKey: boolean; ctrlKey: boolean;
shiftKey: boolean; shiftKey: boolean;
altKey: boolean; altKey: boolean;
metaKey: boolean; metaKey: boolean;
keyCode: KeyCode; keyCode: KeyCode;
clone(): IKeyboardEvent;
asKeybinding(): number; asKeybinding(): number;
equals(keybinding: number): boolean; equals(keybinding: number): boolean;
preventDefault(): void; preventDefault(): void;
@ -1499,13 +1486,9 @@ declare module monaco.editor {
*/ */
className?: string; className?: string;
/** /**
* Message to be rendered when hovering over the decoration. * Array of MarkedString to render as the decoration message.
*/ */
hoverMessage?: string; hoverMessage?: MarkedString | MarkedString[];
/**
* Array of IHTMLContentElements to render as the decoration message.
*/
htmlMessage?: IHTMLContentElement[];
/** /**
* Should the decoration expand to encompass a whole line. * Should the decoration expand to encompass a whole line.
*/ */
@ -2115,11 +2098,6 @@ declare module monaco.editor {
* A model. * A model.
*/ */
export interface IModel extends IReadOnlyModel, IEditableTextModel, ITextModelWithMarkers, ITokenizedModel, ITextModelWithTrackedRanges, ITextModelWithDecorations, IEditorModel { export interface IModel extends IReadOnlyModel, IEditableTextModel, ITextModelWithMarkers, ITokenizedModel, ITextModelWithTrackedRanges, ITextModelWithDecorations, IEditorModel {
/**
* @deprecated Please use `onDidChangeContent` instead.
* An event emitted when the contents of the model have changed.
*/
onDidChangeRawContent(listener: (e: IModelContentChangedEvent) => void): IDisposable;
/** /**
* An event emitted when the contents of the model have changed. * An event emitted when the contents of the model have changed.
*/ */
@ -2241,32 +2219,6 @@ declare module monaco.editor {
isRedoing: boolean; isRedoing: boolean;
} }
/**
* An event describing a change in the text of a model.
*/
export interface IModelContentChangedEvent {
/**
* The event type. It can be used to detect the actual event type:
* EditorCommon.EventType.ModelContentChangedFlush => IModelContentChangedFlushEvent
* EditorCommon.EventType.ModelContentChangedLinesDeleted => IModelContentChangedLineChangedEvent
* EditorCommon.EventType.ModelContentChangedLinesInserted => IModelContentChangedLinesDeletedEvent
* EditorCommon.EventType.ModelContentChangedLineChanged => IModelContentChangedLinesInsertedEvent
*/
changeType: string;
/**
* The new version id the model has transitioned to.
*/
versionId: number;
/**
* Flag that indicates that this event was generated while undoing.
*/
isUndoing: boolean;
/**
* Flag that indicates that this event was generated while redoing.
*/
isRedoing: boolean;
}
/** /**
* The raw text backing a model. * The raw text backing a model.
*/ */
@ -2293,62 +2245,6 @@ declare module monaco.editor {
options: ITextModelResolvedOptions; options: ITextModelResolvedOptions;
} }
/**
* An event describing that a model has been reset to a new value.
*/
export interface IModelContentChangedFlushEvent extends IModelContentChangedEvent {
/**
* The new text content of the model.
*/
detail: IRawText;
}
/**
* An event describing that a line has changed in a model.
*/
export interface IModelContentChangedLineChangedEvent extends IModelContentChangedEvent {
/**
* The line that has changed.
*/
lineNumber: number;
/**
* The new value of the line.
*/
detail: string;
}
/**
* An event describing that line(s) have been deleted in a model.
*/
export interface IModelContentChangedLinesDeletedEvent extends IModelContentChangedEvent {
/**
* At what line the deletion began (inclusive).
*/
fromLineNumber: number;
/**
* At what line the deletion stopped (inclusive).
*/
toLineNumber: number;
}
/**
* An event describing that line(s) have been inserted in a model.
*/
export interface IModelContentChangedLinesInsertedEvent extends IModelContentChangedEvent {
/**
* Before what line did the insertion begin
*/
fromLineNumber: number;
/**
* `toLineNumber` - `fromLineNumber` + 1 denotes the number of lines that were inserted
*/
toLineNumber: number;
/**
* The text that was inserted
*/
detail: string;
}
/** /**
* Decoration data associated with a model decorations changed event. * Decoration data associated with a model decorations changed event.
*/ */
@ -2915,11 +2811,6 @@ declare module monaco.editor {
* An editor. * An editor.
*/ */
export interface IEditor { export interface IEditor {
/**
* @deprecated. Please use `onDidChangeModelContent` instead.
* An event emitted when the content of the current model has changed.
*/
onDidChangeModelRawContent(listener: (e: IModelContentChangedEvent) => void): IDisposable;
/** /**
* An event emitted when the content of the current model has changed. * An event emitted when the content of the current model has changed.
*/ */
@ -3841,6 +3732,30 @@ declare module monaco.languages {
*/ */
export function registerCompletionItemProvider(languageId: string, provider: CompletionItemProvider): IDisposable; export function registerCompletionItemProvider(languageId: string, provider: CompletionItemProvider): IDisposable;
/**
* Contains additional diagnostic information about the context in which
* a [code action](#CodeActionProvider.provideCodeActions) is run.
*/
export interface CodeActionContext {
/**
* An array of diagnostics.
*
* @readonly
*/
markers: editor.IMarkerData[];
}
/**
* The code action interface defines the contract between extensions and
* the [light bulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature.
*/
export interface CodeActionProvider {
/**
* Provide commands for the given document and range.
*/
provideCodeActions(model: editor.IReadOnlyModel, range: Range, context: CodeActionContext, token: CancellationToken): CodeAction[] | Thenable<CodeAction[]>;
}
/** /**
* Completion item kinds. * Completion item kinds.
*/ */
@ -4145,7 +4060,7 @@ declare module monaco.languages {
/** /**
* The contents of this hover. * The contents of this hover.
*/ */
htmlContent: IHTMLContentElement[]; contents: MarkedString[];
/** /**
* The range to which this hover applies. When missing, the * The range to which this hover applies. When missing, the
* editor will use the range at the current position or the * editor will use the range at the current position or the
@ -4175,17 +4090,6 @@ declare module monaco.languages {
score: number; score: number;
} }
/**
* The code action interface defines the contract between extensions and
* the [light bulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature.
*/
export interface CodeActionProvider {
/**
* Provide commands for the given document and range.
*/
provideCodeActions(model: editor.IReadOnlyModel, range: Range, token: CancellationToken): CodeAction[] | Thenable<CodeAction[]>;
}
/** /**
* Represents a parameter of a callable-signature. A parameter can * Represents a parameter of a callable-signature. A parameter can
* have a label and a doc-comment. * have a label and a doc-comment.
@ -4712,13 +4616,15 @@ declare module monaco.worker {
export interface IMirrorModel { export interface IMirrorModel {
uri: Uri; uri: Uri;
version: number; version: number;
getText(): string; getValue(): string;
} }
export interface IWorkerContext {
/** /**
* Get all available mirror models in this worker. * Get all available mirror models in this worker.
*/ */
export function getMirrorModels(): IMirrorModel[]; getMirrorModels(): IMirrorModel[];
}
} }
@ -4830,3 +4736,43 @@ declare module monaco.languages.typescript {
export var typescriptDefaults: LanguageServiceDefaults; export var typescriptDefaults: LanguageServiceDefaults;
export var javascriptDefaults: LanguageServiceDefaults; export var javascriptDefaults: LanguageServiceDefaults;
} }
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module monaco.languages.css {
export interface DiagnosticsOptions {
validate?: boolean;
lint?: {
compatibleVendorPrefixes?: 'ignore' | 'warning' | 'error',
vendorPrefix?: 'ignore' | 'warning' | 'error',
duplicateProperties?: 'ignore' | 'warning' | 'error',
emptyRules?: 'ignore' | 'warning' | 'error',
importStatement?: 'ignore' | 'warning' | 'error',
boxModel?: 'ignore' | 'warning' | 'error',
universalSelector?: 'ignore' | 'warning' | 'error',
zeroUnits?: 'ignore' | 'warning' | 'error',
fontFaceProperties?: 'ignore' | 'warning' | 'error',
hexColorLength?: 'ignore' | 'warning' | 'error',
argumentsInColorFunction?: 'ignore' | 'warning' | 'error',
unknownProperties?: 'ignore' | 'warning' | 'error',
ieHack?: 'ignore' | 'warning' | 'error',
unknownVendorSpecificProperties?: 'ignore' | 'warning' | 'error',
propertyIgnoredDueToDisplay?: 'ignore' | 'warning' | 'error',
important?: 'ignore' | 'warning' | 'error',
float?: 'ignore' | 'warning' | 'error',
idSelector?: 'ignore' | 'warning' | 'error'
}
}
export interface LanguageServiceDefaults {
onDidChange: IEvent<LanguageServiceDefaults>;
diagnosticsOptions: DiagnosticsOptions;
setDiagnosticsOptions(options: DiagnosticsOptions): void;
}
export var cssDefaults: LanguageServiceDefaults;
export var lessDefaults: LanguageServiceDefaults;
export var scssDefaults: LanguageServiceDefaults;
}