mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-14 13:51:24 +00:00
Merge branch 'master' into publishing-framework
This commit is contained in:
@@ -39,7 +39,7 @@ exports["application/x-bibtex"] = function(text,fields) {
|
||||
"bibtex-entry-type": entry.entryType
|
||||
};
|
||||
$tw.utils.each(entry.entryTags,function(value,name) {
|
||||
fields["bibtex-" + name] = value;
|
||||
fields["bibtex-" + name.toLowerCase()] = value;
|
||||
});
|
||||
results.push(fields);
|
||||
});
|
||||
|
||||
@@ -124,8 +124,11 @@ function CodeMirrorEngine(options) {
|
||||
self.widget.invokeActionString(self.widget.editInputActions);
|
||||
}
|
||||
});
|
||||
|
||||
this.cm.on("drop",function(cm,event) {
|
||||
event.stopPropagation(); // Otherwise TW's dropzone widget sees the drop event
|
||||
if(!self.widget.isFileDropEnabled) {
|
||||
event.stopPropagation(); // Otherwise TW's dropzone widget sees the drop event
|
||||
}
|
||||
return false;
|
||||
});
|
||||
this.cm.on("keydown",function(cm,event) {
|
||||
@@ -136,6 +139,32 @@ function CodeMirrorEngine(options) {
|
||||
$tw.popup.cancel(0);
|
||||
}
|
||||
});
|
||||
// Add drag and drop event listeners if fileDrop is enabled
|
||||
if(this.widget.isFileDropEnabled) {
|
||||
// If the drag event contains Files, prevent the default CodeMirror handling
|
||||
this.cm.on("dragenter",function(cm,event) {
|
||||
if($tw.utils.dragEventContainsFiles(event)) {
|
||||
event.preventDefault();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
this.cm.on("dragleave",function(cm,event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
this.cm.on("dragover",function(cm,event) {
|
||||
if($tw.utils.dragEventContainsFiles(event)) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
this.cm.on("drop",function(cm,event) {
|
||||
if($tw.utils.dragEventContainsFiles(event)) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
this.cm.on("paste",function(cm,event) {
|
||||
self.widget.handlePasteEvent.call(self.widget,event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -40,14 +40,17 @@ function debounce(callback) {
|
||||
}
|
||||
|
||||
function setupEvents(host) {
|
||||
var events = new EventSource(host + "events/plugins/tiddlywiki/tiddlyweb");
|
||||
var debouncedSync = debounce($tw.syncer.syncFromServer.bind($tw.syncer));
|
||||
events.addEventListener("change",debouncedSync);
|
||||
events.onerror = function() {
|
||||
events.close();
|
||||
setTimeout(function() {
|
||||
setupEvents(host);
|
||||
},$tw.syncer.errorRetryInterval);
|
||||
};
|
||||
if(window.EventSource) {
|
||||
var events = new EventSource(host + "events/plugins/tiddlywiki/tiddlyweb");
|
||||
var debouncedSync = debounce($tw.syncer.syncFromServer.bind($tw.syncer));
|
||||
events.addEventListener("change",debouncedSync);
|
||||
events.onerror = function() {
|
||||
events.close();
|
||||
setTimeout(function() {
|
||||
setupEvents(host);
|
||||
},$tw.syncer.errorRetryInterval);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user