lets just say I have textarea
something like this
<textarea name="description" id="description" class="input_text"></textarea>
how do I add BBCode Editor?
See the quick start part here: https://www.sceditor.com/. You will need to change the URL for the javascript and CSS files to use the ones in SMF though, and change the id in the code to match the id of your textarea.
Inside SMF you need to load Subs-Editor.php and call create_control_richedit() with the right options. See Display.php for a simpler example of this.
Then on saving I forget the exact order but I think you htmlspecialchars the spring (using smcFunc's version) then preparsecode() it then save it to the database.