> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/pfrankov/obsidian-local-gpt/llms.txt
> Use this file to discover all available pages before exploring further.

# Context Menu

> Access AI assistant actions via context menu on selected text

The context menu feature allows you to quickly access AI assistant actions by opening a menu on your selected text.

## How to Use

### Opening the Context Menu

There are two ways to access the context menu:

1. **Configure a Hotkey** (Recommended):
   * Open Obsidian Settings
   * Go to **Hotkeys**
   * Search for "Local GPT: Show context menu"
   * Click the `+` icon and set your preferred hotkey (e.g., `⌘ + M` or `Ctrl + M`)

2. **Command Palette**:
   * Open the command palette (`⌘/Ctrl + P`)
   * Search for "Local GPT: Show context menu"

### Using the Context Menu

1. Select the text you want to process
2. Trigger the context menu using your configured hotkey
3. Choose an action from the menu
4. The AI will process your selection and insert the result

<img width="600" alt="Context Menu Demo" src="https://github.com/pfrankov/obsidian-local-gpt/assets/584632/724d4399-cb6c-4531-9f04-a1e5df2e3dad" />

## Default Actions

Local GPT comes with several built-in actions:

<CardGroup cols={2}>
  <Card title="Continue Writing" icon="pen">
    Generates a continuation of your selected text
  </Card>

  <Card title="Summarize Text" icon="compress">
    Creates a concise summary of the selected content
  </Card>

  <Card title="Fix Spelling and Grammar" icon="spell-check">
    Corrects spelling and grammatical errors
  </Card>

  <Card title="Find Action Items" icon="list-check">
    Extracts actionable tasks from your text
  </Card>

  <Card title="General Help" icon="circle-question">
    Uses your selected text as a prompt for any purpose
  </Card>

  <Card title="New System Prompt" icon="plus">
    Create custom actions tailored to your needs
  </Card>
</CardGroup>

## Quick Access Commands

You can also assign hotkeys to individual actions for even faster access:

1. Open **Hotkeys** in Obsidian Settings
2. Search for "Local GPT"
3. You'll see numbered commands like "1 | Continue writing", "2 | Summarize text", etc.
4. Assign hotkeys to your most-used actions

<CodeGroup>
  ```typescript src/main.ts theme={null}
  this.addCommand({
    id: "context-menu",
    name: I18n.t("commands.showContextMenu"),
    editorCallback: (editor: Editor) => {
      const contextMenu = new Menu();
      
      populateActionContextMenu(
        contextMenu,
        this.settings.actions,
        (action) => this.runAction(action, editor),
      );
      
      // Show menu at cursor position
      contextMenu.showAtPosition({
        x: fromRect.left,
        y: toRect.top + editorView.defaultLineHeight,
      });
    },
  });
  ```
</CodeGroup>

## Tips

<Tip>
  If no text is selected, the context menu actions will process the entire document.
</Tip>

<Warning>
  Press `Escape` to cancel any running action.
</Warning>

## Next Steps

<CardGroup cols={2}>
  <Card title="Action Palette" icon="palette" href="/features/action-palette">
    Learn about the Action Palette for one-time actions
  </Card>

  <Card title="Enhanced Actions" icon="sparkles" href="/features/enhanced-actions">
    Discover how to use RAG for context-aware actions
  </Card>
</CardGroup>
