Skip to content

Commit

Permalink
Standardize on monaco 0.3x.x (#2796)
Browse files Browse the repository at this point in the history
This is compatible with the ~0.31.0 version that the Azure Portal uses for ReactView blades
  • Loading branch information
dpwatrous committed Sep 7, 2023
1 parent 1fa572a commit df863d9
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 57 deletions.
36 changes: 25 additions & 11 deletions desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"loader-utils": "^1.4.2",
"merge2": "^1.4.1",
"mini-css-extract-plugin": "^0.5.0",
"monaco-editor-webpack-plugin": "^1.9.0",
"monaco-editor-webpack-plugin": "^6.0.0",
"node-fetch": "^2.6.7",
"nyc": "^15.1.0",
"patch-package": "^6.5.1",
Expand Down Expand Up @@ -228,7 +228,7 @@
"luxon": "^1.28.1",
"make-dir": "^2.1.0",
"mkdirp": "^1.0.4",
"monaco-editor": "^0.19.0",
"monaco-editor": "~0.30.0",
"node-abi": "^2.18.0",
"node-downloader-helper": "^2.1.6",
"node-forge": "^1.3.0",
Expand Down
17 changes: 8 additions & 9 deletions desktop/src/@batch-flask/ui/editor/editor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import {
} from "@angular/core";
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms";
import * as elementResizeDetectorMaker from "element-resize-detector";
import { Uri, editor } from "monaco-editor";
import { AutoscaleLanguage } from "./monaco-languages";
import IStandaloneCodeEditor = editor.IStandaloneCodeEditor;
import type { Uri, editor, IDisposable } from "monaco-editor";

import "./editor.scss";

Expand Down Expand Up @@ -63,9 +61,9 @@ export class EditorComponent implements ControlValueAccessor, AfterViewInit, OnC
private _value = "";
private _resizeDetector: any;
private _config: EditorConfig;
private _editor: IStandaloneCodeEditor;
private _model: monaco.editor.IModel;
private _modelChangeSub: monaco.IDisposable;
private _editor: editor.IStandaloneCodeEditor | null = null;
private _model: editor.IModel | null = null;
private _modelChangeSub: IDisposable;

@Input() public set value(v) {
if (v !== this._value) {
Expand Down Expand Up @@ -114,7 +112,8 @@ export class EditorComponent implements ControlValueAccessor, AfterViewInit, OnC
}

public async initMonaco() {
const monaco = await import("monaco-editor");
const monaco = await import("monaco-editor/esm/vs/editor/editor.api");
const { AutoscaleLanguage } = await import("./monaco-languages");
AutoscaleLanguage.define();
const myDiv: HTMLDivElement = this.editorContent.nativeElement;
// const options: IEditorConstructionOptions = this.config;
Expand All @@ -125,7 +124,7 @@ export class EditorComponent implements ControlValueAccessor, AfterViewInit, OnC
// Assign _model to existing model instead of create new one to avoid error
const uri = this.config.uri as any;
const model = uri ? monaco.editor.getModel(uri) : null;
this._model = model || monaco.editor.createModel(this._value || "", this.config.language, uri);
this._model = model ?? monaco.editor.createModel(this._value || "", this.config.language, uri);
// Inject this because initMonaco() function is invoked after writeValue()
// which causes reopen json editor with an incorrect value populated
this._model.setValue(this._value);
Expand All @@ -142,7 +141,7 @@ export class EditorComponent implements ControlValueAccessor, AfterViewInit, OnC
}
}
this._modelChangeSub = this._model.onDidChangeContent((e) => {
this.updateValue(this._model.getValue());
this.updateValue(this._model?.getValue());
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as monaco from "monaco-editor/esm/vs/editor/editor.api";

/**
* AutoscaleLanguage class defines autoscale formula syntax highlight and keyword autocomplete features in
* Monaco text editor. Autoscale text editor can be viewed directly in create pool flyout.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe("TextFileViewer", () => {
},
uri: Uri.file("foo.ts"),
keybindings: [
{ key: KeyMod.CtrlCmd | KeyCode.KEY_S, action: jasmine.anything() },
{ key: KeyMod.CtrlCmd | KeyCode.KeyS, action: jasmine.anything() },
],
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class TextFileViewerComponent extends FileViewer {
const keybindings: EditorKeyBinding[] = [];

if (this.fileLoader && !this.fileLoader.isReadonly) {
keybindings.push({ key: KeyMod.CtrlCmd | KeyCode.KEY_S, action: () => this.save() });
keybindings.push({ key: KeyMod.CtrlCmd | KeyCode.KeyS, action: () => this.save() });
}
this.editorConfig = {
readOnly: Boolean(this.fileLoader && this.fileLoader.isReadonly),
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@uifabric/azure-themes": "7.5.19",
"mobx": "^6.3.2",
"mobx-react-lite": "^3.2.0",
"monaco-editor": "^0.41.0",
"monaco-editor": "~0.31.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"tslib": "^2.3.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/bonito-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/bonito-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"@uifabric/azure-themes": ">=7.5.19 <8.0.0",
"mobx": "^6.3.2",
"mobx-react-lite": "^3.2.0",
"monaco-editor": "^0.19.0 || ^0.25.1",
"monaco-editor": ">=0.30.0 <0.40.0",
"react": ">=17.0.2 <18.0.0",
"react-dom": ">=17.0.2 <18.0.0",
"tslib": "~2.3.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@uifabric/azure-themes": ">=7.5.19 <8.0.0",
"mobx": "^6.3.2",
"mobx-react-lite": "^3.2.0",
"monaco-editor": "^0.19.0 || ^0.25.1",
"monaco-editor": ">=0.30.0 <0.40.0",
"react": ">=17.0.2 <18.0.0",
"react-dom": ">=17.0.2 <18.0.0",
"tslib": "~2.3.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"@uifabric/azure-themes": ">=7.5.19 <8.0.0",
"mobx": "^6.3.2",
"mobx-react-lite": "^3.2.0",
"monaco-editor": "^0.19.0 || ^0.25.1",
"monaco-editor": ">=0.30.0 <0.40.0",
"react": ">=17.0.2 <18.0.0",
"react-dom": ">=17.0.2 <18.0.0",
"tslib": "~2.3.1"
Expand Down
11 changes: 0 additions & 11 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@
"workspace:test:web": "npm run test",
"workspace:test:web:all": "npm run test:all"
},
"peerDependencies": {
"@fluentui/react": ">=8.97.2 <9.0.0",
"@fluentui/react-theme-provider": ">=0.16.2 <1.0.0",
"@uifabric/azure-themes": ">=7.5.19 <8.0.0",
"mobx": "^6.3.2",
"mobx-react-lite": "^3.2.0",
"monaco-editor": "^0.41.0",
"react": ">=17.0.2 <18.0.0",
"react-dom": ">=17.0.2 <18.0.0",
"tslib": "~2.3.1"
},
"dependencies": {
"@azure/bonito-core": "^1.0.0",
"@azure/bonito-ui": "^1.0.0",
Expand Down

0 comments on commit df863d9

Please sign in to comment.