diff --git a/CHANGELOG.md b/CHANGELOG.md index acf3e57..b17b0f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog for malle +## 2.5.2 + +* Allow returning a `Promise` with `onEdit` + ## 2.5.1 * Fix the type of `input` from `fun` or `onEdit` to `HTMLInputElement|HTMLSelectElement` diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index bc56789..c4f3db4 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -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` default: `undefined` This function will be called once the input is there and user is ready to type. The return value is not checked. diff --git a/package-lock.json b/package-lock.json index 8932e60..585ecec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@deltablot/malle", - "version": "2.5.1", + "version": "2.5.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@deltablot/malle", - "version": "2.5.1", + "version": "2.5.2", "license": "MIT", "devDependencies": { "@types/jest": "^27.4.1", diff --git a/package.json b/package.json index 77b07ca..3c017d3 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/main.ts b/src/main.ts index d9aa73f..642db74 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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; onEnter?: Action; onEscape?: Action; placeholder?: string;