How to use the @webiny/app-page-builder/editor/selectors.getParentElementWithChildren 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 / plugins / elements / column / index.js View on Github external
const splitColumn = (source, target) => {
    let dispatchNew = false;
    let row = getParentElementWithChildren(redux.store.getState(), target.id);
    // $FlowFixMe
    const targetIndex = row.elements.findIndex(el => el.id === target.id);

    // Split target column in half
    // $FlowFixMe
    row.elements[targetIndex].data.width /= 2;

    // Create a new column with half of the original target width
    let newColumn;
    if (source.path) {
        // $FlowFixMe
        newColumn = cloneElement(source);
    } else {
        dispatchNew = true;
        newColumn = createColumn();
    }
github webiny / webiny-js / packages / app-page-builder / src / editor / actions / actions.js View on Github external
addMiddleware([DELETE_ELEMENT], ({ store, next, action }) => {
    next(action);

    store.dispatch(deactivateElement());
    const state = store.getState();

    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;
    }
github webiny / webiny-js / packages / app-page-builder / src / editor / plugins / elements / column / index.js View on Github external
canDelete({ element }) {
            const parent = getParentElementWithChildren(redux.store.getState(), element.id);
            return parent.elements.length > 1;
        },
        onReceived({ source, target, position = null }) {
github webiny / webiny-js / packages / app-page-builder / src / editor / plugins / elementSettings / clone / CloneAction.js View on Github external
duplicate: ({ element }) => () => {
            const state = redux.store.getState();
            element = getElementWithChildren(state, element.id);
            const parent = getParentElementWithChildren(state, element.id);
            const position = parent.elements.findIndex(el => el.id === element.id) + 1;

            const newElement = set(parent, "elements", [
                ...parent.elements.slice(0, position),
                cloneElement(element),
                ...(position < parent.elements.length ? parent.elements.slice(position) : [])
            ]);
            return redux.store.dispatch(updateElement({ element: newElement }));
        }
    })

@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 11 days ago

Package Health Score

78 / 100
Full package analysis

Similar packages