背景: 用户需要实现同步协同,undo操作时无法同步,该示例实现同步并可撤销
核心代码:
- var spreadNS = GC.Spread.Sheets;
- var undoManager = spread.undoManager();
- var undoManager1 = spread1.undoManager();
- var commandManager = spread.commandManager();
- var commandManager1 = spread1.commandManager();
- var oldExecute = commandManager.execute;
- commandManager.execute = function () {
- commandManager1.execute.apply(commandManager1, arguments);
- return oldExecute.apply(this, arguments);
- };
- var oldUndo = undoManager.undo;
- undoManager.undo = function () {
- undoManager1.undo.apply(undoManager1, arguments);
- return oldUndo.apply(this, arguments);
- };
- var oldRedo = undoManager.redo;
- undoManager.redo = function () {
- undoManager1.redo.apply(undoManager1, arguments);
- return oldRedo.apply(this, arguments);
- };
复制代码
|
|