feat: restore Wolai workspace navigation and assets
This commit is contained in:
+65
@@ -74,6 +74,71 @@ export function download_mnote_selected_image() {
|
||||
}
|
||||
}
|
||||
|
||||
export function download_mnote_image_url(src, filenameHint) {
|
||||
try {
|
||||
if (!src) return false;
|
||||
const url = new URL(String(src), window.location.href);
|
||||
if (!(url.protocol === 'http:' || url.protocol === 'https:' || url.protocol === 'data:')) return false;
|
||||
const link = document.createElement('a');
|
||||
link.href = url.href;
|
||||
link.download = mnoteImageFilename({ getAttribute: (name) => name === 'title' || name === 'alt' ? String(filenameHint || '') : '' }, url.href);
|
||||
link.style.display = 'none';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.warn('mnote image preview download failed', error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function request_mnote_image_preview_fullscreen() {
|
||||
try {
|
||||
const target = document.querySelector('[data-testid="image-preview-stage"]')
|
||||
|| document.querySelector('[data-testid="image-preview-dialog"]');
|
||||
const request = target?.requestFullscreen || target?.webkitRequestFullscreen || target?.mozRequestFullScreen || target?.msRequestFullscreen;
|
||||
if (!target || typeof request !== 'function') return false;
|
||||
const result = request.call(target);
|
||||
if (result?.catch) result.catch(() => {});
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.warn('mnote image preview fullscreen failed', error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function open_mnote_page_block_href(href) {
|
||||
try {
|
||||
const target = new URL(String(href || ''), window.location.href);
|
||||
if (target.origin === window.location.origin && target.pathname.startsWith('/documents/')) {
|
||||
const encodedId = target.pathname.slice('/documents/'.length).split('/')[0] || '';
|
||||
const documentId = decodeURIComponent(encodedId);
|
||||
const runtime = window.__mnoteDocumentPaneRuntime;
|
||||
if (documentId && runtime && typeof runtime.openPrimaryDocument === 'function') {
|
||||
const result = runtime.openPrimaryDocument({
|
||||
documentId,
|
||||
workspaceId: target.searchParams.get('workspaceId') || '',
|
||||
sourceKind: target.searchParams.get('sourceKind') || '',
|
||||
rootUri: target.searchParams.get('rootUri') || '',
|
||||
url: target,
|
||||
pageBlockNavigation: true,
|
||||
});
|
||||
if (result && typeof result.catch === 'function') {
|
||||
result.catch((error) => {
|
||||
console.warn('mnote page block pane navigation failed', error);
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.warn('mnote page block navigation failed', error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function bump_mnote_e27_ai_bridge_request_count() {
|
||||
try {
|
||||
const key = '__MNOTE_E27_AI_BRIDGE_REQUEST_COUNT__';
|
||||
|
||||
Reference in New Issue
Block a user