mirror of
https://github.com/zadam/trilium.git
synced 2025-10-21 15:49:00 +02:00
chore(react/note_title): focus content on enter
This commit is contained in:
parent
945e180a6f
commit
8a543d4513
@ -31,9 +31,6 @@ export default class NoteTitleWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
shortcutService.bindElShortcut(this.$noteTitle, "return", () => {
|
|
||||||
this.triggerCommand("focusOnDetail", { ntxId: this.noteContext?.ntxId });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async beforeNoteSwitchEvent({ noteContext }: EventData<"beforeNoteSwitch">) {
|
async beforeNoteSwitchEvent({ noteContext }: EventData<"beforeNoteSwitch">) {
|
||||||
|
@ -9,7 +9,7 @@ import { isLaunchBarConfig } from "../services/utils";
|
|||||||
import appContext from "../components/app_context";
|
import appContext from "../components/app_context";
|
||||||
|
|
||||||
export default function NoteTitleWidget() {
|
export default function NoteTitleWidget() {
|
||||||
const { note, noteId, componentId, viewScope, noteContext } = useNoteContext();
|
const { note, noteId, componentId, viewScope, noteContext, parentComponent } = useNoteContext();
|
||||||
const title = useNoteProperty(note, "title", componentId);
|
const title = useNoteProperty(note, "title", componentId);
|
||||||
const isProtected = useNoteProperty(note, "isProtected");
|
const isProtected = useNoteProperty(note, "isProtected");
|
||||||
const newTitle = useRef("");
|
const newTitle = useRef("");
|
||||||
@ -57,6 +57,14 @@ export default function NoteTitleWidget() {
|
|||||||
newTitle.current = newValue;
|
newTitle.current = newValue;
|
||||||
spacedUpdate.scheduleUpdate();
|
spacedUpdate.scheduleUpdate();
|
||||||
}}
|
}}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
// Focus on the note content when pressing enter.
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
e.preventDefault();
|
||||||
|
parentComponent.triggerCommand("focusOnDetail", { ntxId: noteContext?.ntxId });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>}
|
/>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -271,7 +271,8 @@ export function useNoteContext() {
|
|||||||
ntxId: noteContext?.ntxId,
|
ntxId: noteContext?.ntxId,
|
||||||
viewScope: noteContext?.viewScope,
|
viewScope: noteContext?.viewScope,
|
||||||
componentId: parentComponent.componentId,
|
componentId: parentComponent.componentId,
|
||||||
noteContext: noteContext
|
noteContext,
|
||||||
|
parentComponent
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user