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!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
modifications to rich-input link component
Amruth Pillaidf99470df8f8
diff --git a/libs/ui/src/components/rich-input.tsx b/libs/ui/src/components/rich-input.tsxindex 22824f101..2b06be054 100644--- a/libs/ui/src/components/rich-input.tsx+++ b/libs/ui/src/components/rich-input.tsx@@ -113,29 +113,25 @@ const InsertImageForm = ({ onInsert }: InsertImageProps) => {);};-const setLinkGlobal = (editor: Editor) => {- const previousUrl = editor.getAttributes("link").href;- const url = window.prompt("URL", previousUrl);-- // cancelled- if (url === null) {- return;- }+const Toolbar = ({ editor }: { editor: Editor }) => {+ const setLink = useCallback(() => {+ const previousUrl = editor.getAttributes("link").href;+ const url = window.prompt("URL", previousUrl);- // empty- if (url === "") {- editor.chain().focus().extendMarkRange("link").unsetLink().run();+ // cancelled+ if (url === null) {+ return;+ }- return;- }+ // empty+ if (url === "") {+ editor.chain().focus().extendMarkRange("link").unsetLink().run();- // update link- editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();-};+ return;+ }-const Toolbar = ({ editor }: { editor: Editor }) => {- const setLink = useCallback(() => {- setLinkGlobal(editor);+ // update link+ editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();}, [editor]);return (@@ -446,14 +442,9 @@ export const RichInput = forwardRef<Editor, RichInputProps>(Highlight,Link.extend({inclusive: false,- addKeyboardShortcuts() {- return {- "Mod-k": () => {- setLinkGlobal(this.editor as Editor);- return true;- },- };- },+ addKeyboardShortcuts: () => ({+ "Mod-k": () => setLink(),+ }),}).configure({ openOnClick: false }),TextAlign.configure({ types: ["heading", "paragraph"] }),],@@ -470,6 +461,24 @@ export const RichInput = forwardRef<Editor, RichInputProps>(onUpdate: ({ editor }) => onChange?.(editor.getHTML()),});+ const setLink = useCallback(() => {+ if (!editor) return false;++ const previousUrl = editor.getAttributes("link").href;+ const url = window.prompt("URL", previousUrl);++ // cancelled+ if (url === null) return false;++ // empty+ if (url === "") {+ return editor.chain().focus().extendMarkRange("link").unsetLink().run();+ }++ // update link+ return editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();+ }, [editor]);+if (!editor) {return (<div className="space-y-2">