@marimo-team/islands 0.26.1-dev104 → 0.26.1-dev108

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.
Files changed (106) hide show
  1. package/dist/{ConnectedDataExplorerComponent-BJBdnd0O.js → ConnectedDataExplorerComponent-DQaiOY7w.js} +15 -15
  2. package/dist/{ErrorBoundary-DLR6xE2E.js → ErrorBoundary-BW4TciqU.js} +19 -19
  3. package/dist/{abnfDiagram-VCTEODGH-Ba0MYVW8.js → abnfDiagram-VCTEODGH-Df80tEYq.js} +2 -2
  4. package/dist/{any-language-editor-BNe8do3C.js → any-language-editor-BW-gNmbk.js} +2 -2
  5. package/dist/{architectureDiagram-5GKGNRK7-7MqAehef.js → architectureDiagram-5GKGNRK7-DNNMvKkY.js} +1 -1
  6. package/dist/{assertNever-5vhHGKOK.js → assertNever-B9_7z-dW.js} +13 -13
  7. package/dist/{chat-ui-Bs3rgm2m.js → chat-ui-Be9X-W22.js} +49 -49
  8. package/dist/{check-DUIc04aK.js → check-BqF09bSG.js} +1 -1
  9. package/dist/{chunk-IMKFNOWR-CAWA0HGB.js → chunk-IMKFNOWR-pXqnQ_fj.js} +1 -1
  10. package/dist/{chunk-SHT3W25Y-BIwVQjG5.js → chunk-SHT3W25Y-BWrxB3I2.js} +1 -1
  11. package/dist/{chunk-SVP7TREG-Cux251TB.js → chunk-SVP7TREG-CPdQP8_U.js} +1 -1
  12. package/dist/{chunk-TICWLB2K-DJVQ6khO.js → chunk-TICWLB2K-C5MYCwBz.js} +1 -1
  13. package/dist/{circle-question-mark-evCnVIut.js → circle-question-mark-YmLYXyvS.js} +1 -1
  14. package/dist/{classDiagram-ZZMXUADV-Cwve77ev.js → classDiagram-ZZMXUADV-Ba0SRm01.js} +2 -2
  15. package/dist/{classDiagram-v2-VYDZK3BY-BAeHKXmD.js → classDiagram-v2-VYDZK3BY-DSSzL_Dk.js} +2 -2
  16. package/dist/{code-visibility-BhWW3jkv.js → code-visibility-BKmktPMd.js} +18 -18
  17. package/dist/{common-i4mVHMGl.js → common-CSJAjJGa.js} +169 -169
  18. package/dist/{copy-icon-CmNLxT5_.js → copy-icon-zP4__HPI.js} +2 -2
  19. package/dist/{createReducer-BUQhgLOI.js → createReducer-CArOwUaJ.js} +16 -19
  20. package/dist/{cynefinDiagram-5FMLGOSQ-t4eEkPJh.js → cynefinDiagram-5FMLGOSQ-BOtNvA04.js} +1 -1
  21. package/dist/{dagre-GXQ25YYZ-IuZuI28B.js → dagre-GXQ25YYZ-FpCEOTxX.js} +1 -1
  22. package/dist/{data-grid-overlay-editor-7durYJXa.js → data-grid-overlay-editor-DTibdR4H.js} +1 -1
  23. package/dist/{diagram-S7CK7UJ4-D8R5Q_ok.js → diagram-S7CK7UJ4-Cm1HaBuu.js} +1 -1
  24. package/dist/{diagram-UQ7AKVKN-BGuMPsr-.js → diagram-UQ7AKVKN-D1lA7Ggu.js} +1 -1
  25. package/dist/{diagram-VX7I27RA-BkTtpO8P.js → diagram-VX7I27RA-BX3e-Rue.js} +1 -1
  26. package/dist/{diagram-Z3DM3KII-C0__Mxfm.js → diagram-Z3DM3KII-Dgoj7bPf.js} +1 -1
  27. package/dist/{dialog-BvjfalZ9.js → dialog-DfKgafXJ.js} +30 -30
  28. package/dist/{dropdown-menu-D0DeN-aL.js → dropdown-menu-Dge_SmqE.js} +168 -168
  29. package/dist/{ebnfDiagram-PWID7BFC-CSESPZoz.js → ebnfDiagram-PWID7BFC-B0xWiXrz.js} +2 -2
  30. package/dist/{erDiagram-RLTQ6QDP-DsDTtabH.js → erDiagram-RLTQ6QDP-Cm-GO31-.js} +1 -1
  31. package/dist/{error-banner-CXLjTW24.js → error-banner-CfYrJaIb.js} +91 -91
  32. package/dist/{error-entries-BcAyFIeh.js → error-entries-23Z_1oDM.js} +586 -595
  33. package/dist/{export-context-CkgZeARR.js → export-context-B1jdxzHF.js} +21 -21
  34. package/dist/{feedback-button-CeuzSBrq.js → feedback-button-CPu5SV3b.js} +72 -72
  35. package/dist/{flowDiagram-HODETNUW-qxDPYbfV.js → flowDiagram-HODETNUW-CH6xMlW_.js} +2 -2
  36. package/dist/{formats-CcQrzFo8.js → formats-Y52bg800.js} +1 -1
  37. package/dist/{glide-data-editor-BLGr2vQF.js → glide-data-editor-CC9_NDNi.js} +11 -11
  38. package/dist/{glide-utils-CD8BaFTm.js → glide-utils-BRcuSTCx.js} +2 -2
  39. package/dist/{globals-DorvG5dC.js → globals-BFlYTNoR.js} +3 -3
  40. package/dist/{html-to-image-BmLTjaGw.js → html-to-image-Cw7o1IbE.js} +4300 -4296
  41. package/dist/{infoDiagram-27XIBGKW-B5hq8RM_.js → infoDiagram-27XIBGKW-DbUO63CX.js} +1 -1
  42. package/dist/{ishikawaDiagram-5VMMS53U-DkHc_9ET.js → ishikawaDiagram-5VMMS53U-CfQrrELH.js} +1 -1
  43. package/dist/{kanban-definition-UXKFOSKX-CqkTFXmU.js → kanban-definition-UXKFOSKX-C5SJcu1W.js} +1 -1
  44. package/dist/{loader-CGrYn73j.js → loader-C9-qRO3m.js} +2 -2
  45. package/dist/main.js +6698 -6604
  46. package/dist/{mermaid-pmVHDUQA.js → mermaid-C2alqcd8.js} +34 -34
  47. package/dist/{mindmap-definition-YA3MSWOX-D6cNa__z.js → mindmap-definition-YA3MSWOX-ByVHE0Ax.js} +1 -1
  48. package/dist/{number-overlay-editor-DQAdvZrn.js → number-overlay-editor-qDcRKPE0.js} +1 -1
  49. package/dist/{pegDiagram-XKGWAZYB-CmWJX_s1.js → pegDiagram-XKGWAZYB-DF5FBKZi.js} +2 -2
  50. package/dist/{pencil-CxMgOe04.js → pencil-D7jyZPnP.js} +1 -1
  51. package/dist/{pieDiagram-E7YTZNPT-CAQAxHah.js → pieDiagram-E7YTZNPT-B5n9nBQN.js} +1 -1
  52. package/dist/{process-output-CcNpl5Qu.js → process-output-DdBM0lmd.js} +4 -4
  53. package/dist/{railroadDiagram-O6MQD6OU-jlSsiQg3.js → railroadDiagram-O6MQD6OU-r5t7OYNE.js} +2 -2
  54. package/dist/{requirementDiagram-BXWQKSXE-DkDjfPhn.js → requirementDiagram-BXWQKSXE-D4QtEyZQ.js} +1 -1
  55. package/dist/{reveal-component-B6xeeht1.js → reveal-component-BE1xhtNc.js} +1008 -1008
  56. package/dist/{select-CEnB18uc.js → select-Buk3aXi1.js} +341 -341
  57. package/dist/{sequenceDiagram-WJ2MYXX4-DLywsGCW.js → sequenceDiagram-WJ2MYXX4-CK3Atn-z.js} +1 -1
  58. package/dist/{spec-Dz-Avv1m.js → spec-BEp9O9dy.js} +4 -4
  59. package/dist/{stateDiagram-D77RDMKH-DUmlKwYU.js → stateDiagram-D77RDMKH-C1SxRI8V.js} +2 -2
  60. package/dist/{stateDiagram-v2-MP3YSRHH-D646KiXs.js → stateDiagram-v2-MP3YSRHH-DK5X6bsr.js} +2 -2
  61. package/dist/{static-state-iw0PrHK4.js → static-state-D-aT9dOr.js} +9 -9
  62. package/dist/{swimlanes-42K2YHIH-L7B1GphF.js → swimlanes-42K2YHIH-DdH5TZdu.js} +1 -1
  63. package/dist/{swimlanesDiagram-VR7AAH4N-DEu2wxtC.js → swimlanesDiagram-VR7AAH4N-CWBIvzgR.js} +2 -2
  64. package/dist/{timeline-definition-24CTP7MA-DDPyx1yG.js → timeline-definition-24CTP7MA-DE7-o2zU.js} +1 -1
  65. package/dist/{toast-BTjH6fIf.js → toast-b3k4YxaT.js} +54 -54
  66. package/dist/{tooltip-DyLdBIM4.js → tooltip-D-9pDheN.js} +62 -62
  67. package/dist/{use-restore-focus-DJ_-uSn_.js → use-restore-focus-CCfk-ey2.js} +1 -1
  68. package/dist/{useDateFormatter-HpKD0jEC.js → useDateFormatter-DH0uFwfL.js} +2 -2
  69. package/dist/{useDeepCompareMemoize-CHx-NxMl.js → useDeepCompareMemoize-Dn-ZJVTd.js} +1 -1
  70. package/dist/{useLifecycle-tPpAt-OE.js → useLifecycle-yjK7JsRL.js} +1 -1
  71. package/dist/{vega-component-BzNDFvQf.js → vega-component-BIq0qzhQ.js} +8 -8
  72. package/dist/{vennDiagram-4TSXK5OY-CRwWeb7g.js → vennDiagram-4TSXK5OY-D7yfNz0d.js} +1 -1
  73. package/dist/{wardleyDiagram-VM6X3IG4-DVlG9eoq.js → wardleyDiagram-VM6X3IG4-m5Jcz26Z.js} +1 -1
  74. package/dist/{xychartDiagram-S5SC5T6Z-CM32AISp.js → xychartDiagram-S5SC5T6Z-CA3zV3RW.js} +1 -1
  75. package/package.json +1 -1
  76. package/src/__mocks__/intersection-observer.ts +13 -12
  77. package/src/components/editor/Output.tsx +1 -1
  78. package/src/components/editor/__tests__/cell-renders.test.tsx +17 -1
  79. package/src/components/editor/cell/__tests__/cell-actions.test.tsx +74 -0
  80. package/src/components/editor/cell/cell-action-body.tsx +28 -0
  81. package/src/components/editor/cell/cell-actions.tsx +60 -72
  82. package/src/components/editor/cell/cell-context-menu.tsx +36 -62
  83. package/src/components/editor/chrome/panels/outline/__tests__/outline-keyboard.test.tsx +517 -68
  84. package/src/components/editor/chrome/panels/outline/__tests__/useActiveOutline.test.ts +17 -5
  85. package/src/components/editor/chrome/panels/outline/floating-outline.tsx +29 -59
  86. package/src/components/editor/chrome/panels/outline/useActiveOutline.tsx +333 -133
  87. package/src/components/editor/chrome/panels/outline-panel.tsx +5 -19
  88. package/src/components/editor/navigation/navigation.ts +1 -1
  89. package/src/components/editor/notebook-cell.tsx +263 -267
  90. package/src/core/cells/__tests__/layout.test.ts +1 -1
  91. package/src/core/cells/__tests__/notebook-outline.test.ts +31 -3
  92. package/src/core/cells/__tests__/use-cell-actions.test.tsx +48 -0
  93. package/src/core/cells/actions.ts +68 -89
  94. package/src/core/cells/cells.ts +23 -14
  95. package/src/core/cells/outline.ts +8 -8
  96. package/src/core/codemirror/language/extension.ts +6 -3
  97. package/src/core/codemirror/language/panel/panel.test.tsx +144 -0
  98. package/src/core/codemirror/language/panel/panel.tsx +9 -6
  99. package/src/core/codemirror/react-dom/createPanel.tsx +15 -15
  100. package/src/core/dom/__tests__/outline.test.ts +29 -170
  101. package/src/core/dom/outline.ts +21 -61
  102. package/src/core/executions/atoms.ts +12 -4
  103. package/src/core/islands/components/output-wrapper.tsx +7 -2
  104. package/src/plugins/layout/OutlinePlugin.tsx +5 -17
  105. package/src/utils/__tests__/createReducer.test.tsx +4 -3
  106. package/src/utils/createReducer.ts +19 -12
@@ -1,36 +1,36 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
- import type { EditorView, Panel } from "@codemirror/view";
3
+ import type { EditorView, Panel, ViewUpdate } from "@codemirror/view";
4
4
  import { Provider } from "jotai";
5
5
  import { createRoot, type Root } from "react-dom/client";
6
6
  import { store } from "@/core/state/jotai";
7
7
 
8
- /**
9
- * Bridge between Codemirror panels and React
10
- */
11
8
  export function createPanel(
12
9
  view: EditorView,
13
10
  Component: React.ComponentType<{ view: EditorView }>,
11
+ shouldRender: (update: ViewUpdate) => boolean = () => true,
14
12
  ): Panel {
15
13
  const dom = document.createElement("div");
16
14
  let root: Root | undefined;
17
15
 
16
+ const render = () => {
17
+ root?.render(
18
+ <Provider store={store}>
19
+ <Component view={view} />
20
+ </Provider>,
21
+ );
22
+ };
23
+
18
24
  return {
19
25
  dom,
20
26
  mount() {
21
27
  root = createRoot(dom);
22
- root.render(
23
- <Provider store={store}>
24
- <Component view={view} />
25
- </Provider>,
26
- );
28
+ render();
27
29
  },
28
- update() {
29
- root?.render(
30
- <Provider store={store}>
31
- <Component view={view} />
32
- </Provider>,
33
- );
30
+ update(update) {
31
+ if (shouldRender(update)) {
32
+ render();
33
+ }
34
34
  },
35
35
  destroy() {
36
36
  root?.unmount();
@@ -1,10 +1,8 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
  import { describe, expect, it } from "vitest";
3
- import type { Outline } from "@/core/cells/outline";
4
3
  import {
5
4
  canCollapseOutline,
6
5
  findCollapseRange,
7
- mergeOutlines,
8
6
  parseOutline,
9
7
  } from "../outline";
10
8
 
@@ -21,12 +19,12 @@ describe("parseOutline", () => {
21
19
  expect(outline).toEqual({
22
20
  items: [
23
21
  {
24
- by: { id: "title" },
22
+ id: "title",
25
23
  level: 1,
26
24
  name: "Title bold",
27
25
  html: '<marimo-test style="animation: spin 1s linear;">Title</marimo-test> <strong>bold</strong>',
28
26
  },
29
- { by: { id: "next" }, level: 2, name: "Next" },
27
+ { id: "next", level: 2, name: "Next" },
30
28
  ],
31
29
  });
32
30
  },
@@ -52,24 +50,18 @@ describe("parseOutline", () => {
52
50
  {
53
51
  "items": [
54
52
  {
55
- "by": {
56
- "id": "welcome-to-marimo",
57
- },
53
+ "id": "welcome-to-marimo",
58
54
  "level": 1,
59
55
  "name": "Welcome to marimo! 🌊🍃",
60
56
  },
61
57
  {
62
- "by": {
63
- "id": "what-is-marimo",
64
- },
65
58
  "html": "What is <b>marimo</b>?",
59
+ "id": "what-is-marimo",
66
60
  "level": 2,
67
61
  "name": "What is marimo?",
68
62
  },
69
63
  {
70
- "by": {
71
- "id": "how-do-i-use-marimo",
72
- },
64
+ "id": "how-do-i-use-marimo",
73
65
  "level": 2,
74
66
  "name": "How do I use marimo?",
75
67
  },
@@ -101,58 +93,42 @@ describe("parseOutline", () => {
101
93
  {
102
94
  "items": [
103
95
  {
104
- "by": {
105
- "id": "experiment-1",
106
- },
96
+ "id": "experiment-1",
107
97
  "level": 1,
108
98
  "name": "Experiment 1",
109
99
  },
110
100
  {
111
- "by": {
112
- "id": "setup",
113
- },
101
+ "id": "setup",
114
102
  "level": 2,
115
103
  "name": "Setup",
116
104
  },
117
105
  {
118
- "by": {
119
- "id": "instructions",
120
- },
106
+ "id": "instructions",
121
107
  "level": 2,
122
108
  "name": "Instructions",
123
109
  },
124
110
  {
125
- "by": {
126
- "id": "experiment-2",
127
- },
111
+ "id": "experiment-2",
128
112
  "level": 1,
129
113
  "name": "Experiment 2",
130
114
  },
131
115
  {
132
- "by": {
133
- "id": "setup",
134
- },
116
+ "id": "setup",
135
117
  "level": 2,
136
118
  "name": "Setup",
137
119
  },
138
120
  {
139
- "by": {
140
- "id": "instructions",
141
- },
121
+ "id": "instructions",
142
122
  "level": 2,
143
123
  "name": "Instructions",
144
124
  },
145
125
  {
146
- "by": {
147
- "id": "ack",
148
- },
126
+ "id": "ack",
149
127
  "level": 1,
150
128
  "name": "Acknowledgements",
151
129
  },
152
130
  {
153
- "by": {
154
- "id": "marimo",
155
- },
131
+ "id": "marimo",
156
132
  "level": 3,
157
133
  "name": "marimo",
158
134
  },
@@ -179,23 +155,17 @@ describe("parseOutline", () => {
179
155
  {
180
156
  "items": [
181
157
  {
182
- "by": {
183
- "id": "introduction",
184
- },
158
+ "id": "introduction",
185
159
  "level": 1,
186
160
  "name": "Introduction",
187
161
  },
188
162
  {
189
- "by": {
190
- "id": "getting-started",
191
- },
163
+ "id": "getting-started",
192
164
  "level": 2,
193
165
  "name": "Getting Started",
194
166
  },
195
167
  {
196
- "by": {
197
- "id": "installation",
198
- },
168
+ "id": "installation",
199
169
  "level": 3,
200
170
  "name": "Installation",
201
171
  },
@@ -230,7 +200,7 @@ describe("parseOutline", () => {
230
200
  ).toEqual({ items: [] });
231
201
  });
232
202
 
233
- it("can handle invalid outline", () => {
203
+ it("can parse headings without IDs", () => {
234
204
  const html = "<h1>foo</h1><h2>bar</h2><h3>baz</h3>";
235
205
  const outline = parseOutline({
236
206
  mimetype: "text/html",
@@ -242,23 +212,14 @@ describe("parseOutline", () => {
242
212
  {
243
213
  "items": [
244
214
  {
245
- "by": {
246
- "path": "//H1[contains(., "foo")]",
247
- },
248
215
  "level": 1,
249
216
  "name": "foo",
250
217
  },
251
218
  {
252
- "by": {
253
- "path": "//H2[contains(., "bar")]",
254
- },
255
219
  "level": 2,
256
220
  "name": "bar",
257
221
  },
258
222
  {
259
- "by": {
260
- "path": "//H3[contains(., "baz")]",
261
- },
262
223
  "level": 3,
263
224
  "name": "baz",
264
225
  },
@@ -288,44 +249,32 @@ describe("parseOutline", () => {
288
249
  {
289
250
  "items": [
290
251
  {
291
- "by": {
292
- "id": "chapter",
293
- },
252
+ "id": "chapter",
294
253
  "level": 1,
295
254
  "name": "Chapter",
296
255
  },
297
256
  {
298
- "by": {
299
- "id": "section",
300
- },
257
+ "id": "section",
301
258
  "level": 2,
302
259
  "name": "Section",
303
260
  },
304
261
  {
305
- "by": {
306
- "id": "subsection",
307
- },
262
+ "id": "subsection",
308
263
  "level": 3,
309
264
  "name": "Subsection",
310
265
  },
311
266
  {
312
- "by": {
313
- "id": "paragraph",
314
- },
267
+ "id": "paragraph",
315
268
  "level": 4,
316
269
  "name": "Paragraph",
317
270
  },
318
271
  {
319
- "by": {
320
- "id": "subparagraph",
321
- },
272
+ "id": "subparagraph",
322
273
  "level": 5,
323
274
  "name": "Subparagraph",
324
275
  },
325
276
  {
326
- "by": {
327
- "id": "detail",
328
- },
277
+ "id": "detail",
329
278
  "level": 6,
330
279
  "name": "Detail",
331
280
  },
@@ -352,24 +301,18 @@ describe("parseOutline", () => {
352
301
  {
353
302
  "items": [
354
303
  {
355
- "by": {
356
- "id": "intro",
357
- },
304
+ "id": "intro",
358
305
  "level": 1,
359
306
  "name": "Introduction",
360
307
  },
361
308
  {
362
- "by": {
363
- "id": "the-equation",
364
- },
365
309
  "html": "The equation <marimo-tex class="arithmatex">||(E = mc^2||)</marimo-tex>",
310
+ "id": "the-equation",
366
311
  "level": 2,
367
312
  "name": "The equation ||(E = mc^2||)",
368
313
  },
369
314
  {
370
- "by": {
371
- "id": "plain",
372
- },
315
+ "id": "plain",
373
316
  "level": 2,
374
317
  "name": "Plain heading",
375
318
  },
@@ -407,16 +350,12 @@ describe("parseOutline", () => {
407
350
  {
408
351
  "items": [
409
352
  {
410
- "by": {
411
- "id": "included-heading",
412
- },
353
+ "id": "included-heading",
413
354
  "level": 1,
414
355
  "name": "Included Heading",
415
356
  },
416
357
  {
417
- "by": {
418
- "id": "another-included-heading",
419
- },
358
+ "id": "another-included-heading",
420
359
  "level": 2,
421
360
  "name": "Another Included Heading",
422
361
  },
@@ -426,92 +365,12 @@ describe("parseOutline", () => {
426
365
  });
427
366
  });
428
367
 
429
- const OUTLINE_1: Outline = {
430
- items: [
431
- {
432
- name: "h1",
433
- level: 1,
434
- by: { id: "h1" },
435
- },
436
- {
437
- name: "h2",
438
- level: 2,
439
- by: { id: "h2" },
440
- },
441
- {
442
- name: "h3",
443
- level: 3,
444
- by: { id: "h3" },
445
- },
446
- ],
447
- };
448
-
449
- const OUTLINE_2: Outline = {
450
- items: [
451
- {
452
- name: "other-h1",
453
- level: 1,
454
- by: { path: "other-h1" },
455
- },
456
- {
457
- name: "other-h2",
458
- level: 2,
459
- by: { path: "other-h2" },
460
- },
461
- ],
462
- };
463
-
464
- it("mergeOutlines", () => {
465
- expect(mergeOutlines([OUTLINE_1, null, OUTLINE_2, null]))
466
- .toMatchInlineSnapshot(`
467
- {
468
- "items": [
469
- {
470
- "by": {
471
- "id": "h1",
472
- },
473
- "level": 1,
474
- "name": "h1",
475
- },
476
- {
477
- "by": {
478
- "id": "h2",
479
- },
480
- "level": 2,
481
- "name": "h2",
482
- },
483
- {
484
- "by": {
485
- "id": "h3",
486
- },
487
- "level": 3,
488
- "name": "h3",
489
- },
490
- {
491
- "by": {
492
- "path": "other-h1",
493
- },
494
- "level": 1,
495
- "name": "other-h1",
496
- },
497
- {
498
- "by": {
499
- "path": "other-h2",
500
- },
501
- "level": 2,
502
- "name": "other-h2",
503
- },
504
- ],
505
- }
506
- `);
507
- });
508
-
509
368
  const makeOutline = (levels: number[]) => {
510
369
  return {
511
370
  items: levels.map((level) => ({
512
371
  name: `h${level}`,
513
372
  level,
514
- by: { id: `h${level}` },
373
+ id: `h${level}`,
515
374
  })),
516
375
  };
517
376
  };
@@ -5,19 +5,20 @@ import { invariant } from "@/utils/invariant";
5
5
  import { Logger } from "@/utils/Logger";
6
6
  import type { Outline, OutlineItem } from "../cells/outline";
7
7
  import type { CellOutput } from "@/core/executions/output";
8
- import type { OutputMessage } from "../kernel/messages";
9
8
 
10
- // Tags that we don't want to include in the outline
11
- const excludedTags = [
12
- "marimo-carousel",
13
- "marimo-tabs",
14
- "marimo-accordion",
15
- "marimo-sidebar",
16
- ];
17
-
18
- // We go up to h6. Previously we did h3 to match Google Docs and Notion, but users have requested more levels.
19
- // This could be made configurable in the future.
20
- const HEADER_TAGS = "h1, h2, h3, h4, h5, h6";
9
+ export const OUTLINE_HEADING_TAGS: ReadonlySet<string> = new Set([
10
+ "h1",
11
+ "h2",
12
+ "h3",
13
+ "h4",
14
+ "h5",
15
+ "h6",
16
+ ]);
17
+ const HEADER_TAGS = [...OUTLINE_HEADING_TAGS].join(", ");
18
+ const OUTSIDE_WIDGETS =
19
+ ":not(:is(marimo-carousel, marimo-tabs, marimo-accordion, marimo-sidebar) *)";
20
+ const OUTLINE_HEADINGS = `:is(${HEADER_TAGS})${OUTSIDE_WIDGETS}`;
21
+ export const OUTLINE_TARGETS = `:is(${HEADER_TAGS}, [id])${OUTSIDE_WIDGETS}`;
21
22
 
22
23
  /**
23
24
  * Extracts a table of contents {@link Outline} from an HTML string.
@@ -39,22 +40,19 @@ function getOutline(html: string): Outline | null {
39
40
  const parser = new DOMParser();
40
41
  const document = parser.parseFromString(html, "text/html");
41
42
 
42
- const headings = document.querySelectorAll(HEADER_TAGS);
43
- // oxlint-disable-next-line unicorn/prefer-spread
44
- for (const heading of Array.from(headings)) {
43
+ const headings = document.querySelectorAll(OUTLINE_HEADINGS);
44
+ for (const heading of headings) {
45
45
  const name = heading.textContent;
46
- // Check if the heading is within any of the excluded tags
47
- if (excludedTags.some((tag) => heading.closest(tag))) {
48
- continue;
49
- }
50
-
51
46
  if (!name) {
52
47
  continue;
53
48
  }
54
49
 
55
50
  const level = Number.parseInt(heading.tagName[1], 10);
56
51
  const innerHTML = heading.innerHTML;
57
- const item: OutlineItem = { name, level, by: headingToIdentifier(heading) };
52
+ const item: OutlineItem = { name, level };
53
+ if (heading.id) {
54
+ item.id = heading.id;
55
+ }
58
56
  if (innerHTML !== name) {
59
57
  item.html = sanitizeHtml(innerHTML);
60
58
  }
@@ -64,46 +62,8 @@ function getOutline(html: string): Outline | null {
64
62
  return { items };
65
63
  }
66
64
 
67
- function toXPathStringLiteral(value: string): string {
68
- if (!value.includes('"')) {
69
- return `"${value}"`;
70
- }
71
- if (!value.includes("'")) {
72
- return `'${value}'`;
73
- }
74
-
75
- const segments = value.split('"');
76
- const literals: string[] = [];
77
- for (const [index, segment] of segments.entries()) {
78
- if (segment) {
79
- literals.push(`"${segment}"`);
80
- }
81
- if (index < segments.length - 1) {
82
- literals.push(`'"'`);
83
- }
84
- }
85
- return `concat(${literals.join(", ")})`;
86
- }
87
-
88
- export function headingToIdentifier(heading: Element): OutlineItem["by"] {
89
- const id = heading.id;
90
- if (id) {
91
- return { id };
92
- }
93
- const name = heading.textContent ?? "";
94
- return {
95
- path: `//${heading.tagName}[contains(., ${toXPathStringLiteral(name)})]`,
96
- };
97
- }
98
-
99
- export function mergeOutlines(outlines: (Outline | null)[]): Outline {
100
- return {
101
- items: outlines.filter(Boolean).flatMap((outline) => outline.items),
102
- };
103
- }
104
-
105
- export function parseOutline(
106
- output: OutputMessage | CellOutput | null,
65
+ export function parseOutline<T extends Pick<CellOutput, "mimetype" | "data">>(
66
+ output: T | null,
107
67
  ): Outline | null {
108
68
  if (output == null) {
109
69
  return null;
@@ -7,7 +7,6 @@ import { dequal } from "dequal";
7
7
  import { atom, type Atom, type createStore } from "jotai";
8
8
  import { atomFamily, selectAtom } from "jotai/utils";
9
9
  import type { CellId } from "@/core/cells/ids";
10
- import type { Outline } from "@/core/cells/outline";
11
10
  import { parseOutline } from "@/core/dom/outline";
12
11
  import {
13
12
  ConnectionState,
@@ -22,6 +21,7 @@ import {
22
21
  activeNotebookReplicaAtom,
23
22
  activeNotebookFrameAtom,
24
23
  } from "@/core/session/active-notebook";
24
+ import { Functions } from "@/utils/functions";
25
25
  import { type CellFreshnessInputs, freshnessOf } from "./freshness";
26
26
  import {
27
27
  type CellOutputInputs,
@@ -388,9 +388,17 @@ export const cellFreshnessForAtom = atomFamily((id: Protocol.CellId) =>
388
388
  );
389
389
 
390
390
  /** The headings in a cell's output, for the table of contents and folding. */
391
- export const cellOutlineAtom = atomFamily((cellId: CellId) =>
392
- atom((get): Outline | null => parseOutline(get(cellOutputAtom(cellId)))),
393
- );
391
+ export const cellOutlineAtom = atomFamily((cellId: CellId) => {
392
+ const outline = atomWithSelectedInputs(
393
+ cellOutputAtom(cellId),
394
+ (output) => [output?.mimetype, output?.data],
395
+ ([mimetype, data]) =>
396
+ mimetype == null || data == null
397
+ ? null
398
+ : parseOutline({ mimetype, data }),
399
+ );
400
+ return selectAtom(outline, Functions.identity, dequal);
401
+ });
394
402
 
395
403
  /** Drop the cached atoms of a cell that left the document. */
396
404
  export function releaseCellOutputAtoms(cellId: CellId): void {
@@ -4,7 +4,7 @@ import { useAtomValue } from "jotai";
4
4
  import { Loader2Icon } from "lucide-react";
5
5
  import React, { type PropsWithChildren, useEffect, useRef } from "react";
6
6
  import { OutputRenderer } from "@/components/editor/Output";
7
- import type { CellId } from "@/core/cells/ids";
7
+ import { type CellId, CellOutputId } from "@/core/cells/ids";
8
8
  import { isOutputEmpty } from "@/core/cells/outputs";
9
9
  import {
10
10
  type CellRunStatus,
@@ -83,7 +83,12 @@ export const MarimoOutputWrapper: React.FC<MarimoOutputWrapperProps> = ({
83
83
  }
84
84
 
85
85
  return (
86
- <div ref={wrapperRef} className="relative min-h-6">
86
+ <div
87
+ ref={wrapperRef}
88
+ id={CellOutputId.create(cellId)}
89
+ data-cell-role="output"
90
+ className="relative min-h-6"
91
+ >
87
92
  <OutputRenderer message={output} />
88
93
  <RunningIndicator status={status} />
89
94
  <IslandControls
@@ -1,14 +1,10 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
- import { Provider, useAtomValue } from "jotai";
2
+ import { Provider } from "jotai";
3
3
  import type { JSX } from "react";
4
4
  import { z } from "zod";
5
- import { notebookOutline } from "@/core/cells/cells";
6
5
  import { store } from "@/core/state/jotai";
7
6
  import { OutlineList } from "../../components/editor/chrome/panels/outline/floating-outline";
8
- import {
9
- findOutlineElements,
10
- useActiveOutline,
11
- } from "../../components/editor/chrome/panels/outline/useActiveOutline";
7
+ import { useActiveOutline } from "../../components/editor/chrome/panels/outline/useActiveOutline";
12
8
  import type {
13
9
  IStatelessPlugin,
14
10
  IStatelessPluginProps,
@@ -19,12 +15,9 @@ interface Data {
19
15
  }
20
16
 
21
17
  const OutlineContent: React.FC<{ label?: string }> = ({ label }) => {
22
- const { items } = useAtomValue(notebookOutline);
23
- const headerElements = findOutlineElements(items);
24
- const { activeHeaderId, activeOccurrences } =
25
- useActiveOutline(headerElements);
18
+ const outline = useActiveOutline();
26
19
 
27
- if (items.length === 0) {
20
+ if (outline.entries.length === 0) {
28
21
  return (
29
22
  <div className="text-muted-foreground text-sm p-4 border border-dashed border-border rounded-lg">
30
23
  No outline found. Add markdown headings to your notebook to create an
@@ -40,12 +33,7 @@ const OutlineContent: React.FC<{ label?: string }> = ({ label }) => {
40
33
  {label}
41
34
  </div>
42
35
  )}
43
- <OutlineList
44
- className="max-h-[400px]"
45
- items={items}
46
- activeHeaderId={activeHeaderId}
47
- activeOccurrences={activeOccurrences}
48
- />
36
+ <OutlineList className="max-h-[400px]" {...outline} />
49
37
  </div>
50
38
  );
51
39
  };
@@ -248,7 +248,7 @@ describe("createReducerAndAtoms", () => {
248
248
  }),
249
249
  };
250
250
  const seen: number[] = [];
251
- const { valueAtom, useActions } = createReducerAndAtoms(
251
+ const { valueAtom, useActions, getActionsForStore } = createReducerAndAtoms(
252
252
  initialState,
253
253
  reducers,
254
254
  [(_prev, next) => seen.push(store.get(valueAtom).count, next.count)],
@@ -260,9 +260,10 @@ describe("createReducerAndAtoms", () => {
260
260
  const { result } = renderHook(() => useActions(), { wrapper });
261
261
 
262
262
  result.current.increment(5);
263
+ getActionsForStore(store).increment(2);
263
264
 
264
- expect(seen).toEqual([5, 5]);
265
- expect(store.get(valueAtom)).toEqual({ count: 5 });
265
+ expect(seen).toEqual([5, 5, 7, 7]);
266
+ expect(store.get(valueAtom)).toEqual({ count: 7 });
266
267
  });
267
268
 
268
269
  it("should log an error for non-existent action types", () => {