@marimo-team/islands 0.26.1-dev105 → 0.26.1-dev112
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.
- package/dist/{ConnectedDataExplorerComponent-C6dY5fiI.js → ConnectedDataExplorerComponent-DQaiOY7w.js} +15 -15
- package/dist/{ErrorBoundary-Bn664FZa.js → ErrorBoundary-pNKOBKXw.js} +19 -19
- package/dist/{abnfDiagram-VCTEODGH-Ba0MYVW8.js → abnfDiagram-VCTEODGH-Df80tEYq.js} +2 -2
- package/dist/{any-language-editor-BNe8do3C.js → any-language-editor-BW-gNmbk.js} +2 -2
- package/dist/{architectureDiagram-5GKGNRK7-7MqAehef.js → architectureDiagram-5GKGNRK7-DNNMvKkY.js} +1 -1
- package/dist/{assertNever-5vhHGKOK.js → assertNever-B9_7z-dW.js} +13 -13
- package/dist/{chat-ui-zGgiq5zN.js → chat-ui-C9NZA-bk.js} +49 -49
- package/dist/{check-DUIc04aK.js → check-BqF09bSG.js} +1 -1
- package/dist/{chunk-IMKFNOWR-CAWA0HGB.js → chunk-IMKFNOWR-pXqnQ_fj.js} +1 -1
- package/dist/{chunk-SHT3W25Y-BIwVQjG5.js → chunk-SHT3W25Y-BWrxB3I2.js} +1 -1
- package/dist/{chunk-SVP7TREG-Cux251TB.js → chunk-SVP7TREG-CPdQP8_U.js} +1 -1
- package/dist/{chunk-TICWLB2K-DJVQ6khO.js → chunk-TICWLB2K-C5MYCwBz.js} +1 -1
- package/dist/{circle-question-mark-evCnVIut.js → circle-question-mark-YmLYXyvS.js} +1 -1
- package/dist/{classDiagram-ZZMXUADV-Cwve77ev.js → classDiagram-ZZMXUADV-Ba0SRm01.js} +2 -2
- package/dist/{classDiagram-v2-VYDZK3BY-BAeHKXmD.js → classDiagram-v2-VYDZK3BY-DSSzL_Dk.js} +2 -2
- package/dist/{code-visibility-CMgSFUs7.js → code-visibility-B9s3Hl8z.js} +18 -18
- package/dist/{common-DWnR77Qk.js → common-Bn3jx0X6.js} +170 -168
- package/dist/{copy-icon-CmNLxT5_.js → copy-icon-zP4__HPI.js} +2 -2
- package/dist/{createReducer-m7yAXmDu.js → createReducer-CArOwUaJ.js} +1 -1
- package/dist/{cynefinDiagram-5FMLGOSQ-t4eEkPJh.js → cynefinDiagram-5FMLGOSQ-BOtNvA04.js} +1 -1
- package/dist/{dagre-GXQ25YYZ-IuZuI28B.js → dagre-GXQ25YYZ-FpCEOTxX.js} +1 -1
- package/dist/{data-grid-overlay-editor-zS1h3iMI.js → data-grid-overlay-editor-mxwwRaQy.js} +1 -1
- package/dist/{diagram-S7CK7UJ4-D8R5Q_ok.js → diagram-S7CK7UJ4-Cm1HaBuu.js} +1 -1
- package/dist/{diagram-UQ7AKVKN-BGuMPsr-.js → diagram-UQ7AKVKN-D1lA7Ggu.js} +1 -1
- package/dist/{diagram-VX7I27RA-BkTtpO8P.js → diagram-VX7I27RA-BX3e-Rue.js} +1 -1
- package/dist/{diagram-Z3DM3KII-C0__Mxfm.js → diagram-Z3DM3KII-Dgoj7bPf.js} +1 -1
- package/dist/{dialog-BvjfalZ9.js → dialog-DfKgafXJ.js} +30 -30
- package/dist/{dropdown-menu-D0DeN-aL.js → dropdown-menu-Dge_SmqE.js} +168 -168
- package/dist/{ebnfDiagram-PWID7BFC-CSESPZoz.js → ebnfDiagram-PWID7BFC-B0xWiXrz.js} +2 -2
- package/dist/{erDiagram-RLTQ6QDP-DsDTtabH.js → erDiagram-RLTQ6QDP-Cm-GO31-.js} +1 -1
- package/dist/{error-banner-CXLjTW24.js → error-banner-CfYrJaIb.js} +91 -91
- package/dist/{error-entries-DVclFjaE.js → error-entries-1DC4BiYB.js} +661 -656
- package/dist/{export-context-CkgZeARR.js → export-context-B1jdxzHF.js} +21 -21
- package/dist/{feedback-button-BMGqp8Ff.js → feedback-button-BrzbnRTT.js} +72 -72
- package/dist/{flowDiagram-HODETNUW-qxDPYbfV.js → flowDiagram-HODETNUW-CH6xMlW_.js} +2 -2
- package/dist/{formats-CcQrzFo8.js → formats-Y52bg800.js} +1 -1
- package/dist/{glide-data-editor-Bra6h4KB.js → glide-data-editor-Cnsv3NcI.js} +11 -11
- package/dist/{glide-utils-CD8BaFTm.js → glide-utils-BRcuSTCx.js} +2 -2
- package/dist/{globals-_bXqC0R8.js → globals-BGqfFPx8.js} +3 -3
- package/dist/{html-to-image-Cst4BlIm.js → html-to-image-CsvAOgd3.js} +5073 -5076
- package/dist/{infoDiagram-27XIBGKW-B5hq8RM_.js → infoDiagram-27XIBGKW-DbUO63CX.js} +1 -1
- package/dist/{ishikawaDiagram-5VMMS53U-DkHc_9ET.js → ishikawaDiagram-5VMMS53U-CfQrrELH.js} +1 -1
- package/dist/{kanban-definition-UXKFOSKX-CqkTFXmU.js → kanban-definition-UXKFOSKX-C5SJcu1W.js} +1 -1
- package/dist/{loader-CGrYn73j.js → loader-C9-qRO3m.js} +2 -2
- package/dist/main.js +6696 -6602
- package/dist/{mermaid-pmVHDUQA.js → mermaid-C2alqcd8.js} +34 -34
- package/dist/{mindmap-definition-YA3MSWOX-D6cNa__z.js → mindmap-definition-YA3MSWOX-ByVHE0Ax.js} +1 -1
- package/dist/{number-overlay-editor-XLUhOVa7.js → number-overlay-editor-DuSCOMTK.js} +1 -1
- package/dist/{pegDiagram-XKGWAZYB-CmWJX_s1.js → pegDiagram-XKGWAZYB-DF5FBKZi.js} +2 -2
- package/dist/{pencil-CxMgOe04.js → pencil-D7jyZPnP.js} +1 -1
- package/dist/{pieDiagram-E7YTZNPT-CAQAxHah.js → pieDiagram-E7YTZNPT-B5n9nBQN.js} +1 -1
- package/dist/{process-output-DizFa5IE.js → process-output-CtfJ_Gbp.js} +4 -4
- package/dist/{railroadDiagram-O6MQD6OU-jlSsiQg3.js → railroadDiagram-O6MQD6OU-r5t7OYNE.js} +2 -2
- package/dist/{requirementDiagram-BXWQKSXE-DkDjfPhn.js → requirementDiagram-BXWQKSXE-D4QtEyZQ.js} +1 -1
- package/dist/{reveal-component-llpC324_.js → reveal-component-DzmiQyN9.js} +1008 -1008
- package/dist/{select-CEnB18uc.js → select-Buk3aXi1.js} +341 -341
- package/dist/{sequenceDiagram-WJ2MYXX4-DLywsGCW.js → sequenceDiagram-WJ2MYXX4-CK3Atn-z.js} +1 -1
- package/dist/{spec-Dz-Avv1m.js → spec-BEp9O9dy.js} +4 -4
- package/dist/{stateDiagram-D77RDMKH-DUmlKwYU.js → stateDiagram-D77RDMKH-C1SxRI8V.js} +2 -2
- package/dist/{stateDiagram-v2-MP3YSRHH-D646KiXs.js → stateDiagram-v2-MP3YSRHH-DK5X6bsr.js} +2 -2
- package/dist/{static-state-iw0PrHK4.js → static-state-D-aT9dOr.js} +9 -9
- package/dist/style.css +1 -1
- package/dist/{swimlanes-42K2YHIH-L7B1GphF.js → swimlanes-42K2YHIH-DdH5TZdu.js} +1 -1
- package/dist/{swimlanesDiagram-VR7AAH4N-DEu2wxtC.js → swimlanesDiagram-VR7AAH4N-CWBIvzgR.js} +2 -2
- package/dist/{timeline-definition-24CTP7MA-DDPyx1yG.js → timeline-definition-24CTP7MA-DE7-o2zU.js} +1 -1
- package/dist/{toast-BTjH6fIf.js → toast-b3k4YxaT.js} +54 -54
- package/dist/{tooltip-DyLdBIM4.js → tooltip-D-9pDheN.js} +62 -62
- package/dist/{use-restore-focus-DJ_-uSn_.js → use-restore-focus-CCfk-ey2.js} +1 -1
- package/dist/{useDateFormatter-HpKD0jEC.js → useDateFormatter-DH0uFwfL.js} +2 -2
- package/dist/{useDeepCompareMemoize-CHx-NxMl.js → useDeepCompareMemoize-Dn-ZJVTd.js} +1 -1
- package/dist/{useLifecycle-tPpAt-OE.js → useLifecycle-yjK7JsRL.js} +1 -1
- package/dist/{vega-component-BzNDFvQf.js → vega-component-BIq0qzhQ.js} +8 -8
- package/dist/{vennDiagram-4TSXK5OY-CRwWeb7g.js → vennDiagram-4TSXK5OY-D7yfNz0d.js} +1 -1
- package/dist/{wardleyDiagram-VM6X3IG4-DVlG9eoq.js → wardleyDiagram-VM6X3IG4-m5Jcz26Z.js} +1 -1
- package/dist/{xychartDiagram-S5SC5T6Z-CM32AISp.js → xychartDiagram-S5SC5T6Z-CA3zV3RW.js} +1 -1
- package/package.json +1 -1
- package/src/__mocks__/intersection-observer.ts +13 -12
- package/src/components/editor/Output.tsx +1 -1
- package/src/components/editor/__tests__/cell-renders.test.tsx +344 -2
- package/src/components/editor/ai/__tests__/completion-utils.test.ts +12 -20
- package/src/components/editor/ai/ai-completion-editor.tsx +391 -289
- package/src/components/editor/ai/completion-utils.ts +9 -7
- package/src/components/editor/cell/CellDeleteShoulder.tsx +82 -0
- package/src/components/editor/cell/DeleteButton.tsx +11 -2
- package/src/components/editor/cell/__tests__/CellDeleteShoulder.test.tsx +181 -0
- package/src/components/editor/cell/code/cell-editor.tsx +15 -25
- package/src/components/editor/chrome/panels/__tests__/logs-panel.test.tsx +26 -2
- package/src/components/editor/chrome/panels/logs-panel.tsx +27 -11
- package/src/components/editor/chrome/panels/outline/__tests__/outline-keyboard.test.tsx +517 -68
- package/src/components/editor/chrome/panels/outline/__tests__/useActiveOutline.test.ts +17 -5
- package/src/components/editor/chrome/panels/outline/floating-outline.tsx +29 -59
- package/src/components/editor/chrome/panels/outline/useActiveOutline.tsx +333 -133
- package/src/components/editor/chrome/panels/outline-panel.tsx +5 -19
- package/src/components/editor/notebook-cell.tsx +250 -274
- package/src/core/ai/state.ts +6 -0
- package/src/core/cells/__tests__/cells.test.ts +34 -20
- package/src/core/cells/__tests__/layout.test.ts +1 -1
- package/src/core/cells/__tests__/notebook-outline.test.ts +31 -3
- package/src/core/cells/cell-log-chunks.ts +31 -0
- package/src/core/cells/cells.ts +31 -20
- package/src/core/cells/outline.ts +8 -8
- package/src/core/codemirror/language/extension.ts +6 -3
- package/src/core/codemirror/language/panel/panel.test.tsx +144 -0
- package/src/core/codemirror/language/panel/panel.tsx +9 -6
- package/src/core/codemirror/lsp/__tests__/log-messages.test.ts +1 -1
- package/src/core/codemirror/lsp/__tests__/transports.test.ts +1 -1
- package/src/core/codemirror/react-dom/createPanel.tsx +15 -15
- package/src/core/dom/__tests__/outline.test.ts +29 -170
- package/src/core/dom/outline.ts +21 -61
- package/src/core/executions/atoms.ts +12 -4
- package/src/core/islands/__tests__/bridge.test.ts +2 -5
- package/src/core/islands/components/output-wrapper.tsx +7 -2
- package/src/core/session/__tests__/useNotebookSession.hook.test.tsx +10 -1
- package/src/css/common.css +11 -0
- package/src/hooks/useFinePointer.ts +30 -0
- package/src/plugins/layout/OutlinePlugin.tsx +5 -17
- package/src/stories/log-viewer.stories.tsx +48 -44
|
@@ -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
|
-
|
|
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
|
-
{
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
-
"
|
|
105
|
-
"id": "experiment-1",
|
|
106
|
-
},
|
|
96
|
+
"id": "experiment-1",
|
|
107
97
|
"level": 1,
|
|
108
98
|
"name": "Experiment 1",
|
|
109
99
|
},
|
|
110
100
|
{
|
|
111
|
-
"
|
|
112
|
-
"id": "setup",
|
|
113
|
-
},
|
|
101
|
+
"id": "setup",
|
|
114
102
|
"level": 2,
|
|
115
103
|
"name": "Setup",
|
|
116
104
|
},
|
|
117
105
|
{
|
|
118
|
-
"
|
|
119
|
-
"id": "instructions",
|
|
120
|
-
},
|
|
106
|
+
"id": "instructions",
|
|
121
107
|
"level": 2,
|
|
122
108
|
"name": "Instructions",
|
|
123
109
|
},
|
|
124
110
|
{
|
|
125
|
-
"
|
|
126
|
-
"id": "experiment-2",
|
|
127
|
-
},
|
|
111
|
+
"id": "experiment-2",
|
|
128
112
|
"level": 1,
|
|
129
113
|
"name": "Experiment 2",
|
|
130
114
|
},
|
|
131
115
|
{
|
|
132
|
-
"
|
|
133
|
-
"id": "setup",
|
|
134
|
-
},
|
|
116
|
+
"id": "setup",
|
|
135
117
|
"level": 2,
|
|
136
118
|
"name": "Setup",
|
|
137
119
|
},
|
|
138
120
|
{
|
|
139
|
-
"
|
|
140
|
-
"id": "instructions",
|
|
141
|
-
},
|
|
121
|
+
"id": "instructions",
|
|
142
122
|
"level": 2,
|
|
143
123
|
"name": "Instructions",
|
|
144
124
|
},
|
|
145
125
|
{
|
|
146
|
-
"
|
|
147
|
-
"id": "ack",
|
|
148
|
-
},
|
|
126
|
+
"id": "ack",
|
|
149
127
|
"level": 1,
|
|
150
128
|
"name": "Acknowledgements",
|
|
151
129
|
},
|
|
152
130
|
{
|
|
153
|
-
"
|
|
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
|
-
"
|
|
183
|
-
"id": "introduction",
|
|
184
|
-
},
|
|
158
|
+
"id": "introduction",
|
|
185
159
|
"level": 1,
|
|
186
160
|
"name": "Introduction",
|
|
187
161
|
},
|
|
188
162
|
{
|
|
189
|
-
"
|
|
190
|
-
"id": "getting-started",
|
|
191
|
-
},
|
|
163
|
+
"id": "getting-started",
|
|
192
164
|
"level": 2,
|
|
193
165
|
"name": "Getting Started",
|
|
194
166
|
},
|
|
195
167
|
{
|
|
196
|
-
"
|
|
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
|
|
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
|
-
"
|
|
292
|
-
"id": "chapter",
|
|
293
|
-
},
|
|
252
|
+
"id": "chapter",
|
|
294
253
|
"level": 1,
|
|
295
254
|
"name": "Chapter",
|
|
296
255
|
},
|
|
297
256
|
{
|
|
298
|
-
"
|
|
299
|
-
"id": "section",
|
|
300
|
-
},
|
|
257
|
+
"id": "section",
|
|
301
258
|
"level": 2,
|
|
302
259
|
"name": "Section",
|
|
303
260
|
},
|
|
304
261
|
{
|
|
305
|
-
"
|
|
306
|
-
"id": "subsection",
|
|
307
|
-
},
|
|
262
|
+
"id": "subsection",
|
|
308
263
|
"level": 3,
|
|
309
264
|
"name": "Subsection",
|
|
310
265
|
},
|
|
311
266
|
{
|
|
312
|
-
"
|
|
313
|
-
"id": "paragraph",
|
|
314
|
-
},
|
|
267
|
+
"id": "paragraph",
|
|
315
268
|
"level": 4,
|
|
316
269
|
"name": "Paragraph",
|
|
317
270
|
},
|
|
318
271
|
{
|
|
319
|
-
"
|
|
320
|
-
"id": "subparagraph",
|
|
321
|
-
},
|
|
272
|
+
"id": "subparagraph",
|
|
322
273
|
"level": 5,
|
|
323
274
|
"name": "Subparagraph",
|
|
324
275
|
},
|
|
325
276
|
{
|
|
326
|
-
"
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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
|
-
"
|
|
411
|
-
"id": "included-heading",
|
|
412
|
-
},
|
|
353
|
+
"id": "included-heading",
|
|
413
354
|
"level": 1,
|
|
414
355
|
"name": "Included Heading",
|
|
415
356
|
},
|
|
416
357
|
{
|
|
417
|
-
"
|
|
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
|
-
|
|
373
|
+
id: `h${level}`,
|
|
515
374
|
})),
|
|
516
375
|
};
|
|
517
376
|
};
|
package/src/core/dom/outline.ts
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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(
|
|
43
|
-
|
|
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
|
|
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
|
|
68
|
-
|
|
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
|
-
|
|
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 {
|
|
@@ -444,11 +444,8 @@ describe("IslandsPyodideBridge", () => {
|
|
|
444
444
|
expect(
|
|
445
445
|
store
|
|
446
446
|
.get(notebookAtom)
|
|
447
|
-
.cellLogs.
|
|
448
|
-
|
|
449
|
-
message,
|
|
450
|
-
source,
|
|
451
|
-
]),
|
|
447
|
+
.cellLogs.flat()
|
|
448
|
+
.map(({ level, message, source }) => [level, message, source]),
|
|
452
449
|
).toEqual([
|
|
453
450
|
["stdout", "hello", { type: "cell", cellId: "c2" }],
|
|
454
451
|
["stderr", "warning", { type: "cell", cellId: "c2" }],
|
|
@@ -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
|
|
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
|
|
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
|
|
@@ -1092,6 +1092,12 @@ it.each(["live", "replay", "batched"])(
|
|
|
1092
1092
|
}
|
|
1093
1093
|
});
|
|
1094
1094
|
expect(rows()).toEqual(["ABC"]);
|
|
1095
|
+
const messages = () =>
|
|
1096
|
+
store
|
|
1097
|
+
.get(notebookAtom)
|
|
1098
|
+
.cellLogs.flat()
|
|
1099
|
+
.map((log) => log.message);
|
|
1100
|
+
expect(messages()).toEqual(mode === "replay" ? [] : ["B", "C"]);
|
|
1095
1101
|
act(() => {
|
|
1096
1102
|
conn.receive({ event: "console.removed", data: { id: "line-0" } });
|
|
1097
1103
|
conn.receive({ event: "console.removed", data: { id: "line-1" } });
|
|
@@ -1337,7 +1343,10 @@ it("clears the private debugger prompt and transcript when editing moves to anot
|
|
|
1337
1343
|
});
|
|
1338
1344
|
expect(rows()).toEqual([]);
|
|
1339
1345
|
expect(
|
|
1340
|
-
store
|
|
1346
|
+
store
|
|
1347
|
+
.get(notebookAtom)
|
|
1348
|
+
.cellLogs.flat()
|
|
1349
|
+
.map((log) => log.message),
|
|
1341
1350
|
).not.toContain("private debugger");
|
|
1342
1351
|
expect(store.get(pendingPdbInputAtom)).toBeNull();
|
|
1343
1352
|
});
|
package/src/css/common.css
CHANGED
|
@@ -20,6 +20,17 @@
|
|
|
20
20
|
display: inline-flex !important;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
/*
|
|
24
|
+
* Let the cell's delete control take and keep keyboard focus. A hidden
|
|
25
|
+
* control cannot take focus, so the first selector keeps the control visible
|
|
26
|
+
* in the moment when focus leaves the cell and no element holds focus yet.
|
|
27
|
+
* Focus on any other element in the cell does not show the control.
|
|
28
|
+
*/
|
|
29
|
+
.marimo-cell:focus-within:not(:has(:focus)) .shoulder-bottom.hover-action,
|
|
30
|
+
.shoulder-bottom.hover-action:focus-within {
|
|
31
|
+
display: inline-flex !important;
|
|
32
|
+
}
|
|
33
|
+
|
|
23
34
|
.hover-actions-parent:hover .hover-action,
|
|
24
35
|
.hover-actions-parent:focus .hover-action {
|
|
25
36
|
display: inline-flex !important;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { useSyncExternalStore } from "react";
|
|
4
|
+
import { createSharedSubscription } from "@/utils/shared-resource";
|
|
5
|
+
|
|
6
|
+
/** Matches the media query that common.css uses to hide hover actions. */
|
|
7
|
+
const FINE_POINTER_QUERY = "(hover: hover) and (pointer: fine)";
|
|
8
|
+
|
|
9
|
+
function getQuery(): MediaQueryList | undefined {
|
|
10
|
+
return window.matchMedia?.(FINE_POINTER_QUERY);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const subscribeToFinePointer = createSharedSubscription((notify) => {
|
|
14
|
+
const query = getQuery();
|
|
15
|
+
query?.addEventListener("change", notify);
|
|
16
|
+
return () => query?.removeEventListener("change", notify);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
function getSnapshot(): boolean {
|
|
20
|
+
return getQuery()?.matches ?? false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Whether the primary input can hover precisely (mouse or trackpad).
|
|
25
|
+
* Updates when the pointer capabilities change during a session.
|
|
26
|
+
* Environments without `matchMedia` report `false`.
|
|
27
|
+
*/
|
|
28
|
+
export function useFinePointer(): boolean {
|
|
29
|
+
return useSyncExternalStore(subscribeToFinePointer, getSnapshot, () => false);
|
|
30
|
+
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
-
import { Provider
|
|
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
|
|
23
|
-
const headerElements = findOutlineElements(items);
|
|
24
|
-
const { activeHeaderId, activeOccurrences } =
|
|
25
|
-
useActiveOutline(headerElements);
|
|
18
|
+
const outline = useActiveOutline();
|
|
26
19
|
|
|
27
|
-
if (
|
|
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
|
};
|