fix(desktop): fix can not past content on monaco editor #1917
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is the current behavior?
Monaco Editor's clipboard functionality, especially paste, doesn't work properly in Electron environments. The issue occurs because Monaco checks for
platform.isWeb
before using the clipboard service as a fallback whendocument.execCommand('paste')
fails. Since Electron isn't detected as a web platform (despite running in a Chromium environment), the clipboard functionality fails.This issue became more critical with Electron, where
execCommand('paste')
support was dropped entirely, making paste functionality unusable in the Monaco Editor.Issue Number
Related to microsoft/monaco-editor#4855
What is the new behavior?
This PR adds a patch script that removes the
platform.isWeb
check in Monaco Editor's clipboard implementation, allowing the clipboard service to be used in Electron environments. The patch is applied automatically after dependency installation.Specifically:
patch-monaco-clipboard.js
script that modifies the Monaco clipboard codepostinstall
script to run this patch after dependencies are installedMonaco Editor's paste functionality works properly in MQTTX when running in Electron with this patch.
Does this PR introduce a breaking change?
Specific Instructions
After merging this PR, anyone who installs dependencies will automatically get the patched version of Monaco Editor. If anyone is experiencing clipboard issues with Monaco Editor in the application, they should run:
This will reapply the patch and fix the issue.