Skip to content

Commit

Permalink
Merge branch 'develop' into fix/1423
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 authored Apr 5, 2024
2 parents 3613b41 + 0e6c022 commit 29b9188
Show file tree
Hide file tree
Showing 6 changed files with 1,063 additions and 403 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/diagramUpdate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ A & B & C & D & E --> F & G & K & Z & i`);
});

it('supports commenting code out/in', () => {
cy.get('#editor').contains('Car').click();
cy.get('#editor').contains('Car').click({ force: true });
cy.get('#editor').get('textarea').type(`${cmd}/`, { force: true });
cy.get('#view').contains('Car').should('not.exist');

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"devDependencies": {
"@cypress/snapshot": "2.1.7",
"@sveltejs/adapter-static": "3.0.1",
"@sveltejs/kit": "2.5.4",
"@sveltejs/kit": "2.5.5",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@testing-library/svelte": "4.1.0",
"@types/lodash-es": "^4.17.12",
Expand Down Expand Up @@ -69,6 +69,7 @@
"vitest-dom": "^0.1.1"
},
"dependencies": {
"@mermaid-js/mermaid-zenuml": "^0.2.0",
"daisyui": "2.52.0",
"dayjs": "^1.11.7",
"js-base64": "3.7.7",
Expand Down
29 changes: 27 additions & 2 deletions src/lib/components/Preset.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,30 @@
C --> db
D --> C
style m fill:#d6d,stroke:#333,stroke-width:4px
`,
ZenUML: `zenuml
title Order Service
@Actor Client #FFEBE6
@Boundary OrderController #0747A6
@EC2 <<BFF>> OrderService #E3FCEF
group BusinessService {
@Lambda PurchaseService
@AzureFunction InvoiceService
}
@Starter(Client)
// \`POST /orders\`
OrderController.post(payload) {
OrderService.create(payload) {
order = new Order(payload)
if(order != null) {
par {
PurchaseService.createPO(order)
InvoiceService.createInvoice(order)
}
}
}
}
`
};
Expand All @@ -154,7 +178,7 @@
};
// Adding in this array will add an icon to the preset menu
const newDiagrams: SampleTypes[] = ['QuadrantChart', 'XYChart', 'Block'];
const newDiagrams: SampleTypes[] = ['QuadrantChart', 'XYChart', 'Block', 'ZenUML'];
const diagramOrder: SampleTypes[] = [
'Flow',
'Sequence',
Expand All @@ -168,7 +192,8 @@
'Mindmap',
'QuadrantChart',
'XYChart',
'Block'
'Block',
'ZenUML'
];
</script>

Expand Down
10 changes: 7 additions & 3 deletions src/lib/util/fileLoaders/gist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { addHistoryEntry } from '$lib/components/History/history';
import type { State } from '$lib/types';
import { defaultState } from '$lib/util/state';
import { addHistoryEntry } from '$lib/components/History/history';
import { fetchJSON, fetchText } from '$lib/util/util';

const codeFileName = 'code.mmd';
Expand Down Expand Up @@ -102,8 +102,12 @@ export const loadGistData = async (gistURL: string): Promise<State> => {
);
const gistHistory: GistData[] = [];
for (const entry of history) {
const data: GistData | undefined = await getGistData(entry.url).catch();
data && gistHistory.push(data);
try {
const data: GistData = await getGistData(entry.url);
gistHistory.push(data);
} catch (error) {
console.error(error);
}
}
if (gistHistory.length === 0) {
throw new Error('Invalid gist provided');
Expand Down
5 changes: 5 additions & 0 deletions src/lib/util/mermaid.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import mermaid from 'mermaid';
import type { MermaidConfig, RenderResult } from 'mermaid';
import zenuml from '@mermaid-js/mermaid-zenuml';

const init = mermaid.registerExternalDiagrams([zenuml]);

export const render = async (
config: MermaidConfig,
code: string,
id: string
): Promise<RenderResult> => {
await init;

// Should be able to call this multiple times without any issues.
mermaid.initialize(config);
return await mermaid.render(id, code);
Expand Down
Loading

0 comments on commit 29b9188

Please sign in to comment.