VisBug Documentation
repository·main·Indexed 26 days ago
https://github.com/googlechromelabs/projectvisbugAn open-source web design debug tool that enables real-time editing of text, images, and layouts directly in the browser. Available as a browser extension, npm package, or a custom HTML element <vis-bug> with support for programmatic command execution via execCommand() and configurable color schemes.
What's inside VisBug
- You can add VisBug to your browser using the official extensions available for various platforms:
Install VisBug via npm
mainA Web Component version of VisBug is coming soon. You can currently install the package via npm.
npm i visbugGet started with VisBug
mainTo begin using VisBug, you can explore the following resources:
- Wiki: For detailed guides and documentation.
- Keyboard Master List: To learn the full suite of keyboard commands for efficient tinkering.
- CDN: Load VisBug directly from a CDN (example available on CodePen).
- Community: Join discussions on Gitter or Spectrum.
Use the VisBug Web Component
mainVisBug is exposed as a custom HTML element
<vis-bug>. When added to the DOM, it initializes the VisBug toolbar, provides design tools (like Move, Margin, Padding, Font, etc.), and enables hotkey interactions.Attributes
color-scheme: Sets the visual theme. Supported values areauto,light, ordark.color-mode: Sets the color format. Defaults tohex.tutsBaseURL: (Optional) The base URL for tool demonstration GIFs. Defaults totuts.
Interaction
- Tool Selection: Click a tool icon in the toolbar or use the registered hotkeys.
- Toggle Visibility: Use
metaKey + /ormetaKey + .to show/hide the VisBug interface. - Command Execution: You can execute plugin commands via the
execCommand(command)method.
Execute VisBug plugin commands via execCommand()
mainThe
execCommand(command)method allows you to programmatically trigger VisBug plugins. Thecommandstring is prefixed with a forward slash/internally to look up the plugin in thePluginRegistry.If a plugin is found, it is called with an object containing:
selected: The current selection from theselectorEngine.query: The command string (e.g.,'/command-name').
Returns a
Promisethat resolves to the plugin execution or anErrorif the query is not found.Get the currently active VisBug tool
mainYou can check which tool is currently active on the<vis-bug>element by accessing theactiveToolgetter. This returns the string value of thedata-toolattribute of the currently selected tool element.