11<template >
22 <div class =" editor-wrapper" :class =" { 'is-focused': editor && editor.focused, 'is-readonly': !editable }" >
3+ <!-- 에티터 메뉴바 -->
34 <div class =" editor-menubar" v-if =" editor && editable" >
45 <!-- 진하게 -->
56 <div class =" menubar__button" :class =" { 'is-active': editor.isActive.bold() }"
7879 <Icon type="forward" size="20"></Icon >
7980 </div >
8081 </div >
81-
82- <div class =" editor-content-box" :class =" { 'readonly-content': !editable }" >
82+ <!-- 에디터 글 쓰는 곳 (최소 높이 지정 가능) -->
83+ <div class =" editor-content-box" :class =" { 'readonly-content': !editable }" :style =" { minHeight: minHeight }"
84+ @click =" focusEditor" >
8385 <editor-content class =" editor__content" :editor =" editor" />
8486 </div >
8587 </div >
@@ -102,6 +104,7 @@ import {
102104 Strike ,
103105 Underline ,
104106 History ,
107+ Placeholder ,
105108} from ' tiptap-extensions' ;
106109
107110// 언어별 하이라이팅 라이브러리
@@ -158,6 +161,14 @@ export default {
158161 type: Boolean ,
159162 default: true ,
160163 },
164+ minHeight: {
165+ type: String ,
166+ default: ' 400px' ,
167+ },
168+ placeholder: {
169+ type: String ,
170+ default: ' ' ,
171+ },
161172 },
162173 data () {
163174 return {
@@ -209,13 +220,24 @@ export default {
209220 javascript, python, cpp, java, bash, go
210221 },
211222 }),
223+ new Placeholder ({
224+ emptyNodeClass: ' is-empty' ,
225+ emptyNodeText: this .placeholder ,
226+ showOnlyWhenEditable: true ,
227+ }),
212228 ],
213229 content: this .value ,
214230 onUpdate : ({ getHTML }) => {
215231 this .$emit (' input' , getHTML ());
216232 },
217233 });
218234 },
235+ // 에디터 어느 곳이나 마우스 클릭하면 글 쓰기 모드로 전환
236+ focusEditor () {
237+ if (this .editor && ! this .editor .focused && this .editable ) {
238+ this .editor .focus ()
239+ }
240+ },
219241 },
220242}
221243 </script >
@@ -316,13 +338,12 @@ export default {
316338
317339.editor-content-box {
318340 background : white ;
319- min-height : 400px ;
320341 cursor : text ;
321342 padding : 20px ;
322343
323344 & .readonly-content {
324345 padding : 0 ;
325- min-height : auto ;
346+ min-height : auto !important ;
326347 }
327348}
328349
@@ -331,10 +352,19 @@ export default {
331352 outline : none ;
332353}
333354
334- /* ProseMirror Content Styles */
355+ // placeholder 스타일
356+ / deep/ .ProseMirror p .is-empty :first-child ::before {
357+ content : attr (data-empty-text );
358+ float : left ;
359+ color : #aaa ;
360+ pointer-events : none ;
361+ height : 0 ;
362+ }
363+
335364/ deep/ .ProseMirror {
336365 outline : none ;
337- min-height : 360px ;
366+ height : 100% ;
367+ min-height : inherit ;
338368 font-size : 16px ;
339369 line-height : 1.7 ;
340370 color : #2c3e50 ;
0 commit comments