Skip to content

Commit de6990a

Browse files
author
昔梦
committed
feat:增加撤销与重做按钮隐藏
1 parent 6069f21 commit de6990a

3 files changed

Lines changed: 25 additions & 11 deletions

File tree

docs/xflow/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ group:
6868
| -------------- | ------------------------------------------ | --------- | ------ |
6969
| hideAddNode | 是否隐藏增加节点功能 | `boolean` | false |
7070
| hideAnnotate | 是否隐藏注释节点功能 | `boolean` | false |
71+
| hideUndoRedoBtns | 是否隐藏撤销和重做按钮 | `boolean` | false |
72+
7173

7274
## THandle
7375

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
1-
import React, { memo } from 'react';
1+
import React, { memo, useContext } from 'react';
22
// import UndoRedo from '../header/undo-redo'
3-
import ZoomInOut from './ZoomInOut';
4-
import UndoRedo from './UndoRedo';
53
import Control from './Control';
4+
import UndoRedo from './UndoRedo';
5+
import ZoomInOut from './ZoomInOut';
66

7-
import './index.less';
87
import { useTemporalStore } from '../hooks/useTemporalStore';
8+
import { ConfigContext } from '../models/context';
9+
import './index.less';
910

1011
export type OperatorProps = {
1112
addNode: any;
1213
xflowRef: any;
13-
}
14+
};
1415

1516
const Operator = ({ addNode, xflowRef }: OperatorProps) => {
1617
const { undo, redo, pastStates, futureStates } = useTemporalStore();
18+
const { globalConfig } = useContext(ConfigContext);
19+
const hideUndoRedoBtns = globalConfig?.controls?.hideUndoRedoBtns ?? false;
20+
1721
return (
18-
<div className='fai-reactflow-operator'>
19-
<div className='operator-section'>
22+
<div className="fai-reactflow-operator">
23+
<div className="operator-section">
2024
<ZoomInOut />
21-
<UndoRedo handleUndo={() => undo()} handleRedo={() => redo()} pastStates={pastStates} futureStates={futureStates} />
25+
{!Boolean(hideUndoRedoBtns) && (
26+
<UndoRedo
27+
handleUndo={() => undo()}
28+
handleRedo={() => redo()}
29+
pastStates={pastStates}
30+
futureStates={futureStates}
31+
/>
32+
)}
2233
<Control addNode={addNode} xflowRef={xflowRef} />
2334
</div>
2435
</div>
2536
);
26-
}
37+
};
2738

28-
export default memo(Operator)
39+
export default memo(Operator);

packages/x-flow/src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ export interface TEdge {
100100

101101
export interface TControl{
102102
hideAddNode?:boolean
103-
hideAnnotate?:boolean
103+
hideAnnotate?: boolean
104+
hideUndoRedoBtns?:boolean
104105
}
105106

106107
export interface THandle{

0 commit comments

Comments
 (0)