Add copy buttons to the API key displays
Reading the API key out of the settings panel meant selecting it by hand. The pre blocks are styled user-select: all, so a single click already selects the whole value, but nothing about them advertises that. Adds renderCopyableValue(), which pairs a pre block with an ExtraButtonComponent carrying the "copy" icon, and copyToClipboard(), which writes via navigator.clipboard and confirms with a Notice. The rejection path gets its own Notice rather than being swallowed: the notice is the button's only feedback, so a silent failure would be indistinguishable from success. Both the REST and MCP sections now show two forms of the key: the existing authorization header value, and the key on its own for tools that ask for it without the Bearer prefix. Each has its own button that copies exactly what is displayed, rather than one button copying something other than what the user is looking at. The second block is introduced with new prose so the two are not mistaken for duplicates. navigator.clipboard is permitted by obsidianmd/platform, which bans only navigator.userAgent and navigator.platform for OS detection; the plugin's own test suite asserts navigator.clipboard.writeText as valid. Verified by linting both calls. The API key control on the Advanced settings page does not get a button: it is a declarative text control, and SettingControlBase exposes no class or render hook to attach one to. No test coverage: src/main.ts has none today, and mocks/obsidian.ts lacks Setting, Notice, and the createEl/createDiv HTMLElement augmentations this code depends on. Covering it means building out that mock, which is a larger job than this change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A
Adam Coddington committed
fef66df51b7c78e78f8c85b48b828cfac2eec62c
Parent: caef5cb