mirror of
https://github.com/jez500/pricebuddy.git
synced 2026-11-24 19:58:13 +01:00
Each context entry on the log message view gets a copy button that copies the value and shows a Filament success notification. The global clipboard success handler clears the text selection and only notifies when the trigger opts in via data-copy-notify, so the share-store button keeps its own inline feedback.
25 lines
664 B
JavaScript
25 lines
664 B
JavaScript
import pbChart from "./pbChart.js";
|
|
window.pbChart = pbChart;
|
|
|
|
const clipboard = new ClipboardJS('.copy-to-clipboard');
|
|
|
|
clipboard.on('success', (event) => {
|
|
// ClipboardJS selects the target to run execCommand('copy'); clear the
|
|
// highlight once the copy has completed.
|
|
event.clearSelection?.();
|
|
|
|
if (! event.trigger?.hasAttribute('data-copy-notify') || ! window.FilamentNotification) {
|
|
return;
|
|
}
|
|
|
|
new window.FilamentNotification()
|
|
.title('Copied to clipboard')
|
|
.success()
|
|
.send();
|
|
});
|
|
|
|
window.copyToClipboard = function (id) {
|
|
document.getElementById(id).select();
|
|
document.execCommand('copy');
|
|
}
|