refactor: delegate filetree upload fallback
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user