import { atom, useAtom } from 'jotai'; import { useLocation, useParams } from 'react-router-dom'; // import { Virgo } from '@toeverything/components/editor-core'; // type EditorsMap = Record; type EditorsMap = Record; const _currentEditors = atom({} 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(1020); export const usePageClientWidth = () => { const [pageClientWidth, setPageClientWidth] = useAtom(_pageClientWidth); return { pageClientWidth, setPageClientWidth, }; };