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 AutoLayoutResetFn = () => void;
|
||||||
|
|
||||||
type AutoLayoutFn = (options?: LayoutOptions) => Promise<AutoLayoutResetFn>;
|
export type AutoLayoutOptions = LayoutOptions & {
|
||||||
|
disableFitView?: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
type AutoLayoutFn = (options?: AutoLayoutOptions) => Promise<AutoLayoutResetFn>;
|
||||||
|
|
||||||
type UseAutoLayout = () => AutoLayoutFn;
|
type UseAutoLayout = () => AutoLayoutFn;
|
||||||
|
|
||||||
@ -124,10 +128,15 @@ export const useAutoLayout: UseAutoLayout = () => {
|
|||||||
[document, playground]
|
[document, playground]
|
||||||
);
|
);
|
||||||
const autoLayout: AutoLayoutFn = useCallback(
|
const autoLayout: AutoLayoutFn = useCallback(
|
||||||
async (options?: LayoutOptions): Promise<AutoLayoutResetFn> => {
|
async (options: AutoLayoutOptions = {}): Promise<AutoLayoutResetFn> => {
|
||||||
handleFitView();
|
const { disableFitView } = options;
|
||||||
|
if (disableFitView !== true) {
|
||||||
|
handleFitView();
|
||||||
|
}
|
||||||
const resetFn: AutoLayoutResetFn = await applyLayout(options);
|
const resetFn: AutoLayoutResetFn = await applyLayout(options);
|
||||||
handleFitView();
|
if (disableFitView !== true) {
|
||||||
|
handleFitView();
|
||||||
|
}
|
||||||
return resetFn;
|
return resetFn;
|
||||||
},
|
},
|
||||||
[applyLayout]
|
[applyLayout]
|
||||||
|
|||||||
@ -16,10 +16,9 @@ import {
|
|||||||
usePlayground,
|
usePlayground,
|
||||||
useService,
|
useService,
|
||||||
} from '@flowgram.ai/free-layout-core';
|
} from '@flowgram.ai/free-layout-core';
|
||||||
import { LayoutOptions } from '@flowgram.ai/free-auto-layout-plugin';
|
|
||||||
import { EditorState } from '@flowgram.ai/editor';
|
import { EditorState } from '@flowgram.ai/editor';
|
||||||
|
|
||||||
import { useAutoLayout } from './use-auto-layout';
|
import { useAutoLayout, type AutoLayoutOptions } from './use-auto-layout';
|
||||||
|
|
||||||
interface SetCursorStateCallbackEvent {
|
interface SetCursorStateCallbackEvent {
|
||||||
isPressingSpaceBar: boolean;
|
isPressingSpaceBar: boolean;
|
||||||
@ -31,7 +30,7 @@ export interface PlaygroundTools {
|
|||||||
zoomin: (easing?: boolean) => void;
|
zoomin: (easing?: boolean) => void;
|
||||||
zoomout: (easing?: boolean) => void;
|
zoomout: (easing?: boolean) => void;
|
||||||
fitView: (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 {
|
export interface LayoutOptions {
|
||||||
getFollowNode?: GetFollowNode;
|
getFollowNode?: GetFollowNode;
|
||||||
enableAnimation: boolean;
|
enableAnimation?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LayoutConfig {
|
export interface LayoutConfig {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user