@dxos/plugin-thread 0.6.12-main.89e9959 → 0.6.12-main.ac23639
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/{ThreadArticle-4VU752F4.mjs → ThreadArticle-GBPIH47W.mjs} +3 -3
- package/dist/lib/browser/{ThreadMain-ML3P4XSD.mjs → ThreadMain-PGF7W5EV.mjs} +3 -3
- package/dist/lib/browser/{chunk-7NUYW5IW.mjs → chunk-5G3KL6TC.mjs} +4 -6
- package/dist/lib/browser/chunk-5G3KL6TC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GJRBBPXI.mjs → chunk-JFQZ5W2I.mjs} +2 -2
- package/dist/lib/browser/{chunk-GJRBBPXI.mjs.map → chunk-JFQZ5W2I.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-XF5QKI75.mjs → chunk-O4YRHIZC.mjs} +2 -2
- package/dist/lib/browser/index.mjs +168 -148
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/types.mjs +2 -2
- package/dist/lib/node/{ThreadArticle-ERUHPHVT.cjs → ThreadArticle-GH5UBWFU.cjs} +7 -7
- package/dist/lib/node/{ThreadMain-6DN7FDNB.cjs → ThreadMain-CO6I3DNX.cjs} +7 -7
- package/dist/lib/node/{chunk-PZVUW4W2.cjs → chunk-FDYRG7HE.cjs} +9 -9
- package/dist/lib/node/{chunk-FXD3DYMO.cjs → chunk-FOZUQZF4.cjs} +6 -6
- package/dist/lib/node/{chunk-FXD3DYMO.cjs.map → chunk-FOZUQZF4.cjs.map} +1 -1
- package/dist/lib/node/{chunk-6EVXCSDS.cjs → chunk-JIJ7Z6NO.cjs} +6 -8
- package/dist/lib/node/chunk-JIJ7Z6NO.cjs.map +7 -0
- package/dist/lib/node/index.cjs +196 -178
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.cjs +4 -4
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +3 -3
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{ThreadArticle-NKI5F4W5.mjs → ThreadArticle-ZTYD52TR.mjs} +3 -3
- package/dist/lib/node-esm/{ThreadMain-2A3VQLCW.mjs → ThreadMain-LEHGOF7R.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-Y475KZTX.mjs → chunk-DC5ZA6H5.mjs} +4 -6
- package/dist/lib/node-esm/chunk-DC5ZA6H5.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-A44C4MTQ.mjs → chunk-XOVJ65DG.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-YO46JGAE.mjs → chunk-ZXIPFXSA.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-YO46JGAE.mjs.map → chunk-ZXIPFXSA.mjs.map} +1 -1
- package/dist/lib/node-esm/index.mjs +168 -148
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +1 -1
- package/dist/lib/node-esm/types.mjs +2 -2
- package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
- package/dist/types/src/components/ThreadComplementary.d.ts +2 -2
- package/dist/types/src/components/ThreadComplementary.d.ts.map +1 -1
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/extensions/threads.d.ts +9 -0
- package/dist/types/src/extensions/threads.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +3 -6
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +5 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +28 -28
- package/src/ThreadPlugin.tsx +53 -136
- package/src/components/ThreadComplementary.tsx +4 -4
- package/src/extensions/index.ts +5 -0
- package/src/extensions/threads.ts +117 -0
- package/src/{meta.tsx → meta.ts} +3 -4
- package/src/types.ts +7 -2
- package/dist/lib/browser/chunk-7NUYW5IW.mjs.map +0 -7
- package/dist/lib/node/chunk-6EVXCSDS.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y475KZTX.mjs.map +0 -7
- /package/dist/lib/browser/{ThreadArticle-4VU752F4.mjs.map → ThreadArticle-GBPIH47W.mjs.map} +0 -0
- /package/dist/lib/browser/{ThreadMain-ML3P4XSD.mjs.map → ThreadMain-PGF7W5EV.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-XF5QKI75.mjs.map → chunk-O4YRHIZC.mjs.map} +0 -0
- /package/dist/lib/node/{ThreadArticle-ERUHPHVT.cjs.map → ThreadArticle-GH5UBWFU.cjs.map} +0 -0
- /package/dist/lib/node/{ThreadMain-6DN7FDNB.cjs.map → ThreadMain-CO6I3DNX.cjs.map} +0 -0
- /package/dist/lib/node/{chunk-PZVUW4W2.cjs.map → chunk-FDYRG7HE.cjs.map} +0 -0
- /package/dist/lib/node-esm/{ThreadArticle-NKI5F4W5.mjs.map → ThreadArticle-ZTYD52TR.mjs.map} +0 -0
- /package/dist/lib/node-esm/{ThreadMain-2A3VQLCW.mjs.map → ThreadMain-LEHGOF7R.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-A44C4MTQ.mjs.map → chunk-XOVJ65DG.mjs.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ChatContainer
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-O4YRHIZC.mjs";
|
|
4
|
+
import "./chunk-5G3KL6TC.mjs";
|
|
5
5
|
|
|
6
6
|
// packages/plugins/plugin-thread/src/components/ThreadArticle.tsx
|
|
7
7
|
import React from "react";
|
|
@@ -15,4 +15,4 @@ var ThreadArticle_default = ThreadArticle;
|
|
|
15
15
|
export {
|
|
16
16
|
ThreadArticle_default as default
|
|
17
17
|
};
|
|
18
|
-
//# sourceMappingURL=ThreadArticle-
|
|
18
|
+
//# sourceMappingURL=ThreadArticle-GBPIH47W.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ChatContainer
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-O4YRHIZC.mjs";
|
|
4
|
+
import "./chunk-5G3KL6TC.mjs";
|
|
5
5
|
|
|
6
6
|
// packages/plugins/plugin-thread/src/components/ThreadMain.tsx
|
|
7
7
|
import React from "react";
|
|
@@ -23,4 +23,4 @@ var ThreadMain_default = ThreadMain;
|
|
|
23
23
|
export {
|
|
24
24
|
ThreadMain_default as default
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=ThreadMain-
|
|
26
|
+
//# sourceMappingURL=ThreadMain-PGF7W5EV.mjs.map
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
// packages/plugins/plugin-thread/src/meta.
|
|
2
|
-
import { pluginMeta } from "@dxos/app-framework";
|
|
1
|
+
// packages/plugins/plugin-thread/src/meta.ts
|
|
3
2
|
var THREAD_PLUGIN = "dxos.org/plugin/thread";
|
|
4
3
|
var THREAD_ITEM = `${THREAD_PLUGIN}/item`;
|
|
5
|
-
var meta_default =
|
|
4
|
+
var meta_default = {
|
|
6
5
|
id: THREAD_PLUGIN,
|
|
7
6
|
name: "Threads",
|
|
8
|
-
// TODO(wittjosiah): Update once scope of threads expands.
|
|
9
7
|
description: "Comment threads on documents.",
|
|
10
8
|
icon: "ph--chat--regular"
|
|
11
|
-
}
|
|
9
|
+
};
|
|
12
10
|
|
|
13
11
|
export {
|
|
14
12
|
THREAD_PLUGIN,
|
|
15
13
|
THREAD_ITEM,
|
|
16
14
|
meta_default
|
|
17
15
|
};
|
|
18
|
-
//# sourceMappingURL=chunk-
|
|
16
|
+
//# sourceMappingURL=chunk-5G3KL6TC.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const THREAD_PLUGIN = 'dxos.org/plugin/thread';\nexport const THREAD_ITEM = `${THREAD_PLUGIN}/item`;\n\nexport default {\n id: THREAD_PLUGIN,\n name: 'Threads',\n description: 'Comment threads on documents.',\n icon: 'ph--chat--regular',\n} satisfies PluginMeta;\n"],
|
|
5
|
+
"mappings": ";AAMO,IAAMA,gBAAgB;AACtB,IAAMC,cAAc,GAAGD,aAAAA;AAE9B,IAAA,eAAe;EACbE,IAAIF;EACJG,MAAM;EACNC,aAAa;EACbC,MAAM;AACR;",
|
|
6
|
+
"names": ["THREAD_PLUGIN", "THREAD_ITEM", "id", "name", "description", "icon"]
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
THREAD_PLUGIN
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5G3KL6TC.mjs";
|
|
4
4
|
|
|
5
5
|
// packages/plugins/plugin-thread/src/types.ts
|
|
6
6
|
var THREAD_ACTION = `${THREAD_PLUGIN}/action`;
|
|
@@ -17,4 +17,4 @@ var ThreadAction;
|
|
|
17
17
|
export {
|
|
18
18
|
ThreadAction
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=chunk-
|
|
20
|
+
//# sourceMappingURL=chunk-JFQZ5W2I.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n MetadataRecordsProvides,\n SettingsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport { type SchemaProvides } from '@dxos/plugin-client';\nimport { type MarkdownExtensionProvides } from '@dxos/plugin-markdown';\nimport { type ThreadType } from '@dxos/plugin-space/types';\n\nimport { THREAD_PLUGIN } from './meta';\n\nconst THREAD_ACTION = `${THREAD_PLUGIN}/action`;\nexport enum ThreadAction {\n CREATE = `${THREAD_ACTION}/create`,\n SELECT = `${THREAD_ACTION}/select`,\n DELETE = `${THREAD_ACTION}/delete`,\n ON_MESSAGE_ADD = `${THREAD_ACTION}/on-message-add`,\n DELETE_MESSAGE = `${THREAD_ACTION}/delete-message`,\n TOGGLE_RESOLVED = `${THREAD_ACTION}/toggle-resolved`,\n}\n\n// TODO(Zan): Move this to the plugin-space plugin or another common location
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n MetadataRecordsProvides,\n SettingsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport { type SchemaProvides } from '@dxos/plugin-client';\nimport { type MarkdownExtensionProvides } from '@dxos/plugin-markdown';\nimport { type ThreadType } from '@dxos/plugin-space/types';\n\nimport { THREAD_PLUGIN } from './meta';\n\nconst THREAD_ACTION = `${THREAD_PLUGIN}/action`;\nexport enum ThreadAction {\n CREATE = `${THREAD_ACTION}/create`,\n SELECT = `${THREAD_ACTION}/select`,\n DELETE = `${THREAD_ACTION}/delete`,\n ON_MESSAGE_ADD = `${THREAD_ACTION}/on-message-add`,\n DELETE_MESSAGE = `${THREAD_ACTION}/delete-message`,\n TOGGLE_RESOLVED = `${THREAD_ACTION}/toggle-resolved`,\n}\n\n// TODO(Zan): Move this to the plugin-space plugin or another common location when we implement threads in sheets.\nexport type ThreadProvides<T> = {\n thread: {\n predicate: (obj: any) => obj is T;\n createSort: (obj: T) => (anchorA: string | undefined, anchorB: string | undefined) => number;\n };\n};\n\nexport type ThreadPluginProvides = SurfaceProvides &\n IntentResolverProvides &\n GraphBuilderProvides &\n MetadataRecordsProvides &\n SettingsProvides &\n TranslationsProvides &\n SchemaProvides &\n MarkdownExtensionProvides;\n\nexport type ThreadSettingsProps = { standalone?: boolean };\n\nexport interface ThreadModel {\n root: ThreadType;\n}\n\nexport type ThreadState = {\n /** In-memory draft threads. */\n drafts: Record<string, ThreadType[]>;\n current?: string | undefined;\n};\n"],
|
|
5
5
|
"mappings": ";;;;;AAkBA,IAAMA,gBAAgB,GAAGC,aAAAA;;UACbC,eAAAA;0CACD,GAAGF,aAAAA,SAAsB,IAAA;0CACzB,GAAGA,aAAAA,SAAsB,IAAA;0CACzB,GAAGA,aAAAA,SAAsB,IAAA;kDACjB,GAAGA,aAAAA,iBAA8B,IAAA;kDACjC,GAAGA,aAAAA,iBAA8B,IAAA;mDAChC,GAAGA,aAAAA,kBAA+B,IAAA;GAN1CE,iBAAAA,eAAAA,CAAAA,EAAAA;",
|
|
6
6
|
"names": ["THREAD_ACTION", "THREAD_PLUGIN", "ThreadAction"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
THREAD_ITEM,
|
|
3
3
|
THREAD_PLUGIN
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5G3KL6TC.mjs";
|
|
5
5
|
|
|
6
6
|
// packages/plugins/plugin-thread/src/hooks/useStatus.ts
|
|
7
7
|
import { useEffect, useState } from "react";
|
|
@@ -409,4 +409,4 @@ export {
|
|
|
409
409
|
ChatHeading,
|
|
410
410
|
ChatContainer
|
|
411
411
|
};
|
|
412
|
-
//# sourceMappingURL=chunk-
|
|
412
|
+
//# sourceMappingURL=chunk-O4YRHIZC.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ThreadAction
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JFQZ5W2I.mjs";
|
|
4
4
|
import {
|
|
5
5
|
ChatContainer,
|
|
6
6
|
ChatHeading,
|
|
@@ -10,17 +10,16 @@ import {
|
|
|
10
10
|
useAnalyticsCallback,
|
|
11
11
|
useOnEditAnalytics,
|
|
12
12
|
useStatus
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-O4YRHIZC.mjs";
|
|
14
14
|
import {
|
|
15
15
|
THREAD_ITEM,
|
|
16
16
|
THREAD_PLUGIN,
|
|
17
17
|
meta_default
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-5G3KL6TC.mjs";
|
|
19
19
|
|
|
20
20
|
// packages/plugins/plugin-thread/src/ThreadPlugin.tsx
|
|
21
|
-
import { computed, effect } from "@preact/signals-core";
|
|
22
21
|
import React6 from "react";
|
|
23
|
-
import {
|
|
22
|
+
import { NavigationAction, parseIntentPlugin, parseNavigationPlugin, resolvePlugin, isLayoutParts, parseMetadataResolverPlugin } from "@dxos/app-framework";
|
|
24
23
|
import { getTypename } from "@dxos/echo-schema";
|
|
25
24
|
import { create as create2 } from "@dxos/echo-schema";
|
|
26
25
|
import { LocalStorageStore } from "@dxos/local-storage";
|
|
@@ -29,11 +28,9 @@ import { parseClientPlugin } from "@dxos/plugin-client";
|
|
|
29
28
|
import { createExtension, isActionGroup, toSignal } from "@dxos/plugin-graph";
|
|
30
29
|
import { ObservabilityAction } from "@dxos/plugin-observability/meta";
|
|
31
30
|
import { SpaceAction } from "@dxos/plugin-space";
|
|
32
|
-
import { ThreadType, MessageType as MessageType2, ChannelType } from "@dxos/plugin-space/types";
|
|
33
|
-
import { getSpace as
|
|
34
|
-
import { comments, createExternalCommentSync, listener as listener2 } from "@dxos/react-ui-editor";
|
|
31
|
+
import { ThreadType as ThreadType2, MessageType as MessageType2, ChannelType } from "@dxos/plugin-space/types";
|
|
32
|
+
import { getSpace as getSpace3, fullyQualifiedId as fullyQualifiedId5, loadObjectReferences } from "@dxos/react-client/echo";
|
|
35
33
|
import { translations as threadTranslations } from "@dxos/react-ui-thread";
|
|
36
|
-
import { nonNullable as nonNullable3 } from "@dxos/util";
|
|
37
34
|
|
|
38
35
|
// packages/plugins/plugin-thread/src/components/index.ts
|
|
39
36
|
import React4 from "react";
|
|
@@ -209,9 +206,9 @@ import React3, { useEffect } from "react";
|
|
|
209
206
|
import { fullyQualifiedId as fullyQualifiedId2 } from "@dxos/react-client/echo";
|
|
210
207
|
import { useTranslation as useTranslation3, Trans } from "@dxos/react-ui";
|
|
211
208
|
import { descriptionText, mx as mx2 } from "@dxos/react-ui-theme";
|
|
212
|
-
var CommentsContainer = ({ threads, detached = [], currentId, showResolvedThreads, onThreadAttend, onThreadDelete, onMessageDelete, onThreadToggleResolved, ...props }) => {
|
|
209
|
+
var CommentsContainer = ({ threads: threads2, detached = [], currentId, showResolvedThreads, onThreadAttend, onThreadDelete, onMessageDelete, onThreadToggleResolved, ...props }) => {
|
|
213
210
|
const { t } = useTranslation3(THREAD_PLUGIN);
|
|
214
|
-
const filteredThreads = showResolvedThreads ?
|
|
211
|
+
const filteredThreads = showResolvedThreads ? threads2 : threads2.filter((thread) => !(thread?.status === "resolved"));
|
|
215
212
|
useEffect(() => {
|
|
216
213
|
if (currentId) {
|
|
217
214
|
document.getElementById(currentId)?.scrollIntoView({
|
|
@@ -260,8 +257,8 @@ var CommentsContainer = ({ threads, detached = [], currentId, showResolvedThread
|
|
|
260
257
|
};
|
|
261
258
|
|
|
262
259
|
// packages/plugins/plugin-thread/src/components/index.ts
|
|
263
|
-
var ThreadMain = React4.lazy(() => import("./ThreadMain-
|
|
264
|
-
var ThreadArticle = React4.lazy(() => import("./ThreadArticle-
|
|
260
|
+
var ThreadMain = React4.lazy(() => import("./ThreadMain-PGF7W5EV.mjs"));
|
|
261
|
+
var ThreadArticle = React4.lazy(() => import("./ThreadArticle-GBPIH47W.mjs"));
|
|
265
262
|
|
|
266
263
|
// packages/plugins/plugin-thread/src/components/ThreadComplementary.tsx
|
|
267
264
|
import React5, { useEffect as useEffect2, useMemo as useMemo2 } from "react";
|
|
@@ -271,7 +268,7 @@ import { ScrollArea } from "@dxos/react-ui";
|
|
|
271
268
|
import { useAttended } from "@dxos/react-ui-attention";
|
|
272
269
|
import { nonNullable as nonNullable2 } from "@dxos/util";
|
|
273
270
|
var providesThreadsConfig = (plugin) => "thread" in plugin.provides ? plugin : void 0;
|
|
274
|
-
var ThreadComplementary = ({ role, subject,
|
|
271
|
+
var ThreadComplementary = ({ role, subject, drafts, current, showResolvedThreads }) => {
|
|
275
272
|
const dispatch = useIntentDispatcher();
|
|
276
273
|
const threadsIntegrators = useResolvePlugins(providesThreadsConfig);
|
|
277
274
|
const threadProvides = useMemo2(() => threadsIntegrators.map((p) => p.provides.thread), [
|
|
@@ -285,25 +282,25 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, showResolved
|
|
|
285
282
|
createSort,
|
|
286
283
|
subject
|
|
287
284
|
]);
|
|
288
|
-
const
|
|
289
|
-
return subject.threads.concat(
|
|
285
|
+
const threads2 = useMemo2(() => {
|
|
286
|
+
return subject.threads.concat(drafts ?? []).filter(nonNullable2);
|
|
290
287
|
}, [
|
|
291
288
|
JSON.stringify(subject.threads),
|
|
292
|
-
JSON.stringify(
|
|
289
|
+
JSON.stringify(drafts)
|
|
293
290
|
]);
|
|
294
291
|
const detachedIds = useMemo2(() => {
|
|
295
|
-
return
|
|
292
|
+
return threads2.filter(({ anchor }) => !anchor).map((thread) => fullyQualifiedId3(thread));
|
|
296
293
|
}, [
|
|
297
|
-
|
|
294
|
+
threads2
|
|
298
295
|
]);
|
|
299
296
|
useEffect2(() => {
|
|
300
297
|
if (!sort) {
|
|
301
298
|
return;
|
|
302
299
|
}
|
|
303
|
-
|
|
300
|
+
threads2.sort((a, b) => sort(a?.anchor, b?.anchor));
|
|
304
301
|
}, [
|
|
305
302
|
sort,
|
|
306
|
-
|
|
303
|
+
threads2
|
|
307
304
|
]);
|
|
308
305
|
const attended = useAttended();
|
|
309
306
|
const qualifiedSubjectId = fullyQualifiedId3(subject);
|
|
@@ -313,7 +310,7 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, showResolved
|
|
|
313
310
|
}, /* @__PURE__ */ React5.createElement(ScrollArea.Root, {
|
|
314
311
|
classNames: "row-span-2"
|
|
315
312
|
}, /* @__PURE__ */ React5.createElement(ScrollArea.Viewport, null, /* @__PURE__ */ React5.createElement(CommentsContainer, {
|
|
316
|
-
threads,
|
|
313
|
+
threads: threads2,
|
|
317
314
|
detached: detachedIds,
|
|
318
315
|
currentId: attended.includes(qualifiedSubjectId) ? current : void 0,
|
|
319
316
|
showResolvedThreads,
|
|
@@ -374,6 +371,95 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, showResolved
|
|
|
374
371
|
}), /* @__PURE__ */ React5.createElement(ScrollArea.Scrollbar, null, /* @__PURE__ */ React5.createElement(ScrollArea.Thumb, null)))));
|
|
375
372
|
};
|
|
376
373
|
|
|
374
|
+
// packages/plugins/plugin-thread/src/extensions/threads.ts
|
|
375
|
+
import { EditorView } from "@codemirror/view";
|
|
376
|
+
import { computed, effect } from "@preact/signals-core";
|
|
377
|
+
import { ThreadType } from "@dxos/plugin-space/types";
|
|
378
|
+
import { getSpace as getSpace2, getTextInRange, createDocAccessor, fullyQualifiedId as fullyQualifiedId4 } from "@dxos/react-client/echo";
|
|
379
|
+
import { comments, createExternalCommentSync } from "@dxos/react-ui-editor";
|
|
380
|
+
import { nonNullable as nonNullable3 } from "@dxos/util";
|
|
381
|
+
var getName = (doc, anchor) => {
|
|
382
|
+
if (doc.content) {
|
|
383
|
+
const [start, end] = anchor.split(":");
|
|
384
|
+
return getTextInRange(createDocAccessor(doc.content, [
|
|
385
|
+
"content"
|
|
386
|
+
]), start, end);
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
var threads = (state, doc, dispatch) => {
|
|
390
|
+
const space = doc && getSpace2(doc);
|
|
391
|
+
if (!doc || !space || !dispatch) {
|
|
392
|
+
return [
|
|
393
|
+
comments()
|
|
394
|
+
];
|
|
395
|
+
}
|
|
396
|
+
const threads2 = computed(() => [
|
|
397
|
+
...doc.threads.filter(nonNullable3),
|
|
398
|
+
...state.drafts[fullyQualifiedId4(doc)] ?? []
|
|
399
|
+
].filter((thread) => !(thread?.status === "resolved")));
|
|
400
|
+
return [
|
|
401
|
+
EditorView.updateListener.of((update) => {
|
|
402
|
+
if (update.docChanged) {
|
|
403
|
+
doc.threads.forEach((thread) => {
|
|
404
|
+
if (thread?.anchor) {
|
|
405
|
+
const name = getName(doc, thread.anchor);
|
|
406
|
+
if (name && name !== thread.name) {
|
|
407
|
+
thread.name = name;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
}),
|
|
413
|
+
createExternalCommentSync(fullyQualifiedId4(doc), (sink) => effect(() => sink()), () => threads2.value.filter((thread) => thread?.anchor).map((thread) => ({
|
|
414
|
+
id: fullyQualifiedId4(thread),
|
|
415
|
+
cursor: thread.anchor
|
|
416
|
+
}))),
|
|
417
|
+
comments({
|
|
418
|
+
id: fullyQualifiedId4(doc),
|
|
419
|
+
onCreate: ({ cursor }) => {
|
|
420
|
+
const name = getName(doc, cursor);
|
|
421
|
+
void dispatch({
|
|
422
|
+
action: ThreadAction.CREATE,
|
|
423
|
+
data: {
|
|
424
|
+
cursor,
|
|
425
|
+
name,
|
|
426
|
+
subject: doc
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
},
|
|
430
|
+
onDelete: ({ id }) => {
|
|
431
|
+
const draft = state.drafts[fullyQualifiedId4(doc)];
|
|
432
|
+
if (draft) {
|
|
433
|
+
const index = draft.findIndex((thread2) => fullyQualifiedId4(thread2) === id);
|
|
434
|
+
if (index !== -1) {
|
|
435
|
+
draft.splice(index, 1);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
const thread = doc.threads.find((thread2) => thread2?.id === id);
|
|
439
|
+
if (thread) {
|
|
440
|
+
thread.anchor = void 0;
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
onUpdate: ({ id, cursor }) => {
|
|
444
|
+
const thread = state.drafts[fullyQualifiedId4(doc)]?.find((thread2) => fullyQualifiedId4(thread2) === id) ?? doc.threads.find((thread2) => thread2?.id === id);
|
|
445
|
+
if (thread instanceof ThreadType && thread.anchor) {
|
|
446
|
+
thread.name = getName(doc, thread.anchor);
|
|
447
|
+
thread.anchor = cursor;
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
onSelect: ({ selection: { current, closest } }) => {
|
|
451
|
+
void dispatch({
|
|
452
|
+
action: ThreadAction.SELECT,
|
|
453
|
+
data: {
|
|
454
|
+
current: current ?? closest,
|
|
455
|
+
skipOpen: true
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
})
|
|
460
|
+
];
|
|
461
|
+
};
|
|
462
|
+
|
|
377
463
|
// packages/plugins/plugin-thread/src/translations.ts
|
|
378
464
|
var translations_default = [
|
|
379
465
|
{
|
|
@@ -418,7 +504,7 @@ var initialViewState = {
|
|
|
418
504
|
var ThreadPlugin = () => {
|
|
419
505
|
const settings = new LocalStorageStore(THREAD_PLUGIN);
|
|
420
506
|
const state = create2({
|
|
421
|
-
|
|
507
|
+
drafts: {}
|
|
422
508
|
});
|
|
423
509
|
const viewStore = create2({});
|
|
424
510
|
const getViewState = (subjectId) => {
|
|
@@ -462,7 +548,7 @@ var ThreadPlugin = () => {
|
|
|
462
548
|
// TODO(wittjosiah): Move out of metadata.
|
|
463
549
|
loadReferences: (channel) => loadObjectReferences(channel, (channel2) => channel2.threads)
|
|
464
550
|
},
|
|
465
|
-
[
|
|
551
|
+
[ThreadType2.typename]: {
|
|
466
552
|
// TODO(wittjosiah): Move out of metadata.
|
|
467
553
|
loadReferences: (thread) => loadObjectReferences(thread, (thread2) => thread2.messages)
|
|
468
554
|
},
|
|
@@ -498,7 +584,7 @@ var ThreadPlugin = () => {
|
|
|
498
584
|
echo: {
|
|
499
585
|
schema: [
|
|
500
586
|
ChannelType,
|
|
501
|
-
|
|
587
|
+
ThreadType2,
|
|
502
588
|
MessageType2
|
|
503
589
|
]
|
|
504
590
|
},
|
|
@@ -654,8 +740,7 @@ var ThreadPlugin = () => {
|
|
|
654
740
|
settings: settings.values
|
|
655
741
|
}) : null;
|
|
656
742
|
}
|
|
657
|
-
case "article":
|
|
658
|
-
case "complementary": {
|
|
743
|
+
case "article": {
|
|
659
744
|
const location = navigationPlugin?.provides.location;
|
|
660
745
|
if (data.object instanceof ChannelType && data.object.threads[0]) {
|
|
661
746
|
const channel = data.object;
|
|
@@ -664,7 +749,7 @@ var ThreadPlugin = () => {
|
|
|
664
749
|
const currentPosition = layoutEntries.findIndex((entry) => channel.id === entry.id);
|
|
665
750
|
if (currentPosition > 0) {
|
|
666
751
|
const objectToTheLeft = layoutEntries[currentPosition - 1];
|
|
667
|
-
const context =
|
|
752
|
+
const context = getSpace3(data.object)?.db.getObjectById(objectToTheLeft.id);
|
|
668
753
|
return /* @__PURE__ */ React6.createElement(ThreadArticle, {
|
|
669
754
|
thread: data.object.threads[0],
|
|
670
755
|
context
|
|
@@ -675,23 +760,27 @@ var ThreadPlugin = () => {
|
|
|
675
760
|
thread: data.object.threads[0]
|
|
676
761
|
});
|
|
677
762
|
}
|
|
678
|
-
if (data.subject instanceof
|
|
763
|
+
if (data.subject instanceof ThreadType2) {
|
|
679
764
|
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(ChatHeading, {
|
|
680
765
|
attendableId: data.subject.id
|
|
681
766
|
}), /* @__PURE__ */ React6.createElement(ChatContainer, {
|
|
682
767
|
thread: data.subject
|
|
683
768
|
}));
|
|
684
769
|
}
|
|
770
|
+
break;
|
|
771
|
+
}
|
|
772
|
+
case "complementary--comments": {
|
|
685
773
|
if (data.subject && typeof data.subject === "object" && "threads" in data.subject && Array.isArray(data.subject.threads)) {
|
|
686
|
-
const { showResolvedThreads } = getViewState(
|
|
774
|
+
const { showResolvedThreads } = getViewState(fullyQualifiedId5(data.subject));
|
|
687
775
|
return /* @__PURE__ */ React6.createElement(ThreadComplementary, {
|
|
688
776
|
role,
|
|
689
777
|
subject: data.subject,
|
|
690
|
-
|
|
778
|
+
drafts: state.drafts[fullyQualifiedId5(data.subject)],
|
|
691
779
|
current: state.current,
|
|
692
780
|
showResolvedThreads
|
|
693
781
|
});
|
|
694
782
|
}
|
|
783
|
+
break;
|
|
695
784
|
}
|
|
696
785
|
}
|
|
697
786
|
return null;
|
|
@@ -706,28 +795,28 @@ var ThreadPlugin = () => {
|
|
|
706
795
|
if (subject?.threads === void 0) {
|
|
707
796
|
try {
|
|
708
797
|
subject.threads = [];
|
|
709
|
-
} catch (
|
|
798
|
+
} catch (err) {
|
|
710
799
|
log.error("Subject does not support threads array", subject?.typename, {
|
|
711
800
|
F: __dxlog_file,
|
|
712
|
-
L:
|
|
801
|
+
L: 322,
|
|
713
802
|
S: void 0,
|
|
714
803
|
C: (f, a) => f(...a)
|
|
715
804
|
});
|
|
716
805
|
return;
|
|
717
806
|
}
|
|
718
807
|
}
|
|
719
|
-
const subjectId =
|
|
720
|
-
const thread = create2(
|
|
808
|
+
const subjectId = fullyQualifiedId5(subject);
|
|
809
|
+
const thread = create2(ThreadType2, {
|
|
721
810
|
name,
|
|
722
811
|
anchor: cursor,
|
|
723
812
|
messages: [],
|
|
724
813
|
status: "staged"
|
|
725
814
|
});
|
|
726
|
-
const
|
|
727
|
-
if (
|
|
728
|
-
|
|
815
|
+
const draft = state.drafts[subjectId];
|
|
816
|
+
if (draft) {
|
|
817
|
+
draft.push(thread);
|
|
729
818
|
} else {
|
|
730
|
-
state.
|
|
819
|
+
state.drafts[subjectId] = [
|
|
731
820
|
thread
|
|
732
821
|
];
|
|
733
822
|
}
|
|
@@ -738,15 +827,17 @@ var ThreadPlugin = () => {
|
|
|
738
827
|
{
|
|
739
828
|
action: ThreadAction.SELECT,
|
|
740
829
|
data: {
|
|
741
|
-
current:
|
|
830
|
+
current: fullyQualifiedId5(thread)
|
|
742
831
|
}
|
|
743
|
-
}
|
|
832
|
+
}
|
|
833
|
+
],
|
|
834
|
+
[
|
|
744
835
|
{
|
|
745
|
-
action:
|
|
836
|
+
action: NavigationAction.OPEN,
|
|
746
837
|
data: {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
838
|
+
activeParts: {
|
|
839
|
+
complementary: "comments"
|
|
840
|
+
}
|
|
750
841
|
}
|
|
751
842
|
}
|
|
752
843
|
]
|
|
@@ -756,7 +847,7 @@ var ThreadPlugin = () => {
|
|
|
756
847
|
return {
|
|
757
848
|
data: create2(ChannelType, {
|
|
758
849
|
threads: [
|
|
759
|
-
create2(
|
|
850
|
+
create2(ThreadType2, {
|
|
760
851
|
messages: []
|
|
761
852
|
})
|
|
762
853
|
]
|
|
@@ -767,12 +858,24 @@ var ThreadPlugin = () => {
|
|
|
767
858
|
case ThreadAction.SELECT: {
|
|
768
859
|
state.current = intent.data?.current;
|
|
769
860
|
return {
|
|
770
|
-
data: true
|
|
861
|
+
data: true,
|
|
862
|
+
intents: !intent.data?.skipOpen ? [
|
|
863
|
+
[
|
|
864
|
+
{
|
|
865
|
+
action: NavigationAction.OPEN,
|
|
866
|
+
data: {
|
|
867
|
+
activeParts: {
|
|
868
|
+
complementary: "comments"
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
]
|
|
873
|
+
] : []
|
|
771
874
|
};
|
|
772
875
|
}
|
|
773
876
|
case ThreadAction.TOGGLE_RESOLVED: {
|
|
774
877
|
const { thread } = intent.data ?? {};
|
|
775
|
-
if (!(thread instanceof
|
|
878
|
+
if (!(thread instanceof ThreadType2)) {
|
|
776
879
|
return;
|
|
777
880
|
}
|
|
778
881
|
if (thread.status === "active" || thread.status === void 0) {
|
|
@@ -780,9 +883,10 @@ var ThreadPlugin = () => {
|
|
|
780
883
|
} else if (thread.status === "resolved") {
|
|
781
884
|
thread.status = "active";
|
|
782
885
|
}
|
|
783
|
-
const space =
|
|
886
|
+
const space = getSpace3(thread);
|
|
784
887
|
const spaceId = space?.id;
|
|
785
888
|
return {
|
|
889
|
+
data: true,
|
|
786
890
|
intents: [
|
|
787
891
|
[
|
|
788
892
|
{
|
|
@@ -801,21 +905,21 @@ var ThreadPlugin = () => {
|
|
|
801
905
|
}
|
|
802
906
|
case ThreadAction.DELETE: {
|
|
803
907
|
const { subject, thread } = intent.data ?? {};
|
|
804
|
-
if (!(thread instanceof
|
|
908
|
+
if (!(thread instanceof ThreadType2) || !(subject && typeof subject === "object" && "threads" in subject)) {
|
|
805
909
|
return;
|
|
806
910
|
}
|
|
807
|
-
const subjectId =
|
|
808
|
-
const
|
|
809
|
-
if (
|
|
810
|
-
const index =
|
|
911
|
+
const subjectId = fullyQualifiedId5(subject);
|
|
912
|
+
const draft = state.drafts[subjectId];
|
|
913
|
+
if (draft) {
|
|
914
|
+
const index = draft.findIndex((t) => t.id === thread.id);
|
|
811
915
|
if (index !== -1) {
|
|
812
|
-
|
|
916
|
+
draft.splice(index, 1);
|
|
813
917
|
return {
|
|
814
918
|
data: true
|
|
815
919
|
};
|
|
816
920
|
}
|
|
817
921
|
}
|
|
818
|
-
const space =
|
|
922
|
+
const space = getSpace3(thread);
|
|
819
923
|
if (!space || !subject.threads) {
|
|
820
924
|
return;
|
|
821
925
|
}
|
|
@@ -873,22 +977,22 @@ var ThreadPlugin = () => {
|
|
|
873
977
|
}
|
|
874
978
|
case ThreadAction.ON_MESSAGE_ADD: {
|
|
875
979
|
const { thread, subject } = intent.data ?? {};
|
|
876
|
-
if (!(thread instanceof
|
|
980
|
+
if (!(thread instanceof ThreadType2) || !(subject && typeof subject === "object" && "threads" in subject && Array.isArray(subject.threads))) {
|
|
877
981
|
return;
|
|
878
982
|
}
|
|
879
|
-
const subjectId =
|
|
880
|
-
const space =
|
|
983
|
+
const subjectId = fullyQualifiedId5(subject);
|
|
984
|
+
const space = getSpace3(subject);
|
|
881
985
|
const intents = [];
|
|
882
986
|
const analyticsProperties = {
|
|
883
987
|
threadId: thread.id,
|
|
884
988
|
spaceId: space?.id
|
|
885
989
|
};
|
|
886
|
-
if (state.
|
|
990
|
+
if (state.drafts[subjectId]?.find((t) => t === thread)) {
|
|
887
991
|
thread.status = "active";
|
|
888
992
|
subject.threads ? subject.threads.push(thread) : subject.threads = [
|
|
889
993
|
thread
|
|
890
994
|
];
|
|
891
|
-
state.
|
|
995
|
+
state.drafts[subjectId] = state.drafts[subjectId]?.filter(({ id }) => id !== thread.id);
|
|
892
996
|
intents.push({
|
|
893
997
|
action: ObservabilityAction.SEND_EVENT,
|
|
894
998
|
data: {
|
|
@@ -916,8 +1020,8 @@ var ThreadPlugin = () => {
|
|
|
916
1020
|
}
|
|
917
1021
|
case ThreadAction.DELETE_MESSAGE: {
|
|
918
1022
|
const { subject, thread, messageId } = intent.data ?? {};
|
|
919
|
-
const space =
|
|
920
|
-
if (!(thread instanceof
|
|
1023
|
+
const space = getSpace3(subject);
|
|
1024
|
+
if (!(thread instanceof ThreadType2) || !(subject && typeof subject === "object" && "threads" in subject)) {
|
|
921
1025
|
return;
|
|
922
1026
|
}
|
|
923
1027
|
if (!intent.undo) {
|
|
@@ -996,92 +1100,8 @@ var ThreadPlugin = () => {
|
|
|
996
1100
|
}
|
|
997
1101
|
},
|
|
998
1102
|
markdown: {
|
|
999
|
-
// TODO(burdon): Factor out extension factory into separate file (for simplicity).
|
|
1000
1103
|
extensions: ({ document: doc }) => {
|
|
1001
|
-
|
|
1002
|
-
if (!doc || !space) {
|
|
1003
|
-
return [
|
|
1004
|
-
comments()
|
|
1005
|
-
];
|
|
1006
|
-
}
|
|
1007
|
-
const threads = computed(() => [
|
|
1008
|
-
...doc.threads.filter(nonNullable3),
|
|
1009
|
-
...state.staging[fullyQualifiedId4(doc)] ?? []
|
|
1010
|
-
].filter((thread) => !(thread?.status === "resolved")));
|
|
1011
|
-
return [
|
|
1012
|
-
listener2({
|
|
1013
|
-
onChange: () => {
|
|
1014
|
-
doc.threads.forEach((thread) => {
|
|
1015
|
-
if (thread?.anchor) {
|
|
1016
|
-
const [start, end] = thread.anchor.split(":");
|
|
1017
|
-
const name = doc.content && getTextInRange(createDocAccessor(doc.content, [
|
|
1018
|
-
"content"
|
|
1019
|
-
]), start, end);
|
|
1020
|
-
if (name && name !== thread.name) {
|
|
1021
|
-
thread.name = name;
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
});
|
|
1025
|
-
}
|
|
1026
|
-
}),
|
|
1027
|
-
createExternalCommentSync(fullyQualifiedId4(doc), (sink) => effect(() => sink()), () => threads.value.filter((thread) => thread?.anchor).map((thread) => ({
|
|
1028
|
-
id: fullyQualifiedId4(thread),
|
|
1029
|
-
cursor: thread.anchor
|
|
1030
|
-
}))),
|
|
1031
|
-
comments({
|
|
1032
|
-
id: fullyQualifiedId4(doc),
|
|
1033
|
-
onCreate: ({ cursor }) => {
|
|
1034
|
-
const [start, end] = cursor.split(":");
|
|
1035
|
-
const name = doc.content && getTextInRange(createDocAccessor(doc.content, [
|
|
1036
|
-
"content"
|
|
1037
|
-
]), start, end);
|
|
1038
|
-
void intentPlugin?.provides.intent.dispatch({
|
|
1039
|
-
action: ThreadAction.CREATE,
|
|
1040
|
-
data: {
|
|
1041
|
-
cursor,
|
|
1042
|
-
name,
|
|
1043
|
-
subject: doc
|
|
1044
|
-
}
|
|
1045
|
-
});
|
|
1046
|
-
},
|
|
1047
|
-
onDelete: ({ id }) => {
|
|
1048
|
-
const stagingArea = state.staging[fullyQualifiedId4(doc)];
|
|
1049
|
-
if (stagingArea) {
|
|
1050
|
-
const index = stagingArea.findIndex((thread2) => fullyQualifiedId4(thread2) === id);
|
|
1051
|
-
if (index !== -1) {
|
|
1052
|
-
stagingArea.splice(index, 1);
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
const thread = doc.threads.find((thread2) => thread2?.id === id);
|
|
1056
|
-
if (thread) {
|
|
1057
|
-
thread.anchor = void 0;
|
|
1058
|
-
}
|
|
1059
|
-
},
|
|
1060
|
-
onUpdate: ({ id, cursor }) => {
|
|
1061
|
-
const thread = state.staging[fullyQualifiedId4(doc)]?.find((thread2) => fullyQualifiedId4(thread2) === id) ?? doc.threads.find((thread2) => thread2?.id === id);
|
|
1062
|
-
if (thread instanceof ThreadType && thread.anchor) {
|
|
1063
|
-
const [start, end] = thread.anchor.split(":");
|
|
1064
|
-
thread.name = doc.content && getTextInRange(createDocAccessor(doc.content, [
|
|
1065
|
-
"content"
|
|
1066
|
-
]), start, end);
|
|
1067
|
-
thread.anchor = cursor;
|
|
1068
|
-
}
|
|
1069
|
-
},
|
|
1070
|
-
onSelect: ({ selection: { current, closest } }) => {
|
|
1071
|
-
const dispatch = intentPlugin?.provides.intent.dispatch;
|
|
1072
|
-
if (dispatch) {
|
|
1073
|
-
void dispatch([
|
|
1074
|
-
{
|
|
1075
|
-
action: ThreadAction.SELECT,
|
|
1076
|
-
data: {
|
|
1077
|
-
current: current ?? closest
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
]);
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
})
|
|
1084
|
-
];
|
|
1104
|
+
return threads(state, doc, intentPlugin?.provides.intent.dispatch);
|
|
1085
1105
|
}
|
|
1086
1106
|
}
|
|
1087
1107
|
}
|