Skip to content

Add copy YAML (automation & script) fallback without navigator.clipboard#7900

Merged
bramkragten merged 3 commits intohome-assistant:devfrom
spacegaier:issue-7899
Dec 10, 2020
Merged

Add copy YAML (automation & script) fallback without navigator.clipboard#7900
bramkragten merged 3 commits intohome-assistant:devfrom
spacegaier:issue-7899

Conversation

@spacegaier
Copy link
Copy Markdown
Member

Breaking change

Proposed change

The navigator.clipboard approach will only work with HTTPS. Add fallback for other use cases.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@spacegaier spacegaier changed the title Add copy fallback without navigator.clipboard Add copy YAML (automation & script) fallback without navigator.clipboard Dec 3, 2020
@bramkragten bramkragten added this to the 1.0.0 milestone Dec 4, 2020
document.execCommand("copy");
document.body.removeChild(el);
if (navigator.clipboard) {
navigator.clipboard.writeText(str);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This returns a promise, we should await it and catch any errors so we can fallback

@bramkragten bramkragten merged commit f9dece0 into home-assistant:dev Dec 10, 2020
@bramkragten bramkragten mentioned this pull request Dec 10, 2020
@spacegaier spacegaier deleted the issue-7899 branch December 10, 2020 19:03
@spacegaier spacegaier mentioned this pull request Dec 10, 2020
9 tasks
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy to Clipboard button on Automation Editor "Edit as YAML" mode doesn't work (0.1.0b0)

3 participants