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.47k stars 320 forks source link

Pluggable dialog implementations #395

Open mscharley opened 2 years ago

mscharley commented 2 years ago

Is your feature request related to a problem? Please describe.

I'm working on an electron app and I would like to use the options to prompt the user for link/image url's but Electron will not implement the prompt() API.

Describe the solution you'd like

It would be cool if I could provide an alternative implementation of these dialog API's using in-browser dialogs instead of the native dialogs for environments that don't support them.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context

I feel like for everyone's sake, simpler is better here - stick to the API defined by the browsers, just take an extra option or two so you can provide an implementation of prompt() and any other similar functions (alert() and confirm() are the other two, but I'm not sure if this library actually uses them). This extra option can then just default back to the browser API if nothing is provided, eg. config.prompt || browser.prompt.

mscharley commented 2 years ago

Hmm, ok, according to the documentation in TypeScript the official definition is:

prompt(message?: string, _default?: string): string | null;

For the sake of being able to do something useful to prompt the user for input, this will probably need to return a Promise or take a callback instead.

Zignature commented 2 years ago

CodeMirror has a dialog plugin that might be useful.

https://codemirror.net/doc/manual.html#addons

https://codemirror.net/addon/dialog/dialog.js