mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-16 05:47:09 +08:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
54
blocksuite/playground/apps/starter/data/embed.ts
Normal file
54
blocksuite/playground/apps/starter/data/embed.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { type DocCollection, Text } from '@blocksuite/store';
|
||||
|
||||
import type { InitFn } from './utils.js';
|
||||
|
||||
export const embed: InitFn = (collection: DocCollection, id: string) => {
|
||||
const doc = collection.getDoc(id) ?? collection.createDoc({ id });
|
||||
doc.clear();
|
||||
|
||||
doc.load(() => {
|
||||
// Add root block and surface block at root level
|
||||
const rootId = doc.addBlock('affine:page', {
|
||||
title: new Text(),
|
||||
});
|
||||
|
||||
const surfaceId = doc.addBlock('affine:surface', {}, rootId);
|
||||
|
||||
// Add note block inside root block
|
||||
const noteId = doc.addBlock('affine:note', {}, rootId);
|
||||
// Add paragraph block inside note block
|
||||
doc.addBlock('affine:paragraph', {}, noteId);
|
||||
|
||||
doc.addBlock(
|
||||
'affine:embed-github',
|
||||
{
|
||||
url: 'https://github.com/toeverything/AFFiNE/pull/5453',
|
||||
},
|
||||
noteId
|
||||
);
|
||||
doc.addBlock(
|
||||
'affine:embed-github',
|
||||
{
|
||||
url: 'https://www.github.com/toeverything/blocksuite/pull/5927',
|
||||
style: 'vertical',
|
||||
xywh: '[0, 400, 364, 390]',
|
||||
},
|
||||
surfaceId
|
||||
);
|
||||
doc.addBlock(
|
||||
'affine:embed-github',
|
||||
{
|
||||
url: 'https://github.com/Milkdown/milkdown/pull/1215',
|
||||
xywh: '[500, 400, 752, 116]',
|
||||
},
|
||||
surfaceId
|
||||
);
|
||||
doc.addBlock('affine:paragraph', {}, noteId);
|
||||
});
|
||||
|
||||
doc.resetHistory();
|
||||
};
|
||||
|
||||
embed.id = 'embed';
|
||||
embed.displayName = 'Example for embed blocks';
|
||||
embed.description = 'Example for embed blocks';
|
||||
Reference in New Issue
Block a user