TinyMCE: update the wpView toolbar to look the same as the new image toolbar.
Fixes #30561. git-svn-id: https://develop.svn.wordpress.org/trunk@30694 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
eb2f29f1c3
commit
4eb3c5960f
@ -56,9 +56,9 @@ window.wp = window.wp || {};
|
|||||||
this.setContent(
|
this.setContent(
|
||||||
'<p class="wpview-selection-before">\u00a0</p>' +
|
'<p class="wpview-selection-before">\u00a0</p>' +
|
||||||
'<div class="wpview-body" contenteditable="false">' +
|
'<div class="wpview-body" contenteditable="false">' +
|
||||||
'<div class="toolbar">' +
|
'<div class="toolbar mce-arrow-down">' +
|
||||||
( _.isFunction( views[ this.type ].edit ) ? '<div class="dashicons dashicons-edit edit"></div>' : '' ) +
|
( _.isFunction( views[ this.type ].edit ) ? '<div class="dashicons dashicons-edit edit"></div>' : '' ) +
|
||||||
'<div class="dashicons dashicons-no-alt remove"></div>' +
|
'<div class="dashicons dashicons-no remove"></div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="wpview-content wpview-type-' + this.type + '">' +
|
'<div class="wpview-content wpview-type-' + this.type + '">' +
|
||||||
( this.getHtml() || this.loadingPlaceholder() ) +
|
( this.getHtml() || this.loadingPlaceholder() ) +
|
||||||
|
@ -115,8 +115,13 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||||||
var clipboard,
|
var clipboard,
|
||||||
dom = editor.dom;
|
dom = editor.dom;
|
||||||
|
|
||||||
// Bail if node is already selected.
|
if ( ! viewNode ) {
|
||||||
if ( ! viewNode || viewNode === selected ) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adjust the toolbar position and bail if node is already selected.
|
||||||
|
if ( viewNode === selected ) {
|
||||||
|
adjustToolbarPosition( viewNode );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +133,7 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||||||
deselect();
|
deselect();
|
||||||
selected = viewNode;
|
selected = viewNode;
|
||||||
dom.setAttrib( viewNode, 'data-mce-selected', 1 );
|
dom.setAttrib( viewNode, 'data-mce-selected', 1 );
|
||||||
|
adjustToolbarPosition( viewNode );
|
||||||
|
|
||||||
clipboard = dom.create( 'div', {
|
clipboard = dom.create( 'div', {
|
||||||
'class': 'wpview-clipboard',
|
'class': 'wpview-clipboard',
|
||||||
@ -151,6 +157,24 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
|||||||
editor.fire( 'wpview-selected', viewNode );
|
editor.fire( 'wpview-selected', viewNode );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function adjustToolbarPosition( viewNode ) {
|
||||||
|
var delta = 0,
|
||||||
|
toolbar = editor.$( viewNode ).find( '.toolbar' ),
|
||||||
|
editorToolbar = tinymce.$( editor.editorContainer ).find( '.mce-toolbar-grp' )[0],
|
||||||
|
editorToolbarBottom = ( editorToolbar && editorToolbar.getBoundingClientRect().bottom ) || 0;
|
||||||
|
|
||||||
|
if ( toolbar.length && editor.iframeElement ) {
|
||||||
|
// 48 = 43 for the toolbar + 5 buffer
|
||||||
|
delta = viewNode.getBoundingClientRect().top + editor.iframeElement.getBoundingClientRect().top - editorToolbarBottom - 48;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( delta < 0 ) {
|
||||||
|
toolbar.removeClass( 'mce-arrow-down' ).css({ top: ( -43 + delta * -1 ) });
|
||||||
|
} else if ( delta > 0 && ! toolbar.hasClass( 'mce-arrow-down' ) ) {
|
||||||
|
toolbar.addClass( 'mce-arrow-down' ).css({ top: '' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deselect a selected view and remove clipboard
|
* Deselect a selected view and remove clipboard
|
||||||
*/
|
*/
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 251 B After Width: | Height: | Size: 368 B |
Binary file not shown.
Before Width: | Height: | Size: 164 B |
Binary file not shown.
After Width: | Height: | Size: 339 B |
@ -224,9 +224,7 @@ audio {
|
|||||||
|
|
||||||
/* delegate the handling of the selection to the wpview tinymce plugin */
|
/* delegate the handling of the selection to the wpview tinymce plugin */
|
||||||
.wpview-wrap,
|
.wpview-wrap,
|
||||||
.wpview-wrap *,
|
.wpview-wrap * {
|
||||||
#wp-image-toolbar,
|
|
||||||
#wp-image-toolbar * {
|
|
||||||
-moz-user-select: none;
|
-moz-user-select: none;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
-ms-user-select: none;
|
-ms-user-select: none;
|
||||||
@ -323,16 +321,89 @@ audio {
|
|||||||
|
|
||||||
.wpview-wrap .toolbar {
|
.wpview-wrap .toolbar {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: -43px;
|
||||||
left: 0;
|
left: 45%;
|
||||||
|
left: calc(50% - 32px);
|
||||||
display: none;
|
display: none;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
border: 1px solid #aaa;
|
||||||
|
padding: 1px;
|
||||||
|
cursor: default;
|
||||||
|
-webkit-border-radius: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
-webkit-box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.2 );
|
||||||
|
box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.2 );
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wpview-wrap[data-mce-selected] .toolbar {
|
.wpview-wrap[data-mce-selected] .toolbar {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wpview-wrap .toolbar:before,
|
||||||
|
.wpview-wrap .toolbar:after {
|
||||||
|
position: absolute;
|
||||||
|
left: 50%;
|
||||||
|
display: block;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: transparent;
|
||||||
|
border-width: 9px;
|
||||||
|
margin-left: -9px;
|
||||||
|
content: '';
|
||||||
|
}
|
||||||
|
|
||||||
|
.wpview-wrap .toolbar:after {
|
||||||
|
border-width: 8px;
|
||||||
|
margin-left: -8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wpview-wrap .toolbar.mce-arrow-down:before {
|
||||||
|
bottom: -18px;
|
||||||
|
border-top-color: #aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wpview-wrap .toolbar.mce-arrow-down:after {
|
||||||
|
bottom: -16px;
|
||||||
|
border-top-color: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wpview-wrap .toolbar.mce-arrow-up:before {
|
||||||
|
top: -18px;
|
||||||
|
border-bottom-color: #aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wpview-wrap .toolbar.mce-arrow-up:after {
|
||||||
|
top: -16px;
|
||||||
|
border-bottom-color: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wpview-wrap .toolbar div {
|
||||||
|
margin: 2px;
|
||||||
|
padding: 2px 3px;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
color: #777;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 20px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wpview-wrap .toolbar div:hover {
|
||||||
|
background-color: #fafafa;
|
||||||
|
border-color: #999;
|
||||||
|
color: #222;
|
||||||
|
-webkit-box-shadow: inset 0 1px 0 #fff, 0 1px 0 rgba( 0, 0, 0, 0.08 );
|
||||||
|
box-shadow: inset 0 1px 0 #fff, 0 1px 0 rgba( 0, 0, 0, 0.08 );
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
.wpview-wrap .loading-placeholder {
|
.wpview-wrap .loading-placeholder {
|
||||||
border: 1px dashed #ccc;
|
border: 1px dashed #ccc;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
@ -384,32 +455,10 @@ audio {
|
|||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
#wp-image-toolbar {
|
|
||||||
position: absolute;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wpview-wrap .toolbar div,
|
|
||||||
#wp-image-toolbar i {
|
|
||||||
margin-top: 7px;
|
|
||||||
margin-left: 7px;
|
|
||||||
padding: 2px;
|
|
||||||
width: 30px;
|
|
||||||
height: 30px;
|
|
||||||
box-shadow: 0 1px 3px rgba(0,0,0,0.5);
|
|
||||||
background-color: #000;
|
|
||||||
background-color: rgba(0,0,0,0.9);
|
|
||||||
cursor: pointer;
|
|
||||||
color: white;
|
|
||||||
font-size: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ie8 .wpview-wrap .toolbar div,
|
.ie8 .wpview-wrap .toolbar div,
|
||||||
.ie7 .wpview-wrap .toolbar div,
|
.ie7 .wpview-wrap .toolbar div {
|
||||||
.ie8 #wp-image-toolbar i,
|
|
||||||
.ie7 #wp-image-toolbar i {
|
|
||||||
display: inline;
|
display: inline;
|
||||||
padding: 0;
|
padding: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ie8 .dashicons-edit,
|
.ie8 .dashicons-edit,
|
||||||
@ -417,9 +466,9 @@ audio {
|
|||||||
background-image: url(images/dashicon-edit.png);
|
background-image: url(images/dashicon-edit.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
.ie8 .dashicons-no-alt,
|
.ie8 .dashicons-no,
|
||||||
.ie7 .dashicons-no-alt {
|
.ie7 .dashicons-no {
|
||||||
background-image: url(images/dashicon-no-alt.png);
|
background-image: url(images/dashicon-no.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
.wpview-error {
|
.wpview-error {
|
||||||
@ -448,27 +497,6 @@ audio {
|
|||||||
font-family: 'Open Sans', sans-serif;
|
font-family: 'Open Sans', sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wpview-wrap .toolbar div:hover,
|
|
||||||
#wp-image-toolbar i:hover {
|
|
||||||
box-shadow: 0 1px 3px rgba(0,0,0,0.8);
|
|
||||||
background-color: #000;
|
|
||||||
color: #2ea2cc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Audio player is short; therefore let's put the toolbar above */
|
|
||||||
.wpview-wrap[data-wpview-type="audio"] .toolbar {
|
|
||||||
top: auto;
|
|
||||||
bottom: -34px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wpview-wrap[data-wpview-type="audio"] .toolbar div {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wpview-wrap[data-wpview-type="audio"] .toolbar div:first-child {
|
|
||||||
margin-left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wont-play {
|
.wont-play {
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
}
|
}
|
||||||
@ -595,17 +623,6 @@ img.wp-oembed {
|
|||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rtl .wpview-wrap .toolbar {
|
|
||||||
left: auto;
|
|
||||||
right: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rtl .wpview-wrap .toolbar div,
|
|
||||||
.rtl #wp-image-toolbar i {
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: 7px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media print,
|
@media print,
|
||||||
(-o-min-device-pixel-ratio: 5/4),
|
(-o-min-device-pixel-ratio: 5/4),
|
||||||
(-webkit-min-device-pixel-ratio: 1.25),
|
(-webkit-min-device-pixel-ratio: 1.25),
|
||||||
|
Loading…
Reference in New Issue
Block a user