FindNamespace>= v1.19.0
FindNamespace:
{}The Find namespace on DocAuthEditor. Lets hosts search the document or drive
the editor’s Find bar programmatically.
Example
Section titled “Example”// Open the Find bar with a preset queryeditor.find.open({ query: 'hello' });
// Close it programmaticallyeditor.find.close();
// Drive a Find button in your own chromeconst toggleFind = () => (editor.find.getState().open ? editor.find.close() : editor.find.open());
// Search without opening or changing the Find barconst occurrences = await editor.find.search('{{customer_name}}');await occurrences[0]?.select();Methods
Section titled “Methods”open()
Section titled “open()”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.
Parameters
Section titled “Parameters”Optional overrides for the bar’s persisted state.
query— preset the search text. Overrides any persisted value.
query?
Section titled “query?”Returns
Section titled “Returns”close()
Section titled “close()”close():
void
Closes the Find bar. Match decorations are cleared. Calling close() while already
closed is a no-op.
Returns
Section titled “Returns”getState()
Section titled “getState()”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.
Returns
Section titled “Returns”An object with open — whether the Find bar is currently shown.
open:
boolean
search()
Section titled “search()”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.
Parameters
Section titled “Parameters”Literal text to find. An empty query returns no results.
Returns
Section titled “Returns”Promise<Readonly<{ location: DocumentLocation; select: Promise<boolean>; }>[]>
Selectable matches in document order.