mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-28 04:53:53 +03:00
fix(core): default page mode (#3745)
This commit is contained in:
parent
25052220a4
commit
42dfd0a4bb
@ -20,8 +20,10 @@ import { getOrCreateWorkspace } from '@affine/workspace/manager';
|
||||
import { createIndexedDBDownloadProvider } from '@affine/workspace/providers';
|
||||
import { nanoid } from '@blocksuite/store';
|
||||
import { useStaticBlockSuiteWorkspace } from '@toeverything/infra/__internal__/react';
|
||||
import { rootStore } from '@toeverything/infra/atom';
|
||||
import { buildShowcaseWorkspace } from '@toeverything/infra/blocksuite';
|
||||
|
||||
import { setPageModeAtom } from '../../atoms';
|
||||
import {
|
||||
BlockSuitePageList,
|
||||
NewWorkspaceSettingDetail,
|
||||
@ -43,7 +45,12 @@ export const LocalAdapter: WorkspaceAdapter<WorkspaceFlavour.LOCAL> = {
|
||||
);
|
||||
blockSuiteWorkspace.meta.setName(DEFAULT_WORKSPACE_NAME);
|
||||
if (runtimeConfig.enablePreloading) {
|
||||
buildShowcaseWorkspace(blockSuiteWorkspace).catch(err => {
|
||||
buildShowcaseWorkspace(blockSuiteWorkspace, {
|
||||
store: rootStore,
|
||||
atoms: {
|
||||
pageMode: setPageModeAtom,
|
||||
},
|
||||
}).catch(err => {
|
||||
logger.error('init page with preloading failed', err);
|
||||
});
|
||||
} else {
|
||||
|
@ -5,12 +5,14 @@ import { saveWorkspaceToLocalStorage } from '@affine/workspace/local/crud';
|
||||
import { getOrCreateWorkspace } from '@affine/workspace/manager';
|
||||
import { nanoid } from '@blocksuite/store';
|
||||
import { getWorkspace } from '@toeverything/infra/__internal__/workspace';
|
||||
import { rootStore } from '@toeverything/infra/atom';
|
||||
import { buildShowcaseWorkspace } from '@toeverything/infra/blocksuite';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { LocalAdapter } from '../adapters/local';
|
||||
import { WorkspaceAdapters } from '../adapters/workspace';
|
||||
import { setPageModeAtom } from '../atoms';
|
||||
|
||||
const logger = new DebugLogger('use-workspaces');
|
||||
|
||||
@ -52,7 +54,12 @@ export function useAppHelper() {
|
||||
id,
|
||||
WorkspaceFlavour.LOCAL
|
||||
);
|
||||
await buildShowcaseWorkspace(blockSuiteWorkspace);
|
||||
await buildShowcaseWorkspace(blockSuiteWorkspace, {
|
||||
store: rootStore,
|
||||
atoms: {
|
||||
pageMode: setPageModeAtom,
|
||||
},
|
||||
});
|
||||
}
|
||||
set(workspaces => [
|
||||
...workspaces,
|
||||
|
@ -1,6 +1,19 @@
|
||||
import type { PageMeta, Workspace } from '@blocksuite/store';
|
||||
import type { createStore, WritableAtom } from 'jotai/vanilla';
|
||||
|
||||
export async function buildShowcaseWorkspace(workspace: Workspace) {
|
||||
export async function buildShowcaseWorkspace(
|
||||
workspace: Workspace,
|
||||
options: {
|
||||
atoms: {
|
||||
pageMode: WritableAtom<
|
||||
undefined,
|
||||
[pageId: string, mode: 'page' | 'edgeless'],
|
||||
void
|
||||
>;
|
||||
};
|
||||
store: ReturnType<typeof createStore>;
|
||||
}
|
||||
) {
|
||||
const showcaseWorkspaceVersions = {
|
||||
'affine:code': 1,
|
||||
'affine:paragraph': 1,
|
||||
@ -66,6 +79,11 @@ export async function buildShowcaseWorkspace(workspace: Workspace) {
|
||||
},
|
||||
};
|
||||
workspace.meta.setProperties(prototypes);
|
||||
const { store, atoms } = options;
|
||||
['F1SX6cgNxy', 'nQd2Bdvoqz'].forEach(pageId => {
|
||||
store.set(atoms.pageMode, pageId, 'edgeless');
|
||||
});
|
||||
|
||||
const pageMetas = {
|
||||
'gc5FeppNDv-hello-world': {
|
||||
createDate: 1691548231530,
|
||||
|
Loading…
Reference in New Issue
Block a user