Quoting now also includes the spoiler and code tags.
This commit is contained in:
parent
5ca21b1f4a
commit
f456495160
@ -168,12 +168,28 @@ QR =
|
|||||||
e?.preventDefault()
|
e?.preventDefault()
|
||||||
return unless QR.postingIsEnabled
|
return unless QR.postingIsEnabled
|
||||||
|
|
||||||
sel = d.getSelection()
|
sel = d.getSelection()
|
||||||
post = Get.postFromNode @
|
post = Get.postFromNode @
|
||||||
text = ">>#{post}\n"
|
text = ">>#{post}\n"
|
||||||
if (s = sel.toString().trim()) and post is Get.postFromNode sel.anchorNode
|
if sel.toString().trim() and post is Get.postFromNode sel.anchorNode
|
||||||
s = s.replace /\n/g, '\n>'
|
range = sel.getRangeAt()
|
||||||
text += ">#{s}\n"
|
frag = range.cloneContents()
|
||||||
|
ancestor = range.commonAncestorContainer
|
||||||
|
if ancestor.nodeName is '#text'
|
||||||
|
# Quoting the insides of a spoiler/code tag.
|
||||||
|
if $.x 'ancestor::s', ancestor
|
||||||
|
$.prepend frag, $.tn '[spoiler]'
|
||||||
|
$.add frag, $.tn '[/spoiler]'
|
||||||
|
if $.x 'ancestor::pre[contains(@class,"prettyprint")]', ancestor
|
||||||
|
$.prepend frag, $.tn '[code]'
|
||||||
|
$.add frag, $.tn '[/code]'
|
||||||
|
for node in $$ 'br', frag
|
||||||
|
$.replace node, $.tn '\n>'
|
||||||
|
for node in $$ 's', frag
|
||||||
|
$.replace node, [$.tn('[spoiler]'), node.childNodes..., $.tn '[/spoiler]']
|
||||||
|
for node in $$ '.prettyprint', frag
|
||||||
|
$.replace node, [$.tn('[code]'), node.childNodes..., $.tn '[/code]']
|
||||||
|
text += ">#{frag.textContent.trim()}\n"
|
||||||
|
|
||||||
QR.open()
|
QR.open()
|
||||||
if QR.selected.isLocked
|
if QR.selected.isLocked
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user