# code/editor/reveal (zidane-ui/code/editor)

Import: `import { … } from 'zidane-ui/code/editor'`. Source: [ui/src/code/editor/reveal.ts](https://github.com/Tahul/zidane/blob/main/ui/src/code/editor/reveal.ts).

## Functions

### `revealOnHighlight`

Function.

pierre's `onPostRender`, with whether the current render carries tokens.

```ts
function revealOnHighlight(
  host: HTMLElement,
  highlighted: boolean,
  phase: 'mount' | 'update' | 'unmount',
  colors?: boolean,
): void
```

**Parameters**

- `host` (`HTMLElement`): The `<diffs-container>` element; it carries the pending and held attributes.
- `highlighted` (`boolean`): Whether this render already has its syntax tokens.
- `phase` (`'mount' | 'update' | 'unmount'`): pierre's render phase: a mount without tokens holds the body back, an update with tokens reveals it, an unmount clears the host for the next mount.
- `colors?` (`boolean`, default `true`): Whether pierre colors this body at all (it leaves empty, plain-text and massive ones plain): only then are tokens pending.

Source: [ui/src/code/editor/reveal.ts:30](https://github.com/Tahul/zidane/blob/main/ui/src/code/editor/reveal.ts#L30)

## Constants

### `REVEAL_FALLBACK_MS`

Constant.

When a code body (a file, a diff) shows. pierre paints a body as plain text
first and recolors it once the highlight workers answer; shown at once,
that reads as a flash of uncolored code. A body that mounts without its
tokens is held back (`data-zg-pending` on the host) and eases in once they
land, or after `REVEAL_FALLBACK_MS` for text no grammar colors. One that
mounts highlighted (cached, a tab coming back) shows at once: nothing fades
twice. The styles are in `DIFFS_UNSAFE_CSS`. Apart from the hold, a host
whose tokens are coming carries `data-zg-highlight="pending"` until they
land (past the fallback too): tests and screenshots wait on it.

```ts
const REVEAL_FALLBACK_MS = 250
```

Source: [ui/src/code/editor/reveal.ts:12](https://github.com/Tahul/zidane/blob/main/ui/src/code/editor/reveal.ts#L12)
