mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Use inlined context menu from package.json when available
This commit is contained in:
@@ -8,6 +8,11 @@ Grim = require 'grim'
|
||||
MenuHelpers = require './menu-helpers'
|
||||
{validateSelector} = require './selector-validator'
|
||||
|
||||
try
|
||||
platformContextMenu = require('../package.json')?._atomMenu?['context-menu']
|
||||
catch error
|
||||
platformContextMenu = null
|
||||
|
||||
SpecificityCache = {}
|
||||
|
||||
# Extended: Provides a registry for commands that you'd like to appear in the
|
||||
@@ -49,10 +54,13 @@ class ContextMenuManager
|
||||
atom.keymaps.onDidLoadBundledKeymaps => @loadPlatformItems()
|
||||
|
||||
loadPlatformItems: ->
|
||||
menusDirPath = path.join(@resourcePath, 'menus')
|
||||
platformMenuPath = fs.resolve(menusDirPath, process.platform, ['cson', 'json'])
|
||||
map = CSON.readFileSync(platformMenuPath)
|
||||
atom.contextMenu.add(map['context-menu'])
|
||||
if platformContextMenu?
|
||||
@add(platformContextMenu)
|
||||
else
|
||||
menusDirPath = path.join(@resourcePath, 'menus')
|
||||
platformMenuPath = fs.resolve(menusDirPath, process.platform, ['cson', 'json'])
|
||||
map = CSON.readFileSync(platformMenuPath)
|
||||
@add(map['context-menu'])
|
||||
|
||||
# Public: Add context menu items scoped by CSS selectors.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user