Debug Value Scrubbing

PreviousNext

Slate formats some thrown error details with document values and nodes. Text fields are redacted by default. Apps that need stricter diagnostics can install a scrubber for additional fields.

import { setDebugValueScrubber } from '@platejs/slate'
 
setDebugValueScrubber((key, value) => {
  if (key === 'text' || key === 'src') return '[redacted]'
  return value
})
import { setDebugValueScrubber } from '@platejs/slate'
 
setDebugValueScrubber((key, value) => {
  if (key === 'text' || key === 'src') return '[redacted]'
  return value
})

Pass null or undefined to restore the default scrubber.

setDebugValueScrubber(null)
setDebugValueScrubber(null)

API

setDebugValueScrubber(scrubber?: DebugValueScrubber | null): void

Set the function used before Slate formats debug values.

type DebugValueScrubber = (key: string, value: unknown) => unknown
type DebugValueScrubber = (key: string, value: unknown) => unknown

The custom scrubber runs before Slate's default text redaction. Return the original value to let the default scrubber handle it.