Skip to content

Commit a40d98b

Browse files
authored
preview mode
1 parent a2d4604 commit a40d98b

File tree

5 files changed

+212
-21
lines changed

5 files changed

+212
-21
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"dependencies": {
1515
"@babel/polyfill": "^7.4.4",
1616
"easymde": "^2.6.0",
17+
"markdown-it": "^8.4.2",
1718
"nextcloud-axios": "^0.2.0",
1819
"nextcloud-vue": "^0.11.4",
1920
"vue": "^2.6.10",

src/components/EditorEasyMDE.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export default {
9696
9797
.markdown-editor {
9898
min-height: 100%;
99-
padding: 1em;
10099
}
101100
102101
.CodeMirror {

src/components/EditorMarkdownIt.vue

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<template>
2+
<div class="note-preview" v-html="html" />
3+
</template>
4+
<script>
5+
6+
import MarkdownIt from 'markdown-it'
7+
8+
export default {
9+
name: 'ThePreview',
10+
11+
props: {
12+
value: {
13+
type: String,
14+
required: true,
15+
},
16+
},
17+
18+
data: function() {
19+
return {
20+
html: '',
21+
md: new MarkdownIt({
22+
linkify: true,
23+
}),
24+
}
25+
},
26+
27+
watch: {
28+
value: 'onUpdate',
29+
},
30+
31+
created() {
32+
this.onUpdate()
33+
},
34+
35+
methods: {
36+
onUpdate() {
37+
this.html = this.md.render(this.value)
38+
},
39+
},
40+
41+
}
42+
</script>
43+
<style lang="scss">
44+
.note-preview {
45+
padding: 0 1em;
46+
line-height: 1.5em;
47+
48+
& h1, & h2, & h3, & h4, & h5, & h6 {
49+
padding: 0;
50+
margin-top: 2ex;
51+
margin-bottom: 1ex;
52+
font-weight: bold;
53+
color: inherit;
54+
}
55+
56+
& h1 {
57+
font-size: 165%;
58+
}
59+
60+
& h2 {
61+
font-size: 140%;
62+
}
63+
64+
& h3 {
65+
font-size: 120%;
66+
}
67+
68+
& h4 {
69+
font-size: 110%;
70+
}
71+
72+
& p, & pre, & ul, & ol {
73+
margin: 2ex 0;
74+
}
75+
76+
& ul {
77+
list-style: initial;
78+
}
79+
80+
& ul, & ol {
81+
margin-left: 3ex;
82+
}
83+
84+
& li > p, & li > ul, & li > ol {
85+
margin-top: 0.5ex;
86+
margin-bottom: 0.5ex;
87+
}
88+
89+
& em {
90+
font-style: italic;
91+
color: inherit;
92+
}
93+
94+
& a {
95+
color: var(--color-primary);
96+
}
97+
98+
& pre, & code {
99+
background: var(--color-background-dark);
100+
font-size: 90%;
101+
padding: 0.2ex 0.5ex;
102+
}
103+
104+
& pre code {
105+
font-size: inherit;
106+
padding: 0;
107+
}
108+
109+
& blockquote {
110+
font-style: italic;
111+
border-left: 4px solid var(--color-border);
112+
padding-left: 2ex;
113+
color: var(--color-text-light)
114+
}
115+
}
116+
</style>

0 commit comments

Comments
 (0)