Skip to content
This repository was archived by the owner on Apr 6, 2020. It is now read-only.

Commit c6552e8

Browse files
author
Sohee Lee
committed
test: move Test.vue to example and use @vue/cli in script
1 parent 1904c35 commit c6552e8

File tree

4 files changed

+4358
-340
lines changed

4 files changed

+4358
-340
lines changed

Test.vue

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

example/App.vue

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<template>
2+
<div class="container">
3+
<h1>🍞📝Toast UI Markdown Editor + Vue</h1>
4+
<editor
5+
ref="tuiEditor"
6+
v-model="editorText"
7+
:options="editorOptions"
8+
:html="editorHtml"
9+
:mode="editorMode"
10+
:previewStyle="editorPreviewStyle"
11+
@load="onEditorLoad"
12+
@focus="onEditorFocus"
13+
@blur="onEditorBlur"
14+
@change="onEditorChange"
15+
@stateChange="onEditorStateChange"
16+
/>
17+
<div>
18+
<h3>Props Test Buttons</h3>
19+
<button @click="changeText">changeText</button>
20+
<button @click="changeHtml">changeHtml</button>
21+
<button @click="changeMode">changeMode</button>
22+
<button @click="changePreviewStyle">changePreviewStyle</button>
23+
</div>
24+
<div>
25+
<h3>Function Test Buttons</h3>
26+
<button v-for="method in methodNames" :key="method" @click="methodInvoke(method)">
27+
{{ method }}
28+
</button>
29+
<p>Function Result : {{ message }}</p>
30+
</div>
31+
<viewer
32+
class="viewer"
33+
:value="viewerText"
34+
/>
35+
</div>
36+
</template>
37+
38+
<script>
39+
import {Editor, Viewer} from '../src/index.js';
40+
41+
const eventListenr = [
42+
'onEditorLoad',
43+
'onEditorFocus',
44+
'onEditorBlur',
45+
'onEditorChange',
46+
'onEditorStateChange'
47+
].reduce((methods, methodName) => {
48+
methods[methodName] = function() {
49+
// eslint-disable-next-line no-console
50+
console.log(`[editor] ${methodName}`);
51+
};
52+
53+
return methods;
54+
}, {});
55+
56+
export default {
57+
components: {
58+
Editor,
59+
Viewer
60+
},
61+
data() {
62+
return {
63+
message: '',
64+
methodNames: [
65+
'focus',
66+
'getValue',
67+
'getHtml',
68+
'getSelectedText',
69+
'moveCursorToStart',
70+
'moveCursorToEnd',
71+
'reset'
72+
],
73+
viewerText: '# TOAST UI Markdown Viewer + Vue\n This is Viewer.',
74+
editorText: 'This is initialValue.',
75+
editorOptions: {
76+
hideModeSwitch: false,
77+
toolbarItems: [
78+
'heading',
79+
'bold',
80+
'italic',
81+
'strike',
82+
'divider',
83+
'hr',
84+
'quote',
85+
'divider',
86+
'ul',
87+
'ol',
88+
'task',
89+
'indent',
90+
'outdent',
91+
'divider',
92+
'table',
93+
'image',
94+
'link',
95+
'divider',
96+
'code',
97+
'codeblock'
98+
]
99+
},
100+
editorHeight: '200px',
101+
editorHtml: '',
102+
editorMode: 'markdown',
103+
editorVisible: true,
104+
editorPreviewStyle: 'vertical'
105+
};
106+
},
107+
methods: Object.assign(eventListenr, {
108+
methodInvoke(methodName) {
109+
this.message = this.$refs.tuiEditor.invoke(methodName);
110+
},
111+
changeText() {
112+
this.editorText += 'hihi';
113+
},
114+
changeHtml() {
115+
this.editorHtml = '<h1>Hi</h1>';
116+
},
117+
changeMode() {
118+
this.editorMode = this.editorMode === 'wysiwyg' ? 'markdown' : 'wysiwyg';
119+
},
120+
changePreviewStyle() {
121+
this.editorPreviewStyle = this.editorPreviewStyle === 'tab' ? 'vertical' : 'tab';
122+
}
123+
})
124+
};
125+
</script>
126+
127+
<style>
128+
@import 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.41.0/codemirror.css';
129+
@import 'https://uicdn.toast.com/tui-editor/latest/tui-editor-contents.css';
130+
@import 'https://uicdn.toast.com/tui-editor/latest/tui-editor.css';
131+
@import 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/github.min.css';
132+
133+
.container {
134+
width: 960px;
135+
}
136+
.viewer {
137+
background-color: lightpink
138+
}
139+
</style>

0 commit comments

Comments
 (0)