반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- localserver
- 센토스
- xcode
- VirtualBox
- 리눅스
- Android
- ReactNative
- Chrome
- MAC
- androidstudio
- PYTHON
- react
- 맥
- TensorFlow
- 오블완
- linux
- jest
- qunit
- build
- unittest
- MachineLearning
- webpack
- node
- vsCode
- centos
- IOS
- 네트워크
- 티스토리챌린지
- 개발
Archives
- Today
- Total
로메오의 블로그
[Vue + typescript] text editor 사용하기 - TOAST UI Editor for Vue 본문
Frontend/Vue
[Vue + typescript] text editor 사용하기 - TOAST UI Editor for Vue
romeoh 2022. 6. 16. 18:13반응형
Toast ui editor for Vue 설치
$ npm install --save @toast-ui/vue-editor
Toast ui editor for Vue 설정
<template>
<div>
<editor />
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import { Editor } from '@toast-ui/vue-editor'
import '@toast-ui/editor/dist/toastui-editor.css'
@Component({
components: {
Editor
}
})
export default class TsrEditor extends Vue {
}
</script>
옵션 & getter setter
<template>
<div>
<editor ref="editor"
v-if="mode === 'editor' && content !== null"
:initialValue="content"
initialEditType="wysiwyg" />
<viewer ref="viewer"
v-if="mode === 'viewer' && content !== null"
:initialValue="content" />
</div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import { Editor, Viewer } from '@toast-ui/vue-editor'
import '@toast-ui/editor/dist/toastui-editor.css'
@Component({
components: {
Editor,
Viewer
}
})
export default class TsrEditor extends Vue {
@Prop() mode?: string;
content?: string | null = null
static content: any;
/**
* Editor value를 반환한다.
*/
getValue () {
let content = (this.$refs.editor as Editor).invoke('getHTML')
if (content === '<p><br class="ProseMirror-trailingBreak"></p>') {
content = ''
}
return content
}
/**
* Editor value를 설정한다.
*/
setValue (val: string) {
this.content = val
}
/**
* Editor 초기화한다.
*/
initValue () {
this.content = ''
}
}
</script>
https://www.npmjs.com/package/@toast-ui/vue-editor
https://github.com/nhn/tui.editor/blob/master/docs/en/getting-started.md
반응형
'Frontend > Vue' 카테고리의 다른 글
[Vue + typescript] *.d.ts 파일 만들기 (0) | 2022.08.03 |
---|---|
[Vue + typescript] filter 사용하기 (0) | 2022.06.22 |
[Vue + typescript] text editor 사용하기 - tiptap (0) | 2022.06.16 |
[Vue + typescript] 숫자 tween (0) | 2022.05.11 |
[Vue + typescript] transition (0) | 2022.05.04 |
Comments