Skip to content

Commit

Permalink
Allow returning a Promise<boolean> with onEdit
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasCARPi committed Nov 19, 2023
1 parent 152c1bf commit e683a31
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog for malle

## 2.5.2

* Allow returning a `Promise<boolean>` with `onEdit`

## 2.5.1

* Fix the type of `input` from `fun` or `onEdit` to `HTMLInputElement|HTMLSelectElement`
Expand Down
2 changes: 1 addition & 1 deletion DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ default value: 'submit'
What to do when the user clicks outside the input? By default the form will be submitted (if valid), but you can decide to do nothing or cancel the edition.

#### onEdit
`Function(original: HTMLElement, event: Event, input: HTMLInputElement): any`
`Function(original: HTMLElement, event: Event, input: HTMLInputElement): boolean | Promise<boolean>`
default: `undefined`

This function will be called once the input is there and user is ready to type. The return value is not checked.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deltablot/malle",
"version": "2.5.1",
"version": "2.5.2",
"description": "Make text elements malleable, without dependencies.",
"main": "dist/main.js",
"typings": "dist/main.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface Options {
listenNow?: boolean;
listenOn?: string;
onBlur?: Action;
onEdit?(original: HTMLElement, event:Event, input: HTMLInputElement|HTMLSelectElement): boolean;
onEdit?(original: HTMLElement, event:Event, input: HTMLInputElement|HTMLSelectElement): boolean | Promise<boolean>;
onEnter?: Action;
onEscape?: Action;
placeholder?: string;
Expand Down

0 comments on commit e683a31

Please sign in to comment.