Ionaru / easy-markdown-editor

EasyMDE: A simple, beautiful, and embeddable JavaScript Markdown editor. Delightful editing for beginners and experts alike. Features built-in autosaving and spell checking.
https://stackblitz.com/edit/easymde
MIT License
2.39k stars 316 forks source link

Option to set/override editor preview class #99

Closed sn3p closed 5 years ago

sn3p commented 5 years ago

It would be nice to have more control over the preview styling. In our app users can write content (in EasyMDE) and we render this content with specific styling. I want to apply the same styling to the preview in EasyMDE without having to override default styling from .editor-preview and .editor-preview-side.

Proposal

Introduce a classname solely for preview content styling, e.g. .editor-preview-content. And use .editor-preview and .editor-preview-side only for positioning the preview within the editor.

In addition introduce an option to set a custom class(es):

const editor = new EasyMDE({
  // Default class
  previewClass: "editor-preview-content",
  // Custom class
  previewClass: "custom-editor",
  // Default and custom class
  previewClass: ["editor-preview-content", "custom-overrides"],
});

Personally I think editor-preview as default for the content would be better, and use .editor-preview-full and .editor-preview-side for internal display variants.

Alternative solution would be building a separate css file for the bare editor styling, e.g. easymde-nopreview.css. This way we have more control over what styling we import.

Related issues (from SimpleMDE):

Ionaru commented 5 years ago

@sn3p, please have a look at https://github.com/Ionaru/easy-markdown-editor/pull/100, does this work for you?

sn3p commented 5 years ago

Wow thats was quick ⚡️ Thanks, I will check this out ASAP!

sn3p commented 5 years ago

@Ionaru tested and works!