Skip to content

Commit

Permalink
add support to unfocus code mirror elements (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyfast committed Jun 11, 2024
1 parent 7214737 commit a53ad0f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/thebe/src/codemirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface RequiredCodeMirrorConfig {
extraKeys: {
'Shift-Enter': () => void;
'Ctrl-Space': () => void;
'Esc': () => void;
};
}

Expand Down Expand Up @@ -62,6 +63,10 @@ export function setupCodemirror(

const ref: { cm?: any } = { cm: undefined };

function unFocus() {
ref.cm?.display.input.blur()
}

function codeCompletion() {
console.debug(`thebe:codemirror:codeCompletion`);
const code = ref.cm?.getValue();
Expand Down Expand Up @@ -116,7 +121,8 @@ export function setupCodemirror(
extraKeys: {
'Shift-Enter': execute,
'Ctrl-Space': codeCompletion,
},
'Esc': unFocus,
},
};

const codeMirrorConfig = Object.assign(
Expand Down

0 comments on commit a53ad0f

Please sign in to comment.