Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/17258

Vanessa23b6e934971a
diff --git a/app/src/history/history.ts b/app/src/history/history.ts
index bfa740c1d0..2cad30077c 100644
--- a/app/src/history/history.ts
+++ b/app/src/history/history.ts
@@ -16,6 +16,7 @@ import {closeModel} from "../mobile/util/closePanel";
import {App} from "../index";
import {resizeSide} from "./resizeSide";
import {isSupportCSSHL, searchMarkRender} from "../protyle/render/searchMarkRender";
+import {pathPosix} from "../util/pathName";
let historyEditor: Protyle;
@@ -292,6 +293,11 @@ const renderRepoSearchResult = (response: IWebSocketData, element: Element) => {
</div>
<div class="fn__flex" style="height: 26px">
<span class="fn__flex-1"></span>
+ <span class="b3-list-item__action" data-type="view">
+ <svg><use xlink:href="#iconEye"></use></svg>
+ <span class="fn__space"></span>${window.siyuan.languages.cardPreview}
+ </span>
+ <span class="fn__space"></span>
<span class="b3-list-item__action" data-type="saveAs">
<svg><use xlink:href="#iconDownload"></use></svg>
<span class="fn__space"></span>${window.siyuan.languages.saveAs}
@@ -316,12 +322,15 @@ const renderRepoSearchResult = (response: IWebSocketData, element: Element) => {
${dayjs(item.updated).format("YYYY-MM-DD HH:mm:ss")}
</div>
</div>
- <span class="b3-list-item__action b3-tooltips b3-tooltips__w" data-type="rollback" aria-label="${window.siyuan.languages.rollback}">
- <svg><use xlink:href="#iconUndo"></use></svg>
+ <span class="b3-list-item__action b3-tooltips b3-tooltips__w" data-type="view" aria-label="${window.siyuan.languages.cardPreview}">
+ <svg><use xlink:href="#iconEye"></use></svg>
</span>
<span class="b3-list-item__action b3-tooltips b3-tooltips__w" data-type="saveAs" aria-label="${window.siyuan.languages.saveAs}">
<svg><use xlink:href="#iconDownload"></use></svg>
</span>
+ <span class="b3-list-item__action b3-tooltips b3-tooltips__w" data-type="rollback" aria-label="${window.siyuan.languages.rollback}">
+ <svg><use xlink:href="#iconUndo"></use></svg>
+ </span>
</li>`;
/// #endif
});
@@ -733,6 +742,49 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
event.stopPropagation();
event.preventDefault();
break;
+ } else if (type === "view") {
+ const liElement = target.closest(".b3-list-item");
+ const dialog = new Dialog({
+ title: liElement.querySelector(".b3-list-item__text").textContent.trim(),
+ content: '<div class="b3-dialog__content"><div style="border-radius: var(--b3-border-radius-b);"></div></div>',
+ width: isMobile() ? "100vw" : "80vw",
+ height: isMobile() ? "100vh" : "70vh",
+ });
+ const contentElement = dialog.element.querySelector(".b3-dialog__content");
+ fetchPost("/api/repo/openRepoSnapshotFile", {id: liElement.getAttribute("data-id")}, (response) => {
+ const type = pathPosix().extname(response.data.content).toLowerCase();
+ if (Constants.SIYUAN_ASSETS_IMAGE.concat(Constants.SIYUAN_ASSETS_AUDIO).concat(Constants.SIYUAN_ASSETS_VIDEO).includes(type)) {
+ contentElement.firstElementChild.innerHTML = renderAssetsPreview(response.data.content);
+ } else if (response.data.displayInText) {
+ contentElement.innerHTML = '<textarea readonly class="b3-text-field fn__block" style="height: 100%"></textarea>';
+ (contentElement.firstElementChild as HTMLTextAreaElement).value = response.data.content || response.data.title;
+ } else {
+ const viewEditor = new Protyle(app, contentElement.firstElementChild as HTMLElement, {
+ blockId: "",
+ action: [Constants.CB_GET_HISTORY],
+ history: {
+ snapshot: ""
+ },
+ render: {
+ background: false,
+ gutter: false,
+ breadcrumb: false,
+ breadcrumbDocName: false,
+ },
+ typewriterMode: false
+ });
+ disabledProtyle(viewEditor.protyle);
+ viewEditor.protyle.options.history.snapshot = ""; // TODO: 88250;
+ onGet({
+ data: response,
+ protyle: viewEditor.protyle,
+ action: [Constants.CB_GET_HISTORY, Constants.CB_GET_HTML],
+ });
+ }
+ });
+ event.stopPropagation();
+ event.preventDefault();
+ break;
} else if (type === "more") {
target.parentElement.parentElement.querySelectorAll(".b3-list-item__meta").forEach(item => {
item.classList.toggle("fn__none");