-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f227c7
commit 84da502
Showing
11 changed files
with
164 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 14 additions & 14 deletions
28
docs/assets/index-BGqMXhJy.js → docs/assets/index-Bc7OF9RB.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { createContext } from "react"; | ||
|
||
type SelectNodeContextValue = ( | ||
selectNode: () => void, | ||
deselectNode: () => void | ||
) => void; | ||
|
||
export const SelectNodeContext = createContext<SelectNodeContextValue>( | ||
null as unknown as SelectNodeContextValue | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useContext } from "react"; | ||
|
||
import { SelectNodeContext } from "../contexts/SelectNodeContext.js"; | ||
|
||
import { useEditorEffect } from "./useEditorEffect.js"; | ||
import { useEditorEventCallback } from "./useEditorEventCallback.js"; | ||
|
||
export function useSelectNode( | ||
selectNode: () => void, | ||
deselectNode?: () => void | ||
) { | ||
const register = useContext(SelectNodeContext); | ||
const selectNodeMemo = useEditorEventCallback(selectNode); | ||
const deselectNodeMemo = useEditorEventCallback( | ||
deselectNode ?? | ||
(() => { | ||
// empty | ||
}) | ||
); | ||
return useEditorEffect(() => { | ||
register(selectNodeMemo, deselectNodeMemo); | ||
}, [deselectNodeMemo, register, selectNodeMemo]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters