feat: new preload pages (#3674)

This commit is contained in:
Alex Yang
2023-08-10 15:56:16 -04:00
committed by GitHub
parent f06efd4d02
commit 43b35a77bb
43 changed files with 14197 additions and 6833 deletions
+16 -5
View File
@@ -10,6 +10,11 @@
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./blocksuite": {
"types": "./dist/src/blocksuite/index.d.ts",
"import": "./dist/blocksuite.js",
"require": "./dist/blocksuite.cjs"
},
"./core/*": {
"types": "./dist/src/core/*.d.ts",
"import": "./dist/core/*.js",
@@ -45,15 +50,15 @@
},
"dependencies": {
"@affine/sdk": "workspace:*",
"@blocksuite/blocks": "0.0.0-20230810005427-25adb757-nightly",
"@blocksuite/global": "0.0.0-20230810005427-25adb757-nightly",
"@blocksuite/store": "0.0.0-20230810005427-25adb757-nightly",
"@blocksuite/blocks": "0.0.0-20230810154852-8a8eccea-nightly",
"@blocksuite/global": "0.0.0-20230810154852-8a8eccea-nightly",
"@blocksuite/store": "0.0.0-20230810154852-8a8eccea-nightly",
"jotai": "^2.2.2",
"zod": "^3.21.4"
},
"devDependencies": {
"@blocksuite/editor": "0.0.0-20230810005427-25adb757-nightly",
"@blocksuite/lit": "0.0.0-20230810005427-25adb757-nightly",
"@blocksuite/editor": "0.0.0-20230810154852-8a8eccea-nightly",
"@blocksuite/lit": "0.0.0-20230810154852-8a8eccea-nightly",
"async-call-rpc": "^6.3.1",
"electron": "link:../../apps/electron/node_modules/electron",
"react": "^18.2.0",
@@ -61,11 +66,17 @@
"vite-plugin-dts": "3.5.1"
},
"peerDependencies": {
"@affine/templates": "*",
"@blocksuite/editor": "*",
"@blocksuite/lit": "*",
"async-call-rpc": "*",
"electron": "*",
"react": "*"
},
"peerDependenciesMeta": {
"@affine/templates": {
"optional": true
},
"@blocksuite/editor": {
"optional": true
},
+169
View File
@@ -0,0 +1,169 @@
import type { PageMeta, Workspace } from '@blocksuite/store';
export async function buildShowcaseWorkspace(workspace: Workspace) {
const showcaseWorkspaceVersions = {
'affine:code': 1,
'affine:paragraph': 1,
'affine:page': 2,
'affine:list': 1,
'affine:note': 1,
'affine:divider': 1,
'affine:image': 1,
'affine:surface': 3,
'affine:bookmark': 1,
'affine:database': 2,
};
workspace.doc.getMap('meta').set('blockVersions', showcaseWorkspaceVersions);
const prototypes = {
tags: {
options: [
{
id: 'icg1n5UdkP',
value: 'Travle',
color: 'var(--affine-tag-gray)',
},
{
id: 'Oe5dSe1DDJ',
value: 'quick dummary',
color: 'var(--affine-tag-green)',
},
{
id: 'g1L5dXKctL',
value: 'OKR',
color: 'var(--affine-tag-purple)',
},
{
id: 'q3mceOl_zi',
value: 'streamline your workflow',
color: 'var(--affine-tag-teal)',
},
{
id: 'ze07JVwBu4',
value: 'plan',
color: 'var(--affine-tag-teal)',
},
{
id: '8qcYPCTK0h',
value: 'review',
color: 'var(--affine-tag-orange)',
},
{
id: 'wg-fBtd2eI',
value: 'Engage',
color: 'var(--affine-tag-pink)',
},
{
id: 'QYFD_HeQc-',
value: 'Create',
color: 'var(--affine-tag-blue)',
},
{
id: 'ZHBa2NtdSo',
value: 'Learn',
color: 'var(--affine-tag-yellow)',
},
],
},
};
workspace.meta.setProperties(prototypes);
const pageMetas = {
'F1SX6cgNxy-hello-world': {
createDate: 1691548220794,
tags: [],
jumpOnce: true,
updatedDate: 1691676775642,
favorite: false,
},
gc5FeppNDv: {
createDate: 1691548231530,
tags: ['ZHBa2NtdSo', 'QYFD_HeQc-', 'wg-fBtd2eI'],
updatedDate: 1691676331623,
favorite: true,
},
'3R9X-gMh3m': {
createDate: 1691551731225,
tags: [],
updatedDate: 1691654611175,
favorite: false,
},
z_v6LOqNpp: {
createDate: 1691552082822,
tags: [],
updatedDate: 1691654606912,
favorite: false,
},
'0N0WzwmtK_': {
createDate: 1691552090989,
tags: [],
updatedDate: 1691646748171,
favorite: false,
},
'6gexHy-jto': {
createDate: 1691564303138,
tags: [],
updatedDate: 1691646845195,
},
nQd2Bdvoqz: {
createDate: 1691574743531,
tags: ['icg1n5UdkP'],
updatedDate: 1691647117761,
},
bj_cuI1tN7: {
createDate: 1691574859042,
tags: [],
updatedDate: 1691648159371,
},
fFoDX2J1Z5: {
createDate: 1691575011078,
tags: ['8qcYPCTK0h'],
updatedDate: 1691645074511,
favorite: false,
},
PqZ7MLlL_9: {
createDate: 1691634722239,
tags: ['ze07JVwBu4'],
updatedDate: 1691647069662,
favorite: false,
},
A4wBRdQZN0: {
createDate: 1691635388447,
tags: ['Oe5dSe1DDJ'],
updatedDate: 1691645873930,
},
kBB4lzhm7C: {
createDate: 1691636192263,
tags: ['q3mceOl_zi', 'g1L5dXKctL'],
updatedDate: 1691645102104,
},
} satisfies Record<string, Partial<PageMeta>>;
const data = [
['F1SX6cgNxy-hello-world', import('@affine/templates/v1/preloading.json')],
['gc5FeppNDv', import('@affine/templates/v1/getting-started.json')],
['3R9X-gMh3m', import('@affine/templates/v1/template-galleries.json')],
['z_v6LOqNpp', import('@affine/templates/v1/personal-home.json')],
['0N0WzwmtK_', import('@affine/templates/v1/working-home.json')],
[
'6gexHy-jto',
import('@affine/templates/v1/personal-project-management.json'),
],
['nQd2Bdvoqz', import('@affine/templates/v1/travel-plan.json')],
[
'bj_cuI1tN7',
import('@affine/templates/v1/personal-knowledge-management.json'),
],
[
'fFoDX2J1Z5',
import('@affine/templates/v1/annual-performance-review.json'),
],
['PqZ7MLlL_9', import('@affine/templates/v1/brief-event-planning.json')],
['A4wBRdQZN0', import('@affine/templates/v1/meeting-summary.json')],
['kBB4lzhm7C', import('@affine/templates/v1/okr-template.json')],
] as const;
await Promise.all(
data.map(async ([id, promise]) => {
const { default: template } = await promise;
await workspace.importPageSnapshot(template, id);
workspace.setPageMeta(id, pageMetas[id]);
})
);
}
+2
View File
@@ -11,6 +11,7 @@ export default defineConfig({
minify: false,
lib: {
entry: {
blocksuite: resolve(root, 'src/blocksuite/index.ts'),
index: resolve(root, 'src/index.ts'),
atom: resolve(root, 'src/atom.ts'),
type: resolve(root, 'src/type.ts'),
@@ -35,6 +36,7 @@ export default defineConfig({
'react',
/^jotai/,
/^@blocksuite/,
/^@affine\/templates/,
],
},
},