remirror/remirror

View on GitHub
packages/remirror__react-renderer/src/handlers/code-block.tsx

Summary

Maintainability
A
30 mins
Test Coverage
B
85%
import React, { FC } from 'react';
import { RemirrorJSON } from '@remirror/core';

import { MarkMap } from '../types';
import { TextHandler } from './text';

export const CodeBlock: FC<{
  node: RemirrorJSON;
  markMap: MarkMap;
}> = (props) => {
  const content = props.node.content;

  if (!content) {
    return null;
  }

  const children = content.map((node, ii) => <TextHandler key={ii} {...{ ...props, node }} />);

  return (
    <pre>
      <code>{children}</code>
    </pre>
  );
};