easy-markdown-editor icon indicating copy to clipboard operation
easy-markdown-editor copied to clipboard

Pluggable dialog implementations

Open mscharley opened this issue 3 years ago • 2 comments
trafficstars

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 avatar Jan 24 '22 13:01 mscharley

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.

mscharley avatar Jan 24 '22 13:01 mscharley

CodeMirror has a dialog plugin that might be useful.

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

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

Zignature avatar Jan 25 '22 09:01 Zignature