Bring back aggression

This commit is contained in:
Jon Staab
2025-01-17 14:31:42 -08:00
parent 892eb9a00c
commit d636abb0a6
2 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@welshman/editor", "name": "@welshman/editor",
"version": "0.0.6", "version": "0.0.7",
"scripts": { "scripts": {
"pub": "npm run check && npm run build && npm publish", "pub": "npm run check && npm run build && npm publish",
"fix": "", "fix": "",
@@ -3,6 +3,9 @@ import {HardBreak, type HardBreakOptions} from "@tiptap/extension-hard-break"
export interface BreakOrSubmitOptions extends HardBreakOptions { export interface BreakOrSubmitOptions extends HardBreakOptions {
/** Handler for when enter is pressed. */ /** Handler for when enter is pressed. */
submit: () => void submit: () => void
/** Whether to call `submit` on unmodified Enter */
aggressive?: boolean
} }
export const BreakOrSubmit = HardBreak.extend<BreakOrSubmitOptions>({ export const BreakOrSubmit = HardBreak.extend<BreakOrSubmitOptions>({
@@ -14,6 +17,15 @@ export const BreakOrSubmit = HardBreak.extend<BreakOrSubmitOptions>({
return true return true
}, },
"Enter": () => {
if (this.options.aggressive) {
this.options.submit()
return true
}
return false
},
} }
}, },
}) })