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.8k stars 1.12k forks source link

Lag when changing to preview #714

Open ryanmavilia opened 5 years ago

ryanmavilia commented 5 years ago

I am using the following code to render a SimpleMDE instance that I want just for rendering the text with no ability for the user to edit because it's the view page. Unfortunately it is a noticeable "switch" from the normal mode to the preview only. The text comes from the variable note_body and the behavior persists if I change that to be pure text.

<textarea id="main_text" name="main_text" oninput="this.editor.update()" rows="4">
     <%- note_body %>
</textarea>
            <script>
                var simplemde = new SimpleMDE({
                   autofocus: true,
                   element: document.getElementById("main_text"),
                   placeholder: "Type here...",
                   promptURLs: true,
                   renderingConfig: {
                   singleLineBreaks: false,
                       codeSyntaxHighlighting: true,
                        },
                   tabSize: 4,
                   toolbar: false,
                    }).togglePreview();
                </script>

This is what it looks like when I load the page.

ezgif com-gif-maker 1

Is it an issue of the way I am going about having it be preview only? Or is it just because it takes a bit of time to load SimpleMDE?