react-movable-block-editor
Version:
React component for creating layouts and content via drag-and-drop blocks.
47 lines (46 loc) • 1.56 kB
TypeScript
export declare type BlockNodeType = 'row' | 'col' | 'markdown' | 'image' | 'layer' | 'custom';
export interface BlockNode {
id: string;
type: BlockNodeType;
customType?: string;
name: string;
value?: any;
backgroundColor?: string | null;
color?: string | null;
parentId?: string;
childrenIds: Array<string>;
children?: Array<BlockNode>;
isPlaceHolder?: boolean;
width: number;
height: number;
top?: number;
left?: number;
paddingLeftPercentWidth?: number;
paddingTopPercentHeight?: number;
borderWidth?: number;
borderTopWidth?: number;
borderBottomWidth?: number;
borderLeftWidth?: number;
borderRightWidth?: number;
borderStyle?: string;
display?: string;
flexDirection?: string;
justifyContent?: string;
alignItems?: string;
}
export declare type ById = {
[id: string]: BlockNode | undefined;
};
export declare function updateNode(byId: ById, newNode: BlockNode): ById;
export declare function removeNode(byId: ById, nodeId: string): ById;
export declare function hasDescendent(byId: ById, nodeId: string, descendentId: string, checked?: {
[id: string]: boolean;
}): boolean;
export declare function placeNodeInParent(byId: ById, node: BlockNode, newParentId: string, opts?: {
beforeItemId?: string;
afterItemId?: string;
}): ById;
export declare function reinsertIntoList(ids: Array<string>, itemId: string, opts?: {
beforeItemId?: string;
afterItemId?: string;
}): string[];