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 +1 -1
- package/src/Form/Form.js +1 -0
- package/src/Form/printForm.js +30 -56
package/package.json
CHANGED
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
|
|
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 {
|
@@ -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
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
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
|
}
|