schlechtenburg/packages/core/lib/types.ts

38 lines
748 B
TypeScript
Raw Normal View History

2021-03-08 15:29:35 +00:00
import { Component } from 'vue';
export interface TreeNode {
id: string;
name: string;
icon?: string;
children: TreeNode[];
}
export interface BlockData<T> {
id: string;
name: string;
data: T;
}
export interface BlockProps<T> {
blockId: string;
data?: T,
onUpdate?: (b?: BlockData<T>) => void;
onPrependBlock?: (b?: BlockData<T>) => void;
onAppendBlock?: (b?: BlockData<T>) => void;
onRemoveSelf?: () => void;
onActivateNext?: () => void;
onActivatePrevious?: () => void;
}
export interface BlockDefinition<T> {
name: string;
icon?: string;
getDefaultData: T;
edit: Component<BlockProps<T>>;
display: Component<BlockProps<T>>;
}
export interface BlockLibrary {
[name: string]: BlockDefinition<any>;
}