draft-js
Version:
A React framework for building text editors.
27 lines (23 loc) • 704 B
JavaScript
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*
* @emails oncall+draft_js
*/
;
/**
* Find the string of text between the previous entity and the specified
* offset. This allows us to narrow down search areas for regex matching.
*/
function getTextAfterNearestEntity(block, offset) {
var start = offset; // Get start based on where the last entity ended.
while (start > 0 && block.getEntityAt(start - 1) === null) {
start--;
}
return block.getText().slice(start, offset);
}
module.exports = getTextAfterNearestEntity;