Support [spoiler] and [code] tags in 'Copy Text' menu item.
This commit is contained in:
parent
59b64a2a20
commit
fe6a8336fa
@ -12,7 +12,7 @@ CopyTextLink =
|
||||
el: a
|
||||
order: 12
|
||||
open: (post) ->
|
||||
CopyTextLink.text = post.info.comment
|
||||
CopyTextLink.text = post.commentOrig()
|
||||
true
|
||||
|
||||
copy: ->
|
||||
|
||||
@ -313,10 +313,7 @@ QR =
|
||||
$.replace node, $.tn '\n'
|
||||
for node in $$ 'br', frag
|
||||
$.replace node, $.tn '\n>' unless node is frag.lastChild
|
||||
for node in $$ 's, .removed-spoiler', frag
|
||||
$.replace node, [$.tn('[spoiler]'), node.childNodes..., $.tn '[/spoiler]']
|
||||
for node in $$ '.prettyprint', frag
|
||||
$.replace node, [$.tn('[code]'), node.childNodes..., $.tn '[/code]']
|
||||
Post::insertTags frag
|
||||
for node in $$ '.linkify[data-original]', frag
|
||||
$.replace node, $.tn node.dataset.original
|
||||
for node in $$ '.embedder', frag
|
||||
|
||||
@ -129,6 +129,12 @@ class Post
|
||||
@cleanCommentDisplay bq
|
||||
@nodesToText(bq).trim().replace(/\s+$/gm, '')
|
||||
|
||||
commentOrig: ->
|
||||
# Get the comment's text for reposting purposes.
|
||||
bq = @nodes.commentClean.cloneNode true
|
||||
@insertTags bq
|
||||
@nodesToText bq
|
||||
|
||||
nodesToText: (bq) ->
|
||||
text = ""
|
||||
nodes = $.X './/br|.//text()', bq
|
||||
@ -155,6 +161,13 @@ class Post
|
||||
$.rm b if (b = $ 'b', bq) and /^Rolled /.test(b.textContent)
|
||||
$.rm $('.fortune', bq)
|
||||
|
||||
insertTags: (bq) ->
|
||||
for node in $$ 's, .removed-spoiler', bq
|
||||
$.replace node, [$.tn('[spoiler]'), node.childNodes..., $.tn '[/spoiler]']
|
||||
for node in $$ '.prettyprint', bq
|
||||
$.replace node, [$.tn('[code]'), node.childNodes..., $.tn '[/code]']
|
||||
return
|
||||
|
||||
parseQuotes: ->
|
||||
@quotes = []
|
||||
# XXX https://github.com/4chan/4chan-JS/issues/77
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user