mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-02 19:00:15 +01:00
This commit is contained in:
parent
6cb4ec8777
commit
f822e4d69e
3 changed files with 61 additions and 16 deletions
|
|
@ -8,7 +8,7 @@ import {pathPosix} from "../../util/pathName";
|
|||
import {genAssetHTML} from "../../asset/renderAssets";
|
||||
import {hasClosestBlock} from "../util/hasClosest";
|
||||
import {getContenteditableElement} from "../wysiwyg/getBlock";
|
||||
import {updateCellsValue} from "../render/av/cell";
|
||||
import {getTypeByCellElement, updateCellsValue} from "../render/av/cell";
|
||||
|
||||
export class Upload {
|
||||
public element: HTMLElement;
|
||||
|
|
@ -143,17 +143,48 @@ const genUploadedLabel = (responseText: string, protyle: IProtyle) => {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
if ((nodeElement && nodeElement.classList.contains("av"))) {
|
||||
updateCellsValue(protyle, nodeElement, avAssets);
|
||||
document.querySelector(".av__panel")?.remove();
|
||||
return;
|
||||
}
|
||||
if (document.querySelector(".av__panel")) {
|
||||
const blockElement = hasClosestBlock(protyle.wysiwyg.element.querySelector(".av__cell--select"));
|
||||
if (blockElement) {
|
||||
updateCellsValue(protyle, blockElement, avAssets);
|
||||
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[] = []
|
||||
protyle.wysiwyg.element.querySelectorAll(".av__cell--active").forEach((item: HTMLElement) => {
|
||||
if (getTypeByCellElement(item) === "mAsset") {
|
||||
cellElements.push(item);
|
||||
}
|
||||
})
|
||||
if (cellElements.length > 0) {
|
||||
const blockElement = hasClosestBlock(cellElements[0]);
|
||||
if (blockElement) {
|
||||
updateCellsValue(protyle, blockElement, avAssets, cellElements);
|
||||
document.querySelector(".av__panel")?.remove();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 避免插入代码块中,其次因为都要独立成块 https://github.com/siyuan-note/siyuan/issues/7607
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue