Skip to content

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

ParameterTypeDescription
projectIdRef<string>Reactive project UUID

Block Types

typescript
type BlockType =
  | 'text'
  | 'image'
  | 'image_compare'  // AI before/after
  | 'floor_plan'
  | 'spec'
  | 'material'

Return Values

PropertyTypeDescription
pagesRef<Page[]>All document pages
currentPageRef<Page | null>Currently active page
blocksComputedRef<Block[]>Blocks on current page
selectedBlockRef<Block | null>Currently selected block
isLoadingRef<boolean>Loading state

Methods

MethodParametersReturnsDescription
addPageafterIndex?: numberPromise<Page>Add new page
removePagepageId: stringPromise<void>Remove page
reorderPagesfromIndex: number, toIndex: numbervoidReorder pages
addBlockpageId: string, type: BlockType, content: anyPromise<Block>Add block to page
updateBlockblockId: string, updates: Partial<Block>Promise<void>Update block
removeBlockblockId: stringPromise<void>Remove block
selectBlockblock: Block | nullvoidSelect block
moveBlockblockId: string, x: number, y: numbervoidMove block position
resizeBlockblockId: string, w: number, h: numbervoidResize block

Source

app/composables/useDocumentBuilder.ts

Built with VitePress