refactor: add filetree sidebar snapshot helper
This commit is contained in:
@@ -225,6 +225,20 @@ function replaceSidebarTreeFromDocument(nextDocument, rootId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function applyLocalFolderSidebarSnapshot(nextDocument, options) {
|
||||
options = options || {};
|
||||
var pageRootId = String(options.pageRootId || 'sidebar-tree-root');
|
||||
var fileRootId = String(options.fileRootId || 'sidebar-file-tree-root');
|
||||
var appliedPage = replaceSidebarTreeFromDocument(nextDocument, pageRootId);
|
||||
var appliedFile = replaceSidebarTreeFromDocument(nextDocument, fileRootId);
|
||||
var applied = appliedPage || appliedFile;
|
||||
if (applied && typeof options.onApplied === 'function') options.onApplied({
|
||||
pageRootApplied: appliedPage,
|
||||
fileRootApplied: appliedFile
|
||||
});
|
||||
return applied;
|
||||
}
|
||||
|
||||
function revealFileTreeRow(row) {
|
||||
if (!(row instanceof HTMLElement)) return;
|
||||
var node = row.closest('.tree-node');
|
||||
@@ -363,6 +377,7 @@ window.__mnoteFileTreeRuntime = {
|
||||
fileWorkspaceRelativePath: fileWorkspaceRelativePath,
|
||||
groupRowsByParent: groupRowsByParent,
|
||||
replaceSidebarTreeFromDocument: replaceSidebarTreeFromDocument,
|
||||
applyLocalFolderSidebarSnapshot: applyLocalFolderSidebarSnapshot,
|
||||
fileTreeRowKind: fileTreeRowKind,
|
||||
fileTreeRowDocumentId: fileTreeRowDocumentId,
|
||||
fileTreeRowAssetId: fileTreeRowAssetId,
|
||||
|
||||
Reference in New Issue
Block a user