Skip to content

Commit

Permalink
Proposal for Issue facebookarchive#430
Browse files Browse the repository at this point in the history
Sometimes, we do not want MUTABLE entities to be continued when they are on the left of
the cursor, for example when creating a LINK entity that we do not want to continue after
pressing the space key, this proposal adds a "Contiguous" setting set to true by default that
we can set to false to get the desired behavior
  • Loading branch information
iandoe committed Jul 5, 2016
1 parent bda9b78 commit 9ca679f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/model/entity/DraftEntity.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ var DraftEntity = {
create: function(
type: DraftEntityType,
mutability: DraftEntityMutability,
contiguous?: bool,
data?: Object
): string {
return DraftEntity.add(
new DraftEntityInstance({type, mutability, data: data || {}})
new DraftEntityInstance({type, mutability, contiguous: true, data: data || {}})
);
},

Expand Down
4 changes: 4 additions & 0 deletions src/model/entity/DraftEntityInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class DraftEntityInstance extends DraftEntityInstanceRecord {
return this.get('type');
}

getContiguity(): DraftEntityMutability {
return this.get('contiguous');
}

getMutability(): DraftEntityMutability {
return this.get('mutability');
}
Expand Down
2 changes: 1 addition & 1 deletion src/model/entity/getEntityKeyForSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function filterKey(
): ?string {
if (entityKey) {
var entity = DraftEntity.get(entityKey);
return entity.getMutability() === 'MUTABLE' ? entityKey : null;
return (entity.getMutability() === 'MUTABLE' || entity.getContiguity()) ? entityKey : null;
}
return null;
}
Expand Down

0 comments on commit 9ca679f

Please sign in to comment.