diff --git a/app/src/protyle/upload/index.ts b/app/src/protyle/upload/index.ts index e882fddeb..9a956c206 100644 --- a/app/src/protyle/upload/index.ts +++ b/app/src/protyle/upload/index.ts @@ -122,7 +122,7 @@ const genUploadedLabel = (responseText: string, protyle: IProtyle) => { let successFileText = ""; const keys = Object.keys(response.data.succMap); // 插入多个资源文件时按文件名自然升序排列 Use natural ascending order when inserting multiple assets https://github.com/siyuan-note/siyuan/issues/14643 - keys.sort((a, b) => a.localeCompare(b, undefined, { numeric: true })); + keys.sort((a, b) => a.localeCompare(b, undefined, {numeric: true})); const avAssets: IAVCellAssetValue[] = []; let hasImage = false; keys.forEach((key, index) => { @@ -149,31 +149,6 @@ const genUploadedLabel = (responseText: string, protyle: IProtyle) => { } }); - if ((nodeElement && nodeElement.classList.contains("av"))) { - const cellElements: HTMLElement[] = []; - nodeElement.querySelectorAll(".av__row--select:not(.av__row--header)").forEach(item => { - item.querySelectorAll(".av__cell").forEach((cellItem: HTMLElement) => { - if (getTypeByCellElement(cellItem) === "mAsset") { - cellElements.push(cellItem); - } - }); - }); - if (cellElements.length === 0) { - protyle.wysiwyg.element.querySelectorAll(".av__cell--active").forEach((item: HTMLElement) => { - if (getTypeByCellElement(item) === "mAsset") { - cellElements.push(item); - } - }); - } - if (cellElements.length > 0) { - updateCellsValue(protyle, nodeElement, avAssets, cellElements); - document.querySelector(".av__panel")?.remove(); - return; - } else { - return; - } - } - if (document.querySelector(".av__panel")) { const cellElements: HTMLElement[] = [document.querySelector('.custom-attr__avvalue[data-type="mAsset"][data-active="true"]')]; if (!cellElements[0]) { @@ -194,6 +169,28 @@ const genUploadedLabel = (responseText: string, protyle: IProtyle) => { } else { return; } + } else if (nodeElement && nodeElement.classList.contains("av")) { + const cellElements: HTMLElement[] = []; + nodeElement.querySelectorAll(".av__row--select:not(.av__row--header)").forEach(item => { + item.querySelectorAll(".av__cell").forEach((cellItem: HTMLElement) => { + if (getTypeByCellElement(cellItem) === "mAsset") { + cellElements.push(cellItem); + } + }); + }); + if (cellElements.length === 0) { + protyle.wysiwyg.element.querySelectorAll(".av__cell--active").forEach((item: HTMLElement) => { + if (getTypeByCellElement(item) === "mAsset") { + cellElements.push(item); + } + }); + } + if (cellElements.length > 0) { + updateCellsValue(protyle, nodeElement, avAssets, cellElements); + return; + } else { + return; + } } // 避免插入代码块中,其次因为都要独立成块 https://github.com/siyuan-note/siyuan/issues/7607 insertHTML(successFileText, protyle, insertBlock);