Avoid custom drag data type

This commit is contained in:
Mikei386
2026-06-22 23:17:46 +02:00
parent b449a74cad
commit 88b49fd0bd
5 changed files with 18 additions and 7 deletions
+15 -4
View File
@@ -242,8 +242,11 @@ function renderExplorer(body, win) {
});
row.addEventListener('dragstart', (event) => {
state.draggedEntry = { path: entry.path, name: entry.name, sourceWindowId: win.id };
event.dataTransfer.setData('application/x-u-navigator-path', entry.path);
event.dataTransfer.setData('text/plain', entry.path);
try {
event.dataTransfer.setData('text/plain', entry.path);
} catch {
// Some WebKit builds reject programmatic drag data. App state is the primary channel.
}
event.dataTransfer.effectAllowed = 'copyMove';
row.classList.add('dragging');
});
@@ -359,7 +362,7 @@ async function handleDrop(event, win, targetPath) {
return;
}
const internalPath = event.dataTransfer.getData('application/x-u-navigator-path') || event.dataTransfer.getData('text/plain') || state.draggedEntry?.path;
const internalPath = state.draggedEntry?.path || safeGetDragText(event);
if (internalPath) {
const name = internalPath.split('/').filter(Boolean).at(-1);
const destination = `${targetPath.replace(/\/$/, '')}/${name}`;
@@ -402,7 +405,7 @@ async function reloadExplorerWindows(ids) {
}
function hasDropPayload(event) {
return Boolean(state.draggedEntry || event.dataTransfer?.types?.includes('Files') || event.dataTransfer?.types?.includes('application/x-u-navigator-path') || event.dataTransfer?.types?.includes('text/plain'));
return Boolean(state.draggedEntry || event.dataTransfer?.types?.includes('Files') || event.dataTransfer?.types?.includes('text/plain'));
}
function showError(error) {
@@ -410,6 +413,14 @@ function showError(error) {
alert(message);
}
function safeGetDragText(event) {
try {
return event.dataTransfer.getData('text/plain');
} catch {
return '';
}
}
async function renameEntry(win, entry) {
const nextName = prompt('Neuer Name', entry.name);
if (!nextName || nextName === entry.name) {