2025-11-09 01:35:33 +02:00
|
|
|
import "./ReadOnlyNoteInfoBar.css";
|
2025-11-05 23:52:38 +02:00
|
|
|
import { t } from "../services/i18n";
|
2025-11-06 00:45:16 +02:00
|
|
|
import { useIsNoteReadOnly, useNoteContext, useTriliumEvent } from "./react/hooks"
|
2025-11-05 23:52:38 +02:00
|
|
|
import Button from "./react/Button";
|
2025-11-07 23:45:48 +02:00
|
|
|
import InfoBar from "./react/InfoBar";
|
2025-11-05 23:52:38 +02:00
|
|
|
|
2025-11-09 01:35:33 +02:00
|
|
|
export default function ReadOnlyNoteInfoBar(props: {}) {
|
2025-11-06 07:48:11 +02:00
|
|
|
const {note, noteContext} = useNoteContext();
|
|
|
|
|
const {isReadOnly, enableEditing} = useIsNoteReadOnly(note, noteContext);
|
2025-11-07 23:45:48 +02:00
|
|
|
const isExplicitReadOnly = note?.isLabelTruthy("readOnly");
|
2025-11-05 23:52:38 +02:00
|
|
|
|
2025-11-09 01:35:33 +02:00
|
|
|
return <div class={`read-only-note-info-bar-widget ${(isReadOnly) ? "visible" : ""}`}>
|
2025-11-07 23:45:48 +02:00
|
|
|
{isReadOnly && <InfoBar type={(isExplicitReadOnly ? "subtle" : "prominent")}>
|
|
|
|
|
<div class="read-only-note-info-bar-widget-content">
|
|
|
|
|
{(isExplicitReadOnly) ? (
|
|
|
|
|
<div>{t("read-only-info.read-only-note")}</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div>
|
|
|
|
|
{t("read-only-info.auto-read-only-note")}
|
|
|
|
|
|
|
|
|
|
<a class="tn-link"
|
|
|
|
|
href="https://docs.triliumnotes.org/user-guide/concepts/notes/read-only-notes#automatic-read-only-mode">
|
|
|
|
|
|
|
|
|
|
{t("read-only-info.auto-read-only-learn-more")}
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<Button text={t("read-only-info.edit-note")}
|
|
|
|
|
icon="bx-pencil" onClick={() => enableEditing()} />
|
|
|
|
|
</div>
|
|
|
|
|
</InfoBar>}
|
2025-11-05 23:52:38 +02:00
|
|
|
</div>;
|
|
|
|
|
}
|