diff --git a/lms/static/js/edxnotes/plugins/llm_summarize.js b/lms/static/js/edxnotes/plugins/llm_summarize.js index 9ad93471910..bf7a675de01 100644 --- a/lms/static/js/edxnotes/plugins/llm_summarize.js +++ b/lms/static/js/edxnotes/plugins/llm_summarize.js @@ -146,37 +146,36 @@ throw new Error(gettext('There was an error while summarizing the content.')); }) .then((data) => { - const annotatorEditor = editor.element[0] - const annotatorForm = annotatorEditor.children[0] + const annotatorEditor = editor.element[0]; + const annotatorForm = annotatorEditor.children[0]; const containerWidth = container.offsetWidth; - const containerPadding = window.getComputedStyle(container).getPropertyValue('padding'); - const controlsHeight = annotatorForm.children[1].offsetHeight - const editorLeft = parseInt(annotatorEditor.style.getPropertyValue('left')) - const editorTop = parseInt(annotatorEditor.style.getPropertyValue('top')) - const tagFieldHeight = editor.fields[1].element.offsetHeight - const textArea = textAreaWrapper.children[0] + const containerPadding = parseInt(window.getComputedStyle(container).getPropertyValue('padding')); + const controlsHeight = annotatorForm.children[1].offsetHeight; + const editorLeft = parseInt(annotatorEditor.style.getPropertyValue('left')); + const editorTop = parseInt(annotatorEditor.style.getPropertyValue('top')); + const tagFieldHeight = editor.fields[1].element.offsetHeight; + const textArea = textAreaWrapper.children[0]; textArea.value = data.summary; textArea.setAttribute('style', ` background-color: #f7f7f7 !important; border-radius: 5px; font-size: 12px !important; - width: ${containerWidth - editorLeft - parseInt(containerPadding)}px !important; + width: ${containerWidth - editorLeft - containerPadding}px !important; height: auto; overflow-y: auto; `); - textArea.style.height = `${textArea.scrollHeight}px`; if (annotatorForm.offsetHeight > editorTop){ - textArea.style.maxHeight = `${editorTop - controlsHeight - tagFieldHeight - parseInt(containerPadding)}px`; + textArea.style.maxHeight = `${editorTop - controlsHeight - tagFieldHeight - containerPadding}px`; } - textArea.setAttribute('tabindex', '-1'); - textArea.scrollIntoView({behavior: 'smooth', block: 'start'}); + annotatorForm.setAttribute('tabindex', '-1'); + annotatorForm.scrollIntoView({behavior: 'smooth', block: 'start'}); const resizeObserver = new ResizeObserver(() => { const containerWidth = container.offsetWidth; - textArea.style.width = `${containerWidth - editorLeft - parseInt(containerPadding)}px`; + textArea.style.width = `${containerWidth - editorLeft - containerPadding}px`; }); resizeObserver.observe(container); })