code: function (level, event) {
            var i, settings = editor.settings, lastLevel, currentLevel;
  
            currentLevel = Levels.createFromEditor(editor);
            level = level || {};
            level = Tools.extend(level, currentLevel);
  
            if (isUnlocked() === false || editor.removed) {
              return null;
            }
  
            lastLevel = data[index];
            if (editor.fire('BeforeAddUndo', { level: level, lastLevel: lastLevel, originalEvent: event }).isDefaultPrevented()) {
              return null;
            }
  
            // Add undo level if needed
            if (lastLevel && Levels.isEq(lastLevel, level)) {
              return null;
            }
  
            // Set before bookmark on previous level
            if (data[index]) {
              data[index].beforeBookmark = beforeBookmark;
            }
  
            // Time to compress
            if (settings.custom_undo_redo_levels) {
              if (data.length > settings.custom_undo_redo_levels) {
                for (i = 0; i < data.length - 1; i++) {
                  data[i] = data[i + 1];
                }
  
                data.length--;
                index = data.length;
              }
            }
  
            // Get a non intrusive normalized bookmark
            level.bookmark = editor.selection.getBookmark(2, true);
  
            // Crop array if needed
            if (index < data.length - 1) {
              data.length = index + 1;
            }
  
            data.push(level);
            index = data.length - 1;
  
            var args = { level: level, lastLevel: lastLevel, originalEvent: event };
  
            editor.fire('AddUndo', args);
  
            if (index > 0) {
              setDirty(true);
              editor.fire('change', args);
            }
  
            return level;
          }
docs: Adds a new undo level/snapshot to the undo list.
  
  @method add
  @param {Object} level Optional undo level object to add.
  @param {DOMEvent} event Optional event responsible for the creation of the undo level.
  @return {Object} Undo level that got added or null it a level wasn't needed.