Giter Club home page Giter Club logo

debug-menu's Introduction

debug-menu

Chrome-like "inspect element" context-menu for Electron

This module was extracted from electron-debug to keep it focused on its main features.

Travis Build Status npm module npm downloads

Context menu items

Inspect element

Inspect the clicked HTML element. It shows DevTools if it's not already opened.

Install

$ npm install --save-dev debug-menu

Usage

When you use this module in renderer process code, BrowserWindow instance need to be opened with node integration enabled.

We usually load this module only if the DEBUG environment variable is defined, to avoid end users of the app inadvertently opening DevTools.

const debugMenu = require('debug-menu');
debugMenu.install();  // activate context menu

// later, if needed
debugMenu.uninstall();  // deactivate context menu

API

debugMenu.install()

Activate context menu. This method add a listener on window DOM object contextmenu event.

debugMenu.middleware

Expose a middleware context menu that can be mounted with electron-contextmenu-middleware. See related example

debugMenu.uninstall()

Deactivate context menu. This method remove the listener on window object.

debugMenu.windowDebugMenu(win);

The debug Menu object template. You can use it to integrate with your own app context or BrowserWindow menu.

Arguments

  • win

BrowserWindow instance to use for this Menu.

Type: BrowserWindow
Default: the currently focused BrowserWindow.

Example

  // ... require electorn module

  const debugMenu = require('debug-menu');
  const win = new BrowserWindow();

  const menu = Menu.buildFromTemplate([{
    label: 'Debug',
    submenu: debugMenu.windowDebugMenu(win)
  }]);

  if (process.platform !== 'darwin') {
    win.setMenu(menu);
  } else {
    electron.Menu.setApplicationMenu(menu);
  }

  // ... show window

Middleware example

  const debugMenu = require('debug-menu').middleware;
  const context = require('electron-contextmenu-middleware');

  context.use(debugMenu);

  context.activate();

Related projects

License

The MIT License (MIT)

Copyright (c) 2016 Andrea Parodi

debug-menu's People

Contributors

bradstewart avatar parro-it avatar sindresorhus avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.