mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[draft-js] Allow a merged SelectionState to be passed to forceSelection (#45522)
* add override for merge on SelectionState * prettier fix * remove accidentally committed file
This commit is contained in:
parent
f1b6c1b820
commit
a956dfd56d
@ -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);
|
||||
|
||||
12
types/draft-js/index.d.ts
vendored
12
types/draft-js/index.d.ts
vendored
@ -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<keyof SelectionStateProperties, SelectionStateProperties[keyof SelectionStateProperties]>[]): SelectionState
|
||||
merge(...iterables: Partial<SelectionStateProperties>[]): SelectionState
|
||||
|
||||
serialize(): string;
|
||||
getAnchorKey(): string;
|
||||
getAnchorOffset(): number;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user