01.code/LanweiUI/UEditor/_src/plugins/undo.js
(开头部分) 8KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
///import core
///commands 撤销和重做
///commandsName Undo,Redo
///commandsTitle 撤销,重做
/**
* @description 回退
* @author zhanyi
*/
UE.plugins['undo'] = function() {
var me = this,
maxUndoCount = me.options.maxUndoCount || 20,
maxInputCount = me.options.maxInputCount || 20,
fillchar = new RegExp(domUtils.fillChar + '|<\/hr>','gi'),// ie会产生多余的</hr>
//在比较时,需要过滤掉这些属性
specialAttr = /\b(?:href|src|name)="[^"]*?"/gi;
function UndoManager() {
this.list = [];
this.index = 0;
this.hasUndo = false;
this.hasRedo = false;
this.undo = function() {
if ( this.hasUndo ) {
var currentScene = this.getScene(),
lastScene = this.list[this.index];
if ( lastScene.content.replace(specialAttr,'') != currentScene.content.replace(specialAttr,'') ) {
this.save();
}
if(!this.list[this.index - 1] && this.list.length == 1){
this.reset();
return;
}
while ( this.list[this.index].content == this.list[this.index - 1].content ) {
this.index--;
if ( this.index == 0 ) {
return this.restore( 0 )
}
}
this.restore( --this.index );
}
};
this.redo = function() {
if ( this.hasRedo ) {
while ( this.list[this.index].content == this.list[this.index + 1].content ) {
this.index++;
if ( this.index == this.list.length - 1 ) {
return this.restore( this.index )
}
}
this.restore( ++this.index );
}
};
this.restore = function() {
var scene = this.list[this.index];
//trace:873
后面还有 168 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
