Skip to content

fix: Ctrl+V paste not working in Firefox (SIMPL-39)#3350

Draft
thabotswana with Copilot wants to merge 2 commits into
trunkfrom
copilot/fix-ctrl-v-not-working
Draft

fix: Ctrl+V paste not working in Firefox (SIMPL-39)#3350
thabotswana with Copilot wants to merge 2 commits into
trunkfrom
copilot/fix-ctrl-v-not-working

Conversation

Copilot AI commented Mar 2, 2026

Copy link
Copy Markdown

In recent Firefox versions, Monaco never registers editor.action.clipboardPasteAction because its clipboard-support detection explicitly excludes Firefox (navigator.clipboard && !isFirefox) and document.queryCommandSupported('paste') now returns false (deprecated). The existing Ctrl+V keybinding silently fails with "command not found".

Changes

  • lib/note-content-editor.tsxeditorReady: After addKeybindingRules, check whether editor.action.clipboardPasteAction was registered. If not, register a fallback under the same ID using navigator.clipboard.readText() + editor.executeEdits():
if (!window.electron && !editor.getAction('editor.action.clipboardPasteAction')) {
  editor.addAction({
    id: 'editor.action.clipboardPasteAction',
    label: 'Paste',
    contextMenuGroupId: '9_cutcopypaste',
    contextMenuOrder: 2,
    run: () => {
      navigator.clipboard.readText().then((text) => {
        const selection = editor.getSelection();
        if (selection) {
          editor.executeEdits('paste', [
            { range: selection, text, forceMoveMarkers: true },
          ]);
        }
      }).catch(() => {
        // clipboard read failed (e.g., permission denied); nothing to paste
      });
    },
  });
}

Using the same action ID means the existing keybinding rule picks up the fallback transparently. The !window.electron + absence-of-action guard ensures Chrome, Safari, and Electron are unaffected.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

In newer Firefox versions, Monaco's `editor.action.clipboardPasteAction` is
never registered because Monaco's clipboard-support detection explicitly
excludes Firefox (`!isFirefox`) and `document.queryCommandSupported('paste')`
returns false (deprecated). The existing Ctrl+V keybinding silently fails.

Add a fallback: after the keybindingRules call, check whether
`editor.action.clipboardPasteAction` was registered; if not, register a
custom implementation with the same ID that uses `navigator.clipboard.readText()`
so the existing keybinding transparently picks it up.

This is guarded by `!window.electron` (browsers only) and only runs when
the built-in action is absent, so Chrome/Safari/Electron behaviour is unchanged.

Co-authored-by: thabotswana <35628116+thabotswana@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix ctrl-v keyboard shortcut for pasting in webapp fix: Ctrl+V paste not working in Firefox (SIMPL-39) Mar 2, 2026
@thabotswana

Copy link
Copy Markdown

@mdawaffe can I bug you for a review of this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants