![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/libs/absol-full/dist/js/ |
Upload File : |
/*** module: node_modules/absol-acomp/js/tokenizeiput/TIHistory.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; /*** * @param {TokenizeInput} elt * @constructor */ function TIHistory(elt) { this.elt = elt; this.stack = []; this.topIdx = -1; } TIHistory.prototype.commit = function (text, offset) { while (this.topIdx < this.stack.length - 1) { this.stack.pop(); } var lastText = this.stack.length > 0 ? this.stack[this.stack.length - 1].text : null; if (text === lastText) { if (this.stack[this.stack.length - 1].offset !== offset) this.stack[this.stack.length - 1].offset = offset; } else { this.topIdx = this.stack.length; var record = { text: text, offset: offset }; this.stack.push(record); this.elt.emit('change', { target: this, value: record.text, action: 'commit', record: record, type: 'change' }, this); } }; TIHistory.prototype.undo = function () { if (this.topIdx <= 0) return; this.topIdx--; var record = this.stack[this.topIdx]; this.elt.applyData(record.text, record.offset); this.elt.emit('change', { target: this, value: record.text, action: 'undo', record: record, type: 'change' }, this); }; TIHistory.prototype.redo = function () { if (this.topIdx + 1 >= this.stack.length) return; this.topIdx++; var record = this.stack[this.topIdx]; this.elt.applyData(record.text, record.offset); this.elt.emit('change', { target: this, value: record.text, action: 'redo', record: record, type: 'change' }, this); }; var _default = TIHistory; exports.default = _default;