-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
172 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
"version": "0.0.0", | ||
"type": "module", | ||
"private": true, | ||
"packageManager": "[email protected].38", | ||
"packageManager": "[email protected].43", | ||
"workspaces": [ | ||
"nodepkg/*", | ||
"nodedevpkg/*" | ||
|
@@ -26,10 +26,11 @@ | |
"@innoai-tech/lodash": "^0.2.5", | ||
"@innoai-tech/vuekit": "workspace:*", | ||
"@innoai-tech/vueuikit": "workspace:*", | ||
"mermaid": "^11.4.1", | ||
"rxjs": "^7.8.1" | ||
}, | ||
"devDependencies": { | ||
"@happy-dom/global-registrator": "^15.11.7", | ||
"@happy-dom/global-registrator": "^16.5.3", | ||
"@innoai-tech/config": "^0.5.7", | ||
"@innoai-tech/devconfig": "^0.5.0", | ||
"@innoai-tech/monobundle": "^0.14.6", | ||
|
@@ -39,17 +40,17 @@ | |
"@vue/test-utils": "^2.4.6", | ||
"bun-types": "latest", | ||
"copy-to-clipboard": "^3.3.3", | ||
"core-js": "^3.39.0", | ||
"core-js": "^3.40.0", | ||
"normalize.css": "^8.0.1", | ||
"prettier": "^3.4.2", | ||
"turbo": "^2.3.3", | ||
"typescript": "^5.7.2", | ||
"vite": "^6.0.3", | ||
"typescript": "^5.7.3", | ||
"vite": "^6.0.7", | ||
"vue": "^3.5.13" | ||
}, | ||
"resolutions": { | ||
"vite": "^6.0.3", | ||
"vue": "^3.5.13", | ||
"rollup": "^4.20.0" | ||
"rollup": "^4.30.1", | ||
"vite": "^6.0.7", | ||
"vue": "^3.5.13" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { styled } from "@innoai-tech/vueuikit"; | ||
import type { VNodeChild } from "vue"; | ||
import { component$, observableRef, rx, subscribeOnMountedUntilUnmount } from "@innoai-tech/vuekit"; | ||
// @ts-ignore | ||
import mermaid from "mermaid/dist/mermaid.esm.mjs"; | ||
import { EMPTY, from, switchMap } from "rxjs"; | ||
|
||
export const PreWithMermaid = styled<{ | ||
$default?: VNodeChild | ||
}, "pre">("pre", ({}, { slots }) => { | ||
return (Root) => { | ||
const children = slots.default?.(); | ||
const child = children?.[0]; | ||
|
||
if (child && (child as any).props.className === "language-mermaid") { | ||
return <Mermaid code={(child as any).children} />; | ||
} | ||
|
||
return ( | ||
<Root> | ||
{children} | ||
</Root> | ||
); | ||
}; | ||
})({}); | ||
|
||
|
||
const Mermaid = component$<{ | ||
code: string | ||
}>((props, {}) => { | ||
const $el = observableRef(null); | ||
|
||
mermaid.initialize({}); | ||
|
||
rx( | ||
$el, | ||
switchMap((el) => { | ||
if (el) { | ||
return from(mermaid.run({ nodes: [el] })); | ||
} | ||
return EMPTY; | ||
}), | ||
subscribeOnMountedUntilUnmount() | ||
); | ||
|
||
return () => { | ||
return ( | ||
<MermaidContainer ref={$el} class={"mermaid"}> | ||
{props.code} | ||
</MermaidContainer> | ||
); | ||
}; | ||
}); | ||
|
||
const MermaidContainer = styled("div")({ | ||
"& > svg": { | ||
minWidth: "80%" | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters