From 6a6e4cd182f9cc735ce897b7340e2436f6b423e5 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 6 Mar 2024 10:11:46 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/10523 --- app/src/protyle/render/av/relation.ts | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/app/src/protyle/render/av/relation.ts b/app/src/protyle/render/av/relation.ts index e46faca9b..489985f62 100644 --- a/app/src/protyle/render/av/relation.ts +++ b/app/src/protyle/render/av/relation.ts @@ -4,7 +4,7 @@ import {upDownHint} from "../../../util/upDownHint"; import {fetchPost} from "../../../util/fetch"; import {escapeGreat, escapeHtml} from "../../../util/escape"; import {transaction} from "../../wysiwyg/transaction"; -import {updateCellsValue} from "./cell"; +import {genCellValueByElement, updateCellsValue} from "./cell"; import {updateAttrViewCellAnimation} from "./action"; import {focusBlock} from "../../util/selection"; import {setPosition} from "../../../util/setPosition"; @@ -237,7 +237,7 @@ const filterItem = (menuElement: Element, keyword: string) => { id: menuElement.firstElementChild.getAttribute("data-av-id"), keyword, }, response => { - const cells = response.data.rows.values as IAVCellValue[]; + const cells = response.data.rows.values as IAVCellValue[] || []; let html = ""; let selectHTML = ""; hasIds.forEach(hasId => { @@ -272,7 +272,7 @@ export const bindRelationEvent = (options: { id: options.menuElement.firstElementChild.getAttribute("data-av-id"), keyword: "", }, response => { - const cells = response.data.rows.values as IAVCellValue[]; + const cells = response.data.rows.values as IAVCellValue[] || []; let html = ""; let selectHTML = ""; hasIds.forEach(hasId => { @@ -363,20 +363,7 @@ export const setRelationCell = (protyle: IProtyle, nodeElement: HTMLElement, tar if (!menuElement) { return; } - const newValue: { - blockIDs: string[] - contents?: string[] - } = { - blockIDs: [], - contents: [] - }; - Array.from(menuElement.children).forEach((item) => { - const id = item.getAttribute("data-id"); - if (item.getAttribute("draggable") && id) { - newValue.blockIDs.push(id); - newValue.contents.push(item.textContent.trim()); - } - }); + const newValue = genCellValueByElement("relation", cellElements[0]).relation; if (target.classList.contains("b3-menu__item")) { const targetId = target.getAttribute("data-id"); const separatorElement = menuElement.querySelector(".b3-menu__separator");