PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
← All changes | admin/js/jspreadsheet.js +42 -2 3.3.1 → 3.4 View file →
@@ -6,9 +6,12 @@
6 6 *
7 7 * This software is distributed under MIT License
8 8 */
9 9
10 -// TablePress: var formula = ... removed.
10 +/* TablePress:
11 + * - var formula = ... removed.
12 + * - obj.updateTablePressToolbarUndoRedoState(); added
13 + */
11 14
12 15 ;(function (global, factory) {
13 16 // TablePress: Comment out next to lines to force creation of a global jspreadsheet object.
14 17 // typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -5347,9 +5350,9 @@
5347 5350 obj.formula[tokens[i]].push(parentId);
5348 5351 }
5349 5352
5350 5353 // Do not calculate again
5351 - if (eval('typeof(' + tokens[i] + ') == "undefined"')) {
5354 + if (typeof globalThis[tokens[i]] === 'undefined') {
5352 5355 // Coords
5353 5356 var position = jexcel.getIdFromColumnName(tokens[i], 1);
5354 5357 // Get value
5355 5358 if (typeof(obj.options.data[position[1]]) != 'undefined' && typeof(obj.options.data[position[1]][position[0]]) != 'undefined') {
@@ -6264,8 +6267,36 @@
6264 6267 }
6265 6268 }
6266 6269
6267 6270 /**
6271 + * TablePress: Initialize the toolbar state for undo/redo buttons.
6272 + */
6273 + obj.tablePressToolbarUndoRedoState = {
6274 + undoDisabled: true,
6275 + redoDisabled: true,
6276 + };
6277 +
6278 + /**
6279 + * TablePress: Updates the toolbar state for undo/redo buttons, if the state has changed.
6280 + *
6281 + * @return null
6282 + */
6283 + obj.updateTablePressToolbarUndoRedoState = function() {
6284 + const newToolbarUndoRedoState = {
6285 + undoDisabled: ( -1 === obj.historyIndex ),
6286 + redoDisabled: ( obj.historyIndex === obj.history.length - 1 ),
6287 + };
6288 +
6289 + if (
6290 + newToolbarUndoRedoState.undoDisabled !== obj.tablePressToolbarUndoRedoState.undoDisabled
6291 + || newToolbarUndoRedoState.redoDisabled !== obj.tablePressToolbarUndoRedoState.redoDisabled
6292 + ) {
6293 + obj.tablePressToolbarUndoRedoState = newToolbarUndoRedoState;
6294 + wp?.hooks?.doAction?.( 'tablepress.toolbarUndoRedoStateUpdate', newToolbarUndoRedoState );
6295 + }
6296 + };
6297 +
6298 + /**
6268 6299 * Initializes a new history record for undo/redo
6269 6300 *
6270 6301 * @return null
6271 6302 */
@@ -6278,8 +6309,11 @@
6278 6309 obj.history = (obj.history = obj.history.slice(0, index + 1));
6279 6310
6280 6311 // Keep history
6281 6312 obj.history[index] = changes;
6313 +
6314 + // TablePress: Update the toolbar state for undo/redo buttons.
6315 + obj.updateTablePressToolbarUndoRedoState();
6282 6316 }
6283 6317 }
6284 6318
6285 6319 /**
@@ -6868,8 +6902,11 @@
6868 6902 obj.ignoreHistory = ignoreHistory;
6869 6903
6870 6904 // Events
6871 6905 obj.dispatch('onundo', el, historyRecord);
6906 +
6907 + // TablePress: Update the toolbar state for undo/redo buttons.
6908 + obj.updateTablePressToolbarUndoRedoState();
6872 6909 }
6873 6910
6874 6911 /**
6875 6912 * Redo previously undone action
@@ -6935,8 +6972,11 @@
6935 6972 obj.ignoreHistory = ignoreHistory;
6936 6973
6937 6974 // Events
6938 6975 obj.dispatch('onredo', el, historyRecord);
6976 +
6977 + // TablePress: Update the toolbar state for undo/redo buttons.
6978 + obj.updateTablePressToolbarUndoRedoState();
6939 6979 }
6940 6980
6941 6981 /**
6942 6982 * Get dropdown value from key