瀏覽代碼

Clean up handling of default theme

Steven Silvester 8 年之前
父節點
當前提交
dd1f0db573
共有 3 個文件被更改,包括 18 次插入11 次删除
  1. 14 7
      src/codemirror/editor.ts
  2. 2 2
      src/codemirror/plugin.ts
  3. 2 2
      src/renderers/widget.ts

+ 14 - 7
src/codemirror/editor.ts

@@ -51,12 +51,6 @@ const EDITOR_CLASS = 'jp-CodeMirrorWidget';
  */
 const READ_ONLY_CLASS = 'jp-mod-readOnly';
 
-/**
- * The name of the default CodeMirror theme
- */
-export
-const DEFAULT_CODEMIRROR_THEME: string = 'jupyter';
-
 /**
  * The key code for the up arrow key.
  */
@@ -669,6 +663,19 @@ class CodeMirrorEditor implements CodeEditor.IEditor {
 }
 
 
+/**
+ * The namespace for `CodeMirrorEditor` statics.
+ */
+export
+namespace CodeMirrorEditor {
+  /**
+   * The name of the default CodeMirror theme
+   */
+  export
+  const DEFAULT_THEME: string = 'jupyter';
+}
+
+
 // Define the signals for the `CodeMirrorEditor` class.
 defineSignal(CodeMirrorEditor.prototype, 'completionRequested');
 defineSignal(CodeMirrorEditor.prototype, 'edgeRequested');
@@ -699,7 +706,7 @@ namespace Private {
     if (options.wordWrap !== undefined) {
       config.lineWrapping = options.wordWrap;
     }
-    config.theme = (config.theme || DEFAULT_CODEMIRROR_THEME);
+    config.theme = (config.theme || CodeMirrorEditor.DEFAULT_THEME);
     config.indentUnit = config.indentUnit || 4;
   }
 

+ 2 - 2
src/codemirror/plugin.ts

@@ -31,7 +31,7 @@ import {
 } from '../mainmenu';
 
 import {
-  editorServices, CodeMirrorEditor, DEFAULT_CODEMIRROR_THEME
+  editorServices, CodeMirrorEditor
 } from '.';
 
 
@@ -132,7 +132,7 @@ function activateEditorCommands(app: JupyterLab, tracker: IEditorTracker, mainMe
     commands.addCommand(cmdIds.changeTheme, {
       label: args => args['theme'] as string,
       execute: args => {
-        let name: string = args['theme'] as string || DEFAULT_CODEMIRROR_THEME;
+        let name: string = args['theme'] as string || CodeMirrorEditor.DEFAULT_THEME;
         tracker.forEach(widget => {
           if (widget.editor instanceof CodeMirrorEditor) {
             let cm = widget.editor.editor;

+ 2 - 2
src/renderers/widget.ts

@@ -15,7 +15,7 @@ import {
 } from '../codemirror';
 
 import {
-  DEFAULT_CODEMIRROR_THEME
+  CodeMirrorEditor
 } from '../codemirror/editor';
 
 import * as marked
@@ -91,7 +91,7 @@ marked.setOptions({
   sanitize: false,
   tables: true,
   // breaks: true; We can't use GFM breaks as it causes problems with HTML tables
-  langPrefix: `cm-s-${DEFAULT_CODEMIRROR_THEME} language-`,
+  langPrefix: `cm-s-${CodeMirrorEditor.DEFAULT_THEME} language-`,
   highlight: (code, lang, callback) => {
     if (!lang) {
         // no language, no highlight