Skip to content

Commit

Permalink
v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
skanaar committed Dec 14, 2024
1 parent d76a085 commit ab904af
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [1.7.0] - 2024-12-14

- Add `data-compartment` attribute to SVG output for identifying the compartment index when building interactivity.

## [1.6.3] - 2024-12-01

- Fix bug when running `nomnoml-cli` with input files in the same directory.
Expand Down
13 changes: 11 additions & 2 deletions dist/nomnoml.js
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@
const style = config.styles[node.type] || styles.class;
g.save();
g.setData('name', node.id);
g.setData('compartment', undefined);
g.save();
g.fillStyle(style.fill || config.fill[level] || last(config.fill));
g.strokeStyle(style.stroke || config.stroke);
Expand All @@ -1157,12 +1158,15 @@
g.path(divider.map((e) => add(e, { x, y }))).stroke();
}
g.restore();
let partIndex = 0;
for (let part of node.parts) {
const textStyle = part === node.parts[0] ? style.title : style.body;
g.save();
g.setData('compartment', String(partIndex));
g.translate(x + part.x, y + part.y);
g.setFont(config.font, config.fontSize, textStyle.bold ? 'bold' : 'normal', textStyle.italic ? 'italic' : 'normal');
renderCompartment(part, style.stroke, textStyle, level + 1);
partIndex++;
g.restore();
}
g.restore();
Expand Down Expand Up @@ -1440,7 +1444,7 @@
return this.parent;
}
serialize() {
const data = getDefined(this.group(), (e) => e.data) ?? {};
const data = getAncestorData(this.group()) ?? {};
const attrs = toAttrString({ ...this.attr, ...data });
const content = this.children.map((o) => o.serialize()).join('\n');
if (this.text && this.children.length === 0)
Expand All @@ -1453,6 +1457,11 @@
</${this.name}>`;
}
}
function getAncestorData(group) {
if (!group)
return syntheticRoot.data;
return { ...getAncestorData(group.parent), ...group.data };
}
function getDefined(group, getter) {
if (!group)
return getter(syntheticRoot);
Expand Down Expand Up @@ -1744,7 +1753,7 @@
return processImports(loadFile(rootFileName), loadFile, maxImportDepth);
}

const version = '1.6.3';
const version = '1.7.0';

exports.ImportDepthError = ImportDepthError;
exports.ParseError = ParseError;
Expand Down
4 changes: 2 additions & 2 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
@@ -1,6 +1,6 @@
{
"name": "nomnoml",
"version": "1.6.3",
"version": "1.7.0",
"description": "The sassy UML renderer that generates diagrams from text",
"homepage": "http://www.nomnoml.com",
"author": "Daniel Kallin <daniel.kallin@gmail.com>",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export {
processAsyncImports,
ImportDepthError,
} from './nomnoml'
export const version = '1.6.3'
export const version = '1.7.0'

export * as skanaar from './util'
export { parse, ParseError } from './parser'
Expand Down

0 comments on commit ab904af

Please sign in to comment.