An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Simplify mobile snapshot controls and straighten pane divider https://github.com/siyuan-note/siyuan/issues/19956
Daniel0422963555d5
diff --git a/app/src/assets/scss/business/_history.scss b/app/src/assets/scss/business/_history.scssindex 7b8d1bcc7c..61ea8c5dbf 100644--- a/app/src/assets/scss/business/_history.scss+++ b/app/src/assets/scss/business/_history.scss@@ -142,9 +142,36 @@&--search:not(&--narrow) [data-repo-source="cloud"] {display: none;}++ &--mobile {+ .history__snapshot-mobile-control {+ display: inline-flex;+ }++ .history__snapshot-date-controls {+ flex-basis: 100%;+ }++ &:not(.history__snapshots--filters) .history__snapshot-date-controls,+ [data-action="purge"],+ .history__snapshot-menu-action {+ display: none;+ }+ }}&__snapshot {+ &-mobile-control {+ display: none;+ }++ &-date-controls {+ display: flex;+ align-items: center;+ flex-wrap: wrap;+ gap: 8px;+ }+&-loading {position: relative;height: 100%;@@ -359,6 +386,10 @@height: 100%;box-sizing: border-box;border-radius: 0 0 var(--b3-border-radius-b) var(--b3-border-radius-b);++ &.history__snapshot-pane {+ border-radius: 0;+ }}&__repo-actions {diff --git a/app/src/history/history.ts b/app/src/history/history.tsindex 59c1dbba18..27a3a67ea0 100644--- a/app/src/history/history.ts+++ b/app/src/history/history.ts@@ -22,6 +22,7 @@ import {renderRepoFile, renderRepoFileList, rollbackRepoFile, saveRepoFile} fromimport {openDocHistory} from "./doc";import {getRepoSnapshotRange, getRepoSnapshotType, initRepoPanel, updateRepoSelection} from "./repoPanel";import {repoSnapshotInRange} from "./repoRange";+import {MenuItem} from "../menus/Menu";let historyEditor: Protyle;const repoPanelCleanup = new WeakMap<Element, () => void>();@@ -265,6 +266,12 @@ const renderRepoItem = (response: IWebSocketData, element: Element, type: stringif (["getRepoTagSnapshots", "getRepoSnapshots"].includes(type) && !window.siyuan.config.readonly) {actionHTML = `<span class="b3-list-item__action b3-tooltips b3-tooltips__w" data-type="editSnapshotMemo" aria-label="${window.siyuan.languages.editSnapshotMemo}"><svg><use xlink:href="#iconEdit"></use></svg></span>` + actionHTML;}+ if (isMobile()) {+ actionHTML = actionHTML.replace(/class="b3-list-item__action([^"]*)" data-type="([^"]+)"/g,+ (match, classes, action) => ["rollback", "downloadRollback"].includes(action) ? match :+ `class="b3-list-item__action history__snapshot-menu-action${classes}" data-type="${action}"`);+ actionHTML = actionHTML.replaceAll('<span class="fn__flex-1"></span>', "");+ }const memos = new Map<string, string>();snapshotMemos.set(element, memos);let repoHTML = "";@@ -318,7 +325,7 @@ ${statHTML}`;repoHTML += `<li class="b3-list-item${hasSelected ? " b3-list-item--focus" : ""}" data-type="repoitem" data-id="${item.id}" data-tag="${escapeAttr(escapeHtml(item.tag || ""))}"><div class="fn__flex-1">${infoHTML}- <div class="fn__flex" style="height: 26px" data-type="repoitem" data-id="${item.id}" data-tag="${escapeAttr(escapeHtml(item.tag || ""))}">+ <div class="fn__flex history__repo-actions" data-type="repoitem" data-id="${item.id}" data-tag="${escapeAttr(escapeHtml(item.tag || ""))}">${actionHTML}<span class="b3-list-item__action" data-type="more"><svg><use xlink:href="#iconMore"></use></svg>@@ -833,9 +840,26 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {event.preventDefault();break;} else if (type === "more") {- target.parentElement.parentElement.querySelectorAll(".b3-list-item__meta").forEach(item => {- item.classList.toggle("fn__none");+ const row = target.closest<HTMLElement>('li[data-type="repoitem"]');+ const menu = window.siyuan.menus.menu;+ menu.remove();+ row.querySelectorAll<HTMLElement>(".history__snapshot-menu-action").forEach(action => {+ menu.append(new MenuItem({+ icon: action.querySelector("use").getAttribute("xlink:href").substring(1),+ label: action.getAttribute("aria-label") || action.textContent.trim(),+ click: () => {+ menu.remove();+ action.click();+ },+ }).element);});+ menu.append(new MenuItem({+ icon: "iconInfo",+ label: window.siyuan.languages.info,+ click: () => row.querySelectorAll(".b3-list-item__meta").forEach(item => item.classList.toggle("fn__none")),+ }).element);+ const rect = target.getBoundingClientRect();+ menu.popup({x: rect.left, y: rect.bottom, h: rect.height});event.stopPropagation();event.preventDefault();break;diff --git a/app/src/history/repoPanel.ts b/app/src/history/repoPanel.tsindex 83d74d586c..a72fb887c2 100644--- a/app/src/history/repoPanel.ts+++ b/app/src/history/repoPanel.ts@@ -5,6 +5,7 @@ import {isMobile} from "../util/functions";import {removeSelectedRepoTags, repoSelectionKey, RepoSource, RepoTagSelection} from "./repoBatch";import {canPurgeRepo} from "./repoPurge";import {repoDateRange, RepoTimeRange} from "./repoRange";+import {MenuItem} from "../menus/Menu";interface RepoPanelState {selected: Map<string, RepoTagSelection>;@@ -44,6 +45,7 @@ export const updateRepoSelection = (pane: Element) => {root.querySelectorAll<HTMLElement>("[data-repo-source]").forEach(column => {const source = column.dataset.repoSource as RepoSource;column.querySelector('[data-action="purge"]').classList.toggle("fn__none", !canPurgeRepo(source, window.siyuan.config.sync.provider));+ column.querySelector('[data-action="source-more"]').classList.toggle("fn__none", !canPurgeRepo(source, window.siyuan.config.sync.provider));const comparison: {id: string}[] = JSON.parse(column.querySelector('[data-type="compare"]').getAttribute("data-ids") || "[]");column.querySelectorAll<HTMLLIElement>('li[data-type="repoitem"]').forEach(row => {row.classList.toggle("b3-list-item--focus", !state.managing && comparison.some(item => item.id === row.dataset.id));@@ -87,6 +89,7 @@ export const initRepoPanel = (root: HTMLElement, render: (pane: Element, page: nconst state: RepoPanelState = {selected: new Map(), managing: false, busy: false, tagged: false, range: {}};states.set(root, state);root.classList.add("history__snapshots");+ root.classList.toggle("history__snapshots--mobile", isMobile());root.classList.toggle("history__snapshots--narrow", isMobile());root.dataset.source = "local";const template = root.innerHTML;@@ -94,6 +97,8 @@ export const initRepoPanel = (root: HTMLElement, render: (pane: Element, page: n<button type="button" class="b3-button b3-button--text" data-action="normal" aria-pressed="true">${lang.dataSnapshot}</button><button type="button" class="b3-button b3-button--text" data-action="tagged" aria-pressed="false">${lang.repoTaggedSnapshots}</button><span class="fn__flex-1"></span>+ <button type="button" class="b3-button b3-button--text history__snapshot-mobile-control" data-action="filters" aria-expanded="false">${lang.filter}</button>+ <div class="history__snapshot-date-controls"><div class="history__snapshot-range"><input type="date" class="b3-text-field" data-range="start" aria-label="${lang.startDate}" min="1970-01-01" max="9999-12-31"><span aria-hidden="true">-</span>@@ -101,6 +106,7 @@ export const initRepoPanel = (root: HTMLElement, render: (pane: Element, page: n</div><button type="submit" class="b3-button b3-button--outline">${lang.filter}</button><button type="button" class="b3-button b3-button--text" data-action="range-clear">${lang.clear}</button>+ </div><button type="button" class="b3-button b3-button--outline fn__none" data-action="manage">${lang.repoBatchManage}</button></form><div class="history__snapshot-columns"></div>@@ -122,6 +128,7 @@ export const initRepoPanel = (root: HTMLElement, render: (pane: Element, page: n<button class="b3-button b3-button--text" data-action="cloud" aria-pressed="false">${lang.cloudSnapshot}</button></div><span class="fn__flex-1"></span><button class="b3-button b3-button--text${canPurgeRepo(source, window.siyuan.config.sync.provider) ? "" : " fn__none"}" data-action="purge">${source === "local" ? lang.dataRepoPurge : lang.cloudStoragePurge}</button>+ <button class="block__icon block__icon--show history__snapshot-mobile-control" data-action="source-more" aria-label="${lang.more}"><svg><use xlink:href="#iconMore"></use></svg></button></div><label class="history__snapshot-toolbar fn__none"><input type="checkbox" class="history__snapshot-check" data-repo-all> ${lang.selectAll}</label>${template}`;const createButton = pane.querySelector('[data-type="genRepo"]');@@ -166,6 +173,7 @@ export const initRepoPanel = (root: HTMLElement, render: (pane: Element, page: nendDate.addEventListener("change", updateDateLimits);const applyRange = () => {state.range = repoDateRange(startDate.value, endDate.value);+ root.querySelector('[data-action="filters"]').setAttribute("aria-pressed", String(!!startDate.value || !!endDate.value));state.selected.clear();panes().forEach(pane => {pane.querySelector<HTMLInputElement>(".b3-text-field").value = "";@@ -219,7 +227,26 @@ export const initRepoPanel = (root: HTMLElement, render: (pane: Element, page: n}event.stopPropagation();const action = button.dataset.action;- if (action === "range-clear") {+ if (action === "filters") {+ const expanded = root.classList.toggle("history__snapshots--filters");+ button.setAttribute("aria-expanded", String(expanded));+ } else if (action === "source-more") {+ const pane = button.closest<HTMLElement>("[data-repo-source]");+ const purge = pane.querySelector<HTMLButtonElement>('[data-action="purge"]');+ const menu = window.siyuan.menus.menu;+ menu.remove();+ menu.append(new MenuItem({+ icon: "iconTrashcan",+ label: purge.textContent,+ disabled: !canPurgeRepo(pane.dataset.repoSource as RepoSource, window.siyuan.config.sync.provider),+ click: () => {+ menu.remove();+ purge.click();+ },+ }).element);+ const rect = button.getBoundingClientRect();+ menu.popup({x: rect.left, y: rect.bottom, h: rect.height});+ } else if (action === "range-clear") {startDate.value = "";endDate.value = "";updateDateLimits();