sparksuite / simplemde-markdown-editor

A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving and spell checking.
https://simplemde.com
MIT License
9.79k stars 1.12k forks source link

Cannot read property 'first' of undefined #702

Open vanvanni opened 6 years ago

vanvanni commented 6 years ago

Error

simplemde.min.js:7 Uncaught TypeError: Cannot read property 'first' of undefined
    at new t (simplemde.min.js:7)
    at new e (simplemde.min.js:7)
    at e (simplemde.min.js:7)
    at Function.e.fromTextArea (simplemde.min.js:12)
    at B.render (simplemde.min.js:15)
    at new B (simplemde.min.js:14)
    at add:140

My Code

<script>
        var content = new SimpleMDE({ element: document.getElementById("topiccontent") });
    </script>
vanvanni commented 6 years ago

Fixed: Needed to use a Textarea only controls do not work

repat commented 5 years ago

Same here. Did you figure out a fix?

jonathanlb commented 5 years ago

@repat It looks like the fix is the element argument to the SimpleMDE constructor should be a textarea element (as opposed to a div).

Is it worth putting a DOM-element type check in the SimpleMDE constructor to avoid confusion for new users? I'd be happy to submit a PR.