diff --git a/types/draft-js/draft-js-tests.tsx b/types/draft-js/draft-js-tests.tsx index 952c8c213e..da438ee8a2 100644 --- a/types/draft-js/draft-js-tests.tsx +++ b/types/draft-js/draft-js-tests.tsx @@ -362,6 +362,11 @@ ReactDOM.render( ); const editorState = EditorState.createEmpty(); + +const selection = editorState.getSelection(); +const newSelection = selection.merge({ focusKey: '8ajs', focusOffset: 0, isBackward: true }); +EditorState.forceSelection(editorState, newSelection); + const contentState = editorState.getCurrentContent(); const entityMap = contentState.getEntityMap(); const rawContentState: RawDraftContentState = convertToRaw(contentState); diff --git a/types/draft-js/index.d.ts b/types/draft-js/index.d.ts index 71ff5e4eb3..4fbb6a44ea 100644 --- a/types/draft-js/index.d.ts +++ b/types/draft-js/index.d.ts @@ -852,9 +852,21 @@ declare namespace Draft { hasText(): boolean; } + interface SelectionStateProperties { + anchorKey: string + anchorOffset: number + focusKey: string + focusOffset: number + isBackward: boolean + hasFocus: boolean + } + class SelectionState extends Record { static createEmpty(key: string): SelectionState; + merge(...iterables: Immutable.Iterable[]): SelectionState + merge(...iterables: Partial[]): SelectionState + serialize(): string; getAnchorKey(): string; getAnchorOffset(): number;