Skip to content

Commit ed5e11c

Browse files
committed
whiteboard html jupyter output: fix #8442, fix #8000
1 parent e5c75e8 commit ed5e11c

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

src/packages/frontend/jupyter/cell-list.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { Cell } from "./cell";
3737
import HeadingTagComponent from "./heading-tag";
3838

3939
interface StableHtmlContextType {
40+
enabled?: boolean;
4041
cellListDivRef?: MutableRefObject<any>;
4142
scrollOrResize?: { [key: string]: () => void };
4243
}
@@ -571,7 +572,9 @@ export const CellList: React.FC<CellListProps> = (props: CellListProps) => {
571572

572573
if (use_windowed_list) {
573574
body = (
574-
<StableHtmlContext.Provider value={{ cellListDivRef, scrollOrResize }}>
575+
<StableHtmlContext.Provider
576+
value={{ cellListDivRef, scrollOrResize, enabled: true }}
577+
>
575578
<div ref={cellListDivRef} className="smc-vfill">
576579
<Virtuoso
577580
ref={virtuosoRef}

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

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ If for any reason the react element exists or the parent is scrolled, then
2424
the idle timeout is reset.
2525
*/
2626

27-
import { useCallback, useEffect, useRef } from "react";
27+
import { useCallback, useEffect, useMemo, useRef } from "react";
2828
import $ from "jquery";
2929
import { useFrameContext } from "@cocalc/frontend/frame-editors/frame-tree/frame-context";
3030
import { useStableHtmlContext } from "@cocalc/frontend/jupyter/cell-list";
@@ -86,11 +86,39 @@ export default function StableUnsafeHtml({
8686
html,
8787
zIndex = Z_INDEX, // todo: support changing?
8888
}: Props) {
89+
const stableHtmlContext = useStableHtmlContext();
90+
if (stableHtmlContext.enabled) {
91+
return (
92+
<EnabledStableUnsafeHtml
93+
docId={docId}
94+
html={html}
95+
zIndex={zIndex}
96+
stableHtmlContext={stableHtmlContext}
97+
/>
98+
);
99+
} else {
100+
return <DisabledStableUnsafeHtml html={html} />;
101+
}
102+
}
103+
104+
export function DisabledStableUnsafeHtml({ html }) {
105+
const elt = useMemo(
106+
() => <div style={STYLE} dangerouslySetInnerHTML={{ __html: html }}></div>,
107+
[html],
108+
);
109+
return elt;
110+
}
111+
112+
export function EnabledStableUnsafeHtml({
113+
docId,
114+
html,
115+
zIndex = Z_INDEX, // todo: support changing?
116+
stableHtmlContext,
117+
}) {
89118
const divRef = useRef<any>(null);
90119
const cellOutputDivRef = useRef<any>(null);
91120
const intervalRef = useRef<any>(null);
92121
const { isVisible, project_id, path, id } = useFrameContext();
93-
const stableHtmlContext = useStableHtmlContext();
94122
const htmlRef = useRef<string>(html);
95123
const globalKeyRef = useRef<string>(
96124
sha1(`${project_id}-${id}-${docId}-${path}-${html}`),

src/packages/util/db-schema/accounts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,13 +471,13 @@ Table({
471471
undo_depth: 300,
472472
jupyter_classic: false,
473473
jupyter_window: false,
474-
disable_jupyter_windowing: false,
474+
disable_jupyter_windowing: true,
475475
show_exec_warning: true,
476476
physical_keyboard: "default",
477477
keyboard_variant: "",
478478
ask_jupyter_kernel: true,
479479
show_my_other_cursors: false,
480-
disable_jupyter_virtualization: false,
480+
disable_jupyter_virtualization: true,
481481
},
482482
other_settings: {
483483
katex: true,

src/packages/util/smc-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/* autogenerated by the update_version script */
2-
exports.version=1753891241;
2+
exports.version=1755363036;

0 commit comments

Comments
 (0)