Make WordPress Core

Changeset 29183


Ignore:
Timestamp:
07/16/2014 12:09:58 AM (10 years ago)
Author:
azaozz
Message:

TinyMCE wpView:

  • Cast off commands targeted to a view except undo, redo, RemoveFormat and mceToggleFormat (bold, italic, etc.).
  • Disable the link and unlink buttons when a view is selected.

Props avryl, see #28595

Location:
trunk/src/wp-includes/js/tinymce/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/tinymce/plugins/wplink/plugin.js

    r28185 r29183  
    1616
    1717    function setState( button, node ) {
    18         var parent = editor.dom.getParent( node, 'a' );
     18        var parent = editor.dom.getParent( node, 'a' ),
     19            getView = editor.plugins.wpview ? editor.plugins.wpview.getView : function() { return false; };
    1920
    20         button.disabled( ( editor.selection.isCollapsed() && ! parent ) || ( parent && ! parent.href ) );
     21        button.disabled( ( editor.selection.isCollapsed() && ! parent ) || ( parent && ! parent.href ) || getView( node ) );
    2122        button.active( parent && parent.href );
    2223    }
  • trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js

    r29182 r29183  
    11/* global tinymce */
     2
    23/**
    34 * WordPress View plugin.
     
    2223    function getParent( node, className ) {
    2324        while ( node && node.parentNode ) {
    24             if ( node.className && (' ' + node.className + ' ').indexOf(' ' + className + ' ') !== -1 ) {
     25            if ( node.className && ( ' ' + node.className + ' ' ).indexOf( ' ' + className + ' ' ) !== -1 ) {
    2526                return node;
    2627            }
     
    564565    } );
    565566
    566     editor.on( 'nodechange', function( event ) {
     567    editor.on( 'NodeChange', function( event ) {
    567568        var dom = editor.dom,
    568569            views = editor.dom.select( '.wpview-wrap' ),
     
    618619    });
    619620
    620     editor.on( 'resolvename', function( event ) {
     621    editor.on( 'BeforeExecCommand', function( event ) {
     622        var cmd = event.command,
     623            view;
     624
     625        if ( cmd === 'undo' || cmd === 'redo' || cmd === 'RemoveFormat' || cmd === 'mceToggleFormat' ) {
     626            return;
     627        }
     628
     629        if ( view = getView( editor.selection.getNode() ) ) {
     630            handleEnter( view );
     631        }
     632    });
     633
     634    editor.on( 'ResolveName', function( event ) {
    621635        if ( editor.dom.hasClass( event.target, 'wpview-wrap' ) ) {
    622636            event.name = editor.dom.getAttrib( event.target, 'data-wpview-type' ) || 'wpview';
Note: See TracChangeset for help on using the changeset viewer.