Zulko / eagle.js

A hackable slideshow framework built with Vue.js
https://zulko.github.io/eaglejs-demo/
ISC License
4.08k stars 223 forks source link

Add extension system #75

Closed yaodingyd closed 5 years ago

yaodingyd commented 5 years ago

The PR aims to help solve the issue of unnecessary to core yet useful addition to Eagle.js ecosystem.

Here I propose a new concept: extensitions. It includes two categories, namely widgets and plugins.

  1. Widgets are the Vue component that can be used in a slide.
  2. Plugins are used mostly in slideshow to enhance slide.

Both widgets and plugins have the same interface to use, just like how Vue uses plugins, for example

// plugin
Eagle.use(Zoom, {scale: 2})
// Widget
Eagle.use(CodeBlock)

To do this I have extract the two main plugins (presenter mode and zoom) into their own files.

Plugin

Plugins are used mostly by "config", like how we "use" Eagle.js. A plugin has three common properties: init, destroy and isPlugin. For each plugin, init is called after slideshow is mounted, and destroy is called before slideshow destroys.

Widget

We can still use widget like the old way:

Vue.component(widget.name, widget)

The new Eagle.use is just a wrapper of the above call.

I really appreciate if @Zulko can take a look!

Zulko commented 5 years ago

I agree that UX features like presenter mode and zoom could be in their own extension. I don't see the advantage of widgets like codeblocks as plugins though, they would rather be classical Vue components (possibly provided by a library external to Vue).

yaodingyd commented 5 years ago

Widget behavior stays the same and they are not plugins. I added the extension wrapper to make the interface identical so user can use a widget/plugin the same way as how the user could use a Vue plugin. If you feel like this is redundant then I think just splitting out plugins is a good start.

Zulko commented 5 years ago

Sorry never got back to this. I'm fine with PR this if you want to merge.

yaodingyd commented 5 years ago

@Zulko Thanks! I'll add more documentation and merge ASAP.