Reputation: 3
I've been playing around with the tiptap editor framework for a few days now, and I have trouble understanding what is the difference between set and toggle functions. As an example, what is the difference between the setBold()
function and the toggleBold()
(https://tiptap.dev/api/marks/bold).
Thanks!
Upvotes: 0
Views: 643
Reputation: 9441
So if you know you definitely want to switch bolding ON, use .setBold()
If you definitely want to switch bolding OFF, use .unsetBold()
And if you just want to reverse the bolding state, use .toggleBold()
If you tried both, and found identical effects, probably you were testing from a state of "not bolded".
If you try the two functions on a piece of text that is already bold, you will see that "toggle" turns off the bold, and "set" leaves the text remaining bold.
Upvotes: 0