@vite-hub/ui 0.0.3 → 0.1.0
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/README.md +27 -7
- package/dist/{andromeeda-DnSv6o6l.js → andromeeda-BASpqCeJ.js} +1 -1
- package/dist/attachment-B3dXC7jM.js +71 -0
- package/dist/attachment-BBndG9_P.d.ts +88 -0
- package/dist/attachment.d.ts +2 -0
- package/dist/attachment.js +2 -0
- package/dist/{aurora-x-XJ5I8rFc.js → aurora-x-DugsLcii.js} +1 -1
- package/dist/avatar-stack-DM6HRnc0.js +63 -0
- package/dist/avatar-stack-DXmCQhxd.d.ts +59 -0
- package/dist/avatar-stack.d.ts +2 -0
- package/dist/avatar-stack.js +2 -0
- package/dist/{ayu-dark-CBRGL64-.js → ayu-dark-BT3qdi3o.js} +1 -1
- package/dist/{ayu-light-BlrCS3Ih.js → ayu-light-BVZyHoh9.js} +1 -1
- package/dist/{ayu-mirage-CqpTmLcF.js → ayu-mirage-XFwUVZQZ.js} +1 -1
- package/dist/bubble-BJH2rfii.d.ts +72 -0
- package/dist/bubble-BPyFQlW7.js +53 -0
- package/dist/bubble.d.ts +2 -0
- package/dist/bubble.js +2 -0
- package/dist/catppuccin-frappe-D20KODDN.js +4 -0
- package/dist/catppuccin-latte-eGLVHIUJ.js +4 -0
- package/dist/catppuccin-macchiato-bQGch4PY.js +4 -0
- package/dist/catppuccin-mocha-Bes8-0Mr.js +4 -0
- package/dist/chat-B9HlZWA2.d.ts +50 -0
- package/dist/chat-BoFHlu9V.js +73 -0
- package/dist/chat-message-BNK9G7xF.js +51 -0
- package/dist/chat-message-mpDmZbIC.d.ts +28 -0
- package/dist/chat-message.d.ts +2 -0
- package/dist/chat-message.js +2 -0
- package/dist/chat-session-D6C7VJBR.d.ts +29 -0
- package/dist/chat-session-DYEHB1HC.js +38 -0
- package/dist/chat-session.d.ts +2 -0
- package/dist/chat-session.js +2 -0
- package/dist/chat.d.ts +2 -0
- package/dist/chat.js +2 -0
- package/dist/code-block-Br-02hn-.js +139 -0
- package/dist/code-block.d.ts +2 -0
- package/dist/code-block.js +3 -0
- package/dist/code-view-J4OsgEdh.js +158 -0
- package/dist/code-view-vDM-hph-.d.ts +4091 -0
- package/dist/code-view.d.ts +2 -0
- package/dist/code-view.js +2 -0
- package/dist/comment-layer-CBlxJ8eK.js +1113 -0
- package/dist/comments-C08J3z4e.js +456 -0
- package/dist/comments-ChNJkV1d.d.ts +108 -0
- package/dist/comments-Cq5eewsu.d.ts +537 -0
- package/dist/comments.d.ts +2 -0
- package/dist/comments.js +2 -0
- package/dist/{config-BwhBDTjC.d.ts → config-Bux_AJzm.d.ts} +0 -1
- package/dist/{config-CzOjpPth.js → config-bHqE4JOs.js} +2 -7
- package/dist/connection-status-CzuWBENf.js +65 -0
- package/dist/connection-status-DjGBw6xX.d.ts +39 -0
- package/dist/connection-status.d.ts +2 -0
- package/dist/connection-status.js +2 -0
- package/dist/{dark-plus-BCxGtnt0.js → dark-plus-BGuiqa1B.js} +1 -1
- package/dist/{dracula-fPErIccy.js → dracula-0CVA2XY5.js} +1 -1
- package/dist/{dracula-soft-BrQbqXs8.js → dracula-soft-Dk9bpbVU.js} +1 -1
- package/dist/error-diagnostics-B4hMpJRL.js +13 -0
- package/dist/{everforest-dark-gTeBQCos.js → everforest-dark-CRjTbhh5.js} +1 -1
- package/dist/{everforest-light-DUjxsp-2.js → everforest-light-CEeYFLn8.js} +1 -1
- package/dist/file-diff.d.ts +2 -0
- package/dist/file-diff.js +2 -0
- package/dist/file-tree-C1pv4_AI.js +9307 -0
- package/dist/file-tree-Ctb8hZ_g.d.ts +459 -0
- package/dist/file-tree.d.ts +2 -0
- package/dist/file-tree.js +2 -0
- package/dist/file-view.d.ts +2 -0
- package/dist/file-view.js +2 -0
- package/dist/{getSingularPatch-D0VFiyjB.js → getSingularPatch-Dsb8EgxR.js} +191 -116
- package/dist/{github-dark-Dg1hl_QD.js → github-dark-BXgKmOw_.js} +1 -1
- package/dist/{github-dark-default-Dym2P842.js → github-dark-default-DzJQXksd.js} +1 -1
- package/dist/{github-dark-dimmed-7iDMx266.js → github-dark-dimmed-B1pEmGtS.js} +1 -1
- package/dist/{github-dark-high-contrast-DkV2fyPG.js → github-dark-high-contrast-BkHIa6jc.js} +1 -1
- package/dist/{github-light-BQKYgor9.js → github-light-BKRlUbaB.js} +1 -1
- package/dist/{github-light-default-BZhIfzqQ.js → github-light-default-BU3eYkzs.js} +1 -1
- package/dist/{github-light-high-contrast-C7zHfx4C.js → github-light-high-contrast-B3MumDcI.js} +1 -1
- package/dist/{gruvbox-dark-hard-CQiwpF03.js → gruvbox-dark-hard-B0ecF443.js} +1 -1
- package/dist/{gruvbox-dark-medium-BKe6XKBS.js → gruvbox-dark-medium-BQnpC39k.js} +1 -1
- package/dist/{gruvbox-dark-soft-Cz6U6pa4.js → gruvbox-dark-soft-DFZUgESr.js} +1 -1
- package/dist/{gruvbox-light-hard-DgU_i19B.js → gruvbox-light-hard-CuB_LOJr.js} +1 -1
- package/dist/{gruvbox-light-medium-D64I06ER.js → gruvbox-light-medium-idDHgxjs.js} +1 -1
- package/dist/{gruvbox-light-soft-B-YxAs1L.js → gruvbox-light-soft-CfWH49MY.js} +1 -1
- package/dist/headless.d.ts +14 -14
- package/dist/headless.js +3 -333
- package/dist/highlighted-code-Ck4zexJX.js +90 -0
- package/dist/highlighted-code-Dzf6o54i.d.ts +112 -0
- package/dist/{horizon-bright-CPyV7XIA.js → horizon-bright-Ba6M8QSV.js} +1 -1
- package/dist/{horizon-DYoumREk.js → horizon-h92C5OlZ.js} +1 -1
- package/dist/{houston-B3NWfq0V.js → houston-EQnPegWq.js} +1 -1
- package/dist/image-preview-VfknBEFu.js +102 -0
- package/dist/index-DcH0QSI5.d.ts +61 -0
- package/dist/index.d.ts +34 -6378
- package/dist/index.js +27 -12338
- package/dist/kanagawa-dragon-DgDvwi3B.js +4 -0
- package/dist/kanagawa-lotus-BgoQro20.js +4 -0
- package/dist/kanagawa-wave-DgXEowHs.js +4 -0
- package/dist/{laserwave-DkfjiLxA.js → laserwave-IxBH_3yW.js} +1 -1
- package/dist/{light-plus-DuO6rXxZ.js → light-plus-S8JBx6is.js} +1 -1
- package/dist/markdown-BoLBN0qH.js +197 -0
- package/dist/markdown-Dse5ldJe.d.ts +47 -0
- package/dist/markdown.d.ts +2 -0
- package/dist/markdown.js +2 -0
- package/dist/marker-Di2ZG_k1.js +23 -0
- package/dist/marker-ea-tvx-J.d.ts +35 -0
- package/dist/marker.d.ts +2 -0
- package/dist/marker.js +2 -0
- package/dist/{material-theme-C_YrwKEa.js → material-theme-D1f3HBq-.js} +1 -1
- package/dist/{material-theme-darker-DB3YVCla.js → material-theme-darker-ExzYhT0j.js} +1 -1
- package/dist/{material-theme-lighter-D2fgNrBK.js → material-theme-lighter-D6gH9nnA.js} +1 -1
- package/dist/{material-theme-ocean-DVy172Rs.js → material-theme-ocean-D1w5BPAa.js} +1 -1
- package/dist/{material-theme-palenight-uMMwIfpG.js → material-theme-palenight-CkqWmVpF.js} +1 -1
- package/dist/message-CW_paC1k.d.ts +35 -0
- package/dist/message-DiyBthIq.js +23 -0
- package/dist/message-parts-BBFUkluC.d.ts +28 -0
- package/dist/message-parts-DQnfioAH.js +38 -0
- package/dist/message-parts.d.ts +2 -0
- package/dist/message-parts.js +2 -0
- package/dist/message-scroller-CX6NJTdm.js +335 -0
- package/dist/message.d.ts +2 -0
- package/dist/message.js +2 -0
- package/dist/{min-dark-C7Ec8I_2.js → min-dark-npsJH98j.js} +1 -1
- package/dist/{min-light-Be6foA7m.js → min-light-DUk1XsVt.js} +1 -1
- package/dist/monokai-CfFRWUNl.js +4 -0
- package/dist/multi-file-diff.d.ts +2 -0
- package/dist/multi-file-diff.js +2 -0
- package/dist/{night-owl-CqqbiLON.js → night-owl-BS7V-av_.js} +1 -1
- package/dist/{night-owl-light-B9vYgGRt.js → night-owl-light-CZtRawYE.js} +1 -1
- package/dist/{nord-BZ9DVmcN.js → nord-BFh54Nqz.js} +1 -1
- package/dist/nuxt.d.ts +8 -5
- package/dist/nuxt.js +136 -22
- package/dist/one-dark-pro-zDovGosB.js +4 -0
- package/dist/{one-light-CzxBC38_.js → one-light-gmHK3iK6.js} +1 -1
- package/dist/patch-diff.d.ts +2 -0
- package/dist/patch-diff.js +2 -0
- package/dist/{pierre-code-view-DYpF5M8R.js → pierre-code-view-T7V67hwT.js} +7209 -15318
- package/dist/{plastic-BGkJ2das.js → plastic-DtdaCjub.js} +1 -1
- package/dist/{poimandres-CpnMgZuc.js → poimandres-Hdda6aHK.js} +1 -1
- package/dist/primitive-rail.d.ts +222 -0
- package/dist/primitive-rail.js +348 -0
- package/dist/prompt-input-BbnCb80O.js +299 -0
- package/dist/prompt-input-Cy_Ue6B5.d.ts +93 -0
- package/dist/prompt-input.d.ts +2 -0
- package/dist/prompt-input.js +2 -0
- package/dist/red-VqZFRByZ.js +4 -0
- package/dist/rose-pine-DiTkEueR.js +4 -0
- package/dist/rose-pine-dawn-tfo5y2X0.js +4 -0
- package/dist/rose-pine-moon-C0gON9XN.js +4 -0
- package/dist/runtime/nuxt-plugin.js +3 -1
- package/dist/runtime-type-DlCscMfw.js +59 -0
- package/dist/{slack-dark-BS2AOOdo.js → slack-dark-v8P_eXr6.js} +1 -1
- package/dist/{slack-ochin-Nc7Cucwk.js → slack-ochin-D8SyEdKz.js} +1 -1
- package/dist/slot-part-C7Ocxn3b.js +20 -0
- package/dist/{snazzy-light-C2ghKZXY.js → snazzy-light-BtkQkvXb.js} +1 -1
- package/dist/solarized-dark-B8nAdMfM.js +4 -0
- package/dist/solarized-light-B-3F1INj.js +4 -0
- package/dist/styles.css +2134 -2034
- package/dist/sync-status-BpxYdZIJ.js +48 -0
- package/dist/sync-status-refELOZn.d.ts +25 -0
- package/dist/sync-status.d.ts +2 -0
- package/dist/sync-status.js +2 -0
- package/dist/{synthwave-84-CPtGYwOz.js → synthwave-84-DcsXCF_c.js} +1 -1
- package/dist/{tokyo-night-BKYoawWu.js → tokyo-night-Bvpqduda.js} +1 -1
- package/dist/tool-list-BdSr5CT4.js +150 -0
- package/dist/tool-list-E7CA52rz.d.ts +31 -0
- package/dist/tool-list.d.ts +2 -0
- package/dist/tool-list.js +2 -0
- package/dist/trace-V7rM3Pyd.d.ts +62 -0
- package/dist/trace-llBCDiSW.js +70 -0
- package/dist/trace-run-BIQ17CED.js +98 -0
- package/dist/trace-run-COeXn46Z.d.ts +28 -0
- package/dist/trace-run.d.ts +2 -0
- package/dist/trace-run.js +2 -0
- package/dist/trace.d.ts +2 -0
- package/dist/trace.js +2 -0
- package/dist/types-CqDwuJAm.d.ts +33 -0
- package/dist/unresolved-file.d.ts +2 -0
- package/dist/unresolved-file.js +2 -0
- package/dist/{vesper-ClvmKzqD.js → vesper-CfxmMOy3.js} +1 -1
- package/dist/vite.d.ts +3 -5
- package/dist/{vitesse-black-BY6Qtyq-.js → vitesse-black-D9-_1mjV.js} +1 -1
- package/dist/{vitesse-dark-BT-v_EgR.js → vitesse-dark-DlSMLlr9.js} +1 -1
- package/dist/{vitesse-light-Box8ZFz6.js → vitesse-light-KRWWWztf.js} +1 -1
- package/package.json +176 -26
- package/dist/abap-LtYK6g-v.js +0 -3
- package/dist/actionscript-3-Czo0lKSf.js +0 -3
- package/dist/ada-twHwrVWN.js +0 -3
- package/dist/angular-html-Ct-40ew8.js +0 -33
- package/dist/angular-ts-D6akBVit.js +0 -27
- package/dist/apache-BIl2qPOf.js +0 -3
- package/dist/apex-BkQQFAhi.js +0 -3
- package/dist/apl-Cxjn4xYu.js +0 -17
- package/dist/applescript-CJ80B5XJ.js +0 -3
- package/dist/ara-IxnQjO6j.js +0 -3
- package/dist/asciidoc-Dsw6zvwf.js +0 -3
- package/dist/asm-wBDSgBbA.js +0 -3
- package/dist/astro-BPVTb8uX.js +0 -19
- package/dist/awk-D6dA05Ye.js +0 -3
- package/dist/ballerina-DIdXD2KH.js +0 -3
- package/dist/bat-hQslfzu-.js +0 -3
- package/dist/beancount-CXtOQ8oS.js +0 -3
- package/dist/berry-CgA2ea0_.js +0 -3
- package/dist/bibtex-BzgdqG3s.js +0 -3
- package/dist/bicep-CZ338dSk.js +0 -3
- package/dist/bird2-GLyzhwkD.js +0 -3
- package/dist/blade-0LMawyyw.js +0 -21
- package/dist/bsl-0NWGiiFE.js +0 -6
- package/dist/c-Dc0_AVM6.js +0 -6
- package/dist/c3-BLXk7BLN.js +0 -3
- package/dist/cadence-B1ELWULD.js +0 -3
- package/dist/cairo-DjG4M3vq.js +0 -6
- package/dist/catppuccin-frappe-COUg_LSX.js +0 -4
- package/dist/catppuccin-latte-r30LFfsa.js +0 -4
- package/dist/catppuccin-macchiato-D-EwZyPh.js +0 -4
- package/dist/catppuccin-mocha-C6RD5yh3.js +0 -4
- package/dist/clarity-2iIoRiLx.js +0 -3
- package/dist/clojure-DDsQ0FaV.js +0 -3
- package/dist/cmake-DPsCB_V6.js +0 -3
- package/dist/cobol-CocL1RYn.js +0 -11
- package/dist/codeowners-CxEKPWu0.js +0 -3
- package/dist/codeql-BwdvwJnv.js +0 -3
- package/dist/coffee-DtqnQNu5.js +0 -6
- package/dist/common-lisp-DJtwvW4V.js +0 -3
- package/dist/coq-Ds6Ye5el.js +0 -3
- package/dist/cpp-Mb4ikSI3.js +0 -25
- package/dist/crystal-D4OMbAh_.js +0 -19
- package/dist/csharp-CFKaLbHg.js +0 -3
- package/dist/css-DTzmO9U0.js +0 -6
- package/dist/csv-DqIVFkK7.js +0 -3
- package/dist/cue-B5KneM5p.js +0 -3
- package/dist/cypher-D8Bb8Cq2.js +0 -3
- package/dist/d-BQY8TDgQ.js +0 -3
- package/dist/dart-C6DUdjib.js +0 -3
- package/dist/dax-S-Noo-ku.js +0 -3
- package/dist/desktop-BgOb7Aj4.js +0 -3
- package/dist/diff-Blb4MjsC.js +0 -3
- package/dist/docker-PC1tuYpa.js +0 -3
- package/dist/dotenv-Dkdv7Sm2.js +0 -3
- package/dist/dream-maker-CngiPd8U.js +0 -3
- package/dist/edge-DrFNu-N9.js +0 -13
- package/dist/elixir-OpZyQ8Ht.js +0 -6
- package/dist/elm-CjX_545P.js +0 -6
- package/dist/emacs-lisp-DxhFFVu_.js +0 -3
- package/dist/erb-trZRdc47.js +0 -11
- package/dist/erlang-BJeTH9QH.js +0 -6
- package/dist/fennel-B3wtZRne.js +0 -3
- package/dist/fish-D7qAeWQz.js +0 -3
- package/dist/fluent-BjfpB34g.js +0 -3
- package/dist/fortran-fixed-form-B_eBTsj9.js +0 -6
- package/dist/fortran-free-form-yxJ7igsv.js +0 -3
- package/dist/fsharp-UvrT6oWG.js +0 -6
- package/dist/gdresource-Dl9wvKCd.js +0 -11
- package/dist/gdscript-jjgTGGzd.js +0 -3
- package/dist/gdshader-D7JfdFV3.js +0 -3
- package/dist/genie-DnK2KWIP.js +0 -3
- package/dist/gherkin-D6Lr12YQ.js +0 -3
- package/dist/git-commit-2LMniMoO.js +0 -6
- package/dist/git-rebase-DUOURRPN.js +0 -6
- package/dist/gleam-CTllUdfC.js +0 -3
- package/dist/glimmer-js-D_32hFh8.js +0 -15
- package/dist/glimmer-ts-CVt002zd.js +0 -15
- package/dist/glsl-pHhzolba.js +0 -8
- package/dist/gn-DDjbVPF4.js +0 -3
- package/dist/gnuplot-DgWvVXI8.js +0 -3
- package/dist/go-aXtTCanQ.js +0 -3
- package/dist/graphql-BjqekQIR.js +0 -17
- package/dist/groovy-Bw2Ku4bU.js +0 -3
- package/dist/hack-BITNGzgt.js +0 -11
- package/dist/haml-DVwRP8W9.js +0 -13
- package/dist/handlebars-T3TJj8Il.js +0 -15
- package/dist/haskell-CfGsE1Cf.js +0 -3
- package/dist/haxe-B0odltAZ.js +0 -3
- package/dist/hcl-DHg_Osgo.js +0 -3
- package/dist/hjson-Cuaphql8.js +0 -3
- package/dist/hlsl-BJLUNfne.js +0 -3
- package/dist/html-CamevgpM.js +0 -13
- package/dist/html-derivative-jMOJf6rB.js +0 -6
- package/dist/http-BEHztmFP.js +0 -15
- package/dist/hurl-LmFBxrwm.js +0 -13
- package/dist/hxml-BQ4V4Tez.js +0 -6
- package/dist/hy-CJKxDzbh.js +0 -3
- package/dist/imba-96qKoJCa.js +0 -3
- package/dist/ini-C24lZfdM.js +0 -3
- package/dist/java-Cfowl-Ex.js +0 -6
- package/dist/javascript-C4sF7sej.js +0 -6
- package/dist/jinja-CCAEwzP4.js +0 -10
- package/dist/jison-BKCoBkyT.js +0 -6
- package/dist/json-E4f3l6hr.js +0 -6
- package/dist/json5-xULSgPQI.js +0 -3
- package/dist/jsonc-Cu6rqcrJ.js +0 -3
- package/dist/jsonl-Bp0qqr10.js +0 -3
- package/dist/jsonnet-BafgE6cE.js +0 -3
- package/dist/jssm-Dx5A5sBR.js +0 -3
- package/dist/jsx-BZjOirBP.js +0 -6
- package/dist/julia-nEdJo0dp.js +0 -17
- package/dist/just-Brtw3q7S.js +0 -19
- package/dist/kanagawa-dragon-DExkuQAs.js +0 -4
- package/dist/kanagawa-lotus-qdYh7_RY.js +0 -4
- package/dist/kanagawa-wave-CSW_hADG.js +0 -4
- package/dist/kdl-DkTyxPcj.js +0 -3
- package/dist/kotlin-BHE8CoV9.js +0 -3
- package/dist/kusto-6FdaWTzR.js +0 -3
- package/dist/latex-QHQNiZDD.js +0 -6
- package/dist/lean-BwOKScIt.js +0 -3
- package/dist/less-BzbdhFUi.js +0 -3
- package/dist/liquid-DYQ7uW5u.js +0 -15
- package/dist/llvm-uY68ROGz.js +0 -3
- package/dist/log-Dad54gsi.js +0 -3
- package/dist/logo-DTXV8SKw.js +0 -3
- package/dist/lua-BhkUWs1q.js +0 -8
- package/dist/luau-YC4aaMmR.js +0 -3
- package/dist/make-B2ukzWs3.js +0 -3
- package/dist/markdown-CkmxmzqY.js +0 -3
- package/dist/marko-BHWvxp04.js +0 -15
- package/dist/matlab-CfRK6IMC.js +0 -3
- package/dist/mdc-Dg7VPYLa.js +0 -13
- package/dist/mdx-BK9ZufRc.js +0 -3
- package/dist/mermaid-r7OoIYpE.js +0 -3
- package/dist/mipsasm-EL46Y4Xg.js +0 -3
- package/dist/mojo-YCzvCoMT.js +0 -3
- package/dist/monokai-CREPpJ3k.js +0 -4
- package/dist/moonbit-B_9L5rST.js +0 -3
- package/dist/move-Dqi5fhOb.js +0 -3
- package/dist/narrat-D9rrR0H5.js +0 -3
- package/dist/nextflow-CgUAk9iA.js +0 -6
- package/dist/nextflow-groovy-CdFFX-gF.js +0 -3
- package/dist/nginx-Q-E8IJvs.js +0 -6
- package/dist/nim-CNcTuF14.js +0 -21
- package/dist/nix-Bm1Ax-Z3.js +0 -7
- package/dist/nushell-r7hBzeS_.js +0 -3
- package/dist/objective-c-6dJF64Dt.js +0 -3
- package/dist/objective-cpp-_ooRQ-PY.js +0 -3
- package/dist/ocaml-vm1Y8An6.js +0 -3
- package/dist/odin-vjOJSyfV.js +0 -3
- package/dist/one-dark-pro-Ev8UPkf4.js +0 -4
- package/dist/openscad-jn-f1Ocl.js +0 -3
- package/dist/pascal-D8-gNZ2I.js +0 -3
- package/dist/perl-Bbgb6Twx.js +0 -17
- package/dist/php-CBOR45_G.js +0 -19
- package/dist/pkl-C7lWzykI.js +0 -3
- package/dist/plsql-DCNXypXO.js +0 -3
- package/dist/po-IjpR1yHO.js +0 -3
- package/dist/polar-4pN1JrJ8.js +0 -3
- package/dist/postcss-D1gKt4z_.js +0 -3
- package/dist/powerquery-SrvS_NBM.js +0 -3
- package/dist/powershell-CpTLv_ai.js +0 -3
- package/dist/prisma-BWfa4-tI.js +0 -3
- package/dist/prolog-Bacii3Ue.js +0 -3
- package/dist/proto-ClkOcAW0.js +0 -3
- package/dist/pug-Cn_U_o_I.js +0 -13
- package/dist/puppet-CQlPp728.js +0 -3
- package/dist/purescript-CLpaGMbw.js +0 -3
- package/dist/python-BjnOIxPe.js +0 -3
- package/dist/qml-DNlrbxJT.js +0 -6
- package/dist/qmldir-Dz8ttxjf.js +0 -3
- package/dist/qss-Iltvkn1C.js +0 -3
- package/dist/r-VqTZMNY_.js +0 -6
- package/dist/racket-DRv7j6nv.js +0 -3
- package/dist/raku-DI9yGpeW.js +0 -3
- package/dist/razor-Bw2un3e8.js +0 -11
- package/dist/red-EHiRGXSv.js +0 -4
- package/dist/reg-DpJf71oO.js +0 -3
- package/dist/regexp-5HbFqwky.js +0 -6
- package/dist/rel-BT0iIKKw.js +0 -3
- package/dist/riscv-CvzikGLb.js +0 -3
- package/dist/ron-DzAo6FTJ.js +0 -3
- package/dist/rose-pine-DTI-z1Qp.js +0 -4
- package/dist/rose-pine-dawn-BIiGXpWs.js +0 -4
- package/dist/rose-pine-moon-DU4wt90U.js +0 -4
- package/dist/rosmsg-CyYq6XdT.js +0 -3
- package/dist/rst-BZPDb03W.js +0 -23
- package/dist/ruby-BbVp0_gQ.js +0 -31
- package/dist/rust-COBzcmTx.js +0 -3
- package/dist/sas-DSkdG4wF.js +0 -6
- package/dist/sass-DI2zJwx7.js +0 -3
- package/dist/scala-CtSYTRYT.js +0 -3
- package/dist/scheme-D3A2QBtM.js +0 -3
- package/dist/scss-BQ7uffpQ.js +0 -8
- package/dist/sdbl-CdQg5gu1.js +0 -3
- package/dist/shaderlab-CWP9wBCf.js +0 -6
- package/dist/shellscript-B42c0JAn.js +0 -6
- package/dist/shellsession-Oc9-NqAv.js +0 -6
- package/dist/smalltalk-BEQkVl4K.js +0 -3
- package/dist/solarized-dark-UHgjRWhr.js +0 -4
- package/dist/solarized-light-B-Zcwve2.js +0 -4
- package/dist/solidity-lB9VjfB9.js +0 -3
- package/dist/soy-tgh9u9aW.js +0 -6
- package/dist/sparql-B4t0ZbEe.js +0 -6
- package/dist/splunk-xP_ZjUH2.js +0 -3
- package/dist/sql-CrPlEQn4.js +0 -6
- package/dist/ssh-config-DXFPABYp.js +0 -3
- package/dist/stata-D_KqT8cj.js +0 -6
- package/dist/stylus-ZZDn1yUO.js +0 -3
- package/dist/surrealql-C0KhgoyZ.js +0 -6
- package/dist/svelte-DuHT0xxw.js +0 -15
- package/dist/swift-BTPQlRLK.js +0 -3
- package/dist/system-verilog-BEoxaBuU.js +0 -3
- package/dist/systemd-DFbUltlW.js +0 -3
- package/dist/talonscript-CLxaFu-b.js +0 -3
- package/dist/tasl-_AAbKiWM.js +0 -3
- package/dist/tcl-DLe0Tsfm.js +0 -3
- package/dist/templ-DF54artD.js +0 -13
- package/dist/terraform-v0KN9QQh.js +0 -3
- package/dist/tex-Bbhb8xAP.js +0 -6
- package/dist/toml-B7BHZIqX.js +0 -3
- package/dist/ts-tags-DH1AB-Ri.js +0 -59
- package/dist/tsv-BorGVq2Z.js +0 -3
- package/dist/tsx-BR8s1Lhs.js +0 -6
- package/dist/turtle-BEG5g_eT.js +0 -3
- package/dist/twig-DziFF7iU.js +0 -19
- package/dist/typescript-D8TR6ff2.js +0 -6
- package/dist/typespec-C_R5TbvO.js +0 -3
- package/dist/typst-BV9w0z8-.js +0 -3
- package/dist/v-DfbeXLo8.js +0 -3
- package/dist/vala-BnnASFsX.js +0 -3
- package/dist/vb-DU29mvss.js +0 -3
- package/dist/verilog-BW5U03XW.js +0 -3
- package/dist/vhdl-Co2XFKY7.js +0 -3
- package/dist/viml-BReTXeDA.js +0 -3
- package/dist/vue-BRy8iDCZ.js +0 -31
- package/dist/vue-html-B24bjO_3.js +0 -6
- package/dist/vue-vine-l7O7Mg81.js +0 -19
- package/dist/vyper-C6KGx0YU.js +0 -3
- package/dist/wasm-BRCjOXGL.js +0 -7
- package/dist/wasm-gNIKwGlD.js +0 -3
- package/dist/wenyan-BeysbCrW.js +0 -3
- package/dist/wgsl-1s5rV5xS.js +0 -3
- package/dist/wikitext-wjhjmmzD.js +0 -3
- package/dist/wit-CeQiCbz_.js +0 -3
- package/dist/wolfram-CcZPfnLd.js +0 -3
- package/dist/xml-CduVPlYa.js +0 -8
- package/dist/xsl-BeH_vLTK.js +0 -6
- package/dist/yaml-Cb0uRU1q.js +0 -6
- package/dist/zenscript-BoijL7rl.js +0 -3
- package/dist/zig-lTQvxhLD.js +0 -3
|
@@ -0,0 +1,1113 @@
|
|
|
1
|
+
import { t as uiErrorDiagnostics } from "./error-diagnostics-B4hMpJRL.js";
|
|
2
|
+
import { t as Markdown } from "./markdown-BoLBN0qH.js";
|
|
3
|
+
import { t as PromptInput } from "./prompt-input-BbnCb80O.js";
|
|
4
|
+
import { t as AvatarStack } from "./avatar-stack-DM6HRnc0.js";
|
|
5
|
+
import { a as consumedPointerEvents, c as shakeEventName, i as useCommentsContext, l as swallowNextClick, n as provideComments, o as pathOf, r as useComments, s as shakeDirtyComposers, u as useDocumentPointerDown } from "./comments-C08J3z4e.js";
|
|
6
|
+
import { n as MarkerContent, t as Marker } from "./marker-Di2ZG_k1.js";
|
|
7
|
+
import { computed, defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref, resolveComponent, useId, watch } from "vue";
|
|
8
|
+
//#region src/internal/comment-person.ts
|
|
9
|
+
const displayName = (user) => user.name ?? user.id;
|
|
10
|
+
function toPerson(user) {
|
|
11
|
+
return {
|
|
12
|
+
id: user.id,
|
|
13
|
+
image: user.image,
|
|
14
|
+
name: displayName(user)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** One line of a message for a label: Markdown marks and line breaks gone, and cut at `length`. */
|
|
18
|
+
function excerpt(body, length = 60) {
|
|
19
|
+
const line = body.replace(/\s+/g, " ").trim();
|
|
20
|
+
return line.length > length ? `${line.slice(0, length - 1)}…` : line;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/components/comment-composer.ts
|
|
24
|
+
const placeholders = {
|
|
25
|
+
comment: "Add a comment",
|
|
26
|
+
edit: "Edit your comment",
|
|
27
|
+
reply: "Reply"
|
|
28
|
+
};
|
|
29
|
+
/** The name of the send button. A comment on a page is sent as a comment, and an answer in a thread as a reply. */
|
|
30
|
+
const sendLabels = {
|
|
31
|
+
comment: "Comment",
|
|
32
|
+
edit: "Save",
|
|
33
|
+
reply: "Reply"
|
|
34
|
+
};
|
|
35
|
+
const labels = {
|
|
36
|
+
comment: "Comment",
|
|
37
|
+
edit: "Edit comment",
|
|
38
|
+
reply: "Reply"
|
|
39
|
+
};
|
|
40
|
+
const CommentComposer = defineComponent({
|
|
41
|
+
name: "CommentComposer",
|
|
42
|
+
props: {
|
|
43
|
+
modelValue: {
|
|
44
|
+
default: "",
|
|
45
|
+
type: String
|
|
46
|
+
},
|
|
47
|
+
/** The ids of the people mentioned so far. */
|
|
48
|
+
mentions: {
|
|
49
|
+
default: () => [],
|
|
50
|
+
type: Array
|
|
51
|
+
},
|
|
52
|
+
/** Whose avatar shows beside the box. */
|
|
53
|
+
user: { type: Object },
|
|
54
|
+
variant: {
|
|
55
|
+
default: "comment",
|
|
56
|
+
type: String
|
|
57
|
+
},
|
|
58
|
+
placeholder: { type: String },
|
|
59
|
+
/** A send is running. The box keeps its text and cannot send again. */
|
|
60
|
+
busy: {
|
|
61
|
+
default: false,
|
|
62
|
+
type: Boolean
|
|
63
|
+
},
|
|
64
|
+
/** Why the last send failed. */
|
|
65
|
+
error: { type: String },
|
|
66
|
+
/** Focus the box when it appears. */
|
|
67
|
+
autofocus: {
|
|
68
|
+
default: true,
|
|
69
|
+
type: Boolean
|
|
70
|
+
},
|
|
71
|
+
/** Treat a click outside as a close, or as a shake when there is text. Turn it off when the parent decides. */
|
|
72
|
+
guard: {
|
|
73
|
+
default: true,
|
|
74
|
+
type: Boolean
|
|
75
|
+
},
|
|
76
|
+
/** People whose names the text may hold, such as the authors of a thread. Only mentions of a person whose `@name` is still in the text are sent. */
|
|
77
|
+
people: {
|
|
78
|
+
default: () => [],
|
|
79
|
+
type: Array
|
|
80
|
+
},
|
|
81
|
+
/** Finds people for `@mentions`. Without it the box has no mention menu. */
|
|
82
|
+
users: { type: Function }
|
|
83
|
+
},
|
|
84
|
+
emits: [
|
|
85
|
+
"update:modelValue",
|
|
86
|
+
"update:mentions",
|
|
87
|
+
"submit",
|
|
88
|
+
"cancel"
|
|
89
|
+
],
|
|
90
|
+
setup(props, { emit, expose }) {
|
|
91
|
+
const root = ref(null);
|
|
92
|
+
const shaking = ref(null);
|
|
93
|
+
const menu = ref(null);
|
|
94
|
+
const picked = /* @__PURE__ */ new Map();
|
|
95
|
+
const menuId = useId();
|
|
96
|
+
const optionId = (index) => `${menuId}-option-${index}`;
|
|
97
|
+
let timer;
|
|
98
|
+
let lookup = 0;
|
|
99
|
+
let mentionCaret;
|
|
100
|
+
const nameOf = (id) => {
|
|
101
|
+
const person = props.people.find((entry) => entry.id === id);
|
|
102
|
+
return picked.get(id) ?? (person ? displayName(person) : void 0);
|
|
103
|
+
};
|
|
104
|
+
const textarea = () => root.value?.querySelector("textarea") ?? null;
|
|
105
|
+
const hasText = () => props.modelValue.trim().length > 0;
|
|
106
|
+
const focus = () => textarea()?.focus();
|
|
107
|
+
async function shake() {
|
|
108
|
+
const reduced = typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
109
|
+
shaking.value = null;
|
|
110
|
+
await nextTick();
|
|
111
|
+
root.value?.offsetWidth;
|
|
112
|
+
shaking.value = reduced ? "flash" : "shake";
|
|
113
|
+
clearTimeout(timer);
|
|
114
|
+
timer = setTimeout(() => shaking.value = null, 450);
|
|
115
|
+
focus();
|
|
116
|
+
}
|
|
117
|
+
const onShake = () => void shake();
|
|
118
|
+
onMounted(() => {
|
|
119
|
+
root.value?.addEventListener(shakeEventName, onShake);
|
|
120
|
+
if (props.autofocus) nextTick(focus);
|
|
121
|
+
});
|
|
122
|
+
onBeforeUnmount(() => {
|
|
123
|
+
root.value?.removeEventListener(shakeEventName, onShake);
|
|
124
|
+
clearTimeout(timer);
|
|
125
|
+
});
|
|
126
|
+
expose({
|
|
127
|
+
focus,
|
|
128
|
+
shake
|
|
129
|
+
});
|
|
130
|
+
watch(menu, (open) => {
|
|
131
|
+
const field = textarea();
|
|
132
|
+
if (!field) return;
|
|
133
|
+
field.setAttribute("role", "combobox");
|
|
134
|
+
field.setAttribute("aria-autocomplete", "list");
|
|
135
|
+
field.setAttribute("aria-expanded", String(open !== null));
|
|
136
|
+
if (open) {
|
|
137
|
+
field.setAttribute("aria-controls", `${menuId}-list`);
|
|
138
|
+
field.setAttribute("aria-activedescendant", optionId(open.index));
|
|
139
|
+
} else {
|
|
140
|
+
field.removeAttribute("aria-controls");
|
|
141
|
+
field.removeAttribute("aria-activedescendant");
|
|
142
|
+
}
|
|
143
|
+
}, { deep: true });
|
|
144
|
+
useDocumentPointerDown((event) => {
|
|
145
|
+
if (!props.guard || !root.value || pathOf(event).includes(root.value)) return;
|
|
146
|
+
consumedPointerEvents.add(event);
|
|
147
|
+
if (hasText()) {
|
|
148
|
+
event.stopPropagation();
|
|
149
|
+
swallowNextClick();
|
|
150
|
+
shake();
|
|
151
|
+
} else emit("cancel");
|
|
152
|
+
});
|
|
153
|
+
function checkSelection() {
|
|
154
|
+
const field = textarea();
|
|
155
|
+
if (!field || field.selectionStart === mentionCaret && field.selectionEnd === mentionCaret) return;
|
|
156
|
+
lookup++;
|
|
157
|
+
mentionCaret = void 0;
|
|
158
|
+
menu.value = null;
|
|
159
|
+
}
|
|
160
|
+
function choose(person) {
|
|
161
|
+
checkSelection();
|
|
162
|
+
const field = textarea();
|
|
163
|
+
const current = menu.value;
|
|
164
|
+
if (!field || !current) return;
|
|
165
|
+
if (field.selectionStart !== field.selectionEnd || field.value.slice(0, field.selectionStart) !== current.before) {
|
|
166
|
+
menu.value = null;
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const caret = field.selectionStart;
|
|
170
|
+
const insert = `@${displayName(person)} `;
|
|
171
|
+
const next = props.modelValue.slice(0, current.start) + insert + props.modelValue.slice(caret);
|
|
172
|
+
picked.set(person.id, displayName(person));
|
|
173
|
+
emit("update:modelValue", next);
|
|
174
|
+
if (!props.mentions.includes(person.id)) emit("update:mentions", [...props.mentions, person.id]);
|
|
175
|
+
menu.value = null;
|
|
176
|
+
nextTick(() => {
|
|
177
|
+
const position = current.start + insert.length;
|
|
178
|
+
field.setSelectionRange(position, position);
|
|
179
|
+
field.focus();
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
async function findPeople(field) {
|
|
183
|
+
const run = ++lookup;
|
|
184
|
+
mentionCaret = field.selectionStart;
|
|
185
|
+
const search = props.users;
|
|
186
|
+
const before = field.value.slice(0, field.selectionStart);
|
|
187
|
+
const match = /(^|\s)@([^\s@]*)$/.exec(before);
|
|
188
|
+
if (!search || !match || field.selectionStart !== field.selectionEnd) {
|
|
189
|
+
menu.value = null;
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const start = before.length - match[2].length - 1;
|
|
193
|
+
const items = await search(match[2]).catch(() => []);
|
|
194
|
+
checkSelection();
|
|
195
|
+
if (run !== lookup) return;
|
|
196
|
+
const sameToken = field.selectionStart === field.selectionEnd && field.value.slice(0, field.selectionStart) === before;
|
|
197
|
+
menu.value = sameToken && items.length > 0 ? {
|
|
198
|
+
before,
|
|
199
|
+
index: 0,
|
|
200
|
+
items,
|
|
201
|
+
start
|
|
202
|
+
} : null;
|
|
203
|
+
}
|
|
204
|
+
function submit(payload) {
|
|
205
|
+
if (props.busy || !payload.text) return;
|
|
206
|
+
const mentions = props.mentions.filter((id) => {
|
|
207
|
+
const name = nameOf(id);
|
|
208
|
+
if (name === void 0) return false;
|
|
209
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
210
|
+
return new RegExp(`(^|[^\\p{L}\\p{N}\\p{M}_])@${escaped}(?=$|[^\\p{L}\\p{N}\\p{M}_])`, "iu").test(payload.text);
|
|
211
|
+
});
|
|
212
|
+
emit("submit", {
|
|
213
|
+
body: payload.text,
|
|
214
|
+
mentions: [...mentions]
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function keydown(event) {
|
|
218
|
+
if (event.isComposing) return;
|
|
219
|
+
const open = menu.value;
|
|
220
|
+
if (open && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
|
|
221
|
+
event.preventDefault();
|
|
222
|
+
const step = event.key === "ArrowDown" ? 1 : -1;
|
|
223
|
+
open.index = (open.index + step + open.items.length) % open.items.length;
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (open && (event.key === "Enter" || event.key === "Tab") && !event.shiftKey) {
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
event.stopPropagation();
|
|
229
|
+
choose(open.items[open.index]);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (event.key !== "Escape") return;
|
|
233
|
+
event.preventDefault();
|
|
234
|
+
event.stopPropagation();
|
|
235
|
+
if (open) menu.value = null;
|
|
236
|
+
else if (hasText()) shake();
|
|
237
|
+
else emit("cancel");
|
|
238
|
+
}
|
|
239
|
+
return () => h("div", {
|
|
240
|
+
"data-busy": props.busy ? "true" : void 0,
|
|
241
|
+
"data-dirty": hasText() ? "true" : void 0,
|
|
242
|
+
"data-shake": shaking.value ?? void 0,
|
|
243
|
+
"data-slot": "comment-composer",
|
|
244
|
+
"data-variant": props.variant,
|
|
245
|
+
onKeydownCapture: keydown,
|
|
246
|
+
onKeyupCapture: checkSelection,
|
|
247
|
+
onClickCapture: checkSelection,
|
|
248
|
+
onSelectCapture: checkSelection,
|
|
249
|
+
onInputCapture: (event) => {
|
|
250
|
+
if (event.target instanceof HTMLTextAreaElement) findPeople(event.target);
|
|
251
|
+
},
|
|
252
|
+
ref: root
|
|
253
|
+
}, [props.user ? h(AvatarStack, {
|
|
254
|
+
"aria-hidden": "true",
|
|
255
|
+
people: [toPerson(props.user)],
|
|
256
|
+
size: "sm"
|
|
257
|
+
}) : null, h("div", { "data-slot": "comment-composer-box" }, [
|
|
258
|
+
h(PromptInput, {
|
|
259
|
+
"aria-label": labels[props.variant],
|
|
260
|
+
attachments: false,
|
|
261
|
+
modelValue: props.modelValue,
|
|
262
|
+
placeholder: props.placeholder ?? placeholders[props.variant],
|
|
263
|
+
submitLabel: sendLabels[props.variant],
|
|
264
|
+
onSubmit: submit,
|
|
265
|
+
"onUpdate:modelValue": (value) => emit("update:modelValue", value)
|
|
266
|
+
}),
|
|
267
|
+
menu.value ? h("ul", {
|
|
268
|
+
"aria-label": "People",
|
|
269
|
+
"data-slot": "comment-composer-mentions",
|
|
270
|
+
id: `${menuId}-list`,
|
|
271
|
+
role: "listbox"
|
|
272
|
+
}, menu.value.items.map((person, index) => h("li", {
|
|
273
|
+
"aria-selected": String(index === menu.value?.index),
|
|
274
|
+
"data-slot": "comment-composer-mention",
|
|
275
|
+
id: optionId(index),
|
|
276
|
+
key: person.id,
|
|
277
|
+
onMousedown: (event) => {
|
|
278
|
+
event.preventDefault();
|
|
279
|
+
choose(person);
|
|
280
|
+
},
|
|
281
|
+
role: "option"
|
|
282
|
+
}, displayName(person)))) : null,
|
|
283
|
+
props.error ? h("p", {
|
|
284
|
+
"data-slot": "comment-composer-error",
|
|
285
|
+
role: "alert"
|
|
286
|
+
}, props.error) : null
|
|
287
|
+
])]);
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/internal/comment-time.ts
|
|
292
|
+
const units = [
|
|
293
|
+
["day", 864e5],
|
|
294
|
+
["hour", 36e5],
|
|
295
|
+
["minute", 6e4]
|
|
296
|
+
];
|
|
297
|
+
/** "5 minutes ago", "yesterday", or "now" for under a minute. */
|
|
298
|
+
function timeAgo(at, now = Date.now()) {
|
|
299
|
+
const difference = at - now;
|
|
300
|
+
for (const [unit, size] of units) if (Math.abs(difference) >= size) return new Intl.RelativeTimeFormat("en", { numeric: "auto" }).format(Math.round(difference / size), unit);
|
|
301
|
+
return "now";
|
|
302
|
+
}
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region src/components/comment-list.ts
|
|
305
|
+
const commentsProp = { type: Object };
|
|
306
|
+
const CommentFilters = defineComponent({
|
|
307
|
+
name: "CommentFilters",
|
|
308
|
+
props: { comments: commentsProp },
|
|
309
|
+
setup(props) {
|
|
310
|
+
const UButton = resolveComponent("UButton");
|
|
311
|
+
const comments = useCommentsContext(props.comments);
|
|
312
|
+
return () => {
|
|
313
|
+
const button = (key, label, count) => h(UButton, {
|
|
314
|
+
"aria-pressed": String(comments.filters[key]),
|
|
315
|
+
color: "neutral",
|
|
316
|
+
"data-slot": "comment-filter",
|
|
317
|
+
"data-state": comments.filters[key] ? "on" : "off",
|
|
318
|
+
key,
|
|
319
|
+
label: count === void 0 ? label : `${label} ${count}`,
|
|
320
|
+
onClick: () => comments.filters[key] = !comments.filters[key],
|
|
321
|
+
size: "xs",
|
|
322
|
+
variant: comments.filters[key] ? "soft" : "ghost"
|
|
323
|
+
});
|
|
324
|
+
return h("div", {
|
|
325
|
+
"aria-label": "Filter comments",
|
|
326
|
+
"data-slot": "comment-filters",
|
|
327
|
+
role: "group"
|
|
328
|
+
}, [
|
|
329
|
+
button("open", "Open", comments.counts.value.open),
|
|
330
|
+
button("resolved", "Resolved", comments.counts.value.resolved),
|
|
331
|
+
button("mine", "Mine")
|
|
332
|
+
]);
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
function preview(thread) {
|
|
337
|
+
const text = thread.anchor.kind === "text" ? thread.anchor.exact : "";
|
|
338
|
+
return thread.messages[0]?.body ?? text;
|
|
339
|
+
}
|
|
340
|
+
const CommentList = defineComponent({
|
|
341
|
+
name: "CommentList",
|
|
342
|
+
props: {
|
|
343
|
+
comments: commentsProp,
|
|
344
|
+
/** Goes to the page of a thread that is not on this page. Defaults to `location.assign`. */
|
|
345
|
+
navigate: { type: Function }
|
|
346
|
+
},
|
|
347
|
+
emits: ["select"],
|
|
348
|
+
setup(props, { emit }) {
|
|
349
|
+
const UButton = resolveComponent("UButton");
|
|
350
|
+
const comments = useCommentsContext(props.comments);
|
|
351
|
+
function select(thread, event) {
|
|
352
|
+
emit("select", thread);
|
|
353
|
+
if (event && (event.ctrlKey || event.metaKey || event.shiftKey || event.button !== 0)) return;
|
|
354
|
+
event?.preventDefault();
|
|
355
|
+
if (thread.subject.kind === comments.subject.value.kind && thread.subject.id === comments.subject.value.id) comments.open(thread, { scroll: true });
|
|
356
|
+
else if (comments.close()) (props.navigate ?? ((href) => window.location.assign(href)))(comments.link(thread));
|
|
357
|
+
}
|
|
358
|
+
return () => {
|
|
359
|
+
const scopeButton = (value, label) => h(UButton, {
|
|
360
|
+
"aria-pressed": String(comments.scope.value === value),
|
|
361
|
+
color: "neutral",
|
|
362
|
+
"data-slot": "comment-list-scope",
|
|
363
|
+
label,
|
|
364
|
+
onClick: () => comments.scope.value = value,
|
|
365
|
+
size: "xs",
|
|
366
|
+
variant: comments.scope.value === value ? "soft" : "ghost"
|
|
367
|
+
});
|
|
368
|
+
const rows = comments.listed.value;
|
|
369
|
+
return h("section", {
|
|
370
|
+
"aria-label": "Comments",
|
|
371
|
+
"data-comments-ui": "",
|
|
372
|
+
"data-slot": "comment-list"
|
|
373
|
+
}, [h("header", { "data-slot": "comment-list-header" }, [h("div", {
|
|
374
|
+
"data-slot": "comment-list-scopes",
|
|
375
|
+
role: "group",
|
|
376
|
+
"aria-label": "Scope"
|
|
377
|
+
}, [scopeButton("page", "This page"), scopeButton("site", "All pages")]), h(CommentFilters, { comments })]), rows.length === 0 ? h("p", {
|
|
378
|
+
"data-slot": "comment-list-empty",
|
|
379
|
+
role: "status"
|
|
380
|
+
}, comments.status.value === "loading" && comments.threads.value.length === 0 ? "Loading comments." : comments.status.value === "error" ? "The comments could not load." : "No comments here.") : h("ol", { "data-slot": "comment-list-items" }, rows.map((thread) => {
|
|
381
|
+
const detached = comments.positions.value.get(thread.id)?.detached === true;
|
|
382
|
+
const replies = thread.messages.length - 1;
|
|
383
|
+
const person = toPerson(thread.author);
|
|
384
|
+
return h("li", { key: thread.id }, [h("a", {
|
|
385
|
+
"aria-current": comments.openId.value === thread.id ? "true" : void 0,
|
|
386
|
+
"data-detached": detached ? "true" : void 0,
|
|
387
|
+
"data-slot": "comment-list-item",
|
|
388
|
+
"data-status": thread.status,
|
|
389
|
+
href: comments.link(thread),
|
|
390
|
+
onClick: (event) => select(thread, event)
|
|
391
|
+
}, [
|
|
392
|
+
h("span", { "data-slot": "comment-list-number" }, String(thread.n)),
|
|
393
|
+
h(AvatarStack, {
|
|
394
|
+
"aria-hidden": "true",
|
|
395
|
+
people: [person],
|
|
396
|
+
size: "sm"
|
|
397
|
+
}),
|
|
398
|
+
h("span", { "data-slot": "comment-list-body" }, [h("span", { "data-slot": "comment-list-text" }, preview(thread)), h("span", { "data-slot": "comment-list-meta" }, [
|
|
399
|
+
h("span", displayName(thread.author)),
|
|
400
|
+
h("span", timeAgo(thread.updatedAt)),
|
|
401
|
+
replies > 0 ? h("span", `${replies} ${replies === 1 ? "reply" : "replies"}`) : null,
|
|
402
|
+
thread.status === "resolved" ? h("span", "Resolved") : null,
|
|
403
|
+
detached ? h("span", { "data-slot": "comment-list-detached" }, "Detached") : null,
|
|
404
|
+
comments.scope.value === "site" && thread.subject.kind === "page" ? h("span", thread.subject.id) : null
|
|
405
|
+
])])
|
|
406
|
+
])]);
|
|
407
|
+
}))]);
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
const CommentToolbar = defineComponent({
|
|
412
|
+
name: "CommentToolbar",
|
|
413
|
+
props: {
|
|
414
|
+
comments: commentsProp,
|
|
415
|
+
/** The people on this page, from Realtime. Shown as a stack of avatars. */
|
|
416
|
+
people: {
|
|
417
|
+
default: () => [],
|
|
418
|
+
type: Array
|
|
419
|
+
}
|
|
420
|
+
},
|
|
421
|
+
setup(props, { slots }) {
|
|
422
|
+
const UButton = resolveComponent("UButton");
|
|
423
|
+
const comments = useCommentsContext(props.comments);
|
|
424
|
+
return () => {
|
|
425
|
+
const open = comments.pageThreads.value.length;
|
|
426
|
+
return h("div", {
|
|
427
|
+
"aria-label": "Comments",
|
|
428
|
+
"data-comments-ui": "",
|
|
429
|
+
"data-slot": "comment-toolbar",
|
|
430
|
+
role: "toolbar"
|
|
431
|
+
}, [
|
|
432
|
+
h(UButton, {
|
|
433
|
+
"aria-keyshortcuts": "C",
|
|
434
|
+
"aria-label": "Comment mode",
|
|
435
|
+
"aria-pressed": String(comments.active.value),
|
|
436
|
+
color: "neutral",
|
|
437
|
+
"data-slot": "comment-toolbar-mode",
|
|
438
|
+
icon: "i-ph-chat-circle",
|
|
439
|
+
onClick: comments.toggle,
|
|
440
|
+
size: "sm",
|
|
441
|
+
title: "Comment (C)",
|
|
442
|
+
variant: comments.active.value ? "solid" : "ghost"
|
|
443
|
+
}),
|
|
444
|
+
h(UButton, {
|
|
445
|
+
"aria-label": `Comment list, ${open} on this page`,
|
|
446
|
+
"aria-pressed": String(comments.listOpen.value),
|
|
447
|
+
color: "neutral",
|
|
448
|
+
"data-slot": "comment-toolbar-list",
|
|
449
|
+
icon: "i-ph-list-bullets",
|
|
450
|
+
label: String(open),
|
|
451
|
+
onClick: () => comments.listOpen.value = !comments.listOpen.value,
|
|
452
|
+
size: "sm",
|
|
453
|
+
variant: comments.listOpen.value ? "solid" : "ghost"
|
|
454
|
+
}),
|
|
455
|
+
h(UButton, {
|
|
456
|
+
"aria-label": "Comment on page",
|
|
457
|
+
color: "neutral",
|
|
458
|
+
"data-slot": "comment-toolbar-page",
|
|
459
|
+
icon: "i-ph-note-pencil",
|
|
460
|
+
onClick: () => {
|
|
461
|
+
comments.startDraft("page");
|
|
462
|
+
},
|
|
463
|
+
size: "sm",
|
|
464
|
+
title: "Comment on the whole page",
|
|
465
|
+
variant: "ghost"
|
|
466
|
+
}),
|
|
467
|
+
props.people.length > 0 ? h(AvatarStack, {
|
|
468
|
+
people: props.people,
|
|
469
|
+
size: "sm",
|
|
470
|
+
variant: "outline"
|
|
471
|
+
}) : null,
|
|
472
|
+
slots.default?.()
|
|
473
|
+
]);
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
//#endregion
|
|
478
|
+
//#region src/components/comment-pin.ts
|
|
479
|
+
const CommentPin = defineComponent({
|
|
480
|
+
name: "CommentPin",
|
|
481
|
+
props: {
|
|
482
|
+
/** The thread number. A draft has none. */
|
|
483
|
+
n: { type: Number },
|
|
484
|
+
author: { type: Object },
|
|
485
|
+
status: {
|
|
486
|
+
default: "open",
|
|
487
|
+
type: String
|
|
488
|
+
},
|
|
489
|
+
/** A short piece of the comment. It is part of the label that a screen reader says. */
|
|
490
|
+
excerpt: { type: String },
|
|
491
|
+
/** The thread of this pin is open. */
|
|
492
|
+
active: {
|
|
493
|
+
default: false,
|
|
494
|
+
type: Boolean
|
|
495
|
+
},
|
|
496
|
+
/** The comment is still being written. */
|
|
497
|
+
draft: {
|
|
498
|
+
default: false,
|
|
499
|
+
type: Boolean
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
emits: [
|
|
503
|
+
"select",
|
|
504
|
+
"hover",
|
|
505
|
+
"leave"
|
|
506
|
+
],
|
|
507
|
+
setup(props, { emit }) {
|
|
508
|
+
const label = () => {
|
|
509
|
+
if (props.draft) return "New comment";
|
|
510
|
+
const by = props.author ? ` by ${displayName(props.author)}` : "";
|
|
511
|
+
const text = props.excerpt ? `: ${props.excerpt}` : "";
|
|
512
|
+
return `Comment ${props.n}${by}${text}${props.status === "resolved" ? ", resolved" : ""}`;
|
|
513
|
+
};
|
|
514
|
+
return () => h("button", {
|
|
515
|
+
"aria-expanded": props.draft ? void 0 : String(props.active),
|
|
516
|
+
"aria-label": label(),
|
|
517
|
+
"data-active": props.active ? "true" : void 0,
|
|
518
|
+
"data-draft": props.draft ? "true" : void 0,
|
|
519
|
+
"data-slot": "comment-pin",
|
|
520
|
+
"data-status": props.status,
|
|
521
|
+
onBlur: () => emit("leave"),
|
|
522
|
+
onClick: () => emit("select"),
|
|
523
|
+
onFocus: () => emit("hover"),
|
|
524
|
+
onPointerenter: () => emit("hover"),
|
|
525
|
+
onPointerleave: () => emit("leave"),
|
|
526
|
+
type: "button"
|
|
527
|
+
}, [props.author ? h(AvatarStack, {
|
|
528
|
+
"aria-hidden": "true",
|
|
529
|
+
people: [toPerson(props.author)],
|
|
530
|
+
size: "sm"
|
|
531
|
+
}) : null, props.draft || props.n === void 0 ? null : h("span", { "data-slot": "comment-pin-number" }, String(props.n))]);
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
//#endregion
|
|
535
|
+
//#region src/components/comment-thread.ts
|
|
536
|
+
function reason(error) {
|
|
537
|
+
return error instanceof Error ? error.message : "That did not work. Try again.";
|
|
538
|
+
}
|
|
539
|
+
const CommentReply = defineComponent({
|
|
540
|
+
name: "CommentReply",
|
|
541
|
+
props: {
|
|
542
|
+
message: {
|
|
543
|
+
required: true,
|
|
544
|
+
type: Object
|
|
545
|
+
},
|
|
546
|
+
/** The signed-in user may edit and delete this message. */
|
|
547
|
+
editable: {
|
|
548
|
+
default: false,
|
|
549
|
+
type: Boolean
|
|
550
|
+
},
|
|
551
|
+
/** The message, and its author, show in one line without actions. */
|
|
552
|
+
compact: {
|
|
553
|
+
default: false,
|
|
554
|
+
type: Boolean
|
|
555
|
+
},
|
|
556
|
+
/** Deleting asks first. Deleting the first message of a thread deletes the whole thread, so a thread sets it there. */
|
|
557
|
+
confirmDelete: {
|
|
558
|
+
default: false,
|
|
559
|
+
type: Boolean
|
|
560
|
+
},
|
|
561
|
+
/** People whose `@name` the message may hold, so an edit keeps their mentions. */
|
|
562
|
+
people: {
|
|
563
|
+
default: () => [],
|
|
564
|
+
type: Array
|
|
565
|
+
},
|
|
566
|
+
users: { type: Function },
|
|
567
|
+
/** Saves an edit. Gets `(messageId, body, mentions)`. */
|
|
568
|
+
onEdit: { type: Function },
|
|
569
|
+
/** Deletes the message. Gets `(messageId)`. */
|
|
570
|
+
onDelete: { type: Function }
|
|
571
|
+
},
|
|
572
|
+
setup(props) {
|
|
573
|
+
const UButton = resolveComponent("UButton");
|
|
574
|
+
const editing = ref(false);
|
|
575
|
+
const confirming = ref(false);
|
|
576
|
+
const busy = ref(false);
|
|
577
|
+
const error = ref();
|
|
578
|
+
const draft = ref("");
|
|
579
|
+
const mentions = ref([]);
|
|
580
|
+
async function run(task) {
|
|
581
|
+
if (busy.value) return false;
|
|
582
|
+
busy.value = true;
|
|
583
|
+
error.value = void 0;
|
|
584
|
+
try {
|
|
585
|
+
await task();
|
|
586
|
+
return true;
|
|
587
|
+
} catch (cause) {
|
|
588
|
+
error.value = reason(cause);
|
|
589
|
+
return false;
|
|
590
|
+
} finally {
|
|
591
|
+
busy.value = false;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
function startEdit() {
|
|
595
|
+
draft.value = props.message.body;
|
|
596
|
+
mentions.value = [...props.message.mentions];
|
|
597
|
+
error.value = void 0;
|
|
598
|
+
editing.value = true;
|
|
599
|
+
}
|
|
600
|
+
async function save(submit) {
|
|
601
|
+
if (!props.onEdit) return;
|
|
602
|
+
const submitted = draft.value;
|
|
603
|
+
const submittedMentions = mentions.value;
|
|
604
|
+
const savedMentions = submit.body === props.message.body ? [.../* @__PURE__ */ new Set([...props.message.mentions, ...submit.mentions])] : submit.mentions;
|
|
605
|
+
if (await run(() => props.onEdit?.(props.message.id, submit.body, savedMentions)) && draft.value === submitted && mentions.value === submittedMentions) editing.value = false;
|
|
606
|
+
}
|
|
607
|
+
async function remove() {
|
|
608
|
+
if (!props.onDelete) return;
|
|
609
|
+
if (await run(() => props.onDelete?.(props.message.id))) confirming.value = false;
|
|
610
|
+
}
|
|
611
|
+
return () => {
|
|
612
|
+
const { message } = props;
|
|
613
|
+
return h("div", {
|
|
614
|
+
"data-compact": props.compact ? "true" : void 0,
|
|
615
|
+
"data-editing": editing.value ? "true" : void 0,
|
|
616
|
+
"data-slot": "comment-reply"
|
|
617
|
+
}, [
|
|
618
|
+
h(AvatarStack, {
|
|
619
|
+
"aria-hidden": "true",
|
|
620
|
+
people: [toPerson(message.author)],
|
|
621
|
+
size: "sm"
|
|
622
|
+
}),
|
|
623
|
+
h("div", { "data-slot": "comment-reply-content" }, [
|
|
624
|
+
h("div", { "data-slot": "comment-reply-header" }, [
|
|
625
|
+
h("span", { "data-slot": "comment-reply-author" }, displayName(message.author)),
|
|
626
|
+
message.actor ? h("span", { "data-slot": "comment-reply-actor" }, `via ${message.actor.name ?? message.actor.id}`) : null,
|
|
627
|
+
h("time", {
|
|
628
|
+
"data-slot": "comment-reply-time",
|
|
629
|
+
datetime: new Date(message.createdAt).toISOString(),
|
|
630
|
+
title: new Date(message.createdAt).toLocaleString()
|
|
631
|
+
}, timeAgo(message.createdAt)),
|
|
632
|
+
message.editedAt ? h("span", { "data-slot": "comment-reply-edited" }, "edited") : null
|
|
633
|
+
]),
|
|
634
|
+
editing.value ? h(CommentComposer, {
|
|
635
|
+
autofocus: true,
|
|
636
|
+
busy: busy.value,
|
|
637
|
+
error: error.value,
|
|
638
|
+
mentions: mentions.value,
|
|
639
|
+
modelValue: draft.value,
|
|
640
|
+
onCancel: () => {
|
|
641
|
+
if (!busy.value) editing.value = false;
|
|
642
|
+
},
|
|
643
|
+
onSubmit: save,
|
|
644
|
+
"onUpdate:mentions": (value) => mentions.value = value,
|
|
645
|
+
"onUpdate:modelValue": (value) => draft.value = value,
|
|
646
|
+
people: props.people,
|
|
647
|
+
users: props.users,
|
|
648
|
+
variant: "edit"
|
|
649
|
+
}) : h(Markdown, {
|
|
650
|
+
"data-slot": "comment-reply-body",
|
|
651
|
+
value: message.body
|
|
652
|
+
}),
|
|
653
|
+
confirming.value ? h("div", {
|
|
654
|
+
"aria-label": "Confirm delete",
|
|
655
|
+
"data-slot": "comment-reply-confirm",
|
|
656
|
+
role: "group"
|
|
657
|
+
}, [
|
|
658
|
+
h("p", "Delete this comment and every reply to it?"),
|
|
659
|
+
h(UButton, {
|
|
660
|
+
color: "error",
|
|
661
|
+
label: "Delete thread",
|
|
662
|
+
loading: busy.value,
|
|
663
|
+
onClick: remove,
|
|
664
|
+
size: "xs"
|
|
665
|
+
}),
|
|
666
|
+
h(UButton, {
|
|
667
|
+
color: "neutral",
|
|
668
|
+
label: "Cancel",
|
|
669
|
+
onClick: () => confirming.value = false,
|
|
670
|
+
size: "xs",
|
|
671
|
+
variant: "ghost"
|
|
672
|
+
})
|
|
673
|
+
]) : null,
|
|
674
|
+
!editing.value && error.value ? h("p", {
|
|
675
|
+
"data-slot": "comment-reply-error",
|
|
676
|
+
role: "alert"
|
|
677
|
+
}, error.value) : null
|
|
678
|
+
]),
|
|
679
|
+
props.editable && !editing.value && !confirming.value && !props.compact ? h("div", { "data-slot": "comment-reply-actions" }, [props.onEdit ? h(UButton, {
|
|
680
|
+
"aria-label": "Edit",
|
|
681
|
+
color: "neutral",
|
|
682
|
+
icon: "i-ph-pencil-simple-light",
|
|
683
|
+
onClick: startEdit,
|
|
684
|
+
size: "xs",
|
|
685
|
+
variant: "ghost"
|
|
686
|
+
}) : null, props.onDelete ? h(UButton, {
|
|
687
|
+
"aria-label": "Delete",
|
|
688
|
+
color: "neutral",
|
|
689
|
+
icon: "i-ph-trash-light",
|
|
690
|
+
onClick: () => props.confirmDelete ? confirming.value = true : void remove(),
|
|
691
|
+
size: "xs",
|
|
692
|
+
variant: "ghost"
|
|
693
|
+
}) : null]) : null
|
|
694
|
+
]);
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
const CommentThread = defineComponent({
|
|
699
|
+
name: "CommentThread",
|
|
700
|
+
props: {
|
|
701
|
+
thread: {
|
|
702
|
+
required: true,
|
|
703
|
+
type: Object
|
|
704
|
+
},
|
|
705
|
+
/** The signed-in user. Their messages can be edited and deleted. */
|
|
706
|
+
user: { type: Object },
|
|
707
|
+
/** A read-only card for hovering a pin. */
|
|
708
|
+
preview: {
|
|
709
|
+
default: false,
|
|
710
|
+
type: Boolean
|
|
711
|
+
},
|
|
712
|
+
/** Keep the full thread readable without reply, edit, delete, or status controls. */
|
|
713
|
+
readOnly: {
|
|
714
|
+
default: false,
|
|
715
|
+
type: Boolean
|
|
716
|
+
},
|
|
717
|
+
/** Show a reply as being sent, on top of the thread's own tracking. */
|
|
718
|
+
busy: {
|
|
719
|
+
default: false,
|
|
720
|
+
type: Boolean
|
|
721
|
+
},
|
|
722
|
+
/** An error to show, on top of the ones from the handlers. */
|
|
723
|
+
error: { type: String },
|
|
724
|
+
/** The thread is no longer on the page, so no pin shows where it was. */
|
|
725
|
+
detached: {
|
|
726
|
+
default: false,
|
|
727
|
+
type: Boolean
|
|
728
|
+
},
|
|
729
|
+
users: { type: Function },
|
|
730
|
+
/** Sends a reply. Gets `(body, mentions)`. */
|
|
731
|
+
onReply: { type: Function },
|
|
732
|
+
/** Saves an edited message. Gets `(messageId, body, mentions)`. */
|
|
733
|
+
onEdit: { type: Function },
|
|
734
|
+
/** Deletes a message. Gets `(messageId)`. Deleting the first message deletes the thread. */
|
|
735
|
+
onDelete: { type: Function },
|
|
736
|
+
onResolve: { type: Function },
|
|
737
|
+
onReopen: { type: Function }
|
|
738
|
+
},
|
|
739
|
+
emits: ["close"],
|
|
740
|
+
setup(props, { emit }) {
|
|
741
|
+
const UButton = resolveComponent("UButton");
|
|
742
|
+
const root = ref(null);
|
|
743
|
+
const reply = ref("");
|
|
744
|
+
const mentions = ref([]);
|
|
745
|
+
const sending = ref(false);
|
|
746
|
+
const failure = ref();
|
|
747
|
+
const composer = ref(null);
|
|
748
|
+
const people = computed(() => {
|
|
749
|
+
const seen = /* @__PURE__ */ new Map();
|
|
750
|
+
for (const person of [
|
|
751
|
+
props.thread.author,
|
|
752
|
+
...props.thread.messages.map((message) => message.author),
|
|
753
|
+
...props.user ? [props.user] : []
|
|
754
|
+
]) seen.set(person.id, person);
|
|
755
|
+
return [...seen.values()];
|
|
756
|
+
});
|
|
757
|
+
useDocumentPointerDown((event) => {
|
|
758
|
+
const path = pathOf(event);
|
|
759
|
+
if (props.preview || !root.value || path.includes(root.value)) return;
|
|
760
|
+
if (path.some((element) => element.matches("[data-slot='comment-pin']")) || consumedPointerEvents.has(event)) return;
|
|
761
|
+
consumedPointerEvents.add(event);
|
|
762
|
+
const where = root.value.getRootNode();
|
|
763
|
+
if (shakeDirtyComposers(where instanceof ShadowRoot ? where : document)) {
|
|
764
|
+
event.stopPropagation();
|
|
765
|
+
swallowNextClick();
|
|
766
|
+
} else emit("close");
|
|
767
|
+
});
|
|
768
|
+
async function send(submit) {
|
|
769
|
+
if (sending.value || !props.onReply) return;
|
|
770
|
+
sending.value = true;
|
|
771
|
+
failure.value = void 0;
|
|
772
|
+
const submitted = reply.value;
|
|
773
|
+
const submittedMentions = mentions.value;
|
|
774
|
+
try {
|
|
775
|
+
await props.onReply(submit.body, [...submit.mentions]);
|
|
776
|
+
if (reply.value === submitted && mentions.value === submittedMentions) {
|
|
777
|
+
reply.value = "";
|
|
778
|
+
mentions.value = [];
|
|
779
|
+
}
|
|
780
|
+
nextTick(() => composer.value?.focus());
|
|
781
|
+
} catch (cause) {
|
|
782
|
+
failure.value = reason(cause);
|
|
783
|
+
} finally {
|
|
784
|
+
sending.value = false;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
async function act(task) {
|
|
788
|
+
if (root.value && shakeDirtyComposers(root.value)) return;
|
|
789
|
+
failure.value = void 0;
|
|
790
|
+
try {
|
|
791
|
+
await task?.();
|
|
792
|
+
} catch (cause) {
|
|
793
|
+
failure.value = reason(cause);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
function close() {
|
|
797
|
+
if (root.value && shakeDirtyComposers(root.value)) return;
|
|
798
|
+
emit("close");
|
|
799
|
+
}
|
|
800
|
+
return () => {
|
|
801
|
+
const { thread } = props;
|
|
802
|
+
const resolved = thread.status === "resolved";
|
|
803
|
+
const first = thread.messages[0];
|
|
804
|
+
const quote = thread.anchor.kind === "text" ? thread.anchor.exact : void 0;
|
|
805
|
+
if (props.preview) {
|
|
806
|
+
const replies = thread.messages.length - 1;
|
|
807
|
+
return h("div", {
|
|
808
|
+
"data-slot": "comment-thread",
|
|
809
|
+
"data-preview": "true",
|
|
810
|
+
"data-status": thread.status
|
|
811
|
+
}, [first ? h(CommentReply, {
|
|
812
|
+
compact: true,
|
|
813
|
+
message: first
|
|
814
|
+
}) : null, replies > 0 ? h("p", { "data-slot": "comment-thread-count" }, `${replies} ${replies === 1 ? "reply" : "replies"}`) : null]);
|
|
815
|
+
}
|
|
816
|
+
return h("section", {
|
|
817
|
+
"aria-label": `Comment ${thread.n}`,
|
|
818
|
+
"data-slot": "comment-thread",
|
|
819
|
+
"data-status": thread.status,
|
|
820
|
+
ref: root,
|
|
821
|
+
role: "dialog",
|
|
822
|
+
tabindex: -1
|
|
823
|
+
}, [
|
|
824
|
+
h("header", { "data-slot": "comment-thread-header" }, [
|
|
825
|
+
h("span", { "data-slot": "comment-thread-title" }, `Comment ${thread.n}`),
|
|
826
|
+
h("span", { "data-slot": "comment-thread-spacer" }),
|
|
827
|
+
props.readOnly ? null : h(UButton, {
|
|
828
|
+
"aria-label": resolved ? "Reopen" : "Resolve",
|
|
829
|
+
color: "neutral",
|
|
830
|
+
icon: resolved ? "i-ph-arrow-counter-clockwise" : "i-ph-check",
|
|
831
|
+
onClick: () => void act(resolved ? props.onReopen : props.onResolve),
|
|
832
|
+
size: "xs",
|
|
833
|
+
variant: "ghost"
|
|
834
|
+
}),
|
|
835
|
+
h(UButton, {
|
|
836
|
+
"aria-label": "Close",
|
|
837
|
+
color: "neutral",
|
|
838
|
+
icon: "i-ph-x-light",
|
|
839
|
+
onClick: close,
|
|
840
|
+
size: "xs",
|
|
841
|
+
variant: "ghost"
|
|
842
|
+
})
|
|
843
|
+
]),
|
|
844
|
+
h("div", { "data-slot": "comment-thread-messages" }, [
|
|
845
|
+
quote ? h("blockquote", { "data-slot": "comment-thread-quote" }, quote) : null,
|
|
846
|
+
props.detached ? h("p", {
|
|
847
|
+
"data-slot": "comment-thread-detached",
|
|
848
|
+
role: "status"
|
|
849
|
+
}, "The place of this comment is no longer on the page.") : null,
|
|
850
|
+
...thread.messages.map((message, index) => h(CommentReply, {
|
|
851
|
+
confirmDelete: index === 0,
|
|
852
|
+
editable: !props.readOnly && message.author.id === props.user?.id,
|
|
853
|
+
key: message.id,
|
|
854
|
+
message,
|
|
855
|
+
onDelete: props.onDelete,
|
|
856
|
+
onEdit: props.onEdit,
|
|
857
|
+
people: people.value,
|
|
858
|
+
users: props.users
|
|
859
|
+
})),
|
|
860
|
+
resolved ? h(Marker, { variant: "separator" }, () => h(MarkerContent, () => `Resolved${thread.resolvedBy ? ` by ${displayName(thread.resolvedBy)}` : ""}`)) : null
|
|
861
|
+
]),
|
|
862
|
+
props.readOnly ? null : h(CommentComposer, {
|
|
863
|
+
autofocus: false,
|
|
864
|
+
busy: props.busy || sending.value,
|
|
865
|
+
error: failure.value ?? props.error,
|
|
866
|
+
guard: false,
|
|
867
|
+
mentions: mentions.value,
|
|
868
|
+
modelValue: reply.value,
|
|
869
|
+
onCancel: close,
|
|
870
|
+
onSubmit: send,
|
|
871
|
+
"onUpdate:mentions": (value) => mentions.value = value,
|
|
872
|
+
"onUpdate:modelValue": (value) => reply.value = value,
|
|
873
|
+
people: people.value,
|
|
874
|
+
ref: composer,
|
|
875
|
+
user: props.user,
|
|
876
|
+
users: props.users,
|
|
877
|
+
variant: "reply"
|
|
878
|
+
})
|
|
879
|
+
]);
|
|
880
|
+
};
|
|
881
|
+
}
|
|
882
|
+
});
|
|
883
|
+
//#endregion
|
|
884
|
+
//#region src/components/comment-layer.ts
|
|
885
|
+
const popoverWidth = 360;
|
|
886
|
+
const popoverHeight = 420;
|
|
887
|
+
const clickSlop = 6;
|
|
888
|
+
const CommentLayer = defineComponent({
|
|
889
|
+
name: "CommentLayer",
|
|
890
|
+
props: {
|
|
891
|
+
client: { type: Object },
|
|
892
|
+
/** What the threads of this page are about. For a page, `{ kind: "page", id: "/pricing" }`. */
|
|
893
|
+
subject: { type: Object },
|
|
894
|
+
/** The signed-in user. Defaults to the client's user. */
|
|
895
|
+
user: { type: Object },
|
|
896
|
+
/** A state from `useComments()`, instead of `client` and `subject`. */
|
|
897
|
+
comments: { type: Object },
|
|
898
|
+
/** The people on this page, shown in the toolbar. */
|
|
899
|
+
people: {
|
|
900
|
+
default: () => [],
|
|
901
|
+
type: Array
|
|
902
|
+
},
|
|
903
|
+
/** The key that toggles comment mode. `false` turns it off. */
|
|
904
|
+
hotkey: {
|
|
905
|
+
default: "c",
|
|
906
|
+
type: [String, Boolean]
|
|
907
|
+
},
|
|
908
|
+
/** Hide thread mutation controls when the viewer may only read. */
|
|
909
|
+
readOnly: {
|
|
910
|
+
default: false,
|
|
911
|
+
type: Boolean
|
|
912
|
+
},
|
|
913
|
+
/** The URL of the page that a subject lives on, for the links of threads that are not page threads. */
|
|
914
|
+
subjectUrl: { type: Function },
|
|
915
|
+
/** Navigates to the page of a thread from the list. Defaults to `location.assign`. */
|
|
916
|
+
navigate: { type: Function }
|
|
917
|
+
},
|
|
918
|
+
setup(props, { slots }) {
|
|
919
|
+
const { client, subject } = props;
|
|
920
|
+
if (!props.comments && (!client || !subject)) throw uiErrorDiagnostics.UI_R0002({ message: "CommentLayer needs a `client` and a `subject`, or the `comments` state from useComments()." });
|
|
921
|
+
const layer = ref(null);
|
|
922
|
+
const uiRoot = () => {
|
|
923
|
+
const node = layer.value?.getRootNode();
|
|
924
|
+
return node instanceof ShadowRoot ? node : document;
|
|
925
|
+
};
|
|
926
|
+
const state = props.comments ?? useComments({
|
|
927
|
+
client,
|
|
928
|
+
hotkey: props.hotkey,
|
|
929
|
+
subject: () => props.subject,
|
|
930
|
+
subjectUrl: props.subjectUrl,
|
|
931
|
+
uiRoot,
|
|
932
|
+
user: () => props.user
|
|
933
|
+
});
|
|
934
|
+
provideComments(state);
|
|
935
|
+
const user = computed(() => state.user.value);
|
|
936
|
+
const pinned = computed(() => {
|
|
937
|
+
const threads = [...state.pageThreads.value];
|
|
938
|
+
const opened = state.opened.value;
|
|
939
|
+
if (opened && opened.subject.kind === state.subject.value.kind && opened.subject.id === state.subject.value.id && !threads.includes(opened)) threads.push(opened);
|
|
940
|
+
return threads;
|
|
941
|
+
});
|
|
942
|
+
let down = null;
|
|
943
|
+
const press = (event) => {
|
|
944
|
+
down = consumedPointerEvents.has(event) || event.button !== 0 ? null : {
|
|
945
|
+
x: event.clientX,
|
|
946
|
+
y: event.clientY
|
|
947
|
+
};
|
|
948
|
+
};
|
|
949
|
+
const release = (event) => {
|
|
950
|
+
const start = down;
|
|
951
|
+
down = null;
|
|
952
|
+
if (!start || Math.hypot(event.clientX - start.x, event.clientY - start.y) > clickSlop) return;
|
|
953
|
+
event.preventDefault();
|
|
954
|
+
try {
|
|
955
|
+
state.startDraft({
|
|
956
|
+
x: event.clientX,
|
|
957
|
+
y: event.clientY
|
|
958
|
+
});
|
|
959
|
+
} catch {}
|
|
960
|
+
};
|
|
961
|
+
let returnTo = null;
|
|
962
|
+
let restoring = false;
|
|
963
|
+
watch(() => state.openId.value, (id, previous) => {
|
|
964
|
+
if (id) {
|
|
965
|
+
nextTick(() => layer.value?.querySelector("[data-slot='comment-thread']:not([data-preview])")?.focus());
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
returnTo = null;
|
|
969
|
+
const active = uiRoot().activeElement;
|
|
970
|
+
const thread = layer.value?.querySelector("[data-slot='comment-thread']:not([data-preview])");
|
|
971
|
+
if (previous && (!active || active === document.body || thread?.contains(active))) returnTo = previous;
|
|
972
|
+
}, { flush: "pre" });
|
|
973
|
+
watch(() => state.openId.value, (id) => {
|
|
974
|
+
if (id || !returnTo) return;
|
|
975
|
+
const target = returnTo;
|
|
976
|
+
returnTo = null;
|
|
977
|
+
nextTick(() => {
|
|
978
|
+
const pins = layer.value?.querySelectorAll("[data-slot='comment-pin']") ?? [];
|
|
979
|
+
restoring = true;
|
|
980
|
+
([...pins].find((pin) => pin.getAttribute("data-thread-id") === target) ?? layer.value?.querySelector("[data-slot='comment-toolbar-mode']"))?.focus();
|
|
981
|
+
restoring = false;
|
|
982
|
+
});
|
|
983
|
+
}, { flush: "post" });
|
|
984
|
+
const side = (x, y) => ({
|
|
985
|
+
"data-flip-x": x + popoverWidth > window.innerWidth ? "true" : void 0,
|
|
986
|
+
"data-flip-y": y + popoverHeight > window.innerHeight ? "true" : void 0
|
|
987
|
+
});
|
|
988
|
+
const threadView = (thread) => h(CommentThread, {
|
|
989
|
+
key: thread.id,
|
|
990
|
+
detached: state.positions.value.get(thread.id)?.detached === true,
|
|
991
|
+
readOnly: props.readOnly,
|
|
992
|
+
onClose: () => state.close(),
|
|
993
|
+
onDelete: (messageId) => state.remove(thread.id, messageId),
|
|
994
|
+
onEdit: (messageId, body, mentions) => state.edit(thread.id, messageId, body, mentions),
|
|
995
|
+
onReopen: () => state.reopen(thread.id),
|
|
996
|
+
onReply: (body, mentions) => state.reply(thread.id, body, mentions),
|
|
997
|
+
onResolve: async () => {
|
|
998
|
+
await state.resolve(thread.id);
|
|
999
|
+
state.close();
|
|
1000
|
+
},
|
|
1001
|
+
thread,
|
|
1002
|
+
user: user.value,
|
|
1003
|
+
users: state.users
|
|
1004
|
+
});
|
|
1005
|
+
return () => {
|
|
1006
|
+
const items = pinned.value.flatMap((thread) => {
|
|
1007
|
+
const position = state.positions.value.get(thread.id);
|
|
1008
|
+
if (!position || position.detached || position.clipped || thread.anchor.kind === "page") return [];
|
|
1009
|
+
const open = state.openId.value === thread.id;
|
|
1010
|
+
const hover = state.hoverId.value === thread.id && !open && !state.draft.value;
|
|
1011
|
+
return [h("div", {
|
|
1012
|
+
...side(position.x, position.y),
|
|
1013
|
+
"data-slot": "comment-layer-item",
|
|
1014
|
+
key: thread.id,
|
|
1015
|
+
style: {
|
|
1016
|
+
left: `${position.x}px`,
|
|
1017
|
+
top: `${position.y}px`
|
|
1018
|
+
}
|
|
1019
|
+
}, [h(CommentPin, {
|
|
1020
|
+
active: open,
|
|
1021
|
+
author: thread.author,
|
|
1022
|
+
"data-thread-id": thread.id,
|
|
1023
|
+
excerpt: excerpt(thread.messages[0]?.body ?? ""),
|
|
1024
|
+
n: thread.n,
|
|
1025
|
+
onHover: () => {
|
|
1026
|
+
if (!open && !restoring && !state.draft.value) state.hoverId.value = thread.id;
|
|
1027
|
+
},
|
|
1028
|
+
onLeave: () => {
|
|
1029
|
+
if (state.hoverId.value === thread.id) state.hoverId.value = null;
|
|
1030
|
+
},
|
|
1031
|
+
onSelect: () => open ? state.close() : state.open(thread),
|
|
1032
|
+
status: thread.status
|
|
1033
|
+
}), hover ? h("div", {
|
|
1034
|
+
"data-preview": "true",
|
|
1035
|
+
"data-slot": "comment-layer-popover"
|
|
1036
|
+
}, h(CommentThread, {
|
|
1037
|
+
preview: true,
|
|
1038
|
+
thread
|
|
1039
|
+
})) : null])];
|
|
1040
|
+
});
|
|
1041
|
+
const opened = state.opened.value;
|
|
1042
|
+
const openedPosition = opened && state.positions.value.get(opened.id);
|
|
1043
|
+
const pointForThread = openedPosition && !openedPosition.detached && !openedPosition.clipped && opened?.anchor.kind !== "page" ? openedPosition : void 0;
|
|
1044
|
+
const openThread = opened ? h("div", {
|
|
1045
|
+
...pointForThread ? side(pointForThread.x, pointForThread.y) : {},
|
|
1046
|
+
"data-slot": "comment-layer-item",
|
|
1047
|
+
key: "opened-thread",
|
|
1048
|
+
style: pointForThread ? {
|
|
1049
|
+
left: `${pointForThread.x}px`,
|
|
1050
|
+
top: `${pointForThread.y}px`
|
|
1051
|
+
} : void 0
|
|
1052
|
+
}, h("div", {
|
|
1053
|
+
"data-floating": pointForThread ? void 0 : "true",
|
|
1054
|
+
"data-slot": "comment-layer-popover"
|
|
1055
|
+
}, threadView(opened))) : null;
|
|
1056
|
+
const draft = state.draft.value;
|
|
1057
|
+
const draftPosition = draft && state.positions.value.get("draft");
|
|
1058
|
+
const point = draftPosition && !draftPosition.detached && draft?.anchor.kind !== "page" ? draftPosition : draft?.point;
|
|
1059
|
+
const composing = draft && point ? h("div", {
|
|
1060
|
+
...side(point.x, point.y),
|
|
1061
|
+
"data-draft": "true",
|
|
1062
|
+
"data-slot": "comment-layer-item",
|
|
1063
|
+
style: {
|
|
1064
|
+
left: `${point.x}px`,
|
|
1065
|
+
top: `${point.y}px`
|
|
1066
|
+
}
|
|
1067
|
+
}, [h(CommentPin, {
|
|
1068
|
+
author: user.value,
|
|
1069
|
+
draft: true
|
|
1070
|
+
}), h("div", { "data-slot": "comment-layer-popover" }, h(CommentComposer, {
|
|
1071
|
+
busy: draft.busy,
|
|
1072
|
+
error: draft.error,
|
|
1073
|
+
mentions: draft.mentions,
|
|
1074
|
+
modelValue: draft.body,
|
|
1075
|
+
onCancel: () => state.cancelDraft(),
|
|
1076
|
+
onSubmit: (submit) => {
|
|
1077
|
+
draft.mentions = submit.mentions;
|
|
1078
|
+
state.send();
|
|
1079
|
+
},
|
|
1080
|
+
"onUpdate:mentions": (value) => draft.mentions = value,
|
|
1081
|
+
"onUpdate:modelValue": (value) => draft.body = value,
|
|
1082
|
+
people: user.value ? [user.value] : [],
|
|
1083
|
+
user: user.value,
|
|
1084
|
+
users: state.users
|
|
1085
|
+
}))]) : null;
|
|
1086
|
+
return h("div", {
|
|
1087
|
+
"data-active": state.active.value ? "true" : void 0,
|
|
1088
|
+
"data-comments-ui": "",
|
|
1089
|
+
"data-slot": "comment-layer",
|
|
1090
|
+
ref: layer
|
|
1091
|
+
}, [
|
|
1092
|
+
state.active.value ? h("div", {
|
|
1093
|
+
"data-slot": "comment-layer-overlay",
|
|
1094
|
+
onPointercancel: () => down = null,
|
|
1095
|
+
onPointerdown: press,
|
|
1096
|
+
onPointerup: release
|
|
1097
|
+
}) : null,
|
|
1098
|
+
...items,
|
|
1099
|
+
composing,
|
|
1100
|
+
openThread,
|
|
1101
|
+
slots.default?.({ comments: state }) ?? [h(CommentToolbar, {
|
|
1102
|
+
comments: state,
|
|
1103
|
+
people: props.people
|
|
1104
|
+
}), state.listOpen.value ? h(CommentList, {
|
|
1105
|
+
comments: state,
|
|
1106
|
+
navigate: props.navigate
|
|
1107
|
+
}) : null]
|
|
1108
|
+
]);
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
});
|
|
1112
|
+
//#endregion
|
|
1113
|
+
export { CommentFilters as a, CommentComposer as c, CommentPin as i, CommentReply as n, CommentList as o, CommentThread as r, CommentToolbar as s, CommentLayer as t };
|