diff --git a/site/contribute/index.html b/site/contribute/index.html index ea5ac4f2..9e4c3a9c 100644 --- a/site/contribute/index.html +++ b/site/contribute/index.html @@ -12,6 +12,8 @@ + + diff --git a/site/doc/copy-code.css b/site/doc/copy-code.css new file mode 100644 index 00000000..6585de5b --- /dev/null +++ b/site/doc/copy-code.css @@ -0,0 +1,50 @@ +/* Copy Code Button Styles */ +pre { + position: relative; +} + +pre code { + display: block; +} + +.copy-code-btn { + position: absolute; + top: 4px; + right: 8px; + padding: 6px; + background-color: rgba(255, 255, 255, 0.9); + color: #6b7280; + border: 1px solid rgba(0, 0, 0, 0.1); + border-radius: 6px; + cursor: pointer; + transition: all 0.2s ease; + z-index: 1000; + display: flex; + align-items: center; + justify-content: center; + width: 28px; + height: 28px; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); +} + +.copy-code-btn:hover { + background-color: #ffffff; + color: #374151; + border-color: rgba(0, 0, 0, 0.2); + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); +} + +.copy-code-btn:active { + transform: scale(0.95); +} + +.copy-code-btn.copied { + color: #337ab7; + border-color: #5dabf0; +} + +.copy-code-btn svg { + width: 18px; + height: 18px; + display: block; +} diff --git a/site/doc/copy-code.js b/site/doc/copy-code.js new file mode 100644 index 00000000..d7c1ca4d --- /dev/null +++ b/site/doc/copy-code.js @@ -0,0 +1,64 @@ +/** + * Add copy buttons to all code blocks on the page + */ +window.addEventListener('DOMContentLoaded', function() { + // Clipboard style icons + var copyIcon = ''; + var checkIcon = ''; + + // Add copy buttons to all pre/code blocks + document.querySelectorAll('pre').forEach(function(pre) { + // Skip if button already exists + if (pre.querySelector('.copy-code-btn')) return; + + // Create copy button + var btn = document.createElement('button'); + btn.className = 'copy-code-btn'; + btn.innerHTML = copyIcon; + btn.setAttribute('aria-label', 'Copy code to clipboard'); + btn.setAttribute('title', 'Copy code'); + + btn.onclick = function(e) { + e.preventDefault(); + var code = pre.querySelector('code') ? pre.querySelector('code').textContent : pre.textContent; + code = code.trim(); + + navigator.clipboard.writeText(code).then(function() { + btn.innerHTML = checkIcon; + btn.classList.add('copied'); + btn.setAttribute('title', 'Copied!'); + setTimeout(function() { + btn.innerHTML = copyIcon; + btn.classList.remove('copied'); + btn.setAttribute('title', 'Copy code'); + }, 2000); + }).catch(function(err) { + console.error('Failed to copy: ', err); + // Fallback for older browsers + var textArea = document.createElement('textarea'); + textArea.value = code; + textArea.style.position = 'fixed'; + textArea.style.left = '-999999px'; + textArea.style.top = '-999999px'; + document.body.appendChild(textArea); + textArea.select(); + try { + document.execCommand('copy'); + btn.innerHTML = checkIcon; + btn.classList.add('copied'); + btn.setAttribute('title', 'Copied!'); + setTimeout(function() { + btn.innerHTML = copyIcon; + btn.classList.remove('copied'); + btn.setAttribute('title', 'Copy code'); + }, 2000); + } catch (err) { + console.error('Copy command failed'); + } + document.body.removeChild(textArea); + }); + }; + + pre.appendChild(btn); + }); +}); diff --git a/site/doc/faq.html b/site/doc/faq.html index 5474186d..c2723ed8 100644 --- a/site/doc/faq.html +++ b/site/doc/faq.html @@ -12,6 +12,8 @@ + + diff --git a/site/doc/format.html b/site/doc/format.html index eb113de9..6ab6ea88 100644 --- a/site/doc/format.html +++ b/site/doc/format.html @@ -12,6 +12,8 @@ + + diff --git a/site/doc/index.html b/site/doc/index.html index cac655c0..46d63b72 100644 --- a/site/doc/index.html +++ b/site/doc/index.html @@ -12,6 +12,8 @@ + + diff --git a/site/doc/internals.html b/site/doc/internals.html index 1788a1da..310aef49 100644 --- a/site/doc/internals.html +++ b/site/doc/internals.html @@ -12,6 +12,8 @@ + + diff --git a/site/doc/quickstart.html b/site/doc/quickstart.html index a35532b3..3cd80924 100644 --- a/site/doc/quickstart.html +++ b/site/doc/quickstart.html @@ -12,6 +12,8 @@ + + diff --git a/site/doc/render.html b/site/doc/render.html index f208ce8e..e8a49319 100644 --- a/site/doc/render.html +++ b/site/doc/render.html @@ -12,6 +12,8 @@ + + diff --git a/site/doc/roadmap.html b/site/doc/roadmap.html index 275a28ad..bcd14369 100644 --- a/site/doc/roadmap.html +++ b/site/doc/roadmap.html @@ -12,6 +12,8 @@ + + diff --git a/site/doc/script.html b/site/doc/script.html index 05396f8e..25b0de69 100644 --- a/site/doc/script.html +++ b/site/doc/script.html @@ -12,6 +12,8 @@ + + diff --git a/site/doc/style.html b/site/doc/style.html index c536eca1..9fc5fb69 100644 --- a/site/doc/style.html +++ b/site/doc/style.html @@ -12,6 +12,8 @@ + + diff --git a/site/doc/symbols.html b/site/doc/symbols.html index 0c2e4625..00be53d6 100644 --- a/site/doc/symbols.html +++ b/site/doc/symbols.html @@ -12,6 +12,8 @@ + + diff --git a/site/doc/version.html b/site/doc/version.html index 265ebdab..2af37bde 100644 --- a/site/doc/version.html +++ b/site/doc/version.html @@ -12,6 +12,8 @@ + +