Skip to content

Commit

Permalink
Include double square brackets when dragging titles
Browse files Browse the repository at this point in the history
Dragging a tiddler link into a tiddler editor, or outside the browser
into another app, will now add double square brackets around the title
if it includes spaces. Suggested by @tgirod.

I’m not 100% sure about this change. It breaks one habit that I had
developed: typing `[[sometext|]]` and then dragging a title in between
the vertical bar and the first closing square bracket. What do others
think?
  • Loading branch information
Jermolene committed Nov 3, 2014
1 parent 0550efa commit 335c470
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/modules/widgets/link.js
Expand Up @@ -154,15 +154,16 @@ LinkWidget.prototype.handleDragStartEvent = function(event) {
// Then the data
dataTransfer.clearData();
var jsonData = this.wiki.getTiddlerAsJson(this.to),
textData = this.wiki.getTiddlerText(this.to,"");
textData = this.wiki.getTiddlerText(this.to,""),
title = this.to.indexOf(" ") === -1 ? this.to : "[[" + this.to + "]]";
// IE doesn't like these content types
if(!$tw.browser.isIE) {
dataTransfer.setData("text/vnd.tiddler",jsonData);
dataTransfer.setData("text/plain",this.to);
dataTransfer.setData("text/plain",title);
dataTransfer.setData("text/x-moz-url","data:text/vnd.tiddler," + encodeURI(jsonData));
}
dataTransfer.setData("URL","data:text/vnd.tiddler," + encodeURI(jsonData));
dataTransfer.setData("Text",this.to);
dataTransfer.setData("Text",title);
event.stopPropagation();
} else {
event.preventDefault();
Expand Down

0 comments on commit 335c470

Please sign in to comment.