diff --git a/libs/components/editor-blocks/src/blocks/group/GroupView.tsx b/libs/components/editor-blocks/src/blocks/group/GroupView.tsx index 7955d28ac3..f377aeb73b 100644 --- a/libs/components/editor-blocks/src/blocks/group/GroupView.tsx +++ b/libs/components/editor-blocks/src/blocks/group/GroupView.tsx @@ -17,7 +17,6 @@ const SceneMap: Record> = { page: ScenePage, table: SceneTable, kanban: SceneKanban, - whiteboard: ScenePage, } as const; const GroupBox = styled('div')(({ theme }) => { diff --git a/libs/components/editor-blocks/src/blocks/group/config.ts b/libs/components/editor-blocks/src/blocks/group/config.ts index 1a3abb29b4..a9d99276d0 100644 --- a/libs/components/editor-blocks/src/blocks/group/config.ts +++ b/libs/components/editor-blocks/src/blocks/group/config.ts @@ -1,3 +1,5 @@ +import { RecastScene } from '@toeverything/components/editor-core'; + export const PANEL_CONFIG = { FILTER: 'filter', SORTER: 'sorter', @@ -5,9 +7,11 @@ export const PANEL_CONFIG = { GROUP_BY: 'group_by', } as const; -export const SCENE_CONFIG = { +/** + * See {@link RecastScene} + */ +export const SCENE_CONFIG: Record, string> = { PAGE: 'page', KANBAN: 'kanban', TABLE: 'table', - REFLINK: 'reflink', } as const; diff --git a/libs/components/editor-blocks/src/blocks/image/ImageView.tsx b/libs/components/editor-blocks/src/blocks/image/ImageView.tsx index dbdc6f493b..36b446d790 100644 --- a/libs/components/editor-blocks/src/blocks/image/ImageView.tsx +++ b/libs/components/editor-blocks/src/blocks/image/ImageView.tsx @@ -1,18 +1,16 @@ -import { FC, useState, useEffect, useRef } from 'react'; -import { CreateView } from '@toeverything/framework/virgo'; -import { Upload } from '../../components/upload/upload'; -import { services } from '@toeverything/datasource/db-service'; -import { styled } from '@toeverything/components/ui'; -import DeleteSweepOutlinedIcon from '@mui/icons-material/DeleteSweepOutlined'; -import DownloadIcon from '@mui/icons-material/Download'; -import { Image as SourceView } from '../../components/ImageView'; import { + useCurrentView, useOnSelect, - useRecastBlockScene, WrapperWithPendantAndDragDrop, } from '@toeverything/components/editor-core'; -import './styles.css'; +import { styled } from '@toeverything/components/ui'; +import { services } from '@toeverything/datasource/db-service'; +import { CreateView } from '@toeverything/framework/virgo'; +import { FC, useEffect, useRef, useState } from 'react'; +import { Image as SourceView } from '../../components/ImageView'; +import { Upload } from '../../components/upload/upload'; import { SCENE_CONFIG } from '../group/config'; +import './styles.css'; const MESSAGES = { ADD_AN_IMAGE: 'Add an image', }; @@ -62,14 +60,14 @@ export const ImageView: FC = ({ block, editor }) => { const [imgWidth, setImgWidth] = useState(0); const [ratio, set_ratio] = useState(0); const resize_box = useRef(null); - const { scene } = useRecastBlockScene(); + const [currentView] = useCurrentView(); const [isSelect, setIsSelect] = useState(); useOnSelect(block.id, (isSelect: boolean) => { setIsSelect(isSelect); }); const img_load = (url: string) => { - let boxWidth = resize_box.current.offsetWidth; + const boxWidth = resize_box.current.offsetWidth; const imageStyle = block.getProperty('image_style'); if (imageStyle?.width) { @@ -171,7 +169,7 @@ export const ImageView: FC = ({ block, editor }) => { e.stopPropagation(); }} > - {scene === SCENE_CONFIG.PAGE ? ( + {currentView.type === SCENE_CONFIG.PAGE ? ( { - const { scene } = useRecastBlockScene(); - const isKanbanScene = scene === SCENE_CONFIG.KANBAN; + const [currentView] = useCurrentView(); + const isKanbanScene = currentView.type === SCENE_CONFIG.KANBAN; return (
0; - const [isSelect, setIsSelect] = useState(); - useOnSelect(block.id, (is_select: boolean) => { - setIsSelect(is_select); + const [isSelect, setIsSelect] = useState(false); + useOnSelect(block.id, (isSelect: boolean) => { + setIsSelect(isSelect); }); const handleCollapse = () => { block.setProperty('collapsed', { value: true }); diff --git a/libs/components/editor-core/src/recast-block/Scene.tsx b/libs/components/editor-core/src/recast-block/Scene.tsx index b10734732c..b8dc710cc6 100644 --- a/libs/components/editor-core/src/recast-block/Scene.tsx +++ b/libs/components/editor-core/src/recast-block/Scene.tsx @@ -7,6 +7,7 @@ import { RecastScene } from './types'; * * 获取/设置多维区块场景 * @public + * @deprecated Use the `useRecastView` or `useCurrentView` API */ export const useRecastBlockScene = () => { const groupBlock = useRecastBlock(); diff --git a/libs/components/editor-core/src/recast-block/types/view.ts b/libs/components/editor-core/src/recast-block/types/view.ts index acc9c72f55..3f03187bce 100644 --- a/libs/components/editor-core/src/recast-block/types/view.ts +++ b/libs/components/editor-core/src/recast-block/types/view.ts @@ -7,7 +7,7 @@ export enum RecastScene { Page = 'page', Kanban = 'kanban', Table = 'table', - Whiteboard = 'whiteboard', + // Whiteboard = 'whiteboard', } export type RecastViewId = string & {