mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-22 03:33:06 +08:00
feat(core): new onboarding template (#5951)
This commit is contained in:
@@ -34,11 +34,12 @@ export async function buildShowcaseWorkspace(
|
|||||||
) {
|
) {
|
||||||
const meta = await workspaceManager.createWorkspace(
|
const meta = await workspaceManager.createWorkspace(
|
||||||
flavour,
|
flavour,
|
||||||
async blockSuiteWorkspace => {
|
async (blockSuiteWorkspace, blobStorage) => {
|
||||||
blockSuiteWorkspace.meta.setName(workspaceName);
|
blockSuiteWorkspace.meta.setName(workspaceName);
|
||||||
const { onboarding } = await import('@affine/templates');
|
const { onboarding } = await import('@affine/templates');
|
||||||
|
|
||||||
const info = onboarding['info.json'] as WorkspaceInfoSnapshot;
|
const info = onboarding['info.json'] as WorkspaceInfoSnapshot;
|
||||||
|
const blob = onboarding['blob.json'] as { [key: string]: string };
|
||||||
|
|
||||||
const migrationMiddleware: JobMiddleware = ({ slots, workspace }) => {
|
const migrationMiddleware: JobMiddleware = ({ slots, workspace }) => {
|
||||||
slots.afterImport.on(payload => {
|
slots.afterImport.on(payload => {
|
||||||
@@ -80,6 +81,10 @@ export async function buildShowcaseWorkspace(
|
|||||||
blockSuiteWorkspace.doc
|
blockSuiteWorkspace.doc
|
||||||
.getMap('meta')
|
.getMap('meta')
|
||||||
.set('blockVersions', new YMap(Object.entries(newVersions)));
|
.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
|
// todo: find better way to do the following
|
||||||
// perhaps put them into middleware?
|
// 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(
|
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) {
|
if (edgelessPage1) {
|
||||||
edgelessPage1.setMode('edgeless');
|
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 =>
|
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) {
|
if (defaultPage) {
|
||||||
@@ -115,3 +120,11 @@ export async function buildShowcaseWorkspace(
|
|||||||
release();
|
release();
|
||||||
return meta;
|
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
File diff suppressed because one or more lines are too long
@@ -1,40 +1,21 @@
|
|||||||
{
|
{
|
||||||
"type": "info",
|
"type": "info",
|
||||||
"id": "XdwdkEYm8fFZcYAdDa0qT",
|
"id": "dc61f2e3-a973-432f-a463-164a15cfc778",
|
||||||
"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
|
|
||||||
},
|
|
||||||
"pageVersion": 2,
|
"pageVersion": 2,
|
||||||
"workspaceVersion": 2,
|
"workspaceVersion": 2,
|
||||||
"properties": {
|
"properties": {
|
||||||
"tags": {
|
"tags": {
|
||||||
"options": [
|
"options": []
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"pages": [
|
"pages": [
|
||||||
{
|
{
|
||||||
"id": "9iIScyvuIB_kUKbs1AYOQ",
|
"id": "W-d9_llZ6rE-qoTiHKTk4",
|
||||||
"title": "AFFiNE - not just a note-taking app",
|
"createDate": 1706862386590,
|
||||||
"createDate": 1691548220794,
|
|
||||||
"tags": [],
|
"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 */
|
/* eslint-disable simple-import-sort/imports */
|
||||||
// Auto generated, do not edit manually
|
// Auto generated, do not edit manually
|
||||||
import json_0 from './onboarding/info.json';
|
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 = {
|
export const onboarding = {
|
||||||
'info.json': json_0,
|
'info.json': json_0,
|
||||||
'9iIScyvuIB_kUKbs1AYOQ.snapshot.json': json_1
|
'blob.json': json_1,
|
||||||
|
'W-d9_llZ6rE-qoTiHKTk4.snapshot.json': json_2
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user