codemirror
Advanced tools
Comparing version 5.50.2 to 5.51.0
@@ -325,2 +325,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
}); | ||
this.scrollToActive() | ||
@@ -367,2 +368,8 @@ CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]); | ||
node.className += " " + ACTIVE_HINT_ELEMENT_CLASS; | ||
this.scrollToActive() | ||
CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node); | ||
}, | ||
scrollToActive: function() { | ||
var node = this.hints.childNodes[this.selectedHint] | ||
if (node.offsetTop < this.hints.scrollTop) | ||
@@ -372,3 +379,2 @@ this.hints.scrollTop = node.offsetTop - 3; | ||
this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3; | ||
CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node); | ||
}, | ||
@@ -375,0 +381,0 @@ |
@@ -174,3 +174,3 @@ // CodeMirror, copyright (c) by Marijn Haverbeke and others | ||
{ | ||
source.next(); | ||
source.next(); | ||
setState(normal()); | ||
@@ -177,0 +177,0 @@ return 'string'; |
{ | ||
"name": "codemirror", | ||
"version": "5.50.2", | ||
"version": "5.51.0", | ||
"main": "lib/codemirror.js", | ||
@@ -5,0 +5,0 @@ "style": "lib/codemirror.css", |
@@ -123,2 +123,5 @@ import { Display } from "../display/Display.js" | ||
on(d.scroller, "contextmenu", e => onContextMenu(cm, e)) | ||
on(d.input.getField(), "contextmenu", e => { | ||
if (!d.scroller.contains(e.target)) onContextMenu(cm, e) | ||
}) | ||
@@ -125,0 +128,0 @@ // Used to suppress mouse event handling when a touch happens |
@@ -32,24 +32,35 @@ import { drawSelectionCursor } from "../display/selection.js" | ||
let n = files.length, text = Array(n), read = 0 | ||
let loadFile = (file, i) => { | ||
if (cm.options.allowDropFileTypes && | ||
indexOf(cm.options.allowDropFileTypes, file.type) == -1) | ||
return | ||
let reader = new FileReader | ||
reader.onload = operation(cm, () => { | ||
let content = reader.result | ||
if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) content = "" | ||
text[i] = content | ||
if (++read == n) { | ||
const markAsReadAndPasteIfAllFilesAreRead = () => { | ||
if (++read == n) { | ||
operation(cm, () => { | ||
pos = clipPos(cm.doc, pos) | ||
let change = {from: pos, to: pos, | ||
text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())), | ||
text: cm.doc.splitLines( | ||
text.filter(t => t != null).join(cm.doc.lineSeparator())), | ||
origin: "paste"} | ||
makeChange(cm.doc, change) | ||
setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change))) | ||
})() | ||
} | ||
} | ||
const readTextFromFile = (file, i) => { | ||
if (cm.options.allowDropFileTypes && | ||
indexOf(cm.options.allowDropFileTypes, file.type) == -1) { | ||
markAsReadAndPasteIfAllFilesAreRead() | ||
return | ||
} | ||
let reader = new FileReader | ||
reader.onerror = () => markAsReadAndPasteIfAllFilesAreRead() | ||
reader.onload = () => { | ||
let content = reader.result | ||
if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { | ||
markAsReadAndPasteIfAllFilesAreRead() | ||
return | ||
} | ||
}) | ||
text[i] = content; | ||
markAsReadAndPasteIfAllFilesAreRead() | ||
} | ||
reader.readAsText(file) | ||
} | ||
for (let i = 0; i < n; ++i) loadFile(files[i], i) | ||
for (let i = 0; i < files.length; i++) readTextFromFile(files[i], i) | ||
} else { // Normal drop | ||
@@ -56,0 +67,0 @@ // Don't do a replace if the drop happened inside of the selected text. |
@@ -69,2 +69,2 @@ // EDITOR CONSTRUCTOR | ||
CodeMirror.version = "5.50.2" | ||
CodeMirror.version = "5.51.0" |
@@ -472,4 +472,5 @@ import { deleteNearSelection } from "./deleteNearSelection.js" | ||
let lineObj = getLine(doc, pos.line) | ||
let lineDir = visually && doc.cm && doc.cm.getOption("direction") == "rtl" ? -dir : dir | ||
function findNextLine() { | ||
let l = pos.line + dir | ||
let l = pos.line + lineDir | ||
if (l < doc.first || l >= doc.first + doc.size) return false | ||
@@ -488,3 +489,3 @@ pos = new Pos(l, pos.ch, pos.sticky) | ||
if (!boundToLine && findNextLine()) | ||
pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir) | ||
pos = endOfLine(visually, doc.cm, lineObj, pos.line, lineDir) | ||
else | ||
@@ -491,0 +492,0 @@ return false |
@@ -18,2 +18,3 @@ import { Pos } from "../line/pos.js" | ||
if (visually) { | ||
if (cm.getOption("direction") == "rtl") dir = -dir | ||
let order = getOrder(lineObj, cm.doc.direction) | ||
@@ -20,0 +21,0 @@ if (order) { |
@@ -200,3 +200,6 @@ import CodeMirror from "../edit/CodeMirror.js" | ||
}, | ||
clearHistory: function() {this.history = new History(this.history.maxGeneration)}, | ||
clearHistory: function() { | ||
this.history = new History(this.history.maxGeneration) | ||
linkedDocs(this, doc => doc.history = this.history, true) | ||
}, | ||
@@ -203,0 +206,0 @@ markClean: function() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2832626
64086