From c2b584cfdc0a29efd25050f764eefe3627d94a46 Mon Sep 17 00:00:00 2001 From: Ben Salili-James Date: Fri, 16 Aug 2019 19:52:08 +0100 Subject: [PATCH] Add `editorKey` and `textDirectionality` props to `draft-js` (#37674) --- types/draft-js/draft-js-tests.tsx | 1 + types/draft-js/index.d.ts | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/types/draft-js/draft-js-tests.tsx b/types/draft-js/draft-js-tests.tsx index d6b05601ba..19cf0c2646 100644 --- a/types/draft-js/draft-js-tests.tsx +++ b/types/draft-js/draft-js-tests.tsx @@ -172,6 +172,7 @@ class RichEditorExample extends React.Component<{}, { editorState: EditorState } // Kevin Hawkinson // Munif Tanjim +// Ben Salili-James // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.9 @@ -76,11 +77,20 @@ declare namespace Draft { // regardless of input characters. textAlignment?: DraftTextAlignment; + // Specify whether text directionality should be forced in a direction + // regardless of input characters. + textDirectionality?: DraftTextDirectionality; + // For a given `ContentBlock` object, return an object that specifies // a custom block component and/or props. If no object is returned, // the default `TextEditorBlock` is used. blockRendererFn?(block: ContentBlock): any; + // 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 + // Function that allows to define class names to apply to the given block when it is rendered. blockStyleFn?(block: ContentBlock): string; @@ -130,6 +140,10 @@ declare namespace Draft { webDriverTestID?: string; + // If using server-side rendering, this prop is required to be set to + // avoid client/server mismatches. + editorKey?: 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. @@ -172,14 +186,11 @@ declare namespace Draft { onBlur?(e: SyntheticEvent): void, onFocus?(e: SyntheticEvent): void, - - // 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 } type DraftTextAlignment = "left" | "center" | "right"; + + type DraftTextDirectionality = "LTR" | "RTL" | "NEUTRAL"; } namespace Components {