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: Support block selection from cross-block text in read-only mode https://github.com/siyuan-note/siyuan/issues/19116
Daniel14bb9632794f
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20260830213256-fgl32qu.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20260830213256-fgl32qu.syindex 8b330fd131..b27639e457 100644--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20260830213256-fgl32qu.sy+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-h361q1i/20260830213256-fgl32qu.sy@@ -6,7 +6,7 @@"id": "20260830213256-fgl32qu","title": "Select and operate content blocks","type": "doc",- "updated": "20260830213256"+ "updated": "20260903165745"},"Children": [{@@ -29,7 +29,7 @@"HeadingLevel": 2,"Properties": {"id": "20260830213256-5do6z3r",- "updated": "20260830213256"+ "updated": "20260903165745"},"Children": [{@@ -43,7 +43,7 @@"ID": "20260830213256-819rhwy","Properties": {"id": "20260830213256-819rhwy",- "updated": "20260830213256"+ "updated": "20260903165745"},"Children": [{@@ -57,7 +57,16 @@},{"Type": "NodeText",- "Data": " to enter block selection mode. Press "+ "Data": " to enter block selection mode. After selecting text across blocks, press "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Esc"+ },+ {+ "Type": "NodeText",+ "Data": " to convert the range to a block selection; this also works in read-only mode. Press "},{"Type": "NodeTextMark",diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20260830213256-ye4cos4.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20260830213256-ye4cos4.syindex 8b5b75f442..0920ed6a6c 100644--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20260830213256-ye4cos4.sy+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-abz7w6k/20260830213256-ye4cos4.sy@@ -6,7 +6,7 @@"id": "20260830213256-ye4cos4","title": "选择和操作内容块","type": "doc",- "updated": "20260830213256"+ "updated": "20260903165745"},"Children": [{@@ -29,7 +29,7 @@"HeadingLevel": 2,"Properties": {"id": "20260830213256-ub9wfgv",- "updated": "20260830213256"+ "updated": "20260903165745"},"Children": [{@@ -43,7 +43,7 @@"ID": "20260830213256-2bk3bwx","Properties": {"id": "20260830213256-2bk3bwx",- "updated": "20260830213256"+ "updated": "20260903165745"},"Children": [{@@ -57,7 +57,16 @@},{"Type": "NodeText",- "Data": " 进入块选择模式。按 "+ "Data": " 进入块选择模式。跨块划选文本后按 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Esc"+ },+ {+ "Type": "NodeText",+ "Data": " 可将划选范围转换为块选择,只读模式下同样适用。按 "},{"Type": "NodeTextMark",diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20260830213256-jbsiw4b.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20260830213256-jbsiw4b.syindex 80d0380fc5..c9aa32a44e 100644--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20260830213256-jbsiw4b.sy+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120854-dr1jfx2/20260830213256-jbsiw4b.sy@@ -6,7 +6,7 @@"id": "20260830213256-jbsiw4b","title": "選取和操作內容區塊","type": "doc",- "updated": "20260830213256"+ "updated": "20260903165745"},"Children": [{@@ -29,7 +29,7 @@"HeadingLevel": 2,"Properties": {"id": "20260830213256-lp6qpp0",- "updated": "20260830213256"+ "updated": "20260903165745"},"Children": [{@@ -43,7 +43,7 @@"ID": "20260830213256-y3gtmf5","Properties": {"id": "20260830213256-y3gtmf5",- "updated": "20260830213256"+ "updated": "20260903165745"},"Children": [{@@ -57,7 +57,16 @@},{"Type": "NodeText",- "Data": " 進入區塊選取模式。按 "+ "Data": " 進入區塊選取模式。跨區塊選取文字後按 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Esc"+ },+ {+ "Type": "NodeText",+ "Data": " 可將選取範圍轉換為區塊選取;唯讀模式下同樣適用。按 "},{"Type": "NodeTextMark",diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20260830213256-014vk79.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20260830213256-014vk79.syindex 865c66e648..0406fe5d57 100644--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20260830213256-014vk79.sy+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-hnu6o79/20260830213256-014vk79.sy@@ -6,7 +6,7 @@"id": "20260830213256-014vk79","title": "ブロックの選択と操作","type": "doc",- "updated": "20260830213256"+ "updated": "20260903165745"},"Children": [{@@ -29,7 +29,7 @@"HeadingLevel": 2,"Properties": {"id": "20260830213256-pjttne5",- "updated": "20260830213256"+ "updated": "20260903165745"},"Children": [{@@ -43,7 +43,7 @@"ID": "20260830213256-5e9nkff","Properties": {"id": "20260830213256-5e9nkff",- "updated": "20260830213256"+ "updated": "20260903165745"},"Children": [{@@ -57,7 +57,16 @@},{"Type": "NodeText",- "Data": " を押すとブロック選択モードになります。"+ "Data": " を押すとブロック選択モードになります。複数のブロックにまたがってテキストを選択した後、"+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Esc"+ },+ {+ "Type": "NodeText",+ "Data": " を押すと、その範囲をブロック選択に切り替えられます。読み取り専用モードでも同様に使用できます。"},{"Type": "NodeTextMark",diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.tsindex 82c93f7923..a62dcbee0b 100644--- a/app/src/boot/globalEvent/keydown.ts+++ b/app/src/boot/globalEvent/keydown.ts@@ -29,9 +29,9 @@ import {fetchPost} from "../../util/fetch";import {goBack, goForward} from "../../util/backForward";import {getDisplayName, getNotebookName, isEncryptedBox} from "../../util/pathName";import {openFileById} from "../../editor/util";-import {getAllDocks, getAllModels, getAllTabs} from "../../layout/getAll";+import {getAllDocks, getAllEditor, getAllModels, getAllTabs} from "../../layout/getAll";import {getDockHotkey} from "../../layout/dock/hotkey";-import {focusBlock, focusByRange, getBlockElementsByRange} from "../../protyle/util/selection";+import {focusBlock, focusByRange, getBlockElementsByRange, selectBlocksByRange} from "../../protyle/util/selection";import {initFileMenu, initNavigationMenu} from "../../menus/navigation";import {bindMenuKeydown} from "../../menus/Menu";import {Dialog} from "../../dialog";@@ -87,6 +87,22 @@ const EDITOR_FONT_SIZE_COMMANDS: Array<{{command: "resetEditorFontSize", action: "reset"},];+const selectReadonlyBlocksByRange = (range: Range) => {+ const startElement = hasClosestBlock(range.startContainer);+ const endElement = hasClosestBlock(range.endContainer);+ if (!startElement || !endElement || startElement === endElement) {+ return false;+ }+ const protyle = getAllEditor().find(item => item.protyle.wysiwyg.element.contains(startElement) &&+ item.protyle.wysiwyg.element.contains(endElement))?.protyle;+ if (!protyle?.disabled) {+ return false;+ }+ hideElements(["toolbar", "hint", "util", "select"], protyle);+ selectBlocksByRange(protyle, range);+ return true;+};+const switchDialogEvent = (app: App, event: MouseEvent) => {event.preventDefault();let target = event.target as HTMLElement;@@ -1630,6 +1646,10 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {if (getSelection().rangeCount > 0) {const range = getSelection().getRangeAt(0);if (hasClosestByClassName(range.startContainer, "protyle-content", true)) {+ if (!event.repeat && selectReadonlyBlocksByRange(range)) {+ event.preventDefault();+ return;+ }focusByRange(range);return;}diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex 72b8076fcd..2b88fd8a28 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -296,10 +296,17 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {matchHotKey(Constants.SIYUAN_KEYMAP.editor.general.redo.default, event)) {event.preventDefault();}- if (protyle.disabled ||- (!protyle.selectElement.classList.contains("fn__none") &&- // 框选块时放行 ⌘C,以便复制选中的块 https://github.com/siyuan-note/siyuan/issues/18043- !matchHotKey("⌘C", event))) {+ if (protyle.disabled) {+ if (event.key === "Escape" && !event.isComposing && !event.repeat) {+ return;+ }+ event.stopPropagation();+ event.preventDefault();+ return;+ }+ if (!protyle.selectElement.classList.contains("fn__none") &&+ // 框选块时放行 ⌘C,以便复制选中的块 https://github.com/siyuan-note/siyuan/issues/18043+ !matchHotKey("⌘C", event)) {event.stopPropagation();event.preventDefault();return;