mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-12 15:46:29 +08:00
b35c9b2c14
* feat: update landing page * feat: update landing page * fix: react warning * feat(route): rename variables * feat(route): better refresh * fix: update logo and i18n * feat(code): remove unused comment * refactor(workspace): rename workspaceId * refactor(page): rename pageId * feat(edit): more robust editing experience * fix: landing page mobile * fix: landing page mobile Co-authored-by: tzhangchi <terry.zhangchi@outlook.com> Co-authored-by: DarkSky <25152247+darkskygit@users.noreply.github.com>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { atom, useAtom } from 'jotai';
|
|
import { useLocation, useParams } from 'react-router-dom';
|
|
// import { Virgo } from '@toeverything/components/editor-core';
|
|
|
|
// type EditorsMap = Record<string, Virgo>;
|
|
type EditorsMap = Record<string, any>;
|
|
|
|
const _currentEditors = atom<EditorsMap>({} as EditorsMap);
|
|
|
|
/** hook for using editors outside page */
|
|
export const useCurrentEditors = () => {
|
|
const { workspaceId, pageId } = useParams();
|
|
const { pathname } = useLocation();
|
|
const [currentEditors, setCurrentEditors] = useAtom(_currentEditors);
|
|
|
|
/* not useful: 2022.8.25 */
|
|
// useEffect(() => {
|
|
// if (!workspaceId || !pageId) return;
|
|
// if (pathname.split('/').length >= 3) {
|
|
// setCurrentEditors({});
|
|
// }
|
|
// }, [pageId, pathname, setCurrentEditors, workspaceId]);
|
|
|
|
return {
|
|
currentEditors,
|
|
setCurrentEditors,
|
|
};
|
|
};
|
|
|
|
// when first time transfer doc to board, need init the editor shape size to page size.
|
|
const _pageClientWidth = atom<number>(1020);
|
|
export const usePageClientWidth = () => {
|
|
const [pageClientWidth, setPageClientWidth] = useAtom(_pageClientWidth);
|
|
return {
|
|
pageClientWidth,
|
|
setPageClientWidth,
|
|
};
|
|
};
|