How to add another block after exact block in Slate.js editor?

1.5k Views Asked by At

This code changes type of the block with matched text.
How to add another block AFTER this one in Slate.js?

import {Range} from 'slate';
import {blockTypes} from 'core/slate-types';

export default function autoreplaceHeading(node, matched, change) {
  const matchedLength = matched[0].length;

  return change
    .setBlocks(blockTypes.HEADING)
    .deleteAtRange(
      Range.create({
        anchorKey: node.key,
        focusKey: node.key,
        anchorOffset: matched.index,
        focusOffset: matched.index + matchedLength
      })
  );
}
0

There are 0 best solutions below