Make WordPress Core

Ticket #27389: 27389-wpviews-undo-revamp-02.patch

File 27389-wpviews-undo-revamp-02.patch, 4.9 KB (added by gcorne, 10 years ago)
  • src/wp-includes/js/mce-view.js

    diff --git src/wp-includes/js/mce-view.js src/wp-includes/js/mce-view.js
    index d3af61e..27135cf 100644
    window.wp = window.wp || {}; 
    4141                                        doc = editor.getDoc();
    4242                                        $( doc ).find( '[data-wpview-text="' + this.encodedText + '"]' ).each(function (i, elem) {
    4343                                                var node = $( elem );
    44                                                 node.html( html );
     44                                                node.html( html ).append( '<span data-wp-view-end class="wp-view-end"></span>' );
    4545                                                $( self ).trigger( 'ready', elem );
    4646                                        });
    4747                                }
  • src/wp-includes/js/tinymce/plugins/wpview/plugin.js

    diff --git src/wp-includes/js/tinymce/plugins/wpview/plugin.js src/wp-includes/js/tinymce/plugins/wpview/plugin.js
    index 75f7047..d7602d4 100644
    tinymce.PluginManager.add( 'wpview', function( editor ) { 
    141141        }
    142142
    143143        editor.on( 'BeforeAddUndo', function( event ) {
    144                 if ( selected && ! toRemove ) {
    145                         event.preventDefault();
     144                var replace,
     145                        previousContent,
     146                        content;
     147
     148                replace = function( content ) {
     149                        return content.replace(/(<div[^>]+wpview-wrap[^>]+>)([\s\S]+)(<span[^>]+data-wp-view-end[^>]+><\/span><\/div>)/mg, '$`$1$3$\'' );
     150                };
     151
     152                if ( event.lastLevel ) {
     153                        previousContent = replace( event.lastLevel.content );
     154                        content = replace( event.level.content );
     155
     156                        if ( content === previousContent ) {
     157                                event.preventDefault();
     158                        }
    146159                }
    147160        });
    148161
    tinymce.PluginManager.add( 'wpview', function( editor ) { 
    162175        editor.on( 'SetContent', function( event ) {
    163176                var body, padNode;
    164177
    165                 // don't (re-)render views if the format of the content is raw
    166                 // to avoid adding additional undo levels on undo/redo
    167                 if ( event.format !== 'raw' ) {
    168                         wp.mce.views.render();
    169                 }
     178                wp.mce.views.render();
    170179
    171180                // Add padding <p> if the noneditable node is last
    172181                if ( event.load || ! event.set ) {
  • src/wp-includes/js/tinymce/tinymce.js

    diff --git src/wp-includes/js/tinymce/tinymce.js src/wp-includes/js/tinymce/tinymce.js
    index 1c291c9..5f7bb10 100644
    define("tinymce/UndoManager", [ 
    1716517165                                        return null;
    1716617166                                }
    1716717167
    17168                                 if (editor.fire('BeforeAddUndo', {level: level, originalEvent: event}).isDefaultPrevented()) {
     17168                                lastLevel = data[index];
     17169                                if (editor.fire('BeforeAddUndo', {level: level, lastLevel: lastLevel, originalEvent: event}).isDefaultPrevented()) {
    1716917170                                        return null;
    1717017171                                }
    1717117172
    1717217173                                // Add undo level if needed
    17173                                 lastLevel = data[index];
    1717417174                                if (lastLevel && lastLevel.content == level.content) {
    1717517175                                        return null;
    1717617176                                }
    define("tinymce/ui/Throbber", [ 
    3497734977});
    3497834978
    3497934979expose(["tinymce/dom/EventUtils","tinymce/dom/Sizzle","tinymce/dom/DomQuery","tinymce/html/Styles","tinymce/dom/TreeWalker","tinymce/util/Tools","tinymce/dom/Range","tinymce/html/Entities","tinymce/Env","tinymce/dom/StyleSheetLoader","tinymce/dom/DOMUtils","tinymce/dom/ScriptLoader","tinymce/AddOnManager","tinymce/html/Node","tinymce/html/Schema","tinymce/html/SaxParser","tinymce/html/DomParser","tinymce/html/Writer","tinymce/html/Serializer","tinymce/dom/Serializer","tinymce/dom/TridentSelection","tinymce/util/VK","tinymce/dom/ControlSelection","tinymce/dom/RangeUtils","tinymce/dom/Selection","tinymce/fmt/Preview","tinymce/Formatter","tinymce/UndoManager","tinymce/EnterKey","tinymce/ForceBlocks","tinymce/EditorCommands","tinymce/util/URI","tinymce/util/Class","tinymce/ui/Selector","tinymce/ui/Collection","tinymce/ui/DomUtils","tinymce/ui/Control","tinymce/ui/Factory","tinymce/ui/KeyboardNavigation","tinymce/ui/Container","tinymce/ui/DragHelper","tinymce/ui/Scrollable","tinymce/ui/Panel","tinymce/ui/Movable","tinymce/ui/Resizable","tinymce/ui/FloatPanel","tinymce/ui/Window","tinymce/ui/MessageBox","tinymce/WindowManager","tinymce/util/Quirks","tinymce/util/Observable","tinymce/Shortcuts","tinymce/Editor","tinymce/util/I18n","tinymce/FocusManager","tinymce/EditorManager","tinymce/LegacyInput","tinymce/util/XHR","tinymce/util/JSON","tinymce/util/JSONRequest","tinymce/util/JSONP","tinymce/util/LocalStorage","tinymce/Compat","tinymce/ui/Layout","tinymce/ui/AbsoluteLayout","tinymce/ui/Tooltip","tinymce/ui/Widget","tinymce/ui/Button","tinymce/ui/ButtonGroup","tinymce/ui/Checkbox","tinymce/ui/PanelButton","tinymce/ui/ColorButton","tinymce/ui/ComboBox","tinymce/ui/Path","tinymce/ui/ElementPath","tinymce/ui/FormItem","tinymce/ui/Form","tinymce/ui/FieldSet","tinymce/ui/FilePicker","tinymce/ui/FitLayout","tinymce/ui/FlexLayout","tinymce/ui/FlowLayout","tinymce/ui/FormatControls","tinymce/ui/GridLayout","tinymce/ui/Iframe","tinymce/ui/Label","tinymce/ui/Toolbar","tinymce/ui/MenuBar","tinymce/ui/MenuButton","tinymce/ui/ListBox","tinymce/ui/MenuItem","tinymce/ui/Menu","tinymce/ui/Radio","tinymce/ui/ResizeHandle","tinymce/ui/Spacer","tinymce/ui/SplitButton","tinymce/ui/StackLayout","tinymce/ui/TabPanel","tinymce/ui/TextBox","tinymce/ui/Throbber"]);
    34980 })(this);
    34981  No newline at end of file
     34980})(this);