Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
954 changes: 637 additions & 317 deletions src-tauri/Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ opener = { version = "0.7", features = ["reveal"] }
chrono = "0.4"
env_logger = "0.11.8"
log = "0.4.29"
font-kit = "0.14"


[target.'cfg(windows)'.dependencies]
Expand Down
13 changes: 12 additions & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ fn is_win11() -> bool {
false
}

#[tauri::command]
fn get_system_fonts() -> Vec<String> {
use font_kit::source::SystemSource;
let source = SystemSource::new();
let mut families = source.all_families().unwrap_or_default();
families.sort();
families.dedup();
families
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
#[cfg(target_os = "linux")]
Expand Down Expand Up @@ -373,7 +383,8 @@ pub fn run() {
watch_file,
unwatch_file,
show_window,
save_theme
save_theme,
get_system_fonts
])
.build(tauri::generate_context!())
.expect("error while building tauri application")
Expand Down
24 changes: 22 additions & 2 deletions src/lib/MarkdownViewer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { open, save, ask } from '@tauri-apps/plugin-dialog';
import Installer from './Installer.svelte';
import Uninstaller from './Uninstaller.svelte';
import Settings from './components/Settings.svelte';
import TitleBar from './components/TitleBar.svelte';
import Editor from './components/Editor.svelte';
import Modal from './components/Modal.svelte';
Expand All @@ -18,6 +19,7 @@
import DOMPurify from 'dompurify';
import HomePage from './components/HomePage.svelte';
import { tabManager } from './stores/tabs.svelte.js';
import { settings } from './stores/settings.svelte.js';

// syntax highlighting & latex
let hljs: any = $state(null);
Expand All @@ -29,6 +31,8 @@

let mode = $state<'loading' | 'app' | 'installer' | 'uninstall'>('loading');

let showSettings = $state(false);

let recentFiles = $state<string[]>([]);
let isFocused = $state(true);
let markdownBody = $state<HTMLElement | null>(null);
Expand Down Expand Up @@ -1336,6 +1340,7 @@
ontoggleFullWidth={() => (isFullWidth = !isFullWidth)}
{theme}
onSetTheme={(t) => (theme = t)}
onopenSettings={() => (showSettings = true)}
oncloseTab={(id) => {
canCloseTab(id).then((can) => {
if (can) tabManager.closeTab(id);
Expand Down Expand Up @@ -1382,15 +1387,22 @@
ontoggleFullWidth={() => (isFullWidth = !isFullWidth)}
{theme}
onSetTheme={(t) => (theme = t)}
onopenSettings={() => (showSettings = true)}
oncloseTab={(id) => {
canCloseTab(id).then((can) => {
if (can) tabManager.closeTab(id);
});
}} />

<Settings show={showSettings} {theme} onSetTheme={(t) => (theme = t)} onclose={() => (showSettings = false)} />

{#if tabManager.activeTab && (tabManager.activeTab.path !== '' || tabManager.activeTab.title !== 'Recents') && !showHome}
{#key tabManager.activeTabId}
<div class="markdown-container" style="zoom: {isEditing && !isSplit ? 1 : zoomLevel / 100}" onwheel={handleWheel} role="presentation">
<div
class="markdown-container"
style="zoom: {isEditing && !isSplit ? 1 : zoomLevel / 100}; --code-font: {settings.codeFont}, monospace; --code-font-size: {settings.codeFontSize}px"
onwheel={handleWheel}
role="presentation">
<div class="layout-container" class:split={isSplit} class:editing={isEditing}>
<!-- Editor Pane -->
<div class="pane editor-pane" class:active={isEditing || isSplit} style="flex: {isSplit ? tabManager.activeTab.splitRatio : isEditing ? 1 : 0}">
Expand Down Expand Up @@ -1430,7 +1442,7 @@
bind:innerHTML={htmlContent}
onscroll={handleScroll}
tabindex="-1"
style="outline: none;">
style="outline: none; font-family: {settings.previewFont}, sans-serif; font-size: {settings.previewFontSize}px;">
</article>
</div>
</div>
Expand Down Expand Up @@ -1506,6 +1518,14 @@
transform: translate3d(0, 0, 0);
}

.markdown-container :global(.markdown-body pre),
.markdown-container :global(.markdown-body pre code),
.markdown-container :global(.markdown-body pre tt),
.markdown-container :global(.markdown-body code) {
font-family: var(--code-font, Consolas, monospace) !important;
font-size: var(--code-font-size, 14px) !important;
}

.markdown-body.full-width {
padding: 50px;
max-width: 100%;
Expand Down
5 changes: 4 additions & 1 deletion src/lib/components/Editor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@
lineNumbers: settings.lineNumbers as 'on' | 'off' | 'relative' | 'interval',
renderLineHighlight: settings.renderLineHighlight ? 'line' : 'none',
occurrencesHighlight: settings.occurrencesHighlight ? 'singleFile' : 'off',
fontSize: settings.editorFontSize,
fontFamily: settings.editorFont,
});

if (tabManager.activeTab?.editorViewState) {
Expand Down Expand Up @@ -536,7 +538,8 @@
lineNumbers: settings.lineNumbers as 'on' | 'off' | 'relative' | 'interval',
renderLineHighlight: settings.renderLineHighlight as 'line' | 'none',
occurrencesHighlight: settings.occurrencesHighlight ? 'singleFile' : 'off',
fontSize: 14 * (zoomLevel / 100),
fontSize: settings.editorFontSize * (zoomLevel / 100),
fontFamily: settings.editorFont,
});
}
});
Expand Down
15 changes: 9 additions & 6 deletions src/lib/components/HomePage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,19 @@
<p class="empty-recent">Your recently opened files will appear here.</p>
{/if}
</div>
<div class="version-tag">v{version}</div>
</div>
<div class="version-tag">v{version}</div>

<style>
.message {
display: flex;
flex-direction: column;
justify-content: center;
margin-top: 32px;
align-items: center;
user-select: none;
font-family: var(--win-font);
height: 90vh;
height: 100vh;
width: 100%;
padding-top: 32px 20px 0px 20px;
box-sizing: border-box;
color: var(--color-fg-default);
opacity: 0.8;
Expand Down Expand Up @@ -297,8 +295,13 @@
}

.version-tag {
margin-top: auto;
padding-bottom: 20px;
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
width: 100%;
text-align: center;
font-family: var(--win-font);
font-size: 10px;
opacity: 0.25;
font-weight: 500;
Expand Down
Loading