UNPKG

@alilc/lowcode-shell

Version:

Shell Layer for AliLowCodeEngine

78 lines (70 loc) 1.75 kB
import _createClass from "@babel/runtime/helpers/createClass"; import { historySymbol, documentSymbol } from '../symbols'; export var History = /*#__PURE__*/function () { function History(document) { this[documentSymbol] = void 0; this[documentSymbol] = document; } /** * 历史记录跳转到指定位置 * @param cursor */ var _proto = History.prototype; _proto.go = function go(cursor) { this[historySymbol].go(cursor); } /** * 历史记录后退 */; _proto.back = function back() { this[historySymbol].back(); } /** * 历史记录前进 */; _proto.forward = function forward() { this[historySymbol].forward(); } /** * 保存当前状态 */; _proto.savePoint = function savePoint() { this[historySymbol].savePoint(); } /** * 当前是否是「保存点」,即是否有状态变更但未保存 * @returns */; _proto.isSavePoint = function isSavePoint() { return this[historySymbol].isSavePoint(); } /** * 获取 state,判断当前是否为「可回退」、「可前进」的状态 * @returns */; _proto.getState = function getState() { return this[historySymbol].getState(); } /** * 监听 state 变更事件 * @param func * @returns */; _proto.onChangeState = function onChangeState(func) { return this[historySymbol].onChangeState(func); } /** * 监听历史记录游标位置变更事件 * @param func * @returns */; _proto.onChangeCursor = function onChangeCursor(func) { return this[historySymbol].onChangeCursor(func); }; return _createClass(History, [{ key: historySymbol, get: function get() { return this[documentSymbol].getHistory(); } }]); }();