Skip to content

Commit

Permalink
Merge pull request #566 from NASA-IMPACT/fix/equation-number-repetition
Browse files Browse the repository at this point in the history
Fix equation number repetition
  • Loading branch information
wrynearson authored Oct 20, 2023
2 parents 7783e33 + 71de924 commit fe57369
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function EquationElement(props) {
const isSelected = useSelected();
const { element, attributes, children } = props;
const latexEquation = Node.string(element);
const equationPath = JSON.stringify(ReactEditor.findPath(editor, element));
const readOnly = useReadOnly();

const handleClick = useCallback(() => {
Expand All @@ -60,9 +61,9 @@ function EquationElement(props) {

useEffect(() => {
if (numberingContext && !isInline) {
numberingContext.registerEquation(latexEquation);
numberingContext.registerEquation(equationPath);
}
}, [numberingContext, isInline, latexEquation]);
}, [numberingContext, isInline, equationPath]);

const returnElement = React.useMemo(() => {
if (readOnly) {
Expand All @@ -83,7 +84,7 @@ function EquationElement(props) {
<MathElement math={latexEquation || 'latex~empty~equation'} />
</span>
{!isInline && numberingContext && (
<span>{numberingContext.getEquationNumbering(latexEquation)}</span>
<span>{numberingContext.getEquationNumbering(equationPath)}</span>
)}
{!isInline && <span className='equation-number' />}
</EquationReadOnly>
Expand All @@ -110,6 +111,7 @@ function EquationElement(props) {
isInline,
isSelected,
latexEquation,
equationPath,
numberingContext,
readOnly
]);
Expand Down

0 comments on commit fe57369

Please sign in to comment.