Merge branch 'master' into publishing-framework

This commit is contained in:
jeremy@jermolene.com
2021-05-20 13:53:29 +01:00
101 changed files with 1865 additions and 369 deletions
+1 -1
View File
@@ -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);
});
+30 -1
View File
@@ -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);
});
}
}
/*
+12 -9
View File
@@ -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);
};
}
}
})();