This commit is contained in:
Vanessa 2023-10-31 09:46:19 +08:00
parent 98692c85df
commit 22a4fd9285
9 changed files with 26 additions and 27 deletions

View file

@ -266,10 +266,10 @@ export class Background {
event.stopPropagation();
break;
} else if (type === "show-random") {
let html = ""
let html = "";
bgs.forEach((item: string, index: number) => {
html += `<div data-index="${index}" style="height: 148px;width: 148px;${item}" class="b3-card"></div>`
})
html += `<div data-index="${index}" style="height: 148px;width: 148px;${item}" class="b3-card"></div>`;
});
const dialog = new Dialog({
title: window.siyuan.languages.random,
content: `<div class="b3-cards" style="margin-right: 0">${html}</div>`,
@ -277,7 +277,7 @@ export class Background {
height: isMobile() ? "80vh" : "70vh",
});
dialog.element.addEventListener("click", (event) => {
const target = event.target as HTMLElement
const target = event.target as HTMLElement;
if (target.classList.contains("b3-card")) {
this.ial["title-img"] = bgs[parseInt(target.getAttribute("data-index"))];
this.render(this.ial, protyle.block.rootID);
@ -287,7 +287,7 @@ export class Background {
});
dialog.destroy();
}
})
});
event.preventDefault();
event.stopPropagation();
break;

View file

@ -350,7 +350,7 @@ ${genHintItemHTML(item)}
searchHTML = `<button style="width: calc(100% - 16px)" class="b3-list-item b3-list-item--two" data-value="">${window.siyuan.languages.emptyContent}</button>`;
}
this.element.lastElementChild.innerHTML = searchHTML;
setPosition(this.element, parseInt(this.element.style.left), parseInt(this.element.style.right))
setPosition(this.element, parseInt(this.element.style.left), parseInt(this.element.style.right));
});
}

View file

@ -334,24 +334,24 @@ export const dragUpload = (files: string[], protyle: IProtyle, cellElement: HTML
id: protyle.block.rootID
}, (response) => {
hideMessage(msgId);
const addUpdateValue: IAVCellAssetValue[] = []
const addUpdateValue: IAVCellAssetValue[] = [];
Object.keys(response.data.succMap).forEach(key => {
const type = pathPosix().extname(key).toLowerCase();
const name = key.substring(0, key.length - type.length)
const name = key.substring(0, key.length - type.length);
if (Constants.SIYUAN_ASSETS_IMAGE.includes(type)) {
addUpdateValue.push({
type: "image",
name,
content: response.data.succMap[key],
})
});
} else {
addUpdateValue.push({
type: "file",
name,
content: response.data.succMap[key],
})
});
}
})
});
fetchPost("/api/av/renderAttributeView", {
id: avID,
}, (response) => {
@ -362,6 +362,6 @@ export const dragUpload = (files: string[], protyle: IProtyle, cellElement: HTML
type: "addUpdate",
addUpdateValue
});
})
});
});
}
};

View file

@ -990,7 +990,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
} else if (!window.siyuan.dragElement && (event.dataTransfer.types[0] === "Files" || event.dataTransfer.types.includes("text/html"))) {
// 外部文件拖入编辑器中或者编辑器内选中文字拖拽
// https://github.com/siyuan-note/siyuan/issues/9544
const avElement = hasClosestByClassName(event.target, 'av')
const avElement = hasClosestByClassName(event.target, "av");
if (!avElement) {
focusByRange(getRangeByPoint(event.clientX, event.clientY));
if (event.dataTransfer.types[0] === "Files" && !isBrowser()) {
@ -1003,9 +1003,9 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
paste(protyle, event);
}
} else {
const cellElement = hasClosestByClassName(event.target, 'av__cell')
const cellElement = hasClosestByClassName(event.target, "av__cell");
if (cellElement) {
const cellType = avElement.querySelector(`.av__row--header [data-col-id="${cellElement.dataset.colId}"]`)?.getAttribute("data-dtype")
const cellType = avElement.querySelector(`.av__row--header [data-col-id="${cellElement.dataset.colId}"]`)?.getAttribute("data-dtype");
if (cellType === "mAsset" && event.dataTransfer.types[0] === "Files" && !isBrowser()) {
const files: string[] = [];
for (let i = 0; i < event.dataTransfer.files.length; i++) {