Skip to content

Commit 948dd01

Browse files
committed
Improve UI, Implement prediction of serial list
1 parent 37919d0 commit 948dd01

File tree

2 files changed

+49
-7
lines changed

2 files changed

+49
-7
lines changed

src/renderer/App.vue

+47-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<template>
22
<div id="root">
3-
<textarea v-model="text" />
4-
<p v-html="compiledMarkdown" />
3+
<textarea
4+
:value="text"
5+
@input="updateText"
6+
/>
7+
<div v-html="compiledMarkdown" />
58
</div>
69
</template>
710

@@ -17,20 +20,57 @@ export default {
1720
},
1821
computed: {
1922
compiledMarkdown() {
20-
return marked(this.text, { sanitize: true });
23+
return marked(this.text);
24+
},
25+
},
26+
methods: {
27+
updateText(e) {
28+
this.text = e.target.value;
29+
this.handleEnter(e);
30+
},
31+
handleEnter(e) {
32+
if (e.inputType !== 'insertLineBreak') return;
33+
34+
const splitText = e.target.value.split('\n');
35+
const lenLine = splitText.length;
36+
const prevLine = splitText[lenLine - 2];
37+
const isOrderedList = prevLine.match(/^\d*\.\s.*/);
38+
const isUnorderedList = prevLine.match(/^[\*|-]\s.*/);
39+
40+
let prefix = '';
41+
42+
if (isOrderedList) {
43+
const num = prevLine.match(/^\d*/);
44+
prefix = `${parseInt(num) + 1}.\v`;
45+
} else if (isUnorderedList) {
46+
prefix = prevLine.slice(0, 2);
47+
}
48+
49+
this.text += prefix;
2150
},
2251
},
2352
};
2453
</script>
2554

2655
<style lang="scss" scoped>
2756
#root {
28-
display: grid;
29-
grid-template-rows: 100vh;
30-
grid-template-columns: 1fr 1fr;
57+
width: 100%;
58+
height: 100vh;
59+
display: flex;
60+
61+
textarea {
62+
width: 50%;
63+
height: 100%;
64+
padding: 10px;
65+
font-size: 1.5rem;
66+
}
3167
32-
p {
68+
div {
69+
width: 50%;
70+
height: 100%;
3371
padding: 10px;
72+
font-size: 1.5rem;
73+
overflow-y: scroll;
3474
}
3575
}
3676
</style>

static/index.css

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
* {
22
margin: 0;
3+
box-sizing: border-box;
4+
font-family: 'Nunito', sans-serif;
35
color: #C9D2D9;
46
background-color: #161C22;
57
}

0 commit comments

Comments
 (0)