@@ -4005,7 +4005,11 @@ _e(function (E, $) {
40054005 value = value . replace ( / < s c r i p t [ \s \S ] * ?< \/ s c r i p t > / ig, '' ) ;
40064006 }
40074007 // 赋值
4008- $txt . html ( value ) ;
4008+ try {
4009+ $txt . html ( value ) ;
4010+ } catch ( ex ) {
4011+ // 更新 html 源码出错,一般都是取消了 js 过滤之后,js报错导致的
4012+ }
40094013 }
40104014
40114015 // 定义click事件
@@ -4028,6 +4032,11 @@ _e(function (E, $) {
40284032 // 赋值
40294033 $code . val ( $txt . html ( ) ) ;
40304034
4035+ // 监控变化
4036+ $code . on ( 'change' , function ( e ) {
4037+ updateValue ( ) ;
4038+ } ) ;
4039+
40314040 // 渲染
40324041 $txt . after ( $code ) . hide ( ) ;
40334042 $code . show ( ) ;
@@ -7379,6 +7388,7 @@ _e(function (E, $) {
73797388 var editor = this ;
73807389 var txt = editor . txt ;
73817390 var $txt = txt . $txt ;
7391+ var html = '' ;
73827392 // 说明:设置了 max-height 之后,$txt.parent() 负责滚动处理
73837393 var $currentTxt = editor . useMaxHeight ? $txt . parent ( ) : $txt ;
73847394 var $currentTable ;
@@ -7414,8 +7424,20 @@ _e(function (E, $) {
74147424 // 统一执行命令的方法
74157425 var commandFn ;
74167426 function command ( e , callback ) {
7427+ // 执行命令之前,先存储html内容
7428+ html = $txt . html ( ) ;
7429+ // 监控内容变化
7430+ var cb = function ( ) {
7431+ if ( callback ) {
7432+ callback ( ) ;
7433+ }
7434+ if ( html !== $txt . html ( ) ) {
7435+ $txt . change ( ) ;
7436+ }
7437+ } ;
7438+ // 执行命令
74177439 if ( commandFn ) {
7418- editor . customCommand ( e , commandFn , callback ) ;
7440+ editor . customCommand ( e , commandFn , cb ) ;
74197441 }
74207442 }
74217443
@@ -7558,6 +7580,7 @@ _e(function (E, $) {
75587580 var lang = editor . config . lang ;
75597581 var txt = editor . txt ;
75607582 var $txt = txt . $txt ;
7583+ var html = '' ;
75617584 // 说明:设置了 max-height 之后,$txt.parent() 负责滚动处理
75627585 var $currentTxt = editor . useMaxHeight ? $txt . parent ( ) : $txt ;
75637586 var $editorContainer = editor . $editorContainer ;
@@ -7603,6 +7626,9 @@ _e(function (E, $) {
76037626 if ( url != null ) {
76047627 currentLink = url ;
76057628 }
7629+ if ( html !== $txt . html ( ) ) {
7630+ $txt . change ( ) ;
7631+ }
76067632 } ;
76077633 var $link ;
76087634 var inLink = false ;
@@ -7643,6 +7669,9 @@ _e(function (E, $) {
76437669
76447670 // 执行命令
76457671 if ( commandFn ) {
7672+ // 记录下执行命令之前的html内容
7673+ html = $txt . html ( ) ;
7674+ // 执行命令
76467675 editor . customCommand ( e , commandFn , callback ) ;
76477676 }
76487677 }
@@ -7689,8 +7718,20 @@ _e(function (E, $) {
76897718 // 统一执行命令的方法
76907719 var commandFn ;
76917720 function customCommand ( e , callback ) {
7721+ var cb ;
7722+ // 记录下执行命令之前的html内容
7723+ html = $txt . html ( ) ;
7724+ cb = function ( ) {
7725+ if ( callback ) {
7726+ callback ( ) ;
7727+ }
7728+ if ( html !== $txt . html ( ) ) {
7729+ $txt . change ( ) ;
7730+ }
7731+ } ;
7732+ // 执行命令
76927733 if ( commandFn ) {
7693- editor . customCommand ( e , commandFn , callback ) ;
7734+ editor . customCommand ( e , commandFn , cb ) ;
76947735 }
76957736 }
76967737
0 commit comments