mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-11 18:00:26 +00:00
Fix for IE drag/drop issue #252
This commit is contained in:
parent
819843e4b0
commit
80e0714c0d
@ -102,8 +102,10 @@ DropZoneWidget.prototype.handleDropEvent = function(event) {
|
||||
DropZoneWidget.prototype.importData = function(dataTransfer) {
|
||||
for(var t=0; t<this.importDataTypes.length; t++) {
|
||||
var dataType = this.importDataTypes[t];
|
||||
var data = dataTransfer.getData(dataType.type);
|
||||
if(data !== "") {
|
||||
try {
|
||||
var data = dataTransfer.getData(dataType.type);
|
||||
} catch(e) { if(e.description !== "Invalid argument.") throw e; } // deal with formats that IE doesn't support
|
||||
if(data !== "" && data != null) {
|
||||
var tiddlerFields = dataType.convertToFields(data);
|
||||
if(!tiddlerFields.title) {
|
||||
tiddlerFields.title = this.wiki.generateNewTitle("Untitled");
|
||||
@ -115,6 +117,22 @@ DropZoneWidget.prototype.importData = function(dataTransfer) {
|
||||
};
|
||||
|
||||
DropZoneWidget.prototype.importDataTypes = [
|
||||
{type: "URL", convertToFields: function(data) {
|
||||
// check for tiddler data URI
|
||||
var match = decodeURI(data).match(/^data\:text\/vnd\.tiddler,(.*)/i);
|
||||
if(match) {
|
||||
return JSON.parse(match[1]);
|
||||
} else {
|
||||
return { // as URL string
|
||||
text: data
|
||||
};
|
||||
}
|
||||
}},
|
||||
{type: "Text", convertToFields: function(data) {
|
||||
return {
|
||||
text: data
|
||||
};
|
||||
}},
|
||||
{type: "text/vnd.tiddler", convertToFields: function(data) {
|
||||
return JSON.parse(data);
|
||||
}},
|
||||
|
@ -125,10 +125,14 @@ LinkWidget.prototype.handleDragStartEvent = function(event) {
|
||||
// Set the data transfer properties
|
||||
var dataTransfer = event.dataTransfer;
|
||||
dataTransfer.effectAllowed = "copy";
|
||||
dataTransfer.setDragImage(this.dragImage.firstChild,-16,-16);
|
||||
if(dataTransfer.setDragImage) {
|
||||
dataTransfer.setDragImage(this.dragImage.firstChild,-16,-16);
|
||||
}
|
||||
dataTransfer.clearData();
|
||||
dataTransfer.setData("text/vnd.tiddler",this.wiki.getTiddlerAsJson(this.to));
|
||||
dataTransfer.setData("text/plain",this.wiki.getTiddlerText(this.to,""));
|
||||
dataTransfer.setData("URL","data:text/vnd.tiddler," + encodeURI(this.wiki.getTiddlerAsJson(this.to)));
|
||||
dataTransfer.setData("Text",this.wiki.getTiddlerText(this.to,""));
|
||||
event.stopPropagation();
|
||||
} else {
|
||||
event.preventDefault();
|
||||
|
Loading…
Reference in New Issue
Block a user