1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-26 03:27:18 +00:00

Fix drag and drop from chrome-like browsers to FireFox (#7622)

* fix drag and drop from chrome-like browsers to FireFox

* test feature matchMedia function

* implement new borwser sniffing functions as utilities

* use $tw.browser structure for isMobileChrome detection
This commit is contained in:
Mario Pietsch 2023-07-22 16:47:39 +02:00 committed by GitHub
parent ad6e09f1cb
commit e60232e0cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -27,6 +27,11 @@ exports.startup = function() {
if($tw.browser) {
$tw.browser.isIE = (/msie|trident/i.test(navigator.userAgent));
$tw.browser.isFirefox = !!document.mozFullScreenEnabled;
// 2023-07-21 Edge returns UA below. So we use "isChromeLike"
//'mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/114.0.0.0 safari/537.36 edg/114.0.1823.82'
$tw.browser.isChromeLike = navigator.userAgent.toLowerCase().indexOf("chrome") > -1;
$tw.browser.hasTouch = !!window.matchMedia && window.matchMedia("(pointer: coarse)").matches;
$tw.browser.isMobileChrome = $tw.browser.isChromeLike && $tw.browser.hasTouch;
}
// Platform detection
$tw.platform = {};

View File

@ -80,7 +80,7 @@ exports.makeDraggable = function(options) {
if(dataTransfer.setDragImage) {
if(dragImageType === "pill") {
dataTransfer.setDragImage(dragImage.firstChild,-16,-16);
} else if (dragImageType === "blank") {
} else if(dragImageType === "blank") {
dragImage.removeChild(dragImage.firstChild);
dataTransfer.setDragImage(dragImage,0,0);
} else {
@ -106,7 +106,9 @@ exports.makeDraggable = function(options) {
dataTransfer.setData("text/vnd.tiddler",jsonData);
dataTransfer.setData("text/plain",titleString);
dataTransfer.setData("text/x-moz-url","data:text/vnd.tiddler," + encodeURIComponent(jsonData));
} else {
}
// If browser is Chrome-like and has a touch-input device do NOT .setData
if(!($tw.browser.isMobileChrome)) {
dataTransfer.setData("URL","data:text/vnd.tiddler," + encodeURIComponent(jsonData));
}
dataTransfer.setData("Text",titleString);