Vanessa 2024-03-28 23:34:11 +08:00
parent 2d04decf7e
commit 4c23037242
3 changed files with 33 additions and 3 deletions

View file

@ -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");
}

View file

@ -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();

View file

@ -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");