MCPcopy Create free account
hub / github.com/sql-js/sql.js / loadFile

Function loadFile

GUI/codemirror/lib/codemirror.js:2791–2803  ·  view source on GitHub ↗
(file, i)

Source from the content-addressed store, hash-verified

2789 if (files && files.length && window.FileReader && window.File) {
2790 var n = files.length, text = Array(n), read = 0;
2791 var loadFile = function(file, i) {
2792 var reader = new FileReader;
2793 reader.onload = operation(cm, function() {
2794 text[i] = reader.result;
2795 if (++read == n) {
2796 pos = clipPos(cm.doc, pos);
2797 var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"};
2798 makeChange(cm.doc, change);
2799 setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
2800 }
2801 });
2802 reader.readAsText(file);
2803 };
2804 for (var i = 0; i < n; ++i) loadFile(files[i], i);
2805 } else { // Normal drop
2806 // Don't do a replace if the drop happened inside of the selected text.

Callers 1

onDropFunction · 0.85

Calls 5

operationFunction · 0.85
clipPosFunction · 0.85
makeChangeFunction · 0.85
simpleSelectionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…