diff --git a/app/src/constants.ts b/app/src/constants.ts
index ea369e44f..ba67cee7c 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -102,7 +102,7 @@ export abstract class Constants {
public static readonly LOCAL_SEARCHUNREF = "local-searchunref";
public static readonly LOCAL_DOCINFO = "local-docinfo"; // only mobile
public static readonly LOCAL_DAILYNOTEID = "local-dailynoteid"; // string
- public static readonly LOCAL_HISTORYNOTEID = "local-historynoteid"; // string
+ public static readonly LOCAL_HISTORY = "local-history";
public static readonly LOCAL_CODELANG = "local-codelang"; // string
public static readonly LOCAL_FONTSTYLES = "local-fontstyles";
public static readonly LOCAL_EXPORTPDF = "local-exportpdf";
diff --git a/app/src/history/history.ts b/app/src/history/history.ts
index 8b5182da3..3ee74538a 100644
--- a/app/src/history/history.ts
+++ b/app/src/history/history.ts
@@ -30,22 +30,44 @@ const renderDoc = (element: HTMLElement, currentPage: number) => {
const opElement = element.querySelector('.b3-select[data-type="opselect"]') as HTMLSelectElement;
const typeElement = element.querySelector('.b3-select[data-type="typeselect"]') as HTMLSelectElement;
const notebookElement = element.querySelector('.b3-select[data-type="notebookselect"]') as HTMLSelectElement;
- window.siyuan.storage[Constants.LOCAL_HISTORYNOTEID] = notebookElement.value;
- setStorageVal(Constants.LOCAL_HISTORYNOTEID, window.siyuan.storage[Constants.LOCAL_HISTORYNOTEID]);
const docElement = element.querySelector('.history__text[data-type="docPanel"]');
const assetElement = element.querySelector('.history__text[data-type="assetPanel"]');
const mdElement = element.querySelector('.history__text[data-type="mdPanel"]') as HTMLTextAreaElement;
docElement.classList.add("fn__none");
mdElement.classList.add("fn__none");
- if (typeElement.value === "0" || typeElement.value === "1") {
- opElement.removeAttribute("disabled");
- notebookElement.removeAttribute("disabled");
- assetElement.classList.add("fn__none");
- } else {
- opElement.setAttribute("disabled", "disabled");
+ if (typeElement.value === "2") {
notebookElement.setAttribute("disabled", "disabled");
assetElement.classList.remove("fn__none");
+ if (window.siyuan.storage[Constants.LOCAL_HISTORY].type !== 2) {
+ opElement.value = "all";
+ }
+ opElement.querySelector('option[value="clean"]').classList.remove("fn__none")
+ opElement.querySelector('option[value="update"]').classList.remove("fn__none")
+ opElement.querySelector('option[value="delete"]').classList.add("fn__none")
+ opElement.querySelector('option[value="format"]').classList.add("fn__none")
+ opElement.querySelector('option[value="sync"]').classList.remove("fn__none")
+ opElement.querySelector('option[value="replace"]').classList.add("fn__none")
+ opElement.querySelector('option[value="outline"]').classList.add("fn__none")
+ } else {
+ notebookElement.removeAttribute("disabled");
+ assetElement.classList.add("fn__none");
+ if (window.siyuan.storage[Constants.LOCAL_HISTORY].type === 2) {
+ opElement.value = "all";
+ }
+ opElement.querySelector('option[value="clean"]').classList.add("fn__none")
+ opElement.querySelector('option[value="update"]').classList.remove("fn__none")
+ opElement.querySelector('option[value="delete"]').classList.remove("fn__none")
+ opElement.querySelector('option[value="format"]').classList.remove("fn__none")
+ opElement.querySelector('option[value="sync"]').classList.remove("fn__none")
+ opElement.querySelector('option[value="replace"]').classList.remove("fn__none")
+ opElement.querySelector('option[value="outline"]').classList.remove("fn__none")
}
+ window.siyuan.storage[Constants.LOCAL_HISTORY] = {
+ notebookId: notebookElement.value,
+ type: parseInt(typeElement.value),
+ operation: opElement.value
+ };
+ setStorageVal(Constants.LOCAL_HISTORY, window.siyuan.storage[Constants.LOCAL_HISTORY]);
fetchPost("/api/history/searchHistory", {
notebook: notebookElement.value,
query: inputElement.value,
@@ -303,19 +325,11 @@ export const openHistory = (app: App) => {
return;
}
- let existLocalHistoryNoteID = false;
+ const localHistory = window.siyuan.storage[Constants.LOCAL_HISTORY];
+ let notebookSelectHTML = ``;
window.siyuan.notebooks.forEach((item) => {
if (!item.closed) {
- if (item.id === window.siyuan.storage[Constants.LOCAL_HISTORYNOTEID]) {
- existLocalHistoryNoteID = true;
- }
- }
- });
-
- let notebookSelectHTML = ``;
- window.siyuan.notebooks.forEach((item) => {
- if (!item.closed) {
- notebookSelectHTML += ` `;
+ notebookSelectHTML += ` `;
}
});
@@ -342,20 +356,20 @@ export const openHistory = (app: App) => {