ink-mde icon indicating copy to clipboard operation
ink-mde copied to clipboard

Allow a text element to be supplied in constructor

Open davidmyersdev opened this issue 3 years ago • 1 comments

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).

davidmyersdev avatar Jun 24 '22 15:06 davidmyersdev

When a text element is supplied, Ink could also set the element to hidden and keep the value in sync with the actual editor.

davidmyersdev avatar Jun 24 '22 15:06 davidmyersdev

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?

asecondwill avatar Feb 01 '23 16:02 asecondwill

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)
})

davidmyersdev avatar Feb 03 '23 06:02 davidmyersdev