## Summary Adds a "Copy as Markdown" button to the documentation toolbar that allows users to easily copy the raw markdown content of any documentation page. This feature is inspired by similar implementations on sites like [Better Auth docs](https://www.better-auth.com/docs/installation) and [Cloudflare Workers docs](https://developers.cloudflare.com/workers/) which provide easy ways for users to copy documentation content. ## Features - **Button placement**: Positioned between theme toggle and search icon for optimal UX - **Content fetching**: Retrieves raw markdown from GitHub's API for the current page - **Consistent styling**: Matches existing toolbar button patterns ## Test plan - [x] Copy functionality works on all documentation pages - [x] Toast notifications appear and disappear correctly - [x] Button icon animations work properly (spinner → checkmark → copy) - [x] Styling matches other toolbar buttons - [x] Works in both light and dark themes ## Screenshots The button appears as a copy icon between the theme and search buttons in the left toolbar. <img width="798" height="295" alt="image" src="https://github.com/user-attachments/assets/37d41258-d71b-40f8-b8fe-16eaa46b8d7f" /> <img width="1628" height="358" alt="image" src="https://github.com/user-attachments/assets/fc45bc04-a290-4a07-8d1a-a010a92be033" /> --------- Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
318 lines
14 KiB
Handlebars
318 lines
14 KiB
Handlebars
<!DOCTYPE HTML>
|
|
<html lang="{{ language }}" data-theme="{{ default_theme }}" data-color-scheme="{{ default_theme }}" dir="{{ text_direction }}">
|
|
<head>
|
|
<!-- Book generated using mdBook -->
|
|
<meta charset="UTF-8">
|
|
<title>{{ title }}</title>
|
|
{{#if is_print }}
|
|
<meta name="robots" content="noindex">
|
|
{{/if}}
|
|
{{#if base_url}}
|
|
<base href="{{ base_url }}">
|
|
{{/if}}
|
|
|
|
|
|
<!-- Custom HTML head -->
|
|
{{> head}}
|
|
|
|
<meta name="description" content="#description#">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="theme-color" content="#ffffff">
|
|
|
|
<link rel="shortcut icon" href="{{ path_to_root }}favicon.png">
|
|
<link rel="stylesheet" href="{{ path_to_root }}css/variables.css">
|
|
<link rel="stylesheet" href="{{ path_to_root }}css/general.css">
|
|
<link rel="stylesheet" href="{{ path_to_root }}css/chrome.css">
|
|
{{#if print_enable}}
|
|
<link rel="stylesheet" href="{{ path_to_root }}css/print.css" media="print">
|
|
{{/if}}
|
|
|
|
<!-- Fonts -->
|
|
<link rel="stylesheet" href="{{ path_to_root }}FontAwesome/css/font-awesome.css">
|
|
{{#if copy_fonts}}
|
|
<link rel="stylesheet" href="{{ path_to_root }}fonts/fonts.css">
|
|
{{/if}}
|
|
|
|
<!-- Highlight.js Stylesheets -->
|
|
<link rel="stylesheet" href="{{ path_to_root }}highlight.css">
|
|
<link rel="stylesheet" href="{{ path_to_root }}tomorrow-night.css">
|
|
<link rel="stylesheet" href="{{ path_to_root }}ayu-highlight.css">
|
|
|
|
<!-- Custom theme stylesheets -->
|
|
{{#each additional_css}}
|
|
<link rel="stylesheet" href="{{ ../path_to_root }}{{ this }}">
|
|
{{/each}}
|
|
|
|
{{#if mathjax_support}}
|
|
<!-- MathJax -->
|
|
<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
|
{{/if}}
|
|
</head>
|
|
<body class="sidebar-visible no-js">
|
|
<div id="body-container">
|
|
<!-- Provide site root to javascript -->
|
|
<script>
|
|
var path_to_root = "{{ path_to_root }}";
|
|
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}";
|
|
</script>
|
|
|
|
<!-- Support dark mode -->
|
|
<script>
|
|
var theme;
|
|
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
|
if (theme === null || theme === undefined) {
|
|
theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
}
|
|
var html = document.querySelector('html');
|
|
html.classList.remove('light', 'dark')
|
|
html.classList.add(theme);
|
|
var body = document.querySelector('body');
|
|
body.classList.remove('no-js')
|
|
body.classList.add('js');
|
|
</script>
|
|
|
|
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
|
|
|
|
<!-- Hide / unhide sidebar before it is displayed -->
|
|
<script>
|
|
var body = document.querySelector('body');
|
|
var sidebar = null;
|
|
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
|
|
if (document.body.clientWidth >= 1080) {
|
|
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
|
|
sidebar = sidebar || 'visible';
|
|
} else {
|
|
sidebar = 'hidden';
|
|
}
|
|
sidebar_toggle.checked = sidebar === 'visible';
|
|
body.classList.remove('sidebar-visible');
|
|
body.classList.add("sidebar-" + sidebar);
|
|
</script>
|
|
|
|
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
|
<div class="sidebar-scrollbox">
|
|
{{#toc}}{{/toc}}
|
|
</div>
|
|
<div style="display: none;" id="sidebar-resize-handle" class="sidebar-resize-handle">
|
|
<div class="sidebar-resize-indicator"></div>
|
|
</div>
|
|
</nav>
|
|
|
|
<!-- Track and set sidebar scroll position -->
|
|
<script>
|
|
var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
|
|
sidebarScrollbox.addEventListener('click', function(e) {
|
|
if (e.target.tagName === 'A') {
|
|
sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
|
|
}
|
|
}, { passive: true });
|
|
var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
|
|
sessionStorage.removeItem('sidebar-scroll');
|
|
if (sidebarScrollTop) {
|
|
// preserve sidebar scroll position when navigating via links within sidebar
|
|
sidebarScrollbox.scrollTop = sidebarScrollTop;
|
|
} else {
|
|
// scroll sidebar to current active section when navigating via "next/previous chapter" buttons
|
|
var activeSection = document.querySelector('#sidebar .active');
|
|
if (activeSection) {
|
|
activeSection.scrollIntoView({ block: 'center' });
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<div id="page-wrapper" class="page-wrapper">
|
|
<div class="page">
|
|
{{> header}}
|
|
<div id="menu-bar-hover-placeholder"></div>
|
|
<div id="menu-bar" class="menu-bar sticky">
|
|
<div class="left-buttons">
|
|
|
|
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
|
|
<i class="fa fa-bars"></i>
|
|
</label>
|
|
|
|
<button id="theme-toggle" class="icon-button" type="button" title="Change Theme" aria-label="Change Theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
|
|
<i class="fa fa-paint-brush"></i>
|
|
</button>
|
|
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
|
|
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="dark">Dark</button></li>
|
|
</ul>
|
|
|
|
<button id="copy-markdown-toggle" class="icon-button" type="button" title="Copy Page as Markdown" aria-label="Copy page as markdown">
|
|
<i class="fa fa-copy"></i>
|
|
</button>
|
|
|
|
{{#if search_enabled}}
|
|
<button id="search-toggle" class="icon-button" type="button" title="Search (s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
|
|
<i class="fa fa-search"></i>
|
|
</button>
|
|
{{/if}}
|
|
</div>
|
|
|
|
<header class="menu-title">
|
|
<a href="/">
|
|
<img src="https://zed.dev/logo_wordmark_1500.webp" alt="Zed Industries" style="height: 28px;">
|
|
</a>
|
|
</header>
|
|
|
|
<div class="right-buttons">
|
|
<a class="download-button" href="https://zed.dev/download" title="Download Zed" aria-label="Download Zed">
|
|
Download
|
|
</a>
|
|
{{#if git_repository_url}}
|
|
<a href="{{git_repository_url}}" title="Git repository" aria-label="Git repository">
|
|
<i id="git-repository-button" class="fa {{git_repository_icon}}"></i>
|
|
</a>
|
|
{{/if}}
|
|
{{#if git_repository_edit_url}}
|
|
<a href="{{git_repository_edit_url}}" title="Suggest an edit" aria-label="Suggest an edit">
|
|
<i id="git-edit-button" class="fa fa-edit"></i>
|
|
</a>
|
|
{{/if}}
|
|
</div>
|
|
</div>
|
|
|
|
{{#if search_enabled}}
|
|
<div id="search-wrapper" class="hidden">
|
|
<form id="searchbar-outer" class="searchbar-outer">
|
|
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
|
|
</form>
|
|
<div id="searchresults-outer" class="searchresults-outer hidden">
|
|
<div id="searchresults-header" class="searchresults-header"></div>
|
|
<ul id="searchresults">
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
{{/if}}
|
|
|
|
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
|
|
<script>
|
|
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
|
|
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
|
|
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
|
|
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
|
|
});
|
|
</script>
|
|
|
|
<div id="content" class="content">
|
|
<main>
|
|
<div class="sidetoc">
|
|
<nav class="pagetoc">
|
|
<p class="toc-title">On this page</p>
|
|
</nav>
|
|
</div>
|
|
{{{ content }}}
|
|
<div class="footer-buttons">
|
|
{{#previous}}
|
|
<a rel="prev" href="{{ path_to_root }}{{link}}" class="footer-button" title="{{title}}">
|
|
<i class="fa fa-angle-left"></i>
|
|
{{title}}
|
|
</a>
|
|
{{/previous}}
|
|
{{#next}}
|
|
<a rel="next" href="{{ path_to_root }}{{link}}" class="footer-button" title="{{title}}">
|
|
{{title}}
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
{{/next}}
|
|
</div>
|
|
</main>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{{#if live_reload_endpoint}}
|
|
<!-- Livereload script (if served using the cli tool) -->
|
|
<script>
|
|
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}";
|
|
const socket = new WebSocket(wsAddress);
|
|
socket.onmessage = function (event) {
|
|
if (event.data === "reload") {
|
|
socket.close();
|
|
location.reload();
|
|
}
|
|
};
|
|
|
|
window.onbeforeunload = function() {
|
|
socket.close();
|
|
}
|
|
</script>
|
|
{{/if}}
|
|
|
|
{{#if playground_line_numbers}}
|
|
<script>
|
|
window.playground_line_numbers = true;
|
|
</script>
|
|
{{/if}}
|
|
|
|
{{#if playground_copyable}}
|
|
<script>
|
|
window.playground_copyable = true;
|
|
</script>
|
|
{{/if}}
|
|
|
|
{{#if playground_js}}
|
|
<script src="{{ path_to_root }}ace.js"></script>
|
|
<script src="{{ path_to_root }}editor.js"></script>
|
|
<script src="{{ path_to_root }}mode-rust.js"></script>
|
|
<script src="{{ path_to_root }}theme-dawn.js"></script>
|
|
<script src="{{ path_to_root }}theme-tomorrow_night.js"></script>
|
|
{{/if}}
|
|
|
|
{{#if search_js}}
|
|
<script src="{{ path_to_root }}elasticlunr.min.js"></script>
|
|
<script src="{{ path_to_root }}mark.min.js"></script>
|
|
<script src="{{ path_to_root }}searcher.js"></script>
|
|
{{/if}}
|
|
|
|
<script src="{{ path_to_root }}clipboard.min.js"></script>
|
|
<script src="{{ path_to_root }}highlight.js"></script>
|
|
<script src="{{ path_to_root }}book.js"></script>
|
|
|
|
<!-- Custom JS scripts -->
|
|
{{#each additional_js}}
|
|
<script src="{{ ../path_to_root }}{{this}}"></script>
|
|
{{/each}}
|
|
|
|
{{#if is_print}}
|
|
{{#if mathjax_support}}
|
|
<script>
|
|
window.addEventListener('load', function() {
|
|
MathJax.Hub.Register.StartupHook('End', function() {
|
|
window.setTimeout(window.print, 100);
|
|
});
|
|
});
|
|
</script>
|
|
{{else}}
|
|
<script>
|
|
window.addEventListener('load', function() {
|
|
window.setTimeout(window.print, 100);
|
|
});
|
|
</script>
|
|
{{/if}}
|
|
{{/if}}
|
|
|
|
<script>
|
|
(function() {
|
|
var theme = localStorage.getItem('mdbook-theme');
|
|
var html = document.querySelector('html');
|
|
if (theme) {
|
|
html.setAttribute('data-theme', theme);
|
|
html.setAttribute('data-color-scheme', theme);
|
|
html.className = theme;
|
|
} else {
|
|
var systemPreference = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
html.setAttribute('data-theme', systemPreference);
|
|
html.setAttribute('data-color-scheme', systemPreference);
|
|
html.className = systemPreference;
|
|
}
|
|
})();
|
|
</script>
|
|
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|