diff --git a/components.d.ts b/components.d.ts index a9b2d776..5fbe4e72 100644 --- a/components.d.ts +++ b/components.d.ts @@ -179,7 +179,6 @@ declare module '@vue/runtime-core' { IconMdiEye: typeof import('~icons/mdi/eye')['default'] IconMdiEyeOff: typeof import('~icons/mdi/eye-off')['default'] IconMdiHeart: typeof import('~icons/mdi/heart')['default'] - IconMdiRefresh: typeof import('~icons/mdi/refresh')['default'] IconMdiSearch: typeof import('~icons/mdi/search')['default'] IconMdiTranslate: typeof import('~icons/mdi/translate')['default'] IconMdiTriangleDown: typeof import('~icons/mdi/triangle-down')['default'] @@ -260,7 +259,7 @@ declare module '@vue/runtime-core' { MenuBarItem: typeof import('./src/tools/html-wysiwyg-editor/editor/menu-bar-item.vue')['default'] MenuIconItem: typeof import('./src/components/MenuIconItem.vue')['default'] MenuLayout: typeof import('./src/components/MenuLayout.vue')['default'] - MermaidPreviewer: typeof import('./src/tools/mermaid-previewer/mermaid-previewer.vue')['default'] + MermaidExporter: typeof import('./src/tools/mermaid-exporter/mermaid-exporter.vue')['default'] MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default'] MicTester: typeof import('./src/tools/mic-tester/mic-tester.vue')['default'] MimeConverter: typeof import('./src/tools/mime-converter/mime-converter.vue')['default'] @@ -270,19 +269,14 @@ declare module '@vue/runtime-core' { MorseConverter: typeof import('./src/tools/morse-converter/morse-converter.vue')['default'] MultiLinkDownloader: typeof import('./src/tools/multi-link-downloader/multi-link-downloader.vue')['default'] MyIp: typeof import('./src/tools/my-ip/my-ip.vue')['default'] - NA: typeof import('naive-ui')['NA'] NanoidGenerator: typeof import('./src/tools/nanoid-generator/nanoid-generator.vue')['default'] NanoMemo: typeof import('./src/tools/nano-memo/nano-memo.vue')['default'] 'NanoMemo.content': typeof import('./src/tools/nano-memo/nano-memo.content.md')['default'] NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default'] NButton: typeof import('naive-ui')['NButton'] - NCard: typeof import('naive-ui')['NCard'] - NCheckbox: typeof import('naive-ui')['NCheckbox'] NCode: typeof import('naive-ui')['NCode'] NCollapseTransition: typeof import('naive-ui')['NCollapseTransition'] - NColorPicker: typeof import('naive-ui')['NColorPicker'] NConfigProvider: typeof import('naive-ui')['NConfigProvider'] - NDatePicker: typeof import('naive-ui')['NDatePicker'] NDivider: typeof import('naive-ui')['NDivider'] NEllipsis: typeof import('naive-ui')['NEllipsis'] NFormItem: typeof import('naive-ui')['NFormItem'] @@ -290,22 +284,13 @@ declare module '@vue/runtime-core' { NH1: typeof import('naive-ui')['NH1'] NH3: typeof import('naive-ui')['NH3'] NIcon: typeof import('naive-ui')['NIcon'] - NImage: typeof import('naive-ui')['NImage'] NInputNumber: typeof import('naive-ui')['NInputNumber'] NLayout: typeof import('naive-ui')['NLayout'] NLayoutSider: typeof import('naive-ui')['NLayoutSider'] NMenu: typeof import('naive-ui')['NMenu'] - NModal: typeof import('naive-ui')['NModal'] - NP: typeof import('naive-ui')['NP'] - NProgress: typeof import('naive-ui')['NProgress'] - NRate: typeof import('naive-ui')['NRate'] NScrollbar: typeof import('naive-ui')['NScrollbar'] - NSlider: typeof import('naive-ui')['NSlider'] NSpace: typeof import('naive-ui')['NSpace'] NSwitch: typeof import('naive-ui')['NSwitch'] - NTable: typeof import('naive-ui')['NTable'] - NTag: typeof import('naive-ui')['NTag'] - NTimePicker: typeof import('naive-ui')['NTimePicker'] NumberInput: typeof import('./src/tools/pomodoro-timer/app/components/NumberInput.vue')['default'] NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default'] OcrImage: typeof import('./src/tools/ocr-image/ocr-image.vue')['default'] diff --git a/package.json b/package.json index c98d734b..94e9a4ed 100644 --- a/package.json +++ b/package.json @@ -202,6 +202,7 @@ "mathjs": "^14.2.1", "md-editor-v3": "^4.21.3", "memorystream": "^0.3.1", + "mermaid": "^11.6.0", "mime-types": "^2.1.35", "mitex-wasm": "^0.2.5", "moment": "^2.30.1", @@ -267,7 +268,6 @@ "vue-i18n": "^9.14.3", "vue-markdown-render": "^2.2.1", "vue-mathjax-next": "^0.0.6", - "vue-mermaid-string": "^7.0.0", "vue-router": "^4.1.6", "vue-shadow-dom": "^4.2.0", "vue-tsc": "^1.8.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c033da18..7a5b558d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -503,6 +503,9 @@ dependencies: memorystream: specifier: ^0.3.1 version: 0.3.1 + mermaid: + specifier: ^11.6.0 + version: 11.6.0 mime-types: specifier: ^2.1.35 version: 2.1.35 @@ -698,9 +701,6 @@ dependencies: vue-mathjax-next: specifier: ^0.0.6 version: 0.0.6 - vue-mermaid-string: - specifier: ^7.0.0 - version: 7.0.0 vue-router: specifier: ^4.1.6 version: 4.1.6(vue@3.3.4) @@ -18095,16 +18095,6 @@ packages: resolution: {integrity: sha512-H4nZ8t31TmBJgiR6pHrOGz+RWhlw34d0yhD8fi8CnXoGOydGFreNH/Crd/9Jfd2IMSu/I0AC3ymT9D09JRMIrw==} dev: false - /vue-mermaid-string@7.0.0: - resolution: {integrity: sha512-bpOXTO6ppZ/hwHOkKJOUhRI98i5xZmroDXmyBSnUJC2IO1IsXZJE0EL+YleDs5EtuOH25Db4m7OVVkFgQaLYqg==} - engines: {node: '>=18'} - dependencies: - mermaid: 11.6.0 - nanoid: 5.0.9 - transitivePeerDependencies: - - supports-color - dev: false - /vue-router@4.1.6(vue@3.3.4): resolution: {integrity: sha512-DYWYwsG6xNPmLq/FmZn8Ip+qrhFEzA14EI12MsMgVxvHFDYvlr4NXpVF5hrRH1wVcDP8fGi5F4rxuJSl8/r+EQ==} peerDependencies: diff --git a/src/tools/mermaid-exporter/index.ts b/src/tools/mermaid-exporter/index.ts new file mode 100644 index 00000000..abac5500 --- /dev/null +++ b/src/tools/mermaid-exporter/index.ts @@ -0,0 +1,14 @@ +import { Markdown } from '@vicons/tabler'; +import { defineTool } from '../tool'; + +export const tool = defineTool({ + name: 'Mermaid exporter', + path: '/mermaid-exporter', + description: 'Convert Markdown (Mermaid) to image and allow to export to PNG, JPG & SVG', + keywords: ['mermaid', 'exporter', 'markdown', 'MD'], + component: () => import('./mermaid-exporter.vue'), + icon: Markdown, + createdAt: new Date('2025-04-11'), + category: 'Text', + redirectFrom: ['/mermaid-previewer'], +}); diff --git a/src/tools/mermaid-exporter/mermaid-exporter.e2e.spec.ts b/src/tools/mermaid-exporter/mermaid-exporter.e2e.spec.ts new file mode 100644 index 00000000..f8850f92 --- /dev/null +++ b/src/tools/mermaid-exporter/mermaid-exporter.e2e.spec.ts @@ -0,0 +1,39 @@ +import { expect, test } from '@playwright/test'; + +test.describe('Mermaid Diagram Renderer', () => { + test.beforeEach(async ({ page }) => { + await page.goto('/mermaid-exporter'); + }); + + test('should render the initial diagram', async ({ page }) => { + const diagramContainer = page.locator('.diagram-container svg'); + await expect(diagramContainer).toBeVisible(); + await expect(diagramContainer).toHaveAttribute('xmlns', 'http://www.w3.org/2000/svg'); + }); + + test('should update diagram when user edits Mermaid code', async ({ page }) => { + const input = page.getByLabel('Your Mermaid to convert:'); + const updatedMermaid = ` + graph LR + X[Start] --> Y{Working?} + Y -- Yes --> Z[Success!] + Y -- No --> W[Fix again!] + `; + await input.fill(updatedMermaid); + await page.waitForTimeout(500); + + const svg = page.locator('.diagram-container svg'); + await expect(svg).toContainText('Start'); + await expect(svg).toContainText('Success!'); + }); + + test('should allow exporting in SVG, PNG, and JPG', async ({ page }) => { + const formats = ['svg', 'png', 'jpg']; + + for (const format of formats) { + const button = page.getByRole('button', { name: new RegExp(`Export as ${format}`, 'i') }); + await expect(button).toBeVisible(); + await button.click(); + } + }); +}); diff --git a/src/tools/mermaid-exporter/mermaid-exporter.vue b/src/tools/mermaid-exporter/mermaid-exporter.vue new file mode 100644 index 00000000..9461d99a --- /dev/null +++ b/src/tools/mermaid-exporter/mermaid-exporter.vue @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + Export as PNG + + + Export as JPG + + + Export as SVG + + + + + + diff --git a/src/tools/mermaid-previewer/index.ts b/src/tools/mermaid-previewer/index.ts deleted file mode 100644 index 740b8f94..00000000 --- a/src/tools/mermaid-previewer/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ChartPie } from '@vicons/tabler'; -import { defineTool } from '../tool'; - -export const tool = defineTool({ - name: 'Mermaid previewer', - path: '/mermaid-previewer', - description: 'Mermaid Diagrams Previewer', - keywords: ['mermaid', 'diagrams', 'previewer'], - component: () => import('./mermaid-previewer.vue'), - icon: ChartPie, - createdAt: new Date('2025-03-09'), - category: 'Text', -}); diff --git a/src/tools/mermaid-previewer/mermaid-previewer.vue b/src/tools/mermaid-previewer/mermaid-previewer.vue deleted file mode 100644 index 2ee137ba..00000000 --- a/src/tools/mermaid-previewer/mermaid-previewer.vue +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/tools/mermaid-previewer/vue-mermaid-string.d.ts b/src/tools/mermaid-previewer/vue-mermaid-string.d.ts deleted file mode 100644 index 945dc910..00000000 --- a/src/tools/mermaid-previewer/vue-mermaid-string.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module "vue-mermaid-string" { - -} \ No newline at end of file