@comet-cli/plugin-documentation
Version:
Plugin for generating API documentation
33 lines (26 loc) • 823 B
text/typescript
import { Vue, Component, Prop } from 'vue-property-decorator';
export default class ResizableTextarea extends Vue {
public name: string = 'resizable-textarea';
public readonly value!: string;
resizeTextarea (event: Event) {
const target = <HTMLElement>event.target;
target.style.height = 'auto';
target.style.height = `${target.scrollHeight}px`;
}
mounted () {
this.$nextTick(() => {
this.$el.setAttribute('style', `height: ${this.$el.scrollHeight}px;min-height:100px;overflow-y:hidden;`);
});
this.$el.addEventListener('input', this.resizeTextarea);
}
beforeDestroy () {
this.$el.removeEventListener('input', this.resizeTextarea);
}
render () {
// @ts-ignore
return this.$slots.default[0];
}
}