How to use the @webiny/app-page-builder/editor/components.withKeyHandler 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 / elementSettings / advanced / AdvancedSettings.js View on Github external
)}
                
            
        );
    }
}

export default compose(
    connect(
        state => ({
            open: isPluginActive("pb-page-element-settings-advanced")(state)
        }),
        { updateElement, deactivatePlugin }
    ),
    withActiveElement({ shallow: true }),
    withKeyHandler(),
    withHandlers({
        closeDialog: ({ deactivatePlugin }) => () => {
            deactivatePlugin({ name: "pb-page-element-settings-advanced" });
        }
    }),
    withHandlers({
        onSubmit: ({ element, updateElement, closeDialog }) => (formData: Object) => {
            // Get element settings plugins
            const plugins = getPlugins("pb-page-element-advanced-settings").filter(
                pl => pl.elementType === element.type
            );
            formData = plugins.reduce((formData, pl) => {
                if (pl.onSave) {
                    return pl.onSave(formData);
                }
                return formData;
github webiny / webiny-js / packages / app-page-builder / src / editor / plugins / defaultBar / components / PageSettings.js View on Github external
)}
                    
                
            
        
    );
};

export default compose(
    connect(
        state => ({ page: omit(getPage(state), ["content"]) }),
        { deactivatePlugin, updateRevision }
    ),
    withSnackbar(),
    withKeyHandler(),
    withState("active", "setActive", "pb-editor-page-settings-general"),
    withHandlers({
        savePage: ({ showSnackbar, updateRevision }) => (page: Object) =>
            updateRevision(page, {
                onFinish: () => showSnackbar("Settings saved")
            })
    }),
    lifecycle({
        componentDidMount() {
            this.props.addKeyHandler("escape", e => {
                e.preventDefault();
                this.props.deactivatePlugin({ name: "pb-editor-page-settings-bar" });
            });
        },
        componentWillUnmount() {
            this.props.removeKeyHandler("escape");
github webiny / webiny-js / packages / app-page-builder / src / editor / components / Editor / Editor.js View on Github external
connect(
        state => {
            const ui: Object = getUi(state);

            return {
                slateFocused: ui.slateFocused,
                isDragging: ui.dragging,
                isResizing: ui.resizing
            };
        },
        {
            undo: ActionCreators.undo,
            redo: ActionCreators.redo
        }
    ),
    withKeyHandler(),
    lifecycle({
        componentDidMount() {
            const { addKeyHandler, undo, redo } = this.props;
            addKeyHandler("mod+z", e => {
                if (!this.props.slateFocused) {
                    e.preventDefault();
                    undo();
                }
            });
            addKeyHandler("mod+shift+z", e => {
                if (!this.props.slateFocused) {
                    e.preventDefault();
                    redo();
                }
            });
        },
github webiny / webiny-js / packages / app-page-builder / src / editor / components / Editor / Toolbar.js View on Github external
position: "fixed",
        top: 64,
        width: "490px !important",
        maxWidth: "490px !important",
        ".mdc-drawer__content": {
            width: "100%"
        }
    }
});

const drawerKeyHandler = compose(
    connect(
        null,
        { deactivatePlugin }
    ),
    withKeyHandler(),
    lifecycle({
        componentDidUpdate({ active, name }) {
            if (!active && this.props.active) {
                this.props.addKeyHandler("escape", e => {
                    e.preventDefault();
                    this.props.deactivatePlugin({ name });
                });
            }

            if (active && !this.props.active) {
                this.props.removeKeyHandler("escape");
            }
        }
    })
);
github webiny / webiny-js / packages / app-page-builder / src / editor / plugins / toolbar / onboarding / Onboarding.js View on Github external
);
    }
}

export default compose(
    connect(
        state => ({
            showOnboarding: isPluginActive("pb-editor-toolbar-onboarding")(state)
        }),
        { deactivatePlugin }
    ),
    withKeyHandler(),
    withHandlers({
        closeDialog: ({ deactivatePlugin }) => () => {
            deactivatePlugin({ name: "pb-editor-toolbar-onboarding" });
        }
    }),
    lifecycle({
        componentDidUpdate() {
            const { showOnboarding, addKeyHandler, removeKeyHandler, closeDialog } = this.props;
            showOnboarding ? addKeyHandler("escape", closeDialog) : removeKeyHandler("escape");
        }
    })
)(Onboarding);

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

Package Health Score

80 / 100
Full package analysis

Similar packages