3232</template >
3333
3434<style >
35+ .mp-editor-container {
36+ height : 100% ;
37+ }
3538 .mp-editor-area {
3639 box-sizing : border-box ;
3740 width : 50% ;
@@ -94,16 +97,28 @@ export default {
9497 const config = getConfig (this .config )
9598 return {
9699 code: ' ' ,
100+ ready: false ,
97101 showDialog: false ,
98102 dialogRequest: {},
99103 insertCode: null ,
100104 editorConfig: config,
101- editorHeight: config . height ,
105+ editorHeight: ' 500px ' ,
102106 contentParser: contentParserFactory (config .parsers )
103107 }
104108 },
109+ computed: {
110+ elementHeight () {
111+ if (this .ready ) {
112+ return this .$el .clientHeight
113+ } else {
114+ return ' 100%'
115+ }
116+ }
117+ },
105118 mounted () {
106119 this .code = this .value
120+ this .ready = true
121+ this .updateEditorHeight ()
107122 },
108123 components: {
109124 InputArea,
@@ -134,17 +149,24 @@ export default {
134149 this .dialogRequest = request
135150 this .showDialog = true
136151 },
152+ updateEditorHeight () {
153+ if (this .config .fullScreen ) {
154+ 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'
157+ }
158+ },
137159 handleToolbarOperation (operation ) {
138160 if (operation === ' hide' ) {
139161 if (this .config .previewDisplay === ' normal' ) { this .config .previewDisplay = ' hide' } else { this .config .previewDisplay = ' normal' }
140162 }
141163 if (operation === ' fullScreen' ) {
142164 if (! this .config .fullScreen ) {
143165 this .config .fullScreen = true
144- this .editorHeight = ( window . innerHeight - this . $refs . toolbar . $el . clientHeight ). toString () + ' px '
166+ this .updateEditorHeight ()
145167 } else {
146168 this .config .fullScreen = false
147- this .editorHeight = this . editorConfig . height
169+ this .updateEditorHeight ()
148170 }
149171 }
150172 }
@@ -153,6 +175,11 @@ export default {
153175 value (newValue ) {
154176 this .code = newValue
155177 this .updateCode (newValue)
178+ },
179+ elementHeight () {
180+ if (this .ready ) {
181+ this .updateEditorHeight ()
182+ }
156183 }
157184 }
158185}
0 commit comments