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 selected text onto list-links-draggable macro adds unwieldy HTML to the list #8158

Open
bluepenguindeveloper opened this issue Apr 20, 2024 · 1 comment

Comments

@bluepenguindeveloper
Copy link

Describe the bug

If you select some piece of text with the mouse other than from a text input, and then drag that selected text onto a list created via the list-links-draggable macro, the HTML code for the selected text get added as a (missing) tiddler to the list. For example, if you highlight (select with the mouse) a tiddler name in the "Open" Tab of the side bar and then attempt to move that tiddler to a different location in the story river by dragging the link for the tiddler to a different location in the list, it drops the HTML code for the link instead.

Expected behavior

I would expect the HTML to be stripped (except any HTML that is part of the rendered text that was selected); for example, if you select the text concise description and drag it into the list, then concise description (and not <span attr1=val1 attr2=val2 ...>concise description</span>) to be dropped into the list. (But if the text is displayed as <span>some text</span>, then if you select it and drag it into a list-links-draggable's list, then it should be displayed in the list as <span>some text</span>.)

To Reproduce

You can reproduce with any list created by a links-list-draggable macro, but here's one example of how to reproduce:

  1. Go to https://tiddlywiki.com/
  2. On the sidebar on the right, in the story list (displayed in the "Open" tab), use the mouse to select the "GettingStarted" tiddler (or only part of it), as in the screenshot below:
    image
  3. Drag the selected "GettingStarted" tiddler title onto the "HelloThere" tiddler title immediately above it (and release the mouse button).
  4. Note the HTML code that gets displayed (and the missing tiddler that appears in the story river as a result of being added to the story list)
    image

Screenshots

No response

TiddlyWiki Configuration

  • Version [e.g. v5.3.3]
  • Saving mechanism: TiddlyDesktop, or just opened in the browser
  • Plugins installed: none (tested with new Empty wiki)

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Brave, TiddlyDesktop (most likely others)

Additional context

No response

@Jermolene
Copy link
Owner

Copying my answer from the discussion group thread:

Hi @bluepenguindeveloper I’m pretty sure that this issue reflects the peculiarities in the way that browsers handle drag and drop, and isn’t a bug in TiddlyWiki per se.

Browsers support a number of different payload types for drag and drop events. TiddlyWiki uses a custom link format as the payload format when dragging and dropping tiddlers. This all works fine when dragging the link itself.

However, if text is selected then the browser behaves completely differently. Instead of the payload being a link, it sends a fragment of HTML representing the selected text. TiddlyWiki doesn’t recognise that as a link because it isn’t a link, and so it just tries to import it as a fragment of HTML text in a new untitled tiddler.

The fact that browsers implement two semantically different types of drag and drop with almost the same user interface seems like the heart of the problem.

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

2 participants