@@ -237,55 +237,65 @@ export class RootInteraction {
237237 hideColumns ( this . spreadsheet , hiddenColumnFields , true ) ;
238238 }
239239
240- /**
241- * 注册交互(组件按自己的场景写交互,继承此方法注册)
242- * @param options
243- */
240+ private getDefaultInteractions ( ) {
241+ const { resize, brushSelection } = this . spreadsheet . options . interaction ;
242+ return [
243+ {
244+ key : InteractionName . DATA_CELL_CLICK ,
245+ interaction : DataCellClick ,
246+ } ,
247+ {
248+ key : InteractionName . ROW_COLUMN_CLICK ,
249+ interaction : RowColumnClick ,
250+ } ,
251+ {
252+ key : InteractionName . ROW_TEXT_CLICK ,
253+ interaction : RowTextClick ,
254+ } ,
255+ {
256+ key : InteractionName . MERGED_CELLS_CLICK ,
257+ interaction : MergedCellClick ,
258+ } ,
259+ {
260+ key : InteractionName . HOVER ,
261+ interaction : HoverEvent ,
262+ enable : ! isMobile ( ) ,
263+ } ,
264+ {
265+ key : InteractionName . BRUSH_SELECTION ,
266+ interaction : BrushSelection ,
267+ enable : ! isMobile ( ) && brushSelection ,
268+ } ,
269+ {
270+ key : InteractionName . COL_ROW_RESIZE ,
271+ interaction : RowColumnResize ,
272+ enable : ! isMobile ( ) && resize ,
273+ } ,
274+ {
275+ key : InteractionName . DATA_CELL_MULTI_SELECTION ,
276+ interaction : DataCellMultiSelection ,
277+ enable : ! isMobile ( ) ,
278+ } ,
279+ {
280+ key : InteractionName . COL_ROW_SHIFT_MULTI_SELECTION ,
281+ interaction : ShiftMultiSelection ,
282+ enable : ! isMobile ( ) ,
283+ } ,
284+ ] ;
285+ }
286+
244287 private registerInteractions ( ) {
245- this . interactions . clear ( ) ;
288+ const { customInteractions } = this . spreadsheet . options . interaction ;
246289
247- this . interactions . set (
248- InteractionName . DATA_CELL_CLICK ,
249- new DataCellClick ( this . spreadsheet ) ,
250- ) ;
251- this . interactions . set (
252- InteractionName . ROW_COLUMN_CLICK ,
253- new RowColumnClick ( this . spreadsheet ) ,
254- ) ;
255- this . interactions . set (
256- InteractionName . ROW_TEXT_CLICK ,
257- new RowTextClick ( this . spreadsheet ) ,
258- ) ;
259- this . interactions . set (
260- InteractionName . MERGED_CELLS_CLICK ,
261- new MergedCellClick ( this . spreadsheet ) ,
262- ) ;
263- this . interactions . set (
264- InteractionName . HOVER ,
265- new HoverEvent ( this . spreadsheet ) ,
266- ) ;
290+ this . interactions . clear ( ) ;
267291
268- if ( ! isMobile ( ) ) {
269- this . interactions . set (
270- InteractionName . BRUSH_SELECTION ,
271- new BrushSelection ( this . spreadsheet ) ,
272- ) ;
273- this . interactions . set (
274- InteractionName . COL_ROW_RESIZE ,
275- new RowColumnResize ( this . spreadsheet ) ,
276- ) ;
277- this . interactions . set (
278- InteractionName . DATA_CELL_MULTI_SELECTION ,
279- new DataCellMultiSelection ( this . spreadsheet ) ,
280- ) ;
281- this . interactions . set (
282- InteractionName . COL_ROW_SHIFT_MULTI_SELECTION ,
283- new ShiftMultiSelection ( this . spreadsheet ) ,
284- ) ;
285- }
292+ const defaultInteractions = this . getDefaultInteractions ( ) ;
293+ defaultInteractions . forEach ( ( { key, interaction : Interaction , enable } ) => {
294+ if ( enable !== false ) {
295+ this . interactions . set ( key , new Interaction ( this . spreadsheet ) ) ;
296+ }
297+ } ) ;
286298
287- const customInteractions =
288- this . spreadsheet . options ?. interaction . customInteractions ;
289299 if ( ! isEmpty ( customInteractions ) ) {
290300 forEach ( customInteractions , ( customInteraction : CustomInteraction ) => {
291301 const CustomInteractionClass = customInteraction . interaction ;
0 commit comments