Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove force options in Caret.navigateNext() and Caret.navigatePrevious() #1525

Merged
merged 2 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/editor.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

### 2.19.2

- `Fix` - Remove force options in Caret.navigateNext() and Caret.navigatePrevious() [#857](https://github.com/codex-team/editor.js/issues/857#issuecomment-770363438).


### 2.19.1

- `Improvements` - The [Cypress](https://www.cypress.io) was integrated as the end-to-end testing framework
Expand Down
12 changes: 4 additions & 8 deletions src/components/modules/caret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,9 @@ export default class Caret extends Module {
* Before moving caret, we should check if caret position is at the end of Plugins node
* Using {@link Dom#getDeepestNode} to get a last node and match with current selection
*
* @param {boolean} force - force navigation even if caret is not at the end
*
* @returns {boolean}
*/
public navigateNext(force = false): boolean {
public navigateNext(): boolean {
const { BlockManager, Tools } = this.Editor;
const { currentBlock, nextContentfulBlock } = BlockManager;
const { nextInput } = currentBlock;
Expand Down Expand Up @@ -422,7 +420,7 @@ export default class Caret extends Module {
nextBlock = BlockManager.insertAtEnd();
}

if (force || isAtEnd) {
if (isAtEnd) {
/** If next Tool`s input exists, focus on it. Otherwise set caret to the next Block */
if (!nextInput) {
this.setToBlock(nextBlock, this.positions.START);
Expand All @@ -441,11 +439,9 @@ export default class Caret extends Module {
* Before moving caret, we should check if caret position is start of the Plugins node
* Using {@link Dom#getDeepestNode} to get a last node and match with current selection
*
* @param {boolean} force - force navigation even if caret is not at the start
*
* @returns {boolean}
*/
public navigatePrevious(force = false): boolean {
public navigatePrevious(): boolean {
const { currentBlock, previousContentfulBlock } = this.Editor.BlockManager;

if (!currentBlock) {
Expand All @@ -458,7 +454,7 @@ export default class Caret extends Module {
return false;
}

if (force || this.isAtStart) {
if (this.isAtStart) {
/** If previous Tool`s input exists, focus on it. Otherwise set caret to the previous Block */
if (!previousInput) {
this.setToBlock(previousContentfulBlock, this.positions.END);
Expand Down