diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index 4a5b278c3..b340411be 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -1,4 +1,5 @@
{
+ "compare": "比较",
"switchTab": "页签切换",
"recentDocs": "最近打开的文档",
"autoLaunch": "开机自动启动",
diff --git a/app/src/history/diff.ts b/app/src/history/diff.ts
new file mode 100644
index 000000000..517a880ac
--- /dev/null
+++ b/app/src/history/diff.ts
@@ -0,0 +1,3 @@
+export const showDiff = () => {
+
+}
diff --git a/app/src/util/history.ts b/app/src/history/history.ts
similarity index 93%
rename from app/src/util/history.ts
rename to app/src/history/history.ts
index 6081350da..06ba0231b 100644
--- a/app/src/util/history.ts
+++ b/app/src/history/history.ts
@@ -1,14 +1,14 @@
import {Dialog} from "../dialog";
import {confirmDialog} from "../dialog/confirmDialog";
-import {fetchPost} from "./fetch";
import {Constants} from "../constants";
-import {escapeHtml} from "./escape";
-import {isMobile} from "./functions";
import {hasClosestByClassName} from "../protyle/util/hasClosest";
import {renderAssetsPreview} from "../asset/renderAssets";
import {Protyle} from "../protyle";
import {disabledProtyle, onGet} from "../protyle/util/onGet";
import * as dayjs from "dayjs";
+import {fetchPost} from "../util/fetch";
+import {escapeHtml} from "../util/escape";
+import {isMobile} from "../util/functions";
let historyEditor: Protyle;
const renderDoc = (element: HTMLElement, currentPage: number) => {
@@ -88,7 +88,7 @@ const renderRepoItem = (response: IWebSocketData, element: Element, type: string
let repoHTML = "";
response.data.snapshots.forEach((item: { memo: string, id: string, hCreated: string, count: number, hSize: string, tag: string, typesCount: { type: string, count: number }[] }) => {
if (isMobile()) {
- repoHTML += `
+ repoHTML += `
${escapeHtml(item.memo)}
${item.tag}
@@ -101,7 +101,7 @@ const renderRepoItem = (response: IWebSocketData, element: Element, type: string
${actionHTML}
`;
} else {
- repoHTML += `
+ repoHTML += `
${escapeHtml(item.memo)}
@@ -111,15 +111,15 @@ const renderRepoItem = (response: IWebSocketData, element: Element, type: string
${item.hCreated}
${window.siyuan.languages.fileSize} ${item.hSize}
${window.siyuan.languages.fileCount} ${item.count}`;
- let statHTML = "";
- if (item.typesCount && 0 < item.typesCount.length) {
- statHTML += `
+ let statHTML = "";
+ if (item.typesCount && 0 < item.typesCount.length) {
+ statHTML += `
${item.typesCount.map((type: { type: string, count: number }) => {
- return `${type.type} ${type.count}`;
- }).join(" ")}`;
- }
- repoHTML += `${statHTML}
+ return `${type.type} ${type.count}`;
+ }).join(" ")}`;
+ }
+ repoHTML += `${statHTML}
@@ -284,6 +284,8 @@ export const openHistory = () => {
+
+
- ${window.siyuan.languages.emptyContent}
@@ -341,6 +343,9 @@ export const openHistory = () => {
} else if (value === "2") {
renderRepo(repoElement, -2);
}
+ const btnElement = dialog.element.querySelector(".b3-button[data-type='compare']")
+ btnElement.removeAttribute("disabled");
+ btnElement.removeAttribute("data-ids");
});
dialog.element.addEventListener("click", (event) => {
let target = event.target as HTMLElement;
@@ -430,6 +435,33 @@ export const openHistory = () => {
target.nextElementSibling.classList.toggle("fn__none");
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 ids = idstring ? idstring.split(",") : [];
+ const id = target.getAttribute("data-id");
+ if (target.classList.contains("b3-list-item--focus")) {
+ target.classList.remove("b3-list-item--focus");
+ if (ids.includes(id)) {
+ ids.splice(ids.indexOf(id), 1);
+ }
+ } else {
+ target.classList.add("b3-list-item--focus")
+ if (!ids.includes(id)) {
+ while (ids.length > 1) {
+ const removeId = ids.splice(0, 1)[0];
+ target.parentElement.querySelector(`.b3-list-item[data-id="${removeId}"]`)?.classList.remove("b3-list-item--focus");
+ }
+ ids.push(id);
+ }
+ }
+ if (ids.length === 2) {
+ btnElement.removeAttribute("disabled")
+ } else {
+ btnElement.setAttribute("disabled", "disabled")
+ }
+ btnElement.setAttribute("data-ids", ids.join(","));
+ break;
} else if (target.classList.contains("b3-list-item") && (type === "assets" || type === "doc")) {
const dataPath = target.getAttribute("data-path");
if (type === "assets") {
@@ -563,6 +595,9 @@ export const openHistory = () => {
renderDoc(firstPanelElement, 1);
});
break;
+ } else if (type === "compare") {
+ showDiff()
+ break;
}
target = target.parentElement;
}
diff --git a/app/src/mobile/util/menu.ts b/app/src/mobile/util/menu.ts
index 882a0de47..fc96440bd 100644
--- a/app/src/mobile/util/menu.ts
+++ b/app/src/mobile/util/menu.ts
@@ -11,7 +11,7 @@ import * as md5 from "blueimp-md5";
import {showMessage} from "../../dialog/message";
import {exitSiYuan} from "../../dialog/processSystem";
import {confirmDialog} from "../../dialog/confirmDialog";
-import {openHistory} from "../../util/history";
+import {openHistory} from "../../history/history";
import {Dialog} from "../../dialog";
import {syncGuide} from "../../sync/syncGuide";
diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.ts
index 5a1210077..189f95fe8 100644
--- a/app/src/util/globalShortcut.ts
+++ b/app/src/util/globalShortcut.ts
@@ -31,7 +31,6 @@ import {focusBlock, focusByRange} from "../protyle/util/selection";
import {initFileMenu, initNavigationMenu} from "../menus/navigation";
import {bindMenuKeydown} from "../menus/Menu";
import {showMessage} from "../dialog/message";
-import {openHistory} from "./history";
import {Dialog} from "../dialog";
import {unicode2Emoji} from "../emoji";
import {deleteFiles} from "../editor/deleteFile";
@@ -43,6 +42,7 @@ import {getNextFileLi, getPreviousFileLi} from "../protyle/wysiwyg/getBlock";
import {editor} from "../config/editor";
import {hintMoveBlock} from "../protyle/hint/extend";
import {Backlink} from "../layout/dock/Backlink";
+import {openHistory} from "../history/history";
const getRightBlock = (element: HTMLElement, x: number, y: number) => {
let index = 1;
diff --git a/app/src/util/onGetConfig.ts b/app/src/util/onGetConfig.ts
index 61d28a410..2798baa5b 100644
--- a/app/src/util/onGetConfig.ts
+++ b/app/src/util/onGetConfig.ts
@@ -23,13 +23,13 @@ import {focusByRange} from "../protyle/util/selection";
import {exitSiYuan} from "../dialog/processSystem";
import {openSetting} from "../config";
import {getSearch} from "./functions";
-import {openHistory} from "./history";
import {initStatus} from "../layout/status";
import {syncGuide} from "../sync/syncGuide";
import {showMessage} from "../dialog/message";
import {editor} from "../config/editor";
import {goBack, goForward} from "./backForward";
import {replaceLocalPath} from "../editor/rename";
+import {openHistory} from "../history/history";
const matchKeymap = (keymap: Record, key1: "general" | "editor", key2?: "general" | "insert" | "heading" | "list" | "table") => {
if (key1 === "general") {