fix greentext selection

This commit is contained in:
plebeius.eth
2023-06-24 16:36:59 +02:00
parent 79afa78142
commit 31ce77d77d
6 changed files with 64 additions and 4 deletions
+13
View File
@@ -62,6 +62,7 @@ const All = () => {
setSelectedShortCid,
selectedStyle,
setSelectedThread,
setSelectedText,
setSelectedTitle,
setTriggerInsertion,
} = useGeneralStore(state => state);
@@ -706,6 +707,9 @@ const All = () => {
e.preventDefault();
setSelectedThreadCid(thread.cid);
setSelectedAddress(thread.subplebbitAddress);
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(thread.shortCid);
setTriggerInsertion(Date.now());
@@ -991,6 +995,9 @@ const All = () => {
e.preventDefault();
setSelectedThreadCid(thread.cid);
setSelectedAddress(thread.subplebbitAddress);
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(reply.shortCid);
setTriggerInsertion(Date.now());
@@ -1526,6 +1533,9 @@ const All = () => {
e.preventDefault();
setSelectedThreadCid(thread.cid);
setSelectedAddress(thread.subplebbitAddress);
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(thread.shortCid);
setTriggerInsertion(Date.now());
@@ -1704,6 +1714,9 @@ const All = () => {
e.preventDefault();
setSelectedThreadCid(thread.cid);
setSelectedAddress(thread.subplebbitAddress);
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(reply.shortCid);
setTriggerInsertion(Date.now());
+13
View File
@@ -64,6 +64,7 @@ const Board = () => {
setSelectedShortCid,
selectedStyle,
setSelectedThread,
setSelectedText,
selectedTitle, setSelectedTitle,
showPostForm,
showPostFormLink,
@@ -1150,6 +1151,9 @@ const Board = () => {
if (e.button === 2) return;
e.preventDefault();
setSelectedThreadCid(thread.cid);
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(thread.shortCid);
setTriggerInsertion(Date.now());
@@ -1433,6 +1437,9 @@ const Board = () => {
if (e.button === 2) return;
e.preventDefault();
setSelectedThreadCid(thread.cid);
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(reply.shortCid);
setTriggerInsertion(Date.now());
@@ -1939,6 +1946,9 @@ const Board = () => {
if (e.button === 2) return;
e.preventDefault();
setSelectedThreadCid(thread.cid);
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(thread.shortCid);
setTriggerInsertion(Date.now());
@@ -2095,6 +2105,9 @@ const Board = () => {
if (e.button === 2) return;
e.preventDefault();
setSelectedThreadCid(thread.cid);
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(reply.shortCid);
setTriggerInsertion(Date.now());
+13
View File
@@ -62,6 +62,7 @@ const Subscriptions = () => {
setSelectedShortCid,
selectedStyle,
setSelectedThread,
setSelectedText,
setSelectedTitle,
setTriggerInsertion,
} = useGeneralStore(state => state);
@@ -714,6 +715,9 @@ const Subscriptions = () => {
e.preventDefault();
setSelectedThreadCid(thread.cid);
setSelectedAddress(thread.subplebbitAddress);
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(thread.shortCid);
setTriggerInsertion(Date.now());
@@ -999,6 +1003,9 @@ const Subscriptions = () => {
e.preventDefault();
setSelectedThreadCid(thread.cid);
setSelectedAddress(thread.subplebbitAddress);
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(reply.shortCid);
setTriggerInsertion(Date.now());
@@ -1534,6 +1541,9 @@ const Subscriptions = () => {
e.preventDefault();
setSelectedThreadCid(thread.cid);
setSelectedAddress(thread.subplebbitAddress);
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(thread.shortCid);
setTriggerInsertion(Date.now());
@@ -1712,6 +1722,9 @@ const Subscriptions = () => {
e.preventDefault();
setSelectedThreadCid(thread.cid);
setSelectedAddress(thread.subplebbitAddress);
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(reply.shortCid);
setTriggerInsertion(Date.now());
+13
View File
@@ -63,6 +63,7 @@ const Thread = () => {
setSelectedShortCid,
selectedStyle,
selectedThread, setSelectedThread,
setSelectedText,
selectedTitle, setSelectedTitle,
showPostForm,
showPostFormLink,
@@ -844,6 +845,9 @@ const Thread = () => {
<span>c/</span>
<Link to={() => {}} id="reply-button" style={{ cursor: 'pointer' }}
onClick={() => {
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(comment.shortCid);
setTriggerInsertion(Date.now());
@@ -1085,6 +1089,9 @@ const Thread = () => {
{reply.shortCid ? (
<Link id="reply-button" key={`pl2-${index}`}
onClick={() => {
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(reply.shortCid);
setTriggerInsertion(Date.now());
@@ -1463,6 +1470,9 @@ const Thread = () => {
<span key={`mob-no-${comment.cid}`}>c/</span>
<Link to={() => {}} id="reply-button" key={`mob-no2-${comment.cid}`} title="Reply to this post"
onClick={() => {
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(comment.shortCid);
setTriggerInsertion(Date.now());
@@ -1588,6 +1598,9 @@ const Thread = () => {
{reply.shortCid ? (
<Link id="reply-button" key={`mob-pl2-${index}`}
onClick={() => {
let text = document.getSelection().toString();
text = text ? `>${text}` : text;
setSelectedText(text);
if (isReplyOpen) {
setReplyQuoteCid(reply.shortCid);
setTriggerInsertion(Date.now());