"Discussion examples" converted into tiddlers?

TiddlyClip can use user defined macros. So it’s conceivable you could have a custom item in your TC context menu that would let you turn your selected text into a tid. The question is, how often does this come up?

1 Like

If you paste text, how does the pasting know you’re in the special zone? And not in the default zone at the top of the page?

Thanks!

1 Like

In theory, the dropzone’s DOM element or one of its children should have focus when you paste. In practice, just clicking inside the dropzone and then pasting works even if there are no focusable elements within.

Example:

<$dropzone deserializer="application/x-tiddler" tag="div">
<div style.height="200px" style.width="200px" style.border="2px solid red"  style.textAlign="center" style.lineHeight="200px" tabindex="1">
Paste or drop here
</div>
</$dropzone>
3 Likes

That’s pretty cool. It worked out of the box with CodaCoder’s example, and would have worked with Mat’s original post if the sample text had been separated like a real tiddler instead of specified with a “text” field.

1 Like

yep, the ability to use custom deserializers with pasted text content was added in 5.2.0

One of my more ambitious prototypes - a cascade of deserializers where the first one to successfully parse the content gets used - might get revisited at some point for the core, perhaps in conjunction with other work on the import mechanism.

When I drag a tiddler from one of my TiddlyWiki instances to any other, here is what is getting dragged:

data:text/vnd.tiddler,%7B%22created%22%3A%2220220327045105023%22%2C%22creator%22%3A%22Charlie%20Veniot%22%2C%22text%22%3A%22%22%2C%22tags%22%3A%22Bib%20BASIC%22%2C%22title%22%3A%22MSX%20Programming%22%2C%22modified%22%3A%2220220327045209636%22%2C%22modifier%22%3A%22Charlie%20Veniot%22%2C%22by%22%3A%22Graham%20Bland%22%2C%22pub_date%22%3A%221986-05%22%2C%22publisher%22%3A%22Financial%20Times%20Prentice%20Hall%22%2C%22url%22%3A%22IA%3A%3AMSXProgramming%22%7D

The result is the following in the $:/Import tiddler (before clicking the “Import” button):

{
    "tiddlers": {
        "MSX Programming": {
            "created": "20220327045105023",
            "creator": "Charlie Veniot",
            "text": "",
            "tags": "Bib BASIC",
            "title": "MSX Programming",
            "modified": "20220327045209636",
            "modifier": "Charlie Veniot",
            "by": "Graham Bland",
            "pub_date": "1986-05",
            "publisher": "Financial Times Prentice Hall",
            "url": "IA::MSXProgramming"
        }
    }
}

I’m thinking it is easy to implement a separate import process that is just about processing DRAGGED snippets of text for creation of new tiddlers, massaging the input to look like the json above.

Create a special tiddler for that kind of import. Set up a drop area. Upon drop, a process does as best it can to parse the text into individual fields. Allow for manual tweaking, and press the import button when ready.

The process would take as input whatever formatted text is coming in (ideally nice json like above, but otherwise hopefully at least something that looks like key-value pairs. And do it’s best to create the standard json to import a tiddler, which we have to manually fix if things are totally wacky.

I wouldn’t muck around with the current import process to handle this. This requires a distinct interface to process “garbage in” (i.e. can’t rely on what is coming to necessarily be properly formatted.)

Something like that.

I agree, Saqs example is really cool! (Thanks @saqimtiaz !) Using a “text” fieldname or not is just a matter of agreeing on a convention to stick to, so not important at all. But the direct copy-paste into the wiki is the critical piece…

This code of @Charlie_Veniot can be selected and dragged (but not copy-pasted) directly into TW to produce the tiddler:

data:text/vnd.tiddler,%7B%22created%22%3A%2220220327045105023%22%2C%22creator%22%3A%22Charlie%20Veniot%22%2C%22text%22%3A%22%22%2C%22tags%22%3A%22Bib%20BASIC%22%2C%22title%22%3A%22MSX%20Programming%22%2C%22modified%22%3A%2220220327045209636%22%2C%22modifier%22%3A%22Charlie%20Veniot%22%2C%22by%22%3A%22Graham%20Bland%22%2C%22pub_date%22%3A%221986-05%22%2C%22publisher%22%3A%22Financial%20Times%20Prentice%20Hall%22%2C%22url%22%3A%22IA%3A%3AMSXProgramming%22%7D

You have (edit: had) triple backticks (I think) before and after that data URL.

I have just single backticks.

It seems triple-backticks before and after whatever causes that content to be displayed with horizontal scroll bar and no-wrapping. And single-backticks before and after whatever causes content to be displayed with no horizontal scroll bar and wrapping is on.

Something like that.

Thanks @Charlie_Veniot - I did just edit my post with your help. So people afterwards reading your post, and mine here, will be a bit confused :wink:

Note: That DATA URI, that is what gets dragged when dragging a tiddler from one TiddlyWiki to another, and the action triggered on drop of that beast generates the pretty JSON inside the import tiddler.

Very cool stuff.

But whatever parsing is going on, we need similar kind of parsing to handle pseudo tiddlers, and that process needs to handle garbage in.

The current drag and drop process to import tiddlers, a nice and proper DATA URI is generated by TiddlyWiki for dragging, and that nice and proper DATA URI is processed by TiddlyWiki on dropping. No garbage to deal with.

There is a problem here. If the “drop-handler” automatically converts every text-snippet, that looks like a tiddler into a tiddler, it will be impossible to import those text-snipptes as plain text.

So we would get requests to change that.


Option 1

I think there has to be a “user interaction” somewhere in the import process as shown in the following image.

From my point of view a user can reliably decide, if a queued tiddler should be converted when the text is shown. See image. …

I think it is possible, to create a button, that converts the queued “payload” into a real tiddler when the user clicks it.


Option 2

It would be possible, to let the “drop-handler” check, if an “Untitled” string looks like a tiddler and name it: “Untitled.raw” …

So an upgrader, similar to the one I did create for image.png could automatically handle them, if enabled.

The upgrader can do 2 things.

  • auto rename the tiddler and import it as plain text
  • convert it to a tiddler and use the name in the “title” field

There will still be a problem that importing a tiddler from the clipboard named: my-tiddler several times, will need to be either overwritten, or it will need to be renamed.

I personally would also like to be able to have the following functionality.

Copy paste the following text snippet into TW and it should create tiddler “a” and “b” with the text from the value section.

title: do-something.multids

a: text for tiddler a
b: text for tiddler b

I have only come to this thread now. I did play with an easy to/from “Discussion tiddler” format in the past.

Here, by “discussions tiddler” I mean, one of the old tiddler form you can paste to from a discussion thread.

A personal view would be

  • A ViewToolbar button to copy any tiddler and its content and relevant field/values to the clipboard in the original tid format , I suggest the standard include "title: " at the top, see also “a special preview” below.
    • Settings driven would most likely not include created/modified dates)
  • Now if you copied such a tiddler from a discussion you just paste it into a tiddler text field, you may be tempted to keep it that way as documentation. Perhaps set type text/plain.
  • It is trivial to add a viewtoolbar button that only appears if;
    • The current tiddlers text field has a prefix of "title: " and the “rest” of the first line (the title) is not an existing tiddler, with “new tiddler n” option.
    • Clicking this button would create the tiddler described in the currentTiddlers text field.
    • This should also work for ctrl-V which creates “untitled tiddlers”,. which you can retain / rename / or trash after creating the tiddler.
    • This should also work if you imported a text file containing the tid format (but not a .tid file)

Additions I can see include;

  • A special preview in the editor which shows any tiddler as a “discussion tiddler” you can select or copy to clipboard. Perhaps avoiding the need for a viewToolbar button?
  • Additional import preview(s)
    • To view any pre-imported tiddler as a “Discussion Tiddler format”
    • To allow a tiddler with the text prefix "title: " to also be imported as a tiddler with a click before import.

All of the above can leverage existing code in tiddlywiki such as templates.

The following is a “discussion tiddler preview”

discussion-tiddler-preview.json (1.1 KB)

Open for edit any tiddler then select preview discussion tiddler.

Currently the copy to clipboard button is not working, but it can all be copied manually.

Next the reverse as discussed.

This is why I always want “headless” tw, in Headless mode for browser or SSR · Discussion #6590 · Jermolene/TiddlyWiki5 · GitHub

If so, we can make a userscript, that renders anything using $tw.wiki.renderText