Edit File by line
/home/barbar84/www/wp-inclu.../js/dist
File: blocks.js
* manipulate the attributes of a block
[1500] Fix | Delete
* in the context of an editor.
[1501] Fix | Delete
* @property {WPBlockVariation[]} [variations] The list of block variations.
[1502] Fix | Delete
* @property {Object} [example] Example provides structured data for
[1503] Fix | Delete
* the block preview. When not defined
[1504] Fix | Delete
* then no preview is shown.
[1505] Fix | Delete
*/
[1506] Fix | Delete
[1507] Fix | Delete
/**
[1508] Fix | Delete
* Mapping of legacy category slugs to their latest normal values, used to
[1509] Fix | Delete
* accommodate updates of the default set of block categories.
[1510] Fix | Delete
*
[1511] Fix | Delete
* @type {Record<string,string>}
[1512] Fix | Delete
*/
[1513] Fix | Delete
[1514] Fix | Delete
var LEGACY_CATEGORY_MAPPING = {
[1515] Fix | Delete
common: 'text',
[1516] Fix | Delete
formatting: 'text',
[1517] Fix | Delete
layout: 'design'
[1518] Fix | Delete
};
[1519] Fix | Delete
var serverSideBlockDefinitions = {};
[1520] Fix | Delete
/**
[1521] Fix | Delete
* Sets the server side block definition of blocks.
[1522] Fix | Delete
*
[1523] Fix | Delete
* @param {Object} definitions Server-side block definitions
[1524] Fix | Delete
*/
[1525] Fix | Delete
// eslint-disable-next-line camelcase
[1526] Fix | Delete
[1527] Fix | Delete
function unstable__bootstrapServerSideBlockDefinitions(definitions) {
[1528] Fix | Delete
for (var _i = 0, _Object$keys = Object.keys(definitions); _i < _Object$keys.length; _i++) {
[1529] Fix | Delete
var blockName = _Object$keys[_i];
[1530] Fix | Delete
[1531] Fix | Delete
// Don't overwrite if already set. It covers the case when metadata
[1532] Fix | Delete
// was initialized from the server.
[1533] Fix | Delete
if (serverSideBlockDefinitions[blockName]) {
[1534] Fix | Delete
continue;
[1535] Fix | Delete
}
[1536] Fix | Delete
[1537] Fix | Delete
serverSideBlockDefinitions[blockName] = Object(external_lodash_["mapKeys"])(Object(external_lodash_["pickBy"])(definitions[blockName], function (value) {
[1538] Fix | Delete
return !Object(external_lodash_["isNil"])(value);
[1539] Fix | Delete
}), function (value, key) {
[1540] Fix | Delete
return Object(external_lodash_["camelCase"])(key);
[1541] Fix | Delete
});
[1542] Fix | Delete
}
[1543] Fix | Delete
}
[1544] Fix | Delete
/**
[1545] Fix | Delete
* Registers a new block provided a unique name and an object defining its
[1546] Fix | Delete
* behavior. Once registered, the block is made available as an option to any
[1547] Fix | Delete
* editor interface where blocks are implemented.
[1548] Fix | Delete
*
[1549] Fix | Delete
* @param {string} name Block name.
[1550] Fix | Delete
* @param {Object} settings Block settings.
[1551] Fix | Delete
*
[1552] Fix | Delete
* @return {?WPBlock} The block, if it has been successfully registered;
[1553] Fix | Delete
* otherwise `undefined`.
[1554] Fix | Delete
*/
[1555] Fix | Delete
[1556] Fix | Delete
function registerBlockType(name, settings) {
[1557] Fix | Delete
settings = registration_objectSpread(registration_objectSpread({
[1558] Fix | Delete
name: name,
[1559] Fix | Delete
icon: block_default["a" /* default */],
[1560] Fix | Delete
keywords: [],
[1561] Fix | Delete
attributes: {},
[1562] Fix | Delete
providesContext: {},
[1563] Fix | Delete
usesContext: [],
[1564] Fix | Delete
supports: {},
[1565] Fix | Delete
styles: [],
[1566] Fix | Delete
save: function save() {
[1567] Fix | Delete
return null;
[1568] Fix | Delete
}
[1569] Fix | Delete
}, serverSideBlockDefinitions === null || serverSideBlockDefinitions === void 0 ? void 0 : serverSideBlockDefinitions[name]), settings);
[1570] Fix | Delete
[1571] Fix | Delete
if (typeof name !== 'string') {
[1572] Fix | Delete
console.error('Block names must be strings.');
[1573] Fix | Delete
return;
[1574] Fix | Delete
}
[1575] Fix | Delete
[1576] Fix | Delete
if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) {
[1577] Fix | Delete
console.error('Block names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-block');
[1578] Fix | Delete
return;
[1579] Fix | Delete
}
[1580] Fix | Delete
[1581] Fix | Delete
if (Object(external_wp_data_["select"])(store).getBlockType(name)) {
[1582] Fix | Delete
console.error('Block "' + name + '" is already registered.');
[1583] Fix | Delete
return;
[1584] Fix | Delete
}
[1585] Fix | Delete
[1586] Fix | Delete
var preFilterSettings = registration_objectSpread({}, settings);
[1587] Fix | Delete
[1588] Fix | Delete
settings = Object(external_wp_hooks_["applyFilters"])('blocks.registerBlockType', settings, name);
[1589] Fix | Delete
[1590] Fix | Delete
if (settings.deprecated) {
[1591] Fix | Delete
settings.deprecated = settings.deprecated.map(function (deprecation) {
[1592] Fix | Delete
return Object(external_lodash_["pick"])( // Only keep valid deprecation keys.
[1593] Fix | Delete
Object(external_wp_hooks_["applyFilters"])('blocks.registerBlockType', // Merge deprecation keys with pre-filter settings
[1594] Fix | Delete
// so that filters that depend on specific keys being
[1595] Fix | Delete
// present don't fail.
[1596] Fix | Delete
registration_objectSpread(registration_objectSpread({}, Object(external_lodash_["omit"])(preFilterSettings, DEPRECATED_ENTRY_KEYS)), deprecation), name), DEPRECATED_ENTRY_KEYS);
[1597] Fix | Delete
});
[1598] Fix | Delete
}
[1599] Fix | Delete
[1600] Fix | Delete
if (!Object(external_lodash_["isPlainObject"])(settings)) {
[1601] Fix | Delete
console.error('Block settings must be a valid object.');
[1602] Fix | Delete
return;
[1603] Fix | Delete
}
[1604] Fix | Delete
[1605] Fix | Delete
if (!Object(external_lodash_["isFunction"])(settings.save)) {
[1606] Fix | Delete
console.error('The "save" property must be a valid function.');
[1607] Fix | Delete
return;
[1608] Fix | Delete
}
[1609] Fix | Delete
[1610] Fix | Delete
if ('edit' in settings && !Object(external_lodash_["isFunction"])(settings.edit)) {
[1611] Fix | Delete
console.error('The "edit" property must be a valid function.');
[1612] Fix | Delete
return;
[1613] Fix | Delete
} // Canonicalize legacy categories to equivalent fallback.
[1614] Fix | Delete
[1615] Fix | Delete
[1616] Fix | Delete
if (LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) {
[1617] Fix | Delete
settings.category = LEGACY_CATEGORY_MAPPING[settings.category];
[1618] Fix | Delete
}
[1619] Fix | Delete
[1620] Fix | Delete
if ('category' in settings && !Object(external_lodash_["some"])(Object(external_wp_data_["select"])(store).getCategories(), {
[1621] Fix | Delete
slug: settings.category
[1622] Fix | Delete
})) {
[1623] Fix | Delete
console.warn('The block "' + name + '" is registered with an invalid category "' + settings.category + '".');
[1624] Fix | Delete
delete settings.category;
[1625] Fix | Delete
}
[1626] Fix | Delete
[1627] Fix | Delete
if (!('title' in settings) || settings.title === '') {
[1628] Fix | Delete
console.error('The block "' + name + '" must have a title.');
[1629] Fix | Delete
return;
[1630] Fix | Delete
}
[1631] Fix | Delete
[1632] Fix | Delete
if (typeof settings.title !== 'string') {
[1633] Fix | Delete
console.error('Block titles must be strings.');
[1634] Fix | Delete
return;
[1635] Fix | Delete
}
[1636] Fix | Delete
[1637] Fix | Delete
settings.icon = normalizeIconObject(settings.icon);
[1638] Fix | Delete
[1639] Fix | Delete
if (!isValidIcon(settings.icon.src)) {
[1640] Fix | Delete
console.error('The icon passed is invalid. ' + 'The icon should be a string, an element, a function, or an object following the specifications documented in https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#icon-optional');
[1641] Fix | Delete
return;
[1642] Fix | Delete
}
[1643] Fix | Delete
[1644] Fix | Delete
Object(external_wp_data_["dispatch"])(store).addBlockTypes(settings);
[1645] Fix | Delete
return settings;
[1646] Fix | Delete
}
[1647] Fix | Delete
/**
[1648] Fix | Delete
* Registers a new block collection to group blocks in the same namespace in the inserter.
[1649] Fix | Delete
*
[1650] Fix | Delete
* @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace.
[1651] Fix | Delete
* @param {Object} settings The block collection settings.
[1652] Fix | Delete
* @param {string} settings.title The title to display in the block inserter.
[1653] Fix | Delete
* @param {Object} [settings.icon] The icon to display in the block inserter.
[1654] Fix | Delete
*/
[1655] Fix | Delete
[1656] Fix | Delete
function registerBlockCollection(namespace, _ref) {
[1657] Fix | Delete
var title = _ref.title,
[1658] Fix | Delete
icon = _ref.icon;
[1659] Fix | Delete
Object(external_wp_data_["dispatch"])(store).addBlockCollection(namespace, title, icon);
[1660] Fix | Delete
}
[1661] Fix | Delete
/**
[1662] Fix | Delete
* Unregisters a block collection
[1663] Fix | Delete
*
[1664] Fix | Delete
* @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace
[1665] Fix | Delete
*
[1666] Fix | Delete
*/
[1667] Fix | Delete
[1668] Fix | Delete
function unregisterBlockCollection(namespace) {
[1669] Fix | Delete
Object(external_wp_data_["dispatch"])(store).removeBlockCollection(namespace);
[1670] Fix | Delete
}
[1671] Fix | Delete
/**
[1672] Fix | Delete
* Unregisters a block.
[1673] Fix | Delete
*
[1674] Fix | Delete
* @param {string} name Block name.
[1675] Fix | Delete
*
[1676] Fix | Delete
* @return {?WPBlock} The previous block value, if it has been successfully
[1677] Fix | Delete
* unregistered; otherwise `undefined`.
[1678] Fix | Delete
*/
[1679] Fix | Delete
[1680] Fix | Delete
function unregisterBlockType(name) {
[1681] Fix | Delete
var oldBlock = Object(external_wp_data_["select"])(store).getBlockType(name);
[1682] Fix | Delete
[1683] Fix | Delete
if (!oldBlock) {
[1684] Fix | Delete
console.error('Block "' + name + '" is not registered.');
[1685] Fix | Delete
return;
[1686] Fix | Delete
}
[1687] Fix | Delete
[1688] Fix | Delete
Object(external_wp_data_["dispatch"])(store).removeBlockTypes(name);
[1689] Fix | Delete
return oldBlock;
[1690] Fix | Delete
}
[1691] Fix | Delete
/**
[1692] Fix | Delete
* Assigns name of block for handling non-block content.
[1693] Fix | Delete
*
[1694] Fix | Delete
* @param {string} blockName Block name.
[1695] Fix | Delete
*/
[1696] Fix | Delete
[1697] Fix | Delete
function setFreeformContentHandlerName(blockName) {
[1698] Fix | Delete
Object(external_wp_data_["dispatch"])(store).setFreeformFallbackBlockName(blockName);
[1699] Fix | Delete
}
[1700] Fix | Delete
/**
[1701] Fix | Delete
* Retrieves name of block handling non-block content, or undefined if no
[1702] Fix | Delete
* handler has been defined.
[1703] Fix | Delete
*
[1704] Fix | Delete
* @return {?string} Block name.
[1705] Fix | Delete
*/
[1706] Fix | Delete
[1707] Fix | Delete
function getFreeformContentHandlerName() {
[1708] Fix | Delete
return Object(external_wp_data_["select"])(store).getFreeformFallbackBlockName();
[1709] Fix | Delete
}
[1710] Fix | Delete
/**
[1711] Fix | Delete
* Retrieves name of block used for handling grouping interactions.
[1712] Fix | Delete
*
[1713] Fix | Delete
* @return {?string} Block name.
[1714] Fix | Delete
*/
[1715] Fix | Delete
[1716] Fix | Delete
function registration_getGroupingBlockName() {
[1717] Fix | Delete
return Object(external_wp_data_["select"])(store).getGroupingBlockName();
[1718] Fix | Delete
}
[1719] Fix | Delete
/**
[1720] Fix | Delete
* Assigns name of block handling unregistered block types.
[1721] Fix | Delete
*
[1722] Fix | Delete
* @param {string} blockName Block name.
[1723] Fix | Delete
*/
[1724] Fix | Delete
[1725] Fix | Delete
function setUnregisteredTypeHandlerName(blockName) {
[1726] Fix | Delete
Object(external_wp_data_["dispatch"])(store).setUnregisteredFallbackBlockName(blockName);
[1727] Fix | Delete
}
[1728] Fix | Delete
/**
[1729] Fix | Delete
* Retrieves name of block handling unregistered block types, or undefined if no
[1730] Fix | Delete
* handler has been defined.
[1731] Fix | Delete
*
[1732] Fix | Delete
* @return {?string} Block name.
[1733] Fix | Delete
*/
[1734] Fix | Delete
[1735] Fix | Delete
function getUnregisteredTypeHandlerName() {
[1736] Fix | Delete
return Object(external_wp_data_["select"])(store).getUnregisteredFallbackBlockName();
[1737] Fix | Delete
}
[1738] Fix | Delete
/**
[1739] Fix | Delete
* Assigns the default block name.
[1740] Fix | Delete
*
[1741] Fix | Delete
* @param {string} name Block name.
[1742] Fix | Delete
*/
[1743] Fix | Delete
[1744] Fix | Delete
function registration_setDefaultBlockName(name) {
[1745] Fix | Delete
Object(external_wp_data_["dispatch"])(store).setDefaultBlockName(name);
[1746] Fix | Delete
}
[1747] Fix | Delete
/**
[1748] Fix | Delete
* Assigns name of block for handling block grouping interactions.
[1749] Fix | Delete
*
[1750] Fix | Delete
* @param {string} name Block name.
[1751] Fix | Delete
*/
[1752] Fix | Delete
[1753] Fix | Delete
function registration_setGroupingBlockName(name) {
[1754] Fix | Delete
Object(external_wp_data_["dispatch"])(store).setGroupingBlockName(name);
[1755] Fix | Delete
}
[1756] Fix | Delete
/**
[1757] Fix | Delete
* Retrieves the default block name.
[1758] Fix | Delete
*
[1759] Fix | Delete
* @return {?string} Block name.
[1760] Fix | Delete
*/
[1761] Fix | Delete
[1762] Fix | Delete
function registration_getDefaultBlockName() {
[1763] Fix | Delete
return Object(external_wp_data_["select"])(store).getDefaultBlockName();
[1764] Fix | Delete
}
[1765] Fix | Delete
/**
[1766] Fix | Delete
* Returns a registered block type.
[1767] Fix | Delete
*
[1768] Fix | Delete
* @param {string} name Block name.
[1769] Fix | Delete
*
[1770] Fix | Delete
* @return {?Object} Block type.
[1771] Fix | Delete
*/
[1772] Fix | Delete
[1773] Fix | Delete
function registration_getBlockType(name) {
[1774] Fix | Delete
return Object(external_wp_data_["select"])(store).getBlockType(name);
[1775] Fix | Delete
}
[1776] Fix | Delete
/**
[1777] Fix | Delete
* Returns all registered blocks.
[1778] Fix | Delete
*
[1779] Fix | Delete
* @return {Array} Block settings.
[1780] Fix | Delete
*/
[1781] Fix | Delete
[1782] Fix | Delete
function registration_getBlockTypes() {
[1783] Fix | Delete
return Object(external_wp_data_["select"])(store).getBlockTypes();
[1784] Fix | Delete
}
[1785] Fix | Delete
/**
[1786] Fix | Delete
* Returns the block support value for a feature, if defined.
[1787] Fix | Delete
*
[1788] Fix | Delete
* @param {(string|Object)} nameOrType Block name or type object
[1789] Fix | Delete
* @param {string} feature Feature to retrieve
[1790] Fix | Delete
* @param {*} defaultSupports Default value to return if not
[1791] Fix | Delete
* explicitly defined
[1792] Fix | Delete
*
[1793] Fix | Delete
* @return {?*} Block support value
[1794] Fix | Delete
*/
[1795] Fix | Delete
[1796] Fix | Delete
function registration_getBlockSupport(nameOrType, feature, defaultSupports) {
[1797] Fix | Delete
return Object(external_wp_data_["select"])(store).getBlockSupport(nameOrType, feature, defaultSupports);
[1798] Fix | Delete
}
[1799] Fix | Delete
/**
[1800] Fix | Delete
* Returns true if the block defines support for a feature, or false otherwise.
[1801] Fix | Delete
*
[1802] Fix | Delete
* @param {(string|Object)} nameOrType Block name or type object.
[1803] Fix | Delete
* @param {string} feature Feature to test.
[1804] Fix | Delete
* @param {boolean} defaultSupports Whether feature is supported by
[1805] Fix | Delete
* default if not explicitly defined.
[1806] Fix | Delete
*
[1807] Fix | Delete
* @return {boolean} Whether block supports feature.
[1808] Fix | Delete
*/
[1809] Fix | Delete
[1810] Fix | Delete
function registration_hasBlockSupport(nameOrType, feature, defaultSupports) {
[1811] Fix | Delete
return Object(external_wp_data_["select"])(store).hasBlockSupport(nameOrType, feature, defaultSupports);
[1812] Fix | Delete
}
[1813] Fix | Delete
/**
[1814] Fix | Delete
* Determines whether or not the given block is a reusable block. This is a
[1815] Fix | Delete
* special block type that is used to point to a global block stored via the
[1816] Fix | Delete
* API.
[1817] Fix | Delete
*
[1818] Fix | Delete
* @param {Object} blockOrType Block or Block Type to test.
[1819] Fix | Delete
*
[1820] Fix | Delete
* @return {boolean} Whether the given block is a reusable block.
[1821] Fix | Delete
*/
[1822] Fix | Delete
[1823] Fix | Delete
function isReusableBlock(blockOrType) {
[1824] Fix | Delete
return blockOrType.name === 'core/block';
[1825] Fix | Delete
}
[1826] Fix | Delete
/**
[1827] Fix | Delete
* Returns an array with the child blocks of a given block.
[1828] Fix | Delete
*
[1829] Fix | Delete
* @param {string} blockName Name of block (example: “latest-posts”).
[1830] Fix | Delete
*
[1831] Fix | Delete
* @return {Array} Array of child block names.
[1832] Fix | Delete
*/
[1833] Fix | Delete
[1834] Fix | Delete
var registration_getChildBlockNames = function getChildBlockNames(blockName) {
[1835] Fix | Delete
return Object(external_wp_data_["select"])(store).getChildBlockNames(blockName);
[1836] Fix | Delete
};
[1837] Fix | Delete
/**
[1838] Fix | Delete
* Returns a boolean indicating if a block has child blocks or not.
[1839] Fix | Delete
*
[1840] Fix | Delete
* @param {string} blockName Name of block (example: “latest-posts”).
[1841] Fix | Delete
*
[1842] Fix | Delete
* @return {boolean} True if a block contains child blocks and false otherwise.
[1843] Fix | Delete
*/
[1844] Fix | Delete
[1845] Fix | Delete
var registration_hasChildBlocks = function hasChildBlocks(blockName) {
[1846] Fix | Delete
return Object(external_wp_data_["select"])(store).hasChildBlocks(blockName);
[1847] Fix | Delete
};
[1848] Fix | Delete
/**
[1849] Fix | Delete
* Returns a boolean indicating if a block has at least one child block with inserter support.
[1850] Fix | Delete
*
[1851] Fix | Delete
* @param {string} blockName Block type name.
[1852] Fix | Delete
*
[1853] Fix | Delete
* @return {boolean} True if a block contains at least one child blocks with inserter support
[1854] Fix | Delete
* and false otherwise.
[1855] Fix | Delete
*/
[1856] Fix | Delete
[1857] Fix | Delete
var registration_hasChildBlocksWithInserterSupport = function hasChildBlocksWithInserterSupport(blockName) {
[1858] Fix | Delete
return Object(external_wp_data_["select"])(store).hasChildBlocksWithInserterSupport(blockName);
[1859] Fix | Delete
};
[1860] Fix | Delete
/**
[1861] Fix | Delete
* Registers a new block style variation for the given block.
[1862] Fix | Delete
*
[1863] Fix | Delete
* @param {string} blockName Name of block (example: “core/latest-posts”).
[1864] Fix | Delete
* @param {Object} styleVariation Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user.
[1865] Fix | Delete
*/
[1866] Fix | Delete
[1867] Fix | Delete
var registration_registerBlockStyle = function registerBlockStyle(blockName, styleVariation) {
[1868] Fix | Delete
Object(external_wp_data_["dispatch"])(store).addBlockStyles(blockName, styleVariation);
[1869] Fix | Delete
};
[1870] Fix | Delete
/**
[1871] Fix | Delete
* Unregisters a block style variation for the given block.
[1872] Fix | Delete
*
[1873] Fix | Delete
* @param {string} blockName Name of block (example: “core/latest-posts”).
[1874] Fix | Delete
* @param {string} styleVariationName Name of class applied to the block.
[1875] Fix | Delete
*/
[1876] Fix | Delete
[1877] Fix | Delete
var registration_unregisterBlockStyle = function unregisterBlockStyle(blockName, styleVariationName) {
[1878] Fix | Delete
Object(external_wp_data_["dispatch"])(store).removeBlockStyles(blockName, styleVariationName);
[1879] Fix | Delete
};
[1880] Fix | Delete
/**
[1881] Fix | Delete
* Returns an array with the variations of a given block type.
[1882] Fix | Delete
*
[1883] Fix | Delete
* @param {string} blockName Name of block (example: “core/columns”).
[1884] Fix | Delete
* @param {WPBlockVariationScope} [scope] Block variation scope name.
[1885] Fix | Delete
*
[1886] Fix | Delete
* @return {(WPBlockVariation[]|void)} Block variations.
[1887] Fix | Delete
*/
[1888] Fix | Delete
[1889] Fix | Delete
var registration_getBlockVariations = function getBlockVariations(blockName, scope) {
[1890] Fix | Delete
return Object(external_wp_data_["select"])(store).getBlockVariations(blockName, scope);
[1891] Fix | Delete
};
[1892] Fix | Delete
/**
[1893] Fix | Delete
* Registers a new block variation for the given block type.
[1894] Fix | Delete
*
[1895] Fix | Delete
* @param {string} blockName Name of the block (example: “core/columns”).
[1896] Fix | Delete
* @param {WPBlockVariation} variation Object describing a block variation.
[1897] Fix | Delete
*/
[1898] Fix | Delete
[1899] Fix | Delete
var registration_registerBlockVariation = function registerBlockVariation(blockName, variation) {
[1900] Fix | Delete
Object(external_wp_data_["dispatch"])(store).addBlockVariations(blockName, variation);
[1901] Fix | Delete
};
[1902] Fix | Delete
/**
[1903] Fix | Delete
* Unregisters a block variation defined for the given block type.
[1904] Fix | Delete
*
[1905] Fix | Delete
* @param {string} blockName Name of the block (example: “core/columns”).
[1906] Fix | Delete
* @param {string} variationName Name of the variation defined for the block.
[1907] Fix | Delete
*/
[1908] Fix | Delete
[1909] Fix | Delete
var registration_unregisterBlockVariation = function unregisterBlockVariation(blockName, variationName) {
[1910] Fix | Delete
Object(external_wp_data_["dispatch"])(store).removeBlockVariations(blockName, variationName);
[1911] Fix | Delete
};
[1912] Fix | Delete
[1913] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/factory.js
[1914] Fix | Delete
[1915] Fix | Delete
[1916] Fix | Delete
[1917] Fix | Delete
[1918] Fix | Delete
function factory_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
[1919] Fix | Delete
[1920] Fix | Delete
function factory_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { factory_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { factory_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
[1921] Fix | Delete
[1922] Fix | Delete
/**
[1923] Fix | Delete
* External dependencies
[1924] Fix | Delete
*/
[1925] Fix | Delete
[1926] Fix | Delete
[1927] Fix | Delete
/**
[1928] Fix | Delete
* WordPress dependencies
[1929] Fix | Delete
*/
[1930] Fix | Delete
[1931] Fix | Delete
[1932] Fix | Delete
/**
[1933] Fix | Delete
* Internal dependencies
[1934] Fix | Delete
*/
[1935] Fix | Delete
[1936] Fix | Delete
[1937] Fix | Delete
[1938] Fix | Delete
/**
[1939] Fix | Delete
* Returns a block object given its type and attributes.
[1940] Fix | Delete
*
[1941] Fix | Delete
* @param {string} name Block name.
[1942] Fix | Delete
* @param {Object} attributes Block attributes.
[1943] Fix | Delete
* @param {?Array} innerBlocks Nested blocks.
[1944] Fix | Delete
*
[1945] Fix | Delete
* @return {Object} Block object.
[1946] Fix | Delete
*/
[1947] Fix | Delete
[1948] Fix | Delete
function createBlock(name) {
[1949] Fix | Delete
var attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
[1950] Fix | Delete
var innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
[1951] Fix | Delete
var sanitizedAttributes = sanitizeBlockAttributes(name, attributes);
[1952] Fix | Delete
var clientId = Object(v4["a" /* default */])(); // Blocks are stored with a unique ID, the assigned type name, the block
[1953] Fix | Delete
// attributes, and their inner blocks.
[1954] Fix | Delete
[1955] Fix | Delete
return {
[1956] Fix | Delete
clientId: clientId,
[1957] Fix | Delete
name: name,
[1958] Fix | Delete
isValid: true,
[1959] Fix | Delete
attributes: sanitizedAttributes,
[1960] Fix | Delete
innerBlocks: innerBlocks
[1961] Fix | Delete
};
[1962] Fix | Delete
}
[1963] Fix | Delete
/**
[1964] Fix | Delete
* Given an array of InnerBlocks templates or Block Objects,
[1965] Fix | Delete
* returns an array of created Blocks from them.
[1966] Fix | Delete
* It handles the case of having InnerBlocks as Blocks by
[1967] Fix | Delete
* converting them to the proper format to continue recursively.
[1968] Fix | Delete
*
[1969] Fix | Delete
* @param {Array} innerBlocksOrTemplate Nested blocks or InnerBlocks templates.
[1970] Fix | Delete
*
[1971] Fix | Delete
* @return {Object[]} Array of Block objects.
[1972] Fix | Delete
*/
[1973] Fix | Delete
[1974] Fix | Delete
function createBlocksFromInnerBlocksTemplate() {
[1975] Fix | Delete
var innerBlocksOrTemplate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
[1976] Fix | Delete
return innerBlocksOrTemplate.map(function (innerBlock) {
[1977] Fix | Delete
var innerBlockTemplate = Array.isArray(innerBlock) ? innerBlock : [innerBlock.name, innerBlock.attributes, innerBlock.innerBlocks];
[1978] Fix | Delete
[1979] Fix | Delete
var _innerBlockTemplate = Object(slicedToArray["a" /* default */])(innerBlockTemplate, 3),
[1980] Fix | Delete
name = _innerBlockTemplate[0],
[1981] Fix | Delete
attributes = _innerBlockTemplate[1],
[1982] Fix | Delete
_innerBlockTemplate$ = _innerBlockTemplate[2],
[1983] Fix | Delete
innerBlocks = _innerBlockTemplate$ === void 0 ? [] : _innerBlockTemplate$;
[1984] Fix | Delete
[1985] Fix | Delete
return createBlock(name, attributes, createBlocksFromInnerBlocksTemplate(innerBlocks));
[1986] Fix | Delete
});
[1987] Fix | Delete
}
[1988] Fix | Delete
/**
[1989] Fix | Delete
* Given a block object, returns a copy of the block object while sanitizing its attributes,
[1990] Fix | Delete
* optionally merging new attributes and/or replacing its inner blocks.
[1991] Fix | Delete
*
[1992] Fix | Delete
* @param {Object} block Block instance.
[1993] Fix | Delete
* @param {Object} mergeAttributes Block attributes.
[1994] Fix | Delete
* @param {?Array} newInnerBlocks Nested blocks.
[1995] Fix | Delete
*
[1996] Fix | Delete
* @return {Object} A cloned block.
[1997] Fix | Delete
*/
[1998] Fix | Delete
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function