浏览代码

Remove css attribute on selectionStyle, simplify background color
calculation.

Ian Rose 8 年之前
父节点
当前提交
2ed6fcfabe

+ 1 - 6
packages/codeeditor/src/editor.ts

@@ -107,12 +107,7 @@ namespace CodeEditor {
     displayName?: string;
 
     /**
-     * A CSS string to apply to the selection.
-     */
-    css?: string;
-
-    /**
-     * A color for cursors.
+     * A color for UI elements.
      */
     color?: string;
   }

+ 8 - 1
packages/codemirror/src/editor.ts

@@ -585,10 +585,17 @@ class CodeMirrorEditor implements CodeEditor.IEditor {
    */
   private _toTextMarkerOptions(style: CodeEditor.ISelectionStyle | undefined): CodeMirror.TextMarkerOptions | undefined {
     if (style) {
+      let css: string;
+      if (style.color) {
+        let r = parseInt(style.color.slice(1,3), 16);
+        let g  = parseInt(style.color.slice(3,5), 16);
+        let b  = parseInt(style.color.slice(5,7), 16);
+        css = `background-color: rgba( ${r}, ${g}, ${b}, 0.1)`;
+      }
       return {
         className: style.className,
         title: style.displayName,
-        css: style.css
+        css
       };
     }
     return undefined;

+ 0 - 5
packages/fileeditor/src/widget.ts

@@ -55,12 +55,7 @@ class FileEditor extends CodeEditorWrapper {
         //Setup the selection style for collaborators
         let localCollaborator = modelDB.collaborators.localCollaborator;
         this.editor.uuid = localCollaborator.sessionId;
-        let color = localCollaborator.color;
-        let r = parseInt(color.slice(1,3), 16);
-        let g  = parseInt(color.slice(3,5), 16);
-        let b  = parseInt(color.slice(5,7), 16);
         this.editor.selectionStyle = {
-          css: `background-color: rgba( ${r}, ${g}, ${b}, 0.1)`,
           color: localCollaborator.color
         };
 

+ 0 - 5
packages/notebook/src/widget.ts

@@ -967,12 +967,7 @@ class Notebook extends StaticNotebook {
           //Setup the selection style for collaborators
           let localCollaborator = modelDB.collaborators.localCollaborator;
           cell.editor.uuid = localCollaborator.sessionId;
-          let color = localCollaborator.color;
-          let r = parseInt(color.slice(1,3), 16);
-          let g  = parseInt(color.slice(3,5), 16);
-          let b  = parseInt(color.slice(5,7), 16);
           cell.editor.selectionStyle = {
-            css: `background-color: rgba( ${r}, ${g}, ${b}, 0.1)`,
             color: localCollaborator.color
           };
         }