You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docuseal/app/views/scripts/_autosize_field.html.erb

25 lines
909 B

<script id="autosize_script" nonce="<%= content_security_policy_nonce %>">
if (!window.customElements.get('autosize-field')) {
window.customElements.define('autosize-field', class extends HTMLElement {
connectedCallback() {
const originalFontValue = this.field.style.fontSize
if (this.field.scrollHeight > this.field.clientHeight) {
this.field.style.fontSize = `calc(${originalFontValue} / 1.5)`;
this.field.style.lineHeight = `calc(${this.field.style.fontSize} * 1.3)`;
if (this.field.scrollHeight > this.field.clientHeight) {
this.field.style.fontSize = `calc(${originalFontValue} / 2.0)`;
this.field.style.lineHeight = `calc(${this.field.style.fontSize} * 1.3)`;
}
}
}
get field() {
return this.closest('field-value');
}
});
}
window.autosize_script.remove()
</script>