Skip to content

Commit

Permalink
change fontSize to string
Browse files Browse the repository at this point in the history
  • Loading branch information
ad1992 committed Jul 10, 2024
1 parent 700211f commit c7cfd67
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- Add support for passing config params `maxEdge` and `maxTextSize` to mermaid by [@ad1992](https://github.com/ad1992) in https://github.com/excalidraw/mermaid-to-excalidraw/pull/68

Additonally the param `fontSize` is renamed to `themeVariables.fontSize` to be consistent with the [mermaid config](https://mermaid.js.org/schemas/config.schema.json).
Additonally the param `fontSize` is renamed to `themeVariables.fontSize` and type is changed from `number` to `string` to be consistent with the [mermaid config](https://mermaid.js.org/schemas/config.schema.json).

## v1.0.0 (2024-05-20)

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ Currently `mermaid-to-excalidraw` only supports the :point_down: config params
};
/**
* Theme variables
* @default { fontSize: 25 }
* @default { fontSize: "25px" }
*/
themeVariables?: {
fontSize?: number;
fontSize?: string;
};
/**
* Maximum number of edges to be rendered.
Expand All @@ -77,7 +77,7 @@ try {
diagramDefinition,
{
themeVariables: {
fontSize: DEFAULT_FONT_SIZE,
fontSize: "25px",
},
}
);
Expand Down
2 changes: 1 addition & 1 deletion playground/ExcalidrawWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const ExcalidrawWrapper = ({

const { elements, files } = graphToExcalidraw(mermaidOutput, {
themeVariables: {
fontSize: DEFAULT_FONT_SIZE,
fontSize: `${DEFAULT_FONT_SIZE}px`,
},
});

Expand Down
1 change: 1 addition & 0 deletions playground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ExcalidrawWrapper from "./ExcalidrawWrapper.tsx";
import Testcases from "./Testcases.tsx";
import { parseMermaid } from "../src/parseMermaid.ts";
import GitHubCorner from "./GitHubCorner.tsx";
import { DEFAULT_FONT_SIZE } from "../src/constants.ts";

export interface MermaidData {
definition: string;
Expand Down
3 changes: 2 additions & 1 deletion src/converter/types/flowchart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ const computeGroupIds = (
export const FlowchartToExcalidrawSkeletonConverter = new GraphConverter({
converter: (graph: Flowchart, options) => {
const elements: ExcalidrawElementSkeleton[] = [];
const fontSize = options.themeVariables?.fontSize || DEFAULT_FONT_SIZE;
const fontSize =
parseInt(options.themeVariables?.fontSize ?? "") || DEFAULT_FONT_SIZE;
const { getGroupIds, getParentId } = computeGroupIds(graph);

// SubGraphs
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export interface MermaidConfig {
};
/**
* Theme variables
* @default { fontSize: "25px" }
*/
themeVariables?: {
fontSize?: number;
fontSize?: string;
};
/**
* Maximum number of edges to be rendered.
Expand All @@ -44,7 +45,8 @@ const parseMermaidToExcalidraw = async (
const excalidrawElements = graphToExcalidraw(parsedMermaidData, {
themeVariables: {
...mermaidConfig.themeVariables,
fontSize: mermaidConfig.themeVariables?.fontSize || DEFAULT_FONT_SIZE,
fontSize:
mermaidConfig.themeVariables?.fontSize || `${DEFAULT_FONT_SIZE}px`,
},
});
return excalidrawElements;
Expand Down

0 comments on commit c7cfd67

Please sign in to comment.