editor-react-parser
Version:
A renderer for editorjs block data for react
50 lines (49 loc) • 1.35 kB
TypeScript
import React from "react";
import { OutputBlockData } from "../BlockParser";
/**
* Output of the code block
*
* Default output just includes the "code" field
*
* "mode" is included if you're using @rxpm/editor-js-code
* "language" is included if you're using @bomdi/codebox or @calumk/editorjs-codeflask (note that "theme" is omitted)
*
* This parser should support most editorJS code block tools
*/
export type EditorJsCode = {
code: string;
mode?: string;
language?: string;
};
export type CodeLanguage = {
shortName: string;
language: string;
logoSrc: string;
logoAlt: string;
displayText: string;
};
/**
* Changes the default configured values for a code block
*
* Code styles can be found under react-syntax-highlighter, these objects can be passed directly to "codeStyle"
*
* Only fields set will be overridden
*/
export type CodeConfig = {
classNames?: {
container?: string;
languageInfoBar?: string;
languageInfoBarText?: string;
};
codeStyle?: {
[key: string]: React.CSSProperties;
};
languages?: CodeLanguage[];
showLineNumbers?: boolean;
};
export interface CodeProps {
item: OutputBlockData<EditorJsCode>;
config?: CodeConfig;
}
declare const CodeBlock: ({ item, config }: CodeProps) => React.JSX.Element;
export default CodeBlock;