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) => {
+9 -10
View File
@@ -7486,17 +7486,16 @@ const SIDEBAR_TREE_JS: &str = r##"
openEditorAttachmentLink(editorAttachmentLink);
}
window.addEventListener('mousedown', interceptEditorAttachmentLink, true);
window.addEventListener('click', interceptEditorAttachmentLink, true);
document.addEventListener('click', function(e) {
var editorAttachmentLink = closestAction(e.target, '.editor-surface .ProseMirror a[data-mnote-attachment-link="true"], .editor-surface .ProseMirror a.mnote-uploaded-attachment-row');
function suppressEditorAttachmentLinkDefault(event) {
var editorAttachmentLink = closestAction(event.target, '.editor-surface .ProseMirror a[data-mnote-attachment-link="true"], .editor-surface .ProseMirror a.mnote-uploaded-attachment-row');
if (!(editorAttachmentLink instanceof HTMLAnchorElement)) return;
e.preventDefault();
e.stopPropagation();
if (typeof e.stopImmediatePropagation === 'function') e.stopImmediatePropagation();
openEditorAttachmentLink(editorAttachmentLink);
}, true);
event.preventDefault();
event.stopPropagation();
if (typeof event.stopImmediatePropagation === 'function') event.stopImmediatePropagation();
}
window.addEventListener('mousedown', suppressEditorAttachmentLinkDefault, true);
window.addEventListener('click', interceptEditorAttachmentLink, true);
document.addEventListener('mouseover', function(event) {
var link = closestAction(event.target, '.editor-surface .ProseMirror a[data-mnote-attachment-link="true"], .editor-surface .ProseMirror a.mnote-uploaded-attachment-row');