Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structure: Modularize build of Stackedit #542

Closed
jesperronn opened this issue Sep 22, 2014 · 6 comments
Closed

Structure: Modularize build of Stackedit #542

jesperronn opened this issue Sep 22, 2014 · 6 comments

Comments

@jesperronn
Copy link

Obviously an enhancement.

Stackedit has grown very big in terms of included javascripts, html, libraries.

As a developer, I want to be able to build only the parts I need. For example, if I don't need Mathjax, I want to be able to create a build without Mathjax.

This will probably require a more clean way to define extensions (or maybe I just have not figured out how to do it the 'right' way).

Let's discuss how the modularity could look. One example could be a /plugins folder with the following structure:

plugins
└── mathjax
    ├── core.js        # any code that should be triggered by the main core.js
    ├── constants.js   # any constants that should be available globally
    ├── eventMgr.js    # any global event that should be triggered/subscribed to
    ├── index.js       # any routes that should be defined
    ├── main.js        # require.js loading of modules
    ├── bower.json     #bower dependencies if needed?
    ├── providers      # define providers here
    ├── publishers     # define publishers here
    ├── synchronizers  # define synchronizers here
    └── views          # all dialogs, new pages, etc should go here

I got this idea when looking at where hooks are added for example for Mathjax, MonetizeJS and Google Picasa integration. There is probably a thing or too I am missing out. For example, where is the correct place to attach browser events (such as click) to DOM elements?

I would like your feedback on this. Also, I am not aware if this structure is already possible. Furthermore, what do you think it would take to make the structure more modularizable?

@jesperronn
Copy link
Author

One other strategy could be to add a node package, like, for instance, stackedit-mathjax. This package could be included in package.json / bower.json.

For example:

  "dependencies": {
    "stackedit-mathjax": "1.0.0",
    ...
}

Still, this would probably require all hooks to work so that the events/functionality can be insert correctly.
@benweet, please advice what you would prefer?

@benweet
Copy link
Owner

benweet commented Oct 4, 2014

To get rid of MathJax, just remove the mathJax extension dependency (which is a RequireJS module by the way) at the beginning of eventMgr.js.

@benweet benweet closed this as completed Oct 4, 2014
@jesperronn
Copy link
Author

Sorry to bother, this is NOT just about getting rid of MathJax. See #549 and #551 for that.This is about Stackedit being more modular, and thus making it easy to add/remove functionality. This will eventually bring faster load times, faster build times and smaller payloads.

I suggest your comment fits better for #549 and #551. Also I cannot see how this issue is solved or addressed? Maybe I am missing a point. I will gladly add to developers guide if you can help me understand how I can easily create a new plugin where all functionality is encapsulated in it's own area (folder, dependency, or similar).

Please, once again, help me understand :)

@benweet
Copy link
Owner

benweet commented Oct 4, 2014

Indeed, I've read too quickly, sorry about that.

I guess your question is about refactoring the whole project. StackEdit is organized around few big modules like core, fileMgr, synchronizer, publisher (as described in the architecture diagram here). These modules are here since the beginning (including the providers and helpers mechanism). After that I tried to create patterns as soon as I added some features, so I ended up with the eventMgr and the extension pattern.

Today, the number of features is quite significant so I guess the best strategy for a whole refactoring is to list each feature and try to define new patterns that could tackle them all (the developer guide describes most of them, but may not be up to date..)

About DOM in general (elements, events, templating...), I guess there are some good frameworks out there (like angular.js) that I didn't consider at that time. Though, it has to be flexible enough to integrate with the editor and the layout modules.

@benweet benweet reopened this Oct 4, 2014
@jesperronn jesperronn changed the title Modularize build of Stackedit Structure: Modularize build of Stackedit Oct 27, 2014
@jesperronn
Copy link
Author

@benweet I have some ideas on how to refactor and modularize, at least for the publisher/synchronizer/provider structure.. Will make a pull-request as WIP (work in progress) so that I can get your input on it.

@benweet
Copy link
Owner

benweet commented Mar 15, 2018

Closing this as too old.

@benweet benweet closed this as completed Mar 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants