diff --git a/apps/client/src/widgets/NoteDetail.tsx b/apps/client/src/widgets/NoteDetail.tsx index 8c6df291b..8fef34046 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.tsx index 8b916aae5..205e25b45 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 "./util import { 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(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} /> + + + + { + if (noteContext?.viewScope) { + noteContext.viewScope.readOnlyTemporarilyDisabled = true; + appContext.triggerEvent("readOnlyTemporarilyDisabled", { noteContext }); + } + }} + /> + ) } diff --git a/apps/client/src/widgets/type_widgets/type_widget.ts b/apps/client/src/widgets/type_widgets/type_widget.ts index 8be76fecd..4723060a2 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 | 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.ts deleted file mode 100644 index 407083c43..000000000 --- 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(); - } - }) - ]; - } - -}