@box/threaded-annotations 1.94.9 → 1.94.11
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/dist/esm/lib/components/v2/message-editor/editor-extensions/custom-mention/useMentionState.js +17 -14
- package/dist/esm/lib/components/v2/message-editor/message-editor.js +110 -94
- package/dist/types/lib/components/v2/message-editor/editor-extensions/custom-mention/useMentionState.d.ts +1 -0
- package/package.json +11 -11
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
var
|
|
1
|
+
import { useCallback as e, useMemo as t, useState as n } from "react";
|
|
2
|
+
var r = /* @__PURE__ */ function(e) {
|
|
3
3
|
return e.ARROW_DOWN = "ArrowDown", e.ARROW_UP = "ArrowUp", e.ENTER = "Enter", e;
|
|
4
|
-
}({}),
|
|
5
|
-
let [
|
|
4
|
+
}({}), i = (i) => {
|
|
5
|
+
let [a, o] = n(!1), [s, c] = n(""), [l, u] = n(null);
|
|
6
6
|
return {
|
|
7
|
-
isActive:
|
|
8
|
-
query:
|
|
9
|
-
command:
|
|
10
|
-
suggestionCallbacks:
|
|
7
|
+
isActive: a,
|
|
8
|
+
query: s,
|
|
9
|
+
command: l,
|
|
10
|
+
suggestionCallbacks: t(() => ({
|
|
11
11
|
onSuggestionStart: (e) => {
|
|
12
|
-
|
|
12
|
+
o(!0), c(e.query), u(() => e.command);
|
|
13
13
|
},
|
|
14
14
|
onSuggestionUpdate: (e) => {
|
|
15
|
-
|
|
15
|
+
o(!0), c(e.query), u(() => e.command);
|
|
16
16
|
},
|
|
17
|
-
onSuggestionKeyDown: (e) =>
|
|
17
|
+
onSuggestionKeyDown: (e) => i.current ? e.event.key === r.ARROW_DOWN ? (i.current.selectNext(), !0) : e.event.key === r.ARROW_UP ? (i.current.selectPrevious(), !0) : e.event.key === r.ENTER ? (i.current.selectItem(), !0) : !1 : !1,
|
|
18
18
|
onSuggestionExit: () => {
|
|
19
|
-
|
|
19
|
+
o(!1);
|
|
20
20
|
}
|
|
21
|
-
}), [
|
|
21
|
+
}), [i]),
|
|
22
|
+
close: e(() => {
|
|
23
|
+
o(!1), c(""), u(null);
|
|
24
|
+
}, [])
|
|
22
25
|
};
|
|
23
26
|
};
|
|
24
|
-
export {
|
|
27
|
+
export { r as KeyEvents, i as useMentionState };
|
|
@@ -2,161 +2,177 @@ import { THREADED_ANNOTATIONS_PORTAL as e } from "../../../v2/constants.js";
|
|
|
2
2
|
import { useMentionContext as t } from "../../mention-component/mention-context.js";
|
|
3
3
|
import { CustomMention as n } from "./editor-extensions/custom-mention/custom-mention.js";
|
|
4
4
|
import { createSuggestionOptions as r } from "./editor-extensions/custom-mention/custom-mention-suggestions.js";
|
|
5
|
-
import { MENTION_PLUGIN_KEY as i, normalizeMentionPastedText as a, normalizeMentionTextInput as
|
|
6
|
-
import { useMentionState as
|
|
7
|
-
import { CustomParagraph as
|
|
8
|
-
import { useCharacterLimit as
|
|
9
|
-
import { useEditorContainerState as
|
|
10
|
-
import { useMentionUserSelection as
|
|
11
|
-
import { MessageEditorProvider as
|
|
12
|
-
import
|
|
13
|
-
import { t as
|
|
14
|
-
import { CharacterLimitCounter as
|
|
15
|
-
import { EditButtons as
|
|
16
|
-
import { ErrorMessage as
|
|
17
|
-
import { PostButton as
|
|
18
|
-
import { MessageEditorVariant as
|
|
19
|
-
import { VisuallyHidden as
|
|
20
|
-
import
|
|
21
|
-
import { useEffect as
|
|
22
|
-
import { useIntl as
|
|
23
|
-
import { Fragment as
|
|
24
|
-
import { UserSelectorHeadless as
|
|
25
|
-
import { EditorContent as
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
var E = (
|
|
30
|
-
let { disableComponent: E = !1, initialContent: D, isFirstAnnotation: O = !1, isReply:
|
|
5
|
+
import { MENTION_PLUGIN_KEY as i, normalizeMentionPastedText as a, normalizeMentionTextInput as ee } from "./editor-extensions/custom-mention/mention-trigger-normalization.js";
|
|
6
|
+
import { useMentionState as o } from "./editor-extensions/custom-mention/useMentionState.js";
|
|
7
|
+
import { CustomParagraph as te } from "./editor-extensions/custom-paragraph.js";
|
|
8
|
+
import { useCharacterLimit as ne } from "./hooks/useCharacterLimit.js";
|
|
9
|
+
import { useEditorContainerState as re } from "./hooks/useEditorContainerState.js";
|
|
10
|
+
import { useMentionUserSelection as ie } from "./hooks/useMentionUserSelection.js";
|
|
11
|
+
import { MessageEditorProvider as s, useMessageEditorContext as ae } from "./message-editor-context.js";
|
|
12
|
+
import c from "./messages.js";
|
|
13
|
+
import { t as l } from "../../../../../chunks/message-editor2.module.js";
|
|
14
|
+
import { CharacterLimitCounter as u } from "./subcomponents/character-limit-counter.js";
|
|
15
|
+
import { EditButtons as d } from "./subcomponents/edit-buttons.js";
|
|
16
|
+
import { ErrorMessage as f } from "./subcomponents/error-message.js";
|
|
17
|
+
import { PostButton as p } from "./subcomponents/post-button.js";
|
|
18
|
+
import { MessageEditorVariant as m } from "./message-editor.types.js";
|
|
19
|
+
import { VisuallyHidden as oe } from "@box/blueprint-web";
|
|
20
|
+
import h from "clsx";
|
|
21
|
+
import { useEffect as g, useMemo as se, useRef as _ } from "react";
|
|
22
|
+
import { useIntl as v } from "react-intl";
|
|
23
|
+
import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
24
|
+
import { UserSelectorHeadless as S } from "@box/user-selector";
|
|
25
|
+
import { EditorContent as C, useEditor as w } from "@tiptap/react";
|
|
26
|
+
import T from "@tiptap/extension-document";
|
|
27
|
+
import ce from "@tiptap/extension-text";
|
|
28
|
+
import le from "@tiptap/extension-placeholder";
|
|
29
|
+
var E = (s) => {
|
|
30
|
+
let { disableComponent: E = !1, initialContent: D, isFirstAnnotation: O = !1, isReply: ue = !1, maxCharacterCount: k, userSelectorProps: A } = s, j = _(null), M = _(null), N = _(null), P = v(), { errorMessage: F, isLoading: I } = ae(), { close: L, isActive: R, query: z, command: B, suggestionCallbacks: V } = o(j), { closeAllPopovers: H } = t(), U = P.formatMessage(ue ? c.placeholderReply : c.placeholderAddComment), W = s.variant === m.EDIT_MESSAGE, G = w({
|
|
31
31
|
extensions: [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
T,
|
|
33
|
+
te,
|
|
34
|
+
le.configure({
|
|
35
35
|
placeholder: U,
|
|
36
36
|
showOnlyWhenEditable: !1
|
|
37
37
|
}),
|
|
38
|
-
|
|
38
|
+
ce,
|
|
39
39
|
n.configure({ suggestion: r(i, "@", V) })
|
|
40
40
|
],
|
|
41
41
|
autofocus: !0,
|
|
42
42
|
content: D,
|
|
43
43
|
editorProps: {
|
|
44
|
-
attributes: { class:
|
|
45
|
-
handleTextInput:
|
|
44
|
+
attributes: { class: l.editor },
|
|
45
|
+
handleTextInput: ee,
|
|
46
46
|
transformPastedText: a
|
|
47
47
|
},
|
|
48
48
|
onCreate: ({ editor: e }) => {
|
|
49
|
-
|
|
49
|
+
N.current = e.view.dom, e.commands.focus("end");
|
|
50
50
|
},
|
|
51
51
|
onUpdate: () => {
|
|
52
52
|
H?.();
|
|
53
53
|
}
|
|
54
|
-
}, [U]), { onUserSelected:
|
|
54
|
+
}, [U]), { onUserSelected: de } = ie(se(() => B && G && !G.isDestroyed ? {
|
|
55
55
|
command: B,
|
|
56
56
|
editor: G
|
|
57
|
-
} : null, [B, G])), { exceedsSingleLine:
|
|
58
|
-
|
|
57
|
+
} : null, [B, G])), { exceedsSingleLine: fe, hasScroll: K, isAtBottom: q } = re(M, G), J = ne(G, D, k), Y = W || !O || O && fe, pe = !G || G?.isEmpty, X = E || I, Z = (J?.excess ?? 0) > 0, Q = pe || X || Z, $ = J && J.excess > 0 && Y;
|
|
58
|
+
g(() => {
|
|
59
59
|
G && G.setEditable(!X);
|
|
60
|
-
}, [G, X]),
|
|
61
|
-
if (!Z || !
|
|
60
|
+
}, [G, X]), g(() => {
|
|
61
|
+
if (!Z || !M.current || !D) return;
|
|
62
62
|
let e = 0, t = requestAnimationFrame(() => {
|
|
63
63
|
e = requestAnimationFrame(() => {
|
|
64
|
-
|
|
64
|
+
M.current?.scrollTo({ top: M.current.scrollHeight });
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
return () => {
|
|
68
68
|
cancelAnimationFrame(t), cancelAnimationFrame(e);
|
|
69
69
|
};
|
|
70
|
-
}, [Z]),
|
|
70
|
+
}, [Z]), g(() => {
|
|
71
71
|
!G || D === void 0 || queueMicrotask(() => {
|
|
72
72
|
G.commands.setContent(D ?? "", !1), G.commands.focus("end");
|
|
73
73
|
});
|
|
74
|
-
}, [D])
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
}, [D]), g(() => {
|
|
75
|
+
if (!R) return;
|
|
76
|
+
let t = `[${Object.keys(e)[0]}]`, n = (e) => {
|
|
77
|
+
if (M.current?.contains(e)) return !0;
|
|
78
|
+
let n = document.querySelectorAll(t);
|
|
79
|
+
for (let t of n) if (t.contains(e)) return !0;
|
|
80
|
+
return !1;
|
|
81
|
+
}, r = (e) => {
|
|
82
|
+
let t = e.target;
|
|
83
|
+
!t || n(t) || L();
|
|
84
|
+
}, i = requestAnimationFrame(() => {
|
|
85
|
+
document.addEventListener("mousedown", r), document.addEventListener("focusin", r);
|
|
86
|
+
});
|
|
87
|
+
return () => {
|
|
88
|
+
cancelAnimationFrame(i), document.removeEventListener("mousedown", r), document.removeEventListener("focusin", r);
|
|
89
|
+
};
|
|
90
|
+
}, [L, R]);
|
|
91
|
+
let me = /* @__PURE__ */ b("div", { className: l.anchorElement });
|
|
92
|
+
return /* @__PURE__ */ b("div", {
|
|
77
93
|
"data-no-expand": !0,
|
|
78
|
-
className:
|
|
79
|
-
children: /* @__PURE__ */
|
|
80
|
-
className:
|
|
81
|
-
[
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
[
|
|
85
|
-
[
|
|
94
|
+
className: l.messageEditorWrapper,
|
|
95
|
+
children: /* @__PURE__ */ x("div", {
|
|
96
|
+
className: h(l.messageEditor, {
|
|
97
|
+
[l.editorHasScroll]: K,
|
|
98
|
+
[l.editorEditMode]: W,
|
|
99
|
+
[l.editorError]: F || Z,
|
|
100
|
+
[l.editorFirstAnnotation]: !W && O,
|
|
101
|
+
[l.editorCharacterLimitExceeded]: Z
|
|
86
102
|
}),
|
|
87
|
-
children: [/* @__PURE__ */
|
|
88
|
-
className:
|
|
89
|
-
children: [/* @__PURE__ */
|
|
90
|
-
ref:
|
|
91
|
-
className:
|
|
92
|
-
"aria-label":
|
|
93
|
-
children: [/* @__PURE__ */
|
|
94
|
-
"aria-label":
|
|
103
|
+
children: [/* @__PURE__ */ x("div", {
|
|
104
|
+
className: h(l.editorViewport, { [l.editorFullWidth]: Y }),
|
|
105
|
+
children: [/* @__PURE__ */ x("div", {
|
|
106
|
+
ref: M,
|
|
107
|
+
className: l.editorContainer,
|
|
108
|
+
"aria-label": P.formatMessage(c.scrollContainerAriaLabel),
|
|
109
|
+
children: [/* @__PURE__ */ b(C, {
|
|
110
|
+
"aria-label": P.formatMessage(c.editorContentAriaLabel),
|
|
95
111
|
editor: G
|
|
96
|
-
}), /* @__PURE__ */ S
|
|
97
|
-
ref:
|
|
98
|
-
inputElementRef:
|
|
99
|
-
onSelectedUserChange:
|
|
112
|
+
}), /* @__PURE__ */ b(S, {
|
|
113
|
+
ref: j,
|
|
114
|
+
inputElementRef: N,
|
|
115
|
+
onSelectedUserChange: de,
|
|
100
116
|
open: R,
|
|
101
|
-
rootElement:
|
|
117
|
+
rootElement: me,
|
|
102
118
|
value: z,
|
|
103
|
-
...
|
|
119
|
+
...A,
|
|
104
120
|
popoverContentContainerProps: {
|
|
105
|
-
...
|
|
121
|
+
...A.popoverContentContainerProps,
|
|
106
122
|
...e,
|
|
107
123
|
avoidCollisions: !0
|
|
108
124
|
}
|
|
109
125
|
})]
|
|
110
|
-
}), K && /* @__PURE__ */
|
|
111
|
-
className:
|
|
126
|
+
}), K && /* @__PURE__ */ b("div", {
|
|
127
|
+
className: h(l.editorFade, { [l.editorFadeHidden]: q }),
|
|
112
128
|
"aria-hidden": "true"
|
|
113
129
|
})]
|
|
114
|
-
}), /* @__PURE__ */
|
|
115
|
-
className:
|
|
116
|
-
children: /* @__PURE__ */
|
|
117
|
-
className:
|
|
118
|
-
[
|
|
119
|
-
[
|
|
130
|
+
}), /* @__PURE__ */ b("div", {
|
|
131
|
+
className: h(l.actionsWrapper),
|
|
132
|
+
children: /* @__PURE__ */ x("div", {
|
|
133
|
+
className: h(l.actionsWrapperInner, {
|
|
134
|
+
[l.scrolledToBottom]: q,
|
|
135
|
+
[l.characterLimitExceeded]: Z
|
|
120
136
|
}),
|
|
121
137
|
children: [
|
|
122
|
-
|
|
123
|
-
J && J.excess > 0 && !Y && /* @__PURE__ */
|
|
138
|
+
F && /* @__PURE__ */ b(f, { errorMessage: F }),
|
|
139
|
+
J && J.excess > 0 && !Y && /* @__PURE__ */ b(oe, {
|
|
124
140
|
role: "alert",
|
|
125
|
-
children:
|
|
141
|
+
children: P.formatMessage(c.characterLimitExceeded, { excess: J.excess })
|
|
126
142
|
}),
|
|
127
|
-
W ? /* @__PURE__ */
|
|
128
|
-
className:
|
|
129
|
-
children: [$ && /* @__PURE__ */
|
|
143
|
+
W ? /* @__PURE__ */ x("div", {
|
|
144
|
+
className: l.editActionsColumn,
|
|
145
|
+
children: [$ && /* @__PURE__ */ b(u, {
|
|
130
146
|
count: J.count,
|
|
131
147
|
excess: J.excess,
|
|
132
148
|
maxCount: J.maxCount
|
|
133
|
-
}), /* @__PURE__ */
|
|
134
|
-
className:
|
|
135
|
-
children: /* @__PURE__ */
|
|
149
|
+
}), /* @__PURE__ */ b("div", {
|
|
150
|
+
className: l.editActionsRow,
|
|
151
|
+
children: /* @__PURE__ */ b(d, {
|
|
136
152
|
disabled: Q,
|
|
137
153
|
getEditorJsonContent: () => G?.getJSON(),
|
|
138
|
-
onCancel:
|
|
139
|
-
onEditSuccess:
|
|
140
|
-
onSave:
|
|
141
|
-
onSaveError:
|
|
154
|
+
onCancel: s.onEditCancel,
|
|
155
|
+
onEditSuccess: s.onEditSuccess,
|
|
156
|
+
onSave: s.onSave,
|
|
157
|
+
onSaveError: s.onSaveError
|
|
142
158
|
})
|
|
143
159
|
})]
|
|
144
|
-
}) : /* @__PURE__ */
|
|
160
|
+
}) : /* @__PURE__ */ x(y, { children: [$ && /* @__PURE__ */ b(u, {
|
|
145
161
|
count: J.count,
|
|
146
162
|
excess: J.excess,
|
|
147
163
|
maxCount: J.maxCount
|
|
148
|
-
}), /* @__PURE__ */
|
|
164
|
+
}), /* @__PURE__ */ b(p, {
|
|
149
165
|
cleanEditor: () => G?.commands.setContent(""),
|
|
150
166
|
disabled: Q,
|
|
151
167
|
getEditorJsonContent: () => G?.getJSON(),
|
|
152
|
-
onPost:
|
|
153
|
-
onPostError:
|
|
154
|
-
onPostSuccess:
|
|
168
|
+
onPost: s.onPost,
|
|
169
|
+
onPostError: s.onPostError,
|
|
170
|
+
onPostSuccess: s.onPostSuccess
|
|
155
171
|
})] })
|
|
156
172
|
]
|
|
157
173
|
})
|
|
158
174
|
})]
|
|
159
175
|
})
|
|
160
176
|
});
|
|
161
|
-
}, D = (e) => /* @__PURE__ */
|
|
162
|
-
export { D as MessageEditor,
|
|
177
|
+
}, D = (e) => /* @__PURE__ */ b(s, { children: /* @__PURE__ */ b(E, { ...e }) });
|
|
178
|
+
export { D as MessageEditor, m as MessageEditorVariant };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/threaded-annotations",
|
|
3
|
-
"version": "1.94.
|
|
3
|
+
"version": "1.94.11",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@tanstack/react-virtual": "^3.10.8",
|
|
@@ -16,23 +16,23 @@
|
|
|
16
16
|
"uuid": "^9.0.1"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@box/blueprint-web": "^15.
|
|
20
|
-
"@box/blueprint-web-assets": "^4.121.
|
|
21
|
-
"@box/collaboration-popover": "^1.63.
|
|
22
|
-
"@box/readable-time": "^1.42.
|
|
23
|
-
"@box/user-selector": "^1.77.
|
|
19
|
+
"@box/blueprint-web": "^15.5.0",
|
|
20
|
+
"@box/blueprint-web-assets": "^4.121.8",
|
|
21
|
+
"@box/collaboration-popover": "^1.63.9",
|
|
22
|
+
"@box/readable-time": "^1.42.9",
|
|
23
|
+
"@box/user-selector": "^1.77.9",
|
|
24
24
|
"clsx": "^1.2.1",
|
|
25
25
|
"react": "^18.0.0",
|
|
26
26
|
"react-dom": "^18.0.0",
|
|
27
27
|
"react-intl": "^6.4.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@box/blueprint-web": "^15.
|
|
31
|
-
"@box/blueprint-web-assets": "^4.121.
|
|
30
|
+
"@box/blueprint-web": "^15.5.0",
|
|
31
|
+
"@box/blueprint-web-assets": "^4.121.8",
|
|
32
32
|
"@box/eslint-plugin-blueprint": "1.2.4",
|
|
33
|
-
"@box/readable-time": "^1.42.
|
|
34
|
-
"@box/storybook-utils": "^0.20.
|
|
35
|
-
"@box/user-selector": "^1.77.
|
|
33
|
+
"@box/readable-time": "^1.42.9",
|
|
34
|
+
"@box/storybook-utils": "^0.20.8",
|
|
35
|
+
"@box/user-selector": "^1.77.9",
|
|
36
36
|
"react": "^18.0.0",
|
|
37
37
|
"react-dom": "^18.0.0"
|
|
38
38
|
},
|