Socket
Socket
Sign inDemoInstall

@types/draft-js

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/draft-js - npm Package Compare versions

Comparing version 0.10.38 to 0.10.39

466

draft-js/index.d.ts

@@ -19,4 +19,4 @@ // Type definitions for Draft.js v0.10.5

import * as Immutable from 'immutable';
import * as React from 'react';
import * as Immutable from 'immutable';

@@ -44,3 +44,3 @@ type SyntheticKeyboardEvent = React.KeyboardEvent<{}>;

type DraftStyleMap = {
[styleName: string]: React.CSSProperties
[styleName: string]: React.CSSProperties;
};

@@ -56,5 +56,5 @@

class DraftEditor extends React.Component<DraftEditorProps, {}> {
// Force focus back onto the editor node.
/** Force focus back onto the editor node. */
focus(): void;
// Remove focus from the editor node.
/** Remove focus from the editor node. */
blur(): void;

@@ -79,48 +79,70 @@ }

// Specify whether text alignment should be forced in a direction
// regardless of input characters.
/**
* 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.
/**
* 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.
/**
* 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
/**
* 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.
/**
* Function that allows to define class names to apply to the given block when it is rendered.
*/
blockStyleFn?(block: ContentBlock): string;
// Provide a map of inline style names corresponding to CSS style objects
// that will be rendered for matching ranges.
/**
* Provide a map of inline style names corresponding to CSS style objects
* that will be rendered for matching ranges.
*/
customStyleMap?: DraftStyleMap;
// Define a function to transform inline styles to CSS objects
// that are applied to spans of text.
/**
* Define a function to transform inline styles to CSS objects
* that are applied to spans of text.
*/
customStyleFn?: (style: DraftInlineStyle, block: ContentBlock) => React.CSSProperties;
// A function that accepts a synthetic key event and returns
// the matching DraftEditorCommand constant, or null if no command should
// be invoked.
/**
* A function that accepts a synthetic key event and returns
* the matching DraftEditorCommand constant, or null if no command should
* be invoked.
*/
keyBindingFn?(e: SyntheticKeyboardEvent): EditorCommand | null;
// Set whether the `DraftEditor` component should be editable. Useful for
// temporarily disabling edit behavior or allowing `DraftEditor` rendering
// to be used for consumption purposes.
/**
* 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.
/**
* 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`.
/**
* 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;

@@ -141,3 +163,5 @@

ariaLabel?: string;
ariaLabelledBy?: boolean;
ariaMultiline?: boolean;
ariaOwneeID?: string;

@@ -148,58 +172,69 @@ role?: string;

// If using server-side rendering, this prop is required to be set to
// avoid client/server mismatches.
/**
* 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.
/**
* Cancelable event handlers, handled from the top level down. A handler
* that returns `handled` will be the last handler to execute for that event.
* Useful for managing special behavior for pressing the `Return` key. E.g.
* removing the style from an empty list item.
*/
handleReturn?(e: SyntheticKeyboardEvent, editorState: EditorState): DraftHandleValue;
// Useful for managing special behavior for pressing the `Return` key. E.g.
// removing the style from an empty list item.
handleReturn?(e: SyntheticKeyboardEvent, editorState: EditorState): DraftHandleValue,
/**
* Map a key command string provided by your key binding function to a
* specified behavior.
*/
handleKeyCommand?(
command: EditorCommand,
editorState: EditorState,
eventTimeStamp: number,
): DraftHandleValue;
// Map a key command string provided by your key binding function to a
// specified behavior.
handleKeyCommand?(command: EditorCommand, 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
* emoji Unicode character, or replacing ASCII quote characters with smart
* quotes.
*/
handleBeforeInput?(chars: 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
// emoji Unicode character, or replacing ASCII quote characters with smart
// quotes.
handleBeforeInput?(chars: string, editorState: EditorState, eventTimeStamp: number): DraftHandleValue,
handlePastedText?(text: string, html: string | undefined, editorState: EditorState): DraftHandleValue;
handlePastedText?(text: string, html: string|undefined, editorState: EditorState): DraftHandleValue,
handlePastedFiles?(files: Array<Blob>): DraftHandleValue;
handlePastedFiles?(files: Array<Blob>): DraftHandleValue,
/** Handle dropped files */
handleDroppedFiles?(selection: SelectionState, 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;
// Handle other drops to prevent default text movement/insertion behaviour
handleDrop?(selection: SelectionState, dataTransfer: Object, isInternal: DraftDragType): DraftHandleValue,
// Non-cancelable event triggers.
onEscape?(e: SyntheticKeyboardEvent): void;
onTab?(e: SyntheticKeyboardEvent): void;
onUpArrow?(e: SyntheticKeyboardEvent): void;
onDownArrow?(e: SyntheticKeyboardEvent): void;
onRightArrow?(e: SyntheticKeyboardEvent): void;
onLeftArrow?(e: SyntheticKeyboardEvent): void;
/**
* Non-cancelable event triggers.
*/
onEscape?(e: SyntheticKeyboardEvent): void,
onTab?(e: SyntheticKeyboardEvent): void,
onUpArrow?(e: SyntheticKeyboardEvent): void,
onDownArrow?(e: SyntheticKeyboardEvent): void,
onRightArrow?(e: SyntheticKeyboardEvent): void,
onLeftArrow?(e: SyntheticKeyboardEvent): void,
onBlur?(e: SyntheticEvent): void,
onFocus?(e: SyntheticEvent): void,
onBlur?(e: SyntheticEvent): void;
onFocus?(e: SyntheticEvent): void;
}
type DraftTextAlignment = "left" | "center" | "right";
type DraftTextAlignment = 'left' | 'center' | 'right';
type DraftTextDirectionality = "LTR" | "RTL" | "NEUTRAL";
type DraftTextDirectionality = 'LTR' | 'RTL' | 'NEUTRAL';
}
namespace Components {
class DraftEditorBlock extends React.Component<any, {}> {
}
class DraftEditorBlock extends React.Component<any, {}> {}
}

@@ -209,8 +244,8 @@

interface FakeClientRect {
left: number,
width: number,
right: number,
top: number,
bottom: number,
height: number,
left: number;
width: number;
right: number;
top: number;
bottom: number;
height: number;
}

@@ -222,3 +257,3 @@

* temporarily invalid, return null.
*/
*/
function getVisibleSelectionRect(global: any): FakeClientRect;

@@ -243,2 +278,9 @@ }

static isSoftNewlineEvent(e: SyntheticKeyboardEvent): boolean;
/**
* Check whether heuristics that only apply to macOS are used
* internally, for example when determining the key combination
* used as command modifier.
*/
static usesMacOSHeuristics(): boolean;
}

@@ -260,8 +302,8 @@

*/
type DraftEditorCommand = (
type DraftEditorCommand =
/**
* Self-explanatory.
*/
"undo" |
"redo" |
| 'undo'
| 'redo'

@@ -271,3 +313,3 @@ /**

*/
"delete" |
| 'delete'

@@ -277,3 +319,3 @@ /**

*/
"delete-word" |
| 'delete-word'

@@ -283,3 +325,3 @@ /**

*/
"backspace" |
| 'backspace'

@@ -290,3 +332,3 @@ /**

*/
"backspace-word" |
| 'backspace-word'

@@ -296,3 +338,3 @@ /**

*/
"backspace-to-start-of-line" |
| 'backspace-to-start-of-line'

@@ -303,7 +345,7 @@ /**

*/
"bold" |
"code" |
"italic" |
"strikethrough" |
"underline" |
| 'bold'
| 'code'
| 'italic'
| 'strikethrough'
| 'underline'

@@ -313,3 +355,3 @@ /**

*/
"split-block" |
| 'split-block'

@@ -319,5 +361,5 @@ /**

*/
"transpose-characters" |
"move-selection-to-start-of-block" |
"move-selection-to-end-of-block" |
| 'transpose-characters'
| 'move-selection-to-start-of-block'
| 'move-selection-to-end-of-block'

@@ -328,5 +370,4 @@ /**

*/
"secondary-cut" |
"secondary-paste"
);
| 'secondary-cut'
| 'secondary-paste';

@@ -337,3 +378,3 @@ /**

*/
type DraftDragType = "internal" | "external";
type DraftDragType = 'internal' | 'external';

@@ -343,17 +384,16 @@ /**

*/
type CoreDraftBlockType = (
"unstyled" |
"paragraph" |
"header-one" |
"header-two" |
"header-three" |
"header-four" |
"header-five" |
"header-six" |
"unordered-list-item" |
"ordered-list-item" |
"blockquote" |
"code-block" |
"atomic"
);
type CoreDraftBlockType =
| 'unstyled'
| 'paragraph'
| 'header-one'
| 'header-two'
| 'header-three'
| 'header-four'
| 'header-five'
| 'header-six'
| 'unordered-list-item'
| 'ordered-list-item'
| 'blockquote'
| 'code-block'
| 'atomic';

@@ -368,3 +408,3 @@ type CustomBlockType = string;

*/
type DraftRemovalDirection = "backward" | "forward";
type DraftRemovalDirection = 'backward' | 'forward';

@@ -375,3 +415,3 @@ /**

*/
type DraftHandleValue = "handled" | "not-handled";
type DraftHandleValue = 'handled' | 'not-handled';

@@ -382,3 +422,3 @@ /**

*/
type DraftInsertionType = "replace" | "before" | "after";
type DraftInsertionType = 'replace' | 'before' | 'after';

@@ -388,9 +428,3 @@ /**

*/
type DraftInlineStyleType = (
"BOLD" |
"CODE" |
"ITALIC" |
"STRIKETHROUGH" |
"UNDERLINE"
)
type DraftInlineStyleType = 'BOLD' | 'CODE' | 'ITALIC' | 'STRIKETHROUGH' | 'UNDERLINE';

@@ -400,8 +434,3 @@ /**

*/
type ComposedEntityType = (
"LINK" |
"TOKEN" |
"PHOTO" |
"IMAGE"
)
type ComposedEntityType = 'LINK' | 'TOKEN' | 'PHOTO' | 'IMAGE';

@@ -439,3 +468,3 @@ /**

*/
type DraftEntityMutability = "MUTABLE" | "IMMUTABLE" | "SEGMENTED";
type DraftEntityMutability = 'MUTABLE' | 'IMMUTABLE' | 'SEGMENTED';
}

@@ -447,7 +476,7 @@

/**
* An interface for document decorator classes, allowing the creation of
* custom decorator classes.
*
* See `CompositeDraftDecorator` for the most common use case.
*/
* An interface for document decorator classes, allowing the creation of
* custom decorator classes.
*
* See `CompositeDraftDecorator` for the most common use case.
*/
interface DraftDecoratorType {

@@ -488,3 +517,7 @@ /**

interface DraftDecorator {
strategy: (block: ContentBlock, callback: (start: number, end: number) => void, contentState: ContentState) => void;
strategy: (
block: ContentBlock,
callback: (start: number, end: number) => void,
contentState: ContentState,
) => void;
component: Function;

@@ -549,5 +582,5 @@ props?: object;

interface RawDraftEntityRange {
key: number,
offset: number,
length: number,
key: number;
offset: number;
length: number;
}

@@ -592,3 +625,7 @@

function convertFromHTMLtoContentBlocks(html: string, DOMBuilder?: Function, blockRenderMap?: DraftBlockRenderMap): { contentBlocks: Array<ContentBlock>, entityMap: any };
function convertFromHTMLtoContentBlocks(
html: string,
DOMBuilder?: Function,
blockRenderMap?: DraftBlockRenderMap,
): { contentBlocks: Array<ContentBlock>; entityMap: any };
function convertFromRawToDraftState(rawState: RawDraftContentState): ContentState;

@@ -732,3 +769,7 @@ function convertFromDraftStateToRaw(contentState: ContentState): RawDraftContentState;

*/
static push(editorState: EditorState, contentState: ContentState, changeType: EditorChangeType): EditorState;
static push(
editorState: EditorState,
contentState: ContentState,
changeType: EditorChangeType,
): EditorState;

@@ -769,3 +810,6 @@ /**

static setInlineStyleOverride(editorState: EditorState, inlineStyleOverride: DraftInlineStyle): EditorState;
static setInlineStyleOverride(
editorState: EditorState,
inlineStyleOverride: DraftInlineStyle,
): EditorState;

@@ -801,3 +845,6 @@ /**

*/
findStyleRanges(filterFn: (value: CharacterMetadata) => boolean, callback: (start: number, end: number) => void): void;
findStyleRanges(
filterFn: (value: CharacterMetadata) => boolean,
callback: (start: number, end: number) => void,
): void;

@@ -807,3 +854,6 @@ /**

*/
findEntityRanges(filterFn: (value: CharacterMetadata) => boolean, callback: (start: number, end: number) => void): void;
findEntityRanges(
filterFn: (value: CharacterMetadata) => boolean,
callback: (start: number, end: number) => void,
): void;
}

@@ -823,3 +873,2 @@

getBlockMap(): BlockMap;

@@ -888,18 +937,17 @@ getSelectionBefore(): SelectionState;

type EditorChangeType = (
"adjust-depth" |
"apply-entity" |
"backspace-character" |
"change-block-data" |
"change-block-type" |
"change-inline-style" |
"delete-character" |
"insert-characters" |
"insert-fragment" |
"redo" |
"remove-range" |
"spellcheck-change" |
"split-block" |
"undo"
)
type EditorChangeType =
| 'adjust-depth'
| 'apply-entity'
| 'backspace-character'
| 'change-block-data'
| 'change-block-type'
| 'change-inline-style'
| 'delete-character'
| 'insert-characters'
| 'insert-fragment'
| 'redo'
| 'remove-range'
| 'spellcheck-change'
| 'split-block'
| 'undo';

@@ -935,3 +983,8 @@ class BlockMapBuilder {

static insertAtomicBlock(editorState: EditorState, entityKey: string, character: string): EditorState;
static moveAtomicBlock(editorState: EditorState, atomicBlock: ContentBlock, targetRange: SelectionState, insertionMode?: DraftInsertionType): EditorState;
static moveAtomicBlock(
editorState: EditorState,
atomicBlock: ContentBlock,
targetRange: SelectionState,
insertionMode?: DraftInsertionType,
): EditorState;
}

@@ -950,19 +1003,71 @@

class DraftModifier {
static replaceText(contentState: ContentState, rangeToReplace: SelectionState, text: string, inlineStyle?: DraftInlineStyle, entityKey?: string): ContentState;
static insertText(contentState: ContentState, targetRange: SelectionState, text: string, inlineStyle?: DraftInlineStyle, entityKey?: string): ContentState;
static moveText(contentState: ContentState, removalRange: SelectionState, targetRange: SelectionState): ContentState;
static replaceWithFragment(contentState: ContentState, targetRange: SelectionState, fragment: BlockMap): ContentState;
static replaceText(
contentState: ContentState,
rangeToReplace: SelectionState,
text: string,
inlineStyle?: DraftInlineStyle,
entityKey?: string,
): ContentState;
static insertText(
contentState: ContentState,
targetRange: SelectionState,
text: string,
inlineStyle?: DraftInlineStyle,
entityKey?: string,
): ContentState;
static moveText(
contentState: ContentState,
removalRange: SelectionState,
targetRange: SelectionState,
): ContentState;
static replaceWithFragment(
contentState: ContentState,
targetRange: SelectionState,
fragment: BlockMap,
): ContentState;
static removeRange(contentState: ContentState, rangeToRemove: SelectionState, removalDirection: DraftRemovalDirection): ContentState;
static removeRange(
contentState: ContentState,
rangeToRemove: SelectionState,
removalDirection: DraftRemovalDirection,
): ContentState;
static splitBlock(contentState: ContentState, selectionState: SelectionState): ContentState;
static applyInlineStyle(contentState: ContentState, selectionState: SelectionState, inlineStyle: string): ContentState;
static removeInlineStyle(contentState: ContentState, selectionState: SelectionState, inlineStyle: string): ContentState;
static applyInlineStyle(
contentState: ContentState,
selectionState: SelectionState,
inlineStyle: string,
): ContentState;
static removeInlineStyle(
contentState: ContentState,
selectionState: SelectionState,
inlineStyle: string,
): ContentState;
static setBlockType(contentState: ContentState, selectionState: SelectionState, blockType: DraftBlockType): ContentState;
static setBlockType(contentState: ContentState, selectionState: SelectionState, blockType: string): ContentState;
static setBlockType(
contentState: ContentState,
selectionState: SelectionState,
blockType: DraftBlockType,
): ContentState;
static setBlockType(
contentState: ContentState,
selectionState: SelectionState,
blockType: string,
): ContentState;
static setBlockData(contentState: ContentState, selectionState: SelectionState, blockData: Immutable.Map<any, any>): ContentState;
static mergeBlockData(contentState: ContentState, selectionState: SelectionState, blockData: Immutable.Map<any, any>): ContentState;
static applyEntity(contentState: ContentState, selectionState: SelectionState, entityKey: string | null): ContentState;
static setBlockData(
contentState: ContentState,
selectionState: SelectionState,
blockData: Immutable.Map<any, any>,
): ContentState;
static mergeBlockData(
contentState: ContentState,
selectionState: SelectionState,
blockData: Immutable.Map<any, any>,
): ContentState;
static applyEntity(
contentState: ContentState,
selectionState: SelectionState,
entityKey: string | null,
): ContentState;
}

@@ -1002,3 +1107,7 @@

static toggleLink(editorState: EditorState, targetSelection: SelectionState, entityKey: string | null): EditorState;
static toggleLink(
editorState: EditorState,
targetSelection: SelectionState,
entityKey: string | null,
): EditorState;

@@ -1075,3 +1184,2 @@ /**

EditorChangeType,
DraftDecorator,

@@ -1081,3 +1189,2 @@ CompositeDecorator,

EntityInstance,
BlockMapBuilder,

@@ -1090,3 +1197,2 @@ CharacterMetadata,

BlockMap,
AtomicBlockUtils,

@@ -1096,6 +1202,4 @@ KeyBindingUtil,

RichUtils,
DefaultDraftBlockRenderMap,
DefaultDraftInlineStyle,
RawDraftInlineStyleRange,

@@ -1109,7 +1213,5 @@ RawDraftEntityRange,

convertFromHTML,
genKey,
getDefaultKeyBinding,
getVisibleSelectionRect,
DraftEditorCommand,

@@ -1126,3 +1228,3 @@ DraftDragType,

DraftInsertionType,
DraftStyleMap
DraftStyleMap,
};
{
"name": "@types/draft-js",
"version": "0.10.38",
"version": "0.10.39",
"description": "TypeScript definitions for Draft.js",

@@ -85,4 +85,4 @@ "license": "MIT",

},
"typesPublisherContentHash": "ffd5ead557cec0efcf1bfb04350cc5d56c598d92913cd659d14bd46dd47827ae",
"typesPublisherContentHash": "4634753f5b132000902458e0742fa9adb32579b2abb2eed9348be42fedf53d5d",
"typeScriptVersion": "2.9"
}

@@ -11,7 +11,7 @@ # Installation

### Additional Details
* Last updated: Thu, 02 Jan 2020 23:59:03 GMT
* Dependencies: [@types/react](https://npmjs.com/package/@types/react), [@types/immutable](https://npmjs.com/package/@types/immutable)
* Last updated: Sat, 11 Apr 2020 02:45:45 GMT
* Dependencies: [@types/immutable](https://npmjs.com/package/@types/immutable), [@types/react](https://npmjs.com/package/@types/react)
* Global values: `Draft`
# Credits
These definitions were written by Dmitry Rogozhny (https://github.com/dmitryrogozhny), Eelco Lempsink (https://github.com/eelco), Yale Cason (https://github.com/ghotiphud), Ryan Schwers (https://github.com/schwers), Michael Wu (https://github.com/michael-yx-wu), Willis Plummer (https://github.com/willisplummer), Santiago Vilar (https://github.com/smvilar), Ulf Schwekendiek (https://github.com/sulf), Pablo Varela (https://github.com/pablopunk), Claudio Procida (https://github.com/claudiopro), Kevin Hawkinson (https://github.com/khawkinson), Munif Tanjim (https://github.com/MunifTanjim), and Ben Salili-James (https://github.com/benhjames).
These definitions were written by [Dmitry Rogozhny](https://github.com/dmitryrogozhny), [Eelco Lempsink](https://github.com/eelco), [Yale Cason](https://github.com/ghotiphud), [Ryan Schwers](https://github.com/schwers), [Michael Wu](https://github.com/michael-yx-wu), [Willis Plummer](https://github.com/willisplummer), [Santiago Vilar](https://github.com/smvilar), [Ulf Schwekendiek](https://github.com/sulf), [Pablo Varela](https://github.com/pablopunk), [Claudio Procida](https://github.com/claudiopro), [Kevin Hawkinson](https://github.com/khawkinson), [Munif Tanjim](https://github.com/MunifTanjim), and [Ben Salili-James](https://github.com/benhjames).

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc