@backmatter/studio 0.0.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/chunks/UiKitPage-CgNMOqfE.js +172 -0
- package/dist/chunks/WorkspaceRoutes-DgRtdie8.js +87297 -0
- package/dist/chunks/abap-Y8Dl9g_6.js +6 -0
- package/dist/chunks/actionscript-3-DQVEcJUW.js +6 -0
- package/dist/chunks/ada-vP6ak0IW.js +6 -0
- package/dist/chunks/andromeeda-BbmzSJq1.js +4 -0
- package/dist/chunks/angular-html-DPB4Rf0C.js +32 -0
- package/dist/chunks/angular-ts-CTOR2ofC.js +21 -0
- package/dist/chunks/apache-BUjz-sD2.js +6 -0
- package/dist/chunks/apex-OyTfjCYK.js +6 -0
- package/dist/chunks/apl-CjNiDgad.js +16 -0
- package/dist/chunks/applescript-BPx7YFFu.js +6 -0
- package/dist/chunks/ara-Z2fSOxSw.js +6 -0
- package/dist/chunks/asciidoc-C1T9ziH6.js +6 -0
- package/dist/chunks/asm-BTWLY5ym.js +6 -0
- package/dist/chunks/astro-CFFExE8Q.js +18 -0
- package/dist/chunks/aurora-x-BwoVEUWZ.js +4 -0
- package/dist/chunks/awk-Fb0P9dkn.js +6 -0
- package/dist/chunks/ayu-dark-DJoqd4M9.js +4 -0
- package/dist/chunks/ayu-light-BzXEJRJ-.js +4 -0
- package/dist/chunks/ayu-mirage-BJ2oZGzi.js +4 -0
- package/dist/chunks/ballerina-oZK-YekG.js +6 -0
- package/dist/chunks/bat-0FvbqU9S.js +6 -0
- package/dist/chunks/beancount-DqJEb89h.js +6 -0
- package/dist/chunks/berry-DODBq_Ff.js +6 -0
- package/dist/chunks/bibtex-EULQRLY5.js +6 -0
- package/dist/chunks/bicep-BorU73w0.js +6 -0
- package/dist/chunks/bird2-CIjBSNj3.js +6 -0
- package/dist/chunks/blade-D0HyNvCw.js +20 -0
- package/dist/chunks/bsl-NkNNwerW.js +8 -0
- package/dist/chunks/c-eeMepfLm.js +6 -0
- package/dist/chunks/c3-BY5XW5ym.js +6 -0
- package/dist/chunks/cadence-02UX7mW8.js +6 -0
- package/dist/chunks/cairo-DM6WF2e3.js +8 -0
- package/dist/chunks/catppuccin-frappe-D3cH2rXe.js +4 -0
- package/dist/chunks/catppuccin-latte-C0LRGUW4.js +4 -0
- package/dist/chunks/catppuccin-macchiato-c5wQ11TT.js +4 -0
- package/dist/chunks/catppuccin-mocha-WMD6Qvya.js +4 -0
- package/dist/chunks/clarity-PKm5CwqM.js +6 -0
- package/dist/chunks/clojure-CXJfHrL3.js +6 -0
- package/dist/chunks/cmake-BJz8BOTU.js +6 -0
- package/dist/chunks/cobol-HihOMwht.js +10 -0
- package/dist/chunks/codeowners-Bt9yU6NX.js +6 -0
- package/dist/chunks/codeql-DHkodjjI.js +6 -0
- package/dist/chunks/coffee-DGBR_nr_.js +8 -0
- package/dist/chunks/common-lisp-EVqT9Zhp.js +6 -0
- package/dist/chunks/coq-B0L9upzn.js +6 -0
- package/dist/chunks/cpp-Cj177cuW.js +18 -0
- package/dist/chunks/crystal-CRJyc4G-.js +18 -0
- package/dist/chunks/csharp-CCgA4A09.js +6 -0
- package/dist/chunks/css-CECN5uSL.js +6 -0
- package/dist/chunks/csv-CmYOceLb.js +6 -0
- package/dist/chunks/cue-ZzumE7IT.js +6 -0
- package/dist/chunks/cypher-jpdmjtA6.js +6 -0
- package/dist/chunks/d-CBagWSwH.js +6 -0
- package/dist/chunks/dark-plus-pUHDTVV0.js +4 -0
- package/dist/chunks/dart-6ObCrKr9.js +6 -0
- package/dist/chunks/dashboard-XKKZuJGm.js +1736 -0
- package/dist/chunks/dax-CcDT-8dH.js +6 -0
- package/dist/chunks/define-studio-BYtYDGLX.js +33 -0
- package/dist/chunks/desktop-B93p9R9O.js +6 -0
- package/dist/chunks/diff-BxzP2J8R.js +6 -0
- package/dist/chunks/docker-CsHqm9tx.js +6 -0
- package/dist/chunks/dotenv-BMjVjUL1.js +6 -0
- package/dist/chunks/dracula-BtZx2Kac.js +4 -0
- package/dist/chunks/dracula-soft-BKa-aqBv.js +4 -0
- package/dist/chunks/dream-maker-PAx17jaB.js +6 -0
- package/dist/chunks/edge-BYQkOzbF.js +12 -0
- package/dist/chunks/elixir-Dh036GMp.js +8 -0
- package/dist/chunks/elm-BtNbw_Cd.js +8 -0
- package/dist/chunks/emacs-lisp-Cfxdx5D-.js +6 -0
- package/dist/chunks/erb-ScVOXVpH.js +10 -0
- package/dist/chunks/erlang-DNcDT8Hi.js +8 -0
- package/dist/chunks/everforest-dark-DMCBqXCK.js +4 -0
- package/dist/chunks/everforest-light-BbXl82Em.js +4 -0
- package/dist/chunks/fennel-N4WcXuKx.js +6 -0
- package/dist/chunks/fish-BTDEUgqH.js +6 -0
- package/dist/chunks/fluent-BMXUxfv1.js +6 -0
- package/dist/chunks/fortran-fixed-form-B67KFkXH.js +8 -0
- package/dist/chunks/fortran-free-form-CwqYvCLJ.js +6 -0
- package/dist/chunks/fsharp-CYOiIVNx.js +8 -0
- package/dist/chunks/gdresource-CvCIUjhi.js +10 -0
- package/dist/chunks/gdscript-DSAxJ_aS.js +6 -0
- package/dist/chunks/gdshader-Bk8fF6yr.js +6 -0
- package/dist/chunks/genie-DzUvd7U9.js +6 -0
- package/dist/chunks/gherkin-DHRaV0YP.js +6 -0
- package/dist/chunks/git-commit-Bd32YZ0K.js +8 -0
- package/dist/chunks/git-rebase-ZWUFO_T4.js +8 -0
- package/dist/chunks/github-dark-DenFmJkN.js +4 -0
- package/dist/chunks/github-dark-default-BJPUVz4H.js +4 -0
- package/dist/chunks/github-dark-dimmed-DUshB20C.js +4 -0
- package/dist/chunks/github-dark-high-contrast-D3aGCnF8.js +4 -0
- package/dist/chunks/github-light-JYsPkUQd.js +4 -0
- package/dist/chunks/github-light-default-D99KPAby.js +4 -0
- package/dist/chunks/github-light-high-contrast-BbmZE-Mp.js +4 -0
- package/dist/chunks/gleam-Bv284lvN.js +6 -0
- package/dist/chunks/glimmer-js-DkxNrfPT.js +14 -0
- package/dist/chunks/glimmer-ts-D6YZEmK_.js +14 -0
- package/dist/chunks/glsl-CkUcVZNK.js +8 -0
- package/dist/chunks/gn-XtJxiLa4.js +6 -0
- package/dist/chunks/gnuplot-yPG9-sE_.js +6 -0
- package/dist/chunks/go-CvFNMTvu.js +6 -0
- package/dist/chunks/graphql-CBu2ehBn.js +14 -0
- package/dist/chunks/groovy-CJQTphOW.js +6 -0
- package/dist/chunks/gruvbox-dark-hard-C5HOtKIh.js +4 -0
- package/dist/chunks/gruvbox-dark-medium-FVgwJHuz.js +4 -0
- package/dist/chunks/gruvbox-dark-soft-B46F314v.js +4 -0
- package/dist/chunks/gruvbox-light-hard-CJD38wDZ.js +4 -0
- package/dist/chunks/gruvbox-light-medium-BlIhMYTA.js +4 -0
- package/dist/chunks/gruvbox-light-soft-DoPHyLVZ.js +4 -0
- package/dist/chunks/hack-ItRNKiEb.js +10 -0
- package/dist/chunks/haml-NZLVzu_R.js +10 -0
- package/dist/chunks/handlebars-mxStpSE7.js +14 -0
- package/dist/chunks/haskell-WeIwNIP6.js +6 -0
- package/dist/chunks/haxe-TztHsm5T.js +6 -0
- package/dist/chunks/hcl-D438OF-I.js +6 -0
- package/dist/chunks/hjson-DYBUbqOl.js +6 -0
- package/dist/chunks/hlsl-Bk8TCZNL.js +6 -0
- package/dist/chunks/horizon-CJQ10nlf.js +4 -0
- package/dist/chunks/horizon-bright-CdkBZOMB.js +4 -0
- package/dist/chunks/houston-BDYrDoDW.js +4 -0
- package/dist/chunks/html-B50bmoVb.js +10 -0
- package/dist/chunks/html-derivative-C6bxFbFW.js +8 -0
- package/dist/chunks/http-DLvAkeD-.js +14 -0
- package/dist/chunks/hurl-CgkFN90t.js +12 -0
- package/dist/chunks/hxml-GbqSQCLa.js +8 -0
- package/dist/chunks/hy-Brt5EZ7-.js +6 -0
- package/dist/chunks/imba-CimUv-Uh.js +6 -0
- package/dist/chunks/index-CFAIR8GH.js +18924 -0
- package/dist/chunks/ini-BZIuRIvJ.js +6 -0
- package/dist/chunks/java-DY6VlHhP.js +6 -0
- package/dist/chunks/javascript-C25yR2R2.js +6 -0
- package/dist/chunks/jinja-CFW5uAwY.js +11 -0
- package/dist/chunks/jison-DdreslRX.js +8 -0
- package/dist/chunks/json-DxJze_jm.js +6 -0
- package/dist/chunks/json5-BT4Fjg39.js +6 -0
- package/dist/chunks/jsonc-CHjZD8gR.js +6 -0
- package/dist/chunks/jsonl-BGuvDmy9.js +6 -0
- package/dist/chunks/jsonnet-Bx2cfsXg.js +6 -0
- package/dist/chunks/jssm-BcADi6EI.js +6 -0
- package/dist/chunks/jsx-BtKADgXT.js +6 -0
- package/dist/chunks/julia-CZiKXNNP.js +16 -0
- package/dist/chunks/just-CEK2SJ_k.js +18 -0
- package/dist/chunks/kanagawa-dragon-CiKur4Hl.js +4 -0
- package/dist/chunks/kanagawa-lotus-BKu-smKu.js +4 -0
- package/dist/chunks/kanagawa-wave-CQwozSzG.js +4 -0
- package/dist/chunks/kdl-BNOv9TC3.js +6 -0
- package/dist/chunks/kotlin-ByBMgTeR.js +6 -0
- package/dist/chunks/kusto-DH_XitHS.js +6 -0
- package/dist/chunks/laserwave-6a00oqik.js +4 -0
- package/dist/chunks/latex-B8Egmqc5.js +8 -0
- package/dist/chunks/lean-BnVxaZxY.js +6 -0
- package/dist/chunks/less-B1GLI2Di.js +6 -0
- package/dist/chunks/light-plus-CZuVqSLX.js +4 -0
- package/dist/chunks/liquid-CHzkx3jT.js +14 -0
- package/dist/chunks/llvm-Bk2XctFf.js +6 -0
- package/dist/chunks/log-Al8wyEFV.js +6 -0
- package/dist/chunks/logo-DBa4JDzV.js +6 -0
- package/dist/chunks/lua-Bp3IRv7I.js +8 -0
- package/dist/chunks/luau-UQyhudEE.js +6 -0
- package/dist/chunks/make-CsMclxtr.js +6 -0
- package/dist/chunks/markdown-CrScaQ96.js +6 -0
- package/dist/chunks/marko-CJBA24Ri.js +14 -0
- package/dist/chunks/material-theme-D6KBX41T.js +4 -0
- package/dist/chunks/material-theme-darker-CkRroheE.js +4 -0
- package/dist/chunks/material-theme-lighter-BUBw43Yz.js +4 -0
- package/dist/chunks/material-theme-ocean-ClGX14Ja.js +4 -0
- package/dist/chunks/material-theme-palenight-C1RVm8K1.js +4 -0
- package/dist/chunks/matlab-BOAaUVP0.js +6 -0
- package/dist/chunks/mdc-C9YSUwVC.js +12 -0
- package/dist/chunks/mdx-BOhZZUJ8.js +6 -0
- package/dist/chunks/mermaid-C3rz4dYh.js +6 -0
- package/dist/chunks/min-dark-C7ak0t6c.js +4 -0
- package/dist/chunks/min-light-CKFxVcPp.js +4 -0
- package/dist/chunks/mipsasm-CTx18fBl.js +6 -0
- package/dist/chunks/mojo-EIZIZRTQ.js +6 -0
- package/dist/chunks/monokai-C1KBYcO0.js +4 -0
- package/dist/chunks/moonbit-B1TV0fG3.js +6 -0
- package/dist/chunks/move-Db4ltDq1.js +6 -0
- package/dist/chunks/narrat-DmhDCBs-.js +6 -0
- package/dist/chunks/nextflow-47kAzSl1.js +8 -0
- package/dist/chunks/nextflow-groovy-Drz_2V0j.js +6 -0
- package/dist/chunks/nginx-D7O4WoB1.js +8 -0
- package/dist/chunks/night-owl-Bm2rzalh.js +4 -0
- package/dist/chunks/night-owl-light-CBI5u5kw.js +4 -0
- package/dist/chunks/nim-QAjRdh9w.js +20 -0
- package/dist/chunks/nix-fTRXMGic.js +9 -0
- package/dist/chunks/nord-CC5OiUXg.js +4 -0
- package/dist/chunks/nushell-BGCPRlV5.js +6 -0
- package/dist/chunks/objective-c-Itk8tzmv.js +6 -0
- package/dist/chunks/objective-cpp-DGt5UKRO.js +6 -0
- package/dist/chunks/ocaml-eSVK32Eg.js +6 -0
- package/dist/chunks/odin-BItnF517.js +6 -0
- package/dist/chunks/one-dark-pro-DTA3VF0_.js +4 -0
- package/dist/chunks/one-light-LkMrt1Cf.js +4 -0
- package/dist/chunks/openscad-Sp5uZ6f2.js +6 -0
- package/dist/chunks/pascal-xy8pJNns.js +6 -0
- package/dist/chunks/perl-DkVrgJBg.js +16 -0
- package/dist/chunks/php-BIzsF_5x.js +18 -0
- package/dist/chunks/pkl-C-zSNmaA.js +6 -0
- package/dist/chunks/plastic-CSTz3KZp.js +4 -0
- package/dist/chunks/plsql-pVbGZfOv.js +6 -0
- package/dist/chunks/po-BNfHvqmm.js +6 -0
- package/dist/chunks/poimandres-C-VADXHD.js +4 -0
- package/dist/chunks/polar-CAZahv3u.js +6 -0
- package/dist/chunks/postcss-05aHdL-n.js +6 -0
- package/dist/chunks/powerquery-DI9HkTvs.js +6 -0
- package/dist/chunks/powershell-Clc4ydu-.js +6 -0
- package/dist/chunks/prisma-FZjmVtSl.js +6 -0
- package/dist/chunks/prolog-C5-yg4TO.js +6 -0
- package/dist/chunks/proto-C7QgialS.js +6 -0
- package/dist/chunks/pug-XOw9Q1Ho.js +12 -0
- package/dist/chunks/puppet-CUJHmnxV.js +6 -0
- package/dist/chunks/purescript-rUfGld-4.js +6 -0
- package/dist/chunks/python-BFNSHbwJ.js +6 -0
- package/dist/chunks/qml-rTNXsquU.js +8 -0
- package/dist/chunks/qmldir-BInDYbpo.js +6 -0
- package/dist/chunks/qss-AeJTysr_.js +6 -0
- package/dist/chunks/r-CSmzDPi7.js +6 -0
- package/dist/chunks/racket-B83wSAja.js +6 -0
- package/dist/chunks/raku-nEQ4ZJJ7.js +6 -0
- package/dist/chunks/razor-Ci8D0dQK.js +10 -0
- package/dist/chunks/red-7y8PH7HH.js +4 -0
- package/dist/chunks/reg-m_s_Kiip.js +6 -0
- package/dist/chunks/regexp-BazyLpPg.js +6 -0
- package/dist/chunks/rel-BcRfyd6Q.js +6 -0
- package/dist/chunks/riscv-Ce8MAQLP.js +6 -0
- package/dist/chunks/ron-DCEEQypA.js +6 -0
- package/dist/chunks/rose-pine-BKc3yVeu.js +4 -0
- package/dist/chunks/rose-pine-dawn-BulJcPZT.js +4 -0
- package/dist/chunks/rose-pine-moon-j6jiXKV8.js +4 -0
- package/dist/chunks/rosmsg-Cz0w1km8.js +6 -0
- package/dist/chunks/rst-DM32Wy3O.js +22 -0
- package/dist/chunks/ruby-BeqCs27h.js +30 -0
- package/dist/chunks/rust-CLzF9zIN.js +6 -0
- package/dist/chunks/sas-fpEvgATw.js +8 -0
- package/dist/chunks/sass-DxHp5rTx.js +6 -0
- package/dist/chunks/scala-D4grkFkl.js +6 -0
- package/dist/chunks/scheme-BCRWuEm4.js +6 -0
- package/dist/chunks/scss-B1FaCqwR.js +8 -0
- package/dist/chunks/sdbl-B7T8abf4.js +6 -0
- package/dist/chunks/shaderlab-Cr62-Wb4.js +8 -0
- package/dist/chunks/shellscript-InADTalH.js +6 -0
- package/dist/chunks/shellsession-DiDJNQdy.js +8 -0
- package/dist/chunks/slack-dark-i7wN4OET.js +4 -0
- package/dist/chunks/slack-ochin-ndHf0LoP.js +4 -0
- package/dist/chunks/smalltalk-BlI1_OkM.js +6 -0
- package/dist/chunks/snazzy-light-BlSJXAu4.js +4 -0
- package/dist/chunks/solarized-dark-UTmkh7lw.js +4 -0
- package/dist/chunks/solarized-light-BheCkDPT.js +4 -0
- package/dist/chunks/solidity-DUWnFhS6.js +6 -0
- package/dist/chunks/soy-C1-6njHa.js +8 -0
- package/dist/chunks/sparql-B0KWFEri.js +8 -0
- package/dist/chunks/splunk-CRXR8A9s.js +6 -0
- package/dist/chunks/sql-Cn_v3PB0.js +6 -0
- package/dist/chunks/ssh-config-DP-hNVbF.js +6 -0
- package/dist/chunks/stata-B8c5fTjX.js +8 -0
- package/dist/chunks/stylus-CyKEU1Ej.js +6 -0
- package/dist/chunks/surrealql-CQi7GQN7.js +8 -0
- package/dist/chunks/svelte-rYri41WT.js +14 -0
- package/dist/chunks/swift-DJpUqPLg.js +6 -0
- package/dist/chunks/synthwave-84-NU3C_KFZ.js +4 -0
- package/dist/chunks/system-verilog-BCm7smPJ.js +6 -0
- package/dist/chunks/systemd-C-4qm6XH.js +6 -0
- package/dist/chunks/talonscript-CFF3LF_O.js +6 -0
- package/dist/chunks/tasl-Cg_WBUAe.js +6 -0
- package/dist/chunks/tcl-DN7buRTF.js +6 -0
- package/dist/chunks/templ-Crs9Ui8q.js +12 -0
- package/dist/chunks/terraform-DGvcn9zM.js +6 -0
- package/dist/chunks/tex-AHxmLTL0.js +8 -0
- package/dist/chunks/tokyo-night-DP4TmcQl.js +4 -0
- package/dist/chunks/toml-DY62mUL_.js +6 -0
- package/dist/chunks/ts-tags-ioVe2PKw.js +41 -0
- package/dist/chunks/tsv-BtvSkaG0.js +6 -0
- package/dist/chunks/tsx-B8rCNbgL.js +6 -0
- package/dist/chunks/turtle-_H59FV7D.js +6 -0
- package/dist/chunks/twig-DwV2Fi4L.js +18 -0
- package/dist/chunks/typescript-RycA9KXf.js +6 -0
- package/dist/chunks/typespec-DWqp-kUU.js +6 -0
- package/dist/chunks/typst-D_1QKWns.js +6 -0
- package/dist/chunks/v-BPCNiyYe.js +6 -0
- package/dist/chunks/vala-uxaPR7d1.js +6 -0
- package/dist/chunks/vb-D8_c5-KN.js +6 -0
- package/dist/chunks/verilog-B-bybjPF.js +6 -0
- package/dist/chunks/vesper-BckBta1U.js +4 -0
- package/dist/chunks/vhdl-CUlNa8ac.js +6 -0
- package/dist/chunks/viml-DsfA-sWm.js +6 -0
- package/dist/chunks/vitesse-black-BoGvW84i.js +4 -0
- package/dist/chunks/vitesse-dark-Cym-eLtO.js +4 -0
- package/dist/chunks/vitesse-light-CcmG315c.js +4 -0
- package/dist/chunks/vue-DXEmyXn9.js +31 -0
- package/dist/chunks/vue-html-j9xNEdu3.js +8 -0
- package/dist/chunks/vue-vine-D41-N99t.js +18 -0
- package/dist/chunks/vyper-CPQuu50u.js +6 -0
- package/dist/chunks/wasm-BBXxrAl7.js +6 -0
- package/dist/chunks/wasm-DQxwEHae.js +7 -0
- package/dist/chunks/wenyan-pbVjoM9_.js +6 -0
- package/dist/chunks/wgsl-DY4iK1q1.js +6 -0
- package/dist/chunks/wikitext-Z-MoUasO.js +6 -0
- package/dist/chunks/wit-CQMQOlTg.js +6 -0
- package/dist/chunks/wolfram-Dz4KXISs.js +6 -0
- package/dist/chunks/xml-C2J0sS9M.js +8 -0
- package/dist/chunks/xsl-BmSZphgC.js +8 -0
- package/dist/chunks/yaml-DaO7k5B1.js +6 -0
- package/dist/chunks/zenscript-CxBjpf9c.js +6 -0
- package/dist/chunks/zig-Vm0PO9wB.js +6 -0
- package/dist/dashboard.js +8 -0
- package/dist/define.js +4 -0
- package/dist/index.js +317 -0
- package/dist/studio.css +2272 -0
- package/dist/styles.js +1 -0
- package/package.json +88 -0
- package/prose-node-shims/fs.ts +6 -0
- package/prose-node-shims/path.ts +16 -0
- package/prose-node-shims/sharp.ts +4 -0
- package/prose-ui-node-shim.ts +26 -0
- package/src/App.tsx +173 -0
- package/src/WorkspaceRoutes.tsx +38 -0
- package/src/api.ts +833 -0
- package/src/auth-client.ts +15 -0
- package/src/chat/ChangeCard.tsx +330 -0
- package/src/chat/ChatBar.tsx +238 -0
- package/src/chat/ChatMessage.tsx +478 -0
- package/src/chat/ChatPanel.tsx +406 -0
- package/src/chat/ChatProvider.tsx +661 -0
- package/src/chat/Composer.tsx +461 -0
- package/src/chat/DocListCard.tsx +322 -0
- package/src/chat/LiveStatus.tsx +83 -0
- package/src/chat/MentionPopover.tsx +164 -0
- package/src/chat/ModelPicker.tsx +113 -0
- package/src/chat/Shimmer.tsx +39 -0
- package/src/chat/ThreadHistory.tsx +268 -0
- package/src/chat/chat-context.ts +41 -0
- package/src/chat/chat-helpers.ts +402 -0
- package/src/chat/chat-state.ts +59 -0
- package/src/chat/icons.tsx +171 -0
- package/src/chat/useStickToBottom.ts +110 -0
- package/src/chrome/AppShell.tsx +100 -0
- package/src/chrome/AppSidebar.tsx +305 -0
- package/src/chrome/CommandPalette.tsx +559 -0
- package/src/chrome/ContentApiPopover.tsx +215 -0
- package/src/chrome/EditorActionsContext.tsx +63 -0
- package/src/chrome/EditorFocusContext.tsx +80 -0
- package/src/chrome/EditorStatusContext.tsx +84 -0
- package/src/chrome/NavItem.tsx +75 -0
- package/src/chrome/OpenSiteButton.tsx +148 -0
- package/src/chrome/StatusBar.tsx +73 -0
- package/src/chrome/UserMenu.tsx +130 -0
- package/src/chrome/WorkspaceNavContext.tsx +60 -0
- package/src/chrome/WorkspaceStatusBar.tsx +940 -0
- package/src/chrome/content-api-url.ts +111 -0
- package/src/chrome/content-type-groups.ts +32 -0
- package/src/chrome/hotkeys.ts +79 -0
- package/src/chrome/icons.tsx +191 -0
- package/src/chrome/open-site.ts +30 -0
- package/src/chrome/status-bar-action.ts +24 -0
- package/src/components/AppChromeContext.tsx +32 -0
- package/src/components/Shell.tsx +18 -0
- package/src/components/WorkspaceSwitcher.tsx +345 -0
- package/src/content-blocks/index.tsx +262 -0
- package/src/css.d.ts +2 -0
- package/src/dashboard.ts +5 -0
- package/src/define-studio.tsx +98 -0
- package/src/define.ts +12 -0
- package/src/index.css +123 -0
- package/src/index.ts +19 -0
- package/src/last-user.ts +40 -0
- package/src/last-workspace.ts +57 -0
- package/src/mcp/McpConnectorsPanel.tsx +872 -0
- package/src/mcp/parse-json.ts +52 -0
- package/src/pages/AcceptInvitePage.tsx +99 -0
- package/src/pages/BlockSettingsDialog.tsx +303 -0
- package/src/pages/BlocksList.tsx +402 -0
- package/src/pages/BodyProse.tsx +236 -0
- package/src/pages/DocEditorPage.tsx +1394 -0
- package/src/pages/EmbedChatPage.tsx +110 -0
- package/src/pages/EmbedPublishPage.tsx +259 -0
- package/src/pages/EnterPage.tsx +96 -0
- package/src/pages/GithubConnectPage.tsx +142 -0
- package/src/pages/LegacyWorkspaceRedirect.tsx +57 -0
- package/src/pages/LoginPage.tsx +335 -0
- package/src/pages/NewWorkspacePage.tsx +74 -0
- package/src/pages/RenderedBody.tsx +598 -0
- package/src/pages/ResumeHome.tsx +18 -0
- package/src/pages/SelectionBar.tsx +277 -0
- package/src/pages/SettingsGeneralPage.tsx +403 -0
- package/src/pages/SettingsGithubPage.tsx +277 -0
- package/src/pages/SettingsLayout.tsx +127 -0
- package/src/pages/SettingsMcpPage.tsx +30 -0
- package/src/pages/SettingsSchemaPage.tsx +93 -0
- package/src/pages/SettingsUsersPage.tsx +363 -0
- package/src/pages/TypeDocsPage.tsx +225 -0
- package/src/pages/UiKitPage.tsx +331 -0
- package/src/pages/UserSettingsPage.tsx +94 -0
- package/src/pages/WorkspaceHomeRedirect.tsx +17 -0
- package/src/pages/WorkspaceLayout.tsx +103 -0
- package/src/pages/WorkspacesPage.tsx +35 -0
- package/src/pages/blocks-list.ts +73 -0
- package/src/pages/body-blocks.ts +233 -0
- package/src/pages/body-mdx.tsx +82 -0
- package/src/pages/compile-body.ts +37 -0
- package/src/pages/host-env.ts +22 -0
- package/src/pages/html-to-markdown.ts +99 -0
- package/src/pages/preview-bridge.ts +46 -0
- package/src/pages/preview-split.ts +30 -0
- package/src/pages/preview-url.ts +92 -0
- package/src/pages/selection-format.ts +179 -0
- package/src/pages/type-docs.ts +9 -0
- package/src/replica/BootstrapSplash.tsx +80 -0
- package/src/replica/ReplicaProvider.tsx +267 -0
- package/src/replica/cache.ts +30 -0
- package/src/replica/idb.ts +89 -0
- package/src/replica/instance.ts +39 -0
- package/src/replica/pull.ts +23 -0
- package/src/replica/store.ts +497 -0
- package/src/replica/sync-cache.ts +51 -0
- package/src/replica/types.ts +119 -0
- package/src/replica/useReplica.ts +13 -0
- package/src/site.tsx +230 -0
- package/src/studio-config.ts +81 -0
- package/src/styles/themes.ts +49 -0
- package/src/styles/tokens.stylex.ts +58 -0
- package/src/styles.ts +11 -0
- package/src/theme/AccentOverride.tsx +29 -0
- package/src/theme/ThemeProvider.tsx +130 -0
- package/src/theme/apply-theme-class.ts +12 -0
- package/src/ui/BackLink.tsx +28 -0
- package/src/ui/Button.tsx +167 -0
- package/src/ui/ConfirmDialog.tsx +141 -0
- package/src/ui/Field.tsx +45 -0
- package/src/ui/Input.tsx +183 -0
- package/src/ui/ListRow.tsx +88 -0
- package/src/ui/Page.tsx +151 -0
- package/src/ui/Text.tsx +77 -0
- package/src/ui/Tooltip.tsx +85 -0
- package/src/ui/popup.ts +216 -0
- package/src/workspace/permissions.ts +17 -0
- package/src/workspace/types.ts +12 -0
- package/src/workspace-path.ts +98 -0
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
// packages/studio/src/pages/RenderedBody.tsx
|
|
2
|
+
import {
|
|
3
|
+
forwardRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useImperativeHandle,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
type KeyboardEvent,
|
|
10
|
+
type ReactNode,
|
|
11
|
+
type Ref,
|
|
12
|
+
} from "react";
|
|
13
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
14
|
+
import * as stylex from "@stylexjs/stylex";
|
|
15
|
+
import type { BlockSnapshot } from "../api";
|
|
16
|
+
import { ContentBlockView, contentBlockFields, contentBlockLabel, contentBlockProps } from "../content-blocks";
|
|
17
|
+
import { colors, radius, space, type } from "../styles/tokens.stylex";
|
|
18
|
+
import {
|
|
19
|
+
blockFromMarkdown,
|
|
20
|
+
blocksFromSource,
|
|
21
|
+
codeParts,
|
|
22
|
+
joinBlocks,
|
|
23
|
+
jsxBlockSource,
|
|
24
|
+
jsxWithProps,
|
|
25
|
+
type BodyBlock,
|
|
26
|
+
} from "./body-blocks";
|
|
27
|
+
import { editorMdxComponents } from "./body-mdx";
|
|
28
|
+
import { compileBody } from "./compile-body";
|
|
29
|
+
import { BlockSettingsDialog } from "./BlockSettingsDialog";
|
|
30
|
+
import { markdownFromEditable } from "./html-to-markdown";
|
|
31
|
+
import { SelectionBar, type FormatSelection } from "./SelectionBar";
|
|
32
|
+
import {
|
|
33
|
+
applyBlockFormat,
|
|
34
|
+
applyLink,
|
|
35
|
+
blockFormatOf,
|
|
36
|
+
marksAt,
|
|
37
|
+
placeCaretAtEnd,
|
|
38
|
+
toggleInline,
|
|
39
|
+
type BlockFormat,
|
|
40
|
+
} from "./selection-format";
|
|
41
|
+
|
|
42
|
+
export type RenderedBodyHandle = {
|
|
43
|
+
insert: (markdown: string) => void;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const RenderedBody = forwardRef<
|
|
47
|
+
RenderedBodyHandle,
|
|
48
|
+
{
|
|
49
|
+
value: string;
|
|
50
|
+
catalog?: Array<BlockSnapshot & { label?: string }>;
|
|
51
|
+
readOnly?: boolean;
|
|
52
|
+
labelledBy: string;
|
|
53
|
+
onChange: (value: string) => void;
|
|
54
|
+
}
|
|
55
|
+
>(function RenderedBody({ value, catalog = [], readOnly, labelledBy, onChange }, ref) {
|
|
56
|
+
const local = useRef(value);
|
|
57
|
+
const hosts = useRef(new Map<string, HTMLElement>());
|
|
58
|
+
const commits = useRef(new Map<string, () => void>());
|
|
59
|
+
const linking = useRef(false);
|
|
60
|
+
const [blocks, setBlocks] = useState(() => blocksFromSource(value));
|
|
61
|
+
const [activeId, setActiveId] = useState<string | null>(null);
|
|
62
|
+
const [focusId, setFocusId] = useState<string | null>(null);
|
|
63
|
+
const [selection, setSelection] = useState<FormatSelection | null>(null);
|
|
64
|
+
const [settingsId, setSettingsId] = useState<string | null>(null);
|
|
65
|
+
const selectionBlock = useRef<string | null>(null);
|
|
66
|
+
|
|
67
|
+
const register = useCallback((id: string, host: HTMLElement, commit: () => void) => {
|
|
68
|
+
hosts.current.set(id, host);
|
|
69
|
+
commits.current.set(id, commit);
|
|
70
|
+
}, []);
|
|
71
|
+
|
|
72
|
+
const unregister = useCallback((id: string) => {
|
|
73
|
+
hosts.current.delete(id);
|
|
74
|
+
commits.current.delete(id);
|
|
75
|
+
}, []);
|
|
76
|
+
|
|
77
|
+
const syncSelection = useCallback(() => {
|
|
78
|
+
if (linking.current) return;
|
|
79
|
+
const next = readSelection(hosts.current);
|
|
80
|
+
selectionBlock.current = next?.blockId ?? null;
|
|
81
|
+
setSelection(next?.selection ?? null);
|
|
82
|
+
}, []);
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
document.addEventListener("selectionchange", syncSelection);
|
|
86
|
+
window.addEventListener("resize", syncSelection);
|
|
87
|
+
document.addEventListener("scroll", syncSelection, true);
|
|
88
|
+
return () => {
|
|
89
|
+
document.removeEventListener("selectionchange", syncSelection);
|
|
90
|
+
window.removeEventListener("resize", syncSelection);
|
|
91
|
+
document.removeEventListener("scroll", syncSelection, true);
|
|
92
|
+
};
|
|
93
|
+
}, [syncSelection]);
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (value === local.current) return;
|
|
97
|
+
local.current = value;
|
|
98
|
+
setBlocks(blocksFromSource(value));
|
|
99
|
+
}, [value]);
|
|
100
|
+
|
|
101
|
+
function publish(next: BodyBlock[]) {
|
|
102
|
+
const source = joinBlocks(next);
|
|
103
|
+
local.current = source;
|
|
104
|
+
setBlocks(next);
|
|
105
|
+
if (source !== value) onChange(source);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function insert(markdown: string) {
|
|
109
|
+
const id = crypto.randomUUID();
|
|
110
|
+
const block = blockFromMarkdown(markdown, id);
|
|
111
|
+
const index = blocks.findIndex((item) => item.id === activeId);
|
|
112
|
+
const next = [...blocks];
|
|
113
|
+
if (index === -1) next.push(block);
|
|
114
|
+
else next.splice(index + 1, 0, block);
|
|
115
|
+
if (block.kind === "jsx" && catalog.some((item) => item.name === block.jsxName)) {
|
|
116
|
+
setSettingsId(id);
|
|
117
|
+
} else {
|
|
118
|
+
setFocusId(id);
|
|
119
|
+
}
|
|
120
|
+
publish(next);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
useImperativeHandle(ref, () => ({ insert }));
|
|
124
|
+
|
|
125
|
+
function commitHost(id: string) {
|
|
126
|
+
commits.current.get(id)?.();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function onFormat(format: BlockFormat) {
|
|
130
|
+
const id = selectionBlock.current;
|
|
131
|
+
const host = id ? hosts.current.get(id) : undefined;
|
|
132
|
+
const range = currentRange();
|
|
133
|
+
if (!id || !host || !range) return;
|
|
134
|
+
if (blockFormatOf(host, range) === format) return;
|
|
135
|
+
applyBlockFormat(host, format, range);
|
|
136
|
+
placeCaretAtEnd(host);
|
|
137
|
+
commitHost(id);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function onInline(tag: "strong" | "em") {
|
|
141
|
+
const id = selectionBlock.current;
|
|
142
|
+
const host = id ? hosts.current.get(id) : undefined;
|
|
143
|
+
const range = currentRange();
|
|
144
|
+
if (!id || !host || !range || !host.contains(range.commonAncestorContainer)) return;
|
|
145
|
+
toggleInline(range, tag);
|
|
146
|
+
commitHost(id);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function onLink(href: string, range: Range) {
|
|
150
|
+
const id = selectionBlock.current;
|
|
151
|
+
const host = id ? hosts.current.get(id) : undefined;
|
|
152
|
+
if (!id || !host) return;
|
|
153
|
+
host.focus();
|
|
154
|
+
applyLink(range, href);
|
|
155
|
+
commitHost(id);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function commit(id: string, markdown: string) {
|
|
159
|
+
const current = blocks.find((block) => block.id === id);
|
|
160
|
+
if (!current || current.markdown.trim() === markdown.trim()) return;
|
|
161
|
+
publish(
|
|
162
|
+
blocks.map((block) => (block.id === id ? blockFromMarkdown(markdown, id) : block)),
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function split(id: string, before: string, after: string) {
|
|
167
|
+
const nextId = crypto.randomUUID();
|
|
168
|
+
const next: BodyBlock[] = [];
|
|
169
|
+
for (const block of blocks) {
|
|
170
|
+
if (block.id !== id) {
|
|
171
|
+
next.push(block);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
next.push(blockFromMarkdown(before, block.id));
|
|
175
|
+
next.push(blockFromMarkdown(after, nextId));
|
|
176
|
+
}
|
|
177
|
+
setFocusId(nextId);
|
|
178
|
+
publish(next);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const settingsBlock = blocks.find((block) => block.id === settingsId);
|
|
182
|
+
const settingsDef = settingsBlock?.jsxName
|
|
183
|
+
? catalog.find((item) => item.name === settingsBlock.jsxName)
|
|
184
|
+
: undefined;
|
|
185
|
+
const settings =
|
|
186
|
+
settingsBlock && settingsDef ? { block: settingsBlock, def: settingsDef } : null;
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
<RenderedSurface labelledBy={labelledBy}>
|
|
190
|
+
{blocks.length === 0 ? (
|
|
191
|
+
<EditableBlock
|
|
192
|
+
block={{ id: "empty", markdown: "", kind: "text" }}
|
|
193
|
+
readOnly={readOnly}
|
|
194
|
+
autoFocus={false}
|
|
195
|
+
catalog={catalog}
|
|
196
|
+
onOpenSettings={setSettingsId}
|
|
197
|
+
onRegister={register}
|
|
198
|
+
onUnregister={unregister}
|
|
199
|
+
onFocus={() => setActiveId(null)}
|
|
200
|
+
onCommit={(markdown) => {
|
|
201
|
+
if (!markdown.trim()) return;
|
|
202
|
+
publish([blockFromMarkdown(markdown, crypto.randomUUID())]);
|
|
203
|
+
}}
|
|
204
|
+
onSplit={() => {}}
|
|
205
|
+
onRemove={() => {}}
|
|
206
|
+
/>
|
|
207
|
+
) : (
|
|
208
|
+
blocks.map((block) => (
|
|
209
|
+
<EditableBlock
|
|
210
|
+
key={block.id}
|
|
211
|
+
block={block}
|
|
212
|
+
readOnly={readOnly}
|
|
213
|
+
autoFocus={focusId === block.id}
|
|
214
|
+
catalog={catalog}
|
|
215
|
+
onOpenSettings={setSettingsId}
|
|
216
|
+
onRegister={register}
|
|
217
|
+
onUnregister={unregister}
|
|
218
|
+
onFocus={() => setActiveId(block.id)}
|
|
219
|
+
onCommit={(markdown) => commit(block.id, markdown)}
|
|
220
|
+
onSplit={(before, after) => split(block.id, before, after)}
|
|
221
|
+
onRemove={() => publish(blocks.filter((item) => item.id !== block.id))}
|
|
222
|
+
/>
|
|
223
|
+
))
|
|
224
|
+
)}
|
|
225
|
+
{selection && !readOnly ? (
|
|
226
|
+
<SelectionBar
|
|
227
|
+
selection={selection}
|
|
228
|
+
onFormat={onFormat}
|
|
229
|
+
onInline={onInline}
|
|
230
|
+
onLink={onLink}
|
|
231
|
+
onLinking={(next) => {
|
|
232
|
+
linking.current = next;
|
|
233
|
+
if (!next) syncSelection();
|
|
234
|
+
}}
|
|
235
|
+
/>
|
|
236
|
+
) : null}
|
|
237
|
+
{settings ? (
|
|
238
|
+
<BlockSettingsDialog
|
|
239
|
+
key={settings.block.id}
|
|
240
|
+
name={settings.def.name}
|
|
241
|
+
title={contentBlockLabel(settings.def.name)}
|
|
242
|
+
fields={contentBlockFields(settings.def)}
|
|
243
|
+
value={contentBlockProps(settings.block.markdown, settings.def.name)}
|
|
244
|
+
readOnly={readOnly}
|
|
245
|
+
onOpenChange={(open) => {
|
|
246
|
+
if (!open) setSettingsId(null);
|
|
247
|
+
}}
|
|
248
|
+
onSave={(props) => {
|
|
249
|
+
const markdown =
|
|
250
|
+
settings.def.name === "Image"
|
|
251
|
+
? jsxBlockSource(settings.def.name, props, settings.def.fields)
|
|
252
|
+
: jsxWithProps(
|
|
253
|
+
settings.block.markdown,
|
|
254
|
+
settings.def.name,
|
|
255
|
+
props,
|
|
256
|
+
settings.def.fields,
|
|
257
|
+
);
|
|
258
|
+
commit(settings.block.id, markdown);
|
|
259
|
+
setSettingsId(null);
|
|
260
|
+
}}
|
|
261
|
+
onRemove={() => {
|
|
262
|
+
publish(blocks.filter((block) => block.id !== settings.block.id));
|
|
263
|
+
setSettingsId(null);
|
|
264
|
+
}}
|
|
265
|
+
/>
|
|
266
|
+
) : null}
|
|
267
|
+
</RenderedSurface>
|
|
268
|
+
);
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
function RenderedSurface({
|
|
272
|
+
labelledBy,
|
|
273
|
+
children,
|
|
274
|
+
}: {
|
|
275
|
+
labelledBy: string;
|
|
276
|
+
children: ReactNode;
|
|
277
|
+
}) {
|
|
278
|
+
const surface = stylex.props(styles.surface);
|
|
279
|
+
return (
|
|
280
|
+
<div
|
|
281
|
+
aria-labelledby={labelledBy}
|
|
282
|
+
className={["prose-ui", surface.className].filter(Boolean).join(" ")}
|
|
283
|
+
style={surface.style}
|
|
284
|
+
>
|
|
285
|
+
{children}
|
|
286
|
+
</div>
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function EditableBlock({
|
|
291
|
+
block,
|
|
292
|
+
catalog,
|
|
293
|
+
readOnly,
|
|
294
|
+
autoFocus,
|
|
295
|
+
onOpenSettings,
|
|
296
|
+
onRegister,
|
|
297
|
+
onUnregister,
|
|
298
|
+
onFocus,
|
|
299
|
+
onCommit,
|
|
300
|
+
onSplit,
|
|
301
|
+
onRemove,
|
|
302
|
+
}: {
|
|
303
|
+
block: BodyBlock;
|
|
304
|
+
catalog: Array<BlockSnapshot & { label?: string }>;
|
|
305
|
+
readOnly?: boolean;
|
|
306
|
+
autoFocus: boolean;
|
|
307
|
+
onOpenSettings: (id: string) => void;
|
|
308
|
+
onRegister: (id: string, host: HTMLElement, commit: () => void) => void;
|
|
309
|
+
onUnregister: (id: string) => void;
|
|
310
|
+
onFocus: () => void;
|
|
311
|
+
onCommit: (markdown: string) => void;
|
|
312
|
+
onSplit: (before: string, after: string) => void;
|
|
313
|
+
onRemove: () => void;
|
|
314
|
+
}) {
|
|
315
|
+
const ref = useRef<HTMLElement>(null);
|
|
316
|
+
const editing = useRef(false);
|
|
317
|
+
const commitRef = useRef<() => void>(() => {});
|
|
318
|
+
commitRef.current = () => {
|
|
319
|
+
const host = ref.current;
|
|
320
|
+
if (!host || readOnly) return;
|
|
321
|
+
onCommit(markdownFromEditable(host, block));
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
useEffect(() => {
|
|
325
|
+
if (autoFocus) ref.current?.focus();
|
|
326
|
+
}, [autoFocus]);
|
|
327
|
+
|
|
328
|
+
useEffect(() => {
|
|
329
|
+
if (block.kind !== "text") return;
|
|
330
|
+
const host = ref.current;
|
|
331
|
+
if (!host) return;
|
|
332
|
+
onRegister(block.id, host, () => commitRef.current());
|
|
333
|
+
return () => onUnregister(block.id);
|
|
334
|
+
}, [block.id, block.kind, onRegister, onUnregister]);
|
|
335
|
+
|
|
336
|
+
useEffect(() => {
|
|
337
|
+
const host = ref.current;
|
|
338
|
+
if (!host || editing.current) return;
|
|
339
|
+
if (block.kind === "code") {
|
|
340
|
+
host.textContent = codeParts(block.markdown).code;
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (!block.markdown.trim()) {
|
|
344
|
+
host.innerHTML = "";
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
let cancelled = false;
|
|
348
|
+
void compileBody(block.markdown, editorMdxComponents(block.jsxName))
|
|
349
|
+
.then((result) => {
|
|
350
|
+
if (cancelled || editing.current || ref.current !== host) return;
|
|
351
|
+
if (result.error || result.node == null) {
|
|
352
|
+
host.textContent = block.markdown;
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
try {
|
|
356
|
+
host.innerHTML = renderToStaticMarkup(result.node).replace(/<link\b[^>]*>/g, "");
|
|
357
|
+
} catch {
|
|
358
|
+
host.textContent = block.markdown;
|
|
359
|
+
}
|
|
360
|
+
})
|
|
361
|
+
.catch(() => {
|
|
362
|
+
if (!cancelled && ref.current === host) host.textContent = block.markdown;
|
|
363
|
+
});
|
|
364
|
+
return () => {
|
|
365
|
+
cancelled = true;
|
|
366
|
+
};
|
|
367
|
+
}, [block.kind, block.markdown]);
|
|
368
|
+
|
|
369
|
+
function commitFromDom() {
|
|
370
|
+
const host = ref.current;
|
|
371
|
+
if (!host || readOnly) return;
|
|
372
|
+
onCommit(markdownFromEditable(host, block));
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function onKeyDown(event: KeyboardEvent<HTMLElement>) {
|
|
376
|
+
if (readOnly) return;
|
|
377
|
+
const emptyText = (ref.current?.innerText ?? "").trim() === "";
|
|
378
|
+
if (event.key === "Backspace" && block.kind === "text" && emptyText) {
|
|
379
|
+
event.preventDefault();
|
|
380
|
+
onRemove();
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
if (event.key !== "Enter" || event.shiftKey || block.kind !== "text") return;
|
|
384
|
+
const host = ref.current;
|
|
385
|
+
if (!host) return;
|
|
386
|
+
const parts = splitAtCaret(host);
|
|
387
|
+
if (!parts) return;
|
|
388
|
+
event.preventDefault();
|
|
389
|
+
onSplit(parts.before, parts.after);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const empty = !block.markdown.trim();
|
|
393
|
+
const catalogBlock =
|
|
394
|
+
block.kind === "jsx" ? catalog.find((item) => item.name === block.jsxName) : undefined;
|
|
395
|
+
|
|
396
|
+
if (catalogBlock) {
|
|
397
|
+
return (
|
|
398
|
+
<div data-body-block="" {...stylex.props(styles.block)}>
|
|
399
|
+
<button
|
|
400
|
+
type="button"
|
|
401
|
+
aria-label={`Edit ${catalogBlock.name} settings`}
|
|
402
|
+
onClick={() => onOpenSettings(block.id)}
|
|
403
|
+
{...stylex.props(styles.card)}
|
|
404
|
+
>
|
|
405
|
+
<ContentBlockView
|
|
406
|
+
name={catalogBlock.name}
|
|
407
|
+
props={contentBlockProps(block.markdown, catalogBlock.name)}
|
|
408
|
+
/>
|
|
409
|
+
</button>
|
|
410
|
+
</div>
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return (
|
|
415
|
+
<div
|
|
416
|
+
data-body-block=""
|
|
417
|
+
{...stylex.props(styles.block)}
|
|
418
|
+
>
|
|
419
|
+
{block.kind === "code" ? (
|
|
420
|
+
<pre {...stylex.props(styles.pre)}>
|
|
421
|
+
<code
|
|
422
|
+
ref={ref as Ref<HTMLElement>}
|
|
423
|
+
role="textbox"
|
|
424
|
+
aria-multiline="true"
|
|
425
|
+
aria-label={block.lang ? `${block.lang} code` : "Code"}
|
|
426
|
+
contentEditable={!readOnly}
|
|
427
|
+
suppressContentEditableWarning
|
|
428
|
+
spellCheck={false}
|
|
429
|
+
onFocus={() => {
|
|
430
|
+
editing.current = true;
|
|
431
|
+
onFocus();
|
|
432
|
+
}}
|
|
433
|
+
onBlur={() => {
|
|
434
|
+
editing.current = false;
|
|
435
|
+
commitFromDom();
|
|
436
|
+
}}
|
|
437
|
+
onKeyDown={onKeyDown}
|
|
438
|
+
{...stylex.props(styles.codeText)}
|
|
439
|
+
/>
|
|
440
|
+
</pre>
|
|
441
|
+
) : (
|
|
442
|
+
<div
|
|
443
|
+
ref={ref as Ref<HTMLDivElement>}
|
|
444
|
+
role="textbox"
|
|
445
|
+
aria-multiline="true"
|
|
446
|
+
aria-label={block.jsxName ?? "Text"}
|
|
447
|
+
contentEditable={!readOnly}
|
|
448
|
+
suppressContentEditableWarning
|
|
449
|
+
spellCheck
|
|
450
|
+
data-text-block=""
|
|
451
|
+
data-empty={empty ? "" : undefined}
|
|
452
|
+
onFocus={() => {
|
|
453
|
+
editing.current = true;
|
|
454
|
+
onFocus();
|
|
455
|
+
}}
|
|
456
|
+
onBlur={() => {
|
|
457
|
+
editing.current = false;
|
|
458
|
+
commitFromDom();
|
|
459
|
+
}}
|
|
460
|
+
onKeyDown={onKeyDown}
|
|
461
|
+
onClick={(event) => {
|
|
462
|
+
const anchor = (event.target as HTMLElement).closest?.("a");
|
|
463
|
+
if (anchor) event.preventDefault();
|
|
464
|
+
}}
|
|
465
|
+
{...stylex.props(styles.text, empty && styles.placeholder)}
|
|
466
|
+
/>
|
|
467
|
+
)}
|
|
468
|
+
</div>
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
type SelectionSnap = { blockId: string; selection: FormatSelection };
|
|
473
|
+
|
|
474
|
+
function readSelection(hosts: Map<string, HTMLElement>): SelectionSnap | null {
|
|
475
|
+
const current = window.getSelection();
|
|
476
|
+
if (!current || current.isCollapsed || current.rangeCount === 0) return null;
|
|
477
|
+
if (current.toString().trim() === "") return null;
|
|
478
|
+
const range = current.getRangeAt(0);
|
|
479
|
+
const node = range.commonAncestorContainer;
|
|
480
|
+
const element = node instanceof Element ? node : node.parentElement;
|
|
481
|
+
if (element?.closest("[data-selection-bar]")) return null;
|
|
482
|
+
const host = element?.closest("[data-text-block]");
|
|
483
|
+
if (!(host instanceof HTMLElement) || !host.isContentEditable) return null;
|
|
484
|
+
if (host.getClientRects().length === 0) return null;
|
|
485
|
+
let blockId: string | null = null;
|
|
486
|
+
for (const [id, registered] of hosts) {
|
|
487
|
+
if (registered === host) blockId = id;
|
|
488
|
+
}
|
|
489
|
+
if (!blockId) return null;
|
|
490
|
+
const rects = range.getClientRects();
|
|
491
|
+
const rect = rects.length > 0 ? rects[0] : range.getBoundingClientRect();
|
|
492
|
+
if (!rect || (rect.width === 0 && rect.height === 0)) return null;
|
|
493
|
+
return {
|
|
494
|
+
blockId,
|
|
495
|
+
selection: {
|
|
496
|
+
top: rect.top,
|
|
497
|
+
left: rect.left,
|
|
498
|
+
width: rect.width,
|
|
499
|
+
bottom: rect.bottom,
|
|
500
|
+
format: blockFormatOf(host, range),
|
|
501
|
+
...marksAt(range),
|
|
502
|
+
},
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function currentRange(): Range | null {
|
|
507
|
+
const current = window.getSelection();
|
|
508
|
+
if (!current || current.rangeCount === 0) return null;
|
|
509
|
+
return current.getRangeAt(0);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function splitAtCaret(root: HTMLElement): { before: string; after: string } | null {
|
|
513
|
+
const selection = window.getSelection();
|
|
514
|
+
if (!selection || selection.rangeCount === 0) return null;
|
|
515
|
+
const range = selection.getRangeAt(0);
|
|
516
|
+
if (!root.contains(range.startContainer)) return null;
|
|
517
|
+
|
|
518
|
+
const beforeRange = range.cloneRange();
|
|
519
|
+
beforeRange.selectNodeContents(root);
|
|
520
|
+
beforeRange.setEnd(range.startContainer, range.startOffset);
|
|
521
|
+
const afterRange = range.cloneRange();
|
|
522
|
+
afterRange.selectNodeContents(root);
|
|
523
|
+
afterRange.setStart(range.endContainer, range.endOffset);
|
|
524
|
+
|
|
525
|
+
const beforeHost = document.createElement("div");
|
|
526
|
+
beforeHost.appendChild(beforeRange.cloneContents());
|
|
527
|
+
const afterHost = document.createElement("div");
|
|
528
|
+
afterHost.appendChild(afterRange.cloneContents());
|
|
529
|
+
return {
|
|
530
|
+
before: markdownFromEditable(beforeHost, { id: "before", kind: "text", markdown: "" }),
|
|
531
|
+
after: markdownFromEditable(afterHost, { id: "after", kind: "text", markdown: "" }),
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const hover = "@media (hover: hover)";
|
|
536
|
+
|
|
537
|
+
const styles = stylex.create({
|
|
538
|
+
surface: {
|
|
539
|
+
minHeight: "26rem",
|
|
540
|
+
overflowX: "auto",
|
|
541
|
+
padding: space.lg,
|
|
542
|
+
borderWidth: 1,
|
|
543
|
+
borderStyle: "solid",
|
|
544
|
+
borderColor: colors.border,
|
|
545
|
+
borderRadius: radius.md,
|
|
546
|
+
backgroundColor: colors.bgInput,
|
|
547
|
+
},
|
|
548
|
+
block: {
|
|
549
|
+
marginBottom: space.lg,
|
|
550
|
+
":last-child": {
|
|
551
|
+
marginBottom: 0,
|
|
552
|
+
},
|
|
553
|
+
},
|
|
554
|
+
card: {
|
|
555
|
+
display: "block",
|
|
556
|
+
width: "100%",
|
|
557
|
+
margin: 0,
|
|
558
|
+
padding: 0,
|
|
559
|
+
borderWidth: 0,
|
|
560
|
+
borderRadius: radius.md,
|
|
561
|
+
backgroundColor: "transparent",
|
|
562
|
+
color: "inherit",
|
|
563
|
+
fontFamily: "inherit",
|
|
564
|
+
fontSize: "inherit",
|
|
565
|
+
lineHeight: "inherit",
|
|
566
|
+
textAlign: "left",
|
|
567
|
+
cursor: "pointer",
|
|
568
|
+
[hover]: {
|
|
569
|
+
":hover": {
|
|
570
|
+
backgroundColor: colors.bgHover,
|
|
571
|
+
},
|
|
572
|
+
},
|
|
573
|
+
},
|
|
574
|
+
text: {
|
|
575
|
+
minHeight: "1.5em",
|
|
576
|
+
outlineWidth: 0,
|
|
577
|
+
},
|
|
578
|
+
placeholder: {
|
|
579
|
+
":empty::before": {
|
|
580
|
+
content: '"Write…"',
|
|
581
|
+
color: colors.textMuted,
|
|
582
|
+
},
|
|
583
|
+
},
|
|
584
|
+
pre: {
|
|
585
|
+
margin: 0,
|
|
586
|
+
padding: space.md,
|
|
587
|
+
borderRadius: radius.md,
|
|
588
|
+
backgroundColor: colors.bgSurface,
|
|
589
|
+
overflowX: "auto",
|
|
590
|
+
},
|
|
591
|
+
codeText: {
|
|
592
|
+
fontFamily: type.mono,
|
|
593
|
+
fontSize: type.sm,
|
|
594
|
+
lineHeight: 1.5,
|
|
595
|
+
whiteSpace: "pre",
|
|
596
|
+
outlineWidth: 0,
|
|
597
|
+
},
|
|
598
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// packages/studio/src/pages/ResumeHome.tsx
|
|
2
|
+
import { Navigate } from "react-router";
|
|
3
|
+
import { useAppChrome } from "../components/AppChromeContext";
|
|
4
|
+
import {
|
|
5
|
+
forgetLastWorkspace,
|
|
6
|
+
readLastWorkspace,
|
|
7
|
+
resumePath,
|
|
8
|
+
} from "../last-workspace";
|
|
9
|
+
import { useReplicaState } from "../replica/useReplica";
|
|
10
|
+
|
|
11
|
+
export function ResumeHome() {
|
|
12
|
+
const { userId } = useAppChrome();
|
|
13
|
+
const replica = useReplicaState();
|
|
14
|
+
const last = readLastWorkspace(userId);
|
|
15
|
+
const to = resumePath(last, replica.control?.workspaces ?? []);
|
|
16
|
+
if (to === "/workspaces" && last) forgetLastWorkspace(userId);
|
|
17
|
+
return <Navigate to={to} replace />;
|
|
18
|
+
}
|