INNER CODE UNIT · TypeScript

getDirtyBlocks

software-mansion/react-native-enriched-html · src/web/pmPlugins/AutolinkPlugin/index.ts:133

function getDirtyBlocks(
  doc: Node,
  transactions: readonly Transaction[]
): DirtyBlock[] {
  const mapping = new Mapping();
  for (const tr of transactions) mapping.appendMapping(tr.mapping);

  const blocks = new Map<number, Node>();
  const docSize = doc.content.size;

  mapping.maps.forEach((stepMap, i) => {
    const rest = mapping.slice(i + 1);

    stepMap.forEach((_oldStart, _oldEnd, newStart, newEnd) => {
      const from = Math.max(0, rest.map(newStart, -1) - 1);
      const to = Math.min(docSize, rest.map(newEnd, 1) + 1);

      doc.nodesBetween(from, to, (node, pos) => {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…