An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Simplify controls for small images https://github.com/siyuan-note/siyuan/issues/20719
Daniel47b6e53e5b6d
diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scssindex dd17ffb41e..9c466a7957 100644--- a/app/src/assets/scss/protyle/_wysiwyg.scss+++ b/app/src/assets/scss/protyle/_wysiwyg.scss@@ -671,6 +671,23 @@ $block-rtl-selector: ".protyle-block--rtl" !default;position: relative;}+ > .protyle-image-container--compact {+ > .protyle-icons,+ > .img__net,+ .protyle-block-resize[data-resize-axis="width"],+ .protyle-block-resize[data-resize-axis="height"] {+ display: none;+ }++ .protyle-block-resize[data-resize-axis="both"]::after {+ width: 5px;+ height: 5px;+ border: 0;+ border-radius: 50%;+ background-color: currentColor;+ }+ }+.protyle-image-resize {position: absolute;pointer-events: none;diff --git a/app/src/protyle/render/imageResize.test.ts b/app/src/protyle/render/imageResize.test.tsindex e919f5aa29..1ebecf6f27 100644--- a/app/src/protyle/render/imageResize.test.ts+++ b/app/src/protyle/render/imageResize.test.ts@@ -196,6 +196,38 @@ const browserCases = async (source: string, resizeSource: string, luteSource: stcheck.equal(handle.classList.contains("touch-resize-active"), false);check.equal(getComputedStyle(handle).visibility, "visible", "cancelling a drag preserves selected handles");}+ for (const [width, height] of [[24, 12], [200, 20], [40, 100]]) {+ const compact = await create();+ compact.style.width = width + "px";+ compact.style.height = height + "px";+ compact.parentElement.insertAdjacentHTML("beforeend", '<span class="img__net">network</span>');+ await settle();+ tap(compact);+ const container = compact.parentElement;+ check.equal(getComputedStyle(container.querySelector(".protyle-icons")).display, "none",+ "small images hide overlay menus");+ check.equal(getComputedStyle(container.querySelector(".img__net")).display, "none",+ "network markers do not obscure small images");+ for (const axis of ["width", "height"]) {+ check.equal(getComputedStyle(container.querySelector(`[data-resize-axis="${axis}"]`)).display, "none");+ }+ const corner = container.querySelector<HTMLElement>('[data-resize-axis="both"]');+ check.equal(getComputedStyle(corner, "::after").width, "5px");+ const rect = corner.getBoundingClientRect();+ check.equal(document.elementFromPoint(rect.left + rect.width / 2, rect.top + rect.height / 2), corner,+ "the compact corner retains its pointer and touch target");+ begin(compact, "both", new MouseEvent("mousedown", {clientX: 300, clientY: 200}));+ document.onmousemove(new MouseEvent("mousemove", {clientX: 320, clientY: 210}));+ document.onmouseup(new MouseEvent("mouseup"));+ check.ok(compact.clientWidth > width, "small images can still be enlarged");+ container.style.width = "200px";+ compact.style.width = "";+ compact.style.height = "";+ await settle();+ check.notEqual(getComputedStyle(container.querySelector(".protyle-icons")).display, "none",+ "enlarging restores overlay menus");+ check.equal(getComputedStyle(corner, "::after").width, "16px");+ }const centered = await create();root.firstElementChild.setAttribute("style", "text-align: center");begin(centered, "width", new MouseEvent("mousedown", {clientX: 300, clientY: 200}));diff --git a/app/src/protyle/render/imageResize.ts b/app/src/protyle/render/imageResize.tsindex 25ff83e596..0efc8c9532 100644--- a/app/src/protyle/render/imageResize.ts+++ b/app/src/protyle/render/imageResize.ts@@ -14,6 +14,7 @@ export const getImageResizeWidth = (width: number, height: number, deltaX: numbeexport const bindImageResize = (root: HTMLElement) => {const images = new Map<HTMLImageElement, {frame: HTMLElement, container: HTMLElement}>();const position = (image: HTMLImageElement, frame: HTMLElement) => {+ image.parentElement.classList.toggle("protyle-image-container--compact", image.clientWidth < 96 || image.clientHeight < 48);frame.style.left = image.offsetLeft + "px";frame.style.top = image.offsetTop + "px";frame.style.width = image.clientWidth + "px";