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/15998
Vanessabd6cf652667f
diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.tsindex 6cef3e64de..7da9f0d33c 100644--- a/app/src/mobile/util/keyboardToolbar.ts+++ b/app/src/mobile/util/keyboardToolbar.ts@@ -542,11 +542,12 @@ export const initKeyboardToolbar = () => {const slashBtnElement = hasClosestByClassName(event.target as HTMLElement, "keyboard__slash-item");if (slashBtnElement && !slashBtnElement.getAttribute("data-type")) {const dataValue = decodeURIComponent(slashBtnElement.getAttribute("data-value"));- protyle.hint.fill(dataValue, protyle, false); // 点击后 range 会改变- if (dataValue !== Constants.ZWSP + 3) {- event.preventDefault();- event.stopPropagation();+ if (dataValue === Constants.ZWSP + 3) {+ return;}+ protyle.hint.fill(dataValue, protyle, false); // 点击后 range 会改变+ event.preventDefault();+ event.stopPropagation();if (slashBtnElement.getAttribute("data-focus") === "true") {focusByRange(protyle.toolbar.range);}diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.tsindex 4864eb13a4..c98a1c9971 100644--- a/app/src/protyle/util/selection.ts+++ b/app/src/protyle/util/selection.ts@@ -5,7 +5,7 @@ import {hasPreviousSibling,isNotEditBlock} from "../wysiwyg/getBlock";-import {hasClosestByAttribute, hasClosestByTag} from "./hasClosest";+import {hasClosestBlock, hasClosestByAttribute, hasClosestByTag} from "./hasClosest";import {countBlockWord, countSelectWord} from "../../layout/status";import {hideElements} from "../ui/hideElements";import {genRenderFrame} from "../render/util";@@ -140,12 +140,23 @@ export const getEditorRange = (element: Element): Range => {if (getSelection().rangeCount > 0) {range = getSelection().getRangeAt(0);if (element === range.startContainer || element.contains(range.startContainer)) {- // 有时候点击编辑器头部需要矫正到第一个块中- if (range.toString() === "" && range.startContainer.nodeType === 1 && range.startOffset === 0 &&- (range.startContainer as HTMLElement).classList.contains("protyle-wysiwyg")) {- const focusRange = focusBlock(range.startContainer.firstChild as Element);- if (focusRange) {- return focusRange;+ if (range.toString() === "" && range.startContainer.nodeType === 1) {+ // 有时候点击编辑器头部需要矫正到第一个块中+ if (range.startOffset === 0 && (range.startContainer as HTMLElement).classList.contains("protyle-wysiwyg")) {+ const focusRange = focusBlock(range.startContainer.firstChild as Element);+ if (focusRange) {+ return focusRange;+ }+ }+ // 移动端获取有偏差 https://github.com/siyuan-note/siyuan/issues/15998+ if (getContenteditableElement(range.startContainer as Element)) {+ const blockElement = hasClosestBlock(range.startContainer);+ if (blockElement) {+ const focusRange = focusBlock(blockElement);+ if (focusRange) {+ return focusRange;+ }+ }}}return range;