chore(react/type_widget): bring back read-only

This commit is contained in:
Elian Doran 2025-09-20 12:34:36 +03:00
parent 3d5b319eb2
commit c8a9b994d6
No known key found for this signature in database
3 changed files with 13 additions and 14 deletions

View file

@ -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 (
<div className={`note-detail-split note-detail-printable ${"split-" + splitEditorOrientation}`}>
<div className="note-detail-split-editor-col">
<div className="note-detail-split-editor">Detail goes here.</div>
<div className="admonition caution note-detail-error-container hidden-ext">Errors go here.</div>
</div>
<div className={`note-detail-split note-detail-printable ${"split-" + splitEditorOrientation} ${readOnly ? "split-read-only" : ""}`}>
{!readOnly && (
<div className="note-detail-split-editor-col">
<div className="note-detail-split-editor">Detail goes here.</div>
<div className="admonition caution note-detail-error-container hidden-ext">Errors go here.</div>
</div>
)}
<div className="note-detail-split-preview-col">
<div className="note-detail-split-preview">Preview goes here</div>
<div className="btn-group btn-group-sm map-type-switcher content-floating-buttons preview-buttons bottom-right" role="group">Buttons go here</div>

View file

@ -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

View file

@ -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;
}
/**