@univerjs/thread-comment-ui 1.0.4 → 1.2.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 +74 -28
- package/lib/cjs/locale/ar-SA.js +2 -0
- package/lib/cjs/locale/ca-ES.js +2 -0
- package/lib/cjs/locale/de-DE.js +2 -0
- package/lib/cjs/locale/en-US.js +2 -0
- package/lib/cjs/locale/es-ES.js +2 -0
- package/lib/cjs/locale/fa-IR.js +2 -0
- package/lib/cjs/locale/fr-FR.js +2 -0
- package/lib/cjs/locale/id-ID.js +2 -0
- package/lib/cjs/locale/it-IT.js +2 -0
- package/lib/cjs/locale/ja-JP.js +2 -0
- package/lib/cjs/locale/ko-KR.js +2 -0
- package/lib/cjs/locale/pl-PL.js +2 -0
- package/lib/cjs/locale/pt-BR.js +2 -0
- package/lib/cjs/locale/ru-RU.js +2 -0
- package/lib/cjs/locale/sk-SK.js +2 -0
- package/lib/cjs/locale/vi-VN.js +2 -0
- package/lib/cjs/locale/zh-CN.js +2 -0
- package/lib/cjs/locale/zh-HK.js +2 -0
- package/lib/cjs/locale/zh-TW.js +2 -0
- package/lib/es/index.js +71 -25
- 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 +8 -0
- package/lib/index.js +71 -25
- 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 +2 -0
- package/lib/types/views/thread-comment-editor/util.d.ts +5 -1
- package/lib/umd/index.js +5 -5
- 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 +12 -12
package/lib/es/locale/de-DE.js
CHANGED
package/lib/es/locale/en-US.js
CHANGED
package/lib/es/locale/es-ES.js
CHANGED
package/lib/es/locale/fa-IR.js
CHANGED
package/lib/es/locale/fr-FR.js
CHANGED
package/lib/es/locale/id-ID.js
CHANGED
package/lib/es/locale/it-IT.js
CHANGED
package/lib/es/locale/ja-JP.js
CHANGED
package/lib/es/locale/ko-KR.js
CHANGED
package/lib/es/locale/pl-PL.js
CHANGED
package/lib/es/locale/pt-BR.js
CHANGED
package/lib/es/locale/ru-RU.js
CHANGED
package/lib/es/locale/sk-SK.js
CHANGED
package/lib/es/locale/vi-VN.js
CHANGED
package/lib/es/locale/zh-CN.js
CHANGED
package/lib/es/locale/zh-HK.js
CHANGED
package/lib/es/locale/zh-TW.js
CHANGED
package/lib/index.css
CHANGED
|
@@ -149,6 +149,10 @@
|
|
|
149
149
|
cursor: pointer;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
.univer-select-text {
|
|
153
|
+
user-select: text;
|
|
154
|
+
}
|
|
155
|
+
|
|
152
156
|
.univer-list-none {
|
|
153
157
|
list-style-type: none;
|
|
154
158
|
}
|
|
@@ -399,6 +403,10 @@
|
|
|
399
403
|
color: var(--univer-primary-600);
|
|
400
404
|
}
|
|
401
405
|
|
|
406
|
+
.univer-underline {
|
|
407
|
+
text-decoration-line: underline;
|
|
408
|
+
}
|
|
409
|
+
|
|
402
410
|
.univer-shadow {
|
|
403
411
|
--univer-tw-shadow: 0 1px 3px 0 #0000001a, 0 1px 2px -1px #0000001a;
|
|
404
412
|
--univer-tw-shadow-colored: 0 1px 3px 0 var(--univer-tw-shadow-color), 0 1px 2px -1px var(--univer-tw-shadow-color);
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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, toDisposable } from "@univerjs/core";
|
|
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, isSafeUrl, merge, mergeOverrideWithDependencies, toDisposable } from "@univerjs/core";
|
|
2
2
|
import { ISidebarService, KeyCode, UI_PLUGIN_CONFIG_KEY, UniverMobileUIPlugin, useConfigValue, useDependency, useEvent, useObservable } from "@univerjs/ui";
|
|
3
3
|
import { BehaviorSubject, debounceTime, map, of, startWith } from "rxjs";
|
|
4
4
|
import { BreakLineCommand, DeleteLeftCommand, DeleteRightCommand, IEditorService, RichTextEditor, UniverDocsUIPlugin } from "@univerjs/docs-ui";
|
|
@@ -9,7 +9,7 @@ import { DeleteIcon, IncreaseIcon, MoreHorizontalIcon, MoreLeftIcon, ReplyToComm
|
|
|
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.153.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.153.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.153.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.153.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.153.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.153.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
|
|
136
|
+
var version = "1.2.0";
|
|
137
137
|
|
|
138
138
|
//#endregion
|
|
139
139
|
//#region src/config/config.ts
|
|
@@ -487,13 +487,23 @@ const transformDocument2TextNodesInParagraph = (doc) => {
|
|
|
487
487
|
type: "text",
|
|
488
488
|
content: dataStream.slice(lastIndex, range.startIndex)
|
|
489
489
|
});
|
|
490
|
-
|
|
490
|
+
const content = dataStream.slice(range.startIndex, range.endIndex + 1);
|
|
491
|
+
if (range.rangeType === CustomRangeType.MENTION) textNodes.push({
|
|
491
492
|
type: "mention",
|
|
492
493
|
content: {
|
|
493
|
-
label:
|
|
494
|
+
label: content,
|
|
494
495
|
id: range.rangeId
|
|
495
496
|
}
|
|
496
497
|
});
|
|
498
|
+
else if (range.rangeType === CustomRangeType.HYPERLINK) textNodes.push({
|
|
499
|
+
type: "hyperlink",
|
|
500
|
+
content,
|
|
501
|
+
range
|
|
502
|
+
});
|
|
503
|
+
else textNodes.push({
|
|
504
|
+
type: "text",
|
|
505
|
+
content
|
|
506
|
+
});
|
|
497
507
|
lastIndex = range.endIndex + 1;
|
|
498
508
|
});
|
|
499
509
|
textNodes.push({
|
|
@@ -533,6 +543,16 @@ const transformTextNodes2Document = (nodes) => {
|
|
|
533
543
|
});
|
|
534
544
|
break;
|
|
535
545
|
}
|
|
546
|
+
case "hyperlink": {
|
|
547
|
+
const startIndex = str.length;
|
|
548
|
+
str += node.content;
|
|
549
|
+
customRanges.push({
|
|
550
|
+
...node.range,
|
|
551
|
+
startIndex,
|
|
552
|
+
endIndex: str.length - 1
|
|
553
|
+
});
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
536
556
|
}
|
|
537
557
|
});
|
|
538
558
|
str += "\r\n";
|
|
@@ -861,7 +881,8 @@ const ThreadCommentItem = (props) => {
|
|
|
861
881
|
return success;
|
|
862
882
|
}
|
|
863
883
|
}) : /* @__PURE__ */ jsx("div", {
|
|
864
|
-
|
|
884
|
+
tabIndex: -1,
|
|
885
|
+
className: "univer-select-text univer-text-sm univer-text-gray-900 dark:!univer-text-gray-0",
|
|
865
886
|
children: transformDocument2TextNodes(item.text).map((paragraph, paragraphIndex) => {
|
|
866
887
|
var _item$text$paragraphs;
|
|
867
888
|
let offset = 0;
|
|
@@ -871,10 +892,23 @@ const ThreadCommentItem = (props) => {
|
|
|
871
892
|
const key = offset;
|
|
872
893
|
offset += node.type === "mention" ? node.content.label.length : node.content.length;
|
|
873
894
|
switch (node.type) {
|
|
874
|
-
case "mention": return /* @__PURE__ */ jsxs("
|
|
895
|
+
case "mention": return /* @__PURE__ */ jsxs("span", {
|
|
875
896
|
className: "univer-text-primary-600",
|
|
876
897
|
children: [node.content.label, " "]
|
|
877
898
|
}, key);
|
|
899
|
+
case "hyperlink": {
|
|
900
|
+
var _node$range$propertie;
|
|
901
|
+
const url = (_node$range$propertie = node.range.properties) === null || _node$range$propertie === void 0 ? void 0 : _node$range$propertie.url;
|
|
902
|
+
if (!isSafeUrl(url)) return node.content;
|
|
903
|
+
return /* @__PURE__ */ jsx("a", {
|
|
904
|
+
href: url,
|
|
905
|
+
target: "_blank",
|
|
906
|
+
rel: "noopener noreferrer",
|
|
907
|
+
className: "univer-text-primary-600 univer-underline",
|
|
908
|
+
onClick: (event) => event.stopPropagation(),
|
|
909
|
+
children: node.content
|
|
910
|
+
}, key);
|
|
911
|
+
}
|
|
878
912
|
default: return node.content;
|
|
879
913
|
}
|
|
880
914
|
})
|
|
@@ -957,6 +991,8 @@ const ThreadCommentTree = (props) => {
|
|
|
957
991
|
const subUnitName = getSubUnitName((comments === null || comments === void 0 ? void 0 : comments.root.subUnitId) ?? subUnitId);
|
|
958
992
|
const editorVisible = showEdit && !editingId && !resolved;
|
|
959
993
|
const title = `${displayRef ?? refStr ?? (comments === null || comments === void 0 ? void 0 : comments.root.ref) ?? ""}${subUnitName ? " · " : ""}${subUnitName}`;
|
|
994
|
+
const resolveLabel = localeService.t(resolved ? "thread-comment-ui.item.markUnresolved" : "thread-comment-ui.item.markResolved");
|
|
995
|
+
const deleteLabel = localeService.t("thread-comment-ui.item.delete");
|
|
960
996
|
const threadCommentEditorId = getThreadCommentEditorId({
|
|
961
997
|
location,
|
|
962
998
|
unitId,
|
|
@@ -972,7 +1008,11 @@ const ThreadCommentTree = (props) => {
|
|
|
972
1008
|
"univer-shadow": !resolved && (showHighlight || isHover || location === "CELL")
|
|
973
1009
|
}),
|
|
974
1010
|
style,
|
|
975
|
-
onClick
|
|
1011
|
+
onClick: (event) => {
|
|
1012
|
+
const selection = event.currentTarget.ownerDocument.getSelection();
|
|
1013
|
+
if (selection && !selection.isCollapsed && selection.anchorNode && selection.focusNode && event.currentTarget.contains(selection.anchorNode) && event.currentTarget.contains(selection.focusNode)) return;
|
|
1014
|
+
onClick === null || onClick === void 0 || onClick();
|
|
1015
|
+
},
|
|
976
1016
|
onMouseEnter: () => {
|
|
977
1017
|
onMouseEnter === null || onMouseEnter === void 0 || onMouseEnter();
|
|
978
1018
|
setIsHover(true);
|
|
@@ -997,18 +1037,24 @@ const ThreadCommentTree = (props) => {
|
|
|
997
1037
|
})]
|
|
998
1038
|
}), !!comments && /* @__PURE__ */ jsxs("div", {
|
|
999
1039
|
className: "univer-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-row",
|
|
1000
|
-
children: [/* @__PURE__ */ jsx(
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
children: /* @__PURE__ */ jsx(
|
|
1040
|
+
children: [/* @__PURE__ */ jsx(Tooltip, {
|
|
1041
|
+
title: resolveLabel,
|
|
1042
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
1043
|
+
type: "button",
|
|
1044
|
+
"aria-label": resolveLabel,
|
|
1045
|
+
className: clsx("univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-border-0 univer-bg-transparent univer-p-0 univer-text-base hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800", { "univer-text-green-500": resolved }),
|
|
1046
|
+
onClick: handleResolve,
|
|
1047
|
+
children: resolved ? /* @__PURE__ */ jsx(SuccessIcon, {}) : /* @__PURE__ */ jsx(SuccessOutlineIcon, {})
|
|
1048
|
+
})
|
|
1049
|
+
}), (currentUser === null || currentUser === void 0 ? void 0 : currentUser.userID) === comments.root.personId ? /* @__PURE__ */ jsx(Tooltip, {
|
|
1050
|
+
title: deleteLabel,
|
|
1051
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
1052
|
+
type: "button",
|
|
1053
|
+
"aria-label": deleteLabel,
|
|
1054
|
+
className: "univer-ml-1 univer-inline-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-[3px] univer-border-0 univer-bg-transparent univer-p-0 univer-text-base hover:univer-bg-gray-50 rtl:univer-ml-0 rtl:univer-mr-1 dark:hover:!univer-bg-gray-800",
|
|
1055
|
+
onClick: handleDeleteRoot,
|
|
1056
|
+
children: /* @__PURE__ */ jsx(DeleteIcon, {})
|
|
1057
|
+
})
|
|
1012
1058
|
}) : null]
|
|
1013
1059
|
})]
|
|
1014
1060
|
}),
|
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
package/lib/locale/zh-CN.js
CHANGED
package/lib/locale/zh-HK.js
CHANGED
package/lib/locale/zh-TW.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { IDocumentBody } from '@univerjs/core';
|
|
16
|
+
import type { ICustomRange, IDocumentBody } from '@univerjs/core';
|
|
17
17
|
import type { IThreadCommentMention } from '@univerjs/thread-comment';
|
|
18
18
|
interface IThreadCommentEditorFocusService {
|
|
19
19
|
focus: (editorId: string) => void;
|
|
@@ -27,6 +27,10 @@ export type TextNode = {
|
|
|
27
27
|
} | {
|
|
28
28
|
type: 'mention';
|
|
29
29
|
content: IThreadCommentMention;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'hyperlink';
|
|
32
|
+
content: string;
|
|
33
|
+
range: ICustomRange;
|
|
30
34
|
};
|
|
31
35
|
export declare const transformDocument2TextNodes: (doc: IDocumentBody) => TextNode[][];
|
|
32
36
|
export declare const transformTextNodes2Document: (nodes: TextNode[]) => IDocumentBody;
|