From eaa8ccaccb1091820d0a8d1223996a6dd057347d Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sun, 17 Jan 2016 14:28:04 -0600 Subject: Upgrade CodeMirror to 5.10.1 and now support fullscreen, jump-to-line in editor --- .../codemirror/addon/lint/coffeescript-lint.js | 0 public/vendor/codemirror/addon/lint/css-lint.js | 0 public/vendor/codemirror/addon/lint/html-lint.js | 46 ++++++++++++++++++++++ .../codemirror/addon/lint/javascript-lint.js | 0 public/vendor/codemirror/addon/lint/json-lint.js | 0 public/vendor/codemirror/addon/lint/lint.css | 0 public/vendor/codemirror/addon/lint/lint.js | 34 +++++++++++++--- public/vendor/codemirror/addon/lint/yaml-lint.js | 0 8 files changed, 75 insertions(+), 5 deletions(-) mode change 100755 => 100644 public/vendor/codemirror/addon/lint/coffeescript-lint.js mode change 100755 => 100644 public/vendor/codemirror/addon/lint/css-lint.js create mode 100644 public/vendor/codemirror/addon/lint/html-lint.js mode change 100755 => 100644 public/vendor/codemirror/addon/lint/javascript-lint.js mode change 100755 => 100644 public/vendor/codemirror/addon/lint/json-lint.js mode change 100755 => 100644 public/vendor/codemirror/addon/lint/lint.css mode change 100755 => 100644 public/vendor/codemirror/addon/lint/lint.js mode change 100755 => 100644 public/vendor/codemirror/addon/lint/yaml-lint.js (limited to 'public/vendor/codemirror/addon/lint') diff --git a/public/vendor/codemirror/addon/lint/coffeescript-lint.js b/public/vendor/codemirror/addon/lint/coffeescript-lint.js old mode 100755 new mode 100644 diff --git a/public/vendor/codemirror/addon/lint/css-lint.js b/public/vendor/codemirror/addon/lint/css-lint.js old mode 100755 new mode 100644 diff --git a/public/vendor/codemirror/addon/lint/html-lint.js b/public/vendor/codemirror/addon/lint/html-lint.js new file mode 100644 index 00000000..1e841709 --- /dev/null +++ b/public/vendor/codemirror/addon/lint/html-lint.js @@ -0,0 +1,46 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +// Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js + +// declare global: HTMLHint + +(function(mod) { + if (typeof exports == "object" && typeof module == "object") // CommonJS + mod(require("../../lib/codemirror"), require("htmlhint")); + else if (typeof define == "function" && define.amd) // AMD + define(["../../lib/codemirror", "htmlhint"], mod); + else // Plain browser env + mod(CodeMirror); +})(function(CodeMirror) { + "use strict"; + + var defaultRules = { + "tagname-lowercase": true, + "attr-lowercase": true, + "attr-value-double-quotes": true, + "doctype-first": false, + "tag-pair": true, + "spec-char-escape": true, + "id-unique": true, + "src-not-empty": true, + "attr-no-duplication": true + }; + + CodeMirror.registerHelper("lint", "html", function(text, options) { + var found = []; + if (!window.HTMLHint) return found; + var messages = HTMLHint.verify(text, options && options.rules || defaultRules); + for (var i = 0; i < messages.length; i++) { + var message = messages[i]; + var startLine = message.line - 1, endLine = message.line - 1, startCol = message.col - 1, endCol = message.col; + found.push({ + from: CodeMirror.Pos(startLine, startCol), + to: CodeMirror.Pos(endLine, endCol), + message: message.message, + severity : message.type + }); + } + return found; + }); +}); diff --git a/public/vendor/codemirror/addon/lint/javascript-lint.js b/public/vendor/codemirror/addon/lint/javascript-lint.js old mode 100755 new mode 100644 diff --git a/public/vendor/codemirror/addon/lint/json-lint.js b/public/vendor/codemirror/addon/lint/json-lint.js old mode 100755 new mode 100644 diff --git a/public/vendor/codemirror/addon/lint/lint.css b/public/vendor/codemirror/addon/lint/lint.css old mode 100755 new mode 100644 diff --git a/public/vendor/codemirror/addon/lint/lint.js b/public/vendor/codemirror/addon/lint/lint.js old mode 100755 new mode 100644 index 3eea203c..5afe49d0 --- a/public/vendor/codemirror/addon/lint/lint.js +++ b/public/vendor/codemirror/addon/lint/lint.js @@ -61,6 +61,7 @@ this.timeout = null; this.hasGutter = hasGutter; this.onMouseOver = function(e) { onMouseOver(cm, e); }; + this.waitingFor = 0 } function parseOptions(_cm, options) { @@ -115,15 +116,32 @@ return tip; } + function lintAsync(cm, getAnnotations, passOptions) { + var state = cm.state.lint + var id = ++state.waitingFor + function abort() { + id = -1 + cm.off("change", abort) + } + cm.on("change", abort) + getAnnotations(cm.getValue(), function(annotations, arg2) { + cm.off("change", abort) + if (state.waitingFor != id) return + if (arg2 && annotations instanceof CodeMirror) annotations = arg2 + updateLinting(cm, annotations) + }, passOptions, cm); + } + function startLinting(cm) { var state = cm.state.lint, options = state.options; var passOptions = options.options || options; // Support deprecated passing of `options` property in options var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint"); if (!getAnnotations) return; - if (options.async || getAnnotations.async) - getAnnotations(cm.getValue(), updateLinting, passOptions, cm); - else + if (options.async || getAnnotations.async) { + lintAsync(cm, getAnnotations, passOptions) + } else { updateLinting(cm, getAnnotations(cm.getValue(), passOptions, cm)); + } } function updateLinting(cm, annotationsNotSorted) { @@ -187,7 +205,8 @@ CodeMirror.defineOption("lint", false, function(cm, val, old) { if (old && old != CodeMirror.Init) { clearMarks(cm); - cm.off("change", onChange); + if (cm.state.lint.options.lintOnChange !== false) + cm.off("change", onChange); CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver); clearTimeout(cm.state.lint.timeout); delete cm.state.lint; @@ -197,11 +216,16 @@ var gutters = cm.getOption("gutters"), hasLintGutter = false; for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true; var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter); - cm.on("change", onChange); + if (state.options.lintOnChange !== false) + cm.on("change", onChange); if (state.options.tooltips != false) CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver); startLinting(cm); } }); + + CodeMirror.defineExtension("performLint", function() { + if (this.state.lint) startLinting(this); + }); }); diff --git a/public/vendor/codemirror/addon/lint/yaml-lint.js b/public/vendor/codemirror/addon/lint/yaml-lint.js old mode 100755 new mode 100644 -- cgit v1.2.3