import type { DomProvider } from './dom.js'; import type { StateProvider } from './state.js'; import type { AdapterContext } from '#blokkli/editor/adapter'; import { type ComputedRef } from '#imports'; import type { RenderedFieldListItem } from '../types/field.js'; export type BlocksProvider = { /** * Get a rendered block by its UUID. * * Returns a RenderedFieldListItem with complete block metadata including: * - Host entity and field information * - Publishing status and schedule * - Library/fragment data (if applicable) * - Parent block bundle (for nested blocks) * * Results are cached and invalidated on state reload. * * @param uuid - The block's UUID * @returns The rendered block item, or undefined if not found */ getBlock: (uuid: string) => RenderedFieldListItem | undefined; /** * Get all rendered blocks in the current state. * * Returns an array of all blocks with complete metadata. * Iterates through all UUIDs in state and builds RenderedFieldListItem for each. * * @returns Array of all rendered block items */ getAllBlocks: () => RenderedFieldListItem[]; /** * Get the bundle of a block's ROOT block — the top-most block under the page * entity, found by walking `host` upward while the host is a block. * * For a block directly under the page, returns its own bundle. Returns * undefined if the UUID is not a block (e.g. the page entity itself). * * @param uuid - The block's UUID * @returns The root block's bundle, or undefined */ getRootBundle: (uuid: string) => string | undefined; }; export default function (state: StateProvider, dom: DomProvider, context: ComputedRef): BlocksProvider;