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
feat(touch_bar): add unlock button for read-only text
Elian Doran8a1b565aeea9
diff --git a/src/public/app/widgets/type_widgets/read_only_text.ts b/src/public/app/widgets/type_widgets/read_only_text.tsindex 8d788d6bd4..2ac4d671b7 100644--- a/src/public/app/widgets/type_widgets/read_only_text.ts+++ b/src/public/app/widgets/type_widgets/read_only_text.ts@@ -3,11 +3,12 @@ import libraryLoader from "../../services/library_loader.js";import { applySyntaxHighlight } from "../../services/syntax_highlight.js";import { getMermaidConfig } from "../mermaid.js";import type FNote from "../../entities/fnote.js";-import type { EventData } from "../../components/app_context.js";+import type { CommandListenerData, EventData } from "../../components/app_context.js";import { getLocaleById } from "../../services/i18n.js";+import appContext from "../../components/app_context.js";const TPL = `-<div class="note-detail-readonly-text note-detail-printable">+<div class="note-detail-readonly-text note-detail-printable" tabindex="100"><style>/* h1 should not be used at all since semantically that's a note title */.note-detail-readonly-text h1 { font-size: 1.8em; }@@ -164,4 +165,20 @@ export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget {this.$widget.attr("dir", isRtl ? "rtl" : "ltr");}+ 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();+ }+ })+ ];+ }+}