Skip to content

Commit 076c328

Browse files
committed
Added markdown parser using rust
1 parent 65b24a5 commit 076c328

25 files changed

+2133
-163
lines changed

package-lock.json

Lines changed: 1420 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030
"*.{js,ts,vue}": "eslint --cache --fix"
3131
},
3232
"devDependencies": {
33+
"@tailwindcss/typography": "^0.4.1",
3334
"@types/electron-devtools-installer": "2.2.0",
3435
"@typescript-eslint/eslint-plugin": "5.2.0",
3536
"@vitejs/plugin-vue": "1.9.4",
37+
"autoprefixer": "^10.4.0",
3638
"cross-env": "7.0.3",
3739
"electron": "15.3.0",
3840
"electron-builder": "22.13.1",
@@ -41,13 +43,18 @@
4143
"eslint-plugin-vue": "8.0.2",
4244
"lint-staged": "11.2.6",
4345
"playwright": "1.16.2",
46+
"postcss": "^8.3.11",
47+
"sass": "^1.43.4",
4448
"simple-git-hooks": "2.7.0",
49+
"tailwindcss": "^2.2.19",
4550
"typescript": "4.4.4",
4651
"vite": "2.6.13",
4752
"vue-tsc": "0.28.10"
4853
},
4954
"dependencies": {
55+
"brace": "^0.11.1",
5056
"electron-updater": "4.6.1",
57+
"vite-plugin-wasm-pack": "^0.1.7",
5158
"vue": "3.2.20",
5259
"vue-router": "4.0.12"
5360
}

packages/main/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if (!isSingleInstance) {
1313
app.disableHardwareAcceleration();
1414

1515
// Install "Vue.js devtools"
16-
if (import.meta.env.MODE === 'development') {
16+
if (import.meta.env.MODE !== 'development') {
1717
app.whenReady()
1818
.then(() => import('electron-devtools-installer'))
1919
.then(({default: installExtension, VUEJS3_DEVTOOLS}) => installExtension(VUEJS3_DEVTOOLS, {
@@ -29,6 +29,10 @@ let mainWindow: BrowserWindow | null = null;
2929
const createWindow = async () => {
3030
mainWindow = new BrowserWindow({
3131
show: false, // Use 'ready-to-show' event to show window
32+
minWidth: 1280,
33+
minHeight: 768,
34+
width: 1280,
35+
height: 768,
3236
webPreferences: {
3337
nativeWindowOpen: true,
3438
preload: join(__dirname, '../../preload/dist/index.cjs'),

packages/renderer/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<meta http-equiv="Content-Security-Policy" content="script-src 'self' blob:">
5+
<!-- <meta http-equiv="Content-Security-Policy" content="script-src 'self' blob:"> -->
66
<meta content="width=device-width, initial-scale=1.0" name="viewport">
77
<title>Vite App</title>
88
</head>

packages/renderer/src/App.vue

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,16 @@
11
<template>
2-
<img
3-
alt="Vue logo"
4-
src="../assets/logo.svg"
5-
width="300"
6-
>
7-
<app-navigation />
82
<router-view />
93
</template>
104

115
<script lang="ts">
126
import {defineComponent} from 'vue';
13-
import AppNavigation from '/@/components/AppNavigation.vue';
147
export default defineComponent({
158
name: 'App',
16-
components: {
17-
AppNavigation,
18-
},
199
});
2010
</script>
2111

22-
<style>
23-
#app {
24-
font-family: Avenir, Helvetica, Arial, sans-serif;
25-
-webkit-font-smoothing: antialiased;
26-
-moz-osx-font-smoothing: grayscale;
27-
text-align: center;
28-
color: #2c3e50;
29-
margin-top: 60px;
30-
}
12+
<style lang="scss">
13+
@import "tailwindcss/base";
14+
@import "tailwindcss/components";
15+
@import "tailwindcss/utilities";
3116
</style>

packages/renderer/src/components/About.vue

Lines changed: 0 additions & 36 deletions
This file was deleted.

packages/renderer/src/components/AppNavigation.vue

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 58 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,73 @@
11
<template>
2-
<p>
3-
For a guide and recipes on how to configure / customize this project,<br>
4-
check out the
5-
<a
6-
href="https://github.com/cawa-93/vite-electron-builder"
7-
rel="noopener"
8-
target="_blank"
9-
>vite-electron-builder documentation</a>.
10-
</p>
11-
12-
<p>
13-
<a
14-
href="https://vitejs.dev/guide/features.html"
15-
target="_blank"
16-
>Vite Documentation</a> |
17-
<a
18-
href="https://v3.vuejs.org/"
19-
target="_blank"
20-
>Vue 3 Documentation</a>
21-
</p>
22-
23-
<hr>
24-
<button @click="count++">
25-
count is: {{ count }}
26-
</button>
27-
<p>
28-
Edit
29-
<code>renderer/components/Home.vue</code> to test hot module replacement.
30-
</p>
2+
<div class="h-full flex">
3+
<div class="flex-1 relative z-0 flex overflow-hidden">
4+
<main class="w-1/2 h-screen flex-1 relative z-0 overflow-y-auto focus:outline-none xl:order-last">
5+
<div
6+
class="overflow-y-auto p-5 prose"
7+
v-html="content"
8+
/>
9+
</main>
10+
<aside class="h-screen relative order-first flex flex-col flex-shrink-0 w-1/2 border-r border-gray-200 overflow-y-auto">
11+
<div
12+
id="markdown-editor"
13+
style="width: 100%; height: 100%"
14+
/>
15+
</aside>
16+
</div>
17+
</div>
3118
</template>
3219

3320
<script lang="ts">
34-
import {defineComponent, ref} from 'vue';
21+
import init, { parse } from '/@/parser/parser';
22+
import * as ace from 'brace';
23+
import {defineComponent, onMounted, reactive, toRefs } from 'vue';
24+
import 'brace/mode/markdown';
25+
import 'brace/theme/github';
26+
import 'brace/ext/searchbox';
27+
28+
type mdData = {
29+
editor: ace.Editor | null,
30+
content: string | undefined,
31+
}
3532
3633
export default defineComponent({
37-
name: 'HelloWorld',
34+
name: 'MarkDownApp',
3835
setup() {
39-
const count = ref(0);
36+
const markDownData: mdData = reactive({
37+
editor: null,
38+
content: undefined,
39+
});
40+
41+
onMounted(() => {
42+
markDownData.editor = ace.edit('markdown-editor');
43+
markDownData.editor.setOptions({
44+
wrapBehavioursEnabled: true,
45+
wrap: true,
46+
useWorker: true,
47+
behavioursEnabled: true,
48+
showGutter: true,
49+
highlightActiveLine: true,
50+
highlightSelectedWord: true,
51+
});
52+
markDownData.editor.getSession().setMode('ace/mode/markdown');
53+
markDownData.editor.setTheme('ace/theme/github');
54+
markDownData.editor.on('change', async () => {
55+
await init();
56+
markDownData.content = parse(<string> markDownData.editor?.getValue());
57+
});
58+
});
4059
41-
return {count};
60+
return {
61+
...toRefs(markDownData),
62+
};
4263
},
4364
});
4465
</script>
4566

4667
<!-- Add "scoped" attribute to limit CSS to this component only -->
47-
<style scoped>
48-
a {
49-
color: #42b983;
68+
<style lang="scss" scoped>
69+
textarea {
70+
width: 100% !important;
71+
height: 100vh !important;
5072
}
5173
</style>

0 commit comments

Comments
 (0)