refactor: delegate filetree upload fallback

This commit is contained in:
lix-2026
2026-05-25 02:55:45 +08:00
parent 3b8445ffab
commit fa3dc76d53
3 changed files with 49 additions and 1 deletions
@@ -120,6 +120,35 @@ function fileTreeChildCount(documentId, deps) {
return children.length;
}
function fileTreeUploadTargetFallback(detail, deps) {
detail = detail || {};
deps = deps || {};
var resolveWorkspaceId = typeof deps.resolveWorkspaceId === 'function' ? deps.resolveWorkspaceId : function() { return ''; };
var currentDocumentId = typeof deps.currentDocumentId === 'function' ? deps.currentDocumentId : function() { return ''; };
var workspaceId = String(detail.workspaceId || resolveWorkspaceId(document.body) || '').trim();
var documentId = String(detail.documentId || currentDocumentId() || '').trim();
if (Object.prototype.hasOwnProperty.call(detail, 'targetRelativePath')) {
return {
workspaceId: workspaceId,
targetDocumentId: documentId,
targetMindmapId: null,
targetSubPath: null,
targetRelativePath: String(detail.targetRelativePath || ''),
uploadIntent: String(detail.uploadIntent || 'filetree.folder.drop')
};
}
if (!workspaceId || !documentId) {
throw new Error('请选择一个目标页面后再拖入文件');
}
return {
workspaceId: workspaceId,
targetDocumentId: documentId,
targetMindmapId: null,
targetSubPath: null,
uploadIntent: String(detail.uploadIntent || 'editor.markdown.attach')
};
}
window.__mnoteFileTreeRuntime = {
fileTreeRowKind: fileTreeRowKind,
fileTreeRowDocumentId: fileTreeRowDocumentId,
@@ -131,5 +160,6 @@ window.__mnoteFileTreeRuntime = {
isFileTreeDownloadableRow: isFileTreeDownloadableRow,
fileTreeAssetDownloadDetail: fileTreeAssetDownloadDetail,
fileTreeRowsByRowIds: fileTreeRowsByRowIds,
fileTreeChildCount: fileTreeChildCount
fileTreeChildCount: fileTreeChildCount,
fileTreeUploadTargetFallback: fileTreeUploadTargetFallback
};