Skip to content

Commit

Permalink
quote selected text if any, otherwise quote whole item
Browse files Browse the repository at this point in the history
  • Loading branch information
SatsAllDay committed Sep 27, 2023
1 parent 64ca88e commit 291ca7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/action-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function ActionDropdown ({ children }) {
}
return (
<Dropdown className={`pointer ${styles.dropdown}`} as='span'>
<Dropdown.Toggle variant='success' as='a'>
<Dropdown.Toggle variant='success' as='a' onMouseDown={e => e.preventDefault()}>
<MoreIcon className='fill-grey ms-1' height={16} width={16} />
</Dropdown.Toggle>
<Dropdown.Menu>
Expand Down
6 changes: 4 additions & 2 deletions components/reply.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ export default forwardRef(function Reply ({ item, onSuccess, replyOpen, children
if (!reply) {
setReply(true)
}
const selection = window.getSelection()
const textToQuote = selection.isCollapsed ? item.text : selection.toString()
let updatedValue
if (formInnerRef.current && formInnerRef.current.values && !formInnerRef.current.values.text) {
updatedValue = quote(item.text)
updatedValue = quote(textToQuote)
} else if (formInnerRef.current?.values?.text) {
// append quote reply text if the input already has content
updatedValue = `${replyInput.current.value}\n${quote(item.text)}`
updatedValue = `${replyInput.current.value}\n${quote(textToQuote)}`
}
if (updatedValue) {
replyInput.current.value = updatedValue
Expand Down

0 comments on commit 291ca7a

Please sign in to comment.