How to use webiny-plugins - 10 common examples

To help you get started, we’ve selected a few webiny-plugins examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / packages / demo-api / src / install / install.js View on Github external
// @flow
import config from "./../configs";
import { registerPlugins } from "webiny-plugins";
import install from "webiny-install";

import securityPlugins from "webiny-api-security/install/plugins";
import cmsPlugins from "webiny-api-cms/install/plugins";

registerPlugins(securityPlugins, cmsPlugins);

export default async () => {
    await install({
        config: await config(),
        cms: { copyFiles: true, copyFilesTo: "../../__static" }, // TODO: handled by the CLI install
        security: { admin: { email: "admin@webiny.com", password: "12345678" } }
    });
    process.exit();
};
github webiny / webiny-js / packages / webiny-app-forms / src / admin / components / FormEditor / EditTab / useEditTab.js View on Github external
if (fields[pos.row].length === 0) {
                    fields.splice(pos.row, 1);
                    if (pos.row < row) {
                        createAtRef.current.row--;
                    }
                }

                return insertField(fieldData, createAtRef.current, { ...state, fields });
            });

            return;
        }

        // Find field plugin which handles the dropped field type "id".
        const plugin = getPlugins("form-editor-field-type").find(pl => pl.fieldType.id === type);
        const data = plugin.fieldType.createField();
        insertField(data, createAtRef.current);
    }
github webiny / webiny-js / packages / webiny-app-cms / src / editor / plugins / elementSettings / advanced / index.js View on Github external
middleware: ({ store, action, next }: Object) => {
            const { element, source } = action.payload;

            next(action);

            // Check the source of the element (could be `saved` element which behaves differently from other elements)
            const sourcePlugin = getPlugin(source.type);
            if (!sourcePlugin) {
                return;
            }
            const { onCreate } = sourcePlugin;
            if (!onCreate || onCreate !== "skip") {
                // If source element does not define a specific `onCreate` behavior - continue with the actual element plugin
                const plugin = getPlugin(element.type);
                if (!plugin) {
                    return;
                }
                const { onCreate } = plugin;
                if (onCreate && onCreate === "open-settings") {
                    store.dispatch(activateElement({ element: element.id }));
                    store.dispatch(togglePlugin({ name: "cms-element-settings-advanced" }));
                }
            }
github webiny / webiny-js / packages / webiny-cli / src / init / template / packages / admin / src / App.js View on Github external
import { hot } from "react-hot-loader";
import React, { cloneElement, Fragment } from "react";
import { UiProvider } from "webiny-app/context/ui";
import { registerPlugins, getPlugins } from "webiny-plugins";
import { Theme as AdminTheme } from "webiny-admin";
import { CmsProvider } from "webiny-app-cms/context";
import { CircularProgress } from "webiny-ui/Progress";
import { Security } from "webiny-app-security/components";
import Login from "webiny-app-security/admin/views/Login";
import myTheme from "theme";
import "./App.scss";
import plugins from "./plugins";

// Register all plugins
registerPlugins(plugins);

// Execute `init` plugins, they may register more plugins dynamically
getPlugins("webiny-init").forEach(plugin => plugin.callback());

const App = () => {
    return (
        /* UiProvider is a simple provider for UI state (dialogs, snackbars, dark theme, ...). */
        
            {/* Security components handles user authentication. */}
            
                {({ initialLoad, authenticated, notAuthenticated }) => (
                    
                        {/* AdminTheme handles the Dark/Light theme switching and initialization. */}
                        
                            {/* Render a loader during initial load of user data */}
                            {initialLoad()}
github webiny / webiny-js / packages / demo-service-security / src / handler.js View on Github external
// @flow
import { registerPlugins } from "webiny-plugins";
import { createHandler as createBaseHandler } from "webiny-api";
import createConfig from "demo-service-config";
import plugins from "./plugins";

registerPlugins(plugins);

export const handler = async (event: Object, context: Object) => {
    const config = await createConfig();
    const apolloHandler = await createBaseHandler(config);
    return apolloHandler(event, context);
};
github webiny / webiny-js / packages / webiny-app-page-builder / src / admin / index.js View on Github external
if (route.path.startsWith("/page-builder/pages") && !loaded.render) {
        const renderPlugins = await import("webiny-app-page-builder/render/presets/default");
        registerPlugins(renderPlugins.default);

        loaded.render = true;
    }

    // If we are on the Editor route, import plugins required to render both editor and preview.
    if (route.path.startsWith("/page-builder/editor") && !loaded.editor) {
        const plugins = await Promise.all(
            [
                import("webiny-app-page-builder/editor/presets/default"),
                !loaded.render ? import("webiny-app-page-builder/render/presets/default") : null
            ].filter(Boolean)
        );
        registerPlugins(plugins.map(p => p.default));

        loaded.editor = true;
        loaded.render = true;
    }

    next();
};
github webiny / webiny-js / packages / demo-service-headless / src / handler.js View on Github external
// @flow
import { registerPlugins } from "webiny-plugins";
import { createHandler as createBaseHandler } from "webiny-api";
import servicePlugins from "webiny-api/plugins/service";
import securityPlugins from "webiny-api-security/plugins/service";
import headlessPlugins from "webiny-api-headless/plugins";
import createConfig from "demo-service-config";

registerPlugins(servicePlugins, securityPlugins, headlessPlugins);

/**
 * `createHandler(context)` - function which returns an actual handler function.
 */
export const createHandler = async (context: Object) => {
    const config = await createConfig(context);
    return await createBaseHandler(config);
};
github webiny / webiny-js / packages / webiny-app-page-builder / src / admin / index.js View on Github external
export const lazyLoadMiddleware = () => async (params: Object, next: Function) => {
    const { route } = params;

    // If we are on pages list route, import plugins required to render the page content.
    if (route.path.startsWith("/page-builder/pages") && !loaded.render) {
        const renderPlugins = await import("webiny-app-page-builder/render/presets/default");
        registerPlugins(renderPlugins.default);

        loaded.render = true;
    }

    // If we are on the Editor route, import plugins required to render both editor and preview.
    if (route.path.startsWith("/page-builder/editor") && !loaded.editor) {
        const plugins = await Promise.all(
            [
                import("webiny-app-page-builder/editor/presets/default"),
                !loaded.render ? import("webiny-app-page-builder/render/presets/default") : null
            ].filter(Boolean)
        );
        registerPlugins(plugins.map(p => p.default));

        loaded.editor = true;
        loaded.render = true;
github webiny / webiny-js / packages / webiny-cli / src / init / template / packages / api / src / handler.js View on Github external
// @flow
import { registerPlugins } from "webiny-plugins";
import { createHandler as createBaseHandler } from "webiny-api";
import createConfig from "./configs";
import plugins from "./plugins";

registerPlugins(plugins);

/**
 * `createHandler(context)` - function which returns an actual handler function.
 */
export const createHandler = async (context: Object) => {
    const config = await createConfig(context);
    return await createBaseHandler(config);
};
github webiny / webiny-js / packages / webiny-app-page-builder / src / admin / components / EditorPluginsLoader.js View on Github external
async function loadPlugins() {
        // If we are on pages list route, import plugins required to render the page content.
        if (location.pathname.startsWith("/page-builder/pages") && !loaded.render) {
            const renderPlugins = await import("webiny-app-page-builder/render/presets/default");
            registerPlugins(renderPlugins.default);

            globalState.render = true;
            setLoaded({ render: true });
        }

        // If we are on the Editor route, import plugins required to render both editor and preview.
        if (location.pathname.startsWith("/page-builder/editor") && !loaded.editor) {
            const plugins = await Promise.all(
                [
                    import("webiny-app-page-builder/editor/presets/default"),
                    !loaded.render ? import("webiny-app-page-builder/render/presets/default") : null
                ].filter(Boolean)
            );
            registerPlugins(plugins.map(p => p.default));

            globalState.editor = true;

webiny-plugins

A simple registry that stores all plugins in a shared object.

MIT
Latest version published 5 years ago

Package Health Score

66 / 100
Full package analysis