[wp-trac] [WordPress Trac] #28458: wp.mce.view: simplify things a bit

WordPress Trac noreply at wordpress.org
Thu Jun 5 18:55:25 UTC 2014

#28458: wp.mce.view: simplify things a bit
 Reporter:  avryl         |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  4.0
Component:  TinyMCE       |     Version:  3.9
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:  javascript

Comment (by gcorne):

 Everything seems to be working after [28680], but I have a couple thoughts
 on the code changes:

 1. I think that the {{{type}}} property should be reverted to shortcode.
 It can still default to being identical to the {{{type}}} as passed into

 2. I don't think that the creation of the wpview View constructor should
 be done in {{{register()}}}. Doing so takes some control away from the
 code registering the wpview.

 3. I wonder if we should rename the parameter {{{constructor}}} to
 {{{wpview}}}. The parameter isn't really a {{{constructor}}}; it's is a
 module expressed in the form of an object literal. The hard part is coming
 up with a name since there are two different types of views: 1) the wpview
 (aka content block?) and 2) the View that used to construct an individual
 instance of a wpview that is tied to a particular shortcode or other
 substring from the post content. Since the tinymce plugin is named
 {{{wpview}}} maybe that works?

 So {{{register()}}} would end up looking something like:

         register: function( type, wpview ) {
                 var defaults = {
                         shortcode: type,
                         View: {},
                         toView: function( content ) {
                                 var match = wp.shortcode.next(
 this.shortcode, content );
                                 if ( ! match ) {
                                 return {
                                         index: match.index,
                                         content: match.content,
                                         options: {
                                                 shortcode: match.shortcode

                 wpview = _.defaults( wpview, defaults );

                 views[ type ] = wpview;

 And, the other bits would be adjusted accordingly.

Ticket URL: <https://core.trac.wordpress.org/ticket/28458#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list