{"id":26319005,"url":"https://github.com/newmo-oss/mermaid-viewer","last_synced_at":"2025-03-15T15:17:16.801Z","repository":{"id":230635968,"uuid":"779860690","full_name":"newmo-oss/mermaid-viewer","owner":"newmo-oss","description":"User Friendly Mermaid Diagram Viewer.","archived":false,"fork":false,"pushed_at":"2025-03-15T09:23:49.000Z","size":26448,"stargazers_count":37,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-15T10:25:17.286Z","etag":null,"topics":["dialog","mermaid","sequence","viewer","zoom"],"latest_commit_sha":null,"homepage":"https://newmo-oss.github.io/mermaid-viewer/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/newmo-oss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"azu"}},"created_at":"2024-03-31T01:30:52.000Z","updated_at":"2025-03-15T09:23:52.000Z","dependencies_parsed_at":"2024-04-13T00:36:11.925Z","dependency_job_id":"fc0c2aa5-c9b2-4e01-b69e-02b8b795f08f","html_url":"https://github.com/newmo-oss/mermaid-viewer","commit_stats":null,"previous_names":["azu/it-mermaid-viewer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmo-oss%2Fmermaid-viewer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmo-oss%2Fmermaid-viewer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmo-oss%2Fmermaid-viewer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/newmo-oss%2Fmermaid-viewer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/newmo-oss","download_url":"https://codeload.github.com/newmo-oss/mermaid-viewer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243746243,"owners_count":20341204,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dialog","mermaid","sequence","viewer","zoom"],"created_at":"2025-03-15T15:17:16.225Z","updated_at":"2025-03-15T15:17:16.791Z","avatar_url":"https://github.com/newmo-oss.png","language":"TypeScript","funding_links":["https://github.com/sponsors/azu"],"categories":[],"sub_categories":[],"readme":"# @newmo-oss/mermaid-viewer\n\nUser Friendly [Mermaid](https://mermaid.js.org/) Diagram Viewer.\n\n## WebSite\n\n- \u003chttps://newmo-oss.github.io/mermaid-viewer/\u003e\n\n## Motivation\n\nMermaid is a great tool for creating diagrams.\nHowever, it is hard to read large diagrams because the default viewer does not support interactive features like zooming in/out.\n\n[@newmo-oss/mermaid-viewer](https://newmo-oss.github.io/mermaid-viewer/) is a user-friendly Mermaid diagram viewer that supports interactive features like zooming in/out and step-by-step sequence viewing.\n\nhttps://github.com/newmo-oss/mermaid-viewer/assets/19714/9b78b1fc-0b74-4233-948d-ff46f484bbe8\n\n## Features\n\n- Interactive controller for [Sequence diagrams](https://mermaid.js.org/syntax/sequenceDiagram.html)\n  - Enable `autonumber` option by default\n- Zoom in/out\n- Support embed as iframe into your site\n  - `?text=\u003curl-encoded-mermaid-text\u003e` query parameter\n\n## Usage\n\n1. Visit \u003chttps://newmo-oss.github.io/mermaid-viewer/\u003e\n2. Write Mermaid text\n3. Render\n4. Share it!\n\n## URL Parameters/Hash\n\n[@newmo-oss/mermaid-viewer](https://newmo-oss.github.io/mermaid-viewer/) support query parameters.\n\n- `?sequence-number=\u003cnumber\u003e`: Start sequence number\n- `#\u003curl-encoded-mermaid-text\u003e`: Embed Mermaid text\n  - e.g. `?text=encodeURIComponent('sequenceDiagram\\nA-\u003e\u003eB: Hello')`\n  - Note: @newmo-oss/mermaid-viewer compress Mermaid text by [DEFLATE](https://www.rfc-editor.org/rfc/rfc1951).\n  - Allow you to use url-encoded text for passing data, but it will be compressed and rewrite the hash.\n\n### Example\n\nPass your Mermaid text by URL parameters.\n\n```\n// encodeURIComponent('sequenceDiagram\\nA-\u003e\u003eB: Hello')\nhttps://newmo-oss.github.io/mermaid-viewer/?sequence-number=10#sequenceDiagram%0AA-%3E%3EB%3A%20Hello\n```\n\n## GitHub Actions Integration\n\nIf you commit mermaid text to your repository, you can add a link to the @newmo-oss/mermaid-viewer to the PR.\n\n```yaml\nname: mermaid-viewer-notice\non:\n  pull_request:\n    paths:\n      - '**/*.md'\npermissions:\n  contents: read\njobs:\n  mermaid-viewer-notice:\n    name: Add Mermaid Viewer Link to PR\n    runs-on: ubuntu-latest\n    steps:\n      - name: checkout\n        uses: actions/checkout@v4\n      - name: setup Node.js\n        uses: actions/setup-node@v4\n        with:\n          node-version: '20'\n      - name: Get changed files\n        id: changed-files\n        uses: tj-actions/changed-files@20576b4b9ed46d41e2d45a2256e5e2316dde6834\n        with:\n          separator: \",\"\n          files: |\n            **/*.md\n      - name: Show changed files\n        run: echo \"${{ steps.changed-files.outputs.all_changed_files }}\"\n      - name: Add notice to PR\n        uses: actions/github-script@v7\n        with:\n          script: |\n            const fs = require(\"node:fs/promises\");\n            const positionals = process.env.CHANGED_FILES.split(\",\").filter(Boolean);\n            const fileContents = await Promise.all(positionals.map(async (file) =\u003e {\n                return {\n                    name: file,\n                    content: await fs.readFile(file, 'utf-8')\n                }\n            }));\n            const compress = async (target) =\u003e {\n                const arrayBufferToBinaryString = (arrayBuffer) =\u003e {\n                    const bytes = new Uint8Array(arrayBuffer);\n                    let binaryString = \"\";\n                    for (let i = 0; i \u003c bytes.byteLength; i++) {\n                        binaryString += String.fromCharCode(bytes[i]);\n                    }\n                    return binaryString;\n                };\n                const blob = new Blob([target]);\n                const stream = blob.stream();\n                const compressedStream = stream.pipeThrough(\n                    new CompressionStream(\"deflate\")\n                );\n                const buf = await new Response(compressedStream).arrayBuffer();\n                const binaryString = arrayBufferToBinaryString(buf);\n                return btoa(binaryString);\n            };\n            for (const fileContent of fileContents) {\n                const { content } = fileContent;\n                const mermaidCodes = content.matchAll(/```mermaid([\\s\\S]*?)```/g);\n                for (const mermaidCode of mermaidCodes) {\n                    const mermaidText = mermaidCode[1];\n                    const compressed = await compress(mermaidText);\n                    const startLine = content.slice(0, mermaidCode.index).split(\"\\n\").length;\n                    const endLine = content.slice(0, mermaidCode.index + mermaidCode[0].length).split(\"\\n\").length;\n                    console.log(`file: ${fileContent.name}, startColumn: ${mermaidCode.index}, endColumn: ${mermaidCode.index + mermaidCode[0].length}, startLine: ${startLine}, endLine: ${endLine}`);\n                    core.summary.addCodeBlock(`${mermaidText}`, 'mermaid');\n                    core.summary.addLink('Mermaid Viewer', `https://newmo-oss.github.io/mermaid-viewer/#${compressed}`);\n                    core.summary.addSeparator();\n                    core.summary.write({overwrite: true})\n                    core.notice(`https://newmo-oss.github.io/mermaid-viewer/#${compressed}`, { title: \"Mermaid Viewer\", file: fileContent.name, startLine, endLine });\n                }\n            }\n        env:\n          CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}\n```\n\n\n## Changelog\n\nSee [Releases page](https://github.com/newmo-oss/mermaid-viewer/releases).\n\n## Running tests\n\nInstall devDependencies and Run `npm test`:\n\n    npm test\n\n## Contributing\n\nPull requests and stars are always welcome.\n\nFor bugs and feature requests, [please create an issue](https://github.com/newmo-oss/mermaid-viewer/issues).\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n## License\n\nMIT © newmo, Inc.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewmo-oss%2Fmermaid-viewer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnewmo-oss%2Fmermaid-viewer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewmo-oss%2Fmermaid-viewer/lists"}