Wordpress++
This commit is contained in:
1 parent
790f1487a2
commit
3f49ab1747
610 files changed
+58979
-36562
No files matched your search
@@ -1,17 +1,19 @@
|
||||
/* global tinymce, getUserSetting, setUserSetting */
|
||||
|
||||
/* global getUserSetting, setUserSetting */
|
||||
( function( tinymce ) {
|
||||
// Set the minimum value for the modals z-index higher than #wpadminbar (100000)
|
||||
tinymce.ui.FloatPanel.zIndex = 100100;
|
||||
|
||||
tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
var DOM = tinymce.DOM,
|
||||
var wpAdvButton, style,
|
||||
DOM = tinymce.DOM,
|
||||
each = tinymce.each,
|
||||
__ = editor.editorManager.i18n.translate,
|
||||
wpAdvButton, style,
|
||||
last = 0;
|
||||
$ = window.jQuery,
|
||||
wp = window.wp,
|
||||
hasWpautop = ( wp && wp.editor && wp.editor.autop && editor.getParam( 'wpautop', true ) );
|
||||
|
||||
if ( typeof window.jQuery !== 'undefined' ) {
|
||||
window.jQuery( document ).triggerHandler( 'tinymce-editor-setup', [ editor ] );
|
||||
if ( $ ) {
|
||||
$( document ).triggerHandler( 'tinymce-editor-setup', [ editor ] );
|
||||
}
|
||||
|
||||
function toggleToolbars( state ) {
|
||||
@@ -89,26 +91,33 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
});
|
||||
|
||||
// Replace Read More/Next Page tags with images
|
||||
editor.on( 'BeforeSetContent', function( e ) {
|
||||
editor.on( 'BeforeSetContent', function( event ) {
|
||||
var title;
|
||||
|
||||
if ( e.content ) {
|
||||
if ( e.content.indexOf( '<!--more' ) !== -1 ) {
|
||||
if ( event.content ) {
|
||||
if ( event.content.indexOf( '<!--more' ) !== -1 ) {
|
||||
title = __( 'Read more...' );
|
||||
|
||||
e.content = e.content.replace( /<!--more(.*?)-->/g, function( match, moretext ) {
|
||||
event.content = event.content.replace( /<!--more(.*?)-->/g, function( match, moretext ) {
|
||||
return '<img src="' + tinymce.Env.transparentSrc + '" data-wp-more="more" data-wp-more-text="' + moretext + '" ' +
|
||||
'class="wp-more-tag mce-wp-more" title="' + title + '" data-mce-resize="false" data-mce-placeholder="1" />';
|
||||
});
|
||||
}
|
||||
|
||||
if ( e.content.indexOf( '<!--nextpage-->' ) !== -1 ) {
|
||||
if ( event.content.indexOf( '<!--nextpage-->' ) !== -1 ) {
|
||||
title = __( 'Page break' );
|
||||
|
||||
e.content = e.content.replace( /<!--nextpage-->/g,
|
||||
event.content = event.content.replace( /<!--nextpage-->/g,
|
||||
'<img src="' + tinymce.Env.transparentSrc + '" data-wp-more="nextpage" class="wp-more-tag mce-wp-nextpage" ' +
|
||||
'title="' + title + '" data-mce-resize="false" data-mce-placeholder="1" />' );
|
||||
}
|
||||
|
||||
if ( event.load && event.format !== 'raw' && hasWpautop ) {
|
||||
event.content = wp.editor.autop( event.content );
|
||||
}
|
||||
|
||||
// Remove spaces from empty paragraphs.
|
||||
event.content = event.content.replace( /<p>(?: |\u00a0|\uFEFF|\s)+<\/p>/gi, '<p><br /></p>' );
|
||||
}
|
||||
});
|
||||
|
||||
@@ -191,18 +200,139 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
});
|
||||
|
||||
editor.addCommand( 'WP_Help', function() {
|
||||
editor.windowManager.open({
|
||||
url: tinymce.baseURL + '/wp-mce-help.php',
|
||||
var access = tinymce.Env.mac ? __( 'Ctrl + Alt + letter:' ) : __( 'Shift + Alt + letter:' ),
|
||||
meta = tinymce.Env.mac ? __( 'Cmd + letter:' ) : __( 'Ctrl + letter:' ),
|
||||
table1 = [],
|
||||
table2 = [],
|
||||
header, html, dialog, $wrap;
|
||||
|
||||
each( [
|
||||
{ c: 'Copy', x: 'Cut' },
|
||||
{ v: 'Paste', a: 'Select all' },
|
||||
{ z: 'Undo', y: 'Redo' },
|
||||
{ b: 'Bold', i: 'Italic' },
|
||||
{ u: 'Underline', k: 'Insert/edit link' }
|
||||
], function( row ) {
|
||||
table1.push( tr( row ) );
|
||||
} );
|
||||
|
||||
each( [
|
||||
{ 1: 'Heading 1', 2: 'Heading 2' },
|
||||
{ 3: 'Heading 3', 4: 'Heading 4' },
|
||||
{ 5: 'Heading 5', 6: 'Heading 6' },
|
||||
{ l: 'Align left', c: 'Align center' },
|
||||
{ r: 'Align right', j: 'Justify' },
|
||||
{ d: 'Strikethrough', q: 'Blockquote' },
|
||||
{ u: 'Bullet list', o: 'Numbered list' },
|
||||
{ a: 'Insert/edit link', s: 'Remove link' },
|
||||
{ m: 'Insert/edit image', t: 'Insert Read More tag' },
|
||||
{ h: 'Keyboard Shortcuts', x: 'Code' },
|
||||
{ p: 'Insert Page Break tag', w: 'Distraction-free writing mode' }
|
||||
], function( row ) {
|
||||
table2.push( tr( row ) );
|
||||
} );
|
||||
|
||||
function tr( row ) {
|
||||
var out = '<tr>';
|
||||
|
||||
each( row, function( text, key ) {
|
||||
if ( ! text ) {
|
||||
out += '<td></td><td></td>';
|
||||
} else {
|
||||
out += '<td><kbd>' + key + '</kbd></td><td>' + __( text ) + '</td>';
|
||||
}
|
||||
});
|
||||
|
||||
return out + '</tr>';
|
||||
}
|
||||
|
||||
header = [ __( 'Letter' ), __( 'Action' ), __( 'Letter' ), __( 'Action' ) ];
|
||||
header = '<tr><th>' + header.join( '</th><th>' ) + '</th></tr>';
|
||||
|
||||
html = '<div class="wp-editor-help">';
|
||||
|
||||
// Main section, default and additional shortcuts
|
||||
html = html +
|
||||
'<h2>' + __( 'Default shortcuts,' ) + ' ' + meta + '</h2>' +
|
||||
'<table class="wp-help-th-center">' +
|
||||
header +
|
||||
table1.join('') +
|
||||
'</table>' +
|
||||
'<h2>' + __( 'Additional shortcuts,' ) + ' ' + access + '</h2>' +
|
||||
'<table class="wp-help-th-center">' +
|
||||
header +
|
||||
table2.join('') +
|
||||
'</table>';
|
||||
|
||||
if ( editor.plugins.wptextpattern ) {
|
||||
// Text pattern section
|
||||
html = html +
|
||||
'<h2>' + __( 'When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.' ) + '</h2>' +
|
||||
'<table>' +
|
||||
tr({ '*': 'Bullet list' }) +
|
||||
tr({ '-': 'Bullet list' }) +
|
||||
tr({ '1.': 'Numbered list' }) +
|
||||
tr({ '1)': 'Numbered list' }) +
|
||||
'</table>';
|
||||
|
||||
html = html +
|
||||
'<h2>' + __( 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' ) + '</h2>' +
|
||||
'<table>' +
|
||||
tr({ '>': 'Blockquote' }) +
|
||||
tr({ '##': 'Heading 2' }) +
|
||||
tr({ '###': 'Heading 3' }) +
|
||||
tr({ '####': 'Heading 4' }) +
|
||||
tr({ '#####': 'Heading 5' }) +
|
||||
tr({ '######': 'Heading 6' }) +
|
||||
'</table>';
|
||||
}
|
||||
|
||||
// Focus management section
|
||||
html = html +
|
||||
'<h2>' + __( 'Focus shortcuts:' ) + '</h2>' +
|
||||
'<table>' +
|
||||
tr({ 'Alt + F8': 'Inline toolbar (when an image, link or preview is selected)' }) +
|
||||
tr({ 'Alt + F9': 'Editor menu (when enabled)' }) +
|
||||
tr({ 'Alt + F10': 'Editor toolbar' }) +
|
||||
tr({ 'Alt + F11': 'Elements path' }) +
|
||||
'</table>' +
|
||||
'<p>' + __( 'To move focus to other buttons use Tab or the arrow keys. To return focus to the editor press Escape or use one of the buttons.' ) + '</p>';
|
||||
|
||||
html += '</div>';
|
||||
|
||||
dialog = editor.windowManager.open( {
|
||||
title: 'Keyboard Shortcuts',
|
||||
width: 450,
|
||||
height: 420,
|
||||
classes: 'wp-help',
|
||||
buttons: { text: 'Close', onclick: 'close' }
|
||||
});
|
||||
});
|
||||
items: {
|
||||
type: 'container',
|
||||
classes: 'wp-help',
|
||||
html: html
|
||||
},
|
||||
buttons: {
|
||||
text: 'Close',
|
||||
onclick: 'close'
|
||||
}
|
||||
} );
|
||||
|
||||
if ( dialog.$el ) {
|
||||
dialog.$el.find( 'div[role="application"]' ).attr( 'role', 'document' );
|
||||
$wrap = dialog.$el.find( '.mce-wp-help' );
|
||||
|
||||
if ( $wrap[0] ) {
|
||||
$wrap.attr( 'tabindex', '0' );
|
||||
$wrap[0].focus();
|
||||
$wrap.on( 'keydown', function( event ) {
|
||||
// Prevent use of: page up, page down, end, home, left arrow, up arrow, right arrow, down arrow
|
||||
// in the dialog keydown handler.
|
||||
if ( event.keyCode >= 33 && event.keyCode <= 40 ) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addCommand( 'WP_Medialib', function() {
|
||||
if ( typeof wp !== 'undefined' && wp.media && wp.media.editor ) {
|
||||
if ( wp && wp.media && wp.media.editor ) {
|
||||
wp.media.editor.open( editor.id );
|
||||
}
|
||||
});
|
||||
@@ -235,7 +365,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
|
||||
// Menubar
|
||||
// Insert->Add Media
|
||||
if ( typeof wp !== 'undefined' && wp.media && wp.media.editor ) {
|
||||
if ( wp && wp.media && wp.media.editor ) {
|
||||
editor.addMenuItem( 'add_media', {
|
||||
text: 'Add Media',
|
||||
icon: 'wp-media-library',
|
||||
@@ -289,7 +419,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
doc = editor.getDoc(),
|
||||
dom = editor.dom;
|
||||
|
||||
if ( tinymce.Env.iOS ) {
|
||||
if ( env.iOS ) {
|
||||
dom.addClass( doc.documentElement, 'ios' );
|
||||
}
|
||||
|
||||
@@ -319,23 +449,22 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
});
|
||||
|
||||
// Remove invalid parent paragraphs when inserting HTML
|
||||
// TODO: still needed?
|
||||
editor.on( 'BeforeSetContent', function( e ) {
|
||||
if ( e.content ) {
|
||||
e.content = e.content.replace(/<p>\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)( [^>]*)?>/gi, '<$1$2>');
|
||||
e.content = e.content.replace(/<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre|address)>\s*<\/p>/gi, '</$1>');
|
||||
editor.on( 'BeforeSetContent', function( event ) {
|
||||
if ( event.content ) {
|
||||
event.content = event.content.replace( /<p>\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre)( [^>]*)?>/gi, '<$1$2>' )
|
||||
.replace( /<\/(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre)>\s*<\/p>/gi, '</$1>' );
|
||||
}
|
||||
});
|
||||
|
||||
if ( typeof window.jQuery !== 'undefined' ) {
|
||||
window.jQuery( document ).triggerHandler( 'tinymce-editor-init', [editor] );
|
||||
if ( $ ) {
|
||||
$( document ).triggerHandler( 'tinymce-editor-init', [editor] );
|
||||
}
|
||||
|
||||
if ( window.tinyMCEPreInit && window.tinyMCEPreInit.dragDropUpload ) {
|
||||
dom.bind( doc, 'dragstart dragend dragover drop', function( event ) {
|
||||
if ( typeof window.jQuery !== 'undefined' ) {
|
||||
if ( $ ) {
|
||||
// Trigger the jQuery handlers.
|
||||
window.jQuery( document ).trigger( new window.jQuery.Event( event ) );
|
||||
$( document ).trigger( new $.Event( event ) );
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -363,50 +492,29 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
}
|
||||
});
|
||||
|
||||
// Word count
|
||||
if ( typeof window.jQuery !== 'undefined' ) {
|
||||
editor.on( 'keyup', function( e ) {
|
||||
var key = e.keyCode || e.charCode;
|
||||
|
||||
if ( key === last ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 13 === key || 8 === last || 46 === last ) {
|
||||
window.jQuery( document ).triggerHandler( 'wpcountwords', [ editor.getContent({ format : 'raw' }) ] );
|
||||
}
|
||||
|
||||
last = key;
|
||||
});
|
||||
}
|
||||
|
||||
editor.on( 'SaveContent', function( e ) {
|
||||
editor.on( 'SaveContent', function( event ) {
|
||||
// If editor is hidden, we just want the textarea's value to be saved
|
||||
if ( ! editor.inline && editor.isHidden() ) {
|
||||
e.content = e.element.value;
|
||||
event.content = event.element.value;
|
||||
return;
|
||||
}
|
||||
|
||||
// Keep empty paragraphs :(
|
||||
e.content = e.content.replace( /<p>(?:<br ?\/?>|\u00a0|\uFEFF| )*<\/p>/g, '<p> </p>' );
|
||||
event.content = event.content.replace( /<p>(?:<br ?\/?>|\u00a0|\uFEFF| )*<\/p>/g, '<p> </p>' );
|
||||
|
||||
if ( editor.getParam( 'wpautop', true ) && typeof window.switchEditors !== 'undefined' ) {
|
||||
e.content = window.switchEditors.pre_wpautop( e.content );
|
||||
}
|
||||
});
|
||||
|
||||
// Remove spaces from empty paragraphs.
|
||||
editor.on( 'BeforeSetContent', function( event ) {
|
||||
var paragraph = tinymce.Env.webkit ? '<p><br /></p>' : '<p></p>';
|
||||
|
||||
if ( event.content ) {
|
||||
event.content = event.content.replace( /<p>(?: |\u00a0|\uFEFF|\s)+<\/p>/gi, paragraph );
|
||||
if ( hasWpautop ) {
|
||||
event.content = wp.editor.removep( event.content );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'preInit', function() {
|
||||
// Don't replace <i> with <em> and <b> with <strong> and don't remove them when empty
|
||||
editor.schema.addValidElements( '@[id|accesskey|class|dir|lang|style|tabindex|title|contenteditable|draggable|dropzone|hidden|spellcheck|translate],i,b' );
|
||||
var validElementsSetting = '@[id|accesskey|class|dir|lang|style|tabindex|' +
|
||||
'title|contenteditable|draggable|dropzone|hidden|spellcheck|translate],' + // Global attributes.
|
||||
'i,' + // Don't replace <i> with <em> and <b> with <strong> and don't remove them when empty.
|
||||
'b,' +
|
||||
'script[src|async|defer|type|charset|crossorigin|integrity]'; // Add support for <script>.
|
||||
|
||||
editor.schema.addValidElements( validElementsSetting );
|
||||
|
||||
if ( tinymce.Env.iOS ) {
|
||||
editor.settings.height = 300;
|
||||
@@ -433,7 +541,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
} );
|
||||
|
||||
editor.addShortcut( 'meta+s', '', function() {
|
||||
if ( typeof wp !== 'undefined' && wp.autosave ) {
|
||||
if ( wp && wp.autosave ) {
|
||||
wp.autosave.server.triggerSave();
|
||||
}
|
||||
} );
|
||||
@@ -443,13 +551,29 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
* Experimental: create a floating toolbar.
|
||||
* This functionality will change in the next releases. Not recommended for use by plugins.
|
||||
*/
|
||||
( function() {
|
||||
editor.on( 'preinit', function() {
|
||||
var Factory = tinymce.ui.Factory,
|
||||
settings = editor.settings,
|
||||
currentToolbar,
|
||||
currentSelection;
|
||||
activeToolbar,
|
||||
currentSelection,
|
||||
timeout,
|
||||
container = editor.getContainer(),
|
||||
wpAdminbar = document.getElementById( 'wpadminbar' ),
|
||||
mceIframe = document.getElementById( editor.id + '_ifr' ),
|
||||
mceToolbar,
|
||||
mceStatusbar,
|
||||
wpStatusbar;
|
||||
|
||||
function create( buttons ) {
|
||||
if ( container ) {
|
||||
mceToolbar = tinymce.$( '.mce-toolbar-grp', container )[0];
|
||||
mceStatusbar = tinymce.$( '.mce-statusbar', container )[0];
|
||||
}
|
||||
|
||||
if ( editor.id === 'content' ) {
|
||||
wpStatusbar = document.getElementById( 'post-status-info' );
|
||||
}
|
||||
|
||||
function create( buttons, bottom ) {
|
||||
var toolbar,
|
||||
toolbarItems = [],
|
||||
buttonGroup;
|
||||
@@ -573,120 +697,102 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
} ]
|
||||
} );
|
||||
|
||||
function hide() {
|
||||
toolbar.hide();
|
||||
}
|
||||
toolbar.bottom = bottom;
|
||||
|
||||
function reposition() {
|
||||
var top, left, minTop, className,
|
||||
windowPos, adminbar, mceToolbar, boundary,
|
||||
boundaryMiddle, boundaryVerticalMiddle, spaceTop,
|
||||
spaceBottom, windowWidth, toolbarWidth, toolbarHalf,
|
||||
iframe, iframePos, iframeWidth, iframeHeigth,
|
||||
toolbarNodeHeight, verticalSpaceNeeded,
|
||||
toolbarNode = this.getEl(),
|
||||
if ( ! currentSelection ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
var scrollX = window.pageXOffset || document.documentElement.scrollLeft,
|
||||
scrollY = window.pageYOffset || document.documentElement.scrollTop,
|
||||
windowWidth = window.innerWidth,
|
||||
windowHeight = window.innerHeight,
|
||||
iframeRect = mceIframe ? mceIframe.getBoundingClientRect() : {
|
||||
top: 0,
|
||||
right: windowWidth,
|
||||
bottom: windowHeight,
|
||||
left: 0,
|
||||
width: windowWidth,
|
||||
height: windowHeight
|
||||
},
|
||||
toolbar = this.getEl(),
|
||||
toolbarWidth = toolbar.offsetWidth,
|
||||
toolbarHeight = toolbar.offsetHeight,
|
||||
selection = currentSelection.getBoundingClientRect(),
|
||||
selectionMiddle = ( selection.left + selection.right ) / 2,
|
||||
buffer = 5,
|
||||
margin = 8,
|
||||
adminbarHeight = 0;
|
||||
spaceNeeded = toolbarHeight + margin + buffer,
|
||||
wpAdminbarBottom = wpAdminbar ? wpAdminbar.getBoundingClientRect().bottom : 0,
|
||||
mceToolbarBottom = mceToolbar ? mceToolbar.getBoundingClientRect().bottom : 0,
|
||||
mceStatusbarTop = mceStatusbar ? windowHeight - mceStatusbar.getBoundingClientRect().top : 0,
|
||||
wpStatusbarTop = wpStatusbar ? windowHeight - wpStatusbar.getBoundingClientRect().top : 0,
|
||||
blockedTop = Math.max( 0, wpAdminbarBottom, mceToolbarBottom, iframeRect.top ),
|
||||
blockedBottom = Math.max( 0, mceStatusbarTop, wpStatusbarTop, windowHeight - iframeRect.bottom ),
|
||||
spaceTop = selection.top + iframeRect.top - blockedTop,
|
||||
spaceBottom = windowHeight - iframeRect.top - selection.bottom - blockedBottom,
|
||||
editorHeight = windowHeight - blockedTop - blockedBottom,
|
||||
className = '',
|
||||
top, left;
|
||||
|
||||
if ( ! currentSelection ) {
|
||||
return;
|
||||
if ( spaceTop >= editorHeight || spaceBottom >= editorHeight ) {
|
||||
return this.hide();
|
||||
}
|
||||
|
||||
windowPos = window.pageYOffset || document.documentElement.scrollTop;
|
||||
adminbar = tinymce.$( '#wpadminbar' )[0];
|
||||
mceToolbar = tinymce.$( '.mce-toolbar-grp', editor.getContainer() )[0];
|
||||
boundary = currentSelection.getBoundingClientRect();
|
||||
boundaryMiddle = ( boundary.left + boundary.right ) / 2;
|
||||
boundaryVerticalMiddle = ( boundary.top + boundary.bottom ) / 2;
|
||||
spaceTop = boundary.top;
|
||||
spaceBottom = iframeHeigth - boundary.bottom;
|
||||
windowWidth = window.innerWidth;
|
||||
toolbarWidth = toolbarNode.offsetWidth;
|
||||
toolbarHalf = toolbarWidth / 2;
|
||||
iframe = document.getElementById( editor.id + '_ifr' );
|
||||
iframePos = DOM.getPos( iframe );
|
||||
iframeWidth = iframe.offsetWidth;
|
||||
iframeHeigth = iframe.offsetHeight;
|
||||
toolbarNodeHeight = toolbarNode.offsetHeight;
|
||||
verticalSpaceNeeded = toolbarNodeHeight + margin + buffer;
|
||||
|
||||
if ( spaceTop >= verticalSpaceNeeded ) {
|
||||
className = ' mce-arrow-down';
|
||||
top = boundary.top + iframePos.y - toolbarNodeHeight - margin;
|
||||
} else if ( spaceBottom >= verticalSpaceNeeded ) {
|
||||
className = ' mce-arrow-up';
|
||||
top = boundary.bottom + iframePos.y;
|
||||
} else {
|
||||
top = buffer;
|
||||
|
||||
if ( boundaryVerticalMiddle >= verticalSpaceNeeded ) {
|
||||
className = ' mce-arrow-down';
|
||||
} else {
|
||||
if ( this.bottom ) {
|
||||
if ( spaceBottom >= spaceNeeded ) {
|
||||
className = ' mce-arrow-up';
|
||||
top = selection.bottom + iframeRect.top + scrollY;
|
||||
} else if ( spaceTop >= spaceNeeded ) {
|
||||
className = ' mce-arrow-down';
|
||||
top = selection.top + iframeRect.top + scrollY - toolbarHeight - margin;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the image toolbar is below the main toolbar.
|
||||
if ( mceToolbar ) {
|
||||
minTop = DOM.getPos( mceToolbar ).y + mceToolbar.clientHeight;
|
||||
} else {
|
||||
minTop = iframePos.y;
|
||||
}
|
||||
|
||||
// Make sure the image toolbar is below the adminbar (if visible) or below the top of the window.
|
||||
if ( windowPos ) {
|
||||
if ( adminbar && adminbar.getBoundingClientRect().top === 0 ) {
|
||||
adminbarHeight = adminbar.clientHeight;
|
||||
}
|
||||
|
||||
if ( windowPos + adminbarHeight > minTop ) {
|
||||
minTop = windowPos + adminbarHeight;
|
||||
if ( spaceTop >= spaceNeeded ) {
|
||||
className = ' mce-arrow-down';
|
||||
top = selection.top + iframeRect.top + scrollY - toolbarHeight - margin;
|
||||
} else if ( spaceBottom >= spaceNeeded && editorHeight / 2 > selection.bottom + iframeRect.top - blockedTop ) {
|
||||
className = ' mce-arrow-up';
|
||||
top = selection.bottom + iframeRect.top + scrollY;
|
||||
}
|
||||
}
|
||||
|
||||
if ( top && minTop && ( minTop + buffer > top ) ) {
|
||||
top = minTop + buffer;
|
||||
className = '';
|
||||
if ( typeof top === 'undefined' ) {
|
||||
top = scrollY + blockedTop + buffer;
|
||||
}
|
||||
|
||||
left = boundaryMiddle - toolbarHalf;
|
||||
left += iframePos.x;
|
||||
left = selectionMiddle - toolbarWidth / 2 + iframeRect.left + scrollX;
|
||||
|
||||
if ( boundary.left < 0 || boundary.right > iframeWidth ) {
|
||||
left = iframePos.x + ( iframeWidth - toolbarWidth ) / 2;
|
||||
if ( selection.left < 0 || selection.right > iframeRect.width ) {
|
||||
left = iframeRect.left + scrollX + ( iframeRect.width - toolbarWidth ) / 2;
|
||||
} else if ( toolbarWidth >= windowWidth ) {
|
||||
className += ' mce-arrow-full';
|
||||
left = 0;
|
||||
} else if ( ( left < 0 && boundary.left + toolbarWidth > windowWidth ) ||
|
||||
( left + toolbarWidth > windowWidth && boundary.right - toolbarWidth < 0 ) ) {
|
||||
|
||||
} else if ( ( left < 0 && selection.left + toolbarWidth > windowWidth ) || ( left + toolbarWidth > windowWidth && selection.right - toolbarWidth < 0 ) ) {
|
||||
left = ( windowWidth - toolbarWidth ) / 2;
|
||||
} else if ( left < iframePos.x ) {
|
||||
} else if ( left < iframeRect.left + scrollX ) {
|
||||
className += ' mce-arrow-left';
|
||||
left = boundary.left + iframePos.x;
|
||||
} else if ( left + toolbarWidth > iframeWidth + iframePos.x ) {
|
||||
left = selection.left + iframeRect.left + scrollX;
|
||||
} else if ( left + toolbarWidth > iframeRect.width + iframeRect.left + scrollX ) {
|
||||
className += ' mce-arrow-right';
|
||||
left = boundary.right - toolbarWidth + iframePos.x;
|
||||
left = selection.right - toolbarWidth + iframeRect.left + scrollX;
|
||||
}
|
||||
|
||||
toolbarNode.className = toolbarNode.className.replace( / ?mce-arrow-[\w]+/g, '' );
|
||||
toolbarNode.className += className;
|
||||
toolbar.className = toolbar.className.replace( / ?mce-arrow-[\w]+/g, '' ) + className;
|
||||
|
||||
DOM.setStyles( toolbarNode, { 'left': left, 'top': top } );
|
||||
DOM.setStyles( toolbar, {
|
||||
'left': left,
|
||||
'top': top
|
||||
} );
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
toolbar.on( 'show', function() {
|
||||
currentToolbar = this;
|
||||
this.reposition();
|
||||
} );
|
||||
|
||||
toolbar.on( 'hide', function() {
|
||||
currentToolbar = false;
|
||||
} );
|
||||
|
||||
toolbar.on( 'keydown', function( event ) {
|
||||
if ( event.keyCode === 27 ) {
|
||||
this.hide();
|
||||
@@ -694,16 +800,8 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
}
|
||||
} );
|
||||
|
||||
toolbar.on( 'remove', function() {
|
||||
DOM.unbind( window, 'resize scroll', hide );
|
||||
editor.dom.unbind( editor.getWin(), 'resize scroll', hide );
|
||||
editor.off( 'blur hide', hide );
|
||||
} );
|
||||
|
||||
editor.once( 'init', function() {
|
||||
DOM.bind( window, 'resize scroll', hide );
|
||||
editor.dom.bind( editor.getWin(), 'resize scroll', hide );
|
||||
editor.on( 'blur hide', hide );
|
||||
editor.on( 'remove', function() {
|
||||
toolbar.remove();
|
||||
} );
|
||||
|
||||
toolbar.reposition = reposition;
|
||||
@@ -715,8 +813,8 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
editor.shortcuts.add( 'alt+119', '', function() {
|
||||
var node;
|
||||
|
||||
if ( currentToolbar ) {
|
||||
node = currentToolbar.find( 'toolbar' )[0];
|
||||
if ( activeToolbar ) {
|
||||
node = activeToolbar.find( 'toolbar' )[0];
|
||||
node && node.focus( true );
|
||||
}
|
||||
} );
|
||||
@@ -734,13 +832,55 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
|
||||
currentSelection = args.selection || args.element;
|
||||
|
||||
currentToolbar && currentToolbar.hide();
|
||||
args.toolbar && args.toolbar.show();
|
||||
if ( activeToolbar ) {
|
||||
activeToolbar.hide();
|
||||
}
|
||||
|
||||
if ( args.toolbar ) {
|
||||
activeToolbar = args.toolbar;
|
||||
activeToolbar.show();
|
||||
} else {
|
||||
activeToolbar = false;
|
||||
}
|
||||
} );
|
||||
|
||||
editor.on( 'focus', function() {
|
||||
if ( activeToolbar ) {
|
||||
activeToolbar.show();
|
||||
}
|
||||
} );
|
||||
|
||||
function hide( event ) {
|
||||
if ( activeToolbar ) {
|
||||
activeToolbar.hide();
|
||||
|
||||
if ( event.type === 'hide' ) {
|
||||
activeToolbar = false;
|
||||
} else if ( event.type === 'resize' || event.type === 'scroll' ) {
|
||||
clearTimeout( timeout );
|
||||
|
||||
timeout = setTimeout( function() {
|
||||
if ( activeToolbar && typeof activeToolbar.show === 'function' ) {
|
||||
activeToolbar.show();
|
||||
}
|
||||
}, 250 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DOM.bind( window, 'resize scroll', hide );
|
||||
editor.dom.bind( editor.getWin(), 'resize scroll', hide );
|
||||
|
||||
editor.on( 'remove', function() {
|
||||
DOM.unbind( window, 'resize scroll', hide );
|
||||
editor.dom.unbind( editor.getWin(), 'resize scroll', hide );
|
||||
} );
|
||||
|
||||
editor.on( 'blur hide', hide );
|
||||
|
||||
editor.wp = editor.wp || {};
|
||||
editor.wp._createToolbar = create;
|
||||
}());
|
||||
}, true );
|
||||
|
||||
function noop() {}
|
||||
|
||||
@@ -752,3 +892,5 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||
_getEmbed: noop
|
||||
};
|
||||
});
|
||||
|
||||
}( window.tinymce ));
|
||||
+1
-1
@@ -1 +1 @@
|
||||
tinymce.ui.FloatPanel.zIndex=100100,tinymce.PluginManager.add("wordpress",function(a){function b(b){var c,e,h,i=0;e="hide"===b,a.theme.panel&&(h=a.theme.panel.find(".toolbar:not(.menubar)")),!h||h.length<2||"hide"===b&&!h[1].visible()||(!b&&h[1].visible()&&(b="hide"),g(h,function(a,c){c>0&&("hide"===b?(a.hide(),i+=30):(a.show(),i-=30))}),i&&!e&&(tinymce.Env.iOS||(c=a.getContentAreaContainer().firstChild,f.setStyle(c,"height",c.clientHeight+i)),"hide"===b?(setUserSetting("hidetb","0"),d&&d.active(!1)):(setUserSetting("hidetb","1"),d&&d.active(!0))),a.fire("wp-toolbar-toggle"))}function c(){}var d,e,f=tinymce.DOM,g=tinymce.each,h=a.editorManager.i18n.translate,i=0;return"undefined"!=typeof window.jQuery&&window.jQuery(document).triggerHandler("tinymce-editor-setup",[a]),a.addButton("wp_adv",{tooltip:"Toolbar Toggle",cmd:"WP_Adv",onPostRender:function(){d=this,d.active("1"===getUserSetting("hidetb")?!0:!1)}}),a.on("PostRender",function(){a.getParam("wordpress_adv_hidden",!0)&&"0"===getUserSetting("hidetb","0")&&b("hide")}),a.addCommand("WP_Adv",function(){b()}),a.on("focus",function(){window.wpActiveEditor=a.id}),a.on("BeforeSetContent",function(a){var b;a.content&&(-1!==a.content.indexOf("<!--more")&&(b=h("Read more..."),a.content=a.content.replace(/<!--more(.*?)-->/g,function(a,c){return'<img src="'+tinymce.Env.transparentSrc+'" data-wp-more="more" data-wp-more-text="'+c+'" class="wp-more-tag mce-wp-more" title="'+b+'" data-mce-resize="false" data-mce-placeholder="1" />'})),-1!==a.content.indexOf("<!--nextpage-->")&&(b=h("Page break"),a.content=a.content.replace(/<!--nextpage-->/g,'<img src="'+tinymce.Env.transparentSrc+'" data-wp-more="nextpage" class="wp-more-tag mce-wp-nextpage" title="'+b+'" data-mce-resize="false" data-mce-placeholder="1" />')))}),a.on("PostProcess",function(a){a.get&&(a.content=a.content.replace(/<img[^>]+>/g,function(a){var b,c="";return-1!==a.indexOf('data-wp-more="more"')?((b=a.match(/data-wp-more-text="([^"]+)"/))&&(c=b[1]),a="<!--more"+c+"-->"):-1!==a.indexOf('data-wp-more="nextpage"')&&(a="<!--nextpage-->"),a}))}),a.on("ResolveName",function(b){var c;"IMG"===b.target.nodeName&&(c=a.dom.getAttrib(b.target,"data-wp-more"))&&(b.name=c)}),a.addCommand("WP_More",function(b){var c,d,e,f="wp-more-tag",g=a.dom,i=a.selection.getNode();return b=b||"more",f+=" mce-wp-"+b,e="more"===b?"Read more...":"Next page",e=h(e),d='<img src="'+tinymce.Env.transparentSrc+'" title="'+e+'" class="'+f+'" data-wp-more="'+b+'" data-mce-resize="false" data-mce-placeholder="1" />',"BODY"===i.nodeName||"P"===i.nodeName&&"BODY"===i.parentNode.nodeName?void a.insertContent(d):(c=g.getParent(i,function(a){return a.parentNode&&"BODY"===a.parentNode.nodeName?!0:!1},a.getBody()),void(c&&("P"===c.nodeName?c.appendChild(g.create("p",null,d).firstChild):g.insertAfter(g.create("p",null,d),c),a.nodeChanged())))}),a.addCommand("WP_Code",function(){a.formatter.toggle("code")}),a.addCommand("WP_Page",function(){a.execCommand("WP_More","nextpage")}),a.addCommand("WP_Help",function(){a.windowManager.open({url:tinymce.baseURL+"/wp-mce-help.php",title:"Keyboard Shortcuts",width:450,height:420,classes:"wp-help",buttons:{text:"Close",onclick:"close"}})}),a.addCommand("WP_Medialib",function(){"undefined"!=typeof wp&&wp.media&&wp.media.editor&&wp.media.editor.open(a.id)}),a.addButton("wp_more",{tooltip:"Insert Read More tag",onclick:function(){a.execCommand("WP_More","more")}}),a.addButton("wp_page",{tooltip:"Page break",onclick:function(){a.execCommand("WP_More","nextpage")}}),a.addButton("wp_help",{tooltip:"Keyboard Shortcuts",cmd:"WP_Help"}),a.addButton("wp_code",{tooltip:"Code",cmd:"WP_Code",stateSelector:"code"}),"undefined"!=typeof wp&&wp.media&&wp.media.editor&&a.addMenuItem("add_media",{text:"Add Media",icon:"wp-media-library",context:"insert",cmd:"WP_Medialib"}),a.addMenuItem("wp_more",{text:"Insert Read More tag",icon:"wp_more",context:"insert",onclick:function(){a.execCommand("WP_More","more")}}),a.addMenuItem("wp_page",{text:"Page break",icon:"wp_page",context:"insert",onclick:function(){a.execCommand("WP_More","nextpage")}}),a.on("BeforeExecCommand",function(b){!tinymce.Env.webkit||"InsertUnorderedList"!==b.command&&"InsertOrderedList"!==b.command||(e||(e=a.dom.create("style",{type:"text/css"},"#tinymce,#tinymce span,#tinymce li,#tinymce li>span,#tinymce p,#tinymce p>span{font:medium sans-serif;color:#000;line-height:normal;}")),a.getDoc().head.appendChild(e))}),a.on("ExecCommand",function(b){tinymce.Env.webkit&&e&&("InsertUnorderedList"===b.command||"InsertOrderedList"===b.command)&&a.dom.remove(e)}),a.on("init",function(){var b=tinymce.Env,c=["mceContentBody"],d=a.getDoc(),e=a.dom;tinymce.Env.iOS&&e.addClass(d.documentElement,"ios"),"rtl"===a.getParam("directionality")&&(c.push("rtl"),e.setAttrib(d.documentElement,"dir","rtl")),b.ie?9===parseInt(b.ie,10)?c.push("ie9"):8===parseInt(b.ie,10)?c.push("ie8"):b.ie<8&&c.push("ie7"):b.webkit&&c.push("webkit"),c.push("wp-editor"),g(c,function(a){a&&e.addClass(d.body,a)}),a.onLine truncated
|
||||
!function(a){a.ui.FloatPanel.zIndex=100100,a.PluginManager.add("wordpress",function(b){function c(c){var d,f,i,j=0;f="hide"===c,b.theme.panel&&(i=b.theme.panel.find(".toolbar:not(.menubar)")),!i||i.length<2||"hide"===c&&!i[1].visible()||(!c&&i[1].visible()&&(c="hide"),h(i,function(a,b){b>0&&("hide"===c?(a.hide(),j+=30):(a.show(),j-=30))}),j&&!f&&(a.Env.iOS||(d=b.getContentAreaContainer().firstChild,g.setStyle(d,"height",d.clientHeight+j)),"hide"===c?(setUserSetting("hidetb","0"),e&&e.active(!1)):(setUserSetting("hidetb","1"),e&&e.active(!0))),b.fire("wp-toolbar-toggle"))}function d(){}var e,f,g=a.DOM,h=a.each,i=b.editorManager.i18n.translate,j=window.jQuery,k=window.wp,l=k&&k.editor&&k.editor.autop&&b.getParam("wpautop",!0);return j&&j(document).triggerHandler("tinymce-editor-setup",[b]),b.addButton("wp_adv",{tooltip:"Toolbar Toggle",cmd:"WP_Adv",onPostRender:function(){e=this,e.active("1"===getUserSetting("hidetb")?!0:!1)}}),b.on("PostRender",function(){b.getParam("wordpress_adv_hidden",!0)&&"0"===getUserSetting("hidetb","0")&&c("hide")}),b.addCommand("WP_Adv",function(){c()}),b.on("focus",function(){window.wpActiveEditor=b.id}),b.on("BeforeSetContent",function(b){var c;b.content&&(-1!==b.content.indexOf("<!--more")&&(c=i("Read more..."),b.content=b.content.replace(/<!--more(.*?)-->/g,function(b,d){return'<img src="'+a.Env.transparentSrc+'" data-wp-more="more" data-wp-more-text="'+d+'" class="wp-more-tag mce-wp-more" title="'+c+'" data-mce-resize="false" data-mce-placeholder="1" />'})),-1!==b.content.indexOf("<!--nextpage-->")&&(c=i("Page break"),b.content=b.content.replace(/<!--nextpage-->/g,'<img src="'+a.Env.transparentSrc+'" data-wp-more="nextpage" class="wp-more-tag mce-wp-nextpage" title="'+c+'" data-mce-resize="false" data-mce-placeholder="1" />')),b.load&&"raw"!==b.format&&l&&(b.content=k.editor.autop(b.content)),b.content=b.content.replace(/<p>(?: |\u00a0|\uFEFF|\s)+<\/p>/gi,"<p><br /></p>"))}),b.on("PostProcess",function(a){a.get&&(a.content=a.content.replace(/<img[^>]+>/g,function(a){var b,c="";return-1!==a.indexOf('data-wp-more="more"')?((b=a.match(/data-wp-more-text="([^"]+)"/))&&(c=b[1]),a="<!--more"+c+"-->"):-1!==a.indexOf('data-wp-more="nextpage"')&&(a="<!--nextpage-->"),a}))}),b.on("ResolveName",function(a){var c;"IMG"===a.target.nodeName&&(c=b.dom.getAttrib(a.target,"data-wp-more"))&&(a.name=c)}),b.addCommand("WP_More",function(c){var d,e,f,g="wp-more-tag",h=b.dom,j=b.selection.getNode();return c=c||"more",g+=" mce-wp-"+c,f="more"===c?"Read more...":"Next page",f=i(f),e='<img src="'+a.Env.transparentSrc+'" title="'+f+'" class="'+g+'" data-wp-more="'+c+'" data-mce-resize="false" data-mce-placeholder="1" />',"BODY"===j.nodeName||"P"===j.nodeName&&"BODY"===j.parentNode.nodeName?void b.insertContent(e):(d=h.getParent(j,function(a){return a.parentNode&&"BODY"===a.parentNode.nodeName?!0:!1},b.getBody()),void(d&&("P"===d.nodeName?d.appendChild(h.create("p",null,e).firstChild):h.insertAfter(h.create("p",null,e),d),b.nodeChanged())))}),b.addCommand("WP_Code",function(){b.formatter.toggle("code")}),b.addCommand("WP_Page",function(){b.execCommand("WP_More","nextpage")}),b.addCommand("WP_Help",function(){function c(a){var b="<tr>";return h(a,function(a,c){b+=a?"<td><kbd>"+c+"</kbd></td><td>"+i(a)+"</td>":"<td></td><td></td>"}),b+"</tr>"}var d,e,f,g,j=i(a.Env.mac?"Ctrl + Alt + letter:":"Shift + Alt + letter:"),k=i(a.Env.mac?"Cmd + letter:":"Ctrl + letter:"),l=[],m=[];h([{c:"Copy",x:"Cut"},{v:"Paste",a:"Select all"},{z:"Undo",y:"Redo"},{b:"Bold",i:"Italic"},{u:"Underline",k:"Insert/edit link"}],function(a){l.push(c(a))}),h([{1:"Heading 1",2:"Heading 2"},{3:"Heading 3",4:"Heading 4"},{5:"Heading 5",6:"Heading 6"},{l:"Align left",c:"Align center"},{r:"Align right",j:"Justify"},{d:"Strikethrough",q:"Blockquote"},{u:"Bullet list",o:"Numbered list"},{a:"Insert/edit link",s:"Remove link"},{m:"Insert/edit image",t:"Insert Read More tag"},{h:"Keyboard Shortcuts",x:"Code"},{p:"Insert Page Break tag",w:"Distraction-free writing mode"}],function(a){m.push(c(a))}),d=[i("Letter"),i("Action"),i("Letter"),i("Action")],d="<tr><th>"+d.join("</th><th>")+"</th></tr>",e='<div class="wp-editor-help">',e=e+"<h2>"+i("Default shortcuts,")+" "+k+'</h2><table class="wp-help-th-center">'+d+l.join("")+"</table><h2>"+i("Additional shortcuts,")+" "+j+'</h2><table class="wp-help-th-center">'+d+m.join("")+"</table>",b.plugins.wptextpattern&&(e=e+"<h2>"+i("When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.")+"</h2><table>"+c({"*":"Bullet list"})+c({"-":"Bullet list"})+c({"1.":"Numbered list"})+c({"1)":"Numbered list"})+"</table>",e=e+"<h2>"+i("The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.")+"</h2><table>"+c({">":"Blockquote"})+c({"##":"Heading 2"})+c({"###":"Heading 3"})+c({"####":"Heading 4"})+c({"#####":"Heading 5"})+c({"######":"Heading 6"})+"</Line truncated
|
||||
Reference in new issue
Block a user