How to use the @webiny/app-page-builder/editor/redux.createAction function in @webiny/app-page-builder

To help you get started, we’ve selected a few @webiny/app-page-builder 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
export const focusSlateEditor = createAction(FOCUS_SLATE_EDITOR);
addReducer([FOCUS_SLATE_EDITOR], "ui.slateFocused", () => true);

export const blurSlateEditor = createAction(BLUR_SLATE_EDITOR);
addReducer([BLUR_SLATE_EDITOR], "ui.slateFocused", () => false);

export const dragStart = createAction(DRAG_START);
addReducer([DRAG_START], "ui.dragging", () => true);

export const dragEnd = createAction(DRAG_END);
addReducer([DRAG_END], "ui.dragging", () => false);

export const elementCreated = createAction(ELEMENT_CREATED);

export const updateElement = createAction(UPDATE_ELEMENT);
addReducer(
    [UPDATE_ELEMENT],
    action => {
        const { element } = action.payload;
        if (element.type === "document") {
            return "page.content";
        }
        // .slice(2) removes `0.` from the beginning of the generated path
        return "page.content." + action.payload.element.path.replace(/\./g, ".elements.").slice(2);
    },
    (state, action) => {
        const { element, merge = false } = action.payload;
        if (element.elements && typeof element.elements[0] === "string") {
            delete element["elements"];
        }
        updateChildPaths(element);
github webiny / webiny-js / packages / app-page-builder / src / editor / actions / actions.js View on Github external
return action.payload.element;
});

export const deactivateElement = createAction(DEACTIVATE_ELEMENT);
addReducer([DEACTIVATE_ELEMENT], "ui.activeElement", () => null);

export const focusSlateEditor = createAction(FOCUS_SLATE_EDITOR);
addReducer([FOCUS_SLATE_EDITOR], "ui.slateFocused", () => true);

export const blurSlateEditor = createAction(BLUR_SLATE_EDITOR);
addReducer([BLUR_SLATE_EDITOR], "ui.slateFocused", () => false);

export const dragStart = createAction(DRAG_START);
addReducer([DRAG_START], "ui.dragging", () => true);

export const dragEnd = createAction(DRAG_END);
addReducer([DRAG_END], "ui.dragging", () => false);

export const elementCreated = createAction(ELEMENT_CREATED);

export const updateElement = createAction(UPDATE_ELEMENT);
addReducer(
    [UPDATE_ELEMENT],
    action => {
        const { element } = action.payload;
        if (element.type === "document") {
            return "page.content";
        }
        // .slice(2) removes `0.` from the beginning of the generated path
        return "page.content." + action.payload.element.path.replace(/\./g, ".elements.").slice(2);
    },
    (state, action) => {
github webiny / webiny-js / packages / app-page-builder / src / editor / actions / actions.js View on Github external
export const deactivateElement = createAction(DEACTIVATE_ELEMENT);
addReducer([DEACTIVATE_ELEMENT], "ui.activeElement", () => null);

export const focusSlateEditor = createAction(FOCUS_SLATE_EDITOR);
addReducer([FOCUS_SLATE_EDITOR], "ui.slateFocused", () => true);

export const blurSlateEditor = createAction(BLUR_SLATE_EDITOR);
addReducer([BLUR_SLATE_EDITOR], "ui.slateFocused", () => false);

export const dragStart = createAction(DRAG_START);
addReducer([DRAG_START], "ui.dragging", () => true);

export const dragEnd = createAction(DRAG_END);
addReducer([DRAG_END], "ui.dragging", () => false);

export const elementCreated = createAction(ELEMENT_CREATED);

export const updateElement = createAction(UPDATE_ELEMENT);
addReducer(
    [UPDATE_ELEMENT],
    action => {
        const { element } = action.payload;
        if (element.type === "document") {
            return "page.content";
        }
        // .slice(2) removes `0.` from the beginning of the generated path
        return "page.content." + action.payload.element.path.replace(/\./g, ".elements.").slice(2);
    },
    (state, action) => {
        const { element, merge = false } = action.payload;
        if (element.elements && typeof element.elements[0] === "string") {
            delete element["elements"];
github webiny / webiny-js / packages / app-page-builder / src / editor / actions / actions.js View on Github external
const alreadyActive = typePlugins.findIndex(pl => pl.name === plugin.name);

    if (alreadyActive > -1) {
        typePlugins = dotProp.delete(typePlugins, alreadyActive);
    }

    return dotProp.set(state, `${plugin.type}`, typePlugins);
});

export const highlightElement = createAction(HIGHLIGHT_ELEMENT, { log: false });
addReducer([HIGHLIGHT_ELEMENT], "ui.highlightElement", (state, action) => {
    return action.payload.element ? action.payload.element : null;
});

export const activateElement = createAction(ACTIVATE_ELEMENT);
addReducer([ACTIVATE_ELEMENT], "ui.activeElement", (state, action) => {
    return action.payload.element;
});

export const deactivateElement = createAction(DEACTIVATE_ELEMENT);
addReducer([DEACTIVATE_ELEMENT], "ui.activeElement", () => null);

export const focusSlateEditor = createAction(FOCUS_SLATE_EDITOR);
addReducer([FOCUS_SLATE_EDITOR], "ui.slateFocused", () => true);

export const blurSlateEditor = createAction(BLUR_SLATE_EDITOR);
addReducer([BLUR_SLATE_EDITOR], "ui.slateFocused", () => false);

export const dragStart = createAction(DRAG_START);
addReducer([DRAG_START], "ui.dragging", () => true);
github webiny / webiny-js / packages / app-page-builder / src / editor / actions / actions.js View on Github external
}

    return dotProp.set(state, `${plugin.type}`, typePlugins);
});

export const highlightElement = createAction(HIGHLIGHT_ELEMENT, { log: false });
addReducer([HIGHLIGHT_ELEMENT], "ui.highlightElement", (state, action) => {
    return action.payload.element ? action.payload.element : null;
});

export const activateElement = createAction(ACTIVATE_ELEMENT);
addReducer([ACTIVATE_ELEMENT], "ui.activeElement", (state, action) => {
    return action.payload.element;
});

export const deactivateElement = createAction(DEACTIVATE_ELEMENT);
addReducer([DEACTIVATE_ELEMENT], "ui.activeElement", () => null);

export const focusSlateEditor = createAction(FOCUS_SLATE_EDITOR);
addReducer([FOCUS_SLATE_EDITOR], "ui.slateFocused", () => true);

export const blurSlateEditor = createAction(BLUR_SLATE_EDITOR);
addReducer([BLUR_SLATE_EDITOR], "ui.slateFocused", () => false);

export const dragStart = createAction(DRAG_START);
addReducer([DRAG_START], "ui.dragging", () => true);

export const dragEnd = createAction(DRAG_END);
addReducer([DRAG_END], "ui.dragging", () => false);

export const elementCreated = createAction(ELEMENT_CREATED);
github webiny / webiny-js / packages / app-page-builder / src / editor / actions / actions.js View on Github external
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);
    }

    return dotProp.set(state, `${plugin.type}`, typePlugins);
});

export const highlightElement = createAction(HIGHLIGHT_ELEMENT, { log: false });
addReducer([HIGHLIGHT_ELEMENT], "ui.highlightElement", (state, action) => {
    return action.payload.element ? action.payload.element : null;
});

export const activateElement = createAction(ACTIVATE_ELEMENT);
addReducer([ACTIVATE_ELEMENT], "ui.activeElement", (state, action) => {
    return action.payload.element;
});

export const deactivateElement = createAction(DEACTIVATE_ELEMENT);
addReducer([DEACTIVATE_ELEMENT], "ui.activeElement", () => null);

export const focusSlateEditor = createAction(FOCUS_SLATE_EDITOR);
addReducer([FOCUS_SLATE_EDITOR], "ui.slateFocused", () => true);

export const blurSlateEditor = createAction(BLUR_SLATE_EDITOR);
github webiny / webiny-js / packages / app-page-builder / src / editor / actions / actions.js View on Github external
});

export const highlightElement = createAction(HIGHLIGHT_ELEMENT, { log: false });
addReducer([HIGHLIGHT_ELEMENT], "ui.highlightElement", (state, action) => {
    return action.payload.element ? action.payload.element : null;
});

export const activateElement = createAction(ACTIVATE_ELEMENT);
addReducer([ACTIVATE_ELEMENT], "ui.activeElement", (state, action) => {
    return action.payload.element;
});

export const deactivateElement = createAction(DEACTIVATE_ELEMENT);
addReducer([DEACTIVATE_ELEMENT], "ui.activeElement", () => null);

export const focusSlateEditor = createAction(FOCUS_SLATE_EDITOR);
addReducer([FOCUS_SLATE_EDITOR], "ui.slateFocused", () => true);

export const blurSlateEditor = createAction(BLUR_SLATE_EDITOR);
addReducer([BLUR_SLATE_EDITOR], "ui.slateFocused", () => false);

export const dragStart = createAction(DRAG_START);
addReducer([DRAG_START], "ui.dragging", () => true);

export const dragEnd = createAction(DRAG_END);
addReducer([DRAG_END], "ui.dragging", () => false);

export const elementCreated = createAction(ELEMENT_CREATED);

export const updateElement = createAction(UPDATE_ELEMENT);
addReducer(
    [UPDATE_ELEMENT],
github webiny / webiny-js / packages / app-page-builder / src / editor / actions / actions.js View on Github external
);

/************************* SAVE REVISION *************************/
let lastSavedRevision = null;
const dataChanged = revision => {
    if (!lastSavedRevision) {
        return true;
    }

    const { content, ...other } = revision;
    const { content: lastContent, ...lastOther } = lastSavedRevision;

    return !isEqual(content, lastContent) || !isEqual(other, lastOther);
};

export const saveRevision = createAction(SAVING_REVISION);
let debouncedSave = null;
addMiddleware(
    [UPDATE_REVISION, UPDATE_ELEMENT, DELETE_ELEMENT, "@@redux-undo/UNDO", "@@redux-undo/REDO"],
    ({ store, next, action }) => {
        next(action);

        const { onFinish } = action.meta || {};

        if (action.type === UPDATE_ELEMENT && action.payload.history === false) {
            return;
        }

        const page = getPage(store.getState());
        if (page.locked) {
            return;
        }
github webiny / webiny-js / packages / app-page-builder / src / editor / actions / actions.js View on Github external
const alreadyActive = typePlugins.findIndex(pl => pl.name === plugin.name);

    if (alreadyActive > -1) {
        typePlugins = dotProp.delete(typePlugins, alreadyActive);
    } else {
        if (closeOtherInGroup) {
            typePlugins = [{ name, params }];
        } else {
            typePlugins.push({ name, params });
        }
    }

    return dotProp.set(state, `${plugin.type}`, typePlugins);
});

export const deactivatePlugin = createAction(DEACTIVATE_PLUGIN);
addReducer([DEACTIVATE_PLUGIN], "ui.plugins", (state, action) => {
    const { name } = 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);
github webiny / webiny-js / packages / app-page-builder / src / editor / actions / actions.js View on Github external
addReducer([HIGHLIGHT_ELEMENT], "ui.highlightElement", (state, action) => {
    return action.payload.element ? action.payload.element : null;
});

export const activateElement = createAction(ACTIVATE_ELEMENT);
addReducer([ACTIVATE_ELEMENT], "ui.activeElement", (state, action) => {
    return action.payload.element;
});

export const deactivateElement = createAction(DEACTIVATE_ELEMENT);
addReducer([DEACTIVATE_ELEMENT], "ui.activeElement", () => null);

export const focusSlateEditor = createAction(FOCUS_SLATE_EDITOR);
addReducer([FOCUS_SLATE_EDITOR], "ui.slateFocused", () => true);

export const blurSlateEditor = createAction(BLUR_SLATE_EDITOR);
addReducer([BLUR_SLATE_EDITOR], "ui.slateFocused", () => false);

export const dragStart = createAction(DRAG_START);
addReducer([DRAG_START], "ui.dragging", () => true);

export const dragEnd = createAction(DRAG_END);
addReducer([DRAG_END], "ui.dragging", () => false);

export const elementCreated = createAction(ELEMENT_CREATED);

export const updateElement = createAction(UPDATE_ELEMENT);
addReducer(
    [UPDATE_ELEMENT],
    action => {
        const { element } = action.payload;
        if (element.type === "document") {

@webiny/app-page-builder

[![](https://img.shields.io/npm/dw/@webiny/app-page-builder.svg)](https://www.npmjs.com/package/@webiny/app-page-builder) [![](https://img.shields.io/npm/v/@webiny/app-page-builder.svg)](https://www.npmjs.com/package/@webiny/app-page-builder) [![code sty

MIT
Latest version published 20 days ago

Package Health Score

78 / 100
Full package analysis

Similar packages