Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Dragging tiddler links inconsistently wraps titles in double square brackets #7405

Open
Jermolene opened this issue Apr 17, 2023 · 6 comments

Comments

@Jermolene
Copy link
Owner

Describe the bug

Dragging a title link of a tiddler with a space in the title into a text area will create a link to that tiddler by wrapping the title in double square brackets. However, dragging a title link of a tiddler that does not have a space in the title into a text area will not wrap the title in double square brackets and thus will not create a link.

This behaviour occurs because of the use of $tw.utils.stringifyList() in dragndrop.js:

var titleString = $tw.utils.stringifyList(titles);

Expected behavior

The expected behaviour is that dragging a tiddler title into a text area will always wrap each title in double square brackets to make it act as a link.

There is a thread on talk.tiddlywiki.org where a user requests the option to wrap dragged titles in double braces (for transclusion) instead of double square brackets, and that seems a reasonable option to support

To Reproduce

  1. Go to https://tiddlywiki.com/
  2. Click the "new tiddler" button in the sidebar
  3. Click the "done" button to create a new tiddler called "New Tiddler"
  4. Click the "new tiddler" button in the sidebar again to create a draft tiddler called "Draft of 'New Tiddler 1'"
  5. From the "Open" tab in the sidebar, drag the link to "New Tiddler" into the editable text area for the new tiddler
  6. Notice that the text "[[New Tiddler]]" including double square brackets is inserted into the text area
  7. From the "Open" tab in the sidebar, drag the link to "HelloThere" into the editable text area for the new tiddler
  8. Notice that the text "HelloThere" without square brackets is inserted into the text area

Screenshots

No response

TiddlyWiki Configuration

TiddlyWiki v5.2.7

Additional context

No response

@saqimtiaz
Copy link
Contributor

See #6317 which also requests consistency in applying square brackets.

Dpeneding on how we address this, there might be backwards compatibility implications for use of the draggable widget.

@pmario
Copy link
Contributor

pmario commented Jun 25, 2023

I think that's an issue now since we disabled automatic wiki-links for new wikis. ...

I personally do like this default behaviour and we should not change it. I use the drag from Open sidebar mainly to drag tiddler titles into tag-like fields. For tags we need [[New Tiddler]] but we do not need [[HelloThere]]

I think that's the way how it was initially intended to work.

Instead I do propose that we add modifier-keys eg: SHIFT, CTRL and ALT to create different type of links. So it would be possible eg:

  • shift-drag ... never use braces
  • ctrl-drag .. always use braces
  • alt-drag ... use eg: {{HelloThere}} to create a transclusion

and so on

@pmario
Copy link
Contributor

pmario commented Jun 25, 2023

I did some more testing. For tags, it does not matter if HelloThere has braces or not. The tag field removes them.

For standard fields, we need to have a closer look what filter operators like enlist or enlist-input return if they are fed with [[HelloThere]] instead of HelloThere as it is now. I don't know that atm

@Jermolene
Copy link
Owner Author

Hi @pmario the current behaviour is nothing to do with automatic wikilinks; it's the function "stringifyList()" (referenced in the OP) that adds the double square brackets purely according to whether the title contains whitespace.

The idea of using modifier keys is not universal because it won't work on touch devices.

@pmario
Copy link
Contributor

pmario commented Jun 25, 2023

I think this issue is also related to: [IDEA] Option to make drag and dropping tiddler titles (shown as a link) always make a link #6317

which mentions: [IDEA] In editor, drop image-link to create an external link #5309

As I wrote in #6317, the title string that is dropped into a text-area is created at the drag-start which is line:

var titleString = $tw.utils.stringifyList(titles);

And it's the dataTransfer object text/plain text that is passed to the text-input for import.

dataTransfer.setData("text/plain",titleString);

Just an idea

For very fine grained control for desktop and mobile

It may be possible to set a tv-dnd-start="titlelist" variable, which imo would be in line with the format:titlelist operator suffix.

For mobile and desktop

The utility.makedraggable() function could read the tv-dnd-* variables and act according to their value. eg:

  • tv-dnd-start="titlelist" ... Creates a titlelist for every tiddler title that is dragged & dropped into a text-area
    • Dragging a single tiddler named: "test" will create: [[test]]
    • Dragging the "About" tag-pill atm creates
      • Acknowledgements Contributors [[Funding TiddlyWiki]] ...
    • Dragging "About tag-pill" should create
      • [[Acknowledgements]] [[Contributors]] [[Funding TiddlyWiki]] ...

Possible tv-dnd- variables

For desktop

  • There should be keyboard-modifier keys like SHIFT, CTRL, ALT and combinations thereof that will also count as tv-dnd-* settings.

utility.makedraggable() ... DnD-dragend may have similar possibilities with tv-dnd-end-<you-name-it>

@Jermolene
Copy link
Owner Author

Hi @pmario rather than supporting a fixed list of transformations such as title, transclusion, templatelist etc. we could instead have a configuration variable that contains a function that is executed to convert the title of a tiddler at the point that it is dragged into the text that the receiving application sees. For example:

\function tv-dnd-incoming-title-transformation(title) [<title>addprefix[{{]addsuffix[}}]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants