Skip to content

Commit 2415b24

Browse files
committed
bad jquery way of dealing with scrolled state of output and stable html
- also add tooltip to make it MUCH EASIER to toggle scrolled state. Duh.
1 parent 44166ec commit 2415b24

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

src/packages/frontend/jupyter/cell-output-toggle.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,18 @@ export const OutputToggle: React.FC<OutputToggleProps> = React.memo(
4343
}
4444

4545
return (
46-
<Tooltip title="Click to toggle whether large output is scrolled. Double click to hide.">
46+
<Tooltip
47+
title={
48+
<>
49+
Click{" "}
50+
<a onClick={toggle_scrolled}>
51+
to {scrolled ? "show" : "hide"} large output
52+
</a>
53+
.<br />
54+
Double click <a onClick={collapse_output}>to hide</a>.
55+
</>
56+
}
57+
>
4758
<Button
4859
type="text"
4960
style={scrolled ? SCROLLED_STYLE : NORMAL_STYLE}

src/packages/frontend/jupyter/output-messages/stable-unsafe-html.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,25 @@ export default function StableUnsafeHtml({
130130
eltRect.width,
131131
parentRect.right - SCROLL_WIDTH - eltRect.left,
132132
);
133-
const bottom = Math.min(eltRect.height, parentRect.bottom - eltRect.top);
133+
134+
// .closest('.a');
135+
//const bottom = Math.min(eltRect.height, parentRect.bottom - eltRect.top);
136+
// We do this so that if the output is COLLAPSED, then the html doesn't
137+
// go outside the shortened div. We do not do anything regarding making
138+
// scroll work in there though -- if you want to see the whole thing, you
139+
// must not collapse it.
140+
const containerRect = $(divRef.current)
141+
.closest(".cocalc-jupyter-rendered")[0]
142+
?.getBoundingClientRect();
143+
const bottom = Math.max(
144+
top,
145+
Math.min(
146+
eltRect.height,
147+
(containerRect?.bottom ?? parentRect.bottom) - eltRect.top,
148+
parentRect.bottom - eltRect.top,
149+
),
150+
);
151+
134152
const left = Math.max(0, parentRect.left - eltRect.left);
135153

136154
// Apply clip-path to elt to make it visible only inside of parentRect:

0 commit comments

Comments
 (0)