From ee51e873b834c4133f4dea2d1b433dcf3dbbf3d0 Mon Sep 17 00:00:00 2001 From: Laurent Nguyen Date: Mon, 13 Jul 2020 13:52:23 +0200 Subject: [PATCH] Fix build issues --- .../Notebook/MonacoEditor/MonacoEditor.tsx | 37 ++++++++++--------- .../Notebook/MonacoEditor/converter.ts | 8 ++-- .../Notebook/MonacoEditor/selectors.ts | 7 ++-- src/Explorer/Notebook/MonacoEditor/styles.css | 4 -- .../NotebookRenderer/NotebookRenderer.tsx | 2 +- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Explorer/Notebook/MonacoEditor/MonacoEditor.tsx b/src/Explorer/Notebook/MonacoEditor/MonacoEditor.tsx index 7a561b513..897a4b00f 100644 --- a/src/Explorer/Notebook/MonacoEditor/MonacoEditor.tsx +++ b/src/Explorer/Notebook/MonacoEditor/MonacoEditor.tsx @@ -1,5 +1,4 @@ import { Channels } from "@nteract/messaging"; -// import * as monaco from "./monaco"; import * as monaco from "monaco-editor/esm/vs/editor/editor.api"; import * as React from "react"; // import { completionProvider } from "./completions/completionItemProvider"; @@ -27,7 +26,7 @@ export interface IMonacoProps { channels: Channels | undefined; enableCompletion: boolean; shouldRegisterDefaultCompletion?: boolean; - onChange: (value: string, event?: any) => void; + onChange: (value: string, event?: unknown) => void; onFocusChange: (focus: boolean) => void; onCursorPositionChange?: (selection: monaco.ISelection | null) => void; onRegisterCompletionProvider?: (languageId: string) => void; @@ -82,7 +81,7 @@ function getMonacoTheme(theme: monaco.editor.IStandaloneThemeData | monaco.edito const makeMapStateToProps = (initialState: AppState, initialProps: IMonacoProps) => { const { id, contentRef } = initialProps; - function mapStateToProps(state: any, ownProps: IMonacoProps & IMonacoStateProps) { + function mapStateToProps(state: AppState, ownProps: IMonacoProps & IMonacoStateProps) { return { language: getCellMonacoLanguage( state, @@ -112,7 +111,7 @@ export class MonacoEditor extends React.Component { - // Do nothing. This is handled elsewhere, we just don't want the editor to put the newline. - }, undefined); + this.editor.addCommand( + monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, + () => { + // Do nothing. This is handled elsewhere, we just don't want the editor to put the newline. + }, + undefined + ); // TODO Add right context this.toggleEditorOptions(this.props.editorFocused); @@ -269,13 +272,13 @@ export class MonacoEditor extends React.Component { + this.editor.changeViewZones(changeAccessor => { const domNode = document.createElement("div"); changeAccessor.addZone({ afterLineNumber: 0, @@ -289,13 +292,13 @@ export class MonacoEditor extends React.Component
@@ -388,7 +391,7 @@ export class MonacoEditor extends React.Component { // monaco.languages.registerCompletionItemProvider(language, completionProvider); @@ -413,7 +416,7 @@ export class MonacoEditor extends React.Component + this.cursorPositionListener = this.editor.onDidChangeCursorSelection(event => this.props.onCursorPositionChange!(event.selection) ); } diff --git a/src/Explorer/Notebook/MonacoEditor/converter.ts b/src/Explorer/Notebook/MonacoEditor/converter.ts index f64d81af6..c80dc79db 100644 --- a/src/Explorer/Notebook/MonacoEditor/converter.ts +++ b/src/Explorer/Notebook/MonacoEditor/converter.ts @@ -1,5 +1,4 @@ import Immutable from "immutable"; -// import * as monaco from "./monaco"; import * as monaco from "monaco-editor/esm/vs/editor/editor.api"; /** @@ -8,7 +7,8 @@ import * as monaco from "monaco-editor/esm/vs/editor/editor.api"; export enum Mode { markdown = "markdown", raw = "plaintext", - python = "python" + python = "python", + csharp = "csharp" } /** @@ -17,7 +17,7 @@ export enum Mode { * @param mode Code Mirror mode * @returns Monaco language */ -export function mapCodeMirrorModeToMonaco(mode: any): string { +export function mapCodeMirrorModeToMonaco(mode: string | { name: string }): string { let language = ""; // Parse codemirror mode object @@ -36,6 +36,8 @@ export function mapCodeMirrorModeToMonaco(mode: any): string { // Need to handle "ipython" as a special case since it is not a registered language if (language === "ipython") { return Mode.python; + } else if (language === "text/x-csharp") { + return Mode.csharp; } else if (monaco.languages.getEncodedLanguageId(language) > 0) { return language; } diff --git a/src/Explorer/Notebook/MonacoEditor/selectors.ts b/src/Explorer/Notebook/MonacoEditor/selectors.ts index de6518357..f02e763ce 100644 --- a/src/Explorer/Notebook/MonacoEditor/selectors.ts +++ b/src/Explorer/Notebook/MonacoEditor/selectors.ts @@ -11,7 +11,7 @@ export const getCellMonacoLanguage = ( cellId: CellId, cellLanguageOverride?: string, notebookLanguageOverride?: string -) => { +): string => { const model = nteractSelectors.model(state, { contentRef }); if (!model || model.type !== "notebook") { throw new Error("Connected Editor components should not be used with non-notebook models"); @@ -35,7 +35,6 @@ export const getCellMonacoLanguage = ( return getNotebookMonacoLanguage(state, contentRef, notebookLanguageOverride); } } - return Mode.raw; }; /** @@ -45,7 +44,7 @@ export const getNotebookMonacoLanguage = ( state: AppState, contentRef: ContentRef, notebookLanguageOverride?: string -) => { +): string => { const model = nteractSelectors.model(state, { contentRef }); if (!model || model.type !== "notebook") { throw new Error("Connected Editor components should not be used with non-notebook models"); @@ -56,7 +55,7 @@ export const getNotebookMonacoLanguage = ( } const kernelRef = model.kernelRef; - let codeMirrorMode = null; + let codeMirrorMode; // Try to get the CodeMirror mode from the kernel. if (kernelRef) { codeMirrorMode = nteractSelectors.kernel(state, { kernelRef })?.info?.codemirrorMode; diff --git a/src/Explorer/Notebook/MonacoEditor/styles.css b/src/Explorer/Notebook/MonacoEditor/styles.css index 0c0db64b3..a8f4b3bf8 100644 --- a/src/Explorer/Notebook/MonacoEditor/styles.css +++ b/src/Explorer/Notebook/MonacoEditor/styles.css @@ -1,7 +1,3 @@ -.monaco-container { - padding: 0px 0px 7px 0px; -} - /* For the following components, we use the inherited width values from monaco-container. On resizing the browser, the width of monaco-container will be calculated diff --git a/src/Explorer/Notebook/NotebookRenderer/NotebookRenderer.tsx b/src/Explorer/Notebook/NotebookRenderer/NotebookRenderer.tsx index 6a0db7b97..8d13e26fa 100644 --- a/src/Explorer/Notebook/NotebookRenderer/NotebookRenderer.tsx +++ b/src/Explorer/Notebook/NotebookRenderer/NotebookRenderer.tsx @@ -100,7 +100,7 @@ class BaseNotebookRenderer extends React.Component { editor: { codemirror: (props: PassedEditorProps) => ( // - + ) }, prompt: ({ id, contentRef }: { id: CellId; contentRef: ContentRef }) => (