MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / loadFile

Function loadFile

static/js/codemirror/codemirror.js:1671–1681  ·  view source on GitHub ↗
(file, i)

Source from the content-addressed store, hash-verified

1669 if (files && files.length && window.FileReader && window.File) {
1670 var n = files.length, text = Array(n), read = 0;
1671 var loadFile = function(file, i) {
1672 var reader = new FileReader;
1673 reader.onload = function() {
1674 text[i] = reader.result;
1675 if (++read == n) {
1676 pos = clipPos(cm.doc, pos);
1677 replaceRange(cm.doc, text.join(""), pos, "around", "paste");
1678 }
1679 };
1680 reader.readAsText(file);
1681 };
1682 for (var i = 0; i < n; ++i) loadFile(files[i], i);
1683 } else {
1684 // Don't do a replace if the drop happened inside of the selected text.

Callers 1

onDropFunction · 0.85

Calls 2

clipPosFunction · 0.85
replaceRangeFunction · 0.85

Tested by

no test coverage detected