Skip to content

Commit

Permalink
fix(content): prevent editor extending on typing (#933)
Browse files Browse the repository at this point in the history
  • Loading branch information
NozomuIkuta committed Oct 21, 2021
1 parent 7d1aa87 commit d4dce1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/content/templates/editor.vue
Expand Up @@ -2,7 +2,6 @@
<textarea
ref="textarea"
v-model="file"
@keyup.stop="onType"
@keydown.tab.exact.prevent="onTabRight"
@keydown.tab.shift.prevent="onTabLeft"
@compositionstart.prevent="isInComposition = true"
Expand Down Expand Up @@ -32,13 +31,18 @@ export default {
this.$refs.textarea.focus()
},
file () {
this.onType()
this.$emit('input', this.file)
}
},
methods: {
onType () {
const el = this.$refs.textarea
el.style.height = el.scrollHeight + 'px'
el.style.height = 'auto'
this.$nextTick(() => {
el.style.height = el.scrollHeight + 'px'
})
},
onTabRight(event) {
if (this.isInComposition) {
Expand Down
4 changes: 4 additions & 0 deletions packages/content/templates/nuxt-content.dev.vue
Expand Up @@ -98,7 +98,11 @@ export default {
}
.nuxt-content-editor {
box-sizing: border-box;
display: block;
width: 100%;
padding: 8px;
overflow: hidden;
resize: none;
}
</style>

0 comments on commit d4dce1e

Please sign in to comment.