Move core logic of setLink to outer scope

Will allow code changes in a subsequent commit to access the function
and utilize the same core logic
This commit is contained in:
CorreyL
2024-01-21 10:37:15 -08:00
parent 8bca7f5390
commit 37a869fa24

View File

@ -113,8 +113,7 @@ const InsertImageForm = ({ onInsert }: InsertImageProps) => {
);
};
const Toolbar = ({ editor }: { editor: Editor }) => {
const setLink = useCallback(() => {
const setLinkGlobal = (editor: Editor) => {
const previousUrl = editor.getAttributes("link").href;
const url = window.prompt("URL", previousUrl);
@ -132,6 +131,11 @@ const Toolbar = ({ editor }: { editor: Editor }) => {
// update link
editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
};
const Toolbar = ({ editor }: { editor: Editor }) => {
const setLink = useCallback(() => {
setLinkGlobal(editor);
}, [editor]);
return (