feat(touch_bar): add unlock button for read-only text

This commit is contained in:
Elian Doran 2025-03-09 20:41:31 +02:00
parent 975e641286
commit 8a1b565aee
No known key found for this signature in database

View File

@ -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();
}
})
];
}
}