mirror of
https://gitee.com/ByteDance/flowgram.ai.git
synced 2025-07-07 17:43:29 +08:00
feat(client): autoLayout add disableFitView option (#459)
This commit is contained in:
parent
4a857ba9a3
commit
1792e5f190
@ -20,7 +20,11 @@ import { TransformData } from '@flowgram.ai/editor';
|
||||
|
||||
type AutoLayoutResetFn = () => void;
|
||||
|
||||
type AutoLayoutFn = (options?: LayoutOptions) => Promise<AutoLayoutResetFn>;
|
||||
export type AutoLayoutOptions = LayoutOptions & {
|
||||
disableFitView?: boolean;
|
||||
};
|
||||
|
||||
type AutoLayoutFn = (options?: AutoLayoutOptions) => Promise<AutoLayoutResetFn>;
|
||||
|
||||
type UseAutoLayout = () => AutoLayoutFn;
|
||||
|
||||
@ -124,10 +128,15 @@ export const useAutoLayout: UseAutoLayout = () => {
|
||||
[document, playground]
|
||||
);
|
||||
const autoLayout: AutoLayoutFn = useCallback(
|
||||
async (options?: LayoutOptions): Promise<AutoLayoutResetFn> => {
|
||||
handleFitView();
|
||||
async (options: AutoLayoutOptions = {}): Promise<AutoLayoutResetFn> => {
|
||||
const { disableFitView } = options;
|
||||
if (disableFitView !== true) {
|
||||
handleFitView();
|
||||
}
|
||||
const resetFn: AutoLayoutResetFn = await applyLayout(options);
|
||||
handleFitView();
|
||||
if (disableFitView !== true) {
|
||||
handleFitView();
|
||||
}
|
||||
return resetFn;
|
||||
},
|
||||
[applyLayout]
|
||||
|
||||
@ -16,10 +16,9 @@ import {
|
||||
usePlayground,
|
||||
useService,
|
||||
} from '@flowgram.ai/free-layout-core';
|
||||
import { LayoutOptions } from '@flowgram.ai/free-auto-layout-plugin';
|
||||
import { EditorState } from '@flowgram.ai/editor';
|
||||
|
||||
import { useAutoLayout } from './use-auto-layout';
|
||||
import { useAutoLayout, type AutoLayoutOptions } from './use-auto-layout';
|
||||
|
||||
interface SetCursorStateCallbackEvent {
|
||||
isPressingSpaceBar: boolean;
|
||||
@ -31,7 +30,7 @@ export interface PlaygroundTools {
|
||||
zoomin: (easing?: boolean) => void;
|
||||
zoomout: (easing?: boolean) => void;
|
||||
fitView: (easing?: boolean) => void;
|
||||
autoLayout: (options?: LayoutOptions) => Promise<() => void>;
|
||||
autoLayout: (options?: AutoLayoutOptions) => Promise<() => void>;
|
||||
/**
|
||||
* 切换线条
|
||||
*/
|
||||
|
||||
@ -71,7 +71,7 @@ export interface LayoutParams {
|
||||
|
||||
export interface LayoutOptions {
|
||||
getFollowNode?: GetFollowNode;
|
||||
enableAnimation: boolean;
|
||||
enableAnimation?: boolean;
|
||||
}
|
||||
|
||||
export interface LayoutConfig {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user