mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +01:00
This commit is contained in:
parent
3b41b73367
commit
621bee1f14
2 changed files with 35 additions and 4 deletions
|
|
@ -24,6 +24,7 @@ interface ITableOptions {
|
||||||
selectItemIds: string[],
|
selectItemIds: string[],
|
||||||
isSearching: boolean,
|
isSearching: boolean,
|
||||||
editIds: string[],
|
editIds: string[],
|
||||||
|
pageSizes: { [key: string]: string },
|
||||||
query: string,
|
query: string,
|
||||||
oldOffset: number,
|
oldOffset: number,
|
||||||
}
|
}
|
||||||
|
|
@ -137,6 +138,13 @@ const afterRenderGallery = (options: ITableOptions) => {
|
||||||
if (options.resetData.alignSelf) {
|
if (options.resetData.alignSelf) {
|
||||||
options.blockElement.style.alignSelf = options.resetData.alignSelf;
|
options.blockElement.style.alignSelf = options.resetData.alignSelf;
|
||||||
}
|
}
|
||||||
|
Object.keys(options.resetData.pageSizes).forEach((groupId) => {
|
||||||
|
if (groupId === "unGroup") {
|
||||||
|
(options.blockElement.querySelector(".av__body") as HTMLElement).dataset.pageSize = options.resetData.pageSizes[groupId];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(options.blockElement.querySelector(`.av__body[data-group-id="${groupId}"]`) as HTMLElement).dataset.pageSize = options.resetData.pageSizes[groupId];
|
||||||
|
});
|
||||||
if (getSelection().rangeCount > 0) {
|
if (getSelection().rangeCount > 0) {
|
||||||
// 修改表头后光标重新定位
|
// 修改表头后光标重新定位
|
||||||
const range = getSelection().getRangeAt(0);
|
const range = getSelection().getRangeAt(0);
|
||||||
|
|
@ -233,6 +241,10 @@ export const renderGallery = async (options: {
|
||||||
selectItemIds.push(rowId);
|
selectItemIds.push(rowId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const pageSizes: { [key: string]: string } = {};
|
||||||
|
options.blockElement.querySelectorAll(".av__body").forEach((item: HTMLElement) => {
|
||||||
|
pageSizes[item.dataset.groupId || "unGroup"] = item.dataset.pageSize;
|
||||||
|
});
|
||||||
const resetData = {
|
const resetData = {
|
||||||
isSearching: searchInputElement && document.activeElement === searchInputElement,
|
isSearching: searchInputElement && document.activeElement === searchInputElement,
|
||||||
query: searchInputElement?.value || "",
|
query: searchInputElement?.value || "",
|
||||||
|
|
@ -240,6 +252,7 @@ export const renderGallery = async (options: {
|
||||||
oldOffset: options.protyle.contentElement.scrollTop,
|
oldOffset: options.protyle.contentElement.scrollTop,
|
||||||
editIds,
|
editIds,
|
||||||
selectItemIds,
|
selectItemIds,
|
||||||
|
pageSizes,
|
||||||
};
|
};
|
||||||
if (options.blockElement.firstElementChild.innerHTML === "") {
|
if (options.blockElement.firstElementChild.innerHTML === "") {
|
||||||
options.blockElement.style.alignSelf = "";
|
options.blockElement.style.alignSelf = "";
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ interface ITableOptions {
|
||||||
dragFillId: string,
|
dragFillId: string,
|
||||||
activeIds: string[],
|
activeIds: string[],
|
||||||
query: string,
|
query: string,
|
||||||
|
pageSizes: { [key: string]: string },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -270,7 +271,10 @@ const afterRenderTable = (options: ITableOptions) => {
|
||||||
options.blockElement.style.alignSelf = options.resetData.alignSelf;
|
options.blockElement.style.alignSelf = options.resetData.alignSelf;
|
||||||
const editRect = options.protyle.contentElement.getBoundingClientRect();
|
const editRect = options.protyle.contentElement.getBoundingClientRect();
|
||||||
if (options.resetData.headerTransform) {
|
if (options.resetData.headerTransform) {
|
||||||
(options.blockElement.querySelector('.av__row--header[style^="transform"]') as HTMLElement).style.transform = options.resetData.headerTransform;
|
const headerTransformElement = options.blockElement.querySelector('.av__row--header[style^="transform"]') as HTMLElement;
|
||||||
|
if (headerTransformElement) {
|
||||||
|
headerTransformElement.style.transform = options.resetData.headerTransform;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 需等待渲染完,否则 getBoundingClientRect 错误 https://github.com/siyuan-note/siyuan/issues/13787
|
// 需等待渲染完,否则 getBoundingClientRect 错误 https://github.com/siyuan-note/siyuan/issues/13787
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
@ -278,7 +282,10 @@ const afterRenderTable = (options: ITableOptions) => {
|
||||||
}, Constants.TIMEOUT_LOAD);
|
}, Constants.TIMEOUT_LOAD);
|
||||||
}
|
}
|
||||||
if (options.resetData.footerTransform) {
|
if (options.resetData.footerTransform) {
|
||||||
(options.blockElement.querySelector(".av__row--footer") as HTMLElement).style.transform = options.resetData.footerTransform;
|
const footerTransformElement = options.blockElement.querySelector('.av__row--footer[style^="transform"]') as HTMLElement;
|
||||||
|
if (footerTransformElement) {
|
||||||
|
footerTransformElement.style.transform = options.resetData.footerTransform;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 需等待渲染完,否则 getBoundingClientRect 错误 https://github.com/siyuan-note/siyuan/issues/13787
|
// 需等待渲染完,否则 getBoundingClientRect 错误 https://github.com/siyuan-note/siyuan/issues/13787
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
@ -315,7 +322,13 @@ const afterRenderTable = (options: ITableOptions) => {
|
||||||
updateHeader(rowElement);
|
updateHeader(rowElement);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Object.keys(options.resetData.pageSizes).forEach((groupId) => {
|
||||||
|
if (groupId === "unGroup") {
|
||||||
|
(options.blockElement.querySelector(".av__body") as HTMLElement).dataset.pageSize = options.resetData.pageSizes[groupId];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(options.blockElement.querySelector(`.av__body[data-group-id="${groupId}"]`) as HTMLElement).dataset.pageSize = options.resetData.pageSizes[groupId];
|
||||||
|
});
|
||||||
if (options.resetData.dragFillId) {
|
if (options.resetData.dragFillId) {
|
||||||
addDragFill(options.blockElement.querySelector(`.av__row[data-id="${options.resetData.dragFillId.split(Constants.ZWSP)[0]}"] .av__cell[data-col-id="${options.resetData.dragFillId.split(Constants.ZWSP)[1]}"]`));
|
addDragFill(options.blockElement.querySelector(`.av__row[data-id="${options.resetData.dragFillId.split(Constants.ZWSP)[0]}"] .av__cell[data-col-id="${options.resetData.dragFillId.split(Constants.ZWSP)[1]}"]`));
|
||||||
}
|
}
|
||||||
|
|
@ -443,6 +456,10 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: (data: IAV) =
|
||||||
activeIds.push((hasClosestByClassName(item, "av__row") as HTMLElement).dataset.id + Constants.ZWSP + item.getAttribute("data-col-id"));
|
activeIds.push((hasClosestByClassName(item, "av__row") as HTMLElement).dataset.id + Constants.ZWSP + item.getAttribute("data-col-id"));
|
||||||
});
|
});
|
||||||
const searchInputElement = e.querySelector('[data-type="av-search"]') as HTMLInputElement;
|
const searchInputElement = e.querySelector('[data-type="av-search"]') as HTMLInputElement;
|
||||||
|
const pageSizes: { [key: string]: string } = {};
|
||||||
|
e.querySelectorAll(".av__body").forEach((item: HTMLElement) => {
|
||||||
|
pageSizes[item.dataset.groupId || "unGroup"] = item.dataset.pageSize;
|
||||||
|
});
|
||||||
const resetData = {
|
const resetData = {
|
||||||
selectCellId,
|
selectCellId,
|
||||||
alignSelf: e.style.alignSelf,
|
alignSelf: e.style.alignSelf,
|
||||||
|
|
@ -453,7 +470,8 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: (data: IAV) =
|
||||||
selectRowIds,
|
selectRowIds,
|
||||||
dragFillId,
|
dragFillId,
|
||||||
activeIds,
|
activeIds,
|
||||||
query: searchInputElement?.value || ""
|
query: searchInputElement?.value || "",
|
||||||
|
pageSizes
|
||||||
};
|
};
|
||||||
if (e.firstElementChild.innerHTML === "") {
|
if (e.firstElementChild.innerHTML === "") {
|
||||||
e.style.alignSelf = "";
|
e.style.alignSelf = "";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue