Bug ID: 61354
           Summary: Inputs should recognize copy-pasted links to Wikidata
           Product: MediaWiki extensions
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: WikidataRepo
       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, 
        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();
            href = $pasteBox.find("a").attr("href");
        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

Reply via email to