setMarkers: function( content ) {
var pieces = [ { content: content } ],
self = this,
- instance,
- current;
+ instance, current;
_.each( views, function( view, type ) {
current = pieces.slice();
_.each( current, function( piece ) {
var remaining = piece.content,
- result;
+ result, text;
// Ignore processed pieces, but retain their location.
if ( piece.processed ) {
}
instance = self.createInstance( type, result.content, result.options );
+ text = instance.loader ? '.' : instance.text;
// Add the processed piece for the match.
pieces.push( {
- content: '<p data-wpview-marker="' + instance.encodedText + '">' + instance.text + '</p>',
+ content: '<p data-wpview-marker="' + instance.encodedText + '">' + text + '</p>',
processed: true
} );
} );
} );
- return _.pluck( pieces, 'content' ).join( '' );
+ content = _.pluck( pieces, 'content' ).join( '' );
+ return content.replace( /<p>\s*<p data-wpview-marker=/g, '<p data-wpview-marker=' ).replace( /<\/p>\s*<\/p>/g, '</p>' );
},
/**
encodedText,
instance;
- text = tinymce.DOM.decode( text ),
- encodedText = encodeURIComponent( text ),
- instance = this.getInstance( encodedText );
+ text = tinymce.DOM.decode( text );
+ instance = this.getInstance( text );
if ( instance ) {
return instance;
}
+ encodedText = encodeURIComponent( text );
+
options = _.extend( options || {}, {
text: text,
encodedText: encodedText
*/
replaceMarkers: function() {
this.getMarkers( function( editor, node ) {
- if ( $( node ).text() !== this.text ) {
+ if ( ! this.loader && $( node ).text() !== this.text ) {
editor.dom.setAttrib( node, 'data-wpview-marker', null );
return;
}