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: fix https://github.com/siyuan-note/siyuan/issues/9886
Vanessaa104c94c5f9f
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.tsindex ede01846df..06e26c0432 100644--- a/app/src/protyle/render/av/action.ts+++ b/app/src/protyle/render/av/action.ts@@ -25,6 +25,7 @@ import * as dayjs from "dayjs";import {openCalcMenu} from "./calc";import {avRender} from "./render";import {addView, openViewMenu} from "./view";+import {writeText} from "../../util/compatibility";export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => {const blockElement = hasClosestBlock(event.target);@@ -41,7 +42,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEleconst copyElement = hasClosestByAttribute(event.target, "data-type", "copy");if (copyElement) {- getCellText(hasClosestByClassName(copyElement, "av__cell"));+ writeText(getCellText(hasClosestByClassName(copyElement, "av__cell")));showMessage(window.siyuan.languages.copied);event.preventDefault();event.stopPropagation();diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.tsindex 0b7e170b07..21bdf3ff9c 100644--- a/app/src/protyle/render/av/cell.ts+++ b/app/src/protyle/render/av/cell.ts@@ -2,7 +2,7 @@ import {transaction} from "../../wysiwyg/transaction";import {hasClosestBlock, hasClosestByClassName} from "../../util/hasClosest";import {openMenuPanel} from "./openMenuPanel";import {updateAttrViewCellAnimation} from "./action";-import {isNotCtrl, writeText} from "../../util/compatibility";+import {isNotCtrl} from "../../util/compatibility";import {objEquals} from "../../../util/functions";import {fetchPost} from "../../../util/fetch";import {focusBlock} from "../../util/selection";@@ -10,19 +10,21 @@ import * as dayjs from "dayjs";export const getCellText = (cellElement: HTMLElement | false) => {if (!cellElement) {- return+ return "";}+ let cellText = ""const textElement = cellElement.querySelector(".av__celltext");if (textElement) {if (textElement.querySelector(".av__cellicon")) {- writeText(`${textElement.firstChild.textContent} → ${textElement.lastChild.textContent}`);+ cellText = `${textElement.firstChild.textContent} → ${textElement.lastChild.textContent}`;} else {- writeText(textElement.textContent);+ cellText = textElement.textContent;}} else {- writeText(cellElement.textContent);+ cellText = cellElement.textContent;}-}+ return cellText;+};const genCellValueByElement = (colType: TAVCol, cellElement: HTMLElement) => {let cellValue: IAVCellValue;@@ -55,7 +57,6 @@ const genCellValueByElement = (colType: TAVCol, cellElement: HTMLElement) => {mSelect};} else if (["date", "created", "updated"].includes(colType)) {- debugger;cellValue = {type: colType,[colType]: JSON.parse(cellElement.querySelector(".av__celltext").getAttribute("data-value"))@@ -97,7 +98,7 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {type: colType,mSelect: [{content: value,- color: ""+ color: value ? "1" : ""}]};} else if (["date", "created", "updated"].includes(colType) && value === "") {@@ -435,7 +436,7 @@ const updateCellValueByInput = (protyle: IProtyle, type: TAVCol, cellElements: H});};-export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement) => {+export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, value = "") => {const doOperations: IOperation[] = []const undoOperations: IOperation[] = []@@ -471,7 +472,7 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement) =>avID,keyID: colId,rowID,- data: genCellValue(type, "")+ data: genCellValue(type, value)});undoOperations.push({action: "updateAttrViewCell",diff --git a/app/src/protyle/render/av/keydown.ts b/app/src/protyle/render/av/keydown.tsindex 5742ae918d..bcc5d79f0d 100644--- a/app/src/protyle/render/av/keydown.ts+++ b/app/src/protyle/render/av/keydown.ts@@ -1,6 +1,6 @@import {matchHotKey} from "../../util/hotKey";import {selectRow} from "./row";-import {cellScrollIntoView, popTextCell} from "./cell";+import {cellScrollIntoView, popTextCell, updateCellsValue} from "./cell";import {avContextmenu} from "./action";import {hasClosestByClassName} from "../../util/hasClosest";import {Constants} from "../../../constants";@@ -34,6 +34,11 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protylevent.preventDefault();return true;}+ if (event.key === "Backspace") {+ updateCellsValue(protyle, nodeElement);+ event.preventDefault();+ return true;+ }let newCellElement;if (event.key === "ArrowLeft" || matchHotKey("⇧⇥", event)) {const previousRowElement = rowElement.previousElementSibling;diff --git a/app/src/protyle/util/insertHTML.ts b/app/src/protyle/util/insertHTML.tsindex 556c543574..a90b90a172 100644--- a/app/src/protyle/util/insertHTML.ts+++ b/app/src/protyle/util/insertHTML.ts@@ -9,6 +9,17 @@ import {highlightRender} from "../render/highlightRender";import {scrollCenter} from "../../util/highlightById";import {updateAVName} from "../render/av/action";import {readText} from "./compatibility";+import {updateCellsValue} from "../render/av/cell";++const processAV = (range: Range, text: string, protyle: IProtyle, blockElement: Element) => {+ if (blockElement.querySelector(".av__cell--select, .av__row--select")) {+ updateCellsValue(protyle, blockElement as HTMLElement, text);+ } else {+ range.insertNode(document.createTextNode(text));+ range.collapse(false);+ updateAVName(protyle, blockElement);+ }+};export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,// 移动端插入嵌入块时,获取到的 range 为旧值@@ -43,14 +54,10 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,range.deleteContents();const text = readText();if (typeof text === "string") {- range.insertNode(document.createTextNode(text));- range.collapse(false);- updateAVName(protyle, blockElement);+ processAV(range, text, protyle, blockElement)} else {text.then((t) => {- range.insertNode(document.createTextNode(t));- range.collapse(false);- updateAVName(protyle, blockElement);+ processAV(range, t, protyle, blockElement)});}return;