@collabchron/notiq 1.1.12 → 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.
Files changed (146) hide show
  1. package/dist/AICommandBarPlugin-ZEC755KY.mjs +27 -0
  2. package/dist/{AIDialog-RHRYHSVN.mjs → AIDialog-HJW6PQPR.mjs} +11 -12
  3. package/dist/{AudioComponent-CKLMLB5T.mjs → AudioComponent-W5XMZPQB.mjs} +10 -6
  4. package/dist/{DynamicBlockComponent-2LOADZUX.mjs → DynamicBlockComponent-CHRL2GAQ.mjs} +7 -6
  5. package/dist/{EquationComponent-4NFG55NQ.mjs → EquationComponent-GNQHG53L.mjs} +26 -7
  6. package/dist/{ExcalidrawComponent-BMSYIPP6.mjs → ExcalidrawComponent-POMYXDSG.mjs} +33 -6
  7. package/dist/{FileComponent-Y56MX5QD.mjs → FileComponent-EOVCH4V5.mjs} +9 -5
  8. package/dist/{HintComponet-ET7M2Q7S.mjs → HintComponet-QXL5ESND.mjs} +32 -8
  9. package/dist/{InlineImageComponent-FVTA4LXZ.mjs → InlineImageComponent-KDN3VGZC.mjs} +8 -3
  10. package/dist/{StoryBuilderComponent-JN4ZPZOW.mjs → StoryBuilderComponent-CBRFPFTR.mjs} +8 -9
  11. package/dist/{chunk-6UVNHT3T.mjs → chunk-4SYRK2NH.mjs} +23 -1
  12. package/dist/chunk-5CJZC5IB.mjs +9086 -0
  13. package/dist/{chunk-FO7M3X2B.mjs → chunk-6NK5DONB.mjs} +1 -1
  14. package/dist/{chunk-N6ILV6NF.mjs → chunk-ACW4DLVO.mjs} +21 -7
  15. package/dist/chunk-BCGD2YXP.mjs +574 -0
  16. package/dist/{chunk-TC3IISJZ.mjs → chunk-BTR3TPIN.mjs} +18 -5
  17. package/dist/{chunk-ZYJ7KABY.mjs → chunk-CQCS5YPS.mjs} +3 -5
  18. package/dist/{chunk-T2UBAZ66.mjs → chunk-D4UBNSUW.mjs} +1 -1
  19. package/dist/{chunk-KNW2CGIP.mjs → chunk-DBRZIA43.mjs} +4 -1
  20. package/dist/{chunk-CDAMHK63.mjs → chunk-GJK2L7ZM.mjs} +23 -2
  21. package/dist/{chunk-ELBTVBTS.mjs → chunk-IKYVBTCJ.mjs} +43 -20
  22. package/dist/chunk-IXRA5D53.mjs +10447 -0
  23. package/dist/{chunk-W6VQSFE5.mjs → chunk-J2CEQXG4.mjs} +1 -1
  24. package/dist/{chunk-43Z4Z2KD.mjs → chunk-JTNLN4JI.mjs} +1 -1
  25. package/dist/{chunk-OE5JRLCN.mjs → chunk-ONOHG5NB.mjs} +6 -4
  26. package/dist/{chunk-QNIY45SF.mjs → chunk-OO42URWA.mjs} +27 -6
  27. package/dist/chunk-PBVRSNGU.mjs +129 -0
  28. package/dist/chunk-QCS57TIF.mjs +1794 -0
  29. package/dist/chunk-RNEIJRUS.mjs +60 -0
  30. package/dist/chunk-TJPTGECP.mjs +1556 -0
  31. package/dist/{chunk-XYMXGU4T.mjs → chunk-TMYRA2W4.mjs} +1 -1
  32. package/dist/{chunk-ZFV2HGD3.mjs → chunk-UNEFOZTS.mjs} +1 -1
  33. package/dist/chunk-X4NI7EQS.mjs +282 -0
  34. package/dist/{chunk-5D4JF3ZZ.mjs → chunk-XAJ4GACN.mjs} +171 -49
  35. package/dist/{chunk-7QRJVZQY.mjs → chunk-YVUQRJVV.mjs} +63 -18
  36. package/dist/components/editor/index.d.ts +1 -1
  37. package/dist/components/editor/nodes/EquationNode/EquationNode.d.ts +1 -0
  38. package/dist/components/editor/nodes/Hint/index.d.ts +2 -1
  39. package/dist/components/editor/plugins/AICommandBarPlugin/index.d.ts +73 -1
  40. package/dist/components/editor/plugins/DraggableBlockPlugin/index.d.ts +25 -3
  41. package/dist/components/editor/plugins/InlineCopilotPlugin/index.d.ts +16 -3
  42. package/dist/components/editor/plugins/LinkWithMetaData/index.d.ts +20 -25
  43. package/dist/components/editor/plugins/MarkdownPastePlugin/index.d.ts +5 -0
  44. package/dist/components/editor/plugins/MarkdownTransformers/index.d.ts +2 -0
  45. package/dist/components/editor/plugins/SlashCommand/index.d.ts +18 -1
  46. package/dist/components/editor/plugins/SmartTypographyPlugin/index.d.ts +26 -0
  47. package/dist/components/editor/utils/aiStream.d.ts +27 -0
  48. package/dist/components/editor/utils/excalidrawDiagramBuilder.d.ts +29 -0
  49. package/dist/components/editor/utils/markdownTransformers.d.ts +4 -1
  50. package/dist/components/editor/utils/url.d.ts +16 -4
  51. package/dist/components/providers/AIContext.d.ts +8 -0
  52. package/dist/components/ui/equation/equationTypography.d.ts +23 -0
  53. package/dist/core/extension.d.ts +3 -1
  54. package/dist/core/extensions/blocks-kit.d.ts +22 -1
  55. package/dist/core/extensions/copilot-and-collab.d.ts +15 -1
  56. package/dist/core/react/NotiqContent.d.ts +4 -1
  57. package/dist/core/react/index.d.ts +1 -0
  58. package/dist/core/react/node-renderers.d.ts +73 -0
  59. package/dist/core.js +15429 -13116
  60. package/dist/core.mjs +47 -39
  61. package/dist/hooks/instructions-messages.d.ts +13 -4
  62. package/dist/{image-QPB2CVXP.mjs → image-AL6PHM2A.mjs} +17 -12
  63. package/dist/index.js +15526 -13194
  64. package/dist/index.mjs +64 -60
  65. package/dist/{insert-audio-I3PD6JFS.mjs → insert-audio-CRWR7EO5.mjs} +4 -6
  66. package/dist/{insert-file-PHR7XL4V.mjs → insert-file-I73AZW3L.mjs} +4 -6
  67. package/dist/{insert-gif-R5ZO4JHC.mjs → insert-gif-KWRC3ACT.mjs} +1 -1
  68. package/dist/{insert-image-PLBZELHK.mjs → insert-image-XIY6BGW5.mjs} +4 -3
  69. package/dist/{insert-poll-6BCIFY5G.mjs → insert-poll-J5YVZNZ4.mjs} +4 -3
  70. package/dist/{insert-table-ZRJP6X52.mjs → insert-table-OIMJRFFK.mjs} +1 -1
  71. package/dist/{poll-component-VHMM5KKZ.mjs → poll-component-TVHXIKGQ.mjs} +3 -2
  72. package/dist/react.js +14747 -12554
  73. package/dist/react.mjs +40 -38
  74. package/dist/{stepper-KNITDVLG.mjs → stepper-ILF7YXTO.mjs} +63 -73
  75. package/dist/styles/notiq.css +1 -1
  76. package/package.json +2 -2
  77. package/src/styles/notiq.css +20 -0
  78. package/dist/AICommandBarPlugin-TADJ3X2Y.mjs +0 -12
  79. package/dist/CodeActionMenuPlugin-FGH6HZLL.mjs +0 -14
  80. package/dist/CollaborationPlugin-TIZOQBUT.mjs +0 -405
  81. package/dist/CollaboratorsBar-AMPIAUOY.mjs +0 -20
  82. package/dist/CommentsPlugin-SDJJTUGK.mjs +0 -19
  83. package/dist/ExcalidrawPlugin-QLPGJPSX.mjs +0 -14
  84. package/dist/ExportPlugin-MJHYKQZJ.mjs +0 -43
  85. package/dist/FloatingLinkEditorPlugin-MABB34L7.mjs +0 -12
  86. package/dist/FloatingTextFormatToolbarPlugin-BXCPN3KD.mjs +0 -45
  87. package/dist/InlineCopilotPlugin-PNS5Y6OO.mjs +0 -360
  88. package/dist/MobileToolbar-KV5DX4ED.mjs +0 -982
  89. package/dist/SlashCommand-SPR7G5EI.mjs +0 -39
  90. package/dist/TableCellActionMenuPlugin-YWBA64J7.mjs +0 -838
  91. package/dist/TableHoverActionsPlugin-2EIXHEXN.mjs +0 -265
  92. package/dist/TemplatePlugin-HNTPEXBB.mjs +0 -9
  93. package/dist/ToolbarPlugin-F52PVNXU.mjs +0 -823
  94. package/dist/VersionHistoryPlugin-YWGCREKA.mjs +0 -371
  95. package/dist/background-color-RW5JYLMG.mjs +0 -425
  96. package/dist/block-format-TODFREE2.mjs +0 -14
  97. package/dist/chunk-22ZIL6NH.mjs +0 -88
  98. package/dist/chunk-2LNT36RL.mjs +0 -555
  99. package/dist/chunk-37LC44W3.mjs +0 -2677
  100. package/dist/chunk-3IILA3IP.mjs +0 -28
  101. package/dist/chunk-4DVIYZVB.mjs +0 -193
  102. package/dist/chunk-4FFTOZGJ.mjs +0 -103
  103. package/dist/chunk-4UMUPCDK.mjs +0 -68
  104. package/dist/chunk-6D6QLRYR.mjs +0 -238
  105. package/dist/chunk-6FQFPPLG.mjs +0 -785
  106. package/dist/chunk-ACV47ZKE.mjs +0 -201
  107. package/dist/chunk-BGV62GC2.mjs +0 -26
  108. package/dist/chunk-C4JWLBYN.mjs +0 -132
  109. package/dist/chunk-CLRSETYQ.mjs +0 -431
  110. package/dist/chunk-D3IOUQFR.mjs +0 -441
  111. package/dist/chunk-EEBA6OAH.mjs +0 -59
  112. package/dist/chunk-EIZMKFHF.mjs +0 -32
  113. package/dist/chunk-ENH2IOHI.mjs +0 -1828
  114. package/dist/chunk-EVPWKNE4.mjs +0 -27
  115. package/dist/chunk-HOZ4QRFV.mjs +0 -536
  116. package/dist/chunk-IAFCQV3Z.mjs +0 -349
  117. package/dist/chunk-J6ZUY5BY.mjs +0 -202
  118. package/dist/chunk-K5OAFEVY.mjs +0 -191
  119. package/dist/chunk-KXRLARGI.mjs +0 -26
  120. package/dist/chunk-LBGM4VVZ.mjs +0 -409
  121. package/dist/chunk-LLGVCM7M.mjs +0 -809
  122. package/dist/chunk-LU2XWLOE.mjs +0 -219
  123. package/dist/chunk-LVRJM45C.mjs +0 -171
  124. package/dist/chunk-MSAO3YFB.mjs +0 -144
  125. package/dist/chunk-N3KDPSRI.mjs +0 -496
  126. package/dist/chunk-OXWTZV3U.mjs +0 -174
  127. package/dist/chunk-PD5K4AGP.mjs +0 -64
  128. package/dist/chunk-PFH63ZU4.mjs +0 -33
  129. package/dist/chunk-R7WFRENU.mjs +0 -262
  130. package/dist/chunk-RAVYEEIC.mjs +0 -36
  131. package/dist/chunk-RJQTA6HG.mjs +0 -358
  132. package/dist/chunk-SAOJHVPE.mjs +0 -153
  133. package/dist/chunk-SYUCM5G5.mjs +0 -111
  134. package/dist/chunk-VGAX6YEY.mjs +0 -399
  135. package/dist/chunk-VNDDDXGH.mjs +0 -682
  136. package/dist/chunk-WUVIQCX7.mjs +0 -944
  137. package/dist/chunk-XNJNT6PC.mjs +0 -1701
  138. package/dist/chunk-XYLTLGY5.mjs +0 -775
  139. package/dist/chunk-ZKZ7MLSS.mjs +0 -165
  140. package/dist/color-S55XFDYQ.mjs +0 -13
  141. package/dist/font-IJKFR4BM.mjs +0 -12
  142. package/dist/font-size-3HMJHKO2.mjs +0 -15
  143. package/dist/insert-node-DGCZBGKG.mjs +0 -243
  144. package/dist/table-dropdown-4VCRSQB6.mjs +0 -391
  145. package/dist/text-align-TEB4S52S.mjs +0 -121
  146. package/dist/text-format-T3IY7FBI.mjs +0 -15
@@ -1,944 +0,0 @@
1
- import {
2
- Textarea
3
- } from "./chunk-3JN6QEJR.mjs";
4
- import {
5
- Tabs,
6
- TabsList,
7
- TabsTrigger
8
- } from "./chunk-6UVNHT3T.mjs";
9
- import {
10
- DropdownMenu,
11
- DropdownMenuContent,
12
- DropdownMenuItem,
13
- DropdownMenuTrigger
14
- } from "./chunk-OXWTZV3U.mjs";
15
- import {
16
- useComments
17
- } from "./chunk-R7WFRENU.mjs";
18
- import {
19
- useCollab
20
- } from "./chunk-RJQTA6HG.mjs";
21
- import {
22
- Button
23
- } from "./chunk-OE5JRLCN.mjs";
24
- import {
25
- cn
26
- } from "./chunk-JHXDLYEV.mjs";
27
- import {
28
- init_react_shim
29
- } from "./chunk-WYCFGRFJ.mjs";
30
-
31
- // src/components/editor/plugins/CommentsPlugin/index.tsx
32
- init_react_shim();
33
- import { useEffect as useEffect2 } from "react";
34
- import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
35
- import {
36
- $getSelection,
37
- $isRangeSelection,
38
- COMMAND_PRIORITY_LOW,
39
- createCommand
40
- } from "lexical";
41
-
42
- // src/components/editor/plugins/CommentsPlugin/NewCommentDialog.tsx
43
- init_react_shim();
44
- import { useState, useRef, useEffect, useMemo as useMemo2 } from "react";
45
-
46
- // src/components/editor/plugins/CommentsPlugin/MentionsAutocomplete.tsx
47
- init_react_shim();
48
- import { useMemo } from "react";
49
- import { Users } from "lucide-react";
50
- import { jsx, jsxs } from "react/jsx-runtime";
51
- function getMentionCandidates(users, query) {
52
- const clean = query.trim().toLowerCase();
53
- const results = [];
54
- if (!clean || "everyone".includes(clean) || "all".includes(clean)) {
55
- results.push({
56
- id: "special-everyone",
57
- name: "everyone",
58
- color: "#8b5cf6",
59
- description: "Notify all collaborators",
60
- isSpecial: true
61
- });
62
- }
63
- for (const u of users) {
64
- if (!clean || u.name.toLowerCase().includes(clean)) {
65
- results.push({
66
- id: u.clientId,
67
- name: u.name,
68
- color: u.color,
69
- avatar: u.avatar,
70
- isSelf: u.isSelf
71
- });
72
- }
73
- }
74
- return results;
75
- }
76
- function MentionsAutocomplete({
77
- query,
78
- users,
79
- selectedIndex = 0,
80
- onSelect,
81
- onHoverIndex,
82
- className
83
- }) {
84
- const items = useMemo(() => getMentionCandidates(users, query), [users, query]);
85
- if (items.length === 0) return null;
86
- const safeIndex = Math.min(Math.max(0, selectedIndex), items.length - 1);
87
- return /* @__PURE__ */ jsxs(
88
- "div",
89
- {
90
- role: "listbox",
91
- "aria-label": "Mention options",
92
- className: cn(
93
- "absolute z-50 w-60 max-h-52 overflow-y-auto rounded-xl border border-border bg-popover/95 p-1 text-popover-foreground shadow-xl backdrop-blur-md text-xs",
94
- "animate-in fade-in-50 zoom-in-95 duration-100",
95
- className
96
- ),
97
- children: [
98
- /* @__PURE__ */ jsxs("div", { className: "px-2.5 py-1 text-[10px] font-semibold tracking-wider text-muted-foreground uppercase flex items-center justify-between", children: [
99
- /* @__PURE__ */ jsx("span", { children: "Mention in thread" }),
100
- /* @__PURE__ */ jsx("span", { className: "text-[9px] font-mono opacity-70", children: "\u2191\u2193 navigate \u21B5 select" })
101
- ] }),
102
- /* @__PURE__ */ jsx("div", { className: "space-y-0.5 mt-0.5", children: items.map((item, index) => {
103
- const isSelected = index === safeIndex;
104
- return /* @__PURE__ */ jsxs(
105
- "button",
106
- {
107
- id: `mention-option-${index}`,
108
- role: "option",
109
- "aria-selected": isSelected,
110
- type: "button",
111
- onMouseEnter: () => onHoverIndex == null ? void 0 : onHoverIndex(index),
112
- onClick: (e) => {
113
- e.preventDefault();
114
- e.stopPropagation();
115
- onSelect(item);
116
- },
117
- className: cn(
118
- "w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-left transition-colors cursor-pointer group select-none",
119
- isSelected ? "bg-accent text-accent-foreground ring-1 ring-primary/40 font-medium" : "hover:bg-muted/70 text-foreground"
120
- ),
121
- children: [
122
- item.isSpecial ? /* @__PURE__ */ jsx("span", { className: "h-5 w-5 rounded-full flex items-center justify-center bg-purple-600 text-white shrink-0 shadow-xs", children: /* @__PURE__ */ jsx(Users, { className: "h-3 w-3" }) }) : /* @__PURE__ */ jsx(
123
- "span",
124
- {
125
- className: "h-5 w-5 rounded-full flex items-center justify-center text-[10px] font-bold text-white shrink-0 shadow-xs",
126
- style: { backgroundColor: item.color },
127
- children: item.name.slice(0, 1).toUpperCase()
128
- }
129
- ),
130
- /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
131
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
132
- /* @__PURE__ */ jsxs("span", { className: "truncate font-semibold text-foreground group-hover:text-primary", children: [
133
- "@",
134
- item.name
135
- ] }),
136
- item.isSelf && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-muted-foreground", children: "(You)" })
137
- ] }),
138
- item.description && /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground truncate", children: item.description })
139
- ] })
140
- ]
141
- },
142
- item.id
143
- );
144
- }) })
145
- ]
146
- }
147
- );
148
- }
149
-
150
- // src/components/editor/plugins/CommentsPlugin/NewCommentDialog.tsx
151
- import { MessageSquarePlus, X, Send } from "lucide-react";
152
- import { motion, AnimatePresence } from "framer-motion";
153
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
154
- function NewCommentDialog() {
155
- const { draftComment, setDraftComment, addThread } = useComments();
156
- const { users, username, cursorColor } = useCollab();
157
- const [commentText, setCommentText] = useState("");
158
- const [mentionQuery, setMentionQuery] = useState(null);
159
- const [mentionIndex, setMentionIndex] = useState(0);
160
- const textareaRef = useRef(null);
161
- const backdropRef = useRef(null);
162
- const mentionCandidates = useMemo2(
163
- () => mentionQuery !== null ? getMentionCandidates(users, mentionQuery) : [],
164
- [users, mentionQuery]
165
- );
166
- useEffect(() => {
167
- if (draftComment == null ? void 0 : draftComment.isOpen) {
168
- setCommentText("");
169
- setMentionQuery(null);
170
- setMentionIndex(0);
171
- setTimeout(() => {
172
- var _a;
173
- return (_a = textareaRef.current) == null ? void 0 : _a.focus();
174
- }, 50);
175
- }
176
- }, [draftComment == null ? void 0 : draftComment.isOpen]);
177
- if (!(draftComment == null ? void 0 : draftComment.isOpen)) return null;
178
- const handleTextChange = (e) => {
179
- const val = e.target.value;
180
- setCommentText(val);
181
- const cursorPos = e.target.selectionStart || 0;
182
- const textBeforeCursor = val.slice(0, cursorPos);
183
- const mentionMatch = textBeforeCursor.match(/@([A-Za-z0-9_]*)$/);
184
- if (mentionMatch) {
185
- setMentionQuery(mentionMatch[1]);
186
- setMentionIndex(0);
187
- } else {
188
- setMentionQuery(null);
189
- }
190
- };
191
- const handleSelectMention = (item) => {
192
- if (!textareaRef.current) return;
193
- const cursorPos = textareaRef.current.selectionStart || 0;
194
- const textBeforeCursor = commentText.slice(0, cursorPos);
195
- const textAfterCursor = commentText.slice(cursorPos);
196
- const updatedBefore = textBeforeCursor.replace(/@([A-Za-z0-9_]*)$/, `@${item.name} `);
197
- setCommentText(updatedBefore + textAfterCursor);
198
- setMentionQuery(null);
199
- setMentionIndex(0);
200
- textareaRef.current.focus();
201
- };
202
- const handleSubmit = (e) => {
203
- e == null ? void 0 : e.preventDefault();
204
- if (!commentText.trim()) return;
205
- addThread(draftComment.quote, commentText);
206
- };
207
- const handleKeyDown = (e) => {
208
- if (mentionQuery !== null && mentionCandidates.length > 0) {
209
- if (e.key === "ArrowDown") {
210
- e.preventDefault();
211
- setMentionIndex((prev) => (prev + 1) % mentionCandidates.length);
212
- return;
213
- }
214
- if (e.key === "ArrowUp") {
215
- e.preventDefault();
216
- setMentionIndex((prev) => (prev - 1 + mentionCandidates.length) % mentionCandidates.length);
217
- return;
218
- }
219
- if (e.key === "Enter" || e.key === "Tab") {
220
- e.preventDefault();
221
- const candidate = mentionCandidates[mentionIndex] || mentionCandidates[0];
222
- if (candidate) {
223
- handleSelectMention(candidate);
224
- }
225
- return;
226
- }
227
- if (e.key === "Escape") {
228
- e.preventDefault();
229
- setMentionQuery(null);
230
- return;
231
- }
232
- }
233
- if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
234
- e.preventDefault();
235
- handleSubmit(e);
236
- return;
237
- }
238
- if (e.key === "Escape" && mentionQuery === null) {
239
- e.preventDefault();
240
- setDraftComment(null);
241
- }
242
- };
243
- return /* @__PURE__ */ jsx2(AnimatePresence, { children: /* @__PURE__ */ jsx2(
244
- "div",
245
- {
246
- ref: backdropRef,
247
- onClick: (e) => {
248
- if (e.target === backdropRef.current) {
249
- setDraftComment(null);
250
- }
251
- },
252
- className: "fixed inset-0 z-50 flex items-center justify-center p-4 bg-background/50 backdrop-blur-xs",
253
- children: /* @__PURE__ */ jsxs2(
254
- motion.div,
255
- {
256
- initial: { opacity: 0, scale: 0.95, y: 10 },
257
- animate: { opacity: 1, scale: 1, y: 0 },
258
- exit: { opacity: 0, scale: 0.95, y: 10 },
259
- transition: { duration: 0.15 },
260
- className: "w-full max-w-md rounded-2xl border border-border bg-card p-4 shadow-xl text-xs space-y-3",
261
- children: [
262
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between pb-1 border-b border-border/50", children: [
263
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 font-semibold text-foreground", children: [
264
- /* @__PURE__ */ jsx2(MessageSquarePlus, { className: "h-4 w-4 text-primary" }),
265
- /* @__PURE__ */ jsx2("span", { children: "New Comment Discussion" })
266
- ] }),
267
- /* @__PURE__ */ jsx2(
268
- "button",
269
- {
270
- type: "button",
271
- onClick: () => setDraftComment(null),
272
- className: "text-muted-foreground hover:text-foreground p-1 rounded-md transition-colors cursor-pointer",
273
- "aria-label": "Close comment dialog",
274
- children: /* @__PURE__ */ jsx2(X, { className: "h-4 w-4" })
275
- }
276
- )
277
- ] }),
278
- draftComment.quote && /* @__PURE__ */ jsxs2("div", { className: "pl-3 py-1.5 border-l-2 border-primary bg-muted/40 rounded-r-lg text-muted-foreground italic line-clamp-3 font-serif", children: [
279
- "\u201C",
280
- draftComment.quote,
281
- "\u201D"
282
- ] }),
283
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 text-muted-foreground text-[11px]", children: [
284
- /* @__PURE__ */ jsx2(
285
- "span",
286
- {
287
- className: "h-4 w-4 rounded-full flex items-center justify-center text-[9px] font-bold text-white shadow-xs",
288
- style: { backgroundColor: cursorColor },
289
- children: username.slice(0, 1).toUpperCase()
290
- }
291
- ),
292
- /* @__PURE__ */ jsxs2("span", { children: [
293
- "Commenting as ",
294
- /* @__PURE__ */ jsx2("strong", { className: "text-foreground", children: username })
295
- ] })
296
- ] }),
297
- /* @__PURE__ */ jsxs2("form", { onSubmit: handleSubmit, className: "relative space-y-3", children: [
298
- /* @__PURE__ */ jsxs2("div", { className: "relative", children: [
299
- /* @__PURE__ */ jsx2(
300
- Textarea,
301
- {
302
- ref: textareaRef,
303
- value: commentText,
304
- onChange: handleTextChange,
305
- onKeyDown: handleKeyDown,
306
- placeholder: "Write your thought... (Type @ to mention collaborators)",
307
- className: "min-h-[85px] resize-none text-xs rounded-xl focus-visible:ring-1"
308
- }
309
- ),
310
- mentionQuery !== null && /* @__PURE__ */ jsx2(
311
- MentionsAutocomplete,
312
- {
313
- query: mentionQuery,
314
- users,
315
- selectedIndex: mentionIndex,
316
- onHoverIndex: setMentionIndex,
317
- onSelect: handleSelectMention,
318
- className: "bottom-full mb-1 left-0"
319
- }
320
- )
321
- ] }),
322
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-between pt-1", children: [
323
- /* @__PURE__ */ jsxs2("span", { className: "text-[10px] text-muted-foreground", children: [
324
- "Tip: Press ",
325
- /* @__PURE__ */ jsx2("kbd", { className: "px-1 py-0.5 rounded bg-muted border border-border/80", children: "Ctrl" }),
326
- " + ",
327
- /* @__PURE__ */ jsx2("kbd", { className: "px-1 py-0.5 rounded bg-muted border border-border/80", children: "Enter" }),
328
- " to submit"
329
- ] }),
330
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2", children: [
331
- /* @__PURE__ */ jsx2(
332
- Button,
333
- {
334
- type: "button",
335
- variant: "ghost",
336
- size: "sm",
337
- onClick: () => setDraftComment(null),
338
- className: "h-7 px-3 text-xs",
339
- children: "Cancel"
340
- }
341
- ),
342
- /* @__PURE__ */ jsxs2(
343
- Button,
344
- {
345
- type: "submit",
346
- size: "sm",
347
- disabled: !commentText.trim(),
348
- className: "h-7 px-3 text-xs gap-1.5 shadow-xs",
349
- children: [
350
- /* @__PURE__ */ jsx2(Send, { className: "h-3 w-3" }),
351
- "Comment"
352
- ]
353
- }
354
- )
355
- ] })
356
- ] })
357
- ] })
358
- ]
359
- }
360
- )
361
- }
362
- ) });
363
- }
364
-
365
- // src/components/editor/plugins/CommentsPlugin/CommentsSidebar.tsx
366
- init_react_shim();
367
- import { useState as useState3, useMemo as useMemo4 } from "react";
368
-
369
- // src/components/editor/plugins/CommentsPlugin/CommentThreadItem.tsx
370
- init_react_shim();
371
- import { useState as useState2, useRef as useRef2, useMemo as useMemo3 } from "react";
372
- import {
373
- Check,
374
- RotateCcw,
375
- Trash2,
376
- CornerDownRight,
377
- Send as Send2,
378
- MoreVertical,
379
- Crosshair
380
- } from "lucide-react";
381
- import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
382
- function formatRelativeTime(timestamp) {
383
- const seconds = Math.floor((Date.now() - timestamp) / 1e3);
384
- if (seconds < 60) return "Just now";
385
- const minutes = Math.floor(seconds / 60);
386
- if (minutes < 60) return `${minutes}m ago`;
387
- const hours = Math.floor(minutes / 60);
388
- if (hours < 24) return `${hours}h ago`;
389
- const days = Math.floor(hours / 24);
390
- return `${days}d ago`;
391
- }
392
- function renderMessageContent(content) {
393
- const parts = content.split(/(@[A-Za-z0-9_\s-]+)/g);
394
- return parts.map((part, i) => {
395
- if (part.startsWith("@")) {
396
- const isEveryone = part.toLowerCase().includes("@everyone") || part.toLowerCase().includes("@all");
397
- return /* @__PURE__ */ jsx3(
398
- "span",
399
- {
400
- className: cn(
401
- "inline-flex items-center px-1.5 py-0.2 mx-0.5 rounded-md font-semibold text-[11px] shadow-2xs font-mono",
402
- isEveryone ? "bg-purple-500/15 text-purple-600 dark:text-purple-300 border border-purple-500/20" : "bg-primary/10 text-primary dark:text-primary-foreground border border-primary/20"
403
- ),
404
- children: part
405
- },
406
- i
407
- );
408
- }
409
- return /* @__PURE__ */ jsx3("span", { children: part }, i);
410
- });
411
- }
412
- function CommentThreadItem({
413
- thread,
414
- isActive,
415
- onSelect
416
- }) {
417
- const { addReply, toggleResolveThread, deleteThread, jumpToQuote } = useComments();
418
- const { users } = useCollab();
419
- const [replyText, setReplyText] = useState2("");
420
- const [isReplying, setIsReplying] = useState2(false);
421
- const [mentionQuery, setMentionQuery] = useState2(null);
422
- const [mentionIndex, setMentionIndex] = useState2(0);
423
- const textareaRef = useRef2(null);
424
- const mentionCandidates = useMemo3(
425
- () => mentionQuery !== null ? getMentionCandidates(users, mentionQuery) : [],
426
- [users, mentionQuery]
427
- );
428
- const handleReplyChange = (e) => {
429
- const val = e.target.value;
430
- setReplyText(val);
431
- const cursorPos = e.target.selectionStart || 0;
432
- const textBeforeCursor = val.slice(0, cursorPos);
433
- const mentionMatch = textBeforeCursor.match(/@([A-Za-z0-9_]*)$/);
434
- if (mentionMatch) {
435
- setMentionQuery(mentionMatch[1]);
436
- setMentionIndex(0);
437
- } else {
438
- setMentionQuery(null);
439
- }
440
- };
441
- const handleSelectMention = (item) => {
442
- if (!textareaRef.current) return;
443
- const cursorPos = textareaRef.current.selectionStart || 0;
444
- const textBeforeCursor = replyText.slice(0, cursorPos);
445
- const textAfterCursor = replyText.slice(cursorPos);
446
- const updatedBefore = textBeforeCursor.replace(/@([A-Za-z0-9_]*)$/, `@${item.name} `);
447
- setReplyText(updatedBefore + textAfterCursor);
448
- setMentionQuery(null);
449
- setMentionIndex(0);
450
- textareaRef.current.focus();
451
- };
452
- const handleSubmitReply = (e) => {
453
- e.preventDefault();
454
- if (!replyText.trim()) return;
455
- addReply(thread.id, replyText);
456
- setReplyText("");
457
- setIsReplying(false);
458
- setMentionQuery(null);
459
- setMentionIndex(0);
460
- };
461
- const handleKeyDown = (e) => {
462
- if (mentionQuery !== null && mentionCandidates.length > 0) {
463
- if (e.key === "ArrowDown") {
464
- e.preventDefault();
465
- setMentionIndex((prev) => (prev + 1) % mentionCandidates.length);
466
- return;
467
- }
468
- if (e.key === "ArrowUp") {
469
- e.preventDefault();
470
- setMentionIndex((prev) => (prev - 1 + mentionCandidates.length) % mentionCandidates.length);
471
- return;
472
- }
473
- if (e.key === "Enter" || e.key === "Tab") {
474
- e.preventDefault();
475
- const candidate = mentionCandidates[mentionIndex] || mentionCandidates[0];
476
- if (candidate) {
477
- handleSelectMention(candidate);
478
- }
479
- return;
480
- }
481
- if (e.key === "Escape") {
482
- e.preventDefault();
483
- setMentionQuery(null);
484
- return;
485
- }
486
- }
487
- if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
488
- e.preventDefault();
489
- handleSubmitReply(e);
490
- }
491
- };
492
- const handleCardClick = () => {
493
- onSelect == null ? void 0 : onSelect();
494
- if (thread.quote) {
495
- jumpToQuote(thread.quote, thread.id);
496
- }
497
- };
498
- return /* @__PURE__ */ jsxs3(
499
- "div",
500
- {
501
- onClick: handleCardClick,
502
- className: cn(
503
- "rounded-xl border p-3.5 transition-all text-xs bg-card shadow-xs group cursor-pointer",
504
- isActive ? "border-primary ring-1 ring-primary/40 shadow-sm" : "border-border/60 hover:border-border/90",
505
- thread.resolved && "opacity-75 bg-muted/30"
506
- ),
507
- children: [
508
- /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between gap-2 mb-2", children: [
509
- /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2 min-w-0", children: [
510
- /* @__PURE__ */ jsx3(
511
- "span",
512
- {
513
- className: "h-5 w-5 rounded-full flex items-center justify-center text-[10px] font-bold text-white shrink-0 shadow-xs",
514
- style: { backgroundColor: thread.author.color },
515
- children: thread.author.name.slice(0, 1).toUpperCase()
516
- }
517
- ),
518
- /* @__PURE__ */ jsx3("span", { className: "font-semibold text-foreground truncate", children: thread.author.name }),
519
- /* @__PURE__ */ jsx3("span", { className: "text-[10px] text-muted-foreground shrink-0", children: formatRelativeTime(thread.createdAt) })
520
- ] }),
521
- /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1 opacity-90 group-hover:opacity-100", children: [
522
- /* @__PURE__ */ jsx3(
523
- Button,
524
- {
525
- variant: "ghost",
526
- size: "sm",
527
- onClick: (e) => {
528
- e.stopPropagation();
529
- toggleResolveThread(thread.id);
530
- },
531
- className: cn(
532
- "h-6 px-1.5 text-[11px] gap-1 rounded-md cursor-pointer",
533
- thread.resolved ? "text-emerald-600 hover:text-emerald-700 hover:bg-emerald-50 dark:hover:bg-emerald-950/40" : "text-muted-foreground hover:text-foreground hover:bg-muted"
534
- ),
535
- title: thread.resolved ? "Reopen discussion" : "Resolve discussion",
536
- children: thread.resolved ? /* @__PURE__ */ jsxs3(Fragment, { children: [
537
- /* @__PURE__ */ jsx3(RotateCcw, { className: "h-3 w-3" }),
538
- /* @__PURE__ */ jsx3("span", { children: "Reopen" })
539
- ] }) : /* @__PURE__ */ jsxs3(Fragment, { children: [
540
- /* @__PURE__ */ jsx3(Check, { className: "h-3 w-3" }),
541
- /* @__PURE__ */ jsx3("span", { children: "Resolve" })
542
- ] })
543
- }
544
- ),
545
- /* @__PURE__ */ jsxs3(DropdownMenu, { children: [
546
- /* @__PURE__ */ jsx3(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx3(
547
- Button,
548
- {
549
- variant: "ghost",
550
- size: "sm",
551
- className: "h-6 w-6 p-0 hover:bg-muted rounded-md text-muted-foreground cursor-pointer",
552
- children: /* @__PURE__ */ jsx3(MoreVertical, { className: "h-3 w-3" })
553
- }
554
- ) }),
555
- /* @__PURE__ */ jsx3(DropdownMenuContent, { align: "end", className: "text-xs", children: /* @__PURE__ */ jsxs3(
556
- DropdownMenuItem,
557
- {
558
- onClick: (e) => {
559
- e.stopPropagation();
560
- deleteThread(thread.id);
561
- },
562
- className: "text-destructive focus:text-destructive gap-1.5 cursor-pointer",
563
- children: [
564
- /* @__PURE__ */ jsx3(Trash2, { className: "h-3.5 w-3.5" }),
565
- "Delete thread"
566
- ]
567
- }
568
- ) })
569
- ] })
570
- ] })
571
- ] }),
572
- thread.quote && /* @__PURE__ */ jsxs3(
573
- "button",
574
- {
575
- type: "button",
576
- onClick: (e) => {
577
- e.stopPropagation();
578
- jumpToQuote(thread.quote, thread.id);
579
- },
580
- className: "w-full text-left relative mb-2.5 pl-2.5 py-1.5 pr-2 border-l-2 border-primary/60 bg-muted/40 hover:bg-muted/70 rounded-r-lg text-muted-foreground hover:text-foreground font-serif text-[11px] italic transition-all flex items-center justify-between group/quote cursor-pointer",
581
- title: "Click to jump to quoted text in document",
582
- children: [
583
- /* @__PURE__ */ jsxs3("span", { className: "line-clamp-2 flex-1", children: [
584
- "\u201C",
585
- thread.quote,
586
- "\u201D"
587
- ] }),
588
- /* @__PURE__ */ jsxs3("span", { className: "inline-flex items-center gap-1 text-[10px] text-primary font-sans font-medium not-italic opacity-70 group-hover/quote:opacity-100 ml-2 shrink-0", children: [
589
- /* @__PURE__ */ jsx3(Crosshair, { className: "h-3 w-3" }),
590
- /* @__PURE__ */ jsx3("span", { className: "hidden sm:inline", children: "Jump" })
591
- ] })
592
- ]
593
- }
594
- ),
595
- /* @__PURE__ */ jsx3("div", { className: "space-y-2 mb-3", children: thread.messages.map((msg, index) => /* @__PURE__ */ jsxs3("div", { className: "space-y-0.5", children: [
596
- index > 0 && /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1.5 text-[10px] font-medium text-muted-foreground pt-1", children: [
597
- /* @__PURE__ */ jsx3(
598
- "span",
599
- {
600
- className: "h-3.5 w-3.5 rounded-full flex items-center justify-center text-[8px] font-bold text-white shrink-0",
601
- style: { backgroundColor: msg.author.color },
602
- children: msg.author.name.slice(0, 1).toUpperCase()
603
- }
604
- ),
605
- /* @__PURE__ */ jsx3("span", { className: "font-semibold text-foreground/80", children: msg.author.name }),
606
- /* @__PURE__ */ jsx3("span", { children: "\u2022" }),
607
- /* @__PURE__ */ jsx3("span", { children: formatRelativeTime(msg.createdAt) })
608
- ] }),
609
- /* @__PURE__ */ jsx3("p", { className: "text-foreground/90 leading-relaxed whitespace-pre-wrap break-words pl-0.5", children: renderMessageContent(msg.content) })
610
- ] }, msg.id)) }),
611
- !thread.resolved && /* @__PURE__ */ jsx3(Fragment, { children: isReplying ? /* @__PURE__ */ jsxs3(
612
- "form",
613
- {
614
- onSubmit: handleSubmitReply,
615
- onClick: (e) => e.stopPropagation(),
616
- className: "relative mt-2",
617
- children: [
618
- /* @__PURE__ */ jsx3(
619
- Textarea,
620
- {
621
- ref: textareaRef,
622
- value: replyText,
623
- onChange: handleReplyChange,
624
- onKeyDown: handleKeyDown,
625
- placeholder: "Write a reply... (use @ to mention)",
626
- className: "min-h-[58px] text-xs resize-none pr-14 py-1.5 rounded-lg border-border/80 focus-visible:ring-1",
627
- autoFocus: true
628
- }
629
- ),
630
- mentionQuery !== null && /* @__PURE__ */ jsx3(
631
- MentionsAutocomplete,
632
- {
633
- query: mentionQuery,
634
- users,
635
- selectedIndex: mentionIndex,
636
- onHoverIndex: setMentionIndex,
637
- onSelect: handleSelectMention,
638
- className: "bottom-full mb-1 left-0"
639
- }
640
- ),
641
- /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-end gap-1.5 mt-1.5", children: [
642
- /* @__PURE__ */ jsx3(
643
- Button,
644
- {
645
- type: "button",
646
- variant: "ghost",
647
- size: "sm",
648
- onClick: () => setIsReplying(false),
649
- className: "h-6 px-2 text-[11px]",
650
- children: "Cancel"
651
- }
652
- ),
653
- /* @__PURE__ */ jsxs3(
654
- Button,
655
- {
656
- type: "submit",
657
- size: "sm",
658
- disabled: !replyText.trim(),
659
- className: "h-6 px-2.5 text-[11px] gap-1 cursor-pointer",
660
- children: [
661
- /* @__PURE__ */ jsx3(Send2, { className: "h-2.5 w-2.5" }),
662
- "Reply"
663
- ]
664
- }
665
- )
666
- ] })
667
- ]
668
- }
669
- ) : /* @__PURE__ */ jsxs3(
670
- "button",
671
- {
672
- type: "button",
673
- onClick: (e) => {
674
- e.stopPropagation();
675
- setIsReplying(true);
676
- },
677
- className: "flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground font-medium transition-colors pt-1 cursor-pointer",
678
- children: [
679
- /* @__PURE__ */ jsx3(CornerDownRight, { className: "h-3 w-3 text-muted-foreground/70" }),
680
- "Reply to thread..."
681
- ]
682
- }
683
- ) })
684
- ]
685
- }
686
- );
687
- }
688
-
689
- // src/components/editor/plugins/CommentsPlugin/CommentsSidebar.tsx
690
- import { MessageSquare, X as X2, Inbox, Search, Sparkles } from "lucide-react";
691
- import { motion as motion2, AnimatePresence as AnimatePresence2 } from "framer-motion";
692
- import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
693
- function CommentsSidebar() {
694
- const {
695
- threads,
696
- activeThreadId,
697
- setActiveThreadId,
698
- isSidebarOpen,
699
- setIsSidebarOpen,
700
- unresolvedCount
701
- } = useComments();
702
- const [filter, setFilter] = useState3("open");
703
- const [searchQuery, setSearchQuery] = useState3("");
704
- const openThreads = useMemo4(() => threads.filter((t) => !t.resolved), [threads]);
705
- const resolvedThreads = useMemo4(() => threads.filter((t) => t.resolved), [threads]);
706
- const baseThreads = filter === "open" ? openThreads : filter === "resolved" ? resolvedThreads : threads;
707
- const displayedThreads = useMemo4(() => {
708
- if (!searchQuery.trim()) return baseThreads;
709
- const clean = searchQuery.toLowerCase().trim();
710
- return baseThreads.filter((t) => {
711
- var _a, _b, _c, _d;
712
- const matchQuote = (_a = t.quote) == null ? void 0 : _a.toLowerCase().includes(clean);
713
- const matchAuthor = (_c = (_b = t.author) == null ? void 0 : _b.name) == null ? void 0 : _c.toLowerCase().includes(clean);
714
- const matchMessage = (_d = t.messages) == null ? void 0 : _d.some(
715
- (m) => {
716
- var _a2, _b2, _c2;
717
- return ((_a2 = m.content) == null ? void 0 : _a2.toLowerCase().includes(clean)) || ((_c2 = (_b2 = m.author) == null ? void 0 : _b2.name) == null ? void 0 : _c2.toLowerCase().includes(clean));
718
- }
719
- );
720
- return matchQuote || matchAuthor || matchMessage;
721
- });
722
- }, [baseThreads, searchQuery]);
723
- const sortedThreads = useMemo4(
724
- () => [...displayedThreads].sort((a, b) => b.createdAt - a.createdAt),
725
- [displayedThreads]
726
- );
727
- return /* @__PURE__ */ jsx4(AnimatePresence2, { children: isSidebarOpen && /* @__PURE__ */ jsxs4(Fragment2, { children: [
728
- /* @__PURE__ */ jsx4(
729
- motion2.div,
730
- {
731
- initial: { opacity: 0 },
732
- animate: { opacity: 1 },
733
- exit: { opacity: 0 },
734
- onClick: () => setIsSidebarOpen(false),
735
- className: "fixed inset-0 z-39 bg-black/40 backdrop-blur-2xs sm:hidden",
736
- "aria-hidden": "true"
737
- }
738
- ),
739
- /* @__PURE__ */ jsxs4(
740
- motion2.aside,
741
- {
742
- initial: { x: "100%", opacity: 0 },
743
- animate: { x: 0, opacity: 1 },
744
- exit: { x: "100%", opacity: 0 },
745
- transition: { duration: 0.22, ease: "easeOut" },
746
- className: cn(
747
- "fixed top-14 right-0 bottom-0 z-40 w-full sm:w-80 md:w-96 max-w-full",
748
- "border-l border-border/80 bg-background/95 backdrop-blur-xl shadow-2xl",
749
- "flex flex-col select-none"
750
- ),
751
- children: [
752
- /* @__PURE__ */ jsxs4("div", { className: "flex items-center justify-between px-4 py-3 border-b border-border/60", children: [
753
- /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-2 font-semibold text-sm", children: [
754
- /* @__PURE__ */ jsx4(MessageSquare, { className: "h-4 w-4 text-primary" }),
755
- /* @__PURE__ */ jsx4("span", { children: "Discussions & Comments" }),
756
- unresolvedCount > 0 && /* @__PURE__ */ jsx4("span", { className: "px-1.5 py-0.5 rounded-full text-[10px] font-bold bg-primary text-primary-foreground", children: unresolvedCount })
757
- ] }),
758
- /* @__PURE__ */ jsx4(
759
- Button,
760
- {
761
- variant: "ghost",
762
- size: "sm",
763
- onClick: () => setIsSidebarOpen(false),
764
- className: "h-7 w-7 p-0 rounded-full hover:bg-muted text-muted-foreground hover:text-foreground cursor-pointer",
765
- "aria-label": "Close discussions sidebar",
766
- children: /* @__PURE__ */ jsx4(X2, { className: "h-4 w-4" })
767
- }
768
- )
769
- ] }),
770
- /* @__PURE__ */ jsxs4("div", { className: "px-4 py-2 border-b border-border/40 bg-muted/20 space-y-2", children: [
771
- /* @__PURE__ */ jsx4(
772
- Tabs,
773
- {
774
- value: filter,
775
- onValueChange: (val) => setFilter(val),
776
- className: "w-full",
777
- children: /* @__PURE__ */ jsxs4(TabsList, { className: "grid grid-cols-3 h-7 text-xs p-0.5", children: [
778
- /* @__PURE__ */ jsxs4(TabsTrigger, { value: "open", className: "text-[11px] py-1 cursor-pointer", children: [
779
- "Open (",
780
- openThreads.length,
781
- ")"
782
- ] }),
783
- /* @__PURE__ */ jsxs4(TabsTrigger, { value: "resolved", className: "text-[11px] py-1 cursor-pointer", children: [
784
- "Resolved (",
785
- resolvedThreads.length,
786
- ")"
787
- ] }),
788
- /* @__PURE__ */ jsxs4(TabsTrigger, { value: "all", className: "text-[11px] py-1 cursor-pointer", children: [
789
- "All (",
790
- threads.length,
791
- ")"
792
- ] })
793
- ] })
794
- }
795
- ),
796
- threads.length > 2 && /* @__PURE__ */ jsxs4("div", { className: "relative", children: [
797
- /* @__PURE__ */ jsx4(Search, { className: "absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none" }),
798
- /* @__PURE__ */ jsx4(
799
- "input",
800
- {
801
- type: "text",
802
- value: searchQuery,
803
- onChange: (e) => setSearchQuery(e.target.value),
804
- placeholder: "Search comments or @mentions...",
805
- className: "w-full pl-8 pr-7 py-1 text-xs rounded-md bg-background border border-border/70 placeholder:text-muted-foreground/60 focus:outline-none focus:ring-1 focus:ring-primary"
806
- }
807
- ),
808
- searchQuery && /* @__PURE__ */ jsx4(
809
- "button",
810
- {
811
- type: "button",
812
- onClick: () => setSearchQuery(""),
813
- className: "absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground p-0.5",
814
- children: /* @__PURE__ */ jsx4(X2, { className: "h-3 w-3" })
815
- }
816
- )
817
- ] })
818
- ] }),
819
- /* @__PURE__ */ jsx4("div", { className: "flex-1 overflow-y-auto p-4 space-y-3", children: sortedThreads.length > 0 ? sortedThreads.map((thread) => /* @__PURE__ */ jsx4(
820
- CommentThreadItem,
821
- {
822
- thread,
823
- isActive: activeThreadId === thread.id,
824
- onSelect: () => setActiveThreadId(thread.id)
825
- },
826
- thread.id
827
- )) : /* @__PURE__ */ jsxs4("div", { className: "h-full min-h-[220px] flex flex-col items-center justify-center text-center p-6 text-muted-foreground space-y-2.5", children: [
828
- /* @__PURE__ */ jsx4("div", { className: "h-10 w-10 rounded-full bg-muted flex items-center justify-center shadow-2xs", children: searchQuery ? /* @__PURE__ */ jsx4(Search, { className: "h-5 w-5 text-muted-foreground/60" }) : /* @__PURE__ */ jsx4(Inbox, { className: "h-5 w-5 text-muted-foreground/60" }) }),
829
- /* @__PURE__ */ jsx4("p", { className: "text-xs font-semibold text-foreground", children: searchQuery ? `No discussions matching "${searchQuery}"` : filter === "resolved" ? "No resolved discussions yet" : "All caught up! No open comments" }),
830
- /* @__PURE__ */ jsx4("p", { className: "text-[11px] text-muted-foreground leading-normal max-w-[220px]", children: searchQuery ? "Try searching for a different keyword, author, or quoted text." : "Highlight any text in the document and press Ctrl+Alt+M (or click Comment in toolbar) to start a discussion." }),
831
- !searchQuery && /* @__PURE__ */ jsxs4("div", { className: "inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-muted/60 text-[10px] text-muted-foreground font-mono mt-1 border border-border/50", children: [
832
- /* @__PURE__ */ jsx4(Sparkles, { className: "h-3 w-3 text-primary" }),
833
- /* @__PURE__ */ jsx4("span", { children: "Ctrl+Alt+M to comment" })
834
- ] })
835
- ] }) })
836
- ]
837
- }
838
- )
839
- ] }) });
840
- }
841
-
842
- // src/components/editor/plugins/CommentsPlugin/index.tsx
843
- import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
844
- var INSERT_COMMENT_COMMAND = createCommand(
845
- "INSERT_COMMENT_COMMAND"
846
- );
847
- function findDOMElementForQuote(root, quote) {
848
- var _a, _b, _c;
849
- const clean = quote.trim().toLowerCase();
850
- if (!clean) return null;
851
- const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
852
- let node;
853
- while (node = walker.nextNode()) {
854
- const text = ((_a = node.textContent) == null ? void 0 : _a.toLowerCase()) || "";
855
- if (text.includes(clean)) {
856
- return node.parentElement || null;
857
- }
858
- }
859
- const blockCandidates = root.querySelectorAll(
860
- "p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th"
861
- );
862
- for (const el of Array.from(blockCandidates)) {
863
- const text = ((_b = el.textContent) == null ? void 0 : _b.toLowerCase()) || "";
864
- if (text.includes(clean)) {
865
- return el;
866
- }
867
- }
868
- if (clean.length > 25) {
869
- const prefix = clean.slice(0, 25);
870
- for (const el of Array.from(blockCandidates)) {
871
- if ((_c = el.textContent) == null ? void 0 : _c.toLowerCase().includes(prefix)) {
872
- return el;
873
- }
874
- }
875
- }
876
- return null;
877
- }
878
- function CommentsPlugin() {
879
- const [editor] = useLexicalComposerContext();
880
- const { setDraftComment } = useComments();
881
- useEffect2(() => {
882
- const handleJump = (e) => {
883
- var _a;
884
- const customEvent = e;
885
- const quote = (_a = customEvent.detail) == null ? void 0 : _a.quote;
886
- if (!quote) return;
887
- const root = editor.getRootElement();
888
- if (!root) return;
889
- const target = findDOMElementForQuote(root, quote);
890
- if (target) {
891
- target.scrollIntoView({ behavior: "smooth", block: "center" });
892
- target.classList.remove("notiq-pulse-highlight");
893
- void target.offsetWidth;
894
- target.classList.add("notiq-pulse-highlight");
895
- setTimeout(() => {
896
- target.classList.remove("notiq-pulse-highlight");
897
- }, 2600);
898
- }
899
- };
900
- window.addEventListener("notiq:jump-to-quote", handleJump);
901
- return () => window.removeEventListener("notiq:jump-to-quote", handleJump);
902
- }, [editor]);
903
- useEffect2(() => {
904
- return editor.registerCommand(
905
- INSERT_COMMENT_COMMAND,
906
- () => {
907
- editor.getEditorState().read(() => {
908
- const selection = $getSelection();
909
- if ($isRangeSelection(selection)) {
910
- const quote = selection.getTextContent();
911
- if (quote.trim()) {
912
- setDraftComment({
913
- quote: quote.trim(),
914
- isOpen: true
915
- });
916
- }
917
- }
918
- });
919
- return true;
920
- },
921
- COMMAND_PRIORITY_LOW
922
- );
923
- }, [editor, setDraftComment]);
924
- useEffect2(() => {
925
- const handleKeyDown = (e) => {
926
- if ((e.ctrlKey || e.metaKey) && e.altKey && (e.key === "m" || e.key === "M")) {
927
- e.preventDefault();
928
- editor.dispatchCommand(INSERT_COMMENT_COMMAND, void 0);
929
- }
930
- };
931
- window.addEventListener("keydown", handleKeyDown);
932
- return () => window.removeEventListener("keydown", handleKeyDown);
933
- }, [editor]);
934
- return /* @__PURE__ */ jsxs5(Fragment3, { children: [
935
- /* @__PURE__ */ jsx5(NewCommentDialog, {}),
936
- /* @__PURE__ */ jsx5(CommentsSidebar, {})
937
- ] });
938
- }
939
-
940
- export {
941
- INSERT_COMMENT_COMMAND,
942
- findDOMElementForQuote,
943
- CommentsPlugin
944
- };