@vite-hub/ui 0.1.0 → 0.3.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/README.md +244 -18
- package/dist/attachments-BzTwqRTU.js +90 -0
- package/dist/choices-input-ByXJvDn1.d.ts +94 -0
- package/dist/{code-view-J4OsgEdh.js → code-view-D0bqhogi.js} +20 -4
- package/dist/colors-BghReA9C-CjF9gnmy.js +28 -0
- package/dist/comment-composer-Cc8Jvu6u.d.ts +243 -0
- package/dist/comment-composer-jYv2ULNP.js +591 -0
- package/dist/comment-layer-ClH4MLj4.d.ts +165 -0
- package/dist/comment-list-B8hphLfS.d.ts +62 -0
- package/dist/comment-marks.css +234 -0
- package/dist/comment-panel-fcKSKwLC.d.ts +197 -0
- package/dist/comment-person-CLPlW_SS.js +40 -0
- package/dist/comment-pin-CvwgRSDR.d.ts +68 -0
- package/dist/comment-row-Bbm9WwuF.js +39 -0
- package/dist/comment-thread-CoTLrdal.d.ts +368 -0
- package/dist/comment-visibility-DsVuVndP.d.ts +40 -0
- package/dist/{comments-ChNJkV1d.d.ts → comments-Bx2WRsYy.d.ts} +69 -7
- package/dist/{comments-C08J3z4e.js → comments-CkWc2Khc.js} +155 -60
- package/dist/comments-context-C2lOZyQ5.js +38 -0
- package/dist/config-DgxBW013.d.ts +80 -0
- package/dist/config-Dk67emQt.js +63 -0
- package/dist/copy-button-CRN3kmSD.js +253 -0
- package/dist/draw-DzSmD7uo-Dwz8zoH2.js +72976 -0
- package/dist/editor-C_wt4RRV.js +582 -0
- package/dist/error-diagnostics-SXtnk6bz.js +38 -0
- package/dist/{file-tree-C1pv4_AI.js → file-tree-C4OYgbV-.js} +292 -145
- package/dist/{file-tree-Ctb8hZ_g.d.ts → file-tree-DlT9RGhu.d.ts} +51 -15
- package/dist/format-Du58PlsG.js +18 -0
- package/dist/handlers-DMl-Na3x.js +182 -0
- package/dist/headless.d.ts +5 -176
- package/dist/headless.js +5 -3
- package/dist/icon-swap.css +69 -0
- package/dist/{image-preview-VfknBEFu.js → image-preview-C9tdkmEj.js} +8 -5
- package/dist/{index-DcH0QSI5.d.ts → index-BD1e8vx5.d.ts} +8 -0
- package/dist/{code-view-vDM-hph-.d.ts → index-CNY1uNTh.d.ts} +14 -228
- package/dist/index.d.ts +53 -56
- package/dist/index.js +677 -25
- package/dist/markdown-editor-CMbNZOdN.js +2394 -0
- package/dist/markdown-editor-DqdZfIEn.d.ts +195 -0
- package/dist/markdown-editor.d.ts +108 -0
- package/dist/markdown-editor.js +3 -0
- package/dist/message-scroller-Bm1YWTeY.d.ts +175 -0
- package/dist/nuxt-ui-DSQFzq3s.js +38 -0
- package/dist/nuxt.d.ts +84 -2
- package/dist/nuxt.js +237 -35
- package/dist/parts/components/agent-session.d.ts +254 -0
- package/dist/parts/components/agent-session.js +640 -0
- package/dist/{attachment-BBndG9_P.d.ts → parts/components/attachment.d.ts} +13 -14
- package/dist/{attachment-B3dXC7jM.js → parts/components/attachment.js} +6 -4
- package/dist/{avatar-stack.d.ts → parts/components/avatar-stack.d.ts} +1 -1
- package/dist/{avatar-stack-DM6HRnc0.js → parts/components/avatar-stack.js} +2 -5
- package/dist/{bubble-BJH2rfii.d.ts → parts/components/bubble.d.ts} +8 -9
- package/dist/{bubble-BPyFQlW7.js → parts/components/bubble.js} +2 -2
- package/dist/{chat-message-mpDmZbIC.d.ts → parts/components/chat-message.d.ts} +2 -3
- package/dist/{chat-message-BNK9G7xF.js → parts/components/chat-message.js} +4 -4
- package/dist/{chat-session-D6C7VJBR.d.ts → parts/components/chat-session.d.ts} +3 -4
- package/dist/{chat-session-DYEHB1HC.js → parts/components/chat-session.js} +2 -2
- package/dist/{chat-B9HlZWA2.d.ts → parts/components/chat.d.ts} +8 -4
- package/dist/{chat-BoFHlu9V.js → parts/components/chat.js} +42 -9
- package/dist/{highlighted-code-Dzf6o54i.d.ts → parts/components/code-block.d.ts} +16 -24
- package/dist/{code-block-Br-02hn-.js → parts/components/code-block.js} +9 -38
- package/dist/parts/components/code-view.d.ts +270 -0
- package/dist/parts/components/code-view.js +2 -0
- package/dist/parts/components/comment-composer.d.ts +2 -0
- package/dist/parts/components/comment-composer.js +2 -0
- package/dist/parts/components/comment-layer.d.ts +2 -0
- package/dist/parts/components/comment-layer.js +618 -0
- package/dist/parts/components/comment-list.d.ts +2 -0
- package/dist/parts/components/comment-list.js +167 -0
- package/dist/parts/components/comment-panel.d.ts +2 -0
- package/dist/parts/components/comment-panel.js +299 -0
- package/dist/parts/components/comment-pin.d.ts +2 -0
- package/dist/parts/components/comment-pin.js +75 -0
- package/dist/parts/components/comment-thread.d.ts +2 -0
- package/dist/parts/components/comment-thread.js +571 -0
- package/dist/parts/components/comments.d.ts +7 -0
- package/dist/parts/components/comments.js +8 -0
- package/dist/{connection-status-DjGBw6xX.d.ts → parts/components/connection-status.d.ts} +6 -7
- package/dist/{connection-status-CzuWBENf.js → parts/components/connection-status.js} +1 -1
- package/dist/parts/components/copy-button.d.ts +118 -0
- package/dist/parts/components/copy-button.js +2 -0
- package/dist/parts/components/device-frame.d.ts +130 -0
- package/dist/parts/components/device-frame.js +471 -0
- package/dist/parts/components/file-tree.d.ts +2 -0
- package/dist/parts/components/file-tree.js +2 -0
- package/dist/parts/components/filter-search.d.ts +47 -0
- package/dist/parts/components/filter-search.js +58 -0
- package/dist/parts/components/markdown-editor.d.ts +2 -0
- package/dist/parts/components/markdown-editor.js +2 -0
- package/dist/parts/components/markdown-renderer.d.ts +52 -0
- package/dist/parts/components/markdown-renderer.js +23077 -0
- package/dist/{markdown-Dse5ldJe.d.ts → parts/components/markdown.d.ts} +7 -7
- package/dist/parts/components/markdown.js +47 -0
- package/dist/{marker-ea-tvx-J.d.ts → parts/components/marker.d.ts} +5 -6
- package/dist/{marker-Di2ZG_k1.js → parts/components/marker.js} +2 -2
- package/dist/{message-parts-BBFUkluC.d.ts → parts/components/message-parts.d.ts} +2 -3
- package/dist/{message-parts-DQnfioAH.js → parts/components/message-parts.js} +6 -6
- package/dist/{message-CW_paC1k.d.ts → parts/components/message.d.ts} +8 -9
- package/dist/{message-DiyBthIq.js → parts/components/message.js} +2 -2
- package/dist/parts/components/patch-parsers.d.ts +2 -0
- package/dist/parts/components/patch-parsers.js +2 -0
- package/dist/{prompt-input-Cy_Ue6B5.d.ts → parts/components/prompt-input.d.ts} +54 -11
- package/dist/{prompt-input-BbnCb80O.js → parts/components/prompt-input.js} +66 -111
- package/dist/parts/components/relative-time.d.ts +73 -0
- package/dist/parts/components/relative-time.js +2 -0
- package/dist/parts/components/status.d.ts +60 -0
- package/dist/parts/components/status.js +48 -0
- package/dist/{sync-status-refELOZn.d.ts → parts/components/sync-status.d.ts} +5 -6
- package/dist/{sync-status-BpxYdZIJ.js → parts/components/sync-status.js} +1 -1
- package/dist/{tool-list-E7CA52rz.d.ts → parts/components/tool-list.d.ts} +3 -4
- package/dist/{tool-list-BdSr5CT4.js → parts/components/tool-list.js} +7 -38
- package/dist/{trace-run-COeXn46Z.d.ts → parts/components/trace-run.d.ts} +3 -4
- package/dist/{trace-run-BIQ17CED.js → parts/components/trace-run.js} +15 -23
- package/dist/{trace-V7rM3Pyd.d.ts → parts/components/trace.d.ts} +10 -11
- package/dist/{trace-llBCDiSW.js → parts/components/trace.js} +20 -13
- package/dist/parts/composables/attachments.d.ts +32 -0
- package/dist/parts/composables/attachments.js +2 -0
- package/dist/parts/composables/highlighted-code.d.ts +9 -0
- package/dist/{highlighted-code-Ck4zexJX.js → parts/composables/highlighted-code.js} +5 -2
- package/dist/parts/headless/choices-input.d.ts +2 -0
- package/dist/parts/headless/choices-input.js +162 -0
- package/dist/parts/headless/comment-visibility.d.ts +2 -0
- package/dist/parts/headless/comment-visibility.js +128 -0
- package/dist/parts/headless/comments.d.ts +2 -0
- package/dist/parts/headless/comments.js +2 -0
- package/dist/parts/headless/message-scroller.d.ts +2 -0
- package/dist/{message-scroller-CX6NJTdm.js → parts/headless/message-scroller.js} +2 -2
- package/dist/parts/playground/highlight.d.ts +5 -0
- package/dist/parts/playground/highlight.js +23 -0
- package/dist/parts/playground/paths.d.ts +4 -0
- package/dist/parts/playground/paths.js +7 -0
- package/dist/parts/playground/playground-render.d.ts +126 -0
- package/dist/parts/playground/playground-render.js +356 -0
- package/dist/parts/playground/share.d.ts +2 -0
- package/dist/parts/playground/share.js +92 -0
- package/dist/parts/playground/zip.d.ts +6 -0
- package/dist/parts/playground/zip.js +76 -0
- package/dist/parts/workspace/browser-support-notice.d.ts +76 -0
- package/dist/parts/workspace/browser-support-notice.js +105 -0
- package/dist/parts/workspace/codemirror.d.ts +16 -0
- package/dist/parts/workspace/codemirror.js +243 -0
- package/dist/parts/workspace/connect-panel.d.ts +129 -0
- package/dist/parts/workspace/connect-panel.js +285 -0
- package/dist/parts/workspace/connect-store.d.ts +26 -0
- package/dist/parts/workspace/connect-store.js +59 -0
- package/dist/parts/workspace/icons.d.ts +34 -0
- package/dist/parts/workspace/icons.js +46 -0
- package/dist/parts/workspace/playground-container.d.ts +192 -0
- package/dist/parts/workspace/playground-container.js +603 -0
- package/dist/parts/workspace/workspace-boot-status.d.ts +75 -0
- package/dist/parts/workspace/workspace-boot-status.js +207 -0
- package/dist/parts/workspace/workspace-editor.d.ts +43 -0
- package/dist/parts/workspace/workspace-editor.js +54 -0
- package/dist/parts/workspace/workspace-file-tree.d.ts +53 -0
- package/dist/parts/workspace/workspace-file-tree.js +68 -0
- package/dist/parts/workspace/workspace-preview.d.ts +72 -0
- package/dist/parts/workspace/workspace-preview.js +307 -0
- package/dist/parts/workspace/workspace-shell.d.ts +88 -0
- package/dist/parts/workspace/workspace-shell.js +291 -0
- package/dist/parts/workspace/workspace-terminal.d.ts +39 -0
- package/dist/parts/workspace/workspace-terminal.js +130 -0
- package/dist/payload-text-sjkYAwvw.js +32 -0
- package/dist/{pierre-code-view-T7V67hwT.js → pierre-code-view-xgBL6DO7.js} +209 -86
- package/dist/{pierre-dark-DDWDl8g6.js → pierre-dark-CzUmjETS.js} +3 -1
- package/dist/{pierre-light-CWhW4NrH.js → pierre-light-Dn6E0sWv.js} +3 -1
- package/dist/playground.d.ts +4 -0
- package/dist/playground.js +4 -0
- package/dist/relative-time-BVmjOsYG.js +309 -0
- package/dist/rolldown-runtime-C9mWXvCC.js +29 -0
- package/dist/runtime/nuxt-plugin.js +23 -4
- package/dist/sankey-CAYwt82B-D4uDQoMR.js +2887 -0
- package/dist/share-DM4eNy4q.d.ts +37 -0
- package/dist/{slot-part-C7Ocxn3b.js → slot-part-Doic71uh.js} +7 -1
- package/dist/styles.css +2465 -594
- package/dist/temml-BilSAAws.js +12362 -0
- package/dist/theme-focus-ring.css +42 -0
- package/dist/theme.css +376 -0
- package/dist/theme.d.ts +355 -0
- package/dist/theme.js +265 -0
- package/dist/{types-CqDwuJAm.d.ts → types-Dyr6CfBW.d.ts} +1 -1
- package/dist/vue-BDmSCtay.js +30779 -0
- package/dist/vue-DGstVdGn.js +2492 -0
- package/dist/workspace.d.ts +15 -0
- package/dist/workspace.js +12 -0
- package/package.json +136 -150
- package/dist/andromeeda-BASpqCeJ.js +0 -4
- package/dist/attachment.d.ts +0 -2
- package/dist/attachment.js +0 -2
- package/dist/aurora-x-DugsLcii.js +0 -4
- package/dist/avatar-stack.js +0 -2
- package/dist/ayu-dark-BT3qdi3o.js +0 -4
- package/dist/ayu-light-BVZyHoh9.js +0 -4
- package/dist/ayu-mirage-XFwUVZQZ.js +0 -4
- package/dist/bubble.d.ts +0 -2
- package/dist/bubble.js +0 -2
- package/dist/catppuccin-frappe-D20KODDN.js +0 -4
- package/dist/catppuccin-latte-eGLVHIUJ.js +0 -4
- package/dist/catppuccin-macchiato-bQGch4PY.js +0 -4
- package/dist/catppuccin-mocha-Bes8-0Mr.js +0 -4
- package/dist/chat-message.d.ts +0 -2
- package/dist/chat-message.js +0 -2
- package/dist/chat-session.d.ts +0 -2
- package/dist/chat-session.js +0 -2
- package/dist/chat.d.ts +0 -2
- package/dist/chat.js +0 -2
- package/dist/code-block.d.ts +0 -2
- package/dist/code-block.js +0 -3
- package/dist/code-view.d.ts +0 -2
- package/dist/code-view.js +0 -2
- package/dist/comment-layer-CBlxJ8eK.js +0 -1113
- package/dist/comments-Cq5eewsu.d.ts +0 -537
- package/dist/comments.d.ts +0 -2
- package/dist/comments.js +0 -2
- package/dist/config-Bux_AJzm.d.ts +0 -29
- package/dist/config-bHqE4JOs.js +0 -38
- package/dist/connection-status.d.ts +0 -2
- package/dist/connection-status.js +0 -2
- package/dist/dark-plus-BGuiqa1B.js +0 -4
- package/dist/dracula-0CVA2XY5.js +0 -4
- package/dist/dracula-soft-Dk9bpbVU.js +0 -4
- package/dist/error-diagnostics-B4hMpJRL.js +0 -13
- package/dist/everforest-dark-CRjTbhh5.js +0 -4
- package/dist/everforest-light-CEeYFLn8.js +0 -4
- package/dist/file-diff.d.ts +0 -2
- package/dist/file-diff.js +0 -2
- package/dist/file-tree.d.ts +0 -2
- package/dist/file-tree.js +0 -2
- package/dist/file-view.d.ts +0 -2
- package/dist/file-view.js +0 -2
- package/dist/github-dark-BXgKmOw_.js +0 -4
- package/dist/github-dark-default-DzJQXksd.js +0 -4
- package/dist/github-dark-dimmed-B1pEmGtS.js +0 -4
- package/dist/github-dark-high-contrast-BkHIa6jc.js +0 -4
- package/dist/github-light-BKRlUbaB.js +0 -4
- package/dist/github-light-default-BU3eYkzs.js +0 -4
- package/dist/github-light-high-contrast-B3MumDcI.js +0 -4
- package/dist/gruvbox-dark-hard-B0ecF443.js +0 -4
- package/dist/gruvbox-dark-medium-BQnpC39k.js +0 -4
- package/dist/gruvbox-dark-soft-DFZUgESr.js +0 -4
- package/dist/gruvbox-light-hard-CuB_LOJr.js +0 -4
- package/dist/gruvbox-light-medium-idDHgxjs.js +0 -4
- package/dist/gruvbox-light-soft-CfWH49MY.js +0 -4
- package/dist/horizon-bright-Ba6M8QSV.js +0 -4
- package/dist/horizon-h92C5OlZ.js +0 -4
- package/dist/houston-EQnPegWq.js +0 -4
- package/dist/kanagawa-dragon-DgDvwi3B.js +0 -4
- package/dist/kanagawa-lotus-BgoQro20.js +0 -4
- package/dist/kanagawa-wave-DgXEowHs.js +0 -4
- package/dist/laserwave-IxBH_3yW.js +0 -4
- package/dist/light-plus-S8JBx6is.js +0 -4
- package/dist/markdown-BoLBN0qH.js +0 -197
- package/dist/markdown.d.ts +0 -2
- package/dist/markdown.js +0 -2
- package/dist/marker.d.ts +0 -2
- package/dist/marker.js +0 -2
- package/dist/material-theme-D1f3HBq-.js +0 -4
- package/dist/material-theme-darker-ExzYhT0j.js +0 -4
- package/dist/material-theme-lighter-D6gH9nnA.js +0 -4
- package/dist/material-theme-ocean-D1w5BPAa.js +0 -4
- package/dist/material-theme-palenight-CkqWmVpF.js +0 -4
- package/dist/message-parts.d.ts +0 -2
- package/dist/message-parts.js +0 -2
- package/dist/message.d.ts +0 -2
- package/dist/message.js +0 -2
- package/dist/min-dark-npsJH98j.js +0 -4
- package/dist/min-light-DUk1XsVt.js +0 -4
- package/dist/monokai-CfFRWUNl.js +0 -4
- package/dist/multi-file-diff.d.ts +0 -2
- package/dist/multi-file-diff.js +0 -2
- package/dist/night-owl-BS7V-av_.js +0 -4
- package/dist/night-owl-light-CZtRawYE.js +0 -4
- package/dist/nord-BFh54Nqz.js +0 -4
- package/dist/one-dark-pro-zDovGosB.js +0 -4
- package/dist/one-light-gmHK3iK6.js +0 -4
- package/dist/patch-diff.d.ts +0 -2
- package/dist/patch-diff.js +0 -2
- package/dist/plastic-DtdaCjub.js +0 -4
- package/dist/poimandres-Hdda6aHK.js +0 -4
- package/dist/primitive-rail.d.ts +0 -222
- package/dist/primitive-rail.js +0 -348
- package/dist/prompt-input.d.ts +0 -2
- package/dist/prompt-input.js +0 -2
- package/dist/red-VqZFRByZ.js +0 -4
- package/dist/rose-pine-DiTkEueR.js +0 -4
- package/dist/rose-pine-dawn-tfo5y2X0.js +0 -4
- package/dist/rose-pine-moon-C0gON9XN.js +0 -4
- package/dist/runtime-type-DlCscMfw.js +0 -59
- package/dist/slack-dark-v8P_eXr6.js +0 -4
- package/dist/slack-ochin-D8SyEdKz.js +0 -4
- package/dist/snazzy-light-BtkQkvXb.js +0 -4
- package/dist/solarized-dark-B8nAdMfM.js +0 -4
- package/dist/solarized-light-B-3F1INj.js +0 -4
- package/dist/sync-status.d.ts +0 -2
- package/dist/sync-status.js +0 -2
- package/dist/synthwave-84-DcsXCF_c.js +0 -4
- package/dist/tokyo-night-Bvpqduda.js +0 -4
- package/dist/tool-list.d.ts +0 -2
- package/dist/tool-list.js +0 -2
- package/dist/trace-run.d.ts +0 -2
- package/dist/trace-run.js +0 -2
- package/dist/trace.d.ts +0 -2
- package/dist/trace.js +0 -2
- package/dist/unresolved-file.d.ts +0 -2
- package/dist/unresolved-file.js +0 -2
- package/dist/vesper-CfxmMOy3.js +0 -4
- package/dist/vitesse-black-D9-_1mjV.js +0 -4
- package/dist/vitesse-dark-DlSMLlr9.js +0 -4
- package/dist/vitesse-light-KRWWWztf.js +0 -4
|
@@ -1,1113 +0,0 @@
|
|
|
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 };
|