You just have to emit the js code with wf:wire.
Suppose your element is #simplemde{}. That record contains all options you want to support through nitrogen:
-record(simplemde, {?ELEMENT_BASE(element_simplemde),
status,
promptURLs,
spellChecker,
...
}).
Then in the element implementation you emit the DOM node, and you run the js code through the websocket (wf:wire):
render_element(#simplemde{status=Status, spellChecker=SpellChecker}) ->
Id = wf:temp_id(),
wf:wire(wf:f("var simplemde = new SimpleMDE({ element: document.getElementById('~s'), status: ~p, spellChecker:~p }); ",
[Id, Status, SpellChecker])),
#textarea {html_id=Id}.
Just simple as that. Maybe you will have to use wf:defer instead of wf:wire which also evaluates js code in the browser
but it puts the code at the end of the nitrogen js queue because that document.getElementById must happen after rendering
the textarea node itself, right?
Your element can support more complex options like 'insertTexts' but you have to make sure you are emitting sane JS code. Thats
why my example only uses 'status' and 'spellchecker' which are just booleans. For that you can use wf:f, wf:wire, wf:json_encode,
and wf:js_escape functions to format clean js code. wf:f in particular is just a wrapper to io_lib:format/2. To support all SimpleMDE options
you will have to eventually craft the js string with wf:f (or io_lib:format). Its just a string formatting game...