fix: drop files on markdown row into same folder

This commit is contained in:
lix-2026
2026-05-24 13:59:54 +08:00
parent 36eac664f2
commit 289a44acea
3 changed files with 20 additions and 3 deletions
+11 -3
View File
@@ -5073,6 +5073,16 @@ const SIDEBAR_TREE_JS: &str = r##"
return '';
}
function fileTreeRowLocalUploadTargetRelativePath(row) {
if (!(row instanceof HTMLElement)) return '';
var kind = fileTreeRowKind(row);
var relativePath = fileTreeRowLocalRelativePath(row);
if (!relativePath) return '';
if (kind === 'folder' || kind === 'directory') return relativePath;
var lastSlash = relativePath.lastIndexOf('/');
return lastSlash >= 0 ? relativePath.slice(0, lastSlash) : '';
}
function fileTreeRowKind(row) {
if (!(row instanceof HTMLElement)) return '';
return String(row.getAttribute('data-row-kind') || '').trim();
@@ -10111,9 +10121,7 @@ const SIDEBAR_TREE_JS: &str = r##"
targetRowKind: targetRow ? targetRow.getAttribute('data-row-kind') : 'root',
documentId: targetRow ? targetRow.getAttribute('data-document-id') || targetRow.getAttribute('data-doc-id') : null,
assetId: targetRow ? targetRow.getAttribute('data-asset-id') : null,
targetRelativePath: targetRow && (targetRow.getAttribute('data-row-kind') === 'folder' || targetRow.getAttribute('data-row-kind') === 'directory')
? fileTreeRowLocalRelativePath(targetRow)
: null,
targetRelativePath: targetRow ? fileTreeRowLocalUploadTargetRelativePath(targetRow) : '',
uploadIntent: 'filetree.folder.drop'
};
if (activeFileTreeDropRow instanceof HTMLElement) activeFileTreeDropRow.setAttribute('data-drop-target', 'false');