import { Component } from 'vue'; /** * Schlechtenburg keeps track of the rendered block tree. * This is useful for e.g. the tree select component in the editor header. * * @internal */ export interface ITreeNode { id: string; name: string; icon?: string; children: ITreeNode[]; } /** * Schlechtenburg inputs and outputs a plain JS Object that can be JSON stringified. This is the * interface type for that data structure. `T` will be the data type of the specific block being * * @see SbMain */ export interface IBlockData { id: string; name: string; data: T; } /** * Callback type for sending full block updates. SbBlock takes this as a prop. * * ``` * * ``` * * @see SbBlock */ export type OnUpdateBlockCb = (updated: IBlockData) => void; /** * Callback type for sending partial self-updates in edit mode. * * ``` * props: { * eventUpdate: { * type: (null as unknown) as PropType>, * default: () => {}, * }, * } * ``` * * @see SbBlock */ export type OnUpdateSelfCb = (updated: Partial) => void; /** * Callback type for sending blocks that should be prepended as a sibling before the current block * * ``` * props: { * eventPrependBlock: { * type: (null as unknown) as PropType>, * default: () => {}, * }, * } * ``` * * @see SbBlock */ export type OnPrependBlockCb = (block: IBlockData) => void; /** * Callback type for sending blocks that should be appended as a sibling after the current block * * ``` * props: { * eventAppendBlock: { * type: (null as unknown) as PropType>, * default: () => {}, * }, * } * ``` * * @see SbBlock */ export type OnAppendBlockCb = (block: IBlockData) => void; /** * Callback type for removing the current block. * * ``` * props: { * eventRemoveSelf: { * type: (null as unknown) as PropType, * default: () => {}, * }, * } * ``` * * @see SbBlock */ export type OnRemoveSelfCb = () => void; /** * Callback type for activating the previous block. * * ``` * props: { * eventActivatePrevious: { * type: (null as unknown) as PropType, * default: (_i:number) => {}, * }, * } * ``` * * @see SbBlock */ export type OnActivatePreviousCb = (_i:number) => void; /** * Callback type for activating the next block. * * ``` * props: { * eventActivateNext: { * type: (null as unknown) as PropType, * default: (_i:number) => {}, * }, * } * ``` * * @see SbBlock */ export type OnActivateNextCb = (_i:number) => void; /** * Any Block that you create * * @see IBlockDefinition */ export interface IBlockProps { blockId?: string; data?: T, eventUpdate?: OnUpdateSelfCb; eventPrependBlock?: OnPrependBlockCb; eventAppendBlock?: OnAppendBlockCb; eventRemoveSelf?: OnRemoveSelfCb; eventActivateNext?: OnActivateNextCb; eventActivatePrevious?: OnActivatePreviousCb; } /** * Any Block that you create * * @see IBlockProps */ export interface IBlockDefinition { name: string; icon?: string; getDefaultData: T; edit: Component>; view: Component>; } /** * Schlechtenburg maintains a library of blocks that are available * * @internal */ export interface IBlockLibrary { [name: string]: IBlockDefinition; } export interface IFormattingTool { name: string; icon: string; tagName?: string; className?: string; edit: Component; surfaceTension?: number; } /** * Schlechtenburg maintains a library of formatting tools that are available * * @internal */ export interface IFormattingToolLibrary { [name: string]: IFormattingTool; }