From ad8755aa7049447c6e1174e0f1306543d2f74baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 15 Jan 2014 00:53:06 +0100 Subject: [PATCH] BUGFIX: inline spoiler for text, block spoiler for images --- .../discourse/dialects/bbcode_dialect.js | 22 +++++++++++-------- spec/components/pretty_text_spec.rb | 8 +++++-- test/javascripts/lib/bbcode_test.js | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/discourse/dialects/bbcode_dialect.js b/app/assets/javascripts/discourse/dialects/bbcode_dialect.js index 3222747ca9e..9cdb9de55be 100644 --- a/app/assets/javascripts/discourse/dialects/bbcode_dialect.js +++ b/app/assets/javascripts/discourse/dialects/bbcode_dialect.js @@ -78,6 +78,19 @@ Discourse.Dialect.inlineBetween({ emitter: function(contents) { return ['a', {href: contents, 'data-bbcode': true}, contents]; } }); +Discourse.Dialect.inlineBetween({ + start: '[spoiler]', + stop: '[/spoiler]', + rawContents: true, + emitter: function(contents) { + if (/hello @bob's @bob,@bob; @bob\"

" end - it 'should add spoiler tags' do - PrettyText.cook("[spoiler]hello[/spoiler]").should match_html "

hello

" + it 'should spoiler text' do + PrettyText.cook("[spoiler]hello[/spoiler]").should match_html "

hello

" + end + + it 'should spoiler img' do + PrettyText.cook("[spoiler][/spoiler]").should match_html "

" end end diff --git a/test/javascripts/lib/bbcode_test.js b/test/javascripts/lib/bbcode_test.js index 70cda0b6e21..d1b059180f3 100644 --- a/test/javascripts/lib/bbcode_test.js +++ b/test/javascripts/lib/bbcode_test.js @@ -30,7 +30,7 @@ test('code', function() { }); test('spoiler', function() { - format("[spoiler]it's a sled[/spoiler]", "
it's a sled
", "supports spoiler tags on text"); + format("[spoiler]it's a sled[/spoiler]", "it's a sled", "supports spoiler tags on text"); format("[spoiler][/spoiler]", "
", "supports spoiler tags on images"); });