diff --git a/doc/manual.html b/doc/manual.html index e2a3269d6b9975b20c50180ad5634e921156991d..095a80cd1c0b920b6f2068367e7aa7395b2c17bd 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -421,6 +421,13 @@ <dt id="option_dragDrop"><code><strong>dragDrop</strong>: boolean</code></dt> <dd>Controls whether drag-and-drop is enabled. On by default.</dd> + <dt id="option_allowDropFileTypes"><code><strong>allowDropFileTypes</strong>: array<string></code></dt> + <dd>When set (default is <code>null</code>) only files whose + type is in the array can be dropped into the editor. The strings + should be MIME types, and will be checked against + the <a href="https://w3c.github.io/FileAPI/#dfn-type"><code>type</code></a> + of the <code>File</code> object as reported by the browser.</dd> + <dt id="option_cursorBlinkRate"><code><strong>cursorBlinkRate</strong>: number</code></dt> <dd>Half-period in milliseconds used for cursor blinking. The default blink rate is 530ms. By setting this to zero, blinking can be disabled. A diff --git a/lib/codemirror.js b/lib/codemirror.js index 996978fc67b97c6d0f2044fba2a5ba567261150a..f0f8837aed1919977b46e7f7d5a0a2dd11a6ca7f 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -3821,7 +3821,8 @@ if (files && files.length && window.FileReader && window.File) { var n = files.length, text = Array(n), read = 0; var loadFile = function(file, i) { - if(this.options.allowDroppedFileTypes !== undefined && this.options.allowDroppedFileTypes.indexOf(file.type) === -1) + if (cm.options.allowDropFileTypes && + indexOf(cm.options.allowDropFileTypes, file.type) == -1) return; var reader = new FileReader; @@ -5408,6 +5409,7 @@ }); option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true); option("dragDrop", true, dragDropChanged); + option("allowDropFileTypes", null); option("cursorBlinkRate", 530); option("cursorScrollMargin", 0);