Skip to content

Commit

Permalink
comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
Serafin-dev committed Oct 31, 2024
1 parent ecfa914 commit a0e4911
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions lms/static/js/edxnotes/plugins/llm_summarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
}
@media (max-width: 768px) {
.annotator-invert-x .annotator-widget{
left: 0px !important;
}
.annotator-outer {
left: 10px !important;
}
.annotator-widget textarea{
max-height: 380px;
}
Expand Down Expand Up @@ -123,7 +117,7 @@
saveButton.disabled = !saveButton.disabled;
}

const container = document.querySelector('#main');
const container = document.querySelector('.edx-notes-wrapper-content')
const textAreaWrapper = editor.fields[0].element;
const request = new Request('/pearson-core/llm-assistance/api/v0/summarize-text', {
method: 'POST',
Expand All @@ -149,35 +143,30 @@
const annotatorEditor = editor.element[0];
const annotatorForm = annotatorEditor.children[0];
const containerWidth = container.offsetWidth;
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;
annotatorEditor.style.left = '0px'
textArea.setAttribute('style', `
background-color: #f7f7f7 !important;
border-radius: 5px;
font-size: 12px !important;
width: ${containerWidth - editorLeft - containerPadding}px !important;
width: ${containerWidth}px !important;
height: auto;
overflow-y: auto;
`);
textArea.value = data.summary;
textArea.style.height = `${textArea.scrollHeight}px`;
textAreaWrapper.querySelector(".annotator-resize").remove();

if (annotatorForm.offsetHeight > editorTop){
textArea.style.maxHeight = `${editorTop - controlsHeight - tagFieldHeight - containerPadding}px`;
textArea.style.maxHeight = `${editorTop - controlsHeight - tagFieldHeight}px`;
}

annotatorForm.setAttribute('tabindex', '-1');
annotatorForm.scrollIntoView({behavior: 'smooth', block: 'start'});

const resizeObserver = new ResizeObserver(() => {
const containerWidth = container.offsetWidth;
textArea.style.width = `${containerWidth - editorLeft - containerPadding}px`;
});
resizeObserver.observe(container);
})
.catch((error) => {
alert(error.message);
Expand Down

0 comments on commit a0e4911

Please sign in to comment.