mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 10:21:35 +03:00
feat(core): new onboarding template (#5951)
This commit is contained in:
parent
931c29fd31
commit
fa534869e1
@ -34,11 +34,12 @@ export async function buildShowcaseWorkspace(
|
||||
) {
|
||||
const meta = await workspaceManager.createWorkspace(
|
||||
flavour,
|
||||
async blockSuiteWorkspace => {
|
||||
async (blockSuiteWorkspace, blobStorage) => {
|
||||
blockSuiteWorkspace.meta.setName(workspaceName);
|
||||
const { onboarding } = await import('@affine/templates');
|
||||
|
||||
const info = onboarding['info.json'] as WorkspaceInfoSnapshot;
|
||||
const blob = onboarding['blob.json'] as { [key: string]: string };
|
||||
|
||||
const migrationMiddleware: JobMiddleware = ({ slots, workspace }) => {
|
||||
slots.afterImport.on(payload => {
|
||||
@ -80,6 +81,10 @@ export async function buildShowcaseWorkspace(
|
||||
blockSuiteWorkspace.doc
|
||||
.getMap('meta')
|
||||
.set('blockVersions', new YMap(Object.entries(newVersions)));
|
||||
|
||||
for (const [key, base64] of Object.entries(blob)) {
|
||||
await blobStorage.set(key, new Blob([base64ToUint8Array(base64)]));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@ -92,18 +97,18 @@ export async function buildShowcaseWorkspace(
|
||||
// todo: find better way to do the following
|
||||
// perhaps put them into middleware?
|
||||
{
|
||||
// the "AFFiNE - not just a note-taking app" page should be set to edgeless mode
|
||||
// the "Write, Draw, Plan all at Once." page should be set to edgeless mode
|
||||
const edgelessPage1 = pageRecordList.records.value.find(
|
||||
p => p.title.value === 'AFFiNE - not just a note-taking app'
|
||||
p => p.title.value === 'Write, Draw, Plan all at Once.'
|
||||
);
|
||||
|
||||
if (edgelessPage1) {
|
||||
edgelessPage1.setMode('edgeless');
|
||||
}
|
||||
|
||||
// should jump to "AFFiNE - not just a note-taking app" by default
|
||||
// should jump to "Write, Draw, Plan all at Once." by default
|
||||
const defaultPage = pageRecordList.records.value.find(p =>
|
||||
p.title.value.startsWith('AFFiNE - not just a note-taking app')
|
||||
p.title.value.startsWith('Write, Draw, Plan all at Once.')
|
||||
);
|
||||
|
||||
if (defaultPage) {
|
||||
@ -115,3 +120,11 @@ export async function buildShowcaseWorkspace(
|
||||
release();
|
||||
return meta;
|
||||
}
|
||||
|
||||
function base64ToUint8Array(base64: string) {
|
||||
const binaryString = atob(base64);
|
||||
const binaryArray = binaryString.split('').map(function (char) {
|
||||
return char.charCodeAt(0);
|
||||
});
|
||||
return new Uint8Array(binaryArray);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
5
packages/frontend/templates/onboarding/blob.json
Normal file
5
packages/frontend/templates/onboarding/blob.json
Normal file
File diff suppressed because one or more lines are too long
@ -1,40 +1,21 @@
|
||||
{
|
||||
"type": "info",
|
||||
"id": "XdwdkEYm8fFZcYAdDa0qT",
|
||||
"blockVersions": {
|
||||
"affine:code": 1,
|
||||
"affine:paragraph": 1,
|
||||
"affine:page": 2,
|
||||
"affine:list": 1,
|
||||
"affine:note": 1,
|
||||
"affine:divider": 1,
|
||||
"affine:image": 1,
|
||||
"affine:surface": 5,
|
||||
"affine:bookmark": 1,
|
||||
"affine:frame": 1,
|
||||
"affine:database": 3,
|
||||
"affine:surface-ref": 1,
|
||||
"affine:data-view": 1,
|
||||
"affine:attachment": 1,
|
||||
"affine:embed-github": 1,
|
||||
"affine:embed-html": 1
|
||||
},
|
||||
"id": "dc61f2e3-a973-432f-a463-164a15cfc778",
|
||||
"pageVersion": 2,
|
||||
"workspaceVersion": 2,
|
||||
"properties": {
|
||||
"tags": {
|
||||
"options": [
|
||||
]
|
||||
"options": []
|
||||
}
|
||||
},
|
||||
"pages": [
|
||||
{
|
||||
"id": "9iIScyvuIB_kUKbs1AYOQ",
|
||||
"title": "AFFiNE - not just a note-taking app",
|
||||
"createDate": 1691548220794,
|
||||
"id": "W-d9_llZ6rE-qoTiHKTk4",
|
||||
"createDate": 1706862386590,
|
||||
"tags": [],
|
||||
"updatedDate": 1691676775642,
|
||||
"favorite": false
|
||||
"favorite": false,
|
||||
"title": "Write, Draw, Plan all at Once.",
|
||||
"updatedDate": 1709110332309
|
||||
}
|
||||
]
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
/* eslint-disable simple-import-sort/imports */
|
||||
// Auto generated, do not edit manually
|
||||
import json_0 from './onboarding/info.json';
|
||||
import json_1 from './onboarding/9iIScyvuIB_kUKbs1AYOQ.snapshot.json';
|
||||
import json_1 from './onboarding/blob.json';
|
||||
import json_2 from './onboarding/W-d9_llZ6rE-qoTiHKTk4.snapshot.json';
|
||||
|
||||
export const onboarding = {
|
||||
'info.json': json_0,
|
||||
'9iIScyvuIB_kUKbs1AYOQ.snapshot.json': json_1
|
||||
'blob.json': json_1,
|
||||
'W-d9_llZ6rE-qoTiHKTk4.snapshot.json': json_2
|
||||
}
|
Loading…
Reference in New Issue
Block a user