From 18d82f04fc6659d55ada12158f1920b977e5ce40 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 20 Dec 2022 20:14:24 +0800 Subject: [PATCH] :rotating_light: --- app/src/history/diff.ts | 24 ++++++++++++------------ app/src/history/history.ts | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/src/history/diff.ts b/app/src/history/diff.ts index 9f88275a0..6db15879e 100644 --- a/app/src/history/diff.ts +++ b/app/src/history/diff.ts @@ -8,7 +8,7 @@ import {escapeHtml} from "../util/escape"; const genItem = (data: [], data2?: { title: string, fileID: string }[]) => { if (!data || data.length === 0) { - return `
  • ${window.siyuan.languages.emptyContent}
  • ` + return `
  • ${window.siyuan.languages.emptyContent}
  • `; } let html = ""; data.forEach((item: { title: string, fileID: string }, index) => { @@ -19,14 +19,14 @@ const genItem = (data: [], data2?: { title: string, fileID: string }[]) => { html += `
  • ${escapeHtml(item.title)}
  • `; - }) + }); return html; -} +}; let leftEditor: Protyle; let rightEditor: Protyle; const renderCompare = (element: HTMLElement) => { - const listElement = hasClosestByClassName(element, "b3-dialog__diff") + const listElement = hasClosestByClassName(element, "b3-dialog__diff"); if (!listElement) { return; } @@ -73,8 +73,8 @@ const renderCompare = (element: HTMLElement) => { leftElement.lastElementChild.classList.remove("fn__none"); onGet(response, leftEditor.protyle, [Constants.CB_GET_HISTORY, Constants.CB_GET_HTML]); } - }) - const id2 = element.getAttribute("data-id2") + }); + const id2 = element.getAttribute("data-id2"); if (id2) { rightElement.classList.remove("fn__none"); fetchPost("/api/repo/openRepoSnapshotDoc", {id: id2}, (response) => { @@ -87,11 +87,11 @@ const renderCompare = (element: HTMLElement) => { rightElement.lastElementChild.classList.remove("fn__none"); onGet(response, rightEditor.protyle, [Constants.CB_GET_HISTORY, Constants.CB_GET_HTML]); } - }) + }); } else { rightElement.classList.add("fn__none"); } -} +}; export const showDiff = (ids: string) => { const idArray = ids.split(","); @@ -145,8 +145,8 @@ export const showDiff = (ids: string) => { width: "80vw", height: "80vh", destroyCallback() { - leftEditor = undefined - rightEditor = undefined + leftEditor = undefined; + rightEditor = undefined; } }); dialog.element.addEventListener("click", (event) => { @@ -162,10 +162,10 @@ export const showDiff = (ids: string) => { } 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) + renderCompare(target); } target = target.parentElement; } }); }); -} +}; diff --git a/app/src/history/history.ts b/app/src/history/history.ts index 5b8d0e5d3..08261e755 100644 --- a/app/src/history/history.ts +++ b/app/src/history/history.ts @@ -345,7 +345,7 @@ export const openHistory = () => { } else if (value === "2") { renderRepo(repoElement, -2); } - const btnElement = dialog.element.querySelector(".b3-button[data-type='compare']") + const btnElement = dialog.element.querySelector(".b3-button[data-type='compare']"); btnElement.removeAttribute("disabled"); btnElement.removeAttribute("data-ids"); }); @@ -438,8 +438,8 @@ export const openHistory = () => { target.firstElementChild.firstElementChild.classList.toggle("b3-list-item__arrow--open"); break; } else if (target.classList.contains("b3-list-item") && type === "repoitem") { - const btnElement = dialog.element.querySelector(".b3-button[data-type='compare']") - const idstring = btnElement.getAttribute("data-ids") + const btnElement = dialog.element.querySelector(".b3-button[data-type='compare']"); + const idstring = btnElement.getAttribute("data-ids"); const ids = idstring ? idstring.split(",") : []; const id = target.getAttribute("data-id"); if (target.classList.contains("b3-list-item--focus")) { @@ -448,7 +448,7 @@ export const openHistory = () => { ids.splice(ids.indexOf(id), 1); } } else { - target.classList.add("b3-list-item--focus") + target.classList.add("b3-list-item--focus"); if (!ids.includes(id)) { while (ids.length > 1) { const removeId = ids.splice(0, 1)[0]; @@ -458,9 +458,9 @@ export const openHistory = () => { } } if (ids.length === 2) { - btnElement.removeAttribute("disabled") + btnElement.removeAttribute("disabled"); } else { - btnElement.setAttribute("disabled", "disabled") + btnElement.setAttribute("disabled", "disabled"); } btnElement.setAttribute("data-ids", ids.join(",")); break;