test editor
Sun, Mar 03,2024
16:15 GMT-6
Sign in to participate in a fun event
test editor
Past
Sun, Mar 31, 2024
16:15 - 16:30 GMT-6

The prosemirror-markdown package defines a ProseMirror schema that can express exactly the things that can be expressed in Markdown. It also comes with a parser and serializer that convert documents in this schema to and from Markdown text.


To abstract the actual editor, we first create a simple interface around a textarea:

class MarkdownView {
  constructor(target, content) {
    this.textarea = target.appendChild(document.createElement("textarea"))
    this.textarea.value = content
  }

  get content() { return this.textarea.value }
  focus() { this.textarea.focus() }
  destroy() { this.textarea.remove() }
}