init: the first public commit for AFFiNE

This commit is contained in:
DarkSky
2022-07-22 15:49:21 +08:00
commit e3e3741393
1451 changed files with 108124 additions and 0 deletions
@@ -0,0 +1,21 @@
import { FC, useEffect, useMemo, useState } from 'react';
import { InlineRefLink } from '@toeverything/components/common';
import { CreateView } from '@toeverything/framework/virgo';
type RefLinkView = CreateView;
export const RefLinkView: FC<RefLinkView> = ({ block, editor }) => {
const page_id = useMemo(() => block.getProperty('reference'), [block]);
const [block_content, set_block] =
useState<Awaited<ReturnType<typeof editor.search>>[number]>();
useEffect(() => {
editor
.search({ tag: `id:${page_id}` })
.then(block => set_block(block[0]));
}, [editor, page_id]);
return <InlineRefLink block={block_content} pageId={page_id} />;
};