This repository has been archived by the owner on Feb 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Summary: We are splitting up and updating pieces of this PR by Mitermayer. This chunk forks the RichTextEditorUtil and puts them both under the same Flow interface, also adding a test. The forked NestedRichTextEditorUtil is a WIP version of this utility. This is directly taken from mitermayer 's fork, props to him Pull Request resolved: #1828 Reviewed By: mitermayer Differential Revision: D9181952 Pulled By: mitermayer fbshipit-source-id: 75f08fdb228ae1b45f97ae29aeae2f3d5ea53650
- Loading branch information
1 parent
cf48f77
commit 328ddc6
Showing
5 changed files
with
3,445 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @format | ||
* @flow strict-local | ||
*/ | ||
|
||
import type ContentState from 'ContentState'; | ||
import type {DraftBlockType} from 'DraftBlockType'; | ||
import type {DraftEditorCommand} from 'DraftEditorCommand'; | ||
import type EditorState from 'EditorState'; | ||
import type SelectionState from 'SelectionState'; | ||
import type URI from 'URI'; | ||
|
||
export type DataObjectForLink = { | ||
url: string, | ||
}; | ||
|
||
export type RichTextUtils = { | ||
currentBlockContainsLink: (editorState: EditorState) => boolean, | ||
|
||
getCurrentBlockType: (editorState: EditorState) => DraftBlockType, | ||
|
||
getDataObjectForLinkURL: (uri: URI) => DataObjectForLink, | ||
|
||
handleKeyCommand: ( | ||
editorState: EditorState, | ||
command: DraftEditorCommand | string, | ||
) => ?EditorState, | ||
|
||
insertSoftNewline: (editorState: EditorState) => EditorState, | ||
|
||
onBackspace: (editorState: EditorState) => ?EditorState, | ||
|
||
onDelete: (editorState: EditorState) => ?EditorState, | ||
|
||
onTab: ( | ||
event: SyntheticKeyboardEvent<>, | ||
editorState: EditorState, | ||
maxDepth: number, | ||
) => EditorState, | ||
|
||
toggleBlockType: ( | ||
editorState: EditorState, | ||
blockType: DraftBlockType, | ||
) => EditorState, | ||
|
||
toggleCode: (editorState: EditorState) => EditorState, | ||
|
||
toggleInlineStyle: ( | ||
editorState: EditorState, | ||
inlineStyle: string, | ||
) => EditorState, | ||
|
||
toggleLink: ( | ||
editorState: EditorState, | ||
targetSelection: SelectionState, | ||
entityKey: ?string, | ||
) => EditorState, | ||
|
||
tryToRemoveBlockStyle: (editorState: EditorState) => ?ContentState, | ||
}; |
Oops, something went wrong.