<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[29463] trunk/src/wp-includes: TinyMCE: update wpview and editimage plugins for 4.1.3.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/29463">29463</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2014-08-10 04:21:46 +0000 (Sun, 10 Aug 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>TinyMCE: update wpview and editimage plugins for 4.1.3. Add show/hide of the Edit and Delete buttons on views and images on 'touchend'. See <a href="http://core.trac.wordpress.org/ticket/28595">#28595</a>, <a href="http://core.trac.wordpress.org/ticket/29166">#29166</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludescssmediaviewscss">trunk/src/wp-includes/css/media-views.css</a></li>
<li><a href="#trunksrcwpincludesjstinymcepluginswpeditimagepluginjs">trunk/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js</a></li>
<li><a href="#trunksrcwpincludesjstinymcepluginswpviewpluginjs">trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludescssmediaviewscss"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/css/media-views.css (29462 => 29463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/css/media-views.css 2014-08-10 02:43:07 UTC (rev 29462)
+++ trunk/src/wp-includes/css/media-views.css 2014-08-10 04:21:46 UTC (rev 29463)
</span><span class="lines">@@ -1787,6 +1787,8 @@
</span><span class="cx">
</span><span class="cx"> .image-details .embed-media-settings,
</span><span class="cx"> .image-details .embed-media-settings div {
</span><ins>+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
</ins><span class="cx"> box-sizing: border-box;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2319,6 +2321,7 @@
</span><span class="cx"> margin: 11px 0 0;
</span><span class="cx"> height: auto;
</span><span class="cx"> max-width: 65%;
</span><ins>+ max-width: -webkit-calc(100% - 38px);
</ins><span class="cx"> max-width: calc(100% - 38px);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2359,6 +2362,8 @@
</span><span class="cx"> z-index: 1900;
</span><span class="cx"> max-width: 70%;
</span><span class="cx"> bottom: 120%;
</span><ins>+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
</ins><span class="cx"> box-sizing: border-box;
</span><span class="cx"> padding-bottom: 0;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunksrcwpincludesjstinymcepluginswpeditimagepluginjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js (29462 => 29463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js 2014-08-10 02:43:07 UTC (rev 29462)
+++ trunk/src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js 2014-08-10 04:21:46 UTC (rev 29463)
</span><span class="lines">@@ -435,12 +435,14 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> editor.selection.collapse( true );
</span><del>- editor.nodeChanged();
</del><span class="cx"> editor.dom.remove( wrap );
</span><span class="cx"> } else {
</span><span class="cx"> editor.dom.remove( node );
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> removeToolbar();
</span><ins>+ editor.nodeChanged();
+ editor.undoManager.add();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function addToolbar( node ) {
</span><span class="lines">@@ -457,12 +459,12 @@
</span><span class="cx"> dom.setAttrib( node, 'data-wp-imgselect', 1 );
</span><span class="cx"> rectangle = dom.getRect( node );
</span><span class="cx">
</span><del>- toolbarHtml = '<i class="dashicons dashicons-edit edit" data-mce-bogus="1"></i>' +
- '<i class="dashicons dashicons-no-alt remove" data-mce-bogus="1"></i>';
</del><ins>+ toolbarHtml = '<i class="dashicons dashicons-edit edit" data-mce-bogus="all"></i>' +
+ '<i class="dashicons dashicons-no-alt remove" data-mce-bogus="all"></i>';
</ins><span class="cx">
</span><span class="cx"> toolbar = dom.create( 'p', {
</span><span class="cx"> 'id': 'wp-image-toolbar',
</span><del>- 'data-mce-bogus': '1',
</del><ins>+ 'data-mce-bogus': 'all',
</ins><span class="cx"> 'contenteditable': false
</span><span class="cx"> }, toolbarHtml );
</span><span class="cx">
</span><span class="lines">@@ -927,7 +929,7 @@
</span><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx">
</span><del>- editor.on( 'mouseup', function( event ) {
</del><ins>+ editor.on( 'mouseup touchend', function( event ) {
</ins><span class="cx"> var image,
</span><span class="cx"> node = event.target,
</span><span class="cx"> dom = editor.dom;
</span><span class="lines">@@ -956,12 +958,23 @@
</span><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx">
</span><del>- // Remove toolbar from undo levels
</del><ins>+ // Remove from undo levels
</ins><span class="cx"> editor.on( 'BeforeAddUndo', function( event ) {
</span><del>- event.level.content = event.level.content.replace( /<p [^>]*data-mce-bogus[^>]+>[\s\S]*?<\/p>/g, '' );
</del><ins>+ event.level.content = event.level.content.replace( / data-wp-imgselect="1"/g, '' );
</ins><span class="cx"> });
</span><span class="cx">
</span><del>- editor.on( 'cut', function() {
</del><ins>+ // After undo/redo FF seems to set the image height very slowly when it is set to 'auto' in the CSS.
+ // This causes image.getBoundingClientRect() to return wrong values and the resize handles are shown in wrong places.
+ // Collapse the selection to remove the resize handles.
+ if ( tinymce.Env.gecko ) {
+ editor.on( 'undo redo', function() {
+ if ( editor.selection.getNode().nodeName === 'IMG' ) {
+ editor.selection.collapse();
+ }
+ });
+ }
+
+ editor.on( 'cut wpview-selected', function() {
</ins><span class="cx"> removeToolbar();
</span><span class="cx"> });
</span><span class="cx">
</span></span></pre></div>
<a id="trunksrcwpincludesjstinymcepluginswpviewpluginjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js (29462 => 29463)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js 2014-08-10 02:43:07 UTC (rev 29462)
+++ trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js 2014-08-10 04:21:46 UTC (rev 29463)
</span><span class="lines">@@ -11,6 +11,7 @@
</span><span class="cx"> toRemove = false,
</span><span class="cx"> firstFocus = true,
</span><span class="cx"> _noop = function() { return false; },
</span><ins>+ isTouchDevice = ( 'ontouchend' in document ),
</ins><span class="cx"> cursorInterval, lastKeyDownNode, setViewCursorTries, focus, execCommandView;
</span><span class="cx">
</span><span class="cx"> function getView( node ) {
</span><span class="lines">@@ -140,8 +141,14 @@
</span><span class="cx"> dom.bind( selected, 'beforedeactivate focusin focusout', _stop );
</span><span class="cx">
</span><span class="cx"> // select the hidden div
</span><del>- editor.selection.select( clipboard, true );
</del><ins>+ if ( isTouchDevice ) {
+ editor.selection.select( clipboard );
+ } else {
+ editor.selection.select( clipboard, true );
+ }
+
</ins><span class="cx"> editor.nodeChanged();
</span><ins>+ editor.fire( 'wpview-selected', viewNode );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -256,7 +263,8 @@
</span><span class="cx"> });
</span><span class="cx">
</span><span class="cx"> editor.on( 'init', function() {
</span><del>- var selection = editor.selection;
</del><ins>+ var scrolled = false,
+ selection = editor.selection;
</ins><span class="cx">
</span><span class="cx"> // When a view is selected, ensure content that is being pasted
</span><span class="cx"> // or inserted is added to a text node (instead of the view).
</span><span class="lines">@@ -285,16 +293,22 @@
</span><span class="cx"> selection.collapse( true );
</span><span class="cx"> });
</span><span class="cx">
</span><del>- editor.dom.bind( editor.getBody().parentNode, 'mousedown mouseup click', function( event ) {
- var view = getView( event.target );
</del><ins>+ editor.dom.bind( editor.getDoc(), 'touchmove', function() {
+ scrolled = true;
+ });
</ins><span class="cx">
</span><ins>+ editor.on( 'mousedown mouseup click touchend', function( event ) {
+ var view = getView( event.target ),
+ type = isTouchDevice ? 'touchend' : 'mousedown';
+
</ins><span class="cx"> firstFocus = false;
</span><span class="cx">
</span><span class="cx"> // Contain clicks inside the view wrapper
</span><span class="cx"> if ( view ) {
</span><del>- event.stopPropagation();
</del><ins>+ event.stopImmediatePropagation();
+ event.preventDefault();
</ins><span class="cx">
</span><del>- if ( event.type === 'mousedown' && ! event.metaKey && ! event.ctrlKey ) {
</del><ins>+ if ( event.type === type && ! event.metaKey && ! event.ctrlKey ) {
</ins><span class="cx"> if ( editor.dom.hasClass( event.target, 'edit' ) ) {
</span><span class="cx"> wp.mce.views.edit( view );
</span><span class="cx"> editor.focus();
</span><span class="lines">@@ -305,17 +319,25 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- select( view );
</del><ins>+ if ( event.type === 'touchend' && scrolled ) {
+ scrolled = false;
+ } else {
+ select( view );
+ }
</ins><span class="cx">
</span><span class="cx"> // Returning false stops the ugly bars from appearing in IE11 and stops the view being selected as a range in FF.
</span><span class="cx"> // Unfortunately, it also inhibits the dragging of views to a new location.
</span><span class="cx"> return false;
</span><span class="cx"> } else {
</span><del>- if ( event.type === 'mousedown' ) {
</del><ins>+ if ( event.type === type ) {
</ins><span class="cx"> deselect();
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>- });
</del><ins>+
+ if ( event.type === 'touchend' && scrolled ) {
+ scrolled = false;
+ }
+ }, true );
</ins><span class="cx"> });
</span><span class="cx">
</span><span class="cx"> editor.on( 'PreProcess', function( event ) {
</span><span class="lines">@@ -564,41 +586,39 @@
</span><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx">
</span><del>- if ( focus ) {
- if ( view ) {
- if ( ( className === 'wpview-selection-before' || className === 'wpview-selection-after' ) && editor.selection.isCollapsed() ) {
- setViewCursorTries = 0;
</del><ins>+ if ( focus && view ) {
+ if ( ( className === 'wpview-selection-before' || className === 'wpview-selection-after' ) &&
+ editor.selection.isCollapsed() ) {
</ins><span class="cx">
</span><del>- deselect();
</del><ins>+ setViewCursorTries = 0;
</ins><span class="cx">
</span><del>- // Make sure the cursor arrived in the right node.
- // This is necessary for Firefox.
- if ( lKDN === view.previousSibling ) {
- setViewCursor( true, view );
- return;
- } else if ( lKDN === view.nextSibling ) {
- setViewCursor( false, view );
- return;
- }
</del><ins>+ deselect();
</ins><span class="cx">
</span><del>- dom.addClass( view, className );
-
- cursorInterval = setInterval( function() {
- if ( dom.hasClass( view, 'wpview-cursor-hide' ) ) {
- dom.removeClass( view, 'wpview-cursor-hide' );
- } else {
- dom.addClass( view, 'wpview-cursor-hide' );
- }
- }, 500 );
- // If the cursor lands anywhere else in the view, set the cursor before it.
- // Only try this once to prevent a loop. (You never know.)
- } else if ( ! getParent( event.element, 'wpview-clipboard' ) && ! setViewCursorTries ) {
- deselect();
- setViewCursorTries++;
</del><ins>+ // Make sure the cursor arrived in the right node.
+ // This is necessary for Firefox.
+ if ( lKDN === view.previousSibling ) {
</ins><span class="cx"> setViewCursor( true, view );
</span><ins>+ return;
+ } else if ( lKDN === view.nextSibling ) {
+ setViewCursor( false, view );
+ return;
</ins><span class="cx"> }
</span><del>- } else {
</del><ins>+
+ dom.addClass( view, className );
+
+ cursorInterval = setInterval( function() {
+ if ( dom.hasClass( view, 'wpview-cursor-hide' ) ) {
+ dom.removeClass( view, 'wpview-cursor-hide' );
+ } else {
+ dom.addClass( view, 'wpview-cursor-hide' );
+ }
+ }, 500 );
+ // If the cursor lands anywhere else in the view, set the cursor before it.
+ // Only try this once to prevent a loop. (You never know.)
+ } else if ( ! getParent( event.element, 'wpview-clipboard' ) && ! setViewCursorTries ) {
</ins><span class="cx"> deselect();
</span><ins>+ setViewCursorTries++;
+ setViewCursor( true, view );
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> });
</span></span></pre>
</div>
</div>
</body>
</html>