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/17852
Vanessa62518f752566
diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.tsindex d321c5379a..9a58e71e45 100644--- a/app/src/protyle/util/paste.ts+++ b/app/src/protyle/util/paste.ts@@ -3,7 +3,7 @@ import {uploadFiles, uploadLocalFiles} from "../upload";import {processPasteCode, processRender} from "./processCode";import {getLocalFiles, getTextSiyuanFromTextHTML, readText} from "./compatibility";import {hasClosestBlock, hasClosestByAttribute, hasClosestByClassName} from "./hasClosest";-import {getEditorRange} from "./selection";+import {getEditorRange, getSelectionOffset} from "./selection";import {blockRender} from "../render/blockRender";import {highlightRender} from "../render/highlightRender";import {fetchPost} from "../../util/fetch";@@ -19,6 +19,28 @@ import {removeZWJ} from "./normalizeText";import {base64ToURL} from "../../util/image";import {resolveLinkDest} from "../toolbar/util";+export const beforePaste = (protyle: IProtyle, blockElement: HTMLElement) => {+ // 链接,备注,样式,引用,pdf标注粘贴 https://github.com/siyuan-note/siyuan/issues/11572+ const range = getSelection().getRangeAt(0);+ protyle.toolbar.range = range;+ const inlineElement = range.startContainer.parentElement;+ if (range.toString() === "" && inlineElement.tagName === "SPAN") {+ const currentTypes = (inlineElement.getAttribute("data-type") || "").split(" ");+ if (currentTypes.includes("inline-memo") || currentTypes.includes("text") ||+ currentTypes.includes("block-ref") || currentTypes.includes("file-annotation-ref") ||+ currentTypes.includes("a")) {+ const offset = getSelectionOffset(inlineElement, blockElement, range);+ if (offset.start === 0) {+ range.setStartBefore(inlineElement);+ range.collapse(true);+ } else if (offset.start === inlineElement.textContent.length) {+ range.setEndAfter(inlineElement);+ range.collapse(false);+ }+ }+ }+};+export const getTextStar = (blockElement: HTMLElement, contentOnly = false) => {const dataType = blockElement.dataset.type;let refText = "";diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex 82dfff7f9c..3a44e5f2e4 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -1,4 +1,4 @@-import {enableLuteMarkdownSyntax, getTextStar, paste, restoreLuteMarkdownSyntax} from "../util/paste";+import {beforePaste, enableLuteMarkdownSyntax, getTextStar, paste, restoreLuteMarkdownSyntax} from "../util/paste";import {hasClosestBlock,hasClosestByAttribute,@@ -2447,25 +2447,7 @@ export class WYSIWYG {if (!blockElement) {return;}- // 链接,备注,样式,引用,pdf标注粘贴 https://github.com/siyuan-note/siyuan/issues/11572- const range = getSelection().getRangeAt(0);- protyle.toolbar.range = range;- const inlineElement = range.startContainer.parentElement;- if (range.toString() === "" && inlineElement.tagName === "SPAN") {- const currentTypes = (inlineElement.getAttribute("data-type") || "").split(" ");- if (currentTypes.includes("inline-memo") || currentTypes.includes("text") ||- currentTypes.includes("block-ref") || currentTypes.includes("file-annotation-ref") ||- currentTypes.includes("a")) {- const offset = getSelectionOffset(inlineElement, blockElement, range);- if (offset.start === 0) {- range.setStartBefore(inlineElement);- range.collapse(true);- } else if (offset.start === inlineElement.textContent.length) {- range.setEndAfter(inlineElement);- range.collapse(false);- }- }- }+ beforePaste(protyle, blockElement)paste(protyle, event);});diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex 58cd207c72..6b92a25e47 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -65,7 +65,7 @@ import * as dayjs from "dayjs";import {highlightRender} from "../render/highlightRender";import {countBlockWord} from "../../layout/status";import {moveToDown, moveToUp} from "./move";-import {pasteAsPlainText} from "../util/paste";+import {beforePaste, pasteAsPlainText} from "../util/paste";import {preventScroll} from "../scroll/preventScroll";import {getSavePath, newFileBySelect} from "../../util/newFile";import {removeSearchMark} from "../toolbar/util";@@ -1979,6 +1979,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {event.returnValue = false;event.preventDefault();event.stopPropagation();+ beforePaste(protyle, nodeElement);pasteAsPlainText(protyle);return;}