a tool for shared writing and social publishing
0
fork

Configure Feed

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

add link on paste

+10 -2
+10 -2
components/Blocks/TextBlock/useHandlePaste.ts
··· 36 36 if (!editorState) return; 37 37 if (text && betterIsUrl(text)) { 38 38 let selection = view.state.selection as TextSelection; 39 - if (selection.empty) return; 40 39 let tr = view.state.tr; 41 40 let { from, to } = selection; 42 - tr.addMark(from, to, schema.marks.link.create({ href: text })); 41 + if (selection.empty) { 42 + tr.insertText(text, selection.from); 43 + tr.addMark( 44 + from, 45 + from + text.length, 46 + schema.marks.link.create({ href: text }), 47 + ); 48 + } else { 49 + tr.addMark(from, to, schema.marks.link.create({ href: text })); 50 + } 43 51 let oldState = view.state; 44 52 let newState = view.state.apply(tr); 45 53 undoManager.add({