<!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>[37446] trunk/src/wp-includes/js: TinyMCE: use new non-editable implementation</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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/37446">37446</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/37446","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>iseulde</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-05-17 18:48:54 +0000 (Tue, 17 May 2016)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>TinyMCE: use new non-editable implementation
Use TinyMCE's implementation of `contenteditable="false"` for views.
First pass.
See <a href="https://core.trac.wordpress.org/ticket/36434">#36434</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesjsmceviewjs">trunk/src/wp-includes/js/mce-view.js</a></li>
<li><a href="#trunksrcwpincludesjstinymcepluginswpviewpluginjs">trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js</a></li>
<li><a href="#trunksrcwpincludesjstinymceskinswordpresswpcontentcss">trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesjsmceviewjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/js/mce-view.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/mce-view.js 2016-05-17 17:51:17 UTC (rev 37445)
+++ trunk/src/wp-includes/js/mce-view.js 2016-05-17 18:48:54 UTC (rev 37446)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -327,9 +327,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> this.replaceMarkers();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( content ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- this.setContent( content, function( editor, node, contentNode ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ this.setContent( content, function( editor, node ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $( node ).data( 'rendered', true );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- this.bindNode.call( this, editor, node, contentNode );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ this.bindNode.call( this, editor, node );
</ins><span class="cx" style="display: block; padding: 0 10px"> }, force ? null : false );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> this.setLoader();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -351,8 +351,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Runs before their content is removed from the DOM.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> unbind: function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- this.getNodes( function( editor, node, contentNode ) {
- this.unbindNode.call( this, editor, node, contentNode );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ this.getNodes( function( editor, node ) {
+ this.unbindNode.call( this, editor, node );
</ins><span class="cx" style="display: block; padding: 0 10px"> $( node ).trigger( 'wp-mce-view-unbind' );
</span><span class="cx" style="display: block; padding: 0 10px"> }, true );
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -394,7 +394,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return rendered ? data : ! data;
</span><span class="cx" style="display: block; padding: 0 10px"> } )
</span><span class="cx" style="display: block; padding: 0 10px"> .each( function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- callback.call( self, editor, this, $( this ).find( '.wpview-content' ).get( 0 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ callback.call( self, editor, this );
</ins><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -421,8 +421,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> replaceMarkers: function() {
</span><span class="cx" style="display: block; padding: 0 10px"> this.getMarkers( function( editor, node ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var selected = node === editor.selection.getNode(),
- $viewNode;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var $viewNode;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! this.loader && $( node ).text() !== this.text ) {
</span><span class="cx" style="display: block; padding: 0 10px"> editor.dom.setAttrib( node, 'data-wpview-marker', null );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -430,20 +429,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $viewNode = editor.$(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- '<div class="wpview-wrap" data-wpview-text="' + this.encodedText + '" data-wpview-type="' + this.type + '">' +
- '<p class="wpview-selection-before">\u00a0</p>' +
- '<div class="wpview-body" contenteditable="false">' +
- '<div class="wpview-content wpview-type-' + this.type + '"></div>' +
- '</div>' +
- '<p class="wpview-selection-after">\u00a0</p>' +
- '</div>'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ '<div class="wpview" data-wpview-text="' + this.encodedText + '" data-wpview-type="' + this.type + '" contenteditable="false"></div>'
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> editor.$( node ).replaceWith( $viewNode );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- if ( selected ) {
- editor.wp.setViewCursor( false, $viewNode[0] );
- }
</del><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -469,17 +458,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } else if ( _.isString( content ) && content.indexOf( '<script' ) !== -1 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> this.setIframes( '', content, callback, rendered );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- this.getNodes( function( editor, node, contentNode ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ this.getNodes( function( editor, node ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> content = content.body || content;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( content.indexOf( '<iframe' ) !== -1 ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- content += '<div class="wpview-overlay"></div>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ content += '<span class="mce-shim"></span>';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- contentNode.innerHTML = '';
- contentNode.appendChild( _.isString( content ) ? editor.dom.createFragment( content ) : content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ editor.undoManager.transact( function() {
+ node.innerHTML = '';
+ node.appendChild( _.isString( content ) ? editor.dom.createFragment( content ) : content );
+ editor.dom.add( node, 'span', { 'class': 'wpview-end' } );
+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- callback && callback.call( this, editor, node, contentNode );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ callback && callback.call( this, editor, node );
</ins><span class="cx" style="display: block; padding: 0 10px"> }, rendered );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -496,7 +488,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,
</span><span class="cx" style="display: block; padding: 0 10px"> self = this;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- this.getNodes( function( editor, node, contentNode ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ this.getNodes( function( editor, node ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> var dom = editor.dom,
</span><span class="cx" style="display: block; padding: 0 10px"> styles = '',
</span><span class="cx" style="display: block; padding: 0 10px"> bodyClasses = editor.getBody().className || '',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -511,10 +503,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( self.iframeHeight ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- dom.add( contentNode, 'div', { style: {
- width: '100%',
- height: self.iframeHeight
- } } );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ dom.add( node, 'span', {
+ 'data-mce-bogus': 1,
+ style: {
+ display: 'block',
+ width: '100%',
+ height: self.iframeHeight
+ }
+ }, '\u200B' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Seems the browsers need a bit of time to insert/set the view nodes,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -522,24 +518,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> setTimeout( function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var iframe, iframeDoc, observer, i, block;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- contentNode.innerHTML = '';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ editor.undoManager.transact( function() {
+ node.innerHTML = '';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- iframe = dom.add( contentNode, 'iframe', {
- /* jshint scripturl: true */
- src: tinymce.Env.ie ? 'javascript:""' : '',
- frameBorder: '0',
- allowTransparency: 'true',
- scrolling: 'no',
- 'class': 'wpview-sandbox',
- style: {
- width: '100%',
- display: 'block'
- },
- height: self.iframeHeight
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ iframe = dom.add( node, 'iframe', {
+ /* jshint scripturl: true */
+ src: tinymce.Env.ie ? 'javascript:""' : '',
+ frameBorder: '0',
+ allowTransparency: 'true',
+ scrolling: 'no',
+ 'class': 'wpview-sandbox',
+ style: {
+ width: '100%',
+ display: 'block'
+ },
+ height: self.iframeHeight
+ } );
+
+ dom.add( node, 'span', { 'class': 'mce-shim' } );
+ dom.add( node, 'span', { 'class': 'wpview-end' } );
</ins><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- dom.add( contentNode, 'div', { 'class': 'wpview-overlay' } );
-
</del><span class="cx" style="display: block; padding: 0 10px"> iframeDoc = iframe.contentWindow.document;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> iframeDoc.open();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -635,7 +634,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> editor.off( 'wp-body-class-change', classChange );
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- callback && callback.call( self, editor, node, contentNode );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ callback && callback.call( self, editor, node );
</ins><span class="cx" style="display: block; padding: 0 10px"> }, 50 );
</span><span class="cx" style="display: block; padding: 0 10px"> }, rendered );
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -718,7 +717,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {HTMLElement} node The view node to remove.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> remove: function( editor, node ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- this.unbindNode.call( this, editor, node, $( node ).find( '.wpview-content' ).get( 0 ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ this.unbindNode.call( this, editor, node );
</ins><span class="cx" style="display: block; padding: 0 10px"> $( node ).trigger( 'wp-mce-view-unbind' );
</span><span class="cx" style="display: block; padding: 0 10px"> editor.dom.remove( node );
</span><span class="cx" style="display: block; padding: 0 10px"> editor.focus();
</span></span></pre></div>
<a id="trunksrcwpincludesjstinymcepluginswpviewpluginjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js 2016-05-17 17:51:17 UTC (rev 37445)
+++ trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js 2016-05-17 18:48:54 UTC (rev 37446)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,749 +1,173 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/* global tinymce */
-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * WordPress View plugin.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-tinymce.PluginManager.add( 'wpview', function( editor ) {
- var $ = editor.$,
- selected,
- Env = tinymce.Env,
- VK = tinymce.util.VK,
- TreeWalker = tinymce.dom.TreeWalker,
- toRemove = false,
- firstFocus = true,
- _noop = function() { return false; },
- isios = /iPad|iPod|iPhone/.test( navigator.userAgent ),
- cursorInterval,
- lastKeyDownNode,
- setViewCursorTries,
- focus,
- execCommandView,
- execCommandBefore,
- toolbar;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+( function( tinymce, wp ) {
+ tinymce.PluginManager.add( 'wpview', function( editor ) {
+ function noop () {}
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function getView( node ) {
- return getParent( node, 'wpview-wrap' );
- }
-
- /**
- * Returns the node or a parent of the node that has the passed className.
- * Doing this directly is about 40% faster
- */
- function getParent( node, className ) {
- while ( node && node.parentNode ) {
- if ( node.className && ( ' ' + node.className + ' ' ).indexOf( ' ' + className + ' ' ) !== -1 ) {
- return node;
- }
-
- node = node.parentNode;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! wp || ! wp.mce ) {
+ return {
+ getView: noop
+ };
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return false;
- }
-
- function _stop( event ) {
- event.stopPropagation();
- }
-
- function setViewCursor( before, view ) {
- var location = before ? 'before' : 'after',
- offset = before ? 0 : 1;
- deselect();
- editor.selection.setCursorLocation( editor.dom.select( '.wpview-selection-' + location, view )[0], offset );
- editor.nodeChanged();
- }
-
- function handleEnter( view, before, key ) {
- var dom = editor.dom,
- padNode = dom.create( 'p' );
-
- if ( ! ( Env.ie && Env.ie < 11 ) ) {
- padNode.innerHTML = '<br data-mce-bogus="1">';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Check if a node is a view or not.
+ function isView( node ) {
+ return editor.dom.hasClass( node, 'wpview' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( before ) {
- view.parentNode.insertBefore( padNode, view );
- } else {
- dom.insertAfter( padNode, view );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Replace view tags with their text.
+ function resetViews( content ) {
+ function callback( match, $1 ) {
+ return '<p>' + window.decodeURIComponent( $1 ) + '</p>';
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- deselect();
-
- if ( before && key === VK.ENTER ) {
- setViewCursor( before, view );
- } else {
- editor.selection.setCursorLocation( padNode, 0 );
- }
-
- editor.nodeChanged();
- }
-
- function removeView( view ) {
- editor.undoManager.transact( function() {
- handleEnter( view );
- wp.mce.views.remove( editor, view );
- });
- }
-
- function select( viewNode ) {
- var clipboard,
- dom = editor.dom;
-
- if ( ! viewNode ) {
- return;
- }
-
- if ( viewNode !== selected ) {
- // Make sure that the editor is focused.
- // It is possible that the editor is not focused when the mouse event fires
- // without focus, the selection will not work properly.
- editor.getBody().focus();
-
- deselect();
- selected = viewNode;
- dom.setAttrib( viewNode, 'data-mce-selected', 1 );
-
- clipboard = dom.create( 'div', {
- 'class': 'wpview-clipboard',
- 'contenteditable': 'true'
- }, wp.mce.views.getText( viewNode ) );
-
- editor.dom.select( '.wpview-body', viewNode )[0].appendChild( clipboard );
-
- // Both of the following are necessary to prevent manipulating the selection/focus
- dom.bind( clipboard, 'beforedeactivate focusin focusout', _stop );
- dom.bind( selected, 'beforedeactivate focusin focusout', _stop );
-
- // select the hidden div
- if ( isios ) {
- editor.selection.select( clipboard );
- } else {
- editor.selection.select( clipboard, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! content ) {
+ return content;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- editor.nodeChanged();
- editor.fire( 'wpview-selected', viewNode );
- }
-
- /**
- * Deselect a selected view and remove clipboard
- */
- function deselect() {
- var clipboard,
- dom = editor.dom;
-
- if ( selected ) {
- clipboard = editor.dom.select( '.wpview-clipboard', selected )[0];
- dom.unbind( clipboard );
- dom.remove( clipboard );
-
- dom.unbind( selected, 'beforedeactivate focusin focusout click mouseup', _stop );
- dom.setAttrib( selected, 'data-mce-selected', null );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return content
+ .replace( /<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:\.|[\s\S]+?wpview-end[^>]+>\s*<\/span>\s*)?<\/div>/g, callback )
+ .replace( /<p[^>]+data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g, callback );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- selected = null;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Scan new content for matching view patterns and replace them with markers.
+ editor.on( 'beforesetcontent', function( event ) {
+ var node;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Check if the `wp.mce` API exists.
- if ( typeof wp === 'undefined' || ! wp.mce ) {
- return {
- getView: _noop
- };
- }
-
- function resetViewsCallback( match, viewText ) {
- return '<p>' + window.decodeURIComponent( viewText ) + '</p>';
- }
-
- // Replace the view tags with the view string
- function resetViews( content ) {
- return content.replace( /<div[^>]+data-wpview-text="([^"]+)"[^>]*>(?:[\s\S]+?wpview-selection-after[^>]+>[^<>]*<\/p>\s*|\.)<\/div>/g, resetViewsCallback )
- .replace( /<p [^>]*?data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g, resetViewsCallback );
- }
-
- // Prevent adding undo levels on changes inside a view wrapper
- editor.on( 'BeforeAddUndo', function( event ) {
- if ( event.level.content ) {
- event.level.content = resetViews( event.level.content );
- }
- });
-
- // When the editor's content changes, scan the new content for
- // matching view patterns, and transform the matches into
- // view wrappers.
- editor.on( 'BeforeSetContent', function( event ) {
- var node;
-
- if ( ! event.selection ) {
- wp.mce.views.unbind();
- }
-
- if ( ! event.content ) {
- return;
- }
-
- if ( ! event.load ) {
- if ( selected ) {
- removeView( selected );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! event.selection ) {
+ wp.mce.views.unbind();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- node = editor.selection.getNode();
-
- if ( node && node !== editor.getBody() && /^\s*https?:\/\/\S+\s*$/i.test( event.content ) ) {
- // When a url is pasted or inserted, only try to embed it when it is in an empty paragrapgh.
- node = editor.dom.getParent( node, 'p' );
-
- if ( node && /^[\s\uFEFF\u00A0]*$/.test( $( node ).text() || '' ) ) {
- // Make sure there are no empty inline elements in the <p>
- node.innerHTML = '';
- } else {
- return;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! event.content ) {
+ return;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- }
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- event.content = wp.mce.views.setMarkers( event.content );
- });
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! event.load ) {
+ node = editor.selection.getNode();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // When pasting strip all tags and check if the string is an URL.
- // Then replace the pasted content with the cleaned URL.
- editor.on( 'pastePreProcess', function( event ) {
- var pastedStr = event.content;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( node && node !== editor.getBody() && /^\s*https?:\/\/\S+\s*$/i.test( event.content ) ) {
+ // When a url is pasted or inserted, only try to embed it when it is in an empty paragrapgh.
+ node = editor.dom.getParent( node, 'p' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( pastedStr ) {
- pastedStr = tinymce.trim( pastedStr.replace( /<[^>]+>/g, '' ) );
-
- if ( /^https?:\/\/\S+$/i.test( pastedStr ) ) {
- event.content = pastedStr;
- }
- }
- });
-
- // When the editor's content has been updated and the DOM has been
- // processed, render the views in the document.
- editor.on( 'SetContent', function() {
- wp.mce.views.render();
- });
-
- // Set the cursor before or after a view when clicking next to it.
- editor.on( 'click', function( event ) {
- var x = event.clientX,
- y = event.clientY,
- body = editor.getBody(),
- bodyRect = body.getBoundingClientRect(),
- first = body.firstChild,
- last = body.lastChild,
- firstRect, lastRect, view;
-
- if ( ! first || ! last ) {
- return;
- }
-
- firstRect = first.getBoundingClientRect();
- lastRect = last.getBoundingClientRect();
-
- if ( y < firstRect.top && ( view = getView( first ) ) ) {
- setViewCursor( true, view );
- event.preventDefault();
- } else if ( y > lastRect.bottom && ( view = getView( last ) ) ) {
- setViewCursor( false, view );
- event.preventDefault();
- } else if ( x < bodyRect.left || x > bodyRect.right ) {
- tinymce.each( editor.dom.select( '.wpview-wrap' ), function( view ) {
- var rect = view.getBoundingClientRect();
-
- if ( y < rect.top ) {
- return false;
- }
-
- if ( y >= rect.top && y <= rect.bottom ) {
- if ( x < bodyRect.left ) {
- setViewCursor( true, view );
- event.preventDefault();
- } else if ( x > bodyRect.right ) {
- setViewCursor( false, view );
- event.preventDefault();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( node && /^[\s\uFEFF\u00A0]*$/.test( editor.$( node ).text() || '' ) ) {
+ // Make sure there are no empty inline elements in the <p>
+ node.innerHTML = '';
+ } else {
+ return;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- return false;
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- });
- }
- });
-
- editor.on( 'init', function() {
- var scrolled = false,
- selection = editor.selection,
- MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
-
- // When a view is selected, ensure content that is being pasted
- // or inserted is added to a text node (instead of the view).
- editor.on( 'BeforeSetContent', function() {
- var walker, target,
- view = getView( selection.getNode() );
-
- // If the selection is not within a view, bail.
- if ( ! view ) {
- return;
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! view.nextSibling || getView( view.nextSibling ) ) {
- // If there are no additional nodes or the next node is a
- // view, create a text node after the current view.
- target = editor.getDoc().createTextNode('');
- editor.dom.insertAfter( target, view );
- } else {
- // Otherwise, find the next text node.
- walker = new TreeWalker( view.nextSibling, view.nextSibling );
- target = walker.next();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ event.content = wp.mce.views.setMarkers( event.content );
+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Select the `target` text node.
- selection.select( target );
- selection.collapse( true );
- });
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Replace any new markers nodes with views.
+ editor.on( 'setcontent', function() {
+ wp.mce.views.render();
+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- editor.dom.bind( editor.getDoc(), 'touchmove', function() {
- scrolled = true;
- });
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Empty view nodes for easier processing.
+ editor.on( 'preprocess', function( event ) {
+ editor.$( 'div[data-wpview-text], p[data-wpview-marker]', event.node ).each( function( i, node ) {
+ node.innerHTML = '.';
+ } );
+ }, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- editor.on( 'mousedown mouseup click touchend', function( event ) {
- var view = getView( event.target );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Replace views with their text.
+ editor.on( 'postprocess', function( event ) {
+ event.content = resetViews( event.content );
+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- firstFocus = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Replace views with their text inside undo levels.
+ // This also prevents that new levels are added when there are changes inside the views.
+ editor.on( 'beforeaddundo', function( event ) {
+ event.level.content = resetViews( event.level.content );
+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Contain clicks inside the view wrapper
- if ( view ) {
- event.stopImmediatePropagation();
- event.preventDefault();
-
- if ( event.type === 'touchend' && scrolled ) {
- scrolled = false;
- } else {
- select( view );
- }
-
- // Returning false stops the ugly bars from appearing in IE11 and stops the view being selected as a range in FF.
- // Unfortunately, it also inhibits the dragging of views to a new location.
- return false;
- } else {
- if ( event.type === 'touchend' || event.type === 'mousedown' ) {
- deselect();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Make sure views are copied as their text.
+ editor.on( 'drop objectselected', function( event ) {
+ if ( isView( event.targetClone ) ) {
+ event.targetClone = editor.getDoc().createTextNode(
+ window.decodeURIComponent( editor.dom.getAttrib( event.targetClone, 'data-wpview-text' ) )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( event.type === 'touchend' && scrolled ) {
- scrolled = false;
- }
- }, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Clean up URLs for easier processing.
+ editor.on( 'pastepreprocess', function( event ) {
+ var content = event.content;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( MutationObserver ) {
- new MutationObserver( function() {
- editor.fire( 'wp-body-class-change' );
- } )
- .observe( editor.getBody(), {
- attributes: true,
- attributeFilter: ['class']
- } );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( content ) {
+ content = tinymce.trim( content.replace( /<[^>]+>/g, '' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( tinymce.Env.ie ) {
- // Prevent resize handles in newer IE
- editor.dom.bind( editor.getBody(), 'controlselect mscontrolselect', function( event ) {
- if ( getView( event.target ) ) {
- event.preventDefault();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( /^https?:\/\/\S+$/i.test( content ) ) {
+ event.content = content;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- });
- }
- });
-
- // Empty the wpview wrap and marker nodes
- function emptyViewNodes( rootNode ) {
- $( 'div[data-wpview-text], p[data-wpview-marker]', rootNode ).each( function( i, node ) {
- node.innerHTML = '.';
- });
- }
-
- // Run that before the DOM cleanup
- editor.on( 'PreProcess', function( event ) {
- emptyViewNodes( event.node );
- }, true );
-
- editor.on( 'hide', function() {
- wp.mce.views.unbind();
- deselect();
- emptyViewNodes();
- });
-
- editor.on( 'PostProcess', function( event ) {
- if ( event.content ) {
- event.content = event.content.replace( /<div [^>]*?data-wpview-text="([^"]+)"[^>]*>[\s\S]*?<\/div>/g, resetViewsCallback )
- .replace( /<p [^>]*?data-wpview-marker="([^"]+)"[^>]*>[\s\S]*?<\/p>/g, resetViewsCallback );
- }
- });
-
- // Excludes arrow keys, delete, backspace, enter, space bar.
- // Ref: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.keyCode
- function isSpecialKey( key ) {
- return ( ( key <= 47 && key !== VK.SPACEBAR && key !== VK.ENTER && key !== VK.DELETE && key !== VK.BACKSPACE && ( key < 37 || key > 40 ) ) ||
- key >= 224 || // OEM or non-printable
- ( key >= 144 && key <= 150 ) || // Num Lock, Scroll Lock, OEM
- ( key >= 91 && key <= 93 ) || // Windows keys
- ( key >= 112 && key <= 135 ) ); // F keys
- }
-
- // (De)select views when arrow keys are used to navigate the content of the editor.
- editor.on( 'keydown', function( event ) {
- var key = event.keyCode,
- dom = editor.dom,
- selection = editor.selection,
- node, view, cursorBefore, cursorAfter,
- range, clonedRange, tempRange;
-
- if ( selected ) {
- // Ignore key presses that involve the command or control key, but continue when in combination with backspace or v.
- // Also ignore the F# keys.
- if ( ( ( event.metaKey || event.ctrlKey ) && key !== VK.BACKSPACE && key !== 86 ) || ( key >= 112 && key <= 123 ) ) {
- // Remove the view when pressing cmd/ctrl+x on keyup, otherwise the browser can't copy the content.
- if ( ( event.metaKey || event.ctrlKey ) && key === 88 ) {
- toRemove = selected;
- }
- return;
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- view = getView( selection.getNode() );
-
- // If the caret is not within the selected view, deselect the view and bail.
- if ( view !== selected ) {
- deselect();
- return;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Show the view type in the element path.
+ editor.on( 'resolvename', function( event ) {
+ if ( isView( event.target ) ) {
+ event.name = editor.dom.getAttrib( event.target, 'data-wpview-type' ) || 'object';
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( key === VK.LEFT ) {
- setViewCursor( true, view );
- event.preventDefault();
- } else if ( key === VK.UP ) {
- if ( view.previousSibling ) {
- if ( getView( view.previousSibling ) ) {
- setViewCursor( true, view.previousSibling );
- } else {
- deselect();
- selection.select( view.previousSibling, true );
- selection.collapse();
- }
- } else {
- setViewCursor( true, view );
- }
- event.preventDefault();
- } else if ( key === VK.RIGHT ) {
- setViewCursor( false, view );
- event.preventDefault();
- } else if ( key === VK.DOWN ) {
- if ( view.nextSibling ) {
- if ( getView( view.nextSibling ) ) {
- setViewCursor( false, view.nextSibling );
- } else {
- deselect();
- selection.setCursorLocation( view.nextSibling, 0 );
- }
- } else {
- setViewCursor( false, view );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // See `media` plugin.
+ editor.on( 'click keyup', function() {
+ var node = editor.selection.getNode();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- event.preventDefault();
- // Ignore keys that don't insert anything.
- } else if ( ! isSpecialKey( key ) ) {
- removeView( selected );
-
- if ( key === VK.ENTER || key === VK.DELETE || key === VK.BACKSPACE ) {
- event.preventDefault();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isView( node ) ) {
+ if ( editor.dom.getAttrib( node, 'data-mce-selected' ) ) {
+ node.setAttribute( 'data-mce-selected', '2' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } else {
- if ( event.metaKey || event.ctrlKey || ( key >= 112 && key <= 123 ) ) {
- return;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- node = selection.getNode();
- lastKeyDownNode = node;
- view = getView( node );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ editor.addButton( 'wp_view_edit', {
+ tooltip: 'Edit ', // trailing space is needed, used for context
+ icon: 'dashicon dashicons-edit',
+ onclick: function() {
+ var node = editor.selection.getNode();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Make sure we don't delete part of a view.
- // If the range ends or starts with the view, we'll need to trim it.
- if ( ! selection.isCollapsed() ) {
- range = selection.getRng();
-
- if ( view = getView( range.endContainer ) ) {
- clonedRange = range.cloneRange();
- selection.select( view.previousSibling, true );
- selection.collapse();
- tempRange = selection.getRng();
- clonedRange.setEnd( tempRange.endContainer, tempRange.endOffset );
- selection.setRng( clonedRange );
- } else if ( view = getView( range.startContainer ) ) {
- clonedRange = range.cloneRange();
- clonedRange.setStart( view.nextSibling, 0 );
- selection.setRng( clonedRange );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isView( node ) ) {
+ wp.mce.views.edit( editor, node );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! view ) {
- // Make sure we don't eat any content.
- if ( event.keyCode === VK.BACKSPACE ) {
- if ( editor.dom.isEmpty( node ) ) {
- if ( view = getView( node.previousSibling ) ) {
- setViewCursor( false, view );
- editor.dom.remove( node );
- event.preventDefault();
- }
- } else if ( ( range = selection.getRng() ) &&
- range.startOffset === 0 &&
- range.endOffset === 0 &&
- ( view = getView( node.previousSibling ) ) ) {
- setViewCursor( false, view );
- event.preventDefault();
- }
- }
- return;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ editor.addButton( 'wp_view_remove', {
+ tooltip: 'Remove',
+ icon: 'dashicon dashicons-no',
+ onclick: function() {
+ editor.fire( 'cut' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! ( ( cursorBefore = dom.hasClass( view, 'wpview-selection-before' ) ) ||
- ( cursorAfter = dom.hasClass( view, 'wpview-selection-after' ) ) ) ) {
- return;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ editor.once( 'preinit', function() {
+ var toolbar;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isSpecialKey( key ) ) {
- // ignore
- return;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( editor.wp && editor.wp._createToolbar ) {
+ toolbar = editor.wp._createToolbar( [
+ 'wp_view_edit',
+ 'wp_view_remove'
+ ] );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ( cursorAfter && key === VK.UP ) || ( cursorBefore && key === VK.BACKSPACE ) ) {
- if ( view.previousSibling ) {
- if ( getView( view.previousSibling ) ) {
- setViewCursor( false, view.previousSibling );
- } else {
- if ( dom.isEmpty( view.previousSibling ) && key === VK.BACKSPACE ) {
- dom.remove( view.previousSibling );
- } else {
- selection.select( view.previousSibling, true );
- selection.collapse();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ editor.on( 'wptoolbar', function( event ) {
+ if ( isView( event.element ) ) {
+ event.toolbar = toolbar;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } else {
- setViewCursor( true, view );
- }
- event.preventDefault();
- } else if ( cursorAfter && ( key === VK.DOWN || key === VK.RIGHT ) ) {
- if ( view.nextSibling ) {
- if ( getView( view.nextSibling ) ) {
- setViewCursor( key === VK.RIGHT, view.nextSibling );
- } else {
- selection.setCursorLocation( view.nextSibling, 0 );
- }
- }
- event.preventDefault();
- } else if ( cursorBefore && ( key === VK.UP || key === VK.LEFT ) ) {
- if ( view.previousSibling ) {
- if ( getView( view.previousSibling ) ) {
- setViewCursor( key === VK.UP, view.previousSibling );
- } else {
- selection.select( view.previousSibling, true );
- selection.collapse();
- }
- }
- event.preventDefault();
- } else if ( cursorBefore && key === VK.DOWN ) {
- if ( view.nextSibling ) {
- if ( getView( view.nextSibling ) ) {
- setViewCursor( true, view.nextSibling );
- } else {
- selection.setCursorLocation( view.nextSibling, 0 );
- }
- } else {
- setViewCursor( false, view );
- }
- event.preventDefault();
- } else if ( ( cursorAfter && key === VK.LEFT ) || ( cursorBefore && key === VK.RIGHT ) ) {
- select( view );
- event.preventDefault();
- } else if ( cursorAfter && key === VK.BACKSPACE ) {
- removeView( view );
- event.preventDefault();
- } else if ( cursorAfter ) {
- handleEnter( view );
- } else if ( cursorBefore ) {
- handleEnter( view , true, key );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( key === VK.ENTER ) {
- event.preventDefault();
- }
- }
- });
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ editor.wp = editor.wp || {};
+ editor.wp.getView = noop;
+ editor.wp.setViewCursor = noop;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- editor.on( 'keyup', function() {
- if ( toRemove ) {
- removeView( toRemove );
- toRemove = false;
- }
- });
-
- editor.on( 'focus', function() {
- var view;
-
- focus = true;
- editor.dom.addClass( editor.getBody(), 'has-focus' );
-
- // Edge case: show the fake caret when the editor is focused for the first time
- // and the first element is a view.
- if ( firstFocus && ( view = getView( editor.getBody().firstChild ) ) ) {
- setViewCursor( true, view );
- }
-
- firstFocus = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return {
+ getView: noop
+ };
</ins><span class="cx" style="display: block; padding: 0 10px"> } );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- editor.on( 'blur', function() {
- focus = false;
- editor.dom.removeClass( editor.getBody(), 'has-focus' );
- } );
-
- editor.on( 'NodeChange', function( event ) {
- var dom = editor.dom,
- views = editor.dom.select( '.wpview-wrap' ),
- className = event.element.className,
- view = getView( event.element ),
- lKDN = lastKeyDownNode;
-
- lastKeyDownNode = false;
-
- clearInterval( cursorInterval );
-
- // This runs a lot and is faster than replacing each class separately
- tinymce.each( views, function ( view ) {
- if ( view.className ) {
- view.className = view.className.replace( / ?\bwpview-(?:selection-before|selection-after|cursor-hide)\b/g, '' );
- }
- });
-
- if ( focus && view ) {
- if ( ( className === 'wpview-selection-before' || className === 'wpview-selection-after' ) &&
- editor.selection.isCollapsed() ) {
-
- setViewCursorTries = 0;
-
- deselect();
-
- // 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;
- }
-
- 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++;
- setViewCursor( true, view );
- }
- }
- });
-
- editor.on( 'BeforeExecCommand', function() {
- var node = editor.selection.getNode(),
- view;
-
- if ( node && ( ( execCommandBefore = node.className === 'wpview-selection-before' ) || node.className === 'wpview-selection-after' ) && ( view = getView( node ) ) ) {
- handleEnter( view, execCommandBefore );
- execCommandView = view;
- }
- });
-
- editor.on( 'ExecCommand', function() {
- var toSelect, node;
-
- if ( selected ) {
- toSelect = selected;
- deselect();
- select( toSelect );
- }
-
- if ( execCommandView ) {
- node = execCommandView[ execCommandBefore ? 'previousSibling' : 'nextSibling' ];
-
- if ( node && node.nodeName === 'P' && editor.dom.isEmpty( node ) ) {
- editor.dom.remove( node );
- setViewCursor( execCommandBefore, execCommandView );
- }
-
- execCommandView = false;
- }
- });
-
- editor.on( 'ResolveName', function( event ) {
- if ( editor.dom.hasClass( event.target, 'wpview-wrap' ) ) {
- event.name = editor.dom.getAttrib( event.target, 'data-wpview-type' ) || 'wpview';
- event.stopPropagation();
- } else if ( getView( event.target ) ) {
- event.preventDefault();
- event.stopPropagation();
- }
- });
-
- editor.addButton( 'wp_view_edit', {
- tooltip: 'Edit ', // trailing space is needed, used for context
- icon: 'dashicon dashicons-edit',
- onclick: function() {
- selected && wp.mce.views.edit( editor, selected );
- }
- } );
-
- editor.addButton( 'wp_view_remove', {
- tooltip: 'Remove',
- icon: 'dashicon dashicons-no',
- onclick: function() {
- selected && removeView( selected );
- }
- } );
-
- editor.once( 'preinit', function() {
- if ( editor.wp && editor.wp._createToolbar ) {
- toolbar = editor.wp._createToolbar( [
- 'wp_view_edit',
- 'wp_view_remove'
- ] );
- }
- } );
-
- editor.on( 'wptoolbar', function( event ) {
- if ( selected ) {
- event.element = selected;
- event.toolbar = toolbar;
- }
- } );
-
- // Add to editor.wp
- editor.wp = editor.wp || {};
- editor.wp.getView = getView;
- editor.wp.setViewCursor = setViewCursor;
-
- // Keep for back-compat.
- return {
- getView: getView
- };
-});
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+} )( window.tinymce, window.wp );
</ins></span></pre></div>
<a id="trunksrcwpincludesjstinymceskinswordpresswpcontentcss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css 2016-05-17 17:51:17 UTC (rev 37445)
+++ trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css 2016-05-17 18:48:54 UTC (rev 37446)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -209,98 +209,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * WP Views
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.wpview-wrap {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.wpview {
</ins><span class="cx" style="display: block; padding: 0 10px"> width: 99.99%; /* All IE need hasLayout, incl. 11 (ugh, not again!!) */
</span><span class="cx" style="display: block; padding: 0 10px"> position: relative;
</span><span class="cx" style="display: block; padding: 0 10px"> clear: both;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-}
-
-/* delegate the handling of the selection to the wpview tinymce plugin */
-.wpview-wrap,
-.wpview-wrap * {
- -moz-user-select: none;
- -webkit-user-select: none;
- -ms-user-select: none;
- user-select: none;
-}
-
-/* hide the shortcode content, but allow the content to still be selected */
-.wpview-wrap .wpview-clipboard,
-.wpview-wrap > p {
- position: absolute;
- top: 0;
- left: 0;
- z-index: -1;
- clip: rect(1px 1px 1px 1px); /* IE7 */
- clip: rect(1px, 1px, 1px, 1px);
- overflow: hidden;
- outline: 0;
- padding: 0;
- border: 0;
- width: 1px;
- height: 1px;
-}
-
-/* An ugly box will appear when this is focussed in IE, so we'll move it outside the window. */
-.wpview-wrap.wpview-selection-before > p,
-.wpview-wrap.wpview-selection-after > p {
- left: -10000px;
-}
-
-.wpview-wrap .wpview-clipboard,
-.wpview-wrap .wpview-clipboard *,
-.wpview-wrap > p {
- -moz-user-select: text;
- -webkit-user-select: text;
- -ms-user-select: text;
- user-select: text;
-}
-
-.has-focus .wpview-wrap.wpview-selection-before:before,
-.has-focus .wpview-wrap.wpview-selection-after:before {
- content: '';
- margin: 0;
- padding: 0;
- position: absolute;
- top: -2px;
- left: -3px;
- bottom: -2px;
- width: 1px;
- background-color: black;
- background-color: currentcolor;
- opacity: 1;
-}
-
-.has-focus .wpview-wrap.wpview-selection-after:before {
- left: auto;
- right: -3px;
-}
-
-.has-focus .wpview-wrap.wpview-cursor-hide:before {
- opacity: 0;
-}
-
-/**
- * Media previews
- */
-.wpview-wrap {
- position: relative;
- margin-bottom: 16px;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ margin-bottom: 16px;
</ins><span class="cx" style="display: block; padding: 0 10px"> border: 1px solid transparent;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.wpview-wrap[data-mce-selected] {
- background-color: rgba(0,0,0,0.1);
- border-color: rgba(0,0,0,0.3);
-}
-
-.ie8 .wpview-wrap[data-mce-selected],
-.ie7 .wpview-wrap[data-mce-selected] {
- background-color: #e5e5e5;
- border-color: #72777c;
-}
-
-.wpview-overlay {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.mce-shim {
</ins><span class="cx" style="display: block; padding: 0 10px"> position: absolute;
</span><span class="cx" style="display: block; padding: 0 10px"> top: 0;
</span><span class="cx" style="display: block; padding: 0 10px"> right: 0;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -308,21 +225,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> left: 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.wpview-wrap[data-mce-selected] .wpview-overlay {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.wpview[data-mce-selected="2"] .mce-shim {
</ins><span class="cx" style="display: block; padding: 0 10px"> display: none;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.wpview-wrap .loading-placeholder {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.wpview .loading-placeholder {
</ins><span class="cx" style="display: block; padding: 0 10px"> border: 1px dashed #ccc;
</span><span class="cx" style="display: block; padding: 0 10px"> padding: 10px;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.wpview-wrap[data-mce-selected] .loading-placeholder {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.wpview[data-mce-selected] .loading-placeholder {
</ins><span class="cx" style="display: block; padding: 0 10px"> border-color: transparent;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /* A little "loading" animation, not showing in IE < 10 */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.wpview-wrap .wpview-loading {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.wpview .wpview-loading {
</ins><span class="cx" style="display: block; padding: 0 10px"> width: 60px;
</span><span class="cx" style="display: block; padding: 0 10px"> height: 5px;
</span><span class="cx" style="display: block; padding: 0 10px"> overflow: hidden;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -330,7 +247,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> margin: 10px auto 0;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.wpview-wrap .wpview-loading ins {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.wpview .wpview-loading ins {
</ins><span class="cx" style="display: block; padding: 0 10px"> background-color: #333;
</span><span class="cx" style="display: block; padding: 0 10px"> margin: 0 0 0 -60px;
</span><span class="cx" style="display: block; padding: 0 10px"> width: 36px;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -358,7 +275,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.wpview-wrap .wpview-content > iframe {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.wpview .wpview-content > iframe {
</ins><span class="cx" style="display: block; padding: 0 10px"> max-width: 100%;
</span><span class="cx" style="display: block; padding: 0 10px"> background: transparent;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -370,7 +287,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> word-wrap: break-word;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-.wpview-wrap[data-mce-selected] .wpview-error {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+.wpview[data-mce-selected] .wpview-error {
</ins><span class="cx" style="display: block; padding: 0 10px"> border-color: transparent;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre>
</div>
</div>
</body>
</html>