Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit c1d79c2

Browse files
committed
feat(withClauses): adds canAddClause query to editor
Signed-off-by: Diana Lease <[email protected]>
1 parent cb61bda commit c1d79c2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/cicero-ui/src/lib/ContractEditor/plugins/withClauses.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ const withClauses = (editor, withClausesProps) => {
143143
return true;
144144
};
145145

146+
editor.canAddClause = () => {
147+
// do not allow adding a clause in nested elements (ie. lists, other clauses)
148+
if (editor.selection) return (editor.selection.anchor.path.length <= 2);
149+
// do allow adding a clause if no selection (can add it to end of doc)
150+
return true;
151+
};
152+
146153
return editor;
147154
};
148155

0 commit comments

Comments
 (0)