import Immutable from "immutable" ; import * as monaco from "monaco-editor" ; /**
 * Code Mirror to Monaco constants.
 */ export enum Mode { markdown = "markdown" , raw = "plaintext" , python = "python" , csharp = "csharp" } param mode returns export function mapCodeMirrorModeToMonaco ( mode ) { let language = "" ; if ( typeof mode === "string" ) { language = mode ; } else if ( typeof mode === "object" && mode . name ) { language = mode . name ; } else if ( Immutable . Map . isMap ( mode ) && mode . has ( "name" ) ) { language = mode . get ( "name" ) as string ; } if ( language === "ipython" ) { return Mode . python ; } else if ( language === "text/x-csharp" ) { return Mode . csharp ; } else if ( monaco . languages . getEncodedLanguageId ( language ) > 0 ) { return language ; } return Mode . raw ; }