@univerjs/thread-comment-ui 1.0.0-rc.0 → 1.0.0
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/lib/cjs/index.js +308 -47
- package/lib/cjs/locale/ar-SA.js +2 -1
- package/lib/cjs/locale/ca-ES.js +2 -1
- package/lib/cjs/locale/de-DE.js +2 -1
- package/lib/cjs/locale/en-US.js +2 -1
- package/lib/cjs/locale/es-ES.js +2 -1
- package/lib/cjs/locale/fa-IR.js +2 -1
- package/lib/cjs/locale/fr-FR.js +2 -1
- package/lib/cjs/locale/id-ID.js +2 -1
- package/lib/cjs/locale/it-IT.js +2 -1
- package/lib/cjs/locale/ja-JP.js +2 -1
- package/lib/cjs/locale/ko-KR.js +2 -1
- package/lib/cjs/locale/pl-PL.js +2 -1
- package/lib/cjs/locale/pt-BR.js +2 -1
- package/lib/cjs/locale/ru-RU.js +2 -1
- package/lib/cjs/locale/sk-SK.js +2 -1
- package/lib/cjs/locale/vi-VN.js +2 -1
- package/lib/cjs/locale/zh-CN.js +2 -1
- package/lib/cjs/locale/zh-HK.js +2 -1
- package/lib/cjs/locale/zh-TW.js +2 -1
- package/lib/es/index.js +310 -49
- package/lib/es/locale/ar-SA.js +2 -0
- package/lib/es/locale/ca-ES.js +2 -0
- package/lib/es/locale/de-DE.js +2 -0
- package/lib/es/locale/en-US.js +2 -0
- package/lib/es/locale/es-ES.js +2 -0
- package/lib/es/locale/fa-IR.js +2 -0
- package/lib/es/locale/fr-FR.js +2 -0
- package/lib/es/locale/id-ID.js +2 -0
- package/lib/es/locale/it-IT.js +2 -0
- package/lib/es/locale/ja-JP.js +2 -0
- package/lib/es/locale/ko-KR.js +2 -0
- package/lib/es/locale/pl-PL.js +2 -0
- package/lib/es/locale/pt-BR.js +2 -0
- package/lib/es/locale/ru-RU.js +2 -0
- package/lib/es/locale/sk-SK.js +2 -0
- package/lib/es/locale/vi-VN.js +2 -0
- package/lib/es/locale/zh-CN.js +2 -0
- package/lib/es/locale/zh-HK.js +2 -0
- package/lib/es/locale/zh-TW.js +2 -0
- package/lib/index.css +118 -1
- package/lib/index.js +310 -49
- package/lib/locale/ar-SA.js +2 -0
- package/lib/locale/ca-ES.js +2 -0
- package/lib/locale/de-DE.js +2 -0
- package/lib/locale/en-US.js +2 -0
- package/lib/locale/es-ES.js +2 -0
- package/lib/locale/fa-IR.js +2 -0
- package/lib/locale/fr-FR.js +2 -0
- package/lib/locale/id-ID.js +2 -0
- package/lib/locale/it-IT.js +2 -0
- package/lib/locale/ja-JP.js +2 -0
- package/lib/locale/ko-KR.js +2 -0
- package/lib/locale/pl-PL.js +2 -0
- package/lib/locale/pt-BR.js +2 -0
- package/lib/locale/ru-RU.js +2 -0
- package/lib/locale/sk-SK.js +2 -0
- package/lib/locale/vi-VN.js +2 -0
- package/lib/locale/zh-CN.js +2 -0
- package/lib/locale/zh-HK.js +2 -0
- package/lib/locale/zh-TW.js +2 -0
- package/lib/types/locale/en-US.d.ts +4 -0
- package/lib/types/views/ThreadCommentPanel.d.ts +0 -5
- package/lib/types/views/thread-comment-editor/index.d.ts +37 -0
- package/lib/types/views/thread-comment-panel/index.d.ts +37 -0
- package/lib/types/views/thread-comment-tree/index.d.ts +59 -0
- package/lib/umd/index.js +11 -4
- package/lib/umd/locale/ar-SA.js +1 -1
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -1
- package/lib/umd/locale/it-IT.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -1
- package/lib/umd/locale/pt-BR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +11 -11
package/lib/cjs/index.js
CHANGED
|
@@ -10,7 +10,7 @@ let _univerjs_icons = require("@univerjs/icons");
|
|
|
10
10
|
let react = require("react");
|
|
11
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
12
|
|
|
13
|
-
//#region \0@oxc-project+runtime@0.
|
|
13
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
|
|
14
14
|
function _typeof(o) {
|
|
15
15
|
"@babel/helpers - typeof";
|
|
16
16
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -21,7 +21,7 @@ function _typeof(o) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
|
-
//#region \0@oxc-project+runtime@0.
|
|
24
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
|
|
25
25
|
function toPrimitive(t, r) {
|
|
26
26
|
if ("object" != _typeof(t) || !t) return t;
|
|
27
27
|
var e = t[Symbol.toPrimitive];
|
|
@@ -34,14 +34,14 @@ function toPrimitive(t, r) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
|
-
//#region \0@oxc-project+runtime@0.
|
|
37
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
|
|
38
38
|
function toPropertyKey(t) {
|
|
39
39
|
var i = toPrimitive(t, "string");
|
|
40
40
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
//#endregion
|
|
44
|
-
//#region \0@oxc-project+runtime@0.
|
|
44
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
|
|
45
45
|
function _defineProperty(e, r, t) {
|
|
46
46
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
47
47
|
value: t,
|
|
@@ -52,7 +52,7 @@ function _defineProperty(e, r, t) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
//#endregion
|
|
55
|
-
//#region \0@oxc-project+runtime@0.
|
|
55
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
|
|
56
56
|
function __decorateParam(paramIndex, decorator) {
|
|
57
57
|
return function(target, key) {
|
|
58
58
|
decorator(target, key, paramIndex);
|
|
@@ -60,7 +60,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
//#endregion
|
|
63
|
-
//#region \0@oxc-project+runtime@0.
|
|
63
|
+
//#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
|
|
64
64
|
function __decorate(decorators, target, key, desc) {
|
|
65
65
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
66
66
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -134,7 +134,7 @@ const SetActiveCommentOperation = {
|
|
|
134
134
|
//#endregion
|
|
135
135
|
//#region package.json
|
|
136
136
|
var name = "@univerjs/thread-comment-ui";
|
|
137
|
-
var version = "1.0.0
|
|
137
|
+
var version = "1.0.0";
|
|
138
138
|
|
|
139
139
|
//#endregion
|
|
140
140
|
//#region src/config/config.ts
|
|
@@ -507,7 +507,8 @@ const transformDocument2TextNodes = (doc) => {
|
|
|
507
507
|
if (!doc) return [];
|
|
508
508
|
const { paragraphs = [] } = doc;
|
|
509
509
|
return paragraphs.map((paragraph, index) => {
|
|
510
|
-
const
|
|
510
|
+
const lastIndex = index === 0 ? 0 : paragraphs[index - 1].startIndex + 1;
|
|
511
|
+
const body = (0, _univerjs_core.getBodySlice)(doc, lastIndex, paragraph.startIndex);
|
|
511
512
|
return transformDocument2TextNodesInParagraph(body);
|
|
512
513
|
});
|
|
513
514
|
};
|
|
@@ -533,7 +534,6 @@ const transformTextNodes2Document = (nodes) => {
|
|
|
533
534
|
});
|
|
534
535
|
break;
|
|
535
536
|
}
|
|
536
|
-
default: break;
|
|
537
537
|
}
|
|
538
538
|
});
|
|
539
539
|
str += "\r\n";
|
|
@@ -759,6 +759,7 @@ const ThreadCommentItem = (props) => {
|
|
|
759
759
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
760
760
|
const regionService = (0, _univerjs_ui.useDependency)(_univerjs_core.RegionService);
|
|
761
761
|
const userManagerService = (0, _univerjs_ui.useDependency)(_univerjs_core.UserManagerService);
|
|
762
|
+
(0, _univerjs_ui.useObservable)(userManagerService.userChange$);
|
|
762
763
|
const user = userManagerService.getUser(item.personId);
|
|
763
764
|
const currentUser = (0, _univerjs_ui.useObservable)(userManagerService.currentUser$);
|
|
764
765
|
const isCommentBySelf = (currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID) === item.personId;
|
|
@@ -793,11 +794,11 @@ const ThreadCommentItem = (props) => {
|
|
|
793
794
|
className: "univer-absolute univer-left-0 univer-top-0 univer-size-6 univer-rounded-full univer-bg-cover univer-bg-center univer-bg-no-repeat rtl:univer-left-auto rtl:univer-right-0",
|
|
794
795
|
style: { backgroundImage: `url(${(user === null || user === void 0 ? void 0 : user.avatar) || avatarFallback})` }
|
|
795
796
|
}),
|
|
796
|
-
user ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
797
|
+
user || item.authorName ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
797
798
|
className: "univer-mb-1 univer-flex univer-h-6 univer-items-center univer-justify-between",
|
|
798
799
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
799
800
|
className: "univer-text-sm univer-font-medium univer-leading-5",
|
|
800
|
-
children: (user === null || user === void 0 ? void 0 : user.name) || " "
|
|
801
|
+
children: (user === null || user === void 0 ? void 0 : user.name) || item.authorName || " "
|
|
801
802
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [isMock || resolved ? null : showReply && user ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
802
803
|
type: "button",
|
|
803
804
|
"aria-label": localeService.t("thread-comment-ui.editor.reply"),
|
|
@@ -1092,10 +1093,298 @@ const ThreadCommentTree = (props) => {
|
|
|
1092
1093
|
});
|
|
1093
1094
|
};
|
|
1094
1095
|
|
|
1096
|
+
//#endregion
|
|
1097
|
+
//#region src/views/mobile/MobileThreadCommentEditor.tsx
|
|
1098
|
+
const MobileThreadCommentEditor = (0, react.forwardRef)((props, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentEditor, {
|
|
1099
|
+
...props,
|
|
1100
|
+
ref,
|
|
1101
|
+
ActionRowComponent: _univerjs_design.MobileActionRowGroup
|
|
1102
|
+
}));
|
|
1103
|
+
|
|
1104
|
+
//#endregion
|
|
1105
|
+
//#region src/views/mobile/MobileThreadCommentTree.tsx
|
|
1106
|
+
function MobileThreadCommentTree(props) {
|
|
1107
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentTree, {
|
|
1108
|
+
...props,
|
|
1109
|
+
DropdownComponent: _univerjs_design.MobileDropdown,
|
|
1110
|
+
EditorComponent: MobileThreadCommentEditor
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
//#endregion
|
|
1115
|
+
//#region src/views/mobile/MobileThreadCommentPanel.tsx
|
|
1116
|
+
function MobileCommentFilter({ value, options = [], onChange }) {
|
|
1117
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1118
|
+
className: "univer-flex univer-gap-1 univer-overflow-x-auto univer-rounded-xl univer-bg-gray-100 univer-p-1 dark:!univer-bg-gray-800",
|
|
1119
|
+
children: options.flatMap((option) => option.options ?? [option]).map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1120
|
+
type: "button",
|
|
1121
|
+
"aria-pressed": option.value === value,
|
|
1122
|
+
className: (0, _univerjs_design.clsx)(_univerjs_design.resetButtonClassName, "univer-h-10 univer-shrink-0 univer-rounded-lg univer-px-3 univer-text-sm univer-text-gray-700 active:univer-scale-95 dark:!univer-text-gray-200", option.value === value && "univer-bg-gray-0 univer-font-medium univer-text-primary-600 univer-shadow-sm dark:!univer-bg-gray-700 dark:!univer-text-primary-300"),
|
|
1123
|
+
onClick: () => option.value != null && (onChange === null || onChange === void 0 ? void 0 : onChange(option.value)),
|
|
1124
|
+
children: option.label
|
|
1125
|
+
}, option.value))
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
function MobileCommentHeader({ comment: activeComment, displayRef }) {
|
|
1129
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1130
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
1131
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1132
|
+
className: "univer-mt-2 univer-flex univer-min-h-12 univer-items-center univer-gap-2 univer-border-0 univer-border-b univer-border-solid univer-border-gray-200 univer-pb-2 dark:!univer-border-gray-700",
|
|
1133
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1134
|
+
type: "button",
|
|
1135
|
+
"aria-label": localeService.t("thread-comment-ui.mobile.back"),
|
|
1136
|
+
className: `
|
|
1137
|
+
${_univerjs_design.resetButtonClassName}
|
|
1138
|
+
univer-flex univer-size-12 univer-shrink-0 univer-items-center univer-justify-center univer-rounded-xl
|
|
1139
|
+
univer-text-2xl univer-text-gray-700
|
|
1140
|
+
active:univer-bg-gray-100
|
|
1141
|
+
dark:!univer-text-gray-200
|
|
1142
|
+
dark:active:!univer-bg-gray-700
|
|
1143
|
+
`,
|
|
1144
|
+
onClick: () => commandService.executeCommand(SetActiveCommentOperation.id),
|
|
1145
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.MoreLeftIcon, {})
|
|
1146
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1147
|
+
className: "univer-min-w-0 univer-flex-1",
|
|
1148
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1149
|
+
className: "univer-truncate univer-text-base univer-font-semibold univer-text-gray-900 dark:!univer-text-gray-0",
|
|
1150
|
+
children: localeService.t("thread-comment-ui.panel.title")
|
|
1151
|
+
}), activeComment.ref && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1152
|
+
className: "univer-truncate univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",
|
|
1153
|
+
children: displayRef ?? activeComment.ref
|
|
1154
|
+
})]
|
|
1155
|
+
})]
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
function MobileAddComment({ onAdd }) {
|
|
1159
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1160
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileActionRowGroup, {
|
|
1161
|
+
className: "univer-mt-3",
|
|
1162
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
1163
|
+
className: "univer-w-full",
|
|
1164
|
+
onClick: onAdd,
|
|
1165
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.IncreaseIcon, { className: "univer-mr-1.5" }), localeService.t("thread-comment-ui.panel.addComment")]
|
|
1166
|
+
})
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
function MobileThreadCommentPanel(props) {
|
|
1170
|
+
const { unitId, subUnitId$, type, onAdd, getSubUnitName, onResolve, sortComments, onItemLeave, onItemEnter, disableAdd, tempComment, onAddComment, onDeleteComment, onAfterDeleteComment, showComments, formatRef, onTempCommentClose, autoFocusActiveComment = false } = props;
|
|
1171
|
+
const [unit, setUnit] = (0, react.useState)("all");
|
|
1172
|
+
const [status, setStatus] = (0, react.useState)("all");
|
|
1173
|
+
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
1174
|
+
const userService = (0, _univerjs_ui.useDependency)(_univerjs_core.UserManagerService);
|
|
1175
|
+
const threadCommentModel = (0, _univerjs_ui.useDependency)(_univerjs_thread_comment.ThreadCommentModel);
|
|
1176
|
+
const panelService = (0, _univerjs_ui.useDependency)(ThreadCommentPanelService);
|
|
1177
|
+
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
1178
|
+
const activeCommentId = (0, _univerjs_ui.useObservable)(panelService.activeCommentId$);
|
|
1179
|
+
(0, _univerjs_ui.useObservable)(threadCommentModel.commentUpdate$);
|
|
1180
|
+
const subUnitId = (0, _univerjs_ui.useObservable)(subUnitId$);
|
|
1181
|
+
const currentUser = (0, _univerjs_ui.useObservable)(userService.currentUser$);
|
|
1182
|
+
const shouldScrollRef = (0, react.useRef)(true);
|
|
1183
|
+
const location = "PANEL";
|
|
1184
|
+
const unitComments = threadCommentModel.getUnit(unitId);
|
|
1185
|
+
const scopedTempComment = (tempComment === null || tempComment === void 0 ? void 0 : tempComment.unitId) === unitId ? tempComment : null;
|
|
1186
|
+
const activeExists = activeCommentId ? Boolean(threadCommentModel.getComment(activeCommentId.unitId, activeCommentId.subUnitId, activeCommentId.commentId) || scopedTempComment && isSameThreadCommentTarget(activeCommentId, scopedTempComment)) : false;
|
|
1187
|
+
const shouldClearActiveTarget = shouldClearThreadCommentTarget(activeCommentId, unitId, activeExists);
|
|
1188
|
+
const comments = (0, react.useMemo)(() => {
|
|
1189
|
+
const allComments = unit === "all" && type !== _univerjs_core.UniverInstanceType.UNIVER_SLIDE ? unitComments : unitComments.filter((comment) => comment.subUnitId === subUnitId);
|
|
1190
|
+
const sortedComments = sortComments ?? ((commentList) => commentList);
|
|
1191
|
+
const result = allComments.map((comment) => ({
|
|
1192
|
+
...comment.root,
|
|
1193
|
+
children: comment.children ?? [],
|
|
1194
|
+
users: comment.relativeUsers
|
|
1195
|
+
}));
|
|
1196
|
+
if (!showComments) return sortedComments(result);
|
|
1197
|
+
const commentMap = new Map(result.map((comment) => [comment.id, comment]));
|
|
1198
|
+
return [...showComments, ""].map((id) => commentMap.get(id)).filter(Boolean);
|
|
1199
|
+
}, [
|
|
1200
|
+
showComments,
|
|
1201
|
+
sortComments,
|
|
1202
|
+
subUnitId,
|
|
1203
|
+
type,
|
|
1204
|
+
unit,
|
|
1205
|
+
unitComments
|
|
1206
|
+
]);
|
|
1207
|
+
const commentsSorted = (0, react.useMemo)(() => [...comments.filter((comment) => !comment.resolved), ...comments.filter((comment) => comment.resolved)], [comments]);
|
|
1208
|
+
const statusComments = (0, react.useMemo)(() => {
|
|
1209
|
+
if (status === "resolved") return commentsSorted.filter((comment) => comment.resolved);
|
|
1210
|
+
if (status === "unsolved") return commentsSorted.filter((comment) => !comment.resolved);
|
|
1211
|
+
if (status === "concern_me" && (currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID)) return commentsSorted.filter((comment) => comment.users.has(currentUser.userID));
|
|
1212
|
+
return commentsSorted;
|
|
1213
|
+
}, [
|
|
1214
|
+
commentsSorted,
|
|
1215
|
+
currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID,
|
|
1216
|
+
status
|
|
1217
|
+
]);
|
|
1218
|
+
const renderComments = scopedTempComment ? [scopedTempComment, ...statusComments] : statusComments;
|
|
1219
|
+
const activeComment = activeCommentId ? renderComments.find((comment) => isSameThreadCommentTarget(activeCommentId, comment)) : void 0;
|
|
1220
|
+
const visibleComments = activeComment ? [activeComment] : renderComments;
|
|
1221
|
+
const unsolvedComments = visibleComments.filter((comment) => !comment.resolved);
|
|
1222
|
+
const solvedComments = visibleComments.filter((comment) => comment.resolved);
|
|
1223
|
+
const isFiltering = status !== "all" || unit !== "all";
|
|
1224
|
+
const unitFilterOptions = [{
|
|
1225
|
+
value: "current",
|
|
1226
|
+
label: localeService.t("thread-comment-ui.filter.sheet.current")
|
|
1227
|
+
}, {
|
|
1228
|
+
value: "all",
|
|
1229
|
+
label: localeService.t("thread-comment-ui.filter.sheet.all")
|
|
1230
|
+
}];
|
|
1231
|
+
const statusFilterOptions = [
|
|
1232
|
+
{
|
|
1233
|
+
value: "all",
|
|
1234
|
+
label: localeService.t("thread-comment-ui.filter.status.all")
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
value: "resolved",
|
|
1238
|
+
label: localeService.t("thread-comment-ui.filter.status.resolved")
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
value: "unsolved",
|
|
1242
|
+
label: localeService.t("thread-comment-ui.filter.status.unsolved")
|
|
1243
|
+
},
|
|
1244
|
+
{
|
|
1245
|
+
value: "concern_me",
|
|
1246
|
+
label: localeService.t("thread-comment-ui.filter.status.concernMe")
|
|
1247
|
+
}
|
|
1248
|
+
];
|
|
1249
|
+
const handleReset = () => {
|
|
1250
|
+
setStatus("all");
|
|
1251
|
+
setUnit("all");
|
|
1252
|
+
};
|
|
1253
|
+
(0, react.useEffect)(() => {
|
|
1254
|
+
if (shouldClearActiveTarget) panelService.setActiveComment(void 0);
|
|
1255
|
+
}, [panelService, shouldClearActiveTarget]);
|
|
1256
|
+
(0, react.useEffect)(() => {
|
|
1257
|
+
if (tempComment && (tempComment.unitId !== unitId || subUnitId && tempComment.subUnitId !== subUnitId)) onTempCommentClose === null || onTempCommentClose === void 0 || onTempCommentClose();
|
|
1258
|
+
}, [
|
|
1259
|
+
onTempCommentClose,
|
|
1260
|
+
subUnitId,
|
|
1261
|
+
tempComment,
|
|
1262
|
+
unitId
|
|
1263
|
+
]);
|
|
1264
|
+
(0, react.useEffect)(() => {
|
|
1265
|
+
if (!activeCommentId) return;
|
|
1266
|
+
const handlePointerDown = (event) => {
|
|
1267
|
+
const activeTarget = panelService.activeCommentId;
|
|
1268
|
+
const target = event.target;
|
|
1269
|
+
if (event.button !== 0 || !activeTarget || !(target instanceof Element)) return;
|
|
1270
|
+
const activeElement = document.getElementById(`${location}-${activeTarget.unitId}-${activeTarget.subUnitId}-${activeTarget.commentId}`);
|
|
1271
|
+
if ((activeElement === null || activeElement === void 0 ? void 0 : activeElement.contains(target)) || target.closest("button, input, textarea, select, a, [contenteditable=\"true\"], [role=\"menu\"], [role=\"menuitem\"], [role=\"option\"], [role=\"listbox\"], [role=\"combobox\"], [role=\"separator\"]")) return;
|
|
1272
|
+
commandService.executeCommand(SetActiveCommentOperation.id);
|
|
1273
|
+
if (scopedTempComment && isSameThreadCommentTarget(activeTarget, scopedTempComment)) onTempCommentClose === null || onTempCommentClose === void 0 || onTempCommentClose();
|
|
1274
|
+
};
|
|
1275
|
+
document.addEventListener("pointerdown", handlePointerDown, true);
|
|
1276
|
+
return () => document.removeEventListener("pointerdown", handlePointerDown, true);
|
|
1277
|
+
}, [
|
|
1278
|
+
activeCommentId,
|
|
1279
|
+
commandService,
|
|
1280
|
+
location,
|
|
1281
|
+
onTempCommentClose,
|
|
1282
|
+
panelService,
|
|
1283
|
+
scopedTempComment
|
|
1284
|
+
]);
|
|
1285
|
+
(0, react.useEffect)(() => {
|
|
1286
|
+
var _document$getElementB;
|
|
1287
|
+
if (!activeCommentId) return;
|
|
1288
|
+
if (!shouldScrollRef.current) {
|
|
1289
|
+
shouldScrollRef.current = true;
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
const { unitId: activeUnitId, subUnitId: activeSubUnitId, commentId } = activeCommentId;
|
|
1293
|
+
(_document$getElementB = document.getElementById(`${location}-${activeUnitId}-${activeSubUnitId}-${commentId}`)) === null || _document$getElementB === void 0 || _document$getElementB.scrollIntoView({ block: "center" });
|
|
1294
|
+
}, [activeCommentId, location]);
|
|
1295
|
+
const renderComment = (section) => (comment, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileThreadCommentTree, {
|
|
1296
|
+
full: true,
|
|
1297
|
+
location,
|
|
1298
|
+
getSubUnitName,
|
|
1299
|
+
id: comment.id,
|
|
1300
|
+
unitId: comment.unitId,
|
|
1301
|
+
subUnitId: comment.subUnitId,
|
|
1302
|
+
refStr: comment.ref,
|
|
1303
|
+
displayRef: formatRef === null || formatRef === void 0 ? void 0 : formatRef(comment),
|
|
1304
|
+
type,
|
|
1305
|
+
showEdit: !comment.id || isSameThreadCommentTarget(activeCommentId, comment),
|
|
1306
|
+
showHighlight: isSameThreadCommentTarget(activeCommentId, comment),
|
|
1307
|
+
autoFocus: autoFocusActiveComment && isSameThreadCommentTarget(activeCommentId, comment),
|
|
1308
|
+
onClick: () => {
|
|
1309
|
+
shouldScrollRef.current = false;
|
|
1310
|
+
if (comment.resolved) {
|
|
1311
|
+
commandService.executeCommand(SetActiveCommentOperation.id);
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
commandService.executeCommand(SetActiveCommentOperation.id, {
|
|
1315
|
+
unitId: comment.unitId,
|
|
1316
|
+
subUnitId: comment.subUnitId,
|
|
1317
|
+
commentId: comment.id,
|
|
1318
|
+
temp: false
|
|
1319
|
+
});
|
|
1320
|
+
},
|
|
1321
|
+
onMouseEnter: () => {
|
|
1322
|
+
panelService.setHoveredComment({
|
|
1323
|
+
unitId: comment.unitId,
|
|
1324
|
+
subUnitId: comment.subUnitId,
|
|
1325
|
+
commentId: comment.id,
|
|
1326
|
+
trigger: "panel-hover"
|
|
1327
|
+
});
|
|
1328
|
+
onItemEnter === null || onItemEnter === void 0 || onItemEnter(comment);
|
|
1329
|
+
},
|
|
1330
|
+
onMouseLeave: () => {
|
|
1331
|
+
if (isSameThreadCommentTarget(panelService.hoveredCommentId, comment)) panelService.setHoveredComment(void 0);
|
|
1332
|
+
onItemLeave === null || onItemLeave === void 0 || onItemLeave(comment);
|
|
1333
|
+
},
|
|
1334
|
+
onAddComment,
|
|
1335
|
+
onDeleteComment,
|
|
1336
|
+
onAfterDeleteComment,
|
|
1337
|
+
onResolve: (resolved) => onResolve === null || onResolve === void 0 ? void 0 : onResolve(comment.id, resolved),
|
|
1338
|
+
onClose: !comment.id ? onTempCommentClose : void 0
|
|
1339
|
+
}, getThreadCommentPanelItemKey(comment, index, section));
|
|
1340
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1341
|
+
className: "univer-flex univer-min-h-full univer-flex-col univer-pb-3",
|
|
1342
|
+
children: [
|
|
1343
|
+
activeComment && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileCommentHeader, {
|
|
1344
|
+
comment: activeComment,
|
|
1345
|
+
displayRef: formatRef === null || formatRef === void 0 ? void 0 : formatRef(activeComment)
|
|
1346
|
+
}),
|
|
1347
|
+
!activeComment && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1348
|
+
className: "univer-mt-3 univer-flex univer-flex-col univer-gap-2",
|
|
1349
|
+
children: [type === _univerjs_core.UniverInstanceType.UNIVER_SHEET && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileCommentFilter, {
|
|
1350
|
+
value: unit,
|
|
1351
|
+
options: unitFilterOptions,
|
|
1352
|
+
onChange: setUnit
|
|
1353
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileCommentFilter, {
|
|
1354
|
+
value: status,
|
|
1355
|
+
options: statusFilterOptions,
|
|
1356
|
+
onChange: setStatus
|
|
1357
|
+
})]
|
|
1358
|
+
}),
|
|
1359
|
+
!activeComment && !disableAdd && !scopedTempComment && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MobileAddComment, { onAdd }),
|
|
1360
|
+
visibleComments.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1361
|
+
className: "univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
|
|
1362
|
+
children: [localeService.t("thread-comment-ui.panel.empty"), isFiltering ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.MobileActionRowGroup, {
|
|
1363
|
+
className: "univer-mt-2 univer-flex univer-flex-row",
|
|
1364
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1365
|
+
onClick: handleReset,
|
|
1366
|
+
children: localeService.t("thread-comment-ui.panel.reset")
|
|
1367
|
+
})
|
|
1368
|
+
}) : null]
|
|
1369
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1370
|
+
className: "univer-mt-3 univer-flex univer-flex-col univer-gap-3",
|
|
1371
|
+
children: [
|
|
1372
|
+
unsolvedComments.map(renderComment("unsolved")),
|
|
1373
|
+
solvedComments.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1374
|
+
className: "univer-text-xs",
|
|
1375
|
+
children: localeService.t("thread-comment-ui.panel.solved")
|
|
1376
|
+
}),
|
|
1377
|
+
solvedComments.map(renderComment("solved"))
|
|
1378
|
+
]
|
|
1379
|
+
})
|
|
1380
|
+
]
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1095
1384
|
//#endregion
|
|
1096
1385
|
//#region src/views/ThreadCommentPanel.tsx
|
|
1097
1386
|
const ThreadCommentPanel = (props) => {
|
|
1098
|
-
const { unitId, subUnitId$, type, onAdd, getSubUnitName, onResolve, sortComments, onItemLeave, onItemEnter, disableAdd, tempComment, onAddComment, onDeleteComment, onAfterDeleteComment, showComments, formatRef, onTempCommentClose, autoFocusActiveComment = false
|
|
1387
|
+
const { unitId, subUnitId$, type, onAdd, getSubUnitName, onResolve, sortComments, onItemLeave, onItemEnter, disableAdd, tempComment, onAddComment, onDeleteComment, onAfterDeleteComment, showComments, formatRef, onTempCommentClose, autoFocusActiveComment = false } = props;
|
|
1099
1388
|
const [unit, setUnit] = (0, react.useState)("all");
|
|
1100
1389
|
const [status, setStatus] = (0, react.useState)("all");
|
|
1101
1390
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
@@ -1106,7 +1395,8 @@ const ThreadCommentPanel = (props) => {
|
|
|
1106
1395
|
(0, _univerjs_ui.useObservable)(threadCommentModel.commentUpdate$);
|
|
1107
1396
|
const unitComments = threadCommentModel.getUnit(unitId);
|
|
1108
1397
|
const scopedTempComment = (tempComment === null || tempComment === void 0 ? void 0 : tempComment.unitId) === unitId ? tempComment : null;
|
|
1109
|
-
const
|
|
1398
|
+
const activeExists = activeCommentId ? Boolean(threadCommentModel.getComment(activeCommentId.unitId, activeCommentId.subUnitId, activeCommentId.commentId) || scopedTempComment && isSameThreadCommentTarget(activeCommentId, scopedTempComment)) : false;
|
|
1399
|
+
const shouldClearActiveTarget = shouldClearThreadCommentTarget(activeCommentId, unitId, activeExists);
|
|
1110
1400
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
1111
1401
|
const subUnitId = (0, _univerjs_ui.useObservable)(subUnitId$);
|
|
1112
1402
|
const shouldScrollRef = (0, react.useRef)(true);
|
|
@@ -1200,7 +1490,7 @@ const ThreadCommentPanel = (props) => {
|
|
|
1200
1490
|
const id = `${location}-${unitId}-${subUnitId}-${commentId}`;
|
|
1201
1491
|
(_document$getElementB = document.getElementById(id)) === null || _document$getElementB === void 0 || _document$getElementB.scrollIntoView({ block: "center" });
|
|
1202
1492
|
}, [activeCommentId, location]);
|
|
1203
|
-
const renderComment = (section) => (comment, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1493
|
+
const renderComment = (section) => (comment, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentTree, {
|
|
1204
1494
|
full: true,
|
|
1205
1495
|
location,
|
|
1206
1496
|
getSubUnitName,
|
|
@@ -1246,7 +1536,7 @@ const ThreadCommentPanel = (props) => {
|
|
|
1246
1536
|
className: "univer-flex univer-min-h-full univer-flex-col univer-pb-3",
|
|
1247
1537
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1248
1538
|
className: "univer-mt-3 univer-flex univer-flex-row univer-justify-between",
|
|
1249
|
-
children: [type === _univerjs_core.UniverInstanceType.UNIVER_SHEET ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1539
|
+
children: [type === _univerjs_core.UniverInstanceType.UNIVER_SHEET ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
|
|
1250
1540
|
borderless: true,
|
|
1251
1541
|
value: unit,
|
|
1252
1542
|
options: [{
|
|
@@ -1257,7 +1547,7 @@ const ThreadCommentPanel = (props) => {
|
|
|
1257
1547
|
label: localeService.t("thread-comment-ui.filter.sheet.all")
|
|
1258
1548
|
}],
|
|
1259
1549
|
onChange: setUnit
|
|
1260
|
-
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1550
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Select, {
|
|
1261
1551
|
borderless: true,
|
|
1262
1552
|
value: status,
|
|
1263
1553
|
options: [
|
|
@@ -1282,13 +1572,13 @@ const ThreadCommentPanel = (props) => {
|
|
|
1282
1572
|
})]
|
|
1283
1573
|
}), renderComments.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1284
1574
|
className: "univer-flex univer-flex-1 univer-flex-col univer-items-center univer-justify-center univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
|
|
1285
|
-
children: [localeService.t("thread-comment-ui.panel.empty"), isFiltering ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1575
|
+
children: [localeService.t("thread-comment-ui.panel.empty"), isFiltering ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.ActionRow, {
|
|
1286
1576
|
className: "univer-mt-2 univer-flex univer-flex-row",
|
|
1287
1577
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Button, {
|
|
1288
1578
|
onClick: onReset,
|
|
1289
1579
|
children: localeService.t("thread-comment-ui.panel.reset")
|
|
1290
1580
|
})
|
|
1291
|
-
}) : !disableAdd ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1581
|
+
}) : !disableAdd ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.ActionRow, {
|
|
1292
1582
|
className: "univer-mt-2 univer-flex univer-flex-row",
|
|
1293
1583
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_univerjs_design.Button, {
|
|
1294
1584
|
onClick: onAdd,
|
|
@@ -1309,35 +1599,6 @@ const ThreadCommentPanel = (props) => {
|
|
|
1309
1599
|
});
|
|
1310
1600
|
};
|
|
1311
1601
|
|
|
1312
|
-
//#endregion
|
|
1313
|
-
//#region src/views/mobile/MobileThreadCommentEditor.tsx
|
|
1314
|
-
const MobileThreadCommentEditor = (0, react.forwardRef)((props, ref) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentEditor, {
|
|
1315
|
-
...props,
|
|
1316
|
-
ref,
|
|
1317
|
-
ActionRowComponent: _univerjs_design.MobileActionRowGroup
|
|
1318
|
-
}));
|
|
1319
|
-
|
|
1320
|
-
//#endregion
|
|
1321
|
-
//#region src/views/mobile/MobileThreadCommentTree.tsx
|
|
1322
|
-
function MobileThreadCommentTree(props) {
|
|
1323
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentTree, {
|
|
1324
|
-
...props,
|
|
1325
|
-
DropdownComponent: _univerjs_design.MobileDropdown,
|
|
1326
|
-
EditorComponent: MobileThreadCommentEditor
|
|
1327
|
-
});
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
//#endregion
|
|
1331
|
-
//#region src/views/mobile/MobileThreadCommentPanel.tsx
|
|
1332
|
-
function MobileThreadCommentPanel(props) {
|
|
1333
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentPanel, {
|
|
1334
|
-
...props,
|
|
1335
|
-
ActionRowComponent: _univerjs_design.MobileActionRowGroup,
|
|
1336
|
-
SelectComponent: _univerjs_design.MobileSelect,
|
|
1337
|
-
ThreadCommentTreeComponent: MobileThreadCommentTree
|
|
1338
|
-
});
|
|
1339
|
-
}
|
|
1340
|
-
|
|
1341
1602
|
//#endregion
|
|
1342
1603
|
exports.MobileThreadCommentPanel = MobileThreadCommentPanel;
|
|
1343
1604
|
exports.MobileThreadCommentTree = MobileThreadCommentTree;
|
package/lib/cjs/locale/ar-SA.js
CHANGED
package/lib/cjs/locale/ca-ES.js
CHANGED
package/lib/cjs/locale/de-DE.js
CHANGED
package/lib/cjs/locale/en-US.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/locale/en-US.ts
|
|
3
2
|
/**
|
|
4
3
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
@@ -16,7 +15,9 @@
|
|
|
16
15
|
* limitations under the License.
|
|
17
16
|
*/
|
|
18
17
|
const locale = { "thread-comment-ui": {
|
|
18
|
+
mobile: { back: "Back" },
|
|
19
19
|
panel: {
|
|
20
|
+
title: "Comment Management",
|
|
20
21
|
empty: "No comments yet",
|
|
21
22
|
reset: "Reset Filter",
|
|
22
23
|
addComment: "Add Comment",
|
package/lib/cjs/locale/es-ES.js
CHANGED
package/lib/cjs/locale/fa-IR.js
CHANGED
package/lib/cjs/locale/fr-FR.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/locale/fr-FR.ts
|
|
3
2
|
const locale = { "thread-comment-ui": {
|
|
3
|
+
mobile: { back: "Retour" },
|
|
4
4
|
panel: {
|
|
5
|
+
title: "Gestion des commentaires",
|
|
5
6
|
empty: "Pas encore de commentaires",
|
|
6
7
|
reset: "Réinitialiser le filtre",
|
|
7
8
|
addComment: "Ajouter un commentaire",
|
package/lib/cjs/locale/id-ID.js
CHANGED
package/lib/cjs/locale/it-IT.js
CHANGED
package/lib/cjs/locale/ja-JP.js
CHANGED
package/lib/cjs/locale/ko-KR.js
CHANGED
package/lib/cjs/locale/pl-PL.js
CHANGED
package/lib/cjs/locale/pt-BR.js
CHANGED
package/lib/cjs/locale/ru-RU.js
CHANGED
package/lib/cjs/locale/sk-SK.js
CHANGED