Skip to content

Commit

Permalink
feat(withClauses): adds canAddClause query to editor
Browse files Browse the repository at this point in the history
Signed-off-by: Diana Lease <[email protected]>
  • Loading branch information
DianaLease committed May 15, 2020
1 parent cb61bda commit c1d79c2
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ const withClauses = (editor, withClausesProps) => {
return true;
};

editor.canAddClause = () => {
// do not allow adding a clause in nested elements (ie. lists, other clauses)
if (editor.selection) return (editor.selection.anchor.path.length <= 2);
// do allow adding a clause if no selection (can add it to end of doc)
return true;
};

return editor;
};

Expand Down

0 comments on commit c1d79c2

Please sign in to comment.