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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hayun-vite",
3
3
  "private": false,
4
- "version": "0.1.2",
4
+ "version": "0.1.3",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -1,25 +1,8 @@
1
- // import '../style.css'
2
- // import '../fonts/Vazirmatn-Regular.woff2'
3
-
4
-
5
1
  export default function printForm({ container }) {
6
- // const paperForm = document.getElementById(elementID);
7
- const paperForm = container;
8
-
9
- print(paperForm);
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
- hideFrame.srcdoc = `
93
- <!DOCTYPE html>
94
- <html lang="en">
95
-
96
- <head>
97
- <meta charset="UTF-8">
98
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
99
- <title></title>
100
-
101
-
102
-
103
- <style>${style}</style>
104
- </head>
105
-
106
- <body>${paperForm.outerHTML}</body>
107
-
108
- <script type="module">
109
- console.log('fdfd')
110
- </script>
111
-
112
- </html>
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
  }