hayun-vite 0.1.1 → 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.1",
4
+ "version": "0.1.3",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
package/src/Form/Form.js CHANGED
@@ -137,6 +137,7 @@ export default class Form {
137
137
  svg.setAttribute("style", "background-color: BlanchedAlmond");
138
138
  if (this.image) {
139
139
  let image = document.createElementNS(svgNS, "image");
140
+ image.setAttribute('class', 'non-print')
140
141
  image.setAttribute('width', width);
141
142
  image.setAttribute('height', height);
142
143
 
@@ -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 {
@@ -59,6 +42,9 @@ export default function printForm({ container }) {
59
42
  padding: 0;
60
43
  break-inside: avoid;
61
44
  }
45
+ .non-print {
46
+ display: none;
47
+ }
62
48
 
63
49
  }
64
50
 
@@ -85,39 +71,27 @@ export default function printForm({ container }) {
85
71
  font-weight: bold;
86
72
  }
87
73
 
88
- `;
89
- hideFrame.srcdoc = `
90
- <!DOCTYPE html>
91
- <html lang="en">
92
-
93
- <head>
94
- <meta charset="UTF-8">
95
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
96
- <title></title>
97
-
98
-
99
-
100
- <style>${style}</style>
101
- </head>
102
-
103
- <body>${paperForm.outerHTML}</body>
104
-
105
- <script type="module">
106
- console.log('fdfd')
107
- </script>
108
-
109
- </html>
110
- `;
111
- document.body.appendChild(hideFrame);
112
-
113
- return 1;
114
- function setPrint() {
115
- const closePrint = () => { document.body.removeChild(this); };
116
- this.contentWindow.onbeforeunload = () => closePrint();
117
- this.contentWindow.onafterprint = () => {
118
- closePrint();
119
- }
120
- this.contentWindow.print();
121
- }
122
- }
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();
123
97
  }