EditorCommandHandler.shouldAddToViewportMenu method
EditorCommandHandler › shouldAddToViewportMenu
Checks whether the command should appear in the markdown viewport (margin) context menu.That is the menu carrying
Readable line length / Line numbers / Inline title, raised by right-clicking the empty space beside the text or the line-number gutter — a menu shouldAddToEditorMenu can never reach, because a margin click lands outside the editor's contentDOM. It is a natural home for whole-note commands once the editor menu gets crowded.mode and source are passed through rather than filtered here: whether a command belongs in reading mode is the consuming plugin's call. Note that Obsidian 1.13.7 always passes 'gutter' as source, so only mode currently discriminates - see MarkdownViewportMenuEventHandler.Signature:
shouldAddToViewportMenu(_view: MarkdownView, _mode: string, _source: string): booleanParameters:
| Parameter | Type | Description |
|---|---|---|
| _view | MarkdownView | The markdown view the menu was raised over. |
| _mode | string | The view mode ('source' or 'preview'). |
| _source | string | What raised the menu. |
Returns: boolean — Whether to add to the viewport menu.