@ -83,7 +83,8 @@ function _inString(val, str, delimiter) {
}
function _addUnit ( val , unit ) {
unit = unit || 'px' ;
return val && /^\d+$/ . test ( val ) ? val + unit : val ;
//return val && /^\d+$/.test(val) ? val + unit : val;
return val && /^-?\d+(?:\.\d+)?$/ . test ( val ) ? val + unit : val ;
}
function _removeUnit ( val ) {
var match ;
@ -304,7 +305,7 @@ K.options = {
img : [ 'id' , 'class' , 'src' , 'width' , 'height' , 'border' , 'alt' , 'title' , 'align' , '.width' , '.height' , '.border' ] ,
'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [
'id' , 'class' , 'align' , '.text-align' , '.color' , '.background-color' , '.font-size' , '.font-family' , '.background' ,
'.font-weight' , '.font-style' , '.text-decoration' , '.vertical-align' , '.text-indent' , '.margin-left'
'.font-weight' , '.font-style' , '.text-decoration' , '.vertical-align' , '.text-indent' , '.margin-left' , '.margin' , '.border' , '.padding'
] ,
pre : [ 'id' , 'class' ] ,
hr : [ 'id' , 'class' , '.page-break-after' ] ,
@ -597,7 +598,7 @@ function _ready(fn) {
}
_bind ( window , 'load' , readyFunc ) ;
}
if ( _IE ) {
if ( window . attachEvent ) {
window . attachEvent ( 'onunload' , function ( ) {
_each ( _eventData , function ( key , events ) {
if ( events . el ) {
@ -2531,6 +2532,7 @@ K.START_TO_START = _START_TO_START;
K . START _TO _END = _START _TO _END ;
K . END _TO _END = _END _TO _END ;
K . END _TO _START = _END _TO _START ;
function _nativeCommand ( doc , key , val ) {
try {
doc . execCommand ( key , false , val ) ;
@ -3361,6 +3363,10 @@ function _drag(options) {
} ) ;
}
clickEl . mousedown ( function ( e ) {
//新加的
if ( e . button !== 0 && e . button !== 1 ) {
return ;
}
e . stopPropagation ( ) ;
var self = clickEl . get ( ) ,
x = _removeUnit ( moveEl . css ( 'left' ) ) ,
@ -3681,13 +3687,20 @@ _extend(KEdit, KWidget, {
if ( isDocumentDomain ) {
doc . domain = document . domain ;
}
doc . write ( _getInitHtml ( themesPath , bodyClass , cssPath , cssData ) ) ;
doc . close ( ) ;
self . win = self . iframe [ 0 ] . contentWindow ;
self . doc = doc ;
var cmd = _cmd ( doc ) ;
self . afterChange ( function ( e ) {
cmd . selection ( ) ;
// if (e.which == 8) {
// var range = cmd.range
// var bookmark = range.createBookmark();
// cmd.doc.body.innerHTML = cmd.doc.body.innerHTML.replace(/<p>\s*<\/p>/g,"");
// range.moveToBookmark(bookmark);
// }
cmd . selection ( ) ;
} ) ;
if ( _WEBKIT ) {
K ( doc ) . click ( function ( e ) {
@ -3824,9 +3837,20 @@ _extend(KEdit, KWidget, {
if ( ! self . designMode ) {
val = self . html ( ) ;
self . designMode = true ;
self . html ( val ) ;
//self.html(val);
//self.textarea.hide();
//self.iframe.show();
//新加
self . textarea . hide ( ) ;
self . iframe . show ( ) ;
self . html ( val ) ;
var iframe = self . iframe ;
var height = _removeUnit ( self . height ) ;
iframe . height ( height - 2 ) ;
iframe . show ( ) ;
setTimeout ( function ( ) {
iframe . height ( height ) ;
} , 0 ) ;
}
} else {
if ( self . designMode ) {
@ -3958,7 +3982,7 @@ _extend(KToolbar, KWidget, {
} else if ( ! $ ( "#full" , container ) . is ( ':hidden' ) ) {
pdiv = $ ( "#full" , container ) ;
}
return ( this . _itemMap [ name ] = K ( 'span.ke-icon-' + name , p div) . parent ( ) ) ;
return ( this . _itemMap [ name ] = K ( 'span.ke-icon-' + name , this . div) . parent ( ) ) ;
} ,
select : function ( name ) {
_selectToolbar . call ( this , name , function ( knode ) {
@ -4864,6 +4888,11 @@ KEditor.prototype = {
} ,
loadPlugin : function ( name , fn ) {
var self = this ;
//新加
var _pluginStatus = this . _pluginStatus ;
if ( ! _pluginStatus ) {
_pluginStatus = this . _pluginStatus = { } ;
}
if ( _plugins [ name ] ) {
if ( ! _isFunction ( _plugins [ name ] ) ) {
setTimeout ( function ( ) {
@ -4871,7 +4900,12 @@ KEditor.prototype = {
} , 100 ) ;
return self ;
}
_plugins [ name ] . call ( self , KindEditor ) ;
//_plugins[name].call(self, KindEditor);
//新加
if ( ! _pluginStatus [ name ] ) {
_plugins [ name ] . call ( self , KindEditor ) ;
_pluginStatus [ name ] = 'inited' ;
}
if ( fn ) {
fn . call ( self ) ;
}
@ -5510,6 +5544,11 @@ function _create(expr, options) {
_each ( _plugins , function ( name , fn ) {
if ( _isFunction ( fn ) ) {
fn . call ( editor , KindEditor ) ;
//新加
if ( ! editor . _pluginStatus ) {
editor . _pluginStatus = { } ;
}
editor . _pluginStatus [ name ] = 'inited' ;
}
} ) ;
return editor . create ( ) ;
@ -5772,13 +5811,14 @@ _plugin('core', function(K) {
click : function ( ) {
self . select ( ) . exec ( 'formatblock' , '<' + key + '>' ) . hideMenu ( ) ;
//by yk利用html的特性使h1 h2 h3 h4标签之间不能相互包含 并将空的标签去掉
if ( key != "p" ) {
// if (key != "p"){
var val = self . select ( ) . html ( ) ;
self . select ( ) . html ( val ) ;
self . cmd . doc . body . innerHTML = self . cmd . doc . body . innerHTML . replace ( /<p>\s*<\/p>/g , "" ) ;
val = self . select ( ) . html ( ) . replace ( /(<h1>\s*<\/h1>)|(<h2>\s*<\/h2>)|(<h3>\s*<\/h3>)|(<h4>\s*<\/h4>)/g , "" ) ;
self . select ( ) . html ( val ) ;
self . select ( ) ;
}
// }
}
} ) ;
} ) ;
@ -6059,6 +6099,9 @@ _plugin('core', function(K) {
} else {
cmd . range . selectNodeContents ( div [ 0 ] ) ;
cmd . select ( ) ;
//新加
div [ 0 ] . tabIndex = - 1 ;
div [ 0 ] . focus ( ) ;
}
setTimeout ( function ( ) {
movePastedData ( ) ;