Skip to content

Commit

Permalink
Fix #958; Force insert mode when first editing kanban card and vim is…
Browse files Browse the repository at this point in the history
… active
  • Loading branch information
mgmeyers committed May 25, 2024
1 parent 7b6f0d5 commit 51b77ce
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/components/Editor/MarkdownEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ function getMarkdownController(view: KanbanView, getEditor: () => Editor): Recor
};
}

function setInsertMode(cm: EditorView) {
const vim = getVimPlugin(cm);
if (vim) {
(window as any).CodeMirrorAdapter?.Vim?.enterInsertMode(vim);
}
}

function getVimPlugin(cm: EditorView): string {
return (cm as any)?.plugins?.find((p: any) => {
if (!p?.value) return false;
return 'useNextTextInput' in p.value && 'waitForCopy' in p.value;
})?.value?.cm;
}

export function MarkdownEditor({
editorRef,
onEnter,
Expand Down Expand Up @@ -212,6 +226,10 @@ export function MarkdownEditor({
userEvent: 'select.pointer',
selection: EditorSelection.single(cm.posAtCoords(editState, false)),
});

cm.dom.win.setTimeout(() => {
setInsertMode(cm);
});
}

const onShow = () => {
Expand Down

0 comments on commit 51b77ce

Please sign in to comment.