editor.js/types/store/action.ts
2022-05-15 23:08:59 +03:00

35 lines
869 B
TypeScript

import { OutputBlockData } from '../index';
import { BlockMutationType } from '../events/block/mutation-type';
/**
* Action for creating a new block in the editor
* This action will add the new block to the state
*/
export interface CreateBlockAction {
type: BlockMutationType.Added;
data: OutputBlockData;
}
/**
* Action for changing data of an existing block
* This action will change block data in the state by its id
*/
export interface ChangeBlockDataAction {
type: BlockMutationType.Changed;
data: OutputBlockData;
}
/**
* Action for removing a block from the editor
* This action will remove the block from the state by its id
*/
export interface RemoveBlockAction {
type: BlockMutationType.Removed;
blockId: string;
}
/**
* Available action types
*/
export type Action = CreateBlockAction | ChangeBlockDataAction | RemoveBlockAction;