UNPKG

handsontable

Version:

Handsontable is a JavaScript Data Grid available for React, Angular and Vue.

59 lines (56 loc) 2.18 kB
"use strict"; exports.__esModule = true; require("core-js/modules/es.error.cause.js"); var _base = require("./_base"); function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /** * Action that tracks changes in merged cells. * * @class UnmergeCellsAction * @private */ class UnmergeCellsAction extends _base.BaseAction { constructor(_ref) { let { cellRange } = _ref; super('unmerge_cells'); /** * @param {CellRange} cellRange The merged cell range. */ _defineProperty(this, "cellRange", void 0); this.cellRange = cellRange; } static startRegisteringEvents(hot, undoRedoPlugin) { hot.addHook('afterUnmergeCells', (cellRange, auto) => { if (auto) { return; } undoRedoPlugin.done(() => new UnmergeCellsAction({ cellRange })); }); } /** * @param {Core} hot The Handsontable instance. * @param {function(): void} undoneCallback The callback to be called after the action is undone. */ undo(hot, undoneCallback) { const mergeCellsPlugin = hot.getPlugin('mergeCells'); hot.addHookOnce('afterViewRender', undoneCallback); mergeCellsPlugin.mergeRange(this.cellRange, true); } /** * @param {Core} hot The Handsontable instance. * @param {function(): void} redoneCallback The callback to be called after the action is redone. */ redo(hot, redoneCallback) { const mergeCellsPlugin = hot.getPlugin('mergeCells'); hot.addHookOnce('afterViewRender', redoneCallback); mergeCellsPlugin.unmergeRange(this.cellRange, true); hot.render(); } } exports.UnmergeCellsAction = UnmergeCellsAction;