@dxos/plugin-thread 0.6.11 → 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-O64ZECMF.mjs → ThreadArticle-GBPIH47W.mjs} +3 -3
- package/dist/lib/browser/{ThreadMain-ZDCRC6RG.mjs → ThreadMain-PGF7W5EV.mjs} +3 -3
- package/dist/lib/browser/chunk-5G3KL6TC.mjs +16 -0
- package/dist/lib/browser/chunk-5G3KL6TC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GKPZHUT3.mjs → chunk-JFQZ5W2I.mjs} +2 -2
- package/dist/lib/browser/{chunk-GKPZHUT3.mjs.map → chunk-JFQZ5W2I.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-P7ZE5N5M.mjs → chunk-O4YRHIZC.mjs} +13 -11
- package/dist/lib/browser/chunk-O4YRHIZC.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +360 -341
- 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-DO56JXBU.cjs → ThreadArticle-GH5UBWFU.cjs} +7 -7
- package/dist/lib/node/{ThreadMain-XJX75GHG.cjs → ThreadMain-CO6I3DNX.cjs} +7 -7
- package/dist/lib/node/{chunk-5PZNPPQF.cjs → chunk-FDYRG7HE.cjs} +65 -63
- package/dist/lib/node/chunk-FDYRG7HE.cjs.map +7 -0
- package/dist/lib/node/{chunk-D5GOVXHS.cjs → chunk-FOZUQZF4.cjs} +6 -6
- package/dist/lib/node/{chunk-D5GOVXHS.cjs.map → chunk-FOZUQZF4.cjs.map} +1 -1
- package/dist/lib/node/{chunk-BWBONZGU.cjs → chunk-JIJ7Z6NO.cjs} +7 -22
- package/dist/lib/node/chunk-JIJ7Z6NO.cjs.map +7 -0
- package/dist/lib/node/index.cjs +433 -418
- 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-ZTYD52TR.mjs +19 -0
- package/dist/lib/node-esm/ThreadArticle-ZTYD52TR.mjs.map +7 -0
- package/dist/lib/node-esm/ThreadMain-LEHGOF7R.mjs +27 -0
- package/dist/lib/node-esm/ThreadMain-LEHGOF7R.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-DC5ZA6H5.mjs +18 -0
- package/dist/lib/node-esm/chunk-DC5ZA6H5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-XOVJ65DG.mjs +413 -0
- package/dist/lib/node-esm/chunk-XOVJ65DG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZXIPFXSA.mjs +21 -0
- package/dist/lib/node-esm/chunk-ZXIPFXSA.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1122 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/meta.mjs +12 -0
- package/dist/lib/node-esm/meta.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +9 -0
- package/dist/lib/node-esm/types.mjs.map +7 -0
- package/dist/types/src/ThreadPlugin.d.ts.map +1 -1
- package/dist/types/src/components/ChatContainer.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/MessageContainer.d.ts.map +1 -1
- package/dist/types/src/components/ThreadComplementary.d.ts +10 -0
- package/dist/types/src/components/ThreadComplementary.d.ts.map +1 -0
- package/dist/types/src/components/testing.d.ts +2 -0
- package/dist/types/src/components/testing.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 -9
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +6 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +40 -37
- package/src/ThreadPlugin.tsx +115 -310
- package/src/components/ChatContainer.tsx +7 -8
- package/src/components/CommentContainer.tsx +18 -19
- package/src/components/Comments.stories.tsx +2 -2
- package/src/components/CommentsContainer.tsx +18 -31
- package/src/components/MessageContainer.tsx +2 -1
- package/src/components/ThreadComplementary.tsx +113 -0
- package/src/extensions/index.ts +5 -0
- package/src/extensions/threads.ts +117 -0
- package/src/meta.ts +15 -0
- package/src/types.ts +8 -3
- package/dist/lib/browser/chunk-5IBJO53M.mjs +0 -21
- package/dist/lib/browser/chunk-5IBJO53M.mjs.map +0 -7
- package/dist/lib/browser/chunk-P7ZE5N5M.mjs.map +0 -7
- package/dist/lib/node/chunk-5PZNPPQF.cjs.map +0 -7
- package/dist/lib/node/chunk-BWBONZGU.cjs.map +0 -7
- package/dist/types/src/types.test.d.ts +0 -2
- package/dist/types/src/types.test.d.ts.map +0 -1
- package/src/meta.tsx +0 -20
- package/src/types.test.ts +0 -13
- /package/dist/lib/browser/{ThreadArticle-O64ZECMF.mjs.map → ThreadArticle-GBPIH47W.mjs.map} +0 -0
- /package/dist/lib/browser/{ThreadMain-ZDCRC6RG.mjs.map → ThreadMain-PGF7W5EV.mjs.map} +0 -0
- /package/dist/lib/node/{ThreadArticle-DO56JXBU.cjs.map → ThreadArticle-GH5UBWFU.cjs.map} +0 -0
- /package/dist/lib/node/{ThreadMain-XJX75GHG.cjs.map → ThreadMain-CO6I3DNX.cjs.map} +0 -0
package/dist/lib/node/index.cjs
CHANGED
|
@@ -28,73 +28,78 @@ 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_react = require("
|
|
43
|
-
var import_signals_core = require("@preact/signals-core");
|
|
44
|
-
var import_react2 = __toESM(require("react"));
|
|
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");
|
|
42
|
+
var import_react = __toESM(require("react"));
|
|
45
43
|
var import_app_framework = require("@dxos/app-framework");
|
|
46
44
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
47
45
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
48
46
|
var import_local_storage = require("@dxos/local-storage");
|
|
49
|
-
var
|
|
47
|
+
var import_log = require("@dxos/log");
|
|
50
48
|
var import_plugin_client = require("@dxos/plugin-client");
|
|
51
49
|
var import_plugin_graph = require("@dxos/plugin-graph");
|
|
52
|
-
var import_types = require("@dxos/plugin-markdown/types");
|
|
53
50
|
var import_meta = require("@dxos/plugin-observability/meta");
|
|
54
51
|
var import_plugin_space = require("@dxos/plugin-space");
|
|
55
|
-
var
|
|
52
|
+
var import_types = require("@dxos/plugin-space/types");
|
|
56
53
|
var import_echo = require("@dxos/react-client/echo");
|
|
57
|
-
var import_react_ui = require("@dxos/react-ui");
|
|
58
|
-
var import_react_ui_attention = require("@dxos/react-ui-attention");
|
|
59
|
-
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
60
54
|
var import_react_ui_thread = require("@dxos/react-ui-thread");
|
|
61
|
-
var
|
|
55
|
+
var import_react2 = __toESM(require("react"));
|
|
62
56
|
var import_react3 = __toESM(require("react"));
|
|
63
|
-
var import_react4 = __toESM(require("react"));
|
|
64
57
|
var import_plugin_settings = require("@dxos/plugin-settings");
|
|
65
|
-
var
|
|
66
|
-
var
|
|
67
|
-
var
|
|
58
|
+
var import_react_ui = require("@dxos/react-ui");
|
|
59
|
+
var import_react4 = require("@phosphor-icons/react");
|
|
60
|
+
var import_react5 = __toESM(require("react"));
|
|
68
61
|
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
69
|
-
var
|
|
62
|
+
var import_types2 = require("@dxos/plugin-space/types");
|
|
70
63
|
var import_echo2 = require("@dxos/react-client/echo");
|
|
71
64
|
var import_halo = require("@dxos/react-client/halo");
|
|
72
|
-
var
|
|
73
|
-
var
|
|
65
|
+
var import_react_ui2 = require("@dxos/react-ui");
|
|
66
|
+
var import_react_ui_editor = require("@dxos/react-ui-editor");
|
|
74
67
|
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
75
68
|
var import_react_ui_thread2 = require("@dxos/react-ui-thread");
|
|
76
|
-
var
|
|
77
|
-
var
|
|
69
|
+
var import_util = require("@dxos/util");
|
|
70
|
+
var import_react6 = require("@phosphor-icons/react");
|
|
71
|
+
var import_react7 = __toESM(require("react"));
|
|
72
|
+
var import_echo3 = require("@dxos/react-client/echo");
|
|
73
|
+
var import_react_ui3 = require("@dxos/react-ui");
|
|
74
|
+
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
78
75
|
var import_react8 = __toESM(require("react"));
|
|
76
|
+
var import_app_framework2 = require("@dxos/app-framework");
|
|
77
|
+
var import_echo4 = require("@dxos/react-client/echo");
|
|
79
78
|
var import_react_ui4 = require("@dxos/react-ui");
|
|
80
|
-
var
|
|
81
|
-
var
|
|
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");
|
|
86
|
+
var import_util3 = require("@dxos/util");
|
|
82
87
|
var ThreadSettings = ({ settings }) => {
|
|
83
|
-
const { t } = (0,
|
|
84
|
-
return /* @__PURE__ */
|
|
88
|
+
const { t } = (0, import_react_ui.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
|
|
89
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(import_plugin_settings.SettingsValue, {
|
|
85
90
|
label: t("settings standalone label")
|
|
86
|
-
}, /* @__PURE__ */
|
|
91
|
+
}, /* @__PURE__ */ import_react3.default.createElement(import_react_ui.Input.Switch, {
|
|
87
92
|
checked: settings.standalone,
|
|
88
93
|
onCheckedChange: (checked) => settings.standalone = !!checked
|
|
89
94
|
})));
|
|
90
95
|
};
|
|
91
96
|
var sizeClass = (0, import_react_ui_theme.getSize)(4);
|
|
92
97
|
var ToggleResolvedButton = ({ isResolved, onResolve }) => {
|
|
93
|
-
const { t } = (0,
|
|
98
|
+
const { t } = (0, import_react_ui2.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
|
|
94
99
|
const label = t(isResolved ? "mark as unresolved label" : "mark as resolved label");
|
|
95
|
-
return /* @__PURE__ */
|
|
100
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
|
|
96
101
|
asChild: true
|
|
97
|
-
}, /* @__PURE__ */
|
|
102
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Button, {
|
|
98
103
|
variant: "ghost",
|
|
99
104
|
"data-testid": "thread.toggle-resolved",
|
|
100
105
|
onClick: onResolve,
|
|
@@ -102,23 +107,23 @@ var ToggleResolvedButton = ({ isResolved, onResolve }) => {
|
|
|
102
107
|
"min-bs-0 p-1",
|
|
103
108
|
!isResolved && import_react_ui_theme.hoverableControlItem
|
|
104
109
|
]
|
|
105
|
-
}, /* @__PURE__ */
|
|
110
|
+
}, /* @__PURE__ */ import_react5.default.createElement("span", {
|
|
106
111
|
className: "sr-only"
|
|
107
|
-
}, label), isResolved ? /* @__PURE__ */
|
|
112
|
+
}, label), isResolved ? /* @__PURE__ */ import_react5.default.createElement(import_react4.CheckCircle, {
|
|
108
113
|
className: sizeClass,
|
|
109
114
|
weight: "fill"
|
|
110
|
-
}) : /* @__PURE__ */
|
|
115
|
+
}) : /* @__PURE__ */ import_react5.default.createElement(import_react4.CheckCircle, {
|
|
111
116
|
className: sizeClass
|
|
112
|
-
}))), /* @__PURE__ */
|
|
117
|
+
}))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Content, {
|
|
113
118
|
classNames: "z-[21]"
|
|
114
|
-
}, label, /* @__PURE__ */
|
|
119
|
+
}, label, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Arrow, null))));
|
|
115
120
|
};
|
|
116
121
|
var DeleteThreadButton = ({ onDelete }) => {
|
|
117
|
-
const { t } = (0,
|
|
122
|
+
const { t } = (0, import_react_ui2.useTranslation)(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
|
|
118
123
|
const label = t("delete thread label");
|
|
119
|
-
return /* @__PURE__ */
|
|
124
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
|
|
120
125
|
asChild: true
|
|
121
|
-
}, /* @__PURE__ */
|
|
126
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Button, {
|
|
122
127
|
variant: "ghost",
|
|
123
128
|
"data-testid": "thread.delete",
|
|
124
129
|
onClick: onDelete,
|
|
@@ -126,55 +131,49 @@ var DeleteThreadButton = ({ onDelete }) => {
|
|
|
126
131
|
"min-bs-0 p-1",
|
|
127
132
|
import_react_ui_theme.hoverableControlItem
|
|
128
133
|
]
|
|
129
|
-
}, /* @__PURE__ */
|
|
134
|
+
}, /* @__PURE__ */ import_react5.default.createElement("span", {
|
|
130
135
|
className: "sr-only"
|
|
131
|
-
}, label), /* @__PURE__ */
|
|
136
|
+
}, label), /* @__PURE__ */ import_react5.default.createElement(import_react4.X, {
|
|
132
137
|
className: sizeClass
|
|
133
|
-
}))), /* @__PURE__ */
|
|
138
|
+
}))), /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Portal, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Content, {
|
|
134
139
|
classNames: "z-[21]"
|
|
135
|
-
}, label, /* @__PURE__ */
|
|
140
|
+
}, label, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Arrow, null))));
|
|
136
141
|
};
|
|
137
|
-
var CommentContainer = ({ thread, detached, context, current,
|
|
142
|
+
var CommentContainer = ({ thread, detached, context, current, onAttend, onThreadDelete, onMessageDelete, onResolve, onComment }) => {
|
|
138
143
|
const identity = (0, import_halo.useIdentity)();
|
|
139
144
|
const space = (0, import_echo2.getSpace)(thread);
|
|
140
145
|
const members = (0, import_echo2.useMembers)(space?.key);
|
|
141
|
-
const activity = (0,
|
|
142
|
-
const { t } = (0,
|
|
143
|
-
const threadScrollRef = (0,
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
const [_count, _setCount] = (0, import_react6.useState)(0);
|
|
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);
|
|
148
|
+
const threadScrollRef = (0, import_react5.useRef)(null);
|
|
149
|
+
const { themeMode } = (0, import_react_ui2.useThemeContext)();
|
|
150
|
+
const textboxMetadata = (0, import_chunk_FDYRG7HE.getMessageMetadata)((0, import_echo2.fullyQualifiedId)(thread), identity);
|
|
151
|
+
const [_count, _setCount] = (0, import_react5.useState)(0);
|
|
148
152
|
const rerenderEditor = () => _setCount((count) => count + 1);
|
|
149
|
-
const messageRef = (0,
|
|
150
|
-
const extensions = (0,
|
|
151
|
-
(0,
|
|
153
|
+
const messageRef = (0, import_react5.useRef)("");
|
|
154
|
+
const extensions = (0, import_react5.useMemo)(() => [
|
|
155
|
+
(0, import_react_ui_editor.createBasicExtensions)({
|
|
152
156
|
placeholder: t("message placeholder")
|
|
153
157
|
}),
|
|
154
|
-
(0,
|
|
158
|
+
(0, import_react_ui_editor.createThemeExtensions)({
|
|
155
159
|
themeMode
|
|
156
160
|
}),
|
|
157
|
-
(0,
|
|
161
|
+
(0, import_react_ui_editor.listener)({
|
|
158
162
|
onChange: (text) => messageRef.current = text
|
|
159
163
|
}),
|
|
160
|
-
|
|
164
|
+
import_chunk_FDYRG7HE.command
|
|
161
165
|
], [
|
|
162
166
|
_count
|
|
163
167
|
]);
|
|
164
|
-
(0, import_react6.useEffect)(() => {
|
|
165
|
-
setAutoFocus(!!autoFocusTextbox);
|
|
166
|
-
}, [
|
|
167
|
-
autoFocusTextbox
|
|
168
|
-
]);
|
|
169
168
|
const scrollToEnd = (behavior) => setTimeout(() => threadScrollRef.current?.scrollIntoView({
|
|
170
169
|
behavior,
|
|
171
170
|
block: "end"
|
|
172
171
|
}), 10);
|
|
173
|
-
const handleCreate = (0,
|
|
172
|
+
const handleCreate = (0, import_react5.useCallback)(() => {
|
|
174
173
|
if (!messageRef.current) {
|
|
175
174
|
return false;
|
|
176
175
|
}
|
|
177
|
-
thread.messages.push((0, import_echo_schema3.create)(
|
|
176
|
+
thread.messages.push((0, import_echo_schema3.create)(import_types2.MessageType, {
|
|
178
177
|
sender: {
|
|
179
178
|
identityKey: identity.identityKey.toHex()
|
|
180
179
|
},
|
|
@@ -184,7 +183,6 @@ var CommentContainer = ({ thread, detached, context, current, autoFocusTextbox,
|
|
|
184
183
|
}));
|
|
185
184
|
onComment?.(thread);
|
|
186
185
|
messageRef.current = "";
|
|
187
|
-
setAutoFocus(true);
|
|
188
186
|
scrollToEnd("instant");
|
|
189
187
|
rerenderEditor();
|
|
190
188
|
return true;
|
|
@@ -192,64 +190,51 @@ var CommentContainer = ({ thread, detached, context, current, autoFocusTextbox,
|
|
|
192
190
|
thread,
|
|
193
191
|
identity
|
|
194
192
|
]);
|
|
195
|
-
|
|
196
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_react_ui_thread2.Thread, {
|
|
193
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.Thread, {
|
|
197
194
|
onClickCapture: onAttend,
|
|
198
195
|
onFocusCapture: onAttend,
|
|
199
196
|
current,
|
|
200
|
-
id: thread
|
|
201
|
-
}, /* @__PURE__ */
|
|
197
|
+
id: (0, import_echo2.fullyQualifiedId)(thread)
|
|
198
|
+
}, /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
202
199
|
role: "none",
|
|
203
200
|
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)
|
|
204
|
-
}, detached ? /* @__PURE__ */
|
|
201
|
+
}, detached ? /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tooltip.Trigger, {
|
|
205
202
|
asChild: true
|
|
206
|
-
}, /* @__PURE__ */
|
|
203
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.ThreadHeading, {
|
|
207
204
|
detached: true
|
|
208
|
-
}, thread.name ?? t("thread title placeholder"))), /* @__PURE__ */
|
|
205
|
+
}, 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, {
|
|
209
206
|
classNames: "z-[21]",
|
|
210
207
|
side: "top"
|
|
211
|
-
}, t("detached thread label"), /* @__PURE__ */
|
|
208
|
+
}, 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", {
|
|
212
209
|
className: "flex flex-row items-center pli-1"
|
|
213
|
-
}, thread.status === "staged" && /* @__PURE__ */
|
|
210
|
+
}, thread.status === "staged" && /* @__PURE__ */ import_react5.default.createElement(import_react_ui2.Tag, {
|
|
214
211
|
palette: "neutral"
|
|
215
|
-
}, t("draft button")), onResolve && !(thread?.status === "staged") && /* @__PURE__ */
|
|
212
|
+
}, t("draft button")), onResolve && !(thread?.status === "staged") && /* @__PURE__ */ import_react5.default.createElement(ToggleResolvedButton, {
|
|
216
213
|
isResolved: thread?.status === "resolved",
|
|
217
214
|
onResolve
|
|
218
|
-
}), onThreadDelete && /* @__PURE__ */
|
|
215
|
+
}), onThreadDelete && /* @__PURE__ */ import_react5.default.createElement(DeleteThreadButton, {
|
|
219
216
|
onDelete: onThreadDelete
|
|
220
|
-
}))), thread.messages.filter(
|
|
217
|
+
}))), thread.messages.filter(import_util.nonNullable).map((message) => /* @__PURE__ */ import_react5.default.createElement(import_chunk_FDYRG7HE.MessageContainer, {
|
|
221
218
|
key: message.id,
|
|
222
219
|
message,
|
|
223
220
|
members,
|
|
224
|
-
onDelete:
|
|
225
|
-
})), /* @__PURE__ */
|
|
221
|
+
onDelete: (id) => onMessageDelete?.(id)
|
|
222
|
+
})), /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.MessageTextbox, {
|
|
226
223
|
extensions,
|
|
227
|
-
autoFocus,
|
|
228
224
|
onSend: handleCreate,
|
|
229
225
|
...textboxMetadata
|
|
230
|
-
}), /* @__PURE__ */
|
|
226
|
+
}), /* @__PURE__ */ import_react5.default.createElement(import_react_ui_thread2.ThreadFooter, {
|
|
231
227
|
activity
|
|
232
|
-
}, t("activity message")), /* @__PURE__ */
|
|
228
|
+
}, t("activity message")), /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
233
229
|
role: "none",
|
|
234
230
|
className: "bs-px -mbs-px",
|
|
235
231
|
ref: threadScrollRef
|
|
236
232
|
}));
|
|
237
233
|
};
|
|
238
|
-
var
|
|
239
|
-
const { t } = (0,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
className: "flex items-center"
|
|
243
|
-
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui_deck.PlankHeading.Button, {
|
|
244
|
-
attendableId
|
|
245
|
-
}, /* @__PURE__ */ import_react8.default.createElement(import_react7.Quotes, import_react_ui_deck.plankHeadingIconProps)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui_deck.PlankHeading.Label, {
|
|
246
|
-
attendableId
|
|
247
|
-
}, t("comments heading")));
|
|
248
|
-
};
|
|
249
|
-
var CommentsContainer = ({ threads, detached = [], currentId, autoFocusCurrentTextbox, showResolvedThreads, onThreadAttend, onThreadDelete, onMessageDelete, onThreadToggleResolved, ...props }) => {
|
|
250
|
-
const { t } = (0, import_react_ui4.useTranslation)(import_chunk_BWBONZGU.THREAD_PLUGIN);
|
|
251
|
-
const filteredThreads = showResolvedThreads ? threads : threads.filter((thread) => !(thread?.status === "resolved"));
|
|
252
|
-
(0, import_react8.useEffect)(() => {
|
|
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"));
|
|
237
|
+
(0, import_react7.useEffect)(() => {
|
|
253
238
|
if (currentId) {
|
|
254
239
|
document.getElementById(currentId)?.scrollIntoView({
|
|
255
240
|
behavior: "smooth",
|
|
@@ -259,46 +244,232 @@ var CommentsContainer = ({ threads, detached = [], currentId, autoFocusCurrentTe
|
|
|
259
244
|
}, [
|
|
260
245
|
currentId
|
|
261
246
|
]);
|
|
262
|
-
return /* @__PURE__ */
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
onThreadDelete
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
onMessageDelete
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
247
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, filteredThreads.length > 0 ? filteredThreads.map((thread) => {
|
|
248
|
+
const threadId = (0, import_echo3.fullyQualifiedId)(thread);
|
|
249
|
+
return /* @__PURE__ */ import_react7.default.createElement(CommentContainer, {
|
|
250
|
+
key: threadId,
|
|
251
|
+
thread,
|
|
252
|
+
current: currentId === threadId,
|
|
253
|
+
detached: detached.includes(threadId),
|
|
254
|
+
...onThreadAttend && {
|
|
255
|
+
onAttend: () => onThreadAttend(thread)
|
|
256
|
+
},
|
|
257
|
+
...onThreadDelete && {
|
|
258
|
+
onThreadDelete: () => onThreadDelete(thread)
|
|
259
|
+
},
|
|
260
|
+
...onMessageDelete && {
|
|
261
|
+
onMessageDelete: (messageId) => onMessageDelete(thread, messageId)
|
|
262
|
+
},
|
|
263
|
+
...onThreadToggleResolved && {
|
|
264
|
+
onResolve: () => onThreadToggleResolved(thread)
|
|
265
|
+
},
|
|
266
|
+
...props
|
|
267
|
+
});
|
|
268
|
+
}) : /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
282
269
|
role: "alert",
|
|
283
270
|
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")
|
|
284
|
-
}, /* @__PURE__ */
|
|
271
|
+
}, /* @__PURE__ */ import_react7.default.createElement("h2", {
|
|
285
272
|
className: "mbe-2 font-medium text-baseText"
|
|
286
|
-
}, t("no comments title")), /* @__PURE__ */
|
|
273
|
+
}, t("no comments title")), /* @__PURE__ */ import_react7.default.createElement("p", null, /* @__PURE__ */ import_react7.default.createElement(import_react_ui3.Trans, {
|
|
287
274
|
t,
|
|
288
275
|
i18nKey: "no comments message",
|
|
289
276
|
components: {
|
|
290
|
-
commentIcon: /* @__PURE__ */
|
|
277
|
+
commentIcon: /* @__PURE__ */ import_react7.default.createElement(import_react6.ChatText, {
|
|
291
278
|
className: "inline-block"
|
|
292
279
|
})
|
|
293
280
|
}
|
|
294
281
|
}))));
|
|
295
282
|
};
|
|
296
|
-
var ThreadMain =
|
|
297
|
-
var ThreadArticle =
|
|
283
|
+
var ThreadMain = import_react2.default.lazy(() => import("./ThreadMain-CO6I3DNX.cjs"));
|
|
284
|
+
var ThreadArticle = import_react2.default.lazy(() => import("./ThreadArticle-GH5UBWFU.cjs"));
|
|
285
|
+
var providesThreadsConfig = (plugin) => "thread" in plugin.provides ? plugin : void 0;
|
|
286
|
+
var ThreadComplementary = ({ role, subject, drafts, current, showResolvedThreads }) => {
|
|
287
|
+
const dispatch = (0, import_app_framework2.useIntentDispatcher)();
|
|
288
|
+
const threadsIntegrators = (0, import_app_framework2.useResolvePlugins)(providesThreadsConfig);
|
|
289
|
+
const threadProvides = (0, import_react8.useMemo)(() => threadsIntegrators.map((p) => p.provides.thread), [
|
|
290
|
+
threadsIntegrators
|
|
291
|
+
]);
|
|
292
|
+
const createSort = (0, import_react8.useMemo)(() => threadProvides.find((p) => p.predicate(subject))?.createSort, [
|
|
293
|
+
threadProvides,
|
|
294
|
+
subject
|
|
295
|
+
]);
|
|
296
|
+
const sort = (0, import_react8.useMemo)(() => createSort?.(subject), [
|
|
297
|
+
createSort,
|
|
298
|
+
subject
|
|
299
|
+
]);
|
|
300
|
+
const threads2 = (0, import_react8.useMemo)(() => {
|
|
301
|
+
return subject.threads.concat(drafts ?? []).filter(import_util2.nonNullable);
|
|
302
|
+
}, [
|
|
303
|
+
JSON.stringify(subject.threads),
|
|
304
|
+
JSON.stringify(drafts)
|
|
305
|
+
]);
|
|
306
|
+
const detachedIds = (0, import_react8.useMemo)(() => {
|
|
307
|
+
return threads2.filter(({ anchor }) => !anchor).map((thread) => (0, import_echo4.fullyQualifiedId)(thread));
|
|
308
|
+
}, [
|
|
309
|
+
threads2
|
|
310
|
+
]);
|
|
311
|
+
(0, import_react8.useEffect)(() => {
|
|
312
|
+
if (!sort) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
threads2.sort((a, b) => sort(a?.anchor, b?.anchor));
|
|
316
|
+
}, [
|
|
317
|
+
sort,
|
|
318
|
+
threads2
|
|
319
|
+
]);
|
|
320
|
+
const attended = (0, import_react_ui_attention.useAttended)();
|
|
321
|
+
const qualifiedSubjectId = (0, import_echo4.fullyQualifiedId)(subject);
|
|
322
|
+
return /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
323
|
+
role: "none",
|
|
324
|
+
className: "contents"
|
|
325
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Root, {
|
|
326
|
+
classNames: "row-span-2"
|
|
327
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Viewport, null, /* @__PURE__ */ import_react8.default.createElement(CommentsContainer, {
|
|
328
|
+
threads: threads2,
|
|
329
|
+
detached: detachedIds,
|
|
330
|
+
currentId: attended.includes(qualifiedSubjectId) ? current : void 0,
|
|
331
|
+
showResolvedThreads,
|
|
332
|
+
onThreadAttend: (thread) => {
|
|
333
|
+
const threadId = (0, import_echo4.fullyQualifiedId)(thread);
|
|
334
|
+
if (current !== threadId) {
|
|
335
|
+
current = threadId;
|
|
336
|
+
void dispatch?.([
|
|
337
|
+
{
|
|
338
|
+
action: import_app_framework2.LayoutAction.SCROLL_INTO_VIEW,
|
|
339
|
+
data: {
|
|
340
|
+
id: (0, import_echo4.fullyQualifiedId)(subject),
|
|
341
|
+
thread: threadId,
|
|
342
|
+
cursor: thread.anchor
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
]);
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
onThreadDelete: (thread) => {
|
|
349
|
+
return dispatch({
|
|
350
|
+
plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
|
|
351
|
+
action: import_chunk_FOZUQZF4.ThreadAction.DELETE,
|
|
352
|
+
data: {
|
|
353
|
+
subject,
|
|
354
|
+
thread
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
},
|
|
358
|
+
onMessageDelete: (thread, messageId) => dispatch({
|
|
359
|
+
plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
|
|
360
|
+
action: import_chunk_FOZUQZF4.ThreadAction.DELETE_MESSAGE,
|
|
361
|
+
data: {
|
|
362
|
+
subject,
|
|
363
|
+
thread,
|
|
364
|
+
messageId
|
|
365
|
+
}
|
|
366
|
+
}),
|
|
367
|
+
onThreadToggleResolved: (thread) => dispatch({
|
|
368
|
+
plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
|
|
369
|
+
action: import_chunk_FOZUQZF4.ThreadAction.TOGGLE_RESOLVED,
|
|
370
|
+
data: {
|
|
371
|
+
thread
|
|
372
|
+
}
|
|
373
|
+
}),
|
|
374
|
+
onComment: (thread) => {
|
|
375
|
+
void dispatch({
|
|
376
|
+
action: import_chunk_FOZUQZF4.ThreadAction.ON_MESSAGE_ADD,
|
|
377
|
+
data: {
|
|
378
|
+
thread,
|
|
379
|
+
subject
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}), /* @__PURE__ */ import_react8.default.createElement("div", {
|
|
384
|
+
role: "none",
|
|
385
|
+
className: "bs-10"
|
|
386
|
+
}), /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Scrollbar, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui4.ScrollArea.Thumb, null)))));
|
|
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
|
+
};
|
|
298
469
|
var translations_default = [
|
|
299
470
|
{
|
|
300
471
|
"en-US": {
|
|
301
|
-
[
|
|
472
|
+
[import_chunk_JIJ7Z6NO.THREAD_PLUGIN]: {
|
|
302
473
|
"plugin name": "Threads",
|
|
303
474
|
"channel name placeholder": "New channel",
|
|
304
475
|
"channel title label": "Title",
|
|
@@ -329,14 +500,14 @@ var translations_default = [
|
|
|
329
500
|
}
|
|
330
501
|
}
|
|
331
502
|
];
|
|
503
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-thread/src/ThreadPlugin.tsx";
|
|
332
504
|
var initialViewState = {
|
|
333
505
|
showResolvedThreads: false
|
|
334
506
|
};
|
|
335
|
-
var providesThreadsConfig = (plugin) => "thread" in plugin.provides ? plugin : void 0;
|
|
336
507
|
var ThreadPlugin = () => {
|
|
337
|
-
const settings = new import_local_storage.LocalStorageStore(
|
|
508
|
+
const settings = new import_local_storage.LocalStorageStore(import_chunk_JIJ7Z6NO.THREAD_PLUGIN);
|
|
338
509
|
const state = (0, import_echo_schema2.create)({
|
|
339
|
-
|
|
510
|
+
drafts: {}
|
|
340
511
|
});
|
|
341
512
|
const viewStore = (0, import_echo_schema2.create)({});
|
|
342
513
|
const getViewState = (subjectId) => {
|
|
@@ -347,13 +518,11 @@ var ThreadPlugin = () => {
|
|
|
347
518
|
}
|
|
348
519
|
return viewStore[subjectId];
|
|
349
520
|
};
|
|
350
|
-
let attentionPlugin;
|
|
351
521
|
let navigationPlugin;
|
|
352
522
|
let intentPlugin;
|
|
353
|
-
let dispatch;
|
|
354
523
|
const unsubscribeCallbacks = [];
|
|
355
524
|
return {
|
|
356
|
-
meta:
|
|
525
|
+
meta: import_chunk_JIJ7Z6NO.meta_default,
|
|
357
526
|
ready: async (plugins) => {
|
|
358
527
|
settings.prop({
|
|
359
528
|
key: "standalone",
|
|
@@ -361,36 +530,8 @@ var ThreadPlugin = () => {
|
|
|
361
530
|
allowUndefined: true
|
|
362
531
|
})
|
|
363
532
|
});
|
|
364
|
-
attentionPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_attention.parseAttentionPlugin);
|
|
365
533
|
navigationPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseNavigationPlugin);
|
|
366
534
|
intentPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseIntentPlugin);
|
|
367
|
-
dispatch = intentPlugin?.provides.intent.dispatch;
|
|
368
|
-
const graphPlugin = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseGraphPlugin);
|
|
369
|
-
const client = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_client.parseClientPlugin)?.provides.client;
|
|
370
|
-
if (!client) {
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
const channelsQuery = client.spaces.query(import_echo.Filter.schema(import_types2.ChannelType));
|
|
374
|
-
const queryUnsubscribe = channelsQuery.subscribe();
|
|
375
|
-
const unsubscribe = (0, import_signals_core.effect)(() => {
|
|
376
|
-
const attention = attentionPlugin?.provides.attention;
|
|
377
|
-
if (!attention?.attended) {
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
const firstAttendedNodeWithComments = Array.from(attention.attended).map((id) => graphPlugin?.provides.graph.findNode(id)).find((node) => node?.data instanceof import_types.DocumentType && (node.data.threads?.length ?? 0) > 0);
|
|
381
|
-
if (firstAttendedNodeWithComments) {
|
|
382
|
-
void intentPlugin?.provides.intent.dispatch({
|
|
383
|
-
action: import_app_framework.NavigationAction.OPEN,
|
|
384
|
-
data: {
|
|
385
|
-
activeParts: {
|
|
386
|
-
complementary: `${firstAttendedNodeWithComments.id}${import_app_framework.SLUG_PATH_SEPARATOR}comments`
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
unsubscribeCallbacks.push(queryUnsubscribe);
|
|
393
|
-
unsubscribeCallbacks.push(unsubscribe);
|
|
394
535
|
},
|
|
395
536
|
unload: async () => {
|
|
396
537
|
unsubscribeCallbacks.forEach((unsubscribe) => unsubscribe());
|
|
@@ -399,27 +540,26 @@ var ThreadPlugin = () => {
|
|
|
399
540
|
settings: settings.values,
|
|
400
541
|
metadata: {
|
|
401
542
|
records: {
|
|
402
|
-
[
|
|
543
|
+
[import_types.ChannelType.typename]: {
|
|
403
544
|
placeholder: [
|
|
404
545
|
"channel title placeholder",
|
|
405
546
|
{
|
|
406
|
-
ns:
|
|
547
|
+
ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
|
|
407
548
|
}
|
|
408
549
|
],
|
|
409
|
-
icon:
|
|
410
|
-
iconSymbol: "ph--chat--regular",
|
|
550
|
+
icon: "ph--chat--regular",
|
|
411
551
|
// TODO(wittjosiah): Move out of metadata.
|
|
412
552
|
loadReferences: (channel) => (0, import_echo.loadObjectReferences)(channel, (channel2) => channel2.threads)
|
|
413
553
|
},
|
|
414
|
-
[
|
|
554
|
+
[import_types.ThreadType.typename]: {
|
|
415
555
|
// TODO(wittjosiah): Move out of metadata.
|
|
416
556
|
loadReferences: (thread) => (0, import_echo.loadObjectReferences)(thread, (thread2) => thread2.messages)
|
|
417
557
|
},
|
|
418
|
-
[
|
|
558
|
+
[import_types.MessageType.typename]: {
|
|
419
559
|
// TODO(wittjosiah): Move out of metadata.
|
|
420
560
|
loadReferences: (message) => []
|
|
421
561
|
},
|
|
422
|
-
[
|
|
562
|
+
[import_chunk_JIJ7Z6NO.THREAD_ITEM]: {
|
|
423
563
|
parse: (item, type) => {
|
|
424
564
|
switch (type) {
|
|
425
565
|
case "node":
|
|
@@ -446,49 +586,56 @@ var ThreadPlugin = () => {
|
|
|
446
586
|
],
|
|
447
587
|
echo: {
|
|
448
588
|
schema: [
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
589
|
+
import_types.ChannelType,
|
|
590
|
+
import_types.ThreadType,
|
|
591
|
+
import_types.MessageType
|
|
452
592
|
]
|
|
453
593
|
},
|
|
454
594
|
graph: {
|
|
455
595
|
builder: (plugins) => {
|
|
456
596
|
const client = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_client.parseClientPlugin)?.provides.client;
|
|
457
|
-
const
|
|
597
|
+
const dispatch = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseIntentPlugin)?.provides.intent.dispatch;
|
|
458
598
|
const metadataResolver = (0, import_app_framework.resolvePlugin)(plugins, import_app_framework.parseMetadataResolverPlugin)?.provides.metadata.resolver;
|
|
459
|
-
if (!client || !
|
|
599
|
+
if (!client || !dispatch || !metadataResolver) {
|
|
460
600
|
return [];
|
|
461
601
|
}
|
|
462
602
|
return [
|
|
463
603
|
(0, import_plugin_graph.createExtension)({
|
|
464
|
-
id: `${
|
|
604
|
+
id: `${import_chunk_JIJ7Z6NO.THREAD_PLUGIN}/comments-for-subject`,
|
|
465
605
|
resolver: ({ id }) => {
|
|
466
606
|
if (!id.endsWith("~comments")) {
|
|
467
607
|
return;
|
|
468
608
|
}
|
|
469
|
-
const
|
|
470
|
-
const [spaceId, objectId] =
|
|
609
|
+
const subjectId = id.split("~").at(0);
|
|
610
|
+
const [spaceId, objectId] = subjectId?.split(":") ?? [];
|
|
471
611
|
const space = client.spaces.get().find((space2) => space2.id === spaceId);
|
|
472
|
-
const
|
|
473
|
-
|
|
612
|
+
const object = (0, import_plugin_graph.toSignal)((onChange) => {
|
|
613
|
+
const timeout = setTimeout(async () => {
|
|
614
|
+
await space?.db.loadObjectById(objectId);
|
|
615
|
+
onChange();
|
|
616
|
+
});
|
|
617
|
+
return () => clearTimeout(timeout);
|
|
618
|
+
}, () => space?.db.getObjectById(objectId), subjectId);
|
|
619
|
+
if (!object || !subjectId) {
|
|
474
620
|
return;
|
|
475
621
|
}
|
|
476
|
-
const
|
|
477
|
-
const label =
|
|
622
|
+
const meta = metadataResolver((0, import_echo_schema.getTypename)(object) ?? "");
|
|
623
|
+
const label = meta.label?.(object) || object.name || meta.placeholder || [
|
|
478
624
|
"unnamed object threads label",
|
|
479
625
|
{
|
|
480
|
-
ns:
|
|
626
|
+
ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
|
|
481
627
|
}
|
|
482
628
|
];
|
|
483
|
-
const viewState = getViewState(
|
|
629
|
+
const viewState = getViewState(subjectId);
|
|
484
630
|
return {
|
|
485
631
|
id,
|
|
486
632
|
type: "orphan-comments-for-subject",
|
|
487
|
-
data:
|
|
633
|
+
data: null,
|
|
488
634
|
properties: {
|
|
489
|
-
icon:
|
|
635
|
+
icon: "ph--chat-text--regular",
|
|
490
636
|
label,
|
|
491
|
-
showResolvedThreads: viewState.showResolvedThreads
|
|
637
|
+
showResolvedThreads: viewState.showResolvedThreads,
|
|
638
|
+
object
|
|
492
639
|
}
|
|
493
640
|
};
|
|
494
641
|
},
|
|
@@ -502,7 +649,7 @@ var ThreadPlugin = () => {
|
|
|
502
649
|
const toggle = () => {
|
|
503
650
|
const newToggleState = !viewState.showResolvedThreads;
|
|
504
651
|
viewState.showResolvedThreads = newToggleState;
|
|
505
|
-
void
|
|
652
|
+
void dispatch({
|
|
506
653
|
action: import_meta.ObservabilityAction.SEND_EVENT,
|
|
507
654
|
data: {
|
|
508
655
|
name: "threads.toggle-show-resolved",
|
|
@@ -516,25 +663,26 @@ var ThreadPlugin = () => {
|
|
|
516
663
|
};
|
|
517
664
|
return [
|
|
518
665
|
{
|
|
519
|
-
id: `${
|
|
666
|
+
id: `${import_chunk_JIJ7Z6NO.THREAD_PLUGIN}/toggle-show-resolved/${node.id}`,
|
|
520
667
|
data: toggle,
|
|
521
668
|
properties: {
|
|
522
669
|
label: [
|
|
523
670
|
"toggle show resolved",
|
|
524
671
|
{
|
|
525
|
-
ns:
|
|
672
|
+
ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
|
|
526
673
|
}
|
|
527
674
|
],
|
|
528
675
|
menuItemType: "toggle",
|
|
529
676
|
isChecked: viewState.showResolvedThreads,
|
|
530
|
-
testId: "threadPlugin.toggleShowResolved"
|
|
677
|
+
testId: "threadPlugin.toggleShowResolved",
|
|
678
|
+
icon: viewState.showResolvedThreads ? "ph--eye-slash--regular" : "ph--eye--regular"
|
|
531
679
|
}
|
|
532
680
|
}
|
|
533
681
|
];
|
|
534
682
|
}
|
|
535
683
|
}),
|
|
536
684
|
(0, import_plugin_graph.createExtension)({
|
|
537
|
-
id:
|
|
685
|
+
id: import_chunk_FOZUQZF4.ThreadAction.CREATE,
|
|
538
686
|
filter: (node) => !!settings.values.standalone && (0, import_plugin_graph.isActionGroup)(node) && node.id.startsWith(import_plugin_space.SpaceAction.ADD_OBJECT),
|
|
539
687
|
actions: ({ node }) => {
|
|
540
688
|
const id = node.id.split("/").at(-1);
|
|
@@ -547,12 +695,12 @@ var ThreadPlugin = () => {
|
|
|
547
695
|
}
|
|
548
696
|
return [
|
|
549
697
|
{
|
|
550
|
-
id: `${
|
|
698
|
+
id: `${import_chunk_JIJ7Z6NO.THREAD_PLUGIN}/create/${node.id}`,
|
|
551
699
|
data: async () => {
|
|
552
|
-
await
|
|
700
|
+
await dispatch([
|
|
553
701
|
{
|
|
554
|
-
plugin:
|
|
555
|
-
action:
|
|
702
|
+
plugin: import_chunk_JIJ7Z6NO.THREAD_PLUGIN,
|
|
703
|
+
action: import_chunk_FOZUQZF4.ThreadAction.CREATE
|
|
556
704
|
},
|
|
557
705
|
{
|
|
558
706
|
action: import_plugin_space.SpaceAction.ADD_OBJECT,
|
|
@@ -569,11 +717,10 @@ var ThreadPlugin = () => {
|
|
|
569
717
|
label: [
|
|
570
718
|
"create channel label",
|
|
571
719
|
{
|
|
572
|
-
ns:
|
|
720
|
+
ns: import_chunk_JIJ7Z6NO.THREAD_PLUGIN
|
|
573
721
|
}
|
|
574
722
|
],
|
|
575
|
-
icon:
|
|
576
|
-
iconSymbol: "ph--chat--regular",
|
|
723
|
+
icon: "ph--chat--regular",
|
|
577
724
|
testId: "threadPlugin.createObject"
|
|
578
725
|
}
|
|
579
726
|
}
|
|
@@ -587,21 +734,18 @@ var ThreadPlugin = () => {
|
|
|
587
734
|
component: ({ data, role }) => {
|
|
588
735
|
switch (role) {
|
|
589
736
|
case "main": {
|
|
590
|
-
return data.active instanceof
|
|
737
|
+
return data.active instanceof import_types.ChannelType && data.active.threads[0] ? /* @__PURE__ */ import_react.default.createElement(ThreadMain, {
|
|
591
738
|
thread: data.active.threads[0]
|
|
592
739
|
}) : null;
|
|
593
740
|
}
|
|
594
741
|
case "settings": {
|
|
595
|
-
return data.plugin ===
|
|
742
|
+
return data.plugin === import_chunk_JIJ7Z6NO.meta_default.id ? /* @__PURE__ */ import_react.default.createElement(ThreadSettings, {
|
|
596
743
|
settings: settings.values
|
|
597
744
|
}) : null;
|
|
598
745
|
}
|
|
599
|
-
case "article":
|
|
600
|
-
case "complementary": {
|
|
746
|
+
case "article": {
|
|
601
747
|
const location = navigationPlugin?.provides.location;
|
|
602
|
-
|
|
603
|
-
const threadProvides = threadsIntegrators.map((p) => p.provides.thread);
|
|
604
|
-
if (data.object instanceof import_types2.ChannelType && data.object.threads[0]) {
|
|
748
|
+
if (data.object instanceof import_types.ChannelType && data.object.threads[0]) {
|
|
605
749
|
const channel = data.object;
|
|
606
750
|
if ((0, import_app_framework.isLayoutParts)(location?.active) && location.active.main) {
|
|
607
751
|
const layoutEntries = location.active.main;
|
|
@@ -609,102 +753,37 @@ var ThreadPlugin = () => {
|
|
|
609
753
|
if (currentPosition > 0) {
|
|
610
754
|
const objectToTheLeft = layoutEntries[currentPosition - 1];
|
|
611
755
|
const context = (0, import_echo.getSpace)(data.object)?.db.getObjectById(objectToTheLeft.id);
|
|
612
|
-
return /* @__PURE__ */
|
|
756
|
+
return /* @__PURE__ */ import_react.default.createElement(ThreadArticle, {
|
|
613
757
|
thread: data.object.threads[0],
|
|
614
758
|
context
|
|
615
759
|
});
|
|
616
760
|
}
|
|
617
761
|
}
|
|
618
|
-
return /* @__PURE__ */
|
|
762
|
+
return /* @__PURE__ */ import_react.default.createElement(ThreadArticle, {
|
|
619
763
|
thread: data.object.threads[0]
|
|
620
764
|
});
|
|
621
765
|
}
|
|
622
|
-
if (data.subject instanceof
|
|
623
|
-
return /* @__PURE__ */
|
|
766
|
+
if (data.subject instanceof import_types.ThreadType) {
|
|
767
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_chunk_FDYRG7HE.ChatHeading, {
|
|
624
768
|
attendableId: data.subject.id
|
|
625
|
-
}), /* @__PURE__ */
|
|
769
|
+
}), /* @__PURE__ */ import_react.default.createElement(import_chunk_FDYRG7HE.ChatContainer, {
|
|
626
770
|
thread: data.subject
|
|
627
771
|
}));
|
|
628
772
|
}
|
|
773
|
+
break;
|
|
774
|
+
}
|
|
775
|
+
case "complementary--comments": {
|
|
629
776
|
if (data.subject && typeof data.subject === "object" && "threads" in data.subject && Array.isArray(data.subject.threads)) {
|
|
630
|
-
const
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
const attention = attentionPlugin?.provides.attention?.attended ?? /* @__PURE__ */ new Set([
|
|
639
|
-
qualifiedSubjectId
|
|
640
|
-
]);
|
|
641
|
-
const attendableAttrs = (0, import_react_ui_attention.createAttendableAttributes)(qualifiedSubjectId);
|
|
642
|
-
const { showResolvedThreads } = getViewState(qualifiedSubjectId);
|
|
643
|
-
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
644
|
-
role: "none",
|
|
645
|
-
className: "contents group/attention",
|
|
646
|
-
...attendableAttrs
|
|
647
|
-
}, role === "complementary" && /* @__PURE__ */ import_react2.default.createElement(CommentsHeading, {
|
|
648
|
-
attendableId: qualifiedSubjectId
|
|
649
|
-
}), /* @__PURE__ */ import_react2.default.createElement(import_react_ui.ScrollArea.Root, {
|
|
650
|
-
classNames: "row-span-2"
|
|
651
|
-
}, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.ScrollArea.Viewport, null, /* @__PURE__ */ import_react2.default.createElement(CommentsContainer, {
|
|
652
|
-
threads,
|
|
653
|
-
detached,
|
|
654
|
-
currentId: attention.has(qualifiedSubjectId) ? state.current : void 0,
|
|
655
|
-
autoFocusCurrentTextbox: state.focus,
|
|
656
|
-
showResolvedThreads,
|
|
657
|
-
onThreadAttend: (thread) => {
|
|
658
|
-
if (state.current !== thread.id) {
|
|
659
|
-
state.current = thread.id;
|
|
660
|
-
void dispatch?.({
|
|
661
|
-
action: import_app_framework.LayoutAction.SCROLL_INTO_VIEW,
|
|
662
|
-
data: {
|
|
663
|
-
id: (0, import_echo.fullyQualifiedId)(data.subject),
|
|
664
|
-
thread: (0, import_echo.fullyQualifiedId)(thread),
|
|
665
|
-
cursor: thread.anchor
|
|
666
|
-
}
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
},
|
|
670
|
-
onThreadDelete: (thread) => dispatch?.({
|
|
671
|
-
plugin: import_chunk_BWBONZGU.THREAD_PLUGIN,
|
|
672
|
-
action: import_chunk_D5GOVXHS.ThreadAction.DELETE,
|
|
673
|
-
data: {
|
|
674
|
-
subject: data.subject,
|
|
675
|
-
thread
|
|
676
|
-
}
|
|
677
|
-
}),
|
|
678
|
-
onMessageDelete: (thread, messageId) => dispatch?.({
|
|
679
|
-
plugin: import_chunk_BWBONZGU.THREAD_PLUGIN,
|
|
680
|
-
action: import_chunk_D5GOVXHS.ThreadAction.DELETE_MESSAGE,
|
|
681
|
-
data: {
|
|
682
|
-
subject: data.subject,
|
|
683
|
-
thread,
|
|
684
|
-
messageId
|
|
685
|
-
}
|
|
686
|
-
}),
|
|
687
|
-
onThreadToggleResolved: (thread) => dispatch?.({
|
|
688
|
-
plugin: import_chunk_BWBONZGU.THREAD_PLUGIN,
|
|
689
|
-
action: import_chunk_D5GOVXHS.ThreadAction.TOGGLE_RESOLVED,
|
|
690
|
-
data: {
|
|
691
|
-
thread
|
|
692
|
-
}
|
|
693
|
-
}),
|
|
694
|
-
onComment: (thread) => {
|
|
695
|
-
void intentPlugin?.provides.intent.dispatch({
|
|
696
|
-
action: import_chunk_D5GOVXHS.ThreadAction.ON_MESSAGE_ADD,
|
|
697
|
-
data: {
|
|
698
|
-
thread,
|
|
699
|
-
subject: data.subject
|
|
700
|
-
}
|
|
701
|
-
});
|
|
702
|
-
}
|
|
703
|
-
}), /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
704
|
-
role: "none",
|
|
705
|
-
className: "bs-10"
|
|
706
|
-
}), /* @__PURE__ */ import_react2.default.createElement(import_react_ui.ScrollArea.Scrollbar, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui.ScrollArea.Thumb, null)))));
|
|
777
|
+
const { showResolvedThreads } = getViewState((0, import_echo.fullyQualifiedId)(data.subject));
|
|
778
|
+
return /* @__PURE__ */ import_react.default.createElement(ThreadComplementary, {
|
|
779
|
+
role,
|
|
780
|
+
subject: data.subject,
|
|
781
|
+
drafts: state.drafts[(0, import_echo.fullyQualifiedId)(data.subject)],
|
|
782
|
+
current: state.current,
|
|
783
|
+
showResolvedThreads
|
|
784
|
+
});
|
|
707
785
|
}
|
|
786
|
+
break;
|
|
708
787
|
}
|
|
709
788
|
}
|
|
710
789
|
return null;
|
|
@@ -713,21 +792,34 @@ var ThreadPlugin = () => {
|
|
|
713
792
|
intent: {
|
|
714
793
|
resolver: async (intent) => {
|
|
715
794
|
switch (intent.action) {
|
|
716
|
-
case
|
|
795
|
+
case import_chunk_FOZUQZF4.ThreadAction.CREATE: {
|
|
717
796
|
if (intent.data && intent.data.cursor !== void 0) {
|
|
718
797
|
const { cursor, name, subject } = intent.data;
|
|
798
|
+
if (subject?.threads === void 0) {
|
|
799
|
+
try {
|
|
800
|
+
subject.threads = [];
|
|
801
|
+
} catch (err) {
|
|
802
|
+
import_log.log.error("Subject does not support threads array", subject?.typename, {
|
|
803
|
+
F: __dxlog_file,
|
|
804
|
+
L: 322,
|
|
805
|
+
S: void 0,
|
|
806
|
+
C: (f, a) => f(...a)
|
|
807
|
+
});
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
719
811
|
const subjectId = (0, import_echo.fullyQualifiedId)(subject);
|
|
720
|
-
const thread = (0, import_echo_schema2.create)(
|
|
812
|
+
const thread = (0, import_echo_schema2.create)(import_types.ThreadType, {
|
|
721
813
|
name,
|
|
722
814
|
anchor: cursor,
|
|
723
815
|
messages: [],
|
|
724
816
|
status: "staged"
|
|
725
817
|
});
|
|
726
|
-
const
|
|
727
|
-
if (
|
|
728
|
-
|
|
818
|
+
const draft = state.drafts[subjectId];
|
|
819
|
+
if (draft) {
|
|
820
|
+
draft.push(thread);
|
|
729
821
|
} else {
|
|
730
|
-
state.
|
|
822
|
+
state.drafts[subjectId] = [
|
|
731
823
|
thread
|
|
732
824
|
];
|
|
733
825
|
}
|
|
@@ -736,26 +828,19 @@ var ThreadPlugin = () => {
|
|
|
736
828
|
intents: [
|
|
737
829
|
[
|
|
738
830
|
{
|
|
739
|
-
action:
|
|
740
|
-
data: {
|
|
741
|
-
activeParts: {
|
|
742
|
-
complementary: `${subjectId}${import_app_framework.SLUG_PATH_SEPARATOR}comments${import_app_framework.SLUG_COLLECTION_INDICATOR}`
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
},
|
|
746
|
-
{
|
|
747
|
-
action: import_chunk_D5GOVXHS.ThreadAction.SELECT,
|
|
831
|
+
action: import_chunk_FOZUQZF4.ThreadAction.SELECT,
|
|
748
832
|
data: {
|
|
749
|
-
current: thread
|
|
750
|
-
focus: true
|
|
833
|
+
current: (0, import_echo.fullyQualifiedId)(thread)
|
|
751
834
|
}
|
|
752
|
-
}
|
|
835
|
+
}
|
|
836
|
+
],
|
|
837
|
+
[
|
|
753
838
|
{
|
|
754
|
-
action: import_app_framework.
|
|
839
|
+
action: import_app_framework.NavigationAction.OPEN,
|
|
755
840
|
data: {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
841
|
+
activeParts: {
|
|
842
|
+
complementary: "comments"
|
|
843
|
+
}
|
|
759
844
|
}
|
|
760
845
|
}
|
|
761
846
|
]
|
|
@@ -763,9 +848,9 @@ var ThreadPlugin = () => {
|
|
|
763
848
|
};
|
|
764
849
|
} else {
|
|
765
850
|
return {
|
|
766
|
-
data: (0, import_echo_schema2.create)(
|
|
851
|
+
data: (0, import_echo_schema2.create)(import_types.ChannelType, {
|
|
767
852
|
threads: [
|
|
768
|
-
(0, import_echo_schema2.create)(
|
|
853
|
+
(0, import_echo_schema2.create)(import_types.ThreadType, {
|
|
769
854
|
messages: []
|
|
770
855
|
})
|
|
771
856
|
]
|
|
@@ -773,16 +858,27 @@ var ThreadPlugin = () => {
|
|
|
773
858
|
};
|
|
774
859
|
}
|
|
775
860
|
}
|
|
776
|
-
case
|
|
777
|
-
state.focus = intent.data?.current === state.current ? state.focus : intent.data?.focus;
|
|
861
|
+
case import_chunk_FOZUQZF4.ThreadAction.SELECT: {
|
|
778
862
|
state.current = intent.data?.current;
|
|
779
863
|
return {
|
|
780
|
-
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
|
+
] : []
|
|
781
877
|
};
|
|
782
878
|
}
|
|
783
|
-
case
|
|
879
|
+
case import_chunk_FOZUQZF4.ThreadAction.TOGGLE_RESOLVED: {
|
|
784
880
|
const { thread } = intent.data ?? {};
|
|
785
|
-
if (!(thread instanceof
|
|
881
|
+
if (!(thread instanceof import_types.ThreadType)) {
|
|
786
882
|
return;
|
|
787
883
|
}
|
|
788
884
|
if (thread.status === "active" || thread.status === void 0) {
|
|
@@ -793,6 +889,7 @@ var ThreadPlugin = () => {
|
|
|
793
889
|
const space = (0, import_echo.getSpace)(thread);
|
|
794
890
|
const spaceId = space?.id;
|
|
795
891
|
return {
|
|
892
|
+
data: true,
|
|
796
893
|
intents: [
|
|
797
894
|
[
|
|
798
895
|
{
|
|
@@ -809,18 +906,20 @@ var ThreadPlugin = () => {
|
|
|
809
906
|
]
|
|
810
907
|
};
|
|
811
908
|
}
|
|
812
|
-
case
|
|
909
|
+
case import_chunk_FOZUQZF4.ThreadAction.DELETE: {
|
|
813
910
|
const { subject, thread } = intent.data ?? {};
|
|
814
|
-
if (!(
|
|
911
|
+
if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject)) {
|
|
815
912
|
return;
|
|
816
913
|
}
|
|
817
914
|
const subjectId = (0, import_echo.fullyQualifiedId)(subject);
|
|
818
|
-
const
|
|
819
|
-
if (
|
|
820
|
-
const index =
|
|
915
|
+
const draft = state.drafts[subjectId];
|
|
916
|
+
if (draft) {
|
|
917
|
+
const index = draft.findIndex((t) => t.id === thread.id);
|
|
821
918
|
if (index !== -1) {
|
|
822
|
-
|
|
823
|
-
return
|
|
919
|
+
draft.splice(index, 1);
|
|
920
|
+
return {
|
|
921
|
+
data: true
|
|
922
|
+
};
|
|
824
923
|
}
|
|
825
924
|
}
|
|
826
925
|
const space = (0, import_echo.getSpace)(thread);
|
|
@@ -836,7 +935,7 @@ var ThreadPlugin = () => {
|
|
|
836
935
|
space.db.remove(thread);
|
|
837
936
|
return {
|
|
838
937
|
undoable: {
|
|
839
|
-
message: translations_default[0]["en-US"][
|
|
938
|
+
message: translations_default[0]["en-US"][import_chunk_JIJ7Z6NO.THREAD_PLUGIN]["thread deleted label"],
|
|
840
939
|
data: {
|
|
841
940
|
cursor
|
|
842
941
|
}
|
|
@@ -879,9 +978,9 @@ var ThreadPlugin = () => {
|
|
|
879
978
|
}
|
|
880
979
|
break;
|
|
881
980
|
}
|
|
882
|
-
case
|
|
981
|
+
case import_chunk_FOZUQZF4.ThreadAction.ON_MESSAGE_ADD: {
|
|
883
982
|
const { thread, subject } = intent.data ?? {};
|
|
884
|
-
if (!(thread instanceof
|
|
983
|
+
if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject && Array.isArray(subject.threads))) {
|
|
885
984
|
return;
|
|
886
985
|
}
|
|
887
986
|
const subjectId = (0, import_echo.fullyQualifiedId)(subject);
|
|
@@ -891,12 +990,12 @@ var ThreadPlugin = () => {
|
|
|
891
990
|
threadId: thread.id,
|
|
892
991
|
spaceId: space?.id
|
|
893
992
|
};
|
|
894
|
-
if (state.
|
|
993
|
+
if (state.drafts[subjectId]?.find((t) => t === thread)) {
|
|
895
994
|
thread.status = "active";
|
|
896
995
|
subject.threads ? subject.threads.push(thread) : subject.threads = [
|
|
897
996
|
thread
|
|
898
997
|
];
|
|
899
|
-
state.
|
|
998
|
+
state.drafts[subjectId] = state.drafts[subjectId]?.filter(({ id }) => id !== thread.id);
|
|
900
999
|
intents.push({
|
|
901
1000
|
action: import_meta.ObservabilityAction.SEND_EVENT,
|
|
902
1001
|
data: {
|
|
@@ -922,10 +1021,10 @@ var ThreadPlugin = () => {
|
|
|
922
1021
|
]
|
|
923
1022
|
};
|
|
924
1023
|
}
|
|
925
|
-
case
|
|
1024
|
+
case import_chunk_FOZUQZF4.ThreadAction.DELETE_MESSAGE: {
|
|
926
1025
|
const { subject, thread, messageId } = intent.data ?? {};
|
|
927
1026
|
const space = (0, import_echo.getSpace)(subject);
|
|
928
|
-
if (!(
|
|
1027
|
+
if (!(thread instanceof import_types.ThreadType) || !(subject && typeof subject === "object" && "threads" in subject)) {
|
|
929
1028
|
return;
|
|
930
1029
|
}
|
|
931
1030
|
if (!intent.undo) {
|
|
@@ -939,7 +1038,7 @@ var ThreadPlugin = () => {
|
|
|
939
1038
|
intents: [
|
|
940
1039
|
[
|
|
941
1040
|
{
|
|
942
|
-
action:
|
|
1041
|
+
action: import_chunk_FOZUQZF4.ThreadAction.DELETE,
|
|
943
1042
|
data: {
|
|
944
1043
|
subject,
|
|
945
1044
|
thread
|
|
@@ -953,7 +1052,7 @@ var ThreadPlugin = () => {
|
|
|
953
1052
|
}
|
|
954
1053
|
return {
|
|
955
1054
|
undoable: {
|
|
956
|
-
message: translations_default[0]["en-US"][
|
|
1055
|
+
message: translations_default[0]["en-US"][import_chunk_JIJ7Z6NO.THREAD_PLUGIN]["message deleted label"],
|
|
957
1056
|
data: {
|
|
958
1057
|
message,
|
|
959
1058
|
messageIndex
|
|
@@ -967,7 +1066,7 @@ var ThreadPlugin = () => {
|
|
|
967
1066
|
name: "threads.message.delete",
|
|
968
1067
|
properties: {
|
|
969
1068
|
threadId: thread.id,
|
|
970
|
-
spaceId: space
|
|
1069
|
+
spaceId: space?.id
|
|
971
1070
|
}
|
|
972
1071
|
}
|
|
973
1072
|
}
|
|
@@ -977,7 +1076,7 @@ var ThreadPlugin = () => {
|
|
|
977
1076
|
} else if (intent.undo) {
|
|
978
1077
|
const message = intent.data?.message;
|
|
979
1078
|
const messageIndex = intent.data?.messageIndex;
|
|
980
|
-
if (!(message instanceof
|
|
1079
|
+
if (!(message instanceof import_types.MessageType) || !(typeof messageIndex === "number")) {
|
|
981
1080
|
return;
|
|
982
1081
|
}
|
|
983
1082
|
thread.messages.splice(messageIndex, 0, message);
|
|
@@ -991,7 +1090,7 @@ var ThreadPlugin = () => {
|
|
|
991
1090
|
name: "threads.message.undo-delete",
|
|
992
1091
|
properties: {
|
|
993
1092
|
threadId: thread.id,
|
|
994
|
-
spaceId: space
|
|
1093
|
+
spaceId: space?.id
|
|
995
1094
|
}
|
|
996
1095
|
}
|
|
997
1096
|
}
|
|
@@ -1004,92 +1103,8 @@ var ThreadPlugin = () => {
|
|
|
1004
1103
|
}
|
|
1005
1104
|
},
|
|
1006
1105
|
markdown: {
|
|
1007
|
-
// TODO(burdon): Factor out extension factory into separate file (for simplicity).
|
|
1008
1106
|
extensions: ({ document: doc }) => {
|
|
1009
|
-
|
|
1010
|
-
if (!doc || !space) {
|
|
1011
|
-
return [
|
|
1012
|
-
(0, import_react_ui_editor.comments)()
|
|
1013
|
-
];
|
|
1014
|
-
}
|
|
1015
|
-
const threads = (0, import_signals_core.computed)(() => [
|
|
1016
|
-
...doc.threads.filter(import_util.nonNullable),
|
|
1017
|
-
...state.staging[(0, import_echo.fullyQualifiedId)(doc)] ?? []
|
|
1018
|
-
].filter((thread) => !(thread?.status === "resolved")));
|
|
1019
|
-
return [
|
|
1020
|
-
(0, import_react_ui_editor.listener)({
|
|
1021
|
-
onChange: () => {
|
|
1022
|
-
doc.threads.forEach((thread) => {
|
|
1023
|
-
if (thread?.anchor) {
|
|
1024
|
-
const [start, end] = thread.anchor.split(":");
|
|
1025
|
-
const name = doc.content && (0, import_echo.getTextInRange)((0, import_echo.createDocAccessor)(doc.content, [
|
|
1026
|
-
"content"
|
|
1027
|
-
]), start, end);
|
|
1028
|
-
if (name && name !== thread.name) {
|
|
1029
|
-
thread.name = name;
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
});
|
|
1033
|
-
}
|
|
1034
|
-
}),
|
|
1035
|
-
(0, import_react_ui_editor.createExternalCommentSync)(doc.id, (sink) => (0, import_signals_core.effect)(() => sink()), () => threads.value.filter((thread) => thread?.anchor).map((thread) => ({
|
|
1036
|
-
id: thread.id,
|
|
1037
|
-
cursor: thread.anchor
|
|
1038
|
-
}))),
|
|
1039
|
-
(0, import_react_ui_editor.comments)({
|
|
1040
|
-
id: doc.id,
|
|
1041
|
-
onCreate: ({ cursor }) => {
|
|
1042
|
-
const [start, end] = cursor.split(":");
|
|
1043
|
-
const name = doc.content && (0, import_echo.getTextInRange)((0, import_echo.createDocAccessor)(doc.content, [
|
|
1044
|
-
"content"
|
|
1045
|
-
]), start, end);
|
|
1046
|
-
void intentPlugin?.provides.intent.dispatch({
|
|
1047
|
-
action: import_chunk_D5GOVXHS.ThreadAction.CREATE,
|
|
1048
|
-
data: {
|
|
1049
|
-
cursor,
|
|
1050
|
-
name,
|
|
1051
|
-
subject: doc
|
|
1052
|
-
}
|
|
1053
|
-
});
|
|
1054
|
-
},
|
|
1055
|
-
onDelete: ({ id }) => {
|
|
1056
|
-
const stagingArea = state.staging[(0, import_echo.fullyQualifiedId)(doc)];
|
|
1057
|
-
if (stagingArea) {
|
|
1058
|
-
const index = stagingArea.findIndex((thread2) => thread2.id === id);
|
|
1059
|
-
if (index !== -1) {
|
|
1060
|
-
stagingArea.splice(index, 1);
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
const thread = doc.threads.find((thread2) => thread2?.id === id);
|
|
1064
|
-
if (thread) {
|
|
1065
|
-
thread.anchor = void 0;
|
|
1066
|
-
}
|
|
1067
|
-
},
|
|
1068
|
-
onUpdate: ({ id, cursor }) => {
|
|
1069
|
-
const thread = state.staging[(0, import_echo.fullyQualifiedId)(doc)]?.find((thread2) => thread2.id === id) ?? doc.threads.find((thread2) => thread2?.id === id);
|
|
1070
|
-
if (thread instanceof import_types2.ThreadType && thread.anchor) {
|
|
1071
|
-
const [start, end] = thread.anchor.split(":");
|
|
1072
|
-
thread.name = doc.content && (0, import_echo.getTextInRange)((0, import_echo.createDocAccessor)(doc.content, [
|
|
1073
|
-
"content"
|
|
1074
|
-
]), start, end);
|
|
1075
|
-
thread.anchor = cursor;
|
|
1076
|
-
}
|
|
1077
|
-
},
|
|
1078
|
-
onSelect: ({ selection: { current, closest } }) => {
|
|
1079
|
-
const dispatch2 = intentPlugin?.provides.intent.dispatch;
|
|
1080
|
-
if (dispatch2) {
|
|
1081
|
-
void dispatch2([
|
|
1082
|
-
{
|
|
1083
|
-
action: import_chunk_D5GOVXHS.ThreadAction.SELECT,
|
|
1084
|
-
data: {
|
|
1085
|
-
current: current ?? closest
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
]);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
})
|
|
1092
|
-
];
|
|
1107
|
+
return threads(state, doc, intentPlugin?.provides.intent.dispatch);
|
|
1093
1108
|
}
|
|
1094
1109
|
}
|
|
1095
1110
|
}
|