Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
falk-werner committed Dec 21, 2023
0 parents commit a1bdd2b
Show file tree
Hide file tree
Showing 30 changed files with 5,449 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules/
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# note.rs

Yet another note taking tool.

## Run in dev mode

```bash
cargo tauri dev
```

## References

- [tauri](https://tauri.app/)
- [vite](https://vitejs.dev/)
- [npm](https://www.npmjs.com/)
- [codemirror](https://codemirror.net/)
- [marked](https://marked.js.org/)
16 changes: 16 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="style.css" />
<title>note.rs</title>
</head>
<body>
<div id="content">
<div id="editor"></div>
<div id="view"></div>
</div>

<script type="module" src="/main.js"></script>
</body>
</html>
25 changes: 25 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { EditorView, basicSetup } from "codemirror"
import { Compartment, Text } from "@codemirror/state"
import { markdown } from "@codemirror/lang-markdown"
import { marked } from "marked"

const language = new Compartment();
const editor_element = document.querySelector("#editor");
const editor = new EditorView({
extensions: [
basicSetup,
language.of(markdown())
],
doc: "",
parent: editor_element
});

editor.dom.addEventListener('input', async () => {
const text = editor.state.doc.toString();
const html = marked.parse(text, {
pedantic: false,
gfm: true
});
document.querySelector("#view").innerHTML = html;
});

Loading

0 comments on commit a1bdd2b

Please sign in to comment.