@dxos/plugin-thread 0.6.12-staging.e11e696 → 0.6.13-main.041e8aa

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 (72) 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 +234 -215
  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 +272 -255
  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 +234 -215
  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/components/index.d.ts +3 -2
  43. package/dist/types/src/components/index.d.ts.map +1 -1
  44. package/dist/types/src/components/testing.d.ts.map +1 -1
  45. package/dist/types/src/extensions/index.d.ts +2 -0
  46. package/dist/types/src/extensions/index.d.ts.map +1 -0
  47. package/dist/types/src/extensions/threads.d.ts +9 -0
  48. package/dist/types/src/extensions/threads.d.ts.map +1 -0
  49. package/dist/types/src/meta.d.ts +3 -6
  50. package/dist/types/src/meta.d.ts.map +1 -1
  51. package/dist/types/src/types.d.ts +5 -0
  52. package/dist/types/src/types.d.ts.map +1 -1
  53. package/package.json +28 -28
  54. package/src/ThreadPlugin.tsx +68 -146
  55. package/src/components/ThreadComplementary.tsx +4 -4
  56. package/src/components/index.ts +3 -2
  57. package/src/extensions/index.ts +5 -0
  58. package/src/extensions/threads.ts +117 -0
  59. package/src/{meta.tsx → meta.ts} +3 -4
  60. package/src/types.ts +7 -2
  61. package/dist/lib/browser/chunk-7NUYW5IW.mjs.map +0 -7
  62. package/dist/lib/node/chunk-6EVXCSDS.cjs.map +0 -7
  63. package/dist/lib/node-esm/chunk-Y475KZTX.mjs.map +0 -7
  64. /package/dist/lib/browser/{ThreadArticle-4VU752F4.mjs.map → ThreadArticle-GBPIH47W.mjs.map} +0 -0
  65. /package/dist/lib/browser/{ThreadMain-ML3P4XSD.mjs.map → ThreadMain-PGF7W5EV.mjs.map} +0 -0
  66. /package/dist/lib/browser/{chunk-XF5QKI75.mjs.map → chunk-O4YRHIZC.mjs.map} +0 -0
  67. /package/dist/lib/node/{ThreadArticle-ERUHPHVT.cjs.map → ThreadArticle-GH5UBWFU.cjs.map} +0 -0
  68. /package/dist/lib/node/{ThreadMain-6DN7FDNB.cjs.map → ThreadMain-CO6I3DNX.cjs.map} +0 -0
  69. /package/dist/lib/node/{chunk-PZVUW4W2.cjs.map → chunk-FDYRG7HE.cjs.map} +0 -0
  70. /package/dist/lib/node-esm/{ThreadArticle-NKI5F4W5.mjs.map → ThreadArticle-ZTYD52TR.mjs.map} +0 -0
  71. /package/dist/lib/node-esm/{ThreadMain-2A3VQLCW.mjs.map → ThreadMain-LEHGOF7R.mjs.map} +0 -0
  72. /package/dist/lib/node-esm/{chunk-A44C4MTQ.mjs.map → chunk-XOVJ65DG.mjs.map} +0 -0
@@ -28,22 +28,20 @@ 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");
46
- var import_echo_schema2 = require("@dxos/echo-schema");
47
45
  var import_local_storage = require("@dxos/local-storage");
48
46
  var import_log = require("@dxos/log");
49
47
  var import_plugin_client = require("@dxos/plugin-client");
@@ -52,51 +50,46 @@ var import_meta = require("@dxos/plugin-observability/meta");
52
50
  var import_plugin_space = require("@dxos/plugin-space");
53
51
  var import_types = require("@dxos/plugin-space/types");
54
52
  var import_echo = require("@dxos/react-client/echo");
55
- var import_react_ui_editor = require("@dxos/react-ui-editor");
56
53
  var import_react_ui_thread = require("@dxos/react-ui-thread");
57
- var import_util = require("@dxos/util");
58
54
  var import_react2 = __toESM(require("react"));
59
- var import_react3 = __toESM(require("react"));
60
- var import_plugin_settings = require("@dxos/plugin-settings");
61
- var import_react_ui = require("@dxos/react-ui");
62
- var import_react4 = require("@phosphor-icons/react");
63
- var import_react5 = __toESM(require("react"));
64
- var import_echo_schema3 = require("@dxos/echo-schema");
55
+ var import_react3 = require("@phosphor-icons/react");
56
+ var import_react4 = __toESM(require("react"));
57
+ var import_echo_schema2 = require("@dxos/echo-schema");
65
58
  var import_types2 = require("@dxos/plugin-space/types");
66
59
  var import_echo2 = require("@dxos/react-client/echo");
67
60
  var import_halo = require("@dxos/react-client/halo");
68
- var import_react_ui2 = require("@dxos/react-ui");
69
- var import_react_ui_editor2 = require("@dxos/react-ui-editor");
61
+ var import_react_ui = require("@dxos/react-ui");
62
+ var import_react_ui_editor = require("@dxos/react-ui-editor");
70
63
  var import_react_ui_theme = require("@dxos/react-ui-theme");
71
64
  var import_react_ui_thread2 = require("@dxos/react-ui-thread");
72
- var import_util2 = require("@dxos/util");
73
- var import_react6 = require("@phosphor-icons/react");
74
- var import_react7 = __toESM(require("react"));
65
+ var import_util = require("@dxos/util");
66
+ var import_react5 = require("@phosphor-icons/react");
67
+ var import_react6 = __toESM(require("react"));
75
68
  var import_echo3 = require("@dxos/react-client/echo");
76
- var import_react_ui3 = require("@dxos/react-ui");
69
+ var import_react_ui2 = require("@dxos/react-ui");
77
70
  var import_react_ui_theme2 = require("@dxos/react-ui-theme");
78
- var import_react8 = __toESM(require("react"));
71
+ var import_react7 = __toESM(require("react"));
79
72
  var import_app_framework2 = require("@dxos/app-framework");
80
73
  var import_echo4 = require("@dxos/react-client/echo");
81
- var import_react_ui4 = require("@dxos/react-ui");
74
+ var import_react_ui3 = require("@dxos/react-ui");
82
75
  var import_react_ui_attention = require("@dxos/react-ui-attention");
76
+ var import_util2 = require("@dxos/util");
77
+ var import_react8 = __toESM(require("react"));
78
+ var import_plugin_settings = require("@dxos/plugin-settings");
79
+ var import_react_ui4 = require("@dxos/react-ui");
80
+ var import_view = require("@codemirror/view");
81
+ var import_signals_core = require("@preact/signals-core");
82
+ var import_types3 = require("@dxos/plugin-space/types");
83
+ var import_echo5 = require("@dxos/react-client/echo");
84
+ var import_react_ui_editor2 = require("@dxos/react-ui-editor");
83
85
  var import_util3 = require("@dxos/util");
84
- var ThreadSettings = ({ settings }) => {
85
- const { t } = (0, import_react_ui.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
86
- return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(import_plugin_settings.SettingsValue, {
87
- label: t("settings standalone label")
88
- }, /* @__PURE__ */ import_react3.default.createElement(import_react_ui.Input.Switch, {
89
- checked: settings.standalone,
90
- onCheckedChange: (checked) => settings.standalone = !!checked
91
- })));
92
- };
93
86
  var sizeClass = (0, import_react_ui_theme.getSize)(4);
94
87
  var ToggleResolvedButton = ({ isResolved, onResolve }) => {
95
- const { t } = (0, import_react_ui2.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
88
+ const { t } = (0, import_react_ui.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
96
89
  const label = t(isResolved ? "mark as unresolved label" : "mark as resolved label");
97
- return /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
90
+ return /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Root, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Trigger, {
98
91
  asChild: true
99
- }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Button, {
92
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Button, {
100
93
  variant: "ghost",
101
94
  "data-testid": "thread.toggle-resolved",
102
95
  onClick: onResolve,
@@ -104,23 +97,23 @@ var ToggleResolvedButton = ({ isResolved, onResolve }) => {
104
97
  "min-bs-0 p-1",
105
98
  !isResolved && import_react_ui_theme.hoverableControlItem
106
99
  ]
107
- }, /* @__PURE__ */ import_react5.default.createElement("span", {
100
+ }, /* @__PURE__ */ import_react4.default.createElement("span", {
108
101
  className: "sr-only"
109
- }, label), isResolved ? /* @__PURE__ */ import_react5.default.createElement(import_react4.CheckCircle, {
102
+ }, label), isResolved ? /* @__PURE__ */ import_react4.default.createElement(import_react3.CheckCircle, {
110
103
  className: sizeClass,
111
104
  weight: "fill"
112
- }) : /* @__PURE__ */ import_react5.default.createElement(import_react4.CheckCircle, {
105
+ }) : /* @__PURE__ */ import_react4.default.createElement(import_react3.CheckCircle, {
113
106
  className: sizeClass
114
- }))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Content, {
107
+ }))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Portal, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Content, {
115
108
  classNames: "z-[21]"
116
- }, label, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Arrow, null))));
109
+ }, label, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Arrow, null))));
117
110
  };
118
111
  var DeleteThreadButton = ({ onDelete }) => {
119
- const { t } = (0, import_react_ui2.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
112
+ const { t } = (0, import_react_ui.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
120
113
  const label = t("delete thread label");
121
- return /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
114
+ return /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Root, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Trigger, {
122
115
  asChild: true
123
- }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Button, {
116
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Button, {
124
117
  variant: "ghost",
125
118
  "data-testid": "thread.delete",
126
119
  onClick: onDelete,
@@ -128,37 +121,37 @@ var DeleteThreadButton = ({ onDelete }) => {
128
121
  "min-bs-0 p-1",
129
122
  import_react_ui_theme.hoverableControlItem
130
123
  ]
131
- }, /* @__PURE__ */ import_react5.default.createElement("span", {
124
+ }, /* @__PURE__ */ import_react4.default.createElement("span", {
132
125
  className: "sr-only"
133
- }, label), /* @__PURE__ */ import_react5.default.createElement(import_react4.X, {
126
+ }, label), /* @__PURE__ */ import_react4.default.createElement(import_react3.X, {
134
127
  className: sizeClass
135
- }))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Content, {
128
+ }))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Portal, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Content, {
136
129
  classNames: "z-[21]"
137
- }, label, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Arrow, null))));
130
+ }, label, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Arrow, null))));
138
131
  };
139
132
  var CommentContainer = ({ thread, detached, context, current, onAttend, onThreadDelete, onMessageDelete, onResolve, onComment }) => {
140
133
  const identity = (0, import_halo.useIdentity)();
141
134
  const space = (0, import_echo2.getSpace)(thread);
142
135
  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);
145
- const threadScrollRef = (0, import_react5.useRef)(null);
146
- const { themeMode } = (0, import_react_ui2.useThemeContext)();
147
- const textboxMetadata = (0, import_chunk_PZVUW4W2.getMessageMetadata)((0, import_echo2.fullyQualifiedId)(thread), identity);
148
- const [_count, _setCount] = (0, import_react5.useState)(0);
136
+ const activity = (0, import_chunk_FDYRG7HE.useStatus)(space, (0, import_echo2.fullyQualifiedId)(thread));
137
+ const { t } = (0, import_react_ui.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
138
+ const threadScrollRef = (0, import_react4.useRef)(null);
139
+ const { themeMode } = (0, import_react_ui.useThemeContext)();
140
+ const textboxMetadata = (0, import_chunk_FDYRG7HE.getMessageMetadata)((0, import_echo2.fullyQualifiedId)(thread), identity);
141
+ const [_count, _setCount] = (0, import_react4.useState)(0);
149
142
  const rerenderEditor = () => _setCount((count) => count + 1);
150
- const messageRef = (0, import_react5.useRef)("");
151
- const extensions = (0, import_react5.useMemo)(() => [
152
- (0, import_react_ui_editor2.createBasicExtensions)({
143
+ const messageRef = (0, import_react4.useRef)("");
144
+ const extensions = (0, import_react4.useMemo)(() => [
145
+ (0, import_react_ui_editor.createBasicExtensions)({
153
146
  placeholder: t("message placeholder")
154
147
  }),
155
- (0, import_react_ui_editor2.createThemeExtensions)({
148
+ (0, import_react_ui_editor.createThemeExtensions)({
156
149
  themeMode
157
150
  }),
158
- (0, import_react_ui_editor2.listener)({
151
+ (0, import_react_ui_editor.listener)({
159
152
  onChange: (text) => messageRef.current = text
160
153
  }),
161
- import_chunk_PZVUW4W2.command
154
+ import_chunk_FDYRG7HE.command
162
155
  ], [
163
156
  _count
164
157
  ]);
@@ -166,11 +159,11 @@ var CommentContainer = ({ thread, detached, context, current, onAttend, onThread
166
159
  behavior,
167
160
  block: "end"
168
161
  }), 10);
169
- const handleCreate = (0, import_react5.useCallback)(() => {
162
+ const handleCreate = (0, import_react4.useCallback)(() => {
170
163
  if (!messageRef.current) {
171
164
  return false;
172
165
  }
173
- thread.messages.push((0, import_echo_schema3.create)(import_types2.MessageType, {
166
+ thread.messages.push((0, import_echo_schema2.create)(import_types2.MessageType, {
174
167
  sender: {
175
168
  identityKey: identity.identityKey.toHex()
176
169
  },
@@ -187,51 +180,51 @@ var CommentContainer = ({ thread, detached, context, current, onAttend, onThread
187
180
  thread,
188
181
  identity
189
182
  ]);
190
- return /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.Thread, {
183
+ return /* @__PURE__ */ import_react4.default.createElement(import_react_ui_thread2.Thread, {
191
184
  onClickCapture: onAttend,
192
185
  onFocusCapture: onAttend,
193
186
  current,
194
187
  id: (0, import_echo2.fullyQualifiedId)(thread)
195
- }, /* @__PURE__ */ import_react5.default.createElement("div", {
188
+ }, /* @__PURE__ */ import_react4.default.createElement("div", {
196
189
  role: "none",
197
190
  className: (0, import_react_ui_theme.mx)("col-span-2 grid grid-cols-[var(--rail-size)_1fr_min-content]", import_react_ui_theme.hoverableControls, import_react_ui_theme.hoverableFocusedWithinControls)
198
- }, detached ? /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
191
+ }, detached ? /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Root, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Trigger, {
199
192
  asChild: true
200
- }, /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.ThreadHeading, {
193
+ }, /* @__PURE__ */ import_react4.default.createElement(import_react_ui_thread2.ThreadHeading, {
201
194
  detached: true
202
- }, thread.name ?? t("thread title placeholder"))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Content, {
195
+ }, thread.name ?? t("thread title placeholder"))), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Portal, null, /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Content, {
203
196
  classNames: "z-[21]",
204
197
  side: "top"
205
- }, t("detached thread label"), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Arrow, null)))) : /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.ThreadHeading, null, thread.name ?? t("thread title placeholder")), /* @__PURE__ */ import_react5.default.createElement("div", {
198
+ }, t("detached thread label"), /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tooltip.Arrow, null)))) : /* @__PURE__ */ import_react4.default.createElement(import_react_ui_thread2.ThreadHeading, null, thread.name ?? t("thread title placeholder")), /* @__PURE__ */ import_react4.default.createElement("div", {
206
199
  className: "flex flex-row items-center pli-1"
207
- }, thread.status === "staged" && /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tag, {
200
+ }, thread.status === "staged" && /* @__PURE__ */ import_react4.default.createElement(import_react_ui.Tag, {
208
201
  palette: "neutral"
209
- }, t("draft button")), onResolve && !(thread?.status === "staged") && /* @__PURE__ */ import_react5.default.createElement(ToggleResolvedButton, {
202
+ }, t("draft button")), onResolve && !(thread?.status === "staged") && /* @__PURE__ */ import_react4.default.createElement(ToggleResolvedButton, {
210
203
  isResolved: thread?.status === "resolved",
211
204
  onResolve
212
- }), onThreadDelete && /* @__PURE__ */ import_react5.default.createElement(DeleteThreadButton, {
205
+ }), onThreadDelete && /* @__PURE__ */ import_react4.default.createElement(DeleteThreadButton, {
213
206
  onDelete: onThreadDelete
214
- }))), thread.messages.filter(import_util2.nonNullable).map((message) => /* @__PURE__ */ import_react5.default.createElement(import_chunk_PZVUW4W2.MessageContainer, {
207
+ }))), thread.messages.filter(import_util.nonNullable).map((message) => /* @__PURE__ */ import_react4.default.createElement(import_chunk_FDYRG7HE.MessageContainer, {
215
208
  key: message.id,
216
209
  message,
217
210
  members,
218
211
  onDelete: (id) => onMessageDelete?.(id)
219
- })), /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.MessageTextbox, {
212
+ })), /* @__PURE__ */ import_react4.default.createElement(import_react_ui_thread2.MessageTextbox, {
220
213
  extensions,
221
214
  onSend: handleCreate,
222
215
  ...textboxMetadata
223
- }), /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.ThreadFooter, {
216
+ }), /* @__PURE__ */ import_react4.default.createElement(import_react_ui_thread2.ThreadFooter, {
224
217
  activity
225
- }, t("activity message")), /* @__PURE__ */ import_react5.default.createElement("div", {
218
+ }, t("activity message")), /* @__PURE__ */ import_react4.default.createElement("div", {
226
219
  role: "none",
227
220
  className: "bs-px -mbs-px",
228
221
  ref: threadScrollRef
229
222
  }));
230
223
  };
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
- (0, import_react7.useEffect)(() => {
224
+ var CommentsContainer = ({ threads: threads2, detached = [], currentId, showResolvedThreads, onThreadAttend, onThreadDelete, onMessageDelete, onThreadToggleResolved, ...props }) => {
225
+ const { t } = (0, import_react_ui2.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
226
+ const filteredThreads = showResolvedThreads ? threads2 : threads2.filter((thread) => !(thread?.status === "resolved"));
227
+ (0, import_react6.useEffect)(() => {
235
228
  if (currentId) {
236
229
  document.getElementById(currentId)?.scrollIntoView({
237
230
  behavior: "smooth",
@@ -241,9 +234,9 @@ var CommentsContainer = ({ threads, detached = [], currentId, showResolvedThread
241
234
  }, [
242
235
  currentId
243
236
  ]);
244
- return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, filteredThreads.length > 0 ? filteredThreads.map((thread) => {
237
+ return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, filteredThreads.length > 0 ? filteredThreads.map((thread) => {
245
238
  const threadId = (0, import_echo3.fullyQualifiedId)(thread);
246
- return /* @__PURE__ */ import_react7.default.createElement(CommentContainer, {
239
+ return /* @__PURE__ */ import_react6.default.createElement(CommentContainer, {
247
240
  key: threadId,
248
241
  thread,
249
242
  current: currentId === threadId,
@@ -262,67 +255,65 @@ var CommentsContainer = ({ threads, detached = [], currentId, showResolvedThread
262
255
  },
263
256
  ...props
264
257
  });
265
- }) : /* @__PURE__ */ import_react7.default.createElement("div", {
258
+ }) : /* @__PURE__ */ import_react6.default.createElement("div", {
266
259
  role: "alert",
267
260
  className: (0, import_react_ui_theme2.mx)(import_react_ui_theme2.descriptionText, "place-self-center border border-dashed border-neutral-400/50 rounded-lg text-center p-4 m-4")
268
- }, /* @__PURE__ */ import_react7.default.createElement("h2", {
261
+ }, /* @__PURE__ */ import_react6.default.createElement("h2", {
269
262
  className: "mbe-2 font-medium text-baseText"
270
- }, t("no comments title")), /* @__PURE__ */ import_react7.default.createElement("p", null, /* @__PURE__ */ import_react7.default.createElement(import_react_ui3.Trans, {
263
+ }, t("no comments title")), /* @__PURE__ */ import_react6.default.createElement("p", null, /* @__PURE__ */ import_react6.default.createElement(import_react_ui2.Trans, {
271
264
  t,
272
265
  i18nKey: "no comments message",
273
266
  components: {
274
- commentIcon: /* @__PURE__ */ import_react7.default.createElement(import_react6.ChatText, {
267
+ commentIcon: /* @__PURE__ */ import_react6.default.createElement(import_react5.ChatText, {
275
268
  className: "inline-block"
276
269
  })
277
270
  }
278
271
  }))));
279
272
  };
280
- var ThreadMain = import_react2.default.lazy(() => import("./ThreadMain-6DN7FDNB.cjs"));
281
- var ThreadArticle = import_react2.default.lazy(() => import("./ThreadArticle-ERUHPHVT.cjs"));
282
273
  var providesThreadsConfig = (plugin) => "thread" in plugin.provides ? plugin : void 0;
283
- var ThreadComplementary = ({ role, subject, stagedThreads, current, showResolvedThreads }) => {
274
+ var ThreadComplementary = ({ role, subject, drafts, current, showResolvedThreads }) => {
284
275
  const dispatch = (0, import_app_framework2.useIntentDispatcher)();
285
276
  const threadsIntegrators = (0, import_app_framework2.useResolvePlugins)(providesThreadsConfig);
286
- const threadProvides = (0, import_react8.useMemo)(() => threadsIntegrators.map((p) => p.provides.thread), [
277
+ const threadProvides = (0, import_react7.useMemo)(() => threadsIntegrators.map((p) => p.provides.thread), [
287
278
  threadsIntegrators
288
279
  ]);
289
- const createSort = (0, import_react8.useMemo)(() => threadProvides.find((p) => p.predicate(subject))?.createSort, [
280
+ const createSort = (0, import_react7.useMemo)(() => threadProvides.find((p) => p.predicate(subject))?.createSort, [
290
281
  threadProvides,
291
282
  subject
292
283
  ]);
293
- const sort = (0, import_react8.useMemo)(() => createSort?.(subject), [
284
+ const sort = (0, import_react7.useMemo)(() => createSort?.(subject), [
294
285
  createSort,
295
286
  subject
296
287
  ]);
297
- const threads = (0, import_react8.useMemo)(() => {
298
- return subject.threads.concat(stagedThreads ?? []).filter(import_util3.nonNullable);
288
+ const threads2 = (0, import_react7.useMemo)(() => {
289
+ return subject.threads.concat(drafts ?? []).filter(import_util2.nonNullable);
299
290
  }, [
300
291
  JSON.stringify(subject.threads),
301
- JSON.stringify(stagedThreads)
292
+ JSON.stringify(drafts)
302
293
  ]);
303
- const detachedIds = (0, import_react8.useMemo)(() => {
304
- return threads.filter(({ anchor }) => !anchor).map((thread) => (0, import_echo4.fullyQualifiedId)(thread));
294
+ const detachedIds = (0, import_react7.useMemo)(() => {
295
+ return threads2.filter(({ anchor }) => !anchor).map((thread) => (0, import_echo4.fullyQualifiedId)(thread));
305
296
  }, [
306
- threads
297
+ threads2
307
298
  ]);
308
- (0, import_react8.useEffect)(() => {
299
+ (0, import_react7.useEffect)(() => {
309
300
  if (!sort) {
310
301
  return;
311
302
  }
312
- threads.sort((a, b) => sort(a?.anchor, b?.anchor));
303
+ threads2.sort((a, b) => sort(a?.anchor, b?.anchor));
313
304
  }, [
314
305
  sort,
315
- threads
306
+ threads2
316
307
  ]);
317
308
  const attended = (0, import_react_ui_attention.useAttended)();
318
309
  const qualifiedSubjectId = (0, import_echo4.fullyQualifiedId)(subject);
319
- return /* @__PURE__ */ import_react8.default.createElement("div", {
310
+ return /* @__PURE__ */ import_react7.default.createElement("div", {
320
311
  role: "none",
321
312
  className: "contents"
322
- }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Root, {
313
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui3.ScrollArea.Root, {
323
314
  classNames: "row-span-2"
324
- }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Viewport, null, /* @__PURE__ */ import_react8.default.createElement(CommentsContainer, {
325
- threads,
315
+ }, /* @__PURE__ */ import_react7.default.createElement(import_react_ui3.ScrollArea.Viewport, null, /* @__PURE__ */ import_react7.default.createElement(CommentsContainer, {
316
+ threads: threads2,
326
317
  detached: detachedIds,
327
318
  currentId: attended.includes(qualifiedSubjectId) ? current : void 0,
328
319
  showResolvedThreads,
@@ -344,8 +335,8 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, showResolved
344
335
  },
345
336
  onThreadDelete: (thread) => {
346
337
  return dispatch({
347
- plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
348
- action: import_chunk_FXD3DYMO.ThreadAction.DELETE,
338
+ plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
339
+ action: import_chunk_FOZUQZF4.ThreadAction.DELETE,
349
340
  data: {
350
341
  subject,
351
342
  thread
@@ -353,8 +344,8 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, showResolved
353
344
  });
354
345
  },
355
346
  onMessageDelete: (thread, messageId) => dispatch({
356
- plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
357
- action: import_chunk_FXD3DYMO.ThreadAction.DELETE_MESSAGE,
347
+ plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
348
+ action: import_chunk_FOZUQZF4.ThreadAction.DELETE_MESSAGE,
358
349
  data: {
359
350
  subject,
360
351
  thread,
@@ -362,30 +353,122 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, showResolved
362
353
  }
363
354
  }),
364
355
  onThreadToggleResolved: (thread) => dispatch({
365
- plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
366
- action: import_chunk_FXD3DYMO.ThreadAction.TOGGLE_RESOLVED,
356
+ plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
357
+ action: import_chunk_FOZUQZF4.ThreadAction.TOGGLE_RESOLVED,
367
358
  data: {
368
359
  thread
369
360
  }
370
361
  }),
371
362
  onComment: (thread) => {
372
363
  void dispatch({
373
- action: import_chunk_FXD3DYMO.ThreadAction.ON_MESSAGE_ADD,
364
+ action: import_chunk_FOZUQZF4.ThreadAction.ON_MESSAGE_ADD,
374
365
  data: {
375
366
  thread,
376
367
  subject
377
368
  }
378
369
  });
379
370
  }
380
- }), /* @__PURE__ */ import_react8.default.createElement("div", {
371
+ }), /* @__PURE__ */ import_react7.default.createElement("div", {
381
372
  role: "none",
382
373
  className: "bs-10"
383
- }), /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Scrollbar, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Thumb, null)))));
374
+ }), /* @__PURE__ */ import_react7.default.createElement(import_react_ui3.ScrollArea.Scrollbar, null, /* @__PURE__ */ import_react7.default.createElement(import_react_ui3.ScrollArea.Thumb, null)))));
375
+ };
376
+ var ThreadSettings = ({ settings }) => {
377
+ const { t } = (0, import_react_ui4.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
378
+ return /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(import_plugin_settings.SettingsValue, {
379
+ label: t("settings standalone label")
380
+ }, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.Input.Switch, {
381
+ checked: settings.standalone,
382
+ onCheckedChange: (checked) => settings.standalone = !!checked
383
+ })));
384
+ };
385
+ var ThreadMain = import_react2.default.lazy(() => import("./ThreadMain-CO6I3DNX.cjs"));
386
+ var ThreadArticle = import_react2.default.lazy(() => import("./ThreadArticle-GH5UBWFU.cjs"));
387
+ var getName = (doc, anchor) => {
388
+ if (doc.content) {
389
+ const [start, end] = anchor.split(":");
390
+ return (0, import_echo5.getTextInRange)((0, import_echo5.createDocAccessor)(doc.content, [
391
+ "content"
392
+ ]), start, end);
393
+ }
394
+ };
395
+ var threads = (state, doc, dispatch) => {
396
+ const space = doc && (0, import_echo5.getSpace)(doc);
397
+ if (!doc || !space || !dispatch) {
398
+ return [
399
+ (0, import_react_ui_editor2.comments)()
400
+ ];
401
+ }
402
+ const threads2 = (0, import_signals_core.computed)(() => [
403
+ ...doc.threads.filter(import_util3.nonNullable),
404
+ ...state.drafts[(0, import_echo5.fullyQualifiedId)(doc)] ?? []
405
+ ].filter((thread) => !(thread?.status === "resolved")));
406
+ return [
407
+ import_view.EditorView.updateListener.of((update) => {
408
+ if (update.docChanged) {
409
+ doc.threads.forEach((thread) => {
410
+ if (thread?.anchor) {
411
+ const name = getName(doc, thread.anchor);
412
+ if (name && name !== thread.name) {
413
+ thread.name = name;
414
+ }
415
+ }
416
+ });
417
+ }
418
+ }),
419
+ (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) => ({
420
+ id: (0, import_echo5.fullyQualifiedId)(thread),
421
+ cursor: thread.anchor
422
+ }))),
423
+ (0, import_react_ui_editor2.comments)({
424
+ id: (0, import_echo5.fullyQualifiedId)(doc),
425
+ onCreate: ({ cursor }) => {
426
+ const name = getName(doc, cursor);
427
+ void dispatch({
428
+ action: import_chunk_FOZUQZF4.ThreadAction.CREATE,
429
+ data: {
430
+ cursor,
431
+ name,
432
+ subject: doc
433
+ }
434
+ });
435
+ },
436
+ onDelete: ({ id }) => {
437
+ const draft = state.drafts[(0, import_echo5.fullyQualifiedId)(doc)];
438
+ if (draft) {
439
+ const index = draft.findIndex((thread2) => (0, import_echo5.fullyQualifiedId)(thread2) === id);
440
+ if (index !== -1) {
441
+ draft.splice(index, 1);
442
+ }
443
+ }
444
+ const thread = doc.threads.find((thread2) => thread2?.id === id);
445
+ if (thread) {
446
+ thread.anchor = void 0;
447
+ }
448
+ },
449
+ onUpdate: ({ id, cursor }) => {
450
+ const thread = state.drafts[(0, import_echo5.fullyQualifiedId)(doc)]?.find((thread2) => (0, import_echo5.fullyQualifiedId)(thread2) === id) ?? doc.threads.find((thread2) => thread2?.id === id);
451
+ if (thread instanceof import_types3.ThreadType && thread.anchor) {
452
+ thread.name = getName(doc, thread.anchor);
453
+ thread.anchor = cursor;
454
+ }
455
+ },
456
+ onSelect: ({ selection: { current, closest } }) => {
457
+ void dispatch({
458
+ action: import_chunk_FOZUQZF4.ThreadAction.SELECT,
459
+ data: {
460
+ current: current ?? closest,
461
+ skipOpen: true
462
+ }
463
+ });
464
+ }
465
+ })
466
+ ];
384
467
  };
385
468
  var translations_default = [
386
469
  {
387
470
  "en-US": {
388
- [import_chunk_6EVXCSDS.THREAD_PLUGIN]: {
471
+ [import_chunk_JIJ7Z6NO.THREAD_PLUGIN]: {
389
472
  "plugin name": "Threads",
390
473
  "channel name placeholder": "New channel",
391
474
  "channel title label": "Title",
@@ -421,11 +504,11 @@ var initialViewState = {
421
504
  showResolvedThreads: false
422
505
  };
423
506
  var ThreadPlugin = () => {
424
- const settings = new import_local_storage.LocalStorageStore(import_chunk_6EVXCSDS.THREAD_PLUGIN);
425
- const state = (0, import_echo_schema2.create)({
426
- staging: {}
507
+ const settings = new import_local_storage.LocalStorageStore(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
508
+ const state = (0, import_echo_schema.create)({
509
+ drafts: {}
427
510
  });
428
- const viewStore = (0, import_echo_schema2.create)({});
511
+ const viewStore = (0, import_echo_schema.create)({});
429
512
  const getViewState = (subjectId) => {
430
513
  if (!viewStore[subjectId]) {
431
514
  viewStore[subjectId] = {
@@ -438,7 +521,7 @@ var ThreadPlugin = () => {
438
521
  let intentPlugin;
439
522
  const unsubscribeCallbacks = [];
440
523
  return {
441
- meta: import_chunk_6EVXCSDS.meta_default,
524
+ meta: import_chunk_JIJ7Z6NO.meta_default,
442
525
  ready: async (plugins) => {
443
526
  settings.prop({
444
527
  key: "standalone",
@@ -460,7 +543,7 @@ var ThreadPlugin = () => {
460
543
  placeholder: [
461
544
  "channel title placeholder",
462
545
  {
463
- ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
546
+ ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
464
547
  }
465
548
  ],
466
549
  icon: "ph--chat--regular",
@@ -475,7 +558,7 @@ var ThreadPlugin = () => {
475
558
  // TODO(wittjosiah): Move out of metadata.
476
559
  loadReferences: (message) => []
477
560
  },
478
- [import_chunk_6EVXCSDS.THREAD_ITEM]: {
561
+ [import_chunk_JIJ7Z6NO.THREAD_ITEM]: {
479
562
  parse: (item, type) => {
480
563
  switch (type) {
481
564
  case "node":
@@ -517,13 +600,13 @@ var ThreadPlugin = () => {
517
600
  }
518
601
  return [
519
602
  (0, import_plugin_graph.createExtension)({
520
- id: `${import_chunk_6EVXCSDS.THREAD_PLUGIN}/comments-for-subject`,
603
+ id: `${import_chunk_JIJ7Z6NO.THREAD_PLUGIN}/comments-for-subject`,
521
604
  resolver: ({ id }) => {
522
605
  if (!id.endsWith("~comments")) {
523
606
  return;
524
607
  }
525
- const subjectId = id.split("~").at(0);
526
- const [spaceId, objectId] = subjectId?.split(":") ?? [];
608
+ const [subjectId] = id.split("~");
609
+ const [spaceId, objectId] = (0, import_echo.parseFullyQualifiedId)(subjectId);
527
610
  const space = client.spaces.get().find((space2) => space2.id === spaceId);
528
611
  const object = (0, import_plugin_graph.toSignal)((onChange) => {
529
612
  const timeout = setTimeout(async () => {
@@ -539,7 +622,7 @@ var ThreadPlugin = () => {
539
622
  const label = meta.label?.(object) || object.name || meta.placeholder || [
540
623
  "unnamed object threads label",
541
624
  {
542
- ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
625
+ ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
543
626
  }
544
627
  ];
545
628
  const viewState = getViewState(subjectId);
@@ -579,13 +662,13 @@ var ThreadPlugin = () => {
579
662
  };
580
663
  return [
581
664
  {
582
- id: `${import_chunk_6EVXCSDS.THREAD_PLUGIN}/toggle-show-resolved/${node.id}`,
665
+ id: `${import_chunk_JIJ7Z6NO.THREAD_PLUGIN}/toggle-show-resolved/${node.id}`,
583
666
  data: toggle,
584
667
  properties: {
585
668
  label: [
586
669
  "toggle show resolved",
587
670
  {
588
- ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
671
+ ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
589
672
  }
590
673
  ],
591
674
  menuItemType: "toggle",
@@ -598,7 +681,7 @@ var ThreadPlugin = () => {
598
681
  }
599
682
  }),
600
683
  (0, import_plugin_graph.createExtension)({
601
- id: import_chunk_FXD3DYMO.ThreadAction.CREATE,
684
+ id: import_chunk_FOZUQZF4.ThreadAction.CREATE,
602
685
  filter: (node) => !!settings.values.standalone && (0, import_plugin_graph.isActionGroup)(node) && node.id.startsWith(import_plugin_space.SpaceAction.ADD_OBJECT),
603
686
  actions: ({ node }) => {
604
687
  const id = node.id.split("/").at(-1);
@@ -611,12 +694,12 @@ var ThreadPlugin = () => {
611
694
  }
612
695
  return [
613
696
  {
614
- id: `${import_chunk_6EVXCSDS.THREAD_PLUGIN}/create/${node.id}`,
697
+ id: `${import_chunk_JIJ7Z6NO.THREAD_PLUGIN}/create/${node.id}`,
615
698
  data: async () => {
616
699
  await dispatch([
617
700
  {
618
- plugin: import_chunk_6EVXCSDS.THREAD_PLUGIN,
619
- action: import_chunk_FXD3DYMO.ThreadAction.CREATE
701
+ plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
702
+ action: import_chunk_FOZUQZF4.ThreadAction.CREATE
620
703
  },
621
704
  {
622
705
  action: import_plugin_space.SpaceAction.ADD_OBJECT,
@@ -633,7 +716,7 @@ var ThreadPlugin = () => {
633
716
  label: [
634
717
  "create channel label",
635
718
  {
636
- ns: import_chunk_6EVXCSDS.THREAD_PLUGIN
719
+ ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
637
720
  }
638
721
  ],
639
722
  icon: "ph--chat--regular",
@@ -655,12 +738,11 @@ var ThreadPlugin = () => {
655
738
  }) : null;
656
739
  }
657
740
  case "settings": {
658
- return data.plugin === import_chunk_6EVXCSDS.meta_default.id ? /* @__PURE__ */ import_react.default.createElement(ThreadSettings, {
741
+ return data.plugin === import_chunk_JIJ7Z6NO.meta_default.id ? /* @__PURE__ */ import_react.default.createElement(ThreadSettings, {
659
742
  settings: settings.values
660
743
  }) : null;
661
744
  }
662
- case "article":
663
- case "complementary": {
745
+ case "article": {
664
746
  const location = navigationPlugin?.provides.location;
665
747
  if (data.object instanceof import_types.ChannelType && data.object.threads[0]) {
666
748
  const channel = data.object;
@@ -681,22 +763,26 @@ var ThreadPlugin = () => {
681
763
  });
682
764
  }
683
765
  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, {
766
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_chunk_FDYRG7HE.ChatHeading, {
685
767
  attendableId: data.subject.id
686
- }), /* @__PURE__ */ import_react.default.createElement(import_chunk_PZVUW4W2.ChatContainer, {
768
+ }), /* @__PURE__ */ import_react.default.createElement(import_chunk_FDYRG7HE.ChatContainer, {
687
769
  thread: data.subject
688
770
  }));
689
771
  }
772
+ break;
773
+ }
774
+ case "complementary--comments": {
690
775
  if (data.subject && typeof data.subject === "object" && "threads" in data.subject && Array.isArray(data.subject.threads)) {
691
776
  const { showResolvedThreads } = getViewState((0, import_echo.fullyQualifiedId)(data.subject));
692
777
  return /* @__PURE__ */ import_react.default.createElement(ThreadComplementary, {
693
778
  role,
694
779
  subject: data.subject,
695
- stagedThreads: state.staging[(0, import_echo.fullyQualifiedId)(data.subject)],
780
+ drafts: state.drafts[(0, import_echo.fullyQualifiedId)(data.subject)],
696
781
  current: state.current,
697
782
  showResolvedThreads
698
783
  });
699
784
  }
785
+ break;
700
786
  }
701
787
  }
702
788
  return null;
@@ -705,16 +791,16 @@ var ThreadPlugin = () => {
705
791
  intent: {
706
792
  resolver: async (intent) => {
707
793
  switch (intent.action) {
708
- case import_chunk_FXD3DYMO.ThreadAction.CREATE: {
794
+ case import_chunk_FOZUQZF4.ThreadAction.CREATE: {
709
795
  if (intent.data && intent.data.cursor !== void 0) {
710
796
  const { cursor, name, subject } = intent.data;
711
797
  if (subject?.threads === void 0) {
712
798
  try {
713
799
  subject.threads = [];
714
- } catch (e) {
800
+ } catch (err) {
715
801
  import_log.log.error("Subject does not support threads array", subject?.typename, {
716
802
  F: __dxlog_file,
717
- L: 331,
803
+ L: 327,
718
804
  S: void 0,
719
805
  C: (f, a) => f(...a)
720
806
  });
@@ -722,17 +808,17 @@ var ThreadPlugin = () => {
722
808
  }
723
809
  }
724
810
  const subjectId = (0, import_echo.fullyQualifiedId)(subject);
725
- const thread = (0, import_echo_schema2.create)(import_types.ThreadType, {
811
+ const thread = (0, import_echo_schema.create)(import_types.ThreadType, {
726
812
  name,
727
813
  anchor: cursor,
728
814
  messages: [],
729
815
  status: "staged"
730
816
  });
731
- const stagingArea = state.staging[subjectId];
732
- if (stagingArea) {
733
- stagingArea.push(thread);
817
+ const draft = state.drafts[subjectId];
818
+ if (draft) {
819
+ draft.push(thread);
734
820
  } else {
735
- state.staging[subjectId] = [
821
+ state.drafts[subjectId] = [
736
822
  thread
737
823
  ];
738
824
  }
@@ -741,17 +827,19 @@ var ThreadPlugin = () => {
741
827
  intents: [
742
828
  [
743
829
  {
744
- action: import_chunk_FXD3DYMO.ThreadAction.SELECT,
830
+ action: import_chunk_FOZUQZF4.ThreadAction.SELECT,
745
831
  data: {
746
832
  current: (0, import_echo.fullyQualifiedId)(thread)
747
833
  }
748
- },
834
+ }
835
+ ],
836
+ [
749
837
  {
750
- action: import_app_framework.LayoutAction.SET_LAYOUT,
838
+ action: import_app_framework.NavigationAction.OPEN,
751
839
  data: {
752
- element: "complementary",
753
- subject: subjectId,
754
- state: true
840
+ activeParts: {
841
+ complementary: "comments"
842
+ }
755
843
  }
756
844
  }
757
845
  ]
@@ -759,9 +847,9 @@ var ThreadPlugin = () => {
759
847
  };
760
848
  } else {
761
849
  return {
762
- data: (0, import_echo_schema2.create)(import_types.ChannelType, {
850
+ data: (0, import_echo_schema.create)(import_types.ChannelType, {
763
851
  threads: [
764
- (0, import_echo_schema2.create)(import_types.ThreadType, {
852
+ (0, import_echo_schema.create)(import_types.ThreadType, {
765
853
  messages: []
766
854
  })
767
855
  ]
@@ -769,13 +857,25 @@ var ThreadPlugin = () => {
769
857
  };
770
858
  }
771
859
  }
772
- case import_chunk_FXD3DYMO.ThreadAction.SELECT: {
860
+ case import_chunk_FOZUQZF4.ThreadAction.SELECT: {
773
861
  state.current = intent.data?.current;
774
862
  return {
775
- data: true
863
+ data: true,
864
+ intents: !intent.data?.skipOpen ? [
865
+ [
866
+ {
867
+ action: import_app_framework.NavigationAction.OPEN,
868
+ data: {
869
+ activeParts: {
870
+ complementary: "comments"
871
+ }
872
+ }
873
+ }
874
+ ]
875
+ ] : []
776
876
  };
777
877
  }
778
- case import_chunk_FXD3DYMO.ThreadAction.TOGGLE_RESOLVED: {
878
+ case import_chunk_FOZUQZF4.ThreadAction.TOGGLE_RESOLVED: {
779
879
  const { thread } = intent.data ?? {};
780
880
  if (!(thread instanceof import_types.ThreadType)) {
781
881
  return;
@@ -788,6 +888,7 @@ var ThreadPlugin = () => {
788
888
  const space = (0, import_echo.getSpace)(thread);
789
889
  const spaceId = space?.id;
790
890
  return {
891
+ data: true,
791
892
  intents: [
792
893
  [
793
894
  {
@@ -804,17 +905,17 @@ var ThreadPlugin = () => {
804
905
  ]
805
906
  };
806
907
  }
807
- case import_chunk_FXD3DYMO.ThreadAction.DELETE: {
908
+ case import_chunk_FOZUQZF4.ThreadAction.DELETE: {
808
909
  const { subject, thread } = intent.data ?? {};
809
910
  if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject)) {
810
911
  return;
811
912
  }
812
913
  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);
914
+ const draft = state.drafts[subjectId];
915
+ if (draft) {
916
+ const index = draft.findIndex((t) => t.id === thread.id);
816
917
  if (index !== -1) {
817
- stagingArea.splice(index, 1);
918
+ draft.splice(index, 1);
818
919
  return {
819
920
  data: true
820
921
  };
@@ -833,7 +934,7 @@ var ThreadPlugin = () => {
833
934
  space.db.remove(thread);
834
935
  return {
835
936
  undoable: {
836
- message: translations_default[0]["en-US"][import_chunk_6EVXCSDS.THREAD_PLUGIN]["thread deleted label"],
937
+ message: translations_default[0]["en-US"][import_chunk_JIJ7Z6NO.THREAD_PLUGIN]["thread deleted label"],
837
938
  data: {
838
939
  cursor
839
940
  }
@@ -876,7 +977,7 @@ var ThreadPlugin = () => {
876
977
  }
877
978
  break;
878
979
  }
879
- case import_chunk_FXD3DYMO.ThreadAction.ON_MESSAGE_ADD: {
980
+ case import_chunk_FOZUQZF4.ThreadAction.ON_MESSAGE_ADD: {
880
981
  const { thread, subject } = intent.data ?? {};
881
982
  if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject && Array.isArray(subject.threads))) {
882
983
  return;
@@ -888,12 +989,12 @@ var ThreadPlugin = () => {
888
989
  threadId: thread.id,
889
990
  spaceId: space?.id
890
991
  };
891
- if (state.staging[subjectId]?.find((t) => t === thread)) {
992
+ if (state.drafts[subjectId]?.find((t) => t === thread)) {
892
993
  thread.status = "active";
893
994
  subject.threads ? subject.threads.push(thread) : subject.threads = [
894
995
  thread
895
996
  ];
896
- state.staging[subjectId] = state.staging[subjectId]?.filter((t) => t.id !== thread.id);
997
+ state.drafts[subjectId] = state.drafts[subjectId]?.filter(({ id }) => id !== thread.id);
897
998
  intents.push({
898
999
  action: import_meta.ObservabilityAction.SEND_EVENT,
899
1000
  data: {
@@ -919,7 +1020,7 @@ var ThreadPlugin = () => {
919
1020
  ]
920
1021
  };
921
1022
  }
922
- case import_chunk_FXD3DYMO.ThreadAction.DELETE_MESSAGE: {
1023
+ case import_chunk_FOZUQZF4.ThreadAction.DELETE_MESSAGE: {
923
1024
  const { subject, thread, messageId } = intent.data ?? {};
924
1025
  const space = (0, import_echo.getSpace)(subject);
925
1026
  if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject)) {
@@ -936,7 +1037,7 @@ var ThreadPlugin = () => {
936
1037
  intents: [
937
1038
  [
938
1039
  {
939
- action: import_chunk_FXD3DYMO.ThreadAction.DELETE,
1040
+ action: import_chunk_FOZUQZF4.ThreadAction.DELETE,
940
1041
  data: {
941
1042
  subject,
942
1043
  thread
@@ -950,7 +1051,7 @@ var ThreadPlugin = () => {
950
1051
  }
951
1052
  return {
952
1053
  undoable: {
953
- message: translations_default[0]["en-US"][import_chunk_6EVXCSDS.THREAD_PLUGIN]["message deleted label"],
1054
+ message: translations_default[0]["en-US"][import_chunk_JIJ7Z6NO.THREAD_PLUGIN]["message deleted label"],
954
1055
  data: {
955
1056
  message,
956
1057
  messageIndex
@@ -1001,92 +1102,8 @@ var ThreadPlugin = () => {
1001
1102
  }
1002
1103
  },
1003
1104
  markdown: {
1004
- // TODO(burdon): Factor out extension factory into separate file (for simplicity).
1005
1105
  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
- ];
1106
+ return threads(state, doc, intentPlugin?.provides.intent.dispatch);
1090
1107
  }
1091
1108
  }
1092
1109
  }