mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-10-01 01:26:03 -04:00
Chat: fix HTML changes observing in main.js
This commit is contained in:
parent
4eb64a3716
commit
a6420c444c
44
js/main.js
44
js/main.js
@ -145,25 +145,9 @@ targetElement.addEventListener("scroll", function() {
|
||||
// Create a MutationObserver instance
|
||||
const observer = new MutationObserver(function(mutations) {
|
||||
updateCssProperties();
|
||||
|
||||
const firstChild = targetElement.children[0];
|
||||
if (firstChild.classList.contains("generating")) {
|
||||
typing.parentNode.classList.add("visible-dots");
|
||||
document.getElementById("stop").style.display = "flex";
|
||||
document.getElementById("Generate").style.display = "none";
|
||||
} else {
|
||||
typing.parentNode.classList.remove("visible-dots");
|
||||
document.getElementById("stop").style.display = "none";
|
||||
document.getElementById("Generate").style.display = "flex";
|
||||
}
|
||||
|
||||
|
||||
doSyntaxHighlighting();
|
||||
|
||||
if(!isScrolled) {
|
||||
if(!isScrolled)
|
||||
targetElement.scrollTop = targetElement.scrollHeight;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Configure the observer to watch for changes in the subtree and attributes
|
||||
@ -178,6 +162,32 @@ const config = {
|
||||
// Start observing the target element
|
||||
observer.observe(targetElement, config);
|
||||
|
||||
//------------------------------------------------
|
||||
// Chat HTML holder generation
|
||||
//------------------------------------------------
|
||||
const chatHtmlHolder = document.getElementById("chat_html_holder");
|
||||
|
||||
const observerChatHtmlHolder = new MutationObserver(function(mutations) {
|
||||
const isGenerating = Array.from(chatHtmlHolder.children).some(el => el.classList.contains('generating'));
|
||||
if (isGenerating) {
|
||||
typing.parentNode.classList.add("visible-dots");
|
||||
document.getElementById("stop").style.display = "flex";
|
||||
document.getElementById("Generate").style.display = "none";
|
||||
} else {
|
||||
typing.parentNode.classList.remove("visible-dots");
|
||||
document.getElementById("stop").style.display = "none";
|
||||
document.getElementById("Generate").style.display = "flex";
|
||||
}
|
||||
});
|
||||
|
||||
const configChatHtmlHolder = {
|
||||
subtree: true,
|
||||
attributeFilter: ["class"]
|
||||
};
|
||||
|
||||
// Start observing the chat HTML holder
|
||||
observerChatHtmlHolder.observe(chatHtmlHolder, configChatHtmlHolder);
|
||||
|
||||
//------------------------------------------------
|
||||
// Handle syntax highlighting / LaTeX
|
||||
//------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user