From 6e87246506ca59060cb4c6ebc7a9ac3e97609a2a Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Thu, 19 Mar 2020 14:36:23 -0700 Subject: [PATCH] html/shared/ 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 --- src/component/base/DraftEditor.react.js | 5 ++- .../base/DraftEditorPlaceholder.react.js | 1 + src/component/base/DraftEditorProps.js | 32 ++----------------- src/component/base/DraftScrollPosition.js | 1 + .../contents/DraftEditorBlock.react.js | 1 + .../DraftEditorContents-core.react.js | 1 + .../contents/DraftEditorLeaf.react.js | 16 ++-------- .../contents/DraftEditorTextNode.react.js | 4 +-- .../selection/DOMDerivedSelection.js | 1 + src/component/selection/DraftOffsetKeyPath.js | 1 + .../getDraftEditorSelectionWithNodes.js | 1 + .../selection/getRangeBoundingClientRect.js | 1 + 12 files changed, 16 insertions(+), 49 deletions(-) diff --git a/src/component/base/DraftEditor.react.js b/src/component/base/DraftEditor.react.js index 5d48dd19bc..5f764d6a0d 100644 --- a/src/component/base/DraftEditor.react.js +++ b/src/component/base/DraftEditor.react.js @@ -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; diff --git a/src/component/base/DraftEditorPlaceholder.react.js b/src/component/base/DraftEditorPlaceholder.react.js index 97fa7b6b8c..c6da9348ab 100644 --- a/src/component/base/DraftEditorPlaceholder.react.js +++ b/src/component/base/DraftEditorPlaceholder.react.js @@ -23,6 +23,7 @@ type Props = { editorState: EditorState, text: string, textAlignment: DraftTextAlignment, + ... }; /** diff --git a/src/component/base/DraftEditorProps.js b/src/component/base/DraftEditorProps.js index 910db8a83e..592b9cde85 100644 --- a/src/component/base/DraftEditorProps.js +++ b/src/component/base/DraftEditorProps.js @@ -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 @@ -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, @@ -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. @@ -124,7 +107,6 @@ export type DraftEditorProps = { e: SyntheticKeyboardEvent<>, editorState: EditorState, ) => DraftHandleValue, - // Map a key command string provided by your key binding function to a // specified behavior. handleKeyCommand?: ( @@ -132,7 +114,6 @@ export type DraftEditorProps = { 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 @@ -143,28 +124,23 @@ export type DraftEditorProps = { editorState: EditorState, eventTimeStamp: number, ) => DraftHandleValue, - handlePastedText?: ( text: string, html?: string, editorState: EditorState, ) => DraftHandleValue, - handlePastedFiles?: (files: Array) => DraftHandleValue, - // Handle dropped files handleDroppedFiles?: ( selection: SelectionState, files: Array, ) => DraftHandleValue, - // Handle other drops to prevent default text movement/insertion behaviour handleDrop?: ( selection: SelectionState, dataTransfer: Object, isInternal: DraftDragType, ) => DraftHandleValue, - /** * Deprecated event triggers. */ @@ -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