mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-10 21:48:48 +08:00
refactor(component): adjust active editor atom (#5457)
before: set global `blocksuiteEditorAtom` state in `<BlocksuiteEditorImpl />` after: Rename `blocksuiteEditorAtom` to `activeBlocksuiteEditorAtom` And move the logic of setting this atom to `<PageDetailEditor />`. benefit: * make BlocksuiteEditor pure * keep @toeverything/component clear * Clarify the purpose of `activeBlocksuiteEditorAtom`
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
import type { AffineEditorContainer } from '@blocksuite/presets';
|
||||
import { atom, type SetStateAction, useAtom } from 'jotai';
|
||||
|
||||
const editorContainerAtom = atom<AffineEditorContainer | null>(null);
|
||||
const activeEditorContainerAtom = atom<AffineEditorContainer | null>(null);
|
||||
|
||||
export function useBlocksuiteEditor(): [
|
||||
export function useActiveBlocksuiteEditor(): [
|
||||
AffineEditorContainer | null,
|
||||
React.Dispatch<SetStateAction<AffineEditorContainer | null>>,
|
||||
] {
|
||||
const [editorContainer, setEditorContainer] = useAtom(editorContainerAtom);
|
||||
const [editorContainer, setEditorContainer] = useAtom(
|
||||
activeEditorContainerAtom
|
||||
);
|
||||
|
||||
return [editorContainer, setEditorContainer];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user