Skip to content

Commit d4dce1e

Browse files
authored
fix(content): prevent editor extending on typing (#933)
1 parent 7d1aa87 commit d4dce1e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/content/templates/editor.vue

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<textarea
33
ref="textarea"
44
v-model="file"
5-
@keyup.stop="onType"
65
@keydown.tab.exact.prevent="onTabRight"
76
@keydown.tab.shift.prevent="onTabLeft"
87
@compositionstart.prevent="isInComposition = true"
@@ -32,13 +31,18 @@ export default {
3231
this.$refs.textarea.focus()
3332
},
3433
file () {
34+
this.onType()
3535
this.$emit('input', this.file)
3636
}
3737
},
3838
methods: {
3939
onType () {
4040
const el = this.$refs.textarea
41-
el.style.height = el.scrollHeight + 'px'
41+
42+
el.style.height = 'auto'
43+
this.$nextTick(() => {
44+
el.style.height = el.scrollHeight + 'px'
45+
})
4246
},
4347
onTabRight(event) {
4448
if (this.isInComposition) {

packages/content/templates/nuxt-content.dev.vue

+4
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ export default {
9898
}
9999
100100
.nuxt-content-editor {
101+
box-sizing: border-box;
102+
display: block;
101103
width: 100%;
102104
padding: 8px;
105+
overflow: hidden;
106+
resize: none;
103107
}
104108
</style>

0 commit comments

Comments
 (0)