Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/10690

Vanessa4c230372421c
diff --git a/app/src/block/popover.ts b/app/src/block/popover.ts
index 5affab758c..55ee973351 100644
--- a/app/src/block/popover.ts
+++ b/app/src/block/popover.ts
@@ -34,7 +34,7 @@ export const initBlockPopover = (app: App) => {
tip = getCellText(aElement);
}
} else {
- if (aElement.firstElementChild.getAttribute("data-type") === "url") {
+ if (aElement.firstElementChild?.getAttribute("data-type") === "url") {
if (aElement.firstElementChild.textContent.indexOf("...") > -1) {
tip = aElement.firstElementChild.getAttribute("data-href");
}
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index 396f2deacd..36375fb83b 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -3,7 +3,7 @@ import {hasClosestBlock, hasClosestByClassName} from "../../util/hasClosest";
import {openMenuPanel} from "./openMenuPanel";
import {updateAttrViewCellAnimation} from "./action";
import {isNotCtrl} from "../../util/compatibility";
-import {objEquals} from "../../../util/functions";
+import {isDynamicRef, objEquals} from "../../../util/functions";
import {fetchPost} from "../../../util/fetch";
import {focusBlock, focusByRange} from "../../util/selection";
import * as dayjs from "dayjs";
@@ -402,7 +402,13 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
focusByRange(protyle.toolbar.range);
cellElements[0].classList.add("av__cell--select");
addDragFill(cellElements[0]);
- hintRef(inputElement.value.substring(2), protyle, "av");
+ let textPlain = inputElement.value;
+ if (isDynamicRef(textPlain)) {
+ textPlain = textPlain.substring(2, 22 + 2)
+ } else {
+ textPlain = textPlain.substring(2)
+ }
+ hintRef(textPlain, protyle, "av");
avMaskElement?.remove();
event.preventDefault();
event.stopPropagation();
diff --git a/app/src/protyle/util/insertHTML.ts b/app/src/protyle/util/insertHTML.ts
index 56ec30365e..6d1630336b 100644
--- a/app/src/protyle/util/insertHTML.ts
+++ b/app/src/protyle/util/insertHTML.ts
@@ -135,6 +135,30 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
}
return;
}
+ const contenteditableElement = getContenteditableElement(tempElement.content.firstElementChild);
+ if (contenteditableElement && contenteditableElement.childNodes.length === 1 && contenteditableElement.firstElementChild?.getAttribute("data-type") === "block-ref") {
+ const selectCellElement = blockElement.querySelector(".av__cell--select") as HTMLElement
+ if (selectCellElement) {
+ const avID = blockElement.dataset.avId;
+ const sourceId = contenteditableElement.firstElementChild.getAttribute("data-id");
+ const previousID = selectCellElement.dataset.blockId;
+ transaction(protyle, [{
+ action: "replaceAttrViewBlock",
+ avID,
+ previousID,
+ nextID: sourceId,
+ isDetached: false,
+ }], [{
+ action: "replaceAttrViewBlock",
+ avID,
+ previousID: sourceId,
+ nextID: previousID,
+ isDetached: selectCellElement.dataset.detached === "true",
+ }]);
+ return;
+ }
+ }
+
const text = protyle.lute.BlockDOM2EscapeMarkerContent(html);
const cellsElement: HTMLElement[] = Array.from(blockElement.querySelectorAll(".av__cell--select"));
const rowsElement = blockElement.querySelector(".av__row--select");