you could do it like this:
var element = window.focusedElement;
if(element) {// only allow input[type=text]/textarea
if (element.tagName === "TEXTAREA" ||(element.tagName ===
"INPUT" && element.type === "text")) {
return
element.value.substring(element.selectionStart,element.selectionEnd);
}
}
On Saturday, February 6, 2016 at 1:01:46 AM UTC, Andrew wrote:
>
> Currently I'm reworking a format widget that modifies text in edit mode.
> The widgets I'm modifying use the following to get selected text but it
> means the ID had to be added to a core tiddler. I'd like to select the
> element by title instead of a Id if possible so that core tiddlers don't
> have to be overridden?
>
> txt=document.getElementById("myTextarea");
> var startPos = txt.selectionStart;
> var endPos = txt.selectionEnd;
> var listtext= txt.value.substr(startPos, endPos -startPos);
>
> Maybe with something like the following. I really wish I could figure this
> out:
>
> var tiddler =
> this.getAttribute("tiddler",this.getVariable("currentTiddler"));
>
> Or maybe some kind of getTargetElement by title? Help.
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
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/7f44c313-8fd4-4049-8957-e9477af3da95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.