a tool for shared writing and social publishing

append href to urls for inline links in toolbar

+7 -10
+7 -10
components/Toolbar/InlineLinkToolbar.tsx
··· 107 107 let editor = focusedEditor?.editor; 108 108 if (!editor || start === null || !end || !focusedBlock) return; 109 109 let tr = editor.tr; 110 - tr.addMark( 111 - start, 112 - end, 113 - schema.marks.link.create({ href: linkValue }), 114 - ); 110 + let href = linkValue; 111 + if (!href.startsWith("http")) href = `https://${href}`; 112 + tr.addMark(start, end, schema.marks.link.create({ href })); 115 113 tr.setSelection(TextSelection.create(tr.doc, tr.selection.to)); 116 114 setEditorState(focusedBlock?.entityID, { 117 115 editor: editor.apply(tr), ··· 143 141 let editor = focusedEditor?.editor; 144 142 if (!editor || !start || !end || !focusedBlock) return; 145 143 let tr = editor.tr; 146 - tr.addMark( 147 - start, 148 - end, 149 - schema.marks.link.create({ href: linkValue }), 150 - ); 144 + 145 + let href = linkValue; 146 + if (!href.startsWith("http")) href = `https://${href}`; 147 + tr.addMark(start, end, schema.marks.link.create({ href })); 151 148 setEditorState(focusedBlock?.entityID, { 152 149 editor: editor.apply(tr), 153 150 });