mirror of
https://github.com/zadam/trilium.git
synced 2026-03-22 08:13:46 +01:00
feat(mermaid): replace note content on switch
This commit is contained in:
parent
72038fb2ec
commit
4134c4ddd0
@ -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>
|
||||
|
||||
@ -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}
|
||||
/>
|
||||
|
||||
@ -10,7 +10,7 @@ flowchart TD
|
||||
C -->|One| D[Laptop]
|
||||
C -->|Two| E[iPhone]
|
||||
C -->|Three| F[fa:fa-car Car]
|
||||
`
|
||||
`
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user