From 831281bbb4fac55000be48a406adc5d2a3cb4fd3 Mon Sep 17 00:00:00 2001 From: dependentmadani Date: Sat, 13 Jul 2024 00:17:58 +0100 Subject: [PATCH 1/2] fix(normalzeData): convert current line to heading fixed --- src/index.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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; } From e64c3aba90a0353acb3c95b7fe280dd434150f94 Mon Sep 17 00:00:00 2001 From: Peter Savchenko Date: Sat, 13 Jul 2024 16:55:47 +0300 Subject: [PATCH 2/2] Update package.json --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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": [