@@ -172,7 +172,6 @@ _e(function (E, $) {
172172 var $valueContainer = editor . $valueContainer ;
173173 var currentValue = '' ;
174174 var nodeName = editor . valueNodeName ;
175-
176175 if ( nodeName === 'div' ) {
177176 currentValue = $valueContainer . html ( ) ;
178177 } else if ( nodeName === 'textarea' ) {
@@ -1781,7 +1780,7 @@ _e(function (E, $) {
17811780 self . hide ( ) ;
17821781 } ) ;
17831782
1784- E . $window . scroll ( function ( ) {
1783+ E . $window . scroll ( function ( e ) {
17851784 self . hide ( ) ;
17861785 } ) ;
17871786
@@ -2608,6 +2607,12 @@ _e(function (E, $) {
26082607 if ( html === undefined ) {
26092608 // 取值,直接触发jquery原生html方法
26102609 result = $ . fn . html . call ( $txt ) ;
2610+
2611+ // 替换 html 中,src和href属性中的 & 字符。
2612+ // 因为 .html() 或者 .innerHTML 会把所有的 & 字符都改成 & 但是 src 和 href 中的要保持 &
2613+ result = result . replace ( / ( h r e f | s r c ) \= \" ( .* ) \" / igm, function ( a , b , c ) {
2614+ return b + '="' + c . replace ( '&' , '&' ) + '"' ;
2615+ } ) ;
26112616 } else {
26122617 // 赋值,需要同时给 textarea 赋值
26132618 result = $ . fn . html . call ( $txt , html ) ;
@@ -5969,9 +5974,15 @@ _e(function (E, $) {
59695974 var lang = $langSelect ? $langSelect . val ( ) : '' ; // 获取高亮语言
59705975 var langClass = '' ;
59715976 var doHightlight = function ( ) {
5972- $ ( 'pre code' ) . each ( function ( i , block ) {
5973- if ( window . hljs ) {
5977+ $txt . find ( 'pre code' ) . each ( function ( i , block ) {
5978+ var $block = $ ( block ) ;
5979+ if ( $block . attr ( 'codemark' ) ) {
5980+ // 有 codemark 标记的代码块,就不再重新格式化了
5981+ return ;
5982+ } else if ( window . hljs ) {
5983+ // 新代码块,格式化之后,立即标记 codemark
59745984 window . hljs . highlightBlock ( block ) ;
5985+ $block . attr ( 'codemark' , '1' ) ;
59755986 }
59765987 } ) ;
59775988 } ;
@@ -7397,10 +7408,10 @@ _e(function (E, $) {
73977408 e . preventDefault ( ) ;
73987409 e . stopPropagation ( ) ;
73997410
7400- } ) . on ( 'click keypress scroll' , function ( e ) {
7411+ } ) . on ( 'click keydown scroll' , function ( e ) {
74017412 setTimeout ( hide , 100 ) ;
74027413 } ) ;
7403- E . $body . on ( 'click keypress scroll' , function ( e ) {
7414+ E . $body . on ( 'click keydown scroll' , function ( e ) {
74047415 setTimeout ( hide , 100 ) ;
74057416 } ) ;
74067417 } ) ;
@@ -7932,7 +7943,7 @@ _e(function (E, $) {
79327943 e . preventDefault ( ) ;
79337944 e . stopPropagation ( ) ;
79347945
7935- } ) . on ( 'click keypress scroll' , function ( e ) {
7946+ } ) . on ( 'click keydown scroll' , function ( e ) {
79367947 if ( ! isOnDrag ) {
79377948 setTimeout ( hide , 100 ) ;
79387949 }
@@ -8048,7 +8059,7 @@ _e(function (E, $) {
80488059 clearTimeout ( hideTimeoutId ) ;
80498060 }
80508061 hideTimeoutId = setTimeout ( hide , 500 ) ;
8051- } ) . on ( 'click keypress scroll' , function ( e ) {
8062+ } ) . on ( 'click keydown scroll' , function ( e ) {
80528063 setTimeout ( hide , 100 ) ;
80538064 } ) ;
80548065 // $toolbar 绑定事件
0 commit comments