@actuate-media/cms-admin 0.12.0 → 0.13.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 (157) hide show
  1. package/dist/__tests__/components/comment-mark.test.d.ts +2 -0
  2. package/dist/__tests__/components/comment-mark.test.d.ts.map +1 -0
  3. package/dist/__tests__/components/comment-mark.test.js +89 -0
  4. package/dist/__tests__/components/comment-mark.test.js.map +1 -0
  5. package/dist/__tests__/components/comment-side-panel.test.d.ts +2 -0
  6. package/dist/__tests__/components/comment-side-panel.test.d.ts.map +1 -0
  7. package/dist/__tests__/components/comment-side-panel.test.js +291 -0
  8. package/dist/__tests__/components/comment-side-panel.test.js.map +1 -0
  9. package/dist/__tests__/components/notification-bell.test.d.ts +2 -0
  10. package/dist/__tests__/components/notification-bell.test.d.ts.map +1 -0
  11. package/dist/__tests__/components/notification-bell.test.js +346 -0
  12. package/dist/__tests__/components/notification-bell.test.js.map +1 -0
  13. package/dist/__tests__/components/offline-status.test.d.ts +2 -0
  14. package/dist/__tests__/components/offline-status.test.d.ts.map +1 -0
  15. package/dist/__tests__/components/offline-status.test.js +56 -0
  16. package/dist/__tests__/components/offline-status.test.js.map +1 -0
  17. package/dist/__tests__/components/presence-chips-helpers.test.d.ts +2 -0
  18. package/dist/__tests__/components/presence-chips-helpers.test.d.ts.map +1 -0
  19. package/dist/__tests__/components/presence-chips-helpers.test.js +35 -0
  20. package/dist/__tests__/components/presence-chips-helpers.test.js.map +1 -0
  21. package/dist/__tests__/lib/active-editor.test.d.ts +2 -0
  22. package/dist/__tests__/lib/active-editor.test.d.ts.map +1 -0
  23. package/dist/__tests__/lib/active-editor.test.js +57 -0
  24. package/dist/__tests__/lib/active-editor.test.js.map +1 -0
  25. package/dist/__tests__/lib/coauthor-client.test.d.ts +2 -0
  26. package/dist/__tests__/lib/coauthor-client.test.d.ts.map +1 -0
  27. package/dist/__tests__/lib/coauthor-client.test.js +173 -0
  28. package/dist/__tests__/lib/coauthor-client.test.js.map +1 -0
  29. package/dist/__tests__/lib/collaboration-provider.test.d.ts +2 -0
  30. package/dist/__tests__/lib/collaboration-provider.test.d.ts.map +1 -0
  31. package/dist/__tests__/lib/collaboration-provider.test.js +335 -0
  32. package/dist/__tests__/lib/collaboration-provider.test.js.map +1 -0
  33. package/dist/__tests__/lib/comment-anchor.test.d.ts +2 -0
  34. package/dist/__tests__/lib/comment-anchor.test.d.ts.map +1 -0
  35. package/dist/__tests__/lib/comment-anchor.test.js +173 -0
  36. package/dist/__tests__/lib/comment-anchor.test.js.map +1 -0
  37. package/dist/__tests__/lib/comments-client.test.d.ts +2 -0
  38. package/dist/__tests__/lib/comments-client.test.d.ts.map +1 -0
  39. package/dist/__tests__/lib/comments-client.test.js +202 -0
  40. package/dist/__tests__/lib/comments-client.test.js.map +1 -0
  41. package/dist/__tests__/lib/notifications-client.test.d.ts +2 -0
  42. package/dist/__tests__/lib/notifications-client.test.d.ts.map +1 -0
  43. package/dist/__tests__/lib/notifications-client.test.js +283 -0
  44. package/dist/__tests__/lib/notifications-client.test.js.map +1 -0
  45. package/dist/__tests__/lib/slash-command.test.d.ts +2 -0
  46. package/dist/__tests__/lib/slash-command.test.d.ts.map +1 -0
  47. package/dist/__tests__/lib/slash-command.test.js +123 -0
  48. package/dist/__tests__/lib/slash-command.test.js.map +1 -0
  49. package/dist/actuate-admin.css +1 -1
  50. package/dist/components/AICoauthorBubbleMenu.d.ts +18 -0
  51. package/dist/components/AICoauthorBubbleMenu.d.ts.map +1 -0
  52. package/dist/components/AICoauthorBubbleMenu.js +113 -0
  53. package/dist/components/AICoauthorBubbleMenu.js.map +1 -0
  54. package/dist/components/CoauthorResultPopover.d.ts +28 -0
  55. package/dist/components/CoauthorResultPopover.d.ts.map +1 -0
  56. package/dist/components/CoauthorResultPopover.js +42 -0
  57. package/dist/components/CoauthorResultPopover.js.map +1 -0
  58. package/dist/components/CommandPalette.d.ts +1 -1
  59. package/dist/components/CommandPalette.d.ts.map +1 -1
  60. package/dist/components/CommandPalette.js +138 -40
  61. package/dist/components/CommandPalette.js.map +1 -1
  62. package/dist/components/CommentMark.d.ts +54 -0
  63. package/dist/components/CommentMark.d.ts.map +1 -0
  64. package/dist/components/CommentMark.js +104 -0
  65. package/dist/components/CommentMark.js.map +1 -0
  66. package/dist/components/CommentSidePanel.d.ts +86 -0
  67. package/dist/components/CommentSidePanel.d.ts.map +1 -0
  68. package/dist/components/CommentSidePanel.js +165 -0
  69. package/dist/components/CommentSidePanel.js.map +1 -0
  70. package/dist/components/LivePreview.d.ts.map +1 -1
  71. package/dist/components/LivePreview.js +80 -16
  72. package/dist/components/LivePreview.js.map +1 -1
  73. package/dist/components/NotificationBell.d.ts +66 -0
  74. package/dist/components/NotificationBell.d.ts.map +1 -0
  75. package/dist/components/NotificationBell.js +142 -0
  76. package/dist/components/NotificationBell.js.map +1 -0
  77. package/dist/components/OfflineStatus.d.ts +39 -0
  78. package/dist/components/OfflineStatus.d.ts.map +1 -0
  79. package/dist/components/OfflineStatus.js +47 -0
  80. package/dist/components/OfflineStatus.js.map +1 -0
  81. package/dist/components/PresenceChips.d.ts +31 -0
  82. package/dist/components/PresenceChips.d.ts.map +1 -0
  83. package/dist/components/PresenceChips.js +58 -0
  84. package/dist/components/PresenceChips.js.map +1 -0
  85. package/dist/components/TipTapEditor.d.ts +61 -1
  86. package/dist/components/TipTapEditor.d.ts.map +1 -1
  87. package/dist/components/TipTapEditor.js +211 -8
  88. package/dist/components/TipTapEditor.js.map +1 -1
  89. package/dist/components/ui/Badge.d.ts +1 -1
  90. package/dist/index.d.ts +8 -0
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +4 -0
  93. package/dist/index.js.map +1 -1
  94. package/dist/lib/active-editor.d.ts +6 -0
  95. package/dist/lib/active-editor.d.ts.map +1 -0
  96. package/dist/lib/active-editor.js +35 -0
  97. package/dist/lib/active-editor.js.map +1 -0
  98. package/dist/lib/api.d.ts +8 -0
  99. package/dist/lib/api.d.ts.map +1 -1
  100. package/dist/lib/api.js +10 -0
  101. package/dist/lib/api.js.map +1 -1
  102. package/dist/lib/coauthor-client.d.ts +72 -0
  103. package/dist/lib/coauthor-client.d.ts.map +1 -0
  104. package/dist/lib/coauthor-client.js +98 -0
  105. package/dist/lib/coauthor-client.js.map +1 -0
  106. package/dist/lib/collaboration-provider.d.ts +142 -0
  107. package/dist/lib/collaboration-provider.d.ts.map +1 -0
  108. package/dist/lib/collaboration-provider.js +168 -0
  109. package/dist/lib/collaboration-provider.js.map +1 -0
  110. package/dist/lib/comment-anchor.d.ts +86 -0
  111. package/dist/lib/comment-anchor.d.ts.map +1 -0
  112. package/dist/lib/comment-anchor.js +139 -0
  113. package/dist/lib/comment-anchor.js.map +1 -0
  114. package/dist/lib/comments-client.d.ts +106 -0
  115. package/dist/lib/comments-client.d.ts.map +1 -0
  116. package/dist/lib/comments-client.js +138 -0
  117. package/dist/lib/comments-client.js.map +1 -0
  118. package/dist/lib/notifications-client.d.ts +121 -0
  119. package/dist/lib/notifications-client.d.ts.map +1 -0
  120. package/dist/lib/notifications-client.js +173 -0
  121. package/dist/lib/notifications-client.js.map +1 -0
  122. package/dist/lib/slash-command.d.ts +39 -0
  123. package/dist/lib/slash-command.d.ts.map +1 -0
  124. package/dist/lib/slash-command.js +50 -0
  125. package/dist/lib/slash-command.js.map +1 -0
  126. package/package.json +12 -3
  127. package/src/__tests__/components/comment-mark.test.ts +99 -0
  128. package/src/__tests__/components/comment-side-panel.test.tsx +343 -0
  129. package/src/__tests__/components/notification-bell.test.tsx +379 -0
  130. package/src/__tests__/components/offline-status.test.tsx +66 -0
  131. package/src/__tests__/components/presence-chips-helpers.test.ts +44 -0
  132. package/src/__tests__/lib/active-editor.test.ts +70 -0
  133. package/src/__tests__/lib/coauthor-client.test.ts +213 -0
  134. package/src/__tests__/lib/collaboration-provider.test.ts +425 -0
  135. package/src/__tests__/lib/comment-anchor.test.ts +188 -0
  136. package/src/__tests__/lib/comments-client.test.ts +239 -0
  137. package/src/__tests__/lib/notifications-client.test.ts +339 -0
  138. package/src/__tests__/lib/slash-command.test.ts +146 -0
  139. package/src/components/AICoauthorBubbleMenu.tsx +187 -0
  140. package/src/components/CoauthorResultPopover.tsx +193 -0
  141. package/src/components/CommandPalette.tsx +397 -209
  142. package/src/components/CommentMark.ts +138 -0
  143. package/src/components/CommentSidePanel.tsx +521 -0
  144. package/src/components/LivePreview.tsx +117 -11
  145. package/src/components/NotificationBell.tsx +314 -0
  146. package/src/components/OfflineStatus.tsx +90 -0
  147. package/src/components/PresenceChips.tsx +150 -0
  148. package/src/components/TipTapEditor.tsx +310 -12
  149. package/src/index.ts +20 -0
  150. package/src/lib/active-editor.ts +39 -0
  151. package/src/lib/api.ts +11 -0
  152. package/src/lib/coauthor-client.ts +160 -0
  153. package/src/lib/collaboration-provider.ts +306 -0
  154. package/src/lib/comment-anchor.ts +179 -0
  155. package/src/lib/comments-client.ts +208 -0
  156. package/src/lib/notifications-client.ts +292 -0
  157. package/src/lib/slash-command.ts +67 -0
@@ -0,0 +1,193 @@
1
+ 'use client'
2
+
3
+ import { useEffect, useRef } from 'react'
4
+ import { Check, Copy, Loader2, Sparkles, X } from 'lucide-react'
5
+ import type { CoauthorAction, ProofreadChange } from '../lib/coauthor-client.js'
6
+ import { coauthorActionLabel } from '../lib/coauthor-client.js'
7
+
8
+ export interface CoauthorResultPopoverProps {
9
+ open: boolean
10
+ loading: boolean
11
+ action: CoauthorAction
12
+ before: string
13
+ after: string
14
+ error?: string
15
+ changes?: ProofreadChange[]
16
+ /** Label for the apply target, e.g. "Apply to editor" or "Replace selection". */
17
+ applyLabel?: string
18
+ onApply: () => void
19
+ onCopy: () => void
20
+ onDiscard: () => void
21
+ }
22
+
23
+ /**
24
+ * Universal AI-result panel rendered by both the TipTap bubble menu and the
25
+ * Cmd+K slash-command palette. Shows a before/after diff plus three actions:
26
+ *
27
+ * - Apply (write the result back to the active target)
28
+ * - Copy (copy the result to the clipboard)
29
+ * - Discard (close without changing anything)
30
+ *
31
+ * The popover takes the same `{ open, loading, action, before, after, error }`
32
+ * state shape regardless of caller so the UX stays identical across surfaces.
33
+ */
34
+ export function CoauthorResultPopover({
35
+ open,
36
+ loading,
37
+ action,
38
+ before,
39
+ after,
40
+ error,
41
+ changes,
42
+ applyLabel,
43
+ onApply,
44
+ onCopy,
45
+ onDiscard,
46
+ }: CoauthorResultPopoverProps) {
47
+ const dialogRef = useRef<HTMLDivElement>(null)
48
+
49
+ useEffect(() => {
50
+ if (!open) return
51
+ const onKey = (e: KeyboardEvent) => {
52
+ if (e.key === 'Escape') {
53
+ e.preventDefault()
54
+ onDiscard()
55
+ }
56
+ }
57
+ document.addEventListener('keydown', onKey)
58
+ return () => document.removeEventListener('keydown', onKey)
59
+ }, [open, onDiscard])
60
+
61
+ useEffect(() => {
62
+ if (!open) return
63
+ dialogRef.current?.focus()
64
+ }, [open])
65
+
66
+ if (!open) return null
67
+
68
+ const applyDisabled = loading || !!error || after.length === 0
69
+ const copyDisabled = loading || !!error || after.length === 0
70
+
71
+ return (
72
+ <div
73
+ className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 px-4"
74
+ role="presentation"
75
+ onClick={onDiscard}
76
+ >
77
+ <div
78
+ ref={dialogRef}
79
+ role="dialog"
80
+ aria-modal="true"
81
+ aria-label={`AI ${coauthorActionLabel(action)} result`}
82
+ tabIndex={-1}
83
+ onClick={(e) => e.stopPropagation()}
84
+ className="w-full max-w-2xl rounded-lg bg-white shadow-2xl outline-none"
85
+ >
86
+ <div className="flex items-center justify-between border-b border-gray-200 px-4 py-3">
87
+ <div className="flex items-center gap-2 text-sm font-semibold text-gray-900">
88
+ <Sparkles className="h-4 w-4 text-blue-600" aria-hidden />
89
+ <span>AI {coauthorActionLabel(action)}</span>
90
+ {loading && (
91
+ <Loader2 className="ml-1 h-4 w-4 animate-spin text-gray-400" aria-label="Loading" />
92
+ )}
93
+ </div>
94
+ <button
95
+ type="button"
96
+ onClick={onDiscard}
97
+ className="rounded p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600"
98
+ aria-label="Close"
99
+ >
100
+ <X className="h-4 w-4" />
101
+ </button>
102
+ </div>
103
+
104
+ <div className="grid grid-cols-2 gap-4 p-4">
105
+ <section aria-labelledby="coauthor-before">
106
+ <h3
107
+ id="coauthor-before"
108
+ className="mb-2 text-xs font-medium tracking-wide text-gray-500 uppercase"
109
+ >
110
+ Before
111
+ </h3>
112
+ <pre className="max-h-72 overflow-auto rounded border border-gray-200 bg-gray-50 p-3 text-sm whitespace-pre-wrap text-gray-700">
113
+ {before}
114
+ </pre>
115
+ </section>
116
+ <section aria-labelledby="coauthor-after">
117
+ <h3
118
+ id="coauthor-after"
119
+ className="mb-2 text-xs font-medium tracking-wide text-gray-500 uppercase"
120
+ >
121
+ After
122
+ </h3>
123
+ {loading ? (
124
+ <div
125
+ className="flex h-72 items-center justify-center rounded border border-dashed border-gray-200 bg-gray-50 text-sm text-gray-400"
126
+ role="status"
127
+ >
128
+ Thinking…
129
+ </div>
130
+ ) : error ? (
131
+ <div className="flex h-72 items-center justify-center rounded border border-dashed border-red-200 bg-red-50 p-3 text-sm text-red-600">
132
+ {error}
133
+ </div>
134
+ ) : (
135
+ <pre className="max-h-72 overflow-auto rounded border border-blue-200 bg-blue-50 p-3 text-sm whitespace-pre-wrap text-gray-900">
136
+ {after}
137
+ </pre>
138
+ )}
139
+ </section>
140
+ </div>
141
+
142
+ {changes && changes.length > 0 && !loading && !error && (
143
+ <div className="border-t border-gray-200 px-4 py-3">
144
+ <h3 className="mb-2 text-xs font-medium tracking-wide text-gray-500 uppercase">
145
+ Changes ({changes.length})
146
+ </h3>
147
+ <ul className="max-h-32 space-y-1 overflow-auto text-xs">
148
+ {changes.map((change, i) => (
149
+ <li key={i} className="flex items-start gap-2 rounded bg-gray-50 px-2 py-1">
150
+ <span className="text-red-600 line-through">{change.original}</span>
151
+ <span className="text-gray-400">→</span>
152
+ <span className="text-green-700">{change.corrected}</span>
153
+ {change.reason && (
154
+ <span className="ml-auto text-gray-500 italic">{change.reason}</span>
155
+ )}
156
+ </li>
157
+ ))}
158
+ </ul>
159
+ </div>
160
+ )}
161
+
162
+ <div className="flex items-center justify-end gap-2 border-t border-gray-200 bg-gray-50 px-4 py-3">
163
+ <button
164
+ type="button"
165
+ onClick={onDiscard}
166
+ className="rounded-md border border-gray-200 bg-white px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-50"
167
+ >
168
+ <X className="mr-1.5 inline h-3.5 w-3.5" aria-hidden />
169
+ Discard
170
+ </button>
171
+ <button
172
+ type="button"
173
+ onClick={onCopy}
174
+ disabled={copyDisabled}
175
+ className="rounded-md border border-gray-200 bg-white px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50"
176
+ >
177
+ <Copy className="mr-1.5 inline h-3.5 w-3.5" aria-hidden />
178
+ Copy
179
+ </button>
180
+ <button
181
+ type="button"
182
+ onClick={onApply}
183
+ disabled={applyDisabled}
184
+ className="rounded-md bg-blue-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50"
185
+ >
186
+ <Check className="mr-1.5 inline h-3.5 w-3.5" aria-hidden />
187
+ {applyLabel ?? 'Apply'}
188
+ </button>
189
+ </div>
190
+ </div>
191
+ </div>
192
+ )
193
+ }