UNPKG

@wordpress/block-editor

Version:
120 lines (103 loc) 2.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.__experimentalUpdateSettings = __experimentalUpdateSettings; exports.hideBlockInterface = hideBlockInterface; exports.setBlockEditingMode = setBlockEditingMode; exports.showBlockInterface = showBlockInterface; exports.unsetBlockEditingMode = unsetBlockEditingMode; var _element = require("@wordpress/element"); /** * WordPress dependencies */ /** * A list of private/experimental block editor settings that * should not become a part of the WordPress public API. * BlockEditorProvider will remove these settings from the * settings object it receives. * * @see https://github.com/WordPress/gutenberg/pull/46131 */ const privateSettings = ['inserterMediaCategories', 'blockInspectorAnimation']; /** * Action that updates the block editor settings and * conditionally preserves the experimental ones. * * @param {Object} settings Updated settings * @param {boolean} stripExperimentalSettings Whether to strip experimental settings. * @return {Object} Action object */ function __experimentalUpdateSettings(settings, stripExperimentalSettings = false) { let cleanSettings = settings; // There are no plugins in the mobile apps, so there is no // need to strip the experimental settings: if (stripExperimentalSettings && _element.Platform.OS === 'web') { cleanSettings = {}; for (const key in settings) { if (!privateSettings.includes(key)) { cleanSettings[key] = settings[key]; } } } return { type: 'UPDATE_SETTINGS', settings: cleanSettings }; } /** * Hides the block interface (eg. toolbar, outline, etc.) * * @return {Object} Action object. */ function hideBlockInterface() { return { type: 'HIDE_BLOCK_INTERFACE' }; } /** * Shows the block interface (eg. toolbar, outline, etc.) * * @return {Object} Action object. */ function showBlockInterface() { return { type: 'SHOW_BLOCK_INTERFACE' }; } /** * @typedef {import('../components/block-editing-mode').BlockEditingMode} BlockEditingMode */ /** * Sets the block editing mode for a given block. * * @see useBlockEditingMode * * @param {string} clientId The block client ID, or `''` for the root container. * @param {BlockEditingMode} mode The block editing mode. One of `'disabled'`, * `'contentOnly'`, or `'default'`. * * @return {Object} Action object. */ function setBlockEditingMode(clientId = '', mode) { return { type: 'SET_BLOCK_EDITING_MODE', clientId, mode }; } /** * Clears the block editing mode for a given block. * * @see useBlockEditingMode * * @param {string} clientId The block client ID, or `''` for the root container. * * @return {Object} Action object. */ function unsetBlockEditingMode(clientId = '') { return { type: 'UNSET_BLOCK_EDITING_MODE', clientId }; } //# sourceMappingURL=private-actions.js.map