Skip to content

Commit

Permalink
feat: add duplicateViewItem in useScene
Browse files Browse the repository at this point in the history
  • Loading branch information
nomorepanic committed Oct 3, 2024
1 parent 92b16b1 commit 3101e3c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/hooks/useScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ export const useScene = () => {
[getState, setState, currentViewId]
);

const duplicateViewItem = useCallback(
(newViewItem: ViewItem) => {
const newState = reducers.view({
action: 'CREATE_VIEWITEM',
payload: newViewItem,
ctx: { viewId: currentViewId, state: getState() }
});
setState(newState);
},
[getState, setState, currentViewId]
)

const updateViewItem = useCallback(
(id: string, updates: Partial<ViewItem>) => {
const newState = reducers.view({
Expand Down Expand Up @@ -287,6 +299,7 @@ export const useScene = () => {
updateViewItem,
deleteViewItem,
createConnector,
duplicateViewItem,
updateConnector,
deleteConnector,
createTextBox,
Expand Down

0 comments on commit 3101e3c

Please sign in to comment.