Add generics to OutputBlockData (#1326)

* Add generics to OutputBlockData

* Fix typo

* Update CHANGELOG.md

* Add @template description

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
Co-authored-by: George Berezhnoy <gohabereg@users.noreply.github.com>
This commit is contained in:
Tomoyuki Hata 2021-02-28 06:33:06 +09:00 committed by GitHub
parent e5fe93eeb5
commit 3bf30f0c1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -8,6 +8,7 @@
- `Improvements` - Remove bundles from the repo [#1541](https://github.com/codex-team/editor.js/pull/1541).
- `Improvements` - Document will be scrolled when blocks are selected with `SHIFT+UP` or `SHIFT+DOWN` [#1447](https://github.com/codex-team/editor.js/issues/1447)
- `Improvements` - The caret will be set on editor copy/paste [#1470](https://github.com/codex-team/editor.js/pull/1470)
- `Improvements` - Added generic types to OutputBlockData [#1551](https://github.com/codex-team/editor.js/issues/1551).
- `Fix` - Fix BlockManager.setCurrentBlockByChildNode() with multiple Editor.js instances [#1503](https://github.com/codex-team/editor.js/issues/1503).
- `Fix` - Fix an unstable block cut process [#1489](https://github.com/codex-team/editor.js/issues/1489).
- `Fix` - Type definition of the Sanitizer config: the sanitize function now contains param definition [#1491](https://github.com/codex-team/editor.js/pull/1491).

View file

@ -2,16 +2,19 @@ import {BlockToolData} from '../tools';
/**
* Output of one Tool
*
* @template Type - the string literal describing a tool type
* @template Data - the structure describing a data object supported by the tool
*/
export interface OutputBlockData {
export interface OutputBlockData<Type extends string = string, Data extends object = any> {
/**
* Too type
* Tool type
*/
type: string;
type: Type;
/**
* Saved Block data
*/
data: BlockToolData;
data: BlockToolData<Data>;
}
export interface OutputData {