Skip to content

Commit

Permalink
Add generics to OutputBlockData (#1326)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored Feb 27, 2021
1 parent e5fe93e commit 3bf30f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
11 changes: 7 additions & 4 deletions types/data-formats/output-data.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3bf30f0

Please sign in to comment.