2015-06-21 18:01:28 -04:00
/* global getUserSetting, setUserSetting */
( function ( tinymce ) {
2020-01-28 19:45:18 -05:00
// Set the minimum value for the modals z-index higher than #wpadminbar (100000).
2017-10-24 12:52:56 -04:00
if ( ! tinymce . ui . FloatPanel . zIndex || tinymce . ui . FloatPanel . zIndex < 100100 ) {
2017-07-01 16:33:41 -04:00
tinymce . ui . FloatPanel . zIndex = 100100 ;
}
2014-03-07 19:41:16 -05:00
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
tinymce . PluginManager . add ( 'wordpress' , function ( editor ) {
2015-06-21 18:01:28 -04:00
var wpAdvButton , style ,
DOM = tinymce . DOM ,
2015-04-06 18:51:27 -04:00
each = tinymce . each ,
_ _ = editor . editorManager . i18n . translate ,
2015-06-21 18:01:28 -04:00
$ = window . jQuery ,
wp = window . wp ,
2021-09-08 19:29:58 -04:00
hasWpautop = ( wp && wp . editor && wp . editor . autop && editor . getParam ( 'wpautop' , true ) ) ,
2019-03-28 20:49:51 -04:00
wpTooltips = false ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
2015-06-21 18:01:28 -04:00
if ( $ ) {
2020-12-29 08:21:07 -05:00
// Runs as soon as TinyMCE has started initializing, while plugins are loading.
// Handlers attached after the `tinymce.init()` call may not get triggered for this instance.
2015-06-21 18:01:28 -04:00
$ ( document ) . triggerHandler ( 'tinymce-editor-setup' , [ editor ] ) ;
2014-11-13 17:31:22 -05:00
}
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
function toggleToolbars ( state ) {
2019-03-12 16:14:52 -04:00
var initial , toolbars , iframeHeight ,
2018-12-16 22:23:55 -05:00
pixels = 0 ,
classicBlockToolbar = tinymce . $ ( '.block-library-classic__toolbar' ) ;
if ( state === 'hide' ) {
initial = true ;
} else if ( classicBlockToolbar . length && ! classicBlockToolbar . hasClass ( 'has-advanced-toolbar' ) ) {
// Show the second, third, etc. toolbar rows in the Classic block instance.
classicBlockToolbar . addClass ( 'has-advanced-toolbar' ) ;
state = 'show' ;
}
2013-12-29 20:54:11 -05:00
if ( editor . theme . panel ) {
2014-02-18 01:32:14 -05:00
toolbars = editor . theme . panel . find ( '.toolbar:not(.menubar)' ) ;
2013-12-29 20:54:11 -05:00
}
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
2018-12-16 22:23:55 -05:00
if ( toolbars && toolbars . length > 1 ) {
if ( ! state && toolbars [ 1 ] . visible ( ) ) {
state = 'hide' ;
}
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
2018-12-16 22:23:55 -05:00
each ( toolbars , function ( toolbar , i ) {
if ( i > 0 ) {
if ( state === 'hide' ) {
toolbar . hide ( ) ;
2019-03-12 16:14:52 -04:00
pixels += 34 ;
2018-12-16 22:23:55 -05:00
} else {
toolbar . show ( ) ;
2019-03-12 16:14:52 -04:00
pixels -= 34 ;
2018-12-16 22:23:55 -05:00
}
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
}
2018-12-16 22:23:55 -05:00
} ) ;
}
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
2018-12-16 22:23:55 -05:00
// Resize editor iframe, not needed for iOS and inline instances.
2019-03-12 16:14:52 -04:00
// Don't resize if the editor is in a hidden container.
if ( pixels && ! tinymce . Env . iOS && editor . iframeElement && editor . iframeElement . clientHeight ) {
iframeHeight = editor . iframeElement . clientHeight + pixels ;
// Keep min-height.
if ( iframeHeight > 50 ) {
DOM . setStyle ( editor . iframeElement , 'height' , iframeHeight ) ;
}
2018-12-16 22:23:55 -05:00
}
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
2018-12-16 22:23:55 -05:00
if ( ! initial ) {
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
if ( state === 'hide' ) {
2018-12-16 22:23:55 -05:00
setUserSetting ( 'hidetb' , '0' ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
wpAdvButton && wpAdvButton . active ( false ) ;
} else {
2018-12-16 22:23:55 -05:00
setUserSetting ( 'hidetb' , '1' ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
wpAdvButton && wpAdvButton . active ( true ) ;
}
}
2014-07-09 18:06:15 -04:00
editor . fire ( 'wp-toolbar-toggle' ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
}
// Add the kitchen sink button :)
editor . addButton ( 'wp_adv' , {
tooltip : 'Toolbar Toggle' ,
cmd : 'WP_Adv' ,
onPostRender : function ( ) {
wpAdvButton = this ;
2018-12-16 22:23:55 -05:00
wpAdvButton . active ( getUserSetting ( 'hidetb' ) === '1' ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
}
} ) ;
2020-01-28 19:45:18 -05:00
// Hide the toolbars after loading.
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
editor . on ( 'PostRender' , function ( ) {
2014-04-22 09:50:14 -04:00
if ( editor . getParam ( 'wordpress_adv_hidden' , true ) && getUserSetting ( 'hidetb' , '0' ) === '0' ) {
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
toggleToolbars ( 'hide' ) ;
2018-12-16 22:23:55 -05:00
} else {
tinymce . $ ( '.block-library-classic__toolbar' ) . addClass ( 'has-advanced-toolbar' ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
}
} ) ;
editor . addCommand ( 'WP_Adv' , function ( ) {
toggleToolbars ( ) ;
} ) ;
editor . on ( 'focus' , function ( ) {
window . wpActiveEditor = editor . id ;
} ) ;
2015-06-21 18:01:28 -04:00
editor . on ( 'BeforeSetContent' , function ( event ) {
2015-07-28 10:12:25 -04:00
var title ;
2014-07-28 19:45:18 -04:00
2015-06-21 18:01:28 -04:00
if ( event . content ) {
if ( event . content . indexOf ( '<!--more' ) !== - 1 ) {
2015-04-06 18:51:27 -04:00
title = _ _ ( 'Read more...' ) ;
2014-07-28 19:45:18 -04:00
2015-06-21 18:01:28 -04:00
event . content = event . content . replace ( /<!--more(.*?)-->/g , function ( match , moretext ) {
2014-07-28 19:45:18 -04:00
return '<img src="' + tinymce . Env . transparentSrc + '" data-wp-more="more" data-wp-more-text="' + moretext + '" ' +
2015-11-07 11:12:27 -05:00
'class="wp-more-tag mce-wp-more" alt="" title="' + title + '" data-mce-resize="false" data-mce-placeholder="1" />' ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
} ) ;
}
2015-06-21 18:01:28 -04:00
if ( event . content . indexOf ( '<!--nextpage-->' ) !== - 1 ) {
2015-04-06 18:51:27 -04:00
title = _ _ ( 'Page break' ) ;
2014-07-28 19:45:18 -04:00
2015-06-21 18:01:28 -04:00
event . content = event . content . replace ( /<!--nextpage-->/g ,
2014-07-28 19:45:18 -04:00
'<img src="' + tinymce . Env . transparentSrc + '" data-wp-more="nextpage" class="wp-more-tag mce-wp-nextpage" ' +
2015-11-07 11:12:27 -05:00
'alt="" title="' + title + '" data-mce-resize="false" data-mce-placeholder="1" />' ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
}
2015-06-21 18:01:28 -04:00
2018-06-27 22:25:32 -04:00
if ( event . load && event . format !== 'raw' ) {
if ( hasWpautop ) {
2021-09-08 19:29:58 -04:00
event . content = wp . editor . autop ( event . content ) ;
2018-06-27 22:25:32 -04:00
} else {
// Prevent creation of paragraphs out of multiple HTML comments.
event . content = event . content . replace ( /-->\s+<!--/g , '--><!--' ) ;
}
2015-06-21 18:01:28 -04:00
}
2015-07-28 10:12:25 -04:00
2016-07-12 18:09:31 -04:00
if ( event . content . indexOf ( '<script' ) !== - 1 || event . content . indexOf ( '<style' ) !== - 1 ) {
event . content = event . content . replace ( /<(script|style)[^>]*>[\s\S]*?<\/\1>/g , function ( match , tag ) {
return '<img ' +
'src="' + tinymce . Env . transparentSrc + '" ' +
'data-wp-preserve="' + encodeURIComponent ( match ) + '" ' +
'data-mce-resize="false" ' +
'data-mce-placeholder="1" ' +
'class="mce-object" ' +
'width="20" height="20" ' +
'alt="<' + tag + '>" ' +
'title="<' + tag + '>" ' +
'/>' ;
} ) ;
}
2017-01-14 21:06:41 -05:00
}
} ) ;
2016-07-12 18:09:31 -04:00
2017-01-14 21:06:41 -05:00
editor . on ( 'setcontent' , function ( ) {
// Remove spaces from empty paragraphs.
editor . $ ( 'p' ) . each ( function ( i , node ) {
if ( node . innerHTML && node . innerHTML . length < 10 ) {
var html = tinymce . trim ( node . innerHTML ) ;
2016-02-20 14:56:27 -05:00
2017-01-14 21:06:41 -05:00
if ( ! html || html === ' ' ) {
node . innerHTML = ( tinymce . Env . ie && tinymce . Env . ie < 11 ) ? '' : '<br data-mce-bogus="1">' ;
}
}
} ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
} ) ;
2016-07-12 18:09:31 -04:00
editor . on ( 'PostProcess' , function ( event ) {
if ( event . get ) {
event . content = event . content . replace ( /<img[^>]+>/g , function ( image ) {
var match ,
string ,
moretext = '' ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
2014-07-28 19:45:18 -04:00
if ( image . indexOf ( 'data-wp-more="more"' ) !== - 1 ) {
if ( match = image . match ( /data-wp-more-text="([^"]+)"/ ) ) {
moretext = match [ 1 ] ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
}
2014-07-28 19:45:18 -04:00
2016-07-12 18:09:31 -04:00
string = '<!--more' + moretext + '-->' ;
2014-07-28 19:45:18 -04:00
} else if ( image . indexOf ( 'data-wp-more="nextpage"' ) !== - 1 ) {
2016-07-12 18:09:31 -04:00
string = '<!--nextpage-->' ;
} else if ( image . indexOf ( 'data-wp-preserve' ) !== - 1 ) {
if ( match = image . match ( / data-wp-preserve="([^"]+)"/ ) ) {
string = decodeURIComponent ( match [ 1 ] ) ;
}
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
}
2016-07-12 18:09:31 -04:00
return string || image ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
} ) ;
}
} ) ;
2020-01-28 19:45:18 -05:00
// Display the tag name instead of img in element path.
2014-07-28 19:45:18 -04:00
editor . on ( 'ResolveName' , function ( event ) {
var attr ;
if ( event . target . nodeName === 'IMG' && ( attr = editor . dom . getAttrib ( event . target , 'data-wp-more' ) ) ) {
event . name = attr ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
}
} ) ;
2020-01-28 19:45:18 -05:00
// Register commands.
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
editor . addCommand ( 'WP_More' , function ( tag ) {
2014-03-25 22:08:15 -04:00
var parent , html , title ,
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
classname = 'wp-more-tag' ,
dom = editor . dom ,
2017-07-03 17:41:41 -04:00
node = editor . selection . getNode ( ) ,
rootNode = editor . getBody ( ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
tag = tag || 'more' ;
classname += ' mce-wp-' + tag ;
2014-07-28 19:45:18 -04:00
title = tag === 'more' ? 'Read more...' : 'Next page' ;
2015-04-06 18:51:27 -04:00
title = _ _ ( title ) ;
2015-11-07 11:12:27 -05:00
html = '<img src="' + tinymce . Env . transparentSrc + '" alt="" title="' + title + '" class="' + classname + '" ' +
2014-07-28 19:45:18 -04:00
'data-wp-more="' + tag + '" data-mce-resize="false" data-mce-placeholder="1" />' ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
2020-01-28 19:45:18 -05:00
// Most common case.
2017-07-03 17:41:41 -04:00
if ( node === rootNode || ( node . nodeName === 'P' && node . parentNode === rootNode ) ) {
2014-03-25 22:08:15 -04:00
editor . insertContent ( html ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
return ;
}
2020-01-28 19:45:18 -05:00
// Get the top level parent node.
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
parent = dom . getParent ( node , function ( found ) {
2017-07-03 17:41:41 -04:00
if ( found . parentNode && found . parentNode === rootNode ) {
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
return true ;
}
return false ;
} , editor . getBody ( ) ) ;
if ( parent ) {
2014-03-25 22:08:15 -04:00
if ( parent . nodeName === 'P' ) {
parent . appendChild ( dom . create ( 'p' , null , html ) . firstChild ) ;
} else {
dom . insertAfter ( dom . create ( 'p' , null , html ) , parent ) ;
2014-01-14 00:46:11 -05:00
}
editor . nodeChanged ( ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
}
} ) ;
2014-03-14 18:43:16 -04:00
editor . addCommand ( 'WP_Code' , function ( ) {
editor . formatter . toggle ( 'code' ) ;
} ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
editor . addCommand ( 'WP_Page' , function ( ) {
editor . execCommand ( 'WP_More' , 'nextpage' ) ;
} ) ;
editor . addCommand ( 'WP_Help' , function ( ) {
2015-06-26 00:40:24 -04:00
var access = tinymce . Env . mac ? _ _ ( 'Ctrl + Alt + letter:' ) : _ _ ( 'Shift + Alt + letter:' ) ,
2022-04-01 07:09:07 -04:00
meta = tinymce . Env . mac ? _ _ ( '⌘ + letter:' ) : _ _ ( 'Ctrl + letter:' ) ,
2015-06-26 00:40:24 -04:00
table1 = [ ] ,
table2 = [ ] ,
2016-10-24 21:40:31 -04:00
row1 = { } ,
row2 = { } ,
i1 = 0 ,
i2 = 0 ,
labels = editor . settings . wp _shortcut _labels ,
2015-07-26 15:14:26 -04:00
header , html , dialog , $wrap ;
2015-06-26 00:40:24 -04:00
2016-10-24 21:40:31 -04:00
if ( ! labels ) {
return ;
}
2015-06-26 00:40:24 -04:00
2016-10-24 21:40:31 -04:00
function tr ( row , columns ) {
2015-06-26 00:40:24 -04:00
var out = '<tr>' ;
2016-10-24 21:40:31 -04:00
var i = 0 ;
columns = columns || 1 ;
2015-06-26 00:40:24 -04:00
each ( row , function ( text , key ) {
2016-10-24 21:40:31 -04:00
out += '<td><kbd>' + key + '</kbd></td><td>' + _ _ ( text ) + '</td>' ;
i ++ ;
2015-06-26 00:40:24 -04:00
} ) ;
2016-10-24 21:40:31 -04:00
while ( i < columns ) {
out += '<td></td><td></td>' ;
i ++ ;
}
2015-06-26 00:40:24 -04:00
return out + '</tr>' ;
}
2016-10-24 21:40:31 -04:00
each ( labels , function ( label , name ) {
var letter ;
if ( label . indexOf ( 'meta' ) !== - 1 ) {
i1 ++ ;
letter = label . replace ( 'meta' , '' ) . toLowerCase ( ) ;
if ( letter ) {
row1 [ letter ] = name ;
if ( i1 % 2 === 0 ) {
table1 . push ( tr ( row1 , 2 ) ) ;
row1 = { } ;
}
}
} else if ( label . indexOf ( 'access' ) !== - 1 ) {
i2 ++ ;
letter = label . replace ( 'access' , '' ) . toLowerCase ( ) ;
if ( letter ) {
row2 [ letter ] = name ;
if ( i2 % 2 === 0 ) {
table2 . push ( tr ( row2 , 2 ) ) ;
row2 = { } ;
}
}
}
} ) ;
// Add remaining single entries.
if ( i1 % 2 > 0 ) {
table1 . push ( tr ( row1 , 2 ) ) ;
}
if ( i2 % 2 > 0 ) {
table2 . push ( tr ( row2 , 2 ) ) ;
}
2015-06-26 00:40:24 -04:00
header = [ _ _ ( 'Letter' ) , _ _ ( 'Action' ) , _ _ ( 'Letter' ) , _ _ ( 'Action' ) ] ;
2015-07-26 15:14:26 -04:00
header = '<tr><th>' + header . join ( '</th><th>' ) + '</th></tr>' ;
2015-06-26 00:40:24 -04:00
2015-07-08 15:43:24 -04:00
html = '<div class="wp-editor-help">' ;
2020-01-28 19:45:18 -05:00
// Main section, default and additional shortcuts.
2015-07-08 15:43:24 -04:00
html = html +
2015-07-26 15:14:26 -04:00
'<h2>' + _ _ ( 'Default shortcuts,' ) + ' ' + meta + '</h2>' +
2016-02-28 14:00:27 -05:00
'<table class="wp-help-th-center fixed">' +
2015-07-08 15:43:24 -04:00
header +
table1 . join ( '' ) +
'</table>' +
2015-07-26 15:14:26 -04:00
'<h2>' + _ _ ( 'Additional shortcuts,' ) + ' ' + access + '</h2>' +
2016-02-28 14:00:27 -05:00
'<table class="wp-help-th-center fixed">' +
2015-07-08 15:43:24 -04:00
header +
table2 . join ( '' ) +
'</table>' ;
2016-02-28 14:00:27 -05:00
if ( editor . plugins . wptextpattern && ( ! tinymce . Env . ie || tinymce . Env . ie > 8 ) ) {
2020-01-28 19:45:18 -05:00
// Text pattern section.
2015-07-08 15:43:24 -04:00
html = html +
2015-07-29 17:54:24 -04:00
'<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>' +
2016-02-28 14:00:27 -05:00
'<table class="wp-help-th-center fixed">' +
tr ( { '*' : 'Bullet list' , '1.' : 'Numbered list' } ) +
tr ( { '-' : 'Bullet list' , '1)' : 'Numbered list' } ) +
2015-07-29 17:07:23 -04:00
'</table>' ;
html = html +
2015-07-29 17:54:24 -04:00
'<h2>' + _ _ ( 'The following formatting shortcuts are replaced when pressing Enter. Press Escape or the Undo button to undo.' ) + '</h2>' +
2016-02-28 14:00:27 -05:00
'<table class="wp-help-single">' +
2015-07-08 15:43:24 -04:00
tr ( { '>' : 'Blockquote' } ) +
tr ( { '##' : 'Heading 2' } ) +
tr ( { '###' : 'Heading 3' } ) +
tr ( { '####' : 'Heading 4' } ) +
tr ( { '#####' : 'Heading 5' } ) +
tr ( { '######' : 'Heading 6' } ) +
2016-02-28 14:18:26 -05:00
tr ( { '---' : 'Horizontal line' } ) +
2015-07-08 15:43:24 -04:00
'</table>' ;
}
2020-01-28 19:45:18 -05:00
// Focus management section.
2015-07-08 15:43:24 -04:00
html = html +
2015-07-26 15:14:26 -04:00
'<h2>' + _ _ ( 'Focus shortcuts:' ) + '</h2>' +
2016-02-28 14:00:27 -05:00
'<table class="wp-help-single">' +
2015-07-08 15:43:24 -04:00
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>' ;
2015-07-26 15:14:26 -04:00
dialog = editor . windowManager . open ( {
2018-12-16 22:32:21 -05:00
title : editor . settings . classic _block _editor ? 'Classic Block Keyboard Shortcuts' : 'Keyboard Shortcuts' ,
2015-06-26 00:40:24 -04:00
items : {
type : 'container' ,
classes : 'wp-help' ,
2015-07-08 15:43:24 -04:00
html : html
2015-06-26 00:40:24 -04:00
} ,
buttons : {
text : 'Close' ,
onclick : 'close'
}
} ) ;
2015-07-26 15:14:26 -04:00
if ( dialog . $el ) {
dialog . $el . find ( 'div[role="application"]' ) . attr ( 'role' , 'document' ) ;
$wrap = dialog . $el . find ( '.mce-wp-help' ) ;
if ( $wrap [ 0 ] ) {
2015-07-26 17:37:24 -04:00
$wrap . attr ( 'tabindex' , '0' ) ;
2015-07-26 15:14:26 -04:00
$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 ( ) ;
}
} ) ;
}
}
2015-06-26 00:40:24 -04:00
} ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
editor . addCommand ( 'WP_Medialib' , function ( ) {
2015-06-21 18:01:28 -04:00
if ( wp && wp . media && wp . media . editor ) {
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
wp . media . editor . open ( editor . id ) ;
}
} ) ;
2020-01-28 19:45:18 -05:00
// Register buttons.
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
editor . addButton ( 'wp_more' , {
tooltip : 'Insert Read More tag' ,
onclick : function ( ) {
editor . execCommand ( 'WP_More' , 'more' ) ;
}
} ) ;
editor . addButton ( 'wp_page' , {
tooltip : 'Page break' ,
onclick : function ( ) {
editor . execCommand ( 'WP_More' , 'nextpage' ) ;
}
} ) ;
editor . addButton ( 'wp_help' , {
2014-04-07 22:32:14 -04:00
tooltip : 'Keyboard Shortcuts' ,
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
cmd : 'WP_Help'
} ) ;
2014-03-14 18:43:16 -04:00
editor . addButton ( 'wp_code' , {
tooltip : 'Code' ,
cmd : 'WP_Code' ,
stateSelector : 'code'
} ) ;
2020-01-28 19:45:18 -05:00
// Insert->Add Media.
2015-06-21 18:01:28 -04:00
if ( wp && wp . media && wp . media . editor ) {
2018-12-16 22:23:55 -05:00
editor . addButton ( 'wp_add_media' , {
tooltip : 'Add Media' ,
icon : 'dashicon dashicons-admin-media' ,
cmd : 'WP_Medialib'
} ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
editor . addMenuItem ( 'add_media' , {
text : 'Add Media' ,
2014-03-12 04:19:14 -04:00
icon : 'wp-media-library' ,
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
context : 'insert' ,
cmd : 'WP_Medialib'
} ) ;
}
2020-01-28 19:45:18 -05:00
// Insert "Read More...".
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
editor . addMenuItem ( 'wp_more' , {
text : 'Insert Read More tag' ,
2014-03-12 04:19:14 -04:00
icon : 'wp_more' ,
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
context : 'insert' ,
onclick : function ( ) {
editor . execCommand ( 'WP_More' , 'more' ) ;
}
} ) ;
2020-01-28 19:45:18 -05:00
// Insert "Next Page".
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
editor . addMenuItem ( 'wp_page' , {
text : 'Page break' ,
2014-03-12 04:19:14 -04:00
icon : 'wp_page' ,
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
context : 'insert' ,
onclick : function ( ) {
editor . execCommand ( 'WP_More' , 'nextpage' ) ;
}
} ) ;
editor . on ( 'BeforeExecCommand' , function ( e ) {
if ( tinymce . Env . webkit && ( e . command === 'InsertUnorderedList' || e . command === 'InsertOrderedList' ) ) {
if ( ! style ) {
style = editor . 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;}' ) ;
}
editor . getDoc ( ) . head . appendChild ( style ) ;
}
} ) ;
editor . on ( 'ExecCommand' , function ( e ) {
if ( tinymce . Env . webkit && style &&
( 'InsertUnorderedList' === e . command || 'InsertOrderedList' === e . command ) ) {
editor . dom . remove ( style ) ;
}
} ) ;
editor . on ( 'init' , function ( ) {
2014-03-27 13:31:14 -04:00
var env = tinymce . Env ,
2020-01-28 19:45:18 -05:00
bodyClass = [ 'mceContentBody' ] , // Back-compat for themes that use this in editor-style.css...
2014-03-07 19:41:16 -05:00
doc = editor . getDoc ( ) ,
dom = editor . dom ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
2015-06-21 18:01:28 -04:00
if ( env . iOS ) {
2014-05-29 22:38:16 -04:00
dom . addClass ( doc . documentElement , 'ios' ) ;
}
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
if ( editor . getParam ( 'directionality' ) === 'rtl' ) {
bodyClass . push ( 'rtl' ) ;
2014-04-12 20:23:15 -04:00
dom . setAttrib ( doc . documentElement , 'dir' , 'rtl' ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
}
2015-10-16 06:11:27 -04:00
dom . setAttrib ( doc . documentElement , 'lang' , editor . getParam ( 'wp_lang_attr' ) ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
if ( env . ie ) {
if ( parseInt ( env . ie , 10 ) === 9 ) {
bodyClass . push ( 'ie9' ) ;
} else if ( parseInt ( env . ie , 10 ) === 8 ) {
bodyClass . push ( 'ie8' ) ;
} else if ( env . ie < 8 ) {
bodyClass . push ( 'ie7' ) ;
}
2014-06-26 23:00:15 -04:00
} else if ( env . webkit ) {
bodyClass . push ( 'webkit' ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
}
bodyClass . push ( 'wp-editor' ) ;
2015-04-06 18:51:27 -04:00
each ( bodyClass , function ( cls ) {
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
if ( cls ) {
2014-03-07 19:41:16 -05:00
dom . addClass ( doc . body , cls ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
}
} ) ;
2020-01-28 19:45:18 -05:00
// Remove invalid parent paragraphs when inserting HTML.
2015-06-21 18:01:28 -04:00
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>' ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
}
} ) ;
2014-01-19 18:22:14 -05:00
2015-06-21 18:01:28 -04:00
if ( $ ) {
2020-12-29 08:21:07 -05:00
// Run on DOM ready. Otherwise TinyMCE may initialize earlier and handlers attached
// on DOM ready of after the `tinymce.init()` call may not get triggered.
$ ( function ( ) {
$ ( document ) . triggerHandler ( 'tinymce-editor-init' , [ editor ] ) ;
} ) ;
2014-01-19 18:22:14 -05:00
}
2014-02-04 20:10:13 -05:00
2014-04-01 22:42:16 -04:00
if ( window . tinyMCEPreInit && window . tinyMCEPreInit . dragDropUpload ) {
dom . bind ( doc , 'dragstart dragend dragover drop' , function ( event ) {
2015-06-21 18:01:28 -04:00
if ( $ ) {
2014-04-01 22:42:16 -04:00
// Trigger the jQuery handlers.
2015-06-21 18:01:28 -04:00
$ ( document ) . trigger ( new $ . Event ( event ) ) ;
2014-04-01 22:42:16 -04:00
}
} ) ;
}
2014-06-30 17:55:18 -04:00
if ( editor . getParam ( 'wp_paste_filters' , true ) ) {
2015-11-09 23:32:25 -05:00
editor . on ( 'PastePreProcess' , function ( event ) {
2020-01-28 19:45:18 -05:00
// Remove trailing <br> added by WebKit browsers to the clipboard.
2015-11-09 23:32:25 -05:00
event . content = event . content . replace ( /<br class="?Apple-interchange-newline"?>/gi , '' ) ;
2020-01-28 19:45:18 -05:00
// In WebKit this is handled by removeWebKitStyles().
2015-11-09 23:32:25 -05:00
if ( ! tinymce . Env . webkit ) {
2020-01-28 19:45:18 -05:00
// Remove all inline styles.
2014-06-30 17:55:18 -04:00
event . content = event . content . replace ( /(<[^>]+) style="[^"]*"([^>]*>)/gi , '$1$2' ) ;
2020-01-28 19:45:18 -05:00
// Put back the internal styles.
2014-06-30 17:55:18 -04:00
event . content = event . content . replace ( /(<[^>]+) data-mce-style=([^>]+>)/gi , '$1 style=$2' ) ;
2015-11-09 23:32:25 -05:00
}
} ) ;
2014-06-30 17:55:18 -04:00
editor . on ( 'PastePostProcess' , function ( event ) {
2020-01-28 19:45:18 -05:00
// Remove empty paragraphs.
2017-01-16 20:25:44 -05:00
editor . $ ( 'p' , event . node ) . each ( function ( i , node ) {
2014-06-30 17:55:18 -04:00
if ( dom . isEmpty ( node ) ) {
dom . remove ( node ) ;
}
} ) ;
2017-01-16 20:25:44 -05:00
if ( tinymce . isIE ) {
editor . $ ( 'a' , event . node ) . find ( 'font, u' ) . each ( function ( i , node ) {
dom . remove ( node , true ) ;
} ) ;
}
2014-06-30 17:55:18 -04:00
} ) ;
}
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
} ) ;
2015-06-21 18:01:28 -04:00
editor . on ( 'SaveContent' , function ( event ) {
2020-01-28 19:45:18 -05:00
// If editor is hidden, we just want the textarea's value to be saved.
2014-05-28 20:59:15 -04:00
if ( ! editor . inline && editor . isHidden ( ) ) {
2015-06-21 18:01:28 -04:00
event . content = event . element . value ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
return ;
}
// Keep empty paragraphs :(
2015-06-21 18:01:28 -04:00
event . content = event . content . replace ( /<p>(?:<br ?\/?>|\u00a0|\uFEFF| )*<\/p>/g , '<p> </p>' ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
2015-06-21 18:01:28 -04:00
if ( hasWpautop ) {
2021-09-08 19:29:58 -04:00
event . content = wp . editor . removep ( event . content ) ;
2018-06-27 22:25:32 -04:00
} else {
// Restore formatting of block boundaries.
event . content = event . content . replace ( /-->\s*<!-- wp:/g , '-->\n\n<!-- wp:' ) ;
2014-06-06 00:20:14 -04:00
}
} ) ;
2014-02-03 15:26:12 -05:00
editor . on ( 'preInit' , function ( ) {
2015-07-24 18:04:25 -04:00
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 ) ;
2014-05-29 22:38:16 -04:00
if ( tinymce . Env . iOS ) {
editor . settings . height = 300 ;
}
2014-02-03 15:26:12 -05:00
2015-04-06 18:51:27 -04:00
each ( {
c : 'JustifyCenter' ,
r : 'JustifyRight' ,
l : 'JustifyLeft' ,
j : 'JustifyFull' ,
q : 'mceBlockQuote' ,
u : 'InsertUnorderedList' ,
o : 'InsertOrderedList' ,
m : 'WP_Medialib' ,
t : 'WP_More' ,
d : 'Strikethrough' ,
p : 'WP_Page' ,
x : 'WP_Code'
} , function ( command , key ) {
editor . shortcuts . add ( 'access+' + key , '' , command ) ;
} ) ;
2015-04-26 00:51:29 -04:00
editor . addShortcut ( 'meta+s' , '' , function ( ) {
2015-06-21 18:01:28 -04:00
if ( wp && wp . autosave ) {
2015-04-06 18:51:27 -04:00
wp . autosave . server . triggerSave ( ) ;
}
} ) ;
2016-03-02 17:10:27 -05:00
2019-10-04 16:12:58 -04:00
// Alt+Shift+Z removes a block in the block editor, don't add it to the Classic block.
2018-12-16 22:32:21 -05:00
if ( ! editor . settings . classic _block _editor ) {
editor . addShortcut ( 'access+z' , '' , 'WP_Adv' ) ;
}
2019-10-04 16:12:58 -04:00
// Workaround for not triggering the global help modal in the block editor by the Classic block shortcut.
2018-12-16 22:32:21 -05:00
editor . on ( 'keydown' , function ( event ) {
2019-03-15 17:43:50 -04:00
var match ;
if ( tinymce . Env . mac ) {
match = event . ctrlKey && event . altKey && event . code === 'KeyH' ;
} else {
match = event . shiftKey && event . altKey && event . code === 'KeyH' ;
}
if ( match ) {
2018-12-16 22:32:21 -05:00
editor . execCommand ( 'WP_Help' ) ;
event . stopPropagation ( ) ;
event . stopImmediatePropagation ( ) ;
return false ;
}
return true ;
} ) ;
2016-03-02 17:10:27 -05:00
if ( window . getUserSetting ( 'editor_plain_text_paste_warning' ) > 1 ) {
editor . settings . paste _plaintext _inform = false ;
}
2016-07-19 21:39:31 -04:00
// Change the editor iframe title on MacOS, add the correct help shortcut.
if ( tinymce . Env . mac ) {
tinymce . $ ( editor . iframeElement ) . attr ( 'title' , _ _ ( 'Rich Text Area. Press Control-Option-H for help.' ) ) ;
}
2015-04-06 18:51:27 -04:00
} ) ;
2016-03-02 17:10:27 -05:00
editor . on ( 'PastePlainTextToggle' , function ( event ) {
// Warn twice, then stop.
if ( event . state === true ) {
var times = parseInt ( window . getUserSetting ( 'editor_plain_text_paste_warning' ) , 10 ) || 0 ;
if ( times < 2 ) {
window . setUserSetting ( 'editor_plain_text_paste_warning' , ++ times ) ;
}
}
} ) ;
2019-03-28 20:49:51 -04:00
editor . on ( 'beforerenderui' , function ( ) {
if ( editor . theme . panel ) {
each ( [ 'button' , 'colorbutton' , 'splitbutton' ] , function ( buttonType ) {
replaceButtonsTooltips ( editor . theme . panel . find ( buttonType ) ) ;
} ) ;
addShortcutsToListbox ( ) ;
}
} ) ;
function prepareTooltips ( ) {
var access = 'Shift+Alt+' ;
var meta = 'Ctrl+' ;
wpTooltips = { } ;
2020-01-28 19:45:18 -05:00
// For MacOS: ctrl = \u2303, cmd = \u2318, alt = \u2325.
2019-03-28 20:49:51 -04:00
if ( tinymce . Env . mac ) {
access = '\u2303\u2325' ;
meta = '\u2318' ;
}
// Some tooltips are translated, others are not...
if ( editor . settings . wp _shortcut _labels ) {
each ( editor . settings . wp _shortcut _labels , function ( value , tooltip ) {
var translated = editor . translate ( tooltip ) ;
value = value . replace ( 'access' , access ) . replace ( 'meta' , meta ) ;
wpTooltips [ tooltip ] = value ;
// Add the translated so we can match all of them.
if ( tooltip !== translated ) {
wpTooltips [ translated ] = value ;
}
} ) ;
}
}
function getTooltip ( tooltip ) {
var translated = editor . translate ( tooltip ) ;
var label ;
if ( ! wpTooltips ) {
prepareTooltips ( ) ;
}
if ( wpTooltips . hasOwnProperty ( translated ) ) {
label = wpTooltips [ translated ] ;
} else if ( wpTooltips . hasOwnProperty ( tooltip ) ) {
label = wpTooltips [ tooltip ] ;
}
return label ? translated + ' (' + label + ')' : translated ;
}
function replaceButtonsTooltips ( buttons ) {
if ( ! buttons ) {
return ;
}
each ( buttons , function ( button ) {
var tooltip ;
if ( button && button . settings . tooltip ) {
tooltip = getTooltip ( button . settings . tooltip ) ;
button . settings . tooltip = tooltip ;
2021-12-14 03:30:04 -05:00
// Override the aria label with the translated tooltip + shortcut.
2019-03-28 20:49:51 -04:00
if ( button . _aria && button . _aria . label ) {
button . _aria . label = tooltip ;
}
}
} ) ;
}
function addShortcutsToListbox ( ) {
2020-01-28 19:45:18 -05:00
// listbox for the "blocks" drop-down.
2019-03-28 20:49:51 -04:00
each ( editor . theme . panel . find ( 'listbox' ) , function ( listbox ) {
if ( listbox && listbox . settings . text === 'Paragraph' ) {
each ( listbox . settings . values , function ( item ) {
if ( item . text && wpTooltips . hasOwnProperty ( item . text ) ) {
item . shortcut = '(' + wpTooltips [ item . text ] + ')' ;
}
} ) ;
}
} ) ;
}
2015-03-11 15:12:28 -04:00
/ * *
* Experimental : create a floating toolbar .
2015-04-06 18:51:27 -04:00
* This functionality will change in the next releases . Not recommended for use by plugins .
* /
2015-06-18 07:10:25 -04:00
editor . on ( 'preinit' , function ( ) {
2015-04-06 18:51:27 -04:00
var Factory = tinymce . ui . Factory ,
2015-03-11 15:12:28 -04:00
settings = editor . settings ,
2015-06-17 03:08:25 -04:00
activeToolbar ,
2015-06-17 00:42:25 -04:00
currentSelection ,
2015-06-18 07:10:25 -04:00
timeout ,
2015-08-06 17:35:25 -04:00
container = editor . getContainer ( ) ,
2015-06-17 00:42:25 -04:00
wpAdminbar = document . getElementById ( 'wpadminbar' ) ,
2015-06-18 07:10:25 -04:00
mceIframe = document . getElementById ( editor . id + '_ifr' ) ,
2015-08-06 17:35:25 -04:00
mceToolbar ,
mceStatusbar ,
2019-07-11 14:18:58 -04:00
wpStatusbar ,
cachedWinSize ;
2015-06-17 00:42:25 -04:00
2015-08-06 17:35:25 -04:00
if ( container ) {
mceToolbar = tinymce . $ ( '.mce-toolbar-grp' , container ) [ 0 ] ;
mceStatusbar = tinymce . $ ( '.mce-statusbar' , container ) [ 0 ] ;
}
2015-06-17 00:42:25 -04:00
if ( editor . id === 'content' ) {
wpStatusbar = document . getElementById ( 'post-status-info' ) ;
}
function create ( buttons , bottom ) {
2015-03-11 15:12:28 -04:00
var toolbar ,
toolbarItems = [ ] ,
buttonGroup ;
each ( buttons , function ( item ) {
2017-05-08 21:40:46 -04:00
var itemName ;
2019-03-28 20:49:51 -04:00
var tooltip ;
2015-03-11 15:12:28 -04:00
function bindSelectorChanged ( ) {
var selection = editor . selection ;
if ( itemName === 'bullist' ) {
selection . selectorChanged ( 'ul > li' , function ( state , args ) {
var i = args . parents . length ,
nodeName ;
while ( i -- ) {
nodeName = args . parents [ i ] . nodeName ;
if ( nodeName === 'OL' || nodeName == 'UL' ) {
break ;
}
}
item . active ( state && nodeName === 'UL' ) ;
} ) ;
}
if ( itemName === 'numlist' ) {
selection . selectorChanged ( 'ol > li' , function ( state , args ) {
var i = args . parents . length ,
nodeName ;
while ( i -- ) {
nodeName = args . parents [ i ] . nodeName ;
if ( nodeName === 'OL' || nodeName === 'UL' ) {
break ;
}
}
item . active ( state && nodeName === 'OL' ) ;
} ) ;
}
if ( item . settings . stateSelector ) {
selection . selectorChanged ( item . settings . stateSelector , function ( state ) {
item . active ( state ) ;
} , true ) ;
}
if ( item . settings . disabledStateSelector ) {
selection . selectorChanged ( item . settings . disabledStateSelector , function ( state ) {
item . disabled ( state ) ;
} ) ;
}
}
if ( item === '|' ) {
buttonGroup = null ;
} else {
if ( Factory . has ( item ) ) {
item = {
type : item
} ;
if ( settings . toolbar _items _size ) {
item . size = settings . toolbar _items _size ;
}
toolbarItems . push ( item ) ;
buttonGroup = null ;
} else {
if ( ! buttonGroup ) {
buttonGroup = {
type : 'buttongroup' ,
items : [ ]
} ;
toolbarItems . push ( buttonGroup ) ;
}
if ( editor . buttons [ item ] ) {
itemName = item ;
item = editor . buttons [ itemName ] ;
if ( typeof item === 'function' ) {
item = item ( ) ;
}
item . type = item . type || 'button' ;
if ( settings . toolbar _items _size ) {
item . size = settings . toolbar _items _size ;
}
2019-03-28 20:49:51 -04:00
tooltip = item . tooltip || item . title ;
if ( tooltip ) {
item . tooltip = getTooltip ( tooltip ) ;
}
2015-03-11 15:12:28 -04:00
item = Factory . create ( item ) ;
buttonGroup . items . push ( item ) ;
if ( editor . initialized ) {
bindSelectorChanged ( ) ;
} else {
editor . on ( 'init' , bindSelectorChanged ) ;
}
}
}
}
} ) ;
toolbar = Factory . create ( {
type : 'panel' ,
layout : 'stack' ,
classes : 'toolbar-grp inline-toolbar-grp' ,
ariaRoot : true ,
ariaRemember : true ,
items : [ {
type : 'toolbar' ,
layout : 'flow' ,
items : toolbarItems
} ]
} ) ;
2015-06-17 00:42:25 -04:00
toolbar . bottom = bottom ;
2015-03-11 15:12:28 -04:00
function reposition ( ) {
2015-06-30 20:52:25 -04:00
if ( ! currentSelection ) {
return this ;
}
2015-06-17 00:42:25 -04:00
var scrollX = window . pageXOffset || document . documentElement . scrollLeft ,
scrollY = window . pageYOffset || document . documentElement . scrollTop ,
windowWidth = window . innerWidth ,
windowHeight = window . innerHeight ,
2015-08-06 17:35:25 -04:00
iframeRect = mceIframe ? mceIframe . getBoundingClientRect ( ) : {
top : 0 ,
right : windowWidth ,
bottom : windowHeight ,
left : 0 ,
width : windowWidth ,
height : windowHeight
} ,
2015-06-17 00:42:25 -04:00
toolbar = this . getEl ( ) ,
toolbarWidth = toolbar . offsetWidth ,
2016-07-26 22:59:31 -04:00
toolbarHeight = toolbar . clientHeight ,
2015-06-17 00:42:25 -04:00
selection = currentSelection . getBoundingClientRect ( ) ,
selectionMiddle = ( selection . left + selection . right ) / 2 ,
2015-03-11 15:12:28 -04:00
buffer = 5 ,
2016-07-26 22:59:31 -04:00
spaceNeeded = toolbarHeight + buffer ,
2015-06-17 00:42:25 -04:00
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 = '' ,
2015-11-10 22:27:25 -05:00
iosOffsetTop = 0 ,
iosOffsetBottom = 0 ,
2015-06-17 00:42:25 -04:00
top , left ;
2015-06-18 07:10:25 -04:00
if ( spaceTop >= editorHeight || spaceBottom >= editorHeight ) {
2016-01-22 19:08:26 -05:00
this . scrolling = true ;
this . hide ( ) ;
this . scrolling = false ;
return this ;
2015-06-18 07:10:25 -04:00
}
2015-11-10 22:27:25 -05:00
// Add offset in iOS to move the menu over the image, out of the way of the default iOS menu.
if ( tinymce . Env . iOS && currentSelection . nodeName === 'IMG' ) {
iosOffsetTop = 54 ;
iosOffsetBottom = 46 ;
}
2015-06-17 00:42:25 -04:00
if ( this . bottom ) {
if ( spaceBottom >= spaceNeeded ) {
2015-03-11 15:12:28 -04:00
className = ' mce-arrow-up' ;
2015-11-10 22:27:25 -05:00
top = selection . bottom + iframeRect . top + scrollY - iosOffsetBottom ;
2015-06-17 00:42:25 -04:00
} else if ( spaceTop >= spaceNeeded ) {
className = ' mce-arrow-down' ;
2016-07-26 22:59:31 -04:00
top = selection . top + iframeRect . top + scrollY - toolbarHeight + iosOffsetTop ;
2015-03-11 15:12:28 -04:00
}
} else {
2015-06-17 00:42:25 -04:00
if ( spaceTop >= spaceNeeded ) {
className = ' mce-arrow-down' ;
2016-07-26 22:59:31 -04:00
top = selection . top + iframeRect . top + scrollY - toolbarHeight + iosOffsetTop ;
2015-06-17 00:42:25 -04:00
} else if ( spaceBottom >= spaceNeeded && editorHeight / 2 > selection . bottom + iframeRect . top - blockedTop ) {
className = ' mce-arrow-up' ;
2015-11-10 22:27:25 -05:00
top = selection . bottom + iframeRect . top + scrollY - iosOffsetBottom ;
2015-03-11 15:12:28 -04:00
}
}
2015-06-17 00:42:25 -04:00
if ( typeof top === 'undefined' ) {
2015-11-10 22:27:25 -05:00
top = scrollY + blockedTop + buffer + iosOffsetBottom ;
2015-03-11 15:12:28 -04:00
}
2015-06-17 00:42:25 -04:00
left = selectionMiddle - toolbarWidth / 2 + iframeRect . left + scrollX ;
2015-03-11 15:12:28 -04:00
2015-06-17 00:42:25 -04:00
if ( selection . left < 0 || selection . right > iframeRect . width ) {
left = iframeRect . left + scrollX + ( iframeRect . width - toolbarWidth ) / 2 ;
2015-03-11 15:12:28 -04:00
} else if ( toolbarWidth >= windowWidth ) {
className += ' mce-arrow-full' ;
left = 0 ;
2015-06-17 00:42:25 -04:00
} else if ( ( left < 0 && selection . left + toolbarWidth > windowWidth ) || ( left + toolbarWidth > windowWidth && selection . right - toolbarWidth < 0 ) ) {
2015-03-11 15:12:28 -04:00
left = ( windowWidth - toolbarWidth ) / 2 ;
2015-06-17 00:42:25 -04:00
} else if ( left < iframeRect . left + scrollX ) {
2015-03-11 15:12:28 -04:00
className += ' mce-arrow-left' ;
2015-06-17 00:42:25 -04:00
left = selection . left + iframeRect . left + scrollX ;
} else if ( left + toolbarWidth > iframeRect . width + iframeRect . left + scrollX ) {
2015-03-11 15:12:28 -04:00
className += ' mce-arrow-right' ;
2015-06-17 00:42:25 -04:00
left = selection . right - toolbarWidth + iframeRect . left + scrollX ;
2015-03-11 15:12:28 -04:00
}
2015-11-10 22:27:25 -05:00
// No up/down arrows on the menu over images in iOS.
if ( tinymce . Env . iOS && currentSelection . nodeName === 'IMG' ) {
className = className . replace ( / ?mce-arrow-(up|down)/g , '' ) ;
}
2015-06-17 00:42:25 -04:00
toolbar . className = toolbar . className . replace ( / ?mce-arrow-[\w]+/g , '' ) + className ;
2015-03-11 15:12:28 -04:00
2015-06-17 00:42:25 -04:00
DOM . setStyles ( toolbar , {
'left' : left ,
'top' : top
} ) ;
2015-03-11 15:12:28 -04:00
return this ;
}
toolbar . on ( 'show' , function ( ) {
this . reposition ( ) ;
} ) ;
toolbar . on ( 'keydown' , function ( event ) {
if ( event . keyCode === 27 ) {
this . hide ( ) ;
editor . focus ( ) ;
}
} ) ;
2015-07-16 07:11:24 -04:00
editor . on ( 'remove' , function ( ) {
toolbar . remove ( ) ;
} ) ;
2015-03-11 15:12:28 -04:00
toolbar . reposition = reposition ;
toolbar . hide ( ) . renderTo ( document . body ) ;
return toolbar ;
}
editor . shortcuts . add ( 'alt+119' , '' , function ( ) {
var node ;
2015-06-17 03:08:25 -04:00
if ( activeToolbar ) {
node = activeToolbar . find ( 'toolbar' ) [ 0 ] ;
2015-03-11 15:12:28 -04:00
node && node . focus ( true ) ;
}
} ) ;
editor . on ( 'nodechange' , function ( event ) {
var collapsed = editor . selection . isCollapsed ( ) ;
var args = {
element : event . element ,
parents : event . parents ,
collapsed : collapsed
} ;
editor . fire ( 'wptoolbar' , args ) ;
currentSelection = args . selection || args . element ;
2016-01-22 19:08:26 -05:00
if ( activeToolbar && activeToolbar !== args . toolbar ) {
2015-06-17 03:08:25 -04:00
activeToolbar . hide ( ) ;
}
if ( args . toolbar ) {
2017-01-15 19:22:43 -05:00
activeToolbar = args . toolbar ;
if ( activeToolbar . visible ( ) ) {
2016-01-22 19:08:26 -05:00
activeToolbar . reposition ( ) ;
2017-01-15 19:22:43 -05:00
} else {
activeToolbar . show ( ) ;
2016-01-22 19:08:26 -05:00
}
2015-06-17 03:08:25 -04:00
} else {
activeToolbar = false ;
}
} ) ;
editor . on ( 'focus' , function ( ) {
if ( activeToolbar ) {
activeToolbar . show ( ) ;
}
} ) ;
2015-06-18 07:10:25 -04:00
function hide ( event ) {
2019-07-11 14:18:58 -04:00
var win ;
var size ;
2015-06-18 07:10:25 -04:00
if ( activeToolbar ) {
2017-04-19 18:10:42 -04:00
if ( activeToolbar . tempHide || event . type === 'hide' || event . type === 'blur' ) {
2016-01-22 19:08:26 -05:00
activeToolbar . hide ( ) ;
2015-06-18 07:10:25 -04:00
activeToolbar = false ;
2016-05-25 11:13:28 -04:00
} else if ( (
event . type === 'resizewindow' ||
event . type === 'scrollwindow' ||
event . type === 'resize' ||
event . type === 'scroll'
) && ! activeToolbar . blockHide ) {
2020-01-28 19:45:18 -05:00
/ *
* Showing a tooltip may trigger a ` resize ` event in Chromium browsers .
* That results in a flicketing inline menu ; tooltips are shown on hovering over a button ,
* which then hides the toolbar on ` resize ` , then it repeats as soon as the toolbar is shown again .
* /
2019-07-11 14:18:58 -04:00
if ( event . type === 'resize' || event . type === 'resizewindow' ) {
win = editor . getWin ( ) ;
size = win . innerHeight + win . innerWidth ;
// Reset old cached size.
if ( cachedWinSize && ( new Date ( ) ) . getTime ( ) - cachedWinSize . timestamp > 2000 ) {
cachedWinSize = null ;
}
if ( cachedWinSize ) {
if ( size && Math . abs ( size - cachedWinSize . size ) < 2 ) {
// `resize` fired but the window hasn't been resized. Bail.
return ;
}
} else {
// First of a new series of `resize` events. Store the cached size and bail.
cachedWinSize = {
timestamp : ( new Date ( ) ) . getTime ( ) ,
size : size ,
} ;
return ;
}
}
2015-06-18 07:10:25 -04:00
clearTimeout ( timeout ) ;
timeout = setTimeout ( function ( ) {
2015-07-08 20:25:25 -04:00
if ( activeToolbar && typeof activeToolbar . show === 'function' ) {
2016-01-22 19:08:26 -05:00
activeToolbar . scrolling = false ;
2015-07-08 20:25:25 -04:00
activeToolbar . show ( ) ;
}
2015-06-18 07:10:25 -04:00
} , 250 ) ;
2016-01-22 19:08:26 -05:00
activeToolbar . scrolling = true ;
activeToolbar . hide ( ) ;
2015-06-18 07:10:25 -04:00
}
}
}
2019-01-24 06:24:50 -05:00
if ( editor . inline ) {
2019-07-08 21:11:55 -04:00
editor . on ( 'resizewindow' , hide ) ;
2019-01-24 06:24:50 -05:00
// Enable `capture` for the event.
// This will hide/reposition the toolbar on any scrolling in the document.
document . addEventListener ( 'scroll' , hide , true ) ;
} else {
2019-07-11 14:18:58 -04:00
// Bind to the editor iframe and to the parent window.
editor . dom . bind ( editor . getWin ( ) , 'resize scroll' , hide ) ;
2019-01-24 06:24:50 -05:00
editor . on ( 'resizewindow scrollwindow' , hide ) ;
}
2015-07-16 07:11:24 -04:00
editor . on ( 'remove' , function ( ) {
2019-01-24 06:24:50 -05:00
document . removeEventListener ( 'scroll' , hide , true ) ;
2016-05-25 11:13:28 -04:00
editor . off ( 'resizewindow scrollwindow' , hide ) ;
2019-07-11 14:18:58 -04:00
editor . dom . unbind ( editor . getWin ( ) , 'resize scroll' , hide ) ;
2015-07-16 07:11:24 -04:00
} ) ;
2015-06-18 07:10:25 -04:00
editor . on ( 'blur hide' , hide ) ;
2015-03-11 15:12:28 -04:00
editor . wp = editor . wp || { } ;
editor . wp . _createToolbar = create ;
2015-06-18 07:10:25 -04:00
} , true ) ;
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
2015-03-10 16:28:26 -04:00
function noop ( ) { }
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
2020-01-28 19:45:18 -05:00
// Expose some functions (back-compat).
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
return {
2015-03-10 16:28:26 -04:00
_showButtons : noop ,
_hideButtons : noop ,
_setEmbed : noop ,
_getEmbed : noop
TinyMCE 4.0.12, first run.
- Removes wp-tinymce-schema.js and mark-loaded.js, no longer needed.
- Removes the inlinepopups and most of the wpdialogs plugins; wpdialog.js is moved to wp-includes/js.
- Adds charmap, compat3x, image, link and textcolor plugins, previously contained in /themes/advanced.
- Updates the wordpress, wpeditimage, wpfullscreen, wpgallery and wplink plugins.
- Updates DFW, wp-admin/js/wp-fullscreen.js.
See #24067.
Built from https://develop.svn.wordpress.org/trunk@26876
git-svn-id: http://core.svn.wordpress.org/trunk@26759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-28 18:53:15 -05:00
} ;
} ) ;
2015-06-21 18:01:28 -04:00
} ( window . tinymce ) ) ;