Plugin Directory

Changeset 1993190 for tinymce-advanced


Ignore:
Timestamp:
12/13/2018 12:18:14 AM (7 years ago)
Author:
azaozz
Message:

TinyMCE Advanced 4.8.1

Location:
tinymce-advanced/trunk
Files:
5 added
14 edited

Legend:

Unmodified
Added
Removed
  • tinymce-advanced/trunk/css/tadv-styles.css

    r1643101 r1993190  
    55 * Copyright (c) 2007-2016 Andrew Ozz. All rights reserved.
    66 */
     7
     8.wrap.tinymce-advanced {
     9    max-width: 900px;
     10    margin: 10px 20px 0 10px;
     11}
     12
     13#block-editor {
     14    margin-bottom: 45px;
     15    max-width: 672px;
     16}
     17
     18#classic-editor,
     19.tadv-submit-top {
     20    margin-bottom: 45px;
     21    width: 92%;
     22}
     23
     24.rtl #classic-editor,
     25.rtl .tadv-submit-top {
     26    margin: 0 0 35px 280px;
     27}
    728 
    829.tadv-more-plugins label {
     
    1637
    1738.advanced-options {
    18     margin: 20px 0;
    19     border: 1px solid #ccc;
    20     padding: 0 15px;
     39    margin: 40px 0;
    2140}
    2241
     
    2847    margin-left: 22px;
    2948    margin-top: 5px;
     49}
     50
     51.advanced-options .tadv-help {
     52    margin: 1em 0;
    3053}
    3154
     
    7093
    7194ul.container,
    72 #unused {
     95.unused {
    7396    position: relative;
    7497}
     
    105128}
    106129
    107 #tadv-mce-menu {
     130.tadv-mce-menu.mce-menubar {
    108131    margin-bottom: 0;
    109132    background: #fff;
     
    114137}
    115138
    116 #tadv-mce-menu.enabled {
     139.tadv-mce-menu.enabled {
    117140    opacity: 1;
    118141    filter: alpha(opacity=100);
    119142}
    120143
    121 #tadv-mce-menu.mce-menubar .mce-menubtn:hover {
     144.tadv-mce-menu.mce-menubar .mce-menubtn:hover {
    122145    background: transparent;
    123146}
    124147
    125 #tadv-mce-menu .mce-btn .mce-caret {
     148.tadv-mce-menu .mce-btn .mce-caret {
    126149    margin-top: 9px;
    127150    margin-left: 1px;
    128151}
    129152
    130 #tadv-mce-menu * {
     153.tadv-mce-menu * {
    131154    cursor: default;
    132155}
    133156
    134157#tadvzones,
    135 #unused {
     158.unused {
    136159    -webkit-user-select: none;
    137160    -moz-user-select: none;
     
    146169#tadvadmin #save {
    147170    float: right;
    148 }
    149 
    150 #tadvzones {
    151     margin: 25px 280px 0 0;
    152171}
    153172
     
    159178}
    160179
    161 #unuseddiv.highlighted,
     180.unuseddiv .highlighted,
    162181.tadvdropzone.highlighted {
    163     background-color: #efefe9;
     182    background-color: #e4f2fd;
     183    color: #000;
    164184    border-color: #aaa;
    165185}
     
    210230}
    211231
    212 #unuseddiv {
     232.unuseddiv {
    213233    padding: 10px;
    214234    border: 1px solid #ccc;
    215235}
    216236
    217 #unuseddiv h3 {
     237.unuseddiv h4 {
    218238    margin: 5px 5px 12px;
    219 }
    220 
    221 #unused li,
     239    font-size: 1.2em;
     240}
     241
     242.unused li,
    222243.tadvdropzone li {
    223244    margin: 0;
     
    229250}
    230251
    231 #unused li {
     252.unused li {
    232253    margin: 4px;
    233254}
    234255
    235 #unused {
     256.unused {
    236257    margin: 0;
    237258    min-height: 36px;
    238259}
    239260
    240 #unused .tadvmodule .tadvitem {
     261.unused .tadvmodule .tadvitem {
    241262    display: block;
    242     height: 22px;
     263    height: 24px;
    243264    width: 140px;
    244265    border: 1px solid #bbb;
     
    255276}
    256277
    257 #unused .tadvmodule .descr {
     278.unused .tadvmodule .descr {
    258279    display: inline;
    259280    font-size: 12px;
     
    261282}
    262283
    263 #unused .tadvmodule .the-button .descr {
     284.unused .tadvmodule .the-button .descr {
    264285    padding: 0 4px;
    265286    font-size: 13px;
     
    302323.tadv-error {
    303324    color: #d54e21;
    304     font-weight: bold;
    305 }
     325}
     326
     327.tadv-block-editor .mce-menubtn {
     328    margin: 6px 0;
     329}
     330
     331#tadvadmin label {
     332    vertical-align: text-bottom;
     333}
     334
     335.tadv-block-editor.tadvdropzone {
     336    height: 60px;
     337}
  • tinymce-advanced/trunk/js/tadv.js

    r1475916 r1993190  
    3434    });
    3535
     36    $('.container-classic-block' ).sortable({
     37        connectWith: '.container-classic-block',
     38        items: '> li',
     39        cursor: 'move',
     40        stop: function( event, ui ) {
     41            var toolbar_id;
     42
     43            if ( ui && ( toolbar_id = ui.item.parent().attr( 'id' ) ) ) {
     44                ui.item.find( 'input.tadv-button' ).attr( 'name', toolbar_id + '[]' );
     45            }
     46        },
     47        activate: function( event, ui ) {
     48            $(this).parent().addClass( 'highlighted' );
     49        },
     50        deactivate: function( event, ui ) {
     51            $(this).parent().removeClass( 'highlighted' );
     52        },
     53        revert: 300,
     54        opacity: 0.7,
     55        placeholder: 'tadv-placeholder',
     56        forcePlaceholderSize: true,
     57        containment: 'document'
     58    });
     59   
     60
    3661    $( '#menubar' ).on( 'change', function() {
    37         $( '#tadv-mce-menu' ).toggleClass( 'enabled', $(this).prop('checked') );
     62        $( '.tadv-mce-menu.tadv-classic-editor' ).toggleClass( 'enabled', $(this).prop('checked') );
     63    });
     64
     65    $( '#menubar_block' ).on( 'change', function() {
     66        $( '.tadv-mce-menu.tadv-block-editor' ).toggleClass( 'enabled', $(this).prop('checked') );
    3867    });
    3968
     
    86115        });
    87116
    88         $( '#tadv-mce-menu .tadv-translate' ).each( function( i, element ) {
     117        $( '.tadv-mce-menu .tadv-translate' ).each( function( i, element ) {
    89118            var $element = $( element ),
    90119                text = $element.text();
  • tinymce-advanced/trunk/mce/importcss/plugin.js

    r1919233 r1993190  
    7575    function append(styleSheet, imported) {
    7676      var href = styleSheet.href, rules;
    77       href = removeCacheSuffix(href);
     77
     78        if ( editor.settings.classic_block_editor ) {
     79            // Attempt to import the CSS rules from the style tag.
     80            tinymce.$( 'style' ).each( function( i, node ) {
     81                var css = node.textContent || '';
     82
     83                if ( /theme name: /i.test( css ) || css.indexOf( 'TinyMCE' ) > -1 ) {
     84                    try{
     85                        rules = node.sheet.cssRules;
     86                    } catch ( er ) {}
     87                }
     88            });
     89
     90            if ( rules ) {
     91                tinymce.each( rules, function ( cssRule ) {
     92                    if ( cssRule.selectorText ) {
     93                        tinymce.each( cssRule.selectorText.split(','), function ( selector ) {
     94                            selector = selector.replace( /^\.editor-styles-wrapper/, '' );
     95
     96                            if ( selector ) {
     97                                selectors.push( tinymce.trim( selector ) );
     98                            }
     99                        });
     100                    }
     101                });
     102
     103                return;
     104            }
     105        }
     106
     107      href = removeCacheSuffix(href);
    78108      if (!href || !fileFilter(href, imported) || isSkinContentCss(editor, href)) {
    79109        return;
  • tinymce-advanced/trunk/mce/importcss/plugin.min.js

    r1919233 r1993190  
    1 !function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),d=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),v=tinymce.util.Tools.resolve("tinymce.EditorManager"),h=tinymce.util.Tools.resolve("tinymce.Env"),y=tinymce.util.Tools.resolve("tinymce.util.Tools"),o=function(e){return e.getParam("importcss_merge_classes")},n=function(e){return e.getParam("importcss_exclusive")},_=function(e){return e.getParam("importcss_selector_converter")},r=function(e){return e.getParam("importcss_selector_filter")},i=function(e){return e.getParam("importcss_groups")},u=function(e){return e.getParam("importcss_append")},l=function(e){return e.getParam("importcss_file_filter")},a=function(t){return"string"==typeof t?function(e){return-1!==e.indexOf(t)}:t instanceof RegExp?function(e){return t.test(e)}:t},f=function(f,e,m){var g=[],n={};function p(e,t){var n,r,i,c=e.href;if(r=c,i=h.cacheSuffix,"string"==typeof r&&(r=r.replace("?"+i,"").replace("&"+i,"")),(c=r)&&m(c,t)&&(o=c,u=(s=f).settings,!(l=!1!==u.skin&&(u.skin||"lightgray"))||o!==(u.skin_url?s.documentBaseURI.toAbsolute(u.skin_url):v.baseURL+"/skins/"+l)+"/content"+(s.inline?".inline":"")+".min.css")){var s,o,u,l;y.each(e.imports,function(e){p(e,!0)});try{n=e.cssRules||e.rules}catch(a){}y.each(n,function(e){e.styleSheet?p(e.styleSheet,!0):e.selectorText&&y.each(e.selectorText.split(","),function(e){g.push(y.trim(e))})})}}y.each(f.contentCSS,function(e){n[e]=!0}),m||(m=function(e,t){return t||n[e]});try{y.each(e.styleSheets,function(e){p(e)})}catch(t){}return g},x=function(e,t){var n,r=/^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(t);if(r){var i=r[1],c=r[2].substr(1).split(".").join(" "),s=y.makeMap("a,img");return r[1]?(n={title:t},e.schema.getTextBlockElements()[i]?n.block=i:e.schema.getBlockElements()[i]||s[i.toLowerCase()]?n.selector=i:n.inline=i):r[2]&&(n={inline:"span",title:t.substr(1),classes:c}),!1!==o(e)?n.classes=c:n.attributes={"class":c},n}},T=function(e,t){return null===t||!1!==n(e)},c=x,t=function(h){h.on("renderFormatsMenu",function(e){var t,p={},c=a(r(h)),v=e.control,s=(t=i(h),y.map(t,function(e){return y.extend({},e,{original:e,selectors:{},filter:a(e.filter),item:{text:e.title,menu:[]}})})),o=function(e,t){if(f=e,g=p,!(T(h,m=t)?f in g:f in m.selectors)){u=e,a=p,T(h,l=t)?a[u]=!0:l.selectors[u]=!0;var n=(c=(i=h).plugins.importcss,s=e,((o=t)&&o.selector_converter?o.selector_converter:_(i)?_(i):function(){return x(i,s)}).call(c,s,o));if(n){var r=n.name||d.DOM.uniqueId();return h.formatter.register(r,n),y.extend({},v.settings.itemDefaults,{text:n.title,format:r})}}var i,c,s,o,u,l,a,f,m,g;return null};u(h)||v.items().remove(),y.each(f(h,e.doc||h.getDoc(),a(l(h))),function(n){if(-1===n.indexOf(".mce-")&&(!c||c(n))){var e=(r=s,i=n,y.grep(r,function(e){return!e.filter||e.filter(i)}));if(0<e.length)y.each(e,function(e){var t=o(n,e);t&&e.item.menu.push(t)});else{var t=o(n,null);t&&v.add(t)}}var r,i}),y.each(s,function(e){0<e.item.menu.length&&v.add(e.item)}),e.control.renderNew()})},s=function(t){return{convertSelectorToFormat:function(e){return c(t,e)}}};e.add("importcss",function(e){return t(e),s(e)})}();
     1!function(){(function(){"use strict";function a(){}var b=tinymce.util.Tools.resolve("tinymce.PluginManager"),c=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),d=tinymce.util.Tools.resolve("tinymce.EditorManager"),e=tinymce.util.Tools.resolve("tinymce.Env"),f=tinymce.util.Tools.resolve("tinymce.util.Tools"),g=function(a){return a.getParam("importcss_merge_classes")},h=function(a){return a.getParam("importcss_exclusive")},i=function(a){return a.getParam("importcss_selector_converter")},j=function(a){return a.getParam("importcss_selector_filter")},k=function(a){return a.getParam("importcss_groups")},l=function(a){return a.getParam("importcss_append")},m=function(a){return a.getParam("importcss_file_filter")},n={shouldMergeClasses:g,shouldImportExclusive:h,getSelectorConverter:i,getSelectorFilter:j,getCssGroups:k,shouldAppend:l,getFileFilter:m},o=function(a){var b=e.cacheSuffix;return"string"==typeof a&&(a=a.replace("?"+b,"").replace("&"+b,"")),a},p=function(a,b){var c=a.settings,e=c.skin!==!1&&(c.skin||"lightgray");if(e){var f=c.skin_url?a.documentBaseURI.toAbsolute(c.skin_url):d.baseURL+"/skins/"+e;return b===f+"/content"+(a.inline?".inline":"")+".min.css"}return!1},q=function(a){return"string"==typeof a?function(b){return b.indexOf(a)!==-1}:a instanceof RegExp?function(b){return a.test(b)}:a},r=function(a,b,c){function d(b,g){var h,i=b.href;if(a.settings.classic_block_editor&&(tinymce.$("style").each(function(a,b){var c=b.textContent||"";if(/theme name: /i.test(c)||c.indexOf("TinyMCE")>-1)try{h=b.sheet.cssRules}catch(d){}}),h))return void tinymce.each(h,function(a){a.selectorText&&tinymce.each(a.selectorText.split(","),function(a){a=a.replace(/^\.editor-styles-wrapper/,""),a&&e.push(tinymce.trim(a))})});if(i=o(i),i&&c(i,g)&&!p(a,i)){f.each(b.imports,function(a){d(a,!0)});try{h=b.cssRules||b.rules}catch(j){}f.each(h,function(a){a.styleSheet?d(a.styleSheet,!0):a.selectorText&&f.each(a.selectorText.split(","),function(a){e.push(f.trim(a))})})}}var e=[],g={};f.each(a.contentCSS,function(a){g[a]=!0}),c||(c=function(a,b){return b||g[a]});try{f.each(b.styleSheets,function(a){d(a)})}catch(h){}return e},s=function(a,b){var c,d=/^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(b);if(d){var e=d[1],g=d[2].substr(1).split(".").join(" "),h=f.makeMap("a,img");return d[1]?(c={title:b},a.schema.getTextBlockElements()[e]?c.block=e:a.schema.getBlockElements()[e]||h[e.toLowerCase()]?c.selector=e:c.inline=e):d[2]&&(c={inline:"span",title:b.substr(1),classes:g}),n.shouldMergeClasses(a)!==!1?c.classes=g:c.attributes={"class":g},c}},t=function(a,b){return f.grep(a,function(a){return!a.filter||a.filter(b)})},u=function(a){return f.map(a,function(a){return f.extend({},a,{original:a,selectors:{},filter:q(a.filter),item:{text:a.title,menu:[]}})})},v=function(a,b){return null===b||n.shouldImportExclusive(a)!==!1},w=function(a,b,c,d){return!(v(a,c)?b in d:b in c.selectors)},x=function(a,b,c,d){v(a,c)?d[b]=!0:c.selectors[b]=!0},y=function(a,b,c,d){var e;return e=d&&d.selector_converter?d.selector_converter:n.getSelectorConverter(a)?n.getSelectorConverter(a):function(){return s(a,c)},e.call(b,c,d)},z=function(a){a.on("renderFormatsMenu",function(b){var d={},e=q(n.getSelectorFilter(a)),g=b.control,h=u(n.getCssGroups(a)),i=function(b,e){if(w(a,b,e,d)){x(a,b,e,d);var h=y(a,a.plugins.importcss,b,e);if(h){var i=h.name||c.DOM.uniqueId();return a.formatter.register(i,h),f.extend({},g.settings.itemDefaults,{text:h.title,format:i})}}return null};n.shouldAppend(a)||g.items().remove(),f.each(r(a,b.doc||a.getDoc(),q(n.getFileFilter(a))),function(a){if(a.indexOf(".mce-")===-1&&(!e||e(a))){var b=t(h,a);if(b.length>0)f.each(b,function(b){var c=i(a,b);c&&b.item.menu.push(c)});else{var c=i(a,null);c&&g.add(c)}}}),f.each(h,function(a){a.item.menu.length>0&&g.add(a.item)}),b.control.renderNew()})},A={defaultConvertSelectorToFormat:s,setup:z},B=function(a){var b=function(b){return A.defaultConvertSelectorToFormat(a,b)};return{convertSelectorToFormat:b}},C={get:B};return b.add("importcss",function(a){return A.setup(a),C.get(a)}),a})()}();
  • tinymce-advanced/trunk/mce/wptadv/plugin.js

    r1876961 r1993190  
    6666        if ( noAutop ) {
    6767            editor.on( 'beforeSetContent', function( event ) {
    68                 var autop = typeof window.wp !== 'undefined' && window.wp.editor && window.wp.editor.autop;
     68                var autop;
     69                var wp = window.wp;
     70               
     71                if ( ! wp ) {
     72                    return;
     73                }
     74
     75                autop = wp.editor && wp.editor.autop;
     76
     77                if ( ! autop ) {
     78                    autop = wp.oldEditor && wp.oldEditor.autop;
     79                }
    6980
    7081                if ( event.load && autop && event.content && event.content.indexOf( '\n' ) > -1 && ! /<p>/i.test( event.content ) ) {
     
    7283                }
    7384            }, true );
     85
     86            if ( editor.settings.classic_block_editor ) {
     87                editor.on( 'beforeGetContent', function( event ) {
     88                    // Mark all paragraph tags so they are not stripped by the Block Editor...
     89                    if ( event.format !== 'raw' ) {
     90                        editor.$( 'p' ).each( function ( i, node ) {
     91                            if ( ! node.hasAttributes() ) {
     92                                editor.$( node ).attr( 'data-tadv-p', 'keep' );
     93                            }
     94                        } )
     95                    }
     96                }, true );
     97            }
    7498        }
    7599
  • tinymce-advanced/trunk/mce/wptadv/plugin.min.js

    r1475916 r1993190  
    1 !function(a){a.PluginManager.add("wptadv",function(b){function c(b){var c="table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary";return b=b.replace(new RegExp("<(?:"+c+")(?: [^>]*)?>","gi"),"\n$&"),b=b.replace(new RegExp("</(?:"+c+")>","gi"),"$&\n"),b=b.replace(/(<br(?: [^>]*)?>)[\r\n\t]*/gi,"$1\n"),b=b.replace(/>\n[\r\n\t]+</g,">\n<"),b=b.replace(/^<li/gm,"   <li"),b=b.replace(/<td>\u00a0<\/td>/g,"<td>&nbsp;</td>"),a.trim(b)}var d=b.settings.tadv_oembed_regex||[new RegExp("https?://(www\\.)?youtube\\.com/(watch|playlist).*","i"),new RegExp("https?://youtu.be/.*","i"),new RegExp("https?://blip.tv/.*","i"),new RegExp("https?://(www\\.)?vimeo\\.com/.*","i"),new RegExp("https?://(www\\.)?dailymotion\\.com/.*","i"),new RegExp("https?://dai.ly/.*","i"),new RegExp("https?://(www\\.)?flickr\\.com/.*","i"),new RegExp("https?://flic.kr/.*","i"),new RegExp("https?://(.+\\.)?smugmug\\.com/.*","i"),new RegExp("https?://(www\\.)?hulu\\.com/watch/.*","i"),new RegExp("https?://(www\\.)?viddler\\.com/.*","i"),new RegExp("https?://qik.com/.*","i"),new RegExp("https?://revision3.com/.*","i"),new RegExp("https?://i*.photobucket.com/albums/.*","i"),new RegExp("https?://gi*.photobucket.com/groups/.*","i"),new RegExp("https?://(www\\.)?scribd\\.com/.*","i"),new RegExp("https?://wordpress.tv/.*","i"),new RegExp("https?://(.+\\.)?polldaddy\\.com/.*","i"),new RegExp("https?://poll\\.fm/.*","i"),new RegExp("https?://(www\\.)?funnyordie\\.com/videos/.*","i"),new RegExp("https?://(www\\.)?twitter\\.com/.+?/status(es)?/.*","i"),new RegExp("https?://vine\\.co/v/.*","i"),new RegExp("https?://(www\\.)?soundcloud\\.com/.*","i"),new RegExp("https?://(www\\.)?slideshare\\.net/.*","i"),new RegExp("https?://instagr(\\.am|am\\.com)/p/.*","i"),new RegExp("https?://(www\\.)?rdio\\.com/.*","i"),new RegExp("https?://rd\\.io/x/.*","i"),new RegExp("https?://(open|play)\\.spotify\\.com/.*","i"),new RegExp("https?://(.+\\.)?imgur\\.com/.*","i"),new RegExp("https?://(www\\.)?meetu(\\.ps|p\\.com)/.*","i"),new RegExp("https?://(www\\.)?issuu\\.com/.+/docs/.*","i"),new RegExp("https?://(www\\.)?collegehumor\\.com/video/.*","i"),new RegExp("https?://(www\\.)?mixcloud\\.com/.*","i"),new RegExp("https?://(www\\.|embed\\.)?ted\\.com/talks/.*","i"),new RegExp("https?://(www\\.)(animoto|video214)\\.com/play/.*","i"),new RegExp("https?://(.+).tumblr.com/post/.*","i"),new RegExp("https?://(www.)?kickstarter.com/projects/.*","i"),new RegExp("https?://kck.st/.*","i")],e=!b.settings.wpautop&&b.settings.tadv_noautop;return b.on("init",function(){e&&b.on("SaveContent",function(a){b.settings.tadv_noautop2&&(a.content=a.content.replace(/<p>\s*(https?:\/\/[^<>\s]+)\s*<\/p>/gi,function(a,b){for(var c in d)if(d[c].test(b))return b+"\n\n";return a})),a.content=a.content.replace(/caption\](\s|<br[^>]*>|<p>&nbsp;<\/p>)*\[caption/g,"caption] [caption"),a.content=a.content.replace(/<(object|audio|video)[\s\S]+?<\/\1>/g,function(a){return a.replace(/[\r\n\t ]+/g," ")}),a.content=a.content.replace(/<pre( [^>]*)?>[\s\S]+?<\/pre>/g,function(a){return a=a.replace(/<br ?\/?>(\r\n|\n)?/g,"\n"),a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g,"\n")}),a.content=c(a.content)});try{b.plugins.searchreplace&&!b.controlManager.buttons.searchreplace&&b.shortcuts.remove("meta+f")}catch(a){}}),e&&b.on("beforeSetContent",function(a){var b="undefined"!=typeof window.wp&&window.wp.editor&&window.wp.editor.autop;a.load&&b&&a.content&&a.content.indexOf("\n")>-1&&!/<p>/i.test(a.content)&&(a.content=b(a.content))},!0),b.on("beforeGetContent",function(a){"raw"!==a.format&&b.$('img[id="__wp-temp-img-id"]').attr("id",null)}),{addLineBreaks:c}})}(window.tinymce);
     1!function(a){a.PluginManager.add("wptadv",function(b){function c(b){var c="table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary";return b=b.replace(new RegExp("<(?:"+c+")(?: [^>]*)?>","gi"),"\n$&"),b=b.replace(new RegExp("</(?:"+c+")>","gi"),"$&\n"),b=b.replace(/(<br(?: [^>]*)?>)[\r\n\t]*/gi,"$1\n"),b=b.replace(/>\n[\r\n\t]+</g,">\n<"),b=b.replace(/^<li/gm,"\t<li"),b=b.replace(/<td>\u00a0<\/td>/g,"<td>&nbsp;</td>"),a.trim(b)}var d=!b.settings.wpautop&&b.settings.tadv_noautop;return b.addCommand("Tadv_Mark",function(){b.formatter.toggle("mark")}),b.addButton("tadv_mark",{icon:"backcolor",tooltip:"Mark",cmd:"Tadv_Mark",stateSelector:"mark"}),b.on("init",function(){d&&b.on("SaveContent",function(a){a.content=a.content.replace(/caption\](\s|<br[^>]*>|<p>&nbsp;<\/p>)*\[caption/g,"caption] [caption"),a.content=a.content.replace(/<(object|audio|video)[\s\S]+?<\/\1>/g,function(a){return a.replace(/[\r\n\t ]+/g," ")}),a.content=a.content.replace(/<pre( [^>]*)?>[\s\S]+?<\/pre>/g,function(a){return a=a.replace(/<br ?\/?>(\r\n|\n)?/g,"\n"),a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g,"\n")}),a.content=c(a.content)});try{b.plugins.searchreplace&&!b.controlManager.buttons.searchreplace&&b.shortcuts.remove("meta+f")}catch(a){}b.formatter.register({mark:{inline:"mark"}})}),d&&(b.on("beforeSetContent",function(a){var b,c=window.wp;c&&(b=c.editor&&c.editor.autop,b||(b=c.oldEditor&&c.oldEditor.autop),a.load&&b&&a.content&&a.content.indexOf("\n")>-1&&!/<p>/i.test(a.content)&&(a.content=b(a.content)))},!0),b.settings.classic_block_editor&&b.on("beforeGetContent",function(a){"raw"!==a.format&&b.$("p").each(function(a,c){c.hasAttributes()||b.$(c).attr("data-tadv-p","keep")})},!0)),{addLineBreaks:c}})}(window.tinymce);
  • tinymce-advanced/trunk/readme.txt

    r1919235 r1993190  
    11=== TinyMCE Advanced ===
    22Contributors: azaozz
    3 Tags: wysiwyg, formatting, tinymce, write, editor
     3Tags: block editor, classic editor, editor, Gutenberg, formatting, tinymce, write
    44Requires at least: 4.9.8
    5 Tested up to: 4.9
     5Tested up to: 5.0
    66Stable tag: 4.8.0
     7Requires PHP: 5.2
    78License: GPLv2
    89License URI: http://www.gnu.org/licenses/gpl-2.0.html
    910
    10 Extends and enhances TinyMCE, the WordPress Visual Editor.
     11Extends and enhances TinyMCE, the visual editor used in both the Classic Editor and the new Block Editor in WordPress.
    1112
    1213== Description ==
    1314
    14 This plugin will let you add, remove and arrange the buttons that are shown on the Visual Editor toolbar. You can configure up to four rows of buttons including Font Sizes, Font Family, text and background colors, tables, etc. It will also let you enable the editor menu, see the [screenshots](screenshots).
    15 
    16 It includes 15 plugins for [TinyMCE](https://tinymce.com/) that are automatically enabled or disabled depending on the buttons you have chosen. In addition this plugin adds some commonly used options as keeping the paragraph tags in the Text editor and importing the CSS classes from the theme's editor-style.css.
     15For WordPress version 5.0 and newer the TinyMCE Advanced plugin introduces a "Hybrid Mode" for the new Block Editor (Gutenberg).
     16It brings the best of both editors together, enhances the Classic Block and adds a new Classic Paragraph Block that replaces the default Paragraph Block.
     17
     18If you are not quite ready to switch to the Block Editor, or have plugins that cannot be used there (yet), using Hybrid Mode is your best option.
     19It lets you to continue to use the familiar "Classic" editor inside the Classic Block, and at the same time gives you access to all blocks and new features in the Block Editor.
     20
     21If you want to continue to use the previous editor in WordPress 5.0 and newer, this plugin has an option to replace the new editor with the previous one. If you prefer to have access to both editors side by side or to allow your users to switch editors, it would be better to install the [Classic Editor plugin](https://wordpress.org/plugins/classic-editor/). TinyMCE Advanced is fully compatible with the Classic Editor plugin and similar plugins that restore use of the previous WordPress editor.
     22
     23As always this plugin will let you add, remove and arrange the buttons that are shown on the Visual Editor toolbar in the Classic Block in the new Block Editor, and in the Classic Editor (when enabled by a plugin). You can configure up to four rows of buttons including Font Sizes, Font Family, text and background colors, tables, etc. It will also let you enable the editor menu, see the [screenshots](screenshots).
     24
     25It includes 15 plugins for [TinyMCE](https://tinymce.com/) that are automatically enabled or disabled depending on the buttons you have chosen.
     26In addition this plugin adds some commonly used options as keeping the paragraph tags in the Text editor and importing the CSS classes from the theme's editor-style.css.
    1727
    1828= Some of the features added by this plugin =
    1929
    20 * Support for creating and editing tables.
    21 * More options when inserting lists.
    22 * Search and Replace in the editor.
    23 * Ability to set Font Family and Font Sizes.
     30* Hybrid mode that lets you use the best of both editors.
     31* Support for creating and editing tables in the Classic Block or the Classic Editor.
     32* More options when inserting lists in the Classic Block or the Classic Editor.
     33* Search and Replace in the Classic Block or the Classic Editor.
     34* Ability to set Font Family and Font Sizes in the Classic Block or the Classic Editor.
    2435* And many others.
    2536
    26 With this plugin you can also enable the TinyMCE menu above the toolbars. This will make the editor even more powerful and convenient.
    27 
    2837= Privacy =
    2938
     
    3746
    3847== Changelog ==
     48
     49= 4.8.1 =
     50* Updated for WordPress 5.0.
     51* Added Hybrid Mode for the Block Editor. Includes a Classic Paragraph Block that replaces the default Paragraph Block.
     52* Added option to replace the Block Editor with the Classic Editor.
     53* Added another settings section for configuring the toolbars in the Classic Block and the Classic Paragraph Block.
     54* Added some CSS fixed for the Classic Block.
     55* Fixed (removed) setting of inline CSS for table cells when inserting a table. Inline CSS is still added when a table is resized by dragging.
    3956
    4057= 4.8.0 =
     
    6986
    7087= 4.3.10.1 =
    71 * Fixed adding paragraph tags when loading posts that were saved before turning autop off.
     88* Fixed adding paragraph tags when loading posts that were saved before turning `wpautop` off.
    7289* Disabled the (new) inline toolbar for tables as it was overlapping the table in some cases.
    7390
     
    91108
    92109= 4.2.3.1 =
    93 * Fix error with removing the 'textpattern' plugin.
     110* Fix error with removing the `textpattern` plugin.
    94111
    95112= 4.2.3 =
    96113* Updated for WordPress 4.3 and TinyMCE 4.2.3.
    97 * Removed the 'textpattern' plugin as WordPress 4.3 includes similar functionality by default.
     114* Removed the `textpattern` plugin as WordPress 4.3 includes similar functionality by default.
    98115* French translation by Nicolas Schneider.
    99116
     
    113130= 4.1 =
    114131* Updated for WordPress 4.0 and TinyMCE 4.1.
    115 * Add the 'textpattern' plugin that supports some of the markdown syntax while typing, [(more info)](http://www.tinymce.com/wiki.php/Configuration:textpattern_patterns).
     132* Add the `textpattern` plugin that supports some of the markdown syntax while typing, [(more info)](http://www.tinymce.com/wiki.php/Configuration:textpattern_patterns).
    116133* Add the updated 'table' plugin that supports background and border color.
    117134
    118135= 4.0.2 =
    119136* Fix showing of the second, third and forth button rows when the Toolbar Toggle button is not used.
    120 * Fix adding the ''directionality'' plugin when RTL or LTR button is selected.
     137* Fix adding the `directionality` plugin when RTL or LTR button is selected.
    121138* Show the ''Advanced Options'' to super admins on multisite installs.
    122 * Add the ''link'' plugin including link rel setting. Replaces the Insert/Edit Link dialog when enabled.
     139* Add the `link` plugin including link rel setting. Replaces the Insert/Edit Link dialog when enabled.
    123140* Include updated ''table'' plugin that has support for vertical align for cells.
    124141
     
    156173Added advanced options: stop removing iframes, stop removing HTML 5.0 elements, moved the support for custom editor styles to editor-style.css in the current theme.
    157174
    158 Attention: if you have a customized tadv-mce.css file and your theme doesn't have editor-style.css, please download tadv-mce.css, rename it to editor-style.css and upload it to your current theme directory. Alternatively you can add there the editor-style.css from the Twenty Ten theme. If your theme has editor-style.css you can add any custom styles there.
     175Attention: if you have a customized `tadv-mce.css` file and your theme doesn't have editor-style.css, please download `tadv-mce.css`, rename it to editor-style.css and upload it to your current theme directory. Alternatively you can add there the editor-style.css from the Twenty Ten theme. If your theme has editor-style.css you can add any custom styles there.
    159176
    160177= 3.3.9 =
     
    171188
    172189= 3.1 =
    173 Compatibility with WordPress 2.6 and TinyMCE 3.1, keeps empty paragraphs when disabling the removal of P and BR tags, the buttons for MCImageManager and MCFileManager can be arranged (if installed).
     190Compatibility with WordPress 2.6 and TinyMCE 3.1, keeps empty paragraphs when disabling the removal of P and BR tags, the buttons for `MCImageManager` and `MCFileManager` can be arranged (if installed).
    174191
    175192= 3.0.1 =
    176 Compatibility with WordPress 2.5.1 and TinyMCE 3.0.7, added option to disable the removal of P and BR tags when saving and in the HTML editor (autop), added two more buttons to the HTML editor: autop and undo, fixed the removal of non-default TinyMCE buttons.
     193Compatibility with WordPress 2.5.1 and TinyMCE 3.0.7, added option to disable the removal of P and BR tags when saving and in the HTML editor (wpautop), added two more buttons to the HTML editor: `wpautop` and undo, fixed the removal of non-default TinyMCE buttons.
    177194
    178195= 3.0 =
     
    197214
    198215= 4.1 =
    199 Includes the 'textpattern' plugin that supports some of the markdown syntax while typing, and the updated 'table' plugin that supports background and border color for tables.
     216Includes the `textpattern` plugin that supports some of the markdown syntax while typing, and the updated 'table' plugin that supports background and border color for tables.
    200217
    201218== Frequently Asked Questions ==
     
    207224= I have just installed this plugin, but it does not do anything. =
    208225
    209 Change some buttons on one of the toolbars, save your changes, clear your browser cache, and try again. If that does not work try reloding the Edit page several times while holding down Shift or Ctrl. There may also be a network cache somewhere between you and your host. You may need to wait for a few hours until this cache expires.
     226Change some buttons on one of the toolbars, save your changes, clear your browser cache, and try again. If that does not work try reloading the Edit page several times while holding down Shift. There may also be a network cache somewhere between you and your host. You may need to wait for a few hours until this cache expires.
    210227
    211228= When I add "Smilies", they do not show in the editor. =
     
    225242Please post on the support forum or visit the homepage for [TinyMCE Advanced](http://www.laptoptips.ca/projects/tinymce-advanced/).
    226243
    227 
    228244== Screenshots ==
    229245
    230 1. The WordPress editor after installing this plugin (default plugin settings).
    231 2. The TinyMCE Advanced settings page, toolbars options.
    232 3. The TinyMCE Advanced settings page, user options.
    233 4. The TinyMCE Advanced settings page, advanced options.
    234 5. The TinyMCE Advanced settings page, admin options.
     2461. Classic Paragraph Block.
     2472. The Classic Editor (TinyMCE) toolbars settings.
     2483. The Classic Block (Block Editor) toolbars settings.
     2494. Editor options.
     2505. Advanced plugin options.
     2516. Administration options.
     252
     253== Upgrade Notice ==
     254
     255= 4.8.1 =
     256Updated for WordPress 5.0 and the Block Editor (Gutenebrg). Adds a "Classic Paragraph Block" with TinyMCE that replaces the default Paragraph Block.
  • tinymce-advanced/trunk/tadv_admin.php

    r1919233 r1993190  
    1313// TODO
    1414if ( ! current_user_can( 'manage_options' ) ) {
    15     wp_die('Access denied');
     15    wp_die( 'Invalid request' );
    1616}
    1717
     
    2222$tadv_options_updated = false;
    2323$settings = $admin_settings = array();
    24 
    25  
    2624
    2725if ( isset( $_POST['tadv-save'] ) ) {
     
    5048
    5149    ?>
    52     <div class="wrap">
     50    <div class="wrap tinymce-advanced">
    5351    <h2><?php _e( 'TinyMCE Advanced Settings Export', 'tinymce-advanced' ); ?></h2>
    5452
     
    7573    // TODO: all users
    7674    ?>
    77     <div class="wrap">
     75    <div class="wrap tinymce-advanced">
    7876    <h2><?php _e( 'TinyMCE Advanced Settings Import', 'tinymce-advanced' ); ?></h2>
    7977
     
    126124
    127125?>
    128 <div class="wrap" id="contain">
     126<div class="wrap tinymce-advanced" id="contain">
    129127<h2><?php _e( 'Editor Settings', 'tinymce-advanced' ); ?></h2>
    130128<?php
     
    142140<form id="tadvadmin" method="post" action="">
    143141
    144 <p class="tadv-submit">
    145     <input class="button-primary button-large" type="submit" name="tadv-save" value="<?php _e( 'Save Changes', 'tinymce-advanced' ); ?>" />
     142<p class="tadv-submit tadv-submit-top">
     143    <input class="button-primary button-large top-button" type="submit" name="tadv-save" value="<?php _e( 'Save Changes', 'tinymce-advanced' ); ?>" />
    146144</p>
    147145
     146<div id="classic-editor">
     147<h3><?php _e( 'Toolbars for the Classic Editor (TinyMCE)', 'tinymce-advanced' ); ?></h3>
     148
    148149<div id="tadvzones">
    149 
    150 <p><label>
    151 <input type="checkbox" name="options[]" id="menubar" value="menubar" <?php if ( $this->check_user_setting( 'menubar' ) ) { echo ' checked="checked"'; } ?>>
    152 <?php _e( 'Enable the editor menu.', 'tinymce-advanced' ); ?>
    153 </label></p>
    154 
    155 <div id="tadv-mce-menu" class="mce-container mce-menubar mce-toolbar mce-first mce-stack-layout-item
     150<p>
     151    <input type="checkbox" name="options[]" id="menubar" value="menubar" <?php if ( $this->check_user_setting( 'menubar' ) ) { echo ' checked="checked"'; } ?>>
     152    <label for="menubar"><?php _e( 'Enable the editor menu.', 'tinymce-advanced' ); ?></label>
     153</p>
     154
     155<div class="tadv-mce-menu tadv-classic-editor mce-container mce-menubar mce-toolbar mce-first mce-stack-layout-item
    156156    <?php if ( $this->check_user_setting( 'menubar' ) ) { echo ' enabled'; } ?>">
    157157    <div class="mce-container-body mce-flow-layout">
     
    204204
    205205$mce_text_buttons = array( 'styleselect', 'formatselect', 'fontselect', 'fontsizeselect' );
     206$all_buttons_classic = $all_buttons;
    206207
    207208for ( $i = 1; $i < 5; $i++ ) {
     
    218219        }
    219220
    220         if ( isset( $all_buttons[$button] ) ) {
    221             $name = $all_buttons[$button];
    222             unset( $all_buttons[$button] );
     221        if ( isset( $all_buttons_classic[ $button ] ) ) {
     222            $name = $all_buttons_classic[ $button ];
     223            unset( $all_buttons_classic[ $button ] );
    223224        } else {
    224             // error?..
    225225            continue;
    226226        }
    227227
    228         ?><li class="tadvmodule" id="<?php echo $button; ?>">
     228        ?>
     229        <li class="tadvmodule" id="<?php echo $button; ?>">
    229230            <?php
    230231
     
    250251
    251252            ?>
    252         </li><?php
     253        </li>
     254        <?php
    253255
    254256    }
     
    262264</div>
    263265
    264 <p><?php _e( 'Drag buttons from the unused buttons below and drop them in the toolbars above, or drag the buttons in the toolbars to rearrange them.', 'tinymce-advanced' ); ?></p>
    265 
    266 <div id="unuseddiv">
    267 <h3><?php _e( 'Unused Buttons', 'tinymce-advanced' ); ?></h3>
    268 <ul id="unused" class="container">
    269 <?php
    270 
    271 foreach( $all_buttons as $button => $name ) {
    272     if ( strpos( $button, 'separator' ) !== false ) {
    273         continue;
     266<p><?php _e( 'Drop buttons in the toolbars, or drag the buttons to rearrange them.', 'tinymce-advanced' ); ?></p>
     267
     268<div class="unuseddiv">
     269    <h4><?php _e( 'Unused Buttons', 'tinymce-advanced' ); ?></h4>
     270    <div>
     271        <ul id="unused" class="unused container">
     272        <?php
     273
     274        foreach( $all_buttons_classic as $button => $name ) {
     275            if ( strpos( $button, 'separator' ) !== false ) {
     276                continue;
     277            }
     278
     279            ?>
     280            <li class="tadvmodule" id="<?php echo $button; ?>">
     281                <?php
     282
     283                if ( in_array( $button, $mce_text_buttons, true ) ) {
     284                    ?>
     285                    <div class="tadvitem mce-widget mce-btn mce-menubtn mce-fixed-width mce-listbox">
     286                        <div class="the-button">
     287                            <span class="descr"><?php echo $name; ?></span>
     288                            <i class="mce-caret"></i>
     289                            <input type="hidden" class="tadv-button" name="unused[]" value="<?php echo $button; ?>" />
     290                        </div>
     291                    </div>
     292                    <?php
     293                } else {
     294                    ?>
     295                    <div class="tadvitem">
     296                        <i class="mce-ico mce-i-<?php echo $button; ?>" title="<?php echo $name; ?>"></i>
     297                        <span class="descr"><?php echo $name; ?></span>
     298                        <input type="hidden" class="tadv-button" name="unused[]" value="<?php echo $button; ?>" />
     299                    </div>
     300                    <?php
     301                }
     302
     303                ?>
     304            </li>
     305            <?php
     306        }
     307
     308        ?>
     309        </ul>
     310    </div><!-- /highlighted -->
     311</div>
     312</div><!-- /classic-editor -->
     313
     314<div id="block-editor">
     315<h3><?php _e( 'Toolbars for the Classic Blocks in the Block Editor (Gutenberg)', 'tinymce-advanced' ); ?></h3>
     316
     317<p>
     318    <?php _e( 'The toolbars in the Classic Block are narrower and show on focus.', 'tinymce-advanced' ); ?>
     319    <?php _e( 'For best results enable the menu and add only essential buttons.', 'tinymce-advanced' ); ?>
     320    <?php _e( 'The buttons will wrap around depending on the width of the toolbar.', 'tinymce-advanced' ); ?>
     321</p>
     322
     323<p>
     324    <input type="checkbox" name="options[]" id="menubar_block" value="menubar_block" <?php if ( $this->check_user_setting( 'menubar_block' ) ) { echo ' checked'; } ?>>
     325    <label for="menubar_block"><?php _e( 'Enable the editor menu (recommended).', 'tinymce-advanced' ); ?></label>
     326</p>
     327
     328<div class="tadv-mce-menu tadv-block-editor mce-container mce-menubar mce-toolbar mce-first mce-stack-layout-item
     329    <?php if ( $this->check_user_setting( 'menubar' ) ) { echo ' enabled'; } ?>">
     330    <div class="mce-container-body mce-flow-layout">
     331        <div class="mce-widget mce-btn mce-menubtn mce-first mce-flow-layout-item">
     332            <button type="button">
     333                <span class="tadv-translate">File</span>
     334                <i class="mce-caret"></i>
     335            </button>
     336        </div>
     337        <div class="mce-widget mce-btn mce-menubtn mce-flow-layout-item">
     338            <button type="button">
     339                <span class="tadv-translate">Edit</span>
     340                <i class="mce-caret"></i>
     341            </button>
     342        </div>
     343        <div class="mce-widget mce-btn mce-menubtn mce-flow-layout-item">
     344            <button type="button">
     345                <span class="tadv-translate">Insert</span>
     346                <i class="mce-caret"></i>
     347            </button>
     348        </div>
     349        <div class="mce-widget mce-btn mce-menubtn mce-flow-layout-item mce-toolbar-item">
     350            <button type="button">
     351                <span class="tadv-translate">View</span>
     352                <i class="mce-caret"></i>
     353            </button>
     354        </div>
     355        <div class="mce-widget mce-btn mce-menubtn mce-flow-layout-item">
     356            <button type="button">
     357                <span class="tadv-translate">Format</span>
     358                <i class="mce-caret"></i>
     359            </button>
     360        </div>
     361        <div class="mce-widget mce-btn mce-menubtn mce-flow-layout-item">
     362            <button type="button">
     363                <span class="tadv-translate">Table</span>
     364                <i class="mce-caret"></i>
     365            </button>
     366        </div>
     367        <div class="mce-widget mce-btn mce-menubtn mce-last mce-flow-layout-item">
     368            <button type="button">
     369                <span class="tadv-translate">Tools</span>
     370                <i class="mce-caret"></i>
     371            </button>
     372        </div>
     373    </div>
     374</div>
     375
     376<div class="tadvdropzone tadv-block-editor mce-toolbar">
     377    <ul id="toolbar_classic_block" class="container-classic-block">
     378    <?php
     379
     380    $all_buttons_block = $all_buttons;
     381
     382    // Remove the toolbar-toggle
     383    unset( $all_buttons_block['wp_adv'] );
     384
     385    foreach( $this->toolbar_classic_block as $button_id ) {
     386        $name = '';
     387
     388        if ( strpos( $button, 'separator' ) !== false || in_array( $button, array( 'moveforward', 'movebackward', 'absolute' ) ) ) {
     389            continue;
     390        }
     391
     392        if ( isset( $all_buttons_block[ $button_id ] ) ) {
     393            $name = $all_buttons_block[ $button_id ];
     394            unset( $all_buttons_block[ $button_id ] );
     395        } else {
     396            continue;
     397        }
     398
     399        ?>
     400        <li class="tadvmodule" id="<?php echo $button_id; ?>">
     401            <?php
     402
     403            if ( in_array( $button_id, $mce_text_buttons, true ) ) {
     404                ?>
     405                <div class="tadvitem mce-widget mce-btn mce-menubtn mce-fixed-width mce-listbox">
     406                    <div class="the-button">
     407                        <span class="descr"><?php echo $name; ?></span>
     408                        <i class="mce-caret"></i>
     409                        <input type="hidden" class="tadv-button" name="toolbar_classic_block[]" value="<?php echo $button_id; ?>" />
     410                    </div>
     411                </div>
     412                <?php
     413            } else {
     414                ?>
     415                <div class="tadvitem">
     416                    <i class="mce-ico mce-i-<?php echo $button_id; ?>" title="<?php echo $name; ?>"></i>
     417                    <span class="descr"><?php echo $name; ?></span>
     418                    <input type="hidden" class="tadv-button" name="toolbar_classic_block[]" value="<?php echo $button_id; ?>" />
     419                </div>
     420                <?php
     421            }
     422
     423            ?>
     424        </li>
     425        <?php
    274426    }
    275427
    276     ?><li class="tadvmodule" id="<?php echo $button; ?>">
     428    ?>
     429    </ul>
     430</div>
     431
     432<p><?php _e( 'Drop buttons in the toolbars, or drag the buttons to rearrange them.', 'tinymce-advanced' ); ?></p>
     433
     434<div class="unuseddiv">
     435    <h4><?php _e( 'Unused Buttons for the Classic Block', 'tinymce-advanced' ); ?></h4>
     436    <div>
     437        <ul id="unused-classic-block" class="unused container-classic-block">
    277438        <?php
    278439
    279         if ( in_array( $button, $mce_text_buttons, true ) ) {
     440        foreach( $all_buttons_block as $button_id => $name ) {
     441            if ( strpos( $button, 'separator' ) !== false ) {
     442                continue;
     443            }
     444
    280445            ?>
    281             <div class="tadvitem mce-widget mce-btn mce-menubtn mce-fixed-width mce-listbox">
    282                 <div class="the-button">
    283                     <span class="descr"><?php echo $name; ?></span>
    284                     <i class="mce-caret"></i>
    285                     <input type="hidden" class="tadv-button" name="unused[]" value="<?php echo $button; ?>" />
    286                 </div>
    287             </div>
     446            <li class="tadvmodule" id="<?php echo $button_id; ?>">
     447                <?php
     448
     449                if ( in_array( $button_id, $mce_text_buttons, true ) ) {
     450                    ?>
     451                    <div class="tadvitem mce-widget mce-btn mce-menubtn mce-fixed-width mce-listbox">
     452                        <div class="the-button">
     453                            <span class="descr"><?php echo $name; ?></span>
     454                            <i class="mce-caret"></i>
     455                            <input type="hidden" class="tadv-button" name="unused-classic-block[]" value="<?php echo $button_id; ?>" />
     456                        </div>
     457                    </div>
     458                    <?php
     459                } else {
     460                    ?>
     461                    <div class="tadvitem">
     462                        <i class="mce-ico mce-i-<?php echo $button_id; ?>" title="<?php echo $name; ?>"></i>
     463                        <span class="descr"><?php echo $name; ?></span>
     464                        <input type="hidden" class="tadv-button" name="unused-classic-block[]" value="<?php echo $button_id; ?>" />
     465                    </div>
     466                    <?php
     467                }
     468
     469                ?>
     470            </li>
    288471            <?php
    289         } else {
    290             ?>
    291             <div class="tadvitem">
    292                 <i class="mce-ico mce-i-<?php echo $button; ?>" title="<?php echo $name; ?>"></i>
    293                 <span class="descr"><?php echo $name; ?></span>
    294                 <input type="hidden" class="tadv-button" name="unused[]" value="<?php echo $button; ?>" />
    295             </div>
    296             <?php
    297472        }
    298473
    299474        ?>
    300     </li><?php
    301 
    302 }
    303 
    304 ?>
    305 </ul>
    306 </div>
     475        </ul>
     476    </div><!-- /highlight -->
     477</div><!-- /unuseddiv -->
     478</div><!-- /block-editor -->
    307479
    308480<div class="advanced-options">
    309481    <h3><?php _e( 'Options', 'tinymce-advanced' ); ?></h3>
    310     <div>
    311         <label><input type="checkbox" name="options[]" value="advlist" id="advlist" <?php if ( $this->check_user_setting('advlist') ) echo ' checked="checked"'; ?> />
    312         <?php _e( 'List Style Options', 'tinymce-advanced' ); ?></label>
     482
     483    <div>
     484        <input type="checkbox" name="options[]" value="no_merge_toolbars" id="merge_toolbars" <?php if ( ! $this->check_user_setting('no_merge_toolbars') ) echo ' checked'; ?> />
     485        <label for="merge_toolbars"><?php _e( 'Append all buttons to the top toolbar in the Classic and Classic Paragraph blocks.', 'tinymce-advanced' ); ?></label>
     486        <p><?php _e( 'This affects buttons that are added by other plugins. These buttons will be appended to the top toolbar row instead of forming second, third, and forth rows.', 'tinymce-advanced' ); ?></p>
     487    </div>
     488
     489    <div>
     490        <input type="checkbox" name="options[]" value="advlist" id="advlist" <?php if ( $this->check_user_setting('advlist') ) echo ' checked'; ?> />
     491        <label for="advlist"><?php _e( 'List Style Options', 'tinymce-advanced' ); ?></label>
    313492        <p>
    314493            <?php _e( 'Enable more list options: upper or lower case letters for ordered lists, disk or square for unordered lists, etc.', 'tinymce-advanced' ); ?>
    315494        </p>
    316495    </div>
    317     <div>
    318         <label><input type="checkbox" name="options[]" value="contextmenu" id="contextmenu" <?php if ( $this->check_user_setting('contextmenu') ) echo ' checked="checked"'; ?> />
    319         <?php _e( 'Context Menu', 'tinymce-advanced' ); ?></label>
    320         <p>
    321             <?php _e( 'Replace the browser context (right-click) menu.', 'tinymce-advanced' ); ?>
    322         </p>
    323     </div>
    324     <div>
    325         <label><input type="checkbox" name="options[]" value="advlink" id="advlink" <?php if ( $this->check_user_setting('advlink') ) echo ' checked="checked"'; ?> />
    326         <?php _e( 'Alternative link dialog', 'tinymce-advanced' ); ?></label>
    327         <p>
    328             <?php _e( 'Open the TinyMCE link dialog when using the link button on the toolbar or the link menu item.', 'tinymce-advanced' ); ?>
    329         </p>
    330     </div>
    331     <div>
    332         <label><input type="checkbox" name="options[]" value="fontsize_formats" id="fontsize_formats" <?php if ( $this->check_user_setting( 'fontsize_formats' ) ) echo ' checked="checked"'; ?> />
    333         <?php _e( 'Font sizes', 'tinymce-advanced' ); ?></label>
     496
     497    <div>
     498        <input type="checkbox" name="options[]" value="contextmenu" id="contextmenu" <?php if ( $this->check_user_setting('contextmenu') ) echo ' checked'; ?> />
     499        <label for="contextmenu"><?php _e( 'Context Menu', 'tinymce-advanced' ); ?></label>
     500        <p><?php _e( 'Replace the browser context (right-click) menu.', 'tinymce-advanced' ); ?></p>
     501    </div>
     502
     503    <div>
     504        <input type="checkbox" name="options[]" value="advlink" id="advlink" <?php if ( $this->check_user_setting('advlink') ) echo ' checked'; ?> />
     505        <label for="advlink"><?php _e( 'Alternative link dialog', 'tinymce-advanced' ); ?></label>
     506        <p><?php _e( 'Open the TinyMCE link dialog when using the link button on the toolbar or the link menu item.', 'tinymce-advanced' ); ?></p>
     507    </div>
     508
     509    <div>
     510        <input type="checkbox" name="options[]" value="fontsize_formats" id="fontsize_formats" <?php if ( $this->check_user_setting( 'fontsize_formats' ) ) echo ' checked="checked"'; ?> />
     511        <label for="fontsize_formats"><?php _e( 'Font sizes', 'tinymce-advanced' ); ?></label>
    334512        <p><?php printf( __( 'Replace the size setting available for fonts with: %s.', 'tinymce-advanced' ), $this->fontsize_formats ); ?></p>
    335513    </div>
     
    338516
    339517if ( ! is_multisite() || current_user_can( 'manage_sites' ) ) {
     518    $preselect = function_exists( 'use_block_editor_for_post_type' ) ? '' : '<p>' . __( 'You can pre-select this option. It will be enabled as soon as you upgrade to WordPress 5.0 or later.', 'tinymce-advanced' ) . '</p>';
     519
    340520    ?>
    341521    <div class="advanced-options">
    342522    <h3><?php _e( 'Advanced Options', 'tinymce-advanced' ); ?></h3>
     523    <div>
     524        <input type="checkbox" name="admin_options[]" value="no_hybrid_mode" id="no_hybrid_mode" <?php if ( ! $this->check_admin_setting( 'no_hybrid_mode' ) ) echo ' checked'; ?> />
     525        <label for="no_hybrid_mode"><?php _e( 'Hybrid Block Editor Mode', 'tinymce-advanced' ); ?></label>
     526        <p><strong><?php _e( 'Brings the best of both editors together!', 'tinymce-advanced' ); ?></strong></p>
     527        <p>
     528            <?php _e( 'You can continue to use the familiar TinyMCE Editor in the (new and improved) &#8220;Classic&#8221; Paragraph Block, and at the same time have access to all blocks and new goodies of the Block Editor.', 'tinymce-advanced' ); ?>
     529        </p>
     530        <p>
     531            <?php _e( 'Selecting this option makes the Classic Block in the Block Editor more prominent and adds a new &#8220;Classic Paragraph Block&#8221; that includes the TinyMCE Editor and replaces the Paragraph Block.', 'tinymce-advanced' ); ?>
     532            <?php _e( 'Most existing TinyMCE plugins and add-ons will continue to work in the Classic Paragraph Block as well as in the Classic Block.', 'tinymce-advanced' ); ?>
     533            <?php _e( 'This makes the Block Editor more familiar, easier to use, and much more compatible with your existing workflow.', 'tinymce-advanced' ); ?>
     534        </p>
     535        <p>
     536            <?php _e( 'Note: The Classic Paragraph Block and the Classic Block are interchangeable. When saving a post that contains several successive Classic Paragraph blocks, they will be merged into one Classic Block.', 'tinymce-advanced' ); ?>
     537            <?php _e( 'This will keep the blocks compatible should you decide to uninstall this plugin or turn the above option off.', 'tinymce-advanced' ); ?>
     538        </p>
     539        <?php echo $preselect ?>
     540    </div>
     541    <div>
     542        <?php
     543
     544        if ( function_exists( 'is_plugin_active' ) && ! is_plugin_active( 'classic-editor/classic-editor.php' ) ) {
     545
     546            ?>
     547            <input type="checkbox" name="admin_options[]" value="replace_block_editor" id="replace_block_editor" <?php if ( $this->check_admin_setting( 'replace_block_editor' ) ) echo ' checked'; ?> />
     548            <label for="replace_block_editor"><?php _e( 'Replace the Block Editor with the Classic Editor', 'tinymce-advanced' ); ?></label>
     549            <p>
     550                <?php _e( 'Selecting this option will restore the previous (&#8220;classic&#8221;) editor and the previous Edit Post screen.', 'tinymce-advanced' ); ?>
     551                <?php _e( 'It will allow you to use other plugins that enhance that editor, add old-style Meta Boxes, or in some way depend on the previous Edit Post screen.', 'tinymce-advanced' ); ?>
     552            </p>
     553            <?php echo $preselect ?>
     554            <p>
     555                <?php
     556
     557                $text = __( 'If you prefer to use both editors side by side, do not enable this option. It is better to install the %1$sClassic Editor plugin%2$s.', 'tinymce-advanced' );
     558                $url = 'https://wordpress.org/plugins/classic-editor/';
     559                printf( $text, '<a href="' . esc_url( $url ) . '">', '</a>' );
     560
     561                ?>
     562            </p>
     563            <?php
     564        }
     565
     566        ?>
     567    </div>
     568    <div>
     569        <input type="checkbox" name="admin_options[]" value="no_autop" id="no_autop" <?php if ( $this->check_admin_setting( 'no_autop' ) ) echo ' checked'; ?> />
     570        <label for="no_autop"><?php _e( 'Keep paragraph tags', 'tinymce-advanced' ); ?></label>
     571        <p><strong><?php _e( 'Recommended for better compatibility with the Block Editor (Gutenberg).', 'tinymce-advanced' ); ?></strong></p>
     572        <p>
     573            <?php _e( 'Stop removing the &lt;p&gt; and &lt;br&gt; tags when saving and show them in the Text editor.', 'tinymce-advanced' ); ?>
     574            <?php _e( 'This will make it possible to use more advanced coding in the Text editor without the back-end filtering affecting it much.', 'tinymce-advanced' ); ?>
     575            <?php _e( 'However it may behave unexpectedly in rare cases, so test it thoroughly before enabling it permanently.', 'tinymce-advanced' ); ?>
     576            <?php _e( 'Line breaks in the Text editor would still affect the output, in particular do not use empty lines, line breaks inside HTML tags or multiple &lt;br&gt; tags.', 'tinymce-advanced' ); ?>
     577        </p>
     578    </div>
    343579    <?php
    344580
     
    346582    $disabled = ' disabled';
    347583
    348     if ( $has_editor_style === 'not-supporetd' || $has_editor_style === 'not-present' ) {
     584    if ( $has_editor_style === false ) {
    349585        add_editor_style();
     586        $has_editor_style = $this->has_editor_style();
    350587    }
    351588
    352     if ( $this->has_editor_style() === 'present' ) {
     589    if ( $has_editor_style ) {
    353590        $disabled = '';
    354         $has_editor_style = 'present';
    355591    }
    356592
    357593    ?>
    358594    <div>
    359         <label><input type="checkbox" name="admin_options[]" value="importcss" id="importcss" <?php if ( ! $disabled && $this->check_admin_setting( 'importcss' ) ) echo ' checked="checked"'; echo $disabled; ?> />
    360         <?php _e( 'Create CSS classes menu', 'tinymce-advanced' ); ?></label>
    361         <p>
     595        <input type="checkbox" name="admin_options[]" value="importcss" id="importcss" <?php if ( ! $disabled && $this->check_admin_setting( 'importcss' ) ) echo ' checked'; echo $disabled; ?> />
     596        <label for="importcss"><?php _e( 'Create CSS classes menu', 'tinymce-advanced' ); ?></label>
     597        <p>
     598            <?php _e( 'Load the CSS classes used in editor-style.css and replace the Formats menu.', 'tinymce-advanced' ); ?>
     599        </p>
    362600        <?php
    363601
    364         _e( 'Load the CSS classes used in editor-style.css and replace the Formats menu.', 'tinymce-advanced' );
    365 
    366         if ( $has_editor_style === 'not-supporetd' ) {
     602        if ( $disabled ) {
    367603            ?>
    368                 <br>
    369                 <span class="tadv-error"><?php _e( 'ERROR:', 'tinymce-advanced' ); ?></span>
    370                 <?php _e( 'Your theme does not support editor-style.css.', 'tinymce-advanced' ); ?>
     604            <p>
     605            <span class="tadv-error"><?php _e( 'Disabled:', 'tinymce-advanced' ); ?></span>
     606            <?php _e( 'A stylesheet file named editor-style.css was not added by your theme.', 'tinymce-advanced' ); ?>
     607            <br>
    371608            <?php
    372         } elseif ( $disabled ) {
    373             ?>
    374                 <br>
    375                 <span class="tadv-error"><?php _e( 'ERROR:', 'tinymce-advanced' ); ?></span>
    376                 <?php _e( 'A stylesheet file named editor-style.css was not added by your theme.', 'tinymce-advanced' ); ?>
    377             <?php
    378         }
    379 
    380         if ( $has_editor_style === 'not-supporetd' || $disabled ) {
    381             _e( 'To use this option, add editor-style.css to your theme or a child theme. Enabling this option will also load that stylesheet in the editor.', 'tinymce-advanced' );
    382609        }
    383610
     
    386613    </div>
    387614    <div>
    388         <label><input type="checkbox" name="admin_options[]" value="no_autop" id="no_autop" <?php if ( $this->check_admin_setting( 'no_autop' ) ) echo ' checked="checked"'; ?> />
    389         <?php _e( 'Keep paragraph tags', 'tinymce-advanced' ); ?></label>
    390         <p>
    391             <?php _e( 'Stop removing the &lt;p&gt; and &lt;br /&gt; tags when saving and show them in the Text editor.', 'tinymce-advanced' ); ?>
    392             <?php _e( 'This will make it possible to use more advanced coding in the Text editor without the back-end filtering affecting it much.', 'tinymce-advanced' ); ?>
    393             <?php _e( 'However it may behave unexpectedly in rare cases, so test it thoroughly before enabling it permanently.', 'tinymce-advanced' ); ?>
    394             <?php _e( 'Line breaks in the Text editor would still affect the output, in particular do not use empty lines, line breaks inside HTML tags or multiple &lt;br /&gt; tags.', 'tinymce-advanced' ); ?>
    395         </p>
    396     </div>
    397     <div>
    398         <label><input type="checkbox" name="admin_options[]" value="paste_images" id="paste_images" <?php if ( $this->check_admin_setting( 'paste_images' ) ) echo ' checked="checked"'; ?> />
    399         <?php _e( 'Enable pasting of image source', 'tinymce-advanced' ); ?></label>
     615        <input type="checkbox" name="admin_options[]" value="paste_images" id="paste_images" <?php if ( $this->check_admin_setting( 'paste_images' ) ) echo ' checked'; ?> />
     616        <label for="paste_images"><?php _e( 'Enable pasting of image source', 'tinymce-advanced' ); ?></label>
    400617        <p>
    401618            <?php _e( 'Works only in Firefox and Safari. These browsers support pasting of images directly in the editor and convert them to base64 encoded text.', 'tinymce-advanced' ); ?>
     
    404621        </p>
    405622    </div>
     623    <div>
     624        <p class="tadv-help">
     625        <?php
     626
     627        $text = __( 'For other advanced TinyMCE settings, including settings for the Classic Block in the Block Editor, you can use the %1$sAdvanced TinyMCE Configuration plugin%2$s.', 'tinymce-advanced' );
     628        $url = 'https://wordpress.org/plugins/advanced-tinymce-configuration/';
     629        printf( $text, '<a href="' . esc_url( $url ) . '">', '</a>' );
     630
     631        ?>
     632        </p>
     633    </div>
    406634    </div>
    407635
     
    418646        <h4><?php _e( 'Enable the editor enhancements for:', 'tinymce-advanced' ); ?></h4>
    419647        <p>
    420             <label><input type="checkbox" name="tadv_enable_at[]" value="edit_post_screen" <?php if ( $this->check_admin_setting( 'enable_edit_post_screen' ) ) echo ' checked="checked"'; ?> />
    421             <?php _e( 'The main editor (Add New and Edit posts and pages)', 'tinymce-advanced' ); ?></label>
    422         </p>
    423         <p>
    424             <label><input type="checkbox" name="tadv_enable_at[]" value="rest_of_wpadmin" <?php if ( $this->check_admin_setting( 'enable_rest_of_wpadmin' ) ) echo ' checked="checked"'; ?> />
    425             <?php _e( 'Other editors in wp-admin', 'tinymce-advanced' ); ?></label>
    426         </p>
    427         <p>
    428             <label><input type="checkbox" name="tadv_enable_at[]" value="on_front_end" <?php if ( $this->check_admin_setting( 'enable_on_front_end' ) ) echo ' checked="checked"'; ?> />
    429             <?php _e( 'Editors on the front end of the site', 'tinymce-advanced' ); ?></label>
     648            <input type="checkbox" id="tadv_enable_1" name="tadv_enable_at[]" value="edit_post_screen" <?php if ( $this->check_admin_setting( 'enable_edit_post_screen' ) ) echo ' checked'; ?> />
     649            <label for="tadv_enable_1"><?php _e( 'The main editor (Add New and Edit posts and pages)', 'tinymce-advanced' ); ?></label>
     650        </p>
     651        <p>
     652            <input type="checkbox" id="tadv_enable_2" name="tadv_enable_at[]" value="rest_of_wpadmin" <?php if ( $this->check_admin_setting( 'enable_rest_of_wpadmin' ) ) echo ' checked'; ?> />
     653            <label for="tadv_enable_2"><?php _e( 'Other editors in wp-admin', 'tinymce-advanced' ); ?></label>
     654        </p>
     655        <p>
     656            <input type="checkbox" id="tadv_enable_3" name="tadv_enable_at[]" value="on_front_end" <?php if ( $this->check_admin_setting( 'enable_on_front_end' ) ) echo ' checked'; ?> />
     657            <label for="tadv_enable_3"><?php _e( 'Editors on the front end of the site', 'tinymce-advanced' ); ?></label>
    430658        </p>
    431659    </div>
     
    435663}
    436664?>
     665
     666<hr>
    437667
    438668<p class="tadv-submit">
  • tinymce-advanced/trunk/tinymce-advanced.php

    r1919233 r1993190  
    44Plugin URI: http://www.laptoptips.ca/projects/tinymce-advanced/
    55Description: Enables advanced features and plugins in TinyMCE, the visual editor in WordPress.
    6 Version: 4.8.0
     6Version: 4.8.1
    77Author: Andrew Ozz
    88Author URI: http://www.laptoptips.ca/
     
    2828*/
    2929
     30if ( ! defined( 'ABSPATH' ) ) {
     31    exit;
     32}
     33
    3034if ( ! class_exists('Tinymce_Advanced') ) :
    3135
     
    3337
    3438    private $required_version = '4.9.6';
    35     private $plugin_version = '4.7.13';
     39    private $plugin_version = '4.8.1';
    3640
    3741    private $user_settings;
     
    5155    private $buttons_filter = array();
    5256    private $fontsize_formats = '8px 10px 12px 14px 16px 20px 24px 28px 32px 36px 48px 60px 72px 96px';
    53    
     57    private $required_menubar_plugins = array(
     58        'anchor',
     59        'code',
     60        'insertdatetime',
     61        'nonbreaking',
     62        'print',
     63        'searchreplace',
     64        'table',
     65        'visualblocks',
     66        'visualchars'
     67    );
    5468
    5569    private function get_default_user_settings() {
    5670        return array(
    57             'options'   => 'menubar,advlist',
     71            'options'   => 'menubar,advlist,menubar_block',
    5872            'toolbar_1' => 'formatselect,bold,italic,blockquote,bullist,numlist,alignleft,aligncenter,alignright,link,unlink,undo,redo',
    5973            'toolbar_2' => 'fontselect,fontsizeselect,outdent,indent,pastetext,removeformat,charmap,wp_more,forecolor,table,wp_help',
    6074            'toolbar_3' => '',
    6175            'toolbar_4' => '',
     76            'toolbar_classic_block' => 'formatselect,bold,italic,blockquote,bullist,numlist,alignleft,aligncenter,alignright,link,forecolor,backcolor,table,wp_help',
    6277            'plugins'   => 'anchor,code,insertdatetime,nonbreaking,print,searchreplace,table,visualblocks,visualchars,advlist,wptadv',
    6378        );
     
    96111            'contextmenu',
    97112            'menubar',
     113            'menubar_block',
    98114            'fontsize_formats',
     115            'no_merge_toolbars',
    99116        );
    100117    }
     
    105122            'no_autop',
    106123            'paste_images',
     124            'no_hybrid_mode',
     125            'replace_block_editor',
    107126        );
    108127    }
     
    117136
    118137    public function __construct() {
    119         if ( ! defined('ABSPATH') ) {
    120             return;
    121         }
    122138
    123139        register_activation_hook( __FILE__, array( $this, 'check_plugin_version' ) );
     
    136152
    137153        add_filter( 'mce_buttons', array( $this, 'mce_buttons_1' ), 999, 2 );
    138         add_filter( 'mce_buttons_2', array( $this, 'mce_buttons_2' ), 999 );
    139         add_filter( 'mce_buttons_3', array( $this, 'mce_buttons_3' ), 999 );
    140         add_filter( 'mce_buttons_4', array( $this, 'mce_buttons_4' ), 999 );
    141 
    142         add_filter( 'tiny_mce_before_init', array( $this, 'mce_options' ) );
     154        add_filter( 'mce_buttons_2', array( $this, 'mce_buttons_2' ), 999, 2 );
     155        add_filter( 'mce_buttons_3', array( $this, 'mce_buttons_3' ), 999, 2 );
     156        add_filter( 'mce_buttons_4', array( $this, 'mce_buttons_4' ), 999, 2 );
     157
     158        add_filter( 'tiny_mce_before_init', array( $this, 'mce_options' ), 10, 2 );
    143159        add_filter( 'mce_external_plugins', array( $this, 'mce_external_plugins' ), 999 );
    144160        add_filter( 'tiny_mce_plugins', array( $this, 'tiny_mce_plugins' ), 999 );
    145         add_action( 'after_wp_tiny_mce', array( $this, 'after_wp_tiny_mce' ) );
     161
     162        add_action( 'enqueue_block_editor_assets', array( $this, 'block_editor_assets' ), 20 );
     163        // add_filter( 'block_editor_preload_paths', array( $this, 'initial_post_content' ), 10, 2 );
     164
     165        add_action( 'init', array( $this, 'block_editor_init' ) );
     166
     167        add_filter( 'wp_insert_post_data', array( $this, 'filter_post_content' ), 1 );
    146168    }
    147169
     
    174196
    175197        if ( ! $this->disabled_for_editor && ! $editor_style_added ) {
    176             if ( $this->check_admin_setting( 'importcss' ) && $this->has_editor_style() !== 'present' ) {
     198            if ( $this->check_admin_setting( 'importcss' ) && $this->has_editor_style() === false ) {
    177199                add_editor_style();
    178200            }
     
    190212    private function has_editor_style() {
    191213        if ( ! current_theme_supports( 'editor-style' ) ) {
    192             return 'not-supporetd';
     214            return false;
    193215        }
    194216
     
    198220            foreach ( $editor_stylesheets as $url ) {
    199221                if ( strpos( $url, 'editor-style.css' ) !== false ) {
    200                     return 'present';
     222                    return $url;
    201223                }
    202224            }
    203225        }
    204226
    205         return 'not-present';
     227        return '';
    206228    }
    207229
     
    258280        $this->admin_options = ! empty( $this->admin_settings['options'] ) ? explode( ',', $this->admin_settings['options'] ) : array();
    259281
     282        $default_user_settings = $this->get_default_user_settings();
     283
    260284        if ( $this->user_settings === false ) {
    261             $this->user_settings = $this->get_default_user_settings();
     285            $this->user_settings = $default_user_settings;
     286        }
     287
     288        if ( empty( $this->user_settings['toolbar_1'] ) ) {
     289            $this->user_settings['toolbar_1'] = $default_user_settings['toolbar_1'];
     290        }
     291
     292        if ( empty( $this->user_settings['toolbar_classic_block'] ) ) {
     293            $this->user_settings['toolbar_classic_block'] = $default_user_settings['toolbar_classic_block'];
    262294        }
    263295
     
    268300        $this->toolbar_3 = ! empty( $this->user_settings['toolbar_3'] ) ? explode( ',', $this->user_settings['toolbar_3'] ) : array();
    269301        $this->toolbar_4 = ! empty( $this->user_settings['toolbar_4'] ) ? explode( ',', $this->user_settings['toolbar_4'] ) : array();
    270 
    271         $this->used_buttons = array_merge( $this->toolbar_1, $this->toolbar_2, $this->toolbar_3, $this->toolbar_4 );
     302        $this->toolbar_classic_block = ! empty( $this->user_settings['toolbar_classic_block'] ) ? explode( ',', $this->user_settings['toolbar_classic_block'] ) : array();
     303
     304        $this->used_buttons = array_merge( $this->toolbar_1, $this->toolbar_2, $this->toolbar_3, $this->toolbar_4, $this->toolbar_classic_block );
    272305        $this->get_all_buttons();
    273306
     
    400433            'backcolor' => 'Background color',
    401434
    402             // Layer plugin ?
    403         //  'insertlayer' => 'Layer',
    404 
    405435            // WP
    406436            'wp_adv'        => 'Toolbar Toggle',
     
    513543        }
    514544
    515         $buttons_1 = $this->toolbar_1;
     545        if ( $editor_id === 'classic-block' ) {
     546            $buttons_1 = $this->toolbar_classic_block;
     547        } else {
     548            $buttons_1 = $this->toolbar_1;
     549        }
    516550
    517551        if ( is_array( $original ) && ! empty( $original ) ) {
     
    523557    }
    524558
    525     public function mce_buttons_2( $original ) {
     559    public function mce_buttons_2( $original, $editor_id ) {
    526560        if ( $this->is_disabled() ) {
    527561            return $original;
     
    532566        }
    533567
    534         $buttons_2 = $this->toolbar_2;
     568        if ( $editor_id === 'classic-block' ) {
     569            $buttons_2 = array();
     570        } else {
     571            $buttons_2 = $this->toolbar_2;
     572        }
    535573
    536574        if ( is_array( $original ) && ! empty( $original ) ) {
     
    542580    }
    543581
    544     public function mce_buttons_3( $original ) {
     582    public function mce_buttons_3( $original, $editor_id ) {
    545583        if ( $this->is_disabled() ) {
    546584            return $original;
     
    551589        }
    552590
    553         $buttons_3 = $this->toolbar_3;
     591        if ( $editor_id === 'classic-block' ) {
     592            $buttons_3 = array();
     593        } else {
     594            $buttons_3 = $this->toolbar_3;
     595        }
    554596
    555597        if ( is_array( $original ) && ! empty( $original ) ) {
     
    561603    }
    562604
    563     public function mce_buttons_4( $original ) {
     605    public function mce_buttons_4( $original, $editor_id ) {
    564606        if ( $this->is_disabled() ) {
    565607            return $original;
     
    570612        }
    571613
    572         $buttons_4 = $this->toolbar_4;
     614        if ( $editor_id === 'classic-block' ) {
     615            $buttons_4 = array();
     616        } else {
     617            $buttons_4 = $this->toolbar_4;
     618        }
    573619
    574620        if ( is_array( $original ) && ! empty( $original ) ) {
     
    580626    }
    581627
    582     public function mce_options( $init ) {
     628    public function mce_options( $init, $editor_id = '' ) {
    583629        if ( $this->is_disabled() ) {
    584630            return $init;
     
    586632
    587633        $init['image_advtab'] = true;
    588         $init['rel_list'] = '[{text: "None", value: ""}, {text: "Nofollow", value: "nofollow"}]';
     634        $init['rel_list'] = '[{text: "None", value: ""}, {text: "Nofollow", value: "nofollow noreferrer"}]';
    589635
    590636        if ( $this->check_admin_setting( 'no_autop' ) ) {
     
    594640        }
    595641
    596         if ( $this->check_user_setting('menubar') ) {
    597             $init['menubar'] = true;
     642        if ( $editor_id === 'classic-block' ) {
     643            if ( $this->check_user_setting('menubar_block') ) {
     644                $init['menubar'] = true;
     645            }
     646
     647            if (
     648                ! $this->check_user_setting( 'no_merge_toolbars' ) &&
     649                ! empty( $init['toolbar1'] ) &&
     650                is_string( $init['toolbar1'] )
     651            ) {
     652                if ( ! empty( $init['toolbar2'] ) && is_string( $init['toolbar2'] ) ) {
     653                    $init['toolbar1'] = $init['toolbar1'] . ',' . $init['toolbar2'];
     654                    $init['toolbar2'] = '';
     655                }
     656                if ( ! empty( $init['toolbar3'] ) && is_string( $init['toolbar3'] ) ) {
     657                    $init['toolbar1'] = $init['toolbar1'] . ',' . $init['toolbar3'];
     658                    $init['toolbar3'] = '';
     659                }
     660                if ( ! empty( $init['toolbar4'] ) && is_string( $init['toolbar4'] ) ) {
     661                    $init['toolbar1'] = $init['toolbar1'] . ',' . $init['toolbar4'];
     662                    $init['toolbar4'] = '';
     663                }
     664            }
     665        } else {
     666            if ( $this->check_user_setting('menubar') ) {
     667                $init['menubar'] = true;
     668            }
    598669        }
    599670
     
    603674
    604675        if ( $this->check_admin_setting( 'importcss' ) ) {
    605     //      $init['importcss_selector_filter'] = 'function(sel){return /^\.[a-z0-9]+$/i.test(sel);}';
    606676            $init['importcss_file_filter'] = 'editor-style.css';
    607677        }
     
    617687        if ( in_array( 'table', $this->plugins, true ) ) {
    618688            $init['table_toolbar'] = false;
     689
     690            // Remove default table styles and attributes. They should be set by the theme.
     691            // Note that if the table cells are resized by dragging, an inline style with the widths will still be added.
     692            $init['table_default_attributes'] = '{}';
     693            $init['table_default_styles'] = '{}';
    619694        }
    620695
     
    622697    }
    623698
    624     public function after_wp_tiny_mce() {
    625         if ( $this->is_disabled() ) {
    626             return;
    627         }
    628 
    629         ?>
    630         <script>
    631         !function(a,b){"undefined"!=typeof a&&"undefined"!=typeof b&&a(function(){b.addButton("sofbg-axcell","&para;",function(b,c){
    632         var d=a(c),e=a.trim(d.val()),f="table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|" +
    633         "address|math|style|p|h[1-6]|hr|fieldset|legend|tmadv|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary";
    634         -1!==e.indexOf("</p>")&&-1===e.indexOf("\n\n")&&(e=e.replace(new RegExp("<(?:"+f+")(?: [^>]*)?>","gi"),"\n$&"),
    635         e=e.replace(new RegExp("</(?:"+f+")>","gi"),"$&\n"),e=e.replace(/(<br(?: [^>]*)?>)[\r\n\t]*/gi,"$1\n"),
    636         e=e.replace(/>\n[\r\n\t]+</g,">\n<"),e=e.replace(/^<li/gm," <li"),e=e.replace(/<td>\u00a0<\/td>/g,"<td>&nbsp;</td>"),
    637         d.val(a.trim(e)))},"","","Fix line breaks")})}(window.jQuery,window.QTags);
    638         </script>
    639         <?php
    640     }
    641 
    642     public function htmledit( $content ) {
    643         return $content;
     699    public function block_editor_assets() {
     700        $plugin_url = plugins_url( 'block-editor', __FILE__ );
     701
     702        if ( ! $this->check_admin_setting( 'no_hybrid_mode' ) ) {
     703            $dependencies = array( 'wp-element', 'wp-components', 'wp-i18n', 'wp-keycodes', 'wp-blocks', 'wp-hooks', 'lodash' );
     704            wp_enqueue_script( 'tadv-block-register', $plugin_url . '/block-register.js', $dependencies );
     705
     706            wp_enqueue_style( 'tadv-classic-paragraph-styles', $plugin_url . '/classic-paragraph.css' );
     707        }
     708
     709        wp_enqueue_style( 'tadv-block-editor-styles', $plugin_url . '/block-editor.css' );
     710    }
     711
     712    public function initial_post_content( $paths, $post ) {
     713        if ( $post->post_status === 'auto-draft' && empty( $post->post_content ) ) {
     714            $post->post_content = '<p><br data-mce-bogus="1"></p>';
     715        }
     716
     717        return $paths;
     718    }
     719
     720    public function block_editor_init() {
     721        if ( $this->check_admin_setting( 'replace_block_editor' ) && ! class_exists( 'Classic_Editor' ) ) {
     722            add_filter( 'use_block_editor_for_post_type', '__return_false', 1000 );
     723        }
     724    }
     725
     726    public function filter_post_content( $data ) {
     727        $content = $data['post_content'];
     728        // Fix for the fix to keep <p> tags inside the classic block :-(
     729        // $data is slashed...
     730        if ( strpos( $content, '<p data-tadv-p=\"keep\">' ) !== false ) {
     731            $content = str_replace( '<p data-tadv-p=\"keep\">', '<p>', $content );
     732        }
     733
     734        if ( ! $this->check_admin_setting( 'no_hybrid_mode' ) && strpos( $content, '<!-- wp:paragraph {\"tadvType\":\"classic\"} -->' ) !== false ) {
     735            $content = preg_replace( '@<!-- wp:paragraph \{\\\"tadvType\\\":\\\"classic\\\"\} -->\s*([\s\S]+?)<!-- \/wp:paragraph -->\s*@', '$1', $content );
     736        }
     737
     738        $data['post_content'] = $content;
     739        return $data;
    644740    }
    645741
     
    761857        }
    762858
    763         for ( $i = 1; $i < 5; $i++ ) {
    764             $toolbar_name = 'toolbar_' . $i;
     859        for ( $i = 1; $i < 6; $i++ ) {
     860            $toolbar_name = ( $i < 5 ) ? 'toolbar_' . $i : 'toolbar_classic_block';
    765861
    766862            if ( ! empty( $user_settings[ $toolbar_name ] ) ) {
     
    772868            }
    773869
    774             if ( $i > 1 && ( $wp_adv = array_search( 'wp_adv', $toolbar ) ) !== false ) {
    775                 unset( $toolbar[ $wp_adv ] );
     870            if ( $i > 1 && in_array( 'wp_adv', $toolbar, true ) ) {
     871                $toolbar = array_diff( $toolbar, array( 'wp_adv' ) );
    776872            }
    777873
     
    782878            $options = explode( ',', $user_settings['options'] );
    783879        } elseif ( ! empty( $_POST['options'] ) && is_array( $_POST['options'] ) ) {
    784             $options = $_POST['options'];
     880            $options_raw = $_POST['options'];
     881            // Negate
     882            if ( in_array( 'no_merge_toolbars', $options_raw, true ) ) {
     883                $options_raw = array_diff( $options_raw, array( 'no_merge_toolbars' ) );
     884            } else {
     885                $options_raw[] = 'no_merge_toolbars';
     886            }
     887
     888            $options = $options_raw;
    785889        } else {
    786890            $options = array();
     
    791895        if ( ! empty( $user_settings['plugins'] ) ) {
    792896            $plugins = explode( ',', $user_settings['plugins'] );
    793         } elseif ( ! empty( $_POST['options']['menubar'] ) ) {
    794             $plugins = array( 'anchor', 'code', 'insertdatetime', 'nonbreaking', 'print', 'searchreplace', 'table', 'visualblocks', 'visualchars' );
    795897        } else {
    796898            $plugins = array();
     899        }
     900
     901        if ( ! empty( $settings['options']['menubar'] ) || ! empty( $settings['options']['menubar_block'] ) ) {
     902            $plugins = array_merge( $plugins, $this->required_menubar_plugins );
    797903        }
    798904
     
    832938        } elseif ( isset( $_POST['tadv-save'] ) ) {
    833939            if ( ! empty( $_POST['admin_options'] ) && is_array( $_POST['admin_options'] ) ) {
    834                 $save_admin_settings['options'] = $this->validate_settings( $_POST['admin_options'], $this->get_all_admin_options() );
     940                $admin_options = $_POST['admin_options'];
     941                // Negate
     942                if ( in_array( 'no_hybrid_mode', $admin_options, true ) ) {
     943                    $admin_options = array_diff( $admin_options, array( 'no_hybrid_mode' ) );
     944                } else {
     945                    $admin_options[] = 'no_hybrid_mode';
     946                }
     947
     948                $save_admin_settings['options'] = $this->validate_settings( $admin_options, $this->get_all_admin_options() );
    835949            }
    836950
Note: See TracChangeset for help on using the changeset viewer.