mirror of
https://github.com/zadam/trilium.git
synced 2026-03-10 02:13:38 +01:00
refactor: limit ctrl+enter action only at when creating reation on relation map
This commit is contained in:
parent
e74f619d06
commit
91677eb7da
@ -24,6 +24,7 @@ export interface PromptDialogOptions {
|
||||
shown?: PromptShownDialogCallback;
|
||||
callback?: (value: string | null) => void;
|
||||
readOnly?: boolean;
|
||||
submitWithCtrlEnter?: boolean;
|
||||
}
|
||||
|
||||
export default function PromptDialog() {
|
||||
@ -69,7 +70,7 @@ export default function PromptDialog() {
|
||||
submitValue.current = null;
|
||||
opts.current = undefined;
|
||||
}}
|
||||
footer={<Button text={t("prompt.ok")} keyboardShortcut="ctrl+return" kind="primary" />}
|
||||
footer={<Button text={t("prompt.ok")} keyboardShortcut={opts.current?.submitWithCtrlEnter ? "ctrl+return" : "Enter"} kind="primary" />}
|
||||
show={shown}
|
||||
stackable
|
||||
>
|
||||
@ -79,7 +80,7 @@ export default function PromptDialog() {
|
||||
currentValue={value} onChange={setValue}
|
||||
readOnly={opts.current?.readOnly}
|
||||
onKeyDown={(e: KeyboardEvent) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === "Enter") {
|
||||
if (opts.current?.submitWithCtrlEnter && (e.ctrlKey || e.metaKey) && e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
submitValue.current = answerRef.current?.value || value;
|
||||
setShown(false);
|
||||
|
||||
@ -416,6 +416,7 @@ function useRelationCreation({ mapApiRef, jsPlumbApiRef }: { mapApiRef: RefObjec
|
||||
if (!originalEvent || !mapApiRef.current) return;
|
||||
|
||||
const name = await dialog.prompt({
|
||||
submitWithCtrlEnter: true,
|
||||
message: t("relation_map.specify_new_relation_name"),
|
||||
shown: ({ $answer }) => {
|
||||
if (!$answer) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user