refactor: extract dnd target and sidebar helpers
This commit is contained in:
@@ -214,6 +214,17 @@ function groupRowsByParent(rows) {
|
||||
return grouped;
|
||||
}
|
||||
|
||||
function replaceSidebarTreeFromDocument(nextDocument, rootId) {
|
||||
var current = document.getElementById(rootId);
|
||||
var next = nextDocument ? nextDocument.getElementById(rootId) : null;
|
||||
if (!(current instanceof HTMLElement) || !(next instanceof HTMLElement)) return false;
|
||||
current.innerHTML = next.innerHTML;
|
||||
Array.from(next.attributes || []).forEach(function(attr) {
|
||||
current.setAttribute(attr.name, attr.value);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
function revealFileTreeRow(row) {
|
||||
if (!(row instanceof HTMLElement)) return;
|
||||
var node = row.closest('.tree-node');
|
||||
@@ -351,6 +362,7 @@ window.__mnoteFileTreeRuntime = {
|
||||
titleOf: titleOf,
|
||||
fileWorkspaceRelativePath: fileWorkspaceRelativePath,
|
||||
groupRowsByParent: groupRowsByParent,
|
||||
replaceSidebarTreeFromDocument: replaceSidebarTreeFromDocument,
|
||||
fileTreeRowKind: fileTreeRowKind,
|
||||
fileTreeRowDocumentId: fileTreeRowDocumentId,
|
||||
fileTreeRowAssetId: fileTreeRowAssetId,
|
||||
|
||||
Reference in New Issue
Block a user