webeditor是这样的,不然不是所有的都能撤消

解决方案 »

  1.   

    webeditor片段// 修正Undo/Redo
    var history = new Object;
    history.data = [];
    history.position = 0;
    history.book = [];// 保存历史
    function saveHistory() {
    if (bEditMode){
    if (history.data[history.position] != eWebEditor.document.body.innerHTML){
    var nBeginLen = history.data.length;
    var nPopLen = history.data.length - history.position;
    for (var i=1; i<nPopLen; i++){
    history.data.pop();
    history.book.pop();
    } history.data[history.data.length] = eWebEditor.document.body.innerHTML; if (eWebEditor.document.selection.type != "Control"){
    history.book[history.book.length] = eWebEditor.document.selection.createRange().getBook();
    } else {
    var oControl = eWebEditor.document.selection.createRange();
    history.book[history.book.length] = oControl[0];
    } if (nBeginLen!=0){
    history.position++;
    }
    }
    }
    }// 初始历史
    function initHistory() {
    history.data.length = 0;
    history.book.length = 0;
    history.position = 0;
    }// 返回历史
    function goHistory(value) {
    saveHistory();
    // undo
    if (value == -1){
    if (history.position > 0){
    eWebEditor.document.body.innerHTML = history.data[--history.position];
    setHistoryCursor();
    }
    // redo
    } else {
    if (history.position < history.data.length -1){
    eWebEditor.document.body.innerHTML = history.data[++history.position];
    setHistoryCursor();
    }
    }
    }
      

  2.   

    当时是想用office控件,但有些特殊的功能没有办法去实现所有放弃了,现在用js实现了特殊的功能了,但撤销的问题出现了,现在可以一步撤销到我选定区域的初始状态,而不成撤销的上一步修改的状态,大家帮帮忙,想个办法,我现在想的是把每一步修改的文件装入一堆栈,撤销时弹出.