Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"eslint-config-cheminfo-typescript": "^20.0.0",
"eslint-plugin-storybook": "^9.1.16",
"jsdom": "^26.1.0",
"openchemlib": "^9.16.0",
"openchemlib": "^9.18.2",
"playwright": "^1.56.1",
"prettier": "^3.6.2",
"react": "^19.2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/components/canvas/canvas_editor_hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@
return ReactionEncoder.encode(editor.getReaction()) ?? '';
},
getRxn(programName?: string) {
return editor.getReaction().toRxn(programName);
return editor.getReaction().toRxn({ programName });
},
getRxnV3(programName?: string) {
return editor.getReaction().toRxnV3(programName);
return editor.getReaction().toRxnV3({ programName });
},
getSmiles() {
return editor.getReaction().toSmiles();
Expand All @@ -313,7 +313,7 @@
} else {
const reaction =
ReactionEncoder.decode(inputValue) ?? Reaction.create();
editor.setReaction(reaction);

Check warning on line 316 in src/components/canvas/canvas_editor_hook.ts

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Avoid passing data to parents in an effect. Instead, let the parent fetch the data itself and pass it down to the child as a prop
}
} else if (inputFormat === 'molfile') {
if (currentMode === 'molecule') {
Expand All @@ -339,7 +339,7 @@
editorRef: RefObject<CanvasEditor | null>,
fragment: boolean,
): void {
useEffect(() => {

Check warning on line 342 in src/components/canvas/canvas_editor_hook.ts

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

This effect only uses props. Consider lifting the logic up to the parent
const editor = editorRef.current;
if (!editor || editor.isDestroyed) return;

Expand Down
16 changes: 5 additions & 11 deletions src/components/svg/svg_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ import {
isCleanEvent,
isQuickNumberingEvent,
} from './editor/events_predicate.js';
import {
getNextCustomLabel,
getPreviousCustomLabel,
moleculeCustomLabels,
splitCustomLabels,
} from './editor/quick_numbering.js';
import { getPreviousCustomLabel } from './editor/quick_numbering.js';
import type { State } from './editor/reducer.js';
import { stateReducer } from './editor/reducer.js';
import { useHighlight } from './editor/use_highlight.js';
Expand Down Expand Up @@ -88,13 +83,12 @@ export function SvgEditor(props: SvgEditorProps) {
const lastInputLabel = lastInputLabelRef.current;
const newMolecule = molecule.getCompactCopy();

const existingLabels = splitCustomLabels(
moleculeCustomLabels(newMolecule),
const nextLabel = newMolecule.getNextCustomAtomLabel(
lastInputLabel ? `]${lastInputLabel}` : ']1',
);
const nextLabel = getNextCustomLabel(lastInputLabel, existingLabels);

newMolecule.setAtomCustomLabel(atomId, `]${nextLabel}`);
setLastInputLabel(nextLabel);
newMolecule.setAtomCustomLabel(atomId, nextLabel);
setLastInputLabel(nextLabel.replaceAll(']', ''));
onChangeRef.current(newMolecule);
}

Expand Down
Loading