mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-81277 lib: Update atto codemirror to 5.65.16
This commit is contained in:
parent
342319339f
commit
199a644d48
@ -4,7 +4,7 @@
|
||||
<location>yui/src/codemirror</location>
|
||||
<name>codemirror</name>
|
||||
<description>CodeMirror is a versatile text editor implemented in JavaScript for the browser.</description>
|
||||
<version>5.65.15</version>
|
||||
<version>5.65.16</version>
|
||||
<license>MIT</license>
|
||||
<repository>https://github.com/codemirror/codemirror5</repository>
|
||||
</library>
|
||||
|
@ -116,13 +116,14 @@ var define = null; // Remove require.js support in this context.
|
||||
} while (child = child.parentNode)
|
||||
}
|
||||
|
||||
function activeElt(doc) {
|
||||
function activeElt(rootNode) {
|
||||
// IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
|
||||
// IE < 10 will throw when accessed while the page is loading or in an iframe.
|
||||
// IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
|
||||
var doc = rootNode.ownerDocument || rootNode;
|
||||
var activeElement;
|
||||
try {
|
||||
activeElement = doc.activeElement;
|
||||
activeElement = rootNode.activeElement;
|
||||
} catch(e) {
|
||||
activeElement = doc.body || null;
|
||||
}
|
||||
@ -150,6 +151,15 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
function doc(cm) { return cm.display.wrapper.ownerDocument }
|
||||
|
||||
function root(cm) {
|
||||
return rootNode(cm.display.wrapper)
|
||||
}
|
||||
|
||||
function rootNode(element) {
|
||||
// Detect modern browsers (2017+).
|
||||
return element.getRootNode ? element.getRootNode() : element.ownerDocument
|
||||
}
|
||||
|
||||
function win(cm) { return doc(cm).defaultView }
|
||||
|
||||
function bind(f) {
|
||||
@ -3904,7 +3914,7 @@ var define = null; // Remove require.js support in this context.
|
||||
cm.display.maxLineChanged = false;
|
||||
}
|
||||
|
||||
var takeFocus = op.focus && op.focus == activeElt(doc(cm));
|
||||
var takeFocus = op.focus && op.focus == activeElt(root(cm));
|
||||
if (op.preparedSelection)
|
||||
{ cm.display.input.showSelection(op.preparedSelection, takeFocus); }
|
||||
if (op.updatedDisplay || op.startHeight != cm.doc.height)
|
||||
@ -4081,7 +4091,7 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
function selectionSnapshot(cm) {
|
||||
if (cm.hasFocus()) { return null }
|
||||
var active = activeElt(doc(cm));
|
||||
var active = activeElt(root(cm));
|
||||
if (!active || !contains(cm.display.lineDiv, active)) { return null }
|
||||
var result = {activeElt: active};
|
||||
if (window.getSelection) {
|
||||
@ -4097,7 +4107,7 @@ var define = null; // Remove require.js support in this context.
|
||||
}
|
||||
|
||||
function restoreSelection(snapshot) {
|
||||
if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(snapshot.activeElt.ownerDocument)) { return }
|
||||
if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(rootNode(snapshot.activeElt))) { return }
|
||||
snapshot.activeElt.focus();
|
||||
if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) &&
|
||||
snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
|
||||
@ -7268,7 +7278,7 @@ var define = null; // Remove require.js support in this context.
|
||||
function onKeyDown(e) {
|
||||
var cm = this;
|
||||
if (e.target && e.target != cm.display.input.getField()) { return }
|
||||
cm.curOp.focus = activeElt(doc(cm));
|
||||
cm.curOp.focus = activeElt(root(cm));
|
||||
if (signalDOMEvent(cm, e)) { return }
|
||||
// IE does strange things with escape.
|
||||
if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; }
|
||||
@ -7430,7 +7440,7 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
function leftButtonDown(cm, pos, repeat, event) {
|
||||
if (ie) { setTimeout(bind(ensureFocus, cm), 0); }
|
||||
else { cm.curOp.focus = activeElt(doc(cm)); }
|
||||
else { cm.curOp.focus = activeElt(root(cm)); }
|
||||
|
||||
var behavior = configureMouse(cm, repeat, event);
|
||||
|
||||
@ -7500,19 +7510,19 @@ var define = null; // Remove require.js support in this context.
|
||||
// Normal selection, as opposed to text dragging.
|
||||
function leftButtonSelect(cm, event, start, behavior) {
|
||||
if (ie) { delayBlurEvent(cm); }
|
||||
var display = cm.display, doc$1 = cm.doc;
|
||||
var display = cm.display, doc = cm.doc;
|
||||
e_preventDefault(event);
|
||||
|
||||
var ourRange, ourIndex, startSel = doc$1.sel, ranges = startSel.ranges;
|
||||
var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
|
||||
if (behavior.addNew && !behavior.extend) {
|
||||
ourIndex = doc$1.sel.contains(start);
|
||||
ourIndex = doc.sel.contains(start);
|
||||
if (ourIndex > -1)
|
||||
{ ourRange = ranges[ourIndex]; }
|
||||
else
|
||||
{ ourRange = new Range(start, start); }
|
||||
} else {
|
||||
ourRange = doc$1.sel.primary();
|
||||
ourIndex = doc$1.sel.primIndex;
|
||||
ourRange = doc.sel.primary();
|
||||
ourIndex = doc.sel.primIndex;
|
||||
}
|
||||
|
||||
if (behavior.unit == "rectangle") {
|
||||
@ -7529,18 +7539,18 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
if (!behavior.addNew) {
|
||||
ourIndex = 0;
|
||||
setSelection(doc$1, new Selection([ourRange], 0), sel_mouse);
|
||||
startSel = doc$1.sel;
|
||||
setSelection(doc, new Selection([ourRange], 0), sel_mouse);
|
||||
startSel = doc.sel;
|
||||
} else if (ourIndex == -1) {
|
||||
ourIndex = ranges.length;
|
||||
setSelection(doc$1, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
|
||||
setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
|
||||
{scroll: false, origin: "*mouse"});
|
||||
} else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
|
||||
setSelection(doc$1, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
|
||||
setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
|
||||
{scroll: false, origin: "*mouse"});
|
||||
startSel = doc$1.sel;
|
||||
startSel = doc.sel;
|
||||
} else {
|
||||
replaceOneSelection(doc$1, ourIndex, ourRange, sel_mouse);
|
||||
replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
|
||||
}
|
||||
|
||||
var lastPos = start;
|
||||
@ -7550,19 +7560,19 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
if (behavior.unit == "rectangle") {
|
||||
var ranges = [], tabSize = cm.options.tabSize;
|
||||
var startCol = countColumn(getLine(doc$1, start.line).text, start.ch, tabSize);
|
||||
var posCol = countColumn(getLine(doc$1, pos.line).text, pos.ch, tabSize);
|
||||
var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
|
||||
var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
|
||||
var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
|
||||
for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
|
||||
line <= end; line++) {
|
||||
var text = getLine(doc$1, line).text, leftPos = findColumn(text, left, tabSize);
|
||||
var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
|
||||
if (left == right)
|
||||
{ ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); }
|
||||
else if (text.length > leftPos)
|
||||
{ ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); }
|
||||
}
|
||||
if (!ranges.length) { ranges.push(new Range(start, start)); }
|
||||
setSelection(doc$1, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
|
||||
setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
|
||||
{origin: "*mouse", scroll: false});
|
||||
cm.scrollIntoView(pos);
|
||||
} else {
|
||||
@ -7577,8 +7587,8 @@ var define = null; // Remove require.js support in this context.
|
||||
anchor = maxPos(oldRange.to(), range.head);
|
||||
}
|
||||
var ranges$1 = startSel.ranges.slice(0);
|
||||
ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc$1, anchor), head));
|
||||
setSelection(doc$1, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
|
||||
ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head));
|
||||
setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7594,9 +7604,9 @@ var define = null; // Remove require.js support in this context.
|
||||
var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle");
|
||||
if (!cur) { return }
|
||||
if (cmp(cur, lastPos) != 0) {
|
||||
cm.curOp.focus = activeElt(doc(cm));
|
||||
cm.curOp.focus = activeElt(root(cm));
|
||||
extendTo(cur);
|
||||
var visible = visibleLines(display, doc$1);
|
||||
var visible = visibleLines(display, doc);
|
||||
if (cur.line >= visible.to || cur.line < visible.from)
|
||||
{ setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); }
|
||||
} else {
|
||||
@ -7621,7 +7631,7 @@ var define = null; // Remove require.js support in this context.
|
||||
}
|
||||
off(display.wrapper.ownerDocument, "mousemove", move);
|
||||
off(display.wrapper.ownerDocument, "mouseup", up);
|
||||
doc$1.history.lastSelOrigin = null;
|
||||
doc.history.lastSelOrigin = null;
|
||||
}
|
||||
|
||||
var move = operation(cm, function (e) {
|
||||
@ -8621,7 +8631,7 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
signal(this, "overwriteToggle", this, this.state.overwrite);
|
||||
},
|
||||
hasFocus: function() { return this.display.input.getField() == activeElt(doc(this)) },
|
||||
hasFocus: function() { return this.display.input.getField() == activeElt(root(this)) },
|
||||
isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
|
||||
|
||||
scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }),
|
||||
@ -8903,7 +8913,7 @@ var define = null; // Remove require.js support in this context.
|
||||
disableBrowserMagic(te);
|
||||
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
|
||||
te.value = lastCopied.text.join("\n");
|
||||
var hadFocus = activeElt(div.ownerDocument);
|
||||
var hadFocus = activeElt(rootNode(div));
|
||||
selectInput(te);
|
||||
setTimeout(function () {
|
||||
cm.display.lineSpace.removeChild(kludge);
|
||||
@ -8926,7 +8936,7 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
ContentEditableInput.prototype.prepareSelection = function () {
|
||||
var result = prepareSelection(this.cm, false);
|
||||
result.focus = activeElt(this.div.ownerDocument) == this.div;
|
||||
result.focus = activeElt(rootNode(this.div)) == this.div;
|
||||
return result
|
||||
};
|
||||
|
||||
@ -9022,7 +9032,7 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
ContentEditableInput.prototype.focus = function () {
|
||||
if (this.cm.options.readOnly != "nocursor") {
|
||||
if (!this.selectionInEditor() || activeElt(this.div.ownerDocument) != this.div)
|
||||
if (!this.selectionInEditor() || activeElt(rootNode(this.div)) != this.div)
|
||||
{ this.showSelection(this.prepareSelection(), true); }
|
||||
this.div.focus();
|
||||
}
|
||||
@ -9530,7 +9540,7 @@ var define = null; // Remove require.js support in this context.
|
||||
TextareaInput.prototype.supportsTouch = function () { return false };
|
||||
|
||||
TextareaInput.prototype.focus = function () {
|
||||
if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(this.textarea.ownerDocument) != this.textarea)) {
|
||||
if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(rootNode(this.textarea)) != this.textarea)) {
|
||||
try { this.textarea.focus(); }
|
||||
catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
|
||||
}
|
||||
@ -9737,7 +9747,7 @@ var define = null; // Remove require.js support in this context.
|
||||
// Set autofocus to true if this textarea is focused, or if it has
|
||||
// autofocus and no other element is focused.
|
||||
if (options.autofocus == null) {
|
||||
var hasFocus = activeElt(textarea.ownerDocument);
|
||||
var hasFocus = activeElt(rootNode(textarea));
|
||||
options.autofocus = hasFocus == textarea ||
|
||||
textarea.getAttribute("autofocus") != null && hasFocus == document.body;
|
||||
}
|
||||
@ -9871,7 +9881,7 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
addLegacyProps(CodeMirror);
|
||||
|
||||
CodeMirror.version = "5.65.15";
|
||||
CodeMirror.version = "5.65.16";
|
||||
|
||||
return CodeMirror;
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -116,13 +116,14 @@ var define = null; // Remove require.js support in this context.
|
||||
} while (child = child.parentNode)
|
||||
}
|
||||
|
||||
function activeElt(doc) {
|
||||
function activeElt(rootNode) {
|
||||
// IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
|
||||
// IE < 10 will throw when accessed while the page is loading or in an iframe.
|
||||
// IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
|
||||
var doc = rootNode.ownerDocument || rootNode;
|
||||
var activeElement;
|
||||
try {
|
||||
activeElement = doc.activeElement;
|
||||
activeElement = rootNode.activeElement;
|
||||
} catch(e) {
|
||||
activeElement = doc.body || null;
|
||||
}
|
||||
@ -150,6 +151,15 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
function doc(cm) { return cm.display.wrapper.ownerDocument }
|
||||
|
||||
function root(cm) {
|
||||
return rootNode(cm.display.wrapper)
|
||||
}
|
||||
|
||||
function rootNode(element) {
|
||||
// Detect modern browsers (2017+).
|
||||
return element.getRootNode ? element.getRootNode() : element.ownerDocument
|
||||
}
|
||||
|
||||
function win(cm) { return doc(cm).defaultView }
|
||||
|
||||
function bind(f) {
|
||||
@ -3904,7 +3914,7 @@ var define = null; // Remove require.js support in this context.
|
||||
cm.display.maxLineChanged = false;
|
||||
}
|
||||
|
||||
var takeFocus = op.focus && op.focus == activeElt(doc(cm));
|
||||
var takeFocus = op.focus && op.focus == activeElt(root(cm));
|
||||
if (op.preparedSelection)
|
||||
{ cm.display.input.showSelection(op.preparedSelection, takeFocus); }
|
||||
if (op.updatedDisplay || op.startHeight != cm.doc.height)
|
||||
@ -4081,7 +4091,7 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
function selectionSnapshot(cm) {
|
||||
if (cm.hasFocus()) { return null }
|
||||
var active = activeElt(doc(cm));
|
||||
var active = activeElt(root(cm));
|
||||
if (!active || !contains(cm.display.lineDiv, active)) { return null }
|
||||
var result = {activeElt: active};
|
||||
if (window.getSelection) {
|
||||
@ -4097,7 +4107,7 @@ var define = null; // Remove require.js support in this context.
|
||||
}
|
||||
|
||||
function restoreSelection(snapshot) {
|
||||
if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(snapshot.activeElt.ownerDocument)) { return }
|
||||
if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(rootNode(snapshot.activeElt))) { return }
|
||||
snapshot.activeElt.focus();
|
||||
if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) &&
|
||||
snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
|
||||
@ -7268,7 +7278,7 @@ var define = null; // Remove require.js support in this context.
|
||||
function onKeyDown(e) {
|
||||
var cm = this;
|
||||
if (e.target && e.target != cm.display.input.getField()) { return }
|
||||
cm.curOp.focus = activeElt(doc(cm));
|
||||
cm.curOp.focus = activeElt(root(cm));
|
||||
if (signalDOMEvent(cm, e)) { return }
|
||||
// IE does strange things with escape.
|
||||
if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; }
|
||||
@ -7430,7 +7440,7 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
function leftButtonDown(cm, pos, repeat, event) {
|
||||
if (ie) { setTimeout(bind(ensureFocus, cm), 0); }
|
||||
else { cm.curOp.focus = activeElt(doc(cm)); }
|
||||
else { cm.curOp.focus = activeElt(root(cm)); }
|
||||
|
||||
var behavior = configureMouse(cm, repeat, event);
|
||||
|
||||
@ -7500,19 +7510,19 @@ var define = null; // Remove require.js support in this context.
|
||||
// Normal selection, as opposed to text dragging.
|
||||
function leftButtonSelect(cm, event, start, behavior) {
|
||||
if (ie) { delayBlurEvent(cm); }
|
||||
var display = cm.display, doc$1 = cm.doc;
|
||||
var display = cm.display, doc = cm.doc;
|
||||
e_preventDefault(event);
|
||||
|
||||
var ourRange, ourIndex, startSel = doc$1.sel, ranges = startSel.ranges;
|
||||
var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
|
||||
if (behavior.addNew && !behavior.extend) {
|
||||
ourIndex = doc$1.sel.contains(start);
|
||||
ourIndex = doc.sel.contains(start);
|
||||
if (ourIndex > -1)
|
||||
{ ourRange = ranges[ourIndex]; }
|
||||
else
|
||||
{ ourRange = new Range(start, start); }
|
||||
} else {
|
||||
ourRange = doc$1.sel.primary();
|
||||
ourIndex = doc$1.sel.primIndex;
|
||||
ourRange = doc.sel.primary();
|
||||
ourIndex = doc.sel.primIndex;
|
||||
}
|
||||
|
||||
if (behavior.unit == "rectangle") {
|
||||
@ -7529,18 +7539,18 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
if (!behavior.addNew) {
|
||||
ourIndex = 0;
|
||||
setSelection(doc$1, new Selection([ourRange], 0), sel_mouse);
|
||||
startSel = doc$1.sel;
|
||||
setSelection(doc, new Selection([ourRange], 0), sel_mouse);
|
||||
startSel = doc.sel;
|
||||
} else if (ourIndex == -1) {
|
||||
ourIndex = ranges.length;
|
||||
setSelection(doc$1, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
|
||||
setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
|
||||
{scroll: false, origin: "*mouse"});
|
||||
} else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
|
||||
setSelection(doc$1, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
|
||||
setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
|
||||
{scroll: false, origin: "*mouse"});
|
||||
startSel = doc$1.sel;
|
||||
startSel = doc.sel;
|
||||
} else {
|
||||
replaceOneSelection(doc$1, ourIndex, ourRange, sel_mouse);
|
||||
replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
|
||||
}
|
||||
|
||||
var lastPos = start;
|
||||
@ -7550,19 +7560,19 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
if (behavior.unit == "rectangle") {
|
||||
var ranges = [], tabSize = cm.options.tabSize;
|
||||
var startCol = countColumn(getLine(doc$1, start.line).text, start.ch, tabSize);
|
||||
var posCol = countColumn(getLine(doc$1, pos.line).text, pos.ch, tabSize);
|
||||
var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
|
||||
var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
|
||||
var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
|
||||
for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
|
||||
line <= end; line++) {
|
||||
var text = getLine(doc$1, line).text, leftPos = findColumn(text, left, tabSize);
|
||||
var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
|
||||
if (left == right)
|
||||
{ ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); }
|
||||
else if (text.length > leftPos)
|
||||
{ ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); }
|
||||
}
|
||||
if (!ranges.length) { ranges.push(new Range(start, start)); }
|
||||
setSelection(doc$1, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
|
||||
setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
|
||||
{origin: "*mouse", scroll: false});
|
||||
cm.scrollIntoView(pos);
|
||||
} else {
|
||||
@ -7577,8 +7587,8 @@ var define = null; // Remove require.js support in this context.
|
||||
anchor = maxPos(oldRange.to(), range.head);
|
||||
}
|
||||
var ranges$1 = startSel.ranges.slice(0);
|
||||
ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc$1, anchor), head));
|
||||
setSelection(doc$1, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
|
||||
ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head));
|
||||
setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7594,9 +7604,9 @@ var define = null; // Remove require.js support in this context.
|
||||
var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle");
|
||||
if (!cur) { return }
|
||||
if (cmp(cur, lastPos) != 0) {
|
||||
cm.curOp.focus = activeElt(doc(cm));
|
||||
cm.curOp.focus = activeElt(root(cm));
|
||||
extendTo(cur);
|
||||
var visible = visibleLines(display, doc$1);
|
||||
var visible = visibleLines(display, doc);
|
||||
if (cur.line >= visible.to || cur.line < visible.from)
|
||||
{ setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); }
|
||||
} else {
|
||||
@ -7621,7 +7631,7 @@ var define = null; // Remove require.js support in this context.
|
||||
}
|
||||
off(display.wrapper.ownerDocument, "mousemove", move);
|
||||
off(display.wrapper.ownerDocument, "mouseup", up);
|
||||
doc$1.history.lastSelOrigin = null;
|
||||
doc.history.lastSelOrigin = null;
|
||||
}
|
||||
|
||||
var move = operation(cm, function (e) {
|
||||
@ -8621,7 +8631,7 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
signal(this, "overwriteToggle", this, this.state.overwrite);
|
||||
},
|
||||
hasFocus: function() { return this.display.input.getField() == activeElt(doc(this)) },
|
||||
hasFocus: function() { return this.display.input.getField() == activeElt(root(this)) },
|
||||
isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
|
||||
|
||||
scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }),
|
||||
@ -8903,7 +8913,7 @@ var define = null; // Remove require.js support in this context.
|
||||
disableBrowserMagic(te);
|
||||
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
|
||||
te.value = lastCopied.text.join("\n");
|
||||
var hadFocus = activeElt(div.ownerDocument);
|
||||
var hadFocus = activeElt(rootNode(div));
|
||||
selectInput(te);
|
||||
setTimeout(function () {
|
||||
cm.display.lineSpace.removeChild(kludge);
|
||||
@ -8926,7 +8936,7 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
ContentEditableInput.prototype.prepareSelection = function () {
|
||||
var result = prepareSelection(this.cm, false);
|
||||
result.focus = activeElt(this.div.ownerDocument) == this.div;
|
||||
result.focus = activeElt(rootNode(this.div)) == this.div;
|
||||
return result
|
||||
};
|
||||
|
||||
@ -9022,7 +9032,7 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
ContentEditableInput.prototype.focus = function () {
|
||||
if (this.cm.options.readOnly != "nocursor") {
|
||||
if (!this.selectionInEditor() || activeElt(this.div.ownerDocument) != this.div)
|
||||
if (!this.selectionInEditor() || activeElt(rootNode(this.div)) != this.div)
|
||||
{ this.showSelection(this.prepareSelection(), true); }
|
||||
this.div.focus();
|
||||
}
|
||||
@ -9530,7 +9540,7 @@ var define = null; // Remove require.js support in this context.
|
||||
TextareaInput.prototype.supportsTouch = function () { return false };
|
||||
|
||||
TextareaInput.prototype.focus = function () {
|
||||
if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(this.textarea.ownerDocument) != this.textarea)) {
|
||||
if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(rootNode(this.textarea)) != this.textarea)) {
|
||||
try { this.textarea.focus(); }
|
||||
catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
|
||||
}
|
||||
@ -9737,7 +9747,7 @@ var define = null; // Remove require.js support in this context.
|
||||
// Set autofocus to true if this textarea is focused, or if it has
|
||||
// autofocus and no other element is focused.
|
||||
if (options.autofocus == null) {
|
||||
var hasFocus = activeElt(textarea.ownerDocument);
|
||||
var hasFocus = activeElt(rootNode(textarea));
|
||||
options.autofocus = hasFocus == textarea ||
|
||||
textarea.getAttribute("autofocus") != null && hasFocus == document.body;
|
||||
}
|
||||
@ -9871,7 +9881,7 @@ var define = null; // Remove require.js support in this context.
|
||||
|
||||
addLegacyProps(CodeMirror);
|
||||
|
||||
CodeMirror.version = "5.65.15";
|
||||
CodeMirror.version = "5.65.16";
|
||||
|
||||
return CodeMirror;
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
Copyright (C) 2014 by Marijn Haverbeke <marijnh@gmail.com> and others
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2017 by Marijn Haverbeke <marijn@haverbeke.berlin> 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
|
||||
@ -16,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
THE SOFTWARE.
|
@ -112,13 +112,14 @@
|
||||
} while (child = child.parentNode)
|
||||
}
|
||||
|
||||
function activeElt(doc) {
|
||||
function activeElt(rootNode) {
|
||||
// IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
|
||||
// IE < 10 will throw when accessed while the page is loading or in an iframe.
|
||||
// IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
|
||||
var doc = rootNode.ownerDocument || rootNode;
|
||||
var activeElement;
|
||||
try {
|
||||
activeElement = doc.activeElement;
|
||||
activeElement = rootNode.activeElement;
|
||||
} catch(e) {
|
||||
activeElement = doc.body || null;
|
||||
}
|
||||
@ -146,6 +147,15 @@
|
||||
|
||||
function doc(cm) { return cm.display.wrapper.ownerDocument }
|
||||
|
||||
function root(cm) {
|
||||
return rootNode(cm.display.wrapper)
|
||||
}
|
||||
|
||||
function rootNode(element) {
|
||||
// Detect modern browsers (2017+).
|
||||
return element.getRootNode ? element.getRootNode() : element.ownerDocument
|
||||
}
|
||||
|
||||
function win(cm) { return doc(cm).defaultView }
|
||||
|
||||
function bind(f) {
|
||||
@ -3900,7 +3910,7 @@
|
||||
cm.display.maxLineChanged = false;
|
||||
}
|
||||
|
||||
var takeFocus = op.focus && op.focus == activeElt(doc(cm));
|
||||
var takeFocus = op.focus && op.focus == activeElt(root(cm));
|
||||
if (op.preparedSelection)
|
||||
{ cm.display.input.showSelection(op.preparedSelection, takeFocus); }
|
||||
if (op.updatedDisplay || op.startHeight != cm.doc.height)
|
||||
@ -4077,7 +4087,7 @@
|
||||
|
||||
function selectionSnapshot(cm) {
|
||||
if (cm.hasFocus()) { return null }
|
||||
var active = activeElt(doc(cm));
|
||||
var active = activeElt(root(cm));
|
||||
if (!active || !contains(cm.display.lineDiv, active)) { return null }
|
||||
var result = {activeElt: active};
|
||||
if (window.getSelection) {
|
||||
@ -4093,7 +4103,7 @@
|
||||
}
|
||||
|
||||
function restoreSelection(snapshot) {
|
||||
if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(snapshot.activeElt.ownerDocument)) { return }
|
||||
if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(rootNode(snapshot.activeElt))) { return }
|
||||
snapshot.activeElt.focus();
|
||||
if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) &&
|
||||
snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
|
||||
@ -7264,7 +7274,7 @@
|
||||
function onKeyDown(e) {
|
||||
var cm = this;
|
||||
if (e.target && e.target != cm.display.input.getField()) { return }
|
||||
cm.curOp.focus = activeElt(doc(cm));
|
||||
cm.curOp.focus = activeElt(root(cm));
|
||||
if (signalDOMEvent(cm, e)) { return }
|
||||
// IE does strange things with escape.
|
||||
if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; }
|
||||
@ -7426,7 +7436,7 @@
|
||||
|
||||
function leftButtonDown(cm, pos, repeat, event) {
|
||||
if (ie) { setTimeout(bind(ensureFocus, cm), 0); }
|
||||
else { cm.curOp.focus = activeElt(doc(cm)); }
|
||||
else { cm.curOp.focus = activeElt(root(cm)); }
|
||||
|
||||
var behavior = configureMouse(cm, repeat, event);
|
||||
|
||||
@ -7496,19 +7506,19 @@
|
||||
// Normal selection, as opposed to text dragging.
|
||||
function leftButtonSelect(cm, event, start, behavior) {
|
||||
if (ie) { delayBlurEvent(cm); }
|
||||
var display = cm.display, doc$1 = cm.doc;
|
||||
var display = cm.display, doc = cm.doc;
|
||||
e_preventDefault(event);
|
||||
|
||||
var ourRange, ourIndex, startSel = doc$1.sel, ranges = startSel.ranges;
|
||||
var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
|
||||
if (behavior.addNew && !behavior.extend) {
|
||||
ourIndex = doc$1.sel.contains(start);
|
||||
ourIndex = doc.sel.contains(start);
|
||||
if (ourIndex > -1)
|
||||
{ ourRange = ranges[ourIndex]; }
|
||||
else
|
||||
{ ourRange = new Range(start, start); }
|
||||
} else {
|
||||
ourRange = doc$1.sel.primary();
|
||||
ourIndex = doc$1.sel.primIndex;
|
||||
ourRange = doc.sel.primary();
|
||||
ourIndex = doc.sel.primIndex;
|
||||
}
|
||||
|
||||
if (behavior.unit == "rectangle") {
|
||||
@ -7525,18 +7535,18 @@
|
||||
|
||||
if (!behavior.addNew) {
|
||||
ourIndex = 0;
|
||||
setSelection(doc$1, new Selection([ourRange], 0), sel_mouse);
|
||||
startSel = doc$1.sel;
|
||||
setSelection(doc, new Selection([ourRange], 0), sel_mouse);
|
||||
startSel = doc.sel;
|
||||
} else if (ourIndex == -1) {
|
||||
ourIndex = ranges.length;
|
||||
setSelection(doc$1, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
|
||||
setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
|
||||
{scroll: false, origin: "*mouse"});
|
||||
} else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
|
||||
setSelection(doc$1, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
|
||||
setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
|
||||
{scroll: false, origin: "*mouse"});
|
||||
startSel = doc$1.sel;
|
||||
startSel = doc.sel;
|
||||
} else {
|
||||
replaceOneSelection(doc$1, ourIndex, ourRange, sel_mouse);
|
||||
replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
|
||||
}
|
||||
|
||||
var lastPos = start;
|
||||
@ -7546,19 +7556,19 @@
|
||||
|
||||
if (behavior.unit == "rectangle") {
|
||||
var ranges = [], tabSize = cm.options.tabSize;
|
||||
var startCol = countColumn(getLine(doc$1, start.line).text, start.ch, tabSize);
|
||||
var posCol = countColumn(getLine(doc$1, pos.line).text, pos.ch, tabSize);
|
||||
var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
|
||||
var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
|
||||
var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
|
||||
for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
|
||||
line <= end; line++) {
|
||||
var text = getLine(doc$1, line).text, leftPos = findColumn(text, left, tabSize);
|
||||
var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
|
||||
if (left == right)
|
||||
{ ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); }
|
||||
else if (text.length > leftPos)
|
||||
{ ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); }
|
||||
}
|
||||
if (!ranges.length) { ranges.push(new Range(start, start)); }
|
||||
setSelection(doc$1, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
|
||||
setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
|
||||
{origin: "*mouse", scroll: false});
|
||||
cm.scrollIntoView(pos);
|
||||
} else {
|
||||
@ -7573,8 +7583,8 @@
|
||||
anchor = maxPos(oldRange.to(), range.head);
|
||||
}
|
||||
var ranges$1 = startSel.ranges.slice(0);
|
||||
ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc$1, anchor), head));
|
||||
setSelection(doc$1, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
|
||||
ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head));
|
||||
setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7590,9 +7600,9 @@
|
||||
var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle");
|
||||
if (!cur) { return }
|
||||
if (cmp(cur, lastPos) != 0) {
|
||||
cm.curOp.focus = activeElt(doc(cm));
|
||||
cm.curOp.focus = activeElt(root(cm));
|
||||
extendTo(cur);
|
||||
var visible = visibleLines(display, doc$1);
|
||||
var visible = visibleLines(display, doc);
|
||||
if (cur.line >= visible.to || cur.line < visible.from)
|
||||
{ setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); }
|
||||
} else {
|
||||
@ -7617,7 +7627,7 @@
|
||||
}
|
||||
off(display.wrapper.ownerDocument, "mousemove", move);
|
||||
off(display.wrapper.ownerDocument, "mouseup", up);
|
||||
doc$1.history.lastSelOrigin = null;
|
||||
doc.history.lastSelOrigin = null;
|
||||
}
|
||||
|
||||
var move = operation(cm, function (e) {
|
||||
@ -8617,7 +8627,7 @@
|
||||
|
||||
signal(this, "overwriteToggle", this, this.state.overwrite);
|
||||
},
|
||||
hasFocus: function() { return this.display.input.getField() == activeElt(doc(this)) },
|
||||
hasFocus: function() { return this.display.input.getField() == activeElt(root(this)) },
|
||||
isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
|
||||
|
||||
scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }),
|
||||
@ -8899,7 +8909,7 @@
|
||||
disableBrowserMagic(te);
|
||||
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
|
||||
te.value = lastCopied.text.join("\n");
|
||||
var hadFocus = activeElt(div.ownerDocument);
|
||||
var hadFocus = activeElt(rootNode(div));
|
||||
selectInput(te);
|
||||
setTimeout(function () {
|
||||
cm.display.lineSpace.removeChild(kludge);
|
||||
@ -8922,7 +8932,7 @@
|
||||
|
||||
ContentEditableInput.prototype.prepareSelection = function () {
|
||||
var result = prepareSelection(this.cm, false);
|
||||
result.focus = activeElt(this.div.ownerDocument) == this.div;
|
||||
result.focus = activeElt(rootNode(this.div)) == this.div;
|
||||
return result
|
||||
};
|
||||
|
||||
@ -9018,7 +9028,7 @@
|
||||
|
||||
ContentEditableInput.prototype.focus = function () {
|
||||
if (this.cm.options.readOnly != "nocursor") {
|
||||
if (!this.selectionInEditor() || activeElt(this.div.ownerDocument) != this.div)
|
||||
if (!this.selectionInEditor() || activeElt(rootNode(this.div)) != this.div)
|
||||
{ this.showSelection(this.prepareSelection(), true); }
|
||||
this.div.focus();
|
||||
}
|
||||
@ -9526,7 +9536,7 @@
|
||||
TextareaInput.prototype.supportsTouch = function () { return false };
|
||||
|
||||
TextareaInput.prototype.focus = function () {
|
||||
if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(this.textarea.ownerDocument) != this.textarea)) {
|
||||
if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(rootNode(this.textarea)) != this.textarea)) {
|
||||
try { this.textarea.focus(); }
|
||||
catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
|
||||
}
|
||||
@ -9733,7 +9743,7 @@
|
||||
// Set autofocus to true if this textarea is focused, or if it has
|
||||
// autofocus and no other element is focused.
|
||||
if (options.autofocus == null) {
|
||||
var hasFocus = activeElt(textarea.ownerDocument);
|
||||
var hasFocus = activeElt(rootNode(textarea));
|
||||
options.autofocus = hasFocus == textarea ||
|
||||
textarea.getAttribute("autofocus") != null && hasFocus == document.body;
|
||||
}
|
||||
@ -9867,7 +9877,7 @@
|
||||
|
||||
addLegacyProps(CodeMirror);
|
||||
|
||||
CodeMirror.version = "5.65.15";
|
||||
CodeMirror.version = "5.65.16";
|
||||
|
||||
return CodeMirror;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user