ink-mde
ink-mde copied to clipboard
Allow a text element to be supplied in constructor
For better progressive enhancement, a text element should be an acceptable "parent" element. It might require some investigation, but a naive approach, for now, would be to replace that element with a normal container (such as a div).
When a text element is supplied, Ink could also set the element to hidden and keep the value in sync with the actual editor.
Amazing project!
Adding the editor to textarea elements would be ace. I'd like to do something like:
ink(document.getElementsByClassName('editor')!)
.. and have all the textarea's on my rails app with that class become markdown editors.
Is this the kind of direction you are going in?
Thanks, @asecondwill! That's essentially the idea, although you'd need to iterate the elements and initialize each of them right now. Something like this would work.
Array.from(document.getElementsByClassName('editor')).forEach((editor) => {
ink(editor)
})