Skip to content

Commit afb559d

Browse files
committed
attempt at printing
1 parent 29b3206 commit afb559d

File tree

4 files changed

+65
-37
lines changed

4 files changed

+65
-37
lines changed

index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
5-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
65
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Tauri + Svelte + TS</title>
86
</head>
97

108
<body>

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tauri-build = { version = "1.2", features = [] }
1616
[dependencies]
1717
serde_json = "1.0"
1818
serde = { version = "1.0", features = ["derive"] }
19-
tauri = { version = "1.2", features = ["dialog-open", "dialog-save", "fs-read-file", "fs-write-file", "shell-open", "window-center", "window-close", "window-create", "window-hide", "window-maximize", "window-minimize", "window-set-decorations", "window-set-focus", "window-set-fullscreen", "window-set-icon", "window-show", "window-start-dragging", "window-unmaximize", "window-unminimize"] }
19+
tauri = { version = "1.2", features = ["dialog-open", "dialog-save", "fs-read-file", "fs-write-file", "shell-open", "window-center", "window-close", "window-create", "window-hide", "window-maximize", "window-minimize", "window-print", "window-set-decorations", "window-set-focus", "window-set-fullscreen", "window-set-icon", "window-show", "window-start-dragging", "window-unmaximize", "window-unminimize"] }
2020

2121
[features]
2222
# by default Tauri runs in production mode

src/lib/Menu.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<script lang="ts">
22
import { makeEmptyFile, openFile, saveFile } from "./scripts/file";
3-
import {window} from "@tauri-apps/api";
4-
53
64
export let open;
75
export let button;
@@ -50,7 +48,8 @@
5048
</li>
5149
<!-- svelte-ignore a11y-click-events-have-key-events -->
5250
<li class="menu-item" on:click={() => {
53-
// print the content somehow idk
51+
//TODO: fix content from getting cutoff somehow
52+
window.print();
5453
}}>
5554
<div>Print...</div><div class="shortcut">Ctrl + P</div>
5655
</li>

src/style.css

Lines changed: 62 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,90 @@
11
:root {
2-
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
3-
font-size: 16px;
4-
line-height: 24px;
5-
font-weight: 400;
2+
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
3+
font-size: 16px;
4+
line-height: 24px;
5+
font-weight: 400;
66

7-
font-synthesis: none;
8-
text-rendering: optimizeLegibility;
9-
-webkit-font-smoothing: antialiased;
10-
-moz-osx-font-smoothing: grayscale;
11-
-webkit-text-size-adjust: 100%;
7+
font-synthesis: none;
8+
text-rendering: optimizeLegibility;
9+
-webkit-font-smoothing: antialiased;
10+
-moz-osx-font-smoothing: grayscale;
11+
-webkit-text-size-adjust: 100%;
1212
}
13+
1314
body {
14-
margin: 0;
15-
padding: 0;
16-
position: relative;
15+
margin: 0;
16+
padding: 0;
17+
position: relative;
1718
}
1819

19-
html, body {
20-
overflow: hidden;
20+
html,
21+
body {
22+
overflow: hidden;
2123
}
2224

2325
a {
24-
font-weight: 500;
25-
color: #646cff;
26-
text-decoration: inherit;
26+
font-weight: 500;
27+
color: #646cff;
28+
text-decoration: inherit;
2729
}
2830

2931
a:hover {
30-
color: #535bf2;
32+
color: #535bf2;
3133
}
3234

3335
h1 {
34-
text-align: center;
36+
text-align: center;
3537
}
3638

3739
input,
3840
button {
39-
border: none;
40-
background-color: transparent;
41-
outline: none;
41+
border: none;
42+
background-color: transparent;
43+
outline: none;
4244
}
4345

4446
button {
45-
cursor: pointer;
47+
cursor: pointer;
4648
}
4749

48-
ul, li {
49-
display: block;
50-
list-style: none;
51-
padding: 0;
52-
margin: 0;
50+
ul,
51+
li {
52+
display: block;
53+
list-style: none;
54+
padding: 0;
55+
margin: 0;
5356
}
5457

5558
#app {
56-
display: flex;
57-
flex-direction: column;
58-
height: 100vh;
59+
display: flex;
60+
flex-direction: column;
61+
height: 100vh;
62+
}
63+
64+
@media print {
65+
66+
* {
67+
overflow: visible !important;
68+
}
69+
body * {
70+
visibility: hidden;
71+
}
72+
73+
.cm-content,
74+
.cm-content * {
75+
visibility: visible;
76+
white-space: pre-wrap !important;
77+
word-wrap: break-word !important;
78+
page-break-inside: avoid !important;
79+
}
80+
81+
.cm-content {
82+
display: block;
83+
position: relative;
84+
width: auto;
85+
height: auto;
86+
top: 0;
87+
left: 0;
88+
color: black;
89+
}
5990
}

0 commit comments

Comments
 (0)