fix: allow returning from resource tabs

This commit is contained in:
lix-2026
2026-05-20 17:00:17 +08:00
parent bdc05c1d27
commit bbd9dab701
3 changed files with 44 additions and 10 deletions
@@ -3044,6 +3044,17 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str {
});
};
const bindMainEditorPageTab = () => {
const nodes = resourceTabHostNodes();
if (!(nodes.pageTab instanceof HTMLElement)) return;
if (nodes.pageTab.getAttribute('data-mnote-page-tab-bound') === 'true') return;
nodes.pageTab.setAttribute('data-mnote-page-tab-bound', 'true');
nodes.pageTab.addEventListener('click', (event) => {
event.preventDefault();
activateMainEditorTab('');
});
};
const closeResourceTab = (objectIdentity) => {
const key = String(objectIdentity || '').trim();
const entry = resourceTabRegistry.get(key);
@@ -3206,6 +3217,7 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str {
};
const openResourceInActiveTab = async (input = {}) => {
bindMainEditorPageTab();
const objectIdentity = String(input.objectIdentity || input.assetId || input.href || '').trim();
if (!objectIdentity) return false;
const existing = resourceTabRegistry.get(objectIdentity);
@@ -3317,6 +3329,8 @@ pub(crate) fn render_editor_island_adapter_script() -> &'static str {
},
};
bindMainEditorPageTab();
window.addEventListener('pagehide', () => {
Array.from(documentSessionRegistry.values()).forEach((session) => {
sessionViews(session).forEach((view) => {