-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add trimSelection parameter to text editor #7944
Add trimSelection parameter to text editor #7944
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@Jermolene please test with macOS / Safari - I do not have that possibility. -- This PR is a draft atm, so users can play with it |
I also did a short test with CodeMirro5 plugin -> Seems to work as expected. |
@pmario it works as expected with the core toolbar buttons in default editor. However, I cannot make it work with my custom buttons that add markup other than the core buttons. I tried the following in the preview:
The "ignoring" of spaces does not work, so if Is your current solution by any chance hard coded to support only the markup symbols present in core toolbar buttons, but not any arbitrary prefix/suffix? The ignoring of spaces in selection does work if I change the prefix/suffix to something wild that uses "default" symbols only, e.g. |
It should work as expected. I did just test it and it works for me. |
@pmario I got where the problem is. There's a typo in the parameter name, |
We could change But I think hmmm @Jermolene @saqimtiaz ... any ideas? |
I did change the prameter "both" to "yes" - Switch this PR to "ready for review" since there was no other feedback |
@Jermolene -- please review again. IMO this PR is a nice quality of live improvement, which also fixes a constant annoyance if macro parameters are double-clicked and renamed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pmario just some coding style points
if(operation.selStart === operation.selEnd) { | ||
// No selection; check if we're within the prefix/suffix | ||
if(operation.text.substring(operation.selStart - event.paramObject.prefix.length,operation.selStart + event.paramObject.suffix.length) === event.paramObject.prefix + event.paramObject.suffix) { | ||
var o = operation, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of this abbreviation pattern. I understand that it saves a bit of space, but it is hard to apply consistently. For example, here one might wonder why "operation" is abbreviated but "prefix" is not.
On balance, I would prefer to find ways to refactor the code to avoid the repetition, rather than use this pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefix is an abbreviation. It is the shorthand for event.paramObject.prefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "o" abbreviation is used 99 times and was introduced to make the code readable and understandable. If I add it back again, it will make the code completely unreadable. Reducing the file size by 800bytes is a side effect.
IMO there is no redundant, repettitive code on the right side of any =. Every line, that defines o.cutStart, o.cutEnd, ... and so on, has a different pattern on the right side. -- So I do not really see a possility to optimize that any further.
@Jermolene -- Please consider this one again. It is annoying on Widows if a word is double clicked and then CTRL-B for bold is uses. Since Windows does select the word and the following whitespace, the current behaviour will include the withespace within the formatting. Which then needs to be fixed manually. About your concerns of abbreviating As I wrote. I think, there is no duplicated code. The right side of |
I did test it with the default and the codemirror editor. Both work in the same way. |
Thanks @pmario |
As discussed at: https://talk.tiddlywiki.org/t/ideas-to-improve-wrap-selection-and-wrap-lines-operations-tm-edit-text-operation/8935
This PR adds a new parameter to the "wrap-selection" editor button functions.