Skip to content

Commit

Permalink
fix(api): allow entities to only provide a type attr in Flow types
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaudcolas committed Jan 25, 2019
1 parent fc58294 commit f4c918c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ styles: $ReadOnlyArray<string>,
entities: $ReadOnlyArray<{
// Entity type, eg. "LINK"
type: string,
// Allowed attributes. Other attributes will be removed.
attributes: $ReadOnlyArray<string>,
// Allowed attributes. Other attributes will be removed. If this is omitted, all attributes are kept.
attributes?: $ReadOnlyArray<string>,
// Refine which entities are kept by whitelisting acceptable values with regular expression patterns.
// It's also possible to use "true" to signify that a field is required to be present,
// and "false" for fields required to be absent.
whitelist: {
// If this is omitted, all entities are kept.
whitelist?: {
[attribute: string]: string | boolean,
},
}>,
Expand Down
7 changes: 4 additions & 3 deletions src/lib/filters/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ type FilterOptions = {
entities: $ReadOnlyArray<{
// Entity type, eg. "LINK"
type: string,
// Allowed attributes. Other attributes will be removed.
attributes: $ReadOnlyArray<string>,
// Allowed attributes. Other attributes will be removed. If this is omitted, all attributes are kept.
attributes?: $ReadOnlyArray<string>,
// Refine which entities are kept by whitelisting acceptable values with regular expression patterns.
// It's also possible to use "true" to signify that a field is required to be present,
// and "false" for fields required to be absent.
whitelist: {
// If this is omitted, all entities are kept.
whitelist?: {
[attribute: string]: string | boolean,
},
}>,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/filters/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const shouldRemoveImageEntity = (
export const shouldKeepEntityByAttribute = (
entityTypes: $ReadOnlyArray<{
type: string,
whitelist: {
whitelist?: {
[attribute: string]: string | boolean,
},
}>,
Expand Down Expand Up @@ -179,7 +179,7 @@ export const shouldKeepEntityByAttribute = (
export const filterEntityData = (
entityTypes: $ReadOnlyArray<{
type: string,
attributes: $ReadOnlyArray<string>,
attributes?: $ReadOnlyArray<string>,
}>,
content: ContentState,
) => {
Expand Down

0 comments on commit f4c918c

Please sign in to comment.