Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit b051fc1

Browse files
jbrown215facebook-github-bot
authored andcommitted
Upgrade to Flow explicit inexact object type syntax
Reviewed By: dunnbobcat Differential Revision: D19416353 fbshipit-source-id: 26f111ed06e8ad7cee6717dbcb391f94e096f91a
1 parent 824fd12 commit b051fc1

23 files changed

+58
-46
lines changed

src/model/decorators/DraftDecorator.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export type DraftDecorator = {
4343
strategy: DraftDecoratorStrategy,
4444
component: Function,
4545
props?: Object,
46+
...
4647
};
4748

4849
/**
@@ -57,7 +58,6 @@ export type DraftDecoratorComponentProps = {
5758
decoratedText: string,
5859
dir: ?HTMLDir,
5960
end: number,
60-
6161
// Many folks mistakenly assume that there will always be an 'entityKey'
6262
// passed to a DecoratorComponent.
6363
// To find the `entityKey`, Draft calls
@@ -66,8 +66,8 @@ export type DraftDecoratorComponentProps = {
6666
// undefined. That's why `getEntityKeyAt()` is typed to return `?string`.
6767
// See https://github.com/facebook/draft-js/blob/2da3dcb1c4c106d1b2a0f07b3d0275b8d724e777/src/model/immutable/BlockNode.js#L51
6868
entityKey: ?string,
69-
7069
key: React.Key,
7170
offsetKey: string,
7271
start: number,
72+
...
7373
};

src/model/decorators/DraftDecoratorType.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ export type DraftDecoratorType = {
2929
block: BlockNodeRecord,
3030
contentState: ContentState,
3131
): List<?string>,
32-
3332
/**
3433
* Given a decorator key, return the component to use when rendering
3534
* this decorated range.
3635
*/
3736
getComponentForKey(key: string): Function,
38-
3937
/**
4038
* Given a decorator key, optionally return the props to use when rendering
4139
* this decorated range.
4240
*/
4341
getPropsForKey(key: string): ?Object,
42+
...
4443
};

src/model/encoding/EntityRange.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ export type EntityRange = {
2121
key: number,
2222
offset: number,
2323
length: number,
24+
...
2425
};

src/model/encoding/InlineStyleRange.js

+1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ export type InlineStyleRange = {
1818
style: string,
1919
offset: number,
2020
length: number,
21+
...
2122
};

src/model/encoding/RawDraftContentBlock.js

+1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ export type RawDraftContentBlock = {
2828
entityRanges: ?Array<EntityRange>,
2929
data?: Object,
3030
children?: Array<RawDraftContentBlock>,
31+
...
3132
};

src/model/encoding/RawDraftContentState.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ import type {RawDraftEntity} from 'RawDraftEntity';
2525
*/
2626
export type RawDraftContentState = {
2727
blocks: Array<RawDraftContentBlock>,
28-
entityMap: {[key: string]: RawDraftEntity},
28+
entityMap: {[key: string]: RawDraftEntity, ...},
29+
...
2930
};

src/model/encoding/RawDraftEntity.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ import type {DraftEntityType} from 'DraftEntityType';
2020
export type RawDraftEntity = {
2121
type: DraftEntityType,
2222
mutability: DraftEntityMutability,
23-
data: ?{[key: string]: any},
23+
data: ?{[key: string]: any, ...},
24+
...
2425
};

src/model/encoding/convertFromHTMLToContentBlocks.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ type ContentBlockConfig = {
241241
prevSibling: ?string,
242242
nextSibling: ?string,
243243
childConfigs: Array<ContentBlockConfig>,
244+
...
244245
};
245246

246247
/**
@@ -338,6 +339,7 @@ class ContentBlocksBuilder {
338339
getContentBlocks(): {
339340
contentBlocks: ?Array<BlockNodeRecord>,
340341
entityMap: EntityMap,
342+
...
341343
} {
342344
if (this.contentBlocks.length === 0) {
343345
if (experimentalTreeDataSupport) {
@@ -725,6 +727,7 @@ class ContentBlocksBuilder {
725727
): {
726728
text: string,
727729
characterList: List<CharacterMetadata>,
730+
...
728731
} {
729732
const l = blockConfigs.length - 1;
730733
let text = '';
@@ -753,7 +756,11 @@ const convertFromHTMLToContentBlocks = (
753756
html: string,
754757
DOMBuilder: Function = getSafeBodyFromHTML,
755758
blockRenderMap?: DraftBlockRenderMap = DefaultDraftBlockRenderMap,
756-
): ?{contentBlocks: ?Array<BlockNodeRecord>, entityMap: EntityMap} => {
759+
): ?{
760+
contentBlocks: ?Array<BlockNodeRecord>,
761+
entityMap: EntityMap,
762+
...
763+
} => {
757764
// Be ABSOLUTELY SURE that the dom builder you pass here won't execute
758765
// arbitrary code in whatever environment you're running this in. For an
759766
// example of how we try to do this in-browser, see getSafeBodyFromHTML.

src/model/entity/DraftEntity.js

+9-19
Original file line numberDiff line numberDiff line change
@@ -37,48 +37,38 @@ function logWarning(oldMethodCall, newMethodCall) {
3737

3838
export type DraftEntityMapObject = {
3939
getLastCreatedEntityKey: () => string,
40-
4140
create: (
4241
type: DraftEntityType,
4342
mutability: DraftEntityMutability,
4443
data?: Object,
4544
) => string,
46-
4745
add: (instance: DraftEntityInstance) => string,
48-
4946
get: (key: string) => DraftEntityInstance,
50-
5147
mergeData: (
5248
key: string,
53-
toMerge: {[key: string]: any},
49+
toMerge: {[key: string]: any, ...},
5450
) => DraftEntityInstance,
55-
5651
replaceData: (
5752
key: string,
58-
newData: {[key: string]: any},
53+
newData: {[key: string]: any, ...},
5954
) => DraftEntityInstance,
60-
6155
__getLastCreatedEntityKey: () => string,
62-
6356
__create: (
6457
type: DraftEntityType,
6558
mutability: DraftEntityMutability,
6659
data?: Object,
6760
) => string,
68-
6961
__add: (instance: DraftEntityInstance) => string,
70-
7162
__get: (key: string) => DraftEntityInstance,
72-
7363
__mergeData: (
7464
key: string,
75-
toMerge: {[key: string]: any},
65+
toMerge: {[key: string]: any, ...},
7666
) => DraftEntityInstance,
77-
7867
__replaceData: (
7968
key: string,
80-
newData: {[key: string]: any},
69+
newData: {[key: string]: any, ...},
8170
) => DraftEntityInstance,
71+
...
8272
};
8373

8474
/**
@@ -163,7 +153,7 @@ const DraftEntity: DraftEntityMapObject = {
163153
*/
164154
mergeData: function(
165155
key: string,
166-
toMerge: {[key: string]: any},
156+
toMerge: {[key: string]: any, ...},
167157
): DraftEntityInstance {
168158
logWarning('DraftEntity.mergeData', 'contentState.mergeEntityData');
169159
return DraftEntity.__mergeData(key, toMerge);
@@ -177,7 +167,7 @@ const DraftEntity: DraftEntityMapObject = {
177167
*/
178168
replaceData: function(
179169
key: string,
180-
newData: {[key: string]: any},
170+
newData: {[key: string]: any, ...},
181171
): DraftEntityInstance {
182172
logWarning('DraftEntity.replaceData', 'contentState.replaceEntityData');
183173
return DraftEntity.__replaceData(key, newData);
@@ -239,7 +229,7 @@ const DraftEntity: DraftEntityMapObject = {
239229
*/
240230
__mergeData: function(
241231
key: string,
242-
toMerge: {[key: string]: any},
232+
toMerge: {[key: string]: any, ...},
243233
): DraftEntityInstance {
244234
const instance = DraftEntity.__get(key);
245235
const newData = {...instance.getData(), ...toMerge};
@@ -253,7 +243,7 @@ const DraftEntity: DraftEntityMapObject = {
253243
*/
254244
__replaceData: function(
255245
key: string,
256-
newData: {[key: string]: any},
246+
newData: {[key: string]: any, ...},
257247
): DraftEntityInstance {
258248
const instance = DraftEntity.__get(key);
259249
const newInstance = instance.set('data', newData);

src/model/immutable/BlockNode.js

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type BlockNodeConfig = {
2525
key?: BlockNodeKey,
2626
text?: string,
2727
type?: DraftBlockType,
28+
...
2829
};
2930

3031
// https://github.com/facebook/draft-js/issues/1492

src/model/immutable/BlockTree.js

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const returnTrue = function() {
2828
const defaultLeafRange: {
2929
start: ?number,
3030
end: ?number,
31+
...
3132
} = {
3233
start: null,
3334
end: null,
@@ -40,6 +41,7 @@ const defaultDecoratorRange: {
4041
end: ?number,
4142
decoratorKey: ?string,
4243
leaves: ?List<LeafRange>,
44+
...
4345
} = {
4446
start: null,
4547
end: null,

src/model/immutable/CharacterMetadata.js

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type CharacterMetadataConfigValueType = DraftInlineStyle | ?string;
2222
type CharacterMetadataConfig = {
2323
style?: CharacterMetadataConfigValueType,
2424
entity?: CharacterMetadataConfigValueType,
25+
...
2526
};
2627

2728
const EMPTY_SET = OrderedSet();

src/model/immutable/ContentBlockNode.js

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type ContentBlockNodeConfig = BlockNodeConfig & {
3333
parent?: ?BlockNodeKey,
3434
prevSibling?: ?BlockNodeKey,
3535
nextSibling?: ?BlockNodeKey,
36+
...
3637
};
3738

3839
const EMPTY_SET = OrderedSet();

src/model/immutable/ContentState.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const defaultRecord: {
3636
blockMap: ?BlockMap,
3737
selectionBefore: ?SelectionState,
3838
selectionAfter: ?SelectionState,
39+
...
3940
} = {
4041
entityMap: null,
4142
blockMap: null,
@@ -144,13 +145,19 @@ class ContentState extends ContentStateRecord {
144145
return this;
145146
}
146147

147-
mergeEntityData(key: string, toMerge: {[key: string]: any}): ContentState {
148+
mergeEntityData(
149+
key: string,
150+
toMerge: {[key: string]: any, ...},
151+
): ContentState {
148152
// TODO: update this when we fully remove DraftEntity
149153
DraftEntity.__mergeData(key, toMerge);
150154
return this;
151155
}
152156

153-
replaceEntityData(key: string, newData: {[key: string]: any}): ContentState {
157+
replaceEntityData(
158+
key: string,
159+
newData: {[key: string]: any, ...},
160+
): ContentState {
154161
// TODO: update this when we fully remove DraftEntity
155162
DraftEntity.__replaceData(key, newData);
156163
return this;
@@ -169,7 +176,9 @@ class ContentState extends ContentStateRecord {
169176

170177
static createFromBlockArray(
171178
// TODO: update flow type when we completely deprecate the old entity API
172-
blocks: Array<BlockNodeRecord> | {contentBlocks: Array<BlockNodeRecord>},
179+
blocks:
180+
| Array<BlockNodeRecord>
181+
| {contentBlocks: Array<BlockNodeRecord>, ...},
173182
entityMap: ?any,
174183
): ContentState {
175184
// TODO: remove this when we completely deprecate the old entity API

src/model/immutable/DraftBlockRenderConfig.js

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ export type DraftBlockRenderConfig = {
1717
element: string,
1818
wrapper?: React.Node,
1919
aliasedElements?: Array<string>,
20+
...
2021
};

src/model/immutable/EditorState.js

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type EditorStateRecordType = {
4141
selection: ?SelectionState,
4242
treeMap: ?OrderedMap<string, List<any>>,
4343
undoStack: Stack<ContentState>,
44+
...
4445
};
4546

4647
const defaultRecord: EditorStateRecordType = {

src/model/immutable/EditorStateCreationConfig.js

+1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ export type EditorStateCreationConfig = {
2020
currentContent: ContentState,
2121
decorator: ?DraftDecoratorType,
2222
selection: SelectionState,
23+
...
2324
};

src/model/immutable/SelectionState.js

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const defaultRecord: {
2222
focusOffset: number,
2323
isBackward: boolean,
2424
hasFocus: boolean,
25+
...
2526
} = {
2627
anchorKey: '',
2728
anchorOffset: 0,

src/model/modifier/DraftRange.js

+1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
export type DraftRange = {
1515
start: number,
1616
end: number,
17+
...
1718
};

src/model/modifier/RichTextUtils.js

+2-15
Original file line numberDiff line numberDiff line change
@@ -16,51 +16,38 @@ import type EditorState from 'EditorState';
1616
import type SelectionState from 'SelectionState';
1717
import type URI from 'URI';
1818

19-
export type DataObjectForLink = {
20-
url: string,
21-
};
19+
export type DataObjectForLink = {url: string, ...};
2220

2321
export type RichTextUtils = {
2422
currentBlockContainsLink: (editorState: EditorState) => boolean,
25-
2623
getCurrentBlockType: (editorState: EditorState) => DraftBlockType,
27-
2824
getDataObjectForLinkURL: (uri: URI) => DataObjectForLink,
29-
3025
handleKeyCommand: (
3126
editorState: EditorState,
3227
command: DraftEditorCommand | string,
3328
) => ?EditorState,
34-
3529
insertSoftNewline: (editorState: EditorState) => EditorState,
36-
3730
onBackspace: (editorState: EditorState) => ?EditorState,
38-
3931
onDelete: (editorState: EditorState) => ?EditorState,
40-
4132
onTab: (
4233
event: SyntheticKeyboardEvent<>,
4334
editorState: EditorState,
4435
maxDepth: number,
4536
) => EditorState,
46-
4737
toggleBlockType: (
4838
editorState: EditorState,
4939
blockType: DraftBlockType,
5040
) => EditorState,
51-
5241
toggleCode: (editorState: EditorState) => EditorState,
53-
5442
toggleInlineStyle: (
5543
editorState: EditorState,
5644
inlineStyle: string,
5745
) => EditorState,
58-
5946
toggleLink: (
6047
editorState: EditorState,
6148
targetSelection: SelectionState,
6249
entityKey: ?string,
6350
) => EditorState,
64-
6551
tryToRemoveBlockStyle: (editorState: EditorState) => ?ContentState,
52+
...
6653
};

src/model/paste/DraftPasteProcessor.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ const DraftPasteProcessor = {
3838
processHTML(
3939
html: string,
4040
blockRenderMap?: DraftBlockRenderMap,
41-
): ?{contentBlocks: ?Array<BlockNodeRecord>, entityMap: EntityMap} {
41+
): ?{
42+
contentBlocks: ?Array<BlockNodeRecord>,
43+
entityMap: EntityMap,
44+
...
45+
} {
4246
return convertFromHTMLToContentBlocks(
4347
html,
4448
getSafeBodyFromHTML,

src/model/transaction/removeEntitiesAtEdges.js

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ function getRemovalRange(
7575
): {
7676
start: number,
7777
end: number,
78+
...
7879
} {
7980
let removalRange;
8081

0 commit comments

Comments
 (0)