hide-caret
Hides the text caret of the focused element for the length of a capture, so a frame does not depend on which phase of its blink the capture landed in.
A focused <input> or a focused editor blinks its caret about twice a second, and a capture photographs whichever phase it happens to catch. Two captures of an unchanged window therefore alternate between two byte streams: measured against Obsidian 1.14 at the 1200x800 store size, eight captures 170 ms apart gave 2 distinct PNGs for a focused modal input and 2 for a focused Markdown editor, and exactly 1 each once the caret was transparent.
caret-color: transparent, not blur(), and the difference is not cosmetic. Blurring does make the bytes stable too, but it is a state change the app observes: in the same run an open AbstractInputSuggest popover closed the moment its input lost focus, so a blur would photograph a different frame from the one the test built. It also drops the focus ring, which does not blink and is often part of what the frame is showing. Obsidian draws its editor caret natively (the CodeMirror cursor layer is empty), so one caret-color covers inputs and the editor alike.
Restored afterwards, unlike the vault name hideVaultName hides: the focused field is live state a test goes on typing into, and a caret that silently stayed invisible would be a surprise with no error attached.
captureObsidianScreenshot calls this by default. It is exported for the captures that cannot: captureDeviceScreenshot reads the device framebuffer over adb and has no page channel, and its typical frame — a field with the soft keyboard under it — is exactly the frame where blurring is wrong, since blurring would take the keyboard down with the focus.
Interfaces
Section titled “Interfaces”| Interface | Description |
|---|---|
| HiddenCaret | What hideCaret returns: whether a caret was hidden, and how to put it back. |
| HideCaretOptions | Options for hideCaret. |
Functions
Section titled “Functions”| Function | Description |
|---|---|
| hideCaret | Makes the caret of the focused element transparent, leaving the focus itself alone. The element is found through nested shadow roots, since document.activeElement stops at a shadow host and the caret belongs to the element inside it. Re-applying before a restore keeps the ORIGINAL value, so two hides and one restore still leave the element as it was found; a hide on a different element first restores the one an unrestored hide left behind. |