-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Reconsider how removeFormat
works
#954
Comments
Thanks for taking this up. I would personally vote for 2; if you're removing block formats I think it should be expected that you would remove all block formats touched by a selection. Alternatively you could have separate functions for removing line formats and inline formats, and let the code determine what to do based on the selection. I'm new to Quill and not familiar enough to guess at which is more in keeping with your style. In the meantime, though, you may want to edit the documentation which says:
That would make it clearer that the function currently doesn't distinguish scenarios based on the presence of a newline. |
Not sure if this is helpful, but this is what I'm currently doing with my Clear Format button:
I think there may be some quirks related to how I have this set up that mean removeFormat works differently for me, so the inline format removal might not be required in a different implementation. This approach is working for me so far although it needs some more testing. |
Screen capture of 'Clear all Formatting' button in Word on Windows 7. It uses option 1.
I think that the first two points are the expected behavior and what I would like to see in Quill. I'm not sure about the third point. I like option 1 which is the current behavior. |
Hum, nice question question/discussion. Honestly, I think the current behaviour (1) seems to be the more faithful to what the method proposes. I feel that behaviour to be the most unambiguous one for that particular method - perhaps a better wording could be On another hand, variants for the other behaviours could also be considered - I was thinking of something along the lines of Another thing I got into (but still have to confirm that one, I'm afraid bundling may be causing an issue on non-allowed formats removal by Parchment) was the need to remove only specific formats (a list of them) for a given range - including embeds. (Could be an option for these methods?) Thoughts? |
Any updates on this? |
The current
removeFormat
behavior might be unintuitive and might be worth reconsidering. It removes all inline formats within the given range and all block formats on lines the range is on. So if you have (example 1):and your selection surrounds the "|" characters,
{ index: 2, length: 6 }
to be precise including the "|" characters,removeFormat(2, 6);
would remove both header formats. If your cursor position was (example 2):removeFormat(1, 3)
would also remove the header.A few plausible behaviors for
removeFormat()
include:removeFormat
should not handle block formats at all.Google Docs seems to take option 4's approach. There is also the possibility of having the
clean
toolbar button do something different than theremoveFormat
API. Perhaps some of the addition logic of single line vs multiple line could go into theclean
toolbar handler (and thus customizable by the user) and the API can be more straightforward.Thoughts?
The text was updated successfully, but these errors were encountered: