axyseo 2.0.0-alpha.0.0.42 → 2.0.0-alpha.0.0.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -119,4 +119,19 @@ export function checkMissingAlt(htmlString) {
119
119
  };
120
120
  }
121
121
  }
122
+
123
+ /**
124
+ *
125
+ * @param htmlString
126
+ * @returns {*}
127
+ */
128
+ export function cleanHTML(htmlString) {
129
+ const unwantedTagsRegex = /<(script|style)\b[^<]*(?:(?!<\/\1>)<[^<]*)*<\/\1>|<link\b[^>]*rel=["']?stylesheet["']?[^>]*>/gi;
130
+ let cleanedHTML = htmlString.replace(unwantedTagsRegex, '');
131
+ const classAttributeRegex = /\sclass=["'][^"']*["']/gi;
132
+ cleanedHTML = cleanedHTML.replace(classAttributeRegex, '');
133
+ const hiddenSpanRegex = /<span\b[^>]*\bhidden\b[^>]*>.*?<\/span>/gi;
134
+ cleanedHTML = cleanedHTML.replace(hiddenSpanRegex, '');
135
+ return cleanedHTML;
136
+ }
122
137
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["measureTextWidth","getLanguagesWithWordFormSupport","default","formatNumber","getLanguagesWithWordComplexity","createAnchorOpeningTag","getWordComplexityHelper","getWordComplexityConfig","htmlEntities","countWords","str","wordsArray","trim","split","length","isIncludes","firstStr","secondStr","keywordParts","every","part","toLowerCase","includes","containsKeywordInSubheadings","htmlString","keyword","parser","DOMParser","doc","parseFromString","subheadings","querySelectorAll","i","innerText","countWordInHtml","getCharCount","textOnly","replace","words","validWords","filter","word","wordCount","cleanedString","charCount","calculateKeywordDensity","spacedHtml","tempElement","document","createElement","innerHTML","textContent","cleanedText","lowerCaseKeyword","escapedKeyword","keywordCount","match","RegExp","totalWords","density","toFixed","checkMissingAlt","imgTags","isMissing","missingAltTags","forEach","imgTag","test","push"],"sources":["../../src/helpers/index.js"],"sourcesContent":["export {measureTextWidth} from './createMeasurementElement';\nexport {getLanguagesWithWordFormSupport} from './getLanguagesWithWordFormSupport';\nexport {default as formatNumber} from './formatNumber';\nexport {getLanguagesWithWordComplexity} from './getLanguagesWithWordComplexity';\nexport {createAnchorOpeningTag} from './shortlinker';\nexport {default as getWordComplexityHelper} from './getWordComplexityHelper';\nexport {default as getWordComplexityConfig} from './getWordComplexityConfig';\n\nimport * as htmlEntities from './htmlEntities';\n\nexport {htmlEntities};\n\nexport function countWords(str) {\n const wordsArray = str.trim().split(/\\s+/);\n\n return wordsArray.length;\n}\n\n/**\n * To find the first string in the second string\n * @param firstStr\n * @param secondStr\n * @returns {*}\n */\nexport const isIncludes = (firstStr, secondStr) => {\n const keywordParts = firstStr.split(' ');\n return keywordParts.every(part => secondStr.toLowerCase().includes(part));\n};\n\n/**\n * Helper function to check if the HTML string contains the keyword in subheadings.\n * @param {string} htmlString - The HTML string.\n * @param {string} keyword - The keyword.\n * @returns {boolean} True if the HTML string contains the keyword in subheadings, false otherwise.\n */\nexport function containsKeywordInSubheadings(htmlString, keyword) {\n const parser = new DOMParser();\n const doc = parser.parseFromString(htmlString, 'text/html');\n\n const subheadings = doc.querySelectorAll('h2, h3, h4, h5, h6');\n\n for (let i = 0; i < subheadings.length; i++) {\n if (subheadings[i].innerText.toLowerCase().includes(keyword)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n *\n * @param htmlString\n * @param getCharCount\n * @returns {*|{charCount: *, wordCount: *}}\n */\nexport function countWordInHtml(htmlString, getCharCount = false) {\n const textOnly = htmlString.replace(/<[^>]*>/g, ' ');\n const words = textOnly.trim().split(/[\\p{L}\\p{N}]+(?:-[\\p{L}\\p{N}]+)*/gu);\n const validWords = words.filter(word => word.length > 0);\n const wordCount = validWords.length;\n if (!getCharCount) {\n return wordCount;\n }\n const cleanedString = textOnly.replace(/\\s/g, '');\n const charCount = cleanedString.length;\n return {wordCount, charCount};\n}\n\n/**\n *\n * @param htmlString\n * @param keyword\n * @returns {{keywordCount: number, totalWords: number, density: string}}\n */\nexport function calculateKeywordDensity(htmlString, keyword) {\n const spacedHtml = htmlString.replace(/(<[^>]+>)/g, ' $1 ');\n const tempElement = document.createElement('div');\n tempElement.innerHTML = spacedHtml;\n const textContent = tempElement.textContent || tempElement.innerText || '';\n const cleanedText = textContent\n .trim()\n .replace(/\\s+/g, ' ')\n .toLowerCase();\n\n const lowerCaseKeyword = keyword.toLowerCase();\n\n const escapedKeyword = lowerCaseKeyword.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const keywordCount = (cleanedText.match(new RegExp(escapedKeyword, 'g')) || []).length;\n\n const totalWords = cleanedText.split(/\\s+/).filter(word => word.length > 0).length;\n\n const density = (keywordCount / totalWords) * 100;\n\n return {\n keywordCount: keywordCount,\n totalWords: totalWords,\n density: density.toFixed(2)\n };\n}\n\n/**\n *\n * @param htmlString\n * @returns {{isMissing: boolean, missingAltTags: *[], imgTags: *}|{isMissing: boolean, imgTags: *[]}|{isMissing: boolean, imgTags: *}}\n */\nexport function checkMissingAlt(htmlString) {\n const imgTags = htmlString.match(/<img[^>]*>/g);\n\n if (!imgTags) {\n return {isMissing: false, imgTags: []};\n }\n\n const missingAltTags = [];\n\n imgTags.forEach(imgTag => {\n if (!/alt\\s*=\\s*[\"'][^\"']*[\"']/.test(imgTag) || /alt\\s*=\\s*[\"'][\"']/.test(imgTag)) {\n missingAltTags.push(imgTag);\n }\n });\n\n if (missingAltTags.length === 0) {\n return {isMissing: false, imgTags};\n } else {\n return {isMissing: true, imgTags, missingAltTags};\n }\n}\n"],"mappings":"AAAA,SAAQA,gBAAgB;AACxB,SAAQC,+BAA+B;AACvC,SAAQC,OAAO,IAAIC,YAAY;AAC/B,SAAQC,8BAA8B;AACtC,SAAQC,sBAAsB;AAC9B,SAAQH,OAAO,IAAII,uBAAuB;AAC1C,SAAQJ,OAAO,IAAIK,uBAAuB;AAE1C,OAAO,KAAKC,YAAY;AAExB,SAAQA,YAAY;AAEpB,OAAO,SAASC,UAAUA,CAACC,GAAG,EAAE;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AM,CAACC,IAAI,IAAIA,IAAI,CAAC3B,MAAM,GAAG,CAAC,CAAC,CAACA,MAAM;EAElF,MAAM6C,OAAO,GAAIJ,YAAY,GAAGG,UAAU,GAAI,GAAG;EAEjD,OAAO;IACLH,YAAY,EAAEA,YAAY;IAC1BG,UAAU,EAAEA,UAAU;IACtBC,OAAO,EAAEA,OAAO,CAACC,OAAO,CAAC,CAAC;EAC5B,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACrC,UAAU,EAAE;EAC1C,MAAMsC,OAAO,GAAGtC,UAAU,CAACgC,KAAK,CAAC,aAAa,CAAC;EAE/C,IAAI,CAACM,OAAO,EAAE;IACZ,OAAO;MAACC,SAAS,EAAE,KAAK;MAAED,OAAO,EAAE;IAAE,CAAC;EACxC;EAEA,MAAME,cAAc,GAAG,EAAE;EAEzBF,OAAO,CAACG,OAAO,CAACC,MAAM,IAAI;IACxB,IAAI,CAAC,0BAA0B,CAACC,IAAI,CAACD,MAAM,CAAC,IAAI,oBAAoB,CAACC,IAAI,CAACD,MAAM,CAAC,EAAE;MACjFF,cAAc,CAACI,IAAI,CAACF,MAAM,CAAC;IAC7B;EACF,CAAC,CAAC;EAEF,IAAIF,cAAc,CAAClD,MAAM,KAAK,CAAC,EAAE;IAC/B,OAAO;MAACiD,SAAS,EAAE,KAAK;MAAED;IAAO,CAAC;EACpC,CAAC,MAAM;IACL,OAAO;MAACC,SAAS,EAAE,IAAI;MAAED,OAAO;MAAEE;IAAc,CAAC;EACnD;AACF","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["measureTextWidth","getLanguagesWithWordFormSupport","default","formatNumber","getLanguagesWithWordComplexity","createAnchorOpeningTag","getWordComplexityHelper","getWordComplexityConfig","htmlEntities","countWords","str","wordsArray","trim","split","length","isIncludes","firstStr","secondStr","keywordParts","every","part","toLowerCase","includes","containsKeywordInSubheadings","htmlString","keyword","parser","DOMParser","doc","parseFromString","subheadings","querySelectorAll","i","innerText","countWordInHtml","getCharCount","textOnly","replace","words","validWords","filter","word","wordCount","cleanedString","charCount","calculateKeywordDensity","spacedHtml","tempElement","document","createElement","innerHTML","textContent","cleanedText","lowerCaseKeyword","escapedKeyword","keywordCount","match","RegExp","totalWords","density","toFixed","checkMissingAlt","imgTags","isMissing","missingAltTags","forEach","imgTag","test","push","cleanHTML","unwantedTagsRegex","cleanedHTML","classAttributeRegex","hiddenSpanRegex"],"sources":["../../src/helpers/index.js"],"sourcesContent":["export {measureTextWidth} from './createMeasurementElement';\nexport {getLanguagesWithWordFormSupport} from './getLanguagesWithWordFormSupport';\nexport {default as formatNumber} from './formatNumber';\nexport {getLanguagesWithWordComplexity} from './getLanguagesWithWordComplexity';\nexport {createAnchorOpeningTag} from './shortlinker';\nexport {default as getWordComplexityHelper} from './getWordComplexityHelper';\nexport {default as getWordComplexityConfig} from './getWordComplexityConfig';\n\nimport * as htmlEntities from './htmlEntities';\n\nexport {htmlEntities};\n\nexport function countWords(str) {\n const wordsArray = str.trim().split(/\\s+/);\n\n return wordsArray.length;\n}\n\n/**\n * To find the first string in the second string\n * @param firstStr\n * @param secondStr\n * @returns {*}\n */\nexport const isIncludes = (firstStr, secondStr) => {\n const keywordParts = firstStr.split(' ');\n return keywordParts.every(part => secondStr.toLowerCase().includes(part));\n};\n\n/**\n * Helper function to check if the HTML string contains the keyword in subheadings.\n * @param {string} htmlString - The HTML string.\n * @param {string} keyword - The keyword.\n * @returns {boolean} True if the HTML string contains the keyword in subheadings, false otherwise.\n */\nexport function containsKeywordInSubheadings(htmlString, keyword) {\n const parser = new DOMParser();\n const doc = parser.parseFromString(htmlString, 'text/html');\n\n const subheadings = doc.querySelectorAll('h2, h3, h4, h5, h6');\n\n for (let i = 0; i < subheadings.length; i++) {\n if (subheadings[i].innerText.toLowerCase().includes(keyword)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n *\n * @param htmlString\n * @param getCharCount\n * @returns {*|{charCount: *, wordCount: *}}\n */\nexport function countWordInHtml(htmlString, getCharCount = false) {\n const textOnly = htmlString.replace(/<[^>]*>/g, ' ');\n const words = textOnly.trim().split(/[\\p{L}\\p{N}]+(?:-[\\p{L}\\p{N}]+)*/gu);\n const validWords = words.filter(word => word.length > 0);\n const wordCount = validWords.length;\n if (!getCharCount) {\n return wordCount;\n }\n const cleanedString = textOnly.replace(/\\s/g, '');\n const charCount = cleanedString.length;\n return {wordCount, charCount};\n}\n\n/**\n *\n * @param htmlString\n * @param keyword\n * @returns {{keywordCount: number, totalWords: number, density: string}}\n */\nexport function calculateKeywordDensity(htmlString, keyword) {\n const spacedHtml = htmlString.replace(/(<[^>]+>)/g, ' $1 ');\n const tempElement = document.createElement('div');\n tempElement.innerHTML = spacedHtml;\n const textContent = tempElement.textContent || tempElement.innerText || '';\n const cleanedText = textContent\n .trim()\n .replace(/\\s+/g, ' ')\n .toLowerCase();\n\n const lowerCaseKeyword = keyword.toLowerCase();\n\n const escapedKeyword = lowerCaseKeyword.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n const keywordCount = (cleanedText.match(new RegExp(escapedKeyword, 'g')) || []).length;\n\n const totalWords = cleanedText.split(/\\s+/).filter(word => word.length > 0).length;\n\n const density = (keywordCount / totalWords) * 100;\n\n return {\n keywordCount: keywordCount,\n totalWords: totalWords,\n density: density.toFixed(2)\n };\n}\n\n/**\n *\n * @param htmlString\n * @returns {{isMissing: boolean, missingAltTags: *[], imgTags: *}|{isMissing: boolean, imgTags: *[]}|{isMissing: boolean, imgTags: *}}\n */\nexport function checkMissingAlt(htmlString) {\n const imgTags = htmlString.match(/<img[^>]*>/g);\n\n if (!imgTags) {\n return {isMissing: false, imgTags: []};\n }\n\n const missingAltTags = [];\n\n imgTags.forEach(imgTag => {\n if (!/alt\\s*=\\s*[\"'][^\"']*[\"']/.test(imgTag) || /alt\\s*=\\s*[\"'][\"']/.test(imgTag)) {\n missingAltTags.push(imgTag);\n }\n });\n\n if (missingAltTags.length === 0) {\n return {isMissing: false, imgTags};\n } else {\n return {isMissing: true, imgTags, missingAltTags};\n }\n}\n\n/**\n *\n * @param htmlString\n * @returns {*}\n */\nexport function cleanHTML(htmlString) {\n const unwantedTagsRegex = /<(script|style)\\b[^<]*(?:(?!<\\/\\1>)<[^<]*)*<\\/\\1>|<link\\b[^>]*rel=[\"']?stylesheet[\"']?[^>]*>/gi;\n\n let cleanedHTML = htmlString.replace(unwantedTagsRegex, '');\n\n const classAttributeRegex = /\\sclass=[\"'][^\"']*[\"']/gi;\n\n cleanedHTML = cleanedHTML.replace(classAttributeRegex, '');\n\n const hiddenSpanRegex = /<span\\b[^>]*\\bhidden\\b[^>]*>.*?<\\/span>/gi;\n\n cleanedHTML = cleanedHTML.replace(hiddenSpanRegex, '');\n\n return cleanedHTML;\n}\n"],"mappings":"AAAA,SAAQA,gBAAgB;AACxB,SAAQC,+BAA+B;AACvC,SAAQC,OAAO,IAAIC,YAAY;AAC/B,SAAQC,8BAA8B;AACtC,SAAQC,sBAAsB;AAC9B,SAAQH,OAAO,IAAII,uBAAuB;AAC1C,SAAQJ,OAAO,IAAIK,uBAAuB;AAE1C,OAAO,KAAKC,YAAY;AAExB,SAAQA,YAAY;AAEpB,OAAO,SAASC,UAAUA,CAACC,GAAG,EAAE;EAC9B,MAAMC,UAAU,GAAGD,GAAG,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,KAAK,CAAC;EAE1C,OAAOF,UAAU,CAACG,MAAM;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAGA,CAACC,QAAQ,EAAEC,SAAS,KAAK;EACjD,MAAMC,YAAY,GAAGF,QAAQ,CAACH,KAAK,CAAC,GAAG,CAAC;EACxC,OAAOK,YAAY,CAACC,KAAK,CAACC,IAAI,IAAIH,SAAS,CAACI,WAAW,CAAC,CAAC,CAACC,QAAQ,CAACF,IAAI,CAAC,CAAC;AAC3E,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,O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,SAAS,EAAE,KAAK;MAAED,OAAO,EAAE;IAAE,CAAC;EACxC;EAEA,MAAME,cAAc,GAAG,EAAE;EAEzBF,OAAO,CAACG,OAAO,CAACC,MAAM,IAAI;IACxB,IAAI,CAAC,0BAA0B,CAACC,IAAI,CAACD,MAAM,CAAC,IAAI,oBAAoB,CAACC,IAAI,CAACD,MAAM,CAAC,EAAE;MACjFF,cAAc,CAACI,IAAI,CAACF,MAAM,CAAC;IAC7B;EACF,CAAC,CAAC;EAEF,IAAIF,cAAc,CAAClD,MAAM,KAAK,CAAC,EAAE;IAC/B,OAAO;MAACiD,SAAS,EAAE,KAAK;MAAED;IAAO,CAAC;EACpC,CAAC,MAAM;IACL,OAAO;MAACC,SAAS,EAAE,IAAI;MAAED,OAAO;MAAEE;IAAc,CAAC;EACnD;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASK,SAASA,CAAC7C,UAAU,EAAE;EACpC,MAAM8C,iBAAiB,GAAG,gGAAgG;EAE1H,IAAIC,WAAW,GAAG/C,UAAU,CAACa,OAAO,CAACiC,iBAAiB,EAAE,EAAE,CAAC;EAE3D,MAAME,mBAAmB,GAAG,0BAA0B;EAEtDD,WAAW,GAAGA,WAAW,CAAClC,OAAO,CAACmC,mBAAmB,EAAE,EAAE,CAAC;EAE1D,MAAMC,eAAe,GAAG,2CAA2C;EAEnEF,WAAW,GAAGA,WAAW,CAAClC,OAAO,CAACoC,eAAe,EAAE,EAAE,CAAC;EAEtD,OAAOF,WAAW;AACpB","ignoreList":[]}
@@ -63,11 +63,11 @@ export default class TransitionWordsAssessment extends Assessment {
63
63
  * @returns {number} The score.
64
64
  */
65
65
  calculateScoreFromPercentage(percentage) {
66
- if (percentage < 20) {
66
+ if (percentage < 10) {
67
67
  // Red indicator.
68
68
  return 3;
69
69
  }
70
- if (inRange(percentage, 20, 30)) {
70
+ if (inRange(percentage, 10, 20)) {
71
71
  // Orange indicator.
72
72
  return 6;
73
73
  }
@@ -86,10 +86,7 @@ export default class TransitionWordsAssessment extends Assessment {
86
86
  const percentage = this.calculateTransitionWordPercentage(transitionWordSentences);
87
87
  const score = this.calculateScoreFromPercentage(percentage);
88
88
  let status = 'good';
89
- if (score < 7 && percentage === 0) {
90
- status = 'bad';
91
- }
92
- if (score < 7) {
89
+ if (score < 6 || percentage === 0) {
93
90
  status = 'bad';
94
91
  }
95
92
  const customScore = this.getScore(this._config.priority, status);
@@ -1 +1 @@
1
- {"version":3,"file":"TransitionWordsAssessment.js","names":["merge","React","Text","formatNumber","inRangeStartInclusive","inRange","AssessmentResult","Assessment","removeHtmlBlocks","getWords","filterShortcodesFromHTML","TransitionWordsAssessment","constructor","config","defaultConfig","id","fixPosition","ctaType","docUrl","priority","applicableIfTextLongerThan","title","content","good","bad","improve","identifier","_config","calculateTransitionWordPercentage","sentences","transitionWordSentences","totalSentences","calculateScoreFromPercentage","percentage","calculateTransitionWordResult","i18n","score","status","customScore","getScore","body","createElement","as","href","target","rel","translate","getResult","paper","researcher","getResearch","transitionWordResult","assessmentResult","setScore","setStatus","setBody","isApplicable","customCountLength","getHelper","customApplicabilityConfig","getConfig","transitionWords","text","getText","_attributes","shortcodes","textLength","length","hasResearch"],"sources":["../../../../src/scoring/assessments/readability/TransitionWordsAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\n\nimport formatNumber from '../../../helpers/formatNumber';\nimport {inRangeStartInclusive as inRange} from '../../helpers/assessments/inRange';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\nimport removeHtmlBlocks from '@axyseo/languageProcessing/helpers/html/htmlParser';\nimport getWords from '@axyseo/languageProcessing/helpers/word/getWords';\nimport {filterShortcodesFromHTML} from '@axyseo/languageProcessing/helpers';\n\n/**\n * Represents the assessment that checks whether there are enough transition words in the text.\n */\nexport default class TransitionWordsAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {object} config The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'textTransitionWords',\n fixPosition: 'longestParagraph',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#use-of-transition-words',\n priority: 'low',\n applicableIfTextLongerThan: 200,\n title: 'Use of transition words',\n content: {\n good: 'Transition words are used effectively.',\n bad:\n 'Lack of transition words. Improve readability and flow by adding words like \"however,\" \"also,\" etc.',\n improve: ''\n }\n };\n\n this.identifier = 'textTransitionWords';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Calculates the actual percentage of transition words in the sentences.\n *\n * @param {object} sentences The object containing the total number of sentences and the number of sentences containing\n * a transition word.\n *\n * @returns {number} The percentage of sentences containing a transition word.\n */\n calculateTransitionWordPercentage(sentences) {\n if (sentences.transitionWordSentences === 0 || sentences.totalSentences === 0) {\n return 0;\n }\n\n return formatNumber((sentences.transitionWordSentences / sentences.totalSentences) * 100);\n }\n\n /**\n * Calculates the score for the assessment based on the percentage of sentences containing transition words.\n *\n * @param {number} percentage The percentage of sentences containing transition words.\n *\n * @returns {number} The score.\n */\n calculateScoreFromPercentage(percentage) {\n if (percentage < 20) {\n // Red indicator.\n return 3;\n }\n\n if (inRange(percentage, 20, 30)) {\n // Orange indicator.\n return 6;\n }\n\n // Green indicator.\n return 9;\n }\n\n /**\n *\n * @param transitionWordSentences\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateTransitionWordResult(transitionWordSentences, i18n) {\n const percentage = this.calculateTransitionWordPercentage(transitionWordSentences);\n const score = this.calculateScoreFromPercentage(percentage);\n\n let status = 'good';\n if (score < 7 && percentage === 0) {\n status = 'bad';\n }\n\n if (score < 7) {\n status = 'bad';\n }\n const customScore = this.getScore(this._config.priority, status);\n\n return {\n score: customScore,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n {i18n ? i18n.translate(`Axyseo.Button.learnMore`) : 'Learn more'}\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher, i18n}) {\n const transitionWordSentences = researcher.getResearch('findTransitionWords');\n const transitionWordResult = this.calculateTransitionWordResult(transitionWordSentences, i18n);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(transitionWordResult.score);\n assessmentResult.setStatus(transitionWordResult.status);\n assessmentResult.setBody(transitionWordResult.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the transition words assessment is applicable to the paper. Language-specific length requirements and methods of counting text length\n * may apply (e.g. for Japanese, the text should be counted in characters instead of words, which also makes the minimum required length higher).\n *\n * @param {Paper} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} Returns true if the language is available, the paper is not empty and the text is longer than the minimum required length.\n */\n isApplicable(paper, researcher) {\n const customCountLength = researcher.getHelper('customCountLength');\n const customApplicabilityConfig = researcher.getConfig('assessmentApplicability')\n .transitionWords;\n if (customApplicabilityConfig) {\n this._config.applicableIfTextLongerThan = customApplicabilityConfig;\n }\n let text = paper.getText();\n text = removeHtmlBlocks(text);\n text = filterShortcodesFromHTML(text, paper._attributes && paper._attributes.shortcodes);\n const textLength = customCountLength ? customCountLength(text) : getWords(text).length;\n\n // Do not use hasEnoughContent in this assessment as it is mostly redundant with `textLength >= this._config.applicableIfTextLongerThan`\n return (\n textLength >= this._config.applicableIfTextLongerThan &&\n researcher.hasResearch('findTransitionWords')\n );\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,QAAO,kBAAkB;AAErC,OAAOC,YAAY;AACnB,SAAQC,qBAAqB,IAAIC,OAAO;AACxC,OAAOC,gBAAgB;AACvB,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;AACv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,CAAC;MAACO,MAAM,EAAE,IAAI,CAACc;IAAO,CAAC,CAAC;IAErEyB,gBAAgB,CAACC,QAAQ,CAACF,oBAAoB,CAACf,KAAK,CAAC;IACrDgB,gBAAgB,CAACE,SAAS,CAACH,oBAAoB,CAACd,MAAM,CAAC;IACvDe,gBAAgB,CAACG,OAAO,CAACJ,oBAAoB,CAACX,IAAI,CAAC;IAEnD,OAAOY,gBAAgB;EACzB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEI,YAAYA,CAACR,KAAK,EAAEC,UAAU,EAAE;IAC9B,MAAMQ,iBAAiB,GAAGR,UAAU,CAACS,SAAS,CAAC,mBAAmB,CAAC;IACnE,MAAMC,yBAAyB,GAAGV,UAAU,CAACW,SAAS,CAAC,yBAAyB,CAAC,CAC9EC,eAAe;IAClB,IAAIF,yBAAyB,EAAE;MAC7B,IAAI,CAAChC,OAAO,CAACP,0BAA0B,GAAGuC,yBAAyB;IACrE;IACA,IAAIG,IAAI,GAAGd,KAAK,CAACe,OAAO,CAAC,CAAC;IAC1BD,IAAI,GAAGtD,gBAAgB,CAACsD,IAAI,CAAC;IAC7BA,IAAI,GAAGpD,wBAAwB,CAACoD,IAAI,EAAEd,KAAK,CAACgB,WAAW,IAAIhB,KAAK,CAACgB,WAAW,CAACC,UAAU,CAAC;IACxF,MAAMC,UAAU,GAAGT,iBAAiB,GAAGA,iBAAiB,CAACK,IAAI,CAAC,GAAGrD,QAAQ,CAACqD,IAAI,CAAC,CAACK,MAAM;;IAEtF;IACA,OACED,UAAU,IAAI,IAAI,CAACvC,OAAO,CAACP,0BAA0B,IACrD6B,UAAU,CAACmB,WAAW,CAAC,qBAAqB,CAAC;EAEjD;AACF","ignoreList":[]}
1
+ {"version":3,"file":"TransitionWordsAssessment.js","names":["merge","React","Text","formatNumber","inRangeStartInclusive","inRange","AssessmentResult","Assessment","removeHtmlBlocks","getWords","filterShortcodesFromHTML","TransitionWordsAssessment","constructor","config","defaultConfig","id","fixPosition","ctaType","docUrl","priority","applicableIfTextLongerThan","title","content","good","bad","improve","identifier","_config","calculateTransitionWordPercentage","sentences","transitionWordSentences","totalSentences","calculateScoreFromPercentage","percentage","calculateTransitionWordResult","i18n","score","status","customScore","getScore","body","createElement","as","href","target","rel","translate","getResult","paper","researcher","getResearch","transitionWordResult","assessmentResult","setScore","setStatus","setBody","isApplicable","customCountLength","getHelper","customApplicabilityConfig","getConfig","transitionWords","text","getText","_attributes","shortcodes","textLength","length","hasResearch"],"sources":["../../../../src/scoring/assessments/readability/TransitionWordsAssessment.js"],"sourcesContent":["import {merge} from 'lodash';\nimport React from 'react';\nimport {Text} from '@shopify/polaris';\n\nimport formatNumber from '../../../helpers/formatNumber';\nimport {inRangeStartInclusive as inRange} from '../../helpers/assessments/inRange';\nimport AssessmentResult from '../../../values/AssessmentResult';\nimport Assessment from '../assessment';\nimport removeHtmlBlocks from '@axyseo/languageProcessing/helpers/html/htmlParser';\nimport getWords from '@axyseo/languageProcessing/helpers/word/getWords';\nimport {filterShortcodesFromHTML} from '@axyseo/languageProcessing/helpers';\n\n/**\n * Represents the assessment that checks whether there are enough transition words in the text.\n */\nexport default class TransitionWordsAssessment extends Assessment {\n /**\n * Sets the identifier and the config.\n *\n * @param {object} config The configuration to use.\n *\n * @returns {void}\n */\n constructor(config = {}) {\n super();\n\n const defaultConfig = {\n id: 'textTransitionWords',\n fixPosition: 'longestParagraph',\n ctaType: 'fix',\n docUrl:\n 'https://docs.avada.io/seo-suite-help-center/seo-audit/on-page-seo/checklist#use-of-transition-words',\n priority: 'low',\n applicableIfTextLongerThan: 200,\n title: 'Use of transition words',\n content: {\n good: 'Transition words are used effectively.',\n bad:\n 'Lack of transition words. Improve readability and flow by adding words like \"however,\" \"also,\" etc.',\n improve: ''\n }\n };\n\n this.identifier = 'textTransitionWords';\n this._config = merge(defaultConfig, config);\n }\n\n /**\n * Calculates the actual percentage of transition words in the sentences.\n *\n * @param {object} sentences The object containing the total number of sentences and the number of sentences containing\n * a transition word.\n *\n * @returns {number} The percentage of sentences containing a transition word.\n */\n calculateTransitionWordPercentage(sentences) {\n if (sentences.transitionWordSentences === 0 || sentences.totalSentences === 0) {\n return 0;\n }\n\n return formatNumber((sentences.transitionWordSentences / sentences.totalSentences) * 100);\n }\n\n /**\n * Calculates the score for the assessment based on the percentage of sentences containing transition words.\n *\n * @param {number} percentage The percentage of sentences containing transition words.\n *\n * @returns {number} The score.\n */\n calculateScoreFromPercentage(percentage) {\n if (percentage < 10) {\n // Red indicator.\n return 3;\n }\n\n if (inRange(percentage, 10, 20)) {\n // Orange indicator.\n return 6;\n }\n\n // Green indicator.\n return 9;\n }\n\n /**\n *\n * @param transitionWordSentences\n * @param i18n\n * @returns {{score: number, body: React.JSX.Element, status: string}}\n */\n calculateTransitionWordResult(transitionWordSentences, i18n) {\n const percentage = this.calculateTransitionWordPercentage(transitionWordSentences);\n const score = this.calculateScoreFromPercentage(percentage);\n\n let status = 'good';\n if (score < 6 || percentage === 0) {\n status = 'bad';\n }\n\n const customScore = this.getScore(this._config.priority, status);\n\n return {\n score: customScore,\n status,\n body: (\n <Text as={'span'}>\n {this._config.content[status]}{' '}\n {this._config.docUrl && (\n <a href={this._config.docUrl} target=\"_blank\" rel=\"noreferrer\">\n {i18n ? i18n.translate(`Axyseo.Button.learnMore`) : 'Learn more'}\n </a>\n )}\n </Text>\n )\n };\n }\n\n /**\n *\n * @param paper\n * @param researcher\n * @param i18n\n * @returns {AssessmentResult}\n */\n getResult({paper, researcher, i18n}) {\n const transitionWordSentences = researcher.getResearch('findTransitionWords');\n const transitionWordResult = this.calculateTransitionWordResult(transitionWordSentences, i18n);\n const assessmentResult = new AssessmentResult({config: this._config});\n\n assessmentResult.setScore(transitionWordResult.score);\n assessmentResult.setStatus(transitionWordResult.status);\n assessmentResult.setBody(transitionWordResult.body);\n\n return assessmentResult;\n }\n\n /**\n * Checks if the transition words assessment is applicable to the paper. Language-specific length requirements and methods of counting text length\n * may apply (e.g. for Japanese, the text should be counted in characters instead of words, which also makes the minimum required length higher).\n *\n * @param {Paper} paper The paper to check.\n * @param {Researcher} researcher The researcher object.\n *\n * @returns {boolean} Returns true if the language is available, the paper is not empty and the text is longer than the minimum required length.\n */\n isApplicable(paper, researcher) {\n const customCountLength = researcher.getHelper('customCountLength');\n const customApplicabilityConfig = researcher.getConfig('assessmentApplicability')\n .transitionWords;\n if (customApplicabilityConfig) {\n this._config.applicableIfTextLongerThan = customApplicabilityConfig;\n }\n let text = paper.getText();\n text = removeHtmlBlocks(text);\n text = filterShortcodesFromHTML(text, paper._attributes && paper._attributes.shortcodes);\n const textLength = customCountLength ? customCountLength(text) : getWords(text).length;\n\n // Do not use hasEnoughContent in this assessment as it is mostly redundant with `textLength >= this._config.applicableIfTextLongerThan`\n return (\n textLength >= this._config.applicableIfTextLongerThan &&\n researcher.hasResearch('findTransitionWords')\n );\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAK,QAAO,QAAQ;AAC5B,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAQC,IAAI,QAAO,kBAAkB;AAErC,OAAOC,YAAY;AACnB,SAAQC,qBAAqB,IAAIC,OAAO;AACxC,OAAOC,gBAAgB;AACvB,OAAOC,UAAU;AACjB,OAAOC,gBAAgB;AACvB,OAAOC,QAAQ;AACf,SAAQC,wBAAwB;;AAEhC;AACA;AACA;AACA,eAAe,MAAMC,yBAAyB,SAASJ,UAAU,CAAC;EAChE;AACF;AACA;AACA;AACA;AACA;AACA;EACEK,WAAWA,CAACC,MAAM,GAAG,CAAC,CAAC,EAAE;IACvB,KAAK,CAAC,CAAC;IAEP,MAAMC,aAAa,GAAG;MACpBC,EAAE,EAAE,qBAAqB;MACzBC,WAAW,EAAE,kBAAkB;MAC/BC,OAAO,EAAE,KAAK;MACdC,MAAM,EACJ,qGAAqG;MACvGC,QAAQ,EAAE,KAAK;MACfC,0BAA0B,EAAE,GAAG;MAC/BC,KAAK,EAAE,yBAAyB;MAChCC,OAAO,EAAE;QACPC,IAAI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AIF,yBAAyB,EAAE;MAC7B,IAAI,CAAChC,OAAO,CAACP,0BAA0B,GAAGuC,yBAAyB;IACrE;IACA,IAAIG,IAAI,GAAGd,KAAK,CAACe,OAAO,CAAC,CAAC;IAC1BD,IAAI,GAAGtD,gBAAgB,CAACsD,IAAI,CAAC;IAC7BA,IAAI,GAAGpD,wBAAwB,CAACoD,IAAI,EAAEd,KAAK,CAACgB,WAAW,IAAIhB,KAAK,CAACgB,WAAW,CAACC,UAAU,CAAC;IACxF,MAAMC,UAAU,GAAGT,iBAAiB,GAAGA,iBAAiB,CAACK,IAAI,CAAC,GAAGrD,QAAQ,CAACqD,IAAI,CAAC,CAACK,MAAM;;IAEtF;IACA,OACED,UAAU,IAAI,IAAI,CAACvC,OAAO,CAACP,0BAA0B,IACrD6B,UAAU,CAACmB,WAAW,CAAC,qBAAqB,CAAC;EAEjD;AACF","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  import { defaults, isEmpty, isEqual, isNil, isNull, isObject } from 'lodash';
2
+ import { cleanHTML } from "../helpers";
2
3
 
3
4
  /**
4
5
  * Default attributes to be used by the Paper if they are left undefined.
@@ -58,7 +59,7 @@ export default class Paper {
58
59
  * @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.
59
60
  */
60
61
  constructor(text, attributes) {
61
- this._text = text || '';
62
+ this._text = cleanHTML(text || '');
62
63
  this._tree = null;
63
64
  attributes = attributes || {};
64
65
  defaults(attributes, defaultAttributes);
@@ -1 +1 @@
1
- {"version":3,"file":"Paper.js","names":["defaults","isEmpty","isEqual","isNil","isNull","isObject","defaultAttributes","keyword","synonyms","description","title","titleWidth","titleCount","h1Count","slug","domain","locale","permalink","date","customData","textTitle","writingDirection","wpBlocks","isFrontPage","Paper","constructor","text","attributes","_text","_tree","hasOwnProperty","url","onlyLetters","replace","_attributes","hasKeyword","getKeyword","getAttributes","hasSynonyms","getSynonyms","hasH1Count","getH1Count","hasTitleCount","getTitleCount","hasText","getText","getDomain","setTree","tree","getTree","hasDescription","getDescription","hasTitle","getTitle","hasTitleWidth","getTitleWidth","hasSlug","hasShopSettings","shopSettings","getSlug","hasProductSchema","hasData","data","hasRelatedKeywords","relatedKeywords","related_keywords","Array","isArray","length","getData","getIgnoredAssessments","ignoredAssessments","getSkippedAssessments","skippedAssessments","getShopSettings","hasUrl","console","warn","getUrl","hasLocale","getLocale","getWritingDirection","hasPermalink","getPermalink","hasDate","getDate","hasCustomData","getCustomData","hasTextTitle","getTextTitle","serialize","_parseClass","equals","paper","parse","serialized"],"sources":["../../src/values/Paper.js"],"sourcesContent":["import {defaults, isEmpty, isEqual, isNil, isNull, isObject} from 'lodash';\n\n/**\n * Default attributes to be used by the Paper if they are left undefined.\n * @type {{keyword: string, synonyms: string, description: string, title: string, titleWidth: number,\n * \t\t slug: string, locale: string, permalink: string, date: string, customData: object, textTitle: string,\n * \t\t writingDirection: \"LTR\", isFrontPage: boolean }}\n */\nconst defaultAttributes = {\n keyword: '',\n synonyms: '',\n description: '',\n title: '',\n titleWidth: 0,\n titleCount: null,\n h1Count: null,\n slug: '',\n domain: '',\n locale: 'en_US',\n permalink: '',\n date: '',\n customData: {},\n textTitle: '',\n writingDirection: 'LTR',\n wpBlocks: [],\n isFrontPage: false\n};\n\n/**\n * Represents an object where the analysis data is stored.\n */\nexport default class Paper {\n /**\n * Constructs the Paper object and sets its attributes.\n *\n * @param {string} text The text to use in the analysis.\n * @param {object} [attributes] The object containing all attributes.\n * @param {string} [attributes.keyword] The main keyword or keyphrase of the text.\n * @param {string} [attributes.synonyms] The synonyms of the main keyword or keyphrase. It should be separated by commas if multiple synonyms are added.\n * @param {string} [attributes.description] The SEO meta description.\n * @param {string} [attributes.title] The SEO title.\n * @param {string} [attributes.domain] The shop domain.\n * @param {number|null} [attributes.titleCount=null] The title tag count value.\n * @param {number|null} [attributes.h1Count=null] The h1 tag count value.\n * @param {number} [attributes.titleWidth=0] The width of the title in pixels.\n * @param {string} [attributes.slug] The slug.\n * @param {string} [attributes.locale=en_US] The locale.\n * @param {string} [attributes.permalink] The full URL for any given post, page, or other pieces of content on a site.\n * @param {string} [attributes.date] The date.\n * @param {Object[]} [attributes.wpBlocks] The array of texts, encoded in WordPress block editor blocks.\n * @param {Object[]} [attributes.ignoredAssessments] The array of texts, show which assessments should be ignored.\n * @param {Object[]} [attributes.skippedAssessments] The array of texts, show which assessments should be skipped (those assessments will have good result).\n * @param {Object} [attributes.data] Given data.\n * @param {Object} [attributes.customData] Custom data.\n * @param {Object} [attributes.shopSettings] Shop's settings.\n * @param {string} [attributes.textTitle] The title of the text.\n * @param {string} [attributes.writingDirection=LTR] The writing direction of the paper. Defaults to left to right (LTR).\n * @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.\n */\n constructor(text, attributes) {\n this._text = text || '';\n\n this._tree = null;\n\n attributes = attributes || {};\n defaults(attributes, defaultAttributes);\n\n if (attributes.locale === '') {\n attributes.locale = defaultAttributes.locale;\n }\n\n if (attributes.hasOwnProperty('url')) {\n attributes.slug = attributes.url || attributes.slug;\n }\n\n const onlyLetters = attributes.keyword.replace(\n /[‘’“”\"'.?!:;,¿¡«»&*@#±^%|~`[\\](){}⟨⟩<>/\\\\–\\-\\u2014\\u00d7\\u002b\\s]/g,\n ''\n );\n\n if (isEmpty(onlyLetters)) {\n attributes.keyword = defaultAttributes.keyword;\n }\n\n this._attributes = attributes;\n }\n\n /**\n * Checks whether a keyword is available.\n * @returns {boolean} Returns true if the Paper has a keyword.\n */\n hasKeyword() {\n return this._attributes.keyword !== '';\n }\n\n /**\n * Returns the associated keyword or an empty string if no keyword is available.\n * @returns {string} Returns Keyword\n */\n getKeyword() {\n return this._attributes.keyword;\n }\n\n /**\n *\n * @returns {*|{keyword?: string, synonyms?: string, description?: string, title?: string, titleCount?: (number|null), h1Count?: (number|null), titleWidth?: number, slug?: string, locale?: string, permalink?: string, date?: string, wpBlocks?: Object[], customData?: Object, textTitle?: string, writingDirection?: string, isFrontPage?: boolean}|{}|{}}\n */\n getAttributes() {\n return this._attributes;\n }\n\n /**\n * Checks whether synonyms are available.\n * @returns {boolean} Returns true if the Paper has synonyms.\n */\n hasSynonyms() {\n return this._attributes.synonyms !== '';\n }\n\n /**\n * Returns the associated synonyms or an empty string if no synonyms is available.\n * @returns {string} Returns synonyms.\n */\n getSynonyms() {\n return this._attributes.synonyms;\n }\n\n /**\n * Checks whether the h1 count value is available.\n * @returns {boolean} Returns true if the paper has a h1 count value.\n */\n hasH1Count() {\n return !isNull(this._attributes.h1Count);\n }\n\n /**\n * Returns the h1 tag count value.\n * @returns {number | null}\n */\n getH1Count() {\n return this._attributes.h1Count;\n }\n\n /**\n * Checks whether the title count value is available.\n * @returns {boolean} Returns true if the paper has a title count.\n */\n hasTitleCount() {\n return !isNull(this._attributes.titleCount);\n }\n\n /**\n * Returns the title count value.\n * @returns {number | null}\n */\n getTitleCount() {\n return this._attributes.titleCount;\n }\n\n /**\n * Checks whether the text is available.\n * @returns {boolean} Returns true if the paper has a text.\n */\n hasText() {\n return this._text !== '';\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getText() {\n return this._text;\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getDomain() {\n return this._attributes.domain;\n }\n\n /**\n * Sets the tree.\n *\n * @param {Node} tree The tree to set.\n *\n * @returns {void}\n */\n setTree(tree) {\n this._tree = tree;\n }\n\n /**\n * Returns the tree.\n *\n * @returns {Node} The tree.\n */\n getTree() {\n return this._tree;\n }\n\n /**\n * Checks whether a description is available.\n * @returns {boolean} Returns true if the paper has a description.\n */\n hasDescription() {\n return this._attributes.description !== '';\n }\n\n /**\n * Returns the description or an empty string if no description is available.\n * @returns {string} Returns the description.\n */\n getDescription() {\n return this._attributes.description;\n }\n\n /**\n * Checks whether an SEO title is available\n * @returns {boolean} Returns true if the Paper has an SEO title.\n */\n hasTitle() {\n return this._attributes.title !== '';\n }\n\n /**\n * Returns the SEO title, or an empty string if no title is available.\n * @returns {string} Returns the SEO title.\n */\n getTitle() {\n return this._attributes.title;\n }\n\n /**\n * Checks whether an SEO title width in pixels is available.\n * @returns {boolean} Returns true if the Paper's SEO title is wider than 0 pixels.\n */\n hasTitleWidth() {\n return this._attributes.titleWidth !== 0;\n }\n\n /**\n * Gets the SEO title width in pixels, or an empty string of no title width in pixels is available.\n * @returns {number} Returns the SEO title width in pixels.\n */\n getTitleWidth() {\n return this._attributes.titleWidth;\n }\n\n /**\n * Checks whether a slug is available.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasSlug() {\n return this._attributes.slug !== '';\n }\n\n /**\n * Checks whether a shop settings is available.\n * @returns {boolean} Returns true if the Paper has a shop settings.\n */\n hasShopSettings() {\n return !isEmpty(this._attributes?.shopSettings || {});\n }\n\n /**\n * Gets the paper's slug, or an empty string if no slug is available.\n * @returns {string} Returns the slug.\n */\n getSlug() {\n return this._attributes.slug;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasProductSchema() {\n return this._attributes?.hasProductSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasData() {\n const data = this._attributes?.data;\n return isObject(data) && !isEmpty(data);\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasRelatedKeywords() {\n const relatedKeywords = this._attributes?.data?.related_keywords || [];\n return Array.isArray(relatedKeywords) && relatedKeywords.length > 0;\n }\n\n /**\n *\n * @returns {Object|{}}\n */\n getData() {\n return this._attributes?.data || {};\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getIgnoredAssessments() {\n return this._attributes?.ignoredAssessments || [];\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getSkippedAssessments() {\n return this._attributes?.skippedAssessments || [];\n }\n\n /**\n *\n * @returns {*|{}}\n */\n getShopSettings() {\n return this._attributes?.shopSettings || {};\n }\n\n /**\n * Checks if currently edited page is a front page.\n * @returns {boolean} Returns true if the current page is a front page.\n */\n isFrontPage() {\n return this._attributes.isFrontPage;\n }\n\n /**\n * Checks whether an url is available\n * @deprecated Since version 1.19.1. Use hasSlug instead.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasUrl() {\n console.warn('This function is deprecated, use hasSlug instead');\n return this.hasSlug();\n }\n\n /**\n * Returns the url, or an empty string if no url is available.\n * @deprecated Since version 1.19.1. Use getSlug instead.\n * @returns {string} Returns the url\n */\n getUrl() {\n console.warn('This function is deprecated, use getSlug instead');\n return this.getSlug();\n }\n\n /**\n * Checks whether a locale is available.\n * @returns {boolean} Returns true if the paper has a locale.\n */\n hasLocale() {\n return this._attributes.locale !== '';\n }\n\n /**\n * Returns the locale or an empty string if no locale is available\n * @returns {string} Returns the locale.\n */\n getLocale() {\n return this._attributes.locale;\n }\n\n /**\n * Gets the information of the writing direction of the paper.\n * It returns \"LTR\" (left to right) if this attribute is not provided.\n *\n * @returns {string} Returns the information of the writing direction of the paper.\n */\n getWritingDirection() {\n return this._attributes.writingDirection;\n }\n\n /**\n * Checks whether a permalink is available.\n * @returns {boolean} Returns true if the Paper has a permalink.\n */\n hasPermalink() {\n return this._attributes.permalink !== '';\n }\n\n /**\n * Returns the permalink, or an empty string if no permalink is available.\n * @returns {string} Returns the permalink.\n */\n getPermalink() {\n return this._attributes.permalink;\n }\n\n /**\n * Checks whether a date is available.\n * @returns {boolean} Returns true if the Paper has a date.\n */\n hasDate() {\n return this._attributes.date !== '';\n }\n\n /**\n * Returns the date, or an empty string if no date is available.\n * @returns {string} Returns the date.\n */\n getDate() {\n return this._attributes.date;\n }\n\n /**\n * Checks whether custom data is available.\n * @returns {boolean} Returns true if the Paper has custom data.\n */\n hasCustomData() {\n return !isEmpty(this._attributes.customData);\n }\n\n /**\n * Returns the custom data, or an empty object if no data is available.\n * @returns {Object} Returns the custom data.\n */\n getCustomData() {\n return this._attributes.customData;\n }\n\n /**\n * Checks whether a text title is available.\n * @returns {boolean} Returns true if the Paper has a text title.\n */\n hasTextTitle() {\n return this._attributes.textTitle !== '' && !isNil(this._attributes.textTitle);\n }\n\n /**\n * Returns the text title, or an empty string if no data is available.\n * @returns {string} Returns the text title.\n */\n getTextTitle() {\n return this._attributes.textTitle;\n }\n\n /**\n * Serializes the Paper instance to an object.\n *\n * @returns {Object} The serialized Paper.\n */\n serialize() {\n return {\n _parseClass: 'Paper',\n text: this._text,\n ...this._attributes\n };\n }\n\n /**\n * Checks whether the given paper has the same properties as this instance.\n *\n * @param {Paper} paper The paper to compare to.\n *\n * @returns {boolean} Whether the given paper is identical or not.\n */\n equals(paper) {\n return this._text === paper.getText() && isEqual(this._attributes, paper._attributes);\n }\n\n /**\n * Parses the object to a Paper.\n *\n * @param {Object|Paper} serialized The serialized object or Paper instance.\n *\n * @returns {Paper} The parsed Paper.\n */\n static parse(serialized) {\n // For ease of use, check if it is not already a Paper instance.\n if (serialized instanceof Paper) {\n return serialized;\n }\n\n // _parseClass is taken here, so it doesn't end up in the attributes.\n // eslint-disable-next-line no-unused-vars\n const {text, _parseClass, ...attributes} = serialized;\n\n return new Paper(text, attributes);\n }\n}\n"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAO,QAAQ;;AAE1E;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG;EACxBC,OAAO,EAAE,EAAE;EACXC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,EAAE;EACfC,KAAK,EAAE,EAAE;EACTC,UAAU,EAAE,CAAC;EACbC,UAAU,EAAE,IAAI;EAChBC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE,EAAE;EACRC,MAAM,EAAE,EAAE;EACVC,MAAM,EAAE,OAAO;EACfC,SAAS,EAAE,EAAE;EACbC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,CAAC,CAAC;EACdC,SAAS,EAAE,EAAE;EACbC,gBAAgB,EAAE,KAAK;EACvBC,QAAQ,E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A;AACA;EACE0D,MAAMA,CAACC,KAAK,EAAE;IACZ,OAAO,IAAI,CAACjE,KAAK,KAAKiE,KAAK,CAAChD,OAAO,CAAC,CAAC,IAAI3C,OAAO,CAAC,IAAI,CAACgC,WAAW,EAAE2D,KAAK,CAAC3D,WAAW,CAAC;EACvF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACE,OAAO4D,KAAKA,CAACC,UAAU,EAAE;IACvB;IACA,IAAIA,UAAU,YAAYvE,KAAK,EAAE;MAC/B,OAAOuE,UAAU;IACnB;;IAEA;IACA;IACA,MAAM;MAACrE,IAAI;MAAEiE,WAAW;MAAE,GAAGhE;IAAU,CAAC,GAAGoE,UAAU;IAErD,OAAO,IAAIvE,KAAK,CAACE,IAAI,EAAEC,UAAU,CAAC;EACpC;AACF","ignoreList":[]}
1
+ {"version":3,"file":"Paper.js","names":["defaults","isEmpty","isEqual","isNil","isNull","isObject","cleanHTML","defaultAttributes","keyword","synonyms","description","title","titleWidth","titleCount","h1Count","slug","domain","locale","permalink","date","customData","textTitle","writingDirection","wpBlocks","isFrontPage","Paper","constructor","text","attributes","_text","_tree","hasOwnProperty","url","onlyLetters","replace","_attributes","hasKeyword","getKeyword","getAttributes","hasSynonyms","getSynonyms","hasH1Count","getH1Count","hasTitleCount","getTitleCount","hasText","getText","getDomain","setTree","tree","getTree","hasDescription","getDescription","hasTitle","getTitle","hasTitleWidth","getTitleWidth","hasSlug","hasShopSettings","shopSettings","getSlug","hasProductSchema","hasData","data","hasRelatedKeywords","relatedKeywords","related_keywords","Array","isArray","length","getData","getIgnoredAssessments","ignoredAssessments","getSkippedAssessments","skippedAssessments","getShopSettings","hasUrl","console","warn","getUrl","hasLocale","getLocale","getWritingDirection","hasPermalink","getPermalink","hasDate","getDate","hasCustomData","getCustomData","hasTextTitle","getTextTitle","serialize","_parseClass","equals","paper","parse","serialized"],"sources":["../../src/values/Paper.js"],"sourcesContent":["import {defaults, isEmpty, isEqual, isNil, isNull, isObject} from 'lodash';\nimport {cleanHTML} from '@axyseo/helpers';\n\n/**\n * Default attributes to be used by the Paper if they are left undefined.\n * @type {{keyword: string, synonyms: string, description: string, title: string, titleWidth: number,\n * \t\t slug: string, locale: string, permalink: string, date: string, customData: object, textTitle: string,\n * \t\t writingDirection: \"LTR\", isFrontPage: boolean }}\n */\nconst defaultAttributes = {\n keyword: '',\n synonyms: '',\n description: '',\n title: '',\n titleWidth: 0,\n titleCount: null,\n h1Count: null,\n slug: '',\n domain: '',\n locale: 'en_US',\n permalink: '',\n date: '',\n customData: {},\n textTitle: '',\n writingDirection: 'LTR',\n wpBlocks: [],\n isFrontPage: false\n};\n\n/**\n * Represents an object where the analysis data is stored.\n */\nexport default class Paper {\n /**\n * Constructs the Paper object and sets its attributes.\n *\n * @param {string} text The text to use in the analysis.\n * @param {object} [attributes] The object containing all attributes.\n * @param {string} [attributes.keyword] The main keyword or keyphrase of the text.\n * @param {string} [attributes.synonyms] The synonyms of the main keyword or keyphrase. It should be separated by commas if multiple synonyms are added.\n * @param {string} [attributes.description] The SEO meta description.\n * @param {string} [attributes.title] The SEO title.\n * @param {string} [attributes.domain] The shop domain.\n * @param {number|null} [attributes.titleCount=null] The title tag count value.\n * @param {number|null} [attributes.h1Count=null] The h1 tag count value.\n * @param {number} [attributes.titleWidth=0] The width of the title in pixels.\n * @param {string} [attributes.slug] The slug.\n * @param {string} [attributes.locale=en_US] The locale.\n * @param {string} [attributes.permalink] The full URL for any given post, page, or other pieces of content on a site.\n * @param {string} [attributes.date] The date.\n * @param {Object[]} [attributes.wpBlocks] The array of texts, encoded in WordPress block editor blocks.\n * @param {Object[]} [attributes.ignoredAssessments] The array of texts, show which assessments should be ignored.\n * @param {Object[]} [attributes.skippedAssessments] The array of texts, show which assessments should be skipped (those assessments will have good result).\n * @param {Object} [attributes.data] Given data.\n * @param {Object} [attributes.customData] Custom data.\n * @param {Object} [attributes.shopSettings] Shop's settings.\n * @param {string} [attributes.textTitle] The title of the text.\n * @param {string} [attributes.writingDirection=LTR] The writing direction of the paper. Defaults to left to right (LTR).\n * @param {boolean} [attributes.isFrontPage=false] Whether the current page is the front page of the site. Defaults to false.\n */\n constructor(text, attributes) {\n this._text = cleanHTML(text || '');\n\n this._tree = null;\n\n attributes = attributes || {};\n defaults(attributes, defaultAttributes);\n\n if (attributes.locale === '') {\n attributes.locale = defaultAttributes.locale;\n }\n\n if (attributes.hasOwnProperty('url')) {\n attributes.slug = attributes.url || attributes.slug;\n }\n\n const onlyLetters = attributes.keyword.replace(\n /[‘’“”\"'.?!:;,¿¡«»&*@#±^%|~`[\\](){}⟨⟩<>/\\\\–\\-\\u2014\\u00d7\\u002b\\s]/g,\n ''\n );\n\n if (isEmpty(onlyLetters)) {\n attributes.keyword = defaultAttributes.keyword;\n }\n\n this._attributes = attributes;\n }\n\n /**\n * Checks whether a keyword is available.\n * @returns {boolean} Returns true if the Paper has a keyword.\n */\n hasKeyword() {\n return this._attributes.keyword !== '';\n }\n\n /**\n * Returns the associated keyword or an empty string if no keyword is available.\n * @returns {string} Returns Keyword\n */\n getKeyword() {\n return this._attributes.keyword;\n }\n\n /**\n *\n * @returns {*|{keyword?: string, synonyms?: string, description?: string, title?: string, titleCount?: (number|null), h1Count?: (number|null), titleWidth?: number, slug?: string, locale?: string, permalink?: string, date?: string, wpBlocks?: Object[], customData?: Object, textTitle?: string, writingDirection?: string, isFrontPage?: boolean}|{}|{}}\n */\n getAttributes() {\n return this._attributes;\n }\n\n /**\n * Checks whether synonyms are available.\n * @returns {boolean} Returns true if the Paper has synonyms.\n */\n hasSynonyms() {\n return this._attributes.synonyms !== '';\n }\n\n /**\n * Returns the associated synonyms or an empty string if no synonyms is available.\n * @returns {string} Returns synonyms.\n */\n getSynonyms() {\n return this._attributes.synonyms;\n }\n\n /**\n * Checks whether the h1 count value is available.\n * @returns {boolean} Returns true if the paper has a h1 count value.\n */\n hasH1Count() {\n return !isNull(this._attributes.h1Count);\n }\n\n /**\n * Returns the h1 tag count value.\n * @returns {number | null}\n */\n getH1Count() {\n return this._attributes.h1Count;\n }\n\n /**\n * Checks whether the title count value is available.\n * @returns {boolean} Returns true if the paper has a title count.\n */\n hasTitleCount() {\n return !isNull(this._attributes.titleCount);\n }\n\n /**\n * Returns the title count value.\n * @returns {number | null}\n */\n getTitleCount() {\n return this._attributes.titleCount;\n }\n\n /**\n * Checks whether the text is available.\n * @returns {boolean} Returns true if the paper has a text.\n */\n hasText() {\n return this._text !== '';\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getText() {\n return this._text;\n }\n\n /**\n * Returns the associated text or an empty string if no text is available.\n * @returns {string} Returns the text.\n */\n getDomain() {\n return this._attributes.domain;\n }\n\n /**\n * Sets the tree.\n *\n * @param {Node} tree The tree to set.\n *\n * @returns {void}\n */\n setTree(tree) {\n this._tree = tree;\n }\n\n /**\n * Returns the tree.\n *\n * @returns {Node} The tree.\n */\n getTree() {\n return this._tree;\n }\n\n /**\n * Checks whether a description is available.\n * @returns {boolean} Returns true if the paper has a description.\n */\n hasDescription() {\n return this._attributes.description !== '';\n }\n\n /**\n * Returns the description or an empty string if no description is available.\n * @returns {string} Returns the description.\n */\n getDescription() {\n return this._attributes.description;\n }\n\n /**\n * Checks whether an SEO title is available\n * @returns {boolean} Returns true if the Paper has an SEO title.\n */\n hasTitle() {\n return this._attributes.title !== '';\n }\n\n /**\n * Returns the SEO title, or an empty string if no title is available.\n * @returns {string} Returns the SEO title.\n */\n getTitle() {\n return this._attributes.title;\n }\n\n /**\n * Checks whether an SEO title width in pixels is available.\n * @returns {boolean} Returns true if the Paper's SEO title is wider than 0 pixels.\n */\n hasTitleWidth() {\n return this._attributes.titleWidth !== 0;\n }\n\n /**\n * Gets the SEO title width in pixels, or an empty string of no title width in pixels is available.\n * @returns {number} Returns the SEO title width in pixels.\n */\n getTitleWidth() {\n return this._attributes.titleWidth;\n }\n\n /**\n * Checks whether a slug is available.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasSlug() {\n return this._attributes.slug !== '';\n }\n\n /**\n * Checks whether a shop settings is available.\n * @returns {boolean} Returns true if the Paper has a shop settings.\n */\n hasShopSettings() {\n return !isEmpty(this._attributes?.shopSettings || {});\n }\n\n /**\n * Gets the paper's slug, or an empty string if no slug is available.\n * @returns {string} Returns the slug.\n */\n getSlug() {\n return this._attributes.slug;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasProductSchema() {\n return this._attributes?.hasProductSchema || false;\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasData() {\n const data = this._attributes?.data;\n return isObject(data) && !isEmpty(data);\n }\n\n /**\n *\n * @returns {(function(): *)|boolean}\n */\n hasRelatedKeywords() {\n const relatedKeywords = this._attributes?.data?.related_keywords || [];\n return Array.isArray(relatedKeywords) && relatedKeywords.length > 0;\n }\n\n /**\n *\n * @returns {Object|{}}\n */\n getData() {\n return this._attributes?.data || {};\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getIgnoredAssessments() {\n return this._attributes?.ignoredAssessments || [];\n }\n\n /**\n *\n * @returns {Object[String]|*[String]}\n */\n getSkippedAssessments() {\n return this._attributes?.skippedAssessments || [];\n }\n\n /**\n *\n * @returns {*|{}}\n */\n getShopSettings() {\n return this._attributes?.shopSettings || {};\n }\n\n /**\n * Checks if currently edited page is a front page.\n * @returns {boolean} Returns true if the current page is a front page.\n */\n isFrontPage() {\n return this._attributes.isFrontPage;\n }\n\n /**\n * Checks whether an url is available\n * @deprecated Since version 1.19.1. Use hasSlug instead.\n * @returns {boolean} Returns true if the Paper has a slug.\n */\n hasUrl() {\n console.warn('This function is deprecated, use hasSlug instead');\n return this.hasSlug();\n }\n\n /**\n * Returns the url, or an empty string if no url is available.\n * @deprecated Since version 1.19.1. Use getSlug instead.\n * @returns {string} Returns the url\n */\n getUrl() {\n console.warn('This function is deprecated, use getSlug instead');\n return this.getSlug();\n }\n\n /**\n * Checks whether a locale is available.\n * @returns {boolean} Returns true if the paper has a locale.\n */\n hasLocale() {\n return this._attributes.locale !== '';\n }\n\n /**\n * Returns the locale or an empty string if no locale is available\n * @returns {string} Returns the locale.\n */\n getLocale() {\n return this._attributes.locale;\n }\n\n /**\n * Gets the information of the writing direction of the paper.\n * It returns \"LTR\" (left to right) if this attribute is not provided.\n *\n * @returns {string} Returns the information of the writing direction of the paper.\n */\n getWritingDirection() {\n return this._attributes.writingDirection;\n }\n\n /**\n * Checks whether a permalink is available.\n * @returns {boolean} Returns true if the Paper has a permalink.\n */\n hasPermalink() {\n return this._attributes.permalink !== '';\n }\n\n /**\n * Returns the permalink, or an empty string if no permalink is available.\n * @returns {string} Returns the permalink.\n */\n getPermalink() {\n return this._attributes.permalink;\n }\n\n /**\n * Checks whether a date is available.\n * @returns {boolean} Returns true if the Paper has a date.\n */\n hasDate() {\n return this._attributes.date !== '';\n }\n\n /**\n * Returns the date, or an empty string if no date is available.\n * @returns {string} Returns the date.\n */\n getDate() {\n return this._attributes.date;\n }\n\n /**\n * Checks whether custom data is available.\n * @returns {boolean} Returns true if the Paper has custom data.\n */\n hasCustomData() {\n return !isEmpty(this._attributes.customData);\n }\n\n /**\n * Returns the custom data, or an empty object if no data is available.\n * @returns {Object} Returns the custom data.\n */\n getCustomData() {\n return this._attributes.customData;\n }\n\n /**\n * Checks whether a text title is available.\n * @returns {boolean} Returns true if the Paper has a text title.\n */\n hasTextTitle() {\n return this._attributes.textTitle !== '' && !isNil(this._attributes.textTitle);\n }\n\n /**\n * Returns the text title, or an empty string if no data is available.\n * @returns {string} Returns the text title.\n */\n getTextTitle() {\n return this._attributes.textTitle;\n }\n\n /**\n * Serializes the Paper instance to an object.\n *\n * @returns {Object} The serialized Paper.\n */\n serialize() {\n return {\n _parseClass: 'Paper',\n text: this._text,\n ...this._attributes\n };\n }\n\n /**\n * Checks whether the given paper has the same properties as this instance.\n *\n * @param {Paper} paper The paper to compare to.\n *\n * @returns {boolean} Whether the given paper is identical or not.\n */\n equals(paper) {\n return this._text === paper.getText() && isEqual(this._attributes, paper._attributes);\n }\n\n /**\n * Parses the object to a Paper.\n *\n * @param {Object|Paper} serialized The serialized object or Paper instance.\n *\n * @returns {Paper} The parsed Paper.\n */\n static parse(serialized) {\n // For ease of use, check if it is not already a Paper instance.\n if (serialized instanceof Paper) {\n return serialized;\n }\n\n // _parseClass is taken here, so it doesn't end up in the attributes.\n // eslint-disable-next-line no-unused-vars\n const {text, _parseClass, ...attributes} = serialized;\n\n return new Paper(text, attributes);\n }\n}\n"],"mappings":"AAAA,SAAQA,QAAQ,EAAEC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,QAAO,QAAQ;AAC1E,SAAQC,SAAS;;AAEjB;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG;EACxBC,OAAO,EAAE,EAAE;EACXC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE,EAAE;EACfC,KAAK,EAAE,EAAE;EACTC,UAAU,EAAE,CAAC;EACbC,UAAU,EAAE,IAAI;EAChBC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE,EAAE;EACRC,MAAM,EAAE,EAAE;EACVC,MAAM,EAAE,OAAO;EACfC,SAAS,EAAE,EAAE;EACbC,IAAI,EAAE,EAAE;EACRC,UAAU,EAAE,CAAC,CAAC;EACdC,SAAS,EAAE,EAAE;EACbC,gBAAgB,EAAE,KAAK;EACvBC,QAAQ,EAAE,EAAE;EACZC,WAAW,EAAE;AACf,CAAC;;AAED;AACA;AACA;AACA,eAAe,MAAMC,KAAK,CAAC;EACzB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,IAAI,EAAEC,UAAU,EAAE;IAC5B,IAAI,CAACC,KAAK,GAAGvB,SAAS,CAACqB,IAAI,IAAI,EAAE,CAAC;IAElC,IAAI,CAACG,KAAK,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;IAEA;IACA;IACA,MAAM;MAACrE,IAAI;MAAEiE,WAAW;MAAE,GAAGhE;IAAU,CAAC,GAAGoE,UAAU;IAErD,OAAO,IAAIvE,KAAK,CAACE,IAAI,EAAEC,UAAU,CAAC;EACpC;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axyseo",
3
- "version": "2.0.0-alpha.0.0.42",
3
+ "version": "2.0.0-alpha.0.0.44",
4
4
  "main": "build/index.js",
5
5
  "scripts": {
6
6
  "prepublishOnly": "npm run build && npm version prerelease --preid=alpha",