@dxos/plugin-thread 0.7.4-staging.f7e8224 → 0.7.5-labs.071a3e2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/ThreadContainer-T4WIBHY6.mjs +19 -0
- package/dist/lib/browser/ThreadContainer-T4WIBHY6.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-IANFWFYN.mjs +121 -0
- package/dist/lib/browser/app-graph-builder-IANFWFYN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-52HWDLBR.mjs → chunk-5EQVG4L3.mjs} +33 -121
- package/dist/lib/browser/chunk-5EQVG4L3.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ENERBDYI.mjs → chunk-636QDHE3.mjs} +3 -3
- package/dist/lib/browser/chunk-636QDHE3.mjs.map +7 -0
- package/dist/lib/browser/chunk-BNEWNQBO.mjs +71 -0
- package/dist/lib/browser/chunk-BNEWNQBO.mjs.map +7 -0
- package/dist/lib/browser/chunk-L4QHQNDC.mjs +18 -0
- package/dist/lib/browser/chunk-L4QHQNDC.mjs.map +7 -0
- package/dist/lib/browser/chunk-NAO3LZMZ.mjs +16 -0
- package/dist/lib/browser/chunk-NAO3LZMZ.mjs.map +7 -0
- package/dist/lib/browser/chunk-NO5AZLUZ.mjs +81 -0
- package/dist/lib/browser/chunk-NO5AZLUZ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +147 -1094
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-QFP6L3AF.mjs +287 -0
- package/dist/lib/browser/intent-resolver-QFP6L3AF.mjs.map +7 -0
- package/dist/lib/browser/markdown-2NBXKXCY.mjs +112 -0
- package/dist/lib/browser/markdown-2NBXKXCY.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-LDPZN456.mjs +424 -0
- package/dist/lib/browser/react-surface-LDPZN456.mjs.map +7 -0
- package/dist/lib/browser/settings-TKOPRXSU.mjs +22 -0
- package/dist/lib/browser/settings-TKOPRXSU.mjs.map +7 -0
- package/dist/lib/browser/state-GNFUURIC.mjs +33 -0
- package/dist/lib/browser/state-GNFUURIC.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +6 -4
- package/dist/lib/node/{ThreadArticle-I7ADXDW3.cjs → ThreadContainer-4XACAVGV.cjs} +14 -13
- package/dist/lib/node/ThreadContainer-4XACAVGV.cjs.map +7 -0
- package/dist/lib/node/app-graph-builder-LFEDPJLK.cjs +135 -0
- package/dist/lib/node/app-graph-builder-LFEDPJLK.cjs.map +7 -0
- package/dist/lib/node/{ThreadMain-MRNJC3TI.cjs → chunk-346YIZVL.cjs} +26 -23
- package/dist/lib/node/chunk-346YIZVL.cjs.map +7 -0
- package/dist/lib/node/chunk-AUVKOX5Q.cjs +101 -0
- package/dist/lib/node/chunk-AUVKOX5Q.cjs.map +7 -0
- package/dist/lib/node/chunk-AWSTZ2KN.cjs +93 -0
- package/dist/lib/node/chunk-AWSTZ2KN.cjs.map +7 -0
- package/dist/lib/node/{chunk-IC2NICNC.cjs → chunk-F735VMTN.cjs} +7 -7
- package/dist/lib/node/chunk-F735VMTN.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → chunk-FPWNZ6TB.cjs} +13 -10
- package/dist/lib/node/chunk-FPWNZ6TB.cjs.map +7 -0
- package/dist/lib/node/{chunk-YCDM2SZM.cjs → chunk-VAZ3BCTU.cjs} +77 -168
- package/dist/lib/node/chunk-VAZ3BCTU.cjs.map +7 -0
- package/dist/lib/node/index.cjs +142 -1083
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-ZSOQILPJ.cjs +299 -0
- package/dist/lib/node/intent-resolver-ZSOQILPJ.cjs.map +7 -0
- package/dist/lib/node/markdown-FWRKMSKV.cjs +122 -0
- package/dist/lib/node/markdown-FWRKMSKV.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-MCQUT7BC.cjs +426 -0
- package/dist/lib/node/react-surface-MCQUT7BC.cjs.map +7 -0
- package/dist/lib/node/settings-TH4YSUVU.cjs +36 -0
- package/dist/lib/node/settings-TH4YSUVU.cjs.map +7 -0
- package/dist/lib/node/state-TQWEZ6B3.cjs +49 -0
- package/dist/lib/node/state-TQWEZ6B3.cjs.map +7 -0
- package/dist/lib/node/types.cjs +6 -4
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/ThreadContainer-FGFB25TQ.mjs +20 -0
- package/dist/lib/node-esm/ThreadContainer-FGFB25TQ.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-IXHFRMCY.mjs +122 -0
- package/dist/lib/node-esm/app-graph-builder-IXHFRMCY.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3INUK3A6.mjs +20 -0
- package/dist/lib/node-esm/chunk-3INUK3A6.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-B3CF35MY.mjs +82 -0
- package/dist/lib/node-esm/chunk-B3CF35MY.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JG7MXH6O.mjs → chunk-DKCH2H5C.mjs} +33 -121
- package/dist/lib/node-esm/chunk-DKCH2H5C.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7QRGG25F.mjs → chunk-FXUATCLW.mjs} +3 -3
- package/dist/lib/node-esm/chunk-FXUATCLW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HLWJTUWZ.mjs +73 -0
- package/dist/lib/node-esm/chunk-HLWJTUWZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZJITX3TO.mjs +17 -0
- package/dist/lib/node-esm/chunk-ZJITX3TO.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +147 -1094
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-MHP4C2NZ.mjs +288 -0
- package/dist/lib/node-esm/intent-resolver-MHP4C2NZ.mjs.map +7 -0
- package/dist/lib/node-esm/markdown-6AQFDAW3.mjs +113 -0
- package/dist/lib/node-esm/markdown-6AQFDAW3.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-6JMVZUDM.mjs +425 -0
- package/dist/lib/node-esm/react-surface-6JMVZUDM.mjs.map +7 -0
- package/dist/lib/node-esm/settings-KEDRR7RM.mjs +23 -0
- package/dist/lib/node-esm/settings-KEDRR7RM.mjs.map +7 -0
- package/dist/lib/node-esm/state-7MLR27YG.mjs +34 -0
- package/dist/lib/node-esm/state-7MLR27YG.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +6 -4
- package/dist/types/src/ThreadPlugin.d.ts +1 -3
- package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +180 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +15 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +187 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown.d.ts +4 -0
- package/dist/types/src/capabilities/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +4 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/capabilities/state.d.ts +7 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/components/Chat.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/CommentContainer.d.ts +1 -1
- package/dist/types/src/components/CommentContainer.d.ts.map +1 -1
- package/dist/types/src/components/CommentsContainer.d.ts +2 -7
- package/dist/types/src/components/CommentsContainer.d.ts.map +1 -1
- package/dist/types/src/components/MessageContainer.d.ts.map +1 -1
- package/dist/types/src/components/ThreadComplementary.d.ts +1 -6
- package/dist/types/src/components/ThreadComplementary.d.ts.map +1 -1
- package/dist/types/src/components/ThreadContainer.d.ts +7 -0
- package/dist/types/src/components/ThreadContainer.d.ts.map +1 -0
- package/dist/types/src/components/command-extension.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -15
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +50 -66
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +5 -5
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/extensions/threads.d.ts +2 -2
- package/dist/types/src/extensions/threads.d.ts.map +1 -1
- package/dist/types/src/hooks/analytics.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +86 -22
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +30 -38
- package/src/ThreadPlugin.tsx +108 -620
- package/src/capabilities/app-graph-builder.ts +119 -0
- package/src/capabilities/capabilities.ts +19 -0
- package/src/capabilities/index.ts +14 -0
- package/src/capabilities/intent-resolver.ts +239 -0
- package/src/capabilities/markdown.ts +18 -0
- package/src/capabilities/react-surface.tsx +62 -0
- package/src/capabilities/settings.ts +14 -0
- package/src/capabilities/state.ts +25 -0
- package/src/components/Chat.stories.tsx +26 -22
- package/src/components/ChatContainer.tsx +12 -10
- package/src/components/CommentContainer.tsx +21 -32
- package/src/components/CommentsContainer.tsx +1 -17
- package/src/components/MessageContainer.tsx +7 -5
- package/src/components/ThreadComplementary.tsx +91 -68
- package/src/components/ThreadContainer.tsx +22 -0
- package/src/components/ThreadSettings.tsx +3 -3
- package/src/components/command-extension.ts +2 -5
- package/src/components/index.ts +1 -2
- package/src/components/testing.ts +26 -22
- package/src/components/types.ts +5 -5
- package/src/extensions/threads.ts +16 -25
- package/src/hooks/analytics.ts +6 -10
- package/src/index.ts +1 -5
- package/src/meta.ts +1 -1
- package/src/translations.ts +1 -0
- package/src/types.ts +70 -38
- package/dist/lib/browser/ThreadArticle-6IXTL7CH.mjs +0 -18
- package/dist/lib/browser/ThreadArticle-6IXTL7CH.mjs.map +0 -7
- package/dist/lib/browser/ThreadMain-4IAS67KE.mjs +0 -26
- package/dist/lib/browser/ThreadMain-4IAS67KE.mjs.map +0 -7
- package/dist/lib/browser/chunk-52HWDLBR.mjs.map +0 -7
- package/dist/lib/browser/chunk-ENERBDYI.mjs.map +0 -7
- package/dist/lib/browser/chunk-XUHNZID5.mjs +0 -20
- package/dist/lib/browser/chunk-XUHNZID5.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -11
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/lib/node/ThreadArticle-I7ADXDW3.cjs.map +0 -7
- package/dist/lib/node/ThreadMain-MRNJC3TI.cjs.map +0 -7
- package/dist/lib/node/chunk-IC2NICNC.cjs.map +0 -7
- package/dist/lib/node/chunk-XFO6D2LG.cjs +0 -39
- package/dist/lib/node/chunk-XFO6D2LG.cjs.map +0 -7
- package/dist/lib/node/chunk-YCDM2SZM.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/ThreadArticle-CJHYMF2W.mjs +0 -19
- package/dist/lib/node-esm/ThreadArticle-CJHYMF2W.mjs.map +0 -7
- package/dist/lib/node-esm/ThreadMain-VISGW4IF.mjs +0 -27
- package/dist/lib/node-esm/ThreadMain-VISGW4IF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7QRGG25F.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-I5MU54RT.mjs +0 -21
- package/dist/lib/node-esm/chunk-I5MU54RT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JG7MXH6O.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -12
- package/dist/lib/node-esm/meta.mjs.map +0 -7
- package/dist/types/src/components/ThreadArticle.d.ts +0 -5
- package/dist/types/src/components/ThreadArticle.d.ts.map +0 -1
- package/dist/types/src/components/ThreadMain.d.ts +0 -7
- package/dist/types/src/components/ThreadMain.d.ts.map +0 -1
- package/src/components/ThreadArticle.tsx +0 -18
- package/src/components/ThreadMain.tsx +0 -27
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
import { CheckCircle, X } from '@phosphor-icons/react';
|
|
6
6
|
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import { MessageType } from '@dxos/plugin-space/types';
|
|
8
|
+
import { RefArray } from '@dxos/live-object';
|
|
10
9
|
import { fullyQualifiedId, getSpace, useMembers } from '@dxos/react-client/echo';
|
|
11
10
|
import { useIdentity } from '@dxos/react-client/halo';
|
|
12
11
|
import { Button, Tag, Tooltip, useThemeContext, useTranslation } from '@dxos/react-ui';
|
|
@@ -56,7 +55,7 @@ const ToggleResolvedButton = ({
|
|
|
56
55
|
</Button>
|
|
57
56
|
</Tooltip.Trigger>
|
|
58
57
|
<Tooltip.Portal>
|
|
59
|
-
<Tooltip.Content
|
|
58
|
+
<Tooltip.Content>
|
|
60
59
|
{label}
|
|
61
60
|
<Tooltip.Arrow />
|
|
62
61
|
</Tooltip.Content>
|
|
@@ -82,7 +81,7 @@ const DeleteThreadButton = ({ onDelete }: { onDelete: () => void }) => {
|
|
|
82
81
|
</Button>
|
|
83
82
|
</Tooltip.Trigger>
|
|
84
83
|
<Tooltip.Portal>
|
|
85
|
-
<Tooltip.Content classNames='z-
|
|
84
|
+
<Tooltip.Content classNames='z-30'>
|
|
86
85
|
{label}
|
|
87
86
|
<Tooltip.Arrow />
|
|
88
87
|
</Tooltip.Content>
|
|
@@ -94,13 +93,12 @@ const DeleteThreadButton = ({ onDelete }: { onDelete: () => void }) => {
|
|
|
94
93
|
export const CommentContainer = ({
|
|
95
94
|
thread,
|
|
96
95
|
detached,
|
|
97
|
-
context,
|
|
98
96
|
current,
|
|
99
97
|
onAttend,
|
|
100
|
-
onThreadDelete,
|
|
101
|
-
onMessageDelete,
|
|
102
|
-
onResolve,
|
|
103
98
|
onComment,
|
|
99
|
+
onResolve,
|
|
100
|
+
onMessageDelete,
|
|
101
|
+
onThreadDelete,
|
|
104
102
|
}: ThreadContainerProps) => {
|
|
105
103
|
const identity = useIdentity()!;
|
|
106
104
|
const space = getSpace(thread);
|
|
@@ -129,31 +127,26 @@ export const CommentContainer = ({
|
|
|
129
127
|
const scrollToEnd = (behavior: ScrollBehavior) =>
|
|
130
128
|
setTimeout(() => threadScrollRef.current?.scrollIntoView({ behavior, block: 'end' }), 10);
|
|
131
129
|
|
|
132
|
-
const
|
|
130
|
+
const handleAttend = useCallback(() => onAttend?.(thread), [onAttend, thread]);
|
|
131
|
+
const handleResolve = useCallback(() => onResolve?.(thread), [onResolve, thread]);
|
|
132
|
+
const handleMessageDelete = useCallback((id: string) => onMessageDelete?.(thread, id), [onMessageDelete, thread]);
|
|
133
|
+
const handleThreadDelete = useCallback(() => onThreadDelete?.(thread), [onThreadDelete, thread]);
|
|
134
|
+
|
|
135
|
+
const handleComment: MessageTextboxProps['onSend'] = useCallback(() => {
|
|
133
136
|
if (!messageRef.current) {
|
|
134
137
|
return false;
|
|
135
138
|
}
|
|
136
139
|
|
|
137
|
-
thread.
|
|
138
|
-
create(MessageType, {
|
|
139
|
-
sender: { identityKey: identity.identityKey.toHex() },
|
|
140
|
-
timestamp: new Date().toISOString(),
|
|
141
|
-
text: messageRef.current,
|
|
142
|
-
context,
|
|
143
|
-
}),
|
|
144
|
-
);
|
|
145
|
-
onComment?.(thread);
|
|
146
|
-
|
|
140
|
+
onComment?.(thread, messageRef.current);
|
|
147
141
|
messageRef.current = '';
|
|
148
142
|
scrollToEnd('instant');
|
|
149
143
|
rerenderEditor();
|
|
150
144
|
|
|
151
|
-
// TODO(burdon): Scroll to bottom.
|
|
152
145
|
return true;
|
|
153
146
|
}, [thread, identity]);
|
|
154
147
|
|
|
155
148
|
return (
|
|
156
|
-
<Thread onClickCapture={
|
|
149
|
+
<Thread onClickCapture={handleAttend} onFocusCapture={handleAttend} current={current} id={fullyQualifiedId(thread)}>
|
|
157
150
|
<div
|
|
158
151
|
role='none'
|
|
159
152
|
className={mx(
|
|
@@ -168,7 +161,7 @@ export const CommentContainer = ({
|
|
|
168
161
|
<ThreadHeading detached>{thread.name}</ThreadHeading>
|
|
169
162
|
</Tooltip.Trigger>
|
|
170
163
|
<Tooltip.Portal>
|
|
171
|
-
<Tooltip.Content classNames='z-
|
|
164
|
+
<Tooltip.Content classNames='z-30' side='top'>
|
|
172
165
|
{t('detached thread label')}
|
|
173
166
|
<Tooltip.Arrow />
|
|
174
167
|
</Tooltip.Content>
|
|
@@ -180,18 +173,14 @@ export const CommentContainer = ({
|
|
|
180
173
|
<div className='flex flex-row items-center pli-1'>
|
|
181
174
|
{thread.status === 'staged' && <Tag palette='neutral'>{t('draft button')}</Tag>}
|
|
182
175
|
{onResolve && !(thread?.status === 'staged') && (
|
|
183
|
-
<ToggleResolvedButton isResolved={thread?.status === 'resolved'} onResolve={
|
|
176
|
+
<ToggleResolvedButton isResolved={thread?.status === 'resolved'} onResolve={handleResolve} />
|
|
184
177
|
)}
|
|
185
|
-
{onThreadDelete && <DeleteThreadButton onDelete={
|
|
178
|
+
{onThreadDelete && <DeleteThreadButton onDelete={handleThreadDelete} />}
|
|
186
179
|
</div>
|
|
187
180
|
</div>
|
|
188
|
-
{thread.messages
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
message={message}
|
|
192
|
-
members={members}
|
|
193
|
-
onDelete={(id: string) => onMessageDelete?.(id)}
|
|
194
|
-
/>
|
|
181
|
+
{/** TODO(dmaretskyi): How's `thread.messages` undefined? */}
|
|
182
|
+
{RefArray.allResolvedTargets(thread.messages?.filter(nonNullable) ?? []).map((message) => (
|
|
183
|
+
<MessageContainer key={message.id} message={message} members={members} onDelete={handleMessageDelete} />
|
|
195
184
|
))}
|
|
196
185
|
{/*
|
|
197
186
|
TODO(wittjosiah): Can't autofocus this generally.
|
|
@@ -199,7 +188,7 @@ export const CommentContainer = ({
|
|
|
199
188
|
Also, it steals focus from documents when first rendered.
|
|
200
189
|
Need to find a way to autofocus in one scenario only: when a new thread is created.
|
|
201
190
|
*/}
|
|
202
|
-
<MessageTextbox extensions={extensions} onSend={
|
|
191
|
+
<MessageTextbox extensions={extensions} onSend={handleComment} {...textboxMetadata} />
|
|
203
192
|
<ThreadFooter activity={activity}>{t('activity message')}</ThreadFooter>
|
|
204
193
|
{/* NOTE(thure): This can’t also be the `overflow-anchor` because `ScrollArea` injects an interceding node that contains this necessary ref’d element. */}
|
|
205
194
|
<div role='none' className='bs-px -mbs-px' ref={threadScrollRef} />
|
|
@@ -14,10 +14,7 @@ import { CommentContainer } from './CommentContainer';
|
|
|
14
14
|
import { type ThreadContainerProps } from './types';
|
|
15
15
|
import { THREAD_PLUGIN } from '../meta';
|
|
16
16
|
|
|
17
|
-
export type ThreadsContainerProps = Omit<
|
|
18
|
-
ThreadContainerProps,
|
|
19
|
-
'thread' | 'detached' | 'onAttend' | 'onThreadDelete' | 'onMessageDelete' | 'current' | 'autoFocus'
|
|
20
|
-
> & {
|
|
17
|
+
export type ThreadsContainerProps = Omit<ThreadContainerProps, 'thread' | 'detached' | 'current' | 'autoFocus'> & {
|
|
21
18
|
threads: ThreadType[];
|
|
22
19
|
/**
|
|
23
20
|
* Threads that are no longer anchored to a position in the object.
|
|
@@ -25,11 +22,6 @@ export type ThreadsContainerProps = Omit<
|
|
|
25
22
|
detached?: string[];
|
|
26
23
|
currentId?: string;
|
|
27
24
|
showResolvedThreads?: boolean;
|
|
28
|
-
onThreadAttend?: (thread: ThreadType) => void;
|
|
29
|
-
onThreadDelete?: (thread: ThreadType) => void;
|
|
30
|
-
onMessageDelete?: (thread: ThreadType, messageId: string) => void;
|
|
31
|
-
onThreadToggleResolved?: (thread: ThreadType) => void;
|
|
32
|
-
onComment?: (thread: ThreadType) => void;
|
|
33
25
|
};
|
|
34
26
|
|
|
35
27
|
/**
|
|
@@ -40,10 +32,6 @@ export const CommentsContainer = ({
|
|
|
40
32
|
detached = [],
|
|
41
33
|
currentId,
|
|
42
34
|
showResolvedThreads,
|
|
43
|
-
onThreadAttend,
|
|
44
|
-
onThreadDelete,
|
|
45
|
-
onMessageDelete,
|
|
46
|
-
onThreadToggleResolved,
|
|
47
35
|
...props
|
|
48
36
|
}: ThreadsContainerProps) => {
|
|
49
37
|
const { t } = useTranslation(THREAD_PLUGIN);
|
|
@@ -66,10 +54,6 @@ export const CommentsContainer = ({
|
|
|
66
54
|
thread={thread}
|
|
67
55
|
current={currentId === threadId}
|
|
68
56
|
detached={detached.includes(threadId)}
|
|
69
|
-
{...(onThreadAttend && { onAttend: () => onThreadAttend(thread) })}
|
|
70
|
-
{...(onThreadDelete && { onThreadDelete: () => onThreadDelete(thread) })}
|
|
71
|
-
{...(onMessageDelete && { onMessageDelete: (messageId: string) => onMessageDelete(thread, messageId) })}
|
|
72
|
-
{...(onThreadToggleResolved && { onResolve: () => onThreadToggleResolved(thread) })}
|
|
73
57
|
{...props}
|
|
74
58
|
/>
|
|
75
59
|
);
|
|
@@ -7,6 +7,7 @@ import { Check, PencilSimple, X } from '@phosphor-icons/react';
|
|
|
7
7
|
import React, { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
8
8
|
|
|
9
9
|
import { Surface } from '@dxos/app-framework';
|
|
10
|
+
import { RefArray } from '@dxos/live-object';
|
|
10
11
|
import { type MessageType } from '@dxos/plugin-space/types';
|
|
11
12
|
import { PublicKey } from '@dxos/react-client';
|
|
12
13
|
import { type ReactiveEchoObject, type Expando, type SpaceMember } from '@dxos/react-client/echo';
|
|
@@ -22,7 +23,6 @@ import {
|
|
|
22
23
|
mx,
|
|
23
24
|
} from '@dxos/react-ui-theme';
|
|
24
25
|
import { MessageHeading, MessageRoot } from '@dxos/react-ui-thread';
|
|
25
|
-
import { nonNullable } from '@dxos/util';
|
|
26
26
|
|
|
27
27
|
import { command } from './command-extension';
|
|
28
28
|
import { useOnEditAnalytics } from '../hooks';
|
|
@@ -70,7 +70,7 @@ export const MessageContainer = ({
|
|
|
70
70
|
</Button>
|
|
71
71
|
</Tooltip.Trigger>
|
|
72
72
|
<Tooltip.Portal>
|
|
73
|
-
<Tooltip.Content
|
|
73
|
+
<Tooltip.Content>
|
|
74
74
|
{editLabel}
|
|
75
75
|
<Tooltip.Arrow />
|
|
76
76
|
</Tooltip.Content>
|
|
@@ -91,7 +91,7 @@ export const MessageContainer = ({
|
|
|
91
91
|
</Button>
|
|
92
92
|
</Tooltip.Trigger>
|
|
93
93
|
<Tooltip.Portal>
|
|
94
|
-
<Tooltip.Content
|
|
94
|
+
<Tooltip.Content>
|
|
95
95
|
{deleteLabel}
|
|
96
96
|
<Tooltip.Arrow />
|
|
97
97
|
</Tooltip.Content>
|
|
@@ -101,7 +101,9 @@ export const MessageContainer = ({
|
|
|
101
101
|
</ButtonGroup>
|
|
102
102
|
</MessageHeading>
|
|
103
103
|
<TextboxBlock message={message} isAuthor={userIsAuthor} editing={editing} />
|
|
104
|
-
{message.parts
|
|
104
|
+
{RefArray.allResolvedTargets(message.parts ?? []).map((part, index) => (
|
|
105
|
+
<MessagePart key={index} part={part} />
|
|
106
|
+
))}
|
|
105
107
|
</MessageRoot>
|
|
106
108
|
);
|
|
107
109
|
};
|
|
@@ -180,7 +182,7 @@ const MessageBlockObjectTile: MosaicTileComponent<ReactiveEchoObject<any>> = for
|
|
|
180
182
|
<Surface
|
|
181
183
|
role='card'
|
|
182
184
|
limit={1}
|
|
183
|
-
data={{
|
|
185
|
+
data={{ subject: item }}
|
|
184
186
|
draggableProps={draggableProps}
|
|
185
187
|
fallback={title}
|
|
186
188
|
{...props}
|
|
@@ -2,47 +2,40 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { useEffect, useMemo } from 'react';
|
|
5
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { LayoutAction,
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { createIntent, LayoutAction, useCapability, useCapabilities, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
+
import { ThreadCapabilities } from '@dxos/plugin-space';
|
|
9
|
+
import { MessageType, type ThreadType } from '@dxos/plugin-space/types';
|
|
10
|
+
import { create, fullyQualifiedId, makeRef, RefArray } from '@dxos/react-client/echo';
|
|
11
|
+
import { useIdentity } from '@dxos/react-client/halo';
|
|
10
12
|
import { useAttended } from '@dxos/react-ui-attention';
|
|
11
13
|
import { nonNullable } from '@dxos/util';
|
|
12
14
|
|
|
15
|
+
import { ThreadCapabilities as LocalThreadCapabilities } from '../capabilities';
|
|
13
16
|
import { CommentsContainer } from '../components';
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
subject
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
showResolvedThreads,
|
|
26
|
-
}: {
|
|
27
|
-
role: string;
|
|
28
|
-
subject: any;
|
|
29
|
-
drafts: ThreadType[] | undefined;
|
|
30
|
-
current?: string;
|
|
31
|
-
showResolvedThreads?: boolean;
|
|
32
|
-
}) => {
|
|
33
|
-
const dispatch = useIntentDispatcher();
|
|
34
|
-
|
|
35
|
-
const threadsIntegrators = useResolvePlugins(providesThreadsConfig);
|
|
36
|
-
const threadProvides = useMemo(() => threadsIntegrators.map((p) => p.provides.thread), [threadsIntegrators]);
|
|
17
|
+
import { ThreadAction } from '../types';
|
|
18
|
+
|
|
19
|
+
export const ThreadComplementary = ({ subject }: { subject: any }) => {
|
|
20
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
21
|
+
const identity = useIdentity();
|
|
22
|
+
|
|
23
|
+
const { state, getViewState } = useCapability(LocalThreadCapabilities.MutableState);
|
|
24
|
+
const { showResolvedThreads } = getViewState(fullyQualifiedId(subject));
|
|
25
|
+
const drafts = state.drafts[fullyQualifiedId(subject)];
|
|
26
|
+
|
|
27
|
+
const threadsIntegrators = useCapabilities(ThreadCapabilities.Thread);
|
|
37
28
|
const createSort = useMemo(
|
|
38
|
-
() =>
|
|
39
|
-
[
|
|
29
|
+
() => threadsIntegrators.find((p) => p.predicate(subject))?.createSort,
|
|
30
|
+
[threadsIntegrators, subject],
|
|
40
31
|
);
|
|
41
32
|
const sort = useMemo(() => createSort?.(subject), [createSort, subject]);
|
|
42
33
|
|
|
34
|
+
const threadObjects = RefArray.allResolvedTargets(subject.threads ?? []);
|
|
35
|
+
|
|
43
36
|
const threads = useMemo(() => {
|
|
44
|
-
return
|
|
45
|
-
}, [JSON.stringify(
|
|
37
|
+
return threadObjects.concat(drafts ?? []).filter(nonNullable) as ThreadType[];
|
|
38
|
+
}, [JSON.stringify(threadObjects), JSON.stringify(drafts)]);
|
|
46
39
|
|
|
47
40
|
const detachedIds = useMemo(() => {
|
|
48
41
|
return threads.filter(({ anchor }) => !anchor).map((thread) => fullyQualifiedId(thread));
|
|
@@ -58,48 +51,78 @@ export const ThreadComplementary = ({
|
|
|
58
51
|
const attended = useAttended();
|
|
59
52
|
const qualifiedSubjectId = fullyQualifiedId(subject);
|
|
60
53
|
|
|
54
|
+
const handleAttend = useCallback(
|
|
55
|
+
(thread: ThreadType) => {
|
|
56
|
+
const threadId = fullyQualifiedId(thread);
|
|
57
|
+
if (state.current !== threadId) {
|
|
58
|
+
state.current = threadId;
|
|
59
|
+
|
|
60
|
+
// TODO(wittjosiah): Should this be a thread-specific intent?
|
|
61
|
+
// The layout doesn't know about threads and this working depends on other plugins conditionally handling it.
|
|
62
|
+
// This may be overloading this intent or highjacking its intended purpose.
|
|
63
|
+
void dispatch(
|
|
64
|
+
createIntent(LayoutAction.ScrollIntoView, {
|
|
65
|
+
part: 'current',
|
|
66
|
+
subject: fullyQualifiedId(subject),
|
|
67
|
+
options: {
|
|
68
|
+
cursor: thread.anchor,
|
|
69
|
+
ref: threadId,
|
|
70
|
+
},
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
[state.current, dispatch, subject],
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const handleComment = useCallback(
|
|
79
|
+
async (thread: ThreadType, message: string) => {
|
|
80
|
+
thread.messages.push(
|
|
81
|
+
makeRef(
|
|
82
|
+
create(MessageType, {
|
|
83
|
+
sender: { identityKey: identity?.identityKey.toHex() },
|
|
84
|
+
timestamp: new Date().toISOString(),
|
|
85
|
+
text: message,
|
|
86
|
+
// TODO(wittjosiah): Context based on attention.
|
|
87
|
+
// context: context ? makeRef(context) : undefined,
|
|
88
|
+
}),
|
|
89
|
+
),
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
await dispatch(createIntent(ThreadAction.OnMessageAdd, { thread, subject }));
|
|
93
|
+
|
|
94
|
+
state.current = fullyQualifiedId(thread);
|
|
95
|
+
},
|
|
96
|
+
[dispatch, identity, subject],
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const handleResolve = useCallback(
|
|
100
|
+
(thread: ThreadType) => dispatch(createIntent(ThreadAction.ToggleResolved, { thread })),
|
|
101
|
+
[dispatch],
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const handleThreadDelete = useCallback(
|
|
105
|
+
(thread: ThreadType) => dispatch(createIntent(ThreadAction.Delete, { thread, subject })),
|
|
106
|
+
[dispatch, subject],
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const handleMessageDelete = useCallback(
|
|
110
|
+
(thread: ThreadType, messageId: string) =>
|
|
111
|
+
dispatch(createIntent(ThreadAction.DeleteMessage, { thread, subject, messageId })),
|
|
112
|
+
[dispatch, subject],
|
|
113
|
+
);
|
|
114
|
+
|
|
61
115
|
return (
|
|
62
116
|
<CommentsContainer
|
|
63
117
|
threads={threads}
|
|
64
118
|
detached={detachedIds}
|
|
65
|
-
currentId={attended.includes(qualifiedSubjectId) ? current : undefined}
|
|
119
|
+
currentId={attended.includes(qualifiedSubjectId) ? state.current : undefined}
|
|
66
120
|
showResolvedThreads={showResolvedThreads}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// TODO(wittjosiah): Should this be a thread-specific intent?
|
|
73
|
-
// The layout doesn't know about threads and this working depends on other plugins conditionally handling it.
|
|
74
|
-
// This may be overloading this intent or highjacking its intended purpose.
|
|
75
|
-
void dispatch?.([
|
|
76
|
-
{
|
|
77
|
-
action: LayoutAction.SCROLL_INTO_VIEW,
|
|
78
|
-
data: {
|
|
79
|
-
id: fullyQualifiedId(subject),
|
|
80
|
-
thread: threadId,
|
|
81
|
-
cursor: thread.anchor,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
]);
|
|
85
|
-
}
|
|
86
|
-
}}
|
|
87
|
-
onThreadDelete={(thread) => {
|
|
88
|
-
return dispatch({ plugin: THREAD_PLUGIN, action: ThreadAction.DELETE, data: { subject, thread } });
|
|
89
|
-
}}
|
|
90
|
-
onMessageDelete={(thread, messageId) =>
|
|
91
|
-
dispatch({
|
|
92
|
-
plugin: THREAD_PLUGIN,
|
|
93
|
-
action: ThreadAction.DELETE_MESSAGE,
|
|
94
|
-
data: { subject, thread, messageId },
|
|
95
|
-
})
|
|
96
|
-
}
|
|
97
|
-
onThreadToggleResolved={(thread) =>
|
|
98
|
-
dispatch({ plugin: THREAD_PLUGIN, action: ThreadAction.TOGGLE_RESOLVED, data: { thread } })
|
|
99
|
-
}
|
|
100
|
-
onComment={(thread) => {
|
|
101
|
-
void dispatch({ action: ThreadAction.ON_MESSAGE_ADD, data: { thread, subject } });
|
|
102
|
-
}}
|
|
121
|
+
onAttend={handleAttend}
|
|
122
|
+
onComment={handleComment}
|
|
123
|
+
onResolve={handleResolve}
|
|
124
|
+
onMessageDelete={handleMessageDelete}
|
|
125
|
+
onThreadDelete={handleThreadDelete}
|
|
103
126
|
/>
|
|
104
127
|
);
|
|
105
128
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type ComponentProps } from 'react';
|
|
6
|
+
|
|
7
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
8
|
+
|
|
9
|
+
import { ChatContainer } from './ChatContainer';
|
|
10
|
+
|
|
11
|
+
const ThreadContainer = ({
|
|
12
|
+
role,
|
|
13
|
+
...props
|
|
14
|
+
}: Pick<ComponentProps<typeof ChatContainer>, 'thread' | 'context'> & { role: string }) => {
|
|
15
|
+
return (
|
|
16
|
+
<StackItem.Content toolbar={false}>
|
|
17
|
+
<ChatContainer {...props} />
|
|
18
|
+
</StackItem.Content>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default ThreadContainer;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { Input, useTranslation } from '@dxos/react-ui';
|
|
8
|
-
import { DeprecatedFormInput } from '@dxos/react-ui-form';
|
|
8
|
+
import { DeprecatedFormContainer, DeprecatedFormInput } from '@dxos/react-ui-form';
|
|
9
9
|
|
|
10
10
|
import { THREAD_PLUGIN } from '../meta';
|
|
11
11
|
import type { ThreadSettingsProps } from '../types';
|
|
@@ -14,10 +14,10 @@ export const ThreadSettings = ({ settings }: { settings: ThreadSettingsProps })
|
|
|
14
14
|
const { t } = useTranslation(THREAD_PLUGIN);
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
|
-
|
|
17
|
+
<DeprecatedFormContainer>
|
|
18
18
|
<DeprecatedFormInput label={t('settings standalone label')}>
|
|
19
19
|
<Input.Switch checked={settings.standalone} onCheckedChange={(checked) => (settings.standalone = !!checked)} />
|
|
20
20
|
</DeprecatedFormInput>
|
|
21
|
-
|
|
21
|
+
</DeprecatedFormContainer>
|
|
22
22
|
);
|
|
23
23
|
};
|
|
@@ -6,7 +6,7 @@ import { StreamLanguage, HighlightStyle, syntaxHighlighting } from '@codemirror/
|
|
|
6
6
|
import { type Extension } from '@codemirror/state';
|
|
7
7
|
|
|
8
8
|
import { tags } from '@dxos/react-ui-editor';
|
|
9
|
-
import { mx
|
|
9
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* https://github.com/codemirror/stream-parser/blob/main/test/test-stream-parser.ts
|
|
@@ -27,10 +27,7 @@ const parser = StreamLanguage.define<{ count: number }>({
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
const styles = HighlightStyle.define([
|
|
30
|
-
{
|
|
31
|
-
tag: tags.tagName,
|
|
32
|
-
class: mx(tagRoot({ palette: 'cyan' }), 'text-baseText font-medium'),
|
|
33
|
-
},
|
|
30
|
+
{ tag: tags.tagName, class: mx('dx-tag dx-tag--indigo text-baseText font-medium') },
|
|
34
31
|
]);
|
|
35
32
|
|
|
36
33
|
export const command: Extension = [parser, syntaxHighlighting(styles)];
|
package/src/components/index.ts
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { lazy } from 'react';
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
export const ThreadArticle = lazy(() => import('./ThreadArticle'));
|
|
7
|
+
export const ThreadContainer = lazy(() => import('./ThreadContainer'));
|
|
9
8
|
|
|
10
9
|
// TODO(wittjosiah): Suspense boundary for sidebar?
|
|
11
10
|
export * from './CommentContainer';
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { Expando } from '@dxos/echo-schema';
|
|
6
6
|
import { PublicKey } from '@dxos/keys';
|
|
7
|
-
import { create } from '@dxos/live-object';
|
|
7
|
+
import { create, makeRef } from '@dxos/live-object';
|
|
8
8
|
import { MessageType, ThreadType } from '@dxos/plugin-space/types';
|
|
9
9
|
import { faker } from '@dxos/random';
|
|
10
10
|
import { type Identity } from '@dxos/react-client/halo';
|
|
@@ -12,20 +12,22 @@ import { type Identity } from '@dxos/react-client/halo';
|
|
|
12
12
|
export const createChatThread = (identity: Identity) => {
|
|
13
13
|
return create(ThreadType, {
|
|
14
14
|
messages: Array.from({ length: 8 }).map(() =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
makeRef(
|
|
16
|
+
create(MessageType, {
|
|
17
|
+
sender: {
|
|
18
|
+
identityKey: faker.datatype.boolean() ? identity.identityKey.toHex() : PublicKey.random().toHex(),
|
|
19
|
+
},
|
|
20
|
+
timestamp: faker.date.recent().toISOString(),
|
|
21
|
+
text: faker.lorem.sentences(3),
|
|
22
|
+
parts: faker.helpers.multiple(
|
|
23
|
+
() =>
|
|
24
|
+
faker.datatype.boolean({ probability: 0.8 })
|
|
25
|
+
? undefined
|
|
26
|
+
: (makeRef(create(Expando, { name: faker.lorem.sentence() })) as any), // TODO(dmaretskyi): Fix types in schema.
|
|
27
|
+
{ count: { min: 1, max: 3 } },
|
|
28
|
+
),
|
|
29
|
+
}),
|
|
30
|
+
),
|
|
29
31
|
),
|
|
30
32
|
});
|
|
31
33
|
};
|
|
@@ -34,13 +36,15 @@ export const createCommentThread = (identity: Identity) => {
|
|
|
34
36
|
return create(ThreadType, {
|
|
35
37
|
messages: faker.helpers.multiple(
|
|
36
38
|
() =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
makeRef(
|
|
40
|
+
create(MessageType, {
|
|
41
|
+
sender: {
|
|
42
|
+
identityKey: faker.datatype.boolean() ? identity.identityKey.toHex() : PublicKey.random().toHex(),
|
|
43
|
+
},
|
|
44
|
+
timestamp: new Date().toISOString(),
|
|
45
|
+
text: faker.lorem.sentences(3),
|
|
46
|
+
}),
|
|
47
|
+
),
|
|
44
48
|
{ count: { min: 2, max: 3 } },
|
|
45
49
|
),
|
|
46
50
|
});
|
package/src/components/types.ts
CHANGED
|
@@ -24,9 +24,9 @@ export type ThreadContainerProps = {
|
|
|
24
24
|
autoFocusTextbox?: boolean;
|
|
25
25
|
onTextboxFocus?: () => void;
|
|
26
26
|
detached?: boolean;
|
|
27
|
-
onAttend?: () => void;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
onMessageDelete?: (messageId: string) => void;
|
|
31
|
-
|
|
27
|
+
onAttend?: (thread: ThreadType) => void;
|
|
28
|
+
onComment?: (thread: ThreadType, message: string) => void;
|
|
29
|
+
onResolve?: (thread: ThreadType) => void;
|
|
30
|
+
onMessageDelete?: (thread: ThreadType, messageId: string) => void;
|
|
31
|
+
onThreadDelete?: (thread: ThreadType) => void;
|
|
32
32
|
} & Pick<ThreadProps, 'current'>;
|