UNPKG

@wordpress/blocks

Version:
190 lines (188 loc) 5.79 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // packages/blocks/src/store/actions.js var actions_exports = {}; __export(actions_exports, { __experimentalReapplyBlockFilters: () => __experimentalReapplyBlockFilters, addBlockCollection: () => addBlockCollection, addBlockStyles: () => addBlockStyles, addBlockTypes: () => addBlockTypes, addBlockVariations: () => addBlockVariations, reapplyBlockTypeFilters: () => reapplyBlockTypeFilters, removeBlockCollection: () => removeBlockCollection, removeBlockStyles: () => removeBlockStyles, removeBlockTypes: () => removeBlockTypes, removeBlockVariations: () => removeBlockVariations, setCategories: () => setCategories, setDefaultBlockName: () => setDefaultBlockName, setFreeformFallbackBlockName: () => setFreeformFallbackBlockName, setGroupingBlockName: () => setGroupingBlockName, setUnregisteredFallbackBlockName: () => setUnregisteredFallbackBlockName, updateCategory: () => updateCategory }); module.exports = __toCommonJS(actions_exports); var import_deprecated = __toESM(require("@wordpress/deprecated")); var import_process_block_type = require("./process-block-type"); function addBlockTypes(blockTypes) { return { type: "ADD_BLOCK_TYPES", blockTypes: Array.isArray(blockTypes) ? blockTypes : [blockTypes] }; } function reapplyBlockTypeFilters() { return ({ dispatch, select }) => { const processedBlockTypes = []; for (const [name, settings] of Object.entries( select.getUnprocessedBlockTypes() )) { const result = dispatch((0, import_process_block_type.processBlockType)(name, settings)); if (result) { processedBlockTypes.push(result); } } if (!processedBlockTypes.length) { return; } dispatch.addBlockTypes(processedBlockTypes); }; } function __experimentalReapplyBlockFilters() { (0, import_deprecated.default)( 'wp.data.dispatch( "core/blocks" ).__experimentalReapplyBlockFilters', { since: "6.4", alternative: "reapplyBlockFilters" } ); return reapplyBlockTypeFilters(); } function removeBlockTypes(names) { return { type: "REMOVE_BLOCK_TYPES", names: Array.isArray(names) ? names : [names] }; } function addBlockStyles(blockNames, styles) { return { type: "ADD_BLOCK_STYLES", styles: Array.isArray(styles) ? styles : [styles], blockNames: Array.isArray(blockNames) ? blockNames : [blockNames] }; } function removeBlockStyles(blockName, styleNames) { return { type: "REMOVE_BLOCK_STYLES", styleNames: Array.isArray(styleNames) ? styleNames : [styleNames], blockName }; } function addBlockVariations(blockName, variations) { return { type: "ADD_BLOCK_VARIATIONS", variations: Array.isArray(variations) ? variations : [variations], blockName }; } function removeBlockVariations(blockName, variationNames) { return { type: "REMOVE_BLOCK_VARIATIONS", variationNames: Array.isArray(variationNames) ? variationNames : [variationNames], blockName }; } function setDefaultBlockName(name) { return { type: "SET_DEFAULT_BLOCK_NAME", name }; } function setFreeformFallbackBlockName(name) { return { type: "SET_FREEFORM_FALLBACK_BLOCK_NAME", name }; } function setUnregisteredFallbackBlockName(name) { return { type: "SET_UNREGISTERED_FALLBACK_BLOCK_NAME", name }; } function setGroupingBlockName(name) { return { type: "SET_GROUPING_BLOCK_NAME", name }; } function setCategories(categories) { return { type: "SET_CATEGORIES", categories }; } function updateCategory(slug, category) { return { type: "UPDATE_CATEGORY", slug, category }; } function addBlockCollection(namespace, title, icon) { return { type: "ADD_BLOCK_COLLECTION", namespace, title, icon }; } function removeBlockCollection(namespace) { return { type: "REMOVE_BLOCK_COLLECTION", namespace }; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { __experimentalReapplyBlockFilters, addBlockCollection, addBlockStyles, addBlockTypes, addBlockVariations, reapplyBlockTypeFilters, removeBlockCollection, removeBlockStyles, removeBlockTypes, removeBlockVariations, setCategories, setDefaultBlockName, setFreeformFallbackBlockName, setGroupingBlockName, setUnregisteredFallbackBlockName, updateCategory }); //# sourceMappingURL=actions.js.map