Skip to content
Document Authoring DA  API Docs v1.22.1
npmGitHub

FindNamespace>= v1.19.0

FindNamespace:

{
open(opts?: { query?: string }): void;
close(): void;
search(query: string): Promise<Readonly<{ location: DocumentLocation; select: any }>[]>;
}

The Find namespace on DocAuthEditor. Lets hosts search the document or drive the editor’s Find bar programmatically.

// Open the Find bar with a preset query
editor.find.open({ query: 'hello' });
// Close it programmatically
editor.find.close();
// Drive a Find button in your own chrome
const toggleFind = () => (editor.find.getState().open ? editor.find.close() : editor.find.open());
// Search without opening or changing the Find bar
const occurrences = await editor.find.search('{{customer_name}}');
await occurrences[0]?.select();

open(opts?): void

Opens the Find bar and focuses its input.

Calling open() while the bar is already open with no state delta is a no-op — it does not refocus the input.

Optional overrides for the bar’s persisted state.

  • query — preset the search text. Overrides any persisted value.

string

void


close(): void

Closes the Find bar. Match decorations are cleared. Calling close() while already closed is a no-op.

void


getState(): object

Reads the current state of the Find bar.

Use this to keep host-rendered Find affordances in sync — the bar can also be opened with Mod+F and closed from inside the bar (Escape or its close button), so a host that tracks the state itself will drift.

object

An object with open — whether the Find bar is currently shown.

open: boolean


search(query): Promise<Readonly<{ location: DocumentLocation; select: Promise<boolean>; }>[]>

Searches the current document for literal text.

The returned matches are in the same logical document order as the built-in Find bar. Calling this method does not open or otherwise change the visible Find bar. Results are invalidated by the next content change, document replacement, or editor destruction.

string

Literal text to find. An empty query returns no results.

Promise<Readonly<{ location: DocumentLocation; select: Promise<boolean>; }>[]>

Selectable matches in document order.