Skip to content

Commit

Permalink
Removes enters and tabs from the to be analyzed HTML content
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkuu committed Dec 8, 2023
1 parent 58c1e6e commit 4d69f2c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/js/src/watchers/elementorWatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ function getContent( editorDocument ) {
const content = [];

editorDocument.$element.find( ".elementor-widget-container" ).each( ( index, element ) => {
content.push( element.innerHTML.trim() );
// We remove \n and \t from the HTML as Elementor formats the HTML after saving.
// As this spacing is purely cosmetic, we can remove it for analysis purposes.
// When we apply the marks, we do need to make the same amendments.
const rawHtml = element.innerHTML.replace( /[\n\t]/g, "" ).trim();
content.push( rawHtml );
} );

return content.join( "" );
Expand Down Expand Up @@ -152,7 +156,7 @@ const debouncedHandleEditorChange = debounce( handleEditorChange, 500 );
* @returns {void}
*/
export default function initialize() {
// This hook will fire 250ms after a widget is edited.
// This hook will fire 500ms after a widget is edited -- this allows Elementor to set the cursor at the end of the widget.
registerElementorUIHookBefore( "panel/editor/open", "yoast-seo-reset-marks-edit", debounce( resetMarks, 500 ) );
// This hook will fire just before the document is saved.
registerElementorUIHookBefore( "document/save/save", "yoast-seo-reset-marks-save", resetMarks );
Expand Down

0 comments on commit 4d69f2c

Please sign in to comment.