Is there a way to create a tiddler using text that is stored in the clipboard?

511 views
Skip to first unread message

si

unread,
Nov 9, 2020, 4:17:00 PM11/9/20
to TiddlyWiki
Say you have copied a paragraph of text and it is stored in your clipboard.

Is there a way to create a button in TiddlyWiki that will create a new tiddler whose "text" field is populated with whatever was stored in your clipboard?

I'm not expecting the answer to be yes but I thought I'd ask just in case. Thanks in advance for your help.

Jeremy Ruston

unread,
Nov 10, 2020, 2:33:51 AM11/10/20
to tiddl...@googlegroups.com
On a device with a keyboard you can click on TiddlyWiki's page background and then use the keyboard shortcut for "paste". The $:/Import dialogue should open with the pasted item as a tiddler.

Best wishes

Jeremy.


On 9 Nov 2020, at 21:17, si <matthew...@gmail.com> wrote:


Say you have copied a paragraph of text and it is stored in your clipboard.

Is there a way to create a button in TiddlyWiki that will create a new tiddler whose "text" field is populated with whatever was stored in your clipboard?

I'm not expecting the answer to be yes but I thought I'd ask just in case. Thanks in advance for your help.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/faf491ec-7c6c-45cb-9fe1-3c926f412c6do%40googlegroups.com.

si

unread,
Nov 10, 2020, 6:08:24 AM11/10/20
to TiddlyWiki
Hi Jeremy thanks for the response. I was specifically hoping to be able to do it with something like $action-createtiddler so that I could auto-populate the new tiddler with whatever fields and tags I need.

My specific use case is that when I'm reading a PDF I usually create a tiddler to represent the book. All my book tiddlers have a button for creating a tiddler to store quotes from the book, tagged with the book + metadata fields. Currently I just copy the text in manually, which is fine, I just wondered if there was a way I could speed up this process and have it all happen with one button press.

On Tuesday, 10 November 2020 07:33:51 UTC, Jeremy Ruston wrote:
On a device with a keyboard you can click on TiddlyWiki's page background and then use the keyboard shortcut for "paste". The $:/Import dialogue should open with the pasted item as a tiddler.

Best wishes

Jeremy.


On 9 Nov 2020, at 21:17, si <matthew...@gmail.com> wrote:


Say you have copied a paragraph of text and it is stored in your clipboard.

Is there a way to create a button in TiddlyWiki that will create a new tiddler whose "text" field is populated with whatever was stored in your clipboard?

I'm not expecting the answer to be yes but I thought I'd ask just in case. Thanks in advance for your help.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddl...@googlegroups.com.
Message has been deleted

David Gifford

unread,
Nov 10, 2020, 8:19:54 AM11/10/20
to TiddlyWiki
I decided to delete and rewrite my post since it was somewhat incomprehensible:

I have an idea that if implemented in TiddlyWiki, would solve si's problem, and would also solve a problem of my own: my problem is that sometimes I want any tiddler generated by creating a wikilink then clicking on the link, to have certain fields and data.

My idea is this:

1. Have a separate tab in the control panel with the "Title for new tiddlers" and "Tags for new tiddlers"from the basics tab, but with a new element: "Fields for new tiddlers", which could look just like it does at the bottom of edit mode in all tiddlers. That way, si could set the fields (and add text to them if desired) so that when he pastes the text, the tiddler generated would have the fields and data added. Let's call this tab $:/core/ui/ControlPanel/NewTiddlerConfig

2. The other aspect of my idea is that $:/core/ui/ControlPanel/NewTiddlerConfig could be tagged, say, $:/tags/NewTiddlerConfig. And only the tiddler that has this tag will modify the creation of new tiddlers. So users could clone this tiddler and have a number of custom "new tiddler config" tabs - one for images, one for reading notes, one for contacts, etc, and use a switcher to tag the one they want to work on at a given time.

3. Why is this helpful? Currently the only way to create tiddlers with preset fields is to create a custom new tiddler button for the sidebar. There are drawbacks:
a) You have to choose an icon to make it distinct from the others.
b) If none of the standard icons fit, you need to create an icon and add it to a tiddler.
c) Sometimes you want to create tiddlers in other ways: using newhere, or creating a link and clicking on it, but the fields and data aren't added to the tiddler by those methods.

4. What would this look like for the end user process? An example:

Say I have already created custom "New tiddler config" tiddlers.
a) One is for reading notes. It has a bibliographic data field and a page number field. I use some sort of switcher to untag the the core "new tiddler config" tiddler, and tag this one. I add the bib data for the source I am going to read. Then every note I create has that data, and all I need to do is add the page number.
b) Then say I am going to work on adding images. I use the switcher to choose the "new tiddler config" tiddler I created for images. The text field is [img width="90%" [ ]], the tag is image and maybe there is some other field. I create images for a while and just paste the image location.
c) Then I want to add contacts for a while. I use the switcher to choose my contact template. I can create my contact tiddler, tags and fields included, by typing a link to "Jeremy Ruston" and clicking on it, then just fill in the fields.
d) When I am done, I use the switcher to tag the core new tiddler config tiddler so new tiddlers are blank again.

Okay, I really need to get my class ready. Burst of inspiration over. I hope this is doable and that what I wrote inspires someone more knowledgable than me who could actually design this.

TW Tones

unread,
Nov 10, 2020, 7:28:21 PM11/10/20
to TiddlyWiki
Si et al,

Si, are you copying these quotes from an imbedded PDF or from somewhere else?

A code pattern I have being using when copying from tiddlywiki to the clipboard, I built my own button and also copy the content to a temp tiddler, this then becomes a tiddlywiki clipboard you can paste from with a tiddlywiki paste button, or ctrl-v as the same content is in both (until another copy)

But I understand your requirement is different, It could be said to Pull the content from the clipboard into tiddlywiki.

The other code pattern I make use of is use ctrl-v to paste into tiddlywiki, drop also works. This then imports an untitled tiddler, after import I click on the untitled tiddler and a view template that only displays on tiddlers with the prefix "untitled" then provides options to handle the text there in. I have open implementation of this which detects if the text field has the prefix http: https: and file etc... and if so offer's to create an "external link tiddler".

You could add to the second code pattern the first, thus gain ability to copy the content of the untitled tiddler to a tiddlywiki clipboard tiddler.

I do not know if it is technically possible, but an action widget to retrieve the contents of the "system" clipboard would be ideal.

Regards
Tones

TW Tones

unread,
Nov 10, 2020, 7:58:27 PM11/10/20
to TiddlyWiki
David,

In a similar vein for creating tiddlers from found text the OT and your desire for "loaded" new tiddlers, One idea I had was to create a tab in the side bar with a drop zone. Text dropped there would be imported silently and create a tiddler according to a set of standards and fields etc. A Second tab dropzone, could import the text another way. This method would do well to have the below templates idea.
  • David's point 1. Use the viewTemplate for untitled tiddlers and add this feature there (as in my last post)
Templates idea

TiddlyWiki is repeat with the concept of templates, as a result, I think perhaps we have somewhat neglected the use of tiddler templates for creating tiddlers. This should have a core representation so extra bespoke work is not required for such a fundamental function. 

I have developed a number of methods that can help meet the ideas in your other points, The key is however having defined some template tiddlers that are used to create different kinds of tiddlers. Such templates can have what ever fields and values you want and one trick is to also include fields for example with an underscore name eg: _tags value" "tagname1 tagname2", underscore fields are used to populate the no underscore field of the same name eg: tags value" "tagname1 tagname2" when creating the new tiddler from the template.

Fields can only contain lowercase letters, digits and the characters underscore (_), hyphen (-) and period (.) this this are the three punctuation prefixes available.
So I suggest;
  • _fieldname results a in fieldname being created with the value in _fieldname used (if any).
    • One special case would be _source-template which is recorded in the new tiddler
    • another _object-name eg "task" when the template is used to create a task
  • .fieldname If the current tiddler has fieldname use the "current tiddlers fieldname" to set the value "a context field"
  • -fieldname could potentially use a macro or transclusion of a similar name as fieldname to populate the new field.
  • All other fields are cloned into the new tiddler.

springer

unread,
Dec 11, 2020, 7:45:33 PM12/11/20
to TiddlyWiki
I just discovered this thread, while trying to understand related issues.

My workflow includes, for example, coming a cross a citation in google scholar, which I can display in bibtex format like so: 

@book{crary2016inside, 
    title={Inside ethics}, 
    author={Crary, Alice}, 
    year={2016}, 
   publisher={Harvard University Press} 
}

I was hoping that dragging that text into Tiddlywiki would auto-populate the fields. Instead, I get an ordinary tiddler with a text field that looks exactly like the above block.

What works: issuing a terminal command like pbpaste > crary.bib
 ... which yields a .bib file ... which I can then drag into tw5 (for import and recognition via bibtex plugin), but this is terribly roundabout.

Why not be able to drag and drop the contents of a field-parsable string (onto a special bibtex or json drop area if need be) and have tiddlywiki parse directly, populating fields if field patterns are present?

(Sorry that this question is framed with bibtex records in mind; but presumably the issues are similar for any json-formatted strings on the clipboard?)

-Springer

TW Tones

unread,
Dec 11, 2020, 8:30:38 PM12/11/20
to TiddlyWiki
Springer,

Some thoughts for you;
  • When you paste text onto tiddlywiki the import mechaisium will create an "untitled n" tiddler. Go ahead and import it.
  • You can create a view template on tiddlers beginning untitled that tests the content of the text field for various conditions. 
    • I have one that tests if text begins with http:// or https:// meaning its a link, and a button appears to name and create a link tiddler. It uses my own designed logic.
  • You can do similar and detect say @ as the first character and offer to create a citation tiddler.
    • The detail is in parsing and reformatting the citation into fields etc... which I / we can help you with.
  • Yes this could be automated further with the ideas expressed in this thread, but this approach would be a good start.
  • Ideally one day it will be easy to import and transform and common text formats of any type into a tiddler. 
Regards
Tone

Mark S.

unread,
Dec 12, 2020, 12:49:16 AM12/12/20
to TiddlyWiki
If you edit the import tiddler, you'll see it's actually a JSON structure.

So you could possibly use the JsonMangler plugin in conjunction with your own "import" button that would fetch all the values, add your own fields, and create the tiddler. This way you could perform a batch process after you've done a series of import pastes.

Saq Imtiaz

unread,
Dec 12, 2020, 2:14:10 AM12/12/20
to TiddlyWiki
@springer So the dropzone widget which handles the import/paste/drag actually lets you specify how to interpret the incoming text.

So theoretically something like this should work:

<$dropzone deserializer="application/x-bibtex">

paste/drag bibtex here


</$dropzone>

However, it turns out that the deserializer attribute is only honoured for files that are imported and not for text. This is worth creating an issue for on github, I think we can do better.

Saq

Mohammad

unread,
Dec 12, 2020, 2:47:50 AM12/12/20
to TiddlyWiki
Hi Springer,
 I use the multiple citation export from Google Scholar see:
  After I finished I download the text file and save as .bib and then drag and drop into my Tiddlywiki with BibtexImporter plugin installed.

--Mohammad

Mohammad

unread,
Dec 12, 2020, 2:52:08 AM12/12/20
to TiddlyWiki
Hi Saq,
 Great tip. I will submit a ticket.

Cheers
Mohammad

Mohammad

unread,
Dec 12, 2020, 3:03:21 AM12/12/20
to TiddlyWiki
See https://github.com/Jermolene/TiddlyWiki5/issues/5261#issue-763431242

On Saturday, December 12, 2020 at 10:44:10 AM UTC+3:30 saq.i...@gmail.com wrote:

Eric Shulman

unread,
Dec 12, 2020, 3:52:13 AM12/12/20
to TiddlyWiki
On Friday, December 11, 2020 at 4:45:33 PM UTC-8 springer wrote:
drag and drop the contents of a field-parsable string (onto a special bibtex or json drop area if need be) and have tiddlywiki parse directly, populating fields if field patterns are present?

Try this:
\define dropbibtex()
<$wikify name="source" text=<<actionTiddler>>>
<$set name="source" filter="[<source>removeprefix[@book{]removesuffix[}]split[,]rest[]join[,]]" select=0>
   <$list filter="[<source>split[}]first[]trim[]removeprefix[title={]]" variable="title">
      <$list filter="[<source>split[}]]" variable="item">
         <$vars f={{{ [<item>split[={]first[]trim[,]trim[]] }}} v={{{ [<item>split[={]rest[]trim[,]trim[]] }}}>
         <$action-setfield $tiddler=<<title>> $field=<<f>> $value=<<v>> />
         </$vars>
      </$list>
   </$list>
</$set>
</$wikify>
\end
<$droppable actions=<<dropbibtex>>>
<$button style="width:10em;height:10em;">drop bibtex here</$button>
</$droppable>

Notes:
* $wikify converts the dropped content into plain text, removing any surrounding HTML syntax
* $set removes the leading "@book{", trailing "}" and first value (e.g., "crary2016inside")
* first $list extracts the target tiddler title value from title="..."
* second $list extracts each named item (e.g., author={Crary, Alice)
* $vars gets the fieldname (everything before the "={") and fieldvalue (everything after the "={") from the item
* $action-setfield creates each field and value in the target tiddler

enjoy,
-e

Eric Shulman

unread,
Dec 12, 2020, 3:56:24 AM12/12/20
to TiddlyWiki
addendum:
 
 <$vars f={{{ [<item>split[={]first[]trim[,]trim[]] }}} v={{{ [<item>split[={]rest[]trim[,]trim[]] }}}>

Note that these inline filters use the enhanced trim[...] operator available in soon to be released TW5.1.23

-e

 

springer

unread,
Dec 12, 2020, 5:28:41 PM12/12/20
to TiddlyWiki
Wow, Thanks, Eric! 

For book references, it works straightaway! For more general use, this part would need tweaking:

         removeprefix[@book

The "book" part is actually important in the bibtex system, since it belongs in the type-field.

Of course, filling in the type field manually isn't any trouble, but the current bit of code seems to fail if the input has something else (like @article) in that initial position.

Looking forward to spending more time following up on all the posts here.

-Springer



Reply all
Reply to author
Forward
0 new messages