2121 'mp-editor-area': this.config.previewDisplay === 'normal',
2222 'mp-editor-area-hide': this.config.previewDisplay === 'hide'
2323 }" >
24- <preview-area v-model =" code" :parser =" contentParser" ref =" previewArea" ></preview-area >
24+ <preview-area v-model =" code" :parser =" contentParser" ref =" previewArea" :height = " editorHeight " ></preview-area >
2525 </div >
2626 </div >
2727 <div id =" mp-editor-dialog" >
@@ -91,13 +91,16 @@ export default {
9191 default : function () {
9292 return defaultConfig
9393 }
94+ },
95+ size: {
96+ required: false ,
97+ default: true
9498 }
9599 },
96100 data () {
97101 const config = getConfig (this .config )
98102 return {
99103 code: ' ' ,
100- ready: false ,
101104 showDialog: false ,
102105 dialogRequest: {},
103106 insertCode: null ,
@@ -106,19 +109,9 @@ export default {
106109 contentParser: contentParserFactory (config .parsers )
107110 }
108111 },
109- computed: {
110- elementHeight () {
111- if (this .ready ) {
112- return this .$el .clientHeight
113- } else {
114- return ' 100%'
115- }
116- }
117- },
118112 mounted () {
119113 this .code = this .value
120- this .ready = true
121- this .updateEditorHeight ()
114+ this .$nextTick (this .updateEditorHeight )
122115 },
123116 components: {
124117 InputArea,
@@ -152,8 +145,8 @@ export default {
152145 updateEditorHeight () {
153146 if (this .config .fullScreen ) {
154147 this .editorHeight = (window .innerHeight - this .$refs .toolbar .$el .clientHeight ).toString () + ' px'
155- } else if ( this . $el !== undefined ) {
156- this .editorHeight = (this .elementHeight - this .$refs .toolbar .$el .clientHeight ).toString () + ' px'
148+ } else {
149+ this .editorHeight = (this .$el . clientHeight - this .$refs .toolbar .$el .clientHeight ).toString () + ' px'
157150 }
158151 },
159152 handleToolbarOperation (operation ) {
@@ -176,10 +169,8 @@ export default {
176169 this .code = newValue
177170 this .updateCode (newValue)
178171 },
179- elementHeight () {
180- if (this .ready ) {
181- this .updateEditorHeight ()
182- }
172+ size () {
173+ this .$nextTick (this .updateEditorHeight )
183174 }
184175 }
185176}
0 commit comments