import {
  insertNodes,
  PlateEditor,
  Value,
  withoutNormalizing,
} from '@udecode/plate-common';

import { ELEMENT_HIGHLIGH_BLOCK } from './createHighlightPlugin';
import { THighlightBlockElement } from './highlight-block-store';

export const insertHighlight = <V extends Value>(editor: PlateEditor<V>) => {
  withoutNormalizing(editor, () => {
    insertNodes<THighlightBlockElement>(editor, {
      type: ELEMENT_HIGHLIGH_BLOCK,
      category: 'info',
      emoji: '🗒️',
      showEmoji: true,
      children: [
        {
          type: 'p',
          children: [{ text: '标题', fontSize: 18 }],
        },
      ],
    });
  });
};
