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.32k stars 308 forks source link

Expose the `options` field type #522

Open borodean opened 1 year ago

borodean commented 1 year ago

This PR exposes the EasyMDE.prototype.options field and marks the guaranteed fields as non-nullable.

Ionaru commented 1 year ago

Can you explain why you want access to the options property?

Also changing options usually has no effect after the editor is created, maybe those should be read-only?

borodean commented 1 year ago

Hi, and thank you for an excellent library and a quick reply!

Can you explain why you want access to the options property?

I'm implementing an imageUploadFunction, and to mimic some of the original behavior, it wants to access the resolved options like insertTexts, imageMaxSize etc.

Also changing options usually has no effect after the editor is created, maybe those should be read-only?

If that's the case, I agree. We should make them read-only. Do you want me to push an update?

borodean commented 1 year ago

I'm also unsure whether cherry-picking required fields will be challenging to maintain. Perhaps this would be enough:

options: EasyMDE.Options;

In this case, however, all the work of checking the fields for null/undefined falls on the shoulders of the end users.