Skip to content

Commit

Permalink
✨ Add Emoji Panel
Browse files Browse the repository at this point in the history
✨ Add Auto-save support
✨ Add about
📦 Bump version to 0.1.0
  • Loading branch information
SimonShiki committed Jan 9, 2023
1 parent 0ea157a commit a988ca5
Show file tree
Hide file tree
Showing 16 changed files with 251 additions and 42 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: nightly
releaseName: 'Typability Nightly'
releaseBody: 'Here is a Typability Night Build.'
releaseDraft: false
prerelease: true
tagName: __VERSION__
releaseName: 'Typability __VERSION__'
releaseBody: 'Write here'
releaseDraft: true
prerelease: false
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "typability",
"private": true,
"version": "0.0.0",
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
110 changes: 91 additions & 19 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "typability"
version = "0.0.0"
description = "A Tauri App"
authors = ["you"]
version = "0.1.0"
description = "a WYSIWYG markdown editor based on Milkdown."
authors = ["SimonShiki"]
license = ""
repository = ""
edition = "2021"
Expand All @@ -20,6 +20,7 @@ tauri = { version = "1.2", features = ["api-all"] }
window-vibrancy = "0.3.2"
window-shadows = "0.2.1"
os_info = "3.5.1"
rdev = "0.5.2"

[features]
# by default Tauri runs in production mode
Expand Down
22 changes: 19 additions & 3 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,34 @@
windows_subsystem = "windows"
)]

use rdev::{simulate, Button, EventType, Key, SimulateError};
use std::{thread, time};

mod setup;

fn send(event_type: &EventType) {
let delay = time::Duration::from_millis(20);
match simulate(event_type) {
Ok(()) => (),
Err(SimulateError) => {
println!("We could not send {:?}", event_type);
}
}
// Let ths OS catchup (at least MacOS)
thread::sleep(delay);
}

// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
fn open_emoji_panel() {
send(&EventType::KeyPress(Key::MetaLeft));
send(&EventType::KeyPress(Key::Dot));
}

fn main() {
tauri::Builder::default()
.setup(setup::init)
.invoke_handler(tauri::generate_handler![greet])
.invoke_handler(tauri::generate_handler![open_emoji_panel])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "Typability",
"version": "0.0.0"
"version": "0.1.0"
},
"tauri": {
"allowlist": {
Expand Down
22 changes: 20 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styles from './App.module.scss';
import TitleBar from "./components/TitleBar";
import { useAtom } from "jotai";
import { contentJotai, filePathJotai } from "./jotais/file";
import { loadingJotai, preferenceJotai } from "./jotais/ui";
import { aboutJotai, loadingJotai, preferenceJotai } from "./jotais/ui";
import classNames from "classnames";
import { Spinner } from "@fluentui/react-components";
import { useLayoutEffect } from "react";
Expand All @@ -13,16 +13,31 @@ import useIsDarkMode from "./hooks/dark";
import Preferences from "./components/Preferences";
import { writeTextFile } from '@tauri-apps/api/fs';
import { settingsJotai } from "./jotais/settings";
import { useKeyPress } from "ahooks";
import { useKeyPress, useInterval, useEventListener } from "ahooks";
import About from "./components/About";

function App() {
const [content, setContent] = useAtom(contentJotai);
const [filePath] = useAtom(filePathJotai);
const [loading] = useAtom(loadingJotai);
const [settings] = useAtom(settingsJotai);
const [preference, setPreference] = useAtom(preferenceJotai);
const [about, setAbout] = useAtom(aboutJotai);
const isDarkMode = useIsDarkMode();

// Auto save
useInterval(async () => {
if (filePath === null) return;
await writeTextFile({ path: filePath, contents: content });
}, settings.autoSave ? settings.saveInterval * 1000 : -1);

// Save when editor blurred
useEventListener('blur', async () => {
if (!settings.saveBlur || filePath === null) return;
await writeTextFile({ path: filePath, contents: content });
});

// Shortcuts
useKeyPress('ctrl.s', async () => {
if (filePath === null) return;
await writeTextFile({ path: filePath, contents: content });
Expand Down Expand Up @@ -63,6 +78,9 @@ function App() {
<Preferences open={preference} onClose={() => {
setPreference(false);
}} />
<About open={about} onClose={() => {
setAbout(false);
}} />
</div>
</FluentProvider>
);
Expand Down
1 change: 0 additions & 1 deletion src/assets/react.svg

This file was deleted.

1 change: 1 addition & 0 deletions src/assets/typability-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a988ca5

Please sign in to comment.