mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 17:22:18 +03:00
chore: sunset scene api
This commit is contained in:
parent
29d5a8c971
commit
3deabad74c
@ -27,7 +27,6 @@ export interface CreateView {
|
||||
* @deprecated Use recast table instead
|
||||
*/
|
||||
columnsFromId: string;
|
||||
scene: 'page' | 'kanban' | 'table' | 'whiteboard';
|
||||
}
|
||||
|
||||
export interface ChildrenView extends CreateView {
|
||||
|
@ -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,
|
||||
};
|
||||
};
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}>;
|
||||
|
Loading…
Reference in New Issue
Block a user