Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: cursor

Nevo David32ca6ff5b771
diff --git a/apps/frontend/src/app/global.scss b/apps/frontend/src/app/global.scss
index a900a44d4..0c6d5cc03 100644
--- a/apps/frontend/src/app/global.scss
+++ b/apps/frontend/src/app/global.scss
@@ -822,3 +822,8 @@ html[dir='rtl'] [dir='ltr'] {
text-shadow: -1px -1px 0 black, 1px -1px 0 black, -1px 1px 0 black,
1px 1px 0 black;
}
+
+/* Preview page: text that can be selected to leave an inline comment */
+.preview-comment-cursor {
+ cursor: url("data:image/svg+xml,%3Csvg xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22 width%3D%2228%22 height%3D%2228%22 viewBox%3D%220 0 28 28%22%3E%3Cg fill%3D%22none%22 stroke-linecap%3D%22round%22 stroke-linejoin%3D%22round%22%3E%3Cpath d%3D%22M3 4h6M3 24h6M6 4v20%22 stroke%3D%22%23fff%22 stroke-width%3D%224%22%2F%3E%3Cpath d%3D%22M3 4h6M3 24h6M6 4v20%22 stroke%3D%22%23000%22 stroke-width%3D%221.6%22%2F%3E%3Cpath d%3D%22M14 4h10a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2h-6l-4 3v-3a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z%22 fill%3D%22%23612bd3%22 stroke%3D%22%23fff%22 stroke-width%3D%221.5%22%2F%3E%3Cpath d%3D%22M17 8h6M17 11h4%22 stroke%3D%22%23fff%22 stroke-width%3D%221.5%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E") 6 14, text;
+}
diff --git a/apps/frontend/src/components/preview/post.content.client.tsx b/apps/frontend/src/components/preview/post.content.client.tsx
index 680ab431a..fbcbc480e 100644
--- a/apps/frontend/src/components/preview/post.content.client.tsx
+++ b/apps/frontend/src/components/preview/post.content.client.tsx
@@ -150,6 +150,13 @@ export const PostContentClient: FC<{ postId: string; html: string }> = ({
const [selection, setSelection] = useState<
(PendingAnchor & { top: number; left: number }) | null
>(null);
+ // Follows the mouse over the text so nobody has to guess that selecting
+ // it opens a comment.
+ const [hint, setHint] = useState<{
+ top: number;
+ left: number;
+ onMark: boolean;
+ } | null>(null);
const ranges = useMemo<HighlightRange[]>(
() =>
@@ -279,12 +286,32 @@ export const PostContentClient: FC<{ postId: string; html: string }> = ({
.closest<HTMLElement>('mark[data-thread-ids]')
?.dataset.threadIds?.split(',')[0] || null;
+ const onMouseMove = useCallback((e: MouseEvent<HTMLDivElement>) => {
+ const root = ref.current;
+ // While dragging a selection the "Comment" button takes over afterwards.
+ if (!root || e.buttons) {
+ setHint(null);
+ return;
+ }
+ const rootRect = root.getBoundingClientRect();
+ setHint({
+ top: e.clientY - rootRect.top + 22,
+ left: Math.max(
+ 0,
+ Math.min(e.clientX - rootRect.left + 14, rootRect.width - 190)
+ ),
+ onMark: !!threadOf(e),
+ });
+ }, []);
+
return (
<div className="relative">
<div
ref={ref}
- className="text-[14px] whitespace-pre-wrap leading-[22px]"
+ className="text-[14px] whitespace-pre-wrap leading-[22px] preview-comment-cursor"
onMouseUp={onMouseUp}
+ onMouseMove={onMouseMove}
+ onMouseLeave={() => setHint(null)}
onMouseOver={(e) => setHoveredThread(threadOf(e))}
onMouseOut={() => setHoveredThread(null)}
onClick={(e) => {
@@ -295,6 +322,30 @@ export const PostContentClient: FC<{ postId: string; html: string }> = ({
}}
dangerouslySetInnerHTML={{ __html: html }}
/>
+ {!!hint && !selection && !ownPending && (
+ <div
+ style={{ top: hint.top, left: hint.left }}
+ className="absolute z-[10] pointer-events-none bg-newBgColorInner border border-newTableBorder text-newTextColor text-[12px] rounded-[6px] px-[8px] h-[24px] flex items-center gap-[6px] shadow-lg whitespace-nowrap"
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width={12}
+ height={12}
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth={2}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ className="text-btnPrimary"
+ >
+ <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
+ </svg>
+ {hint.onMark
+ ? t('preview_click_to_open_comment', 'Click to open the comment')
+ : t('preview_select_text_to_comment', 'Select text to comment')}
+ </div>
+ )}
{!!selection && (
<button
type="button"