Skip to content

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

:art: Refine database column width snap feedback https://github.com/siyuan-note/siyuan/issues/12952

Danielaa588a91b778
diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scss
index 7a977d3cce..38bcb21d6a 100644
--- a/app/src/assets/scss/business/_av.scss
+++ b/app/src/assets/scss/business/_av.scss
@@ -1186,7 +1186,8 @@
z-index: 1;
touch-action: none;
- &:hover {
+ &:hover,
+ &--active {
background-color: var(--b3-theme-primary);
}
}
@@ -1197,7 +1198,7 @@
position: fixed;
transform: translateX(-50%);
width: 1px;
- z-index: 2;
+ z-index: 1000;
}
&__width-tip {
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 95ce5888e0..c54cb185d0 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -1403,18 +1403,20 @@ export class WYSIWYG {
});
const initialDragRight = dragRect.right;
const widthScale = dragRect.width / oldWidth || 1;
+ const snapGuideThreshold = 16;
const snapGuideRight = previousWidth === undefined ? undefined :
initialDragRight + (previousWidth - oldWidth) * widthScale;
- const headerTop = headerElement.getBoundingClientRect().top;
- const bodyBottom = bodyElement.getBoundingClientRect().bottom;
- const guideHeight = Math.max(0,
- Math.round(Math.min(bodyBottom, contentRect.bottom, window.innerHeight) - headerTop));
+ const headerRect = headerElement.getBoundingClientRect();
+ const headerTop = headerRect.top;
+ const guideHeight = Math.round(headerRect.height);
let newWidth: number;
let resizeGuide: HTMLElement;
let resizeTip: HTMLElement;
let pendingResize: { width: number, snapped: boolean } | undefined;
let resizeAnimationFrame: number | undefined;
+ target.classList.add("av__widthdrag--active");
const clearResizePreview = () => {
+ target.classList.remove("av__widthdrag--active");
resizeGuide?.remove();
resizeTip?.remove();
};
@@ -1432,7 +1434,9 @@ export class WYSIWYG {
resizeTip.className = "av__width-tip";
document.body.appendChild(resizeTip);
}
- resizeGuide?.classList.toggle("fn__none", snapped);
+ const showSnapGuide = !snapped && typeof previousWidth === "number" &&
+ Math.abs(newWidth - previousWidth) <= snapGuideThreshold;
+ resizeGuide?.classList.toggle("fn__none", !showSnapGuide);
const dragRight = initialDragRight + (newWidth - oldWidth) * widthScale;
resizeTip.style.left = `${dragRight}px`;
resizeTip.style.top = `${Math.round(headerTop)}px`;