Update CodeMirror to version 5.17.1

This commit is contained in:
Wu Cheng-Han 2016-07-30 12:25:24 +08:00
parent b6ca8649af
commit 1490eafdd2
27 changed files with 351 additions and 152 deletions

View File

@ -11,30 +11,26 @@
})(function(CodeMirror) { })(function(CodeMirror) {
"use strict"; "use strict";
CodeMirror.defineOption("rulers", false, function(cm, val, old) { CodeMirror.defineOption("rulers", false, function(cm, val) {
if (old && old != CodeMirror.Init) { if (cm.state.rulerDiv) {
clearRulers(cm); cm.display.lineSpace.removeChild(cm.state.rulerDiv)
cm.off("refresh", refreshRulers); cm.state.rulerDiv = null
cm.off("refresh", drawRulers)
} }
if (val && val.length) { if (val && val.length) {
setRulers(cm); cm.state.rulerDiv = cm.display.lineSpace.insertBefore(document.createElement("div"), cm.display.cursorDiv)
cm.on("refresh", refreshRulers); cm.state.rulerDiv.className = "CodeMirror-rulers"
drawRulers(cm)
cm.on("refresh", drawRulers)
} }
}); });
function clearRulers(cm) { function drawRulers(cm) {
for (var i = cm.display.lineSpace.childNodes.length - 1; i >= 0; i--) { cm.state.rulerDiv.textContent = ""
var node = cm.display.lineSpace.childNodes[i];
if (/(^|\s)CodeMirror-ruler($|\s)/.test(node.className))
node.parentNode.removeChild(node);
}
}
function setRulers(cm) {
var val = cm.getOption("rulers"); var val = cm.getOption("rulers");
var cw = cm.defaultCharWidth(); var cw = cm.defaultCharWidth();
var left = cm.charCoords(CodeMirror.Pos(cm.firstLine(), 0), "div").left; var left = cm.charCoords(CodeMirror.Pos(cm.firstLine(), 0), "div").left;
var minH = cm.display.scroller.offsetHeight + 30; cm.state.rulerDiv.style.minHeight = (cm.display.scroller.offsetHeight + 30) + "px";
for (var i = 0; i < val.length; i++) { for (var i = 0; i < val.length; i++) {
var elt = document.createElement("div"); var elt = document.createElement("div");
elt.className = "CodeMirror-ruler"; elt.className = "CodeMirror-ruler";
@ -49,15 +45,7 @@
if (conf.width) elt.style.borderLeftWidth = conf.width; if (conf.width) elt.style.borderLeftWidth = conf.width;
} }
elt.style.left = (left + col * cw) + "px"; elt.style.left = (left + col * cw) + "px";
elt.style.top = "-50px"; cm.state.rulerDiv.appendChild(elt)
elt.style.bottom = "-20px";
elt.style.minHeight = minH + "px";
cm.display.lineSpace.insertBefore(elt, cm.display.cursorDiv);
} }
} }
function refreshRulers(cm) {
clearRulers(cm);
setRulers(cm);
}
}); });

View File

@ -102,8 +102,10 @@
} }
CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
if (old && old != CodeMirror.Init) if (old && old != CodeMirror.Init) {
cm.off("cursorActivity", doMatchBrackets); cm.off("cursorActivity", doMatchBrackets);
if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted = null;}
}
if (val) { if (val) {
cm.state.matchBrackets = typeof val == "object" ? val : {}; cm.state.matchBrackets = typeof val == "object" ? val : {};
cm.on("cursorActivity", doMatchBrackets); cm.on("cursorActivity", doMatchBrackets);

View File

@ -29,7 +29,7 @@ CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
} }
if (pass == 1 && found < start.ch) return; if (pass == 1 && found < start.ch) return;
if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1))) && if (/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1))) &&
(lineText.slice(found - endToken.length, found) == endToken || (found == 0 || lineText.slice(found - endToken.length, found) == endToken ||
!/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found))))) { !/comment/.test(cm.getTokenTypeAt(CodeMirror.Pos(line, found))))) {
startCh = found + startToken.length; startCh = found + startToken.length;
break; break;

View File

@ -49,7 +49,7 @@
}); });
var myRange = cm.markText(range.from, range.to, { var myRange = cm.markText(range.from, range.to, {
replacedWith: myWidget, replacedWith: myWidget,
clearOnEnter: true, clearOnEnter: getOption(cm, options, "clearOnEnter"),
__isFold: true __isFold: true
}); });
myRange.on("clear", function(from, to) { myRange.on("clear", function(from, to) {
@ -129,7 +129,8 @@
rangeFinder: CodeMirror.fold.auto, rangeFinder: CodeMirror.fold.auto,
widget: "\u2194", widget: "\u2194",
minFoldSize: 0, minFoldSize: 0,
scanUp: false scanUp: false,
clearOnEnter: true
}; };
CodeMirror.defineOption("foldOptions", null); CodeMirror.defineOption("foldOptions", null);

View File

@ -50,7 +50,7 @@
} }
function isFolded(cm, line) { function isFolded(cm, line) {
var marks = cm.findMarksAt(Pos(line)); var marks = cm.findMarks(Pos(line, 0), Pos(line + 1, 0));
for (var i = 0; i < marks.length; ++i) for (var i = 0; i < marks.length; ++i)
if (marks[i].__isFold && marks[i].find().from.line == line) return marks[i]; if (marks[i].__isFold && marks[i].find().from.line == line) return marks[i];
} }

View File

@ -16,7 +16,6 @@
background: white; background: white;
font-size: 90%; font-size: 90%;
font-family: monospace; font-family: monospace;
max-width: 19em;
max-height: 20em; max-height: 20em;
overflow-y: auto; overflow-y: auto;

View File

@ -230,6 +230,8 @@
(completion.options.container || document.body).appendChild(hints); (completion.options.container || document.body).appendChild(hints);
var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH; var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
var scrolls = hints.scrollHeight > hints.clientHeight + 1 var scrolls = hints.scrollHeight > hints.clientHeight + 1
var startScroll = cm.getScrollInfo();
if (overlapY > 0) { if (overlapY > 0) {
var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top); var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
if (curTop - height > 0) { // Fits above cursor if (curTop - height > 0) { // Fits above cursor
@ -273,7 +275,6 @@
cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); }); cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); });
} }
var startScroll = cm.getScrollInfo();
cm.on("scroll", this.onScroll = function() { cm.on("scroll", this.onScroll = function() {
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect(); var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
var newTop = top + startScroll.top - curScroll.top; var newTop = top + startScroll.top - curScroll.top;

View File

@ -18,7 +18,7 @@
QUERY_DIV: ";", QUERY_DIV: ";",
ALIAS_KEYWORD: "AS" ALIAS_KEYWORD: "AS"
}; };
var Pos = CodeMirror.Pos; var Pos = CodeMirror.Pos, cmpPos = CodeMirror.cmpPos;
function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" } function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" }
@ -178,15 +178,6 @@
} }
} }
function convertCurToNumber(cur) {
// max characters of a line is 999,999.
return cur.line + cur.ch / Math.pow(10, 6);
}
function convertNumberToCur(num) {
return Pos(Math.floor(num), +num.toString().split('.').pop());
}
function findTableByAlias(alias, editor) { function findTableByAlias(alias, editor) {
var doc = editor.doc; var doc = editor.doc;
var fullQuery = doc.getValue(); var fullQuery = doc.getValue();
@ -209,15 +200,14 @@
separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length)); separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length));
//find valid range //find valid range
var prevItem = 0; var prevItem = null;
var current = convertCurToNumber(editor.getCursor()); var current = editor.getCursor()
for (var i = 0; i < separator.length; i++) { for (var i = 0; i < separator.length; i++) {
var _v = convertCurToNumber(separator[i]); if ((prevItem == null || cmpPos(current, prevItem) > 0) && cmpPos(current, separator[i]) <= 0) {
if (current > prevItem && current <= _v) { validRange = {start: prevItem, end: separator[i]};
validRange = { start: convertNumberToCur(prevItem), end: convertNumberToCur(_v) };
break; break;
} }
prevItem = _v; prevItem = separator[i];
} }
var query = doc.getRange(validRange.start, validRange.end, false); var query = doc.getRange(validRange.start, validRange.end, false);

View File

@ -284,7 +284,9 @@
if (dv.copyButtons) clear(dv.copyButtons); if (dv.copyButtons) clear(dv.copyButtons);
var vpEdit = dv.edit.getViewport(), vpOrig = dv.orig.getViewport(); var vpEdit = dv.edit.getViewport(), vpOrig = dv.orig.getViewport();
var sTopEdit = dv.edit.getScrollInfo().top, sTopOrig = dv.orig.getScrollInfo().top; var outerTop = dv.mv.wrap.getBoundingClientRect().top
var sTopEdit = outerTop - dv.edit.getScrollerElement().getBoundingClientRect().top + dv.edit.getScrollInfo().top
var sTopOrig = outerTop - dv.orig.getScrollerElement().getBoundingClientRect().top + dv.orig.getScrollInfo().top;
for (var i = 0; i < dv.chunks.length; i++) { for (var i = 0; i < dv.chunks.length; i++) {
var ch = dv.chunks[i]; var ch = dv.chunks[i];
if (ch.editFrom <= vpEdit.to && ch.editTo >= vpEdit.from && if (ch.editFrom <= vpEdit.to && ch.editTo >= vpEdit.from &&

View File

@ -40,7 +40,9 @@
if (cm.state.scrollPastEndPadding != padding) { if (cm.state.scrollPastEndPadding != padding) {
cm.state.scrollPastEndPadding = padding; cm.state.scrollPastEndPadding = padding;
cm.display.lineSpace.parentNode.style.paddingBottom = padding; cm.display.lineSpace.parentNode.style.paddingBottom = padding;
cm.off("refresh", updateBottomMargin);
cm.setSize(); cm.setSize();
cm.on("refresh", updateBottomMargin);
} }
} }
}); });

View File

@ -72,7 +72,7 @@
cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style)); cm.addOverlay(state.overlay = makeOverlay(query, hasBoundary, style));
if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) { if (state.options.annotateScrollbar && cm.showMatchesOnScrollbar) {
var searchFor = hasBoundary ? new RegExp("\\b" + query + "\\b") : query; var searchFor = hasBoundary ? new RegExp("\\b" + query + "\\b") : query;
state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, true, state.matchesonscroll = cm.showMatchesOnScrollbar(searchFor, false,
{className: "CodeMirror-selection-highlight-scrollbar"}); {className: "CodeMirror-selection-highlight-scrollbar"});
} }
} }

View File

@ -57,12 +57,13 @@
return cm.getSearchCursor(query, pos, queryCaseInsensitive(query)); return cm.getSearchCursor(query, pos, queryCaseInsensitive(query));
} }
function persistentDialog(cm, text, deflt, f) { function persistentDialog(cm, text, deflt, onEnter, onKeyDown) {
cm.openDialog(text, f, { cm.openDialog(text, onEnter, {
value: deflt, value: deflt,
selectValueOnOpen: true, selectValueOnOpen: true,
closeOnEnter: false, closeOnEnter: false,
onClose: function() { clearSearch(cm); } onClose: function() { clearSearch(cm); },
onKeyDown: onKeyDown
}); });
} }
@ -112,13 +113,13 @@
} }
} }
function doSearch(cm, rev, persistent) { function doSearch(cm, rev, persistent, immediate) {
var state = getSearchState(cm); var state = getSearchState(cm);
if (state.query) return findNext(cm, rev); if (state.query) return findNext(cm, rev);
var q = cm.getSelection() || state.lastQuery; var q = cm.getSelection() || state.lastQuery;
if (persistent && cm.openDialog) { if (persistent && cm.openDialog) {
var hiding = null var hiding = null
persistentDialog(cm, queryDialog, q, function(query, event) { var searchNext = function(query, event) {
CodeMirror.e_stop(event); CodeMirror.e_stop(event);
if (!query) return; if (!query) return;
if (query != state.queryText) { if (query != state.queryText) {
@ -133,7 +134,22 @@
dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top) dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top)
(hiding = dialog).style.opacity = .4 (hiding = dialog).style.opacity = .4
}) })
};
persistentDialog(cm, queryDialog, q, searchNext, function(event, query) {
var cmd = CodeMirror.keyMap[cm.getOption("keyMap")][CodeMirror.keyName(event)];
if (cmd == "findNext" || cmd == "findPrev") {
CodeMirror.e_stop(event);
startSearch(cm, getSearchState(cm), query);
cm.execCommand(cmd);
} else if (cmd == "find" || cmd == "findPersistent") {
CodeMirror.e_stop(event);
searchNext(query, event);
}
}); });
if (immediate) {
startSearch(cm, state, q);
findNext(cm, rev);
}
} else { } else {
dialog(cm, queryDialog, "Search for:", q, function(query) { dialog(cm, queryDialog, "Search for:", q, function(query) {
if (query && !state.query) cm.operation(function() { if (query && !state.query) cm.operation(function() {
@ -223,6 +239,8 @@
CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);}; CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);};
CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);}; CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);};
CodeMirror.commands.findPersistentNext = function(cm) {doSearch(cm, false, true, true);};
CodeMirror.commands.findPersistentPrev = function(cm) {doSearch(cm, true, true, true);};
CodeMirror.commands.findNext = doSearch; CodeMirror.commands.findNext = doSearch;
CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);}; CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);};
CodeMirror.commands.clearSearch = clearSearch; CodeMirror.commands.clearSearch = clearSearch;

View File

@ -30,7 +30,9 @@
} }
function findBreakPoint(text, column, wrapOn, killTrailingSpace) { function findBreakPoint(text, column, wrapOn, killTrailingSpace) {
for (var at = column; at > 0; --at) var at = column
while (at < text.length && text.charAt(at) == " ") at++
for (; at > 0; --at)
if (wrapOn.test(text.slice(at - 1, at + 1))) break; if (wrapOn.test(text.slice(at - 1, at + 1))) break;
for (var first = true;; first = false) { for (var first = true;; first = false) {
var endOfText = at; var endOfText = at;

File diff suppressed because one or more lines are too long

View File

@ -52,8 +52,10 @@
}); });
} }
cmds[map["Alt-Left"] = "goSubwordLeft"] = function(cm) { moveSubword(cm, -1); }; var goSubwordCombo = mac ? "Ctrl-" : "Alt-";
cmds[map["Alt-Right"] = "goSubwordRight"] = function(cm) { moveSubword(cm, 1); };
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"; if (mac) map["Cmd-Left"] = "goLineStartSmart";
@ -420,6 +422,34 @@
map[cK + ctrl + "Backspace"] = "delLineLeft"; 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) { cmds[map[cK + ctrl + "K"] = "delLineRight"] = function(cm) {
cm.operation(function() { cm.operation(function() {
var ranges = cm.listSelections(); var ranges = cm.listSelections();
@ -472,7 +502,8 @@
cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2); 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() { cm.operation(function() {
var ranges = cm.listSelections(); var ranges = cm.listSelections();
for (var i = 0; i < ranges.length; i++) { 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() { cm.operation(function() {
var ranges = cm.listSelections(); var ranges = cm.listSelections();
for (var i = 0; i < ranges.length; i++) { for (var i = 0; i < ranges.length; i++) {

View File

@ -72,6 +72,7 @@
{ keys: '<PageUp>', type: 'keyToKey', toKeys: '<C-b>' }, { keys: '<PageUp>', type: 'keyToKey', toKeys: '<C-b>' },
{ keys: '<PageDown>', type: 'keyToKey', toKeys: '<C-f>' }, { keys: '<PageDown>', type: 'keyToKey', toKeys: '<C-f>' },
{ keys: '<CR>', type: 'keyToKey', toKeys: 'j^', context: 'normal' }, { keys: '<CR>', type: 'keyToKey', toKeys: 'j^', context: 'normal' },
{ keys: '<Ins>', type: 'action', action: 'toggleOverwrite', context: 'insert' },
// Motions // Motions
{ keys: 'H', type: 'motion', motion: 'moveToTopLine', motionArgs: { linewise: true, toJumplist: true }}, { keys: 'H', type: 'motion', motion: 'moveToTopLine', motionArgs: { linewise: true, toJumplist: true }},
{ keys: 'M', type: 'motion', motion: 'moveToMiddleLine', motionArgs: { linewise: true, toJumplist: true }}, { keys: 'M', type: 'motion', motion: 'moveToMiddleLine', motionArgs: { linewise: true, toJumplist: true }},
@ -276,6 +277,7 @@
function cmKey(key, cm) { function cmKey(key, cm) {
if (!cm) { return undefined; } if (!cm) { return undefined; }
if (this[key]) { return this[key]; }
var vimKey = cmKeyToVimKey(key); var vimKey = cmKeyToVimKey(key);
if (!vimKey) { if (!vimKey) {
return false; return false;
@ -288,7 +290,7 @@
} }
var modifiers = {'Shift': 'S', 'Ctrl': 'C', 'Alt': 'A', 'Cmd': 'D', 'Mod': 'A'}; 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) { function cmKeyToVimKey(key) {
if (key.charAt(0) == '\'') { if (key.charAt(0) == '\'') {
// Keypress character binding of format "'a'" // Keypress character binding of format "'a'"
@ -2174,6 +2176,17 @@
var registerName = actionArgs.selectedCharacter; var registerName = actionArgs.selectedCharacter;
macroModeState.enterMacroRecordMode(cm, registerName); 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) { enterInsertMode: function(cm, actionArgs, vim) {
if (cm.getOption('readOnly')) { return; } if (cm.getOption('readOnly')) { return; }
vim.insertMode = true; vim.insertMode = true;
@ -2219,7 +2232,6 @@
return; return;
} }
} }
cm.setOption('keyMap', 'vim-insert');
cm.setOption('disableInput', false); cm.setOption('disableInput', false);
if (actionArgs && actionArgs.replace) { if (actionArgs && actionArgs.replace) {
// Handle Replace-mode as a special case of insert mode. // Handle Replace-mode as a special case of insert mode.
@ -2227,6 +2239,7 @@
cm.setOption('keyMap', 'vim-replace'); cm.setOption('keyMap', 'vim-replace');
CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"}); CodeMirror.signal(cm, "vim-mode-change", {mode: "replace"});
} else { } else {
cm.toggleOverwrite(false);
cm.setOption('keyMap', 'vim-insert'); cm.setOption('keyMap', 'vim-insert');
CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"}); CodeMirror.signal(cm, "vim-mode-change", {mode: "insert"});
} }
@ -4771,13 +4784,6 @@
CodeMirror.keyMap['vim-insert'] = { CodeMirror.keyMap['vim-insert'] = {
// TODO: override navigation keys so that Esc will cancel automatic // TODO: override navigation keys so that Esc will cancel automatic
// indentation from o, O, i_<CR> // 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'], fallthrough: ['default'],
attach: attachVimMap, attach: attachVimMap,
detach: detachVimMap, detach: detachVimMap,

View File

@ -88,8 +88,14 @@
.cm-tab { display: inline-block; text-decoration: inherit; } .cm-tab { display: inline-block; text-decoration: inherit; }
.CodeMirror-rulers {
position: absolute;
left: 0; right: 0; top: -50px; bottom: -20px;
overflow: hidden;
}
.CodeMirror-ruler { .CodeMirror-ruler {
border-left: 1px solid #ccc; border-left: 1px solid #ccc;
top: 0; bottom: 0;
position: absolute; position: absolute;
} }
@ -291,7 +297,10 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
visibility: hidden; visibility: hidden;
} }
.CodeMirror-cursor { position: absolute; } .CodeMirror-cursor {
position: absolute;
pointer-events: none;
}
.CodeMirror-measure pre { position: static; } .CodeMirror-measure pre { position: static; }
div.CodeMirror-cursors { div.CodeMirror-cursors {

View File

@ -1221,7 +1221,7 @@
}; };
function hiddenTextarea() { function hiddenTextarea() {
var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none"); var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none");
var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
// The textarea is kept positioned near the cursor to prevent the // The textarea is kept positioned near the cursor to prevent the
// fact that it'll be scrolled into view on input from scrolling // fact that it'll be scrolled into view on input from scrolling
@ -2700,6 +2700,16 @@
return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}; return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd};
} }
function getUsefulRect(rects, bias) {
var rect = nullRect
if (bias == "left") for (var i = 0; i < rects.length; i++) {
if ((rect = rects[i]).left != rect.right) break
} else for (var i = rects.length - 1; i >= 0; i--) {
if ((rect = rects[i]).left != rect.right) break
}
return rect
}
function measureCharInner(cm, prepared, ch, bias) { function measureCharInner(cm, prepared, ch, bias) {
var place = nodeAndOffsetInLineMap(prepared.map, ch, bias); var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
var node = place.node, start = place.start, end = place.end, collapse = place.collapse; var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
@ -2709,17 +2719,10 @@
for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned
while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start; while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start;
while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end; while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end;
if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) { if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart)
rect = node.parentNode.getBoundingClientRect(); rect = node.parentNode.getBoundingClientRect();
} else if (ie && cm.options.lineWrapping) { else
var rects = range(node, start, end).getClientRects(); rect = getUsefulRect(range(node, start, end).getClientRects(), bias)
if (rects.length)
rect = rects[bias == "right" ? rects.length - 1 : 0];
else
rect = nullRect;
} else {
rect = range(node, start, end).getBoundingClientRect() || nullRect;
}
if (rect.left || rect.right || start == 0) break; if (rect.left || rect.right || start == 0) break;
end = start; end = start;
start = start - 1; start = start - 1;
@ -2945,10 +2948,23 @@
for (;;) { for (;;) {
if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) { if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
var ch = x < fromX || x - fromX <= toX - x ? from : to; var ch = x < fromX || x - fromX <= toX - x ? from : to;
var outside = ch == from ? fromOutside : toOutside
var xDiff = x - (ch == from ? fromX : toX); var xDiff = x - (ch == from ? fromX : toX);
// This is a kludge to handle the case where the coordinates
// are after a line-wrapped line. We should replace it with a
// more general handling of cursor positions around line
// breaks. (Issue #4078)
if (toOutside && !bidi && !/\s/.test(lineObj.text.charAt(ch)) && xDiff > 0 &&
ch < lineObj.text.length && preparedMeasure.view.measure.heights.length > 1) {
var charSize = measureCharPrepared(cm, preparedMeasure, ch, "right");
if (innerOff <= charSize.bottom && innerOff >= charSize.top && Math.abs(x - charSize.right) < xDiff) {
outside = false
ch++
xDiff = x - charSize.right
}
}
while (isExtendingChar(lineObj.text.charAt(ch))) ++ch; while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;
var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside, var pos = PosWithInfo(lineNo, ch, outside, xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
return pos; return pos;
} }
var step = Math.ceil(dist / 2), middle = from + step; var step = Math.ceil(dist / 2), middle = from + step;
@ -3672,6 +3688,7 @@
// Let the drag handler handle this. // Let the drag handler handle this.
if (webkit) display.scroller.draggable = true; if (webkit) display.scroller.draggable = true;
cm.state.draggingText = dragEnd; cm.state.draggingText = dragEnd;
dragEnd.copy = mac ? e.altKey : e.ctrlKey
// IE's approach to draggable // IE's approach to draggable
if (display.scroller.dragDrop) display.scroller.dragDrop(); if (display.scroller.dragDrop) display.scroller.dragDrop();
on(document, "mouseup", dragEnd); on(document, "mouseup", dragEnd);
@ -3902,7 +3919,7 @@
try { try {
var text = e.dataTransfer.getData("Text"); var text = e.dataTransfer.getData("Text");
if (text) { if (text) {
if (cm.state.draggingText && !(mac ? e.altKey : e.ctrlKey)) if (cm.state.draggingText && !cm.state.draggingText.copy)
var selected = cm.listSelections(); var selected = cm.listSelections();
setSelectionNoUndo(cm.doc, simpleSelection(pos, pos)); setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
if (selected) for (var i = 0; i < selected.length; ++i) if (selected) for (var i = 0; i < selected.length; ++i)
@ -4417,7 +4434,7 @@
// Revert a change stored in a document's history. // Revert a change stored in a document's history.
function makeChangeFromHistory(doc, type, allowSelectionOnly) { function makeChangeFromHistory(doc, type, allowSelectionOnly) {
if (doc.cm && doc.cm.state.suppressEdits) return; if (doc.cm && doc.cm.state.suppressEdits && !allowSelectionOnly) return;
var hist = doc.history, event, selAfter = doc.sel; var hist = doc.history, event, selAfter = doc.sel;
var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done; var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
@ -6942,6 +6959,7 @@
var content = elt("span", null, null, webkit ? "padding-right: .1px" : null); var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content, var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content,
col: 0, pos: 0, cm: cm, col: 0, pos: 0, cm: cm,
trailingSpace: false,
splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}; splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
lineView.measure = {}; lineView.measure = {};
@ -7003,7 +7021,7 @@
// the line map. Takes care to render special characters separately. // the line map. Takes care to render special characters separately.
function buildToken(builder, text, style, startStyle, endStyle, title, css) { function buildToken(builder, text, style, startStyle, endStyle, title, css) {
if (!text) return; if (!text) return;
var displayText = builder.splitSpaces ? text.replace(/ {3,}/g, splitSpaces) : text; var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text
var special = builder.cm.state.specialChars, mustWrap = false; var special = builder.cm.state.specialChars, mustWrap = false;
if (!special.test(text)) { if (!special.test(text)) {
builder.col += text.length; builder.col += text.length;
@ -7048,6 +7066,7 @@
builder.pos++; builder.pos++;
} }
} }
builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32
if (style || startStyle || endStyle || mustWrap || css) { if (style || startStyle || endStyle || mustWrap || css) {
var fullStyle = style || ""; var fullStyle = style || "";
if (startStyle) fullStyle += startStyle; if (startStyle) fullStyle += startStyle;
@ -7059,11 +7078,17 @@
builder.content.appendChild(content); builder.content.appendChild(content);
} }
function splitSpaces(old) { function splitSpaces(text, trailingBefore) {
var out = " "; if (text.length > 1 && !/ /.test(text)) return text
for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0"; var spaceBefore = trailingBefore, result = ""
out += " "; for (var i = 0; i < text.length; i++) {
return out; var ch = text.charAt(i)
if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))
ch = "\u00a0"
result += ch
spaceBefore = ch == " "
}
return result
} }
// Work around nonsense dimensions being reported for stretches of // Work around nonsense dimensions being reported for stretches of
@ -7100,6 +7125,7 @@
builder.content.appendChild(widget); builder.content.appendChild(widget);
} }
builder.pos += size; builder.pos += size;
builder.trailingSpace = false
} }
// Outputs a number of spans to make up a line, taking highlighting // Outputs a number of spans to make up a line, taking highlighting
@ -8548,8 +8574,9 @@
if (badBidiRects != null) return badBidiRects; if (badBidiRects != null) return badBidiRects;
var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA")); var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
var r0 = range(txt, 0, 1).getBoundingClientRect(); var r0 = range(txt, 0, 1).getBoundingClientRect();
if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780)
var r1 = range(txt, 1, 2).getBoundingClientRect(); var r1 = range(txt, 1, 2).getBoundingClientRect();
removeChildren(measure);
if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780)
return badBidiRects = (r1.right - r0.right < 3); return badBidiRects = (r1.right - r0.right < 3);
} }
@ -8915,7 +8942,7 @@
// THE END // THE END
CodeMirror.version = "5.15.3"; CodeMirror.version = "5.17.1";
return CodeMirror; return CodeMirror;
}); });

View File

@ -23,7 +23,7 @@ CodeMirror.defineMode("go", function(config) {
"bool":true, "byte":true, "complex64":true, "complex128":true, "bool":true, "byte":true, "complex64":true, "complex128":true,
"float32":true, "float64":true, "int8":true, "int16":true, "int32":true, "float32":true, "float64":true, "int8":true, "int16":true, "int32":true,
"int64":true, "string":true, "uint8":true, "uint16":true, "uint32":true, "int64":true, "string":true, "uint8":true, "uint16":true, "uint32":true,
"uint64":true, "int":true, "uint":true, "uintptr":true "uint64":true, "int":true, "uint":true, "uintptr":true, "error": true
}; };
var atoms = { var atoms = {

View File

@ -216,7 +216,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
var bracket = brackets.indexOf(ch); var bracket = brackets.indexOf(ch);
if (bracket >= 0 && bracket < 3) { if (bracket >= 0 && bracket < 3) {
if (!depth) { ++pos; break; } if (!depth) { ++pos; break; }
if (--depth == 0) break; if (--depth == 0) { if (ch == "(") sawSomething = true; break; }
} else if (bracket >= 3 && bracket < 6) { } else if (bracket >= 3 && bracket < 6) {
++depth; ++depth;
} else if (wordRE.test(ch)) { } else if (wordRE.test(ch)) {
@ -386,8 +386,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma; var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop); if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
if (type == "function") return cont(functiondef, maybeop); if (type == "function") return cont(functiondef, maybeop);
if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression); if (type == "keyword c" || type == "async") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop); if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression); if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop); if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
if (type == "{") return contCommasep(objprop, "}", null, maybeop); if (type == "{") return contCommasep(objprop, "}", null, maybeop);
@ -463,6 +463,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type == "variable") {cx.marked = "property"; return cont();} if (type == "variable") {cx.marked = "property"; return cont();}
} }
function objprop(type, value) { function objprop(type, value) {
if (type == "async") return cont(objprop);
if (type == "variable" || cx.style == "keyword") { if (type == "variable" || cx.style == "keyword") {
cx.marked = "property"; cx.marked = "property";
if (value == "get" || value == "set") return cont(getterSetter); if (value == "get" || value == "set") return cont(getterSetter);
@ -494,7 +495,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
if (type == ",") { if (type == ",") {
var lex = cx.state.lexical; var lex = cx.state.lexical;
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1; if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
return cont(what, proceed); return cont(function(type, value) {
if (type == end || value == end) return pass()
return pass(what)
}, proceed);
} }
if (type == end || value == end) return cont(); if (type == end || value == end) return cont();
return cont(expect(end)); return cont(expect(end));
@ -637,17 +641,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
} }
function arrayLiteral(type) { function arrayLiteral(type) {
if (type == "]") return cont(); if (type == "]") return cont();
return pass(expressionNoComma, maybeArrayComprehension);
}
function maybeArrayComprehension(type) {
if (type == "for") return pass(comprehension, expect("]"));
if (type == ",") return cont(commasep(maybeexpressionNoComma, "]"));
return pass(commasep(expressionNoComma, "]")); return pass(commasep(expressionNoComma, "]"));
} }
function comprehension(type) {
if (type == "for") return cont(forspec, comprehension);
if (type == "if") return cont(expression, comprehension);
}
function isContinuedStatement(state, textAfter) { function isContinuedStatement(state, textAfter) {
return state.lastType == "operator" || state.lastType == "," || return state.lastType == "operator" || state.lastType == "," ||

View File

@ -44,6 +44,9 @@
" [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];", " [keyword import] { [def encrypt], [def decrypt] } [keyword from] [string 'crypto'];",
"}"); "}");
MT("import_trailing_comma",
"[keyword import] {[def foo], [def bar],} [keyword from] [string 'baz']")
MT("const", MT("const",
"[keyword function] [def f]() {", "[keyword function] [def f]() {",
" [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];", " [keyword const] [[ [def a], [def b] ]] [operator =] [[ [number 1], [number 2] ]];",
@ -75,12 +78,6 @@
" [variable something]([variable-2 a], [meta ...][variable-2 b]);", " [variable something]([variable-2 a], [meta ...][variable-2 b]);",
"}"); "}");
MT("comprehension",
"[keyword function] [def f]() {",
" [[([variable x] [operator +] [number 1]) [keyword for] ([keyword var] [def x] [keyword in] [variable y]) [keyword if] [variable pred]([variable-2 x]) ]];",
" ([variable u] [keyword for] ([keyword var] [def u] [keyword of] [variable generateValues]()) [keyword if] ([variable-2 u].[property color] [operator ===] [string 'blue']));",
"}");
MT("quasi", MT("quasi",
"[variable re][string-2 `fofdlakj${][variable x] [operator +] ([variable re][string-2 `foo`]) [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]"); "[variable re][string-2 `fofdlakj${][variable x] [operator +] ([variable re][string-2 `foo`]) [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");

View File

@ -63,7 +63,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
list2: "variable-3", list2: "variable-3",
list3: "keyword", list3: "keyword",
hr: "hr", hr: "hr",
image: "tag", image: "image",
imageAltText: "image-alt-text",
imageMarker: "image-marker",
formatting: "formatting", formatting: "formatting",
linkInline: "link", linkInline: "link",
linkEmail: "link", linkEmail: "link",
@ -313,6 +315,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
if (state.strikethrough) { styles.push(tokenTypes.strikethrough); } if (state.strikethrough) { styles.push(tokenTypes.strikethrough); }
if (state.linkText) { styles.push(tokenTypes.linkText); } if (state.linkText) { styles.push(tokenTypes.linkText); }
if (state.code) { styles.push(tokenTypes.code); } if (state.code) { styles.push(tokenTypes.code); }
if (state.image) { styles.push(tokenTypes.image); }
if (state.imageAltText) { styles.push(tokenTypes.imageAltText, "link"); }
if (state.imageMarker) { styles.push(tokenTypes.imageMarker); }
} }
if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); } if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); }
@ -432,12 +437,29 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
} }
if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) { if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
stream.match(/\[[^\]]*\]/); state.imageMarker = true;
state.inline = state.f = linkHref; state.image = true;
return tokenTypes.image; if (modeCfg.highlightFormatting) state.formatting = "image";
return getType(state);
} }
if (ch === '[' && stream.match(/[^\]]*\](\(.*\)| ?\[.*?\])/, false)) { if (ch === '[' && state.imageMarker) {
state.imageMarker = false;
state.imageAltText = true
if (modeCfg.highlightFormatting) state.formatting = "image";
return getType(state);
}
if (ch === ']' && state.imageAltText) {
if (modeCfg.highlightFormatting) state.formatting = "image";
var type = getType(state);
state.imageAltText = false;
state.image = false;
state.inline = state.f = linkHref;
return type;
}
if (ch === '[' && stream.match(/[^\]]*\](\(.*\)| ?\[.*?\])/, false) && !state.image) {
state.linkText = true; state.linkText = true;
if (modeCfg.highlightFormatting) state.formatting = "link"; if (modeCfg.highlightFormatting) state.formatting = "link";
return getType(state); return getType(state);

View File

@ -22,6 +22,8 @@
"list3" : "override-list3", "list3" : "override-list3",
"hr" : "override-hr", "hr" : "override-hr",
"image" : "override-image", "image" : "override-image",
"imageAltText": "override-image-alt-text",
"imageMarker": "override-image-marker",
"linkInline" : "override-link-inline", "linkInline" : "override-link-inline",
"linkEmail" : "override-link-email", "linkEmail" : "override-link-email",
"linkText" : "override-link-text", "linkText" : "override-link-text",
@ -89,6 +91,9 @@
FT("formatting_escape", FT("formatting_escape",
"[formatting-escape \\*]"); "[formatting-escape \\*]");
FT("formatting_image",
"[formatting&formatting-image&image&image-marker !][formatting&formatting-image&image&image-alt-text&link [[][image&image-alt-text&link alt text][formatting&formatting-image&image&image-alt-text&link ]]][formatting&formatting-link-string&string&url (][url&string http://link.to/image.jpg][formatting&formatting-link-string&string&url )]");
MT("plainText", MT("plainText",
"foo"); "foo");
@ -589,6 +594,20 @@
MT("hrDashLong", MT("hrDashLong",
"[hr ---------------------------------------]"); "[hr ---------------------------------------]");
//Images
MT("Images",
"[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://link.to/image.jpg)]")
//Images with highlight alt text
MT("imageEm",
"[image&image-marker !][image&image-alt-text&link [[][image-alt-text&em&image&link *alt text*][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]");
MT("imageStrong",
"[image&image-marker !][image&image-alt-text&link [[][image-alt-text&strong&image&link **alt text**][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]");
MT("imageEmStrong",
"[image&image-marker !][image&image-alt-text&link [[][image-alt-text&image&strong&link **][image&image-alt-text&em&strong&link *alt text**][image&image-alt-text&em&link *][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)]");
// Inline link with title // Inline link with title
MT("linkTitle", MT("linkTitle",
"[link [[foo]]][string&url (http://example.com/ \"bar\")] hello"); "[link [[foo]]][string&url (http://example.com/ \"bar\")] hello");
@ -599,7 +618,7 @@
// Inline link with image // Inline link with image
MT("linkImage", MT("linkImage",
"[link [[][tag ![[foo]]][string&url (http://example.com/)][link ]]][string&url (http://example.com/)] bar"); "[link [[][link&image&image-marker !][link&image&image-alt-text&link [[alt text]]][string&url (http://link.to/image.jpg)][link ]]][string&url (http://example.com/)] bar");
// Inline link with Em // Inline link with Em
MT("linkEm", MT("linkEm",
@ -615,15 +634,15 @@
// Image with title // Image with title
MT("imageTitle", MT("imageTitle",
"[tag ![[foo]]][string&url (http://example.com/ \"bar\")] hello"); "[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://example.com/ \"bar\")] hello");
// Image without title // Image without title
MT("imageNoTitle", MT("imageNoTitle",
"[tag ![[foo]]][string&url (http://example.com/)] bar"); "[image&image-marker !][image&image-alt-text&link [[alt text]]][string&url (http://example.com/)] bar");
// Image with asterisks // Image with asterisks
MT("imageAsterisks", MT("imageAsterisks",
"[tag ![[*foo*]]][string&url (http://example.com/)] bar"); "[image&image-marker !][image&image-alt-text&link [[ ][image&image-alt-text&em&link *alt text*][image&image-alt-text&link ]]][string&url (http://link.to/image.jpg)] bar");
// Not a link. Should be normal text due to square brackets being used // Not a link. Should be normal text due to square brackets being used
// regularly in text, especially in quoted material, and no space is allowed // regularly in text, especially in quoted material, and no space is allowed
@ -878,7 +897,7 @@
"[override-hr * * *]"); "[override-hr * * *]");
TokenTypeOverrideTest("overrideImage", TokenTypeOverrideTest("overrideImage",
"[override-image ![[foo]]][override-link-href&url (http://example.com/)]") "[override-image&override-image-marker !][override-image&override-image-alt-text&link [[alt text]]][override-link-href&url (http://link.to/image.jpg)]");
TokenTypeOverrideTest("overrideLinkText", TokenTypeOverrideTest("overrideLinkText",
"[override-link-text [[foo]]][override-link-href&url (http://example.com)]"); "[override-link-text [[foo]]][override-link-href&url (http://example.com)]");

View File

@ -233,7 +233,7 @@
function dedent(stream, state) { function dedent(stream, state) {
var indented = stream.indentation(); var indented = stream.indentation();
while (top(state).offset > indented) { while (state.scopes.length > 1 && top(state).offset > indented) {
if (top(state).type != "py") return true; if (top(state).type != "py") return true;
state.scopes.pop(); state.scopes.pop();
} }

View File

@ -121,10 +121,11 @@
return tokenUntil(stream, state, /\{\/literal}/); return tokenUntil(stream, state, /\{\/literal}/);
case "string": case "string":
if (stream.match(/^.*?"/)) { var match = stream.match(/^.*?("|\\[\s\S])/);
state.soyState.pop(); if (!match) {
} else {
stream.skipToEnd(); stream.skipToEnd();
} else if (match[1] == "\"") {
state.soyState.pop();
} }
return "string"; return "string";
} }

View File

@ -366,9 +366,9 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
// http://www.postgresql.org/docs/9.5/static/datatype.html // http://www.postgresql.org/docs/9.5/static/datatype.html
builtin: set("bigint int8 bigserial serial8 bit varying varbit boolean bool box bytea character char varchar cidr circle date double precision float8 inet integer int int4 interval json jsonb line lseg macaddr money numeric decimal path pg_lsn point polygon real float4 smallint int2 smallserial serial2 serial serial4 text time without zone with timetz timestamp timestamptz tsquery tsvector txid_snapshot uuid xml"), builtin: set("bigint int8 bigserial serial8 bit varying varbit boolean bool box bytea character char varchar cidr circle date double precision float8 inet integer int int4 interval json jsonb line lseg macaddr money numeric decimal path pg_lsn point polygon real float4 smallint int2 smallserial serial2 serial serial4 text time without zone with timetz timestamp timestamptz tsquery tsvector txid_snapshot uuid xml"),
atoms: set("false true null unknown"), atoms: set("false true null unknown"),
operatorChars: /^[*+\-%<>!=&|^]/, operatorChars: /^[*+\-%<>!=&|^\/#@?~]/,
dateSQL: set("date time timestamp"), dateSQL: set("date time timestamp"),
support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber nCharCast charsetCast commentHash commentSpaceRequired") support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber nCharCast charsetCast")
}); });
// Google's SQL-like query language, GQL // Google's SQL-like query language, GQL

View File

@ -0,0 +1,94 @@
/*
Name: Panda Syntax
Author: Siamak Mokhtari (http://github.com/siamak/)
CodeMirror template by Siamak Mokhtari (https://github.com/siamak/atom-panda-syntax)
*/
.cm-s-panda-syntax {
/*font-family: 'Operator Mono', 'Source Sans Pro', Helvetica, Arial, sans-serif;*/
font-family: 'Operator Mono', 'Source Sans Pro', Menlo, Monaco, Consolas, Courier New, monospace;
background: #292A2B;
color: #E6E6E6;
}
.cm-s-panda-syntax .CodeMirror-activeline-background {
background: #404954;
}
.cm-s-panda-syntax .cm-comment {
font-style: italic;
color: #676B79;
}
.cm-s-panda-syntax .cm-string,
.cm-s-panda-syntax .cm-string-2 {
color: #19F9D8;
}
.cm-s-panda-syntax .cm-number {
color: #FFB86C;
}
.cm-s-panda-syntax .cm-atom {
color: #FFB86C;
}
.cm-s-panda-syntax .cm-keyword {
color: #FF75B5;
}
.cm-s-panda-syntax .cm-keyword-2 {
color: #FF75B5;
}
.cm-s-panda-syntax .cm-keyword-3 {
color: #B084EB;
}
.cm-s-panda-syntax .cm-variable {
color: #FF9AC1;
}
.cm-s-panda-syntax .cm-variable-2 {
color: #e6e6e6;
}
.cm-s-panda-syntax .cm-variable-3 {
color: #82B1FF;
}
.cm-s-panda-syntax .cm-def {
/*font-style: italic;*/
color: #e6e6e6;
}
.cm-s-panda-syntax .cm-def-2 {
font-style: italic;
color: #ffcc95;
}
.cm-s-panda-syntax .cm-property {
color: #6FC1FF;
}
.cm-s-panda-syntax .cm-matchingbracket,
.CodeMirror .CodeMirror-matchingbracket {
color: #E6E6E6 !important;
border-bottom: 1px dotted #19f9d8;
padding-bottom: 2px;
}
.cm-s-panda-syntax .CodeMirror-gutters {
background: #292A2B;
color: #757575;
border: none;
}
.cm-s-panda-syntax .CodeMirror-guttermarker, .cm-s-panda-syntax .CodeMirror-guttermarker-subtle, .cm-s-panda-syntax .CodeMirror-linenumber {
color: #757575;
}
.cm-s-panda-syntax .CodeMirror-linenumber {
padding-right: 10px;
}
.cm-s-panda-syntax .CodeMirror-cursor {
border-left: 1px solid #757575;
}
/*.cm-s-panda-syntax div.CodeMirror-selected { background: rgba(255, 255, 255, 0.5); }*/
.cm-s-panda-syntax.CodeMirror-focused div.CodeMirror-selected { background: rgba(255, 255, 255, 0.25); }
.cm-s-panda-syntax .CodeMirror-line::selection, .cm-s-panda-syntax .CodeMirror-line > span::selection, .cm-s-panda-syntax .CodeMirror-line > span > span::selection { background: rgba(255, 255, 255, 0.10); }
.cm-s-panda-syntax .CodeMirror-line::-moz-selection, .cm-s-panda-syntax .CodeMirror-line > span::-moz-selection, .cm-s-panda-syntax .CodeMirror-line > span > span::-moz-selection { background: rgba(255, 255, 255, 0.10); }
.cm-s-panda-syntax .CodeMirror-activeline-background { background: rgba(99, 123, 156, 0.125); }