Skip to content

support Copy as HTML in the terminal#144784

Merged
meganrogge merged 7 commits intomainfrom
merogge/copyAsHtml
Mar 14, 2022
Merged

support Copy as HTML in the terminal#144784
meganrogge merged 7 commits intomainfrom
merogge/copyAsHtml

Conversation

@meganrogge
Copy link
Collaborator

This PR fixes #20813

e.clipboardData.setData('text/html', selectionAsHtml);
e.preventDefault();
}
document.addEventListener('copy', listener);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried clipboard.writeHTML and that worked, but was complaining about the cross platform import violation from electron

Copy link
Collaborator Author

@meganrogge meganrogge Mar 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also tried

const type = 'text/html';
const blob = new Blob([selectionAsHtml], { type });
const data = [new ClipboardItem({ [type]: blob })];
await navigator.clipboard.write(data);

per the notebook API example, but hit this known issue

Screen Shot 2022-03-09 at 3 38 11 PM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rebornix do you have any thoughts/experiences here? I'd really prefer to use the navigator.clipboard API.

@meganrogge does it work if you request permissions via navigator.permission explicitly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@meganrogge meganrogge self-assigned this Mar 9, 2022
@meganrogge meganrogge requested a review from Tyriar March 9, 2022 21:39
@Tyriar Tyriar added this to the March 2022 milestone Mar 11, 2022
@meganrogge meganrogge requested a review from Tyriar March 14, 2022 14:29
@meganrogge meganrogge merged commit 04f6cdc into main Mar 14, 2022
@meganrogge meganrogge deleted the merogge/copyAsHtml branch March 14, 2022 16:45
@github-actions github-actions bot locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pasted text copied from an interactive terminal should retain colors

2 participants