@marimo-team/frontend 0.16.0 → 0.16.1
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/assets/ConnectedDataExplorerComponent-2wVcyvDj.js +19 -0
- package/dist/assets/{ImageComparisonComponent-fTHv1Ih0.js → ImageComparisonComponent-D2j6i0hv.js} +1 -1
- package/dist/assets/{VegaLite-Bdi-TyfY.js → VegaLite-BckFaf2D.js} +1 -1
- package/dist/assets/_baseEach-CvTX9w0Y.js +1 -0
- package/dist/assets/_baseMap-CtlwA90f.js +1 -0
- package/dist/assets/_baseUniq-BKktIGQ1.js +1 -0
- package/dist/assets/{_createAggregator-DcD0kTA5.js → _createAggregator-C5CVY-0t.js} +1 -1
- package/dist/assets/{agent-panel-Crv430aI.js → agent-panel-RGLNjkYe.js} +76 -57
- package/dist/assets/{any-language-editor-CQh552Wu.js → any-language-editor-DjuXwGCA.js} +1 -1
- package/dist/assets/{architectureDiagram-W76B3OCA-BAJeBxzt.js → architectureDiagram-W76B3OCA-Dyj4ds_R.js} +1 -1
- package/dist/assets/{between-horizontal-start-Boxgxbt_.js → between-horizontal-start-Dt2aKpPf.js} +1 -1
- package/dist/assets/{blockDiagram-QIGZ2CNN-CL-1svEK.js → blockDiagram-QIGZ2CNN-o-i7DDvN.js} +1 -1
- package/dist/assets/{c4Diagram-FPNF74CW-BbEqbCTl.js → c4Diagram-FPNF74CW-DGHEwWrx.js} +1 -1
- package/dist/assets/channel-Co6iMgWq.js +1 -0
- package/dist/assets/chat-panel-9alr8FS4.js +3 -0
- package/dist/assets/{chunk-4BX2VUAB-C--8TXeE.js → chunk-4BX2VUAB-BJecb-Ri.js} +1 -1
- package/dist/assets/{chunk-55IACEB6-Bj00HDqq.js → chunk-55IACEB6-CAATkc4w.js} +1 -1
- package/dist/assets/{chunk-FMBD7UC4-C-lhB6hN.js → chunk-FMBD7UC4-DPuNbQ-f.js} +1 -1
- package/dist/assets/{chunk-K7UQS3LO-B-pGTXPt.js → chunk-K7UQS3LO-C8TWVLiH.js} +1 -1
- package/dist/assets/{chunk-QN33PNHL-DqUzGhvm.js → chunk-QN33PNHL-DiZZ09q4.js} +1 -1
- package/dist/assets/{chunk-QZHKN3VN-TntJHfSk.js → chunk-QZHKN3VN-BIUM7usu.js} +1 -1
- package/dist/assets/{chunk-TVAH2DTR-HUJb1psV.js → chunk-TVAH2DTR-vGTArPBG.js} +1 -1
- package/dist/assets/{chunk-TZMSLE5B-BK3C__t3.js → chunk-TZMSLE5B-D2KRqp_x.js} +1 -1
- package/dist/assets/{circle-play-DBLOv1Yu.js → circle-play-cjeNez0N.js} +1 -1
- package/dist/assets/classDiagram-KNZD7YFC-BbJ0rY3y.js +1 -0
- package/dist/assets/classDiagram-v2-RKCZMP56-BbJ0rY3y.js +1 -0
- package/dist/assets/{clear-button-BeoFbEKH.js → clear-button-C97JtAez.js} +1 -1
- package/dist/assets/clone-BMP0PsTa.js +1 -0
- package/dist/assets/{command-palette-CXZiSv0I.js → command-palette-B93Pjcky.js} +1 -1
- package/dist/assets/{common-C7oJcmCT.js → common-Du9rSOwD.js} +1 -1
- package/dist/assets/{compile-7L0MwhyI.js → compile-CZXqyOxa.js} +1 -1
- package/dist/assets/{cose-bilkent-S5V4N54A-BMkGLcVC.js → cose-bilkent-S5V4N54A-CqUN5Y9b.js} +1 -1
- package/dist/assets/{dagre-5GWH7T2D-BJtRienS.js → dagre-5GWH7T2D-RJqTI9DM.js} +1 -1
- package/dist/assets/{data-grid-overlay-editor-DBkmGtNs.js → data-grid-overlay-editor-DZN0q1LV.js} +1 -1
- package/dist/assets/datasources-panel-v7H3cR0p.js +1 -0
- package/dist/assets/{dependency-graph-panel-DEdOxp2X.js → dependency-graph-panel-CEog_O7V.js} +1 -1
- package/dist/assets/{diagram-N5W7TBWH-CmECY3nb.js → diagram-N5W7TBWH-D-l4zZ9d.js} +1 -1
- package/dist/assets/{diagram-QEK2KX5R-DMOVSNKD.js → diagram-QEK2KX5R-CCOmBUt-.js} +1 -1
- package/dist/assets/{diagram-S2PKOQOG-BiJ96PNQ.js → diagram-S2PKOQOG-C_I_9jnZ.js} +1 -1
- package/dist/assets/{documentation-panel-xULhaEv3.js → documentation-panel-C1BtMZ3M.js} +1 -1
- package/dist/assets/edit-page-B-oevUZ9.js +129 -0
- package/dist/assets/{ellipsis-vertical-BBqXIlc2.js → ellipsis-vertical-BEb-J8z6.js} +1 -1
- package/dist/assets/{empty-state-B3dA3G5P.js → empty-state-C99UyDE3.js} +1 -1
- package/dist/assets/{erDiagram-AWTI2OKA-MP1DiFRo.js → erDiagram-AWTI2OKA-BePOLi5M.js} +1 -1
- package/dist/assets/{error-panel-Cc1sv-Ag.js → error-panel-Bs34jXFh.js} +1 -1
- package/dist/assets/file-explorer-panel-Ck6UL861.js +1 -0
- package/dist/assets/{flowDiagram-PVAE7QVJ-BX7caPp7.js → flowDiagram-PVAE7QVJ-BgjFu5l7.js} +1 -1
- package/dist/assets/{ganttDiagram-OWAHRB6G-B462g4Yf.js → ganttDiagram-OWAHRB6G-YOPb3XSV.js} +4 -4
- package/dist/assets/{gitGraphDiagram-NY62KEGX-CGgvZ9-9.js → gitGraphDiagram-NY62KEGX-CGhqaDTy.js} +1 -1
- package/dist/assets/{glide-data-editor-C0gUFZON.js → glide-data-editor-9QUH6iso.js} +11 -11
- package/dist/assets/{graph-CHRVBzY5.js → graph-DQQFGrho.js} +1 -1
- package/dist/assets/home-page-DRKpPCrF.js +9 -0
- package/dist/assets/{index-C1v_Z9et.js → index-2252nrk6.js} +1 -1
- package/dist/assets/{index-CQDrxQ0j.js → index-Aeo6WiK7.js} +1 -1
- package/dist/assets/{index-C4Tn5NvJ.js → index-B8jXZ12t.js} +1 -1
- package/dist/assets/{index-DoRmcrKM.js → index-BAbIIxHU.js} +1 -1
- package/dist/assets/{index-BY93Ejhl.js → index-BJNCMUmG.js} +1 -1
- package/dist/assets/{index-CpTPJo4k.js → index-BW3k9Gss.js} +1 -1
- package/dist/assets/{index-D1vmG6DS.js → index-BjgnbONl.js} +1 -1
- package/dist/assets/{index-z9bohSQJ.js → index-BprjMYH5.js} +1 -1
- package/dist/assets/{index-BVgAenPd.js → index-C1ez98sk.js} +1 -1
- package/dist/assets/{index-D9UKkrr2.js → index-C2MD0vgD.js} +1 -1
- package/dist/assets/index-C7CoaNFb.js +578 -0
- package/dist/assets/{index-C-GhZ7ti.js → index-CFKO7WXI.js} +1 -1
- package/dist/assets/{index-lYa_leQE.js → index-CUFv_thQ.js} +1 -1
- package/dist/assets/{index-vmICa5KN.js → index-C_tkBKNO.js} +1 -1
- package/dist/assets/{index-C77h_TXN.js → index-CfaDbEdi.js} +1 -1
- package/dist/assets/{index-DEQvTChO.js → index-ClzeQrN7.js} +1 -1
- package/dist/assets/index-DadI618h.css +1 -0
- package/dist/assets/{index-DRMm6SNo.js → index-DdnKZNxM.js} +1 -1
- package/dist/assets/{index-CWMgowgL.js → index-G5QZppK2.js} +1 -1
- package/dist/assets/{index-Clbi_Yaq.js → index-SGLNXrGP.js} +1 -1
- package/dist/assets/{index-C-8WADat.js → index-aE43R74q.js} +1 -1
- package/dist/assets/infoDiagram-STP46IZ2-CJLOpSAf.js +2 -0
- package/dist/assets/{isEmpty-DU_ogP_D.js → isEmpty-D-4c7sMv.js} +1 -1
- package/dist/assets/{journeyDiagram-BIP6EPQ6-C6EgLP_Q.js → journeyDiagram-BIP6EPQ6-C94u3Mv3.js} +1 -1
- package/dist/assets/{kanban-definition-6OIFK2YF-BXzYO1yj.js → kanban-definition-6OIFK2YF-BEXYFzz7.js} +1 -1
- package/dist/assets/{layout-jihVw5-i.js → layout-Bz2BJ2ru.js} +1 -1
- package/dist/assets/{linear-C4blANlC.js → linear-D8s7K76e.js} +1 -1
- package/dist/assets/links-BpXlz1GG.js +7 -0
- package/dist/assets/{logs-panel-D401qzZh.js → logs-panel-DC7wpmPz.js} +1 -1
- package/dist/assets/{markdown-renderer-Cd9eYyaL.js → markdown-renderer-DRdSWR9X.js} +20 -20
- package/dist/assets/{mermaid-BEVuRz_O.js → mermaid-Y3x4hmD0.js} +1 -1
- package/dist/assets/{mermaid.core-CaSnaLH0.js → mermaid.core-DzthE35Y.js} +4 -4
- package/dist/assets/min-BBO3-1Hg.js +1 -0
- package/dist/assets/{mindmap-definition-Q6HEUPPD-BXUM5MT2.js → mindmap-definition-Q6HEUPPD-DktvuLe1.js} +1 -1
- package/dist/assets/{number-overlay-editor-4uWXGlPG.js → number-overlay-editor-BEfwI1IT.js} +1 -1
- package/dist/assets/outline-panel-CdsnAy2w.js +1 -0
- package/dist/assets/{packages-panel-CJL0MVlj.js → packages-panel-DiTA-d_D.js} +1 -1
- package/dist/assets/{pieDiagram-ADFJNKIX-Dxt5PVNo.js → pieDiagram-ADFJNKIX-DQDNQ-de.js} +1 -1
- package/dist/assets/{quadrantDiagram-LMRXKWRM-D4pUaA31.js → quadrantDiagram-LMRXKWRM-0kgIXc2-.js} +1 -1
- package/dist/assets/{react-plotly-cJZ0VWBq.js → react-plotly-DJqqfM7c.js} +1 -1
- package/dist/assets/{requirementDiagram-4UW4RH46-DVRTjgas.js → requirementDiagram-4UW4RH46-B5rb0ypd.js} +1 -1
- package/dist/assets/{run-page-BUEnMC9w.js → run-page-CFmLrv1R.js} +1 -1
- package/dist/assets/{sankeyDiagram-GR3RE2ED-CVFnD9C-.js → sankeyDiagram-GR3RE2ED-Dom7IlnF.js} +1 -1
- package/dist/assets/{scratchpad-panel-BIgRENkI.js → scratchpad-panel-CuHWpHO8.js} +1 -1
- package/dist/assets/{secrets-panel-xY5-V_BD.js → secrets-panel-CfHc5YD0.js} +1 -1
- package/dist/assets/{sequenceDiagram-C3RYC4MD-_lY4ZN_S.js → sequenceDiagram-C3RYC4MD-PNJWXQbw.js} +1 -1
- package/dist/assets/{slides-component-DMjQomc3.css → slides-component-C-LoGC1U.css} +1 -1
- package/dist/assets/{slides-component-Xjymwj7X.js → slides-component-CJgaTRZ0.js} +1 -1
- package/dist/assets/snippets-panel-B2EC1txM.js +1 -0
- package/dist/assets/sortBy-DZnlX29-.js +1 -0
- package/dist/assets/{state-C4NiC9tO.js → state-CWict9RU.js} +1 -1
- package/dist/assets/{stateDiagram-KXAO66HF-Da0JQWCn.js → stateDiagram-KXAO66HF-BE58aJnr.js} +1 -1
- package/dist/assets/stateDiagram-v2-UMBNRL4Z-CdThjimL.js +1 -0
- package/dist/assets/storage-DRaR04wR.js +26 -0
- package/dist/assets/{terminal-BPwTkXae.js → terminal-BX3Su5q7.js} +1 -1
- package/dist/assets/{time-Dv5_Ouz_.js → time-hUzZfpNE.js} +1 -1
- package/dist/assets/{timeline-definition-XQNQX7LJ-Dxh5Zu2e.js → timeline-definition-XQNQX7LJ-CqQP9t51.js} +1 -1
- package/dist/assets/tracing-B10Q1n-L.js +2 -0
- package/dist/assets/{tracing-panel-DAzrzNmm.js → tracing-panel-Du8WCnno.js} +2 -2
- package/dist/assets/{trash-Dc6DSjz_.js → trash-B81GTiv6.js} +1 -1
- package/dist/assets/{tree-jheoerAX.js → tree-6vW2ogkh.js} +1 -1
- package/dist/assets/{treemap-75Q7IDZK-IgpxeGaf.js → treemap-75Q7IDZK-CdwDwwsz.js} +27 -27
- package/dist/assets/variable-panel-D5qgJI7k.js +1 -0
- package/dist/assets/{vega-component-BpfpiPKI.js → vega-component-DJaJWMJM.js} +1 -1
- package/dist/assets/worker-fHbtoWvT.js +1 -0
- package/dist/assets/{xychartDiagram-6GGTOJPD-CmNigJ31.js → xychartDiagram-6GGTOJPD-WFtXqaM9.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +3 -2
- package/src/components/app-config/user-config-form.tsx +46 -1
- package/src/components/chat/acp/__tests__/__snapshots__/prompt.test.ts.snap +62 -43
- package/src/components/chat/acp/__tests__/atoms.test.ts +1 -1
- package/src/components/chat/acp/__tests__/state.test.ts +36 -36
- package/src/components/chat/acp/agent-panel.tsx +24 -27
- package/src/components/chat/acp/blocks.tsx +6 -6
- package/src/components/chat/acp/prompt.ts +62 -43
- package/src/components/chat/chat-panel.tsx +5 -1
- package/src/components/chat/markdown-renderer.tsx +6 -10
- package/src/components/chat/tool-call-accordion.tsx +52 -20
- package/src/components/data-table/SearchBar.tsx +8 -7
- package/src/components/data-table/__tests__/column_formatting.test.ts +50 -35
- package/src/components/data-table/__tests__/data-table.test.tsx +39 -1
- package/src/components/data-table/cell-hover-template/feature.ts +14 -0
- package/src/components/data-table/cell-hover-template/types.ts +11 -0
- package/src/components/data-table/charts/components/form-fields.tsx +41 -37
- package/src/components/data-table/charts/forms/common-chart.tsx +2 -2
- package/src/components/data-table/column-explorer-panel/column-explorer.tsx +5 -2
- package/src/components/data-table/column-formatting/feature.ts +62 -29
- package/src/components/data-table/column-formatting/types.ts +1 -0
- package/src/components/data-table/column-header.tsx +3 -1
- package/src/components/data-table/column-summary/chart-spec-model.tsx +24 -7
- package/src/components/data-table/column-summary/column-summary.tsx +18 -9
- package/src/components/data-table/columns.tsx +42 -18
- package/src/components/data-table/data-table.tsx +10 -2
- package/src/components/data-table/date-popover.tsx +85 -75
- package/src/components/data-table/filter-pills.tsx +14 -9
- package/src/components/data-table/header-items.tsx +5 -1
- package/src/components/data-table/pagination.tsx +20 -13
- package/src/components/data-table/renderers.tsx +28 -0
- package/src/components/data-table/row-viewer-panel/row-viewer.tsx +10 -8
- package/src/components/datasources/column-preview.tsx +6 -2
- package/src/components/datasources/datasources.tsx +8 -12
- package/src/components/editor/ai/transport/chat-transport.tsx +4 -1
- package/src/components/editor/cell/CellStatus.tsx +23 -20
- package/src/components/editor/cell/CreateCellButton.tsx +3 -4
- package/src/components/editor/cell/code/language-toggle.tsx +3 -4
- package/src/components/editor/chrome/wrapper/footer-items/machine-stats.tsx +39 -28
- package/src/components/editor/controls/notebook-menu-dropdown.tsx +4 -2
- package/src/components/editor/file-tree/requesting-tree.tsx +14 -8
- package/src/components/editor/renderers/CellArray.tsx +3 -4
- package/src/components/editor/renderers/slides-layout/slides-layout.tsx +3 -3
- package/src/components/editor/renderers/slides-layout/types.ts +1 -0
- package/src/components/pages/home-page.tsx +4 -1
- package/src/components/slides/slides-component.tsx +1 -1
- package/src/components/slides/slides.css +6 -0
- package/src/components/terminal/theme.tsx +1 -0
- package/src/components/tracing/tracing-spec.ts +5 -4
- package/src/components/ui/range-slider.tsx +4 -2
- package/src/components/ui/slider.tsx +3 -1
- package/src/components/variables/variables-table.tsx +3 -0
- package/src/core/MarimoApp.tsx +9 -6
- package/src/core/ai/context/__tests__/registry.test.ts +6 -4
- package/src/core/ai/context/providers/cell-output.ts +3 -2
- package/src/core/ai/context/providers/error.ts +3 -1
- package/src/core/ai/context/providers/file.ts +7 -2
- package/src/core/ai/context/providers/tables.ts +3 -2
- package/src/core/ai/context/providers/variable.ts +6 -4
- package/src/core/ai/staged-cells.ts +34 -1
- package/src/core/cells/__tests__/add-missing-import.test.ts +67 -22
- package/src/core/cells/add-missing-import.ts +24 -7
- package/src/core/cells/cells.ts +26 -27
- package/src/core/cells/logs.ts +1 -1
- package/src/core/codemirror/find-replace/search-highlight.ts +3 -1
- package/src/core/codemirror/language/LanguageAdapters.ts +9 -3
- package/src/core/codemirror/lsp/notebook-lsp.ts +8 -2
- package/src/core/codemirror/readonly/__tests__/extension.test.ts +1 -1
- package/src/core/codemirror/rtc/loro/awareness.ts +52 -17
- package/src/core/codemirror/rtc/loro/sync.ts +12 -4
- package/src/core/config/config-schema.ts +1 -0
- package/src/core/config/config.ts +4 -0
- package/src/core/hotkeys/hotkeys.ts +8 -4
- package/src/core/i18n/__tests__/locale-provider.test.tsx +176 -0
- package/src/core/i18n/locale-provider.tsx +35 -0
- package/src/core/i18n/with-locale.tsx +12 -0
- package/src/core/islands/components/web-components.tsx +13 -10
- package/src/core/kernel/RuntimeState.ts +4 -1
- package/src/core/kernel/messages.ts +2 -2
- package/src/core/network/DeferredRequestRegistry.ts +16 -4
- package/src/core/runtime/runtime.ts +5 -4
- package/src/core/wasm/bridge.ts +5 -1
- package/src/core/wasm/store.ts +4 -1
- package/src/core/wasm/worker/message-buffer.ts +3 -2
- package/src/core/websocket/types.ts +22 -16
- package/src/hooks/useFormatting.ts +97 -0
- package/src/hooks/useTimer.ts +8 -5
- package/src/plugins/core/registerReactComponent.tsx +16 -10
- package/src/plugins/impl/DataTablePlugin.tsx +4 -0
- package/src/plugins/impl/RangeSliderPlugin.tsx +5 -3
- package/src/plugins/impl/SliderPlugin.tsx +3 -1
- package/src/plugins/impl/anywidget/model.ts +16 -5
- package/src/plugins/impl/data-editor/types.ts +7 -5
- package/src/plugins/impl/data-explorer/components/column-summary.tsx +20 -13
- package/src/plugins/impl/panel/utils.ts +6 -4
- package/src/plugins/layout/OutlinePlugin.tsx +69 -0
- package/src/plugins/layout/StatPlugin.tsx +4 -1
- package/src/plugins/plugins.ts +2 -0
- package/src/utils/__tests__/dates.test.ts +45 -24
- package/src/utils/__tests__/numbers.test.ts +42 -30
- package/src/utils/__tests__/once.test.ts +187 -0
- package/src/utils/dates.ts +15 -10
- package/src/utils/edit-distance.ts +8 -6
- package/src/utils/errors.ts +1 -1
- package/src/utils/id-tree.tsx +21 -10
- package/src/utils/localStorage.ts +13 -4
- package/src/utils/numbers.ts +11 -11
- package/src/utils/once.ts +32 -0
- package/src/utils/paths.ts +4 -1
- package/src/utils/pluralize.ts +12 -5
- package/src/utils/python-poet/poet.ts +30 -15
- package/src/utils/time.ts +5 -1
- package/dist/assets/ConnectedDataExplorerComponent-BErMbWvG.js +0 -19
- package/dist/assets/_baseEach-CNBxBxvS.js +0 -1
- package/dist/assets/_baseMap-D1WHjKrd.js +0 -1
- package/dist/assets/_baseUniq-CCgDNtZb.js +0 -1
- package/dist/assets/channel-_2eNSz0n.js +0 -1
- package/dist/assets/chat-panel-CXh5Wl6C.js +0 -3
- package/dist/assets/classDiagram-KNZD7YFC-BGmh9POF.js +0 -1
- package/dist/assets/classDiagram-v2-RKCZMP56-BGmh9POF.js +0 -1
- package/dist/assets/clone-BFDSPAj3.js +0 -1
- package/dist/assets/datasources-panel-B7FbYLiy.js +0 -1
- package/dist/assets/edit-page-BrYda9VE.js +0 -129
- package/dist/assets/file-explorer-panel-Bw59Kva1.js +0 -1
- package/dist/assets/home-page-Fb2osjys.js +0 -9
- package/dist/assets/index-Cx0bsY1w.css +0 -1
- package/dist/assets/index-DKEudB02.js +0 -578
- package/dist/assets/infoDiagram-STP46IZ2-CVyrdLc8.js +0 -2
- package/dist/assets/links-D59GIweI.js +0 -7
- package/dist/assets/min-DUMu_zeK.js +0 -1
- package/dist/assets/outline-panel-DIzkvm2I.js +0 -1
- package/dist/assets/snippets-panel-CTPYW41n.js +0 -1
- package/dist/assets/sortBy-BNZKwiq_.js +0 -1
- package/dist/assets/stateDiagram-v2-UMBNRL4Z-D5lYZOOt.js +0 -1
- package/dist/assets/storage-CMdLzB_c.js +0 -26
- package/dist/assets/tracing-BCIurUfa.js +0 -2
- package/dist/assets/variable-panel-DYAiLBmF.js +0 -1
- package/dist/assets/worker-X5rxzQGQ.js +0 -1
|
@@ -20,11 +20,13 @@ export class VariableContextProvider extends AIContextProvider<VariableContextIt
|
|
|
20
20
|
readonly mentionPrefix = "@";
|
|
21
21
|
readonly contextType = "variable";
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
) {
|
|
23
|
+
private variables: Variables;
|
|
24
|
+
private tablesMap: DatasetTablesMap;
|
|
25
|
+
|
|
26
|
+
constructor(variables: Variables, tablesMap: DatasetTablesMap) {
|
|
27
27
|
super();
|
|
28
|
+
this.variables = variables;
|
|
29
|
+
this.tablesMap = tablesMap;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
getItems(): VariableContextItem[] {
|
|
@@ -10,7 +10,12 @@ import { useDeleteCellCallback } from "@/components/editor/cell/useDeleteCell";
|
|
|
10
10
|
import { CellId } from "@/core/cells/ids";
|
|
11
11
|
import { createReducerAndAtoms } from "@/utils/createReducer";
|
|
12
12
|
import { Logger } from "@/utils/Logger";
|
|
13
|
-
import {
|
|
13
|
+
import { maybeAddMarimoImport } from "../cells/add-missing-import";
|
|
14
|
+
import {
|
|
15
|
+
type CreateNewCellAction,
|
|
16
|
+
cellHandleAtom,
|
|
17
|
+
useCellActions,
|
|
18
|
+
} from "../cells/cells";
|
|
14
19
|
import type { LanguageAdapterType } from "../codemirror/language/types";
|
|
15
20
|
import { updateEditorCodeFromPython } from "../codemirror/language/utils";
|
|
16
21
|
import type { JotaiStore } from "../state/jotai";
|
|
@@ -113,6 +118,8 @@ export function useStagedCells(store: JotaiStore) {
|
|
|
113
118
|
cellCreationStream.current = new CellCreationStream(
|
|
114
119
|
createStagedCell,
|
|
115
120
|
updateStagedCell,
|
|
121
|
+
addStagedCell,
|
|
122
|
+
createNewCell,
|
|
116
123
|
);
|
|
117
124
|
break;
|
|
118
125
|
case "text-delta":
|
|
@@ -168,13 +175,20 @@ class CellCreationStream {
|
|
|
168
175
|
|
|
169
176
|
private onCreateCell: (code: string) => CellId;
|
|
170
177
|
private onUpdateCell: (opts: UpdateStagedCellAction) => void;
|
|
178
|
+
private addStagedCell: (payload: { cellId: CellId }) => void;
|
|
179
|
+
private createNewCell: (opts: CreateNewCellAction) => void;
|
|
180
|
+
private hasMarimoImport = false;
|
|
171
181
|
|
|
172
182
|
constructor(
|
|
173
183
|
onCreateCell: (code: string) => CellId,
|
|
174
184
|
onUpdateCell: (opts: UpdateStagedCellAction) => void,
|
|
185
|
+
addStagedCell: (payload: { cellId: CellId }) => void,
|
|
186
|
+
createNewCell: (opts: CreateNewCellAction) => void,
|
|
175
187
|
) {
|
|
176
188
|
this.onCreateCell = onCreateCell;
|
|
177
189
|
this.onUpdateCell = onUpdateCell;
|
|
190
|
+
this.addStagedCell = addStagedCell;
|
|
191
|
+
this.createNewCell = createNewCell;
|
|
178
192
|
}
|
|
179
193
|
|
|
180
194
|
stream(chunk: TextDeltaChunk) {
|
|
@@ -187,6 +201,7 @@ class CellCreationStream {
|
|
|
187
201
|
// For each parsed cell, we either update an existing staged cell or create a new one.
|
|
188
202
|
for (const [idx, cell] of completionCells.entries()) {
|
|
189
203
|
if (idx < this.createdCells.length) {
|
|
204
|
+
this.addMarimoImport(cell.language);
|
|
190
205
|
const existingCell = this.createdCells[idx];
|
|
191
206
|
this.createdCells[idx] = { ...existingCell, cell };
|
|
192
207
|
this.onUpdateCell({
|
|
@@ -201,6 +216,24 @@ class CellCreationStream {
|
|
|
201
216
|
}
|
|
202
217
|
}
|
|
203
218
|
|
|
219
|
+
/** Add a marimo import if the cell is SQL or Markdown and we haven't added it yet. */
|
|
220
|
+
private addMarimoImport(language: LanguageAdapterType) {
|
|
221
|
+
if (this.hasMarimoImport || language === "python") {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const cellId = maybeAddMarimoImport({
|
|
226
|
+
autoInstantiate: false,
|
|
227
|
+
createNewCell: this.createNewCell,
|
|
228
|
+
fromCellId: this.createdCells[0]?.cellId,
|
|
229
|
+
before: true,
|
|
230
|
+
});
|
|
231
|
+
if (cellId) {
|
|
232
|
+
this.addStagedCell({ cellId });
|
|
233
|
+
}
|
|
234
|
+
this.hasMarimoImport = true;
|
|
235
|
+
}
|
|
236
|
+
|
|
204
237
|
stop() {
|
|
205
238
|
// Clear all state
|
|
206
239
|
this.buffer = "";
|
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
/* Copyright 2024 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
3
|
import { createStore } from "jotai";
|
|
4
|
-
import { describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { MockNotebook } from "@/__mocks__/notebook";
|
|
6
|
+
import { MockRequestClient } from "@/__mocks__/requests";
|
|
7
|
+
import { store } from "@/core/state/jotai";
|
|
5
8
|
import { variablesAtom } from "@/core/variables/state";
|
|
6
9
|
import type { Variables } from "@/core/variables/types";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
import {
|
|
11
|
+
maybeAddAltairImport,
|
|
12
|
+
maybeAddMarimoImport,
|
|
13
|
+
maybeAddMissingImport,
|
|
14
|
+
} from "../add-missing-import";
|
|
15
|
+
import { notebookAtom } from "../cells";
|
|
10
16
|
import type { CellId } from "../ids";
|
|
11
|
-
import type { CellData } from "../types";
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
// Mock the getRequestClient function
|
|
19
|
+
const mockRequestClient = MockRequestClient.create();
|
|
20
|
+
vi.mock("@/core/network/requests", () => ({
|
|
21
|
+
getRequestClient: () => mockRequestClient,
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const Cell1 = "1" as CellId;
|
|
25
|
+
const Cell2 = "2" as CellId;
|
|
14
26
|
|
|
15
27
|
describe("maybeAddMissingImport", () => {
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
store.set(variablesAtom, {} as Variables);
|
|
30
|
+
store.set(notebookAtom, MockNotebook.notebookState({ cellData: {} }));
|
|
31
|
+
});
|
|
32
|
+
|
|
16
33
|
it("should not add an import if the variable is already in the variables state", () => {
|
|
17
34
|
const appStore = createStore();
|
|
18
35
|
appStore.set(variablesAtom, { mo: {} } as Variables);
|
|
@@ -36,14 +53,14 @@ describe("maybeAddMissingImport", () => {
|
|
|
36
53
|
(code) => {
|
|
37
54
|
const appStore = createStore();
|
|
38
55
|
appStore.set(variablesAtom, {} as Variables);
|
|
39
|
-
appStore.set(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
56
|
+
appStore.set(
|
|
57
|
+
notebookAtom,
|
|
58
|
+
MockNotebook.notebookState({
|
|
59
|
+
cellData: {
|
|
60
|
+
[Cell1]: { code: code },
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
47
64
|
const onAddImport = vi.fn();
|
|
48
65
|
maybeAddMissingImport({
|
|
49
66
|
moduleName: "marimo",
|
|
@@ -58,14 +75,14 @@ describe("maybeAddMissingImport", () => {
|
|
|
58
75
|
it("should add an import if the variable is not in the variables state and the import statement does not exist in the notebook", () => {
|
|
59
76
|
const appStore = createStore();
|
|
60
77
|
appStore.set(variablesAtom, {} as Variables);
|
|
61
|
-
appStore.set(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
78
|
+
appStore.set(
|
|
79
|
+
notebookAtom,
|
|
80
|
+
MockNotebook.notebookState({
|
|
81
|
+
cellData: {
|
|
82
|
+
[Cell1]: { code: "mo.md('hello')" },
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
69
86
|
const onAddImport = vi.fn();
|
|
70
87
|
maybeAddMissingImport({
|
|
71
88
|
moduleName: "marimo",
|
|
@@ -75,4 +92,32 @@ describe("maybeAddMissingImport", () => {
|
|
|
75
92
|
});
|
|
76
93
|
expect(onAddImport).toHaveBeenCalledWith("import marimo as mo");
|
|
77
94
|
});
|
|
95
|
+
|
|
96
|
+
it("should not create a new cell if import already exists due to skipIfCodeExists", () => {
|
|
97
|
+
const addImports = [maybeAddMarimoImport, maybeAddAltairImport];
|
|
98
|
+
for (const addImport of addImports) {
|
|
99
|
+
store.set(variablesAtom, {} as Variables);
|
|
100
|
+
store.set(
|
|
101
|
+
notebookAtom,
|
|
102
|
+
MockNotebook.notebookState({
|
|
103
|
+
cellData: {
|
|
104
|
+
[Cell1]: { code: "import marimo as mo" },
|
|
105
|
+
[Cell2]: { code: "import altair as alt" },
|
|
106
|
+
},
|
|
107
|
+
}),
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const createNewCell = vi.fn();
|
|
111
|
+
const result = addImport({
|
|
112
|
+
autoInstantiate: false,
|
|
113
|
+
createNewCell,
|
|
114
|
+
fromCellId: Cell1,
|
|
115
|
+
before: false,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Should not create a new cell since the import already exists
|
|
119
|
+
expect(createNewCell).not.toHaveBeenCalled();
|
|
120
|
+
expect(result).toBeNull();
|
|
121
|
+
}
|
|
122
|
+
});
|
|
78
123
|
});
|
|
@@ -47,27 +47,40 @@ export function maybeAddMissingImport({
|
|
|
47
47
|
return true;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Adds a marimo import to the notebook if not already present.
|
|
52
|
+
* @param autoInstantiate Whether to automatically run the cell.
|
|
53
|
+
* @param createNewCell The function to create a new cell.
|
|
54
|
+
* @param fromCellId The cell to add the import to.
|
|
55
|
+
* @param before Whether to add the import before or after the cell.
|
|
56
|
+
*
|
|
57
|
+
* Returns the ID of the new cell if added, otherwise null.
|
|
58
|
+
*/
|
|
50
59
|
export function maybeAddMarimoImport({
|
|
51
60
|
autoInstantiate,
|
|
52
61
|
createNewCell,
|
|
53
62
|
fromCellId,
|
|
63
|
+
before,
|
|
54
64
|
}: {
|
|
55
65
|
autoInstantiate: boolean;
|
|
56
66
|
createNewCell: CellActions["createNewCell"];
|
|
57
67
|
fromCellId?: CellId | null;
|
|
58
|
-
|
|
68
|
+
before?: boolean;
|
|
69
|
+
}): CellId | null {
|
|
59
70
|
const client = getRequestClient();
|
|
60
|
-
|
|
71
|
+
let newCellId: CellId | null = null;
|
|
72
|
+
const added = maybeAddMissingImport({
|
|
61
73
|
moduleName: "marimo",
|
|
62
74
|
variableName: "mo",
|
|
63
75
|
onAddImport: (importStatement) => {
|
|
64
|
-
|
|
76
|
+
newCellId = CellId.create();
|
|
65
77
|
createNewCell({
|
|
66
78
|
cellId: fromCellId ?? "__end__",
|
|
67
|
-
before: false,
|
|
79
|
+
before: before ?? false,
|
|
68
80
|
code: importStatement,
|
|
69
81
|
lastCodeRun: autoInstantiate ? importStatement : undefined,
|
|
70
82
|
newCellId: newCellId,
|
|
83
|
+
skipIfCodeExists: true,
|
|
71
84
|
autoFocus: false,
|
|
72
85
|
});
|
|
73
86
|
if (autoInstantiate) {
|
|
@@ -78,6 +91,7 @@ export function maybeAddMarimoImport({
|
|
|
78
91
|
}
|
|
79
92
|
},
|
|
80
93
|
});
|
|
94
|
+
return added ? newCellId : null;
|
|
81
95
|
}
|
|
82
96
|
|
|
83
97
|
export function maybeAddAltairImport({
|
|
@@ -88,19 +102,21 @@ export function maybeAddAltairImport({
|
|
|
88
102
|
autoInstantiate: boolean;
|
|
89
103
|
createNewCell: CellActions["createNewCell"];
|
|
90
104
|
fromCellId?: CellId | null;
|
|
91
|
-
}):
|
|
105
|
+
}): CellId | null {
|
|
92
106
|
const client = getRequestClient();
|
|
93
|
-
|
|
107
|
+
let newCellId: CellId | null = null;
|
|
108
|
+
const added = maybeAddMissingImport({
|
|
94
109
|
moduleName: "altair",
|
|
95
110
|
variableName: "alt",
|
|
96
111
|
onAddImport: (importStatement) => {
|
|
97
|
-
|
|
112
|
+
newCellId = CellId.create();
|
|
98
113
|
createNewCell({
|
|
99
114
|
cellId: fromCellId ?? "__end__",
|
|
100
115
|
before: false,
|
|
101
116
|
code: importStatement,
|
|
102
117
|
lastCodeRun: autoInstantiate ? importStatement : undefined,
|
|
103
118
|
newCellId: newCellId,
|
|
119
|
+
skipIfCodeExists: true,
|
|
104
120
|
autoFocus: false,
|
|
105
121
|
});
|
|
106
122
|
if (autoInstantiate) {
|
|
@@ -111,4 +127,5 @@ export function maybeAddAltairImport({
|
|
|
111
127
|
}
|
|
112
128
|
},
|
|
113
129
|
});
|
|
130
|
+
return added ? newCellId : null;
|
|
114
131
|
}
|
package/src/core/cells/cells.ts
CHANGED
|
@@ -145,6 +145,31 @@ export function initialNotebookState(): NotebookState {
|
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
export interface CreateNewCellAction {
|
|
149
|
+
/** The target cell ID to create a new cell relative to. Can be:
|
|
150
|
+
* - A CellId string for an existing cell
|
|
151
|
+
* - "__end__" to append at the end of the first column
|
|
152
|
+
* - {type: "__end__", columnId} to append at the end of a specific column
|
|
153
|
+
*/
|
|
154
|
+
cellId: CellId | "__end__" | { type: "__end__"; columnId: CellColumnId };
|
|
155
|
+
/** Whether to insert before (true) or after (false) the target cell */
|
|
156
|
+
before: boolean;
|
|
157
|
+
/** Initial code content for the new cell */
|
|
158
|
+
code?: string;
|
|
159
|
+
/** The last executed code for the new cell */
|
|
160
|
+
lastCodeRun?: string;
|
|
161
|
+
/** Timestamp of the last execution */
|
|
162
|
+
lastExecutionTime?: number;
|
|
163
|
+
/** Optional custom ID for the new cell. Auto-generated if not provided */
|
|
164
|
+
newCellId?: CellId;
|
|
165
|
+
/** Whether to focus the new cell after creation */
|
|
166
|
+
autoFocus?: boolean;
|
|
167
|
+
/** If true, skip creation if code already exists */
|
|
168
|
+
skipIfCodeExists?: boolean;
|
|
169
|
+
/** Hide the code in the new cell. This will be initially shown until the cell is blurred for the first time. */
|
|
170
|
+
hideCode?: boolean;
|
|
171
|
+
}
|
|
172
|
+
|
|
148
173
|
/**
|
|
149
174
|
* Actions and reducer for the notebook state.
|
|
150
175
|
*/
|
|
@@ -154,33 +179,7 @@ const {
|
|
|
154
179
|
useActions,
|
|
155
180
|
valueAtom: notebookAtom,
|
|
156
181
|
} = createReducerAndAtoms(initialNotebookState, {
|
|
157
|
-
createNewCell: (
|
|
158
|
-
state,
|
|
159
|
-
action: {
|
|
160
|
-
/** The target cell ID to create a new cell relative to. Can be:
|
|
161
|
-
* - A CellId string for an existing cell
|
|
162
|
-
* - "__end__" to append at the end of the first column
|
|
163
|
-
* - {type: "__end__", columnId} to append at the end of a specific column
|
|
164
|
-
*/
|
|
165
|
-
cellId: CellId | "__end__" | { type: "__end__"; columnId: CellColumnId };
|
|
166
|
-
/** Whether to insert before (true) or after (false) the target cell */
|
|
167
|
-
before: boolean;
|
|
168
|
-
/** Initial code content for the new cell */
|
|
169
|
-
code?: string;
|
|
170
|
-
/** The last executed code for the new cell */
|
|
171
|
-
lastCodeRun?: string;
|
|
172
|
-
/** Timestamp of the last execution */
|
|
173
|
-
lastExecutionTime?: number;
|
|
174
|
-
/** Optional custom ID for the new cell. Auto-generated if not provided */
|
|
175
|
-
newCellId?: CellId;
|
|
176
|
-
/** Whether to focus the new cell after creation */
|
|
177
|
-
autoFocus?: boolean;
|
|
178
|
-
/** If true, skip creation if code already exists */
|
|
179
|
-
skipIfCodeExists?: boolean;
|
|
180
|
-
/** Hide the code in the new cell. This will be initially shown until the cell is blurred for the first time. */
|
|
181
|
-
hideCode?: boolean;
|
|
182
|
-
},
|
|
183
|
-
) => {
|
|
182
|
+
createNewCell: (state, action: CreateNewCellAction) => {
|
|
184
183
|
const {
|
|
185
184
|
cellId,
|
|
186
185
|
before,
|
package/src/core/cells/logs.ts
CHANGED
|
@@ -102,7 +102,7 @@ export function formatLogTimestamp(timestamp: number): string {
|
|
|
102
102
|
try {
|
|
103
103
|
// parse from UTC
|
|
104
104
|
const date = fromUnixTime(timestamp);
|
|
105
|
-
return date.toLocaleTimeString(
|
|
105
|
+
return date.toLocaleTimeString(undefined, {
|
|
106
106
|
hour12: true,
|
|
107
107
|
hour: "numeric",
|
|
108
108
|
minute: "numeric",
|
|
@@ -91,8 +91,10 @@ const HighlightMargin = 250;
|
|
|
91
91
|
export const searchHighlighter = ViewPlugin.fromClass(
|
|
92
92
|
class {
|
|
93
93
|
decorations: DecorationSet;
|
|
94
|
+
readonly view: EditorView;
|
|
94
95
|
|
|
95
|
-
constructor(
|
|
96
|
+
constructor(view: EditorView) {
|
|
97
|
+
this.view = view;
|
|
96
98
|
this.decorations = this.highlight(view.state.field(searchState));
|
|
97
99
|
}
|
|
98
100
|
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
/* Copyright 2024 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
+
import { once } from "@/utils/once";
|
|
3
4
|
import { MarkdownLanguageAdapter } from "./languages/markdown";
|
|
4
5
|
import { PythonLanguageAdapter } from "./languages/python";
|
|
5
6
|
import { SQLLanguageAdapter } from "./languages/sql/sql";
|
|
6
7
|
import type { LanguageAdapter, LanguageAdapterType } from "./types";
|
|
7
8
|
|
|
9
|
+
// Create cached instances
|
|
10
|
+
const createPythonAdapter = once(() => new PythonLanguageAdapter());
|
|
11
|
+
const createMarkdownAdapter = once(() => new MarkdownLanguageAdapter());
|
|
12
|
+
const createSqlAdapter = once(() => new SQLLanguageAdapter());
|
|
13
|
+
|
|
8
14
|
export const LanguageAdapters: Record<LanguageAdapterType, LanguageAdapter> = {
|
|
9
15
|
// Getters to prevent circular dependencies
|
|
10
16
|
get python() {
|
|
11
|
-
return
|
|
17
|
+
return createPythonAdapter();
|
|
12
18
|
},
|
|
13
19
|
get markdown() {
|
|
14
|
-
return
|
|
20
|
+
return createMarkdownAdapter();
|
|
15
21
|
},
|
|
16
22
|
get sql() {
|
|
17
|
-
return
|
|
23
|
+
return createSqlAdapter();
|
|
18
24
|
},
|
|
19
25
|
};
|
|
20
26
|
|
|
@@ -18,13 +18,19 @@ import { getLSPDocument } from "./utils";
|
|
|
18
18
|
|
|
19
19
|
class Snapshotter {
|
|
20
20
|
private documentVersion = 0;
|
|
21
|
+
private readonly getNotebookCode: () => {
|
|
22
|
+
cellIds: CellId[];
|
|
23
|
+
codes: Record<CellId, string>;
|
|
24
|
+
};
|
|
21
25
|
|
|
22
26
|
constructor(
|
|
23
|
-
|
|
27
|
+
getNotebookCode: () => {
|
|
24
28
|
cellIds: CellId[];
|
|
25
29
|
codes: Record<CellId, string>;
|
|
26
30
|
},
|
|
27
|
-
) {
|
|
31
|
+
) {
|
|
32
|
+
this.getNotebookCode = getNotebookCode;
|
|
33
|
+
}
|
|
28
34
|
|
|
29
35
|
/**
|
|
30
36
|
* Map from the global document version to the cell id and version.
|
|
@@ -9,7 +9,7 @@ import { connectionAtom } from "../../../network/connection";
|
|
|
9
9
|
import { dynamicReadonly, isEditorReadonly } from "../extension";
|
|
10
10
|
|
|
11
11
|
function makeStoreWithConnection(
|
|
12
|
-
state: WebSocketState.CONNECTING | WebSocketState.OPEN,
|
|
12
|
+
state: typeof WebSocketState.CONNECTING | typeof WebSocketState.OPEN,
|
|
13
13
|
) {
|
|
14
14
|
const store = createStore();
|
|
15
15
|
store.set(connectionAtom, { state });
|
|
@@ -202,13 +202,25 @@ export const createSelectionLayer = (): Extension =>
|
|
|
202
202
|
* Renders a blinking cursor to indicate the cursor of another user.
|
|
203
203
|
*/
|
|
204
204
|
export class RemoteCursorMarker implements LayerMarker {
|
|
205
|
+
private left: number;
|
|
206
|
+
private top: number;
|
|
207
|
+
private height: number;
|
|
208
|
+
private name: string;
|
|
209
|
+
private colorClassName: string;
|
|
210
|
+
|
|
205
211
|
constructor(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
) {
|
|
212
|
+
left: number,
|
|
213
|
+
top: number,
|
|
214
|
+
height: number,
|
|
215
|
+
name: string,
|
|
216
|
+
colorClassName: string,
|
|
217
|
+
) {
|
|
218
|
+
this.left = left;
|
|
219
|
+
this.top = top;
|
|
220
|
+
this.height = height;
|
|
221
|
+
this.name = name;
|
|
222
|
+
this.colorClassName = colorClassName;
|
|
223
|
+
}
|
|
212
224
|
|
|
213
225
|
draw(): HTMLElement {
|
|
214
226
|
const elt = document.createElement("div");
|
|
@@ -353,16 +365,30 @@ export interface CursorPosition {
|
|
|
353
365
|
|
|
354
366
|
export class AwarenessPlugin implements PluginValue {
|
|
355
367
|
sub: Subscription;
|
|
368
|
+
public view: EditorView;
|
|
369
|
+
public doc: LoroDoc;
|
|
370
|
+
public user: UserState;
|
|
371
|
+
public awareness: Awareness<AwarenessState>;
|
|
372
|
+
private getTextFromDoc: (doc: LoroDoc) => LoroText;
|
|
373
|
+
private scopeId: ScopeId;
|
|
374
|
+
private getUserId?: () => Uid;
|
|
356
375
|
|
|
357
376
|
constructor(
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
377
|
+
view: EditorView,
|
|
378
|
+
doc: LoroDoc,
|
|
379
|
+
user: UserState,
|
|
380
|
+
awareness: Awareness<AwarenessState>,
|
|
381
|
+
getTextFromDoc: (doc: LoroDoc) => LoroText,
|
|
382
|
+
scopeId: ScopeId,
|
|
383
|
+
getUserId?: () => Uid,
|
|
365
384
|
) {
|
|
385
|
+
this.view = view;
|
|
386
|
+
this.doc = doc;
|
|
387
|
+
this.user = user;
|
|
388
|
+
this.awareness = awareness;
|
|
389
|
+
this.getTextFromDoc = getTextFromDoc;
|
|
390
|
+
this.scopeId = scopeId;
|
|
391
|
+
this.getUserId = getUserId;
|
|
366
392
|
this.sub = this.doc.subscribe((e) => {
|
|
367
393
|
if (e.by === "local") {
|
|
368
394
|
// update remote cursor position
|
|
@@ -435,12 +461,21 @@ export class AwarenessPlugin implements PluginValue {
|
|
|
435
461
|
}
|
|
436
462
|
export class RemoteAwarenessPlugin implements PluginValue {
|
|
437
463
|
_awarenessListener?: AwarenessListener;
|
|
464
|
+
public view: EditorView;
|
|
465
|
+
public doc: LoroDoc;
|
|
466
|
+
public awareness: Awareness<AwarenessState>;
|
|
467
|
+
private scopeId: ScopeId;
|
|
468
|
+
|
|
438
469
|
constructor(
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
470
|
+
view: EditorView,
|
|
471
|
+
doc: LoroDoc,
|
|
472
|
+
awareness: Awareness<AwarenessState>,
|
|
473
|
+
scopeId: ScopeId,
|
|
443
474
|
) {
|
|
475
|
+
this.view = view;
|
|
476
|
+
this.doc = doc;
|
|
477
|
+
this.awareness = awareness;
|
|
478
|
+
this.scopeId = scopeId;
|
|
444
479
|
const listener: AwarenessListener = async (arg, origin) => {
|
|
445
480
|
if (origin === "local") {
|
|
446
481
|
return;
|
|
@@ -40,13 +40,21 @@ export const loroSyncAnnotation = Annotation.define();
|
|
|
40
40
|
export class LoroSyncPluginValue implements PluginValue {
|
|
41
41
|
sub?: Subscription;
|
|
42
42
|
private isInitDispatch = false;
|
|
43
|
+
private view: EditorView;
|
|
44
|
+
private doc: LoroDoc;
|
|
45
|
+
private docPath: string[];
|
|
46
|
+
private getTextFromDoc: (doc: LoroDoc) => LoroText;
|
|
43
47
|
|
|
44
48
|
constructor(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
view: EditorView,
|
|
50
|
+
doc: LoroDoc,
|
|
51
|
+
docPath: string[],
|
|
52
|
+
getTextFromDoc: (doc: LoroDoc) => LoroText,
|
|
49
53
|
) {
|
|
54
|
+
this.view = view;
|
|
55
|
+
this.doc = doc;
|
|
56
|
+
this.docPath = docPath;
|
|
57
|
+
this.getTextFromDoc = getTextFromDoc;
|
|
50
58
|
this.sub = doc.subscribe(this.onRemoteUpdate);
|
|
51
59
|
Promise.resolve().then(() => {
|
|
52
60
|
this.isInitDispatch = true;
|
|
@@ -82,6 +82,10 @@ export const editorFontSizeAtom = atom<number>((get) => {
|
|
|
82
82
|
return get(resolvedMarimoConfigAtom).display.code_editor_font_size;
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
+
export const localeAtom = atom<string | null | undefined>((get) => {
|
|
86
|
+
return get(resolvedMarimoConfigAtom).display.locale;
|
|
87
|
+
});
|
|
88
|
+
|
|
85
89
|
export function isAiEnabled(config: UserConfig) {
|
|
86
90
|
return (
|
|
87
91
|
Boolean(config.ai?.models?.chat_model) ||
|
|
@@ -452,10 +452,13 @@ export class HotkeyProvider implements IHotkeyProvider {
|
|
|
452
452
|
return new HotkeyProvider(DEFAULT_HOT_KEY, { platform });
|
|
453
453
|
}
|
|
454
454
|
|
|
455
|
+
private hotkeys: Record<HotkeyAction, Hotkey>;
|
|
456
|
+
|
|
455
457
|
constructor(
|
|
456
|
-
|
|
458
|
+
hotkeys: Record<HotkeyAction, Hotkey>,
|
|
457
459
|
options: HotkeyProviderOptions = {},
|
|
458
460
|
) {
|
|
461
|
+
this.hotkeys = hotkeys;
|
|
459
462
|
this.platform = options.platform ?? resolvePlatform();
|
|
460
463
|
this.mod = this.platform === "mac" ? "Cmd" : "Ctrl";
|
|
461
464
|
}
|
|
@@ -503,13 +506,14 @@ export class HotkeyProvider implements IHotkeyProvider {
|
|
|
503
506
|
}
|
|
504
507
|
|
|
505
508
|
export class OverridingHotkeyProvider extends HotkeyProvider {
|
|
509
|
+
private readonly overrides: Partial<Record<HotkeyAction, string | undefined>>;
|
|
510
|
+
|
|
506
511
|
constructor(
|
|
507
|
-
|
|
508
|
-
Record<HotkeyAction, string | undefined>
|
|
509
|
-
>,
|
|
512
|
+
overrides: Partial<Record<HotkeyAction, string | undefined>>,
|
|
510
513
|
options: HotkeyProviderOptions = {},
|
|
511
514
|
) {
|
|
512
515
|
super(DEFAULT_HOT_KEY, options);
|
|
516
|
+
this.overrides = overrides;
|
|
513
517
|
}
|
|
514
518
|
|
|
515
519
|
override getHotkey(action: HotkeyAction): ResolvedHotkey {
|