File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -617,6 +617,52 @@ export class Control {
617617 }
618618 }
619619
620+ public selectValue ( ) : boolean {
621+ const elementList = this . getElementList ( )
622+ const { startIndex } = this . getRange ( )
623+ const startElement = elementList [ startIndex ]
624+ if (
625+ ! startElement ?. controlId ||
626+ ( startElement . controlComponent !== ControlComponent . VALUE &&
627+ elementList [ startIndex + 1 ] ?. controlComponent ===
628+ ControlComponent . VALUE )
629+ ) {
630+ return false
631+ }
632+ // 向左查找
633+ let preIndex = startIndex
634+ while ( preIndex > 0 ) {
635+ const preElement = elementList [ preIndex ]
636+ if ( preElement . controlComponent !== ControlComponent . VALUE ) break
637+ preIndex --
638+ }
639+ // 向右查找
640+ let nextIndex = startIndex + 1
641+ while ( nextIndex < elementList . length ) {
642+ const nextElement = elementList [ nextIndex ]
643+ if ( nextElement . controlComponent !== ControlComponent . VALUE ) {
644+ nextIndex --
645+ break
646+ }
647+ nextIndex ++
648+ }
649+ if ( preIndex !== nextIndex ) {
650+ const range = this . range . getRange ( )
651+ this . range . replaceRange ( {
652+ ...range ,
653+ startIndex : preIndex ,
654+ endIndex : nextIndex
655+ } )
656+ this . draw . render ( {
657+ isCompute : false ,
658+ isSetCursor : false ,
659+ isSubmitHistory : false
660+ } )
661+ return true
662+ }
663+ return false
664+ }
665+
620666 public moveCursor ( position : IControlInitOption ) : IMoveCursorResult {
621667 const { index, trIndex, tdIndex, tdValueIndex } = position
622668 let elementList = this . draw . getOriginalElementList ( )
Original file line number Diff line number Diff line change @@ -152,6 +152,10 @@ function dblclick(host: CanvasEvent, evt: MouseEvent) {
152152
153153function threeClick ( host : CanvasEvent ) {
154154 const draw = host . getDraw ( )
155+ // 优先选择控件内容
156+ const control = draw . getControl ( )
157+ if ( control . getActiveControl ( ) && control . selectValue ( ) ) return
158+ // 选择整个段落
155159 const position = draw . getPosition ( )
156160 const cursorPosition = position . getCursorPosition ( )
157161 if ( ! cursorPosition ) return
You can’t perform that action at this time.
0 commit comments