a tool for shared writing and social publishing
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

use correct inline link in button and enter

+20 -28
+20 -28
components/Toolbar/InlineLinkToolbar.tsx
··· 90 90 } 91 91 } 92 92 let [linkValue, setLinkValue] = useState(content); 93 + let setLink = () => { 94 + let href = 95 + !linkValue.startsWith("http") && 96 + !linkValue.startsWith("mailto") && 97 + !linkValue.startsWith("tel:") 98 + ? `https://${linkValue}` 99 + : linkValue; 100 + 101 + let editor = focusedEditor?.editor; 102 + if (!editor || start === null || !end || !focusedBlock) return; 103 + let tr = editor.tr; 104 + tr.addMark(start, end, schema.marks.link.create({ href })); 105 + tr.setSelection(TextSelection.create(tr.doc, tr.selection.to)); 106 + setEditorState(focusedBlock?.entityID, { 107 + editor: editor.apply(tr), 108 + }); 109 + props.onClose(); 110 + }; 93 111 94 112 return ( 95 113 <div className="w-full flex items-center gap-[6px] grow"> ··· 104 122 onKeyDown={(e) => { 105 123 if (e.key === "Enter") { 106 124 e.preventDefault(); 107 - let editor = focusedEditor?.editor; 108 - if (!editor || start === null || !end || !focusedBlock) return; 109 - let tr = editor.tr; 110 - let href = linkValue; 111 - if ( 112 - !href.startsWith("http") && 113 - !href.startsWith("mailto") && 114 - !href.startsWith("tel:") 115 - ) 116 - href = `https://${href}`; 117 - tr.addMark(start, end, schema.marks.link.create({ href })); 118 - tr.setSelection(TextSelection.create(tr.doc, tr.selection.to)); 119 - setEditorState(focusedBlock?.entityID, { 120 - editor: editor.apply(tr), 121 - }); 122 - props.onClose(); 125 + setLink(); 123 126 } 124 127 if (e.key === "Escape") { 125 128 props.onClose(); ··· 143 146 className="hover:text-accent-contrast -mr-6 disabled:text-border" 144 147 onMouseDown={(e) => { 145 148 e.preventDefault(); 146 - let editor = focusedEditor?.editor; 147 - if (!editor || !start || !end || !focusedBlock) return; 148 - let tr = editor.tr; 149 - 150 - let href = linkValue; 151 - if (!href.startsWith("http") && !href.startsWith("mailto")) 152 - href = `https://${href}`; 153 - tr.addMark(start, end, schema.marks.link.create({ href })); 154 - setEditorState(focusedBlock?.entityID, { 155 - editor: editor.apply(tr), 156 - }); 157 - props.onClose(); 149 + setLink(); 158 150 }} 159 151 > 160 152 <CheckTiny />