From 0e1cdc35e00ab9fe98df009f3024f578b4126640 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 21 Dec 2022 15:20:33 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/6899 --- app/src/history/diff.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/history/diff.ts b/app/src/history/diff.ts index 6db15879e..ce48a1db4 100644 --- a/app/src/history/diff.ts +++ b/app/src/history/diff.ts @@ -5,6 +5,7 @@ import {Constants} from "../constants"; import {disabledProtyle, onGet} from "../protyle/util/onGet"; import {hasClosestByClassName} from "../protyle/util/hasClosest"; import {escapeHtml} from "../util/escape"; +import * as dayjs from "dayjs"; const genItem = (data: [], data2?: { title: string, fileID: string }[]) => { if (!data || data.length === 0) { @@ -64,12 +65,13 @@ const renderCompare = (element: HTMLElement) => { } fetchPost("/api/repo/openRepoSnapshotDoc", {id: element.getAttribute("data-id")}, (response) => { + const textElement = (leftElement.firstElementChild.nextElementSibling as HTMLTextAreaElement) if (response.data.isLargeDoc) { - (leftElement.firstElementChild as HTMLTextAreaElement).value = response.data.content; - leftElement.firstElementChild.classList.remove("fn__none"); + textElement.value = response.data.content; + textElement.classList.remove("fn__none"); leftElement.lastElementChild.classList.add("fn__none"); } else { - leftElement.firstElementChild.classList.add("fn__none"); + textElement.classList.add("fn__none"); leftElement.lastElementChild.classList.remove("fn__none"); onGet(response, leftEditor.protyle, [Constants.CB_GET_HISTORY, Constants.CB_GET_HTML]); } @@ -78,12 +80,13 @@ const renderCompare = (element: HTMLElement) => { if (id2) { rightElement.classList.remove("fn__none"); fetchPost("/api/repo/openRepoSnapshotDoc", {id: id2}, (response) => { + const textElement = (rightElement.firstElementChild.nextElementSibling as HTMLTextAreaElement) if (response.data.isLargeDoc) { - (rightElement.firstElementChild as HTMLTextAreaElement).value = response.data.content; - rightElement.firstElementChild.classList.remove("fn__none"); + textElement.value = response.data.content; + textElement.classList.remove("fn__none"); rightElement.lastElementChild.classList.add("fn__none"); } else { - rightElement.firstElementChild.classList.add("fn__none"); + textElement.classList.add("fn__none"); rightElement.lastElementChild.classList.remove("fn__none"); onGet(response, rightEditor.protyle, [Constants.CB_GET_HISTORY, Constants.CB_GET_HTML]); } @@ -132,11 +135,13 @@ export const showDiff = (ids: string) => {
-
+
+
${dayjs(response.data.left.created).format("YYYY-MM-DD HH:mm")}
-
+
+
${dayjs(response.data.right.created).format("YYYY-MM-DD HH:mm")}