@marimo-team/islands 0.23.9-dev44 → 0.23.9-dev46

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.
@@ -3,6 +3,7 @@
3
3
  import { useMemo, useRef, useState } from "react";
4
4
  import type { EditorView } from "@codemirror/view";
5
5
  import { useAtomValue } from "jotai";
6
+ import { cellDomProps } from "@/components/editor/common";
6
7
  import { CellEditor } from "@/components/editor/cell/code/cell-editor";
7
8
  import { CellStatusComponent } from "@/components/editor/cell/CellStatus";
8
9
  import { RunButton } from "@/components/editor/cell/RunButton";
@@ -111,7 +112,10 @@ export const SlideCellView = ({ cell }: { cell: RuntimeCell }) => {
111
112
  );
112
113
 
113
114
  const editor = (
114
- <div className={editorWrapperClassName}>
115
+ <div
116
+ className={editorWrapperClassName}
117
+ {...cellDomProps(cell.id, cell.name)}
118
+ >
115
119
  <CellEditor
116
120
  theme={theme}
117
121
  showPlaceholder={false}
@@ -134,7 +138,14 @@ export const SlideCellView = ({ cell }: { cell: RuntimeCell }) => {
134
138
  languageAdapter={languageAdapter}
135
139
  setLanguageAdapter={setLanguageAdapter}
136
140
  showLanguageToggles={false}
141
+ // The reveal.js transforms in slides view break the inline AI
142
+ // tooltip's fixed positioning, so disable it here.
143
+ inlineAiTooltip={false}
137
144
  outputArea={cellOutputPosition}
145
+ // Parent tooltips (completions, hover, signature help) to the Reveal
146
+ // viewport so they stay visible when presenting fullscreen; `#App` sits
147
+ // outside the fullscreened subtree and would never paint.
148
+ tooltipParentSelector=".reveal-viewport"
138
149
  />
139
150
  {toolbar}
140
151
  </div>
@@ -83,6 +83,11 @@ export interface CodeMirrorSetupOpts {
83
83
  diagnosticsConfig: DiagnosticsConfig;
84
84
  displayConfig: Pick<DisplayConfig, "reference_highlighting">;
85
85
  inlineAiTooltip: boolean;
86
+ /**
87
+ * CSS selector for the element that CodeMirror tooltips (completions, hover,
88
+ * signature help) should be appended to. Defaults to `#App`.
89
+ */
90
+ tooltipParentSelector?: string;
86
91
  }
87
92
 
88
93
  function getPlaceholderType(opts: CodeMirrorSetupOpts) {
@@ -90,6 +95,46 @@ function getPlaceholderType(opts: CodeMirrorSetupOpts) {
90
95
  return showPlaceholder ? "marimo-import" : enableAI ? "ai" : "none";
91
96
  }
92
97
 
98
+ const CODEMIRROR_TOOLTIP_PORTAL_CLASS = "cm-tooltip-portal";
99
+
100
+ /**
101
+ * Resolve the element that editor tooltips (completions, hover, signature help)
102
+ * should be appended to.
103
+ *
104
+ * The default `#App` parent is returned directly. Custom parents are useful
105
+ * when editors live inside a fullscreen subtree, dialog, or scoped typography
106
+ * region. In those cases we append tooltips to a dedicated `not-prose` portal
107
+ * inside the requested parent, reusing it across cells so surrounding typography
108
+ * styles don't leak into editor popups.
109
+ */
110
+ function resolveCodeMirrorTooltipParent(
111
+ selector: string | undefined,
112
+ ): HTMLElement | undefined {
113
+ if (selector == null) {
114
+ return document.querySelector<HTMLElement>("#App") ?? undefined;
115
+ }
116
+
117
+ const host = document.querySelector<HTMLElement>(selector);
118
+ if (host == null) {
119
+ return undefined;
120
+ }
121
+
122
+ const existing = host.querySelector<HTMLElement>(
123
+ `:scope > .${CODEMIRROR_TOOLTIP_PORTAL_CLASS}`,
124
+ );
125
+ if (existing != null) {
126
+ return existing;
127
+ }
128
+
129
+ const portal = document.createElement("div");
130
+ // `not-prose` escapes scoped typography; `contents` keeps the wrapper
131
+ // layout-neutral. Tooltips are `position: fixed`, so the wrapper having no
132
+ // box doesn't affect positioning.
133
+ portal.className = `${CODEMIRROR_TOOLTIP_PORTAL_CLASS} not-prose contents`;
134
+ host.append(portal);
135
+ return portal;
136
+ }
137
+
93
138
  /**
94
139
  * Setup CodeMirror for a cell
95
140
  */
@@ -180,6 +225,7 @@ export const basicBundle = (opts: CodeMirrorSetupOpts): Extension[] => {
180
225
  cellId,
181
226
  lspConfig,
182
227
  diagnosticsConfig,
228
+ tooltipParentSelector,
183
229
  } = opts;
184
230
  const placeholderType = getPlaceholderType(opts);
185
231
  const autoClosePairs = completionConfig.auto_close_pairs !== false;
@@ -200,7 +246,7 @@ export const basicBundle = (opts: CodeMirrorSetupOpts): Extension[] => {
200
246
  position: "fixed",
201
247
  // This the z-index multiple tooltips being stacked
202
248
  // For example, if we have a hover tooltip and a completion tooltip
203
- parent: document.querySelector<HTMLElement>("#App") ?? undefined,
249
+ parent: resolveCodeMirrorTooltipParent(tooltipParentSelector),
204
250
  }),
205
251
  scrollActiveLineIntoViewExtension(),
206
252
  theme === "dark" ? darkTheme : lightTheme,