From 5d865bd4dba0f20b5b3a2bc387f8074c1b80775f Mon Sep 17 00:00:00 2001 From: Martijn van der Klis Date: Fri, 6 Oct 2023 12:50:27 +0200 Subject: [PATCH 1/2] Fixes highlighting for the single H1 assessment for H1s with markup --- .../assessments/seo/SingleH1AssessmentSpec.js | 12 ++++++------ .../scoring/assessments/seo/SingleH1Assessment.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/yoastseo/spec/scoring/assessments/seo/SingleH1AssessmentSpec.js b/packages/yoastseo/spec/scoring/assessments/seo/SingleH1AssessmentSpec.js index bd7bf54bb27..0b8dd856975 100644 --- a/packages/yoastseo/spec/scoring/assessments/seo/SingleH1AssessmentSpec.js +++ b/packages/yoastseo/spec/scoring/assessments/seo/SingleH1AssessmentSpec.js @@ -57,21 +57,21 @@ describe( "An assessment to check whether there is more than one H1 in the text" describe( "A test for marking incorrect H1s in the body", function() { it( "returns markers for incorrect H1s in the body", function() { - const mockPaper = new Paper( "

a paragraph

heading

" ); + const mockPaper = new Paper( "

a paragraph

this is a heading

" ); const mockResearcher = new EnglishResearcher( mockPaper ); buildTree( mockPaper, mockResearcher ); h1Assessment.getResult( mockPaper, mockResearcher ); const expected = [ new Mark( { - original: "

heading

", - marked: "

heading

", + original: "

this is a heading

", + marked: "

this is a heading

", position: { - startOffset: 22, - endOffset: 29, clientId: "", - endOffsetBlock: 7, + startOffset: 22, + endOffset: 56, startOffsetBlock: 0, + endOffsetBlock: 34, } } ), ]; diff --git a/packages/yoastseo/src/scoring/assessments/seo/SingleH1Assessment.js b/packages/yoastseo/src/scoring/assessments/seo/SingleH1Assessment.js index e845fc57405..e644919ef67 100644 --- a/packages/yoastseo/src/scoring/assessments/seo/SingleH1Assessment.js +++ b/packages/yoastseo/src/scoring/assessments/seo/SingleH1Assessment.js @@ -99,7 +99,7 @@ class SingleH1Assessment extends Assessment { startOffset: h1.position.startOffset, endOffset: h1.position.endOffset, startOffsetBlock: 0, - endOffsetBlock: h1.content.length, + endOffsetBlock: h1.position.endOffset - h1.position.startOffset, clientId: h1.position.clientId, }, } ); From 3f61a9696c67787ba9d68b42505a6f88729d9598 Mon Sep 17 00:00:00 2001 From: Martijn van der Klis Date: Fri, 6 Oct 2023 12:51:12 +0200 Subject: [PATCH 2/2] Removes a deprecation warning in the console --- packages/js/src/decorator/gutenberg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/js/src/decorator/gutenberg.js b/packages/js/src/decorator/gutenberg.js index c648f142274..cc26ecec918 100644 --- a/packages/js/src/decorator/gutenberg.js +++ b/packages/js/src/decorator/gutenberg.js @@ -285,7 +285,7 @@ function removeAllAnnotationsFromBlock( blockClientId ) { * @returns {void} */ export function reapplyAnnotationsForSelectedBlock() { - const block = select( "core/editor" ).getSelectedBlock(); + const block = select( "core/block-editor" ).getSelectedBlock(); const activeMarkerId = select( "yoast-seo/editor" ).getActiveMarker(); if ( ! block || ! activeMarkerId ) {