@@ -73,6 +73,7 @@ export class Control {
7373 private options : DeepRequired < IEditorOption >
7474 private controlOptions : IControlOption
7575 private activeControl : IControlInstance | null
76+ private activeControlValue : IElement [ ]
7677
7778 constructor ( draw : Draw ) {
7879 this . controlBorder = new ControlBorder ( draw )
@@ -86,6 +87,7 @@ export class Control {
8687 this . options = draw . getOptions ( )
8788 this . controlOptions = this . options . control
8889 this . activeControl = null
90+ this . activeControlValue = [ ]
8991 }
9092
9193 // 搜索高亮匹配
@@ -271,6 +273,12 @@ export class Control {
271273 return this . activeControl
272274 }
273275
276+ public updateActiveControlValue ( ) {
277+ if ( this . activeControl ) {
278+ this . activeControlValue = this . activeControl . getValue ( )
279+ }
280+ }
281+
274282 public initControl ( ) {
275283 const elementList = this . getElementList ( )
276284 const range = this . getRange ( )
@@ -289,7 +297,11 @@ export class Control {
289297 }
290298 }
291299 const controlElement = this . activeControl . getElement ( )
292- if ( element . controlId === controlElement . controlId ) return
300+ if ( element . controlId === controlElement . controlId ) {
301+ // 更新缓存控件数据
302+ this . updateActiveControlValue ( )
303+ return
304+ }
293305 }
294306 // 销毁旧激活控件
295307 this . destroyControl ( )
@@ -312,15 +324,18 @@ export class Control {
312324 this . activeControl = dateControl
313325 dateControl . awake ( )
314326 }
327+ // 缓存控件数据
328+ this . updateActiveControlValue ( )
315329 // 激活控件回调
316330 const isSubscribeControlChange = this . eventBus . isSubscribe ( 'controlChange' )
317331 if ( this . listener . controlChange || isSubscribeControlChange ) {
318332 let control : IControl
319- const value = this . activeControl ?. getValue ( )
333+ const value = this . activeControlValue
320334 if ( value ?. length ) {
321335 control = zipElementList ( value ) [ 0 ] . control !
322336 } else {
323337 control = pickElementAttr ( deepClone ( element ) ) . control !
338+ control . value = [ ]
324339 }
325340 const payload : IControlChangeResult = {
326341 control,
@@ -349,15 +364,13 @@ export class Control {
349364 this . eventBus . isSubscribe ( 'controlChange' )
350365 if ( this . listener . controlChange || isSubscribeControlChange ) {
351366 let control : IControl
352- const value = this . activeControl . getValue ( {
353- range : this . activeControl . activeRange ,
354- elementList : this . activeControl . activeElementList
355- } )
367+ const value = this . activeControlValue
356368 const activeElement = this . activeControl . getElement ( )
357369 if ( value ?. length ) {
358370 control = zipElementList ( value ) [ 0 ] . control !
359371 } else {
360372 control = pickElementAttr ( deepClone ( activeElement ) ) . control !
373+ control . value = [ ]
361374 }
362375 const payload : IControlChangeResult = {
363376 control,
@@ -372,6 +385,7 @@ export class Control {
372385 }
373386 // 清空变量
374387 this . activeControl = null
388+ this . activeControlValue = [ ]
375389 }
376390
377391 public repaintControl ( options : IRepaintControlOption = { } ) {
0 commit comments