update deps

This commit is contained in:
tophf 2022-08-05 17:50:31 +03:00
parent a832b51d9c
commit f9e6df116f
6 changed files with 2743 additions and 2481 deletions

4700
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@
}, },
"dependencies": { "dependencies": {
"@eight04/draggable-list": "^0.3.0", "@eight04/draggable-list": "^0.3.0",
"codemirror": "5.65.6", "codemirror": "5.65.7",
"db-to-cloud": "^0.7.0", "db-to-cloud": "^0.7.0",
"jsonlint": "^1.6.3", "jsonlint": "^1.6.3",
"less-bundle": "github:openstyles/less-bundle#v0.1.0", "less-bundle": "github:openstyles/less-bundle#v0.1.0",
@ -21,13 +21,13 @@
"webext-launch-web-auth-flow": "^0.1.1" "webext-launch-web-auth-flow": "^0.1.1"
}, },
"devDependencies": { "devDependencies": {
"archiver": "^4.0.1", "archiver": "^5.3.1",
"eslint": "^7.20.0", "eslint": "^8.21.0",
"fs-extra": "^9.0.0", "fs-extra": "^10.1.0",
"glob": "^7.2.0", "glob": "^8.0.3",
"node-fetch": "^2.6.7", "node-fetch": "^2.6.7",
"sync-version": "^1.0.1", "sync-version": "^1.0.1",
"web-ext": "^6.5.0" "web-ext": "^6.8.0"
}, },
"scripts": { "scripts": {
"lint": "eslint \"**/*.js\" --cache", "lint": "eslint \"**/*.js\" --cache",

View File

@ -1,4 +1,4 @@
## codemirror v5.65.6 ## codemirror v5.65.7
Files copied from NPM (node_modules): Files copied from NPM (node_modules):
* addon/comment/comment.js * addon/comment/comment.js

View File

@ -1,3 +1,12 @@
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../lib/codemirror"), require("../addon/search/searchcursor"), require("../addon/dialog/dialog"), require("../addon/edit/matchbrackets.js"));
else if (typeof define == "function" && define.amd) // AMD
define(["../lib/codemirror", "../addon/search/searchcursor", "../addon/dialog/dialog", "../addon/edit/matchbrackets"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
'use strict';
// CodeMirror, copyright (c) by Marijn Haverbeke and others // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/5/LICENSE // Distributed under an MIT license: https://codemirror.net/5/LICENSE
@ -34,15 +43,7 @@
* 9. Ex command implementations. * 9. Ex command implementations.
*/ */
(function(mod) { function initVim$1(CodeMirror) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../lib/codemirror"), require("../addon/search/searchcursor"), require("../addon/dialog/dialog"), require("../addon/edit/matchbrackets.js"));
else if (typeof define == "function" && define.amd) // AMD
define(["../lib/codemirror", "../addon/search/searchcursor", "../addon/dialog/dialog", "../addon/edit/matchbrackets"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
'use strict';
var Pos = CodeMirror.Pos; var Pos = CodeMirror.Pos;
@ -87,6 +88,8 @@
{ keys: '<C-c>', type: 'keyToKey', toKeys: '<Esc>' }, { keys: '<C-c>', type: 'keyToKey', toKeys: '<Esc>' },
{ keys: '<C-[>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' }, { keys: '<C-[>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
{ keys: '<C-c>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' }, { keys: '<C-c>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
{ keys: '<C-Esc>', type: 'keyToKey', toKeys: '<Esc>' }, // ipad keyboard sends C-Esc instead of C-[
{ keys: '<C-Esc>', type: 'keyToKey', toKeys: '<Esc>', context: 'insert' },
{ keys: 's', type: 'keyToKey', toKeys: 'cl', context: 'normal' }, { keys: 's', type: 'keyToKey', toKeys: 'cl', context: 'normal' },
{ keys: 's', type: 'keyToKey', toKeys: 'c', context: 'visual'}, { keys: 's', type: 'keyToKey', toKeys: 'c', context: 'visual'},
{ keys: 'S', type: 'keyToKey', toKeys: 'cc', context: 'normal' }, { keys: 'S', type: 'keyToKey', toKeys: 'cc', context: 'normal' },
@ -225,8 +228,8 @@
{ keys: 'z.', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, { keys: 'z.', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'center' }, motion: 'moveToFirstNonWhiteSpaceCharacter' },
{ keys: 'zt', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }}, { keys: 'zt', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }},
{ keys: 'z<CR>', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, { keys: 'z<CR>', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'top' }, motion: 'moveToFirstNonWhiteSpaceCharacter' },
{ keys: 'z-', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'bottom' }}, { keys: 'zb', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'bottom' }},
{ keys: 'zb', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'bottom' }, motion: 'moveToFirstNonWhiteSpaceCharacter' }, { keys: 'z-', type: 'action', action: 'scrollToCursor', actionArgs: { position: 'bottom' }, motion: 'moveToFirstNonWhiteSpaceCharacter' },
{ keys: '.', type: 'action', action: 'repeatLastEdit' }, { keys: '.', type: 'action', action: 'repeatLastEdit' },
{ keys: '<C-a>', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: true, backtrack: false}}, { keys: '<C-a>', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: true, backtrack: false}},
{ keys: '<C-x>', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: false, backtrack: false}}, { keys: '<C-x>', type: 'action', action: 'incrementNumberToken', isEdit: true, actionArgs: {increase: false, backtrack: false}},
@ -276,7 +279,6 @@
{ name: 'global', shortName: 'g' } { name: 'global', shortName: 'g' }
]; ];
var Vim = function() {
function enterVimMode(cm) { function enterVimMode(cm) {
cm.setOption('disableInput', true); cm.setOption('disableInput', true);
cm.setOption('showCursorWhenSelecting', false); cm.setOption('showCursorWhenSelecting', false);
@ -642,8 +644,8 @@
register.clear(); register.clear();
this.latestRegister = registerName; this.latestRegister = registerName;
if (cm.openDialog) { if (cm.openDialog) {
this.onRecordingDone = cm.openDialog( var template = dom('span', {class: 'cm-vim-message'}, 'recording @' + registerName);
document.createTextNode('(recording)['+registerName+']'), null, {bottom:true}); this.onRecordingDone = cm.openDialog(template, null, {bottom:true});
} }
this.isRecording = true; this.isRecording = true;
} }
@ -717,6 +719,7 @@
var lastInsertModeKeyTimer; var lastInsertModeKeyTimer;
var vimApi = { var vimApi = {
enterVimMode: enterVimMode,
buildKeyMap: function() { buildKeyMap: function() {
// TODO: Convert keymap into dictionary format for fast lookup. // TODO: Convert keymap into dictionary format for fast lookup.
}, },
@ -838,6 +841,8 @@
return command(); return command();
} }
}, },
multiSelectHandleKey: multiSelectHandleKey,
/** /**
* This is the outermost function called by CodeMirror, after keys have * This is the outermost function called by CodeMirror, after keys have
* been mapped to their Vim equivalents. * been mapped to their Vim equivalents.
@ -943,9 +948,10 @@
var match = commandDispatcher.matchCommand(mainKey, defaultKeymap, vim.inputState, context); var match = commandDispatcher.matchCommand(mainKey, defaultKeymap, vim.inputState, context);
if (match.type == 'none') { clearInputState(cm); return false; } if (match.type == 'none') { clearInputState(cm); return false; }
else if (match.type == 'partial') { return true; } else if (match.type == 'partial') { return true; }
else if (match.type == 'clear') { clearInputState(cm); return true; }
vim.inputState.keyBuffer = ''; vim.inputState.keyBuffer = '';
var keysMatcher = /^(\d*)(.*)$/.exec(keys); keysMatcher = /^(\d*)(.*)$/.exec(keys);
if (keysMatcher[1] && keysMatcher[1] != '0') { if (keysMatcher[1] && keysMatcher[1] != '0') {
vim.inputState.pushRepeatDigit(keysMatcher[1]); vim.inputState.pushRepeatDigit(keysMatcher[1]);
} }
@ -1247,7 +1253,7 @@
} }
if (bestMatch.keys.slice(-11) == '<character>') { if (bestMatch.keys.slice(-11) == '<character>') {
var character = lastChar(keys); var character = lastChar(keys);
if (!character) return {type: 'none'}; if (!character || character.length > 1) return {type: 'clear'};
inputState.selectedCharacter = character; inputState.selectedCharacter = character;
} }
return {type: 'full', command: bestMatch}; return {type: 'full', command: bestMatch};
@ -1274,8 +1280,6 @@
case 'keyToEx': case 'keyToEx':
this.processEx(cm, vim, command); this.processEx(cm, vim, command);
break; break;
default:
break;
} }
}, },
processMotion: function(cm, vim, command) { processMotion: function(cm, vim, command) {
@ -1491,6 +1495,7 @@
vimGlobalState.exCommandHistoryController.pushInput(input); vimGlobalState.exCommandHistoryController.pushInput(input);
vimGlobalState.exCommandHistoryController.reset(); vimGlobalState.exCommandHistoryController.reset();
exCommandDispatcher.processCommand(cm, input); exCommandDispatcher.processCommand(cm, input);
clearInputState(cm);
} }
function onPromptKeyDown(e, input, close) { function onPromptKeyDown(e, input, close) {
var keyName = CodeMirror.keyName(e), up, offset; var keyName = CodeMirror.keyName(e), up, offset;
@ -2011,7 +2016,7 @@
} }
var orig = cm.charCoords(head, 'local'); var orig = cm.charCoords(head, 'local');
motionArgs.repeat = repeat; motionArgs.repeat = repeat;
var curEnd = motions.moveByDisplayLines(cm, head, motionArgs, vim); curEnd = motions.moveByDisplayLines(cm, head, motionArgs, vim);
if (!curEnd) { if (!curEnd) {
return null; return null;
} }
@ -2154,6 +2159,20 @@
} }
} else if (character === 't') { } else if (character === 't') {
tmp = expandTagUnderCursor(cm, head, inclusive); tmp = expandTagUnderCursor(cm, head, inclusive);
} else if (character === 's') {
// account for cursor on end of sentence symbol
var content = cm.getLine(head.line);
if (head.ch > 0 && isEndOfSentenceSymbol(content[head.ch])) {
head.ch -= 1;
}
var end = getSentence(cm, head, motionArgs.repeat, 1, inclusive);
var start = getSentence(cm, head, motionArgs.repeat, -1, inclusive);
// closer vim behaviour, 'a' only takes the space after the sentence if there is one before and after
if (isWhiteSpaceString(cm.getLine(start.line)[start.ch])
&& isWhiteSpaceString(cm.getLine(end.line)[end.ch -1])) {
start = {line: start.line, ch: start.ch + 1};
}
tmp = {start: start, end: end};
} else { } else {
// No text object defined for this, don't move. // No text object defined for this, don't move.
return null; return null;
@ -2236,7 +2255,7 @@
} else if (args.fullLine) { } else if (args.fullLine) {
head.ch = Number.MAX_VALUE; head.ch = Number.MAX_VALUE;
head.line--; head.line--;
cm.setSelection(anchor, head) cm.setSelection(anchor, head);
text = cm.getSelection(); text = cm.getSelection();
cm.replaceSelection(""); cm.replaceSelection("");
finalHead = anchor; finalHead = anchor;
@ -2288,6 +2307,13 @@
}, },
indent: function(cm, args, ranges) { indent: function(cm, args, ranges) {
var vim = cm.state.vim; var vim = cm.state.vim;
if (cm.indentMore) {
var repeat = (vim.visualMode) ? args.repeat : 1;
for (var j = 0; j < repeat; j++) {
if (args.indentRight) cm.indentMore();
else cm.indentLess();
}
} else {
var startLine = ranges[0].anchor.line; var startLine = ranges[0].anchor.line;
var endLine = vim.visualBlock ? var endLine = vim.visualBlock ?
ranges[ranges.length - 1].anchor.line : ranges[ranges.length - 1].anchor.line :
@ -2306,6 +2332,7 @@
cm.indentLine(i, args.indentRight); cm.indentLine(i, args.indentRight);
} }
} }
}
return motions.moveToFirstNonWhiteSpaceCharacter(cm, ranges[0].anchor); return motions.moveToFirstNonWhiteSpaceCharacter(cm, ranges[0].anchor);
}, },
indentAuto: function(cm, _args, ranges) { indentAuto: function(cm, _args, ranges) {
@ -2416,11 +2443,14 @@
var charCoords = cm.charCoords(new Pos(lineNum, 0), 'local'); var charCoords = cm.charCoords(new Pos(lineNum, 0), 'local');
var height = cm.getScrollInfo().clientHeight; var height = cm.getScrollInfo().clientHeight;
var y = charCoords.top; var y = charCoords.top;
var lineHeight = charCoords.bottom - y;
switch (actionArgs.position) { switch (actionArgs.position) {
case 'center': y = y - (height / 2) + lineHeight; case 'center': y = charCoords.bottom - height / 2;
break; break;
case 'bottom': y = y - height + lineHeight; case 'bottom':
var lineLastCharPos = new Pos(lineNum, cm.getLine(lineNum).length - 1);
var lineLastCharCoords = cm.charCoords(lineLastCharPos, 'local');
var lineHeight = lineLastCharCoords.bottom - y;
y = y - height + lineHeight;
break; break;
} }
cm.scrollTo(null, y); cm.scrollTo(null, y);
@ -2870,13 +2900,13 @@
} }
if (!actionArgs.backtrack && (end <= cur.ch))return; if (!actionArgs.backtrack && (end <= cur.ch))return;
if (match) { if (match) {
var baseStr = match[2] || match[4] var baseStr = match[2] || match[4];
var digits = match[3] || match[5] var digits = match[3] || match[5];
var increment = actionArgs.increase ? 1 : -1; var increment = actionArgs.increase ? 1 : -1;
var base = {'0b': 2, '0': 8, '': 10, '0x': 16}[baseStr.toLowerCase()]; var base = {'0b': 2, '0': 8, '': 10, '0x': 16}[baseStr.toLowerCase()];
var number = parseInt(match[1] + digits, base) + (increment * actionArgs.repeat); var number = parseInt(match[1] + digits, base) + (increment * actionArgs.repeat);
numberStr = number.toString(base); numberStr = number.toString(base);
var zeroPadding = baseStr ? new Array(digits.length - numberStr.length + 1 + match[1].length).join('0') : '' var zeroPadding = baseStr ? new Array(digits.length - numberStr.length + 1 + match[1].length).join('0') : '';
if (numberStr.charAt(0) === '-') { if (numberStr.charAt(0) === '-') {
numberStr = '-' + baseStr + zeroPadding + numberStr.substr(1); numberStr = '-' + baseStr + zeroPadding + numberStr.substr(1);
} else { } else {
@ -3248,9 +3278,8 @@
fromCh = anchor.ch, fromCh = anchor.ch,
bottom = Math.max(anchor.line, head.line), bottom = Math.max(anchor.line, head.line),
toCh = head.ch; toCh = head.ch;
if (fromCh < toCh) { toCh += 1 } if (fromCh < toCh) { toCh += 1; }
else { fromCh += 1 }; else { fromCh += 1; } var height = bottom - top + 1;
var height = bottom - top + 1;
var primary = head.line == top ? 0 : height - 1; var primary = head.line == top ? 0 : height - 1;
var ranges = []; var ranges = [];
for (var i = 0; i < height; i++) { for (var i = 0; i < height; i++) {
@ -3802,6 +3831,141 @@
start = new Pos(i, 0); start = new Pos(i, 0);
return { start: start, end: end }; return { start: start, end: end };
} }
function getSentence(cm, cur, repeat, dir, inclusive /*includes whitespace*/) {
/*
Takes an index object
{
line: the line string,
ln: line number,
pos: index in line,
dir: direction of traversal (-1 or 1)
}
and modifies the pos member to represent the
next valid position or sets the line to null if there are
no more valid positions.
*/
function nextChar(curr) {
if (curr.pos + curr.dir < 0 || curr.pos + curr.dir >= curr.line.length) {
curr.line = null;
}
else {
curr.pos += curr.dir;
}
}
/*
Performs one iteration of traversal in forward direction
Returns an index object of the new location
*/
function forward(cm, ln, pos, dir) {
var line = cm.getLine(ln);
var curr = {
line: line,
ln: ln,
pos: pos,
dir: dir,
};
if (curr.line === "") {
return { ln: curr.ln, pos: curr.pos };
}
var lastSentencePos = curr.pos;
// Move one step to skip character we start on
nextChar(curr);
while (curr.line !== null) {
lastSentencePos = curr.pos;
if (isEndOfSentenceSymbol(curr.line[curr.pos])) {
if (!inclusive) {
return { ln: curr.ln, pos: curr.pos + 1 };
} else {
nextChar(curr);
while (curr.line !== null ) {
if (isWhiteSpaceString(curr.line[curr.pos])) {
lastSentencePos = curr.pos;
nextChar(curr);
} else {
break;
}
}
return { ln: curr.ln, pos: lastSentencePos + 1, };
}
}
nextChar(curr);
}
return { ln: curr.ln, pos: lastSentencePos + 1 };
}
/*
Performs one iteration of traversal in reverse direction
Returns an index object of the new location
*/
function reverse(cm, ln, pos, dir) {
var line = cm.getLine(ln);
var curr = {
line: line,
ln: ln,
pos: pos,
dir: dir,
};
if (curr.line === "") {
return { ln: curr.ln, pos: curr.pos };
}
var lastSentencePos = curr.pos;
// Move one step to skip character we start on
nextChar(curr);
while (curr.line !== null) {
if (!isWhiteSpaceString(curr.line[curr.pos]) && !isEndOfSentenceSymbol(curr.line[curr.pos])) {
lastSentencePos = curr.pos;
}
else if (isEndOfSentenceSymbol(curr.line[curr.pos]) ) {
if (!inclusive) {
return { ln: curr.ln, pos: lastSentencePos };
} else {
if (isWhiteSpaceString(curr.line[curr.pos + 1])) {
return { ln: curr.ln, pos: curr.pos + 1, };
} else {
return {ln: curr.ln, pos: lastSentencePos};
}
}
}
nextChar(curr);
}
curr.line = line;
if (inclusive && isWhiteSpaceString(curr.line[curr.pos])) {
return { ln: curr.ln, pos: curr.pos };
} else {
return { ln: curr.ln, pos: lastSentencePos };
}
}
var curr_index = {
ln: cur.line,
pos: cur.ch,
};
while (repeat > 0) {
if (dir < 0) {
curr_index = reverse(cm, curr_index.ln, curr_index.pos, dir);
}
else {
curr_index = forward(cm, curr_index.ln, curr_index.pos, dir);
}
repeat--;
}
return new Pos(curr_index.ln, curr_index.pos);
}
function findSentence(cm, cur, repeat, dir) { function findSentence(cm, cur, repeat, dir) {
@ -3847,12 +4011,12 @@
ln: ln, ln: ln,
pos: pos, pos: pos,
dir: dir, dir: dir,
} };
var last_valid = { var last_valid = {
ln: curr.ln, ln: curr.ln,
pos: curr.pos, pos: curr.pos,
} };
var skip_empty_lines = (curr.line === ""); var skip_empty_lines = (curr.line === "");
@ -3908,7 +4072,7 @@
ln: ln, ln: ln,
pos: pos, pos: pos,
dir: dir, dir: dir,
} };
var last_valid = { var last_valid = {
ln: curr.ln, ln: curr.ln,
@ -3937,7 +4101,7 @@
} }
else if (curr.line !== "" && !isWhiteSpaceString(curr.line[curr.pos])) { else if (curr.line !== "" && !isWhiteSpaceString(curr.line[curr.pos])) {
skip_empty_lines = false; skip_empty_lines = false;
last_valid = { ln: curr.ln, pos: curr.pos } last_valid = { ln: curr.ln, pos: curr.pos };
} }
nextChar(cm, curr); nextChar(cm, curr);
@ -4329,7 +4493,7 @@
} }
function showConfirm(cm, template) { function showConfirm(cm, template) {
var pre = dom('pre', {$color: 'red', class: 'cm-vim-message'}, template); var pre = dom('div', {$color: 'red', $whiteSpace: 'pre', class: 'cm-vim-message'}, template);
if (cm.openNotification) { if (cm.openNotification) {
cm.openNotification(pre, {bottom: true, duration: 5000}); cm.openNotification(pre, {bottom: true, duration: 5000});
} else { } else {
@ -4924,7 +5088,7 @@
for (var registerName in registers) { for (var registerName in registers) {
var text = registers[registerName].toString(); var text = registers[registerName].toString();
if (text.length) { if (text.length) {
regInfo += '"' + registerName + ' ' + text + '\n' regInfo += '"' + registerName + ' ' + text + '\n';
} }
} }
} else { } else {
@ -4936,7 +5100,7 @@
continue; continue;
} }
var register = registers[registerName] || new Register(); var register = registers[registerName] || new Register();
regInfo += '"' + registerName + ' ' + register.toString() + '\n' regInfo += '"' + registerName + ' ' + register.toString() + '\n';
} }
} }
showConfirm(cm, regInfo); showConfirm(cm, regInfo);
@ -5730,9 +5894,85 @@
} }
} }
resetVimGlobalState(); // multiselect support
return vimApi; function cloneVimState(state) {
}; var n = new state.constructor();
// Initialize Vim and make it available as an API. Object.keys(state).forEach(function(key) {
CodeMirror.Vim = Vim(); var o = state[key];
if (Array.isArray(o))
o = o.slice();
else if (o && typeof o == "object" && o.constructor != Object)
o = cloneVimState(o);
n[key] = o;
}); });
if (state.sel) {
n.sel = {
head: state.sel.head && copyCursor(state.sel.head),
anchor: state.sel.anchor && copyCursor(state.sel.anchor)
};
}
return n;
}
function multiSelectHandleKey(cm, key, origin) {
var isHandled = false;
var vim = vimApi.maybeInitVimState_(cm);
var visualBlock = vim.visualBlock || vim.wasInVisualBlock;
var wasMultiselect = cm.isInMultiSelectMode();
if (vim.wasInVisualBlock && !wasMultiselect) {
vim.wasInVisualBlock = false;
} else if (wasMultiselect && vim.visualBlock) {
vim.wasInVisualBlock = true;
}
if (key == '<Esc>' && !vim.insertMode && !vim.visualMode && wasMultiselect && vim.status == "<Esc>") {
// allow editor to exit multiselect
clearInputState(cm);
} else if (visualBlock || !wasMultiselect || cm.inVirtualSelectionMode) {
isHandled = vimApi.handleKey(cm, key, origin);
} else {
var old = cloneVimState(vim);
cm.operation(function() {
cm.curOp.isVimOp = true;
cm.forEachSelection(function() {
var head = cm.getCursor("head");
var anchor = cm.getCursor("anchor");
var headOffset = !cursorIsBefore(head, anchor) ? -1 : 0;
var anchorOffset = cursorIsBefore(head, anchor) ? -1 : 0;
head = offsetCursor(head, 0, headOffset);
anchor = offsetCursor(anchor, 0, anchorOffset);
cm.state.vim.sel.head = head;
cm.state.vim.sel.anchor = anchor;
isHandled = vimApi.handleKey(cm, key, origin);
if (cm.virtualSelection) {
cm.state.vim = cloneVimState(old);
}
});
if (cm.curOp.cursorActivity && !isHandled)
cm.curOp.cursorActivity = false;
cm.state.vim = vim;
}, true);
}
// some commands may bring visualMode and selection out of sync
if (isHandled && !vim.visualMode && !vim.insert && vim.visualMode != cm.somethingSelected()) {
handleExternalSelection(cm, vim);
}
return isHandled;
}
resetVimGlobalState();
return vimApi;
}
function initVim(CodeMirror5) {
CodeMirror5.Vim = initVim$1(CodeMirror5);
return CodeMirror5.Vim;
}
CodeMirror.Vim = initVim(CodeMirror);
});

View File

@ -112,15 +112,15 @@
} while (child = child.parentNode) } while (child = child.parentNode)
} }
function activeElt() { function activeElt(doc) {
// IE and Edge may throw an "Unspecified Error" when accessing document.activeElement. // 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 < 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. // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
var activeElement; var activeElement;
try { try {
activeElement = document.activeElement; activeElement = doc.activeElement;
} catch(e) { } catch(e) {
activeElement = document.body || null; activeElement = doc.body || null;
} }
while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement) while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)
{ activeElement = activeElement.shadowRoot.activeElement; } { activeElement = activeElement.shadowRoot.activeElement; }
@ -144,6 +144,10 @@
else if (ie) // Suppress mysterious IE10 errors else if (ie) // Suppress mysterious IE10 errors
{ selectInput = function(node) { try { node.select(); } catch(_e) {} }; } { selectInput = function(node) { try { node.select(); } catch(_e) {} }; }
function doc(cm) { return cm.display.wrapper.ownerDocument }
function win(cm) { return doc(cm).defaultView }
function bind(f) { function bind(f) {
var args = Array.prototype.slice.call(arguments, 1); var args = Array.prototype.slice.call(arguments, 1);
return function(){return f.apply(null, args)} return function(){return f.apply(null, args)}
@ -2573,16 +2577,16 @@
cm.display.lineNumChars = null; cm.display.lineNumChars = null;
} }
function pageScrollX() { function pageScrollX(doc) {
// Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206 // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206
// which causes page_Offset and bounding client rects to use // which causes page_Offset and bounding client rects to use
// different reference viewports and invalidate our calculations. // different reference viewports and invalidate our calculations.
if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) } if (chrome && android) { return -(doc.body.getBoundingClientRect().left - parseInt(getComputedStyle(doc.body).marginLeft)) }
return window.pageXOffset || (document.documentElement || document.body).scrollLeft return doc.defaultView.pageXOffset || (doc.documentElement || doc.body).scrollLeft
} }
function pageScrollY() { function pageScrollY(doc) {
if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) } if (chrome && android) { return -(doc.body.getBoundingClientRect().top - parseInt(getComputedStyle(doc.body).marginTop)) }
return window.pageYOffset || (document.documentElement || document.body).scrollTop return doc.defaultView.pageYOffset || (doc.documentElement || doc.body).scrollTop
} }
function widgetTopHeight(lineObj) { function widgetTopHeight(lineObj) {
@ -2610,8 +2614,8 @@
else { yOff -= cm.display.viewOffset; } else { yOff -= cm.display.viewOffset; }
if (context == "page" || context == "window") { if (context == "page" || context == "window") {
var lOff = cm.display.lineSpace.getBoundingClientRect(); var lOff = cm.display.lineSpace.getBoundingClientRect();
yOff += lOff.top + (context == "window" ? 0 : pageScrollY()); yOff += lOff.top + (context == "window" ? 0 : pageScrollY(doc(cm)));
var xOff = lOff.left + (context == "window" ? 0 : pageScrollX()); var xOff = lOff.left + (context == "window" ? 0 : pageScrollX(doc(cm)));
rect.left += xOff; rect.right += xOff; rect.left += xOff; rect.right += xOff;
} }
rect.top += yOff; rect.bottom += yOff; rect.top += yOff; rect.bottom += yOff;
@ -2625,8 +2629,8 @@
var left = coords.left, top = coords.top; var left = coords.left, top = coords.top;
// First move into "page" coordinate system // First move into "page" coordinate system
if (context == "page") { if (context == "page") {
left -= pageScrollX(); left -= pageScrollX(doc(cm));
top -= pageScrollY(); top -= pageScrollY(doc(cm));
} else if (context == "local" || !context) { } else if (context == "local" || !context) {
var localBox = cm.display.sizer.getBoundingClientRect(); var localBox = cm.display.sizer.getBoundingClientRect();
left += localBox.left; left += localBox.left;
@ -3442,8 +3446,9 @@
if (signalDOMEvent(cm, "scrollCursorIntoView")) { return } if (signalDOMEvent(cm, "scrollCursorIntoView")) { return }
var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
var doc = display.wrapper.ownerDocument;
if (rect.top + box.top < 0) { doScroll = true; } if (rect.top + box.top < 0) { doScroll = true; }
else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; } else if (rect.bottom + box.top > (doc.defaultView.innerHeight || doc.documentElement.clientHeight)) { doScroll = false; }
if (doScroll != null && !phantom) { if (doScroll != null && !phantom) {
var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;")); var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;"));
cm.display.lineSpace.appendChild(scrollNode); cm.display.lineSpace.appendChild(scrollNode);
@ -3895,7 +3900,7 @@
cm.display.maxLineChanged = false; cm.display.maxLineChanged = false;
} }
var takeFocus = op.focus && op.focus == activeElt(); var takeFocus = op.focus && op.focus == activeElt(doc(cm));
if (op.preparedSelection) if (op.preparedSelection)
{ cm.display.input.showSelection(op.preparedSelection, takeFocus); } { cm.display.input.showSelection(op.preparedSelection, takeFocus); }
if (op.updatedDisplay || op.startHeight != cm.doc.height) if (op.updatedDisplay || op.startHeight != cm.doc.height)
@ -4072,11 +4077,11 @@
function selectionSnapshot(cm) { function selectionSnapshot(cm) {
if (cm.hasFocus()) { return null } if (cm.hasFocus()) { return null }
var active = activeElt(); var active = activeElt(doc(cm));
if (!active || !contains(cm.display.lineDiv, active)) { return null } if (!active || !contains(cm.display.lineDiv, active)) { return null }
var result = {activeElt: active}; var result = {activeElt: active};
if (window.getSelection) { if (window.getSelection) {
var sel = window.getSelection(); var sel = win(cm).getSelection();
if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) { if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) {
result.anchorNode = sel.anchorNode; result.anchorNode = sel.anchorNode;
result.anchorOffset = sel.anchorOffset; result.anchorOffset = sel.anchorOffset;
@ -4088,11 +4093,12 @@
} }
function restoreSelection(snapshot) { function restoreSelection(snapshot) {
if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return } if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt(snapshot.activeElt.ownerDocument)) { return }
snapshot.activeElt.focus(); snapshot.activeElt.focus();
if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) && if (!/^(INPUT|TEXTAREA)$/.test(snapshot.activeElt.nodeName) &&
snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) { snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
var sel = window.getSelection(), range = document.createRange(); var doc = snapshot.activeElt.ownerDocument;
var sel = doc.defaultView.getSelection(), range = doc.createRange();
range.setEnd(snapshot.anchorNode, snapshot.anchorOffset); range.setEnd(snapshot.anchorNode, snapshot.anchorOffset);
range.collapse(false); range.collapse(false);
sel.removeAllRanges(); sel.removeAllRanges();
@ -4513,7 +4519,7 @@
// On Chrome 102, viewport updates somehow stop wheel-based // On Chrome 102, viewport updates somehow stop wheel-based
// scrolling. Turning off pointer events during the scroll seems // scrolling. Turning off pointer events during the scroll seems
// to avoid the issue. // to avoid the issue.
if (chrome && chrome_version >= 102) { if (chrome && chrome_version == 102) {
if (cm.display.chromeScrollHack == null) { cm.display.sizer.style.pointerEvents = "none"; } if (cm.display.chromeScrollHack == null) { cm.display.sizer.style.pointerEvents = "none"; }
else { clearTimeout(cm.display.chromeScrollHack); } else { clearTimeout(cm.display.chromeScrollHack); }
cm.display.chromeScrollHack = setTimeout(function () { cm.display.chromeScrollHack = setTimeout(function () {
@ -7256,7 +7262,7 @@
function onKeyDown(e) { function onKeyDown(e) {
var cm = this; var cm = this;
if (e.target && e.target != cm.display.input.getField()) { return } if (e.target && e.target != cm.display.input.getField()) { return }
cm.curOp.focus = activeElt(); cm.curOp.focus = activeElt(doc(cm));
if (signalDOMEvent(cm, e)) { return } if (signalDOMEvent(cm, e)) { return }
// IE does strange things with escape. // IE does strange things with escape.
if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; } if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; }
@ -7363,7 +7369,7 @@
} }
if (clickInGutter(cm, e)) { return } if (clickInGutter(cm, e)) { return }
var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single"; var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single";
window.focus(); win(cm).focus();
// #3261: make sure, that we're not starting a second selection // #3261: make sure, that we're not starting a second selection
if (button == 1 && cm.state.selectingText) if (button == 1 && cm.state.selectingText)
@ -7418,7 +7424,7 @@
function leftButtonDown(cm, pos, repeat, event) { function leftButtonDown(cm, pos, repeat, event) {
if (ie) { setTimeout(bind(ensureFocus, cm), 0); } if (ie) { setTimeout(bind(ensureFocus, cm), 0); }
else { cm.curOp.focus = activeElt(); } else { cm.curOp.focus = activeElt(doc(cm)); }
var behavior = configureMouse(cm, repeat, event); var behavior = configureMouse(cm, repeat, event);
@ -7488,19 +7494,19 @@
// Normal selection, as opposed to text dragging. // Normal selection, as opposed to text dragging.
function leftButtonSelect(cm, event, start, behavior) { function leftButtonSelect(cm, event, start, behavior) {
if (ie) { delayBlurEvent(cm); } if (ie) { delayBlurEvent(cm); }
var display = cm.display, doc = cm.doc; var display = cm.display, doc$1 = cm.doc;
e_preventDefault(event); e_preventDefault(event);
var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges; var ourRange, ourIndex, startSel = doc$1.sel, ranges = startSel.ranges;
if (behavior.addNew && !behavior.extend) { if (behavior.addNew && !behavior.extend) {
ourIndex = doc.sel.contains(start); ourIndex = doc$1.sel.contains(start);
if (ourIndex > -1) if (ourIndex > -1)
{ ourRange = ranges[ourIndex]; } { ourRange = ranges[ourIndex]; }
else else
{ ourRange = new Range(start, start); } { ourRange = new Range(start, start); }
} else { } else {
ourRange = doc.sel.primary(); ourRange = doc$1.sel.primary();
ourIndex = doc.sel.primIndex; ourIndex = doc$1.sel.primIndex;
} }
if (behavior.unit == "rectangle") { if (behavior.unit == "rectangle") {
@ -7517,18 +7523,18 @@
if (!behavior.addNew) { if (!behavior.addNew) {
ourIndex = 0; ourIndex = 0;
setSelection(doc, new Selection([ourRange], 0), sel_mouse); setSelection(doc$1, new Selection([ourRange], 0), sel_mouse);
startSel = doc.sel; startSel = doc$1.sel;
} else if (ourIndex == -1) { } else if (ourIndex == -1) {
ourIndex = ranges.length; ourIndex = ranges.length;
setSelection(doc, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex), setSelection(doc$1, normalizeSelection(cm, ranges.concat([ourRange]), ourIndex),
{scroll: false, origin: "*mouse"}); {scroll: false, origin: "*mouse"});
} else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) { } else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
setSelection(doc, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0), setSelection(doc$1, normalizeSelection(cm, ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
{scroll: false, origin: "*mouse"}); {scroll: false, origin: "*mouse"});
startSel = doc.sel; startSel = doc$1.sel;
} else { } else {
replaceOneSelection(doc, ourIndex, ourRange, sel_mouse); replaceOneSelection(doc$1, ourIndex, ourRange, sel_mouse);
} }
var lastPos = start; var lastPos = start;
@ -7538,19 +7544,19 @@
if (behavior.unit == "rectangle") { if (behavior.unit == "rectangle") {
var ranges = [], tabSize = cm.options.tabSize; var ranges = [], tabSize = cm.options.tabSize;
var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize); var startCol = countColumn(getLine(doc$1, start.line).text, start.ch, tabSize);
var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize); var posCol = countColumn(getLine(doc$1, pos.line).text, pos.ch, tabSize);
var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol); 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)); for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
line <= end; line++) { line <= end; line++) {
var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize); var text = getLine(doc$1, line).text, leftPos = findColumn(text, left, tabSize);
if (left == right) if (left == right)
{ ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); } { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); }
else if (text.length > leftPos) else if (text.length > leftPos)
{ ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); } { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); }
} }
if (!ranges.length) { ranges.push(new Range(start, start)); } if (!ranges.length) { ranges.push(new Range(start, start)); }
setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), setSelection(doc$1, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
{origin: "*mouse", scroll: false}); {origin: "*mouse", scroll: false});
cm.scrollIntoView(pos); cm.scrollIntoView(pos);
} else { } else {
@ -7565,8 +7571,8 @@
anchor = maxPos(oldRange.to(), range.head); anchor = maxPos(oldRange.to(), range.head);
} }
var ranges$1 = startSel.ranges.slice(0); var ranges$1 = startSel.ranges.slice(0);
ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head)); ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc$1, anchor), head));
setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse); setSelection(doc$1, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
} }
} }
@ -7582,9 +7588,9 @@
var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle"); var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle");
if (!cur) { return } if (!cur) { return }
if (cmp(cur, lastPos) != 0) { if (cmp(cur, lastPos) != 0) {
cm.curOp.focus = activeElt(); cm.curOp.focus = activeElt(doc(cm));
extendTo(cur); extendTo(cur);
var visible = visibleLines(display, doc); var visible = visibleLines(display, doc$1);
if (cur.line >= visible.to || cur.line < visible.from) if (cur.line >= visible.to || cur.line < visible.from)
{ setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); } { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); }
} else { } else {
@ -7609,7 +7615,7 @@
} }
off(display.wrapper.ownerDocument, "mousemove", move); off(display.wrapper.ownerDocument, "mousemove", move);
off(display.wrapper.ownerDocument, "mouseup", up); off(display.wrapper.ownerDocument, "mouseup", up);
doc.history.lastSelOrigin = null; doc$1.history.lastSelOrigin = null;
} }
var move = operation(cm, function (e) { var move = operation(cm, function (e) {
@ -8286,7 +8292,7 @@
CodeMirror.prototype = { CodeMirror.prototype = {
constructor: CodeMirror, constructor: CodeMirror,
focus: function(){window.focus(); this.display.input.focus();}, focus: function(){win(this).focus(); this.display.input.focus();},
setOption: function(option, value) { setOption: function(option, value) {
var options = this.options, old = options[option]; var options = this.options, old = options[option];
@ -8610,7 +8616,7 @@
signal(this, "overwriteToggle", this, this.state.overwrite); signal(this, "overwriteToggle", this, this.state.overwrite);
}, },
hasFocus: function() { return this.display.input.getField() == activeElt() }, hasFocus: function() { return this.display.input.getField() == activeElt(doc(this)) },
isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) }, isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }), scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }),
@ -8791,7 +8797,7 @@
function findPosV(cm, pos, dir, unit) { function findPosV(cm, pos, dir, unit) {
var doc = cm.doc, x = pos.left, y; var doc = cm.doc, x = pos.left, y;
if (unit == "page") { if (unit == "page") {
var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight); var pageSize = Math.min(cm.display.wrapper.clientHeight, win(cm).innerHeight || doc(cm).documentElement.clientHeight);
var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3); var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);
y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount; y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
@ -8891,7 +8897,7 @@
var kludge = hiddenTextarea(), te = kludge.firstChild; var kludge = hiddenTextarea(), te = kludge.firstChild;
cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild); cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
te.value = lastCopied.text.join("\n"); te.value = lastCopied.text.join("\n");
var hadFocus = activeElt(); var hadFocus = activeElt(div.ownerDocument);
selectInput(te); selectInput(te);
setTimeout(function () { setTimeout(function () {
cm.display.lineSpace.removeChild(kludge); cm.display.lineSpace.removeChild(kludge);
@ -8914,7 +8920,7 @@
ContentEditableInput.prototype.prepareSelection = function () { ContentEditableInput.prototype.prepareSelection = function () {
var result = prepareSelection(this.cm, false); var result = prepareSelection(this.cm, false);
result.focus = activeElt() == this.div; result.focus = activeElt(this.div.ownerDocument) == this.div;
return result return result
}; };
@ -9010,7 +9016,7 @@
ContentEditableInput.prototype.focus = function () { ContentEditableInput.prototype.focus = function () {
if (this.cm.options.readOnly != "nocursor") { if (this.cm.options.readOnly != "nocursor") {
if (!this.selectionInEditor() || activeElt() != this.div) if (!this.selectionInEditor() || activeElt(this.div.ownerDocument) != this.div)
{ this.showSelection(this.prepareSelection(), true); } { this.showSelection(this.prepareSelection(), true); }
this.div.focus(); this.div.focus();
} }
@ -9513,7 +9519,7 @@
TextareaInput.prototype.supportsTouch = function () { return false }; TextareaInput.prototype.supportsTouch = function () { return false };
TextareaInput.prototype.focus = function () { TextareaInput.prototype.focus = function () {
if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) { if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt(this.textarea.ownerDocument) != this.textarea)) {
try { this.textarea.focus(); } try { this.textarea.focus(); }
catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
} }
@ -9636,9 +9642,9 @@
input.wrapper.style.cssText = "position: static"; input.wrapper.style.cssText = "position: static";
te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"; te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
var oldScrollY; var oldScrollY;
if (webkit) { oldScrollY = window.scrollY; } // Work around Chrome issue (#2712) if (webkit) { oldScrollY = te.ownerDocument.defaultView.scrollY; } // Work around Chrome issue (#2712)
display.input.focus(); display.input.focus();
if (webkit) { window.scrollTo(null, oldScrollY); } if (webkit) { te.ownerDocument.defaultView.scrollTo(null, oldScrollY); }
display.input.reset(); display.input.reset();
// Adds "Select all" to context menu in FF // Adds "Select all" to context menu in FF
if (!cm.somethingSelected()) { te.value = input.prevInput = " "; } if (!cm.somethingSelected()) { te.value = input.prevInput = " "; }
@ -9720,7 +9726,7 @@
// Set autofocus to true if this textarea is focused, or if it has // Set autofocus to true if this textarea is focused, or if it has
// autofocus and no other element is focused. // autofocus and no other element is focused.
if (options.autofocus == null) { if (options.autofocus == null) {
var hasFocus = activeElt(); var hasFocus = activeElt(textarea.ownerDocument);
options.autofocus = hasFocus == textarea || options.autofocus = hasFocus == textarea ||
textarea.getAttribute("autofocus") != null && hasFocus == document.body; textarea.getAttribute("autofocus") != null && hasFocus == document.body;
} }
@ -9854,7 +9860,7 @@
addLegacyProps(CodeMirror); addLegacyProps(CodeMirror);
CodeMirror.version = "5.65.6"; CodeMirror.version = "5.65.7";
return CodeMirror; return CodeMirror;

View File

@ -228,7 +228,7 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
if (type == "}" || type == "{") return popAndPass(type, stream, state); if (type == "}" || type == "{") return popAndPass(type, stream, state);
if (type == "(") return pushContext(state, stream, "parens"); if (type == "(") return pushContext(state, stream, "parens");
if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) { if (type == "hash" && !/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(stream.current())) {
override += " error"; override += " error";
} else if (type == "word") { } else if (type == "word") {
wordAsValue(stream); wordAsValue(stream);