mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 10:22:29 +08:00
feat(touch_bar): add unlock button for read-only text
This commit is contained in:
parent
975e641286
commit
8a1b565aee
@ -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();
|
||||
}
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user