MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / readTextFromFile

Function readTextFromFile

lib/web/CodeMirror/src/edit/drop_events.js:45–63  ·  view source on GitHub ↗
(file, i)

Source from the content-addressed store, hash-verified

43 }
44 }
45 const readTextFromFile = (file, i) => {
46 if (cm.options.allowDropFileTypes &&
47 indexOf(cm.options.allowDropFileTypes, file.type) == -1) {
48 markAsReadAndPasteIfAllFilesAreRead()
49 return
50 }
51 let reader = new FileReader
52 reader.onerror = () => markAsReadAndPasteIfAllFilesAreRead()
53 reader.onload = () => {
54 let content = reader.result
55 if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) {
56 markAsReadAndPasteIfAllFilesAreRead()
57 return
58 }
59 text[i] = content
60 markAsReadAndPasteIfAllFilesAreRead()
61 }
62 reader.readAsText(file)
63 }
64 for (let i = 0; i < files.length; i++) readTextFromFile(files[i], i)
65 } else { // Normal drop
66 // Don't do a replace if the drop happened inside of the selected text.

Callers 1

onDropFunction · 0.70

Calls 3

indexOfFunction · 0.90
testMethod · 0.45

Tested by

no test coverage detected