@univerjs/thread-comment-ui 1.0.0-alpha.8 → 1.0.0-beta.1
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 +29 -31
- package/lib/cjs/locale/ar-SA.js +0 -2
- package/lib/cjs/locale/ca-ES.js +0 -2
- package/lib/cjs/locale/de-DE.js +0 -2
- package/lib/cjs/locale/en-US.js +0 -2
- package/lib/cjs/locale/es-ES.js +0 -2
- package/lib/cjs/locale/fa-IR.js +0 -2
- package/lib/cjs/locale/fr-FR.js +0 -2
- package/lib/cjs/locale/id-ID.js +0 -2
- package/lib/cjs/locale/it-IT.js +0 -2
- package/lib/cjs/locale/ja-JP.js +0 -2
- package/lib/cjs/locale/ko-KR.js +0 -2
- package/lib/cjs/locale/pl-PL.js +0 -2
- package/lib/cjs/locale/pt-BR.js +0 -2
- package/lib/cjs/locale/ru-RU.js +0 -2
- package/lib/cjs/locale/sk-SK.js +0 -2
- package/lib/cjs/locale/vi-VN.js +0 -2
- package/lib/cjs/locale/zh-CN.js +0 -2
- package/lib/cjs/locale/zh-HK.js +0 -2
- package/lib/cjs/locale/zh-TW.js +0 -2
- package/lib/es/index.js +30 -32
- package/lib/es/locale/ar-SA.js +0 -2
- package/lib/es/locale/ca-ES.js +0 -2
- package/lib/es/locale/de-DE.js +0 -2
- package/lib/es/locale/en-US.js +0 -2
- package/lib/es/locale/es-ES.js +0 -2
- package/lib/es/locale/fa-IR.js +0 -2
- package/lib/es/locale/fr-FR.js +0 -2
- package/lib/es/locale/id-ID.js +0 -2
- package/lib/es/locale/it-IT.js +0 -2
- package/lib/es/locale/ja-JP.js +0 -2
- package/lib/es/locale/ko-KR.js +0 -2
- package/lib/es/locale/pl-PL.js +0 -2
- package/lib/es/locale/pt-BR.js +0 -2
- package/lib/es/locale/ru-RU.js +0 -2
- package/lib/es/locale/sk-SK.js +0 -2
- package/lib/es/locale/vi-VN.js +0 -2
- package/lib/es/locale/zh-CN.js +0 -2
- package/lib/es/locale/zh-HK.js +0 -2
- package/lib/es/locale/zh-TW.js +0 -2
- package/lib/index.css +22 -8
- package/lib/index.js +30 -32
- package/lib/locale/ar-SA.js +0 -2
- package/lib/locale/ca-ES.js +0 -2
- package/lib/locale/de-DE.js +0 -2
- package/lib/locale/en-US.js +0 -2
- package/lib/locale/es-ES.js +0 -2
- package/lib/locale/fa-IR.js +0 -2
- package/lib/locale/fr-FR.js +0 -2
- package/lib/locale/id-ID.js +0 -2
- package/lib/locale/it-IT.js +0 -2
- package/lib/locale/ja-JP.js +0 -2
- package/lib/locale/ko-KR.js +0 -2
- package/lib/locale/pl-PL.js +0 -2
- package/lib/locale/pt-BR.js +0 -2
- package/lib/locale/ru-RU.js +0 -2
- package/lib/locale/sk-SK.js +0 -2
- package/lib/locale/vi-VN.js +0 -2
- package/lib/locale/zh-CN.js +0 -2
- package/lib/locale/zh-HK.js +0 -2
- package/lib/locale/zh-TW.js +0 -2
- package/lib/types/locale/en-US.d.ts +0 -2
- package/lib/umd/index.js +3 -3
- 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 +10 -10
package/lib/cjs/index.js
CHANGED
|
@@ -125,7 +125,7 @@ const SetActiveCommentOperation = {
|
|
|
125
125
|
//#endregion
|
|
126
126
|
//#region package.json
|
|
127
127
|
var name = "@univerjs/thread-comment-ui";
|
|
128
|
-
var version = "1.0.0-
|
|
128
|
+
var version = "1.0.0-beta.1";
|
|
129
129
|
|
|
130
130
|
//#endregion
|
|
131
131
|
//#region src/config/config.ts
|
|
@@ -180,7 +180,7 @@ _defineProperty(UniverThreadCommentUIPlugin, "packageName", name);
|
|
|
180
180
|
_defineProperty(UniverThreadCommentUIPlugin, "version", version);
|
|
181
181
|
_defineProperty(UniverThreadCommentUIPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_UNKNOWN);
|
|
182
182
|
UniverThreadCommentUIPlugin = __decorate([
|
|
183
|
-
(0, _univerjs_core.DependentOn)(_univerjs_thread_comment.UniverThreadCommentPlugin,
|
|
183
|
+
(0, _univerjs_core.DependentOn)(_univerjs_thread_comment.UniverThreadCommentPlugin, _univerjs_docs_ui.UniverDocsUIPlugin),
|
|
184
184
|
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
185
185
|
__decorateParam(2, _univerjs_core.ICommandService),
|
|
186
186
|
__decorateParam(3, _univerjs_core.IConfigService)
|
|
@@ -308,8 +308,8 @@ const ThreadCommentEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
308
308
|
const editor = (0, react.useRef)(null);
|
|
309
309
|
const rootEditorId = type === _univerjs_core.UniverInstanceType.UNIVER_DOC ? _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY : unitId;
|
|
310
310
|
const [canSubmit, setCanSubmit] = (0, react.useState)(() => {
|
|
311
|
-
var _comment$text
|
|
312
|
-
return _univerjs_core.BuildTextUtils.transform.getPlainText((
|
|
311
|
+
var _comment$text;
|
|
312
|
+
return _univerjs_core.BuildTextUtils.transform.getPlainText((comment === null || comment === void 0 || (_comment$text = comment.text) === null || _comment$text === void 0 ? void 0 : _comment$text.dataStream) ?? "");
|
|
313
313
|
});
|
|
314
314
|
const keyboardEventConfig = (0, react.useMemo)(() => ({
|
|
315
315
|
keyCodes: [{ keyCode: _univerjs_ui.KeyCode.ENTER }],
|
|
@@ -368,13 +368,14 @@ const ThreadCommentEditor = (0, react.forwardRef)((props, ref) => {
|
|
|
368
368
|
className: "univer-w-full",
|
|
369
369
|
editorRef: editor,
|
|
370
370
|
editorId,
|
|
371
|
+
preserveHostFocus: true,
|
|
371
372
|
autoFocus,
|
|
372
373
|
keyboardEventConfig,
|
|
373
374
|
placeholder: localeService.t("thread-comment-ui.editor.placeholder"),
|
|
374
375
|
initialValue: (comment === null || comment === void 0 ? void 0 : comment.text) && getSnapshot(comment.text),
|
|
375
376
|
onChange: (data) => {
|
|
376
|
-
var _data$body
|
|
377
|
-
return setCanSubmit(_univerjs_core.BuildTextUtils.transform.getPlainText((
|
|
377
|
+
var _data$body;
|
|
378
|
+
return setCanSubmit(_univerjs_core.BuildTextUtils.transform.getPlainText(((_data$body = data.body) === null || _data$body === void 0 ? void 0 : _data$body.dataStream) ?? ""));
|
|
378
379
|
},
|
|
379
380
|
onFocusChange: (isFocus) => isFocus && setEditing(isFocus),
|
|
380
381
|
isSingle: false,
|
|
@@ -428,7 +429,8 @@ function formatCommentDateTime(value, region) {
|
|
|
428
429
|
day: "numeric",
|
|
429
430
|
hour: "2-digit",
|
|
430
431
|
minute: "2-digit",
|
|
431
|
-
hour12: false
|
|
432
|
+
hour12: false,
|
|
433
|
+
numberingSystem: "latn"
|
|
432
434
|
});
|
|
433
435
|
}
|
|
434
436
|
const ThreadCommentItem = (props) => {
|
|
@@ -445,6 +447,7 @@ const ThreadCommentItem = (props) => {
|
|
|
445
447
|
const uiConfig = (0, _univerjs_ui.useConfigValue)(_univerjs_ui.UI_PLUGIN_CONFIG_KEY);
|
|
446
448
|
const avatarFallback = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.avatarFallback;
|
|
447
449
|
const currentRegion = (0, _univerjs_ui.useObservable)(regionService.currentRegion$, regionService.getCurrentRegion());
|
|
450
|
+
const direction = (0, _univerjs_ui.useObservable)(localeService.direction$, localeService.getDirection());
|
|
448
451
|
const dateText = isMock ? null : formatCommentDateTime(item.dT, currentRegion);
|
|
449
452
|
const handleDeleteItem = () => {
|
|
450
453
|
if ((onDeleteComment === null || onDeleteComment === void 0 ? void 0 : onDeleteComment(item)) === false) return;
|
|
@@ -475,9 +478,10 @@ const ThreadCommentItem = (props) => {
|
|
|
475
478
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ReplyToCommentIcon, {})
|
|
476
479
|
}) : null, isCommentBySelf && !isMock && !resolved ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
|
|
477
480
|
overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
481
|
+
dir: direction,
|
|
478
482
|
className: "univer-rounded-lg",
|
|
479
483
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("ul", {
|
|
480
|
-
className: "univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm [&_a]:univer-block [&_a]:univer-cursor-pointer [&_a]:univer-rounded [&_a]:univer-px-2 [&_a]:univer-py-1.5 [&_a]:univer-transition-colors",
|
|
484
|
+
className: "univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm rtl:univer-text-right [&_a]:univer-block [&_a]:univer-cursor-pointer [&_a]:univer-rounded [&_a]:univer-px-2 [&_a]:univer-py-1.5 [&_a]:univer-transition-colors",
|
|
481
485
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
482
486
|
className: "hover:univer-bg-gray-200",
|
|
483
487
|
onClick: () => onEditingChange === null || onEditingChange === void 0 ? void 0 : onEditingChange(true),
|
|
@@ -497,7 +501,7 @@ const ThreadCommentItem = (props) => {
|
|
|
497
501
|
}) : null,
|
|
498
502
|
dateText && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("time", {
|
|
499
503
|
dir: "ltr",
|
|
500
|
-
className: "univer-mb-1 univer-block univer-text-xs/normal univer-text-gray-600 dark:!univer-text-gray-200",
|
|
504
|
+
className: "univer-mb-1 univer-block univer-text-xs/normal univer-text-gray-600 rtl:univer-text-right dark:!univer-text-gray-200",
|
|
501
505
|
children: dateText
|
|
502
506
|
}),
|
|
503
507
|
editing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentEditor, {
|
|
@@ -522,7 +526,7 @@ const ThreadCommentItem = (props) => {
|
|
|
522
526
|
});
|
|
523
527
|
}
|
|
524
528
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
525
|
-
className: "univer-text-sm univer-text-gray-900 dark:!univer-text-
|
|
529
|
+
className: "univer-text-sm univer-text-gray-900 dark:!univer-text-gray-0",
|
|
526
530
|
children: transformDocument2TextNodes(item.text).map((paragraph, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
527
531
|
className: "univer-break-words",
|
|
528
532
|
children: paragraph.map((item, i) => {
|
|
@@ -540,7 +544,6 @@ const ThreadCommentItem = (props) => {
|
|
|
540
544
|
});
|
|
541
545
|
};
|
|
542
546
|
const ThreadCommentTree = (props) => {
|
|
543
|
-
var _currentUser$userID, _comments$children, _comments$root$subUni;
|
|
544
547
|
const { id, unitId, subUnitId, refStr, showEdit = true, onClick, showHighlight, onClose, getSubUnitName, location, autoFocus, onMouseEnter, onMouseLeave, onAddComment, onDeleteComment, onResolve, type, style, full } = props;
|
|
545
548
|
const threadCommentModel = (0, _univerjs_ui.useDependency)(_univerjs_thread_comment.ThreadCommentModel);
|
|
546
549
|
const [isHover, setIsHover] = (0, react.useState)(false);
|
|
@@ -562,13 +565,13 @@ const ThreadCommentTree = (props) => {
|
|
|
562
565
|
const renderComments = [...comments ? [comments.root] : [{
|
|
563
566
|
id: MOCK_ID,
|
|
564
567
|
text: { dataStream: "\n\r" },
|
|
565
|
-
personId: (
|
|
566
|
-
ref: refStr
|
|
568
|
+
personId: (currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID) ?? "",
|
|
569
|
+
ref: refStr ?? "",
|
|
567
570
|
dT: "",
|
|
568
571
|
unitId,
|
|
569
572
|
subUnitId,
|
|
570
573
|
threadId: ""
|
|
571
|
-
}], ...(
|
|
574
|
+
}], ...(comments === null || comments === void 0 ? void 0 : comments.children) ?? []];
|
|
572
575
|
const scroller = (0, react.useRef)(null);
|
|
573
576
|
const handleResolve = (e) => {
|
|
574
577
|
e.stopPropagation();
|
|
@@ -600,7 +603,7 @@ const ThreadCommentTree = (props) => {
|
|
|
600
603
|
(0, react.useEffect)(() => {
|
|
601
604
|
return onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave();
|
|
602
605
|
}, []);
|
|
603
|
-
const subUnitName = getSubUnitName((
|
|
606
|
+
const subUnitName = getSubUnitName((comments === null || comments === void 0 ? void 0 : comments.root.subUnitId) ?? subUnitId);
|
|
604
607
|
const editorVisible = showEdit && !editingId && !resolved;
|
|
605
608
|
const title = `${refStr || (comments === null || comments === void 0 ? void 0 : comments.root.ref) || ""}${subUnitName ? " · " : ""}${subUnitName}`;
|
|
606
609
|
const threadCommentEditorId = getThreadCommentEditorId({
|
|
@@ -612,7 +615,7 @@ const ThreadCommentTree = (props) => {
|
|
|
612
615
|
});
|
|
613
616
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
614
617
|
id: `${location}-${unitId}-${subUnitId}-${id}`,
|
|
615
|
-
className: (0, _univerjs_design.clsx)("univer-relative univer-box-border univer-rounded-md univer-bg-
|
|
618
|
+
className: (0, _univerjs_design.clsx)("univer-relative univer-box-border univer-rounded-md univer-bg-gray-0 univer-p-4 univer-text-gray-900 dark:!univer-bg-gray-900 dark:!univer-text-gray-0", _univerjs_design.borderClassName, {
|
|
616
619
|
"univer-w-[278px]": !full,
|
|
617
620
|
"univer-w-full": full,
|
|
618
621
|
"univer-shadow": !resolved && (showHighlight || isHover || location === "CELL")
|
|
@@ -656,7 +659,7 @@ const ThreadCommentTree = (props) => {
|
|
|
656
659
|
}),
|
|
657
660
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
658
661
|
ref: scroller,
|
|
659
|
-
className: (0, _univerjs_design.clsx)("univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden", _univerjs_design.scrollbarClassName),
|
|
662
|
+
className: (0, _univerjs_design.clsx)("univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden", _univerjs_design.scrollbarClassName, location === "PANEL" && "-univer-mx-4 univer-px-4"),
|
|
660
663
|
children: renderComments.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentItem, {
|
|
661
664
|
unitId,
|
|
662
665
|
subUnitId,
|
|
@@ -698,18 +701,17 @@ const ThreadCommentTree = (props) => {
|
|
|
698
701
|
subUnitId,
|
|
699
702
|
editorId: threadCommentEditorId,
|
|
700
703
|
onSave: async ({ text, attachments }) => {
|
|
701
|
-
var _currentUser$userID2, _comments$root$thread;
|
|
702
704
|
const comment = {
|
|
703
705
|
text,
|
|
704
706
|
attachments,
|
|
705
707
|
dT: (0, _univerjs_thread_comment.getDT)(),
|
|
706
708
|
id: (0, _univerjs_core.generateRandomId)(),
|
|
707
709
|
ref: refStr,
|
|
708
|
-
personId: (
|
|
710
|
+
personId: (currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID) ?? "",
|
|
709
711
|
parentId: comments === null || comments === void 0 ? void 0 : comments.root.id,
|
|
710
712
|
unitId,
|
|
711
713
|
subUnitId,
|
|
712
|
-
threadId: (
|
|
714
|
+
threadId: (comments === null || comments === void 0 ? void 0 : comments.root.threadId) ?? ""
|
|
713
715
|
};
|
|
714
716
|
if ((onAddComment === null || onAddComment === void 0 ? void 0 : onAddComment(comment)) === false) return;
|
|
715
717
|
await commandService.executeCommand(_univerjs_thread_comment.AddCommentCommand.id, {
|
|
@@ -746,17 +748,13 @@ const ThreadCommentPanel = (props) => {
|
|
|
746
748
|
const location = "PANEL";
|
|
747
749
|
const currentUser = (0, _univerjs_ui.useObservable)(userService.currentUser$);
|
|
748
750
|
const comments = (0, react.useMemo)(() => {
|
|
749
|
-
|
|
750
|
-
const
|
|
751
|
-
const
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
children: (_i$children = i.children) !== null && _i$children !== void 0 ? _i$children : [],
|
|
757
|
-
users: i.relativeUsers
|
|
758
|
-
};
|
|
759
|
-
});
|
|
751
|
+
const allComments = unit === "all" ? unitComments : unitComments.filter((i) => i.subUnitId === subUnitId) ?? [];
|
|
752
|
+
const sort = sortComments ?? ((a) => a);
|
|
753
|
+
const res = allComments.map((i) => ({
|
|
754
|
+
...i.root,
|
|
755
|
+
children: i.children ?? [],
|
|
756
|
+
users: i.relativeUsers
|
|
757
|
+
}));
|
|
760
758
|
if (showComments) {
|
|
761
759
|
const map = /* @__PURE__ */ new Map();
|
|
762
760
|
res.forEach((comment) => {
|
package/lib/cjs/locale/ar-SA.js
CHANGED
package/lib/cjs/locale/ca-ES.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
//#region src/locale/ca-ES.ts
|
|
3
3
|
const locale = { "thread-comment-ui": {
|
|
4
4
|
panel: {
|
|
5
|
-
title: "Gestió de comentaris",
|
|
6
5
|
empty: "Encara no hi ha comentaris",
|
|
7
|
-
filterEmpty: "Cap resultat coincident",
|
|
8
6
|
reset: "Restableix el filtre",
|
|
9
7
|
addComment: "Afegeix un comentari",
|
|
10
8
|
solved: "Resolut"
|
package/lib/cjs/locale/de-DE.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
//#region src/locale/de-DE.ts
|
|
3
3
|
const locale = { "thread-comment-ui": {
|
|
4
4
|
panel: {
|
|
5
|
-
title: "Kommentarverwaltung",
|
|
6
5
|
empty: "Noch keine Kommentare",
|
|
7
|
-
filterEmpty: "Kein Treffer",
|
|
8
6
|
reset: "Filter zurücksetzen",
|
|
9
7
|
addComment: "Kommentar hinzufügen",
|
|
10
8
|
solved: "Gelöst"
|
package/lib/cjs/locale/en-US.js
CHANGED
package/lib/cjs/locale/es-ES.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
//#region src/locale/es-ES.ts
|
|
3
3
|
const locale = { "thread-comment-ui": {
|
|
4
4
|
panel: {
|
|
5
|
-
title: "Gestión de comentarios",
|
|
6
5
|
empty: "Aún no hay comentarios",
|
|
7
|
-
filterEmpty: "Sin resultados coincidentes",
|
|
8
6
|
reset: "Restablecer filtro",
|
|
9
7
|
addComment: "Añadir comentario",
|
|
10
8
|
solved: "Resuelto"
|
package/lib/cjs/locale/fa-IR.js
CHANGED
package/lib/cjs/locale/fr-FR.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
//#region src/locale/fr-FR.ts
|
|
3
3
|
const locale = { "thread-comment-ui": {
|
|
4
4
|
panel: {
|
|
5
|
-
title: "Gestion des commentaires",
|
|
6
5
|
empty: "Pas encore de commentaires",
|
|
7
|
-
filterEmpty: "Aucun résultat correspondant",
|
|
8
6
|
reset: "Réinitialiser le filtre",
|
|
9
7
|
addComment: "Ajouter un commentaire",
|
|
10
8
|
solved: "Résolu"
|
package/lib/cjs/locale/id-ID.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
//#region src/locale/id-ID.ts
|
|
3
3
|
const locale = { "thread-comment-ui": {
|
|
4
4
|
panel: {
|
|
5
|
-
title: "Manajemen Komentar",
|
|
6
5
|
empty: "Belum ada komentar",
|
|
7
|
-
filterEmpty: "Tidak ada hasil yang cocok",
|
|
8
6
|
reset: "Atur Ulang Filter",
|
|
9
7
|
addComment: "Tambah Komentar",
|
|
10
8
|
solved: "Terselesaikan"
|
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
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
//#region src/locale/pt-BR.ts
|
|
3
3
|
const locale = { "thread-comment-ui": {
|
|
4
4
|
panel: {
|
|
5
|
-
title: "Gerenciamento de Comentários",
|
|
6
5
|
empty: "Nenhum comentário ainda",
|
|
7
|
-
filterEmpty: "Nenhum resultado correspondente",
|
|
8
6
|
reset: "Redefinir Filtro",
|
|
9
7
|
addComment: "Adicionar Comentário",
|
|
10
8
|
solved: "Resolvido"
|
package/lib/cjs/locale/ru-RU.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
//#region src/locale/ru-RU.ts
|
|
3
3
|
const locale = { "thread-comment-ui": {
|
|
4
4
|
panel: {
|
|
5
|
-
title: "Управление комментариями",
|
|
6
5
|
empty: "Комментариев пока нет",
|
|
7
|
-
filterEmpty: "Нет совпадений",
|
|
8
6
|
reset: "Сбросить фильтр",
|
|
9
7
|
addComment: "Добавить комментарий",
|
|
10
8
|
solved: "Решено"
|
package/lib/cjs/locale/sk-SK.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
//#region src/locale/sk-SK.ts
|
|
3
3
|
const locale = { "thread-comment-ui": {
|
|
4
4
|
panel: {
|
|
5
|
-
title: "Správa komentárov",
|
|
6
5
|
empty: "Zatiaľ žiadne komentáre",
|
|
7
|
-
filterEmpty: "Žiadne zodpovedajúce výsledky",
|
|
8
6
|
reset: "Obnoviť filter",
|
|
9
7
|
addComment: "Pridať komentár",
|
|
10
8
|
solved: "Vyriešené"
|
package/lib/cjs/locale/vi-VN.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
//#region src/locale/vi-VN.ts
|
|
3
3
|
const locale = { "thread-comment-ui": {
|
|
4
4
|
panel: {
|
|
5
|
-
title: "Quản lý Bình luận",
|
|
6
5
|
empty: "Chưa có bình luận",
|
|
7
|
-
filterEmpty: "Không có kết quả phù hợp",
|
|
8
6
|
reset: "Đặt lại",
|
|
9
7
|
addComment: "Thêm bình luận",
|
|
10
8
|
solved: "Đã giải quyết"
|
package/lib/cjs/locale/zh-CN.js
CHANGED
package/lib/cjs/locale/zh-HK.js
CHANGED
package/lib/cjs/locale/zh-TW.js
CHANGED
package/lib/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuildTextUtils, CommandType, CustomRangeType, DOCS_COMMENT_EDITOR_UNIT_ID_KEY, DOCS_NORMAL_EDITOR_UNIT_ID_KEY, DependentOn, Disposable, ICommandService, IConfigService, IUniverInstanceService, Inject, Injector, LOCALE_META, LocaleService, Plugin, RegionService, Tools, UniverInstanceType, UserManagerService, createParagraphId, createSectionId, dateKit, generateRandomId, getBodySlice, merge, mergeOverrideWithDependencies } from "@univerjs/core";
|
|
2
|
-
import { ISidebarService, KeyCode, UI_PLUGIN_CONFIG_KEY,
|
|
2
|
+
import { ISidebarService, KeyCode, UI_PLUGIN_CONFIG_KEY, useConfigValue, useDependency, useObservable } from "@univerjs/ui";
|
|
3
3
|
import { BehaviorSubject, debounceTime, filter, map, of, startWith } from "rxjs";
|
|
4
4
|
import { BreakLineCommand, IEditorService, RichTextEditor, UniverDocsUIPlugin } from "@univerjs/docs-ui";
|
|
5
5
|
import { AddCommentCommand, DeleteCommentCommand, DeleteCommentTreeCommand, ResolveCommentCommand, ThreadCommentModel, UniverThreadCommentPlugin, UpdateCommentCommand, getDT } from "@univerjs/thread-comment";
|
|
@@ -124,7 +124,7 @@ const SetActiveCommentOperation = {
|
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region package.json
|
|
126
126
|
var name = "@univerjs/thread-comment-ui";
|
|
127
|
-
var version = "1.0.0-
|
|
127
|
+
var version = "1.0.0-beta.1";
|
|
128
128
|
|
|
129
129
|
//#endregion
|
|
130
130
|
//#region src/config/config.ts
|
|
@@ -179,7 +179,7 @@ _defineProperty(UniverThreadCommentUIPlugin, "packageName", name);
|
|
|
179
179
|
_defineProperty(UniverThreadCommentUIPlugin, "version", version);
|
|
180
180
|
_defineProperty(UniverThreadCommentUIPlugin, "type", UniverInstanceType.UNIVER_UNKNOWN);
|
|
181
181
|
UniverThreadCommentUIPlugin = __decorate([
|
|
182
|
-
DependentOn(UniverThreadCommentPlugin,
|
|
182
|
+
DependentOn(UniverThreadCommentPlugin, UniverDocsUIPlugin),
|
|
183
183
|
__decorateParam(1, Inject(Injector)),
|
|
184
184
|
__decorateParam(2, ICommandService),
|
|
185
185
|
__decorateParam(3, IConfigService)
|
|
@@ -307,8 +307,8 @@ const ThreadCommentEditor = forwardRef((props, ref) => {
|
|
|
307
307
|
const editor = useRef(null);
|
|
308
308
|
const rootEditorId = type === UniverInstanceType.UNIVER_DOC ? DOCS_NORMAL_EDITOR_UNIT_ID_KEY : unitId;
|
|
309
309
|
const [canSubmit, setCanSubmit] = useState(() => {
|
|
310
|
-
var _comment$text
|
|
311
|
-
return BuildTextUtils.transform.getPlainText((
|
|
310
|
+
var _comment$text;
|
|
311
|
+
return BuildTextUtils.transform.getPlainText((comment === null || comment === void 0 || (_comment$text = comment.text) === null || _comment$text === void 0 ? void 0 : _comment$text.dataStream) ?? "");
|
|
312
312
|
});
|
|
313
313
|
const keyboardEventConfig = useMemo(() => ({
|
|
314
314
|
keyCodes: [{ keyCode: KeyCode.ENTER }],
|
|
@@ -367,13 +367,14 @@ const ThreadCommentEditor = forwardRef((props, ref) => {
|
|
|
367
367
|
className: "univer-w-full",
|
|
368
368
|
editorRef: editor,
|
|
369
369
|
editorId,
|
|
370
|
+
preserveHostFocus: true,
|
|
370
371
|
autoFocus,
|
|
371
372
|
keyboardEventConfig,
|
|
372
373
|
placeholder: localeService.t("thread-comment-ui.editor.placeholder"),
|
|
373
374
|
initialValue: (comment === null || comment === void 0 ? void 0 : comment.text) && getSnapshot(comment.text),
|
|
374
375
|
onChange: (data) => {
|
|
375
|
-
var _data$body
|
|
376
|
-
return setCanSubmit(BuildTextUtils.transform.getPlainText((
|
|
376
|
+
var _data$body;
|
|
377
|
+
return setCanSubmit(BuildTextUtils.transform.getPlainText(((_data$body = data.body) === null || _data$body === void 0 ? void 0 : _data$body.dataStream) ?? ""));
|
|
377
378
|
},
|
|
378
379
|
onFocusChange: (isFocus) => isFocus && setEditing(isFocus),
|
|
379
380
|
isSingle: false,
|
|
@@ -427,7 +428,8 @@ function formatCommentDateTime(value, region) {
|
|
|
427
428
|
day: "numeric",
|
|
428
429
|
hour: "2-digit",
|
|
429
430
|
minute: "2-digit",
|
|
430
|
-
hour12: false
|
|
431
|
+
hour12: false,
|
|
432
|
+
numberingSystem: "latn"
|
|
431
433
|
});
|
|
432
434
|
}
|
|
433
435
|
const ThreadCommentItem = (props) => {
|
|
@@ -444,6 +446,7 @@ const ThreadCommentItem = (props) => {
|
|
|
444
446
|
const uiConfig = useConfigValue(UI_PLUGIN_CONFIG_KEY);
|
|
445
447
|
const avatarFallback = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.avatarFallback;
|
|
446
448
|
const currentRegion = useObservable(regionService.currentRegion$, regionService.getCurrentRegion());
|
|
449
|
+
const direction = useObservable(localeService.direction$, localeService.getDirection());
|
|
447
450
|
const dateText = isMock ? null : formatCommentDateTime(item.dT, currentRegion);
|
|
448
451
|
const handleDeleteItem = () => {
|
|
449
452
|
if ((onDeleteComment === null || onDeleteComment === void 0 ? void 0 : onDeleteComment(item)) === false) return;
|
|
@@ -474,9 +477,10 @@ const ThreadCommentItem = (props) => {
|
|
|
474
477
|
children: /* @__PURE__ */ jsx(ReplyToCommentIcon, {})
|
|
475
478
|
}) : null, isCommentBySelf && !isMock && !resolved ? /* @__PURE__ */ jsx(Dropdown, {
|
|
476
479
|
overlay: /* @__PURE__ */ jsx("div", {
|
|
480
|
+
dir: direction,
|
|
477
481
|
className: "univer-rounded-lg",
|
|
478
482
|
children: /* @__PURE__ */ jsxs("ul", {
|
|
479
|
-
className: "univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm [&_a]:univer-block [&_a]:univer-cursor-pointer [&_a]:univer-rounded [&_a]:univer-px-2 [&_a]:univer-py-1.5 [&_a]:univer-transition-colors",
|
|
483
|
+
className: "univer-m-0 univer-box-border univer-grid univer-list-none univer-p-1.5 univer-text-sm rtl:univer-text-right [&_a]:univer-block [&_a]:univer-cursor-pointer [&_a]:univer-rounded [&_a]:univer-px-2 [&_a]:univer-py-1.5 [&_a]:univer-transition-colors",
|
|
480
484
|
children: [/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("a", {
|
|
481
485
|
className: "hover:univer-bg-gray-200",
|
|
482
486
|
onClick: () => onEditingChange === null || onEditingChange === void 0 ? void 0 : onEditingChange(true),
|
|
@@ -496,7 +500,7 @@ const ThreadCommentItem = (props) => {
|
|
|
496
500
|
}) : null,
|
|
497
501
|
dateText && /* @__PURE__ */ jsx("time", {
|
|
498
502
|
dir: "ltr",
|
|
499
|
-
className: "univer-mb-1 univer-block univer-text-xs/normal univer-text-gray-600 dark:!univer-text-gray-200",
|
|
503
|
+
className: "univer-mb-1 univer-block univer-text-xs/normal univer-text-gray-600 rtl:univer-text-right dark:!univer-text-gray-200",
|
|
500
504
|
children: dateText
|
|
501
505
|
}),
|
|
502
506
|
editing ? /* @__PURE__ */ jsx(ThreadCommentEditor, {
|
|
@@ -521,7 +525,7 @@ const ThreadCommentItem = (props) => {
|
|
|
521
525
|
});
|
|
522
526
|
}
|
|
523
527
|
}) : /* @__PURE__ */ jsx("div", {
|
|
524
|
-
className: "univer-text-sm univer-text-gray-900 dark:!univer-text-
|
|
528
|
+
className: "univer-text-sm univer-text-gray-900 dark:!univer-text-gray-0",
|
|
525
529
|
children: transformDocument2TextNodes(item.text).map((paragraph, i) => /* @__PURE__ */ jsx("div", {
|
|
526
530
|
className: "univer-break-words",
|
|
527
531
|
children: paragraph.map((item, i) => {
|
|
@@ -539,7 +543,6 @@ const ThreadCommentItem = (props) => {
|
|
|
539
543
|
});
|
|
540
544
|
};
|
|
541
545
|
const ThreadCommentTree = (props) => {
|
|
542
|
-
var _currentUser$userID, _comments$children, _comments$root$subUni;
|
|
543
546
|
const { id, unitId, subUnitId, refStr, showEdit = true, onClick, showHighlight, onClose, getSubUnitName, location, autoFocus, onMouseEnter, onMouseLeave, onAddComment, onDeleteComment, onResolve, type, style, full } = props;
|
|
544
547
|
const threadCommentModel = useDependency(ThreadCommentModel);
|
|
545
548
|
const [isHover, setIsHover] = useState(false);
|
|
@@ -561,13 +564,13 @@ const ThreadCommentTree = (props) => {
|
|
|
561
564
|
const renderComments = [...comments ? [comments.root] : [{
|
|
562
565
|
id: MOCK_ID,
|
|
563
566
|
text: { dataStream: "\n\r" },
|
|
564
|
-
personId: (
|
|
565
|
-
ref: refStr
|
|
567
|
+
personId: (currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID) ?? "",
|
|
568
|
+
ref: refStr ?? "",
|
|
566
569
|
dT: "",
|
|
567
570
|
unitId,
|
|
568
571
|
subUnitId,
|
|
569
572
|
threadId: ""
|
|
570
|
-
}], ...(
|
|
573
|
+
}], ...(comments === null || comments === void 0 ? void 0 : comments.children) ?? []];
|
|
571
574
|
const scroller = useRef(null);
|
|
572
575
|
const handleResolve = (e) => {
|
|
573
576
|
e.stopPropagation();
|
|
@@ -599,7 +602,7 @@ const ThreadCommentTree = (props) => {
|
|
|
599
602
|
useEffect(() => {
|
|
600
603
|
return onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave();
|
|
601
604
|
}, []);
|
|
602
|
-
const subUnitName = getSubUnitName((
|
|
605
|
+
const subUnitName = getSubUnitName((comments === null || comments === void 0 ? void 0 : comments.root.subUnitId) ?? subUnitId);
|
|
603
606
|
const editorVisible = showEdit && !editingId && !resolved;
|
|
604
607
|
const title = `${refStr || (comments === null || comments === void 0 ? void 0 : comments.root.ref) || ""}${subUnitName ? " · " : ""}${subUnitName}`;
|
|
605
608
|
const threadCommentEditorId = getThreadCommentEditorId({
|
|
@@ -611,7 +614,7 @@ const ThreadCommentTree = (props) => {
|
|
|
611
614
|
});
|
|
612
615
|
return /* @__PURE__ */ jsxs("div", {
|
|
613
616
|
id: `${location}-${unitId}-${subUnitId}-${id}`,
|
|
614
|
-
className: clsx("univer-relative univer-box-border univer-rounded-md univer-bg-
|
|
617
|
+
className: clsx("univer-relative univer-box-border univer-rounded-md univer-bg-gray-0 univer-p-4 univer-text-gray-900 dark:!univer-bg-gray-900 dark:!univer-text-gray-0", borderClassName, {
|
|
615
618
|
"univer-w-[278px]": !full,
|
|
616
619
|
"univer-w-full": full,
|
|
617
620
|
"univer-shadow": !resolved && (showHighlight || isHover || location === "CELL")
|
|
@@ -655,7 +658,7 @@ const ThreadCommentTree = (props) => {
|
|
|
655
658
|
}),
|
|
656
659
|
/* @__PURE__ */ jsx("div", {
|
|
657
660
|
ref: scroller,
|
|
658
|
-
className: clsx("univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden", scrollbarClassName),
|
|
661
|
+
className: clsx("univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden", scrollbarClassName, location === "PANEL" && "-univer-mx-4 univer-px-4"),
|
|
659
662
|
children: renderComments.map((item) => /* @__PURE__ */ jsx(ThreadCommentItem, {
|
|
660
663
|
unitId,
|
|
661
664
|
subUnitId,
|
|
@@ -697,18 +700,17 @@ const ThreadCommentTree = (props) => {
|
|
|
697
700
|
subUnitId,
|
|
698
701
|
editorId: threadCommentEditorId,
|
|
699
702
|
onSave: async ({ text, attachments }) => {
|
|
700
|
-
var _currentUser$userID2, _comments$root$thread;
|
|
701
703
|
const comment = {
|
|
702
704
|
text,
|
|
703
705
|
attachments,
|
|
704
706
|
dT: getDT(),
|
|
705
707
|
id: generateRandomId(),
|
|
706
708
|
ref: refStr,
|
|
707
|
-
personId: (
|
|
709
|
+
personId: (currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID) ?? "",
|
|
708
710
|
parentId: comments === null || comments === void 0 ? void 0 : comments.root.id,
|
|
709
711
|
unitId,
|
|
710
712
|
subUnitId,
|
|
711
|
-
threadId: (
|
|
713
|
+
threadId: (comments === null || comments === void 0 ? void 0 : comments.root.threadId) ?? ""
|
|
712
714
|
};
|
|
713
715
|
if ((onAddComment === null || onAddComment === void 0 ? void 0 : onAddComment(comment)) === false) return;
|
|
714
716
|
await commandService.executeCommand(AddCommentCommand.id, {
|
|
@@ -745,17 +747,13 @@ const ThreadCommentPanel = (props) => {
|
|
|
745
747
|
const location = "PANEL";
|
|
746
748
|
const currentUser = useObservable(userService.currentUser$);
|
|
747
749
|
const comments = useMemo(() => {
|
|
748
|
-
|
|
749
|
-
const
|
|
750
|
-
const
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
children: (_i$children = i.children) !== null && _i$children !== void 0 ? _i$children : [],
|
|
756
|
-
users: i.relativeUsers
|
|
757
|
-
};
|
|
758
|
-
});
|
|
750
|
+
const allComments = unit === "all" ? unitComments : unitComments.filter((i) => i.subUnitId === subUnitId) ?? [];
|
|
751
|
+
const sort = sortComments ?? ((a) => a);
|
|
752
|
+
const res = allComments.map((i) => ({
|
|
753
|
+
...i.root,
|
|
754
|
+
children: i.children ?? [],
|
|
755
|
+
users: i.relativeUsers
|
|
756
|
+
}));
|
|
759
757
|
if (showComments) {
|
|
760
758
|
const map = /* @__PURE__ */ new Map();
|
|
761
759
|
res.forEach((comment) => {
|
package/lib/es/locale/ar-SA.js
CHANGED
package/lib/es/locale/ca-ES.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
//#region src/locale/ca-ES.ts
|
|
2
2
|
const locale = { "thread-comment-ui": {
|
|
3
3
|
panel: {
|
|
4
|
-
title: "Gestió de comentaris",
|
|
5
4
|
empty: "Encara no hi ha comentaris",
|
|
6
|
-
filterEmpty: "Cap resultat coincident",
|
|
7
5
|
reset: "Restableix el filtre",
|
|
8
6
|
addComment: "Afegeix un comentari",
|
|
9
7
|
solved: "Resolut"
|
package/lib/es/locale/de-DE.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
//#region src/locale/de-DE.ts
|
|
2
2
|
const locale = { "thread-comment-ui": {
|
|
3
3
|
panel: {
|
|
4
|
-
title: "Kommentarverwaltung",
|
|
5
4
|
empty: "Noch keine Kommentare",
|
|
6
|
-
filterEmpty: "Kein Treffer",
|
|
7
5
|
reset: "Filter zurücksetzen",
|
|
8
6
|
addComment: "Kommentar hinzufügen",
|
|
9
7
|
solved: "Gelöst"
|
package/lib/es/locale/en-US.js
CHANGED