microsoft / microsoft/monaco-editor
[Bug] Copy/pasting multiline content with key:value format in Safari loses line breaks
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
Monaco Editor Playground Code
const value = /* set from `myEditor.getModel()`: */ `key: thing
otherkey: stuff
foo: bar
key : thing
otherkey : stuff
foo : bar
---
key: thing
otherkey: stuff
foo: bar
`;
// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
value,
language: "yaml",
automaticLayout: true,
});
Reproduction Steps
In Safari on MacOS, select multiple lines of text which are of the format key: value, and then paste in a plain text setting, e.g. VSCode, TextEdit, etc. Observe that the text is pasted without line endings - i.e. all on one line.
Note: If pasting into a rich text setting such as Notes app or another Monaco Editor then line endings are correctly preserved.
Actual (Problematic) Behavior
Text is pasted without line breaks.
https://github.com/microsoft/monaco-editor/assets/1550045/404a2e30-595c-47a1-b492-a931526ae516
Expected Behavior
Text is pasted with line breaks in tact.
Additional Context
Safari: Version 16.4 (18615.1.26.110.1)
MacOS: 13.3.1 (a)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Monaco Editor Playground link and the provided TypeScript reproduction, then reproduce the paste behavior in Safari using plain-text and rich-text targets. Trace the editor's clipboard handling for multiline key:value content. Done means pasting into a plain-text setting preserves all line breaks while the existing rich-text behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100