Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

Move core logic of setLink to outer scope

CorreyL37a869fa2426
diff --git a/libs/ui/src/components/rich-input.tsx b/libs/ui/src/components/rich-input.tsx
index d9c716844..badb74bf0 100644
--- a/libs/ui/src/components/rich-input.tsx
+++ b/libs/ui/src/components/rich-input.tsx
@@ -113,25 +113,29 @@ const InsertImageForm = ({ onInsert }: InsertImageProps) => {
);
};
-const Toolbar = ({ editor }: { editor: Editor }) => {
- const setLink = useCallback(() => {
- const previousUrl = editor.getAttributes("link").href;
- const url = window.prompt("URL", previousUrl);
+const setLinkGlobal = (editor: Editor) => {
+ const previousUrl = editor.getAttributes("link").href;
+ const url = window.prompt("URL", previousUrl);
- // cancelled
- if (url === null) {
- return;
- }
+ // cancelled
+ if (url === null) {
+ return;
+ }
- // empty
- if (url === "") {
- editor.chain().focus().extendMarkRange("link").unsetLink().run();
+ // empty
+ if (url === "") {
+ editor.chain().focus().extendMarkRange("link").unsetLink().run();
- return;
- }
+ return;
+ }
- // update link
- editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
+ // update link
+ editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
+};
+
+const Toolbar = ({ editor }: { editor: Editor }) => {
+ const setLink = useCallback(() => {
+ setLinkGlobal(editor);
}, [editor]);
return (