Package for export pdf
This commit is contained in:
30
public/css/app/filament-export-0.3.0.css
Normal file
30
public/css/app/filament-export-0.3.0.css
Normal file
@@ -0,0 +1,30 @@
|
||||
.preview-table {
|
||||
background: white;
|
||||
color: black;
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
.preview-table td,
|
||||
.preview-table th {
|
||||
border-color: #ededed;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
font-size: 13px;
|
||||
line-height: 2;
|
||||
overflow: hidden;
|
||||
padding-left: 6px;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
.preview-table th {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.preview-table-wrapper {
|
||||
max-height: min(500px, 80vh);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
|
||||
36
public/js/app/filament-export-0.3.0.js
Normal file
36
public/js/app/filament-export-0.3.0.js
Normal file
@@ -0,0 +1,36 @@
|
||||
function onElementRemoved(element, callback) {
|
||||
new MutationObserver(function (mutations) {
|
||||
if (!document.body.contains(element)) {
|
||||
callback();
|
||||
this.disconnect();
|
||||
}
|
||||
}).observe(element.parentElement, { childList: true });
|
||||
}
|
||||
|
||||
function triggerInputEvent(statePath, value) {
|
||||
let input = document.getElementById(statePath);
|
||||
input.value = value;
|
||||
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
}
|
||||
|
||||
function printHTML(html, statePath, uniqueActionId) {
|
||||
let iframe = document.createElement("iframe");
|
||||
|
||||
let random = Math.floor(Math.random() * 99999);
|
||||
|
||||
iframe.id = `print-${random}`;
|
||||
|
||||
iframe.srcdoc = html;
|
||||
|
||||
document.body.append(iframe);
|
||||
|
||||
onElementRemoved(iframe, () => triggerInputEvent(statePath, `afterprint-${uniqueActionId}`));
|
||||
|
||||
iframe.contentWindow.onafterprint = () => document.getElementById(iframe.id).remove();
|
||||
|
||||
iframe.contentWindow.onload = () => iframe.contentWindow.print();
|
||||
}
|
||||
|
||||
window.triggerInputEvent = triggerInputEvent;
|
||||
|
||||
window.printHTML = printHTML;
|
||||
Reference in New Issue
Block a user