Shift-Enter in the page navigator now takes the input literally
This commit is contained in:
parent
701a567c95
commit
2c8e1f1809
@ -100,8 +100,10 @@ export function FilterList({
|
||||
darkMode={darkMode}
|
||||
completer={completer}
|
||||
placeholderText={placeholder}
|
||||
onEnter={() => {
|
||||
onSelect(matchingOptions[selectedOption]);
|
||||
onEnter={(_newText, shiftDown) => {
|
||||
onSelect(
|
||||
shiftDown ? { name: text } : matchingOptions[selectedOption],
|
||||
);
|
||||
return true;
|
||||
}}
|
||||
onEscape={() => {
|
||||
|
@ -22,7 +22,7 @@ import {
|
||||
} from "../deps.ts";
|
||||
|
||||
type MiniEditorEvents = {
|
||||
onEnter: (newText: string) => void;
|
||||
onEnter: (newText: string, shiftDown?: boolean) => void;
|
||||
onEscape?: (newText: string) => void;
|
||||
onBlur?: (newText: string) => void | Promise<void>;
|
||||
onChange?: (newText: string) => void;
|
||||
@ -174,7 +174,14 @@ export function MiniEditor(
|
||||
{
|
||||
key: "Enter",
|
||||
run: (view) => {
|
||||
onEnter(view);
|
||||
onEnter(view, false);
|
||||
return true;
|
||||
},
|
||||
},
|
||||
{
|
||||
key: "Shift-Enter",
|
||||
run: (view) => {
|
||||
onEnter(view, true);
|
||||
return true;
|
||||
},
|
||||
},
|
||||
@ -204,7 +211,7 @@ export function MiniEditor(
|
||||
// Enter should be handled by the keymap, except when in Vim normal mode
|
||||
// because then it's disabled
|
||||
if (vimMode && vimModeRef.current === "normal") {
|
||||
onEnter(view);
|
||||
onEnter(view, event.shiftKey);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -233,12 +240,12 @@ export function MiniEditor(
|
||||
});
|
||||
|
||||
// Avoid double triggering these events (may happen due to onkeypress vs onkeyup delay)
|
||||
function onEnter(view: EditorView) {
|
||||
function onEnter(view: EditorView, shiftDown: boolean) {
|
||||
if (onEntered) {
|
||||
return;
|
||||
}
|
||||
onEntered = true;
|
||||
callbacksRef.current!.onEnter(view.state.sliceDoc());
|
||||
callbacksRef.current!.onEnter(view.state.sliceDoc(), shiftDown);
|
||||
// Event may occur again in 500ms
|
||||
setTimeout(() => {
|
||||
onEntered = false;
|
||||
|
Loading…
Reference in New Issue
Block a user