UI kit reference
code/editor/useFileDocument
import { … } from 'zidane-ui/code/editor'ui/src/code/editor/useFileDocument.ts
Functions#
useFileDocumentFunction#
Loads one adapter file for useCodeDocument and keeps it fresh as the adapter reports changes.
function useFileDocument(fs: FileSystemAdapter, path: string): FileDocumentStateParameters
| Name | Type | Description |
|---|---|---|
| fs | FileSystemAdapter | Where the file lives. |
| path | string | The file, from the adapter's root. |
Returns
Interfaces#
FileDocumentStateInterface#
What useFileDocument returns: the file as a CodeDoc plus the save and reload useCodeDocument takes.
interface FileDocumentStateProperties
| Name | Type | Description |
|---|---|---|
| doc | CodeDoc | null | The latest read; |
| error | string | null | Why the file could not be read. |
| reload | () => Promise<CodeDoc | null> | Reads the file again; |
| save | (text: string, base: CodeDoc, force: boolean) => Promise<SaveOutcome<CodeDoc>> | Writes |