feat(viewer): #90 toolbar groupes aussi pour les fichiers texte non markdown
[pop-out][Bookmark] | [Editer][Source][.ext][Pretty] | [Copier] | [Partager] - TOC ancre uniquement au markdown (plus de bouton TOC sur .sh/.py/...) - PDF/Export deja ancres au markdown: groupe export = [Copier] seul sur texte - tests toolbar-order mis a jour (conditions is_markdown sur nav/export)
This commit is contained in:
@@ -35,14 +35,14 @@ function test(label, fn) {
|
||||
}
|
||||
|
||||
// ── viewer.js : définition des groupes ───────────────────────────────────
|
||||
test("viewer.js — group nav = [toc, pop-out, bookmark]", () => {
|
||||
assert.match(
|
||||
viewer,
|
||||
/const navBtns = \[\s*tocBtn,\s*openNewWindowBtn,\s*bookmarkBtn\s*\];/,
|
||||
);
|
||||
test("viewer.js — group nav: TOC markdown-only, then pop-out, bookmark", () => {
|
||||
const m = viewer.match(/const navBtns = \[\];([\s\S]*?)const editBtns/);
|
||||
assert.ok(m, "navBtns block not found");
|
||||
assert.match(m[1], /if \(data\.is_markdown\) navBtns\.push\(tocBtn\);/);
|
||||
assert.match(m[1], /navBtns\.push\(openNewWindowBtn,\s*bookmarkBtn\);/);
|
||||
});
|
||||
|
||||
test("viewer.js — group edit = [edit, source, .md, forge] (pretty appended)", () => {
|
||||
test("viewer.js — group edit = [edit, source, .ext, forge?, pretty?] in order", () => {
|
||||
const m = viewer.match(
|
||||
/const editBtns = \[\];([\s\S]*?)const exportBtns/,
|
||||
);
|
||||
@@ -52,18 +52,21 @@ test("viewer.js — group edit = [edit, source, .md, forge] (pretty appended)",
|
||||
const re = /editBtns\.push\((\w+)\)/g;
|
||||
let g;
|
||||
while ((g = re.exec(block))) order.push(g[1]);
|
||||
// editBtn conditional, then sourceBtn, then mdBtn conditional, then forge conditional
|
||||
// editBtn conditional, then sourceBtn, then ext-download conditional, then forge conditional
|
||||
assert.deepEqual(order, ["editBtn", "sourceBtn", "mdBtn", "forgeBtn", "prettyBtn"]);
|
||||
assert.ok(block.includes("if (!data.unsupported) editBtns.push(editBtn)"));
|
||||
assert.ok(block.includes("if (!data.is_image) editBtns.push(mdBtn)"));
|
||||
assert.ok(block.includes("if (data.is_markdown) editBtns.push(forgeBtn)"));
|
||||
// Pretty (text files) must land in the EDIT group, after the extension button
|
||||
assert.ok(block.indexOf("editBtns.push(prettyBtn)") > block.indexOf("editBtns.push(mdBtn)"));
|
||||
});
|
||||
|
||||
test("viewer.js — group export = [copier, pdf, export]", () => {
|
||||
test("viewer.js — export group = [copier] + [pdf, export] markdown-only", () => {
|
||||
const m = viewer.match(/const exportBtns = \[([\s\S]*?)\];([\s\S]*?)const shareBtns/);
|
||||
assert.ok(m, "exportBtns block not found");
|
||||
assert.ok(m[1].includes("copyBtn"), "copyBtn must be first in export group");
|
||||
assert.match(m[2], /exportBtns\.push\(pdfBtn,\s*exportWrap\)/);
|
||||
assert.match(m[2], /if \(data\.is_markdown\) exportBtns\.push\(pdfBtn,\s*exportWrap\)/,
|
||||
"PDF/Export must be markdown-only (text files: Copier alone)");
|
||||
});
|
||||
|
||||
test("viewer.js — group share = [partager]", () => {
|
||||
|
||||
Reference in New Issue
Block a user