Skip to content

Commit 32040b8

Browse files
committed
Adds a way to correct paste behavior of an URL
1 parent 4e85a62 commit 32040b8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/plugins/autolink.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@
5353
editor: editor
5454
});
5555
}.bind(this));
56+
57+
editor.on('paste', function (event) {
58+
var data = event.data.dataValue;
59+
60+
var match = data.match(REGEX_URL);
61+
62+
if (match && match.length) {
63+
match = match[0];
64+
65+
var remainder = data.replace(match, '');
66+
67+
if (this._isValidURL(match)) {
68+
event.data.dataValue = '<a href=\"' + match + '\">' + match + '</a>' + remainder;
69+
}
70+
}
71+
}.bind(this));
5672
},
5773

5874
/**

0 commit comments

Comments
 (0)