Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(mermaid): use custom placeholder
Elian Doran5f1486cf6a90
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 7a91c831af..4b1baa0d53 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2204,6 +2204,7 @@"more_info": "Learn more"},"mermaid": {+ "placeholder": "Type the content of your Mermaid diagram or use one of the sample diagrams below.","sample_diagrams": "Sample diagrams:","sample_flowchart": "Flowchart","sample_class": "Class",diff --git a/apps/client/src/widgets/layout/NoteContentSwitcher.tsx b/apps/client/src/widgets/layout/NoteContentSwitcher.tsxindex c018d84ac9..a47ff308b6 100644--- a/apps/client/src/widgets/layout/NoteContentSwitcher.tsx+++ b/apps/client/src/widgets/layout/NoteContentSwitcher.tsx@@ -19,7 +19,7 @@ interface NoteContentSwitcherProps {export default function NoteContentSwitcher({ text, note, templates }: NoteContentSwitcherProps) {const blob = useNoteSavedData(note?.noteId);- return (blob?.length === 0 &&+ return (blob?.trim().length === 0 &&<div className="note-content-switcher">{text}{" "}diff --git a/apps/client/src/widgets/type_widgets/code/Code.tsx b/apps/client/src/widgets/type_widgets/code/Code.tsxindex 3c12a8036b..f59d6eff3c 100644--- a/apps/client/src/widgets/type_widgets/code/Code.tsx+++ b/apps/client/src/widgets/type_widgets/code/Code.tsx@@ -30,6 +30,7 @@ export interface EditableCodeProps extends TypeWidgetProps, Omit<CodeEditorPropsonContentChanged?: (content: string) => void;/** Invoked after the content of the note has been uploaded to the server, using a spaced update. */dataSaved?: () => void;+ placeholder?: string;}export function ReadOnlyCode({ note, viewScope, ntxId, parentComponent }: TypeWidgetProps) {@@ -74,7 +75,7 @@ function formatViewSource(note: FNote, content: string) {return content;}-export function EditableCode({ note, ntxId, noteContext, debounceUpdate, parentComponent, updateInterval, noteType = "code", onContentChanged, dataSaved, ...editorProps }: EditableCodeProps) {+export function EditableCode({ note, ntxId, noteContext, debounceUpdate, parentComponent, updateInterval, noteType = "code", onContentChanged, dataSaved, placeholder, ...editorProps }: EditableCodeProps) {const editorRef = useRef<VanillaCodeMirror>(null);const containerRef = useRef<HTMLPreElement>(null);const [ vimKeymapEnabled ] = useTriliumOptionBool("vimKeymapEnabled");@@ -115,7 +116,7 @@ export function EditableCode({ note, ntxId, noteContext, debounceUpdate, parentCeditorRef={editorRef} containerRef={containerRef}mime={mime ?? "text/plain"}className="note-detail-code-editor"- placeholder={t("editable_code.placeholder")}+ placeholder={placeholder ?? t("editable_code.placeholder")}vimKeybindings={vimKeymapEnabled}tabIndex={300}onContentChanged={() => {diff --git a/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.tsx b/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.tsxindex a587eba63a..ac0a44f9a7 100644--- a/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.tsx+++ b/apps/client/src/widgets/type_widgets/helpers/SvgSplitEditor.tsx@@ -117,6 +117,7 @@ export default function SvgSplitEditor({ ntxId, note, attachmentName, renderSvg,error={error}onContentChanged={onContentChanged}dataSaved={onSave}+ placeholder={t("mermaid.placeholder")}previewContent={(<RawHtmlBlockclassName="render-container"