Skip to content

Commit

Permalink
Fix issue where HACS took over the clipbopard
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Jan 1, 2020
1 parent b2111c0 commit c4df84c
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/misc/LoveLaceHint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
css,
TemplateResult,
html,
property
property,
query
} from "lit-element";
import { Configuration, RepositoryData } from "../types";
import { HacsStyle } from "../style/hacs-style";
Expand All @@ -18,6 +19,7 @@ export class LoveLaceHint extends LitElement {
@property({ type: Object }) public configuration!: Configuration;
@property({ type: Object }) public hass!: HomeAssistant;
@property({ type: Object }) public repository!: RepositoryData;
@query("#LovelaceExample") private hint!: any;

protected render(): TemplateResult | void {
const pluginpath = `${this.repository.full_name.split("/")[1]}/${
Expand All @@ -41,22 +43,16 @@ export class LoveLaceHint extends LitElement {
<paper-icon-button
title="${localize(`repository.lovelace_copy_example`)}"
icon="mdi:content-copy"
id="CopyLLExample"
@click="${this.CopyToLovelaceExampleToClipboard}"
role="button"
></paper-icon-button>
</div>
`;
}

CopyToLovelaceExampleToClipboard(ev: any) {
var LLConfig = ev.composedPath()[4].children[0].children[1].innerText;

document.addEventListener("copy", (e: ClipboardEvent) => {
e.clipboardData.setData("text/plain", LLConfig);
e.preventDefault();
document.removeEventListener("copy", null);
});
document.execCommand("copy");
CopyToLovelaceExampleToClipboard() {
navigator.clipboard.writeText(this.hint.innerText);
}
static get styles(): CSSResultArray {
return [
Expand Down

0 comments on commit c4df84c

Please sign in to comment.