fluentd-ui 0.3.12 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd-ui might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/application.js +2 -0
- data/app/assets/javascripts/codemirror.js +29 -0
- data/app/assets/javascripts/codemirror_fluentd.js +59 -0
- data/app/assets/stylesheets/application.css +6 -0
- data/app/views/fluentd/settings/edit.html.haml +1 -1
- data/app/views/shared/vue/_setting.html.erb +1 -1
- data/bower.json +2 -1
- data/lib/fluentd-ui/version.rb +1 -1
- data/spec/features/source_and_output_spec.rb +16 -6
- data/vendor/assets/javascripts/bower/codemirror/.bower.json +29 -0
- data/vendor/assets/javascripts/bower/codemirror/AUTHORS +423 -0
- data/vendor/assets/javascripts/bower/codemirror/CONTRIBUTING.md +76 -0
- data/vendor/assets/javascripts/bower/codemirror/LICENSE +19 -0
- data/vendor/assets/javascripts/bower/codemirror/README.md +11 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/comment/comment.js +183 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/comment/continuecomment.js +85 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/dialog/dialog.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/dialog/dialog.js +155 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/fullscreen.css +6 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/fullscreen.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/panel.js +94 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/placeholder.js +58 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/display/rulers.js +64 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/closebrackets.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/closetag.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/continuelist.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/matchbrackets.js +120 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/matchtags.js +66 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/edit/trailingspace.js +27 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/brace-fold.js +105 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/comment-fold.js +57 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldcode.js +145 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldgutter.css +20 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldgutter.js +134 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/indent-fold.js +44 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/markdown-fold.js +49 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/fold/xml-fold.js +182 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/anyword-hint.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/css-hint.js +56 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/html-hint.js +348 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/javascript-hint.js +146 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/show-hint.css +38 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/show-hint.js +389 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/sql-hint.js +197 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/hint/xml-hint.js +110 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/coffeescript-lint.js +41 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/css-lint.js +35 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/javascript-lint.js +136 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/json-lint.js +31 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/lint.css +73 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/lint.js +204 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/lint/yaml-lint.js +28 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/merge/merge.css +112 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/merge/merge.js +643 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/loadmode.js +64 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/multiplex.js +118 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/multiplex_test.js +33 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/overlay.js +85 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/mode/simple.js +213 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/colorize.js +40 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode-standalone.js +157 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode.js +72 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode.node.js +120 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/annotatescrollbar.js +76 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/scrollpastend.js +46 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/simplescrollbars.css +66 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/scroll/simplescrollbars.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/match-highlighter.js +128 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/matchesonscrollbar.css +8 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/matchesonscrollbar.js +90 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/search.js +164 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/search/searchcursor.js +189 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/selection/active-line.js +71 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/selection/mark-selection.js +118 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/tern.css +86 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/tern.js +670 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/tern/worker.js +44 -0
- data/vendor/assets/javascripts/bower/codemirror/addon/wrap/hardwrap.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/bower.json +16 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/emacs.js +411 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/sublime.js +540 -0
- data/vendor/assets/javascripts/bower/codemirror/keymap/vim.js +4901 -0
- data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.css +309 -0
- data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.js +8029 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/apl/apl.js +175 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/asterisk/asterisk.js +198 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clike/clike.js +489 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clike/scala.html +767 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/clojure/clojure.js +243 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/cobol/cobol.js +255 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/coffeescript/coffeescript.js +369 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/commonlisp/commonlisp.js +122 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/css.js +717 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/less.html +152 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/less_test.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/scss.html +157 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/scss_test.js +110 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/css/test.js +135 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/cypher/cypher.js +146 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/d/d.js +218 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dart/dart.js +50 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/diff/diff.js +47 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/django/django.js +67 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dockerfile/dockerfile.js +76 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dtd/dtd.js +142 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/dylan/dylan.js +299 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ebnf/ebnf.js +195 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ecl/ecl.js +207 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/eiffel/eiffel.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/erlang/erlang.js +622 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/fortran/fortran.js +188 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gas/gas.js +345 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gfm/gfm.js +123 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gfm/test.js +213 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/gherkin/gherkin.js +178 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/go/go.js +184 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/groovy/groovy.js +226 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haml/haml.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haml/test.js +97 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haskell/haskell.js +267 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/haxe/haxe.js +518 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/htmlembedded/htmlembedded.js +86 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/htmlmixed/htmlmixed.js +121 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/http/http.js +113 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/idl/idl.js +290 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/jade/jade.js +590 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/javascript.js +686 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/json-ld.html +72 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/test.js +200 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/javascript/typescript.html +61 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/jinja2/jinja2.js +142 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/julia/julia.js +301 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/kotlin/kotlin.js +280 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/livescript/livescript.js +280 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/lua/lua.js +159 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/markdown/markdown.js +765 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/markdown/test.js +754 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/meta.js +165 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/mirc/mirc.js +193 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/mllike/mllike.js +205 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/modelica/modelica.js +245 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/nginx/nginx.js +178 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ntriples/ntriples.js +186 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/octave/octave.js +135 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pascal/pascal.js +109 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pegjs/pegjs.js +114 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/perl/perl.js +832 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/php/php.js +226 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/php/test.js +154 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/pig/pig.js +188 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/properties/properties.js +78 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/puppet/puppet.js +220 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/python/python.js +359 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/q/q.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/r/r.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rpm/rpm.js +101 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rst/rst.js +557 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ruby/ruby.js +285 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/ruby/test.js +14 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/rust/rust.js +451 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sass/sass.js +327 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/scheme/scheme.js +248 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/shell/shell.js +139 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/shell/test.js +58 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sieve/sieve.js +193 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/slim/slim.js +575 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/slim/test.js +96 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smalltalk/smalltalk.js +168 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smarty/smarty.js +221 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/smartymixed/smartymixed.js +197 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/solr/solr.js +104 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/soy/soy.js +198 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sparql/sparql.js +174 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/spreadsheet/spreadsheet.js +109 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/sql/sql.js +391 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/stex/stex.js +251 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/stex/test.js +123 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tcl/tcl.js +147 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/textile/test.js +417 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/textile/textile.js +469 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiddlywiki/tiddlywiki.js +369 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiki/tiki.css +26 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tiki/tiki.js +323 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/toml/toml.js +88 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/tornado/tornado.js +68 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/turtle/turtle.js +162 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/vb/vb.js +274 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/vbscript/vbscript.js +350 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/velocity/velocity.js +201 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/verilog/test.js +273 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/verilog/verilog.js +364 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xml/test.js +51 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xml/xml.js +384 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xquery/test.js +67 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/xquery/xquery.js +447 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/yaml/yaml.js +117 -0
- data/vendor/assets/javascripts/bower/codemirror/mode/z80/z80.js +100 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/3024-day.css +38 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/3024-night.css +37 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/ambiance-mobile.css +5 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/ambiance.css +77 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/base16-dark.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/base16-light.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/blackboard.css +30 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/cobalt.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/eclipse.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/elegant.css +13 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/erlang-dark.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/lesser-dark.css +45 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/mbo.css +35 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/mdn-like.css +44 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/midnight.css +45 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/monokai.css +31 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/neat.css +12 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/neo.css +43 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/night.css +26 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-dark.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-light.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/pastel-on-dark.css +50 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/rubyblue.css +23 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/solarized.css +165 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/the-matrix.css +28 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-bright.css +35 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-eighties.css +36 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/twilight.css +30 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/vibrant-ink.css +32 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/xq-dark.css +51 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/xq-light.css +43 -0
- data/vendor/assets/javascripts/bower/codemirror/theme/zenburn.css +37 -0
- metadata +225 -2
@@ -0,0 +1,28 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function(mod) {
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
+
mod(require("../../lib/codemirror"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
// Depends on js-yaml.js from https://github.com/nodeca/js-yaml
|
15
|
+
|
16
|
+
// declare global: jsyaml
|
17
|
+
|
18
|
+
CodeMirror.registerHelper("lint", "yaml", function(text) {
|
19
|
+
var found = [];
|
20
|
+
try { jsyaml.load(text); }
|
21
|
+
catch(e) {
|
22
|
+
var loc = e.mark;
|
23
|
+
found.push({ from: CodeMirror.Pos(loc.line, loc.column), to: CodeMirror.Pos(loc.line, loc.column), message: e.message });
|
24
|
+
}
|
25
|
+
return found;
|
26
|
+
});
|
27
|
+
|
28
|
+
});
|
@@ -0,0 +1,112 @@
|
|
1
|
+
.CodeMirror-merge {
|
2
|
+
position: relative;
|
3
|
+
border: 1px solid #ddd;
|
4
|
+
white-space: pre;
|
5
|
+
}
|
6
|
+
|
7
|
+
.CodeMirror-merge, .CodeMirror-merge .CodeMirror {
|
8
|
+
height: 350px;
|
9
|
+
}
|
10
|
+
|
11
|
+
.CodeMirror-merge-2pane .CodeMirror-merge-pane { width: 47%; }
|
12
|
+
.CodeMirror-merge-2pane .CodeMirror-merge-gap { width: 6%; }
|
13
|
+
.CodeMirror-merge-3pane .CodeMirror-merge-pane { width: 31%; }
|
14
|
+
.CodeMirror-merge-3pane .CodeMirror-merge-gap { width: 3.5%; }
|
15
|
+
|
16
|
+
.CodeMirror-merge-pane {
|
17
|
+
display: inline-block;
|
18
|
+
white-space: normal;
|
19
|
+
vertical-align: top;
|
20
|
+
}
|
21
|
+
.CodeMirror-merge-pane-rightmost {
|
22
|
+
position: absolute;
|
23
|
+
right: 0px;
|
24
|
+
z-index: 1;
|
25
|
+
}
|
26
|
+
|
27
|
+
.CodeMirror-merge-gap {
|
28
|
+
z-index: 2;
|
29
|
+
display: inline-block;
|
30
|
+
height: 100%;
|
31
|
+
-moz-box-sizing: border-box;
|
32
|
+
box-sizing: border-box;
|
33
|
+
overflow: hidden;
|
34
|
+
border-left: 1px solid #ddd;
|
35
|
+
border-right: 1px solid #ddd;
|
36
|
+
position: relative;
|
37
|
+
background: #f8f8f8;
|
38
|
+
}
|
39
|
+
|
40
|
+
.CodeMirror-merge-scrolllock-wrap {
|
41
|
+
position: absolute;
|
42
|
+
bottom: 0; left: 50%;
|
43
|
+
}
|
44
|
+
.CodeMirror-merge-scrolllock {
|
45
|
+
position: relative;
|
46
|
+
left: -50%;
|
47
|
+
cursor: pointer;
|
48
|
+
color: #555;
|
49
|
+
line-height: 1;
|
50
|
+
}
|
51
|
+
|
52
|
+
.CodeMirror-merge-copybuttons-left, .CodeMirror-merge-copybuttons-right {
|
53
|
+
position: absolute;
|
54
|
+
left: 0; top: 0;
|
55
|
+
right: 0; bottom: 0;
|
56
|
+
line-height: 1;
|
57
|
+
}
|
58
|
+
|
59
|
+
.CodeMirror-merge-copy {
|
60
|
+
position: absolute;
|
61
|
+
cursor: pointer;
|
62
|
+
color: #44c;
|
63
|
+
}
|
64
|
+
|
65
|
+
.CodeMirror-merge-copy-reverse {
|
66
|
+
position: absolute;
|
67
|
+
cursor: pointer;
|
68
|
+
color: #44c;
|
69
|
+
}
|
70
|
+
|
71
|
+
.CodeMirror-merge-copybuttons-left .CodeMirror-merge-copy { left: 2px; }
|
72
|
+
.CodeMirror-merge-copybuttons-right .CodeMirror-merge-copy { right: 2px; }
|
73
|
+
|
74
|
+
.CodeMirror-merge-r-inserted, .CodeMirror-merge-l-inserted {
|
75
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12MwuCXy3+CWyH8GBgYGJgYkAABZbAQ9ELXurwAAAABJRU5ErkJggg==);
|
76
|
+
background-position: bottom left;
|
77
|
+
background-repeat: repeat-x;
|
78
|
+
}
|
79
|
+
|
80
|
+
.CodeMirror-merge-r-deleted, .CodeMirror-merge-l-deleted {
|
81
|
+
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12M4Kyb2/6yY2H8GBgYGJgYkAABURgPz6Ks7wQAAAABJRU5ErkJggg==);
|
82
|
+
background-position: bottom left;
|
83
|
+
background-repeat: repeat-x;
|
84
|
+
}
|
85
|
+
|
86
|
+
.CodeMirror-merge-r-chunk { background: #ffffe0; }
|
87
|
+
.CodeMirror-merge-r-chunk-start { border-top: 1px solid #ee8; }
|
88
|
+
.CodeMirror-merge-r-chunk-end { border-bottom: 1px solid #ee8; }
|
89
|
+
.CodeMirror-merge-r-connect { fill: #ffffe0; stroke: #ee8; stroke-width: 1px; }
|
90
|
+
|
91
|
+
.CodeMirror-merge-l-chunk { background: #eef; }
|
92
|
+
.CodeMirror-merge-l-chunk-start { border-top: 1px solid #88e; }
|
93
|
+
.CodeMirror-merge-l-chunk-end { border-bottom: 1px solid #88e; }
|
94
|
+
.CodeMirror-merge-l-connect { fill: #eef; stroke: #88e; stroke-width: 1px; }
|
95
|
+
|
96
|
+
.CodeMirror-merge-l-chunk.CodeMirror-merge-r-chunk { background: #dfd; }
|
97
|
+
.CodeMirror-merge-l-chunk-start.CodeMirror-merge-r-chunk-start { border-top: 1px solid #4e4; }
|
98
|
+
.CodeMirror-merge-l-chunk-end.CodeMirror-merge-r-chunk-end { border-bottom: 1px solid #4e4; }
|
99
|
+
|
100
|
+
.CodeMirror-merge-collapsed-widget:before {
|
101
|
+
content: "(...)";
|
102
|
+
}
|
103
|
+
.CodeMirror-merge-collapsed-widget {
|
104
|
+
cursor: pointer;
|
105
|
+
color: #88b;
|
106
|
+
background: #eef;
|
107
|
+
border: 1px solid #ddf;
|
108
|
+
font-size: 90%;
|
109
|
+
padding: 0 3px;
|
110
|
+
border-radius: 4px;
|
111
|
+
}
|
112
|
+
.CodeMirror-merge-collapsed-line .CodeMirror-gutter-elt { display: none; }
|
@@ -0,0 +1,643 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
// declare global: diff_match_patch, DIFF_INSERT, DIFF_DELETE, DIFF_EQUAL
|
5
|
+
|
6
|
+
(function(mod) {
|
7
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
8
|
+
mod(require("../../lib/codemirror"), require("diff_match_patch"));
|
9
|
+
else if (typeof define == "function" && define.amd) // AMD
|
10
|
+
define(["../../lib/codemirror", "diff_match_patch"], mod);
|
11
|
+
else // Plain browser env
|
12
|
+
mod(CodeMirror, diff_match_patch);
|
13
|
+
})(function(CodeMirror, diff_match_patch) {
|
14
|
+
"use strict";
|
15
|
+
var Pos = CodeMirror.Pos;
|
16
|
+
var svgNS = "http://www.w3.org/2000/svg";
|
17
|
+
|
18
|
+
function DiffView(mv, type) {
|
19
|
+
this.mv = mv;
|
20
|
+
this.type = type;
|
21
|
+
this.classes = type == "left"
|
22
|
+
? {chunk: "CodeMirror-merge-l-chunk",
|
23
|
+
start: "CodeMirror-merge-l-chunk-start",
|
24
|
+
end: "CodeMirror-merge-l-chunk-end",
|
25
|
+
insert: "CodeMirror-merge-l-inserted",
|
26
|
+
del: "CodeMirror-merge-l-deleted",
|
27
|
+
connect: "CodeMirror-merge-l-connect"}
|
28
|
+
: {chunk: "CodeMirror-merge-r-chunk",
|
29
|
+
start: "CodeMirror-merge-r-chunk-start",
|
30
|
+
end: "CodeMirror-merge-r-chunk-end",
|
31
|
+
insert: "CodeMirror-merge-r-inserted",
|
32
|
+
del: "CodeMirror-merge-r-deleted",
|
33
|
+
connect: "CodeMirror-merge-r-connect"};
|
34
|
+
if (mv.options.connect == "align")
|
35
|
+
this.aligners = [];
|
36
|
+
}
|
37
|
+
|
38
|
+
DiffView.prototype = {
|
39
|
+
constructor: DiffView,
|
40
|
+
init: function(pane, orig, options) {
|
41
|
+
this.edit = this.mv.edit;
|
42
|
+
this.orig = CodeMirror(pane, copyObj({value: orig, readOnly: !this.mv.options.allowEditingOriginals}, copyObj(options)));
|
43
|
+
|
44
|
+
this.diff = getDiff(asString(orig), asString(options.value));
|
45
|
+
this.diffOutOfDate = false;
|
46
|
+
|
47
|
+
this.showDifferences = options.showDifferences !== false;
|
48
|
+
this.forceUpdate = registerUpdate(this);
|
49
|
+
setScrollLock(this, true, false);
|
50
|
+
registerScroll(this);
|
51
|
+
},
|
52
|
+
setShowDifferences: function(val) {
|
53
|
+
val = val !== false;
|
54
|
+
if (val != this.showDifferences) {
|
55
|
+
this.showDifferences = val;
|
56
|
+
this.forceUpdate("full");
|
57
|
+
}
|
58
|
+
}
|
59
|
+
};
|
60
|
+
|
61
|
+
function ensureDiff(dv) {
|
62
|
+
if (dv.diffOutOfDate) {
|
63
|
+
dv.diff = getDiff(dv.orig.getValue(), dv.edit.getValue());
|
64
|
+
dv.diffOutOfDate = false;
|
65
|
+
CodeMirror.signal(dv.edit, "updateDiff", dv.diff);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
function registerUpdate(dv) {
|
70
|
+
var edit = {from: 0, to: 0, marked: []};
|
71
|
+
var orig = {from: 0, to: 0, marked: []};
|
72
|
+
var debounceChange;
|
73
|
+
function update(mode) {
|
74
|
+
if (mode == "full") {
|
75
|
+
if (dv.svg) clear(dv.svg);
|
76
|
+
if (dv.copyButtons) clear(dv.copyButtons);
|
77
|
+
clearMarks(dv.edit, edit.marked, dv.classes);
|
78
|
+
clearMarks(dv.orig, orig.marked, dv.classes);
|
79
|
+
edit.from = edit.to = orig.from = orig.to = 0;
|
80
|
+
}
|
81
|
+
ensureDiff(dv);
|
82
|
+
if (dv.showDifferences) {
|
83
|
+
updateMarks(dv.edit, dv.diff, edit, DIFF_INSERT, dv.classes);
|
84
|
+
updateMarks(dv.orig, dv.diff, orig, DIFF_DELETE, dv.classes);
|
85
|
+
}
|
86
|
+
makeConnections(dv);
|
87
|
+
}
|
88
|
+
function set(slow) {
|
89
|
+
clearTimeout(debounceChange);
|
90
|
+
debounceChange = setTimeout(update, slow == true ? 250 : 100);
|
91
|
+
}
|
92
|
+
function change() {
|
93
|
+
if (!dv.diffOutOfDate) {
|
94
|
+
dv.diffOutOfDate = true;
|
95
|
+
edit.from = edit.to = orig.from = orig.to = 0;
|
96
|
+
}
|
97
|
+
set(true);
|
98
|
+
}
|
99
|
+
dv.edit.on("change", change);
|
100
|
+
dv.orig.on("change", change);
|
101
|
+
dv.edit.on("markerAdded", set);
|
102
|
+
dv.edit.on("markerCleared", set);
|
103
|
+
dv.orig.on("markerAdded", set);
|
104
|
+
dv.orig.on("markerCleared", set);
|
105
|
+
dv.edit.on("viewportChange", set);
|
106
|
+
dv.orig.on("viewportChange", set);
|
107
|
+
update();
|
108
|
+
return update;
|
109
|
+
}
|
110
|
+
|
111
|
+
function registerScroll(dv) {
|
112
|
+
dv.edit.on("scroll", function() {
|
113
|
+
syncScroll(dv, DIFF_INSERT) && makeConnections(dv);
|
114
|
+
});
|
115
|
+
dv.orig.on("scroll", function() {
|
116
|
+
syncScroll(dv, DIFF_DELETE) && makeConnections(dv);
|
117
|
+
});
|
118
|
+
}
|
119
|
+
|
120
|
+
function syncScroll(dv, type) {
|
121
|
+
// Change handler will do a refresh after a timeout when diff is out of date
|
122
|
+
if (dv.diffOutOfDate) return false;
|
123
|
+
if (!dv.lockScroll) return true;
|
124
|
+
var editor, other, now = +new Date;
|
125
|
+
if (type == DIFF_INSERT) { editor = dv.edit; other = dv.orig; }
|
126
|
+
else { editor = dv.orig; other = dv.edit; }
|
127
|
+
// Don't take action if the position of this editor was recently set
|
128
|
+
// (to prevent feedback loops)
|
129
|
+
if (editor.state.scrollSetBy == dv && (editor.state.scrollSetAt || 0) + 50 > now) return false;
|
130
|
+
|
131
|
+
var sInfo = editor.getScrollInfo();
|
132
|
+
if (dv.mv.options.connect == "align") {
|
133
|
+
targetPos = sInfo.top;
|
134
|
+
} else {
|
135
|
+
var halfScreen = .5 * sInfo.clientHeight, midY = sInfo.top + halfScreen;
|
136
|
+
var mid = editor.lineAtHeight(midY, "local");
|
137
|
+
var around = chunkBoundariesAround(dv.diff, mid, type == DIFF_INSERT);
|
138
|
+
var off = getOffsets(editor, type == DIFF_INSERT ? around.edit : around.orig);
|
139
|
+
var offOther = getOffsets(other, type == DIFF_INSERT ? around.orig : around.edit);
|
140
|
+
var ratio = (midY - off.top) / (off.bot - off.top);
|
141
|
+
var targetPos = (offOther.top - halfScreen) + ratio * (offOther.bot - offOther.top);
|
142
|
+
|
143
|
+
var botDist, mix;
|
144
|
+
// Some careful tweaking to make sure no space is left out of view
|
145
|
+
// when scrolling to top or bottom.
|
146
|
+
if (targetPos > sInfo.top && (mix = sInfo.top / halfScreen) < 1) {
|
147
|
+
targetPos = targetPos * mix + sInfo.top * (1 - mix);
|
148
|
+
} else if ((botDist = sInfo.height - sInfo.clientHeight - sInfo.top) < halfScreen) {
|
149
|
+
var otherInfo = other.getScrollInfo();
|
150
|
+
var botDistOther = otherInfo.height - otherInfo.clientHeight - targetPos;
|
151
|
+
if (botDistOther > botDist && (mix = botDist / halfScreen) < 1)
|
152
|
+
targetPos = targetPos * mix + (otherInfo.height - otherInfo.clientHeight - botDist) * (1 - mix);
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
other.scrollTo(sInfo.left, targetPos);
|
157
|
+
other.state.scrollSetAt = now;
|
158
|
+
other.state.scrollSetBy = dv;
|
159
|
+
return true;
|
160
|
+
}
|
161
|
+
|
162
|
+
function getOffsets(editor, around) {
|
163
|
+
var bot = around.after;
|
164
|
+
if (bot == null) bot = editor.lastLine() + 1;
|
165
|
+
return {top: editor.heightAtLine(around.before || 0, "local"),
|
166
|
+
bot: editor.heightAtLine(bot, "local")};
|
167
|
+
}
|
168
|
+
|
169
|
+
function setScrollLock(dv, val, action) {
|
170
|
+
dv.lockScroll = val;
|
171
|
+
if (val && action != false) syncScroll(dv, DIFF_INSERT) && makeConnections(dv);
|
172
|
+
dv.lockButton.innerHTML = val ? "\u21db\u21da" : "\u21db \u21da";
|
173
|
+
}
|
174
|
+
|
175
|
+
// Updating the marks for editor content
|
176
|
+
|
177
|
+
function clearMarks(editor, arr, classes) {
|
178
|
+
for (var i = 0; i < arr.length; ++i) {
|
179
|
+
var mark = arr[i];
|
180
|
+
if (mark instanceof CodeMirror.TextMarker) {
|
181
|
+
mark.clear();
|
182
|
+
} else if (mark.parent) {
|
183
|
+
editor.removeLineClass(mark, "background", classes.chunk);
|
184
|
+
editor.removeLineClass(mark, "background", classes.start);
|
185
|
+
editor.removeLineClass(mark, "background", classes.end);
|
186
|
+
}
|
187
|
+
}
|
188
|
+
arr.length = 0;
|
189
|
+
}
|
190
|
+
|
191
|
+
// FIXME maybe add a margin around viewport to prevent too many updates
|
192
|
+
function updateMarks(editor, diff, state, type, classes) {
|
193
|
+
var vp = editor.getViewport();
|
194
|
+
editor.operation(function() {
|
195
|
+
if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) {
|
196
|
+
clearMarks(editor, state.marked, classes);
|
197
|
+
markChanges(editor, diff, type, state.marked, vp.from, vp.to, classes);
|
198
|
+
state.from = vp.from; state.to = vp.to;
|
199
|
+
} else {
|
200
|
+
if (vp.from < state.from) {
|
201
|
+
markChanges(editor, diff, type, state.marked, vp.from, state.from, classes);
|
202
|
+
state.from = vp.from;
|
203
|
+
}
|
204
|
+
if (vp.to > state.to) {
|
205
|
+
markChanges(editor, diff, type, state.marked, state.to, vp.to, classes);
|
206
|
+
state.to = vp.to;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
});
|
210
|
+
}
|
211
|
+
|
212
|
+
function markChanges(editor, diff, type, marks, from, to, classes) {
|
213
|
+
var pos = Pos(0, 0);
|
214
|
+
var top = Pos(from, 0), bot = editor.clipPos(Pos(to - 1));
|
215
|
+
var cls = type == DIFF_DELETE ? classes.del : classes.insert;
|
216
|
+
function markChunk(start, end) {
|
217
|
+
var bfrom = Math.max(from, start), bto = Math.min(to, end);
|
218
|
+
for (var i = bfrom; i < bto; ++i) {
|
219
|
+
var line = editor.addLineClass(i, "background", classes.chunk);
|
220
|
+
if (i == start) editor.addLineClass(line, "background", classes.start);
|
221
|
+
if (i == end - 1) editor.addLineClass(line, "background", classes.end);
|
222
|
+
marks.push(line);
|
223
|
+
}
|
224
|
+
// When the chunk is empty, make sure a horizontal line shows up
|
225
|
+
if (start == end && bfrom == end && bto == end) {
|
226
|
+
if (bfrom)
|
227
|
+
marks.push(editor.addLineClass(bfrom - 1, "background", classes.end));
|
228
|
+
else
|
229
|
+
marks.push(editor.addLineClass(bfrom, "background", classes.start));
|
230
|
+
}
|
231
|
+
}
|
232
|
+
|
233
|
+
var chunkStart = 0;
|
234
|
+
for (var i = 0; i < diff.length; ++i) {
|
235
|
+
var part = diff[i], tp = part[0], str = part[1];
|
236
|
+
if (tp == DIFF_EQUAL) {
|
237
|
+
var cleanFrom = pos.line + (startOfLineClean(diff, i) ? 0 : 1);
|
238
|
+
moveOver(pos, str);
|
239
|
+
var cleanTo = pos.line + (endOfLineClean(diff, i) ? 1 : 0);
|
240
|
+
if (cleanTo > cleanFrom) {
|
241
|
+
if (i) markChunk(chunkStart, cleanFrom);
|
242
|
+
chunkStart = cleanTo;
|
243
|
+
}
|
244
|
+
} else {
|
245
|
+
if (tp == type) {
|
246
|
+
var end = moveOver(pos, str, true);
|
247
|
+
var a = posMax(top, pos), b = posMin(bot, end);
|
248
|
+
if (!posEq(a, b))
|
249
|
+
marks.push(editor.markText(a, b, {className: cls}));
|
250
|
+
pos = end;
|
251
|
+
}
|
252
|
+
}
|
253
|
+
}
|
254
|
+
if (chunkStart <= pos.line) markChunk(chunkStart, pos.line + 1);
|
255
|
+
}
|
256
|
+
|
257
|
+
// Updating the gap between editor and original
|
258
|
+
|
259
|
+
function makeConnections(dv) {
|
260
|
+
if (!dv.showDifferences) return;
|
261
|
+
|
262
|
+
var align = dv.mv.options.connect == "align";
|
263
|
+
if (align) {
|
264
|
+
if (!dv.orig.curOp) return dv.orig.operation(function() {
|
265
|
+
makeConnections(dv);
|
266
|
+
});
|
267
|
+
for (var i = 0; i < dv.aligners.length; i++)
|
268
|
+
dv.aligners[i].clear();
|
269
|
+
dv.aligners.length = 0;
|
270
|
+
var extraSpaceAbove = {edit: 0, orig: 0};
|
271
|
+
}
|
272
|
+
|
273
|
+
if (dv.svg) {
|
274
|
+
clear(dv.svg);
|
275
|
+
var w = dv.gap.offsetWidth;
|
276
|
+
attrs(dv.svg, "width", w, "height", dv.gap.offsetHeight);
|
277
|
+
}
|
278
|
+
if (dv.copyButtons) clear(dv.copyButtons);
|
279
|
+
|
280
|
+
var vpEdit = dv.edit.getViewport(), vpOrig = dv.orig.getViewport();
|
281
|
+
var sTopEdit = dv.edit.getScrollInfo().top, sTopOrig = dv.orig.getScrollInfo().top;
|
282
|
+
iterateChunks(dv.diff, function(topOrig, botOrig, topEdit, botEdit) {
|
283
|
+
if (topEdit <= vpEdit.to && botEdit >= vpEdit.from &&
|
284
|
+
topOrig <= vpOrig.to && botOrig >= vpOrig.from)
|
285
|
+
drawConnectorsForChunk(dv, topOrig, botOrig, topEdit, botEdit, sTopOrig, sTopEdit, w);
|
286
|
+
if (align && (topEdit <= vpEdit.to || topOrig <= vpOrig.to)) {
|
287
|
+
var above = (botEdit < vpEdit.from && botOrig < vpOrig.from);
|
288
|
+
alignChunks(dv, topOrig, botOrig, topEdit, botEdit, above && extraSpaceAbove);
|
289
|
+
}
|
290
|
+
});
|
291
|
+
if (align) {
|
292
|
+
if (extraSpaceAbove.edit)
|
293
|
+
dv.aligners.push(padBelow(dv.edit, 0, extraSpaceAbove.edit));
|
294
|
+
if (extraSpaceAbove.orig)
|
295
|
+
dv.aligners.push(padBelow(dv.orig, 0, extraSpaceAbove.orig));
|
296
|
+
}
|
297
|
+
}
|
298
|
+
|
299
|
+
function drawConnectorsForChunk(dv, topOrig, botOrig, topEdit, botEdit, sTopOrig, sTopEdit, w) {
|
300
|
+
var flip = dv.type == "left";
|
301
|
+
var top = dv.orig.heightAtLine(topOrig, "local") - sTopOrig;
|
302
|
+
if (dv.svg) {
|
303
|
+
var topLpx = top;
|
304
|
+
var topRpx = dv.edit.heightAtLine(topEdit, "local") - sTopEdit;
|
305
|
+
if (flip) { var tmp = topLpx; topLpx = topRpx; topRpx = tmp; }
|
306
|
+
var botLpx = dv.orig.heightAtLine(botOrig, "local") - sTopOrig;
|
307
|
+
var botRpx = dv.edit.heightAtLine(botEdit, "local") - sTopEdit;
|
308
|
+
if (flip) { var tmp = botLpx; botLpx = botRpx; botRpx = tmp; }
|
309
|
+
var curveTop = " C " + w/2 + " " + topRpx + " " + w/2 + " " + topLpx + " " + (w + 2) + " " + topLpx;
|
310
|
+
var curveBot = " C " + w/2 + " " + botLpx + " " + w/2 + " " + botRpx + " -1 " + botRpx;
|
311
|
+
attrs(dv.svg.appendChild(document.createElementNS(svgNS, "path")),
|
312
|
+
"d", "M -1 " + topRpx + curveTop + " L " + (w + 2) + " " + botLpx + curveBot + " z",
|
313
|
+
"class", dv.classes.connect);
|
314
|
+
}
|
315
|
+
if (dv.copyButtons) {
|
316
|
+
var copy = dv.copyButtons.appendChild(elt("div", dv.type == "left" ? "\u21dd" : "\u21dc",
|
317
|
+
"CodeMirror-merge-copy"));
|
318
|
+
var editOriginals = dv.mv.options.allowEditingOriginals;
|
319
|
+
copy.title = editOriginals ? "Push to left" : "Revert chunk";
|
320
|
+
copy.chunk = {topEdit: topEdit, botEdit: botEdit, topOrig: topOrig, botOrig: botOrig};
|
321
|
+
copy.style.top = top + "px";
|
322
|
+
|
323
|
+
if (editOriginals) {
|
324
|
+
var topReverse = dv.orig.heightAtLine(topEdit, "local") - sTopEdit;
|
325
|
+
var copyReverse = dv.copyButtons.appendChild(elt("div", dv.type == "right" ? "\u21dd" : "\u21dc",
|
326
|
+
"CodeMirror-merge-copy-reverse"));
|
327
|
+
copyReverse.title = "Push to right";
|
328
|
+
copyReverse.chunk = {topEdit: topOrig, botEdit: botOrig, topOrig: topEdit, botOrig: botEdit};
|
329
|
+
copyReverse.style.top = topReverse + "px";
|
330
|
+
dv.type == "right" ? copyReverse.style.left = "2px" : copyReverse.style.right = "2px";
|
331
|
+
}
|
332
|
+
}
|
333
|
+
}
|
334
|
+
|
335
|
+
function alignChunks(dv, topOrig, botOrig, topEdit, botEdit, aboveViewport) {
|
336
|
+
var topOrigPx = dv.orig.heightAtLine(topOrig, "local");
|
337
|
+
var botOrigPx = dv.orig.heightAtLine(botOrig, "local");
|
338
|
+
var topEditPx = dv.edit.heightAtLine(topEdit, "local");
|
339
|
+
var botEditPx = dv.edit.heightAtLine(botEdit, "local");
|
340
|
+
var origH = botOrigPx -topOrigPx, editH = botEditPx - topEditPx;
|
341
|
+
var diff = editH - origH;
|
342
|
+
if (diff > 1) {
|
343
|
+
if (aboveViewport) aboveViewport.orig += diff;
|
344
|
+
else dv.aligners.push(padBelow(dv.orig, botOrig - 1, diff));
|
345
|
+
} else if (diff < -1) {
|
346
|
+
if (aboveViewport) aboveViewport.edit -= diff;
|
347
|
+
else dv.aligners.push(padBelow(dv.edit, botEdit - 1, -diff));
|
348
|
+
}
|
349
|
+
return 0;
|
350
|
+
}
|
351
|
+
|
352
|
+
function padBelow(cm, line, size) {
|
353
|
+
var elt = document.createElement("div");
|
354
|
+
elt.style.height = size + "px"; elt.style.minWidth = "1px";
|
355
|
+
return cm.addLineWidget(line, elt, {height: size});
|
356
|
+
}
|
357
|
+
|
358
|
+
function copyChunk(dv, to, from, chunk) {
|
359
|
+
if (dv.diffOutOfDate) return;
|
360
|
+
to.replaceRange(from.getRange(Pos(chunk.topOrig, 0), Pos(chunk.botOrig, 0)),
|
361
|
+
Pos(chunk.topEdit, 0), Pos(chunk.botEdit, 0));
|
362
|
+
}
|
363
|
+
|
364
|
+
// Merge view, containing 0, 1, or 2 diff views.
|
365
|
+
|
366
|
+
var MergeView = CodeMirror.MergeView = function(node, options) {
|
367
|
+
if (!(this instanceof MergeView)) return new MergeView(node, options);
|
368
|
+
|
369
|
+
this.options = options;
|
370
|
+
var origLeft = options.origLeft, origRight = options.origRight == null ? options.orig : options.origRight;
|
371
|
+
if (origLeft && origRight) {
|
372
|
+
if (options.connect == "align")
|
373
|
+
throw new Error("connect: \"align\" is not supported for three-way merge views");
|
374
|
+
if (options.collapseIdentical)
|
375
|
+
throw new Error("collapseIdentical option is not supported for three-way merge views");
|
376
|
+
}
|
377
|
+
|
378
|
+
var hasLeft = origLeft != null, hasRight = origRight != null;
|
379
|
+
var panes = 1 + (hasLeft ? 1 : 0) + (hasRight ? 1 : 0);
|
380
|
+
var wrap = [], left = this.left = null, right = this.right = null;
|
381
|
+
|
382
|
+
if (hasLeft) {
|
383
|
+
left = this.left = new DiffView(this, "left");
|
384
|
+
var leftPane = elt("div", null, "CodeMirror-merge-pane");
|
385
|
+
wrap.push(leftPane);
|
386
|
+
wrap.push(buildGap(left));
|
387
|
+
}
|
388
|
+
|
389
|
+
var editPane = elt("div", null, "CodeMirror-merge-pane");
|
390
|
+
wrap.push(editPane);
|
391
|
+
|
392
|
+
if (hasRight) {
|
393
|
+
right = this.right = new DiffView(this, "right");
|
394
|
+
wrap.push(buildGap(right));
|
395
|
+
var rightPane = elt("div", null, "CodeMirror-merge-pane");
|
396
|
+
wrap.push(rightPane);
|
397
|
+
}
|
398
|
+
|
399
|
+
(hasRight ? rightPane : editPane).className += " CodeMirror-merge-pane-rightmost";
|
400
|
+
|
401
|
+
wrap.push(elt("div", null, null, "height: 0; clear: both;"));
|
402
|
+
|
403
|
+
var wrapElt = this.wrap = node.appendChild(elt("div", wrap, "CodeMirror-merge CodeMirror-merge-" + panes + "pane"));
|
404
|
+
this.edit = CodeMirror(editPane, copyObj(options));
|
405
|
+
|
406
|
+
if (left) left.init(leftPane, origLeft, options);
|
407
|
+
if (right) right.init(rightPane, origRight, options);
|
408
|
+
|
409
|
+
if (options.collapseIdentical)
|
410
|
+
collapseIdenticalStretches(left || right, options.collapseIdentical);
|
411
|
+
|
412
|
+
var onResize = function() {
|
413
|
+
if (left) makeConnections(left);
|
414
|
+
if (right) makeConnections(right);
|
415
|
+
};
|
416
|
+
CodeMirror.on(window, "resize", onResize);
|
417
|
+
var resizeInterval = setInterval(function() {
|
418
|
+
for (var p = wrapElt.parentNode; p && p != document.body; p = p.parentNode) {}
|
419
|
+
if (!p) { clearInterval(resizeInterval); CodeMirror.off(window, "resize", onResize); }
|
420
|
+
}, 5000);
|
421
|
+
};
|
422
|
+
|
423
|
+
function buildGap(dv) {
|
424
|
+
var lock = dv.lockButton = elt("div", null, "CodeMirror-merge-scrolllock");
|
425
|
+
lock.title = "Toggle locked scrolling";
|
426
|
+
var lockWrap = elt("div", [lock], "CodeMirror-merge-scrolllock-wrap");
|
427
|
+
CodeMirror.on(lock, "click", function() { setScrollLock(dv, !dv.lockScroll); });
|
428
|
+
var gapElts = [lockWrap];
|
429
|
+
if (dv.mv.options.revertButtons !== false) {
|
430
|
+
dv.copyButtons = elt("div", null, "CodeMirror-merge-copybuttons-" + dv.type);
|
431
|
+
CodeMirror.on(dv.copyButtons, "click", function(e) {
|
432
|
+
var node = e.target || e.srcElement;
|
433
|
+
if (!node.chunk) return;
|
434
|
+
if (node.className == "CodeMirror-merge-copy-reverse") {
|
435
|
+
copyChunk(dv, dv.orig, dv.edit, node.chunk);
|
436
|
+
return;
|
437
|
+
}
|
438
|
+
copyChunk(dv, dv.edit, dv.orig, node.chunk);
|
439
|
+
});
|
440
|
+
gapElts.unshift(dv.copyButtons);
|
441
|
+
}
|
442
|
+
if (dv.mv.options.connect != "align") {
|
443
|
+
var svg = document.createElementNS && document.createElementNS(svgNS, "svg");
|
444
|
+
if (svg && !svg.createSVGRect) svg = null;
|
445
|
+
dv.svg = svg;
|
446
|
+
if (svg) gapElts.push(svg);
|
447
|
+
}
|
448
|
+
|
449
|
+
return dv.gap = elt("div", gapElts, "CodeMirror-merge-gap");
|
450
|
+
}
|
451
|
+
|
452
|
+
MergeView.prototype = {
|
453
|
+
constuctor: MergeView,
|
454
|
+
editor: function() { return this.edit; },
|
455
|
+
rightOriginal: function() { return this.right && this.right.orig; },
|
456
|
+
leftOriginal: function() { return this.left && this.left.orig; },
|
457
|
+
setShowDifferences: function(val) {
|
458
|
+
if (this.right) this.right.setShowDifferences(val);
|
459
|
+
if (this.left) this.left.setShowDifferences(val);
|
460
|
+
},
|
461
|
+
rightChunks: function() {
|
462
|
+
return this.right && getChunks(this.right);
|
463
|
+
},
|
464
|
+
leftChunks: function() {
|
465
|
+
return this.left && getChunks(this.left);
|
466
|
+
}
|
467
|
+
};
|
468
|
+
|
469
|
+
function asString(obj) {
|
470
|
+
if (typeof obj == "string") return obj;
|
471
|
+
else return obj.getValue();
|
472
|
+
}
|
473
|
+
|
474
|
+
// Operations on diffs
|
475
|
+
|
476
|
+
var dmp = new diff_match_patch();
|
477
|
+
function getDiff(a, b) {
|
478
|
+
var diff = dmp.diff_main(a, b);
|
479
|
+
dmp.diff_cleanupSemantic(diff);
|
480
|
+
// The library sometimes leaves in empty parts, which confuse the algorithm
|
481
|
+
for (var i = 0; i < diff.length; ++i) {
|
482
|
+
var part = diff[i];
|
483
|
+
if (!part[1]) {
|
484
|
+
diff.splice(i--, 1);
|
485
|
+
} else if (i && diff[i - 1][0] == part[0]) {
|
486
|
+
diff.splice(i--, 1);
|
487
|
+
diff[i][1] += part[1];
|
488
|
+
}
|
489
|
+
}
|
490
|
+
return diff;
|
491
|
+
}
|
492
|
+
|
493
|
+
function iterateChunks(diff, f) {
|
494
|
+
var startEdit = 0, startOrig = 0;
|
495
|
+
var edit = Pos(0, 0), orig = Pos(0, 0);
|
496
|
+
for (var i = 0; i < diff.length; ++i) {
|
497
|
+
var part = diff[i], tp = part[0];
|
498
|
+
if (tp == DIFF_EQUAL) {
|
499
|
+
var startOff = startOfLineClean(diff, i) ? 0 : 1;
|
500
|
+
var cleanFromEdit = edit.line + startOff, cleanFromOrig = orig.line + startOff;
|
501
|
+
moveOver(edit, part[1], null, orig);
|
502
|
+
var endOff = endOfLineClean(diff, i) ? 1 : 0;
|
503
|
+
var cleanToEdit = edit.line + endOff, cleanToOrig = orig.line + endOff;
|
504
|
+
if (cleanToEdit > cleanFromEdit) {
|
505
|
+
if (i) f(startOrig, cleanFromOrig, startEdit, cleanFromEdit);
|
506
|
+
startEdit = cleanToEdit; startOrig = cleanToOrig;
|
507
|
+
}
|
508
|
+
} else {
|
509
|
+
moveOver(tp == DIFF_INSERT ? edit : orig, part[1]);
|
510
|
+
}
|
511
|
+
}
|
512
|
+
if (startEdit <= edit.line || startOrig <= orig.line)
|
513
|
+
f(startOrig, orig.line + 1, startEdit, edit.line + 1);
|
514
|
+
}
|
515
|
+
|
516
|
+
function getChunks(dv) {
|
517
|
+
ensureDiff(dv);
|
518
|
+
var collect = [];
|
519
|
+
iterateChunks(dv.diff, function(topOrig, botOrig, topEdit, botEdit) {
|
520
|
+
collect.push({origFrom: topOrig, origTo: botOrig,
|
521
|
+
editFrom: topEdit, editTo: botEdit});
|
522
|
+
});
|
523
|
+
return collect;
|
524
|
+
}
|
525
|
+
|
526
|
+
function endOfLineClean(diff, i) {
|
527
|
+
if (i == diff.length - 1) return true;
|
528
|
+
var next = diff[i + 1][1];
|
529
|
+
if (next.length == 1 || next.charCodeAt(0) != 10) return false;
|
530
|
+
if (i == diff.length - 2) return true;
|
531
|
+
next = diff[i + 2][1];
|
532
|
+
return next.length > 1 && next.charCodeAt(0) == 10;
|
533
|
+
}
|
534
|
+
|
535
|
+
function startOfLineClean(diff, i) {
|
536
|
+
if (i == 0) return true;
|
537
|
+
var last = diff[i - 1][1];
|
538
|
+
if (last.charCodeAt(last.length - 1) != 10) return false;
|
539
|
+
if (i == 1) return true;
|
540
|
+
last = diff[i - 2][1];
|
541
|
+
return last.charCodeAt(last.length - 1) == 10;
|
542
|
+
}
|
543
|
+
|
544
|
+
function chunkBoundariesAround(diff, n, nInEdit) {
|
545
|
+
var beforeE, afterE, beforeO, afterO;
|
546
|
+
iterateChunks(diff, function(fromOrig, toOrig, fromEdit, toEdit) {
|
547
|
+
var fromLocal = nInEdit ? fromEdit : fromOrig;
|
548
|
+
var toLocal = nInEdit ? toEdit : toOrig;
|
549
|
+
if (afterE == null) {
|
550
|
+
if (fromLocal > n) { afterE = fromEdit; afterO = fromOrig; }
|
551
|
+
else if (toLocal > n) { afterE = toEdit; afterO = toOrig; }
|
552
|
+
}
|
553
|
+
if (toLocal <= n) { beforeE = toEdit; beforeO = toOrig; }
|
554
|
+
else if (fromLocal <= n) { beforeE = fromEdit; beforeO = fromOrig; }
|
555
|
+
});
|
556
|
+
return {edit: {before: beforeE, after: afterE}, orig: {before: beforeO, after: afterO}};
|
557
|
+
}
|
558
|
+
|
559
|
+
function collapseSingle(cm, from, to) {
|
560
|
+
cm.addLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
|
561
|
+
var widget = document.createElement("span");
|
562
|
+
widget.className = "CodeMirror-merge-collapsed-widget";
|
563
|
+
widget.title = "Identical text collapsed. Click to expand.";
|
564
|
+
var mark = cm.markText(Pos(from, 0), Pos(to - 1), {
|
565
|
+
inclusiveLeft: true,
|
566
|
+
inclusiveRight: true,
|
567
|
+
replacedWith: widget,
|
568
|
+
clearOnEnter: true
|
569
|
+
});
|
570
|
+
function clear() {
|
571
|
+
mark.clear();
|
572
|
+
cm.removeLineClass(from, "wrap", "CodeMirror-merge-collapsed-line");
|
573
|
+
}
|
574
|
+
widget.addEventListener("click", clear);
|
575
|
+
return {mark: mark, clear: clear};
|
576
|
+
}
|
577
|
+
|
578
|
+
function collapseStretch(dv, origStart, editStart, size) {
|
579
|
+
var mOrig = collapseSingle(dv.orig, origStart, origStart + size);
|
580
|
+
var mEdit = collapseSingle(dv.edit, editStart, editStart + size);
|
581
|
+
mOrig.mark.on("clear", function() { mEdit.clear(); });
|
582
|
+
mEdit.mark.on("clear", function() { mOrig.clear(); });
|
583
|
+
}
|
584
|
+
|
585
|
+
function collapseIdenticalStretches(dv, margin) {
|
586
|
+
if (typeof margin != "number") margin = 2;
|
587
|
+
var lastOrig = dv.orig.firstLine(), lastEdit = dv.edit.firstLine();
|
588
|
+
iterateChunks(dv.diff, function(topOrig, botOrig, _topEdit, botEdit) {
|
589
|
+
var identicalSize = topOrig - margin - lastOrig;
|
590
|
+
if (identicalSize > margin)
|
591
|
+
collapseStretch(dv, lastOrig, lastEdit, identicalSize);
|
592
|
+
lastOrig = botOrig + margin; lastEdit = botEdit + margin;
|
593
|
+
});
|
594
|
+
var bottomSize = dv.orig.lastLine() + 1 - lastOrig;
|
595
|
+
if (bottomSize > margin)
|
596
|
+
collapseStretch(dv, lastOrig, lastEdit, bottomSize);
|
597
|
+
}
|
598
|
+
|
599
|
+
// General utilities
|
600
|
+
|
601
|
+
function elt(tag, content, className, style) {
|
602
|
+
var e = document.createElement(tag);
|
603
|
+
if (className) e.className = className;
|
604
|
+
if (style) e.style.cssText = style;
|
605
|
+
if (typeof content == "string") e.appendChild(document.createTextNode(content));
|
606
|
+
else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
|
607
|
+
return e;
|
608
|
+
}
|
609
|
+
|
610
|
+
function clear(node) {
|
611
|
+
for (var count = node.childNodes.length; count > 0; --count)
|
612
|
+
node.removeChild(node.firstChild);
|
613
|
+
}
|
614
|
+
|
615
|
+
function attrs(elt) {
|
616
|
+
for (var i = 1; i < arguments.length; i += 2)
|
617
|
+
elt.setAttribute(arguments[i], arguments[i+1]);
|
618
|
+
}
|
619
|
+
|
620
|
+
function copyObj(obj, target) {
|
621
|
+
if (!target) target = {};
|
622
|
+
for (var prop in obj) if (obj.hasOwnProperty(prop)) target[prop] = obj[prop];
|
623
|
+
return target;
|
624
|
+
}
|
625
|
+
|
626
|
+
function moveOver(pos, str, copy, other) {
|
627
|
+
var out = copy ? Pos(pos.line, pos.ch) : pos, at = 0;
|
628
|
+
for (;;) {
|
629
|
+
var nl = str.indexOf("\n", at);
|
630
|
+
if (nl == -1) break;
|
631
|
+
++out.line;
|
632
|
+
if (other) ++other.line;
|
633
|
+
at = nl + 1;
|
634
|
+
}
|
635
|
+
out.ch = (at ? 0 : out.ch) + (str.length - at);
|
636
|
+
if (other) other.ch = (at ? 0 : other.ch) + (str.length - at);
|
637
|
+
return out;
|
638
|
+
}
|
639
|
+
|
640
|
+
function posMin(a, b) { return (a.line - b.line || a.ch - b.ch) < 0 ? a : b; }
|
641
|
+
function posMax(a, b) { return (a.line - b.line || a.ch - b.ch) > 0 ? a : b; }
|
642
|
+
function posEq(a, b) { return a.line == b.line && a.ch == b.ch; }
|
643
|
+
});
|