mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-12-05 11:15:01 +03:00
Apply the editor font settings to split panes and Center Peek. Save the font settings on Web Desktop and load the serif font assets. Give full screen presentations the desktop viewport. Restore the workbench when the presentation or its document changes. Show tag names in the workbench. Skip writes for an in-place folder drop.
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import { installPlaygroundPreviewBridge } from '../preview-workers.js';
|
|
import { desktopFontUrls, flushDesktopOnHide, startDesktop } from './start.js';
|
|
|
|
try {
|
|
const manifest = JSON.parse(
|
|
document.getElementById('affine-desktop-manifest')?.textContent || '{}'
|
|
);
|
|
const workerAssets = {};
|
|
for (const kind of ['math', 'pdf', 'mermaid', 'typst']) {
|
|
const worker = manifest?.workers?.[kind];
|
|
if (worker?.script) workerAssets[kind + 'Script'] = worker.script;
|
|
if (worker?.wasm) workerAssets[kind + 'Wasm'] = worker.wasm;
|
|
}
|
|
if (Object.keys(workerAssets).length > 0) {
|
|
window.__AFFINE_WORKER_ASSETS__ = {
|
|
...window.__AFFINE_WORKER_ASSETS__,
|
|
...workerAssets,
|
|
};
|
|
}
|
|
|
|
const fontAssets = desktopFontUrls(
|
|
manifest?.fonts,
|
|
window.__AFFINE_FONT_ASSETS__
|
|
);
|
|
|
|
const wasm = await import('/pkg/affine_desktop.js');
|
|
installPlaygroundPreviewBridge(wasm, location.origin + '/');
|
|
const store = await startDesktop(
|
|
wasm,
|
|
fontAssets,
|
|
location.search,
|
|
matchMedia('(prefers-color-scheme: dark)').matches,
|
|
window.__playgroundPreview
|
|
);
|
|
flushDesktopOnHide(wasm, store, window);
|
|
} catch (error) {
|
|
console.error(error);
|
|
const notice = document.createElement('p');
|
|
notice.setAttribute('role', 'alert');
|
|
notice.textContent = `AFFiNE Desktop could not start: ${error.message}`;
|
|
document.body.append(notice);
|
|
}
|