Merge commit 'a024bc7d76fcc5e49e8210f9b0896db9ef21861a'

This commit is contained in:
Bjørn Erik Pedersen
2025-02-13 10:40:34 +01:00
817 changed files with 5301 additions and 14766 deletions

View File

@@ -0,0 +1,36 @@
'use strict';
export function registerMagics(Alpine) {
Alpine.magic('copy', (currentEl) => {
return function (el) {
if (!el) {
el = currentEl;
}
// Select the element to copy.
let range = document.createRange();
range.selectNode(el);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
// Remove the selection after some time.
setTimeout(() => {
window.getSelection().removeAllRanges();
}, 500);
// Trim whitespace.
let text = el.textContent.trim();
navigator.clipboard.writeText(text);
};
});
Alpine.magic('isScrollX', (currentEl) => {
return function (el) {
if (!el) {
el = currentEl;
}
return el.clientWidth < el.scrollWidth;
};
});
}