mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-07-23 09:54:28 -06:00
Update to support allowDropFileTypes
This commit is contained in:
parent
cee66d4873
commit
416d807a92
12
dist/simplemde.min.js
vendored
12
dist/simplemde.min.js
vendored
File diff suppressed because one or more lines are too long
@ -3821,9 +3821,15 @@
|
|||||||
if (files && files.length && window.FileReader && window.File) {
|
if (files && files.length && window.FileReader && window.File) {
|
||||||
var n = files.length, text = Array(n), read = 0;
|
var n = files.length, text = Array(n), read = 0;
|
||||||
var loadFile = function(file, i) {
|
var loadFile = function(file, i) {
|
||||||
|
if (cm.options.allowDropFileTypes &&
|
||||||
|
indexOf(cm.options.allowDropFileTypes, file.type) == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
var reader = new FileReader;
|
var reader = new FileReader;
|
||||||
reader.onload = operation(cm, function() {
|
reader.onload = operation(cm, function() {
|
||||||
text[i] = reader.result;
|
var content = reader.result;
|
||||||
|
if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) content = "";
|
||||||
|
text[i] = content;
|
||||||
if (++read == n) {
|
if (++read == n) {
|
||||||
pos = clipPos(cm.doc, pos);
|
pos = clipPos(cm.doc, pos);
|
||||||
var change = {from: pos, to: pos,
|
var change = {from: pos, to: pos,
|
||||||
@ -4221,6 +4227,7 @@
|
|||||||
// right-click take effect on it.
|
// right-click take effect on it.
|
||||||
function onContextMenu(cm, e) {
|
function onContextMenu(cm, e) {
|
||||||
if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return;
|
if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return;
|
||||||
|
if (signalDOMEvent(cm, e, "contextmenu")) return;
|
||||||
cm.display.input.onContextMenu(e);
|
cm.display.input.onContextMenu(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5404,6 +5411,7 @@
|
|||||||
});
|
});
|
||||||
option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true);
|
option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true);
|
||||||
option("dragDrop", true, dragDropChanged);
|
option("dragDrop", true, dragDropChanged);
|
||||||
|
option("allowDropFileTypes", null);
|
||||||
|
|
||||||
option("cursorBlinkRate", 530);
|
option("cursorBlinkRate", 530);
|
||||||
option("cursorScrollMargin", 0);
|
option("cursorScrollMargin", 0);
|
||||||
@ -5708,8 +5716,8 @@
|
|||||||
var range = cm.listSelections()[i];
|
var range = cm.listSelections()[i];
|
||||||
cm.replaceRange(cm.doc.lineSeparator(), range.anchor, range.head, "+input");
|
cm.replaceRange(cm.doc.lineSeparator(), range.anchor, range.head, "+input");
|
||||||
cm.indentLine(range.from().line + 1, null, true);
|
cm.indentLine(range.from().line + 1, null, true);
|
||||||
ensureCursorVisible(cm);
|
|
||||||
}
|
}
|
||||||
|
ensureCursorVisible(cm);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
toggleOverwrite: function(cm) {cm.toggleOverwrite();}
|
toggleOverwrite: function(cm) {cm.toggleOverwrite();}
|
||||||
|
@ -915,7 +915,7 @@ SimpleMDE.prototype.render = function(el) {
|
|||||||
autofocus: (options.autofocus === true) ? true : false,
|
autofocus: (options.autofocus === true) ? true : false,
|
||||||
extraKeys: keyMaps,
|
extraKeys: keyMaps,
|
||||||
lineWrapping: (options.lineWrapping === false) ? false : true,
|
lineWrapping: (options.lineWrapping === false) ? false : true,
|
||||||
allowDroppedFileTypes: ["text/plain"]
|
allowDropFileTypes: ["text/plain"]
|
||||||
});
|
});
|
||||||
|
|
||||||
if(options.toolbar !== false) {
|
if(options.toolbar !== false) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user