Shortcuts and clipboard
Declare shortcuts to register host keyboard shortcuts and clipboard to write text. The clipboard service is write-only and requires a recent host-observed user interaction.
Copy text from a shortcut
Section titled “Copy text from a shortcut”cleanup.push( await api.shortcuts.register("Ctrl+Shift+X", () => { void api.clipboard.writeText("Copied by my plugin").catch(() => { api.logger.warn("Clipboard write failed; activate the shortcut again."); }); }),);Save the returned disposer and release it in stop. Avoid overlapping Fluxer’s existing shortcuts; expose the combination as a plugin setting if users need to change it.
Matching rules
Section titled “Matching rules”Shortcuts match exact modifiers and ignore repeats. Supported names are Ctrl, Shift, Alt, and Meta. Control and Cmd/Command are aliases. A modifier combination must match the actual event; extra modifiers do not count as the same shortcut. A shortcut must include Ctrl, Alt or Meta, or be a function key (F1 to F12) or Escape on its own; Shift alone doesn’t count, and anything else fails with invalid_shortcut, so a plain key can never capture the user’s typing.
Clipboard restrictions
Section titled “Clipboard restrictions”Writes are limited to 32,768 characters and must come within 1.5 seconds of a trusted user action in your plugin’s UI: a shortcut, inspection click, overlay action, composer attachment action, right-click menu item, decoration button, dialog submission, a click on a button under a view or running one of the plugin’s commands. Posted-file actions don’t count. One action allows one privileged call (clipboard, embed, message box text, link, recent messages or a server request).
A click inside your own frame, or one the sandbox generates, cannot manufacture host authorization; add view buttons instead. Do not defer clipboard work behind unrelated long-running operations. If authorization expires or a write fails, ask the user to activate the action again.
There is no clipboard-read API. Do not request broader privileges or use parent-page code to work around that boundary.
FluxPlugs is an independent project, not affiliated with or endorsed by Fluxer.