Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve frozen column resizing in database tables https://github.com/siyuan-note/siyuan/issues/19680

Daniel377752a665a1
diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts
index 70757b3a2c..684fb2deaf 100644
--- a/app/src/protyle/render/av/render.ts
+++ b/app/src/protyle/render/av/render.ts
@@ -196,9 +196,8 @@ export const genTabHeaderHTML = (data: IAV, showSearch: boolean, editable: boole
const getTableHTMLs = (data: IAVTable, e: HTMLElement, virtualData: IAVVirtualData,
reserveVirtualHeight = false) => {
- const freezeDragHTML = `<div class="av__freeze-drag ariaLabel" data-position="east" aria-label="${escapeAttr(window.siyuan.languages.freezeDrag)}"></div>`;
let calcHTML = "";
- let contentHTML = `<div class="av__row av__row--header"><div class="av__colsticky"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div>${freezeDragHTML}</div>`;
+ let contentHTML = '<div class="av__row av__row--header"><div class="av__colsticky"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div></div>';
let freezeIndex = -1;
data.columns.forEach((item, index) => {
if (!item.hidden && item.pin) {
@@ -226,7 +225,7 @@ style="width: ${escapeAttr(column.width) || "200px"};">
<div class="av__widthdrag"></div>
</div>`;
if (pinIndex === index) {
- contentHTML += `${freezeDragHTML}</div>`;
+ contentHTML += "</div>";
}
if (column.type === "lineNumber") {
// lineNumber type 不参与计算操作
diff --git a/app/src/protyle/render/av/row.ts b/app/src/protyle/render/av/row.ts
index 97b207f7be..e1c2016b82 100644
--- a/app/src/protyle/render/av/row.ts
+++ b/app/src/protyle/render/av/row.ts
@@ -203,9 +203,9 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, options.ro
html = `<div class="av__row" data-index="${options.rowIndex}" data-id="${tableRow.id}">`;
if (options.pinIndex > -1) {
- html += '<div class="av__colsticky av__colsticky--freeze"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div>';
+ html += `<div class="av__colsticky av__colsticky--freeze"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg>${getFreezeDragHTML()}</div>`;
} else {
- html += '<div class="av__colsticky"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div></div>';
+ html += `<div class="av__colsticky"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg>${getFreezeDragHTML()}</div></div>`;
}
tableRow.cells.forEach((cell, index) => {
@@ -236,6 +236,8 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, options.ro
return html + "<div></div></div>";
};
+const getFreezeDragHTML = () => `<div class="av__freeze-drag ariaLabel" data-position="east" aria-label="${escapeAttr(window.siyuan.languages.freezeDrag)}"></div>`;
+
export const getFieldIdByCellElement = (cellElement: Element, viewType: TAVView): string => {
if (isCustomAttr(cellElement)) {
return cellElement.getAttribute("data-row-id");
@@ -431,10 +433,10 @@ export const insertAttrViewBlockAnimation = (options: {
if (!previousElement) {
return;
}
- let cellsHTML = '<div class="av__colsticky"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div></div>';
+ let cellsHTML = `<div class="av__colsticky"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg>${getFreezeDragHTML()}</div></div>`;
const pinIndex = previousElement.querySelectorAll(".av__colsticky .av__cell").length - 1;
if (pinIndex > -1) {
- cellsHTML = '<div class="av__colsticky av__colsticky--freeze"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg></div>';
+ cellsHTML = `<div class="av__colsticky av__colsticky--freeze"><div class="av__firstcol"><svg><use xlink:href="#iconUncheck"></use></svg>${getFreezeDragHTML()}</div>`;
}
previousElement.querySelectorAll(".av__cell").forEach((item: HTMLElement, index) => {
let lineNumber = 1;
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index cbe0413a0b..ace8ba0efd 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -1518,7 +1518,7 @@ export class WYSIWYG {
return;
}
const bodyElement = hasClosestByClassName(target, "av__body") as HTMLElement;
- const headerElement = hasClosestByClassName(target, "av__row--header") as HTMLElement;
+ const headerElement = bodyElement?.querySelector<HTMLElement>(".av__row--header");
if (!bodyElement || !headerElement) {
return;
}
@@ -1540,6 +1540,9 @@ export class WYSIWYG {
};
documentSelf.onmousemove = (moveEvent: MouseEvent) => {
const moveTarget = moveEvent.target as HTMLElement;
+ if (moveTarget.classList.contains("av__freeze-drag")) {
+ return;
+ }
const firstColElement = hasClosestByClassName(moveTarget, "av__firstcol");
const cellElement = hasClosestByClassName(moveTarget, "av__cell") as HTMLElement;
if (firstColElement && bodyElement.contains(firstColElement)) {