Skip to content
Merged
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
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ module.exports = function( grunt ) {
'js-tests/vendor/underscore.js',
'js-tests/vendor/backbone.js',
'js-tests/vendor/wp-util.js',
'js-tests/vendor/wp-editors.js',
'js-tests/vendor/mock-ajax.js',
],
}
Expand Down
2 changes: 1 addition & 1 deletion dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<section class="pullquote" style="padding: 20px; background: rgba(0,0,0,0.1);">
<p style="margin:0; padding: 0;">
<b>Content:</b> <?php echo esc_html( $content ); ?></br>
<b>Content:</b> <?php echo wpautop( wp_kses_post( $content ) ); ?></br>
<b>Source:</b> <?php echo esc_html( $attr['source'] ); ?></br>
<b>Image:</b> <?php echo wp_get_attachment_image( $attr['attachment'], array( 50, 50 ) ); ?></br>
</p>
Expand Down
31 changes: 25 additions & 6 deletions js-tests/build/specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ describe( "MCE View Constructor", function() {
});

it( 'parses shortcode with content', function() {
var shortcode = MceViewConstructor.parseShortcodeString( '[test_shortcode attr="test value 1"]test content [/test_shortcode]')
var shortcode = MceViewConstructor.parseShortcodeString( '[test_shortcode attr="test value 1"]test content[/test_shortcode]')
expect( shortcode instanceof Shortcode ).toEqual( true );
expect( shortcode.get( 'attrs' ).findWhere( { attr: 'attr' }).get('value') ).toEqual( 'test value 1' );
expect( shortcode.get( 'inner_content' ).get('value') ).toEqual( 'test content ' );
expect( shortcode.get( 'inner_content' ).get('value') ).toEqual( 'test content' );
});

it( 'parses shortcode with dashes in name and attribute', function() {
Expand All @@ -263,10 +263,16 @@ describe( "MCE View Constructor", function() {
});

// https://github.com/fusioneng/Shortcake/issues/171
xit( 'parses shortcode with line breaks in inner content', function() {
var shortcode = MceViewConstructor.parseShortcodeString( "[test_shortcode]test \ncontent \r2 [/test_shortcode]")
it( 'parses shortcode with line breaks in inner content', function() {
var shortcode = MceViewConstructor.parseShortcodeString( "[test_shortcode]test \ntest \rtest[/test_shortcode]")
expect( shortcode instanceof Shortcode ).toEqual( true );
expect( shortcode.get( 'inner_content' ).get('value') ).toEqual( "test \ncontent \r2 " );
expect( shortcode.get( 'inner_content' ).get('value') ).toEqual( "test \ntest \rtest" );
} );

it( 'parses shortcode with paragraph and br tags in inner content', function() {
var shortcode = MceViewConstructor.parseShortcodeString( "[test_shortcode]<p>test</p><p>test<br/>test</p>[/test_shortcode]")
expect( shortcode instanceof Shortcode ).toEqual( true );
expect( shortcode.get( 'inner_content' ).get('value') ).toEqual( "test\n\ntest\ntest" );
} );

it( 'parses shortcode with unquoted attributes', function() {
Expand Down Expand Up @@ -658,13 +664,26 @@ var shortcodeViewConstructor = {

if ( matches[3] ) {
var inner_content = currentShortcode.get( 'inner_content' );
inner_content.set( 'value', matches[3] );
inner_content.set( 'value', this.unAutoP( matches[3] ) );
}

return currentShortcode;

},

/**
* Strip 'p' and 'br' tags, replace with line breaks.
* Reverse the effect of the WP editor autop functionality.
*/
unAutoP: function( content ) {
if ( switchEditors && switchEditors.pre_wpautop ) {
content = switchEditors.pre_wpautop( content );
}

return content;

},

// Backwards compatability for Pre WP 4.2.
View: {

Expand Down
16 changes: 11 additions & 5 deletions js-tests/src/utils/mceViewConstructorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ describe( "MCE View Constructor", function() {
});

it( 'parses shortcode with content', function() {
var shortcode = MceViewConstructor.parseShortcodeString( '[test_shortcode attr="test value 1"]test content [/test_shortcode]')
var shortcode = MceViewConstructor.parseShortcodeString( '[test_shortcode attr="test value 1"]test content[/test_shortcode]')
expect( shortcode instanceof Shortcode ).toEqual( true );
expect( shortcode.get( 'attrs' ).findWhere( { attr: 'attr' }).get('value') ).toEqual( 'test value 1' );
expect( shortcode.get( 'inner_content' ).get('value') ).toEqual( 'test content ' );
expect( shortcode.get( 'inner_content' ).get('value') ).toEqual( 'test content' );
});

it( 'parses shortcode with dashes in name and attribute', function() {
Expand All @@ -134,10 +134,16 @@ describe( "MCE View Constructor", function() {
});

// https://github.com/fusioneng/Shortcake/issues/171
xit( 'parses shortcode with line breaks in inner content', function() {
var shortcode = MceViewConstructor.parseShortcodeString( "[test_shortcode]test \ncontent \r2 [/test_shortcode]")
it( 'parses shortcode with line breaks in inner content', function() {
var shortcode = MceViewConstructor.parseShortcodeString( "[test_shortcode]test \ntest \rtest[/test_shortcode]")
expect( shortcode instanceof Shortcode ).toEqual( true );
expect( shortcode.get( 'inner_content' ).get('value') ).toEqual( "test \ncontent \r2 " );
expect( shortcode.get( 'inner_content' ).get('value') ).toEqual( "test \ntest \rtest" );
} );

it( 'parses shortcode with paragraph and br tags in inner content', function() {
var shortcode = MceViewConstructor.parseShortcodeString( "[test_shortcode]<p>test</p><p>test<br/>test</p>[/test_shortcode]")
expect( shortcode instanceof Shortcode ).toEqual( true );
expect( shortcode.get( 'inner_content' ).get('value') ).toEqual( "test\n\ntest\ntest" );
} );

it( 'parses shortcode with unquoted attributes', function() {
Expand Down
Loading