getEventRange
React-specific utility functions for Slate that may be useful in certain use cases.
Functions
cloneFragment
cloneFragment
cloneFragment(event: DOMEvent|ReactEvent, value: Value, fragment: Document)
During a cut or copy event, sets fragment
as the Slate document fragment to be copied.
Note that calling cloneFragment
should be the last thing you do in your event handler. If you change the window selection after calling cloneFragment
, the browser may copy the wrong content. If you need to perform an action after calling cloneFragment
, wrap it in requestAnimationFrame
:
findDOMNode
findDOMNode
findDOMNode(node: Node) => DOMElement
Find the DOM node from a Slate Node
. Modelled after React's built-in findDOMNode
helper.
findDOMRange
findDOMRange
findDOMRange(range: Range) => DOMRange
Find the DOM range from a Slate Range
.
findNode
findNode
findNode(element: DOMElement, value: Value) => Node
Find the Slate node from a DOM element
and Slate value
.
findRange
findRange
findRange(selection: DOMSelection, value: Value) => Range
findRange(range: DOMRange, value: Value) => Range
Find the Slate range from a DOM range
or selection
and a Slate value
.
getEventRange
getEventRange
getEventRange(event: DOMEvent|ReactEvent, value: Value) => Range
Get the affected Slate range from a DOM event
and Slate value
.
getEventTransfer
getEventTransfer
getEventTransfer(event: DOMEvent|ReactEvent) => Object
Get the Slate-related data from a DOM event
and Slate value
.
setEventTransfer
setEventTransfer
setEventTransfer(event: DOMEvent|ReactEvent, type: String, data: Any)
Sets the Slate-related data
with type
on an event
. The type
must be one of the types Slate recognizes: 'fragment'
, 'html'
, 'node'
, 'rich'
, or 'text'
.
Last updated