From c8a9b994d673e6d1e98cbefc6b665dec3ff172ac Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 20 Sep 2025 12:34:36 +0300 Subject: [PATCH] chore(react/type_widget): bring back read-only --- .../type_widgets/helpers/SplitEditor.tsx | 19 ++++++++++++------- .../abstract_split_type_widget.ts | 6 ------ packages/commons/src/lib/attribute_names.ts | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/apps/client/src/widgets/type_widgets/helpers/SplitEditor.tsx b/apps/client/src/widgets/type_widgets/helpers/SplitEditor.tsx index 62c1b8161..64fffd1fc 100644 --- a/apps/client/src/widgets/type_widgets/helpers/SplitEditor.tsx +++ b/apps/client/src/widgets/type_widgets/helpers/SplitEditor.tsx @@ -1,5 +1,5 @@ import { isMobile } from "../../../services/utils"; -import { useTriliumOption } from "../../react/hooks"; +import { useNoteLabel, useNoteLabelBoolean, useTriliumOption } from "../../react/hooks"; import { TypeWidgetProps } from "../type_widget"; import "./SplitEditor.css"; @@ -12,14 +12,19 @@ import "./SplitEditor.css"; * - Can display errors to the user via {@link setError}. * - Horizontal or vertical orientation for the editor/preview split, adjustable via the switch split orientation button floating button. */ -export default function SplitEditor({ }: TypeWidgetProps) { +export default function SplitEditor({ note }: TypeWidgetProps) { const splitEditorOrientation = useSplitOrientation(); + const [ readOnly ] = useNoteLabelBoolean(note, "readOnly"); + return ( -
-
-
Detail goes here.
-
Errors go here.
-
+
+ {!readOnly && ( +
+
Detail goes here.
+
Errors go here.
+
+ )} +
Preview goes here
Buttons go here
diff --git a/apps/client/src/widgets/type_widgets_old/abstract_split_type_widget.ts b/apps/client/src/widgets/type_widgets_old/abstract_split_type_widget.ts index bd2b3b567..3850bd083 100644 --- a/apps/client/src/widgets/type_widgets_old/abstract_split_type_widget.ts +++ b/apps/client/src/widgets/type_widgets_old/abstract_split_type_widget.ts @@ -85,12 +85,6 @@ export default abstract class AbstractSplitTypeWidget extends TypeWidget { } #adjustLayoutOrientation() { - // Read-only - const isReadOnly = this.note?.hasLabel("readOnly"); - if (this.isReadOnly !== isReadOnly) { - this.$editorCol.toggle(!isReadOnly); - } - // Vertical vs horizontal layout if (this.layoutOrientation !== layoutOrientation || this.isReadOnly !== isReadOnly) { this.$widget diff --git a/packages/commons/src/lib/attribute_names.ts b/packages/commons/src/lib/attribute_names.ts index ed527308a..68fa1af3c 100644 --- a/packages/commons/src/lib/attribute_names.ts +++ b/packages/commons/src/lib/attribute_names.ts @@ -29,7 +29,6 @@ type Labels = { status: string; pageSize: number; geolocation: string; - readOnly: boolean; expanded: boolean; "calendar:hideWeekends": boolean; "calendar:weekNumbers": boolean; @@ -42,6 +41,7 @@ type Labels = { // Note-type specific webViewSrc: string; + readOnly: boolean; } /**