mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-30 14:55:27 -04:00
Update CodeMirror to version 5.17.1
This commit is contained in:
parent
b6ca8649af
commit
1490eafdd2
27 changed files with 351 additions and 152 deletions
39
public/vendor/codemirror/keymap/sublime.js
vendored
39
public/vendor/codemirror/keymap/sublime.js
vendored
|
@ -52,8 +52,10 @@
|
|||
});
|
||||
}
|
||||
|
||||
cmds[map["Alt-Left"] = "goSubwordLeft"] = function(cm) { moveSubword(cm, -1); };
|
||||
cmds[map["Alt-Right"] = "goSubwordRight"] = function(cm) { moveSubword(cm, 1); };
|
||||
var goSubwordCombo = mac ? "Ctrl-" : "Alt-";
|
||||
|
||||
cmds[map[goSubwordCombo + "Left"] = "goSubwordLeft"] = function(cm) { moveSubword(cm, -1); };
|
||||
cmds[map[goSubwordCombo + "Right"] = "goSubwordRight"] = function(cm) { moveSubword(cm, 1); };
|
||||
|
||||
if (mac) map["Cmd-Left"] = "goLineStartSmart";
|
||||
|
||||
|
@ -420,6 +422,34 @@
|
|||
|
||||
map[cK + ctrl + "Backspace"] = "delLineLeft";
|
||||
|
||||
cmds[map["Backspace"] = "smartBackspace"] = function(cm) {
|
||||
if (cm.somethingSelected()) return CodeMirror.Pass;
|
||||
|
||||
cm.operation(function() {
|
||||
var cursors = cm.listSelections();
|
||||
var indentUnit = cm.getOption("indentUnit");
|
||||
|
||||
for (var i = cursors.length - 1; i >= 0; i--) {
|
||||
var cursor = cursors[i].head;
|
||||
var toStartOfLine = cm.getRange({line: cursor.line, ch: 0}, cursor);
|
||||
var column = CodeMirror.countColumn(toStartOfLine, null, cm.getOption("tabSize"));
|
||||
|
||||
// Delete by one character by default
|
||||
var deletePos = cm.findPosH(cursor, -1, "char", false);
|
||||
|
||||
if (toStartOfLine && !/\S/.test(toStartOfLine) && column % indentUnit == 0) {
|
||||
var prevIndent = new Pos(cursor.line,
|
||||
CodeMirror.findColumn(toStartOfLine, column - indentUnit, indentUnit));
|
||||
|
||||
// Smart delete only if we found a valid prevIndent location
|
||||
if (prevIndent.ch != cursor.ch) deletePos = prevIndent;
|
||||
}
|
||||
|
||||
cm.replaceRange("", deletePos, cursor, "+delete");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
cmds[map[cK + ctrl + "K"] = "delLineRight"] = function(cm) {
|
||||
cm.operation(function() {
|
||||
var ranges = cm.listSelections();
|
||||
|
@ -472,7 +502,8 @@
|
|||
cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2);
|
||||
};
|
||||
|
||||
cmds[map["Shift-Alt-Up"] = "selectLinesUpward"] = function(cm) {
|
||||
var selectLinesCombo = mac ? "Ctrl-Shift-" : "Ctrl-Alt-";
|
||||
cmds[map[selectLinesCombo + "Up"] = "selectLinesUpward"] = function(cm) {
|
||||
cm.operation(function() {
|
||||
var ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
|
@ -482,7 +513,7 @@
|
|||
}
|
||||
});
|
||||
};
|
||||
cmds[map["Shift-Alt-Down"] = "selectLinesDownward"] = function(cm) {
|
||||
cmds[map[selectLinesCombo + "Down"] = "selectLinesDownward"] = function(cm) {
|
||||
cm.operation(function() {
|
||||
var ranges = cm.listSelections();
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
|
|
24
public/vendor/codemirror/keymap/vim.js
vendored
24
public/vendor/codemirror/keymap/vim.js
vendored
|
@ -72,6 +72,7 @@
|
|||
{ keys: '<PageUp>', type: 'keyToKey', toKeys: '<C-b>' },
|
||||
{ keys: '<PageDown>', type: 'keyToKey', toKeys: '<C-f>' },
|
||||
{ keys: '<CR>', type: 'keyToKey', toKeys: 'j^', context: 'normal' },
|
||||
{ keys: '<Ins>', type: 'action', action: 'toggleOverwrite', context: 'insert' },
|
||||
// Motions
|
||||
{ keys: 'H', type: 'motion', motion: 'moveToTopLine', motionArgs: { linewise: true, toJumplist: true }},
|
||||
{ keys: 'M', type: 'motion', motion: 'moveToMiddleLine', motionArgs: { linewise: true, toJumplist: true }},
|
||||
|
@ -276,6 +277,7 @@
|
|||
|
||||
function cmKey(key, cm) {
|
||||
if (!cm) { return undefined; }
|
||||
if (this[key]) { return this[key]; }
|
||||
var vimKey = cmKeyToVimKey(key);
|
||||
if (!vimKey) {
|
||||
return false;
|
||||
|
@ -288,7 +290,7 @@
|
|||
}
|
||||
|
||||
var modifiers = {'Shift': 'S', 'Ctrl': 'C', 'Alt': 'A', 'Cmd': 'D', 'Mod': 'A'};
|
||||
var specialKeys = {Enter:'CR',Backspace:'BS',Delete:'Del'};
|
||||
var specialKeys = {Enter:'CR',Backspace:'BS',Delete:'Del',Insert:'Ins'};
|
||||
function cmKeyToVimKey(key) {
|
||||
if (key.charAt(0) == '\'') {
|
||||
// Keypress character binding of format "'a'"
|
||||
|
@ -2174,6 +2176,17 @@
|
|||
var registerName = actionArgs.selectedCharacter;
|
||||
macroModeState.enterMacroRecordMode(cm, registerName);
|
||||
},
|
||||
toggleOverwrite: function(cm) {
|
||||
if (!cm.state.overwrite) {
|
||||
cm.toggleOverwrite(true);
|
||||
cm.setOption('keyMap', 'vim-replace');
|
||||
CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"});
|
||||
} else {
|
||||
cm.toggleOverwrite(false);
|
||||
cm.setOption('keyMap', 'vim-insert');
|
||||
CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"});
|
||||
}
|
||||
},
|
||||
enterInsertMode: function(cm, actionArgs, vim) {
|
||||
if (cm.getOption('readOnly')) { return; }
|
||||
vim.insertMode = true;
|
||||
|
@ -2219,7 +2232,6 @@
|
|||
return;
|
||||
}
|
||||
}
|
||||
cm.setOption('keyMap', 'vim-insert');
|
||||
cm.setOption('disableInput', false);
|
||||
if (actionArgs && actionArgs.replace) {
|
||||
// Handle Replace-mode as a special case of insert mode.
|
||||
|
@ -2227,6 +2239,7 @@
|
|||
cm.setOption('keyMap', 'vim-replace');
|
||||
CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"});
|
||||
} else {
|
||||
cm.toggleOverwrite(false);
|
||||
cm.setOption('keyMap', 'vim-insert');
|
||||
CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"});
|
||||
}
|
||||
|
@ -4771,13 +4784,6 @@
|
|||
CodeMirror.keyMap['vim-insert'] = {
|
||||
// TODO: override navigation keys so that Esc will cancel automatic
|
||||
// indentation from o, O, i_<CR>
|
||||
'Ctrl-N': 'autocomplete',
|
||||
'Ctrl-P': 'autocomplete',
|
||||
'Enter': function(cm) {
|
||||
var fn = CodeMirror.commands.newlineAndIndentContinueComment ||
|
||||
CodeMirror.commands.newlineAndIndent;
|
||||
fn(cm);
|
||||
},
|
||||
fallthrough: ['default'],
|
||||
attach: attachVimMap,
|
||||
detach: detachVimMap,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue