diff --git a/app/src/constants.ts b/app/src/constants.ts index 9beeb12d5..a5154561b 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -770,7 +770,7 @@ export abstract class Constants { public static readonly SIYUAN_ASSETS_IMAGE: string[] = [".apng", ".ico", ".cur", ".jpg", ".jpe", ".jpeg", ".jfif", ".pjp", ".pjpeg", ".png", ".gif", ".webp", ".bmp", ".svg", ".avif", ".tiff", ".tif"]; public static readonly SIYUAN_ASSETS_AUDIO: string[] = [".mp3", ".wav", ".ogg", ".m4a", ".aac", ".flac"]; public static readonly SIYUAN_ASSETS_VIDEO: string[] = [".mov", ".weba", ".mkv", ".mp4", ".webm"]; - public static readonly SIYUAN_ASSETS_EXTS: string[] = [".pdf"].concat(Constants.SIYUAN_ASSETS_IMAGE).concat(Constants.SIYUAN_ASSETS_AUDIO).concat(Constants.SIYUAN_ASSETS_VIDEO); + public static readonly SIYUAN_ASSETS_EXTS: string[] = [".pdf"].concat(Constants.SIYUAN_ASSETS_IMAGE, Constants.SIYUAN_ASSETS_AUDIO, Constants.SIYUAN_ASSETS_VIDEO); public static readonly SIYUAN_ASSETS_SEARCH: string[] = [".txt", ".md", ".markdown", ".docx", ".xlsx", ".pptx", ".pdf", ".json", ".log", ".sql", ".html", ".xml", ".java", ".h", ".c", ".cpp", ".go", ".rs", ".swift", ".kt", ".py", ".php", ".js", ".css", ".ts", ".sh", ".bat", ".cmd", ".ini", ".yaml", ".rst", ".adoc", ".textile", ".opml", ".org", ".wiki", ".epub", ".cs"]; diff --git a/app/src/protyle/render/av/relation.ts b/app/src/protyle/render/av/relation.ts index 9e6351409..d3108ac93 100644 --- a/app/src/protyle/render/av/relation.ts +++ b/app/src/protyle/render/av/relation.ts @@ -460,7 +460,7 @@ export const getRelationHTML = (data: IAV, cellElements?: HTMLElement[]) => { } }; -export const setRelationCell = (protyle: IProtyle, nodeElement: HTMLElement, target: HTMLElement, cellElements: HTMLElement[]) => { +export const setRelationCell = async (protyle: IProtyle, nodeElement: HTMLElement, target: HTMLElement, cellElements: HTMLElement[]) => { const menuElement = hasClosestByClassName(target, "b3-menu"); if (!menuElement) { return; @@ -537,12 +537,22 @@ draggable="true">${genSelectItemHTML({ if (!separatorElement.nextElementSibling) { separatorElement.insertAdjacentHTML("afterend", genSelectItemHTML({type: "empty"})); } + updateCellsValue(protyle, nodeElement, newValue, cellElements); } else { const blockID = target.querySelector(".popover__block").getAttribute("data-id"); const content = target.querySelector("b").textContent; const rowId = Lute.NewNodeID(); const bodyElement = hasClosestByClassName(cellElements[0], "av__body"); - transaction(protyle, [{ + newValue.blockIDs.push(rowId); + newValue.contents.push({ + type: "block", + block: { + content + }, + isDetached: true + }); + const updateOptions = await updateCellsValue(protyle, nodeElement, newValue, cellElements, null, null, true); + const doOperations: IOperation[] = [{ action: "insertAttrViewBlock", ignoreDefaultFill: true, avID: menuElement.firstElementChild.getAttribute("data-av-id"), @@ -558,15 +568,8 @@ draggable="true">${genSelectItemHTML({ action: "doUpdateUpdated", id: blockID, data: dayjs().format("YYYYMMDDHHmmss"), - }]); - newValue.blockIDs.push(rowId); - newValue.contents.push({ - type: "block", - block: { - content - }, - isDetached: true - }); + }]; + transaction(protyle, doOperations.concat(updateOptions.doOperations)); separatorElement.insertAdjacentHTML("beforebegin", ``); } } - updateCellsValue(protyle, nodeElement, newValue, cellElements); updateCopyRelatedItems(menuElement); };