codex-team / codex-team/editor.js
Feature: Enter to submit (important usability feature)
- Dominant language
- TypeScript
- Stars
- 31.9k
- Forks
- 2.2k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
I would like to submit content on press enter. Currently, I see no way of doing that. I tried to implement my solution but sometimes it creates an empty bloc on press enter. Is there a way to send a message on **Press Enter**?
```
/**
* submit on enter
* @param e
*/
async submitOnEnter(e: Event) {
const event = e as KeyboardEvent;
const condition1 = event.key === 'Enter';
const condition2 = !event.shiftKey;
// stop on empty text
if (condition1 && !this.contentInput?.str) {
e.preventDefault();
e.stopPropagation();
return false;
}
if (!this.isSubmitOnEnter) return;
if (!this.contentInput?.str) return;
if (!(condition1 && condition2)) return;
// submit
this.contentSubmit();
// stop new line
e.preventDefault();
e.stopPropagation();
return false;
},
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.