Skip to content

Commit

Permalink
#3208 - Refactor code to ensure 'label' object is properly initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
Gayane Chilingaryan committed Sep 7, 2023
1 parent 519e677 commit 94e8124
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions packages/ketcher-core/src/application/render/restruct/reatom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,26 +708,24 @@ function buildLabel(
const label: any = {};
label.text = getLabelText(atom.a);

if (typeof label === 'object') {
if (!label.text) {
label.text = 'R#';
}

if (label.text === atom.a.label) {
const element = Elements.get(label.text);
if (options.atomColoring && element) {
atom.color = ElementColor[label.text] || '#000';
}
if (!label.text) {
label.text = 'R#';
}

const { previewOpacity } = options;
label.path = paper.text(ps.x, ps.y, label.text).attr({
font: options.font,
'font-size': options.fontsz,
fill: atom.color,
'font-style': atom.a.pseudo ? 'italic' : '',
'fill-opacity': atom.a.isPreview ? previewOpacity : 1,
});
if (label.text === atom.a.label) {
const element = Elements.get(label.text);
if (options.atomColoring && element) {
atom.color = ElementColor[label.text] || '#000';
}

const { previewOpacity } = options;
label.path = paper.text(ps.x, ps.y, label.text).attr({
font: options.font,
'font-size': options.fontsz,
fill: atom.color,
'font-style': atom.a.pseudo ? 'italic' : '',
'fill-opacity': atom.a.isPreview ? previewOpacity : 1,
});
}

label.rbb = util.relBox(label.path.getBBox());
Expand Down

0 comments on commit 94e8124

Please sign in to comment.