You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make Custom BBCode Work Like an Existing Tag. #747
So i have a custom BB code but when i select the text and then press my custom button it doesnt behave like the rest. Example, when i highlight some text and press bold it will toggle the selected text bold or not. However after adding my custom BB tag it will constantly just spam my tags in the wysiwyg. So how do i get them to behave the same. Here is my code.
@brunoais I understand that but surly as the logic is already there you can just run a function? i literally need the same logic as a bold tag but cant find that anywhere, the only thing i can find is
Activity
brunoais commentedon Aug 1, 2019
To prevent the tags from being repeatedly spammed, you need to add logic to test if the tag is already there.
See if this example from the source code helps enough: https://github.com/samclarke/SCEditor/blob/master/src/lib/defaultCommands.js#L373
markmorris commentedon Aug 1, 2019
@brunoais I understand that but surly as the logic is already there you can just run a function? i literally need the same logic as a bold tag but cant find that anywhere, the only thing i can find is
Surly theres a better way to get the same logic then to have to write it all over again?
Also
works fine.
brunoais commentedon Aug 2, 2019
The bold button is executed by the browser itself, not SCE.
See here for the explanation on the API the browser offers: https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand
live627 commentedon Feb 18, 2021
I assume you want to toggle the tag on and off. Unfortunately, this requires some extra code.
Bare minimum testing. I just made sure the tag toggles around a word and that the button activates. It may or may not work to your satisfaction.