Release Hudra 0.10 beta 1

This commit is contained in:
git
2026-07-26 16:02:28 +10:00
parent 94a82eac07
commit 51edff809a
9 changed files with 424 additions and 122 deletions
+12 -47
View File
@@ -10,36 +10,19 @@
const presenterMode = config.mode || "single";
const sessionId = config.sessionId || "standalone";
const contentRoot =
document.querySelector(
"#content .user_content, " +
".show-content .user_content, " +
".wiki-page-content .user_content, " +
".user_content"
) ||
document.querySelector(
"[role='main'] .page-content, " +
"[role='main'] .content"
) ||
document.querySelector("#content") ||
document.body;
const detectedPage = window.__hudraPageDetector?.resolve();
const pageTitleElement =
contentRoot.querySelector("h1") ||
document.querySelector(
"#content h1, .page-title, .wiki-page-title, h1.page-title"
if (!detectedPage?.supported) {
window.__hudraPageDetector?.showNotice(
"Hudra couldnt start because this page does not contain a supported lesson."
);
return;
}
const { contentRoot, pageTitleElement } = detectedPage;
let pageTitle = pageTitleElement?.textContent?.trim() || "";
if (!pageTitle) {
pageTitle = document.title.replace(/\s*:\s*[^:]+$/, "").trim();
}
if (!pageTitle) {
pageTitle = "Lesson";
}
function isHidden(element) {
if (!element || element.hidden) return true;
@@ -101,11 +84,6 @@
}
}
if (!slideDefinitions.length) {
alert("No presentable page content was found.");
return;
}
const presentationLayer = document.createElement("div");
presentationLayer.id = "qlearn-presenter-layer";
document.body.appendChild(presentationLayer);
@@ -699,20 +677,6 @@
return heading;
}
function splitParagraph(paragraph) {
const text = paragraph.textContent.trim();
const sentences = text.match(/[^.!?]+[.!?]+|[^.!?]+$/g) || [text];
if (sentences.length < 2) return [paragraph.cloneNode(true)];
const midpoint = Math.ceil(sentences.length / 2);
return [sentences.slice(0, midpoint), sentences.slice(midpoint)]
.filter((part) => part.length)
.map((part) => {
const copy = paragraph.cloneNode(false);
copy.textContent = part.join(" ").trim();
return copy;
});
}
function splitList(list) {
const items = [...list.children].filter((item) => item.tagName === "LI");
if (items.length < 2) return [list.cloneNode(true)];
@@ -726,9 +690,6 @@
function divideOversizedBlock(block) {
if (block.matches("ul, ol")) return splitList(block);
if (block.matches("p") && block.textContent.trim().length > 220) {
return splitParagraph(block);
}
return [block.cloneNode(true)];
}
@@ -1371,6 +1332,9 @@
},
getSlideCount() {
return slideWrappers.length;
},
reportState() {
sendPresenterState();
}
};
@@ -1399,6 +1363,7 @@
if (command === "scrollBy") window.__qlearnPresenter.scrollBy(message.value);
if (command === "resetView") window.__qlearnPresenter.resetView();
if (command === "goTo") window.__qlearnPresenter.goTo(message.value);
if (command === "reportState") window.__qlearnPresenter.reportState();
if (command === "exit") window.__qlearnPresenter.exit(false);
}
});