Drag and drop - excision from the view for text tiddlers

247 views
Skip to first unread message

Mark S.

unread,
Dec 21, 2020, 11:14:22 AM12/21/20
to TiddlyWiki
TW already has excision, but you have to be in edit mode and there are several speed bumps that make it somewhat messy to use.

This is an example project that demonstrates using drag-and-drop to replace text with excerpts that can then be displayed with your own template.

This could be useful is you are studying text, and want to excerpt portions for quotes or for cross-linking with other tiddlers.

Caveats.
  • This is for 5.1.23-prerelease only. 
  • Any other tiddler in the story river that contains the same text will have  it's text replaced also. This is why excerpts are tagged with "Excerpt" so they won't be double-processed.
  • Only works with simple unformatted text. 
  • To make it work with TW's linefeeds, the """ markup is applied to the top of each excerpt.
  • Possibly only works on Mondays. Or on solstices.


 
plugins_MAS_DragAndReplace_8.json

TW Tones

unread,
Dec 21, 2020, 4:40:37 PM12/21/20
to TiddlyWiki
Mark

Thanks for sharing, this sounds like a step towards sophisticated knowledge tools. I will review in details.

Regards
Tones

Mark S.

unread,
Dec 24, 2020, 5:55:34 PM12/24/20
to TiddlyWiki

Now that 5.1.23 has come out, I've added this code to https://marxsal.github.io/various/playground.html so people can try it directly.

Michael Wiktowy

unread,
Dec 25, 2020, 12:39:40 AM12/25/20
to TiddlyWiki
That is very cool. That kind of functionality will prove very useful in quickly tiddlywiking a big flat text file ... something I do a lot of ... very manually at the moment.

I will have to study your 5.1.23-filter wizardry and figure out how to tag the newly created tiddler with the host tiddler and name it based on the highlighted content.

Thanks for sharing a very practical example.
/Mike

Mark S.

unread,
Dec 25, 2020, 10:02:35 AM12/25/20
to TiddlyWiki
The Slicer Edition and NotoWritey can quickly slice up your text files, if you want the whole thing processed.

For this (I think I'll call it Excerpt) getting the source name might be tricky. I'm thinking that the new EventCatcherWidget might be wrapped around your text tiddlers as a template. Beginning a selection would then put the current tiddler name into a tiddler which could then be used by Excerpt for tagging and/or naming.

Mat

unread,
Dec 25, 2020, 3:12:20 PM12/25/20
to TiddlyWiki
Mark - whoa! That is a good step towards a view mode work-interface. If the limitations you point out are removed, including access to the original tiddler title, I think it would be a pracitcal way to postpone splitting up texts into smaller ones (i.e into tiddlers) until it is actually needed. The current TW workflow where we need to estimate if something needs to be a tiddler, probably over-tiddlifies things.

<:-)

Mark S.

unread,
Dec 25, 2020, 6:53:47 PM12/25/20
to TiddlyWiki
The reason it doesn't work with other kinds of text is because when you drag and drop, the dropped text contains the original in HTML. Which means it doesn't match any of the actual text inside the original tiddler. To fix this, the HTML is wikified back to text, which can be compared to the original text in the tiddler IF the text isn't formatted.

Possibly a way to make the approach more universal would be to convert the text in the tiddler to HTML. But most people (I assume) aren't using HTML in their tiddlers.

To make the approach work with wikitext, we need a html-to-wikitext converter so that the dropped text can be converted back to wikitext, compared, and replaced.

Michael Wiktowy

unread,
Dec 26, 2020, 12:20:13 PM12/26/20
to TiddlyWiki
I looked at the slicer-edition when it came out and it didn't quite suit my purposes. I am interesting in chopping up CFRs from eCFR.gov ... specifically the new beta site https://ecfr.federalregister.gov/ ... you can grab an entire part in a number of formats (including JSON) but I end up with a plain text tiddler. Conveniently, each section is uniquely named so it has been fairly simple to semi-manually parse using the excise function in the tiddler editor. It consists of four steps after importing the big text file into a tiddler: copy section title to clipboard, Highlight the whole section in editor, excise and paste the title to name the new tiddler.

If that could be reduced to a single step of dragging a highlighted section onto a sidebar area, that would be super-efficient. In my case, the tiddler title is always the first line of the section being dragged and always unique so I think this might be doable with some creative splitting. Like what was discussed in a previous thread, it might require the ability to trigger two sequential actions like you can with a button. But even if it requires a button press after to post-process the title, that is still much more efficient. I'll investigate when I have some time to dedicate.

Thanks,
/Mike

TW Tones

unread,
Dec 27, 2020, 2:50:23 AM12/27/20
to TiddlyWiki
Keep in mind the JSON mangler plugin for sophisticated import and refactoring of data.

Regards
Tones

TW Tones

unread,
Dec 27, 2020, 2:59:42 AM12/27/20
to TiddlyWiki
Mark,

Thanks this is very impressive, and will help dividing imported text into logical bits, tiddlers.

  • All I would suggest is a little improvement to the User interface such as allowing us to drop on a boxed area
  • I expect the same mechaisium could be used in otherways. 
  • It would be nice if one day we could drop a tiddler title and have it transcluded at the destination indicated by the mouse pointer.
Love your work
Tones

Mat

unread,
Dec 27, 2020, 6:33:31 AM12/27/20
to TiddlyWiki
Mark S. wrote:
The reason it doesn't work with other kinds of text is because when you drag and drop, the dropped text contains the original in HTML. Which means it doesn't match any of the actual text inside the original tiddler. To fix this, the HTML is wikified back to text, which can be compared to the original text in the tiddler IF the text isn't formatted.

Do I understand this right: What is dragged is merely a copy of the seen text (the "view mode" text), i.e there is no mechanism going into the actual wikitext to copy it?

If this is the case... then, yeah, I understand if it can't be much improved... :-(

Not saying you should do it, but is it even technically possible to access the actual wikitext by selecting view mode text? To get away from a need for "pattern matching" (i.e finding the literal selected text also in the wikitext, which is what I interpret your current solution to use) maybe the wikitext could produce some kind of physical position indicator, like the line number, which can be accessed in view mode. So selecting a snip also conveys what original rows this rendered text stems from, and then these rows are instead what is drag'n dropped. 
- At all realistic?

<:-)

TW Tones

unread,
Dec 27, 2020, 8:39:41 PM12/27/20
to TiddlyWiki
Taking mats idea a little further,

With the new layouts switch, you could switch to an alternate view template designed, or rendered in a way, one may be able to obtain information about placement in the raw text field. Of course you cant drop text into the middle of content generated via widgets such as list, but you should be able to drop above and below widgets, and before or after plain text. Perhaps we could even place "insertion points" (drop zones) within the text defined by a macro or css that the insertion tool can use. The technology exists, because I have seen this in the past. Plain text tiddlers would have no barrier's to insertion.

Alternative methods to allow tiddler to be dropped on a list that will tag them such that they now appear in the list would also be cute.

Tones

Reply all
Reply to author
Forward
0 new messages