-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
87 lines (78 loc) · 2.19 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Markdown editor</title>
<style>
* {
box-sizing: border-box;
}
body, html {
margin: 0;
height: 100%;
}
#app {
height: 100%;
}
.editor {
display: flex;
flex-direction: row;
height: 100%;
}
.editor__input {
border: 0;
font: inherit;
outline: none;
}
.editor__input, .editor__preview {
width: 50%;
height: 100%;
padding: 20px;
}
.editor__preview {
background-color: #eee;
padding-top: 0;
}
</style>
</head>
<body>
<div id="app">
<editor></editor>
</div>
<script src="https://unpkg.com/vue"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.6/marked.min.js"></script>
<script>
let Preview = {
props: ['text'],
template: `<div class="editor__preview" v-html="markdownText"></div>`,
computed: {
markdownText() {
return marked(this.text, { sanitize: true })
}
}
}
let Editor = {
components: {
'preview': Preview
},
data() {
return {
text: ''
}
},
template: `
<div class="editor">
<textarea v-model="text" rows="10" cols="30" class="editor__input"></textarea>
<preview :text="text"></preview>
</div>
`
}
let app = new Vue({
el: "#app",
components: {
'editor': Editor
}
})
</script>
</body>
</html>