benweet / stackedit

In-browser Markdown editor
https://stackedit.io/
Apache License 2.0
21.78k stars 2.73k forks source link

Refactor/simplify: Consider using alertify.js or alternatives consistently #602

Open jesperronn opened 10 years ago

jesperronn commented 10 years ago

Stackedit includes Bootstrap which has modals. Modal prompt and confirm dialogs are also available from alertifyjs, and used only in couchdb provider

Many other modal boxes are included the Twitter Bootstrap way, which has grown bodyEditor.html beyond reasonable size. Some of the modals have a content which can be be defined with the simpler prompt/alert/confirm model of alertify.js.

For example (and there could be others)

And there is a special .modal-publish which is one modal serving to prompt for the input of the specifically chosen publishing strategy. This could probably also be changed.

Changing the implementation from Twitter bootstrap html to alertifyjs will give the following advantages:

Now, alertify.js is dead (new maintainer needed), and also has a different visual appearance than Twitter bootstrap modals. Maybe there are alternatives to generate prompt/alert/confirm modals easily without the extraneous markup. Maybe plugins like Bootbox js will give a similar programmatic interface with the same visual appeal.

@benweet, what do you recommend here?

benweet commented 10 years ago

I've added alertify since I needed confirm/prompt popup on top of bootstrap modals (bootbox wouldn't work inside a bootstrap modal). I don't think alertify or bootbox can replace bootstrap modals to build complex dialog with forms.. That said, I agree modal could be built dynamically by different modules.

jesperronn commented 10 years ago

Totally agree that confirm/alert/prompt should not aim to replace complex modals with forms... just the one-liners

Beware that modals on top of modals can be a confusing experience for users, and should be avoided.

Did you have time to consider pull req #595, which could be a driver for moving more stuff out of bodyEditor.htmlwhere needed?

jesperronn commented 9 years ago

Over time, Stackedit source code has grown to a significant size. In order to make Stackedit more customizable, maintainable and modularizable I noticed that anybody who adds or removes functionality, typically ends up editing multiple places.

For instance, you make an extension. This extension is added to core.js as a dependency (or eventMgr or wherever it should be loaded). You also need a modal window. This is added to bodyEditor.html.

Perhaps you also need settings, which must then be added to settings.js, and the HTML for that again added to bodyEditor.html. Same goes if you need local storage or a keyboard shortcut. Different places, different files.

I don't have a prepared solution for all this. But improvements like this can definitely make stackedit easier to maintain, make the code more modularized as such.

A change like this would remove many many lines from the BodyEditor. In my own fork (jesperronn/stackedit) I went from ~1400 to ~450 lines.

More information