Skip to content

Commit 981445f

Browse files
committed
Fix height
1 parent 9f37f34 commit 981445f

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
<link rel="stylesheet" href="/dist/markdown-palettes.css" />
88
</head>
99
<body>
10-
<div id="editor"></div>
10+
<div id="editor-container" style="height: 700px;">
11+
<div id="editor"></div>
12+
</div>
13+
1114
<script src="/dist/markdown-palettes.js"></script>
1215
<script>
1316
var editor = new MarkdownPalettes("#editor")

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules",
1212
"build-dev": "cross-env NODE_ENV=development webpack --progress",
1313
"lint": "eslint --ext .js,.vue src/",
14-
"lint-fix": "eslint --ext .js,.vue --fix src/"
14+
"lint-fix": "eslint --ext .js,.vue --fix src/",
15+
"analyze": "cross-env NODE_ENV=development BUNDLE_ANALYZE=true webpack --progress --hide-modules"
1516
},
1617
"dependencies": {
1718
"babel-runtime": "^6.26.0",

src/components/DefaultConfig.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ function set (obj, config) {
1313
}
1414

1515
export const defaultConfig = {
16-
height: '500px',
1716
previewDisplay: 'normal',
1817
fullScreen: false,
1918
parsers: [

src/components/MarkdownPalettes.vue

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
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
}

src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class MarkdownPalettes {
4040
})
4141
}
4242
getContentParaser () {
43-
return contentParserFactory(getConfig(this.config))
43+
return contentParserFactory(getConfig(this.config).parsers)
4444
}
4545
}
4646

0 commit comments

Comments
 (0)