-
Notifications
You must be signed in to change notification settings - Fork 78
Open
Description
Hi,
Since i cannot set a maximum height using a 50vh, for example, i tried the following workaround:
const editor = new OverType(".overtype-editor", {
autoResize: true,
maxHeight: Math.floor(window.innerHeight / 2) + "px",
})[0];
window.addEventListener('resize', () => {
editor.reinit({
maxHeight: Math.floor(window.innerHeight / 2) + "px",
});
});When i change the browser size, the editor size doesn't change according to the new maxHeight.
But when i add the line below just after my editor.reinit(...), that works fine:
editor._updateAutoHeight();An other way to change the height (without this line) is to change the textarea content.
Reading source code, seems to me that _applyOptions() never calls _updateAutoHeight() when autoResize mode was previously already active.
May be, it could works by changing the function like this:
_applyOptions() {
if (this.options.autofocus) {
this.textarea.focus();
}
if (this.options.autoResize) {
if (!this.container.classList.contains("overtype-auto-resize")) {
this._setupAutoResize();
} else {
this._updateAutoHeight(); // <========== Here is the trick to add, perhaps.
}
} else {
this.container.classList.remove("overtype-auto-resize");
}
if (this.options.toolbar && !this.toolbar) {
this._createToolbar();
} else if (!this.options.toolbar && this.toolbar) {
this._cleanupToolbarListeners();
this.toolbar.destroy();
this.toolbar = null;
}
this.updatePreview();
}But i don't know if this could have side effects on other parts of the code, so i'll leave it up to you to decide.
Thanks in advance.
Metadata
Metadata
Assignees
Labels
No labels