import {fetchPost} from "../util/fetch"; import {Dialog} from "../dialog"; const genItem = (data: [], type: "add" | "update" | "remove") => { if (!data || data.length === 0) { return `
  • ${window.siyuan.languages.emptyContent}
  • ` } let html = ""; data.forEach((item: { id: string, path: string }) => { html += `
  • ${item.path}
  • `; }) return html; } const renderCompare = (element: HTMLElement) => { fetchPost("/api/repo/openRepoSnapshotDoc", {id: element.getAttribute("data-id")}, (response) => { }) } export const showDiff = (ids: string) => { const idArray = ids.split(","); if (idArray.length !== 2) { return; } fetchPost("/api/repo/diffRepoSnapshots", {left: idArray[0], right: idArray[1]}, (response) => { const dialog = new Dialog({ title: window.siyuan.languages.compare, content: `
    `, width: "80vw", height: "80vh", }); dialog.element.addEventListener("click", (event) => { let target = event.target as HTMLElement; while (target && target !== dialog.element) { if (target.classList.contains("b3-list-item") && !target.dataset.id) { target.nextElementSibling.classList.toggle("fn__none"); target.querySelector("svg").classList.toggle("b3-list-item__arrow--open"); break; } else if (target.classList.contains("b3-list-item") && target.dataset.id) { if (target.classList.contains("b3-list-item--focus")) { return; } dialog.element.querySelector(".b3-dialog__diff .b3-list-item--focus")?.classList.remove("b3-list-item--focus"); target.classList.add("b3-list-item--focus"); renderCompare(target) } target = target.parentElement; } }); }); }