mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +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:
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import { AiIcon } from '@blocksuite/icons';
|
||||
import { CopilotPanel } from '@blocksuite/presets';
|
||||
import { useBlocksuiteEditor } from '@toeverything/hooks/use-block-suite-editor';
|
||||
import { useActiveBlocksuiteEditor } from '@toeverything/hooks/use-block-suite-editor';
|
||||
import { useCallback, useRef } from 'react';
|
||||
|
||||
import type { EditorExtension } from '../types';
|
||||
@@ -10,7 +10,7 @@ import * as styles from './outline.css';
|
||||
// A wrapper for CopilotPanel
|
||||
const EditorCopilotPanel = () => {
|
||||
const copilotPanelRef = useRef<CopilotPanel | null>(null);
|
||||
const [editor] = useBlocksuiteEditor();
|
||||
const [editor] = useActiveBlocksuiteEditor();
|
||||
|
||||
const onRefChange = useCallback((container: HTMLDivElement | null) => {
|
||||
if (container) {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import { FrameIcon } from '@blocksuite/icons';
|
||||
import { FramePanel } from '@blocksuite/presets';
|
||||
import { useBlocksuiteEditor } from '@toeverything/hooks/use-block-suite-editor';
|
||||
import { useActiveBlocksuiteEditor } from '@toeverything/hooks/use-block-suite-editor';
|
||||
import { useCallback, useRef } from 'react';
|
||||
|
||||
import type { EditorExtension } from '../types';
|
||||
@@ -11,7 +11,7 @@ import * as styles from './frame.css';
|
||||
const EditorFramePanel = () => {
|
||||
const framePanelRef = useRef<FramePanel | null>(null);
|
||||
|
||||
const [editor] = useBlocksuiteEditor();
|
||||
const [editor] = useActiveBlocksuiteEditor();
|
||||
|
||||
const onRefChange = useCallback((container: HTMLDivElement | null) => {
|
||||
if (container) {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import { TocIcon } from '@blocksuite/icons';
|
||||
import { TOCPanel } from '@blocksuite/presets';
|
||||
import { useBlocksuiteEditor } from '@toeverything/hooks/use-block-suite-editor';
|
||||
import { useActiveBlocksuiteEditor } from '@toeverything/hooks/use-block-suite-editor';
|
||||
import { useCallback, useRef } from 'react';
|
||||
|
||||
import type { EditorExtension } from '../types';
|
||||
@@ -10,7 +10,7 @@ import * as styles from './outline.css';
|
||||
// A wrapper for TOCNotesPanel
|
||||
const EditorOutline = () => {
|
||||
const tocPanelRef = useRef<TOCPanel | null>(null);
|
||||
const [editor] = useBlocksuiteEditor();
|
||||
const [editor] = useActiveBlocksuiteEditor();
|
||||
|
||||
const onRefChange = useCallback((container: HTMLDivElement | null) => {
|
||||
if (container) {
|
||||
|
||||
Reference in New Issue
Block a user