Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let indexes = positions.map((position) => {
let [node, offset] = position;
let blot = Parchment.find(node, true);
let index = blot.offset(this.scroll);
if (offset === 0) {
return index;
} else if (blot instanceof Parchment.Container) {
return index + blot.length();
} else {
return index + blot.index(node, offset);
}
});
let start = Math.min(...indexes), end = Math.max(...indexes);
blot.children.forEachAt(index, length, function(child, index, length) {
if (isLine(child)) {
lines.push(child);
} else if (child instanceof Parchment.Container) {
lines = lines.concat(getLines(child, index, lengthLeft));
}
lengthLeft -= length;
});
return lines;
import Parchment from 'parchment';
import Block, { BlockEmbed } from './block';
class Container extends Parchment.Container { }
Container.allowedChildren = [Block, BlockEmbed, Container];
export default Container;