a tool for shared writing and social publishing

auto-link things on paste in commentbox

+21
+21
app/lish/[did]/[publication]/[rkey]/Interactions/Comments/CommentBox.tsx
··· 81 81 e.clipboardData?.getData("text") || 82 82 e.clipboardData?.getData("text/html"); 83 83 let html = e.clipboardData?.getData("text/html"); 84 + if (text && betterIsUrl(text)) { 85 + let selection = view.state.selection as TextSelection; 86 + let tr = view.state.tr; 87 + let { from, to } = selection; 88 + if (selection.empty) { 89 + tr.insertText(text, selection.from); 90 + tr.addMark( 91 + from, 92 + from + text.length, 93 + multiBlockSchema.marks.link.create({ href: text }), 94 + ); 95 + } else { 96 + tr.addMark( 97 + from, 98 + to, 99 + multiBlockSchema.marks.link.create({ href: text }), 100 + ); 101 + } 102 + view.dispatch(tr); 103 + return true; 104 + } 84 105 if (!text && html) { 85 106 let xml = new DOMParser().parseFromString(html, "text/html"); 86 107 text = xml.textContent || "";