Skip to content

Commit

Permalink
Upgrade to CodeMirror 5.23.0
Browse files Browse the repository at this point in the history
  • Loading branch information
markhillard committed Jan 21, 2017
1 parent e3ef9aa commit 68173d7
Show file tree
Hide file tree
Showing 53 changed files with 1,573 additions and 1,155 deletions.
1 change: 1 addition & 0 deletions codemirror/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
/mode/*/*.html
/mode/index.html
.*
bin
7 changes: 7 additions & 0 deletions codemirror/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Andrea G
Andreas Reischuck
Andres Taylor
Andre von Houck
Andrew Cheng
Andrey Fedorov
Andrey Klyuchnikov
Andrey Lushnikov
Expand Down Expand Up @@ -174,6 +175,7 @@ eborden
edsharp
ekhaled
Elisée
Emmanuel Schanzer
Enam Mijbah Noor
Eric Allam
Erik Welander
Expand All @@ -186,6 +188,7 @@ fbuchinger
feizhang365
Felipe Lalanne
Felix Raab
ficristo
Filip Noetzel
Filip Stollár
flack
Expand Down Expand Up @@ -245,6 +248,7 @@ Irakli Gozalishvili
Ivan Kurnosov
Ivoah
Jacob Lee
Jake Peyser
Jakob Miland
Jakub Vrana
Jakub Vrána
Expand Down Expand Up @@ -500,6 +504,7 @@ Remi Nyborg
Richard Denton
Richard van der Meer
Richard Z.H. Wang
Rishi Goomar
Robert Crossfield
Roberto Abdelkader Martínez Pérez
robertop23
Expand Down Expand Up @@ -582,6 +587,7 @@ Todd Berman
Tomas-A
Tomas Varaneckas
Tom Erik Støwer
Tom Klancer
Tom MacWright
Tony Jian
Travis Heppe
Expand Down Expand Up @@ -613,6 +619,7 @@ Yunchi Luo
Yuvi Panda
Zac Anger
Zachary Dremann
Zeno Rocha
Zhang Hao
zziuni
魏鹏刚
40 changes: 40 additions & 0 deletions codemirror/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
## 5.23.0 (2017-01-19)

### Bug fixes

Presentation-related elements DOM elements are now marked as such to help screen readers.

[markdown mode](http://codemirror.net/mode/markdown/): Be more picky about what HTML tags look like to avoid false positives.

### New features

`findModeByMIME` now understands `+json` and `+xml` MIME suffixes.

[closebrackets addon](http://codemirror.net/doc/manual.html#addon_closebrackets): Add support for an `override` option to ignore language-specific defaults.

[panel addon](http://codemirror.net/doc/manual.html#addon_panel): Add a `stable` option that auto-scrolls the content to keep it in the same place when inserting/removing a panel.

## 5.22.2 (2017-01-12)

### Bug fixes

Include rollup.config.js in NPM package, so that it can be used to build from source.

## 5.22.0 (2016-12-20)

### Bug fixes

[sublime bindings](http://codemirror.net/demo/sublime.html): Make `selectBetweenBrackets` work with multiple cursors.

[javascript mode](http://codemirror.net/mode/javascript/): Fix issues with parsing complex TypeScript types, imports, and exports.

A contentEditable editor instance with autofocus enabled no longer crashes during initializing.

### New features

[emacs bindings](http://codemirror.net/demo/emacs.html): Export `CodeMirror.emacs` to allow other addons to hook into Emacs-style functionality.

[active-line addon](http://codemirror.net/doc/manual.html#addon_active-line): Add `nonEmpty` option.

New event: [`optionChange`](http://codemirror.net/doc/manual.html#event_optionChange).

## 5.21.0 (2016-11-21)

### Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion codemirror/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2016 by Marijn Haverbeke <marijnh@gmail.com> and others
Copyright (C) 2017 by Marijn Haverbeke <marijnh@gmail.com> and others

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 11 additions & 0 deletions codemirror/addon/display/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
var height = (options && options.height) || node.offsetHeight;
this._setSize(null, info.heightLeft -= height);
info.panels++;
if (options.stable && isAtTop(this, node))
this.scrollTo(null, this.getScrollInfo().top + height)

return new Panel(this, node, options, height);
});

Expand All @@ -54,6 +57,8 @@
this.cleared = true;
var info = this.cm.state.panels;
this.cm._setSize(null, info.heightLeft += this.height);
if (this.options.stable && isAtTop(this.cm, this.node))
this.cm.scrollTo(null, this.cm.getScrollInfo().top - this.height)
info.wrapper.removeChild(this.node);
if (--info.panels == 0) removePanels(this.cm);
};
Expand Down Expand Up @@ -109,4 +114,10 @@
cm.setSize = cm._setSize;
cm.setSize();
}

function isAtTop(cm, dom) {
for (var sibling = dom.nextSibling; sibling; sibling = sibling.nextSibling)
if (sibling == cm.getWrapperElement()) return true
return false
}
});
2 changes: 1 addition & 1 deletion codemirror/addon/edit/closebrackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

function getConfig(cm) {
var deflt = cm.state.closeBrackets;
if (!deflt) return null;
if (!deflt || deflt.override) return deflt;
var mode = cm.getModeAt(cm.getCursor());
return mode.closeBrackets || deflt;
}
Expand Down
5 changes: 2 additions & 3 deletions codemirror/addon/merge/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,10 @@
var editOriginals = dv.mv.options.allowEditingOriginals;
copy.title = editOriginals ? "Push to left" : "Revert chunk";
copy.chunk = chunk;
copy.style.top = top + "px";
copy.style.top = (chunk.origTo > chunk.origFrom ? top : dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit) + "px";

if (editOriginals) {
var topReverse = dv.orig.heightAtLine(chunk.editFrom, "local") - sTopEdit;
var topReverse = dv.edit.heightAtLine(chunk.editFrom, "local") - sTopEdit;
var copyReverse = dv.copyButtons.appendChild(elt("div", dv.type == "right" ? "\u21dd" : "\u21dc",
"CodeMirror-merge-copy-reverse"));
copyReverse.title = "Push to right";
Expand Down Expand Up @@ -571,7 +571,6 @@
var dmp = new diff_match_patch();
function getDiff(a, b) {
var diff = dmp.diff_main(a, b);
dmp.diff_cleanupSemantic(diff);
// The library sometimes leaves in empty parts, which confuse the algorithm
for (var i = 0; i < diff.length; ++i) {
var part = diff[i];
Expand Down
9 changes: 7 additions & 2 deletions codemirror/addon/mode/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
innerMode: function(state) { return {state: state.base, mode: base}; },

blankLine: function(state) {
if (base.blankLine) base.blankLine(state.base);
if (overlay.blankLine) overlay.blankLine(state.overlay);
var baseToken, overlayToken;
if (base.blankLine) baseToken = base.blankLine(state.base);
if (overlay.blankLine) overlayToken = overlay.blankLine(state.overlay);

return overlayToken == null ?
baseToken :
(combine && baseToken != null ? baseToken + " " + overlayToken : overlayToken);
}
};
};
Expand Down
24 changes: 11 additions & 13 deletions codemirror/addon/selection/active-line.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE

// Because sometimes you need to style the cursor's line.
//
// Adds an option 'styleActiveLine' which, when enabled, gives the
// active line's wrapping <div> the CSS class "CodeMirror-activeline",
// and gives its background <div> the class "CodeMirror-activeline-background".

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
Expand All @@ -21,16 +15,18 @@
var GUTT_CLASS = "CodeMirror-activeline-gutter";

CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
var prev = old && old != CodeMirror.Init;
if (val && !prev) {
cm.state.activeLines = [];
updateActiveLines(cm, cm.listSelections());
cm.on("beforeSelectionChange", selectionChange);
} else if (!val && prev) {
var prev = old == CodeMirror.Init ? false : old;
if (val == prev) return
if (prev) {
cm.off("beforeSelectionChange", selectionChange);
clearActiveLines(cm);
delete cm.state.activeLines;
}
if (val) {
cm.state.activeLines = [];
updateActiveLines(cm, cm.listSelections());
cm.on("beforeSelectionChange", selectionChange);
}
});

function clearActiveLines(cm) {
Expand All @@ -52,7 +48,9 @@
var active = [];
for (var i = 0; i < ranges.length; i++) {
var range = ranges[i];
if (!range.empty()) continue;
var option = cm.getOption("styleActiveLine");
if (typeof option == "object" && option.nonEmpty ? range.anchor.line != range.head.line : !range.empty())
continue
var line = cm.getLineHandleVisualStart(range.head.line);
if (active[active.length - 1] != line) active.push(line);
}
Expand Down
10 changes: 10 additions & 0 deletions codemirror/demo/activeline.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,24 @@ <h2>Active Line Demo</h2>
</rss></textarea></form>

<script>
var nonEmpty = false;
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: "application/xml",
styleActiveLine: true,
lineNumbers: true,
lineWrapping: true
});

function toggleSelProp() {
nonEmpty = !nonEmpty;
editor.setOption("styleActiveLine", {nonEmpty: nonEmpty});
var label = nonEmpty ? 'Disable nonEmpty option' : 'Enable nonEmpty option';
document.getElementById('toggleButton').innerText = label;
}
</script>

<p>Styling the current cursor line.</p>

<button onclick="toggleSelProp()" id="toggleButton">Enable <code>nonEmpty</code> option</button>

</article>
4 changes: 2 additions & 2 deletions codemirror/demo/panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ <h2>Panel Demo</h2>
}
function addPanel(where) {
var node = makePanel(where);
panels[node.id] = editor.addPanel(node, {position: where});
panels[node.id] = editor.addPanel(node, {position: where, stable: true});
}

addPanel("top");
Expand All @@ -126,7 +126,7 @@ <h2>Panel Demo</h2>
var panel = panels["panel-" + id];
var node = makePanel("");

panels[node.id] = editor.addPanel(node, {replace: panel, position: "after-top"});
panels[node.id] = editor.addPanel(node, {replace: panel, position: "after-top", stable: true});
return false;
}
</script>
Expand Down
44 changes: 32 additions & 12 deletions codemirror/doc/manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<section class=first id=overview>
<h2 style="position: relative">
User manual and reference guide
<span style="color: #888; font-size: 1rem; position: absolute; right: 0; bottom: 0">version 5.21.0</span>
<span style="color: #888; font-size: 1rem; position: absolute; right: 0; bottom: 0">version 5.23.0</span>
</h2>

<p>CodeMirror is a code-editor component that can be embedded in
Expand Down Expand Up @@ -639,6 +639,9 @@ <h2>Events</h2>
or <a href="#setSize">resized</a>. Mostly useful to invalidate
cached values that depend on the editor or character size.</dd>

<dt id="event_optionChange"><code><strong>"optionChange"</strong> (instance: CodeMirror, option: string)</code></dt>
<dd>Dispatched every time an option is changed with <a href="#setOption"><code>setOption</code></a>.</dd>

<dt id="event_scrollCursorIntoView"><code><strong>"scrollCursorIntoView"</strong> (instance: CodeMirror, event: Event)</code></dt>
<dd>Fires when the editor tries to scroll its cursor into view.
Can be hooked into to take care of additional scrollable
Expand Down Expand Up @@ -2311,7 +2314,13 @@ <h2 id="addons">Addons</h2>
it. <code>explode</code> should be a similar string that gives
the pairs of characters that, when enter is pressed between
them, should have the second character also moved to its own
line. <a href="../demo/closebrackets.html">Demo here</a>.</dd>
line. By default, if the active mode has
a <code>closeBrackets</code> property, that overrides the
configuration given in the option. But you can add
an <code>override</code> property with a truthy value to
override mode-specific
configuration. <a href="../demo/closebrackets.html">Demo
here</a>.</dd>

<dt id="addon_matchtags"><a href="../addon/edit/matchtags.js"><code>edit/matchtags.js</code></a></dt>
<dd>Defines an option <code>matchTags</code> that, when enabled,
Expand Down Expand Up @@ -2760,12 +2769,20 @@ <h2 id="addons">Addons</h2>
like in <a href="../demo/markselection.html">this demo</a>.</dd>

<dt id="addon_active-line"><a href="../addon/selection/active-line.js"><code>selection/active-line.js</code></a></dt>
<dd>Defines a <code>styleActiveLine</code> option that, when enabled,
gives the wrapper of the active line the class <code>CodeMirror-activeline</code>,
adds a background with the class <code>CodeMirror-activeline-background</code>,
and adds the class <code>CodeMirror-activeline-gutter</code> to the
line's gutter space is enabled. See the
<a href="../demo/activeline.html">demo</a>.</dd>
<dd>Defines a <code>styleActiveLine</code> option that, when
enabled, gives the wrapper of the line that contains the cursor
the class <code>CodeMirror-activeline</code>, adds a background
with the class <code>CodeMirror-activeline-background</code>,
and adds the class <code>CodeMirror-activeline-gutter</code> to
the line's gutter space is enabled. The option's value may be a
boolean or an object specifying the following options:
<dl>
<dt><code><strong>nonEmpty</strong>: bool</code></dt>
<dd>Controls whether single-line selections, or just cursor
selections, are styled. Defaults to false (only cursor
selections).</dd>
</dl>
See the <a href="../demo/activeline.html">demo</a>.</dd>

<dt id="addon_selection-pointer"><a href="../addon/selection/selection-pointer.js"><code>selection/selection-pointer.js</code></a></dt>
<dd>Defines a <code>selectionPointer</code> option which you can
Expand Down Expand Up @@ -2893,7 +2910,7 @@ <h2 id="addons">Addons</h2>
changed.<br/>
The method accepts the following options:
<dl>
<dt><code><strong>position</strong> : string</code></dt>
<dt><code><strong>position</strong>: string</code></dt>
<dd>Controls the position of the newly added panel. The
following values are recognized:
<dl>
Expand All @@ -2907,12 +2924,15 @@ <h2 id="addons">Addons</h2>
<dd>Adds the panel at the top of the bottom panels.</dd>
</dl>
</dd>
<dt><code><strong>before</strong> : Panel</code></dt>
<dt><code><strong>before</strong>: Panel</code></dt>
<dd>The new panel will be added before the given panel.</dd>
<dt><code><strong>after</strong> : Panel</code></dt>
<dt><code><strong>after</strong>: Panel</code></dt>
<dd>The new panel will be added after the given panel.</dd>
<dt><code><strong>replace</strong> : Panel</code></dt>
<dt><code><strong>replace</strong>: Panel</code></dt>
<dd>The new panel will replace the given panel.</dd>
<dt><code><strong>stable</strong>: bool</code></dt>
<dd>Whether to scroll the editor to keep the text's vertical
position stable, when adding a panel above it. Defaults to false.</dd>
</dl>
When using the <code>after</code>, <code>before</code> or <code>replace</code> options,
if the panel doesn't exists or has been removed,
Expand Down
1 change: 1 addition & 0 deletions codemirror/doc/realworld.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ <h2>CodeMirror real-world uses</h2>
<li><a href="http://rascalmicro.com/docs/basic-tutorial-getting-started.html">Rascal</a> (tiny computer)</li>
<li><a href="https://www.realtime.io/">RealTime.io</a> (Internet-of-Things infrastructure)</li>
<li><a href="http://refork.com/">Refork</a> (animation demo gallery and sharing)</li>
<li><a href="http://sagecell.sagemath.org">SageMathCell</a> (interactive mathematical software)</li>
<li><a href="https://cloud.sagemath.com/">SageMathCloud</a> (interactive mathematical software environment)</li>
<li><a href="https://chrome.google.com/webstore/detail/servephp/mnpikomdchjhkhbhmbboehfdjkobbfpo">ServePHP</a> (PHP code testing in Chrome dev tools)</li>
<li><a href="https://www.shadertoy.com/">Shadertoy</a> (shader sharing)</li>
Expand Down
Loading

0 comments on commit 68173d7

Please sign in to comment.