Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/9983

Vanessaba0700f37448
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index 9d51c702d2..c5ac2e8841 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -5,11 +5,13 @@ import {updateAttrViewCellAnimation} from "./action";
import {isNotCtrl} from "../../util/compatibility";
import {objEquals} from "../../../util/functions";
import {fetchPost} from "../../../util/fetch";
-import {focusBlock} from "../../util/selection";
+import {focusBlock, focusByRange} from "../../util/selection";
import * as dayjs from "dayjs";
import {unicode2Emoji} from "../../../emoji";
import {getColIconByType} from "./col";
import {genAVValueHTML} from "./blockAttr";
+import {Constants} from "../../../constants";
+import {hintRef} from "../../hint/extend";
export const getCellText = (cellElement: HTMLElement | false) => {
if (!cellElement) {
@@ -305,6 +307,24 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
});
});
}
+ if (type === "block" && blockElement) {
+ inputElement.addEventListener("input", (event: InputEvent) => {
+ if (event.isComposing) {
+ return;
+ }
+ if (Constants.BLOCK_HINT_KEYS.includes(inputElement.value)) {
+ protyle.toolbar.range = document.createRange();
+ protyle.toolbar.range.selectNodeContents(cellElements[0].lastChild);
+ focusByRange(protyle.toolbar.range);
+ hintRef("", protyle, "av");
+ inputElement.value = "";
+ updateCellValueByInput(protyle, type, cellElements);
+ avMaskElement?.remove();
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ })
+ }
inputElement.addEventListener("keydown", (event) => {
if (event.isComposing) {
return;