add PostOnHover for quotes in replies

This commit is contained in:
Tom
2023-06-03 17:22:39 +02:00
parent 97e95005d3
commit a6faed9ada
4 changed files with 193 additions and 58 deletions
+55 -13
View File
@@ -49,7 +49,8 @@ const All = () => {
const threadMenuRefs = useRef({});
const replyMenuRefs = useRef({});
const threadBacklinkRefs = useRef({});
const backlinkRefs = useRef({});
const quoteRefs = useRef({});
const postOnHoverRef = useRef(null);
const [isReplyOpen, setIsReplyOpen] = useState(false);
@@ -534,7 +535,7 @@ const All = () => {
.map((reply, index) => (
<div key={`div-${index}`} style={{display: 'inline-block'}}
ref={el => {
threadBacklinkRefs.current[reply.cid] = el;
backlinkRefs.current[reply.cid] = el;
}}>
<Link key={`ql-${index}`}
to={() => {}} className="quote-link"
@@ -543,7 +544,7 @@ const All = () => {
event.stopPropagation();
handleQuoteHover(reply, null, () => {
setOutOfViewCid(reply.cid);
const rect = threadBacklinkRefs.current[reply.cid].getBoundingClientRect();
const rect = backlinkRefs.current[reply.cid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
@@ -739,7 +740,7 @@ const All = () => {
.map((reply, index) => (
<div key={`div-${index}`} style={{display: 'inline-block'}}
ref={el => {
threadBacklinkRefs.current[reply.cid] = el;
backlinkRefs.current[reply.cid] = el;
}}>
<Link key={`ql-${index}`}
to={() => {}} className="quote-link"
@@ -748,7 +749,7 @@ const All = () => {
event.stopPropagation();
handleQuoteHover(reply, null, () => {
setOutOfViewCid(reply.cid);
const rect = threadBacklinkRefs.current[reply.cid].getBoundingClientRect();
const rect = backlinkRefs.current[reply.cid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
@@ -824,10 +825,31 @@ const All = () => {
reply.content?.length > 500 ?
<Fragment key={`fragment8-${index}`}>
<blockquote key={`pm-${index}`} comment={reply} className="post-message">
<Link to={() => {}} key={`r-pm-${index}`} className="quotelink"
onClick={(event) => handleQuoteClick(reply, shortParentCid, thread.shortCid, event)}
onMouseOver={(event) => handleQuoteHover(reply, shortParentCid, thread.shortCid, event)}
onMouseLeave={removeHighlight}>
<Link to={() => {}} key={`r-pm-${index}`} className="quotelink"
ref={el => {
quoteRefs.current[shortParentCid] = el;
}}
onClick={(event) => handleQuoteClick(reply, shortParentCid, event)}
onMouseOver={(event) => {
event.stopPropagation();
handleQuoteHover(reply, shortParentCid, () => {
if (shortParentCid === thread.shortCid) {
return;
} else {
setOutOfViewCid(reply.parentCid);
console.log("risposta: ", reply.parentCid);
const rect = quoteRefs.current[shortParentCid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
});
}
});
}}
onMouseLeave={() => {
removeHighlight();
setOutOfViewCid(null);
}}>
{`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null}
</Link>
<Post content={reply.content?.slice(0, 500)} key={`post-${index}`} />
@@ -839,10 +861,30 @@ const All = () => {
</blockquote>
</Fragment>
: <blockquote key={`pm-${index}`} className="post-message">
<Link to={() => {}} key={`r-pm-${index}`} className="quotelink" onClick={(event) =>
handleQuoteClick(reply, shortParentCid, thread.shortCid, event)}
onMouseOver={(event) => handleQuoteHover(reply, shortParentCid, thread.shortCid, event)}
onMouseLeave={removeHighlight}>
<Link to={() => {}} key={`r-pm-${index}`} className="quotelink"
ref={el => {
quoteRefs.current[shortParentCid] = el;
}}
onClick={(event) => handleQuoteClick(reply, shortParentCid, event)}
onMouseOver={(event) => {
event.stopPropagation();
handleQuoteHover(reply, shortParentCid, () => {
if (shortParentCid === thread.shortCid) {
return;
} else {
setOutOfViewCid(reply.parentCid);
const rect = quoteRefs.current[shortParentCid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
});
}
});
}}
onMouseLeave={() => {
removeHighlight();
setOutOfViewCid(null);
}}>
{`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null}
</Link>
<Post content={reply.content} key={`post-${index}`} comment={reply} />
+55 -19
View File
@@ -76,7 +76,8 @@ const Board = () => {
const threadMenuRefs = useRef({});
const replyMenuRefs = useRef({});
const postMenuCatalogRef = useRef(null);
const threadBacklinkRefs = useRef({});
const backlinkRefs = useRef({});
const quoteRefs = useRef({});
const postOnHoverRef = useRef(null);
const { feed, hasMore, loadMore } = useFeed({subplebbitAddresses: [`${selectedAddress}`], sortType: 'new'});
@@ -980,7 +981,7 @@ const Board = () => {
.map((reply, index) => (
<div key={`div-${index}`} style={{display: 'inline-block'}}
ref={el => {
threadBacklinkRefs.current[reply.cid] = el;
backlinkRefs.current[reply.cid] = el;
}}>
<Link key={`ql-${index}`}
to={() => {}}
@@ -990,7 +991,7 @@ const Board = () => {
event.stopPropagation();
handleQuoteHover(reply, null, () => {
setOutOfViewCid(reply.cid);
const rect = threadBacklinkRefs.current[reply.cid].getBoundingClientRect();
const rect = backlinkRefs.current[reply.cid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
@@ -1218,7 +1219,7 @@ const Board = () => {
.map((reply, index) => (
<div key={`div-${index}`} style={{display: 'inline-block'}}
ref={el => {
threadBacklinkRefs.current[reply.cid] = el;
backlinkRefs.current[reply.cid] = el;
}}>
<Link key={`ql-${index}`}
to={() => {}} className="quote-link"
@@ -1227,7 +1228,7 @@ const Board = () => {
event.stopPropagation();
handleQuoteHover(reply, null, () => {
setOutOfViewCid(reply.cid);
const rect = threadBacklinkRefs.current[reply.cid].getBoundingClientRect();
const rect = backlinkRefs.current[reply.cid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
@@ -1303,13 +1304,31 @@ const Board = () => {
reply.content?.length > 500 ?
<Fragment key={`fragment8-${index}`}>
<blockquote key={`pm-${index}`} comment={reply} className="post-message">
<Link to={() => {}} key={`r-pm-${index}`} className="quotelink"
onClick={(event) => handleQuoteClick(reply, shortParentCid, event)}
onMouseOver={() => handleQuoteHover(reply, shortParentCid, (cid) => setOutOfViewCid(cid))}
onMouseLeave={() => {
removeHighlight();
setOutOfViewCid(null);
}}>
<Link to={() => {}} key={`r-pm-${index}`} className="quotelink"
ref={el => {
quoteRefs.current[shortParentCid] = el;
}}
onClick={(event) => handleQuoteClick(reply, shortParentCid, event)}
onMouseOver={(event) => {
event.stopPropagation();
handleQuoteHover(reply, shortParentCid, () => {
if (shortParentCid === thread.shortCid) {
return;
} else {
setOutOfViewCid(reply.parentCid);
console.log("risposta: ", reply.parentCid);
const rect = quoteRefs.current[shortParentCid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
});
}
});
}}
onMouseLeave={() => {
removeHighlight();
setOutOfViewCid(null);
}}>
{`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null}
</Link>
<Post content={reply.content?.slice(0, 500)} key={`post-${index}`} />
@@ -1328,13 +1347,30 @@ const Board = () => {
</blockquote>
</Fragment>
: <blockquote key={`pm-${index}`} className="post-message">
<Link to={() => {}} key={`r-pm-${index}`} className="quotelink"
onClick={(event) => handleQuoteClick(reply, shortParentCid, event)}
onMouseOver={() => handleQuoteHover(reply, shortParentCid, (cid) => setOutOfViewCid(cid))}
onMouseLeave={() => {
removeHighlight();
setOutOfViewCid(null);
}}>
<Link to={() => {}} key={`r-pm-${index}`} className="quotelink"
ref={el => {
quoteRefs.current[shortParentCid] = el;
}}
onClick={(event) => handleQuoteClick(reply, shortParentCid, event)}
onMouseOver={(event) => {
event.stopPropagation();
handleQuoteHover(reply, shortParentCid, () => {
if (shortParentCid === thread.shortCid) {
return;
} else {
setOutOfViewCid(reply.parentCid);
const rect = quoteRefs.current[shortParentCid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
});
}
});
}}
onMouseLeave={() => {
removeHighlight();
setOutOfViewCid(null);
}}>
{`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null}
</Link>
<Post content={reply.content} key={`post-${index}`} comment={reply} />
+55 -13
View File
@@ -49,7 +49,8 @@ const Subscriptions = () => {
const threadMenuRefs = useRef({});
const replyMenuRefs = useRef({});
const threadBacklinkRefs = useRef({});
const backlinkRefs = useRef({});
const quoteRefs = useRef({});
const postOnHoverRef = useRef(null);
const [isReplyOpen, setIsReplyOpen] = useState(false);
@@ -539,7 +540,7 @@ const Subscriptions = () => {
.map((reply, index) => (
<div key={`div-${index}`} style={{display: 'inline-block'}}
ref={el => {
threadBacklinkRefs.current[reply.cid] = el;
backlinkRefs.current[reply.cid] = el;
}}>
<Link key={`ql-${index}`}
to={() => {}} className="quote-link"
@@ -548,7 +549,7 @@ const Subscriptions = () => {
event.stopPropagation();
handleQuoteHover(reply, null, () => {
setOutOfViewCid(reply.cid);
const rect = threadBacklinkRefs.current[reply.cid].getBoundingClientRect();
const rect = backlinkRefs.current[reply.cid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
@@ -744,7 +745,7 @@ const Subscriptions = () => {
.map((reply, index) => (
<div key={`div-${index}`} style={{display: 'inline-block'}}
ref={el => {
threadBacklinkRefs.current[reply.cid] = el;
backlinkRefs.current[reply.cid] = el;
}}>
<Link key={`ql-${index}`}
to={() => {}} className="quote-link"
@@ -753,7 +754,7 @@ const Subscriptions = () => {
event.stopPropagation();
handleQuoteHover(reply, null, () => {
setOutOfViewCid(reply.cid);
const rect = threadBacklinkRefs.current[reply.cid].getBoundingClientRect();
const rect = backlinkRefs.current[reply.cid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
@@ -829,10 +830,31 @@ const Subscriptions = () => {
reply.content?.length > 500 ?
<Fragment key={`fragment8-${index}`}>
<blockquote key={`pm-${index}`} comment={reply} className="post-message">
<Link to={() => {}} key={`r-pm-${index}`} className="quotelink"
onClick={(event) => handleQuoteClick(reply, shortParentCid, thread.shortCid, event)}
onMouseOver={(event) => handleQuoteHover(reply, shortParentCid, thread.shortCid, event)}
onMouseLeave={removeHighlight}>
<Link to={() => {}} key={`r-pm-${index}`} className="quotelink"
ref={el => {
quoteRefs.current[shortParentCid] = el;
}}
onClick={(event) => handleQuoteClick(reply, shortParentCid, event)}
onMouseOver={(event) => {
event.stopPropagation();
handleQuoteHover(reply, shortParentCid, () => {
if (shortParentCid === thread.shortCid) {
return;
} else {
setOutOfViewCid(reply.parentCid);
console.log("risposta: ", reply.parentCid);
const rect = quoteRefs.current[shortParentCid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
});
}
});
}}
onMouseLeave={() => {
removeHighlight();
setOutOfViewCid(null);
}}>
{`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null}
</Link>
<Post content={reply.content?.slice(0, 500)} key={`post-${index}`} />
@@ -844,10 +866,30 @@ const Subscriptions = () => {
</blockquote>
</Fragment>
: <blockquote key={`pm-${index}`} className="post-message">
<Link to={() => {}} key={`r-pm-${index}`} className="quotelink"
onClick={(event) => handleQuoteClick(reply, shortParentCid, thread.shortCid, event)}
onMouseOver={(event) => handleQuoteHover(reply, shortParentCid, thread.shortCid, event)}
onMouseLeave={removeHighlight}>
<Link to={() => {}} key={`r-pm-${index}`} className="quotelink"
ref={el => {
quoteRefs.current[shortParentCid] = el;
}}
onClick={(event) => handleQuoteClick(reply, shortParentCid, event)}
onMouseOver={(event) => {
event.stopPropagation();
handleQuoteHover(reply, shortParentCid, () => {
if (shortParentCid === thread.shortCid) {
return;
} else {
setOutOfViewCid(reply.parentCid);
const rect = quoteRefs.current[shortParentCid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
});
}
});
}}
onMouseLeave={() => {
removeHighlight();
setOutOfViewCid(null);
}}>
{`c/${shortParentCid}`}{shortParentCid === thread.shortCid ? " (OP)" : null}
</Link>
<Post content={reply.content} key={`post-${index}`} comment={reply} />
+28 -13
View File
@@ -75,7 +75,8 @@ const Thread = () => {
const replyMenuRefs = useRef({});
const postMenuRef = useRef(null);
const postMenuCatalogRef = useRef(null);
const threadBacklinkRefs = useRef({});
const backlinkRefs = useRef({});
const quoteRefs = useRef({});
const postOnHoverRef = useRef(null);
const [triggerPublishComment, setTriggerPublishComment] = useState(false);
@@ -938,7 +939,7 @@ const Thread = () => {
.map((reply, index) => (
<div key={`div-${index}`} style={{display: 'inline-block'}}
ref={el => {
threadBacklinkRefs.current[reply.cid] = el;
backlinkRefs.current[reply.cid] = el;
}}>
<Link key={`ql-${index}`}
to={() => {}} className="quote-link"
@@ -947,7 +948,7 @@ const Thread = () => {
event.stopPropagation();
handleQuoteHover(reply, null, () => {
setOutOfViewCid(reply.cid);
const rect = threadBacklinkRefs.current[reply.cid].getBoundingClientRect();
const rect = backlinkRefs.current[reply.cid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
@@ -1139,7 +1140,7 @@ const Thread = () => {
.map((reply, index) => (
<div key={`div-${index}`} style={{display: 'inline-block'}}
ref={el => {
threadBacklinkRefs.current[reply.cid] = el;
backlinkRefs.current[reply.cid] = el;
}}>
<Link key={`ql-${index}`}
to={() => {}} className="quote-link"
@@ -1148,7 +1149,7 @@ const Thread = () => {
event.stopPropagation();
handleQuoteHover(reply, null, () => {
setOutOfViewCid(reply.cid);
const rect = threadBacklinkRefs.current[reply.cid].getBoundingClientRect();
const rect = backlinkRefs.current[reply.cid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
@@ -1219,18 +1220,32 @@ const Thread = () => {
</div>
) : null}
<blockquote key={`pm-${index}`} className="post-message">
<span style={{cursor: 'pointer'}} className="quote-link"
onClick={(event) => {
handleQuoteClick(reply, shortParentCid, comment.shortCid, event);
<Link to={() => {}} key={`r-pm-${index}`} className="quotelink"
ref={el => {
quoteRefs.current[shortParentCid] = el;
}}
onMouseOver={() => handleQuoteHover(reply, shortParentCid, (cid) => setOutOfViewCid(cid))}
onClick={(event) => handleQuoteClick(reply, shortParentCid, event)}
onMouseOver={(event) => {
event.stopPropagation();
handleQuoteHover(reply, shortParentCid, () => {
if (shortParentCid === comment.shortCid) {
return;
} else {
setOutOfViewCid(reply.parentCid);
const rect = quoteRefs.current[shortParentCid].getBoundingClientRect();
setOutOfViewPosition({
top: rect.top + window.scrollY - rect.height / 2,
left: rect.left + rect.width + 5,
});
}
});
}}
onMouseLeave={() => {
removeHighlight();
setOutOfViewCid(null);
}}
>
{`c/${shortParentCid}`}{shortParentCid === comment.shortCid ? " (OP)" : null}
</span>
}}>
{`c/${shortParentCid}`}{shortParentCid === comment.shortCid ? " (OP)" : null}
</Link>
<Post content={reply.content} comment={reply} key={`post-${index}`} />
<EditLabel key={`edit-label-reply-${index}`}
commentCid={reply.cid}