https://bugzilla.wikimedia.org/show_bug.cgi?id=61354
Bug ID: 61354 Summary: Inputs should recognize copy-pasted links to Wikidata items Product: MediaWiki extensions Version: unspecified Hardware: All OS: All Status: NEW Severity: normal Priority: Unprioritized Component: WikidataRepo Assignee: wikidata-b...@lists.wikimedia.org Reporter: yyairr...@gmail.com CC: wikidata-b...@lists.wikimedia.org Web browser: --- Mobile Platform: --- If one copies a link to a Wikidata item and pastes it into a text field requiring a Wikidata item, the JS should accept it as directly being the item itself, not just the raw text to be used to help find the item. Acting on every copy-paste might slow performance a slight amount, but I think it would be worth it. The code getting the contents of the paste could look something very roughly like this: $input.on("paste", function (e) { try { var oEvt = e.originalEvent, href; if (oEvt.clipboardData && oEvt.clipboardData.getData) { var clp = oEvt.clipboardData.getData('text/html'); href = $("<p>").html(clp).find("a").attr("href"); } else if (document.queryCommandEnabled("paste")) { var $pasteBox = $('<p>').attr("contenteditable", "true").insertBefore( $input ).focus(); document.execCommand("paste"); href = $pasteBox.find("a").attr("href"); $pasteBox.remove(); } var itemId = href && href.match(/Q\d+$/); // preferably with a more thorough check than this... if (itemId) { // do some stuff with itemId return false; } } catch (err) {}; }); -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ Wikibugs-l mailing list Wikibugs-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikibugs-l