Skip to content

Build your personal knowledge base with Trilium Notes

feat(render): show a read-only render note without its setup

Elian Doran2e7e67290bb0
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 2d76682cd4..f092897dd4 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1700,6 +1700,8 @@
"setup_sample_created": "A sample note was created as a child note.",
"disabled_description": "This render notes comes from an external source. To protect you from malicious content, it is not enabled by default. Make sure you trust the source before enabling it.",
"disabled_button_enable": "Enable render note",
+ "disabled_read_only": "This render note comes from an external source, so it is not enabled.",
+ "nothing_to_display": "This note has nothing to display.",
"error_title": "The script note failed to run",
"error_show_details": "Show details",
"error_note_label": "Script note:"
diff --git a/apps/client/src/widgets/type_widgets/Render.tsx b/apps/client/src/widgets/type_widgets/Render.tsx
index 1167ba509d..8aa49b33a9 100644
--- a/apps/client/src/widgets/type_widgets/Render.tsx
+++ b/apps/client/src/widgets/type_widgets/Render.tsx
@@ -11,7 +11,8 @@ import toast from "../../services/toast";
import Button, { SplitButton } from "../react/Button";
import FormGroup from "../react/FormGroup";
import { FormListItem } from "../react/FormList";
-import { useNoteRelation, useTriliumEvent } from "../react/hooks";
+import { useEffectiveReadOnly, useNoteRelation, useTriliumEvent } from "../react/hooks";
+import NoItems from "../react/NoItems";
import NoteAutocomplete from "../react/NoteAutocomplete";
import { ParentComponent, refToJQuerySelector } from "../react/react_utils";
import RenderErrorCard from "../react/RenderErrorCard";
@@ -31,16 +32,22 @@ const HTML_SAMPLE = /*html*/`\
`;
export default function Render(props: TypeWidgetProps) {
- const { note } = props;
+ const { note, noteContext } = props;
const [ renderNote ] = useNoteRelation(note, "renderNote");
const [ disabledRenderNote ] = useNoteRelation(note, "disabled:renderNote");
+ // A read-only note, such as a shared one, is not offered the setup that would change it.
+ const isReadOnly = useEffectiveReadOnly(note, noteContext);
if (disabledRenderNote) {
- return <DisabledRender {...props} />;
+ return isReadOnly
+ ? <NoItems icon="bx bx-extension" text={t("render.disabled_read_only")} />
+ : <DisabledRender {...props} />;
}
if (!renderNote) {
- return <SetupRenderContent {...props} />;
+ return isReadOnly
+ ? <NoItems icon="bx bx-extension" text={t("render.nothing_to_display")} />
+ : <SetupRenderContent {...props} />;
}
return <RenderContent {...props} />;