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