File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change 1- import { DraftHandleValue , EditorState , RichUtils } from "draft-js" ;
1+ import {
2+ DraftEditorCommand ,
3+ DraftHandleValue ,
4+ EditorState ,
5+ getDefaultKeyBinding ,
6+ RichUtils ,
7+ } from "draft-js" ;
28import { EditorPlugin , PluginFunctions } from "draft-js-plugins-editor" ;
39import { KeyboardEvent } from "react" ;
410
@@ -89,13 +95,16 @@ const createListPlugin = (config?: Partial<ListPluginConfig>): EditorPlugin => {
8995
9096 // Handle tab and shift+tab presses if nested lists are allowed
9197 if ( allowNestedLists ) {
92- plugin . onTab = (
98+ plugin . keyBindingFn = (
9399 e : KeyboardEvent ,
94100 { getEditorState, setEditorState } : PluginFunctions ,
95- ) : void => {
96- const editorState = getEditorState ( ) ;
97- const updatedState = RichUtils . onTab ( e , editorState , maxDepth ) ;
98- setEditorState ( updatedState ) ;
101+ ) : DraftEditorCommand | null => {
102+ if ( e . key === "Tab" ) {
103+ const editorState = getEditorState ( ) ;
104+ const updatedState = RichUtils . onTab ( e , editorState , maxDepth ) ;
105+ setEditorState ( updatedState ) ;
106+ }
107+ return getDefaultKeyBinding ( e ) ;
99108 } ;
100109 }
101110
You can’t perform that action at this time.
0 commit comments