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
chore(react/type_widget): finalize read-only text
Elian Doran5d833c1ac434
diff --git a/apps/client/src/widgets/NoteDetail.tsx b/apps/client/src/widgets/NoteDetail.tsxindex 8c6df291b0..8fef34046a 100644--- a/apps/client/src/widgets/NoteDetail.tsx+++ b/apps/client/src/widgets/NoteDetail.tsx@@ -44,7 +44,8 @@ export default function NoteDetail() {note: note!,viewScope,ntxId,- parentComponent+ parentComponent,+ noteContext};useEffect(() => setCorrespondingWidget(getCorrespondingWidget(type, props)), [ note, viewScope, type ]);diff --git a/apps/client/src/widgets/type_widgets/text/ReadOnlyText.tsx b/apps/client/src/widgets/type_widgets/text/ReadOnlyText.tsxindex 8b916aae50..205e25b455 100644--- a/apps/client/src/widgets/type_widgets/text/ReadOnlyText.tsx+++ b/apps/client/src/widgets/type_widgets/text/ReadOnlyText.tsx@@ -15,8 +15,10 @@ import { loadIncludedNote, refreshIncludedNote, setupImageOpening } from "./utilimport { renderMathInElement } from "../../../services/math";import link from "../../../services/link";import { formatCodeBlocks } from "../../../services/syntax_highlight";+import TouchBar, { TouchBarButton, TouchBarSpacer } from "../../react/TouchBar";+import appContext from "../../../components/app_context";-export default function ReadOnlyText({ note, ntxId }: TypeWidgetProps) {+export default function ReadOnlyText({ note, noteContext, ntxId }: TypeWidgetProps) {const blob = useNoteBlob(note);const contentRef = useRef<HTMLDivElement>(null);const { isRtl } = useNoteLanguage(note);@@ -57,6 +59,19 @@ export default function ReadOnlyText({ note, ntxId }: TypeWidgetProps) {className="note-detail-readonly-text-content ck-content use-tn-links"html={blob?.content}/>++ <TouchBar>+ <TouchBarSpacer size="flexible" />+ <TouchBarButton+ icon="NSLockUnlockedTemplate"+ click={() => {+ if (noteContext?.viewScope) {+ noteContext.viewScope.readOnlyTemporarilyDisabled = true;+ appContext.triggerEvent("readOnlyTemporarilyDisabled", { noteContext });+ }+ }}+ />+ </TouchBar></div>)}diff --git a/apps/client/src/widgets/type_widgets/type_widget.ts b/apps/client/src/widgets/type_widgets/type_widget.tsindex 8be76fecd4..4723060a2e 100644--- a/apps/client/src/widgets/type_widgets/type_widget.ts+++ b/apps/client/src/widgets/type_widgets/type_widget.ts@@ -1,10 +1,12 @@import FNote from "../../entities/fnote";import { ViewScope } from "../../services/link";import { TypedComponent } from "../../components/component";+import NoteContext from "../../components/note_context";export interface TypeWidgetProps {note: FNote;viewScope: ViewScope | undefined;ntxId: string | null | undefined;parentComponent: TypedComponent<any> | undefined;+ noteContext: NoteContext | undefined;}diff --git a/apps/client/src/widgets/type_widgets_old/read_only_text.ts b/apps/client/src/widgets/type_widgets_old/read_only_text.tsdeleted file mode 100644index 407083c43b..0000000000--- a/apps/client/src/widgets/type_widgets_old/read_only_text.ts+++ /dev/null@@ -1,24 +0,0 @@-import AbstractTextTypeWidget from "./abstract_text_type_widget.js";-import { formatCodeBlocks } from "../../services/syntax_highlight.js";-import type FNote from "../../entities/fnote.js";-import type { CommandListenerData, EventData } from "../../components/app_context.js";-import appContext from "../../components/app_context.js";--export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget {- buildTouchBarCommand({ TouchBar, buildIcon }: CommandListenerData<"buildTouchBar">) {- return [- new TouchBar.TouchBarSpacer({ size: "flexible" }),- new TouchBar.TouchBarButton({- icon: buildIcon("NSLockUnlockedTemplate"),- click: () => {- if (this.noteContext?.viewScope) {- this.noteContext.viewScope.readOnlyTemporarilyDisabled = true;- appContext.triggerEvent("readOnlyTemporarilyDisabled", { noteContext: this.noteContext });- }- this.refresh();- }- })- ];- }--}