MCPcopy Index your code
hub / github.com/SamyPesse/draft-js-code / hasSelectionInBlock

Function hasSelectionInBlock

lib/hasSelectionInBlock.js:7–14  ·  view source on GitHub ↗

* Return true if selection is inside a code block * * @param {Draft.EditorState} editorState * @return {Boolean}

(editorState)

Source from the content-addressed store, hash-verified

5 * @return {Boolean}
6 */
7function hasSelectionInBlock(editorState) {
8 var selection = editorState.getSelection();
9 var contentState = editorState.getCurrentContent();
10 var startKey = selection.getStartKey();
11 var currentBlock = contentState.getBlockForKey(startKey);
12
13 return currentBlock.getType() === 'code-block';
14}
15
16module.exports = hasSelectionInBlock;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected