Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions css/docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,94 @@ i.bi.bi-copy.copy_btn {
color: #1361DF;
}

.md-actions-bar {
display: flex;
justify-content: flex-end;
margin-bottom: .75rem;
}
.md-actions {
position: relative;
}
.md-actions-toggle,
.md-actions-item {
font: inherit;
font-size: 13px;
color: #3c4257;
background: #ffffff;
cursor: pointer;
}
.md-actions-toggle {
display: inline-flex;
align-items: center;
gap: .5rem;
padding: .35rem .5rem .35rem .65rem;
border: 1px solid #d8dbe3;
border-radius: 6px;
}
.md-actions-toggle:hover,
.md-actions-toggle[aria-expanded="true"] {
border-color: rgba(75, 103, 249, 1);
color: rgba(75, 103, 249, 1);
}
.md-actions-toggle-label {
display: inline-flex;
align-items: center;
gap: .4rem;
}
.md-actions-toggle-chev {
display: inline-flex;
padding-left: .4rem;
border-left: 1px solid #e3e5ec;
}
.md-actions .chev {
transition: transform .15s ease-in-out;
}
.md-actions-toggle[aria-expanded="true"] .chev {
transform: rotate(180deg);
}
.md-actions-menu {
position: absolute;
top: calc(100% + 4px);
right: 0;
z-index: 1020;
display: none;
min-width: 235px;
padding: .25rem;
background: #ffffff;
border: 1px solid #e3e5ec;
border-radius: 8px;
box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
}
.md-actions-menu.show {
display: block;
}
.md-actions-item {
display: flex;
align-items: center;
gap: .5rem;
width: 100%;
padding: .45rem .55rem;
border: 0;
border-radius: 6px;
background: transparent;
text-align: left;
text-decoration: none;
white-space: nowrap;
}
.md-actions-item:hover {
color: rgba(75, 103, 249, 1);
background: #f2f4fb;
text-decoration: none;
}
.md-actions-toggle svg,
.md-actions-item svg {
flex: none;
width: 16px;
height: 16px;
stroke-linecap: round;
stroke-linejoin: round;
}

/*RESPONSIVE*/

@media (max-width: 767.98px) {
Expand Down
58 changes: 58 additions & 0 deletions js/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,61 @@ document.addEventListener("DOMContentLoaded", function () {

document.getElementById("current-year").textContent = new Date().getFullYear().toString();
});

function closeMdActionsMenus(except) {
document.querySelectorAll('.md-actions-toggle[aria-expanded="true"]').forEach(function (toggle) {
if (toggle === except) {
return;
}
toggle.setAttribute('aria-expanded', 'false');
toggle.parentNode.querySelector('.md-actions-menu').classList.remove('show');
});
}

function toggleMdActionsMenu(toggle) {
var expanded = toggle.getAttribute('aria-expanded') === 'true';
closeMdActionsMenus(toggle);
toggle.setAttribute('aria-expanded', expanded ? 'false' : 'true');
toggle.parentNode.querySelector('.md-actions-menu').classList.toggle('show', ! expanded);
}

function copyMarkdownPage(button) {
var label = button.querySelector('.label');
var original = label.textContent;

var restore = function (message) {
label.textContent = message;
window.setTimeout(function () {
label.textContent = original;
}, 2000);
};

fetch(button.dataset.copyUrl, {headers: {'Accept': 'text/markdown, text/plain'}})
.then(function (response) {
if (! response.ok) {
throw new Error('HTTP ' + response.status);
}
return response.text();
})
.then(function (markdown) {
return navigator.clipboard.writeText(markdown);
})
Comment on lines +64 to +66

@alexmerlin alexmerlin Jul 31, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.then(function (markdown) {
return navigator.clipboard.writeText(markdown);
})
.then(async function (markdown) {
return await navigator.clipboard.writeText(markdown);
})

If you don't wait, then if writeText fails (very unlikely, but possible), the user would see a transition like this:
"Copy Page" -> "Copied" -> "Copy failed" -> "Copy Page"
With an async flow, the messages would show up correctly.

The above is not tested - please test it first!

.then(function () {
restore('Copied!');
})
.catch(function () {
restore('Copy failed');
});
}

document.addEventListener('click', function (event) {
if (! event.target.closest('.md-actions')) {
closeMdActionsMenus();
}
});

document.addEventListener('keydown', function (event) {
if (event.key === 'Escape') {
closeMdActionsMenus();
}
});