@quillforms/block-editor
Version:
160 lines (153 loc) • 3.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setCurrentChildBlock = exports.setCurrentBlock = exports.setBlocks = exports.setBlockAttributes = exports.replaceBlockName = exports.deleteBlock = exports.__experimentalReorderBlocks = exports.__experimentalInsertBlock = void 0;
exports.setupStore = setupStore;
var _constants = require("./constants");
/**
* Set up the store.
*
* @param {InitialPayload} initialPayload Initial payload object.
*
* @return {BlockEditorActionTypes} Action object.
*/
function setupStore(initialPayload) {
return {
type: _constants.SETUP_STORE,
initialPayload
};
}
/**
* Set block attributes
*
* @param {string} blockId Block Id
* @param {Object} attributes Block attributes
*
* @param parentIndex
* @param parentId
* @return {BlockEditorActionTypes} Action object.
*/
const setBlockAttributes = (blockId, attributes, parentId = undefined) => {
return {
type: _constants.SET_BLOCK_ATTRIBUTES,
blockId,
attributes,
parentId
};
};
/**
* Reorder form blocks
*
* @param {number} sourceIndex Source index in the array
* @param {number} destinationIndex Destination index in the array
*
* @param sourceId
* @param destinationId
* @param parentSourceIndex
* @param parentDestIndex
* @return {BlockEditorActionTypes} Action object.
*/
exports.setBlockAttributes = setBlockAttributes;
const __experimentalReorderBlocks = (sourceIndex, destinationIndex, parentSourceIndex = undefined, parentDestIndex = undefined) => {
return {
type: _constants.REORDER_BLOCKS,
sourceIndex,
destinationIndex,
parentSourceIndex,
parentDestIndex
};
};
/**
* Insert new form block
*
* @param {FormBlock} block Block object which holds the block definition
* @param {number} destinationIndex Destination object
*
* @param parent
* @return {BlockEditorActionTypes} Action object.
*/
exports.__experimentalReorderBlocks = __experimentalReorderBlocks;
const __experimentalInsertBlock = (block, destinationIndex, parent = undefined) => {
return {
type: _constants.INSERT_BLOCK,
block,
destinationIndex,
parent
};
};
/**
* Replace Block Name
*
* @param {string} blockId Block id
* @param {string} name Block name
*
* @return {BlockEditorActionTypes} Action object.
*/
exports.__experimentalInsertBlock = __experimentalInsertBlock;
const replaceBlockName = (blockId, name, parentId) => {
return {
type: 'REPLACE_BLOCK_NAME',
blockId,
name,
parentId
};
};
/**
* Set blocks
* @param blocks
* @returns
*/
exports.replaceBlockName = replaceBlockName;
const setBlocks = blocks => {
return {
type: 'SET_BLOCKS',
blocks
};
};
/**
* Set current block
*
* @param {string} blockId Block uuid
*
* @return {BlockEditorActionTypes} Action object.
*/
exports.setBlocks = setBlocks;
const setCurrentBlock = blockId => {
return {
type: _constants.SET_CURRENT_BLOCK,
blockId
};
};
/**
* Set current block
*
* @param {string} blockId Block uuid
*
* @return {BlockEditorActionTypes} Action object.
*/
exports.setCurrentBlock = setCurrentBlock;
const setCurrentChildBlock = blockId => {
return {
type: _constants.SET_CURRENT_CHILD_BLOCK,
blockId
};
};
/**
* Delete current block
*
* @param {string} blockId Block uuid
*
* @param parentId
* @return {BlockEditorActionTypes} Action object.
*/
exports.setCurrentChildBlock = setCurrentChildBlock;
const deleteBlock = (blockId, parentId = undefined) => {
return {
type: _constants.DELETE_BLOCK,
blockId,
parentId
};
};
exports.deleteBlock = deleteBlock;
//# sourceMappingURL=actions.js.map