Copy to clipboard without clipboard.js
What does this MR do and why?
Use native navigator methods to copy plain text to the clipboard so that it can be pasted properly in the new rich text editor in GitLab.
Clipboard.js also copied HTML content alongside plain text, and it is hard to detect what to paste when using the rich text editor. When copying content from a <pre>
tag, we only care about plain text, and the rich text should not be copied.
This change will allow people to copy examples from the Markdown docs page and paste directly in the rich text editor. This would fix gitlab#419106 (closed).
Browser support: https://caniuse.com/mdn-api_clipboard_writetext
Screenshots, screen recordings, or links to review app
No visible change.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
-
Configure a local GitLab Docs environment: https://gitlab.com/gitlab-org/gitlab-docs/-/blob/main/doc/setup.md. -
Go to the markdown docs page. -
Copy a code block. -
Paste in plain text / rich text editor in gitlab.
Merge request acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this merge request.