From 3deabad74cf689e2b4e61bd5c8188fc1471e468d Mon Sep 17 00:00:00 2001 From: lawvs <18554747+lawvs@users.noreply.github.com> Date: Wed, 27 Jul 2022 16:15:21 +0800 Subject: [PATCH] chore: sunset scene api --- .../editor-core/src/editor/views/base-view.ts | 1 - .../editor-core/src/recast-block/Scene.tsx | 46 ------------------- .../editor-core/src/recast-block/index.ts | 2 - .../src/recast-block/types/constant.ts | 4 -- .../src/recast-block/types/recast-property.ts | 22 +++++---- 5 files changed, 14 insertions(+), 61 deletions(-) delete mode 100644 libs/components/editor-core/src/recast-block/Scene.tsx diff --git a/libs/components/editor-core/src/editor/views/base-view.ts b/libs/components/editor-core/src/editor/views/base-view.ts index 85346660c8..4fe50d3b90 100644 --- a/libs/components/editor-core/src/editor/views/base-view.ts +++ b/libs/components/editor-core/src/editor/views/base-view.ts @@ -27,7 +27,6 @@ export interface CreateView { * @deprecated Use recast table instead */ columnsFromId: string; - scene: 'page' | 'kanban' | 'table' | 'whiteboard'; } export interface ChildrenView extends CreateView { diff --git a/libs/components/editor-core/src/recast-block/Scene.tsx b/libs/components/editor-core/src/recast-block/Scene.tsx deleted file mode 100644 index b8dc710cc6..0000000000 --- a/libs/components/editor-core/src/recast-block/Scene.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { useCallback } from 'react'; -import { useRecastBlock } from './Context'; -import { RecastScene } from './types'; - -/** - * Get the recast table state - * - * 获取/设置多维区块场景 - * @public - * @deprecated Use the `useRecastView` or `useCurrentView` API - */ -export const useRecastBlockScene = () => { - const groupBlock = useRecastBlock(); - const DEFAULT_SCENE = RecastScene.Page; - let maybeScene = groupBlock.getProperty('scene'); - // TODO remove this - // Backward compatible - if (maybeScene && typeof maybeScene !== 'string') { - groupBlock.setProperty('scene', DEFAULT_SCENE); - maybeScene = DEFAULT_SCENE; - } - // End of backward compatible - const scene = maybeScene ?? DEFAULT_SCENE; - - const setScene = useCallback( - (scene: RecastScene) => { - return groupBlock.setProperty('scene', scene); - }, - [groupBlock] - ); - - const setPage = useCallback(() => setScene(RecastScene.Page), [setScene]); - const setTable = useCallback(() => setScene(RecastScene.Table), [setScene]); - const setKanban = useCallback( - () => setScene(RecastScene.Kanban), - [setScene] - ); - - return { - scene, - setScene, - setPage, - setTable, - setKanban, - }; -}; diff --git a/libs/components/editor-core/src/recast-block/index.ts b/libs/components/editor-core/src/recast-block/index.ts index a472ea63e3..abaed4168b 100644 --- a/libs/components/editor-core/src/recast-block/index.ts +++ b/libs/components/editor-core/src/recast-block/index.ts @@ -4,7 +4,6 @@ import { useSelectProperty, genSelectOptionId, } from './property'; -import { useRecastBlockScene } from './Scene'; export * from './types'; export { RecastBlockProvider, @@ -14,7 +13,6 @@ export { export { getRecastItemValue, - useRecastBlockScene, useRecastBlockMeta, useSelectProperty, genSelectOptionId, diff --git a/libs/components/editor-core/src/recast-block/types/constant.ts b/libs/components/editor-core/src/recast-block/types/constant.ts index a18f21035d..5160a80cc1 100644 --- a/libs/components/editor-core/src/recast-block/types/constant.ts +++ b/libs/components/editor-core/src/recast-block/types/constant.ts @@ -2,9 +2,5 @@ export const META_PROPERTIES_KEY = 'metaProps' as const; export const TABLE_VALUES_KEY = 'recastValues' as const; -/** - * @deprecated Use {@link META_VIEWS_KEY} instead. - */ -export const KANBAN_PROPERTIES_KEY = 'kanbanProps' as const; export const META_VIEWS_KEY = 'recastViews' as const; export const META_CURRENT_VIEW_ID_KEY = 'recastCurrentViewId' as const; diff --git a/libs/components/editor-core/src/recast-block/types/recast-property.ts b/libs/components/editor-core/src/recast-block/types/recast-property.ts index 172c605b9e..c494371ef1 100644 --- a/libs/components/editor-core/src/recast-block/types/recast-property.ts +++ b/libs/components/editor-core/src/recast-block/types/recast-property.ts @@ -1,11 +1,10 @@ import { CSSProperties } from 'react'; import { - KANBAN_PROPERTIES_KEY, META_CURRENT_VIEW_ID_KEY, META_PROPERTIES_KEY, META_VIEWS_KEY, } from './constant'; -import { RecastScene, RecastView, RecastViewId } from './view'; +import { RecastView, RecastViewId } from './view'; // --------------------------------------------------- // Property @@ -108,16 +107,23 @@ export type RecastMetaProperty = | InformationProperty; /** - * @deprecated Use {@link RecastView} + * @deprecated Use {@link META_VIEWS_KEY} instead. */ -export type RecastKanbanProperty = { - groupBy: RecastPropertyId; -}; +const KANBAN_PROPERTIES_KEY = 'kanbanProps' as const; export type RecastDataProperties = Partial<{ - scene: RecastScene; + /** + * PLEASE DO NOT USE IT + * @deprecated Use {@link RecastView} instead + */ + scene?: undefined; + /** + * PLEASE DO NOT USE IT + * @deprecated Use {@link RecastView} instead + */ + [KANBAN_PROPERTIES_KEY]?: undefined; + [META_PROPERTIES_KEY]: RecastMetaProperty[]; [META_VIEWS_KEY]: RecastView[]; [META_CURRENT_VIEW_ID_KEY]: RecastViewId; - [KANBAN_PROPERTIES_KEY]: RecastKanbanProperty; }>;