Plugins

The Client SDK is composed of the main Weavy() instance plus additional plugins that each provides their own functionality and settings.

You may use the core package or the extended package depending on your needs. All the plugins that are included in you package are enabled by default.

Core plugins

Weavy comes with several built-in plugins. You can enable/disable and configure them or replace them with your own custom plugins.

The core package includes a basic setup of plugins needed to integrate weavy panels into your webapp.

AlertDisplaying alerts with messages.
AttachFunctionality for attaching files from dropbox, O365, Google etc.
AuthenticationSign in functionality when not using SSO.
PanelsManager for creating and handling panels.
PreviewDisplaying images and documents in full browser window.
SSO (Single Sign On)Using JWT for providing seamless authentication.
ThemeLoading and injecting styles into the Client.

Extended plugins

The extended package includes all the core plugins and a bigger set of plugins required to use the full Drop-In UI

BadgeHandles badges for notifications and messages.
BubblesState machine for handling spaces connected to urls.
ContextConnect spaces to urls and provide browser context links.
DockThe UI component containing bubble buttons and panel handling.
FallbackOpening panels in popup windows when frames are disallowed.
MessengerThe Weavy Messenger.
NotificationsDisplays notifications in the browser window.
PersonalPanel containing user profile, notifications, stars and drafts.
PositionDock minimizing and drag’n’drop.
StartPanel for the weavy start page for opening spaces and finding people.
UpgradeChecking if new versions of the weavy client are available.

Enabling/Disabling plugins

You can enable or disable a plugin in your options by setting it to true or false.

All enabled plugins will be registered in the weavy.plugins namespace. You can use this to see if a specific plugin is loaded and enabled after you have instantiated Weavy().

Example: enabling the Alert plugin

var weavy = new Weavy({
  plugins: {
    alert: true
  }
});

if (weavy.plugins.alert) {
    weavy.log("The alert plugin is loaded and enabled!")
}

Plugin options

To enable a plugin with options, simply switch true in the plugin options to an {object} instead when creating a new Weavy().

See the documentation for each plugin to see which configuration options that are available for that plugin.

Example: Enabling the SSO plugin and specifying a json web token.

var weavy = new Weavy({
  plugins: {
    sso: {
        jwt: "JSON_WEB_TOKEN"
    }
  }
});

Adding new plugins

The preferred way of extending Weavy client SDK with code, events and communication is by creating your own plugin.

You write your code the same way that you would if you were using the Weavy instance normally. The main advantage is that you get a plugin that is reusable and configurable via options.

Exposing methods and properties

All plugins may add methods or properties to the main Weavy instance. They may also expose methods and properies that are available in the weavy.plugins namespace.

if (weavy.plugins.alert) {
    // Display an alert message
    weavy.plugins.alert.alert("The alert plugin is loaded and enabled!");
}

You may also specify dependencies to other Weavy plugins, to make sure they are available and loaded before your plugin.

Plugin template

This is the minimal structure you need in your plugin for it to be registered and executed. For a more complete guide you chould check out the hello world plugin playground article.

(function ($) {
    /**
     * Your plugin name. This name will be used for registration and options etc.
     */
    var PLUGIN_NAME = "myplugin";

    console.debug("Registering Weavy plugin:", PLUGIN_NAME);

    if (typeof Weavy === 'undefined' || !Weavy.plugins) {
        throw new Error("Weavy must be loaded before registering plugin: " + PLUGIN_NAME);
    }

    Weavy.plugins[PLUGIN_NAME] = function (options) {
        /**
         *  Reference to this instance
         */
        var weavy = this;

        // MY CUSTOM CODE
        // ...

        // Exports
        return {}
    };

    /**
     * Default plugin options
     */
    Weavy.plugins[PLUGIN_NAME].defaults = {
    };

    /**
     * Non-optional dependencies.
     */
    Weavy.plugins[PLUGIN_NAME].dependencies = [];

})(jQuery);

Loading plugins

You just have to load the javascript file of your plugin to get it registered. Make sure to load any custom plugins after weavy.js is loaded and before you make a new Weavy()instance.

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://myweavysite.example/javascript/weavy.js"></script>
<script src="myplugin.js"></script>
<script>var weavy = new Weavy();</script>