Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
Serafin-dev committed Oct 28, 2024
1 parent c71c284 commit ecfa914
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions lms/static/js/edxnotes/plugins/llm_summarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
Expand Down

0 comments on commit ecfa914

Please sign in to comment.