Files
docuseal/app/views/scripts/_autosize_field.html.erb
T

25 lines
909 B
Plaintext
Raw Normal View History

2025-09-25 18:30:07 +03:00
<script id="autosize_script" nonce="<%= content_security_policy_nonce %>">
2023-11-26 00:06:38 +02:00
if (!window.customElements.get('autosize-field')) {
window.customElements.define('autosize-field', class extends HTMLElement {
connectedCallback() {
2025-07-14 12:53:15 +03:00
const originalFontValue = this.field.style.fontSize
2024-03-20 16:52:47 +02:00
2025-07-14 12:53:15 +03:00
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)`;
2025-07-04 13:33:52 +03:00
if (this.field.scrollHeight > this.field.clientHeight) {
2025-07-14 12:53:15 +03:00
this.field.style.fontSize = `calc(${originalFontValue} / 2.0)`;
this.field.style.lineHeight = `calc(${this.field.style.fontSize} * 1.3)`;
2025-07-04 13:33:52 +03:00
}
2023-11-26 00:06:38 +02:00
}
}
get field() {
return this.closest('field-value');
}
});
}
2025-09-25 18:30:07 +03:00
window.autosize_script.remove()
2023-11-26 00:06:38 +02:00
</script>