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C,EAAAA,EAedD,EAAY,CAAC,EAAEA,EAAU,UAAO,CAAC,CAAG,KAdrDzE,CAAAA,EAAAA,EAAAA,SAAAA,EAAU,KACR,GAAI2E,YAAYC,SAAS,EAAI,CAACF,EAC5B,OAAOG,EAAAA,CAAIA,CAGb,IAAMC,EAAWC,SAASC,KAAK,CAE/B,OADAD,SAASC,KAAK,CAAGN,EACV,KACLK,SAASC,KAAK,CAAGF,CACnB,CACF,EAAG,CAACJ,EAAS,CAKf,C","sources":["webpack://@affine/web/../core/src/components/blocksuite/block-suite-header/present/use-present.ts","webpack://@affine/web/../core/src/components/page-detail-editor.tsx","webpack://@affine/web/../core/src/components/page-detail-editor.css.ts","webpack://@affine/web/../core/src/hooks/use-block-suite-workspace-page.ts","webpack://@affine/web/../core/src/hooks/use-global-state.ts"],"sourcesContent":["import { useActiveBlocksuiteEditor } from '@affine/core/hooks/use-block-suite-editor';\nimport type { EdgelessRootService } from '@blocksuite/blocks';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport const usePresent = () => {\n const [isPresent, setIsPresent] = useState(false);\n const [editor] = useActiveBlocksuiteEditor();\n\n const handlePresent = useCallback(\n (enable = true) => {\n isPresent;\n const editorHost = editor?.host;\n if (!editorHost) return;\n\n // TODO(@catsjuice): use surfaceService subAtom\n const enterOrLeavePresentationMode = () => {\n const edgelessRootService = editorHost.spec.getService(\n 'affine:page'\n ) as EdgelessRootService;\n\n if (!edgelessRootService) {\n return;\n }\n\n const activeTool = edgelessRootService.tool.edgelessTool.type;\n const isFrameNavigator = activeTool === 'frameNavigator';\n if ((enable && isFrameNavigator) || (!enable && !isFrameNavigator))\n return;\n\n edgelessRootService.tool.setEdgelessTool({\n type: enable ? 'frameNavigator' : 'default',\n });\n };\n\n enterOrLeavePresentationMode();\n setIsPresent(enable);\n },\n [editor?.host, isPresent]\n );\n\n useEffect(() => {\n if (!isPresent) return;\n\n const editorHost = editor?.host;\n if (!editorHost) return;\n\n const edgelessPage = editorHost?.querySelector('affine-edgeless-root');\n if (!edgelessPage) return;\n\n return edgelessPage.slots.edgelessToolUpdated.on(() => {\n setIsPresent(edgelessPage.edgelessTool.type === 'frameNavigator');\n }).dispose;\n }, [editor?.host, isPresent]);\n\n return {\n isPresent,\n handlePresent,\n };\n};\n","import './page-detail-editor.css';\n\nimport { useDocCollectionPage } from '@affine/core/hooks/use-block-suite-workspace-page';\nimport { assertExists, DisposableGroup } from '@blocksuite/global/utils';\nimport type { AffineEditorContainer } from '@blocksuite/presets';\nimport type { Doc as BlockSuiteDoc, DocCollection } from '@blocksuite/store';\nimport {\n type DocMode,\n DocService,\n fontStyleOptions,\n useLiveData,\n useService,\n} from '@toeverything/infra';\nimport clsx from 'clsx';\nimport type { CSSProperties } from 'react';\nimport { memo, Suspense, useCallback, useMemo } from 'react';\nimport { useLocation } from 'react-router-dom';\n\nimport { useAppSettingHelper } from '../hooks/affine/use-app-setting-helper';\nimport { BlockSuiteEditor as Editor } from './blocksuite/block-suite-editor';\nimport * as styles from './page-detail-editor.css';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var currentEditor: AffineEditorContainer | undefined;\n}\n\nexport type OnLoadEditor = (\n page: BlockSuiteDoc,\n editor: AffineEditorContainer\n) => () => void;\n\nexport interface PageDetailEditorProps {\n isPublic?: boolean;\n publishMode?: DocMode;\n docCollection: DocCollection;\n pageId: string;\n onLoad?: OnLoadEditor;\n}\n\nfunction useRouterHash() {\n return useLocation().hash.substring(1);\n}\n\nconst PageDetailEditorMain = memo(function PageDetailEditorMain({\n page,\n onLoad,\n isPublic,\n publishMode,\n}: PageDetailEditorProps & { page: BlockSuiteDoc }) {\n const currentMode = useLiveData(useService(DocService).doc.mode$);\n const mode = useMemo(() => {\n const shareMode = publishMode || currentMode;\n\n if (isPublic) {\n return shareMode;\n }\n return currentMode;\n }, [isPublic, publishMode, currentMode]);\n\n const { appSettings } = useAppSettingHelper();\n\n const value = useMemo(() => {\n const fontStyle = fontStyleOptions.find(\n option => option.key === appSettings.fontStyle\n );\n assertExists(fontStyle);\n return fontStyle.value;\n }, [appSettings.fontStyle]);\n\n const blockId = useRouterHash();\n\n const onLoadEditor = useCallback(\n (editor: AffineEditorContainer) => {\n // debug current detail editor\n globalThis.currentEditor = editor;\n const disposableGroup = new DisposableGroup();\n localStorage.setItem('last_page_id', page.id);\n\n if (onLoad) {\n // Invoke onLoad once the editor has been mounted to the DOM.\n editor.updateComplete\n .then(() => editor.host?.updateComplete)\n .then(() => {\n disposableGroup.add(onLoad(page, editor));\n })\n .catch(console.error);\n }\n\n return () => {\n disposableGroup.dispose();\n };\n },\n [onLoad, page]\n );\n\n return (\n \n );\n});\n\nexport const PageDetailEditor = (props: PageDetailEditorProps) => {\n const { docCollection, pageId } = props;\n const page = useDocCollectionPage(docCollection, pageId);\n if (!page) {\n return null;\n }\n return (\n \n \n \n );\n};\n","import \"../core/src/components/page-detail-editor.css.ts.vanilla.css!=!../../../../../node_modules/@vanilla-extract/webpack-plugin/virtualFileLoader/dist/vanilla-extract-webpack-plugin-virtualFileLoader.cjs.js?{\\\"fileName\\\":\\\"../core/src/components/page-detail-editor.css.ts.vanilla.css\\\",\\\"source\\\":\\\"Ll8xZ2dxN3VxMCB7CiAgZmxleDogMTsKfQouXzFnZ3E3dXEwLmZ1bGwtc2NyZWVuIHsKICAtLWFmZmluZS1lZGl0b3Itd2lkdGg6IDEwMCU7CiAgLS1hZmZpbmUtZWRpdG9yLXNpZGUtcGFkZGluZzogNzJweDsKfQpAbWVkaWEgc2NyZWVuIGFuZCAobWF4LXdpZHRoOiA4MDBweCkgewogIC5fMWdncTd1cTAuaXMtcHVibGljIHsKICAgIC0tYWZmaW5lLWVkaXRvci13aWR0aDogMTAwJTsKICAgIC0tYWZmaW5lLWVkaXRvci1zaWRlLXBhZGRpbmc6IDI0cHg7CiAgfQp9\\\"}!../../../../../node_modules/@vanilla-extract/webpack-plugin/extracted.js\"\nexport var editor = '_1ggq7uq0';","import { DebugLogger } from '@affine/debug';\nimport { DisposableGroup } from '@blocksuite/global/utils';\nimport type { Doc, DocCollection } from '@blocksuite/store';\nimport { useEffect, useState } from 'react';\n\nconst logger = new DebugLogger('use-doc-collection-page');\n\nexport function useDocCollectionPage(\n docCollection: DocCollection,\n pageId: string | null\n): Doc | null {\n const [page, setPage] = useState(\n pageId ? docCollection.getDoc(pageId) : null\n );\n\n useEffect(() => {\n const group = new DisposableGroup();\n group.add(\n docCollection.slots.docAdded.on(id => {\n if (pageId === id) {\n setPage(docCollection.getDoc(id));\n }\n })\n );\n group.add(\n docCollection.slots.docRemoved.on(id => {\n if (pageId === id) {\n setPage(null);\n }\n })\n );\n return () => {\n group.dispose();\n };\n }, [docCollection, pageId]);\n\n useEffect(() => {\n if (page && !page.loaded) {\n try {\n page.load();\n } catch (err) {\n logger.error('Failed to load page', err);\n }\n }\n }, [page]);\n\n return page;\n}\n","import { noop } from 'lodash-es';\nimport { useEffect } from 'react';\n\nexport function useDocumentTitle(newTitle?: string | null) {\n useEffect(() => {\n if (environment.isDesktop || !newTitle) {\n return noop;\n }\n\n const oldTitle = document.title;\n document.title = newTitle;\n return () => {\n document.title = oldTitle;\n };\n }, [newTitle]);\n}\n\nexport function usePageDocumentTitle(pageTitle?: string) {\n useDocumentTitle(pageTitle ? `${pageTitle} ยท ARMS` : null);\n}\n"],"names":["usePresent","isPresent","setIsPresent","useState","editor","useActiveBlocksuiteEditor","handlePresent","useCallback","enable","editorHost","host","enterOrLeavePresentationMode","edgelessRootService","spec","getService","isFrameNavigator","activeTool","tool","edgelessTool","type","setEdgelessTool","useEffect","edgelessPage","querySelector","slots","edgelessToolUpdated","on","dispose","PageDetailEditorMain","memo","page","onLoad","isPublic","publishMode","currentMode","useLiveData","useService","DocService","doc","mode$","mode","useMemo","shareMode","appSettings","useAppSettingHelper","value","fontStyle","fontStyleOptions","find","option","key","assertExists","blockId","useLocation","hash","substring","onLoadEditor","globalThis","currentEditor","disposableGroup","DisposableGroup","localStorage","setItem","id","updateComplete","then","add","catch","console","error","Editor","className","clsx","fullWidthLayout","style","shared","defaultSelectedBlockId","PageDetailEditor","docCollection","pageId","props","useDocCollectionPage","Suspense","logger","DebugLogger","setPage","getDoc","group","docAdded","docRemoved","loaded","load","err","usePageDocumentTitle","pageTitle","newTitle","environment","isDesktop","noop","oldTitle","document","title"],"sourceRoot":""}