How to use the @webiny/plugins.getPlugin function in @webiny/plugins

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 / app-page-builder / src / editor / actions / actions.js View on Github external
let { element } = action.payload;
    let parent = getParentElementWithChildren(state, element.id);

    // Remove child from parent
    // $FlowFixMe
    if (!parent) {
        return;
    }

    const index = parent.elements.findIndex(el => el.id === element.id);
    parent = dotProp.delete(parent, "elements." + index);
    store.dispatch(updateElement({ element: parent }));

    // Execute `onChildDeleted` if defined
    const plugin = getPlugin(parent.type);
    if (!plugin) {
        return;
    }

    if (typeof plugin.onChildDeleted === "function") {
        plugin.onChildDeleted({ element: parent, child: element });
    }
});
github webiny / webiny-js / packages / app-page-builder / src / admin / utils / components / EditElementDialog.js View on Github external
(props: Props) => {
        const { open, onClose, onSubmit, plugin: pluginName } = props;

        const plugin = getPlugin(pluginName);

        return (
            <dialog open="{open}">
                {plugin &amp;&amp; (
                    <form>
                        {({ submit, Bind }) =&gt; (
                            
                                Update {plugin.title}
                                
                                    
                                        
                                            
                                                <input label="{&quot;Name&quot;}"></form></dialog>
github webiny / webiny-js / packages / app-page-builder / src / editor / plugins / elementSettings / bar / ElementSettingsBar.js View on Github external
const actions = plugin.settings.map(pl => {
        if (typeof pl === "string") {
            return { plugin: getPlugin(pl || divider), options: {} };
        }

        if (Array.isArray(pl)) {
            return { plugin: getPlugin(pl[0] || divider), options: pl[1] };
        }

        return null;
    });
github webiny / webiny-js / packages / app-page-builder / src / editor / plugins / elementSettings / bar / ElementSettingsBar.js View on Github external
const actions = plugin.settings.map(pl => {
        if (typeof pl === "string") {
            return { plugin: getPlugin(pl || divider), options: {} };
        }

        if (Array.isArray(pl)) {
            return { plugin: getPlugin(pl[0] || divider), options: pl[1] };
        }

        return null;
    });

    return [
        ...actions,
        { plugin: getPlugin("pb-page-element-settings-advanced") },
        { plugin: getPlugin("pb-page-element-settings-save") }
    ].filter(pl => pl);
};
github webiny / webiny-js / packages / app-page-builder / src / editor / plugins / elementSettings / bar / ElementSettingsBar.js View on Github external
const actions = plugin.settings.map(pl => {
        if (typeof pl === "string") {
            return { plugin: getPlugin(pl || divider), options: {} };
        }

        if (Array.isArray(pl)) {
            return { plugin: getPlugin(pl[0] || divider), options: pl[1] };
        }

        return null;
    });

    return [
        ...actions,
        { plugin: getPlugin("pb-page-element-settings-advanced") },
        { plugin: getPlugin("pb-page-element-settings-save") }
    ].filter(pl => pl);
};
github webiny / webiny-js / packages / app-page-builder / src / editor / plugins / elementSettings / bar / ElementSettingsBar.js View on Github external
const actions = plugin.settings.map(pl => {
        if (typeof pl === "string") {
            return { plugin: getPlugin(pl || divider), options: {} };
        }

        if (Array.isArray(pl)) {
            return { plugin: getPlugin(pl[0] || divider), options: pl[1] };
        }

        return null;
    });
github webiny / webiny-js / packages / app-page-builder / src / editor / plugins / elementSettings / save / SaveAction.js View on Github external
const onSubmit = useHandler(props, ({ element }) => async formData => {
        formData.content = removeIdsAndPaths(cloneDeep(element));

        const meta = await getDataURLImageDimensions(formData.preview);
        const blob = dataURLtoBlob(formData.preview);
        blob.name = "pb-page-element-" + element.id + ".png";

        const fileUploaderPlugin = getPlugin("file-uploader");
        const previewImage = await fileUploaderPlugin.upload(blob, { apolloClient: client });
        previewImage.meta = meta;
        previewImage.meta.private = true;

        const createdImageResponse = await client.mutate({
            mutation: CREATE_FILE,
            variables: {
                data: previewImage
            }
        });

        const createdImage = get(createdImageResponse, "data.files.createFile", {});
        if (createdImage.error) {
            return showSnackbar("Image could not be saved.");
        }
github webiny / webiny-js / packages / app-admin / src / components / FileManager / getFileTypePlugin.js View on Github external
if (!file) {
        return null;
    }

    const plugins = getPlugins("file-manager-file-type");

    let plugin = null;
    for (let i = 0; i &lt; plugins.length; i++) {
        let current = plugins[i];
        if (Array.isArray(current.types) &amp;&amp; current.types.includes(file.type)) {
            plugin = current;
        }
    }

    if (!plugin) {
        plugin = getPlugin("file-manager-file-type-default");
        invariant(plugin, `Missing default "file-manager-file-type" plugin.`);
    }

    return plugin;
}
github webiny / webiny-js / packages / app-page-builder / src / editor / actions / actions.js View on Github external
addReducer([TOGGLE_PLUGIN], "ui.plugins", (state, action) => {
    const { name, params, closeOtherInGroup = false } = action.payload;

    const plugin = getPlugin(name);

    if (!plugin) {
        return state;
    }

    let typePlugins = dotProp.get(state, plugin.type);
    if (!Array.isArray(typePlugins)) {
        typePlugins = [];
    }

    const alreadyActive = typePlugins.findIndex(pl => pl.name === plugin.name);

    if (alreadyActive > -1) {
        typePlugins = dotProp.delete(typePlugins, alreadyActive);
    } else {
        if (closeOtherInGroup) {
github webiny / webiny-js / packages / app-admin / src / components / FileManager / getFileUploader.js View on Github external
export default () => {
    const fileUploaderPlugin = getPlugin("file-uploader");
    return fileUploaderPlugin.upload;
};

@webiny/plugins

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

MIT
Latest version published 19 days ago

Package Health Score

86 / 100
Full package analysis

Similar packages