diff --git a/apps/client/src/widgets/note_title.bak b/apps/client/src/widgets/note_title.bak
index e07b8380e..059e4b4d1 100644
--- a/apps/client/src/widgets/note_title.bak
+++ b/apps/client/src/widgets/note_title.bak
@@ -9,36 +9,6 @@ import shortcutService from "../services/shortcuts.js";
import utils from "../services/utils.js";
import type FNote from "../entities/fnote.js";
-const TPL = /*html*/`
-
-
-
`;
-
export default class NoteTitleWidget extends NoteContextAwareWidget {
private $noteTitle!: JQuery;
@@ -48,10 +18,6 @@ export default class NoteTitleWidget extends NoteContextAwareWidget {
constructor() {
super();
- this.spacedUpdate = new SpacedUpdate(async () => {
-
- });
-
this.deleteNoteOnEscape = false;
appContext.addBeforeUnloadListener(this);
@@ -92,10 +58,6 @@ export default class NoteTitleWidget extends NoteContextAwareWidget {
this.setProtectedStatus(note);
}
- setProtectedStatus(note: FNote) {
- this.$noteTitle.toggleClass("protected", !!note.isProtected);
- }
-
async beforeNoteSwitchEvent({ noteContext }: EventData<"beforeNoteSwitch">) {
if (this.isNoteContext(noteContext.ntxId)) {
await this.spacedUpdate.updateNowIfNecessary();
@@ -122,17 +84,6 @@ export default class NoteTitleWidget extends NoteContextAwareWidget {
}
}
- entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {
- if (loadResults.isNoteReloaded(this.noteId) && this.note) {
- // not updating the title specifically since the synced title might be older than what the user is currently typing
- this.setProtectedStatus(this.note);
- }
-
- if (loadResults.isNoteReloaded(this.noteId, this.componentId)) {
- this.refresh();
- }
- }
-
beforeUnloadEvent() {
return this.spacedUpdate.isAllSavedAndTriggerUpdate();
}
diff --git a/apps/client/src/widgets/note_title.css b/apps/client/src/widgets/note_title.css
new file mode 100644
index 000000000..294e2a01f
--- /dev/null
+++ b/apps/client/src/widgets/note_title.css
@@ -0,0 +1,24 @@
+.note-title-widget {
+ flex-grow: 1000;
+ height: 100%;
+}
+
+.note-title-widget input.note-title {
+ font-size: 110%;
+ border: 0;
+ margin: 2px 0px;
+ min-width: 5em;
+ width: 100%;
+}
+
+.note-title-widget input.note-title.protected {
+ text-shadow: 4px 4px 4px var(--muted-text-color);
+}
+
+body.mobile .note-title-widget input.note-title {
+ padding: 0;
+}
+
+body.desktop .note-title-widget input.note-title {
+ font-size: 180%;
+}
\ No newline at end of file
diff --git a/apps/client/src/widgets/note_title.tsx b/apps/client/src/widgets/note_title.tsx
index d74779dfa..55769cfee 100644
--- a/apps/client/src/widgets/note_title.tsx
+++ b/apps/client/src/widgets/note_title.tsx
@@ -1,14 +1,17 @@
import { useEffect, useRef, useState } from "preact/hooks";
import { t } from "../services/i18n";
import FormTextBox from "./react/FormTextBox";
-import { useNoteContext, useSpacedUpdate } from "./react/hooks";
+import { useNoteContext, useSpacedUpdate, useTriliumEventBeta } from "./react/hooks";
import protected_session_holder from "../services/protected_session_holder";
import server from "../services/server";
+import "./note_title.css";
export default function NoteTitleWidget() {
const { note, noteId, componentId } = useNoteContext();
const [ title, setTitle ] = useState(note?.title);
- useEffect(() => setTitle(note?.title), [ note?.title ]);
+ const [ isProtected, setProtected ] = useState(note?.isProtected);
+ useEffect(() => setTitle(note?.title), [ note?.noteId ]);
+ useEffect(() => setProtected(note?.isProtected), [ note?.isProtected ]);
const spacedUpdate = useSpacedUpdate(async () => {
if (!note) {
@@ -18,19 +21,28 @@ export default function NoteTitleWidget() {
await server.put(`notes/${noteId}/title`, { title: title }, componentId);
});
+ useTriliumEventBeta("entitiesReloaded", ({ loadResults }) => {
+ if (loadResults.isNoteReloaded(noteId) && note) {
+ setProtected(note.isProtected);
+ }
+ if (loadResults.isNoteReloaded(noteId, componentId)) {
+ setTitle(note?.title);
+ }
+ });
+
return (
- <>
+
{
setTitle(newValue);
spacedUpdate.scheduleUpdate();
}}
/>
- >
+
);
}