@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.
Files changed (68) hide show
  1. package/dist/lib/browser/{ThreadArticle-4VU752F4.mjs → ThreadArticle-GBPIH47W.mjs} +3 -3
  2. package/dist/lib/browser/{ThreadMain-ML3P4XSD.mjs → ThreadMain-PGF7W5EV.mjs} +3 -3
  3. package/dist/lib/browser/{chunk-7NUYW5IW.mjs → chunk-5G3KL6TC.mjs} +4 -6
  4. package/dist/lib/browser/chunk-5G3KL6TC.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-GJRBBPXI.mjs → chunk-JFQZ5W2I.mjs} +2 -2
  6. package/dist/lib/browser/{chunk-GJRBBPXI.mjs.map → chunk-JFQZ5W2I.mjs.map} +1 -1
  7. package/dist/lib/browser/{chunk-XF5QKI75.mjs → chunk-O4YRHIZC.mjs} +2 -2
  8. package/dist/lib/browser/index.mjs +168 -148
  9. package/dist/lib/browser/index.mjs.map +4 -4
  10. package/dist/lib/browser/meta.json +1 -1
  11. package/dist/lib/browser/meta.mjs +1 -1
  12. package/dist/lib/browser/types.mjs +2 -2
  13. package/dist/lib/node/{ThreadArticle-ERUHPHVT.cjs → ThreadArticle-GH5UBWFU.cjs} +7 -7
  14. package/dist/lib/node/{ThreadMain-6DN7FDNB.cjs → ThreadMain-CO6I3DNX.cjs} +7 -7
  15. package/dist/lib/node/{chunk-PZVUW4W2.cjs → chunk-FDYRG7HE.cjs} +9 -9
  16. package/dist/lib/node/{chunk-FXD3DYMO.cjs → chunk-FOZUQZF4.cjs} +6 -6
  17. package/dist/lib/node/{chunk-FXD3DYMO.cjs.map → chunk-FOZUQZF4.cjs.map} +1 -1
  18. package/dist/lib/node/{chunk-6EVXCSDS.cjs → chunk-JIJ7Z6NO.cjs} +6 -8
  19. package/dist/lib/node/chunk-JIJ7Z6NO.cjs.map +7 -0
  20. package/dist/lib/node/index.cjs +196 -178
  21. package/dist/lib/node/index.cjs.map +4 -4
  22. package/dist/lib/node/meta.cjs +4 -4
  23. package/dist/lib/node/meta.cjs.map +1 -1
  24. package/dist/lib/node/meta.json +1 -1
  25. package/dist/lib/node/types.cjs +3 -3
  26. package/dist/lib/node/types.cjs.map +1 -1
  27. package/dist/lib/node-esm/{ThreadArticle-NKI5F4W5.mjs → ThreadArticle-ZTYD52TR.mjs} +3 -3
  28. package/dist/lib/node-esm/{ThreadMain-2A3VQLCW.mjs → ThreadMain-LEHGOF7R.mjs} +3 -3
  29. package/dist/lib/node-esm/{chunk-Y475KZTX.mjs → chunk-DC5ZA6H5.mjs} +4 -6
  30. package/dist/lib/node-esm/chunk-DC5ZA6H5.mjs.map +7 -0
  31. package/dist/lib/node-esm/{chunk-A44C4MTQ.mjs → chunk-XOVJ65DG.mjs} +2 -2
  32. package/dist/lib/node-esm/{chunk-YO46JGAE.mjs → chunk-ZXIPFXSA.mjs} +2 -2
  33. package/dist/lib/node-esm/{chunk-YO46JGAE.mjs.map → chunk-ZXIPFXSA.mjs.map} +1 -1
  34. package/dist/lib/node-esm/index.mjs +168 -148
  35. package/dist/lib/node-esm/index.mjs.map +4 -4
  36. package/dist/lib/node-esm/meta.json +1 -1
  37. package/dist/lib/node-esm/meta.mjs +1 -1
  38. package/dist/lib/node-esm/types.mjs +2 -2
  39. package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
  40. package/dist/types/src/components/ThreadComplementary.d.ts +2 -2
  41. package/dist/types/src/components/ThreadComplementary.d.ts.map +1 -1
  42. package/dist/types/src/extensions/index.d.ts +2 -0
  43. package/dist/types/src/extensions/index.d.ts.map +1 -0
  44. package/dist/types/src/extensions/threads.d.ts +9 -0
  45. package/dist/types/src/extensions/threads.d.ts.map +1 -0
  46. package/dist/types/src/meta.d.ts +3 -6
  47. package/dist/types/src/meta.d.ts.map +1 -1
  48. package/dist/types/src/types.d.ts +5 -0
  49. package/dist/types/src/types.d.ts.map +1 -1
  50. package/package.json +28 -28
  51. package/src/ThreadPlugin.tsx +53 -136
  52. package/src/components/ThreadComplementary.tsx +4 -4
  53. package/src/extensions/index.ts +5 -0
  54. package/src/extensions/threads.ts +117 -0
  55. package/src/{meta.tsx → meta.ts} +3 -4
  56. package/src/types.ts +7 -2
  57. package/dist/lib/browser/chunk-7NUYW5IW.mjs.map +0 -7
  58. package/dist/lib/node/chunk-6EVXCSDS.cjs.map +0 -7
  59. package/dist/lib/node-esm/chunk-Y475KZTX.mjs.map +0 -7
  60. /package/dist/lib/browser/{ThreadArticle-4VU752F4.mjs.map → ThreadArticle-GBPIH47W.mjs.map} +0 -0
  61. /package/dist/lib/browser/{ThreadMain-ML3P4XSD.mjs.map → ThreadMain-PGF7W5EV.mjs.map} +0 -0
  62. /package/dist/lib/browser/{chunk-XF5QKI75.mjs.map → chunk-O4YRHIZC.mjs.map} +0 -0
  63. /package/dist/lib/node/{ThreadArticle-ERUHPHVT.cjs.map → ThreadArticle-GH5UBWFU.cjs.map} +0 -0
  64. /package/dist/lib/node/{ThreadMain-6DN7FDNB.cjs.map → ThreadMain-CO6I3DNX.cjs.map} +0 -0
  65. /package/dist/lib/node/{chunk-PZVUW4W2.cjs.map → chunk-FDYRG7HE.cjs.map} +0 -0
  66. /package/dist/lib/node-esm/{ThreadArticle-NKI5F4W5.mjs.map → ThreadArticle-ZTYD52TR.mjs.map} +0 -0
  67. /package/dist/lib/node-esm/{ThreadMain-2A3VQLCW.mjs.map → ThreadMain-LEHGOF7R.mjs.map} +0 -0
  68. /package/dist/lib/node-esm/{chunk-A44C4MTQ.mjs.map → chunk-XOVJ65DG.mjs.map} +0 -0
@@ -28,18 +28,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var node_exports = {};
30
30
  __export(node_exports, {
31
- ThreadAction: () => import_chunk_FXD3DYMO.ThreadAction,
31
+ ThreadAction: () => import_chunk_FOZUQZF4.ThreadAction,
32
32
  ThreadPlugin: () => ThreadPlugin,
33
33
  default: () => src_default,
34
- useAnalyticsCallback: () => import_chunk_PZVUW4W2.useAnalyticsCallback,
35
- useOnEditAnalytics: () => import_chunk_PZVUW4W2.useOnEditAnalytics,
36
- useStatus: () => import_chunk_PZVUW4W2.useStatus
34
+ useAnalyticsCallback: () => import_chunk_FDYRG7HE.useAnalyticsCallback,
35
+ useOnEditAnalytics: () => import_chunk_FDYRG7HE.useOnEditAnalytics,
36
+ useStatus: () => import_chunk_FDYRG7HE.useStatus
37
37
  });
38
38
  module.exports = __toCommonJS(node_exports);
39
- var import_chunk_FXD3DYMO = require("./chunk-FXD3DYMO.cjs");
40
- var import_chunk_PZVUW4W2 = require("./chunk-PZVUW4W2.cjs");
41
- var import_chunk_6EVXCSDS = require("./chunk-6EVXCSDS.cjs");
42
- var import_signals_core = require("@preact/signals-core");
39
+ var import_chunk_FOZUQZF4 = require("./chunk-FOZUQZF4.cjs");
40
+ var import_chunk_FDYRG7HE = require("./chunk-FDYRG7HE.cjs");
41
+ var import_chunk_JIJ7Z6NO = require("./chunk-JIJ7Z6NO.cjs");
43
42
  var import_react = __toESM(require("react"));
44
43
  var import_app_framework = require("@dxos/app-framework");
45
44
  var import_echo_schema = require("@dxos/echo-schema");
@@ -52,9 +51,7 @@ var import_meta = require("@dxos/plugin-observability/meta");
52
51
  var import_plugin_space = require("@dxos/plugin-space");
53
52
  var import_types = require("@dxos/plugin-space/types");
54
53
  var import_echo = require("@dxos/react-client/echo");
55
- var import_react_ui_editor = require("@dxos/react-ui-editor");
56
54
  var import_react_ui_thread = require("@dxos/react-ui-thread");
57
- var import_util = require("@dxos/util");
58
55
  var import_react2 = __toESM(require("react"));
59
56
  var import_react3 = __toESM(require("react"));
60
57
  var import_plugin_settings = require("@dxos/plugin-settings");
@@ -66,10 +63,10 @@ var import_types2 = require("@dxos/plugin-space/types");
66
63
  var import_echo2 = require("@dxos/react-client/echo");
67
64
  var import_halo = require("@dxos/react-client/halo");
68
65
  var import_react_ui2 = require("@dxos/react-ui");
69
- var import_react_ui_editor2 = require("@dxos/react-ui-editor");
66
+ var import_react_ui_editor = require("@dxos/react-ui-editor");
70
67
  var import_react_ui_theme = require("@dxos/react-ui-theme");
71
68
  var import_react_ui_thread2 = require("@dxos/react-ui-thread");
72
- var import_util2 = require("@dxos/util");
69
+ var import_util = require("@dxos/util");
73
70
  var import_react6 = require("@phosphor-icons/react");
74
71
  var import_react7 = __toESM(require("react"));
75
72
  var import_echo3 = require("@dxos/react-client/echo");
@@ -80,9 +77,15 @@ var import_app_framework2 = require("@dxos/app-framework");
80
77
  var import_echo4 = require("@dxos/react-client/echo");
81
78
  var import_react_ui4 = require("@dxos/react-ui");
82
79
  var import_react_ui_attention = require("@dxos/react-ui-attention");
80
+ var import_util2 = require("@dxos/util");
81
+ var import_view = require("@codemirror/view");
82
+ var import_signals_core = require("@preact/signals-core");
83
+ var import_types3 = require("@dxos/plugin-space/types");
84
+ var import_echo5 = require("@dxos/react-client/echo");
85
+ var import_react_ui_editor2 = require("@dxos/react-ui-editor");
83
86
  var import_util3 = require("@dxos/util");
84
87
  var ThreadSettings = ({ settings }) => {
85
- const { t } = (0, import_react_ui.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
88
+ const { t } = (0, import_react_ui.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
86
89
  return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(import_plugin_settings.SettingsValue, {
87
90
  label: t("settings standalone label")
88
91
  }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui.Input.Switch, {
@@ -92,7 +95,7 @@ var ThreadSettings = ({ settings }) => {
92
95
  };
93
96
  var sizeClass = (0, import_react_ui_theme.getSize)(4);
94
97
  var ToggleResolvedButton = ({ isResolved, onResolve }) => {
95
- const { t } = (0, import_react_ui2.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
98
+ const { t } = (0, import_react_ui2.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
96
99
  const label = t(isResolved ? "mark as unresolved label" : "mark as resolved label");
97
100
  return /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
98
101
  asChild: true
@@ -116,7 +119,7 @@ var ToggleResolvedButton = ({ isResolved, onResolve }) => {
116
119
  }, label, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Arrow, null))));
117
120
  };
118
121
  var DeleteThreadButton = ({ onDelete }) => {
119
- const { t } = (0, import_react_ui2.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
122
+ const { t } = (0, import_react_ui2.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
120
123
  const label = t("delete thread label");
121
124
  return /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
122
125
  asChild: true
@@ -140,25 +143,25 @@ var CommentContainer = ({ thread, detached, context, current, onAttend, onThread
140
143
  const identity = (0, import_halo.useIdentity)();
141
144
  const space = (0, import_echo2.getSpace)(thread);
142
145
  const members = (0, import_echo2.useMembers)(space?.key);
143
- const activity = (0, import_chunk_PZVUW4W2.useStatus)(space, (0, import_echo2.fullyQualifiedId)(thread));
144
- const { t } = (0, import_react_ui2.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
146
+ const activity = (0, import_chunk_FDYRG7HE.useStatus)(space, (0, import_echo2.fullyQualifiedId)(thread));
147
+ const { t } = (0, import_react_ui2.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
145
148
  const threadScrollRef = (0, import_react5.useRef)(null);
146
149
  const { themeMode } = (0, import_react_ui2.useThemeContext)();
147
- const textboxMetadata = (0, import_chunk_PZVUW4W2.getMessageMetadata)((0, import_echo2.fullyQualifiedId)(thread), identity);
150
+ const textboxMetadata = (0, import_chunk_FDYRG7HE.getMessageMetadata)((0, import_echo2.fullyQualifiedId)(thread), identity);
148
151
  const [_count, _setCount] = (0, import_react5.useState)(0);
149
152
  const rerenderEditor = () => _setCount((count) => count + 1);
150
153
  const messageRef = (0, import_react5.useRef)("");
151
154
  const extensions = (0, import_react5.useMemo)(() => [
152
- (0, import_react_ui_editor2.createBasicExtensions)({
155
+ (0, import_react_ui_editor.createBasicExtensions)({
153
156
  placeholder: t("message placeholder")
154
157
  }),
155
- (0, import_react_ui_editor2.createThemeExtensions)({
158
+ (0, import_react_ui_editor.createThemeExtensions)({
156
159
  themeMode
157
160
  }),
158
- (0, import_react_ui_editor2.listener)({
161
+ (0, import_react_ui_editor.listener)({
159
162
  onChange: (text) => messageRef.current = text
160
163
  }),
161
- import_chunk_PZVUW4W2.command
164
+ import_chunk_FDYRG7HE.command
162
165
  ], [
163
166
  _count
164
167
  ]);
@@ -211,7 +214,7 @@ var CommentContainer = ({ thread, detached, context, current, onAttend, onThread
211
214
  onResolve
212
215
  }), onThreadDelete && /* @__PURE__ */ import_react5.default.createElement(DeleteThreadButton, {
213
216
  onDelete: onThreadDelete
214
- }))), thread.messages.filter(import_util2.nonNullable).map((message) => /* @__PURE__ */ import_react5.default.createElement(import_chunk_PZVUW4W2.MessageContainer, {
217
+ }))), thread.messages.filter(import_util.nonNullable).map((message) => /* @__PURE__ */ import_react5.default.createElement(import_chunk_FDYRG7HE.MessageContainer, {
215
218
  key: message.id,
216
219
  message,
217
220
  members,
@@ -228,9 +231,9 @@ var CommentContainer = ({ thread, detached, context, current, onAttend, onThread
228
231
  ref: threadScrollRef
229
232
  }));
230
233
  };
231
- var CommentsContainer = ({ threads, detached = [], currentId, showResolvedThreads, onThreadAttend, onThreadDelete, onMessageDelete, onThreadToggleResolved, ...props }) => {
232
- const { t } = (0, import_react_ui3.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
233
- const filteredThreads = showResolvedThreads ? threads : threads.filter((thread) => !(thread?.status === "resolved"));
234
+ var CommentsContainer = ({ threads: threads2, detached = [], currentId, showResolvedThreads, onThreadAttend, onThreadDelete, onMessageDelete, onThreadToggleResolved, ...props }) => {
235
+ const { t } = (0, import_react_ui3.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
236
+ const filteredThreads = showResolvedThreads ? threads2 : threads2.filter((thread) => !(thread?.status === "resolved"));
234
237
  (0, import_react7.useEffect)(() => {
235
238
  if (currentId) {
236
239
  document.getElementById(currentId)?.scrollIntoView({
@@ -277,10 +280,10 @@ var CommentsContainer = ({ threads, detached = [], currentId, showResolvedThread
277
280
  }
278
281
  }))));
279
282
  };
280
- var ThreadMain = import_react2.default.lazy(() => import("./ThreadMain-6DN7FDNB.cjs"));
281
- var ThreadArticle = import_react2.default.lazy(() => import("./ThreadArticle-ERUHPHVT.cjs"));
283
+ var ThreadMain = import_react2.default.lazy(() => import("./ThreadMain-CO6I3DNX.cjs"));
284
+ var ThreadArticle = import_react2.default.lazy(() => import("./ThreadArticle-GH5UBWFU.cjs"));
282
285
  var providesThreadsConfig = (plugin) => "thread" in plugin.provides ? plugin : void 0;
283
- var ThreadComplementary = ({ role, subject, stagedThreads, current, showResolvedThreads }) => {
286
+ var ThreadComplementary = ({ role, subject, drafts, current, showResolvedThreads }) => {
284
287
  const dispatch = (0, import_app_framework2.useIntentDispatcher)();
285
288
  const threadsIntegrators = (0, import_app_framework2.useResolvePlugins)(providesThreadsConfig);
286
289
  const threadProvides = (0, import_react8.useMemo)(() => threadsIntegrators.map((p) => p.provides.thread), [
@@ -294,25 +297,25 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, showResolved
294
297
  createSort,
295
298
  subject
296
299
  ]);
297
- const threads = (0, import_react8.useMemo)(() => {
298
- return subject.threads.concat(stagedThreads ?? []).filter(import_util3.nonNullable);
300
+ const threads2 = (0, import_react8.useMemo)(() => {
301
+ return subject.threads.concat(drafts ?? []).filter(import_util2.nonNullable);
299
302
  }, [
300
303
  JSON.stringify(subject.threads),
301
- JSON.stringify(stagedThreads)
304
+ JSON.stringify(drafts)
302
305
  ]);
303
306
  const detachedIds = (0, import_react8.useMemo)(() => {
304
- return threads.filter(({ anchor }) => !anchor).map((thread) => (0, import_echo4.fullyQualifiedId)(thread));
307
+ return threads2.filter(({ anchor }) => !anchor).map((thread) => (0, import_echo4.fullyQualifiedId)(thread));
305
308
  }, [
306
- threads
309
+ threads2
307
310
  ]);
308
311
  (0, import_react8.useEffect)(() => {
309
312
  if (!sort) {
310
313
  return;
311
314
  }
312
- threads.sort((a, b) => sort(a?.anchor, b?.anchor));
315
+ threads2.sort((a, b) => sort(a?.anchor, b?.anchor));
313
316
  }, [
314
317
  sort,
315
- threads
318
+ threads2
316
319
  ]);
317
320
  const attended = (0, import_react_ui_attention.useAttended)();
318
321
  const qualifiedSubjectId = (0, import_echo4.fullyQualifiedId)(subject);
@@ -322,7 +325,7 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, showResolved
322
325
  }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Root, {
323
326
  classNames: "row-span-2"
324
327
  }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Viewport, null, /* @__PURE__ */ import_react8.default.createElement(CommentsContainer, {
325
- threads,
328
+ threads: threads2,
326
329
  detached: detachedIds,
327
330
  currentId: attended.includes(qualifiedSubjectId) ? current : void 0,
328
331
  showResolvedThreads,
@@ -344,8 +347,8 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, showResolved
344
347
  },
345
348
  onThreadDelete: (thread) => {
346
349
  return dispatch({
347
- plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
348
- action: import_chunk_FXD3DYMO.ThreadAction.DELETE,
350
+ plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
351
+ action: import_chunk_FOZUQZF4.ThreadAction.DELETE,
349
352
  data: {
350
353
  subject,
351
354
  thread
@@ -353,8 +356,8 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, showResolved
353
356
  });
354
357
  },
355
358
  onMessageDelete: (thread, messageId) => dispatch({
356
- plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
357
- action: import_chunk_FXD3DYMO.ThreadAction.DELETE_MESSAGE,
359
+ plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
360
+ action: import_chunk_FOZUQZF4.ThreadAction.DELETE_MESSAGE,
358
361
  data: {
359
362
  subject,
360
363
  thread,
@@ -362,15 +365,15 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, showResolved
362
365
  }
363
366
  }),
364
367
  onThreadToggleResolved: (thread) => dispatch({
365
- plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
366
- action: import_chunk_FXD3DYMO.ThreadAction.TOGGLE_RESOLVED,
368
+ plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
369
+ action: import_chunk_FOZUQZF4.ThreadAction.TOGGLE_RESOLVED,
367
370
  data: {
368
371
  thread
369
372
  }
370
373
  }),
371
374
  onComment: (thread) => {
372
375
  void dispatch({
373
- action: import_chunk_FXD3DYMO.ThreadAction.ON_MESSAGE_ADD,
376
+ action: import_chunk_FOZUQZF4.ThreadAction.ON_MESSAGE_ADD,
374
377
  data: {
375
378
  thread,
376
379
  subject
@@ -382,10 +385,91 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, showResolved
382
385
  className: "bs-10"
383
386
  }), /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Scrollbar, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Thumb, null)))));
384
387
  };
388
+ var getName = (doc, anchor) => {
389
+ if (doc.content) {
390
+ const [start, end] = anchor.split(":");
391
+ return (0, import_echo5.getTextInRange)((0, import_echo5.createDocAccessor)(doc.content, [
392
+ "content"
393
+ ]), start, end);
394
+ }
395
+ };
396
+ var threads = (state, doc, dispatch) => {
397
+ const space = doc && (0, import_echo5.getSpace)(doc);
398
+ if (!doc || !space || !dispatch) {
399
+ return [
400
+ (0, import_react_ui_editor2.comments)()
401
+ ];
402
+ }
403
+ const threads2 = (0, import_signals_core.computed)(() => [
404
+ ...doc.threads.filter(import_util3.nonNullable),
405
+ ...state.drafts[(0, import_echo5.fullyQualifiedId)(doc)] ?? []
406
+ ].filter((thread) => !(thread?.status === "resolved")));
407
+ return [
408
+ import_view.EditorView.updateListener.of((update) => {
409
+ if (update.docChanged) {
410
+ doc.threads.forEach((thread) => {
411
+ if (thread?.anchor) {
412
+ const name = getName(doc, thread.anchor);
413
+ if (name && name !== thread.name) {
414
+ thread.name = name;
415
+ }
416
+ }
417
+ });
418
+ }
419
+ }),
420
+ (0, import_react_ui_editor2.createExternalCommentSync)((0, import_echo5.fullyQualifiedId)(doc), (sink) => (0, import_signals_core.effect)(() => sink()), () => threads2.value.filter((thread) => thread?.anchor).map((thread) => ({
421
+ id: (0, import_echo5.fullyQualifiedId)(thread),
422
+ cursor: thread.anchor
423
+ }))),
424
+ (0, import_react_ui_editor2.comments)({
425
+ id: (0, import_echo5.fullyQualifiedId)(doc),
426
+ onCreate: ({ cursor }) => {
427
+ const name = getName(doc, cursor);
428
+ void dispatch({
429
+ action: import_chunk_FOZUQZF4.ThreadAction.CREATE,
430
+ data: {
431
+ cursor,
432
+ name,
433
+ subject: doc
434
+ }
435
+ });
436
+ },
437
+ onDelete: ({ id }) => {
438
+ const draft = state.drafts[(0, import_echo5.fullyQualifiedId)(doc)];
439
+ if (draft) {
440
+ const index = draft.findIndex((thread2) => (0, import_echo5.fullyQualifiedId)(thread2) === id);
441
+ if (index !== -1) {
442
+ draft.splice(index, 1);
443
+ }
444
+ }
445
+ const thread = doc.threads.find((thread2) => thread2?.id === id);
446
+ if (thread) {
447
+ thread.anchor = void 0;
448
+ }
449
+ },
450
+ onUpdate: ({ id, cursor }) => {
451
+ const thread = state.drafts[(0, import_echo5.fullyQualifiedId)(doc)]?.find((thread2) => (0, import_echo5.fullyQualifiedId)(thread2) === id) ?? doc.threads.find((thread2) => thread2?.id === id);
452
+ if (thread instanceof import_types3.ThreadType && thread.anchor) {
453
+ thread.name = getName(doc, thread.anchor);
454
+ thread.anchor = cursor;
455
+ }
456
+ },
457
+ onSelect: ({ selection: { current, closest } }) => {
458
+ void dispatch({
459
+ action: import_chunk_FOZUQZF4.ThreadAction.SELECT,
460
+ data: {
461
+ current: current ?? closest,
462
+ skipOpen: true
463
+ }
464
+ });
465
+ }
466
+ })
467
+ ];
468
+ };
385
469
  var translations_default = [
386
470
  {
387
471
  "en-US": {
388
- [import_chunk_6EVXCSDS.THREAD_PLUGIN]: {
472
+ [import_chunk_JIJ7Z6NO.THREAD_PLUGIN]: {
389
473
  "plugin name": "Threads",
390
474
  "channel name placeholder": "New channel",
391
475
  "channel title label": "Title",
@@ -421,9 +505,9 @@ var initialViewState = {
421
505
  showResolvedThreads: false
422
506
  };
423
507
  var ThreadPlugin = () => {
424
- const settings = new import_local_storage.LocalStorageStore(import_chunk_6EVXCSDS.THREAD_PLUGIN);
508
+ const settings = new import_local_storage.LocalStorageStore(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
425
509
  const state = (0, import_echo_schema2.create)({
426
- staging: {}
510
+ drafts: {}
427
511
  });
428
512
  const viewStore = (0, import_echo_schema2.create)({});
429
513
  const getViewState = (subjectId) => {
@@ -438,7 +522,7 @@ var ThreadPlugin = () => {
438
522
  let intentPlugin;
439
523
  const unsubscribeCallbacks = [];
440
524
  return {
441
- meta: import_chunk_6EVXCSDS.meta_default,
525
+ meta: import_chunk_JIJ7Z6NO.meta_default,
442
526
  ready: async (plugins) => {
443
527
  settings.prop({
444
528
  key: "standalone",
@@ -460,7 +544,7 @@ var ThreadPlugin = () => {
460
544
  placeholder: [
461
545
  "channel title placeholder",
462
546
  {
463
- ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
547
+ ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
464
548
  }
465
549
  ],
466
550
  icon: "ph--chat--regular",
@@ -475,7 +559,7 @@ var ThreadPlugin = () => {
475
559
  // TODO(wittjosiah): Move out of metadata.
476
560
  loadReferences: (message) => []
477
561
  },
478
- [import_chunk_6EVXCSDS.THREAD_ITEM]: {
562
+ [import_chunk_JIJ7Z6NO.THREAD_ITEM]: {
479
563
  parse: (item, type) => {
480
564
  switch (type) {
481
565
  case "node":
@@ -517,7 +601,7 @@ var ThreadPlugin = () => {
517
601
  }
518
602
  return [
519
603
  (0, import_plugin_graph.createExtension)({
520
- id: `${import_chunk_6EVXCSDS.THREAD_PLUGIN}/comments-for-subject`,
604
+ id: `${import_chunk_JIJ7Z6NO.THREAD_PLUGIN}/comments-for-subject`,
521
605
  resolver: ({ id }) => {
522
606
  if (!id.endsWith("~comments")) {
523
607
  return;
@@ -539,7 +623,7 @@ var ThreadPlugin = () => {
539
623
  const label = meta.label?.(object) || object.name || meta.placeholder || [
540
624
  "unnamed object threads label",
541
625
  {
542
- ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
626
+ ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
543
627
  }
544
628
  ];
545
629
  const viewState = getViewState(subjectId);
@@ -579,13 +663,13 @@ var ThreadPlugin = () => {
579
663
  };
580
664
  return [
581
665
  {
582
- id: `${import_chunk_6EVXCSDS.THREAD_PLUGIN}/toggle-show-resolved/${node.id}`,
666
+ id: `${import_chunk_JIJ7Z6NO.THREAD_PLUGIN}/toggle-show-resolved/${node.id}`,
583
667
  data: toggle,
584
668
  properties: {
585
669
  label: [
586
670
  "toggle show resolved",
587
671
  {
588
- ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
672
+ ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
589
673
  }
590
674
  ],
591
675
  menuItemType: "toggle",
@@ -598,7 +682,7 @@ var ThreadPlugin = () => {
598
682
  }
599
683
  }),
600
684
  (0, import_plugin_graph.createExtension)({
601
- id: import_chunk_FXD3DYMO.ThreadAction.CREATE,
685
+ id: import_chunk_FOZUQZF4.ThreadAction.CREATE,
602
686
  filter: (node) => !!settings.values.standalone && (0, import_plugin_graph.isActionGroup)(node) && node.id.startsWith(import_plugin_space.SpaceAction.ADD_OBJECT),
603
687
  actions: ({ node }) => {
604
688
  const id = node.id.split("/").at(-1);
@@ -611,12 +695,12 @@ var ThreadPlugin = () => {
611
695
  }
612
696
  return [
613
697
  {
614
- id: `${import_chunk_6EVXCSDS.THREAD_PLUGIN}/create/${node.id}`,
698
+ id: `${import_chunk_JIJ7Z6NO.THREAD_PLUGIN}/create/${node.id}`,
615
699
  data: async () => {
616
700
  await dispatch([
617
701
  {
618
- plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
619
- action: import_chunk_FXD3DYMO.ThreadAction.CREATE
702
+ plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
703
+ action: import_chunk_FOZUQZF4.ThreadAction.CREATE
620
704
  },
621
705
  {
622
706
  action: import_plugin_space.SpaceAction.ADD_OBJECT,
@@ -633,7 +717,7 @@ var ThreadPlugin = () => {
633
717
  label: [
634
718
  "create channel label",
635
719
  {
636
- ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
720
+ ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
637
721
  }
638
722
  ],
639
723
  icon: "ph--chat--regular",
@@ -655,12 +739,11 @@ var ThreadPlugin = () => {
655
739
  }) : null;
656
740
  }
657
741
  case "settings": {
658
- return data.plugin === import_chunk_6EVXCSDS.meta_default.id ? /* @__PURE__ */ import_react.default.createElement(ThreadSettings, {
742
+ return data.plugin === import_chunk_JIJ7Z6NO.meta_default.id ? /* @__PURE__ */ import_react.default.createElement(ThreadSettings, {
659
743
  settings: settings.values
660
744
  }) : null;
661
745
  }
662
- case "article":
663
- case "complementary": {
746
+ case "article": {
664
747
  const location = navigationPlugin?.provides.location;
665
748
  if (data.object instanceof import_types.ChannelType && data.object.threads[0]) {
666
749
  const channel = data.object;
@@ -681,22 +764,26 @@ var ThreadPlugin = () => {
681
764
  });
682
765
  }
683
766
  if (data.subject instanceof import_types.ThreadType) {
684
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_chunk_PZVUW4W2.ChatHeading, {
767
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_chunk_FDYRG7HE.ChatHeading, {
685
768
  attendableId: data.subject.id
686
- }), /* @__PURE__ */ import_react.default.createElement(import_chunk_PZVUW4W2.ChatContainer, {
769
+ }), /* @__PURE__ */ import_react.default.createElement(import_chunk_FDYRG7HE.ChatContainer, {
687
770
  thread: data.subject
688
771
  }));
689
772
  }
773
+ break;
774
+ }
775
+ case "complementary--comments": {
690
776
  if (data.subject && typeof data.subject === "object" && "threads" in data.subject && Array.isArray(data.subject.threads)) {
691
777
  const { showResolvedThreads } = getViewState((0, import_echo.fullyQualifiedId)(data.subject));
692
778
  return /* @__PURE__ */ import_react.default.createElement(ThreadComplementary, {
693
779
  role,
694
780
  subject: data.subject,
695
- stagedThreads: state.staging[(0, import_echo.fullyQualifiedId)(data.subject)],
781
+ drafts: state.drafts[(0, import_echo.fullyQualifiedId)(data.subject)],
696
782
  current: state.current,
697
783
  showResolvedThreads
698
784
  });
699
785
  }
786
+ break;
700
787
  }
701
788
  }
702
789
  return null;
@@ -705,16 +792,16 @@ var ThreadPlugin = () => {
705
792
  intent: {
706
793
  resolver: async (intent) => {
707
794
  switch (intent.action) {
708
- case import_chunk_FXD3DYMO.ThreadAction.CREATE: {
795
+ case import_chunk_FOZUQZF4.ThreadAction.CREATE: {
709
796
  if (intent.data && intent.data.cursor !== void 0) {
710
797
  const { cursor, name, subject } = intent.data;
711
798
  if (subject?.threads === void 0) {
712
799
  try {
713
800
  subject.threads = [];
714
- } catch (e) {
801
+ } catch (err) {
715
802
  import_log.log.error("Subject does not support threads array", subject?.typename, {
716
803
  F: __dxlog_file,
717
- L: 331,
804
+ L: 322,
718
805
  S: void 0,
719
806
  C: (f, a) => f(...a)
720
807
  });
@@ -728,11 +815,11 @@ var ThreadPlugin = () => {
728
815
  messages: [],
729
816
  status: "staged"
730
817
  });
731
- const stagingArea = state.staging[subjectId];
732
- if (stagingArea) {
733
- stagingArea.push(thread);
818
+ const draft = state.drafts[subjectId];
819
+ if (draft) {
820
+ draft.push(thread);
734
821
  } else {
735
- state.staging[subjectId] = [
822
+ state.drafts[subjectId] = [
736
823
  thread
737
824
  ];
738
825
  }
@@ -741,17 +828,19 @@ var ThreadPlugin = () => {
741
828
  intents: [
742
829
  [
743
830
  {
744
- action: import_chunk_FXD3DYMO.ThreadAction.SELECT,
831
+ action: import_chunk_FOZUQZF4.ThreadAction.SELECT,
745
832
  data: {
746
833
  current: (0, import_echo.fullyQualifiedId)(thread)
747
834
  }
748
- },
835
+ }
836
+ ],
837
+ [
749
838
  {
750
- action: import_app_framework.LayoutAction.SET_LAYOUT,
839
+ action: import_app_framework.NavigationAction.OPEN,
751
840
  data: {
752
- element: "complementary",
753
- subject: subjectId,
754
- state: true
841
+ activeParts: {
842
+ complementary: "comments"
843
+ }
755
844
  }
756
845
  }
757
846
  ]
@@ -769,13 +858,25 @@ var ThreadPlugin = () => {
769
858
  };
770
859
  }
771
860
  }
772
- case import_chunk_FXD3DYMO.ThreadAction.SELECT: {
861
+ case import_chunk_FOZUQZF4.ThreadAction.SELECT: {
773
862
  state.current = intent.data?.current;
774
863
  return {
775
- data: true
864
+ data: true,
865
+ intents: !intent.data?.skipOpen ? [
866
+ [
867
+ {
868
+ action: import_app_framework.NavigationAction.OPEN,
869
+ data: {
870
+ activeParts: {
871
+ complementary: "comments"
872
+ }
873
+ }
874
+ }
875
+ ]
876
+ ] : []
776
877
  };
777
878
  }
778
- case import_chunk_FXD3DYMO.ThreadAction.TOGGLE_RESOLVED: {
879
+ case import_chunk_FOZUQZF4.ThreadAction.TOGGLE_RESOLVED: {
779
880
  const { thread } = intent.data ?? {};
780
881
  if (!(thread instanceof import_types.ThreadType)) {
781
882
  return;
@@ -788,6 +889,7 @@ var ThreadPlugin = () => {
788
889
  const space = (0, import_echo.getSpace)(thread);
789
890
  const spaceId = space?.id;
790
891
  return {
892
+ data: true,
791
893
  intents: [
792
894
  [
793
895
  {
@@ -804,17 +906,17 @@ var ThreadPlugin = () => {
804
906
  ]
805
907
  };
806
908
  }
807
- case import_chunk_FXD3DYMO.ThreadAction.DELETE: {
909
+ case import_chunk_FOZUQZF4.ThreadAction.DELETE: {
808
910
  const { subject, thread } = intent.data ?? {};
809
911
  if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject)) {
810
912
  return;
811
913
  }
812
914
  const subjectId = (0, import_echo.fullyQualifiedId)(subject);
813
- const stagingArea = state.staging[subjectId];
814
- if (stagingArea) {
815
- const index = stagingArea.findIndex((t) => t.id === thread.id);
915
+ const draft = state.drafts[subjectId];
916
+ if (draft) {
917
+ const index = draft.findIndex((t) => t.id === thread.id);
816
918
  if (index !== -1) {
817
- stagingArea.splice(index, 1);
919
+ draft.splice(index, 1);
818
920
  return {
819
921
  data: true
820
922
  };
@@ -833,7 +935,7 @@ var ThreadPlugin = () => {
833
935
  space.db.remove(thread);
834
936
  return {
835
937
  undoable: {
836
- message: translations_default[0]["en-US"][import_chunk_6EVXCSDS.THREAD_PLUGIN]["thread deleted label"],
938
+ message: translations_default[0]["en-US"][import_chunk_JIJ7Z6NO.THREAD_PLUGIN]["thread deleted label"],
837
939
  data: {
838
940
  cursor
839
941
  }
@@ -876,7 +978,7 @@ var ThreadPlugin = () => {
876
978
  }
877
979
  break;
878
980
  }
879
- case import_chunk_FXD3DYMO.ThreadAction.ON_MESSAGE_ADD: {
981
+ case import_chunk_FOZUQZF4.ThreadAction.ON_MESSAGE_ADD: {
880
982
  const { thread, subject } = intent.data ?? {};
881
983
  if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject && Array.isArray(subject.threads))) {
882
984
  return;
@@ -888,12 +990,12 @@ var ThreadPlugin = () => {
888
990
  threadId: thread.id,
889
991
  spaceId: space?.id
890
992
  };
891
- if (state.staging[subjectId]?.find((t) => t === thread)) {
993
+ if (state.drafts[subjectId]?.find((t) => t === thread)) {
892
994
  thread.status = "active";
893
995
  subject.threads ? subject.threads.push(thread) : subject.threads = [
894
996
  thread
895
997
  ];
896
- state.staging[subjectId] = state.staging[subjectId]?.filter((t) => t.id !== thread.id);
998
+ state.drafts[subjectId] = state.drafts[subjectId]?.filter(({ id }) => id !== thread.id);
897
999
  intents.push({
898
1000
  action: import_meta.ObservabilityAction.SEND_EVENT,
899
1001
  data: {
@@ -919,7 +1021,7 @@ var ThreadPlugin = () => {
919
1021
  ]
920
1022
  };
921
1023
  }
922
- case import_chunk_FXD3DYMO.ThreadAction.DELETE_MESSAGE: {
1024
+ case import_chunk_FOZUQZF4.ThreadAction.DELETE_MESSAGE: {
923
1025
  const { subject, thread, messageId } = intent.data ?? {};
924
1026
  const space = (0, import_echo.getSpace)(subject);
925
1027
  if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject)) {
@@ -936,7 +1038,7 @@ var ThreadPlugin = () => {
936
1038
  intents: [
937
1039
  [
938
1040
  {
939
- action: import_chunk_FXD3DYMO.ThreadAction.DELETE,
1041
+ action: import_chunk_FOZUQZF4.ThreadAction.DELETE,
940
1042
  data: {
941
1043
  subject,
942
1044
  thread
@@ -950,7 +1052,7 @@ var ThreadPlugin = () => {
950
1052
  }
951
1053
  return {
952
1054
  undoable: {
953
- message: translations_default[0]["en-US"][import_chunk_6EVXCSDS.THREAD_PLUGIN]["message deleted label"],
1055
+ message: translations_default[0]["en-US"][import_chunk_JIJ7Z6NO.THREAD_PLUGIN]["message deleted label"],
954
1056
  data: {
955
1057
  message,
956
1058
  messageIndex
@@ -1001,92 +1103,8 @@ var ThreadPlugin = () => {
1001
1103
  }
1002
1104
  },
1003
1105
  markdown: {
1004
- // TODO(burdon): Factor out extension factory into separate file (for simplicity).
1005
1106
  extensions: ({ document: doc }) => {
1006
- const space = doc && (0, import_echo.getSpace)(doc);
1007
- if (!doc || !space) {
1008
- return [
1009
- (0, import_react_ui_editor.comments)()
1010
- ];
1011
- }
1012
- const threads = (0, import_signals_core.computed)(() => [
1013
- ...doc.threads.filter(import_util.nonNullable),
1014
- ...state.staging[(0, import_echo.fullyQualifiedId)(doc)] ?? []
1015
- ].filter((thread) => !(thread?.status === "resolved")));
1016
- return [
1017
- (0, import_react_ui_editor.listener)({
1018
- onChange: () => {
1019
- doc.threads.forEach((thread) => {
1020
- if (thread?.anchor) {
1021
- const [start, end] = thread.anchor.split(":");
1022
- const name = doc.content && (0, import_echo.getTextInRange)((0, import_echo.createDocAccessor)(doc.content, [
1023
- "content"
1024
- ]), start, end);
1025
- if (name && name !== thread.name) {
1026
- thread.name = name;
1027
- }
1028
- }
1029
- });
1030
- }
1031
- }),
1032
- (0, import_react_ui_editor.createExternalCommentSync)((0, import_echo.fullyQualifiedId)(doc), (sink) => (0, import_signals_core.effect)(() => sink()), () => threads.value.filter((thread) => thread?.anchor).map((thread) => ({
1033
- id: (0, import_echo.fullyQualifiedId)(thread),
1034
- cursor: thread.anchor
1035
- }))),
1036
- (0, import_react_ui_editor.comments)({
1037
- id: (0, import_echo.fullyQualifiedId)(doc),
1038
- onCreate: ({ cursor }) => {
1039
- const [start, end] = cursor.split(":");
1040
- const name = doc.content && (0, import_echo.getTextInRange)((0, import_echo.createDocAccessor)(doc.content, [
1041
- "content"
1042
- ]), start, end);
1043
- void intentPlugin?.provides.intent.dispatch({
1044
- action: import_chunk_FXD3DYMO.ThreadAction.CREATE,
1045
- data: {
1046
- cursor,
1047
- name,
1048
- subject: doc
1049
- }
1050
- });
1051
- },
1052
- onDelete: ({ id }) => {
1053
- const stagingArea = state.staging[(0, import_echo.fullyQualifiedId)(doc)];
1054
- if (stagingArea) {
1055
- const index = stagingArea.findIndex((thread2) => (0, import_echo.fullyQualifiedId)(thread2) === id);
1056
- if (index !== -1) {
1057
- stagingArea.splice(index, 1);
1058
- }
1059
- }
1060
- const thread = doc.threads.find((thread2) => thread2?.id === id);
1061
- if (thread) {
1062
- thread.anchor = void 0;
1063
- }
1064
- },
1065
- onUpdate: ({ id, cursor }) => {
1066
- const thread = state.staging[(0, import_echo.fullyQualifiedId)(doc)]?.find((thread2) => (0, import_echo.fullyQualifiedId)(thread2) === id) ?? doc.threads.find((thread2) => thread2?.id === id);
1067
- if (thread instanceof import_types.ThreadType && thread.anchor) {
1068
- const [start, end] = thread.anchor.split(":");
1069
- thread.name = doc.content && (0, import_echo.getTextInRange)((0, import_echo.createDocAccessor)(doc.content, [
1070
- "content"
1071
- ]), start, end);
1072
- thread.anchor = cursor;
1073
- }
1074
- },
1075
- onSelect: ({ selection: { current, closest } }) => {
1076
- const dispatch = intentPlugin?.provides.intent.dispatch;
1077
- if (dispatch) {
1078
- void dispatch([
1079
- {
1080
- action: import_chunk_FXD3DYMO.ThreadAction.SELECT,
1081
- data: {
1082
- current: current ?? closest
1083
- }
1084
- }
1085
- ]);
1086
- }
1087
- }
1088
- })
1089
- ];
1107
+ return threads(state, doc, intentPlugin?.provides.intent.dispatch);
1090
1108
  }
1091
1109
  }
1092
1110
  }