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