- Timestamp:
- 12/30/2013 01:53:25 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js
r26876 r26880 14 14 15 15 // Check if the `wp.mce` API exists. 16 if ( typeof wp === 'undefined' || ! wp.mce ) 16 if ( typeof wp === 'undefined' || ! wp.mce ) { 17 17 return; 18 } 18 19 19 20 editor.on( 'PreInit', function() { … … 27 28 // we'll wait to render the views. 28 29 editor.on( 'BeforeSetContent', function( e ) { 29 if ( ! e.content ) 30 if ( ! e.content ) { 30 31 return; 32 } 31 33 32 34 e.content = wp.mce.view.toViews( e.content ); … … 43 45 // When a view is selected, ensure content that is being pasted 44 46 // or inserted is added to a text node (instead of the view). 45 editor.on( 'BeforeSetContent', function( e) {47 editor.on( 'BeforeSetContent', function() { 46 48 var walker, target, 47 49 view = wpView.getParentView( selection.getNode() ); 48 50 49 51 // If the selection is not within a view, bail. 50 if ( ! view ) 52 if ( ! view ) { 51 53 return; 54 } 52 55 53 56 // If there are no additional nodes or the next node is a … … 73 76 // Runs on paste and on inserting nodes/html. 74 77 editor.on( 'SetContent', function( e ) { 75 if ( ! e.context ) 78 if ( ! e.context ) { 76 79 return; 80 } 77 81 78 82 var node = selection.getNode(); 79 83 80 if ( ! node.innerHTML ) 84 if ( ! node.innerHTML ) { 81 85 return; 86 } 82 87 83 88 node.innerHTML = wp.mce.view.toViews( node.innerHTML ); … … 89 94 // transform any views back to their text representations. 90 95 editor.on( 'PostProcess', function( e ) { 91 if ( ( ! e.get && ! e.save ) || ! e.content ) 96 if ( ( ! e.get && ! e.save ) || ! e.content ) { 92 97 return; 98 } 93 99 94 100 e.content = wp.mce.view.toText( e.content ); … … 98 104 // Add the event handler to the top of the stack. 99 105 editor.on( 'NodeChange', function( e ) { 100 var view = wpView.getParentView( node);106 var view = wpView.getParentView( e.element ); 101 107 102 108 // Update the selected view. … … 118 124 119 125 // If a view isn't selected, let the event go on its merry way. 120 if ( ! selected ) 126 if ( ! selected ) { 121 127 return; 128 } 122 129 123 130 // If the caret is not within the selected view, deselect the 124 131 // view and bail. 125 view = wpView.getParentView( selection.getNode() );132 view = wpView.getParentView( editor.selection.getNode() ); 126 133 if ( view !== selected ) { 127 134 wpView.deselect(); … … 139 146 // Let keypresses that involve the command or control keys through. 140 147 // Also, let any of the F# keys through. 141 if ( event.metaKey || event.ctrlKey || ( keyCode >= 112 && keyCode <= 123 ) ) 148 if ( event.metaKey || event.ctrlKey || ( keyCode >= 112 && keyCode <= 123 ) ) { 142 149 return; 150 } 143 151 144 152 event.preventDefault(); … … 148 156 getParentView : function( node ) { 149 157 while ( node ) { 150 if ( this.isView( node ) ) 158 if ( this.isView( node ) ) { 151 159 return node; 160 } 152 161 153 162 node = node.parentNode; … … 160 169 161 170 select : function( view ) { 162 if ( view === selected ) 171 if ( view === selected ) { 163 172 return; 173 } 164 174 165 175 this.deselect(); … … 169 179 170 180 deselect : function() { 171 if ( selected ) 181 if ( selected ) { 172 182 wp.mce.view.deselect( selected ); 183 } 184 173 185 selected = null; 174 186 }
Note: See TracChangeset
for help on using the changeset viewer.