tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
27
pulls
pipelines
auto-link things on paste in commentbox
awarm.space
6 months ago
f77e5f04
02824d72
+21
1 changed file
expand all
collapse all
unified
split
app
lish
[did]
[publication]
[rkey]
Interactions
Comments
CommentBox.tsx
+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
84
+
if (text && betterIsUrl(text)) {
85
85
+
let selection = view.state.selection as TextSelection;
86
86
+
let tr = view.state.tr;
87
87
+
let { from, to } = selection;
88
88
+
if (selection.empty) {
89
89
+
tr.insertText(text, selection.from);
90
90
+
tr.addMark(
91
91
+
from,
92
92
+
from + text.length,
93
93
+
multiBlockSchema.marks.link.create({ href: text }),
94
94
+
);
95
95
+
} else {
96
96
+
tr.addMark(
97
97
+
from,
98
98
+
to,
99
99
+
multiBlockSchema.marks.link.create({ href: text }),
100
100
+
);
101
101
+
}
102
102
+
view.dispatch(tr);
103
103
+
return true;
104
104
+
}
84
105
if (!text && html) {
85
106
let xml = new DOMParser().parseFromString(html, "text/html");
86
107
text = xml.textContent || "";