feat(mermaid): replace note content on switch

This commit is contained in:
Elian Doran 2026-03-14 09:29:28 +02:00
parent 72038fb2ec
commit 4134c4ddd0
No known key found for this signature in database
3 changed files with 11 additions and 3 deletions

View File

@ -1,5 +1,7 @@
import "./NoteContentSwitcher.css";
import FNote from "../../entities/fnote";
import server from "../../services/server";
import { Badge } from "../react/Badge";
export interface NoteContentTemplate {
@ -8,16 +10,22 @@ export interface NoteContentTemplate {
}
interface NoteContentSwitcherProps {
note: FNote;
templates: NoteContentTemplate[];
}
export default function NoteContentSwitcher({ templates }: NoteContentSwitcherProps) {
export default function NoteContentSwitcher({ note, templates }: NoteContentSwitcherProps) {
return (
<div className="note-content-switcher">
{templates.map(sample => (
<Badge
key={sample.name}
text={sample.name}
onClick={async () => {
await server.put(`notes/${note.noteId}/data`, {
content: sample.content
});
}}
/>
))}
</div>

View File

@ -34,7 +34,7 @@ export default function Mermaid(props: TypeWidgetProps) {
renderSvg={renderSvg}
noteType="mermaid"
extraContent={(
<NoteContentSwitcher templates={SAMPLE_DIAGRAMS} />
<NoteContentSwitcher note={props.note} templates={SAMPLE_DIAGRAMS} />
)}
{...props}
/>

View File

@ -10,7 +10,7 @@ flowchart TD
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[fa:fa-car Car]
`
`
}
];