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

Commit 4885858

Browse files
author
Sohee Lee
committed
doc: move contents of getting-started.md to README.md
1 parent e4d1fca commit 4885858

File tree

2 files changed

+230
-437
lines changed

2 files changed

+230
-437
lines changed

README.md

Lines changed: 230 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@
1313
* [Collect statistics on the use of open source](#collect-statistics-on-the-use-of-open-source)
1414
* [Install](#-install)
1515
* [Using npm](#using-npm)
16-
* [Usage](#-usage)
16+
* [Editor Usage](#-editor-usage)
1717
* [Load](#load)
1818
* [Implement](#implement)
1919
* [Using v-model](#using-v-model)
2020
* [Props](#props)
2121
* [Event](#event)
2222
* [Method](#method)
23+
* [Viewer Usage](#-viewer-usage)
24+
* [Load](#load-1)
25+
* [Implement](#implement-1)
26+
* [Props](#props-1)
27+
* [Event](#event-1)
2328
* [Pull Request Steps](#-pull-request-steps)
2429
* [Documents](#-documents)
2530
* [Contributing](#-contributing)
@@ -50,9 +55,7 @@ tui.usageStatistics = false;
5055
npm install --save @toast-ui/vue-editor
5156
```
5257

53-
## 🔨 Usage
54-
55-
If you want to more details, see [Tutorials](https://github.com/nhnent/toast-ui.vue-editor/blob/master/docs/getting-started.md) 👀
58+
## 📝 Editor Usage
5659

5760
### Load
5861

@@ -83,7 +86,7 @@ You can use Toast UI Editor for Vue as moudule format or namespace. Also you can
8386
import 'tui-editor/dist/tui-editor.css';
8487
import 'tui-editor/dist/tui-editor-contents.css';
8588
import 'codemirror/lib/codemirror.css';
86-
import Editor from '@toast-ui/vue-editor/src/editor.vue'
89+
import Editor from '@toast-ui/vue-editor/src/Editor.vue'
8790
```
8891

8992
* Using namespace
@@ -125,7 +128,7 @@ new Vue({
125128

126129
### Using v-model
127130

128-
If you use v-model, you have to declare a `data` for binding.
131+
If you use v-model, you have to declare a `data` for binding. (❗️ When using the editor in `wysiwyg` mode, `v-model` can cause performance degradation.)
129132

130133
In the example below, `editorText` is binding to the text of the editor.
131134

@@ -158,7 +161,7 @@ export default {
158161
| height | String | '300px' | This prop can control the height of the editor. |
159162
| previewStyle | String | 'tab' | This prop can change preview style of the editor. (`tab` or `vertical`) |
160163
| mode | String | 'markdown' | This prop can change mode of the editor. (`markdown`or `wysiwyg`) |
161-
| html | String | - | If you want change content of the editor using html format, use this prop. |
164+
| html | String | - | If you want to change content of the editor using html format, use this prop. |
162165
| visible | Boolean | true | This prop can control visible of the eiditor. |
163166
164167
```js
@@ -193,6 +196,40 @@ const defaultOptions = {
193196
]
194197
};
195198
```
199+
Example :
200+
201+
``` html
202+
<template>
203+
<editor
204+
:value="editorText"
205+
:options="editorOptions"
206+
:html="editorHtml"
207+
:visible="editorVisible"
208+
previewStyle="vertical"
209+
height="500px"
210+
mode="wysiwyg"
211+
/>
212+
</template>
213+
<script>
214+
import { Editor } from '@toast-ui/vue-editor'
215+
216+
export default {
217+
components: {
218+
'editor': Editor
219+
},
220+
data() {
221+
return {
222+
editorText: 'This is initialValue.',
223+
editorOptions: {
224+
hideModeSwitch: true
225+
},
226+
editorHtml: '',
227+
editorVisible: true
228+
};
229+
},
230+
};
231+
</script>
232+
```
196233
197234
### Event
198235
@@ -202,6 +239,46 @@ const defaultOptions = {
202239
* focus : It would be emitted when editor get focus
203240
* blur : It would be emitted when editor loose focus
204241
242+
Example :
243+
244+
```html
245+
<template>
246+
<editor
247+
@load="onEditorLoad"
248+
@focus="onEditorFocus"
249+
@blur="onEditorBlur"
250+
@change="onEditorChange"
251+
@stateChange="onEditorStateChange"
252+
/>
253+
</template>
254+
<script>
255+
import { Editor } from '@toast-ui/vue-editor'
256+
257+
export default {
258+
components: {
259+
'editor': Editor
260+
},
261+
methods: {
262+
onEditorLoad() {
263+
// implement your code
264+
},
265+
onEditorFocus() {
266+
// implement your code
267+
},
268+
onEditorBlur() {
269+
// implement your code
270+
},
271+
onEditorChange() {
272+
// implement your code
273+
},
274+
onEditorStateChange() {
275+
// implement your code
276+
},
277+
}
278+
};
279+
</script>
280+
```
281+
205282
### Method
206283
207284
If you want to more manipulate the Editor, you can use `invoke` method to call the method of tui.editor. For more information of method, see [method of tui.editor](http://nhnent.github.io/tui.editor/api/latest/ToastUIEditor.html).
@@ -234,6 +311,152 @@ export default {
234311
</script>
235312
```
236313
314+
## 📃 Viewer Usage
315+
316+
### Load
317+
318+
* Using Ecmascript module
319+
320+
```js
321+
import 'tui-editor/dist/tui-editor-contents.css';
322+
import 'highlight.js/styles/github.css';
323+
import { Viewer } from '@toast-ui/vue-editor'
324+
```
325+
326+
* Using Commonjs module
327+
328+
```js
329+
require('tui-editor/dist/tui-editor-contents.css');
330+
require('highlight.js/styles/github.css');
331+
var toastui = require('@toast-ui/vue-editor');
332+
var Viewer = toastui.Viewer;
333+
```
334+
335+
* Using Single File Component
336+
337+
```js
338+
import 'tui-editor/dist/tui-editor-contents.css';
339+
import 'highlight.js/styles/github.css';
340+
import Viewer from '@toast-ui/vue-editor/src/Viewer.vue'
341+
```
342+
343+
* Using namespace
344+
345+
```js
346+
var Viewer = toastui.Viewer;
347+
```
348+
349+
### Implement
350+
351+
First implement `<viewer/>` in the template.
352+
353+
```html
354+
<template>
355+
<viewer/>
356+
</template>
357+
```
358+
359+
And then add `Viewer` to the `components` in your component or Vue instance like this:
360+
```js
361+
import { Viewer } from '@toast-ui/vue-editor'
362+
363+
export default {
364+
components: {
365+
'viewer': Viewer
366+
}
367+
}
368+
```
369+
or
370+
```js
371+
import { Viewer } from '@toast-ui/vue-editor'
372+
new Vue({
373+
el: '#app',
374+
components: {
375+
'viewer': Viewer
376+
}
377+
});
378+
```
379+
380+
### Props
381+
382+
| Name | Type | Default | Description |
383+
| --- | --- | --- | --- |
384+
| value | String | '' | This prop can change content of the viewer. |
385+
| height | String | '300px' | This prop can control the height of the editor. |
386+
387+
Example :
388+
389+
``` html
390+
<template>
391+
<viewer
392+
:value="viewerText"
393+
height="500px"
394+
/>
395+
</template>
396+
<script>
397+
import { Viewer } from '@toast-ui/vue-editor'
398+
399+
export default {
400+
components: {
401+
'viewer': Viewer
402+
},
403+
data() {
404+
return {
405+
viewerText: '# This is Viewer.\n Hello World.',
406+
};
407+
},
408+
};
409+
</script>
410+
```
411+
412+
### Event
413+
414+
* load : It would be emitted when editor fully load
415+
* change : It would be emitted when content changed
416+
* stateChange : It would be emitted when format change by cursor position
417+
* focus : It would be emitted when editor get focus
418+
* blur : It would be emitted when editor loose focus
419+
420+
Example :
421+
422+
```html
423+
<template>
424+
<viewer
425+
@load="onEditorLoad"
426+
@focus="onEditorFocus"
427+
@blur="onEditorBlur"
428+
@change="onEditorChange"
429+
@stateChange="onEditorStateChange"
430+
/>
431+
</template>
432+
433+
<script>
434+
import { Viewer } from '@toast-ui/vue-editor'
435+
436+
export default {
437+
components: {
438+
'viewer': Viewer
439+
},
440+
methods: {
441+
onEditorLoad() {
442+
// implement your code
443+
},
444+
onEditorFocus() {
445+
// implement your code
446+
},
447+
onEditorBlur() {
448+
// implement your code
449+
},
450+
onEditorChange() {
451+
// implement your code
452+
},
453+
onEditorStateChange() {
454+
// implement your code
455+
},
456+
}
457+
};
458+
```
459+
237460
## 🔧 Pull Request Steps
238461
239462
TOAST UI products are open source, so you can create a pull request(PR) after you fix issues.
@@ -262,9 +485,6 @@ If it has no error, commit and then push it!
262485

263486
For more information on PR's step, please see links of Contributing section.
264487
265-
## 📙 Documents
266-
* [Getting Started](https://github.com/nhnent/toast-ui.vue-editor/blob/master/docs/getting-started.md)
267-
268488
## 💬 Contributing
269489
* [Code of Conduct](https://github.com/nhnent/toast-ui.vue-editor/blob/master/CODE_OF_CONDUCT.md)
270490
* [Contributing guideline](https://github.com/nhnent/toast-ui.vue-editor/blob/master/CONTRIBUTING.md)

0 commit comments

Comments
 (0)