TinyMCE: improve handling of Read More and Nextpage tags. See #24067, fixes #16239.

Built from https://develop.svn.wordpress.org/trunk@26941


git-svn-id: http://core.svn.wordpress.org/trunk@26821 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2014-01-14 05:46:11 +00:00
parent f49bd78ae4
commit 88959be27d
5 changed files with 39 additions and 7 deletions

View File

@ -643,7 +643,7 @@ function edButton(id, display, tagStart, tagEnd, access) {
edButtons[90] = new qt.TagButton('ol','ol','<ol>\n','</ol>\n\n','o'),
edButtons[100] = new qt.TagButton('li','li','\t<li>','</li>\n','l'),
edButtons[110] = new qt.TagButton('code','code','<code>','</code>','c'),
edButtons[120] = new qt.TagButton('more','more','<!--more-->','','t'),
edButtons[120] = new qt.TagButton('more','more','\n\n<!--more-->\n\n','','t'),
edButtons[140] = new qt.CloseButton();
})();

File diff suppressed because one or more lines are too long

View File

@ -126,20 +126,43 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
}
});
// Make sure the "more" tag is in a separate paragraph
editor.on( 'PreProcess', function( event ) {
var more;
if ( event.save ) {
more = editor.dom.select( 'img.wp-more-tag', event.node );
if ( more.length ) {
tinymce.each( more, function( node ) {
var parent = node.parentNode, p;
if ( parent.nodeName === 'P' && parent.childNodes.length > 1 ) {
p = editor.dom.create('p');
parent.parentNode.insertBefore( p, parent );
p.appendChild( node );
}
});
}
}
});
// Register commands
editor.addCommand( 'WP_More', function( tag ) {
var parent, html, title,
var parent, html, title, p1, p2,
classname = 'wp-more-tag',
spacer = tinymce.Env.ie ? '' : '<br data-mce-bogus="1" />',
dom = editor.dom,
node = editor.selection.getNode();
tag = tag || 'more';
classname += ' mce-wp-' + tag;
title = tag === 'more' ? 'More...' : 'Next Page';
html = '<img src="' + tinymce.Env.transparentSrc + '" title="' + title + '" class="' + classname + '" data-mce-resize="false" data-mce-placeholder="1" />';
html = '<img src="' + tinymce.Env.transparentSrc + '" title="' + title + '" class="' + classname + '" ' +
'data-mce-resize="false" data-mce-placeholder="1" />';
if ( node.nodeName === 'BODY' ) {
editor.insertContent( '<p>' + html + '</p>' );
editor.insertContent( '<p>' + html + '</p><p></p>' );
return;
}
@ -153,7 +176,16 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
}, editor.getBody() );
if ( parent ) {
dom.insertAfter( dom.create( 'p', null, html ), parent );
p1 = dom.create( 'p', null, html );
dom.insertAfter( p1, parent );
if ( ! ( p2 = p1.nextSibling ) ) {
p2 = dom.create( 'p', null, spacer );
dom.insertAfter( p2, p1 );
}
editor.nodeChanged();
editor.selection.setCursorLocation( p2, 0 );
}
});

File diff suppressed because one or more lines are too long