Bring back aggression
This commit is contained in:
@@ -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
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user