New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IDEA] Add a textSelection variable to be used by editor toolbar tm-edit-text-operation functions #6949
Comments
The variable as imagined here is only available to the button actions. It's the exact same behaviour as we use to make variables available for action-widgets. As I wrote, the stamp function already does most of it. The only thing missing imo is that the eg: ItemTemplate gets access to a Once "returnText" is defined a "replace-selection" with the new text can be sent. |
@Jermolene I did add step 3 "the manipulation should be triggered with a button" to the OP |
I have extended the edit-text widget (in Streams) to both provide the selection as a variable in actions invoked by toolbar buttons as well as the inputActions fired on every key stroke and have not run into any issues. |
I should add though that getting the selection reliably across different editor engines can get tricky and it took some rather fiddly code to extend the simple, framed and codemirror engine to provide a selection variable in actions triggered within the edit widget. |
As in this discussion Can we access the ‘selection’ in the WidgetMessage: tm-edit-text-operation telumire details the use of $message="tm-edit-text-operation" $param="save-selection" to place the selection into a tiddler/field.
I was keen to see a slightly more straightforward way to access the selection, as a variable, which clearly every Javascript tm-edit-text-operation can, using An example may be a get selection JS macro result can be assigned to a variable
Of note if it were possible to do the same outside the editor we could select something and have a button designed to perform an action on the selection. |
As a user I would like to
That's more or less, what the stamp-function does. ..
The "only" thing missing is a "selectedText" variable that can be used to start with. ...
Original post: https://talk.tiddlywiki.org/t/can-we-access-the-selection-in-the-widgetmessage-tm-edit-text-operation/4558
The text was updated successfully, but these errors were encountered: