react-lz-editor
Version:
An open source react rich-text editor (mordern react editor includes media support such as texts, images, videos, audios, links etc.), development based on Draft-Js and Ant-design, good support html, markdown, draft-raw mode.
34 lines (25 loc) • 678 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (contentState, anchorKey, focusKey) {
var isSameBlock = anchorKey === focusKey;
var startingBlock = contentState.getBlockForKey(anchorKey);
if (!startingBlock) {
return [];
}
var selectedBlocks = [startingBlock];
if (!isSameBlock) {
var blockKey = anchorKey;
while (blockKey !== focusKey) {
var nextBlock = contentState.getBlockAfter(blockKey);
if (!nextBlock) {
selectedBlocks = [];
break;
}
selectedBlocks.push(nextBlock);
blockKey = nextBlock.getKey();
}
}
return selectedBlocks;
};