Skip to content

Commit

Permalink
feat: ignore outdent command if any of the selected nodes have path 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahad-patel committed Sep 30, 2024
1 parent 1348546 commit ef475ef
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ bool isOutdentable(EditorState editorState) {
return false;
}

if (nodes.any((node) => node.path.length == 1)) {
// if the any nodes is having a path which is of size 1.
// for example [0], then that means, it is not indented
// thus we ignore this event.
return false;
}

// keep only immediate children nodes of parent
// since we are keeping only immediate children nodes, all nodes will be on same level
nodes = nodes
Expand All @@ -42,14 +49,6 @@ bool isOutdentable(EditorState editorState) {
return false;
}

if (nodes.first.path.length == 1) {
// if the first node is having a path which is of size 1.
// since all nodes are in same level, thus we can check first element
// for example [0], then that means, it is not indented
// thus we ignore this event.
return false;
}

return true;
}

Expand Down

0 comments on commit ef475ef

Please sign in to comment.