This commit is contained in:
Vanessa 2023-12-29 15:00:36 +08:00
parent c70031ed3a
commit 2e1394a01b
8 changed files with 25 additions and 25 deletions

View File

@ -111,18 +111,18 @@ export const exportImage = (id: string) => {
watermarkPreviewElement.innerHTML = window.siyuan.config.export.imageWatermarkDesc;
} else if (window.siyuan.config.export.imageWatermarkStr) {
if (window.siyuan.config.export.imageWatermarkStr.startsWith("http")) {
watermarkPreviewElement.setAttribute("style", `background-image: url(${window.siyuan.config.export.imageWatermarkStr});background-repeat: repeat;position: absolute;top: 0;left: 0;width: 100%;height: 100%;border-radius: var(--b3-border-radius-b);`)
watermarkPreviewElement.setAttribute("style", `background-image: url(${window.siyuan.config.export.imageWatermarkStr});background-repeat: repeat;position: absolute;top: 0;left: 0;width: 100%;height: 100%;border-radius: var(--b3-border-radius-b);`);
} else {
addScript("/stage/protyle/js/html2canvas.min.js?v=1.4.1", "protyleHtml2canvas").then(() => {
const width = Math.max(exportDialog.element.querySelector('.export-img').clientWidth / 3, 150);
watermarkPreviewElement.setAttribute("style", `width: ${width}px;height: ${width}px;display: flex;justify-content: center;align-items: center;color: var(--b3-border-color);font-size: 14px;`)
const width = Math.max(exportDialog.element.querySelector(".export-img").clientWidth / 3, 150);
watermarkPreviewElement.setAttribute("style", `width: ${width}px;height: ${width}px;display: flex;justify-content: center;align-items: center;color: var(--b3-border-color);font-size: 14px;`);
watermarkPreviewElement.innerHTML = `<div style="transform: rotate(-45deg)">${window.siyuan.config.export.imageWatermarkStr}</div>`;
window.html2canvas(watermarkPreviewElement, {
useCORS: true,
scale: 1,
}).then((canvas) => {
watermarkPreviewElement.innerHTML = "";
watermarkPreviewElement.setAttribute("style", `background-image: url(${canvas.toDataURL("image/png")});background-repeat: repeat;position: absolute;top: 0;left: 0;width: 100%;height: 100%;border-radius: var(--b3-border-radius-b);`)
watermarkPreviewElement.setAttribute("style", `background-image: url(${canvas.toDataURL("image/png")});background-repeat: repeat;position: absolute;top: 0;left: 0;width: 100%;height: 100%;border-radius: var(--b3-border-radius-b);`);
});
});
}
@ -130,7 +130,7 @@ export const exportImage = (id: string) => {
} else {
watermarkPreviewElement.removeAttribute("style");
}
}
};
const refreshPreview = (response: IWebSocketData) => {
previewElement.innerHTML = response.data.content;
// https://github.com/siyuan-note/siyuan/issues/9685

View File

@ -125,7 +125,7 @@ export const updateAssetCell = (options: {
}
const cellValue = genCellValueByElement(getTypeByCellElement(item) || item.dataset.type as TAVCol, item);
const rowID = (hasClosestByClassName(item, "av__row") as HTMLElement).dataset.id;
const oldValue = JSON.parse(JSON.stringify(cellValue))
const oldValue = JSON.parse(JSON.stringify(cellValue));
if (elementIndex === 0) {
if (options.type === "remove") {
cellValue.mAsset.find((oldItem, index) => {
@ -317,7 +317,7 @@ export const addAssetLink = (protyle: IProtyle, data: IAV, cellElements: HTMLEle
});
};
export const dragUpload = (files: string[], protyle: IProtyle, cellElement: HTMLElement, avID: string, blockElement: Element) => {
export const dragUpload = (files: string[], protyle: IProtyle, cellElement: HTMLElement, avID: string) => {
const msgId = showMessage(window.siyuan.languages.uploading, 0);
fetchPost("/api/asset/insertLocalAssets", {
assetPaths: files,

View File

@ -56,7 +56,7 @@ export const genCellValueByElement = (colType: TAVCol, cellElement: HTMLElement)
});
cellValue.mSelect = mSelect;
} else if (["date", "created", "updated"].includes(colType)) {
cellValue[colType as "date"] = JSON.parse(cellElement.querySelector(".av__celltext").getAttribute("data-value"))
cellValue[colType as "date"] = JSON.parse(cellElement.querySelector(".av__celltext").getAttribute("data-value"));
} else if (colType === "checkbox") {
cellValue.checkbox = {
checked: cellElement.querySelector("use").getAttribute("xlink:href") === "#iconCheck" ? true : false
@ -67,16 +67,16 @@ export const genCellValueByElement = (colType: TAVCol, cellElement: HTMLElement)
contents: Array.from(cellElement.querySelectorAll("span")).map((item: HTMLElement) => item.textContent),
};
} else if (colType === "mAsset") {
const mAsset: IAVCellAssetValue[] = []
const mAsset: IAVCellAssetValue[] = [];
Array.from(cellElement.children).forEach((item) => {
const isImg = item.classList.contains("av__cellassetimg")
const isImg = item.classList.contains("av__cellassetimg");
mAsset.push({
type: isImg ? "image" : "file",
content: isImg ? item.getAttribute("src") : item.getAttribute("data-url"),
name: isImg ? "" : item.textContent
})
})
cellValue.mAsset = mAsset
});
});
cellValue.mAsset = mAsset;
}
if (colType === "block") {
cellValue.isDetached = cellElement.dataset.detached === "true";
@ -313,7 +313,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
event.preventDefault();
event.stopPropagation();
}
})
});
}
inputElement.addEventListener("keydown", (event) => {
if (event.isComposing) {

View File

@ -894,7 +894,7 @@ export const openMenuPanel = (options: {
break;
} else if (type === "removeCol") {
const colId = menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id");
let previousID: string
let previousID: string;
const colData = data.view.columns.find((item: IAVColumn, index) => {
if (item.id === colId) {
previousID = data.view.columns[index - 1]?.id;

View File

@ -13,7 +13,7 @@ const updateCol = (protyle: IProtyle, data: IAV, colId: string, itemElement: HTM
if (item.id === colId) {
return true;
}
})
});
transaction(protyle, [{
action: "updateAttrViewColRollup",
id: colId,
@ -28,8 +28,8 @@ const updateCol = (protyle: IProtyle, data: IAV, colId: string, itemElement: HTM
// operation.ParentID 汇总列基于的关联列 ID
// operation.KeyID 目标列 ID
// operation.Data 计算方式
}])
}
}]);
};
const genSearchList = (element: Element, keyword: string, avId: string, cb?: () => void) => {
fetchPost("/api/av/searchAttributeViewRelationKey", {
@ -115,8 +115,8 @@ export const goSearchRollupCol = (options: {
export const goSearchRollupTarget = (avId: string, target: HTMLElement) => {
}
};
export const goSearchRollupCalc = (avId: string, target: HTMLElement) => {
}
};

View File

@ -500,7 +500,7 @@ export const addColOptionOrCell = (protyle: IProtyle, data: IAV, cellElements: H
});
return true;
}
})
});
if (item.classList.contains("custom-attr__avvalue")) {
item.innerHTML = genAVValueHTML(cellValue);
} else {

View File

@ -125,12 +125,12 @@ const genUploadedLabel = (responseText: string, protyle: IProtyle) => {
const path = response.data.succMap[key];
const type = pathPosix().extname(key).toLowerCase();
const filename = protyle.options.upload.filename(key);
const name = filename.substring(0, filename.length - type.length)
const name = filename.substring(0, filename.length - type.length);
avAssets.push({
type: Constants.SIYUAN_ASSETS_IMAGE.includes(type) ? "image" : "file",
content: path,
name: name
})
});
succFileText += genAssetHTML(type, path, name, filename);
if (!Constants.SIYUAN_ASSETS_AUDIO.includes(type) && !Constants.SIYUAN_ASSETS_VIDEO.includes(type) &&
keys.length - 1 !== index) {
@ -146,7 +146,7 @@ const genUploadedLabel = (responseText: string, protyle: IProtyle) => {
if ((nodeElement && nodeElement.classList.contains("av"))) {
updateCellsValue(protyle, nodeElement, avAssets);
document.querySelector(".av__panel")?.remove();
return
return;
}
if (document.querySelector(".av__panel")) {
const blockElement = hasClosestBlock(protyle.wysiwyg.element.querySelector(".av__cell--select"));

View File

@ -1016,7 +1016,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
for (let i = 0; i < event.dataTransfer.files.length; i++) {
files.push(event.dataTransfer.files[i].path);
}
dragUpload(files, protyle, cellElement, avElement.dataset.avId, avElement);
dragUpload(files, protyle, cellElement, avElement.dataset.avId);
}
}
}