Explorar el Código

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

Vanessa hace 1 año
padre
commit
4c23037242

+ 1 - 1
app/src/block/popover.ts

@@ -34,7 +34,7 @@ export const initBlockPopover = (app: App) => {
                         tip = getCellText(aElement);
                         tip = getCellText(aElement);
                     }
                     }
                 } else {
                 } else {
-                    if (aElement.firstElementChild.getAttribute("data-type") === "url") {
+                    if (aElement.firstElementChild?.getAttribute("data-type") === "url") {
                         if (aElement.firstElementChild.textContent.indexOf("...") > -1) {
                         if (aElement.firstElementChild.textContent.indexOf("...") > -1) {
                             tip = aElement.firstElementChild.getAttribute("data-href");
                             tip = aElement.firstElementChild.getAttribute("data-href");
                         }
                         }

+ 8 - 2
app/src/protyle/render/av/cell.ts

@@ -3,7 +3,7 @@ import {hasClosestBlock, hasClosestByClassName} from "../../util/hasClosest";
 import {openMenuPanel} from "./openMenuPanel";
 import {openMenuPanel} from "./openMenuPanel";
 import {updateAttrViewCellAnimation} from "./action";
 import {updateAttrViewCellAnimation} from "./action";
 import {isNotCtrl} from "../../util/compatibility";
 import {isNotCtrl} from "../../util/compatibility";
-import {objEquals} from "../../../util/functions";
+import {isDynamicRef, objEquals} from "../../../util/functions";
 import {fetchPost} from "../../../util/fetch";
 import {fetchPost} from "../../../util/fetch";
 import {focusBlock, focusByRange} from "../../util/selection";
 import {focusBlock, focusByRange} from "../../util/selection";
 import * as dayjs from "dayjs";
 import * as dayjs from "dayjs";
@@ -402,7 +402,13 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
                     focusByRange(protyle.toolbar.range);
                     focusByRange(protyle.toolbar.range);
                     cellElements[0].classList.add("av__cell--select");
                     cellElements[0].classList.add("av__cell--select");
                     addDragFill(cellElements[0]);
                     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();
                     avMaskElement?.remove();
                     event.preventDefault();
                     event.preventDefault();
                     event.stopPropagation();
                     event.stopPropagation();

+ 24 - 0
app/src/protyle/util/insertHTML.ts

@@ -135,6 +135,30 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
         }
         }
         return;
         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 text = protyle.lute.BlockDOM2EscapeMarkerContent(html);
     const cellsElement: HTMLElement[] = Array.from(blockElement.querySelectorAll(".av__cell--select"));
     const cellsElement: HTMLElement[] = Array.from(blockElement.querySelectorAll(".av__cell--select"));
     const rowsElement = blockElement.querySelector(".av__row--select");
     const rowsElement = blockElement.querySelector(".av__row--select");