Fix starred scope page tree and local edit save
This commit is contained in:
@@ -2,9 +2,11 @@ import {
|
||||
conflictDetectionKeyFromBody,
|
||||
editorDocumentFromTiptapDocument,
|
||||
flattenText,
|
||||
hydrateMindmapAttrsFromDom,
|
||||
legacyBlocksFromEditorDocument,
|
||||
pageBodyTiptapDocument,
|
||||
revisionFromConflictKey,
|
||||
textToTiptapDocument,
|
||||
toTiptapDocument,
|
||||
} from './document-tiptap-conversion-runtime.js';
|
||||
|
||||
|
||||
@@ -687,6 +687,23 @@ import { createSidebarPageSettingsRuntime } from './sidebar-page-settings-runtim
|
||||
return root;
|
||||
}
|
||||
|
||||
function ensureStarredFolderPageTreeHost(workspaceId) {
|
||||
var root = document.getElementById('sidebar-tree-root');
|
||||
if (root instanceof HTMLElement) return root;
|
||||
var panel = document.getElementById('wolai-sidebar-page-tree-panel') || document.querySelector('[data-mnote-sidebar-tree-panel="page"]');
|
||||
if (!(panel instanceof HTMLElement)) return null;
|
||||
var section = document.createElement('div');
|
||||
section.className = 'sidebar-tree-section';
|
||||
root = document.createElement('div');
|
||||
root.id = 'sidebar-tree-root';
|
||||
root.className = 'sidebar-tree';
|
||||
root.setAttribute('data-tree-shell-mode', 'page');
|
||||
if (workspaceId) root.setAttribute('data-workspace-id', workspaceId);
|
||||
section.appendChild(root);
|
||||
panel.appendChild(section);
|
||||
return root;
|
||||
}
|
||||
|
||||
function persistStarredFolderScope(workspaceId, rootUri, relativePath) {
|
||||
var targetUrl = new URL(window.location.href);
|
||||
if (workspaceId) targetUrl.searchParams.set('workspaceId', workspaceId);
|
||||
@@ -719,17 +736,23 @@ import { createSidebarPageSettingsRuntime } from './sidebar-page-settings-runtim
|
||||
var tab = document.querySelector('[data-mnote-sidebar-tree-tab="filetree"]');
|
||||
if (tab instanceof HTMLElement) switchSidebarTreeTab(tab);
|
||||
var root = ensureStarredFolderFileTreeHost(workspaceId);
|
||||
var pageRoot = ensureStarredFolderPageTreeHost(workspaceId);
|
||||
if (root instanceof HTMLElement) {
|
||||
root.setAttribute('data-workspace-id', workspaceId);
|
||||
root.setAttribute('data-mnote-filetree-scope', relativePath);
|
||||
root.setAttribute('data-mnote-filetree-scope-title', row.textContent ? row.textContent.trim() : relativePath);
|
||||
}
|
||||
if (pageRoot instanceof HTMLElement) {
|
||||
pageRoot.setAttribute('data-workspace-id', workspaceId);
|
||||
pageRoot.setAttribute('data-mnote-page-tree-scope', relativePath);
|
||||
}
|
||||
persistStarredFolderScope(workspaceId, rootUri, relativePath);
|
||||
document.documentElement.setAttribute('data-mnote-filetree-scope', relativePath);
|
||||
var sidebarUrl = new URL('/api/tree/projections/sidebar', window.location.origin);
|
||||
sidebarUrl.searchParams.set('workspaceId', workspaceId);
|
||||
sidebarUrl.searchParams.set('sourceKind', 'local_folder');
|
||||
sidebarUrl.searchParams.set('rootUri', rootUri);
|
||||
sidebarUrl.searchParams.set('parentRelativePath', relativePath);
|
||||
var url = new URL('/api/tree/projections/file', window.location.origin);
|
||||
url.searchParams.set('workspaceId', workspaceId);
|
||||
url.searchParams.set('sourceKind', 'local_folder');
|
||||
|
||||
Reference in New Issue
Block a user