editor

Textarea and forms

Upgrade an existing form without touching the server.

Pass a <textarea> to createEditor and the editor hides it and takes its place. The textarea value is kept in sync on every change and right before the form submits, so your server keeps reading the same field.

<form method="post" action="/board/write">
  <input name="title" required>
  <textarea id="content" name="content"></textarea>
  <button>Post</button>
</form>
<script>
  const editor = Editor82.createEditor('#content', { toolbar: 'board' });
  document.querySelector('form').addEventListener('submit', (e) => {
    if (editor.isEmpty()) { e.preventDefault(); editor.focus(); }
  });
</script>
  • Whatever the textarea already holds becomes the initial content (edit screens).
  • The browser cannot run required on the editor; check isEmpty() as above.
  • editor.destroy() shows the textarea again with the latest HTML.