Skip to content

Commit a4dcf6a

Browse files
committed
Fix Height
1 parent cb243fe commit a4dcf6a

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

src/components/MarkdownPalettes.vue

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
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
}

src/components/PreviewArea.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div id="mp-preview-area">
2+
<div id="mp-preview-area" :style="{ height: height }">
33
<div id="mp-preview-content" v-html="content"></div>
44
</div>
55
</template>
@@ -88,6 +88,9 @@ export default {
8888
},
8989
parser: {
9090
type: Function
91+
},
92+
height: {
93+
type: String
9194
}
9295
},
9396
data () {

0 commit comments

Comments
 (0)