Skip to content

Commit

Permalink
fix(legacy-markdown-editor): add auto-resize logic for firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
sewerynkalemba committed Oct 3, 2024
1 parent df5738e commit b0533a5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions content/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ function useLegacyMarkdownEditor() {
textarea.addEventListener("keydown", async (event) => {
handleMarkdownKeyboardShortcuts(textarea, event);
element.innerHTML = await marked.parse(textarea.value);

// Auto resize the textarea only on Firefox since it doesn't support the `field-sizing: content` CSS property yet (https://bugzilla.mozilla.org/show_bug.cgi?id=1832409)
if (navigator.userAgent.includes("Firefox")) {
textarea.style.height = "";
textarea.style.height = textarea.scrollHeight + "px";
}
});

const editorWrapper =
Expand All @@ -356,7 +362,12 @@ function useLegacyMarkdownEditor() {

if (editorWrapper && !hasMarkdownEditor) {
editorWrapper.insertBefore(textarea, null);

textarea.focus();

if (navigator.userAgent.includes("Firefox")) {
textarea.style.height = textarea.scrollHeight + "px";
}
}
});
}
Expand Down

0 comments on commit b0533a5

Please sign in to comment.