Skip to content

Commit

Permalink
feat(#202): Add clipboard library
Browse files Browse the repository at this point in the history
  • Loading branch information
Tweekism committed Feb 22, 2025
1 parent ce7a6ba commit 789a4de
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser/copycode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function copycode(md: MarkdownIt) {
<div class="pre-wrapper" style="position: relative">
${renderedPreBlock}
<div class="copy-wrapper">
<button class="copy-button">${copyIcon}</button>
<button class="copy-button" data-clipboard-text="TODO: Implement proper copy content">${copyIcon}</button>
</div>
</div>
`;
Expand Down
2 changes: 2 additions & 0 deletions src/routes/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ router.get(/.*/, async (req: Request, res: Response) => {
</script>
${config.scripts ? `<script type="text/javascript">${config.scripts}</script>` : ''}
<script type="module" src="/static/client.mjs"></script>
<script type="text/javascript" src="/static/copycode/clipboard.min.js"></script>
<script type="text/javascript" src="/static/copycode/client.js"></script>
</html>
`);
});
Expand Down
5 changes: 5 additions & 0 deletions static/copycode/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var clipboard = new ClipboardJS('.copy-button');

//TODO: Implement success callback

//TODO: Implement failure callback
7 changes: 7 additions & 0 deletions static/copycode/clipboard.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 789a4de

Please sign in to comment.