Last modified: 2014-11-19 10:25:58 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T63354, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 61354 - Inputs should recognize copy-pasted links to Wikidata items
Inputs should recognize copy-pasted links to Wikidata items
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
WikidataRepo (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Wikidata bugs
u=dev c=backend p=0
: need-volunteer
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-02-14 00:13 UTC by Yair Rand
Modified: 2014-11-19 10:25 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Yair Rand 2014-02-14 00:13:34 UTC
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) {};
});

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links