@univerjs/thread-comment-ui 1.0.0-beta.0 → 1.0.0-beta.2

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.
Files changed (83) hide show
  1. package/lib/cjs/index.js +38 -26
  2. package/lib/cjs/locale/ar-SA.js +0 -2
  3. package/lib/cjs/locale/ca-ES.js +0 -2
  4. package/lib/cjs/locale/de-DE.js +0 -2
  5. package/lib/cjs/locale/en-US.js +0 -2
  6. package/lib/cjs/locale/es-ES.js +0 -2
  7. package/lib/cjs/locale/fa-IR.js +0 -2
  8. package/lib/cjs/locale/fr-FR.js +0 -2
  9. package/lib/cjs/locale/id-ID.js +0 -2
  10. package/lib/cjs/locale/it-IT.js +0 -2
  11. package/lib/cjs/locale/ja-JP.js +0 -2
  12. package/lib/cjs/locale/ko-KR.js +0 -2
  13. package/lib/cjs/locale/pl-PL.js +0 -2
  14. package/lib/cjs/locale/pt-BR.js +0 -2
  15. package/lib/cjs/locale/ru-RU.js +0 -2
  16. package/lib/cjs/locale/sk-SK.js +0 -2
  17. package/lib/cjs/locale/vi-VN.js +0 -2
  18. package/lib/cjs/locale/zh-CN.js +0 -2
  19. package/lib/cjs/locale/zh-HK.js +0 -2
  20. package/lib/cjs/locale/zh-TW.js +0 -2
  21. package/lib/es/index.js +39 -27
  22. package/lib/es/locale/ar-SA.js +0 -2
  23. package/lib/es/locale/ca-ES.js +0 -2
  24. package/lib/es/locale/de-DE.js +0 -2
  25. package/lib/es/locale/en-US.js +0 -2
  26. package/lib/es/locale/es-ES.js +0 -2
  27. package/lib/es/locale/fa-IR.js +0 -2
  28. package/lib/es/locale/fr-FR.js +0 -2
  29. package/lib/es/locale/id-ID.js +0 -2
  30. package/lib/es/locale/it-IT.js +0 -2
  31. package/lib/es/locale/ja-JP.js +0 -2
  32. package/lib/es/locale/ko-KR.js +0 -2
  33. package/lib/es/locale/pl-PL.js +0 -2
  34. package/lib/es/locale/pt-BR.js +0 -2
  35. package/lib/es/locale/ru-RU.js +0 -2
  36. package/lib/es/locale/sk-SK.js +0 -2
  37. package/lib/es/locale/vi-VN.js +0 -2
  38. package/lib/es/locale/zh-CN.js +0 -2
  39. package/lib/es/locale/zh-HK.js +0 -2
  40. package/lib/es/locale/zh-TW.js +0 -2
  41. package/lib/index.css +22 -8
  42. package/lib/index.js +39 -27
  43. package/lib/locale/ar-SA.js +0 -2
  44. package/lib/locale/ca-ES.js +0 -2
  45. package/lib/locale/de-DE.js +0 -2
  46. package/lib/locale/en-US.js +0 -2
  47. package/lib/locale/es-ES.js +0 -2
  48. package/lib/locale/fa-IR.js +0 -2
  49. package/lib/locale/fr-FR.js +0 -2
  50. package/lib/locale/id-ID.js +0 -2
  51. package/lib/locale/it-IT.js +0 -2
  52. package/lib/locale/ja-JP.js +0 -2
  53. package/lib/locale/ko-KR.js +0 -2
  54. package/lib/locale/pl-PL.js +0 -2
  55. package/lib/locale/pt-BR.js +0 -2
  56. package/lib/locale/ru-RU.js +0 -2
  57. package/lib/locale/sk-SK.js +0 -2
  58. package/lib/locale/vi-VN.js +0 -2
  59. package/lib/locale/zh-CN.js +0 -2
  60. package/lib/locale/zh-HK.js +0 -2
  61. package/lib/locale/zh-TW.js +0 -2
  62. package/lib/types/locale/en-US.d.ts +0 -2
  63. package/lib/umd/index.js +4 -4
  64. package/lib/umd/locale/ar-SA.js +1 -1
  65. package/lib/umd/locale/ca-ES.js +1 -1
  66. package/lib/umd/locale/de-DE.js +1 -1
  67. package/lib/umd/locale/en-US.js +1 -1
  68. package/lib/umd/locale/es-ES.js +1 -1
  69. package/lib/umd/locale/fa-IR.js +1 -1
  70. package/lib/umd/locale/fr-FR.js +1 -1
  71. package/lib/umd/locale/id-ID.js +1 -1
  72. package/lib/umd/locale/it-IT.js +1 -1
  73. package/lib/umd/locale/ja-JP.js +1 -1
  74. package/lib/umd/locale/ko-KR.js +1 -1
  75. package/lib/umd/locale/pl-PL.js +1 -1
  76. package/lib/umd/locale/pt-BR.js +1 -1
  77. package/lib/umd/locale/ru-RU.js +1 -1
  78. package/lib/umd/locale/sk-SK.js +1 -1
  79. package/lib/umd/locale/vi-VN.js +1 -1
  80. package/lib/umd/locale/zh-CN.js +1 -1
  81. package/lib/umd/locale/zh-HK.js +1 -1
  82. package/lib/umd/locale/zh-TW.js +1 -1
  83. package/package.json +9 -9
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-beta.0";
128
+ var version = "1.0.0-beta.2";
129
129
 
130
130
  //#endregion
131
131
  //#region src/config/config.ts
@@ -429,7 +429,8 @@ function formatCommentDateTime(value, region) {
429
429
  day: "numeric",
430
430
  hour: "2-digit",
431
431
  minute: "2-digit",
432
- hour12: false
432
+ hour12: false,
433
+ numberingSystem: "latn"
433
434
  });
434
435
  }
435
436
  const ThreadCommentItem = (props) => {
@@ -446,6 +447,7 @@ const ThreadCommentItem = (props) => {
446
447
  const uiConfig = (0, _univerjs_ui.useConfigValue)(_univerjs_ui.UI_PLUGIN_CONFIG_KEY);
447
448
  const avatarFallback = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.avatarFallback;
448
449
  const currentRegion = (0, _univerjs_ui.useObservable)(regionService.currentRegion$, regionService.getCurrentRegion());
450
+ const direction = (0, _univerjs_ui.useObservable)(localeService.direction$, localeService.getDirection());
449
451
  const dateText = isMock ? null : formatCommentDateTime(item.dT, currentRegion);
450
452
  const handleDeleteItem = () => {
451
453
  if ((onDeleteComment === null || onDeleteComment === void 0 ? void 0 : onDeleteComment(item)) === false) return;
@@ -476,9 +478,10 @@ const ThreadCommentItem = (props) => {
476
478
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_icons.ReplyToCommentIcon, {})
477
479
  }) : null, isCommentBySelf && !isMock && !resolved ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_univerjs_design.Dropdown, {
478
480
  overlay: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
481
+ dir: direction,
479
482
  className: "univer-rounded-lg",
480
483
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("ul", {
481
- 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",
482
485
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
483
486
  className: "hover:univer-bg-gray-200",
484
487
  onClick: () => onEditingChange === null || onEditingChange === void 0 ? void 0 : onEditingChange(true),
@@ -497,9 +500,11 @@ const ThreadCommentItem = (props) => {
497
500
  }) : null] })]
498
501
  }) : null,
499
502
  dateText && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("time", {
500
- dir: "ltr",
501
- className: "univer-mb-1 univer-block univer-text-xs/normal univer-text-gray-600 dark:!univer-text-gray-200",
502
- children: dateText
503
+ className: "univer-mb-1 univer-block univer-text-xs/normal univer-text-gray-600 rtl:univer-text-right dark:!univer-text-gray-200",
504
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("bdo", {
505
+ dir: "ltr",
506
+ children: dateText
507
+ })
503
508
  }),
504
509
  editing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentEditor, {
505
510
  type,
@@ -523,19 +528,25 @@ const ThreadCommentItem = (props) => {
523
528
  });
524
529
  }
525
530
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
526
- className: "univer-text-sm univer-text-gray-900 dark:!univer-text-white",
527
- children: transformDocument2TextNodes(item.text).map((paragraph, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
528
- className: "univer-break-words",
529
- children: paragraph.map((item, i) => {
530
- switch (item.type) {
531
- case "mention": return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
532
- className: "univer-text-primary-600",
533
- children: [item.content.label, " "]
534
- }, i);
535
- default: return item.content;
536
- }
537
- })
538
- }, i))
531
+ className: "univer-text-sm univer-text-gray-900 dark:!univer-text-gray-0",
532
+ children: transformDocument2TextNodes(item.text).map((paragraph, paragraphIndex) => {
533
+ var _item$text$paragraphs;
534
+ let offset = 0;
535
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
536
+ className: "univer-break-words",
537
+ children: paragraph.map((node) => {
538
+ const key = offset;
539
+ offset += node.type === "mention" ? node.content.label.length : node.content.length;
540
+ switch (node.type) {
541
+ case "mention": return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
542
+ className: "univer-text-primary-600",
543
+ children: [node.content.label, " "]
544
+ }, key);
545
+ default: return node.content;
546
+ }
547
+ })
548
+ }, (_item$text$paragraphs = item.text.paragraphs) === null || _item$text$paragraphs === void 0 || (_item$text$paragraphs = _item$text$paragraphs[paragraphIndex]) === null || _item$text$paragraphs === void 0 ? void 0 : _item$text$paragraphs.paragraphId);
549
+ })
539
550
  })
540
551
  ]
541
552
  });
@@ -569,7 +580,8 @@ const ThreadCommentTree = (props) => {
569
580
  subUnitId,
570
581
  threadId: ""
571
582
  }], ...(comments === null || comments === void 0 ? void 0 : comments.children) ?? []];
572
- const scroller = (0, react.useRef)(null);
583
+ const scrollerRef = (0, react.useRef)(null);
584
+ const handleMouseLeave = (0, _univerjs_ui.useEvent)(onMouseLeave);
573
585
  const handleResolve = (e) => {
574
586
  e.stopPropagation();
575
587
  if (!resolved) commandService.executeCommand(SetActiveCommentOperation.id);
@@ -598,8 +610,8 @@ const ThreadCommentTree = (props) => {
598
610
  onClose === null || onClose === void 0 || onClose();
599
611
  };
600
612
  (0, react.useEffect)(() => {
601
- return onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave();
602
- }, []);
613
+ return handleMouseLeave;
614
+ }, [handleMouseLeave]);
603
615
  const subUnitName = getSubUnitName((comments === null || comments === void 0 ? void 0 : comments.root.subUnitId) ?? subUnitId);
604
616
  const editorVisible = showEdit && !editingId && !resolved;
605
617
  const title = `${refStr || (comments === null || comments === void 0 ? void 0 : comments.root.ref) || ""}${subUnitName ? " · " : ""}${subUnitName}`;
@@ -612,7 +624,7 @@ const ThreadCommentTree = (props) => {
612
624
  });
613
625
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
614
626
  id: `${location}-${unitId}-${subUnitId}-${id}`,
615
- className: (0, _univerjs_design.clsx)("univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4 dark:!univer-bg-gray-900 dark:!univer-text-white", _univerjs_design.borderClassName, {
627
+ 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
628
  "univer-w-[278px]": !full,
617
629
  "univer-w-full": full,
618
630
  "univer-shadow": !resolved && (showHighlight || isHover || location === "CELL")
@@ -655,8 +667,8 @@ const ThreadCommentTree = (props) => {
655
667
  })]
656
668
  }),
657
669
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
658
- ref: scroller,
659
- className: (0, _univerjs_design.clsx)("univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden", _univerjs_design.scrollbarClassName),
670
+ ref: scrollerRef,
671
+ 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
672
  children: renderComments.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThreadCommentItem, {
661
673
  unitId,
662
674
  subUnitId,
@@ -716,7 +728,7 @@ const ThreadCommentTree = (props) => {
716
728
  subUnitId,
717
729
  comment
718
730
  });
719
- if (scroller.current) scroller.current.scrollTop = scroller.current.scrollHeight;
731
+ if (scrollerRef.current) scrollerRef.current.scrollTop = scrollerRef.current.scrollHeight;
720
732
  },
721
733
  autoFocus: autoFocus || !comments,
722
734
  onCancel: () => {
@@ -2,9 +2,7 @@
2
2
  //#region src/locale/ar-SA.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: "تم الحل"
@@ -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"
@@ -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"
@@ -17,9 +17,7 @@
17
17
  */
18
18
  const locale = { "thread-comment-ui": {
19
19
  panel: {
20
- title: "Comment Management",
21
20
  empty: "No comments yet",
22
- filterEmpty: "No match result",
23
21
  reset: "Reset Filter",
24
22
  addComment: "Add Comment",
25
23
  solved: "Solved"
@@ -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"
@@ -2,9 +2,7 @@
2
2
  //#region src/locale/fa-IR.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: "حل شده"
@@ -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"
@@ -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"
@@ -2,9 +2,7 @@
2
2
  //#region src/locale/it-IT.ts
3
3
  const locale = { "thread-comment-ui": {
4
4
  panel: {
5
- title: "Gestione commenti",
6
5
  empty: "Nessun commento",
7
- filterEmpty: "Nessun risultato",
8
6
  reset: "Reimposta filtro",
9
7
  addComment: "Aggiungi commento",
10
8
  solved: "Risolto"
@@ -2,9 +2,7 @@
2
2
  //#region src/locale/ja-JP.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: "解決済み"
@@ -2,9 +2,7 @@
2
2
  //#region src/locale/ko-KR.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: "해결됨"
@@ -2,9 +2,7 @@
2
2
  //#region src/locale/pl-PL.ts
3
3
  const locale = { "thread-comment-ui": {
4
4
  panel: {
5
- title: "Zarządzanie komentarzami",
6
5
  empty: "Brak komentarzy",
7
- filterEmpty: "Brak wyników",
8
6
  reset: "Resetuj filtr",
9
7
  addComment: "Dodaj komentarz",
10
8
  solved: "Rozwiązane"
@@ -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"
@@ -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: "Решено"
@@ -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é"
@@ -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"
@@ -2,9 +2,7 @@
2
2
  //#region src/locale/zh-CN.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: "已解决"
@@ -2,9 +2,7 @@
2
2
  //#region src/locale/zh-HK.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: "已解決"
@@ -2,9 +2,7 @@
2
2
  //#region src/locale/zh-TW.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/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, useConfigValue, useDependency, useObservable } from "@univerjs/ui";
2
+ import { ISidebarService, KeyCode, UI_PLUGIN_CONFIG_KEY, useConfigValue, useDependency, useEvent, 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-beta.0";
127
+ var version = "1.0.0-beta.2";
128
128
 
129
129
  //#endregion
130
130
  //#region src/config/config.ts
@@ -428,7 +428,8 @@ function formatCommentDateTime(value, region) {
428
428
  day: "numeric",
429
429
  hour: "2-digit",
430
430
  minute: "2-digit",
431
- hour12: false
431
+ hour12: false,
432
+ numberingSystem: "latn"
432
433
  });
433
434
  }
434
435
  const ThreadCommentItem = (props) => {
@@ -445,6 +446,7 @@ const ThreadCommentItem = (props) => {
445
446
  const uiConfig = useConfigValue(UI_PLUGIN_CONFIG_KEY);
446
447
  const avatarFallback = uiConfig === null || uiConfig === void 0 ? void 0 : uiConfig.avatarFallback;
447
448
  const currentRegion = useObservable(regionService.currentRegion$, regionService.getCurrentRegion());
449
+ const direction = useObservable(localeService.direction$, localeService.getDirection());
448
450
  const dateText = isMock ? null : formatCommentDateTime(item.dT, currentRegion);
449
451
  const handleDeleteItem = () => {
450
452
  if ((onDeleteComment === null || onDeleteComment === void 0 ? void 0 : onDeleteComment(item)) === false) return;
@@ -475,9 +477,10 @@ const ThreadCommentItem = (props) => {
475
477
  children: /* @__PURE__ */ jsx(ReplyToCommentIcon, {})
476
478
  }) : null, isCommentBySelf && !isMock && !resolved ? /* @__PURE__ */ jsx(Dropdown, {
477
479
  overlay: /* @__PURE__ */ jsx("div", {
480
+ dir: direction,
478
481
  className: "univer-rounded-lg",
479
482
  children: /* @__PURE__ */ 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",
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",
481
484
  children: [/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("a", {
482
485
  className: "hover:univer-bg-gray-200",
483
486
  onClick: () => onEditingChange === null || onEditingChange === void 0 ? void 0 : onEditingChange(true),
@@ -496,9 +499,11 @@ const ThreadCommentItem = (props) => {
496
499
  }) : null] })]
497
500
  }) : null,
498
501
  dateText && /* @__PURE__ */ jsx("time", {
499
- dir: "ltr",
500
- className: "univer-mb-1 univer-block univer-text-xs/normal univer-text-gray-600 dark:!univer-text-gray-200",
501
- children: dateText
502
+ className: "univer-mb-1 univer-block univer-text-xs/normal univer-text-gray-600 rtl:univer-text-right dark:!univer-text-gray-200",
503
+ children: /* @__PURE__ */ jsx("bdo", {
504
+ dir: "ltr",
505
+ children: dateText
506
+ })
502
507
  }),
503
508
  editing ? /* @__PURE__ */ jsx(ThreadCommentEditor, {
504
509
  type,
@@ -522,19 +527,25 @@ const ThreadCommentItem = (props) => {
522
527
  });
523
528
  }
524
529
  }) : /* @__PURE__ */ jsx("div", {
525
- className: "univer-text-sm univer-text-gray-900 dark:!univer-text-white",
526
- children: transformDocument2TextNodes(item.text).map((paragraph, i) => /* @__PURE__ */ jsx("div", {
527
- className: "univer-break-words",
528
- children: paragraph.map((item, i) => {
529
- switch (item.type) {
530
- case "mention": return /* @__PURE__ */ jsxs("a", {
531
- className: "univer-text-primary-600",
532
- children: [item.content.label, " "]
533
- }, i);
534
- default: return item.content;
535
- }
536
- })
537
- }, i))
530
+ className: "univer-text-sm univer-text-gray-900 dark:!univer-text-gray-0",
531
+ children: transformDocument2TextNodes(item.text).map((paragraph, paragraphIndex) => {
532
+ var _item$text$paragraphs;
533
+ let offset = 0;
534
+ return /* @__PURE__ */ jsx("div", {
535
+ className: "univer-break-words",
536
+ children: paragraph.map((node) => {
537
+ const key = offset;
538
+ offset += node.type === "mention" ? node.content.label.length : node.content.length;
539
+ switch (node.type) {
540
+ case "mention": return /* @__PURE__ */ jsxs("a", {
541
+ className: "univer-text-primary-600",
542
+ children: [node.content.label, " "]
543
+ }, key);
544
+ default: return node.content;
545
+ }
546
+ })
547
+ }, (_item$text$paragraphs = item.text.paragraphs) === null || _item$text$paragraphs === void 0 || (_item$text$paragraphs = _item$text$paragraphs[paragraphIndex]) === null || _item$text$paragraphs === void 0 ? void 0 : _item$text$paragraphs.paragraphId);
548
+ })
538
549
  })
539
550
  ]
540
551
  });
@@ -568,7 +579,8 @@ const ThreadCommentTree = (props) => {
568
579
  subUnitId,
569
580
  threadId: ""
570
581
  }], ...(comments === null || comments === void 0 ? void 0 : comments.children) ?? []];
571
- const scroller = useRef(null);
582
+ const scrollerRef = useRef(null);
583
+ const handleMouseLeave = useEvent(onMouseLeave);
572
584
  const handleResolve = (e) => {
573
585
  e.stopPropagation();
574
586
  if (!resolved) commandService.executeCommand(SetActiveCommentOperation.id);
@@ -597,8 +609,8 @@ const ThreadCommentTree = (props) => {
597
609
  onClose === null || onClose === void 0 || onClose();
598
610
  };
599
611
  useEffect(() => {
600
- return onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave();
601
- }, []);
612
+ return handleMouseLeave;
613
+ }, [handleMouseLeave]);
602
614
  const subUnitName = getSubUnitName((comments === null || comments === void 0 ? void 0 : comments.root.subUnitId) ?? subUnitId);
603
615
  const editorVisible = showEdit && !editingId && !resolved;
604
616
  const title = `${refStr || (comments === null || comments === void 0 ? void 0 : comments.root.ref) || ""}${subUnitName ? " · " : ""}${subUnitName}`;
@@ -611,7 +623,7 @@ const ThreadCommentTree = (props) => {
611
623
  });
612
624
  return /* @__PURE__ */ jsxs("div", {
613
625
  id: `${location}-${unitId}-${subUnitId}-${id}`,
614
- className: clsx("univer-relative univer-box-border univer-rounded-md univer-bg-white univer-p-4 dark:!univer-bg-gray-900 dark:!univer-text-white", borderClassName, {
626
+ 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
627
  "univer-w-[278px]": !full,
616
628
  "univer-w-full": full,
617
629
  "univer-shadow": !resolved && (showHighlight || isHover || location === "CELL")
@@ -654,8 +666,8 @@ const ThreadCommentTree = (props) => {
654
666
  })]
655
667
  }),
656
668
  /* @__PURE__ */ jsx("div", {
657
- ref: scroller,
658
- className: clsx("univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden", scrollbarClassName),
669
+ ref: scrollerRef,
670
+ className: clsx("univer-max-h-80 univer-overflow-y-auto univer-overflow-x-hidden", scrollbarClassName, location === "PANEL" && "-univer-mx-4 univer-px-4"),
659
671
  children: renderComments.map((item) => /* @__PURE__ */ jsx(ThreadCommentItem, {
660
672
  unitId,
661
673
  subUnitId,
@@ -715,7 +727,7 @@ const ThreadCommentTree = (props) => {
715
727
  subUnitId,
716
728
  comment
717
729
  });
718
- if (scroller.current) scroller.current.scrollTop = scroller.current.scrollHeight;
730
+ if (scrollerRef.current) scrollerRef.current.scrollTop = scrollerRef.current.scrollHeight;
719
731
  },
720
732
  autoFocus: autoFocus || !comments,
721
733
  onCancel: () => {
@@ -1,9 +1,7 @@
1
1
  //#region src/locale/ar-SA.ts
2
2
  const locale = { "thread-comment-ui": {
3
3
  panel: {
4
- title: "إدارة التعليقات",
5
4
  empty: "لا توجد تعليقات بعد",
6
- filterEmpty: "لا توجد نتائج مطابقة",
7
5
  reset: "إعادة ضبط التصفية",
8
6
  addComment: "إضافة تعليق",
9
7
  solved: "تم الحل"
@@ -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"
@@ -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"
@@ -16,9 +16,7 @@
16
16
  */
17
17
  const locale = { "thread-comment-ui": {
18
18
  panel: {
19
- title: "Comment Management",
20
19
  empty: "No comments yet",
21
- filterEmpty: "No match result",
22
20
  reset: "Reset Filter",
23
21
  addComment: "Add Comment",
24
22
  solved: "Solved"
@@ -1,9 +1,7 @@
1
1
  //#region src/locale/es-ES.ts
2
2
  const locale = { "thread-comment-ui": {
3
3
  panel: {
4
- title: "Gestión de comentarios",
5
4
  empty: "Aún no hay comentarios",
6
- filterEmpty: "Sin resultados coincidentes",
7
5
  reset: "Restablecer filtro",
8
6
  addComment: "Añadir comentario",
9
7
  solved: "Resuelto"
@@ -1,9 +1,7 @@
1
1
  //#region src/locale/fa-IR.ts
2
2
  const locale = { "thread-comment-ui": {
3
3
  panel: {
4
- title: "مدیریت نظرات",
5
4
  empty: "هنوز نظری وجود ندارد",
6
- filterEmpty: "نتیجه ای یافت نشد",
7
5
  reset: "بازنشانی فیلتر",
8
6
  addComment: "افزودن نظر",
9
7
  solved: "حل شده"
@@ -1,9 +1,7 @@
1
1
  //#region src/locale/fr-FR.ts
2
2
  const locale = { "thread-comment-ui": {
3
3
  panel: {
4
- title: "Gestion des commentaires",
5
4
  empty: "Pas encore de commentaires",
6
- filterEmpty: "Aucun résultat correspondant",
7
5
  reset: "Réinitialiser le filtre",
8
6
  addComment: "Ajouter un commentaire",
9
7
  solved: "Résolu"
@@ -1,9 +1,7 @@
1
1
  //#region src/locale/id-ID.ts
2
2
  const locale = { "thread-comment-ui": {
3
3
  panel: {
4
- title: "Manajemen Komentar",
5
4
  empty: "Belum ada komentar",
6
- filterEmpty: "Tidak ada hasil yang cocok",
7
5
  reset: "Atur Ulang Filter",
8
6
  addComment: "Tambah Komentar",
9
7
  solved: "Terselesaikan"
@@ -1,9 +1,7 @@
1
1
  //#region src/locale/it-IT.ts
2
2
  const locale = { "thread-comment-ui": {
3
3
  panel: {
4
- title: "Gestione commenti",
5
4
  empty: "Nessun commento",
6
- filterEmpty: "Nessun risultato",
7
5
  reset: "Reimposta filtro",
8
6
  addComment: "Aggiungi commento",
9
7
  solved: "Risolto"
@@ -1,9 +1,7 @@
1
1
  //#region src/locale/ja-JP.ts
2
2
  const locale = { "thread-comment-ui": {
3
3
  panel: {
4
- title: "コメント管理",
5
4
  empty: "まだコメントはありません",
6
- filterEmpty: "一致する結果がありません",
7
5
  reset: "フィルタをリセット",
8
6
  addComment: "コメントを追加",
9
7
  solved: "解決済み"
@@ -1,9 +1,7 @@
1
1
  //#region src/locale/ko-KR.ts
2
2
  const locale = { "thread-comment-ui": {
3
3
  panel: {
4
- title: "댓글 관리",
5
4
  empty: "아직 댓글이 없습니다",
6
- filterEmpty: "일치하는 결과가 없습니다",
7
5
  reset: "필터 초기화",
8
6
  addComment: "댓글 추가",
9
7
  solved: "해결됨"
@@ -1,9 +1,7 @@
1
1
  //#region src/locale/pl-PL.ts
2
2
  const locale = { "thread-comment-ui": {
3
3
  panel: {
4
- title: "Zarządzanie komentarzami",
5
4
  empty: "Brak komentarzy",
6
- filterEmpty: "Brak wyników",
7
5
  reset: "Resetuj filtr",
8
6
  addComment: "Dodaj komentarz",
9
7
  solved: "Rozwiązane"
@@ -1,9 +1,7 @@
1
1
  //#region src/locale/pt-BR.ts
2
2
  const locale = { "thread-comment-ui": {
3
3
  panel: {
4
- title: "Gerenciamento de Comentários",
5
4
  empty: "Nenhum comentário ainda",
6
- filterEmpty: "Nenhum resultado correspondente",
7
5
  reset: "Redefinir Filtro",
8
6
  addComment: "Adicionar Comentário",
9
7
  solved: "Resolvido"