* Parse room input from user id and emoji * Add more plain outputs * Add reply support * Always include formatted reply * Add room mention parser * Allow single linebreak after codeblock * Remove margin from math display blocks * Escape shrug * Rewrite HTML tag function * Normalize def keys * Fix embedding replies into replies * Don't add margin to file name * Collapse spaces in HTML message body * Don't crash with no plaintext rendering * Add blockquote support * Remove ref support * Fix image html rendering * Remove debug output * Remove duplicate default option value * Add table plain rendering support * Correctly handle paragraph padding when mixed with block content * Simplify links if possible * Make blockquote plain rendering better * Don't error when emojis are matching but not found * Allow plain only messages with newlines * Set user id as user mention fallback * Fix mixed up variable name * Replace replaceAll with replace
33 lines
785 B
JavaScript
33 lines
785 B
JavaScript
import React, { useEffect, useRef } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import './Math.scss';
|
|
|
|
import katex from 'katex';
|
|
import 'katex/dist/katex.min.css';
|
|
|
|
import 'katex/dist/contrib/copy-tex';
|
|
|
|
const Math = React.memo(({
|
|
content, throwOnError, errorColor, displayMode,
|
|
}) => {
|
|
const ref = useRef(null);
|
|
|
|
useEffect(() => {
|
|
katex.render(content, ref.current, { throwOnError, errorColor, displayMode });
|
|
}, [content, throwOnError, errorColor, displayMode]);
|
|
|
|
return <span ref={ref} />;
|
|
});
|
|
Math.defaultProps = {
|
|
throwOnError: null,
|
|
errorColor: null,
|
|
displayMode: null,
|
|
};
|
|
Math.propTypes = {
|
|
content: PropTypes.string.isRequired,
|
|
throwOnError: PropTypes.bool,
|
|
errorColor: PropTypes.string,
|
|
displayMode: PropTypes.bool,
|
|
};
|
|
|
|
export default Math;
|