MCPcopy
hub / github.com/pandao/editor.md / loadFile

Function loadFile

lib/codemirror/lib/codemirror.js:3721–3733  ·  view source on GitHub ↗
(file, i)

Source from the content-addressed store, hash-verified

3719 if (files && files.length && window.FileReader && window.File) {
3720 var n = files.length, text = Array(n), read = 0;
3721 var loadFile = function(file, i) {
3722 var reader = new FileReader;
3723 reader.onload = operation(cm, function() {
3724 text[i] = reader.result;
3725 if (++read == n) {
3726 pos = clipPos(cm.doc, pos);
3727 var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"};
3728 makeChange(cm.doc, change);
3729 setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
3730 }
3731 });
3732 reader.readAsText(file);
3733 };
3734 for (var i = 0; i < n; ++i) loadFile(files[i], i);
3735 } else { // Normal drop
3736 // Don't do a replace if the drop happened inside of the selected text.

Callers 1

onDropFunction · 0.70

Calls 6

operationFunction · 0.70
clipPosFunction · 0.70
makeChangeFunction · 0.70
simpleSelectionFunction · 0.70
splitLinesFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…