2

此代码使用匹配的文本更改块的类型。
如何在这个之后添加另一个块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
      })
  );
}
4

0 回答 0