An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: fix https://github.com/siyuan-note/siyuan/issues/6495
Vanessaa0e1d8e2e93a
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.tsindex 02d66eb032..7744809c3a 100644--- a/app/src/protyle/toolbar/index.ts+++ b/app/src/protyle/toolbar/index.ts@@ -70,7 +70,7 @@ export class Toolbar {public render(protyle: IProtyle, range: Range, event?: KeyboardEvent) {this.range = range;- const nodeElement = hasClosestBlock(range.startContainer);+ let nodeElement = hasClosestBlock(range.startContainer);if (!nodeElement || protyle.disabled) {this.element.classList.add("fn__none");return;@@ -100,8 +100,17 @@ export class Toolbar {if (event) { // 在 keyup 中使用 shift+方向键选中if (event.key === "ArrowLeft") {this.range = setLastNodeRange(getContenteditableElement(startElement), range, false);- } else {+ } else if (event.key === "ArrowRight") {+ this.range = setFirstNodeRange(getContenteditableElement(endElement), range);+ this.range.collapse(false);+ } else if (event.key === "ArrowUp") {this.range = setFirstNodeRange(getContenteditableElement(endElement), range);+ nodeElement = hasClosestBlock(endElement)+ if (!nodeElement) {+ return;+ }+ } else if (event.key === "ArrowDown") {+ this.range = setLastNodeRange(getContenteditableElement(startElement), range, false);}} else {this.range = setLastNodeRange(getContenteditableElement(nodeElement), range, false);diff --git a/app/src/protyle/wysiwyg/commonHotkey.ts b/app/src/protyle/wysiwyg/commonHotkey.tsindex c040a00efe..3bee1211d1 100644--- a/app/src/protyle/wysiwyg/commonHotkey.ts+++ b/app/src/protyle/wysiwyg/commonHotkey.ts@@ -1,7 +1,11 @@import {matchHotKey} from "../util/hotKey";import {fetchPost} from "../../util/fetch";import {writeText} from "../util/compatibility";-import {focusByOffset, getSelectionOffset, setFirstNodeRange, setLastNodeRange} from "../util/selection";+import {+ focusByOffset,+ getSelectionOffset,+ setFirstNodeRange,+} from "../util/selection";import {fullscreen, netImg2LocalAssets} from "../breadcrumb/action";import {setPadding} from "../ui/initUI";/// #if !MOBILE@@ -86,8 +90,7 @@ export const upSelect = (options: {options.event.stopPropagation();options.event.preventDefault();} else {- const start = getSelectionOffset(options.nodeElement, options.editorElement, options.range).start;- if (start !== 0) {+ if (getSelectionOffset(options.nodeElement, options.editorElement, options.range).start !== 0) {const editElement = getContenteditableElement(options.nodeElement);if (editElement.tagName === "TABLE") {const cellElement = hasClosestByMatchTag(options.range.startContainer, "TH") || hasClosestByMatchTag(options.range.startContainer, "TD") || editElement.querySelector("th, td");@@ -97,16 +100,9 @@ export const upSelect = (options: {options.event.preventDefault();return;}- } else {- const firstIndex = editElement.textContent.indexOf("\n");- if (firstIndex === -1 || start <= firstIndex || start === editElement.textContent.replace("\n", " ").indexOf("\n")) {- setFirstNodeRange(editElement, options.range);- options.event.stopPropagation();- options.event.preventDefault();- return;- } else {- return;- }+ } else{+ // 选中上一个节点的处理在 toolbar/index.ts 中 `shift+方向键或三击选中`+ return;}}}@@ -139,17 +135,9 @@ export const downSelect = (options: {options.event.stopPropagation();options.event.preventDefault();} else {- const editElement = getContenteditableElement(options.nodeElement);- const end = getSelectionOffset(options.nodeElement, options.editorElement, options.range).end;- if (end < editElement.textContent.length) {- if (end > editElement.textContent.lastIndexOf("\n")) {- setLastNodeRange(editElement, options.range, false);- options.event.stopPropagation();- options.event.preventDefault();- return;- } else {- return;- }+ if (getSelectionOffset(options.nodeElement, options.editorElement, options.range).end < getContenteditableElement(options.nodeElement).textContent.length) {+ // 选中下一个节点的处理在 toolbar/index.ts 中 `shift+方向键或三击选中`+ return;}}options.range.collapse(false);