[TW5] Selected text in edit mode

69 views
Skip to first unread message

Andrew

unread,
Jan 17, 2016, 2:15:03 PM1/17/16
to TiddlyWikiDev
I've figured out that I can pass everything in the text field in edit mode passing {{!!title}} as the param in a button and using in my widget

var text = $tw.wiki.getTiddlerText(event.param);

but what I want is only text that is selected within the text field in edit mode so that when I click a button in my format toolbar the event listener will trigger my widget to collect just the selected text. The following is just one of many that hasn't worked so far.

$tw.rootWidget.addEventListener("tm-selection", function (event) {
    var text = $tw.wiki.getTiddlerText(event.param).substring(this.selectionStart, this.selectionEnd);
    alert(text);
});

Anyone have any suggestions?

Wolfgang Fröch

unread,
Jan 18, 2016, 4:35:07 AM1/18/16
to tiddly...@googlegroups.com


Hello Andrew, hello to all

Andrew, as this is my first posting, before answering your posting, let me express my appreciation of this whole project and the tremendous work behind.
Thank you very much to all.

What I use (want to use) TW5 for I will put in another posting in the non-dev space.
~~
As a newbie to html and javascript I can not give you direct advice.
Just a reference to an already existing example of a tw5 with toolbar I found while searching the net for suitable base tw5s for my own adaption.
Pls refer to http://tw5editor.tiddlyspot.com/
Unfortunately it does not work after upgrade to 5.1.10.


Personally I am answering because I am very interested in such a toolbar (which I hope to be expandable in simple ways by my own buttons calling customized funcationality).

 
Wolfgang

andrew harrison

unread,
Jan 18, 2016, 3:56:22 PM1/18/16
to tiddly...@googlegroups.com
Thanks Wolfgang. I've used that toolbar myself the last couple of months. The reason I'm exploring the Tiddlywiki way of manipulating text in the text field is because I want to create a format toolbar plugin that doesn't override any shadow tiddlers. Still looking for something like window.getSelection().toString(), which works everywhere else but not for the textarea. It seems unless I figure out a way to add a mouseup even, I have to use document.getElementById . Still looking for solutions. Thanks.

On Mon, Jan 18, 2016 at 2:35 AM, Wolfgang Fröch <wf...@gmx.at> wrote:


Hello Andrew, hello to all

Andrew, as this is my first posting, before answering your posting, let me express my appreciation of this whole project and the tremendous work behind. (One part of my life I spend also with programming)

Thank you very much to all.

What I use (want to use) TW5 for I will put in another posting in the non-dev space.
~~
As a newbie to html and javascript I can not give you direct advice.
Just a reference to an already existing example of a tw5 with toolbar I found while searching the net for suitable base tw5s for my own adaption.
Pls refer to http://tw5editor.tiddlyspot.com/
Unfortunately it does not work after upgrade to 5.1.10.


Personally I am answering because I am very interested in such a toolbar (which I hope to be expandable in simple ways by my own buttons calling customized funcationality).

 
Wolfgang

--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/bbd5aa87-2621-4ce3-b28d-dd05228977c2%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages