mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2026-09-22 08:44:55 -05:00
js: Define function for copy to clipboard and provide it in onClick
Instead of looping through all the code blocks at onload, just put an onClick tag in the HTML template, which calls a global function. This also improves the semantics since we aren't abusing href to be javascript. Also improves the writeText function call, since that method actually returns a Promise which we should be waiting on. It technically worked before because Promise starts executing instantly in JS, without being awaited.
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
<div class="code-block">
|
||||
<div class="code-block-header">
|
||||
<pre class="code-block-type">{{ $type }}</pre>
|
||||
<a href="javascript:void(0)" class="code-block-copy-button">
|
||||
{{/* https://blog.udemy.com/javascript-href/ */}}
|
||||
<a href="javascript:null" onClick="javascript:copy_to_clipboard(this)" class="code-block-copy-button">
|
||||
{{ i18n "copy_to_clipboard" }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user