@cocoar/vue-markdown-mermaid 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/registry.d.ts +14 -0
- package/dist/registry.d.ts.map +1 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @cocoar/vue-markdown-mermaid
|
|
2
|
+
|
|
3
|
+
The thin adapter that plugs [`@cocoar/vue-mermaid`](../mermaid)'s diagram renderer
|
|
4
|
+
into [`@cocoar/vue-markdown`](../markdown) as a **fenced-code-block renderer**, so
|
|
5
|
+
` ```mermaid ` blocks render as diagrams.
|
|
6
|
+
|
|
7
|
+
This package is **only** the markdown integration (the fence registry). The
|
|
8
|
+
diagram component, its theming and zoom/pan live in the standalone,
|
|
9
|
+
markdown-free `@cocoar/vue-mermaid` — import `CoarMermaidDiagram` from there to
|
|
10
|
+
render diagrams outside of markdown.
|
|
11
|
+
|
|
12
|
+
The markdown packages have **no dependency on Mermaid**. Installing this package
|
|
13
|
+
and registering it is the opt-in; a consumer that doesn't opt in still sees a
|
|
14
|
+
readable, syntax-highlighted code block. The markdown stays portable.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add @cocoar/vue-markdown-mermaid
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`vue` and `@cocoar/vue-markdown` are peer dependencies; `@cocoar/vue-mermaid`
|
|
23
|
+
(which carries Mermaid) comes along as a regular dependency. Import its
|
|
24
|
+
stylesheet once:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import '@cocoar/vue-mermaid/styles';
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
Pass the ready-made registry fragment to the viewer's `fenceRenderers` prop:
|
|
33
|
+
|
|
34
|
+
```vue
|
|
35
|
+
<template>
|
|
36
|
+
<CoarMarkdown :doc="doc" :fence-renderers="mermaidFenceRenderers" />
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script setup lang="ts">
|
|
40
|
+
import { parse } from '@cocoar/vue-markdown-core';
|
|
41
|
+
import { CoarMarkdown } from '@cocoar/vue-markdown';
|
|
42
|
+
import { mermaidFenceRenderers } from '@cocoar/vue-markdown-mermaid';
|
|
43
|
+
|
|
44
|
+
const doc = parse(source);
|
|
45
|
+
</script>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
An app-wide default works too — `app.provide(MARKDOWN_FENCE_RENDERERS_KEY, mermaidFenceRenderers)`.
|
|
49
|
+
A per-instance `fence-renderers` prop wins over the provided value.
|
|
50
|
+
|
|
51
|
+
## Zoom & pan
|
|
52
|
+
|
|
53
|
+
The fence-renderer contract only passes `{ code, language }` to a component, so
|
|
54
|
+
per-diagram options are configured on the **registry** via
|
|
55
|
+
`createMermaidFenceRenderers`:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { createMermaidFenceRenderers } from '@cocoar/vue-markdown-mermaid';
|
|
59
|
+
|
|
60
|
+
const fenceRenderers = createMermaidFenceRenderers({ zoomable: true });
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
See [`@cocoar/vue-mermaid`](../mermaid) for the zoom/pan controls and behaviour.
|
|
64
|
+
|
|
65
|
+
## Registering your own fence renderer
|
|
66
|
+
|
|
67
|
+
The registry is open — any language can map to any component. Register your own
|
|
68
|
+
alongside Mermaid, or replace it:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import type { FenceRegistry } from '@cocoar/vue-markdown';
|
|
72
|
+
import { mermaidFenceRenderers } from '@cocoar/vue-markdown-mermaid';
|
|
73
|
+
import MyGraphviz from './MyGraphviz.vue';
|
|
74
|
+
|
|
75
|
+
const fenceRenderers: FenceRegistry = { ...mermaidFenceRenderers, dot: MyGraphviz };
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Exports
|
|
79
|
+
|
|
80
|
+
| Export | Description |
|
|
81
|
+
| --- | --- |
|
|
82
|
+
| `mermaidFenceRenderers` | Ready-to-spread `FenceRegistry` fragment (`{ mermaid }`), no zoom. |
|
|
83
|
+
| `createMermaidFenceRenderers(options?)` | Build a registry with options baked in — `{ zoomable }`. |
|
|
84
|
+
| `MermaidFenceOptions` | The options type. |
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@cocoar/vue-markdown-mermaid` — the thin adapter that plugs
|
|
3
|
+
* `@cocoar/vue-mermaid`'s diagram renderer into `@cocoar/vue-markdown` as a
|
|
4
|
+
* fenced-code-block renderer, so ` ```mermaid ` blocks render as diagrams.
|
|
5
|
+
*
|
|
6
|
+
* This package is ONLY the markdown integration (the fence registry). The
|
|
7
|
+
* diagram component itself, its theming and zoom/pan live in the standalone,
|
|
8
|
+
* markdown-free `@cocoar/vue-mermaid` — import `CoarMermaidDiagram` from there to
|
|
9
|
+
* render diagrams outside of markdown.
|
|
10
|
+
*
|
|
11
|
+
* Registering it is the opt-in; a fence with no registered renderer stays a
|
|
12
|
+
* readable code block, so the markdown stays portable.
|
|
13
|
+
*/
|
|
14
|
+
export { createMermaidFenceRenderers, mermaidFenceRenderers, type MermaidFenceOptions, } from './registry';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineComponent as e, h as t } from "vue";
|
|
2
|
+
import { CoarMermaidDiagram as n } from "@cocoar/vue-mermaid";
|
|
3
|
+
//#region src/registry.ts
|
|
4
|
+
function r(r = {}) {
|
|
5
|
+
return { mermaid: e({
|
|
6
|
+
name: "CoarMermaidFence",
|
|
7
|
+
props: {
|
|
8
|
+
code: {
|
|
9
|
+
type: String,
|
|
10
|
+
required: !0
|
|
11
|
+
},
|
|
12
|
+
language: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: "mermaid"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
setup(e) {
|
|
18
|
+
return () => t(n, {
|
|
19
|
+
code: e.code,
|
|
20
|
+
language: e.language,
|
|
21
|
+
zoomable: r.zoomable ?? !1
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}) };
|
|
25
|
+
}
|
|
26
|
+
var i = r();
|
|
27
|
+
//#endregion
|
|
28
|
+
export { r as createMermaidFenceRenderers, i as mermaidFenceRenderers };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FenceRegistry } from '@cocoar/vue-markdown';
|
|
2
|
+
export interface MermaidFenceOptions {
|
|
3
|
+
/** Enable wheel-zoom + drag-pan + double-click-reset on every diagram. */
|
|
4
|
+
zoomable?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Build a `FenceRegistry` mapping the `mermaid` language to a diagram renderer
|
|
8
|
+
* configured with `options`. The wrapper forwards the fence's `{ code, language }`
|
|
9
|
+
* and applies the baked-in options.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createMermaidFenceRenderers(options?: MermaidFenceOptions): FenceRegistry;
|
|
12
|
+
/** Zero-config default: renders ```mermaid blocks, no pan/zoom. */
|
|
13
|
+
export declare const mermaidFenceRenderers: FenceRegistry;
|
|
14
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,mBAAwB,GAAG,aAAa,CAkB5F;AAED,mEAAmE;AACnE,eAAO,MAAM,qBAAqB,EAAE,aAA6C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cocoar/vue-markdown-mermaid",
|
|
3
|
+
"version": "2.14.0",
|
|
4
|
+
"description": "Thin adapter that registers @cocoar/vue-mermaid as a `mermaid` fenced-code-block renderer for @cocoar/vue-markdown, so ```mermaid blocks render as diagrams. The markdown packages have no dependency on Mermaid — installing this package is the opt-in.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/cocoar-dev/cocoar-ui-vue.git",
|
|
9
|
+
"directory": "packages/markdown-mermaid"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://docs.cocoar.dev/cocoar-ui-vue/",
|
|
12
|
+
"bugs": "https://github.com/cocoar-dev/cocoar-ui-vue/issues",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"vue",
|
|
15
|
+
"vue3",
|
|
16
|
+
"markdown",
|
|
17
|
+
"mermaid",
|
|
18
|
+
"diagram"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"module": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "vite build",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"lint": "eslint src/",
|
|
38
|
+
"typecheck": "vue-tsc --noEmit"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@cocoar/vue-mermaid": "2.14.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@cocoar/vue-markdown": "2.14.0",
|
|
45
|
+
"vue": "^3.5.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@cocoar/vue-markdown": "workspace:*",
|
|
49
|
+
"vue": "^3.5.32"
|
|
50
|
+
}
|
|
51
|
+
}
|