@marimo-team/islands 0.23.14-dev11 → 0.23.14-dev14
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/{chat-ui-DYBcNEdd.js → chat-ui-C6y6xLcn.js} +77 -77
- package/dist/{code-visibility-D9_pdpn0.js → code-visibility-BWxpdorj.js} +127 -127
- package/dist/{html-to-image-MqcD07Bw.js → html-to-image-DcTkcjmm.js} +69 -64
- package/dist/main.js +1008 -994
- package/dist/{process-output-Dt3icftd.js → process-output-2FbS8KgW.js} +1 -1
- package/dist/{reveal-component-BbZ44Wvb.js → reveal-component-DXelFX7A.js} +2 -2
- package/package.json +1 -1
- package/src/components/editor/renderers/vertical-layout/__tests__/vertical-layout.test.ts +27 -1
- package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +23 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { s as __toESM } from "./chunk-BNovOVIE.js";
|
|
2
2
|
import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
3
|
-
import { at as parseHtmlContent, it as ansiToPlainText } from "./html-to-image-
|
|
3
|
+
import { at as parseHtmlContent, it as ansiToPlainText } from "./html-to-image-DcTkcjmm.js";
|
|
4
4
|
import { u as createLucideIcon } from "./dist--2Bqjvs0.js";
|
|
5
5
|
import { t as Strings } from "./strings-Dq_j3Rxw.js";
|
|
6
6
|
import { t as require_jsx_runtime } from "./jsx-runtime-DebpN0FN.js";
|
|
@@ -6,10 +6,10 @@ import { s as __toESM } from "./chunk-BNovOVIE.js";
|
|
|
6
6
|
import { _ as Logger, g as cn, h as Events, l as useEventListener, t as Button } from "./button-BacYv-bE.js";
|
|
7
7
|
import { t as require_react } from "./react-DA-nE2FX.js";
|
|
8
8
|
import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
9
|
-
import { lt as kioskModeAtom } from "./html-to-image-
|
|
9
|
+
import { lt as kioskModeAtom } from "./html-to-image-DcTkcjmm.js";
|
|
10
10
|
import "./chunk-5FQGJX7Z-BbqSm5gU.js";
|
|
11
11
|
import { u as createLucideIcon } from "./dist--2Bqjvs0.js";
|
|
12
|
-
import { a as DEFAULT_SLIDE_TYPE, an as EyeOff, c as Slide, ct as PanelResizeHandle, i as DEFAULT_DECK_TRANSITION, ln as Code, on as Expand, ot as Panel, s as SlideSidebar, st as PanelGroup, t as useNotebookCodeAvailable } from "./code-visibility-
|
|
12
|
+
import { a as DEFAULT_SLIDE_TYPE, an as EyeOff, c as Slide, ct as PanelResizeHandle, i as DEFAULT_DECK_TRANSITION, ln as Code, on as Expand, ot as Panel, s as SlideSidebar, st as PanelGroup, t as useNotebookCodeAvailable } from "./code-visibility-BWxpdorj.js";
|
|
13
13
|
import { X as useDebouncedCallback } from "./input-BSdZp5Ng.js";
|
|
14
14
|
import "./toDate-D1Z7ZXWh.js";
|
|
15
15
|
import "./react-dom-BTJzcVJ9.js";
|
package/package.json
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
/* oxlint-disable typescript/no-explicit-any */
|
|
3
3
|
import { describe, expect, it } from "vitest";
|
|
4
4
|
import type { OutputMessage } from "@/core/kernel/messages";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
groupCellsByColumn,
|
|
7
|
+
readonlyDisplay,
|
|
8
|
+
shouldHideCode,
|
|
9
|
+
} from "../vertical-layout";
|
|
6
10
|
|
|
7
11
|
describe("groupCellsByColumn", () => {
|
|
8
12
|
it("should group cells by column and maintain order", () => {
|
|
@@ -171,3 +175,25 @@ describe("shouldHideCode", () => {
|
|
|
171
175
|
});
|
|
172
176
|
});
|
|
173
177
|
});
|
|
178
|
+
|
|
179
|
+
describe("readonlyDisplay", () => {
|
|
180
|
+
it("unwraps SQL cells to their inner query and marks them as sql", () => {
|
|
181
|
+
const result = readonlyDisplay('my_table = mo.sql("""SELECT 1 AS id""")');
|
|
182
|
+
expect(result.language).toBe("sql");
|
|
183
|
+
expect(result.code).toBe("SELECT 1 AS id");
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it("leaves plain Python cells untouched", () => {
|
|
187
|
+
const code = "x = 1 + 2";
|
|
188
|
+
const result = readonlyDisplay(code);
|
|
189
|
+
expect(result.language).toBe("python");
|
|
190
|
+
expect(result.code).toBe(code);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it("leaves non-SQL cells (e.g. markdown) unchanged as python", () => {
|
|
194
|
+
const code = 'mo.md("""## Heading""")';
|
|
195
|
+
const result = readonlyDisplay(code);
|
|
196
|
+
expect(result.language).toBe("python");
|
|
197
|
+
expect(result.code).toBe(code);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
Loader2Icon,
|
|
11
11
|
MoreHorizontalIcon,
|
|
12
12
|
} from "lucide-react";
|
|
13
|
+
import { SQLParser } from "@marimo-team/smart-cells";
|
|
13
14
|
import type React from "react";
|
|
14
15
|
import { memo, useRef, useState } from "react";
|
|
15
16
|
import { z } from "zod";
|
|
@@ -384,6 +385,8 @@ const VerticalCell = memo(
|
|
|
384
385
|
|
|
385
386
|
// Hide the code if it's pure markdown and there's an output, or if the code is empty
|
|
386
387
|
const hideCode = shouldHideCode(code, output);
|
|
388
|
+
// Only unwrap SQL when the code will actually be rendered.
|
|
389
|
+
const display = hideCode ? null : readonlyDisplay(code);
|
|
387
390
|
|
|
388
391
|
return (
|
|
389
392
|
<div
|
|
@@ -393,11 +396,12 @@ const VerticalCell = memo(
|
|
|
393
396
|
{...cellDomProps(cellId, name)}
|
|
394
397
|
>
|
|
395
398
|
{cellOutputArea === "above" && outputArea}
|
|
396
|
-
{
|
|
399
|
+
{display && (
|
|
397
400
|
<div className="tray">
|
|
398
401
|
<ReadonlyCode
|
|
399
402
|
initiallyHideCode={config.hide_code || kiosk}
|
|
400
|
-
code={code}
|
|
403
|
+
code={display.code}
|
|
404
|
+
language={display.language}
|
|
401
405
|
/>
|
|
402
406
|
</div>
|
|
403
407
|
)}
|
|
@@ -496,3 +500,20 @@ export function shouldHideCode(code: string, output: OutputMessage | null) {
|
|
|
496
500
|
const hasOutput = output !== null && !isOutputEmpty(output);
|
|
497
501
|
return (isPureMarkdown && hasOutput) || code.trim() === "";
|
|
498
502
|
}
|
|
503
|
+
|
|
504
|
+
const sqlParser = new SQLParser();
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Unwrap SQL cells to their inner query so read-only views highlight them as
|
|
508
|
+
* SQL instead of showing the raw `mo.sql(...)` wrapper.
|
|
509
|
+
*/
|
|
510
|
+
export function readonlyDisplay(code: string): {
|
|
511
|
+
code: string;
|
|
512
|
+
language: "python" | "sql";
|
|
513
|
+
} {
|
|
514
|
+
const trimmed = code.trim();
|
|
515
|
+
if (sqlParser.isSupported(trimmed)) {
|
|
516
|
+
return { code: sqlParser.transformIn(trimmed).code, language: "sql" };
|
|
517
|
+
}
|
|
518
|
+
return { code, language: "python" };
|
|
519
|
+
}
|