Closed SebiBasti closed 4 years ago
I'm trying to implement easyMDE in my little project. When I test it in the preview it works as intended:
But when I submit it and then display it again it looks like this:
Somehow it gets rid of all the newlines and I can't figure out why. :-(
<script> var easyMDE = new EasyMDE({ element: document.getElementById("mde"), placeholder: "Write your post here...", autosave: { enabled: true, uniqueId: <%= current_user.id %>, delay: 10000, }, renderingConfig: { codeSyntaxHighlighting: true }, promptURLs: true, toolbar: ["bold", "italic", "strikethrough", "heading", "|", "code", "quote", "clean-block", "|", "link", "image", "|", "unordered-list", "ordered-list", "|", "preview", "side-by-side", "fullscreen", "|", "guide"] }); </script>
<script> var easyMDE = new EasyMDE({ element: document.getElementById("<%=j @id %>"), initialValue: "<%=j @content %>", renderingConfig: { codeSyntaxHighlighting: true }, toolbar: false }); easyMDE.togglePreview(); </script>
I found the mistake. I was attaching easyMDE to a text field and not a text area (I'm using rails).
I changed <%= f.text_field :content, id: 'mde' %> to <%= f.text_area :content, id: 'mde' %>
<%= f.text_field :content, id: 'mde' %>
<%= f.text_area :content, id: 'mde' %>
I'm trying to implement easyMDE in my little project. When I test it in the preview it works as intended:
raw input
preview
But when I submit it and then display it again it looks like this:
Somehow it gets rid of all the newlines and I can't figure out why. :-(
easyMDE for my input
easyMDE for displaying content