Debug Value Scrubbing

PreviousNext

Debug scrubber API for redacting values in thrown Plite errors.

Plite 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.

Install A Scrubber

import { setDebugValueScrubber } from "@platejs/plite";
 
setDebugValueScrubber((key, value) => {
  if (key === "text" || key === "src") return "[redacted]";
  return value;
});
import { setDebugValueScrubber } from "@platejs/plite";
 
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 Plite formats debug values.

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

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