There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix: listen on title change
himself65746a6d9ab568
diff --git a/packages/app/src/pages/workspace/[workspaceId]/[pageId].tsx b/packages/app/src/pages/workspace/[workspaceId]/[pageId].tsxindex 05c2c17eba..77cbdb5a18 100644--- a/packages/app/src/pages/workspace/[workspaceId]/[pageId].tsx+++ b/packages/app/src/pages/workspace/[workspaceId]/[pageId].tsx@@ -16,6 +16,7 @@ import type { NextPageWithLayout } from '../..//_app';import WorkspaceLayout from '@/components/workspace-layout';import { useRouter } from 'next/router';import { usePageHelper } from '@/hooks/use-page-helper';+import { Disposable } from '@blocksuite/store/dist/utils/disposable';const StyledEditorContainer = styled('div')(() => {return {@@ -24,6 +25,8 @@ const StyledEditorContainer = styled('div')(() => {};});+const firstPageTitle = 'Welcome to AFFiNE Alpha "Abbey Wood"' as const;+const Page: NextPageWithLayout = () => {const editorContainer = useRef<HTMLDivElement>(null);const { createEditor, setEditor, currentPage, currentWorkspace } =@@ -36,6 +39,7 @@ const Page: NextPageWithLayout = () => {node.removeChild(node.firstChild);}};+ let disposable: Disposable | undefined;const editor = createEditor?.current?.(currentPage!);if (editor) {@@ -45,11 +49,7 @@ const Page: NextPageWithLayout = () => {const isFirstPage = currentWorkspace?.meta.pageMetas.length === 1;// Can not use useCurrentPageMeta to get new title, cause meta title will trigger rerender, but the second time can not remove titleconst { title: metaTitle } = currentPage!.meta;- const title = metaTitle- ? metaTitle- : isFirstPage- ? 'Welcome to AFFiNE Alpha "Abbey Wood"'- : '';+ const title = metaTitle ? metaTitle : isFirstPage ? firstPageTitle : '';currentWorkspace?.setPageMeta(currentPage!.id, { title });const pageId = currentPage!.addBlock({@@ -72,11 +72,17 @@ const Page: NextPageWithLayout = () => {});}currentPage!.resetHistory();+ disposable = editor.pageBlockModel?.propsUpdated.on(() => {+ document.title = isFirstPage+ ? firstPageTitle+ : currentPage?.meta.title || 'Untitled';+ });}}-- document.title = currentPage?.meta.title || 'Untitled';- return ret;+ return () => {+ ret();+ disposable?.dispose();+ };}, [currentWorkspace, currentPage, createEditor, setEditor]);return (