Html
<link rel="stylesheet" href="{$ForumAdress}develop/transfonter/stylesheet.css" />
<script type="text/javascript" src="{$ForumAdress}look/ckeditor5/build/ckeditor.js"></script>
Java
document.addEventListener('DOMContentLoaded', (event) => {
// Initialize Highlight.js
document.querySelectorAll('pre code').forEach((block) => {
hljs.highlightBlock(block);
});
// Initialize line numbers
hljs.initLineNumbersOnLoad();
// Add copy buttons to code blocks
document.querySelectorAll('pre').forEach((block) => {
// Create a copy button
let button = document.createElement('button');
button.className = 'copy-button';
button.textContent = 'Copy';
// Append button to code block
block.appendChild(button);
});
// Initialize Clipboard.js
new ClipboardJS('.copy-button', {
target: function(trigger) {
return trigger.previousElementSibling;
}
});
// Add event listener for copy success
document.querySelectorAll('.copy-button').forEach((button) => {
button.addEventListener('click', () => {
button.textContent = 'Copied!';
setTimeout(() => {
button.textContent = 'Copy';
}, 2000);
});
});
});