Mat, Walking up the Dom tree would just be examining each ancestor of the input element in order until you find one with a data-tiddler-title attribute and use that to find the tiddler that contains the input you are currently using. You may be able to somehow do the same thing with css selectors but I am not good enough with css to say. Either way it would have to be on the javascript side of things. Storing this in a state tiddler would be simple enough, it already stores the caret position so adding in the current tiddler when one exists and can be found would make sense. I don't think finding the current tiddler for inputs on the sidebar can be done the same way, but adding in specific exceptions, like for the search input, should be doable.
Unfortunately limiting it to just the text field requires examining the dom tree to determine if the current input element is part of a tiddler text field or not, so that may actually increase the complexity. I think going directly to making it work with every input element is the way to go. Any buttons that you include that have the same function as the editor toolbar will have the same limitations unless someone comes up with some new magic. The edit area is in an iframe because an iframe can keep its input element that currently has focus when you click outside the iframe, but only one UI element can have focus in the same frame. So the text field loses focus when you click on one of the buttons in the edit toolbar unless the text field is split into a separate iframe. Losing focus means the caret position is lost so inserting text at the caret position doesn't work because the caret is not in the text filed when you click the button. There is a mechanism for passing information from an iframe to the containing page, it is what we use for the plugin library and twederation. There must be someway the iframe lets the wiki know which tiddler it is editing, so we can get that information to set the current tiddler when the toolbar is in use. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/6d1ba174-e3c0-4c9d-b8e7-bd95fdf9801eo%40googlegroups.com.
