An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/11193
Vanessa719803bff699
diff --git a/app/src/block/util.ts b/app/src/block/util.tsindex 9977e273ae..165e6f7952 100644--- a/app/src/block/util.ts+++ b/app/src/block/util.ts@@ -8,7 +8,7 @@ import {Constants} from "../constants";import {hideElements} from "../protyle/ui/hideElements";import {blockRender} from "../protyle/render/blockRender";import {fetchPost} from "../util/fetch";-import {zoomOut} from "../menus/protyle";+import {openFileById} from "../editor/util";export const cancelSB = (protyle: IProtyle, nodeElement: Element) => {const doOperations: IOperation[] = [];@@ -74,25 +74,18 @@ export const genSBElement = (layout: string, id?: string, attrHTML?: string) =>return sbElement;};-export const jumpToParentNext = (protyle: IProtyle, nodeElement: Element) => {- const topElement = getTopAloneElement(nodeElement);- if (topElement) {- const topParentElement = hasClosestByClassName(topElement, "list") || hasClosestByClassName(topElement, "bq") || hasClosestByClassName(topElement, "sb") || topElement;- const nextElement = getNextBlock(topParentElement);- if (nextElement) {- focusBlock(nextElement);- scrollCenter(protyle, nextElement);- } else {- fetchPost("/api/block/getParentNextChildID", {id: nodeElement.getAttribute("data-node-id")}, (response) => {- if (response.data.id) {- zoomOut({- protyle,- id: response.data.id,- });- }- });+export const jumpToParent = (protyle: IProtyle, nodeElement: Element, type: "parent" | "next" | "previous") => {+ fetchPost("/api/block/getBlockSiblingID", {id: nodeElement.getAttribute("data-node-id")}, (response) => {+ const targetId = response.data[type];+ if (!targetId) {+ return;}- }+ openFileById({+ app: protyle.app,+ id: targetId,+ action: [Constants.CB_GET_FOCUS]+ })+ });};export const insertEmptyBlock = (protyle: IProtyle, position: InsertPosition, id?: string) => {diff --git a/app/src/constants.ts b/app/src/constants.tsindex ba67cee7c2..32dc199675 100644--- a/app/src/constants.ts+++ b/app/src/constants.ts@@ -399,6 +399,8 @@ export abstract class Constants {insertBefore: {default: "⇧⌘B", custom: "⇧⌘B"},insertAfter: {default: "⇧⌘A", custom: "⇧⌘A"},jumpToParentNext: {default: "⇧⌘N", custom: "⇧⌘N"},+ jumpToParentPrev: {default: "⇧⌘M", custom: "⇧⌘M"},+ jumpToParent: {default: "⇧⌘J", custom: "⇧⌘J"},moveToUp: {default: "⇧⌘↑", custom: "⇧⌘↑"},moveToDown: {default: "⇧⌘↓", custom: "⇧⌘↓"}},diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 269d9d0b8a..7d2316f57f 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -28,7 +28,13 @@ import {removeEmbed} from "../wysiwyg/removeEmbed";import {getContenteditableElement, getTopAloneElement, isNotEditBlock} from "../wysiwyg/getBlock";import * as dayjs from "dayjs";import {fetchPost, fetchSyncPost} from "../../util/fetch";-import {cancelSB, genEmptyElement, getLangByType, insertEmptyBlock, jumpToParentNext} from "../../block/util";+import {+ cancelSB,+ genEmptyElement,+ getLangByType,+ insertEmptyBlock,+ jumpToParent,+} from "../../block/util";import {countBlockWord} from "../../layout/status";import {Constants} from "../../constants";import {mathRender} from "../render/mathRender";@@ -1630,9 +1636,26 @@ export class Gutter {accelerator: window.siyuan.config.keymap.editor.general.jumpToParentNext.custom,click() {hideElements(["select"], protyle);- jumpToParentNext(protyle, nodeElement);+ jumpToParent(protyle, nodeElement, "next");+ }+ }).element);+ window.siyuan.menus.menu.append(new MenuItem({+ label: window.siyuan.languages.jumpToParentPrev,+ accelerator: window.siyuan.config.keymap.editor.general.jumpToParentPrev.custom,+ click() {+ hideElements(["select"], protyle);+ jumpToParent(protyle, nodeElement, "previous");}}).element);+ window.siyuan.menus.menu.append(new MenuItem({+ label: window.siyuan.languages.jumpToParent,+ accelerator: window.siyuan.config.keymap.editor.general.jumpToParent.custom,+ click() {+ hideElements(["select"], protyle);+ jumpToParent(protyle, nodeElement, "parent");+ }+ }).element);+window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);if (type !== "NodeThematicBreak") {diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex 6d8bf7c163..181cc6b746 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -35,7 +35,7 @@ import {turnsIntoOneTransaction, turnsIntoTransaction, updateBatchTransaction, uimport {fontEvent} from "../toolbar/Font";import {addSubList, listIndent, listOutdent} from "./list";import {newFileContentBySelect, rename, replaceFileName} from "../../editor/rename";-import {insertEmptyBlock, jumpToParentNext} from "../../block/util";+import {insertEmptyBlock, jumpToParent} from "../../block/util";import {isLocalPath} from "../../util/pathName";/// #if !MOBILEimport {openBy, openFileById, openLink} from "../../editor/util";@@ -1358,7 +1358,19 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {return true;}if (matchHotKey(window.siyuan.config.keymap.editor.general.jumpToParentNext.custom, event)) {- jumpToParentNext(protyle, nodeElement);+ jumpToParent(protyle, nodeElement, "next");+ event.preventDefault();+ event.stopPropagation();+ return true;+ }+ if (matchHotKey(window.siyuan.config.keymap.editor.general.jumpToParent.custom, event)) {+ jumpToParent(protyle, nodeElement, "parent");+ event.preventDefault();+ event.stopPropagation();+ return true;+ }+ if (matchHotKey(window.siyuan.config.keymap.editor.general.jumpToParentPrev.custom, event)) {+ jumpToParent(protyle, nodeElement, "previous");event.preventDefault();event.stopPropagation();return true;