-
-
Save sergii/90a57ab0c8d221a4559dd8f62c331678 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller } from "stimulus"; | |
export default class extends Controller { | |
static targets = ["source"]; | |
copy() { | |
const range = document.createRange(); | |
window.getSelection().removeAllRanges(); | |
this.sourceTarget.classList.remove("hidden"); | |
range.selectNode(this.sourceTarget); | |
window.getSelection().addRange(range); | |
document.execCommand("copy"); | |
this.sourceTarget.classList.add("hidden"); | |
window.getSelection().removeAllRanges(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%div(data-controller="copy-html") | |
%button.btn-teal(data-action="copy-html#copy") | |
Copy | |
.hidden(data-copy-html-target="source") | |
%div(style="background: white; font-size: 11pt; font-family: Calibri; color: black;") | |
%br | |
%b(style="border: none;") Recent Changes | |
%br | |
%table(style="width: 800px") | |
%thead | |
%tr(style="font-weight: bold; color: white; background: #9F5B94; text-align: center;") | |
%td(style="border: 1.5pt solid black;") | |
Author | |
%td(style="border: 1.5pt solid black;") | |
Comments | |
%tbody | |
- @changes.each do |change| | |
%tr(style="background: white;") | |
%td(style="width: 200px; border: 1.5pt solid black; padding: 2px 10px") | |
= change.author.display_name | |
%td(style="border: 1.5pt solid black; padding: 2px 10px") | |
%ul | |
- change.comments.each do |c| | |
%li(style="border: none; margin: 0;")= c | |
%br |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment