Skip to content

Commit 3194795

Browse files
committed
Fix height and webpack Release 0.4.0
1 parent 3ffec6a commit 3194795

File tree

8 files changed

+257
-62
lines changed

8 files changed

+257
-62
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"lodash": "^4.17.4",
2424
"markdown-it": "^8.4.1",
2525
"markdown-it-highlightjs": "^3.0.0",
26+
"uglifyjs-webpack-plugin": "^1.2.7",
2627
"vue": "^2.5.11",
2728
"vue-codemirror-lite": "^1.0.3"
2829
},

src/components/InputArea.vue

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@
1010
</template>
1111

1212
<style>
13+
#mp-input-area {
14+
height: 100%;
15+
}
16+
/* hack CodeMirror */
17+
.CodeMirror {
18+
height: 100% !important;
19+
}
20+
21+
.CodeMirror-scroll {
22+
height: 100%;
23+
overflow-y: hidden;
24+
overflow-x: auto;
25+
}
26+
27+
.vue-codemirror-wrap {
28+
height: 100%;
29+
}
1330
</style>
1431

1532
<script>
@@ -27,9 +44,6 @@ export default {
2744
},
2845
insertCode: {
2946
default: null
30-
},
31-
height: {
32-
type: String
3347
}
3448
},
3549
computed: {
@@ -62,9 +76,6 @@ export default {
6276
},
6377
value (newValue) {
6478
this.code = newValue
65-
},
66-
height (newHeight) {
67-
this.editor.setSize('100%', newHeight)
6879
}
6980
},
7081
data: function () {
@@ -77,7 +88,6 @@ export default {
7788
},
7889
mounted: function () {
7990
this.code = this.value
80-
this.editor.setSize('100%', this.height)
8191
},
8292
methods: {
8393
updateCode (code) {

src/components/MarkdownPalettes.vue

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<toolbar @change="insert" @click="clickToolbar" @input="handleToolbarOperation"
55
:toolbarConfig="editorConfig.toolbarConfig" ref="toolbar"></toolbar>
66
</div>
7-
<div id="mp-editor-area" :style="{ height: editorHeight }">
7+
<div id="mp-editor-area">
88
<div id="mp-editor-input-area" class="mp-editor-area mp-input-area" :class="{
99
'mp-editor-area': this.config.previewDisplay === 'normal',
1010
'mp-editor-area-full': this.config.previewDisplay === 'hide'
@@ -14,14 +14,13 @@
1414
@input="updateCode"
1515
@finish="insertCode = null"
1616
:insertCode="insertCode"
17-
:height="editorHeight"
1817
:editorOption="editorConfig.editorOption"></input-area>
1918
</div>
2019
<div id="mp-editor-preview-area" class="mp-editor-area mp-preview-area" :class="{
2120
'mp-editor-area': this.config.previewDisplay === 'normal',
2221
'mp-editor-area-hide': this.config.previewDisplay === 'hide'
2322
}">
24-
<preview-area v-model="code" :parser="contentParser" ref="previewArea" :height="editorHeight"></preview-area>
23+
<preview-area v-model="code" :parser="contentParser" ref="previewArea"></preview-area>
2524
</div>
2625
</div>
2726
<div id="mp-editor-dialog">
@@ -32,7 +31,22 @@
3231
</template>
3332

3433
<style>
34+
#mp-editor-toolbar {
35+
float: left;
36+
width: 100%;
37+
height: 40px;
38+
}
39+
#mp-editor-area {
40+
position: absolute;
41+
width: 100%;
42+
top: 40px;
43+
bottom: 0;
44+
overflow: hidden;
45+
border: 1px solid #ddd;
46+
}
47+
3548
.mp-editor-container {
49+
position:relative;
3650
height: 100%;
3751
}
3852
.mp-editor-area {
@@ -42,11 +56,6 @@
4256
float: left;
4357
}
4458
45-
#mp-editor-area {
46-
overflow: hidden;
47-
border: 1px solid #ddd;
48-
}
49-
5059
.mp-editor-area-full {
5160
box-sizing: border-box;
5261
width: 100%;
@@ -91,10 +100,6 @@ export default {
91100
default: function () {
92101
return defaultConfig
93102
}
94-
},
95-
size: {
96-
required: false,
97-
default: true
98103
}
99104
},
100105
data () {
@@ -111,7 +116,6 @@ export default {
111116
},
112117
mounted () {
113118
this.code = this.value
114-
this.$nextTick(this.updateEditorHeight)
115119
},
116120
components: {
117121
InputArea,
@@ -141,36 +145,12 @@ export default {
141145
}
142146
this.dialogRequest = request
143147
this.showDialog = true
144-
},
145-
updateEditorHeight () {
146-
if (this.config.fullScreen) {
147-
this.editorHeight = (window.innerHeight - this.$refs.toolbar.$el.clientHeight).toString() + 'px'
148-
} else {
149-
this.editorHeight = (this.$el.clientHeight - this.$refs.toolbar.$el.clientHeight).toString() + 'px'
150-
}
151-
},
152-
handleToolbarOperation (operation) {
153-
if (operation === 'hide') {
154-
if (this.config.previewDisplay === 'normal') { this.config.previewDisplay = 'hide' } else { this.config.previewDisplay = 'normal' }
155-
}
156-
if (operation === 'fullScreen') {
157-
if (!this.config.fullScreen) {
158-
this.config.fullScreen = true
159-
this.updateEditorHeight()
160-
} else {
161-
this.config.fullScreen = false
162-
this.updateEditorHeight()
163-
}
164-
}
165148
}
166149
},
167150
watch: {
168151
value (newValue) {
169152
this.code = newValue
170153
this.updateCode(newValue)
171-
},
172-
size () {
173-
this.$nextTick(this.updateEditorHeight)
174154
}
175155
}
176156
}

src/components/PreviewArea.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div id="mp-preview-area" :style="{ height: height }">
2+
<div id="mp-preview-area">
33
<div id="mp-preview-content" v-html="content"></div>
44
</div>
55
</template>
@@ -11,6 +11,7 @@
1111
padding-left: 20px;
1212
padding-right: 20px;
1313
overflow: auto;
14+
height: auto;
1415
word-wrap:break-word;
1516
}
1617

src/components/Toolbar.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
background-color: white;
1919
width: 100%;
2020
padding-right: 1px;
21-
min-height: 35px;
2221
border-right: 1px solid #ddd;
2322
border-left: 1px solid #ddd;
2423
border-top: 1px solid #ddd;

src/components/toolbar-button/btn-info.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
title: '关于',
55
action: {
66
insert () {
7-
window.location.href = 'https://github.com/luogu-dev/markdown-palettes'
7+
window.open('https://github.com/luogu-dev/markdown-palettes')
88
return ''
99
}
1010
}

webpack.config.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
44
const CleanWebpackPlugin = require('clean-webpack-plugin')
55
const ExtractTextPlugin = require('extract-text-webpack-plugin')
66
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
7+
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
78

89
module.exports = {
910
entry: ['./src/main.js'],
@@ -84,12 +85,7 @@ if (process.env.NODE_ENV === 'production') {
8485
NODE_ENV: '"production"'
8586
}
8687
}),
87-
new webpack.optimize.UglifyJsPlugin({
88-
sourceMap: true,
89-
compress: {
90-
warnings: false
91-
}
92-
}),
88+
new UglifyJsPlugin(),
9389
new webpack.LoaderOptionsPlugin({
9490
minimize: true
9591
})

0 commit comments

Comments
 (0)