@marimo-team/islands 0.23.16-dev25 → 0.23.16-dev28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ import { syntaxTree } from "@codemirror/language";
4
4
  import type { EditorState } from "@codemirror/state";
5
5
  import { EditorView } from "@codemirror/view";
6
6
  import type { SyntaxNode, Tree, TreeCursor } from "@lezer/common";
7
+ import { scrollOwnerCell } from "../utils";
7
8
 
8
9
  const SCOPE_CREATING_NODES = new Set([
9
10
  "FunctionDefinition",
@@ -45,6 +46,8 @@ function goToPosition(view: EditorView, from: number): void {
45
46
  }),
46
47
  });
47
48
  });
49
+
50
+ scrollOwnerCell(view);
48
51
  }
49
52
 
50
53
  function findFirstMatchingVariable(
@@ -52,6 +52,34 @@ export function focusInputAndMoveToEnd(
52
52
  });
53
53
  }
54
54
 
55
+ /**
56
+ * Scrolls the `.marimo-cell` that owns `view` into view.
57
+ *
58
+ * `EditorView.scrollIntoView` doesn't work in columns mode: it stops at the
59
+ * first overflowing ancestor even if that ancestor doesn't actually scroll,
60
+ * so it never reaches the real horizontally-scrolling container. The
61
+ * browser's native `Element.scrollIntoView` doesn't have that problem.
62
+ *
63
+ * Deferred a frame so CodeMirror's own scroll settles first; otherwise it
64
+ * clamps this scroll right back.
65
+ *
66
+ * https://github.com/marimo-team/marimo/issues/10222
67
+ */
68
+ export function scrollOwnerCell(view: EditorView): void {
69
+ const cell = view.dom.closest(".marimo-cell");
70
+ if (!cell) {
71
+ return;
72
+ }
73
+
74
+ requestAnimationFrame(() => {
75
+ cell.scrollIntoView({
76
+ behavior: "instant",
77
+ block: "nearest",
78
+ inline: "nearest",
79
+ });
80
+ });
81
+ }
82
+
55
83
  export function isInVimMode(ev: EditorView): boolean {
56
84
  return getCM(ev)?.state.vim != null;
57
85
  }
@@ -17,6 +17,8 @@ export type CellConfig = schemas["CellConfig"];
17
17
  export type RuntimeState = schemas["CellNotification"]["status"];
18
18
  export type CodeCompletionRequest = schemas["CodeCompletionRequest"];
19
19
  export type DeleteCellRequest = schemas["DeleteCellRequest"];
20
+ export type AutoExportAsMarkdownRequest =
21
+ schemas["AutoExportAsMarkdownRequest"];
20
22
  export type ExportAsHTMLRequest = schemas["ExportAsHTMLRequest"];
21
23
  export type ExportAsMarkdownRequest = schemas["ExportAsMarkdownRequest"];
22
24
  export type ExportAsIPYNBRequest = schemas["ExportAsIPYNBRequest"];
@@ -221,7 +223,7 @@ export interface EditRequests {
221
223
  ) => Promise<ExportedFile<string>>;
222
224
  exportAsPDF: (request: ExportAsPDFRequest) => Promise<ExportedFile<Blob>>;
223
225
  autoExportAsHTML: (request: ExportAsHTMLRequest) => Promise<null>;
224
- autoExportAsMarkdown: (request: ExportAsMarkdownRequest) => Promise<null>;
226
+ autoExportAsMarkdown: (request: AutoExportAsMarkdownRequest) => Promise<null>;
225
227
  autoExportAsIPYNB: (request: ExportAsIPYNBRequest) => Promise<null>;
226
228
  updateCellOutputs: (request: UpdateCellOutputsRequest) => Promise<null>;
227
229
  // Package requests