@dxos/plugin-thread 0.7.5-main.9d2a38b → 0.7.5-main.ff8607b
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-4VLBSBI7.mjs → ThreadContainer-OI5M262D.mjs} +2 -2
- package/dist/lib/browser/{chunk-2B3EXYZ7.mjs → chunk-BD3J6HEY.mjs} +3 -3
- package/dist/lib/browser/{chunk-GQONSZ3J.mjs → chunk-GQVZK3BQ.mjs} +3 -5
- package/dist/lib/browser/{chunk-GQONSZ3J.mjs.map → chunk-GQVZK3BQ.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +5 -5
- package/dist/lib/browser/index.mjs.map +3 -3
- 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/meta.json +1 -1
- package/dist/lib/browser/{react-surface-CHCZO4TI.mjs → react-surface-PXYCYPWA.mjs} +30 -32
- package/dist/lib/browser/react-surface-PXYCYPWA.mjs.map +7 -0
- package/dist/lib/node/{ThreadContainer-VOYLV4UL.cjs → ThreadContainer-L6TPQJWA.cjs} +6 -6
- package/dist/lib/node/{chunk-6PUGKCPR.cjs → chunk-2TK6J6BN.cjs} +5 -7
- package/dist/lib/node/{chunk-6PUGKCPR.cjs.map → chunk-2TK6J6BN.cjs.map} +3 -3
- package/dist/lib/node/{chunk-ZRN7B26W.cjs → chunk-S5LH7AIT.cjs} +6 -6
- package/dist/lib/node/index.cjs +10 -10
- package/dist/lib/node/index.cjs.map +3 -3
- 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/meta.json +1 -1
- package/dist/lib/node/{react-surface-LO7S2HPR.cjs → react-surface-CPDCOLUZ.cjs} +33 -35
- package/dist/lib/node/react-surface-CPDCOLUZ.cjs.map +7 -0
- package/dist/lib/node-esm/{ThreadContainer-7DZY2MWA.mjs → ThreadContainer-HE46AQJH.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-GS2OILYF.mjs → chunk-7YYL6QVU.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-DYFIKKDT.mjs → chunk-AZCU7SHI.mjs} +3 -5
- package/dist/lib/node-esm/{chunk-DYFIKKDT.mjs.map → chunk-AZCU7SHI.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +5 -5
- package/dist/lib/node-esm/index.mjs.map +3 -3
- 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/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-LAF3QIPB.mjs → react-surface-RD4F2LRT.mjs} +30 -32
- package/dist/lib/node-esm/react-surface-RD4F2LRT.mjs.map +7 -0
- package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +22 -22
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +30 -30
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/ThreadComplementary.d.ts.map +1 -1
- package/dist/types/src/components/command-extension.d.ts.map +1 -1
- package/package.json +30 -30
- package/src/ThreadPlugin.tsx +3 -4
- package/src/capabilities/intent-resolver.ts +180 -164
- package/src/capabilities/react-surface.tsx +12 -17
- package/src/components/ThreadComplementary.tsx +7 -4
- package/src/components/ThreadSettings.tsx +3 -3
- package/src/components/command-extension.ts +2 -5
- package/dist/lib/browser/intent-resolver-PIEZ3LKQ.mjs +0 -275
- package/dist/lib/browser/intent-resolver-PIEZ3LKQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-CHCZO4TI.mjs.map +0 -7
- package/dist/lib/node/intent-resolver-X5O3SVLF.cjs +0 -287
- package/dist/lib/node/intent-resolver-X5O3SVLF.cjs.map +0 -7
- package/dist/lib/node/react-surface-LO7S2HPR.cjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-XJWT5X6T.mjs +0 -276
- package/dist/lib/node-esm/intent-resolver-XJWT5X6T.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-LAF3QIPB.mjs.map +0 -7
- /package/dist/lib/browser/{ThreadContainer-4VLBSBI7.mjs.map → ThreadContainer-OI5M262D.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-2B3EXYZ7.mjs.map → chunk-BD3J6HEY.mjs.map} +0 -0
- /package/dist/lib/node/{ThreadContainer-VOYLV4UL.cjs.map → ThreadContainer-L6TPQJWA.cjs.map} +0 -0
- /package/dist/lib/node/{chunk-ZRN7B26W.cjs.map → chunk-S5LH7AIT.cjs.map} +0 -0
- /package/dist/lib/node-esm/{ThreadContainer-7DZY2MWA.mjs.map → ThreadContainer-HE46AQJH.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-GS2OILYF.mjs.map → chunk-7YYL6QVU.mjs.map} +0 -0
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
createIntent,
|
|
9
9
|
createResolver,
|
|
10
10
|
LayoutAction,
|
|
11
|
-
NavigationAction,
|
|
12
11
|
type PluginsContext,
|
|
13
12
|
} from '@dxos/app-framework';
|
|
14
13
|
import { Ref } from '@dxos/echo-schema';
|
|
@@ -23,201 +22,218 @@ import { ThreadAction } from '../types';
|
|
|
23
22
|
|
|
24
23
|
export default (context: PluginsContext) =>
|
|
25
24
|
contributes(Capabilities.IntentResolver, [
|
|
26
|
-
createResolver(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
createResolver({
|
|
26
|
+
intent: ThreadAction.Create,
|
|
27
|
+
resolve: ({ name, cursor, subject }) => {
|
|
28
|
+
if (cursor && subject) {
|
|
29
|
+
// Seed the threads array if it does not exist.
|
|
30
|
+
if (subject?.threads === undefined) {
|
|
31
|
+
try {
|
|
32
|
+
// Static schema will throw an error if subject does not support threads array property.
|
|
33
|
+
subject.threads = [];
|
|
34
|
+
} catch (err) {
|
|
35
|
+
log.error('Subject does not support threads array', { typename: subject?.typename });
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
36
38
|
}
|
|
37
|
-
}
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
const { state } = context.requestCapability(ThreadCapabilities.MutableState);
|
|
41
|
+
const subjectId = fullyQualifiedId(subject);
|
|
42
|
+
const thread = create(ThreadType, { name, anchor: cursor, messages: [], status: 'staged' });
|
|
43
|
+
const draft = state.drafts[subjectId];
|
|
44
|
+
if (draft) {
|
|
45
|
+
draft.push(thread);
|
|
46
|
+
} else {
|
|
47
|
+
state.drafts[subjectId] = [thread];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
data: { object: thread },
|
|
52
|
+
intents: [
|
|
53
|
+
createIntent(ThreadAction.Select, { current: fullyQualifiedId(thread) }),
|
|
54
|
+
createIntent(LayoutAction.UpdateComplementary, { part: 'complementary', subject: 'comments' }),
|
|
55
|
+
],
|
|
56
|
+
};
|
|
45
57
|
} else {
|
|
46
|
-
|
|
58
|
+
// NOTE: This is the standalone thread creation case.
|
|
59
|
+
return {
|
|
60
|
+
data: { object: create(ChannelType, { threads: [makeRef(create(ThreadType, { messages: [] }))] }) },
|
|
61
|
+
};
|
|
47
62
|
}
|
|
63
|
+
},
|
|
64
|
+
}),
|
|
65
|
+
createResolver({
|
|
66
|
+
intent: ThreadAction.Select,
|
|
67
|
+
resolve: ({ current, skipOpen }) => {
|
|
68
|
+
const { state } = context.requestCapability(ThreadCapabilities.MutableState);
|
|
69
|
+
state.current = current;
|
|
48
70
|
|
|
49
71
|
return {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
createIntent(NavigationAction.Open, { activeParts: { complementary: 'comments' } }),
|
|
54
|
-
createIntent(LayoutAction.SetLayout, { element: 'complementary', state: true }),
|
|
55
|
-
],
|
|
56
|
-
};
|
|
57
|
-
} else {
|
|
58
|
-
// NOTE: This is the standalone thread creation case.
|
|
59
|
-
return {
|
|
60
|
-
data: { object: create(ChannelType, { threads: [makeRef(create(ThreadType, { messages: [] }))] }) },
|
|
72
|
+
intents: !skipOpen
|
|
73
|
+
? [createIntent(LayoutAction.UpdateComplementary, { part: 'complementary', subject: 'comments' })]
|
|
74
|
+
: undefined,
|
|
61
75
|
};
|
|
62
|
-
}
|
|
63
|
-
}),
|
|
64
|
-
createResolver(ThreadAction.Select, ({ current, skipOpen }) => {
|
|
65
|
-
const { state } = context.requestCapability(ThreadCapabilities.MutableState);
|
|
66
|
-
state.current = current;
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
intents: !skipOpen
|
|
70
|
-
? [createIntent(NavigationAction.Open, { activeParts: { complementary: 'comments' } })]
|
|
71
|
-
: undefined,
|
|
72
|
-
};
|
|
73
|
-
}),
|
|
74
|
-
createResolver(ThreadAction.ToggleResolved, ({ thread }) => {
|
|
75
|
-
if (thread.status === 'active' || thread.status === undefined) {
|
|
76
|
-
thread.status = 'resolved';
|
|
77
|
-
} else if (thread.status === 'resolved') {
|
|
78
|
-
thread.status = 'active';
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const space = getSpace(thread);
|
|
82
|
-
const spaceId = space?.id;
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
intents: [
|
|
86
|
-
createIntent(ObservabilityAction.SendEvent, {
|
|
87
|
-
name: 'threads.toggle-resolved',
|
|
88
|
-
properties: { threadId: thread.id, spaceId },
|
|
89
|
-
}),
|
|
90
|
-
],
|
|
91
|
-
};
|
|
76
|
+
},
|
|
92
77
|
}),
|
|
93
|
-
createResolver(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (index !== -1) {
|
|
101
|
-
draft.splice(index, 1);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const space = getSpace(thread);
|
|
107
|
-
if (!space || !subject.threads) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (!undo) {
|
|
112
|
-
const index = subject.threads.findIndex((t: any) => t?.id === thread.id);
|
|
113
|
-
const cursor = subject.threads[index]?.anchor;
|
|
114
|
-
if (index !== -1) {
|
|
115
|
-
subject.threads?.splice(index, 1);
|
|
78
|
+
createResolver({
|
|
79
|
+
intent: ThreadAction.ToggleResolved,
|
|
80
|
+
resolve: ({ thread }) => {
|
|
81
|
+
if (thread.status === 'active' || thread.status === undefined) {
|
|
82
|
+
thread.status = 'resolved';
|
|
83
|
+
} else if (thread.status === 'resolved') {
|
|
84
|
+
thread.status = 'active';
|
|
116
85
|
}
|
|
117
86
|
|
|
118
|
-
space
|
|
87
|
+
const space = getSpace(thread);
|
|
88
|
+
const spaceId = space?.id;
|
|
119
89
|
|
|
120
90
|
return {
|
|
121
|
-
undoable: {
|
|
122
|
-
message: ['thread deleted label', { ns: THREAD_PLUGIN }],
|
|
123
|
-
data: { cursor },
|
|
124
|
-
},
|
|
125
91
|
intents: [
|
|
126
92
|
createIntent(ObservabilityAction.SendEvent, {
|
|
127
|
-
name: 'threads.
|
|
128
|
-
properties: { threadId: thread.id, spaceId
|
|
93
|
+
name: 'threads.toggle-resolved',
|
|
94
|
+
properties: { threadId: thread.id, spaceId },
|
|
129
95
|
}),
|
|
130
96
|
],
|
|
131
97
|
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
98
|
+
},
|
|
99
|
+
}),
|
|
100
|
+
createResolver({
|
|
101
|
+
intent: ThreadAction.Delete,
|
|
102
|
+
resolve: ({ subject, thread }, undo) => {
|
|
103
|
+
const { state } = context.requestCapability(ThreadCapabilities.MutableState);
|
|
104
|
+
const subjectId = fullyQualifiedId(subject);
|
|
105
|
+
const draft = state.drafts[subjectId];
|
|
106
|
+
if (draft) {
|
|
107
|
+
// Check if we're deleting a draft; if so, remove it.
|
|
108
|
+
const index = draft.findIndex((t) => t.id === thread.id);
|
|
109
|
+
if (index !== -1) {
|
|
110
|
+
draft.splice(index, 1);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
136
114
|
|
|
137
|
-
|
|
138
|
-
|
|
115
|
+
const space = getSpace(thread);
|
|
116
|
+
if (!space || !subject.threads) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!undo) {
|
|
121
|
+
const index = subject.threads.findIndex((t: any) => t?.id === thread.id);
|
|
122
|
+
const cursor = subject.threads[index]?.anchor;
|
|
123
|
+
if (index !== -1) {
|
|
124
|
+
subject.threads?.splice(index, 1);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
space.db.remove(thread);
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
undoable: {
|
|
131
|
+
message: ['thread deleted label', { ns: THREAD_PLUGIN }],
|
|
132
|
+
data: { cursor },
|
|
133
|
+
},
|
|
134
|
+
intents: [
|
|
135
|
+
createIntent(ObservabilityAction.SendEvent, {
|
|
136
|
+
name: 'threads.delete',
|
|
137
|
+
properties: { threadId: thread.id, spaceId: space.id },
|
|
138
|
+
}),
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
} else {
|
|
142
|
+
// TODO(wittjosiah): SDK should do this automatically.
|
|
143
|
+
const savedThread = space.db.add(thread);
|
|
144
|
+
subject.threads.push(savedThread);
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
intents: [
|
|
148
|
+
createIntent(ObservabilityAction.SendEvent, {
|
|
149
|
+
name: 'threads.undo-delete',
|
|
150
|
+
properties: { threadId: thread.id, spaceId: space.id },
|
|
151
|
+
}),
|
|
152
|
+
],
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
}),
|
|
157
|
+
createResolver({
|
|
158
|
+
intent: ThreadAction.OnMessageAdd,
|
|
159
|
+
resolve: ({ thread, subject }) => {
|
|
160
|
+
const { state } = context.requestCapability(ThreadCapabilities.MutableState);
|
|
161
|
+
const subjectId = fullyQualifiedId(subject);
|
|
162
|
+
const space = getSpace(subject);
|
|
163
|
+
const intents = [];
|
|
164
|
+
const analyticsProperties = { threadId: thread.id, spaceId: space?.id };
|
|
165
|
+
|
|
166
|
+
if (state.drafts[subjectId]?.find((t) => t === thread)) {
|
|
167
|
+
// Move draft to document.
|
|
168
|
+
thread.status = 'active';
|
|
169
|
+
subject.threads ? subject.threads.push(makeRef(thread)) : (subject.threads = [makeRef(thread)]);
|
|
170
|
+
state.drafts[subjectId] = state.drafts[subjectId]?.filter(({ id }) => id !== thread.id);
|
|
171
|
+
intents.push(
|
|
139
172
|
createIntent(ObservabilityAction.SendEvent, {
|
|
140
|
-
name: 'threads.
|
|
141
|
-
properties:
|
|
173
|
+
name: 'threads.thread-created',
|
|
174
|
+
properties: analyticsProperties,
|
|
142
175
|
}),
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
}),
|
|
147
|
-
createResolver(ThreadAction.OnMessageAdd, ({ thread, subject }) => {
|
|
148
|
-
const { state } = context.requestCapability(ThreadCapabilities.MutableState);
|
|
149
|
-
const subjectId = fullyQualifiedId(subject);
|
|
150
|
-
const space = getSpace(subject);
|
|
151
|
-
const intents = [];
|
|
152
|
-
const analyticsProperties = { threadId: thread.id, spaceId: space?.id };
|
|
153
|
-
|
|
154
|
-
if (state.drafts[subjectId]?.find((t) => t === thread)) {
|
|
155
|
-
// Move draft to document.
|
|
156
|
-
thread.status = 'active';
|
|
157
|
-
subject.threads ? subject.threads.push(makeRef(thread)) : (subject.threads = [makeRef(thread)]);
|
|
158
|
-
state.drafts[subjectId] = state.drafts[subjectId]?.filter(({ id }) => id !== thread.id);
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
159
179
|
intents.push(
|
|
160
180
|
createIntent(ObservabilityAction.SendEvent, {
|
|
161
|
-
name: 'threads.
|
|
162
|
-
properties: analyticsProperties,
|
|
181
|
+
name: 'threads.message-added',
|
|
182
|
+
properties: { ...analyticsProperties, threadLength: thread.messages.length },
|
|
163
183
|
}),
|
|
164
184
|
);
|
|
165
|
-
}
|
|
166
185
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
name: 'threads.message-added',
|
|
170
|
-
properties: { ...analyticsProperties, threadLength: thread.messages.length },
|
|
171
|
-
}),
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
return { intents };
|
|
186
|
+
return { intents };
|
|
187
|
+
},
|
|
175
188
|
}),
|
|
176
|
-
createResolver(
|
|
177
|
-
|
|
189
|
+
createResolver({
|
|
190
|
+
intent: ThreadAction.DeleteMessage,
|
|
191
|
+
resolve: ({ subject, thread, messageId, message, messageIndex }, undo) => {
|
|
192
|
+
const space = getSpace(subject);
|
|
193
|
+
|
|
194
|
+
if (!undo) {
|
|
195
|
+
const messageIndex = thread.messages.findIndex(Ref.hasObjectId(messageId));
|
|
196
|
+
const message = thread.messages[messageIndex]?.target;
|
|
197
|
+
if (!message) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
178
200
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
201
|
+
if (messageIndex === 0 && thread.messages.length === 1) {
|
|
202
|
+
// If the message is the only message in the thread, delete the thread.
|
|
203
|
+
return {
|
|
204
|
+
intents: [createIntent(ThreadAction.Delete, { subject, thread })],
|
|
205
|
+
};
|
|
206
|
+
} else {
|
|
207
|
+
thread.messages.splice(messageIndex, 1);
|
|
208
|
+
}
|
|
185
209
|
|
|
186
|
-
if (messageIndex === 0 && thread.messages.length === 1) {
|
|
187
|
-
// If the message is the only message in the thread, delete the thread.
|
|
188
210
|
return {
|
|
189
|
-
|
|
211
|
+
undoable: {
|
|
212
|
+
message: ['message deleted label', { ns: THREAD_PLUGIN }],
|
|
213
|
+
data: { message, messageIndex },
|
|
214
|
+
},
|
|
215
|
+
intents: [
|
|
216
|
+
createIntent(ObservabilityAction.SendEvent, {
|
|
217
|
+
name: 'threads.message.delete',
|
|
218
|
+
properties: { threadId: thread.id, spaceId: space?.id },
|
|
219
|
+
}),
|
|
220
|
+
],
|
|
190
221
|
};
|
|
191
222
|
} else {
|
|
192
|
-
|
|
193
|
-
|
|
223
|
+
if (!messageIndex || !message) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
194
226
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}),
|
|
205
|
-
],
|
|
206
|
-
};
|
|
207
|
-
} else {
|
|
208
|
-
if (!messageIndex || !message) {
|
|
209
|
-
return;
|
|
227
|
+
thread.messages.splice(messageIndex, 0, makeRef(message));
|
|
228
|
+
return {
|
|
229
|
+
intents: [
|
|
230
|
+
createIntent(ObservabilityAction.SendEvent, {
|
|
231
|
+
name: 'threads.message.undo-delete',
|
|
232
|
+
properties: { threadId: thread.id, spaceId: space?.id },
|
|
233
|
+
}),
|
|
234
|
+
],
|
|
235
|
+
};
|
|
210
236
|
}
|
|
211
|
-
|
|
212
|
-
thread.messages.splice(messageIndex, 0, makeRef(message));
|
|
213
|
-
return {
|
|
214
|
-
intents: [
|
|
215
|
-
createIntent(ObservabilityAction.SendEvent, {
|
|
216
|
-
name: 'threads.message.undo-delete',
|
|
217
|
-
properties: { threadId: thread.id, spaceId: space?.id },
|
|
218
|
-
}),
|
|
219
|
-
],
|
|
220
|
-
};
|
|
221
|
-
}
|
|
237
|
+
},
|
|
222
238
|
}),
|
|
223
239
|
]);
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { Capabilities, contributes, createSurface,
|
|
7
|
+
import { Capabilities, contributes, createSurface, useLayout } from '@dxos/app-framework';
|
|
8
8
|
import { type Ref } from '@dxos/echo-schema';
|
|
9
|
+
import { SettingsStore } from '@dxos/local-storage';
|
|
9
10
|
import { ChannelType, type ThreadType } from '@dxos/plugin-space/types';
|
|
10
11
|
import { getSpace } from '@dxos/react-client/echo';
|
|
11
12
|
|
|
@@ -21,18 +22,14 @@ export default () =>
|
|
|
21
22
|
filter: (data): data is { subject: ChannelType } =>
|
|
22
23
|
data.subject instanceof ChannelType && !!data.subject.threads[0],
|
|
23
24
|
component: ({ data, role }) => {
|
|
24
|
-
const
|
|
25
|
+
const layout = useLayout();
|
|
25
26
|
const channel = data.subject;
|
|
26
27
|
const thread = channel.threads[0].target!;
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const objectToTheLeft = layoutEntries[currentPosition - 1];
|
|
33
|
-
const context = getSpace(channel)?.db.getObjectById(objectToTheLeft.id);
|
|
34
|
-
return <ThreadContainer role={role} thread={thread} context={context} />;
|
|
35
|
-
}
|
|
28
|
+
const currentPosition = layout.active.findIndex((id) => id === channel.id);
|
|
29
|
+
if (currentPosition > 0) {
|
|
30
|
+
const objectToTheLeft = layout.active[currentPosition - 1];
|
|
31
|
+
const context = getSpace(channel)?.db.getObjectById(objectToTheLeft);
|
|
32
|
+
return <ThreadContainer role={role} thread={thread} context={context} />;
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
return <ThreadContainer role={role} thread={thread} />;
|
|
@@ -51,11 +48,9 @@ export default () =>
|
|
|
51
48
|
}),
|
|
52
49
|
createSurface({
|
|
53
50
|
id: `${THREAD_PLUGIN}/settings`,
|
|
54
|
-
role: '
|
|
55
|
-
filter: (data): data is
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return <ThreadSettings settings={settings} />;
|
|
59
|
-
},
|
|
51
|
+
role: 'article',
|
|
52
|
+
filter: (data): data is { subject: SettingsStore<ThreadSettingsProps> } =>
|
|
53
|
+
data.subject instanceof SettingsStore && data.subject.prefix === THREAD_PLUGIN,
|
|
54
|
+
component: ({ data: { subject } }) => <ThreadSettings settings={subject.value} />,
|
|
60
55
|
}),
|
|
61
56
|
]);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { createIntent, LayoutAction,
|
|
7
|
+
import { createIntent, LayoutAction, useCapability, useCapabilities, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
8
|
import { ThreadCapabilities } from '@dxos/plugin-space';
|
|
9
9
|
import { MessageType, type ThreadType } from '@dxos/plugin-space/types';
|
|
10
10
|
import { create, fullyQualifiedId, makeRef, RefArray } from '@dxos/react-client/echo';
|
|
@@ -62,9 +62,12 @@ export const ThreadComplementary = ({ subject }: { subject: any }) => {
|
|
|
62
62
|
// This may be overloading this intent or highjacking its intended purpose.
|
|
63
63
|
void dispatch(
|
|
64
64
|
createIntent(LayoutAction.ScrollIntoView, {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
part: 'current',
|
|
66
|
+
subject: fullyQualifiedId(subject),
|
|
67
|
+
options: {
|
|
68
|
+
cursor: thread.anchor,
|
|
69
|
+
ref: threadId,
|
|
70
|
+
},
|
|
68
71
|
}),
|
|
69
72
|
);
|
|
70
73
|
}
|
|
@@ -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)];
|