Merge pull request #390 from toeverything/feat/route

Feat/route
This commit is contained in:
DarkSky
2022-09-09 02:03:53 +08:00
committed by GitHub
30 changed files with 124 additions and 138 deletions
@@ -164,9 +164,6 @@ export const CodeView = ({ block, editor }: CreateCodeView) => {
};
useEffect(() => {
handleLangChange(langType ? langType : DEFAULT_LANG);
// setTimeout(() => {
// focusCode();
// }, 100);
}, []);
const copyCode = () => {
@@ -16,7 +16,7 @@ import {
} from '../../components/text-manage';
export const PageView = ({ block, editor }: CreateView) => {
const { workspace_id } = useParams();
const { workspaceId } = useParams();
const textRef = useRef<ExtendedTextUtils>(null);
const [backLinks, setBackLinks] =
useState<Awaited<ReturnType<typeof editor.search>>>();
@@ -100,7 +100,7 @@ export const PageView = ({ block, editor }: CreateView) => {
className={style9(styles.content)}
suppressContentEditableWarning
> */}
<BackLink blocks={backLinks} workspaceId={workspace_id} />
<BackLink blocks={backLinks} workspaceId={workspaceId} />
{/*{block.childrenIds.map(childId => (*/}
{/* <RenderBlock key={childId} blockId={childId} />*/}
{/*))}*/}
@@ -6,16 +6,16 @@ import { CreateView } from '@toeverything/framework/virgo';
type RefLinkView = CreateView;
export const RefLinkView = ({ block, editor }: RefLinkView) => {
const page_id = useMemo(() => block.getProperty('reference'), [block]);
const pageId = useMemo(() => block.getProperty('reference'), [block]);
const [block_content, set_block] =
useState<Awaited<ReturnType<typeof editor.search>>[number]>();
useEffect(() => {
editor
.search({ tag: `id:${page_id}` })
.search({ tag: `id:${pageId}` })
.then(block => set_block(block[0]));
}, [editor, page_id]);
}, [editor, pageId]);
return <InlineRefLink block={block_content} pageId={page_id} />;
return <InlineRefLink block={block_content} pageId={pageId} />;
};
@@ -90,7 +90,9 @@ export const TextView = ({
await block.removeChildren();
await block.after(nextBlock);
editor.selectionManager.activeNodeByNodeId(nextBlock.id);
setTimeout(() => {
editor.selectionManager.activeNodeByNodeId(nextBlock.id, 'start');
});
return true;
};