We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent deca402 commit 5b424bbCopy full SHA for 5b424bb
src/components/ContentNode/CodeListing.vue
@@ -22,6 +22,7 @@
22
>{{ fileName }}
23
</Filename>
24
<div class="container-general">
25
+ <button class="copy-button" @click="copyToClipboard">Copy</button>
26
<!-- Do not add newlines in <pre>, as they'll appear in the rendered HTML. -->
27
<pre><CodeBlock><template
28
v-for="(line, index) in syntaxHighlightedLines"
@@ -122,6 +123,13 @@ export default {
122
123
line === '' ? '\n' : line
124
));
125
},
126
+ copyToClipboard() {
127
+ const lines = this.content;
128
+ const text = lines.join('\n');
129
+ navigator.clipboard.writeText(text)
130
+ .then(() => console.log('Copied!'))
131
+ .catch(err => console.error('Failed to copy: ', err));
132
+ },
133
134
};
135
</script>
0 commit comments