useDocumentBuilder
Document builder state and logic composable.
Import
typescript
const {
pages,
currentPage,
blocks,
selectedBlock,
isLoading,
addPage,
removePage,
reorderPages,
addBlock,
updateBlock,
removeBlock,
selectBlock,
moveBlock,
resizeBlock,
} = useDocumentBuilder(projectId)Parameters
| Parameter | Type | Description |
|---|---|---|
projectId | Ref<string> | Reactive project UUID |
Block Types
typescript
type BlockType =
| 'text'
| 'image'
| 'image_compare' // AI before/after
| 'floor_plan'
| 'spec'
| 'material'Return Values
| Property | Type | Description |
|---|---|---|
pages | Ref<Page[]> | All document pages |
currentPage | Ref<Page | null> | Currently active page |
blocks | ComputedRef<Block[]> | Blocks on current page |
selectedBlock | Ref<Block | null> | Currently selected block |
isLoading | Ref<boolean> | Loading state |
Methods
| Method | Parameters | Returns | Description |
|---|---|---|---|
addPage | afterIndex?: number | Promise<Page> | Add new page |
removePage | pageId: string | Promise<void> | Remove page |
reorderPages | fromIndex: number, toIndex: number | void | Reorder pages |
addBlock | pageId: string, type: BlockType, content: any | Promise<Block> | Add block to page |
updateBlock | blockId: string, updates: Partial<Block> | Promise<void> | Update block |
removeBlock | blockId: string | Promise<void> | Remove block |
selectBlock | block: Block | null | void | Select block |
moveBlock | blockId: string, x: number, y: number | void | Move block position |
resizeBlock | blockId: string, w: number, h: number | void | Resize block |
Source
app/composables/useDocumentBuilder.ts