Skip to content

Commit

Permalink
use getSelectionStart / getSelectionEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
torounit committed Apr 26, 2023
1 parent 15985ec commit d1219a6
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions test/e2e/specs/editor/various/undo.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,15 @@ class UndoUtils {
return { blockIndex };
}

const range = selection.getRangeAt( 0 );
const cloneStart = range.cloneRange();
const cloneEnd = range.cloneRange();

cloneStart.setStart( document.activeElement, 0 );
cloneEnd.setStart( document.activeElement, 0 );

/**
* Zero width non-breaking space, used as padding in the editable DOM
* tree when it is empty otherwise.
*/
const ZWNBSP = '\ufeff';

return {
blockIndex,
editableIndex,
startOffset: cloneStart.toString().replace( ZWNBSP, '' ).length,
endOffset: cloneEnd.toString().replace( ZWNBSP, '' ).length,
startOffset: window.wp.data
.select( 'core/block-editor' )
.getSelectionStart().offset,
endOffset: window.wp.data
.select( 'core/block-editor' )
.getSelectionEnd().offset,
};
} );
}
Expand Down

0 comments on commit d1219a6

Please sign in to comment.