Skip to content

Commit

Permalink
html/shared/
Browse files Browse the repository at this point in the history
Summary:
We are rolling out exact-by-default object type syntax to www. In order to do that, we need to turn all implicitly inexact objects `{}` into explicitly inexact objects `{...}`.
This diff has no runtime or type checking changes.

I made this diff by running `phps CodemodConfigRunner CodemodConfigExactByDefault -m local html/shared` and then reverting generated files `hg st -n | xargs grep -P -l '@(partially-)?generated' | xargs hg revert`

bypass-lint
allow_many_files
drop-conflicts

Reviewed By: gkz

Differential Revision: D20521072

fbshipit-source-id: cf6b885474d0e3f087020a64158c988e27182522
  • Loading branch information
jbrown215 authored and vilemj-Viclick committed Jul 16, 2020
1 parent 7f81437 commit b70076f
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 49 deletions.
5 changes: 2 additions & 3 deletions src/component/base/DraftEditor.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@ const handlerMap = {
render: null,
};

type State = {
contentsKey: number,
};
type State = {contentsKey: number, ...};

let didInitODS = false;

class UpdateDraftEditorFlags extends React.Component<{
editor: DraftEditor,
editorState: EditorState,
...
}> {
render(): React.Node {
return null;
Expand Down
1 change: 1 addition & 0 deletions src/component/base/DraftEditorPlaceholder.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Props = {
editorState: EditorState,
text: string,
textAlignment: DraftTextAlignment,
...
};

/**
Expand Down
32 changes: 2 additions & 30 deletions src/component/base/DraftEditorProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export type DraftEditorProps = {
*/
editorState: EditorState,
onChange: (editorState: EditorState) => void,

// specify editorKey when rendering serverside. If you do not set this prop
// react will complain that there is a server/client mismatch because Draft
// will generate a random editorKey when rendering in each context. The key
Expand All @@ -45,62 +44,48 @@ export type DraftEditorProps = {
// `stripPastedStyles` is false, draft will assume both editors share their
// styling and formatting when re-applying styles.
editorKey?: string,

placeholder?: string,

// Specify whether text alignment should be forced in a direction
// regardless of input characters.
textAlignment?: DraftTextAlignment,

// Specify whether text directionality should be forced in a direction
// regardless of input characters.
textDirectionality?: BidiDirection,

// For a given `ContentBlock` object, return an object that specifies
// a custom block component and/or props. If no object is returned,
// the default `DraftEditorBlock` is used.
blockRendererFn: (block: BlockNodeRecord) => ?Object,

// Function that returns a cx map corresponding to block-level styles.
blockStyleFn: (block: BlockNodeRecord) => string,

// If supplied, a ref which will be passed to the contenteditable.
// Currently, only object refs are supported.
editorRef?: ?(
| {|current: null | HTMLElement|}
| ((HTMLElement | null) => void)
),

// A function that accepts a synthetic key event and returns
// the matching DraftEditorCommand constant, or a custom string,
// or null if no command should be invoked.
keyBindingFn: (e: SyntheticKeyboardEvent<>) => ?string,

// Set whether the editor should prevent scrolling into view on mount
// if it happens offscreen. By default, `false` to match the native behavior.
preventScroll?: boolean,

// Set whether the `DraftEditor` component should be editable. Useful for
// temporarily disabling edit behavior or allowing `DraftEditor` rendering
// to be used for consumption purposes.
readOnly: boolean,

// Note: spellcheck is always disabled for IE. If enabled in Safari, OSX
// autocorrect is enabled as well.
spellCheck: boolean,

// Set whether to remove all style information from pasted content. If your
// use case should not have any block or inline styles, it is recommended
// that you set this to `true`.
stripPastedStyles: boolean,

tabIndex?: number,

// exposed especially to help improve mobile web behaviors
autoCapitalize?: string,
autoComplete?: string,
autoCorrect?: string,

ariaActiveDescendantID?: string,
ariaAutoComplete?: string,
ariaControls?: string,
Expand All @@ -110,9 +95,7 @@ export type DraftEditorProps = {
ariaLabelledBy?: string,
ariaMultiline?: boolean,
ariaOwneeID?: string,

webDriverTestID?: string,

/**
* Cancelable event handlers, handled from the top level down. A handler
* that returns `handled` will be the last handler to execute for that event.
Expand All @@ -124,15 +107,13 @@ export type DraftEditorProps = {
e: SyntheticKeyboardEvent<>,
editorState: EditorState,
) => DraftHandleValue,

// Map a key command string provided by your key binding function to a
// specified behavior.
handleKeyCommand?: (
command: DraftEditorCommand | string,
editorState: EditorState,
eventTimeStamp: number,
) => DraftHandleValue,

// Handle intended text insertion before the insertion occurs. This may be
// useful in cases where the user has entered characters that you would like
// to trigger some special behavior. E.g. immediately converting `:)` to an
Expand All @@ -143,28 +124,23 @@ export type DraftEditorProps = {
editorState: EditorState,
eventTimeStamp: number,
) => DraftHandleValue,

handlePastedText?: (
text: string,
html?: string,
editorState: EditorState,
) => DraftHandleValue,

handlePastedFiles?: (files: Array<Blob>) => DraftHandleValue,

// Handle dropped files
handleDroppedFiles?: (
selection: SelectionState,
files: Array<Blob>,
) => DraftHandleValue,

// Handle other drops to prevent default text movement/insertion behaviour
handleDrop?: (
selection: SelectionState,
dataTransfer: Object,
isInternal: DraftDragType,
) => DraftHandleValue,

/**
* Deprecated event triggers.
*/
Expand All @@ -174,33 +150,28 @@ export type DraftEditorProps = {
onRightArrow?: (e: SyntheticKeyboardEvent<>) => void,
onDownArrow?: (e: SyntheticKeyboardEvent<>) => void,
onLeftArrow?: (e: SyntheticKeyboardEvent<>) => void,

onBlur?: (e: SyntheticEvent<>) => void,
onFocus?: (e: SyntheticEvent<>) => void,

// Provide a map of inline style names corresponding to CSS style objects
// that will be rendered for matching ranges.
customStyleMap?: Object,

// Provide a function that will construct CSS style objects given inline
// style names.
customStyleFn?: (style: DraftInlineStyle, block: BlockNodeRecord) => ?Object,

// Provide a map of block rendering configurations. Each block type maps to
// an element tag and an optional react element wrapper. This configuration
// is used for both rendering and paste processing.
blockRenderMap: DraftBlockRenderMap,

// When the Editor loses focus (blurs) text selections are cleared
// by default to mimic <textarea> behaviour, however in some situations
// users may wish to preserve native behaviour.
preserveSelectionOnBlur?: boolean,

// Overrides for cut, copy & paste, which can be used to implement custom
// behavior like entity cut/copy/paste (see PR #1784)."
onPaste?: (DraftEditor, SyntheticClipboardEvent<>) => void | Promise<void>,
onCut?: (DraftEditor, SyntheticClipboardEvent<>) => void,
onCopy?: (DraftEditor, SyntheticClipboardEvent<>) => void,
...
};

export type DraftEditorDefaultProps = {
Expand All @@ -211,4 +182,5 @@ export type DraftEditorDefaultProps = {
readOnly: boolean,
spellCheck: boolean,
stripPastedStyles: boolean,
...
};
1 change: 1 addition & 0 deletions src/component/base/DraftScrollPosition.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
export type DraftScrollPosition = {
x: number,
y: number,
...
};
1 change: 1 addition & 0 deletions src/component/contents/DraftEditorBlock.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type Props = {
selection: SelectionState,
startIndent?: boolean,
tree: List<any>,
...
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/component/contents/DraftEditorContents-core.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Props = {
editorState: EditorState,
preventScroll?: boolean,
textDirectionality?: BidiDirection,
...
};

/**
Expand Down
16 changes: 3 additions & 13 deletions src/component/contents/DraftEditorLeaf.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ const isHTMLBRElement = require('isHTMLBRElement');
const setDraftEditorSelection = require('setDraftEditorSelection')
.setDraftEditorSelection;

type CSSStyleObject = {
[property: string]: string | number,
};
type CSSStyleObject = {[property: string]: string | number, ...};

type CustomStyleMap = {[name: string]: CSSStyleObject};
type CustomStyleMap = {[name: string]: CSSStyleObject, ...};
type CustomStyleFn = (
style: DraftInlineStyle,
block: BlockNodeRecord,
Expand All @@ -36,33 +34,25 @@ type CustomStyleFn = (
type Props = {
// The block that contains this leaf.
block: BlockNodeRecord,

// Mapping of style names to CSS declarations.
customStyleMap: CustomStyleMap,

// Function that maps style names to CSS style objects.
customStyleFn: CustomStyleFn,

// Whether to force the DOM selection after render.
forceSelection: boolean,

// Whether this leaf is the last in its block. Used for a DOM hack.
isLast: boolean,

offsetKey: string,

// The current `SelectionState`, used to represent a selection range in the
// editor
selection: ?SelectionState,

// The offset of this string within its block.
start: number,

// The set of style(s) names to apply to the node.
styleSet: DraftInlineStyle,

// The full text to be rendered within this node.
text: string,
...
};

/**
Expand Down
4 changes: 1 addition & 3 deletions src/component/contents/DraftEditorTextNode.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ const NEWLINE_B = ref =>
<br key="B" data-text="true" ref={ref} />
);

type Props = {
children: string,
};
type Props = {children: string, ...};

/**
* The lowest-level component in a `DraftEditor`, the text node component
Expand Down
1 change: 1 addition & 0 deletions src/component/selection/DOMDerivedSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ import type SelectionState from 'SelectionState';
export type DOMDerivedSelection = {
selectionState: SelectionState,
needsRecovery: boolean,
...
};
1 change: 1 addition & 0 deletions src/component/selection/DraftOffsetKeyPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export type DraftOffsetKeyPath = {
blockKey: string,
decoratorKey: number,
leafKey: number,
...
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const nullthrows = require('nullthrows');
type SelectionPoint = {
key: string,
offset: number,
...
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/component/selection/getRangeBoundingClientRect.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type FakeClientRect = {
top: number,
bottom: number,
height: number,
...
};

/**
Expand Down

0 comments on commit b70076f

Please sign in to comment.