mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-28 07:32:33 +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 { createIndexedDBDownloadProvider } from '@affine/workspace/providers';
|
||||||
import { nanoid } from '@blocksuite/store';
|
import { nanoid } from '@blocksuite/store';
|
||||||
import { useStaticBlockSuiteWorkspace } from '@toeverything/infra/__internal__/react';
|
import { useStaticBlockSuiteWorkspace } from '@toeverything/infra/__internal__/react';
|
||||||
|
import { rootStore } from '@toeverything/infra/atom';
|
||||||
import { buildShowcaseWorkspace } from '@toeverything/infra/blocksuite';
|
import { buildShowcaseWorkspace } from '@toeverything/infra/blocksuite';
|
||||||
|
|
||||||
|
import { setPageModeAtom } from '../../atoms';
|
||||||
import {
|
import {
|
||||||
BlockSuitePageList,
|
BlockSuitePageList,
|
||||||
NewWorkspaceSettingDetail,
|
NewWorkspaceSettingDetail,
|
||||||
@ -43,7 +45,12 @@ export const LocalAdapter: WorkspaceAdapter<WorkspaceFlavour.LOCAL> = {
|
|||||||
);
|
);
|
||||||
blockSuiteWorkspace.meta.setName(DEFAULT_WORKSPACE_NAME);
|
blockSuiteWorkspace.meta.setName(DEFAULT_WORKSPACE_NAME);
|
||||||
if (runtimeConfig.enablePreloading) {
|
if (runtimeConfig.enablePreloading) {
|
||||||
buildShowcaseWorkspace(blockSuiteWorkspace).catch(err => {
|
buildShowcaseWorkspace(blockSuiteWorkspace, {
|
||||||
|
store: rootStore,
|
||||||
|
atoms: {
|
||||||
|
pageMode: setPageModeAtom,
|
||||||
|
},
|
||||||
|
}).catch(err => {
|
||||||
logger.error('init page with preloading failed', err);
|
logger.error('init page with preloading failed', err);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -5,12 +5,14 @@ import { saveWorkspaceToLocalStorage } from '@affine/workspace/local/crud';
|
|||||||
import { getOrCreateWorkspace } from '@affine/workspace/manager';
|
import { getOrCreateWorkspace } from '@affine/workspace/manager';
|
||||||
import { nanoid } from '@blocksuite/store';
|
import { nanoid } from '@blocksuite/store';
|
||||||
import { getWorkspace } from '@toeverything/infra/__internal__/workspace';
|
import { getWorkspace } from '@toeverything/infra/__internal__/workspace';
|
||||||
|
import { rootStore } from '@toeverything/infra/atom';
|
||||||
import { buildShowcaseWorkspace } from '@toeverything/infra/blocksuite';
|
import { buildShowcaseWorkspace } from '@toeverything/infra/blocksuite';
|
||||||
import { useAtomValue, useSetAtom } from 'jotai';
|
import { useAtomValue, useSetAtom } from 'jotai';
|
||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
|
|
||||||
import { LocalAdapter } from '../adapters/local';
|
import { LocalAdapter } from '../adapters/local';
|
||||||
import { WorkspaceAdapters } from '../adapters/workspace';
|
import { WorkspaceAdapters } from '../adapters/workspace';
|
||||||
|
import { setPageModeAtom } from '../atoms';
|
||||||
|
|
||||||
const logger = new DebugLogger('use-workspaces');
|
const logger = new DebugLogger('use-workspaces');
|
||||||
|
|
||||||
@ -52,7 +54,12 @@ export function useAppHelper() {
|
|||||||
id,
|
id,
|
||||||
WorkspaceFlavour.LOCAL
|
WorkspaceFlavour.LOCAL
|
||||||
);
|
);
|
||||||
await buildShowcaseWorkspace(blockSuiteWorkspace);
|
await buildShowcaseWorkspace(blockSuiteWorkspace, {
|
||||||
|
store: rootStore,
|
||||||
|
atoms: {
|
||||||
|
pageMode: setPageModeAtom,
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
set(workspaces => [
|
set(workspaces => [
|
||||||
...workspaces,
|
...workspaces,
|
||||||
|
@ -1,6 +1,19 @@
|
|||||||
import type { PageMeta, Workspace } from '@blocksuite/store';
|
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 = {
|
const showcaseWorkspaceVersions = {
|
||||||
'affine:code': 1,
|
'affine:code': 1,
|
||||||
'affine:paragraph': 1,
|
'affine:paragraph': 1,
|
||||||
@ -66,6 +79,11 @@ export async function buildShowcaseWorkspace(workspace: Workspace) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
workspace.meta.setProperties(prototypes);
|
workspace.meta.setProperties(prototypes);
|
||||||
|
const { store, atoms } = options;
|
||||||
|
['F1SX6cgNxy', 'nQd2Bdvoqz'].forEach(pageId => {
|
||||||
|
store.set(atoms.pageMode, pageId, 'edgeless');
|
||||||
|
});
|
||||||
|
|
||||||
const pageMetas = {
|
const pageMetas = {
|
||||||
'gc5FeppNDv-hello-world': {
|
'gc5FeppNDv-hello-world': {
|
||||||
createDate: 1691548231530,
|
createDate: 1691548231530,
|
||||||
|
Loading…
Reference in New Issue
Block a user