Skip to content

Instantly share code, notes, and snippets.

View smhmd's full-sized avatar

simohamed smhmd

View GitHub Profile
@nashingofteeth
nashingofteeth / anchor.js
Last active March 24, 2021 16:01
intercept paste event and convert urls in clipboard into links (for contenteditable elements)
document.addEventListener('paste', function (event) {
var clip = event.clipboardData.getData('text/plain');
var urlRegex =/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
var urlq = clip.match(urlRegex);
if (urlq != null) {
event.preventDefault();
var anchored = clip.replace(urlRegex, function(url) {
return '<a href="' + url +
'" style="cursor:pointer" onclick="window.open(this.href);return false">' +
url + '</a>';
@caridy
caridy / export-syntax.js
Last active January 15, 2022 14:22
ES6 Module Syntax Table
// default exports
export default 42;
export default {};
export default [];
export default foo;
export default function () {}
export default class {}
export default function foo () {}
export default class foo {}