UNPKG

@quillforms/block-editor

Version:
145 lines (139 loc) 3.2 kB
import { SETUP_STORE, SET_BLOCK_ATTRIBUTES, INSERT_BLOCK, DELETE_BLOCK, SET_CURRENT_BLOCK, SET_CURRENT_CHILD_BLOCK, REORDER_BLOCKS } from './constants'; /** * Set up the store. * * @param {InitialPayload} initialPayload Initial payload object. * * @return {BlockEditorActionTypes} Action object. */ export function setupStore(initialPayload) { return { type: SETUP_STORE, initialPayload }; } /** * Set block attributes * * @param {string} blockId Block Id * @param {Object} attributes Block attributes * * @param parentIndex * @param parentId * @return {BlockEditorActionTypes} Action object. */ export const setBlockAttributes = (blockId, attributes, parentId = undefined) => { return { type: 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. */ export const __experimentalReorderBlocks = (sourceIndex, destinationIndex, parentSourceIndex = undefined, parentDestIndex = undefined) => { return { type: 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. */ export const __experimentalInsertBlock = (block, destinationIndex, parent = undefined) => { return { type: INSERT_BLOCK, block, destinationIndex, parent }; }; /** * Replace Block Name * * @param {string} blockId Block id * @param {string} name Block name * * @return {BlockEditorActionTypes} Action object. */ export const replaceBlockName = (blockId, name, parentId) => { return { type: 'REPLACE_BLOCK_NAME', blockId, name, parentId }; }; /** * Set blocks * @param blocks * @returns */ export const setBlocks = blocks => { return { type: 'SET_BLOCKS', blocks }; }; /** * Set current block * * @param {string} blockId Block uuid * * @return {BlockEditorActionTypes} Action object. */ export const setCurrentBlock = blockId => { return { type: SET_CURRENT_BLOCK, blockId }; }; /** * Set current block * * @param {string} blockId Block uuid * * @return {BlockEditorActionTypes} Action object. */ export const setCurrentChildBlock = blockId => { return { type: SET_CURRENT_CHILD_BLOCK, blockId }; }; /** * Delete current block * * @param {string} blockId Block uuid * * @param parentId * @return {BlockEditorActionTypes} Action object. */ export const deleteBlock = (blockId, parentId = undefined) => { return { type: DELETE_BLOCK, blockId, parentId }; }; //# sourceMappingURL=actions.js.map