schlechtenburg/packages/core/lib/blocks.ts

43 lines
727 B
TypeScript
Raw Normal View History

2020-12-30 01:32:46 +00:00
import { Component } from 'vue';
2021-02-22 23:12:06 +00:00
export interface BlockTree {
name: string;
icon?: string;
children?: BlockTree[];
}
2020-12-30 01:32:46 +00:00
export interface BlockDefinition {
name: string;
2021-02-22 23:12:06 +00:00
icon?: string;
2020-12-30 01:32:46 +00:00
getDefaultData: any;
edit: Component;
display: Component;
2021-02-22 23:12:06 +00:00
getChildren?: (block: Block) => Block[],
2020-12-30 01:32:46 +00:00
}
export interface BlockLibraryDefinition {
[name: string]: BlockDefinition;
}
2021-02-22 18:13:37 +00:00
export interface BlockProps {
2020-12-30 01:32:46 +00:00
blockId: string;
2021-02-22 18:13:37 +00:00
data: any;
2020-12-30 01:32:46 +00:00
}
2021-02-22 18:13:37 +00:00
export interface Block extends BlockProps {
2020-12-30 01:32:46 +00:00
name: string;
}
export const model = {
prop: 'block',
event: 'update',
};
export const blockProps = {
blockId: {
type: String,
default: () => `${+(new Date())}`,
},
data: { type: Object, default: () => ({}) },
};