hayun-vite 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Form/printForm.js +27 -56
package/package.json
CHANGED
package/src/Form/printForm.js
CHANGED
@@ -1,25 +1,8 @@
|
|
1
|
-
// import '../style.css'
|
2
|
-
// import '../fonts/Vazirmatn-Regular.woff2'
|
3
|
-
|
4
|
-
|
5
1
|
export default function printForm({ container }) {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
function print(paperForm) {
|
12
|
-
iframePrint(paperForm);
|
13
|
-
return new Date().toLocaleString("fa-IR");
|
14
|
-
}
|
15
|
-
|
16
|
-
function iframePrint(paperForm) {
|
17
|
-
const hideFrame = document.createElement("iframe");
|
18
|
-
let printDateTime;
|
19
|
-
hideFrame.onload = setPrint;
|
20
|
-
hideFrame.style.display = "block"; // hide iframe
|
21
|
-
|
22
|
-
let style = `
|
2
|
+
const iframe = document.createElement("iframe");
|
3
|
+
iframe.onload = setPrint;
|
4
|
+
iframe.style.display = "block";
|
5
|
+
let style = `
|
23
6
|
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100..900&display=swap');
|
24
7
|
|
25
8
|
@page {
|
@@ -88,39 +71,27 @@ export default function printForm({ container }) {
|
|
88
71
|
font-weight: bold;
|
89
72
|
}
|
90
73
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
document.body.appendChild(hideFrame);
|
115
|
-
|
116
|
-
return 1;
|
117
|
-
function setPrint() {
|
118
|
-
const closePrint = () => { document.body.removeChild(this); };
|
119
|
-
this.contentWindow.onbeforeunload = () => closePrint();
|
120
|
-
this.contentWindow.onafterprint = () => {
|
121
|
-
closePrint();
|
122
|
-
}
|
123
|
-
this.contentWindow.print();
|
124
|
-
}
|
125
|
-
}
|
74
|
+
`;
|
75
|
+
iframe.srcdoc = `
|
76
|
+
<!DOCTYPE html>
|
77
|
+
<html lang="en">
|
78
|
+
|
79
|
+
<head>
|
80
|
+
<meta charset="UTF-8">
|
81
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
82
|
+
<style>${style}</style>
|
83
|
+
</head>
|
84
|
+
|
85
|
+
<body>${container.outerHTML}</body>
|
86
|
+
|
87
|
+
</html>
|
88
|
+
`;
|
89
|
+
document.body.appendChild(iframe);
|
90
|
+
}
|
91
|
+
|
92
|
+
function setPrint() {
|
93
|
+
const closePrint = () => { document.body.removeChild(this); };
|
94
|
+
this.contentWindow.onbeforeunload = closePrint;
|
95
|
+
this.contentWindow.onafterprint = closePrint;
|
96
|
+
this.contentWindow.print();
|
126
97
|
}
|