Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Option: Avoid Repeated Backlinks when Quoting Text #3263

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/Posting/QR.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ QR =
{root} = post.nodes
postRange = new Range()
postRange.selectNode root
text = if post.board.ID is g.BOARD.ID then ">>#{post}\n" else ">>>/#{post.board}/#{post}\n"
quoteBacklink = if post.board.ID is g.BOARD.ID then ">>#{post}\n" else ">>>/#{post.board}/#{post}\n"
quoteText = ""
for i in [0...sel.rangeCount]
range = sel.getRangeAt i
# Trim range to be fully inside post
Expand Down Expand Up @@ -323,12 +324,20 @@ QR =
for node in $$ '.embedder', frag
$.rm node.previousSibling if node.previousSibling?.nodeValue is ' '
$.rm node
text += ">#{frag.textContent.trim()}\n"
quoteText = ">#{frag.textContent.trim()}\n"

QR.openPost()
{com, thread} = QR.nodes
thread.value = Get.threadFromNode @ unless com.value

text = quoteBacklink
if quoteText != ""
alreadyQuoted = com.value.includes quoteBacklink
if !Conf['Avoid Duplicated Quotes'] or !alreadyQuoted
text = quoteBacklink + quoteText
else
text = quoteText

wasOnlyQuotes = QR.selected.isOnlyQuotes()

caretPos = com.selectionStart
Expand Down
4 changes: 4 additions & 0 deletions src/config/Config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,10 @@ Config =
true
'Add option in header menu to thread conversations.'
]
'Avoid Duplicated Quotes': [
false
'Avoid adding duplicate instances of a given post number when quoting with selected text'
]

imageExpansion:
'Fit width': [
Expand Down