diff --git a/admin/class-gutenberg-compatibility.php b/admin/class-gutenberg-compatibility.php index b53ec432eea..568f73c8f1c 100644 --- a/admin/class-gutenberg-compatibility.php +++ b/admin/class-gutenberg-compatibility.php @@ -15,14 +15,14 @@ class WPSEO_Gutenberg_Compatibility { * * @var string */ - const CURRENT_RELEASE = '16.7.1'; + const CURRENT_RELEASE = '16.8.0'; /** * The minimally supported version of Gutenberg by the plugin. * * @var string */ - const MINIMUM_SUPPORTED = '16.7.1'; + const MINIMUM_SUPPORTED = '16.8.0'; /** * Holds the current version. diff --git a/package.json b/package.json index d3db5033d78..e74c7ffed1c 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "typescript": "^4.2.4" }, "yoast": { - "pluginVersion": "21.4-RC6" + "pluginVersion": "21.4-RC7" }, "version": "0.0.0" } diff --git a/packages/yoastseo/spec/languageProcessing/helpers/sentence/getSentencesFromTreeSpec.js b/packages/yoastseo/spec/languageProcessing/helpers/sentence/getSentencesFromTreeSpec.js index b1c5f2a4999..86cc0477ee4 100644 --- a/packages/yoastseo/spec/languageProcessing/helpers/sentence/getSentencesFromTreeSpec.js +++ b/packages/yoastseo/spec/languageProcessing/helpers/sentence/getSentencesFromTreeSpec.js @@ -11,7 +11,7 @@ describe( "test to get sentences from the tree", () => { } ); it( "returns the sentences from paragraph and heading nodes", () => { const paper = new Paper( "

A very intelligent cat loves their human. A dog is very cute.

A subheading 3" + - "

text text text

A subheading 4

more text.
" ); + "

A subheading 4

" ); researcher.setPaper( paper ); buildTree( paper, researcher ); expect( getSentencesFromTree( paper ) ).toEqual( [ @@ -76,48 +76,76 @@ describe( "test to get sentences from the tree", () => { parentClientId: "", }, { - sourceCodeRange: { startOffset: 96, endOffset: 110 }, - parentStartOffset: 96, - text: "text text text", + sourceCodeRange: { startOffset: 100, endOffset: 114 }, + parentStartOffset: 100, + text: "A subheading 4", tokens: [ - { sourceCodeRange: { startOffset: 96, endOffset: 100 }, text: "text" }, - { sourceCodeRange: { startOffset: 100, endOffset: 101 }, text: " " }, - { sourceCodeRange: { startOffset: 101, endOffset: 105 }, text: "text" }, - { sourceCodeRange: { startOffset: 105, endOffset: 106 }, text: " " }, - { sourceCodeRange: { startOffset: 106, endOffset: 110 }, text: "text" }, + { sourceCodeRange: { startOffset: 100, endOffset: 101 }, text: "A" }, + { sourceCodeRange: { startOffset: 101, endOffset: 102 }, text: " " }, + { sourceCodeRange: { startOffset: 102, endOffset: 112 }, text: "subheading" }, + { sourceCodeRange: { startOffset: 112, endOffset: 113 }, text: " " }, + { sourceCodeRange: { startOffset: 113, endOffset: 114 }, text: "4" }, ], isParentFirstSectionOfBlock: false, parentAttributeId: "", parentClientId: "", }, + ] ); + } ); + it( "returns the sentences from an implicit paragraph (an image caption)", () => { + const paper = new Paper( "[caption id=\"attachment_75\" align=\"alignnone\" width=\"200\"]\"elephant\"" elephant[/caption]", { shortcodes: [ "caption" ] } ); + researcher.setPaper( paper ); + buildTree( paper, researcher ); + expect( getSentencesFromTree( paper ) ).toEqual( [ { - sourceCodeRange: { startOffset: 114, endOffset: 128 }, - parentStartOffset: 114, - text: "A subheading 4", - tokens: [ - { sourceCodeRange: { startOffset: 114, endOffset: 115 }, text: "A" }, - { sourceCodeRange: { startOffset: 115, endOffset: 116 }, text: " " }, - { sourceCodeRange: { startOffset: 116, endOffset: 126 }, text: "subheading" }, - { sourceCodeRange: { startOffset: 126, endOffset: 127 }, text: " " }, - { sourceCodeRange: { startOffset: 127, endOffset: 128 }, text: "4" }, - ], isParentFirstSectionOfBlock: false, parentAttributeId: "", parentClientId: "", - }, - { - sourceCodeRange: { startOffset: 133, endOffset: 143 }, - parentStartOffset: 133, - text: "more text.", + parentStartOffset: 0, + sourceCodeRange: { + endOffset: 252, + startOffset: 0, + }, + text: " elephant", tokens: [ - { sourceCodeRange: { startOffset: 133, endOffset: 137 }, text: "more" }, - { sourceCodeRange: { startOffset: 137, endOffset: 138 }, text: " " }, - { sourceCodeRange: { startOffset: 138, endOffset: 142 }, text: "text" }, - { sourceCodeRange: { startOffset: 142, endOffset: 143 }, text: "." }, + { + sourceCodeRange: { + endOffset: 234, + startOffset: 233, + }, + text: " ", + }, + { + sourceCodeRange: { + endOffset: 242, + startOffset: 234, + }, + text: "elephant", + }, + { + sourceCodeRange: { + endOffset: 243, + startOffset: 242, + }, + text: "[", + }, + { + sourceCodeRange: { + endOffset: 251, + startOffset: 243, + }, + text: "/caption", + }, + { + sourceCodeRange: { + endOffset: 252, + startOffset: 251, + }, + text: "]", + }, ], - isParentFirstSectionOfBlock: false, - parentAttributeId: "", - parentClientId: "", }, ] ); } ); diff --git a/packages/yoastseo/src/languageProcessing/helpers/sentence/getSentencesFromTree.js b/packages/yoastseo/src/languageProcessing/helpers/sentence/getSentencesFromTree.js index f409563791e..0fcbd57b06e 100644 --- a/packages/yoastseo/src/languageProcessing/helpers/sentence/getSentencesFromTree.js +++ b/packages/yoastseo/src/languageProcessing/helpers/sentence/getSentencesFromTree.js @@ -10,12 +10,13 @@ function getStartOffset( node ) { /** * Retrieves the parent node for a given node. - * @param {Paper} paper The current paper. - * @param {Node} node The current node. + * @param {Paper} paper The current paper. + * @param {Node} node The current node. * @returns {Node} The parent node. */ function getParentNode( paper, node ) { - return paper.getTree().findAll( treeNode => treeNode.childNodes && treeNode.childNodes.includes( node ) )[ 0 ]; + // Includes a fallback so that if a parent node cannot be found for an implicit paragraph, we use the current node as the parent node. + return paper.getTree().findAll( treeNode => treeNode.childNodes && treeNode.childNodes.includes( node ) )[ 0 ] || node; } /** @@ -45,9 +46,10 @@ export default function( paper ) { // The block client id of the parent node. parentClientId: parentNode.clientId || "", // The attribute id of the parent node, if available, otherwise an empty string. - parentAttributeId: parentNode.attributeId || "", - // Whether the parent node is the first section of Yoast sub-blocks. - isParentFirstSectionOfBlock: parentNode.isFirstSection || false, + // Only used for position-based highlighting in sub-blocks of Yoast blocks. + parentAttributeId: node.attributeId || "", + // Whether the parent node is the first section of Yoast sub-blocks. Only used for position-based highlighting. + isParentFirstSectionOfBlock: node.isFirstSection || false, }; } ) ); } diff --git a/packages/yoastseo/src/parse/structure/Node.js b/packages/yoastseo/src/parse/structure/Node.js index aa5b82a2602..a0fb631904b 100644 --- a/packages/yoastseo/src/parse/structure/Node.js +++ b/packages/yoastseo/src/parse/structure/Node.js @@ -46,9 +46,9 @@ class Node { /** * Finds all nodes in the tree that satisfies the given condition. * - * @param {function} condition The condition that a node should satisfy to end up in the list. - * @param {boolean} recurseFoundNodes=false Whether to recurse into found nodes - * to see if the condition also applies to sub-nodes of the found node. + * @param {function} condition The condition that a node should satisfy to end up in the list. + * @param {boolean} recurseFoundNodes=false Whether to recurse into found nodes to see if the condition + * also applies to sub-nodes of the found node. * * @returns {(Node|Text|Paragraph|Heading)[]} The list of nodes that satisfy the condition. */ diff --git a/packages/yoastseo/src/parse/traverse/findAllInTree.js b/packages/yoastseo/src/parse/traverse/findAllInTree.js index 7adbb3e68a2..82a1b388ac5 100644 --- a/packages/yoastseo/src/parse/traverse/findAllInTree.js +++ b/packages/yoastseo/src/parse/traverse/findAllInTree.js @@ -1,9 +1,10 @@ /** * Finds all nodes in the tree that satisfies the given condition. * - * @param {Object} tree The tree. - * @param {function} condition The condition that a node should satisfy to end up in the list. - * @param {boolean} recurseFoundNodes=false Whether to recurse into found nodes to see if the condition also applies to sub-nodes of the found node. + * @param {Object} tree The tree. + * @param {function} condition The condition that a node should satisfy to end up in the list. + * @param {boolean} recurseFoundNodes=false Whether to recurse into found nodes to see if the condition also applies to + * sub-nodes of the found node. * If false, as soon as a node is found that satisfies the condition, it is added to the list and no further recursion is done through its children. * If true, the node is added to the list and its children are also checked for the condition. * If they satisfy the condition, they are also added to the list. diff --git a/wp-seo-main.php b/wp-seo-main.php index 2f47796809c..71495bf2c57 100644 --- a/wp-seo-main.php +++ b/wp-seo-main.php @@ -15,7 +15,7 @@ * {@internal Nobody should be able to overrule the real version number as this can cause * serious issues with the options, so no if ( ! defined() ).}} */ -define( 'WPSEO_VERSION', '21.4-RC6' ); +define( 'WPSEO_VERSION', '21.4-RC7' ); if ( ! defined( 'WPSEO_PATH' ) ) { diff --git a/wp-seo.php b/wp-seo.php index 358a2b61c0e..6e50c742a98 100644 --- a/wp-seo.php +++ b/wp-seo.php @@ -8,7 +8,7 @@ * * @wordpress-plugin * Plugin Name: Yoast SEO - * Version: 21.4-RC6 + * Version: 21.4-RC7 * Plugin URI: https://yoa.st/1uj * Description: The first true all-in-one SEO solution for WordPress, including on-page content analysis, XML sitemaps and much more. * Author: Team Yoast