@dxos/plugin-thread 0.6.12-main.15a606f → 0.6.12-main.2d19bf1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{ThreadArticle-4VU752F4.mjs → ThreadArticle-GBPIH47W.mjs} +3 -3
- package/dist/lib/browser/{ThreadMain-ML3P4XSD.mjs → ThreadMain-PGF7W5EV.mjs} +3 -3
- package/dist/lib/browser/{chunk-7NUYW5IW.mjs → chunk-5G3KL6TC.mjs} +4 -6
- package/dist/lib/browser/chunk-5G3KL6TC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GJRBBPXI.mjs → chunk-JFQZ5W2I.mjs} +2 -2
- package/dist/lib/browser/{chunk-GJRBBPXI.mjs.map → chunk-JFQZ5W2I.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-XF5QKI75.mjs → chunk-O4YRHIZC.mjs} +2 -2
- package/dist/lib/browser/index.mjs +185 -196
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/types.mjs +2 -2
- package/dist/lib/node/{ThreadArticle-ERUHPHVT.cjs → ThreadArticle-GH5UBWFU.cjs} +7 -7
- package/dist/lib/node/{ThreadMain-6DN7FDNB.cjs → ThreadMain-CO6I3DNX.cjs} +7 -7
- package/dist/lib/node/{chunk-PZVUW4W2.cjs → chunk-FDYRG7HE.cjs} +9 -9
- package/dist/lib/node/{chunk-FXD3DYMO.cjs → chunk-FOZUQZF4.cjs} +6 -6
- package/dist/lib/node/{chunk-FXD3DYMO.cjs.map → chunk-FOZUQZF4.cjs.map} +1 -1
- package/dist/lib/node/{chunk-6EVXCSDS.cjs → chunk-JIJ7Z6NO.cjs} +6 -8
- package/dist/lib/node/chunk-JIJ7Z6NO.cjs.map +7 -0
- package/dist/lib/node/index.cjs +207 -220
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.cjs +4 -4
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +3 -3
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{ThreadArticle-NKI5F4W5.mjs → ThreadArticle-ZTYD52TR.mjs} +3 -3
- package/dist/lib/node-esm/{ThreadMain-2A3VQLCW.mjs → ThreadMain-LEHGOF7R.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-Y475KZTX.mjs → chunk-DC5ZA6H5.mjs} +4 -6
- package/dist/lib/node-esm/chunk-DC5ZA6H5.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-A44C4MTQ.mjs → chunk-XOVJ65DG.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-YO46JGAE.mjs → chunk-ZXIPFXSA.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-YO46JGAE.mjs.map → chunk-ZXIPFXSA.mjs.map} +1 -1
- package/dist/lib/node-esm/index.mjs +185 -196
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +1 -1
- package/dist/lib/node-esm/types.mjs +2 -2
- package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CommentContainer.d.ts +1 -1
- package/dist/types/src/components/CommentContainer.d.ts.map +1 -1
- package/dist/types/src/components/CommentsContainer.d.ts +1 -5
- package/dist/types/src/components/CommentsContainer.d.ts.map +1 -1
- package/dist/types/src/components/ThreadComplementary.d.ts +2 -3
- package/dist/types/src/components/ThreadComplementary.d.ts.map +1 -1
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/extensions/threads.d.ts +9 -0
- package/dist/types/src/extensions/threads.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +3 -6
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +5 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +31 -31
- package/src/ThreadPlugin.tsx +58 -142
- package/src/components/CommentContainer.tsx +8 -12
- package/src/components/CommentsContainer.tsx +1 -18
- package/src/components/ThreadComplementary.tsx +9 -16
- package/src/extensions/index.ts +5 -0
- package/src/extensions/threads.ts +117 -0
- package/src/{meta.tsx → meta.ts} +3 -4
- package/src/types.ts +7 -2
- package/dist/lib/browser/chunk-7NUYW5IW.mjs.map +0 -7
- package/dist/lib/node/chunk-6EVXCSDS.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y475KZTX.mjs.map +0 -7
- /package/dist/lib/browser/{ThreadArticle-4VU752F4.mjs.map → ThreadArticle-GBPIH47W.mjs.map} +0 -0
- /package/dist/lib/browser/{ThreadMain-ML3P4XSD.mjs.map → ThreadMain-PGF7W5EV.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-XF5QKI75.mjs.map → chunk-O4YRHIZC.mjs.map} +0 -0
- /package/dist/lib/node/{ThreadArticle-ERUHPHVT.cjs.map → ThreadArticle-GH5UBWFU.cjs.map} +0 -0
- /package/dist/lib/node/{ThreadMain-6DN7FDNB.cjs.map → ThreadMain-CO6I3DNX.cjs.map} +0 -0
- /package/dist/lib/node/{chunk-PZVUW4W2.cjs.map → chunk-FDYRG7HE.cjs.map} +0 -0
- /package/dist/lib/node-esm/{ThreadArticle-NKI5F4W5.mjs.map → ThreadArticle-ZTYD52TR.mjs.map} +0 -0
- /package/dist/lib/node-esm/{ThreadMain-2A3VQLCW.mjs.map → ThreadMain-LEHGOF7R.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-A44C4MTQ.mjs.map → chunk-XOVJ65DG.mjs.map} +0 -0
package/dist/lib/node/index.cjs
CHANGED
|
@@ -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: () =>
|
|
31
|
+
ThreadAction: () => import_chunk_FOZUQZF4.ThreadAction,
|
|
32
32
|
ThreadPlugin: () => ThreadPlugin,
|
|
33
33
|
default: () => src_default,
|
|
34
|
-
useAnalyticsCallback: () =>
|
|
35
|
-
useOnEditAnalytics: () =>
|
|
36
|
-
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
|
|
40
|
-
var
|
|
41
|
-
var
|
|
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,24 +63,29 @@ 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
|
|
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
|
|
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");
|
|
76
73
|
var import_react_ui3 = require("@dxos/react-ui");
|
|
77
|
-
var import_react_ui_deck = require("@dxos/react-ui-deck");
|
|
78
74
|
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
79
75
|
var import_react8 = __toESM(require("react"));
|
|
80
76
|
var import_app_framework2 = require("@dxos/app-framework");
|
|
81
77
|
var import_echo4 = require("@dxos/react-client/echo");
|
|
82
78
|
var import_react_ui4 = require("@dxos/react-ui");
|
|
83
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");
|
|
84
86
|
var import_util3 = require("@dxos/util");
|
|
85
87
|
var ThreadSettings = ({ settings }) => {
|
|
86
|
-
const { t } = (0, import_react_ui.useTranslation)(
|
|
88
|
+
const { t } = (0, import_react_ui.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
|
|
87
89
|
return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(import_plugin_settings.SettingsValue, {
|
|
88
90
|
label: t("settings standalone label")
|
|
89
91
|
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui.Input.Switch, {
|
|
@@ -93,7 +95,7 @@ var ThreadSettings = ({ settings }) => {
|
|
|
93
95
|
};
|
|
94
96
|
var sizeClass = (0, import_react_ui_theme.getSize)(4);
|
|
95
97
|
var ToggleResolvedButton = ({ isResolved, onResolve }) => {
|
|
96
|
-
const { t } = (0, import_react_ui2.useTranslation)(
|
|
98
|
+
const { t } = (0, import_react_ui2.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
|
|
97
99
|
const label = t(isResolved ? "mark as unresolved label" : "mark as resolved label");
|
|
98
100
|
return /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
|
|
99
101
|
asChild: true
|
|
@@ -117,7 +119,7 @@ var ToggleResolvedButton = ({ isResolved, onResolve }) => {
|
|
|
117
119
|
}, label, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Arrow, null))));
|
|
118
120
|
};
|
|
119
121
|
var DeleteThreadButton = ({ onDelete }) => {
|
|
120
|
-
const { t } = (0, import_react_ui2.useTranslation)(
|
|
122
|
+
const { t } = (0, import_react_ui2.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
|
|
121
123
|
const label = t("delete thread label");
|
|
122
124
|
return /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
|
|
123
125
|
asChild: true
|
|
@@ -137,38 +139,32 @@ var DeleteThreadButton = ({ onDelete }) => {
|
|
|
137
139
|
classNames: "z-[21]"
|
|
138
140
|
}, label, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Arrow, null))));
|
|
139
141
|
};
|
|
140
|
-
var CommentContainer = ({ thread, detached, context, current,
|
|
142
|
+
var CommentContainer = ({ thread, detached, context, current, onAttend, onThreadDelete, onMessageDelete, onResolve, onComment }) => {
|
|
141
143
|
const identity = (0, import_halo.useIdentity)();
|
|
142
144
|
const space = (0, import_echo2.getSpace)(thread);
|
|
143
145
|
const members = (0, import_echo2.useMembers)(space?.key);
|
|
144
|
-
const activity = (0,
|
|
145
|
-
const { t } = (0, import_react_ui2.useTranslation)(
|
|
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);
|
|
146
148
|
const threadScrollRef = (0, import_react5.useRef)(null);
|
|
147
|
-
const [autoFocus, setAutoFocus] = (0, import_react5.useState)(!!autoFocusTextbox);
|
|
148
149
|
const { themeMode } = (0, import_react_ui2.useThemeContext)();
|
|
149
|
-
const textboxMetadata = (0,
|
|
150
|
+
const textboxMetadata = (0, import_chunk_FDYRG7HE.getMessageMetadata)((0, import_echo2.fullyQualifiedId)(thread), identity);
|
|
150
151
|
const [_count, _setCount] = (0, import_react5.useState)(0);
|
|
151
152
|
const rerenderEditor = () => _setCount((count) => count + 1);
|
|
152
153
|
const messageRef = (0, import_react5.useRef)("");
|
|
153
154
|
const extensions = (0, import_react5.useMemo)(() => [
|
|
154
|
-
(0,
|
|
155
|
+
(0, import_react_ui_editor.createBasicExtensions)({
|
|
155
156
|
placeholder: t("message placeholder")
|
|
156
157
|
}),
|
|
157
|
-
(0,
|
|
158
|
+
(0, import_react_ui_editor.createThemeExtensions)({
|
|
158
159
|
themeMode
|
|
159
160
|
}),
|
|
160
|
-
(0,
|
|
161
|
+
(0, import_react_ui_editor.listener)({
|
|
161
162
|
onChange: (text) => messageRef.current = text
|
|
162
163
|
}),
|
|
163
|
-
|
|
164
|
+
import_chunk_FDYRG7HE.command
|
|
164
165
|
], [
|
|
165
166
|
_count
|
|
166
167
|
]);
|
|
167
|
-
(0, import_react5.useEffect)(() => {
|
|
168
|
-
setAutoFocus(!!autoFocusTextbox);
|
|
169
|
-
}, [
|
|
170
|
-
autoFocusTextbox
|
|
171
|
-
]);
|
|
172
168
|
const scrollToEnd = (behavior) => setTimeout(() => threadScrollRef.current?.scrollIntoView({
|
|
173
169
|
behavior,
|
|
174
170
|
block: "end"
|
|
@@ -187,7 +183,6 @@ var CommentContainer = ({ thread, detached, context, current, autoFocusTextbox,
|
|
|
187
183
|
}));
|
|
188
184
|
onComment?.(thread);
|
|
189
185
|
messageRef.current = "";
|
|
190
|
-
setAutoFocus(true);
|
|
191
186
|
scrollToEnd("instant");
|
|
192
187
|
rerenderEditor();
|
|
193
188
|
return true;
|
|
@@ -219,14 +214,13 @@ var CommentContainer = ({ thread, detached, context, current, autoFocusTextbox,
|
|
|
219
214
|
onResolve
|
|
220
215
|
}), onThreadDelete && /* @__PURE__ */ import_react5.default.createElement(DeleteThreadButton, {
|
|
221
216
|
onDelete: onThreadDelete
|
|
222
|
-
}))), thread.messages.filter(
|
|
217
|
+
}))), thread.messages.filter(import_util.nonNullable).map((message) => /* @__PURE__ */ import_react5.default.createElement(import_chunk_FDYRG7HE.MessageContainer, {
|
|
223
218
|
key: message.id,
|
|
224
219
|
message,
|
|
225
220
|
members,
|
|
226
221
|
onDelete: (id) => onMessageDelete?.(id)
|
|
227
222
|
})), /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.MessageTextbox, {
|
|
228
223
|
extensions,
|
|
229
|
-
autoFocus,
|
|
230
224
|
onSend: handleCreate,
|
|
231
225
|
...textboxMetadata
|
|
232
226
|
}), /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.ThreadFooter, {
|
|
@@ -237,23 +231,9 @@ var CommentContainer = ({ thread, detached, context, current, autoFocusTextbox,
|
|
|
237
231
|
ref: threadScrollRef
|
|
238
232
|
}));
|
|
239
233
|
};
|
|
240
|
-
var
|
|
241
|
-
const { t } = (0, import_react_ui3.useTranslation)(
|
|
242
|
-
|
|
243
|
-
role: "none",
|
|
244
|
-
className: "flex items-center"
|
|
245
|
-
}, /* @__PURE__ */ import_react7.default.createElement(import_react_ui_deck.PlankHeading.Button, {
|
|
246
|
-
attendableId
|
|
247
|
-
}, /* @__PURE__ */ import_react7.default.createElement(import_react_ui3.Icon, {
|
|
248
|
-
icon: "ph--quotes--regular",
|
|
249
|
-
size: 5
|
|
250
|
-
})), /* @__PURE__ */ import_react7.default.createElement(import_react_ui_deck.PlankHeading.Label, {
|
|
251
|
-
attendableId
|
|
252
|
-
}, t("comments heading")));
|
|
253
|
-
};
|
|
254
|
-
var CommentsContainer = ({ threads, detached = [], currentId, autoFocusCurrentTextbox, showResolvedThreads, onThreadAttend, onThreadDelete, onMessageDelete, onThreadToggleResolved, ...props }) => {
|
|
255
|
-
const { t } = (0, import_react_ui3.useTranslation)(import_chunk_6EVXCSDS.THREAD_PLUGIN);
|
|
256
|
-
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"));
|
|
257
237
|
(0, import_react7.useEffect)(() => {
|
|
258
238
|
if (currentId) {
|
|
259
239
|
document.getElementById(currentId)?.scrollIntoView({
|
|
@@ -271,7 +251,6 @@ var CommentsContainer = ({ threads, detached = [], currentId, autoFocusCurrentTe
|
|
|
271
251
|
thread,
|
|
272
252
|
current: currentId === threadId,
|
|
273
253
|
detached: detached.includes(threadId),
|
|
274
|
-
autoFocusTextbox: autoFocusCurrentTextbox && currentId === threadId,
|
|
275
254
|
...onThreadAttend && {
|
|
276
255
|
onAttend: () => onThreadAttend(thread)
|
|
277
256
|
},
|
|
@@ -301,10 +280,10 @@ var CommentsContainer = ({ threads, detached = [], currentId, autoFocusCurrentTe
|
|
|
301
280
|
}
|
|
302
281
|
}))));
|
|
303
282
|
};
|
|
304
|
-
var ThreadMain = import_react2.default.lazy(() => import("./ThreadMain-
|
|
305
|
-
var ThreadArticle = import_react2.default.lazy(() => import("./ThreadArticle-
|
|
283
|
+
var ThreadMain = import_react2.default.lazy(() => import("./ThreadMain-CO6I3DNX.cjs"));
|
|
284
|
+
var ThreadArticle = import_react2.default.lazy(() => import("./ThreadArticle-GH5UBWFU.cjs"));
|
|
306
285
|
var providesThreadsConfig = (plugin) => "thread" in plugin.provides ? plugin : void 0;
|
|
307
|
-
var ThreadComplementary = ({ role, subject,
|
|
286
|
+
var ThreadComplementary = ({ role, subject, drafts, current, showResolvedThreads }) => {
|
|
308
287
|
const dispatch = (0, import_app_framework2.useIntentDispatcher)();
|
|
309
288
|
const threadsIntegrators = (0, import_app_framework2.useResolvePlugins)(providesThreadsConfig);
|
|
310
289
|
const threadProvides = (0, import_react8.useMemo)(() => threadsIntegrators.map((p) => p.provides.thread), [
|
|
@@ -318,42 +297,37 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, focus, showR
|
|
|
318
297
|
createSort,
|
|
319
298
|
subject
|
|
320
299
|
]);
|
|
321
|
-
const
|
|
322
|
-
return subject.threads.concat(
|
|
300
|
+
const threads2 = (0, import_react8.useMemo)(() => {
|
|
301
|
+
return subject.threads.concat(drafts ?? []).filter(import_util2.nonNullable);
|
|
323
302
|
}, [
|
|
324
303
|
JSON.stringify(subject.threads),
|
|
325
|
-
JSON.stringify(
|
|
304
|
+
JSON.stringify(drafts)
|
|
326
305
|
]);
|
|
327
306
|
const detachedIds = (0, import_react8.useMemo)(() => {
|
|
328
|
-
return
|
|
307
|
+
return threads2.filter(({ anchor }) => !anchor).map((thread) => (0, import_echo4.fullyQualifiedId)(thread));
|
|
329
308
|
}, [
|
|
330
|
-
|
|
309
|
+
threads2
|
|
331
310
|
]);
|
|
332
311
|
(0, import_react8.useEffect)(() => {
|
|
333
312
|
if (!sort) {
|
|
334
313
|
return;
|
|
335
314
|
}
|
|
336
|
-
|
|
315
|
+
threads2.sort((a, b) => sort(a?.anchor, b?.anchor));
|
|
337
316
|
}, [
|
|
338
317
|
sort,
|
|
339
|
-
|
|
318
|
+
threads2
|
|
340
319
|
]);
|
|
341
|
-
const
|
|
320
|
+
const attended = (0, import_react_ui_attention.useAttended)();
|
|
342
321
|
const qualifiedSubjectId = (0, import_echo4.fullyQualifiedId)(subject);
|
|
343
|
-
const attendableAttrs = (0, import_react_ui_attention.createAttendableAttributes)(qualifiedSubjectId);
|
|
344
322
|
return /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
345
323
|
role: "none",
|
|
346
|
-
className: "contents
|
|
347
|
-
|
|
348
|
-
}, role === "complementary" && /* @__PURE__ */ import_react8.default.createElement(CommentsHeading, {
|
|
349
|
-
attendableId: qualifiedSubjectId
|
|
350
|
-
}), /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Root, {
|
|
324
|
+
className: "contents"
|
|
325
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Root, {
|
|
351
326
|
classNames: "row-span-2"
|
|
352
327
|
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Viewport, null, /* @__PURE__ */ import_react8.default.createElement(CommentsContainer, {
|
|
353
|
-
threads,
|
|
328
|
+
threads: threads2,
|
|
354
329
|
detached: detachedIds,
|
|
355
|
-
currentId: attended.
|
|
356
|
-
autoFocusCurrentTextbox: focus,
|
|
330
|
+
currentId: attended.includes(qualifiedSubjectId) ? current : void 0,
|
|
357
331
|
showResolvedThreads,
|
|
358
332
|
onThreadAttend: (thread) => {
|
|
359
333
|
const threadId = (0, import_echo4.fullyQualifiedId)(thread);
|
|
@@ -373,8 +347,8 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, focus, showR
|
|
|
373
347
|
},
|
|
374
348
|
onThreadDelete: (thread) => {
|
|
375
349
|
return dispatch({
|
|
376
|
-
plugin:
|
|
377
|
-
action:
|
|
350
|
+
plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
|
|
351
|
+
action: import_chunk_FOZUQZF4.ThreadAction.DELETE,
|
|
378
352
|
data: {
|
|
379
353
|
subject,
|
|
380
354
|
thread
|
|
@@ -382,8 +356,8 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, focus, showR
|
|
|
382
356
|
});
|
|
383
357
|
},
|
|
384
358
|
onMessageDelete: (thread, messageId) => dispatch({
|
|
385
|
-
plugin:
|
|
386
|
-
action:
|
|
359
|
+
plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
|
|
360
|
+
action: import_chunk_FOZUQZF4.ThreadAction.DELETE_MESSAGE,
|
|
387
361
|
data: {
|
|
388
362
|
subject,
|
|
389
363
|
thread,
|
|
@@ -391,15 +365,15 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, focus, showR
|
|
|
391
365
|
}
|
|
392
366
|
}),
|
|
393
367
|
onThreadToggleResolved: (thread) => dispatch({
|
|
394
|
-
plugin:
|
|
395
|
-
action:
|
|
368
|
+
plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
|
|
369
|
+
action: import_chunk_FOZUQZF4.ThreadAction.TOGGLE_RESOLVED,
|
|
396
370
|
data: {
|
|
397
371
|
thread
|
|
398
372
|
}
|
|
399
373
|
}),
|
|
400
374
|
onComment: (thread) => {
|
|
401
375
|
void dispatch({
|
|
402
|
-
action:
|
|
376
|
+
action: import_chunk_FOZUQZF4.ThreadAction.ON_MESSAGE_ADD,
|
|
403
377
|
data: {
|
|
404
378
|
thread,
|
|
405
379
|
subject
|
|
@@ -411,10 +385,91 @@ var ThreadComplementary = ({ role, subject, stagedThreads, current, focus, showR
|
|
|
411
385
|
className: "bs-10"
|
|
412
386
|
}), /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Scrollbar, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Thumb, null)))));
|
|
413
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
|
+
};
|
|
414
469
|
var translations_default = [
|
|
415
470
|
{
|
|
416
471
|
"en-US": {
|
|
417
|
-
[
|
|
472
|
+
[import_chunk_JIJ7Z6NO.THREAD_PLUGIN]: {
|
|
418
473
|
"plugin name": "Threads",
|
|
419
474
|
"channel name placeholder": "New channel",
|
|
420
475
|
"channel title label": "Title",
|
|
@@ -450,9 +505,9 @@ var initialViewState = {
|
|
|
450
505
|
showResolvedThreads: false
|
|
451
506
|
};
|
|
452
507
|
var ThreadPlugin = () => {
|
|
453
|
-
const settings = new import_local_storage.LocalStorageStore(
|
|
508
|
+
const settings = new import_local_storage.LocalStorageStore(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
|
|
454
509
|
const state = (0, import_echo_schema2.create)({
|
|
455
|
-
|
|
510
|
+
drafts: {}
|
|
456
511
|
});
|
|
457
512
|
const viewStore = (0, import_echo_schema2.create)({});
|
|
458
513
|
const getViewState = (subjectId) => {
|
|
@@ -467,7 +522,7 @@ var ThreadPlugin = () => {
|
|
|
467
522
|
let intentPlugin;
|
|
468
523
|
const unsubscribeCallbacks = [];
|
|
469
524
|
return {
|
|
470
|
-
meta:
|
|
525
|
+
meta: import_chunk_JIJ7Z6NO.meta_default,
|
|
471
526
|
ready: async (plugins) => {
|
|
472
527
|
settings.prop({
|
|
473
528
|
key: "standalone",
|
|
@@ -489,7 +544,7 @@ var ThreadPlugin = () => {
|
|
|
489
544
|
placeholder: [
|
|
490
545
|
"channel title placeholder",
|
|
491
546
|
{
|
|
492
|
-
ns:
|
|
547
|
+
ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
|
|
493
548
|
}
|
|
494
549
|
],
|
|
495
550
|
icon: "ph--chat--regular",
|
|
@@ -504,7 +559,7 @@ var ThreadPlugin = () => {
|
|
|
504
559
|
// TODO(wittjosiah): Move out of metadata.
|
|
505
560
|
loadReferences: (message) => []
|
|
506
561
|
},
|
|
507
|
-
[
|
|
562
|
+
[import_chunk_JIJ7Z6NO.THREAD_ITEM]: {
|
|
508
563
|
parse: (item, type) => {
|
|
509
564
|
switch (type) {
|
|
510
565
|
case "node":
|
|
@@ -546,7 +601,7 @@ var ThreadPlugin = () => {
|
|
|
546
601
|
}
|
|
547
602
|
return [
|
|
548
603
|
(0, import_plugin_graph.createExtension)({
|
|
549
|
-
id: `${
|
|
604
|
+
id: `${import_chunk_JIJ7Z6NO.THREAD_PLUGIN}/comments-for-subject`,
|
|
550
605
|
resolver: ({ id }) => {
|
|
551
606
|
if (!id.endsWith("~comments")) {
|
|
552
607
|
return;
|
|
@@ -560,7 +615,7 @@ var ThreadPlugin = () => {
|
|
|
560
615
|
onChange();
|
|
561
616
|
});
|
|
562
617
|
return () => clearTimeout(timeout);
|
|
563
|
-
}, () => space?.db.getObjectById(objectId));
|
|
618
|
+
}, () => space?.db.getObjectById(objectId), subjectId);
|
|
564
619
|
if (!object || !subjectId) {
|
|
565
620
|
return;
|
|
566
621
|
}
|
|
@@ -568,18 +623,19 @@ var ThreadPlugin = () => {
|
|
|
568
623
|
const label = meta.label?.(object) || object.name || meta.placeholder || [
|
|
569
624
|
"unnamed object threads label",
|
|
570
625
|
{
|
|
571
|
-
ns:
|
|
626
|
+
ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
|
|
572
627
|
}
|
|
573
628
|
];
|
|
574
629
|
const viewState = getViewState(subjectId);
|
|
575
630
|
return {
|
|
576
631
|
id,
|
|
577
632
|
type: "orphan-comments-for-subject",
|
|
578
|
-
data:
|
|
633
|
+
data: null,
|
|
579
634
|
properties: {
|
|
580
|
-
icon:
|
|
635
|
+
icon: "ph--chat-text--regular",
|
|
581
636
|
label,
|
|
582
|
-
showResolvedThreads: viewState.showResolvedThreads
|
|
637
|
+
showResolvedThreads: viewState.showResolvedThreads,
|
|
638
|
+
object
|
|
583
639
|
}
|
|
584
640
|
};
|
|
585
641
|
},
|
|
@@ -607,13 +663,13 @@ var ThreadPlugin = () => {
|
|
|
607
663
|
};
|
|
608
664
|
return [
|
|
609
665
|
{
|
|
610
|
-
id: `${
|
|
666
|
+
id: `${import_chunk_JIJ7Z6NO.THREAD_PLUGIN}/toggle-show-resolved/${node.id}`,
|
|
611
667
|
data: toggle,
|
|
612
668
|
properties: {
|
|
613
669
|
label: [
|
|
614
670
|
"toggle show resolved",
|
|
615
671
|
{
|
|
616
|
-
ns:
|
|
672
|
+
ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
|
|
617
673
|
}
|
|
618
674
|
],
|
|
619
675
|
menuItemType: "toggle",
|
|
@@ -626,7 +682,7 @@ var ThreadPlugin = () => {
|
|
|
626
682
|
}
|
|
627
683
|
}),
|
|
628
684
|
(0, import_plugin_graph.createExtension)({
|
|
629
|
-
id:
|
|
685
|
+
id: import_chunk_FOZUQZF4.ThreadAction.CREATE,
|
|
630
686
|
filter: (node) => !!settings.values.standalone && (0, import_plugin_graph.isActionGroup)(node) && node.id.startsWith(import_plugin_space.SpaceAction.ADD_OBJECT),
|
|
631
687
|
actions: ({ node }) => {
|
|
632
688
|
const id = node.id.split("/").at(-1);
|
|
@@ -639,12 +695,12 @@ var ThreadPlugin = () => {
|
|
|
639
695
|
}
|
|
640
696
|
return [
|
|
641
697
|
{
|
|
642
|
-
id: `${
|
|
698
|
+
id: `${import_chunk_JIJ7Z6NO.THREAD_PLUGIN}/create/${node.id}`,
|
|
643
699
|
data: async () => {
|
|
644
700
|
await dispatch([
|
|
645
701
|
{
|
|
646
|
-
plugin:
|
|
647
|
-
action:
|
|
702
|
+
plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
|
|
703
|
+
action: import_chunk_FOZUQZF4.ThreadAction.CREATE
|
|
648
704
|
},
|
|
649
705
|
{
|
|
650
706
|
action: import_plugin_space.SpaceAction.ADD_OBJECT,
|
|
@@ -661,7 +717,7 @@ var ThreadPlugin = () => {
|
|
|
661
717
|
label: [
|
|
662
718
|
"create channel label",
|
|
663
719
|
{
|
|
664
|
-
ns:
|
|
720
|
+
ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
|
|
665
721
|
}
|
|
666
722
|
],
|
|
667
723
|
icon: "ph--chat--regular",
|
|
@@ -683,12 +739,11 @@ var ThreadPlugin = () => {
|
|
|
683
739
|
}) : null;
|
|
684
740
|
}
|
|
685
741
|
case "settings": {
|
|
686
|
-
return data.plugin ===
|
|
742
|
+
return data.plugin === import_chunk_JIJ7Z6NO.meta_default.id ? /* @__PURE__ */ import_react.default.createElement(ThreadSettings, {
|
|
687
743
|
settings: settings.values
|
|
688
744
|
}) : null;
|
|
689
745
|
}
|
|
690
|
-
case "article":
|
|
691
|
-
case "complementary": {
|
|
746
|
+
case "article": {
|
|
692
747
|
const location = navigationPlugin?.provides.location;
|
|
693
748
|
if (data.object instanceof import_types.ChannelType && data.object.threads[0]) {
|
|
694
749
|
const channel = data.object;
|
|
@@ -709,23 +764,26 @@ var ThreadPlugin = () => {
|
|
|
709
764
|
});
|
|
710
765
|
}
|
|
711
766
|
if (data.subject instanceof import_types.ThreadType) {
|
|
712
|
-
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
|
|
767
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_chunk_FDYRG7HE.ChatHeading, {
|
|
713
768
|
attendableId: data.subject.id
|
|
714
|
-
}), /* @__PURE__ */ import_react.default.createElement(
|
|
769
|
+
}), /* @__PURE__ */ import_react.default.createElement(import_chunk_FDYRG7HE.ChatContainer, {
|
|
715
770
|
thread: data.subject
|
|
716
771
|
}));
|
|
717
772
|
}
|
|
773
|
+
break;
|
|
774
|
+
}
|
|
775
|
+
case "complementary--comments": {
|
|
718
776
|
if (data.subject && typeof data.subject === "object" && "threads" in data.subject && Array.isArray(data.subject.threads)) {
|
|
719
777
|
const { showResolvedThreads } = getViewState((0, import_echo.fullyQualifiedId)(data.subject));
|
|
720
778
|
return /* @__PURE__ */ import_react.default.createElement(ThreadComplementary, {
|
|
721
779
|
role,
|
|
722
780
|
subject: data.subject,
|
|
723
|
-
|
|
781
|
+
drafts: state.drafts[(0, import_echo.fullyQualifiedId)(data.subject)],
|
|
724
782
|
current: state.current,
|
|
725
|
-
focus: true,
|
|
726
783
|
showResolvedThreads
|
|
727
784
|
});
|
|
728
785
|
}
|
|
786
|
+
break;
|
|
729
787
|
}
|
|
730
788
|
}
|
|
731
789
|
return null;
|
|
@@ -734,16 +792,16 @@ var ThreadPlugin = () => {
|
|
|
734
792
|
intent: {
|
|
735
793
|
resolver: async (intent) => {
|
|
736
794
|
switch (intent.action) {
|
|
737
|
-
case
|
|
795
|
+
case import_chunk_FOZUQZF4.ThreadAction.CREATE: {
|
|
738
796
|
if (intent.data && intent.data.cursor !== void 0) {
|
|
739
797
|
const { cursor, name, subject } = intent.data;
|
|
740
798
|
if (subject?.threads === void 0) {
|
|
741
799
|
try {
|
|
742
800
|
subject.threads = [];
|
|
743
|
-
} catch (
|
|
801
|
+
} catch (err) {
|
|
744
802
|
import_log.log.error("Subject does not support threads array", subject?.typename, {
|
|
745
803
|
F: __dxlog_file,
|
|
746
|
-
L:
|
|
804
|
+
L: 322,
|
|
747
805
|
S: void 0,
|
|
748
806
|
C: (f, a) => f(...a)
|
|
749
807
|
});
|
|
@@ -757,11 +815,11 @@ var ThreadPlugin = () => {
|
|
|
757
815
|
messages: [],
|
|
758
816
|
status: "staged"
|
|
759
817
|
});
|
|
760
|
-
const
|
|
761
|
-
if (
|
|
762
|
-
|
|
818
|
+
const draft = state.drafts[subjectId];
|
|
819
|
+
if (draft) {
|
|
820
|
+
draft.push(thread);
|
|
763
821
|
} else {
|
|
764
|
-
state.
|
|
822
|
+
state.drafts[subjectId] = [
|
|
765
823
|
thread
|
|
766
824
|
];
|
|
767
825
|
}
|
|
@@ -770,18 +828,19 @@ var ThreadPlugin = () => {
|
|
|
770
828
|
intents: [
|
|
771
829
|
[
|
|
772
830
|
{
|
|
773
|
-
action:
|
|
831
|
+
action: import_chunk_FOZUQZF4.ThreadAction.SELECT,
|
|
774
832
|
data: {
|
|
775
|
-
current: (0, import_echo.fullyQualifiedId)(thread)
|
|
776
|
-
focus: true
|
|
833
|
+
current: (0, import_echo.fullyQualifiedId)(thread)
|
|
777
834
|
}
|
|
778
|
-
}
|
|
835
|
+
}
|
|
836
|
+
],
|
|
837
|
+
[
|
|
779
838
|
{
|
|
780
|
-
action: import_app_framework.
|
|
839
|
+
action: import_app_framework.NavigationAction.OPEN,
|
|
781
840
|
data: {
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
841
|
+
activeParts: {
|
|
842
|
+
complementary: "comments"
|
|
843
|
+
}
|
|
785
844
|
}
|
|
786
845
|
}
|
|
787
846
|
]
|
|
@@ -799,14 +858,25 @@ var ThreadPlugin = () => {
|
|
|
799
858
|
};
|
|
800
859
|
}
|
|
801
860
|
}
|
|
802
|
-
case
|
|
803
|
-
state.focus = intent.data?.current === state.current ? state.focus : intent.data?.focus;
|
|
861
|
+
case import_chunk_FOZUQZF4.ThreadAction.SELECT: {
|
|
804
862
|
state.current = intent.data?.current;
|
|
805
863
|
return {
|
|
806
|
-
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
|
+
] : []
|
|
807
877
|
};
|
|
808
878
|
}
|
|
809
|
-
case
|
|
879
|
+
case import_chunk_FOZUQZF4.ThreadAction.TOGGLE_RESOLVED: {
|
|
810
880
|
const { thread } = intent.data ?? {};
|
|
811
881
|
if (!(thread instanceof import_types.ThreadType)) {
|
|
812
882
|
return;
|
|
@@ -819,6 +889,7 @@ var ThreadPlugin = () => {
|
|
|
819
889
|
const space = (0, import_echo.getSpace)(thread);
|
|
820
890
|
const spaceId = space?.id;
|
|
821
891
|
return {
|
|
892
|
+
data: true,
|
|
822
893
|
intents: [
|
|
823
894
|
[
|
|
824
895
|
{
|
|
@@ -835,17 +906,17 @@ var ThreadPlugin = () => {
|
|
|
835
906
|
]
|
|
836
907
|
};
|
|
837
908
|
}
|
|
838
|
-
case
|
|
909
|
+
case import_chunk_FOZUQZF4.ThreadAction.DELETE: {
|
|
839
910
|
const { subject, thread } = intent.data ?? {};
|
|
840
911
|
if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject)) {
|
|
841
912
|
return;
|
|
842
913
|
}
|
|
843
914
|
const subjectId = (0, import_echo.fullyQualifiedId)(subject);
|
|
844
|
-
const
|
|
845
|
-
if (
|
|
846
|
-
const index =
|
|
915
|
+
const draft = state.drafts[subjectId];
|
|
916
|
+
if (draft) {
|
|
917
|
+
const index = draft.findIndex((t) => t.id === thread.id);
|
|
847
918
|
if (index !== -1) {
|
|
848
|
-
|
|
919
|
+
draft.splice(index, 1);
|
|
849
920
|
return {
|
|
850
921
|
data: true
|
|
851
922
|
};
|
|
@@ -864,7 +935,7 @@ var ThreadPlugin = () => {
|
|
|
864
935
|
space.db.remove(thread);
|
|
865
936
|
return {
|
|
866
937
|
undoable: {
|
|
867
|
-
message: translations_default[0]["en-US"][
|
|
938
|
+
message: translations_default[0]["en-US"][import_chunk_JIJ7Z6NO.THREAD_PLUGIN]["thread deleted label"],
|
|
868
939
|
data: {
|
|
869
940
|
cursor
|
|
870
941
|
}
|
|
@@ -907,7 +978,7 @@ var ThreadPlugin = () => {
|
|
|
907
978
|
}
|
|
908
979
|
break;
|
|
909
980
|
}
|
|
910
|
-
case
|
|
981
|
+
case import_chunk_FOZUQZF4.ThreadAction.ON_MESSAGE_ADD: {
|
|
911
982
|
const { thread, subject } = intent.data ?? {};
|
|
912
983
|
if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject && Array.isArray(subject.threads))) {
|
|
913
984
|
return;
|
|
@@ -919,12 +990,12 @@ var ThreadPlugin = () => {
|
|
|
919
990
|
threadId: thread.id,
|
|
920
991
|
spaceId: space?.id
|
|
921
992
|
};
|
|
922
|
-
if (state.
|
|
993
|
+
if (state.drafts[subjectId]?.find((t) => t === thread)) {
|
|
923
994
|
thread.status = "active";
|
|
924
995
|
subject.threads ? subject.threads.push(thread) : subject.threads = [
|
|
925
996
|
thread
|
|
926
997
|
];
|
|
927
|
-
state.
|
|
998
|
+
state.drafts[subjectId] = state.drafts[subjectId]?.filter(({ id }) => id !== thread.id);
|
|
928
999
|
intents.push({
|
|
929
1000
|
action: import_meta.ObservabilityAction.SEND_EVENT,
|
|
930
1001
|
data: {
|
|
@@ -950,7 +1021,7 @@ var ThreadPlugin = () => {
|
|
|
950
1021
|
]
|
|
951
1022
|
};
|
|
952
1023
|
}
|
|
953
|
-
case
|
|
1024
|
+
case import_chunk_FOZUQZF4.ThreadAction.DELETE_MESSAGE: {
|
|
954
1025
|
const { subject, thread, messageId } = intent.data ?? {};
|
|
955
1026
|
const space = (0, import_echo.getSpace)(subject);
|
|
956
1027
|
if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject)) {
|
|
@@ -967,7 +1038,7 @@ var ThreadPlugin = () => {
|
|
|
967
1038
|
intents: [
|
|
968
1039
|
[
|
|
969
1040
|
{
|
|
970
|
-
action:
|
|
1041
|
+
action: import_chunk_FOZUQZF4.ThreadAction.DELETE,
|
|
971
1042
|
data: {
|
|
972
1043
|
subject,
|
|
973
1044
|
thread
|
|
@@ -981,7 +1052,7 @@ var ThreadPlugin = () => {
|
|
|
981
1052
|
}
|
|
982
1053
|
return {
|
|
983
1054
|
undoable: {
|
|
984
|
-
message: translations_default[0]["en-US"][
|
|
1055
|
+
message: translations_default[0]["en-US"][import_chunk_JIJ7Z6NO.THREAD_PLUGIN]["message deleted label"],
|
|
985
1056
|
data: {
|
|
986
1057
|
message,
|
|
987
1058
|
messageIndex
|
|
@@ -1032,92 +1103,8 @@ var ThreadPlugin = () => {
|
|
|
1032
1103
|
}
|
|
1033
1104
|
},
|
|
1034
1105
|
markdown: {
|
|
1035
|
-
// TODO(burdon): Factor out extension factory into separate file (for simplicity).
|
|
1036
1106
|
extensions: ({ document: doc }) => {
|
|
1037
|
-
|
|
1038
|
-
if (!doc || !space) {
|
|
1039
|
-
return [
|
|
1040
|
-
(0, import_react_ui_editor.comments)()
|
|
1041
|
-
];
|
|
1042
|
-
}
|
|
1043
|
-
const threads = (0, import_signals_core.computed)(() => [
|
|
1044
|
-
...doc.threads.filter(import_util.nonNullable),
|
|
1045
|
-
...state.staging[(0, import_echo.fullyQualifiedId)(doc)] ?? []
|
|
1046
|
-
].filter((thread) => !(thread?.status === "resolved")));
|
|
1047
|
-
return [
|
|
1048
|
-
(0, import_react_ui_editor.listener)({
|
|
1049
|
-
onChange: () => {
|
|
1050
|
-
doc.threads.forEach((thread) => {
|
|
1051
|
-
if (thread?.anchor) {
|
|
1052
|
-
const [start, end] = thread.anchor.split(":");
|
|
1053
|
-
const name = doc.content && (0, import_echo.getTextInRange)((0, import_echo.createDocAccessor)(doc.content, [
|
|
1054
|
-
"content"
|
|
1055
|
-
]), start, end);
|
|
1056
|
-
if (name && name !== thread.name) {
|
|
1057
|
-
thread.name = name;
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
});
|
|
1061
|
-
}
|
|
1062
|
-
}),
|
|
1063
|
-
(0, import_react_ui_editor.createExternalCommentSync)(doc.id, (sink) => (0, import_signals_core.effect)(() => sink()), () => threads.value.filter((thread) => thread?.anchor).map((thread) => ({
|
|
1064
|
-
id: (0, import_echo.fullyQualifiedId)(thread),
|
|
1065
|
-
cursor: thread.anchor
|
|
1066
|
-
}))),
|
|
1067
|
-
(0, import_react_ui_editor.comments)({
|
|
1068
|
-
id: doc.id,
|
|
1069
|
-
onCreate: ({ cursor }) => {
|
|
1070
|
-
const [start, end] = cursor.split(":");
|
|
1071
|
-
const name = doc.content && (0, import_echo.getTextInRange)((0, import_echo.createDocAccessor)(doc.content, [
|
|
1072
|
-
"content"
|
|
1073
|
-
]), start, end);
|
|
1074
|
-
void intentPlugin?.provides.intent.dispatch({
|
|
1075
|
-
action: import_chunk_FXD3DYMO.ThreadAction.CREATE,
|
|
1076
|
-
data: {
|
|
1077
|
-
cursor,
|
|
1078
|
-
name,
|
|
1079
|
-
subject: doc
|
|
1080
|
-
}
|
|
1081
|
-
});
|
|
1082
|
-
},
|
|
1083
|
-
onDelete: ({ id }) => {
|
|
1084
|
-
const stagingArea = state.staging[(0, import_echo.fullyQualifiedId)(doc)];
|
|
1085
|
-
if (stagingArea) {
|
|
1086
|
-
const index = stagingArea.findIndex((thread2) => (0, import_echo.fullyQualifiedId)(thread2) === id);
|
|
1087
|
-
if (index !== -1) {
|
|
1088
|
-
stagingArea.splice(index, 1);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
const thread = doc.threads.find((thread2) => thread2?.id === id);
|
|
1092
|
-
if (thread) {
|
|
1093
|
-
thread.anchor = void 0;
|
|
1094
|
-
}
|
|
1095
|
-
},
|
|
1096
|
-
onUpdate: ({ id, cursor }) => {
|
|
1097
|
-
const thread = state.staging[(0, import_echo.fullyQualifiedId)(doc)]?.find((thread2) => (0, import_echo.fullyQualifiedId)(thread2) === id) ?? doc.threads.find((thread2) => thread2?.id === id);
|
|
1098
|
-
if (thread instanceof import_types.ThreadType && thread.anchor) {
|
|
1099
|
-
const [start, end] = thread.anchor.split(":");
|
|
1100
|
-
thread.name = doc.content && (0, import_echo.getTextInRange)((0, import_echo.createDocAccessor)(doc.content, [
|
|
1101
|
-
"content"
|
|
1102
|
-
]), start, end);
|
|
1103
|
-
thread.anchor = cursor;
|
|
1104
|
-
}
|
|
1105
|
-
},
|
|
1106
|
-
onSelect: ({ selection: { current, closest } }) => {
|
|
1107
|
-
const dispatch = intentPlugin?.provides.intent.dispatch;
|
|
1108
|
-
if (dispatch) {
|
|
1109
|
-
void dispatch([
|
|
1110
|
-
{
|
|
1111
|
-
action: import_chunk_FXD3DYMO.ThreadAction.SELECT,
|
|
1112
|
-
data: {
|
|
1113
|
-
current: current ?? closest
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
]);
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
})
|
|
1120
|
-
];
|
|
1107
|
+
return threads(state, doc, intentPlugin?.provides.intent.dispatch);
|
|
1121
1108
|
}
|
|
1122
1109
|
}
|
|
1123
1110
|
}
|