瀏覽代碼

Update codemirror.js

Clean up.
Michael Herzog 3 年之前
父節點
當前提交
1ab64ebf3a
共有 1 個文件被更改,包括 41 次插入41 次删除
  1. 41 41
      editor/js/libs/codemirror/codemirror.js

+ 41 - 41
editor/js/libs/codemirror/codemirror.js

@@ -393,7 +393,7 @@
     return function(str, direction) {
       var outerType = direction == "ltr" ? "L" : "R";
 
-      if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) { return false }
+      if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) { return false; }
       var len = str.length, types = [];
       for (var i = 0; i < len; ++i)
         { types.push(charType(str.charCodeAt(i))); }
@@ -511,7 +511,7 @@
         }
       }
 
-      return direction == "rtl" ? order.reverse() : order
+      return direction == "rtl" ? order.reverse() : order;
     }
   })();
 
@@ -677,7 +677,7 @@
         pos = nl + 1;
       }
     }
-    return result
+    return result;
   } : function (string) { return string.split(/\r\n?|\n/); };
 
   var hasSelection = window.getSelection ? function (te) {
@@ -1087,7 +1087,7 @@
           i += 2;
           at = Math.min(end, i_end);
         }
-        if (!style) { return }
+        if (!style) { return; }
         if (overlay.opaque) {
           st.splice(start, i - start, end, "overlay " + style);
           i = start + 2;
@@ -1121,7 +1121,7 @@
       if (updateFrontier === cm.doc.highlightFrontier)
         { cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier); }
     }
-    return line.styles
+    return line.styles;
   }
 
   function getContextBefore(cm, n, precise) {
@@ -1786,7 +1786,7 @@
     if (builder.pre.className)
       { builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); }
 
-    return builder
+    return builder;
   }
 
   function defaultSpecialCharPlaceholder(ch) {
@@ -1799,7 +1799,7 @@
   // Build up the DOM representation for a single token, and add it to
   // the line map. Takes care to render special characters separately.
   function buildToken(builder, text, style, startStyle, endStyle, css, attributes) {
-    if (!text) { return }
+    if (!text) { return; }
     var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text;
     var special = builder.cm.state.specialChars, mustWrap = false;
     var content;
@@ -1824,7 +1824,7 @@
           builder.col += skipped;
           builder.pos += skipped;
         }
-        if (!m) { break }
+        if (!m) { break; }
         pos += skipped + 1;
         var txt$1 = (void 0);
         if (m[0] == "\t") {
@@ -1858,7 +1858,7 @@
         for (var attr in attributes) { if (attributes.hasOwnProperty(attr) && attr != "style" && attr != "class")
           { token.setAttribute(attr, attributes[attr]); } }
       }
-      return builder.content.appendChild(token)
+      return builder.content.appendChild(token);
     }
     builder.content.appendChild(content);
   }
@@ -2497,7 +2497,7 @@
           { rect = node.parentNode.getBoundingClientRect(); }
         else
           { rect = getUsefulRect(range(node, start, end).getClientRects(), bias); }
-        if (rect.left || rect.right || start == 0) { break }
+        if (rect.left || rect.right || start == 0) { break; }
         end = start;
         start = start - 1;
         collapse = "right";
@@ -2524,7 +2524,7 @@
     var heights = prepared.view.measure.heights;
     var i = 0;
     for (; i < heights.length - 1; i++)
-      { if (mid < heights[i]) { break } }
+      { if (mid < heights[i]) { break; } }
     var top = i ? heights[i - 1] : 0, bot = heights[i];
     var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
                   right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
@@ -2532,7 +2532,7 @@
     if (!rect.left && !rect.right) { result.bogus = true; }
     if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
 
-    return result
+    return result;
   }
 
   // Work around problem with bounding client rects on ranges being
@@ -2812,7 +2812,7 @@
     }
 
     ch = skipExtendingChars(lineObj.text, ch, 1);
-    return PosWithInfo(lineNo, ch, sticky, outside, x - baseX)
+    return PosWithInfo(lineNo, ch, sticky, outside, x - baseX);
   }
 
   function coordsBidiPart(cm, lineObj, lineNo, preparedMeasure, order, x, y) {
@@ -3357,7 +3357,7 @@
     for (var i = 0; i < display.view.length; i++) {
       var cur = display.view[i], wrapping = cm.options.lineWrapping;
       var height = (void 0), width = 0;
-      if (cur.hidden) { continue }
+      if (cur.hidden) { continue; }
       oldHeight += cur.line.height;
       if (ie && ie_version < 8) {
         var bot = cur.node.offsetTop + cur.node.offsetHeight;
@@ -3421,7 +3421,7 @@
         to = ensureTo;
       }
     }
-    return {from: from, to: Math.max(to, from + 1)}
+    return {from: from, to: Math.max(to, from + 1)};
   }
 
   // SCROLLING THINGS INTO VIEW
@@ -3515,7 +3515,7 @@
       { result.scrollLeft = Math.max(0, rect.left + gutterSpace - (tooWide ? 0 : 10)); }
     else if (rect.right > screenw + screenleft - 3)
       { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; }
-    return result
+    return result;
   }
 
   // Store a relative adjustment to the scroll position in the current
@@ -3670,7 +3670,7 @@
       this.checkedZeroWidth = true;
     }
 
-    return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}
+    return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
   };
 
   NativeScrollbars.prototype.setScrollLeft = function (pos) {
@@ -4011,7 +4011,7 @@
       }
       if (+new Date > end) {
         startWorker(cm, cm.options.workDelay);
-        return true
+        return true;
       }
     });
     doc.highlightFrontier = context.line;
@@ -4644,7 +4644,7 @@
         ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
       }
     }
-    return new Selection(ranges, primIndex)
+    return new Selection(ranges, primIndex);
   }
 
   function simpleSelection(anchor, head) {
@@ -4705,7 +4705,7 @@
         out[i] = new Range(from, from);
       }
     }
-    return new Selection(out, doc.sel.primIndex)
+    return new Selection(out, doc.sel.primIndex);
   }
 
   // Used to get the editor into a consistent state again when options change.
@@ -4805,7 +4805,7 @@
 
   // Attach a document to an editor.
   function attachDoc(cm, doc) {
-    if (doc.cm) { throw new Error("This document is already in use.") }
+    if (doc.cm) { throw new Error("This document is already in use."); }
     cm.doc = doc;
     doc.cm = cm;
     estimateLineHeights(cm);
@@ -5371,7 +5371,7 @@
       change.origin = type;
       if (filter && !filterChange(doc, change, false)) {
         source.length = 0;
-        return {}
+        return {};
       }
 
       antiChanges.push(historyChangeFromChange(doc, change));
@@ -5666,7 +5666,7 @@
           child.removeInner(at, rm);
           this.height -= oldHeight - child.height;
           if (sz == rm) { this.children.splice(i--, 1); child.parent = null; }
-          if ((n -= rm) == 0) { break }
+          if ((n -= rm) == 0) { break; }
           at = 0;
         } else { at -= sz; }
       }
@@ -5705,7 +5705,7 @@
             child.lines = child.lines.slice(0, remaining);
             this.maybeSpill();
           }
-          break
+          break;
         }
         at -= sz;
       }
@@ -5842,7 +5842,7 @@
 
   // Clear the marker.
   TextMarker.prototype.clear = function () {
-    if (this.explicitlyCleared) { return }
+    if (this.explicitlyCleared) { return; }
     var cm = this.doc.cm, withOp = cm && !cm.curOp;
     if (withOp) { startOperation(cm); }
     if (hasHandler(this, "clear")) {
@@ -6095,7 +6095,7 @@
 
   var nextDocId = 0;
   var Doc = function(text, mode, firstLine, lineSep, direction) {
-    if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep, direction) }
+    if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep, direction); }
     if (firstLine == null) { firstLine = 0; }
 
     BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
@@ -6467,7 +6467,7 @@
       ; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
       copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
       copySharedMarkers(copy, findSharedMarkers(this));
-      return copy
+      return copy;
     },
     unlinkDoc: function(other) {
       if (other instanceof CodeMirror) { other = other.doc; }
@@ -7071,7 +7071,7 @@
     transposeChars: function (cm) { return runInOp(cm, function () {
       var ranges = cm.listSelections(), newSel = [];
       for (var i = 0; i < ranges.length; i++) {
-        if (!ranges[i].empty()) { continue }
+        if (!ranges[i].empty()) { continue; }
         var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
         if (line) {
           if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1); }
@@ -7505,7 +7505,7 @@
 
     var lastPos = start;
     function extendTo(pos) {
-      if (cmp(lastPos, pos) == 0) { return }
+      if (cmp(lastPos, pos) == 0) { return; }
       lastPos = pos;
 
       if (behavior.unit == "rectangle") {
@@ -7869,7 +7869,7 @@
   function CodeMirror(place, options) {
     var this$1 = this;
 
-    if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) }
+    if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options); }
 
     this.options = options = options ? copyObj(options) : {};
     // Determine effective options based on given values and defaults.
@@ -8081,7 +8081,7 @@
     } else if (how == "smart") {
       indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
       if (indentation == Pass || indentation > 150) {
-        if (!aggressive) { return }
+        if (!aggressive) { return; }
         how = "prev";
       }
     }
@@ -8105,7 +8105,7 @@
     if (indentString != curSpaceString) {
       replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
       line.stateAfter = null;
-      return true
+      return true;
     } else {
       // Ensure that, if the cursor was in the whitespace at the start
       // of the line, it is moved to the end of that space.
@@ -8114,7 +8114,7 @@
         if (range.head.line == n && range.head.ch < curSpaceString.length) {
           var pos$1 = Pos(n, curSpaceString.length);
           replaceOneSelection(doc, i$1, new Range(pos$1, pos$1));
-          break
+          break;
         }
       }
     }
@@ -8570,7 +8570,7 @@
           while (start > 0 && check(line.charAt(start - 1))) { --start; }
           while (end < line.length && check(line.charAt(end))) { ++end; }
         }
-        return new Range(Pos(pos.line, start), Pos(pos.line, end))
+        return new Range(Pos(pos.line, start), Pos(pos.line, end));
       },
 
       toggleOverwrite: function(value) {
@@ -8657,7 +8657,7 @@
         scrollToCoords(this, doc.scrollLeft, doc.scrollTop);
         this.curOp.forceScroll = true;
         signalLater(this, "swapDoc", this, old);
-        return old
+        return old;
       }),
 
       phrase: function(phraseText) {
@@ -9053,7 +9053,7 @@
       { from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length); }
     if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine())
       { to = Pos(to.line + 1, 0); }
-    if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false }
+    if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false; }
 
     var fromIndex, fromLine, fromNode;
     if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
@@ -9073,13 +9073,13 @@
       toNode = display.view[toIndex + 1].node.previousSibling;
     }
 
-    if (!fromNode) { return false }
+    if (!fromNode) { return false; }
     var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
     var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
     while (newText.length > 1 && oldText.length > 1) {
       if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
       else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }
-      else { break }
+      else { break; }
     }
 
     var cutFront = 0, cutEnd = 0;
@@ -9108,7 +9108,7 @@
     var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
     if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
       replaceRange(cm.doc, newText, chFrom, chTo, "+input");
-      return true
+      return true;
     }
   };
 
@@ -9595,7 +9595,7 @@
     var input = this, cm = input.cm, display = cm.display, te = input.textarea;
     if (input.contextMenuPending) { input.contextMenuPending(); }
     var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
-    if (!pos || presto) { return } // Opera is difficult.
+    if (!pos || presto) { return; } // Opera is difficult.
 
     // Reset the current text selection only if the click is done outside of the selection
     // and 'resetSelectionOnContextMenu' option is true.
@@ -9736,7 +9736,7 @@
     textarea.style.display = "none";
     var cm = CodeMirror(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); },
       options);
-    return cm
+    return cm;
   }
 
   function addLegacyProps(CodeMirror) {