diff --git a/package.json b/package.json index 12a121e..9101807 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { "name": "@editorjs/header", - "version": "2.8.6", + "version": "2.8.7", "keywords": [ "codex editor", "header", + "heading", "editor.js", "editorjs" ], - "description": "Header Tool for Editor.js", + "description": "Heading Tool for Editor.js", "license": "MIT", "repository": "https://github.com/editor-js/header", "files": [ diff --git a/src/index.ts b/src/index.ts index 79fb250..506312c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -144,7 +144,7 @@ export default class Header { * @private */ isHeaderData(data: any): data is HeaderData { - return (data as HeaderData).text !== undefined && (data as HeaderData).level !== undefined; + return (data as HeaderData).text !== undefined; } /** @@ -158,13 +158,14 @@ export default class Header { normalizeData(data: HeaderData | {}): HeaderData { const newData: HeaderData = { text: '', level: this.defaultLevel.number }; - if (!this.isHeaderData(data)) { - return { text: '', level: this.defaultLevel.number}; + if (this.isHeaderData(data)) { + newData.text = data.text || ''; + + if (data.level !== undefined && !isNaN(parseInt(data.level.toString()))) { + newData.level = parseInt(data.level.toString()); + } } - newData.text = data.text || ''; - newData.level = parseInt(data.level.toString()) || this.defaultLevel.number; - return newData; }